sway
sway copied to clipboard
Storing the result of an `abi()` declaration in storage or configurables
Solidity permits the instantiation and storage of types which can be called directly. This would be a useful but low priority UX feature for Sway.
use interface::MyExternalContractAbi;
use std::constants::ZERO_B256;
storage {
target: MyExternalContractAbi = // something here
}
impl MyContract for Contract {
#[storage(write)]
fn constructor() {
storage.target.write(abi(MyExternalContractAbi, ZERO_B256));
}
#[storage(read)]
fn call() {
storage.target.read().call_some_function();
}
}
Storage may not be a good idea because of read costs but some may want to switch the instance. Configurables would also be useful.
This may or may not be a duplicate issue that I would have likely raised some time ago.