Skip to content

Commit 96a223c

Browse files
authored
Merge pull request #51 from FuelLabs/bitzoic-vault-hotfix
hotfix: Add `#[payable]` attribute to vault `deposit()` and `withdraw()` functions
2 parents 77cdc14 + 3a27160 commit 96a223c

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

examples/src6-vault/multi_token_vault/src/main.sw

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ storage {
4040
}
4141

4242
impl SRC6 for Contract {
43+
#[payable]
4344
#[storage(read, write)]
4445
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
4546
let asset_amount = msg_amount();
@@ -76,6 +77,7 @@ impl SRC6 for Contract {
7677
shares
7778
}
7879

80+
#[payable]
7981
#[storage(read, write)]
8082
fn withdraw(
8183
receiver: Identity,

examples/src6-vault/single_token_single_sub_vault/src/main.sw

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ storage {
3737
}
3838

3939
impl SRC6 for Contract {
40+
#[payable]
4041
#[storage(read, write)]
4142
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
4243
require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id");
@@ -69,6 +70,7 @@ impl SRC6 for Contract {
6970
shares
7071
}
7172

73+
#[payable]
7274
#[storage(read, write)]
7375
fn withdraw(
7476
receiver: Identity,

examples/src6-vault/single_token_vault/src/main.sw

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ configurable {
4646
}
4747

4848
impl SRC6 for Contract {
49+
#[payable]
4950
#[storage(read, write)]
5051
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
5152
let asset_amount = msg_amount();
@@ -83,6 +84,7 @@ impl SRC6 for Contract {
8384
shares
8485
}
8586

87+
#[payable]
8688
#[storage(read, write)]
8789
fn withdraw(
8890
receiver: Identity,

standards/src6-vault/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ Incorrect implementation of token vaults could allow attackers to steal underlyi
153153

154154
```sway
155155
abi SRC6 {
156+
#[payable]
156157
#[storage(read, write)]
157158
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64;
158159
160+
#[payable]
159161
#[storage(read, write)]
160162
fn withdraw(receiver: Identity, underlying_asset: AssetId, vault_sub_id: SubId) -> u64;
161163

standards/src6-vault/src/src6.sw

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ abi SRC6 {
5353
/// * If the asset is not supported by the contract.
5454
/// * If the amount of assets forwarded to the contract is zero.
5555
/// * The user crosses any global or user specific deposit limits.
56+
#[payable]
5657
#[storage(read, write)]
5758
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64;
5859

@@ -78,6 +79,7 @@ abi SRC6 {
7879
/// * If the amount of shares is zero.
7980
/// * If the transferred shares do not corresspond to the given asset.
8081
/// * The user crosses any global or user specific withdrawal limits.
82+
#[payable]
8183
#[storage(read, write)]
8284
fn withdraw(
8385
receiver: Identity,

0 commit comments

Comments
 (0)