Skip to content

Commit

Permalink
lang: fix owner compile error caused by missing type annotation (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-schaaf authored Mar 19, 2022
1 parent d42d147 commit bb25cd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
* 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)).
* 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)).
* 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)).
* 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)).
* 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)).
* lang: Fix bug where `owner = <target>` would not compile because of missing type annotation ([#1648](https://github.com/project-serum/anchor/pull/1648)).

### Breaking

Expand Down
10 changes: 5 additions & 5 deletions lang/syn/src/codegen/accounts/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub fn generate_constraint_owner(f: &Field, c: &ConstraintOwner) -> proc_macro2:
);
quote! {
{
let my_owner = #ident.as_ref().owner;
let my_owner = AsRef::<AccountInfo>::as_ref(&#ident).owner;
let owner_address = #owner_address;
if my_owner != &owner_address {
return #error;
Expand Down Expand Up @@ -379,7 +379,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
#find_pda

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.
#payer

Expand Down Expand Up @@ -417,7 +417,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
#find_pda

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

let cpi_program = associated_token_program.to_account_info();
Expand Down Expand Up @@ -470,7 +470,7 @@ fn generate_constraint_init_group(f: &Field, c: &ConstraintInitGroup) -> proc_ma
#find_pda

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.
#payer

Expand Down Expand Up @@ -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()) {
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));
}
}
Expand Down

0 comments on commit bb25cd6

Please sign in to comment.