sway icon indicating copy to clipboard operation
sway copied to clipboard

Storing the result of an `abi()` declaration in storage or configurables

Open Braqzen opened this issue 1 year ago • 1 comments

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.

Braqzen avatar May 02 '24 18:05 Braqzen

This may or may not be a duplicate issue that I would have likely raised some time ago.

Braqzen avatar May 02 '24 18:05 Braqzen