Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vault standard examples #121

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Description of the upcoming release here.
- [#99](https://github.com/FuelLabs/sway-standards/pull/99) Fixes links and typos in the SRC-14 standard.
- [#112](https://github.com/FuelLabs/sway-standards/pull/112) Fixes inline documentation code in the SRC-3 standard.
- [#115](https://github.com/FuelLabs/sway-standards/pull/115) Hotfixes the Cargo.toml version to the v0.5.1 release.
- [#121](https://github.com/FuelLabs/sway-standards/pull/121) Fixes the `deposit` function in the SRC-6 standard, uses try_read instead of read in order to allow first time deposits to a vault.
bitzoic marked this conversation as resolved.
Show resolved Hide resolved

#### Breaking

Expand Down
9 changes: 8 additions & 1 deletion examples/src6-vault/multi_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ impl SRC6 for Contract {

_mint(receiver, share_asset, share_asset_vault_sub_id, shares);

let mut vault_info = storage.vault_info.get(share_asset).read();
let mut vault_info = match storage.vault_info.get(share_asset).try_read() {
Some(vault_info) => vault_info,
None => VaultInfo {
managed_assets: 0,
vault_sub_id,
asset: underlying_asset,
},
};
vault_info.managed_assets = vault_info.managed_assets + asset_amount;
storage.vault_info.insert(share_asset, vault_info);

Expand Down
9 changes: 8 additions & 1 deletion examples/src6-vault/single_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ impl SRC6 for Contract {

_mint(receiver, share_asset, share_asset_vault_sub_id, shares);

let mut vault_info = storage.vault_info.get(share_asset).read();
let mut vault_info = match storage.vault_info.get(share_asset).try_read() {
Some(vault_info) => vault_info,
None => VaultInfo {
managed_assets: 0,
vault_sub_id,
asset: underlying_asset,
},
};
vault_info.managed_assets = vault_info.managed_assets + asset_amount;
storage.vault_info.insert(share_asset, vault_info);

Expand Down
Loading