FuelLabs/sway

Subcurrency example possible changes

Open

#2,473 opened on Aug 8, 2022

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Rust (61,702 stars) (5,421 forks)batch import
P: lowThe Sway Bookdocumentationgood first issue

Description

In the "send" function in the subcurrency example, it checks that the msg_sender() Address is the same as the address of the contract creator. This seems like faulty logic as that means only the contract creator can send tokens (ever). If for some reason this is the desired logic, i think theres still a change required which would be to use a internal function to avoid repeating this piece of code

let sender: Result<Identity, AuthError> = msg_sender();
let sender: Address = match sender.unwrap() {
    Identity::Address(addr) => {
        assert(addr == ~Address::from(MINTER));
        addr
},
    _ => {
        revert(0);
    },
};

Contributor guide

Subcurrency example possible changes · FuelLabs/sway#2473 | Good First Issue