Skip to content

Commit

Permalink
substitution preprocessor - storage mapper from address fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Nov 18, 2024
1 parent 408cceb commit 09767a4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "storage",
"gasSchedule": "v3",
"steps": [
{
"step": "setState",
Expand All @@ -13,7 +12,10 @@
"sc:extra-instance": {
"nonce": "0",
"balance": "0",
"code": "mxsc:../output/basic-features.mxsc.json"
"code": "mxsc:../output/basic-features.mxsc.json",
"storage": {
"str:contract_address": "sc:basic-features"
}
},
"address:an_account": {
"nonce": "0",
Expand Down Expand Up @@ -67,6 +69,29 @@
"refund": "*"
}
},
{
"step": "scCall",
"id": "address_to_id_mapper_get_id_from_address",
"tx": {
"from": "address:an_account",
"to": "sc:extra-instance",
"function": "address_to_id_mapper_get_id_from_address",
"arguments": [
"address:an_account"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"1"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "get_id_non_zero",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,16 @@ pub trait StorageMapperGetAtAddress {
self.single_value_from_address_with_keys(address, extra_key)
.get()
}

#[storage_mapper_from_address("address_ids")]
fn address_ids_from_address(
&self,
address: ManagedAddress,
) -> AddressToIdMapper<ManagedAddress>;

#[view]
fn address_to_id_mapper_get_id_from_address(&self, address_arg: ManagedAddress) -> AddressId {
let address = self.contract_address().get();
self.address_ids_from_address(address).get_id(&address_arg)
}
}
1 change: 1 addition & 0 deletions framework/derive/src/preprocessing/substitution_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fn add_storage_mapper_single_generic_arg(
substitutions: &mut SubstitutionsMap,
mapper_name: &proc_macro2::TokenStream,
) {
add_managed_type_with_generics(substitutions, mapper_name);
substitutions.add_substitution(
quote!(#mapper_name<Self::Api>),
quote!(#mapper_name<Self::Api>),
Expand Down

0 comments on commit 09767a4

Please sign in to comment.