Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support imports from other libraries #55

Open
thlorenz opened this issue Jun 4, 2022 · 4 comments
Open

feat: support imports from other libraries #55

thlorenz opened this issue Jun 4, 2022 · 4 comments
Assignees

Comments

@thlorenz
Copy link
Contributor

thlorenz commented Jun 4, 2022

In order to avoid the below https://github.com/metaplex-foundation/metaplex-program-library/blob/master/candy-machine/program/src/state.rs#L68-L75

// Unfortunate duplication of token metadata so that IDL picks it up.
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug)]
pub struct Creator {
    pub address: Pubkey,
    pub verified: bool,
    // In percentages, NOT basis points ;) Watch out!
    pub share: u8,
}

solita should support specitying where to import a type from that's not part of the rust program , but found in a dependenycy instead.
Thus in the above example, given that token-metadata exports Creators and we have a dep on that SDK if we specify:

module.exports = {
  [..]
  imports: {
    '@metaplex-foundation/token-metadata': [ 'Creator' ]
  }
}

should add the below to all modules which refer to Creator

import { Creator } from '@metaplex-foundation/token-metadata'
@thlorenz thlorenz self-assigned this Jun 4, 2022
@samwise2
Copy link

samwise2 commented Jul 4, 2022

This would be great! Running into this now, with the same struct :)

@thlorenz
Copy link
Contributor Author

thlorenz commented Jul 8, 2022

OK, thanks for letting me know .. will prioritize this.
Do you have a small example that I could use to test this feature while I'm implementing this (since you said you're running into this)?

@samwise2
Copy link

samwise2 commented Jul 8, 2022

At this point I've worked around it, but I was running into it while trying to use this struct in this program. Instead I had to insert a copy here, we called it an adapter for semantics, but the adapter could have been the struct in bubblegum.

Pretty similar to your example :)

@samwise2
Copy link

samwise2 commented Jul 4, 2023

Are there any updates on this ticket? I've run into this again LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants