Closed 0x777A closed 3 months ago
Looks like we don't have a test case for this specific usage.
You can use one of the following workarounds until we support this usage:
Use has_one
constraint:
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(has_one = vault)]
pub pool_state: Account<'info, PoolState>,
pub vault: UncheckedAccount<'info>,
}
#[account]
pub struct PoolState {
pub vault: Pubkey,
}
Use constraint
:
#[derive(Accounts)]
pub struct Initialize<'info> {
pub pool_state: Account<'info, PoolState>,
#[account(constraint = vault.key() == pool_state.vault)
pub vault: UncheckedAccount<'info>,
}
#[account]
pub struct PoolState {
pub vault: Pubkey,
}
Disable resolution
feature in Anchor.toml
:
[features]
resolution = false
+1. Just upgraded from 0.29.0 and 0.30.0 and all my address =
constraints are giving me this error. Perhaps Rust docs should be updated to remove this feature? https://docs.rs/anchor-lang/latest/anchor_lang/derive.Accounts.html
Happy to submit a PR for that if you point me where. Found it, will submit one
When using
anchor build
to compile the program,the fields limited by theaddress constraint
cannot be recognized, but when compiled directly usingcargo build-bpf
, the compilation can be successful. example:Here is the error