lang: fix missing account name info when deser fails when using 'init' or 'zero' (#1800)
This commit is contained in:
parent
765fee0c6e
commit
d0a13e6535
|
@ -17,6 +17,7 @@ The minor version will be incremented upon a breaking change and the patch versi
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
* cli: Move `overflow-checks` into workspace `Cargo.toml` so that it will not be ignored by compiler ([#1806](https://github.com/project-serum/anchor/pull/1806)).
|
* cli: Move `overflow-checks` into workspace `Cargo.toml` so that it will not be ignored by compiler ([#1806](https://github.com/project-serum/anchor/pull/1806)).
|
||||||
|
* lang: Fix missing account name information when deserialization fails when using `init` or `zero` ([#1800](https://github.com/project-serum/anchor/pull/1800)).
|
||||||
|
|
||||||
## [0.24.2] - 2022-04-13
|
## [0.24.2] - 2022-04-13
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,7 @@ impl Field {
|
||||||
checked: bool,
|
checked: bool,
|
||||||
) -> proc_macro2::TokenStream {
|
) -> proc_macro2::TokenStream {
|
||||||
let field = &self.ident;
|
let field = &self.ident;
|
||||||
|
let field_str = field.to_string();
|
||||||
let container_ty = self.container_ty();
|
let container_ty = self.container_ty();
|
||||||
let owner_addr = match &kind {
|
let owner_addr = match &kind {
|
||||||
None => quote! { program_id },
|
None => quote! { program_id },
|
||||||
|
@ -307,13 +308,13 @@ impl Field {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from(
|
#container_ty::try_from(
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from_unchecked(
|
#container_ty::try_from_unchecked(
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if *boxed {
|
if *boxed {
|
||||||
|
@ -329,13 +330,13 @@ impl Field {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from(
|
#container_ty::try_from(
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from_unchecked(
|
#container_ty::try_from_unchecked(
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,14 +345,14 @@ impl Field {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from(
|
#container_ty::try_from(
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from_unchecked(
|
#container_ty::try_from_unchecked(
|
||||||
#owner_addr,
|
#owner_addr,
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,14 +362,14 @@ impl Field {
|
||||||
#container_ty::try_from(
|
#container_ty::try_from(
|
||||||
#owner_addr,
|
#owner_addr,
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
#container_ty::try_from_unchecked(
|
#container_ty::try_from_unchecked(
|
||||||
#owner_addr,
|
#owner_addr,
|
||||||
&#field,
|
&#field,
|
||||||
)?
|
).map_err(|e| e.with_account_name(#field_str))?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue