lang: fix owner compile error caused by missing type annotation (#1648)
This commit is contained in:
parent
d42d147e6a
commit
bb25cd6a6f
|
@ -28,10 +28,11 @@ incremented for features.
|
||||||
* ts: Fix the loss of strict typing using the `methods` namespace on builder functions ([#1539](https://github.com/project-serum/anchor/pull/1539)).
|
* ts: Fix the loss of strict typing using the `methods` namespace on builder functions ([#1539](https://github.com/project-serum/anchor/pull/1539)).
|
||||||
* spl: Update `spl/governance` to use new errors ([#1582](https://github.com/project-serum/anchor/pull/1582)).
|
* spl: Update `spl/governance` to use new errors ([#1582](https://github.com/project-serum/anchor/pull/1582)).
|
||||||
* client: Fix `Cluster`'s `FromStr` implementation ([#1362](https://github.com/project-serum/anchor/pull/1362)).
|
* client: Fix `Cluster`'s `FromStr` implementation ([#1362](https://github.com/project-serum/anchor/pull/1362)).
|
||||||
* lang: implement `Key` for `Pubkey` again, so `associated_token::*` constraints can use pubkey targets again ([#1601](https://github.com/project-serum/anchor/pull/1601)).
|
* lang: Implement `Key` for `Pubkey` again, so `associated_token::*` constraints can use pubkey targets again ([#1601](https://github.com/project-serum/anchor/pull/1601)).
|
||||||
* lang: adjust error code so `#[error_code]` works with just importing `anchor_lang::error_code` ([#1610](https://github.com/project-serum/anchor/pull/1610)).
|
* lang: Adjust error code so `#[error_code]` works with just importing `anchor_lang::error_code` ([#1610](https://github.com/project-serum/anchor/pull/1610)).
|
||||||
* ts: fix `spl-token` coder account parsing ([#1604](https://github.com/project-serum/anchor/pull/1604)).
|
* ts: Fix `spl-token` coder account parsing ([#1604](https://github.com/project-serum/anchor/pull/1604)).
|
||||||
* cli: fix `npm install` fallback if `yarn` install doesn't work ([#1643](https://github.com/project-serum/anchor/pull/1643)).
|
* cli: Fix `npm install` fallback if `yarn` install doesn't work ([#1643](https://github.com/project-serum/anchor/pull/1643)).
|
||||||
|
* lang: Fix bug where `owner = <target>` would not compile because of missing type annotation ([#1648](https://github.com/project-serum/anchor/pull/1648)).
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ pub fn generate_constraint_owner(f: &Field, c: &ConstraintOwner) -> proc_macro2:
|
||||||
);
|
);
|
||||||
quote! {
|
quote! {
|
||||||
{
|
{
|
||||||
let my_owner = #ident.as_ref().owner;
|
let my_owner = AsRef::<AccountInfo>::as_ref(&#ident).owner;
|
||||||
let owner_address = #owner_address;
|
let owner_address = #owner_address;
|
||||||
if my_owner != &owner_address {
|
if my_owner != &owner_address {
|
||||||
return #error;
|
return #error;
|
||||||
|
@ -379,7 +379,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
|
||||||
#find_pda
|
#find_pda
|
||||||
|
|
||||||
let #field: #ty_decl = {
|
let #field: #ty_decl = {
|
||||||
if !#if_needed || #field.as_ref().owner == &anchor_lang::solana_program::system_program::ID {
|
if !#if_needed || AsRef::<AccountInfo>::as_ref(&#field).owner == &anchor_lang::solana_program::system_program::ID {
|
||||||
// Define payer variable.
|
// Define payer variable.
|
||||||
#payer
|
#payer
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
|
||||||
#find_pda
|
#find_pda
|
||||||
|
|
||||||
let #field: #ty_decl = {
|
let #field: #ty_decl = {
|
||||||
if !#if_needed || #field.as_ref().owner == &anchor_lang::solana_program::system_program::ID {
|
if !#if_needed || AsRef::<AccountInfo>::as_ref(&#field).owner == &anchor_lang::solana_program::system_program::ID {
|
||||||
#payer
|
#payer
|
||||||
|
|
||||||
let cpi_program = associated_token_program.to_account_info();
|
let cpi_program = associated_token_program.to_account_info();
|
||||||
|
@ -470,7 +470,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
|
||||||
#find_pda
|
#find_pda
|
||||||
|
|
||||||
let #field: #ty_decl = {
|
let #field: #ty_decl = {
|
||||||
if !#if_needed || #field.as_ref().owner == &anchor_lang::solana_program::system_program::ID {
|
if !#if_needed || AsRef::<AccountInfo>::as_ref(&#field).owner == &anchor_lang::solana_program::system_program::ID {
|
||||||
// Define payer variable.
|
// Define payer variable.
|
||||||
#payer
|
#payer
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ pub fn generate_constraint_state(f: &Field, c: &ConstraintState) -> proc_macro2:
|
||||||
if #ident.key() != anchor_lang::accounts::cpi_state::CpiState::<#account_ty>::address(&#program_target.key()) {
|
if #ident.key() != anchor_lang::accounts::cpi_state::CpiState::<#account_ty>::address(&#program_target.key()) {
|
||||||
return Err(anchor_lang::error::Error::from(anchor_lang::error::ErrorCode::ConstraintState).with_account_name(#name_str));
|
return Err(anchor_lang::error::Error::from(anchor_lang::error::ErrorCode::ConstraintState).with_account_name(#name_str));
|
||||||
}
|
}
|
||||||
if #ident.as_ref().owner != &#program_target.key() {
|
if AsRef::<AccountInfo>::as_ref(&#ident).owner != &#program_target.key() {
|
||||||
return Err(anchor_lang::error::Error::from(anchor_lang::error::ErrorCode::ConstraintState).with_account_name(#name_str));
|
return Err(anchor_lang::error::Error::from(anchor_lang::error::ErrorCode::ConstraintState).with_account_name(#name_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue