Skip to content

Instantly share code, notes, and snippets.

@IGI-111
Last active April 16, 2024 02:37
Show Gist options
  • Save IGI-111/a80da960073f4dbbf03693ec9e41c675 to your computer and use it in GitHub Desktop.
Save IGI-111/a80da960073f4dbbf03693ec9e41c675 to your computer and use it in GitHub Desktop.
contract;
abi ProxyAbi {
#[storage(read)]
fn read_val() -> u64;
#[storage(write)]
fn write_target(target: ContractId);
}
#[namespace(proxy_47892374)]
storage {
target: ContractId,
}
impl ProxyAbi for Contract {
#[storage(read)]
fn read_val() -> u64 {
let target = storage.target.read();
std::execution::run_external(target);
}
#[storage(write)]
fn write_target(target: ContractId) {
storage.target.write(target);
}
}
contract;
abi TargetAbi {
#[storage(read)]
fn read_val() -> u64;
#[storage(write)]
fn write_val(val: u64);
}
storage {
val: u64,
}
impl TargetAbi for Contract {
#[storage(read)]
fn read_val() -> u64 {
storage.val.read()
}
#[storage(write)]
fn write_val(val: u64) {
storage.val.write(val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment