-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add mint constraints and test #562
add mint constraints and test #562
Conversation
EDIT: Resolved, solution in comments below Getting an error when I import your repo to use this feature. Finished release [optimized] target(s) in 8.27s
Running: /Users/hp/.local/share/solana/install/releases/1.7.3/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /Users/hp/Documents/solana-season-hack/cyclos/target/deploy/cyclos.so
To deploy this program:
$ solana program deploy /Users/hp/Documents/solana-season-hack/cyclos/target/deploy/cyclos.so
thread 'main' panicked at 'Code not parseable: Error("Invalid attribute")', lang/syn/src/idl/file.rs:351:62
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: anchor_syn::idl::file::parse_account_derives
4: anchor_syn::idl::file::parse
5: anchor::extract_idl
6: anchor::build_cwd
7: anchor::build
8: anchor::main Here's my code #[account(
init,
mint_decimals = 6 as u8,
mint_authority = open_orders_authority,
seeds = [b"Mint".as_ref(), &[_mint_bump]],
payer = authority,
space = size_of::<Mint>()
)]
pub mint: CpiAccount<'info, Mint>, Imported your repo in [dependencies]
anchor-lang = { git = "https://github.com/Henry-E/anchor", branch = "add_mint_constraints" }
anchor-spl = { git = "https://github.com/Henry-E/anchor", branch = "add_mint_constraints" } Travis build points to an error, is this the reason why I'm getting this issue?
|
You'll need to use the CLI compiled with these changes as well. |
Yeh, you need to use |
Resolved, thanks a lot |
Updated the pull request using Also reduced the number of system program calls from 3 to 1. The original code from the associated token program splits call into three because it can't be sure if the account has already been initialized with some lamports. We don't have that same requirement. @armaniferrante With regards to open orders initializing, I don't actually feel comfortable enough with all of the different syntax being used to access account variables to add it. Apologies! |
It says the builds are still failing after running |
The second macro could be extended to create associated token accounts? This will be more convenient than |
omg, all the builds finally passed |
if self.mint_decimals.is_none() { | ||
return Err(ParseError::new( | ||
c.span(), | ||
"mint decimals must be provided before authority", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debatable whether this should be enforced. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It made more sense with the old token = <mint>, authority = <auth>
syntax, since having the token
first made things more clear. But with the new syntax, it's not really necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, there's no reason to enforce this.
We will have to add in the fallback option eventually for the case where a PDA account already has some lamports in it. Maybe the fallback could just transfer any lamports inside the account to the authority? Then there should be 0 lamports inside the account when it is passed to |
Added new mint constraints so that it's possible to initialize a PDA mint account in the same way as token accounts.
New Constraint Tokens / Keywords
mint_decimals
: au8
corresponding to thedecimals
argument of the InitializeMint function in the SPL token programmint_authority
: a program account, account info or cpi account that will be assigned as the mint's authority. Corresponds tomint_authority
argument of the InitializeMint function in the SPL token programExample usage