Skip to content

Commit

Permalink
Temporarily comment out storage related code in wallet example
Browse files Browse the repository at this point in the history
This example should be updated after FuelLabs#646 lands.
  • Loading branch information
mitchmindtree committed Feb 11, 2022
1 parent 9fb07f4 commit 4da1bee
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions examples/wallet_smart_contract/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// NOTE: Storage is a work in progress (see
// https://github.com/FuelLabs/sway/pull/646), but once it is implemented,
// declaring storage should look like this.

contract;

use std::*;
use std::chain::assert;

const OWNER_ADDRESS: b256 = 0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861;
const ETH_ID: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000;

storage {
balance: u64,
}
// storage {
// balance: u64,
// }

abi Wallet {
fn receive_funds(gas_to_forward: u64, coins_to_forward: u64, asset_id: b256, unused: ());
Expand All @@ -16,17 +21,17 @@ abi Wallet {

impl Wallet for Contract {
fn receive_funds(gas_to_forward: u64, coins_to_forward: u64, asset_id: b256, unused: ()) {
if asset_id == ETH_ID {
let balance = storage.balance.write();
deref balance = balance + coins_to_forward;
};
// if asset_id == ETH_ID {
// let balance = storage.balance.write();
// deref balance = balance + coins_to_forward;
// };
}

fn send_funds(gas_to_forward: u64, coins_to_forward: u64, asset_id: b256, req: SendFundsRequest) {
assert(sender() == OWNER_ADDRESS);
assert(storage.balance > req.amount_to_send);
storage.balance = storage.balance - req.amount_to_send;
transfer_coins(asset_id, req.recipient_address, req.amount_to_send);
// assert(sender() == OWNER_ADDRESS);
// assert(storage.balance > req.amount_to_send);
// storage.balance = storage.balance - req.amount_to_send;
// transfer_coins(asset_id, req.recipient_address, req.amount_to_send);
}
}

Expand Down

0 comments on commit 4da1bee

Please sign in to comment.