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 all 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
31 changes: 27 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,53 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.

### Added Unreleased

- Something new here 1
- Something new here 2

### Changed Unreleased

- Something changed here 1
- Something changed here 2

### Fixed Unreleased

- [#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.

#### Breaking Unreleased

- Some breaking change here 1
- Some breaking change here 2

## [Version 0.5.1]

Description of the upcoming release here.

### Added
### Added v0.5.1

- [#107](https://github.com/FuelLabs/sway-standards/pull/107): Adds the `proxy_owner()` function to the SRC-14 standard.
- [#104](https://github.com/FuelLabs/sway-standards/pull/104): Adds the CHANGELOG.md file to Sway-Standards.
- [#110](https://github.com/FuelLabs/sway-standards/pull/110) Adds the `proxy_target()` function to the SRC-14 standard.
- [#103](https://github.com/FuelLabs/sway-standards/pull/103): Adds Sway-Standards to the [docs hub](https://docs.fuel.network/docs/sway-standards/).

### Changed
### Changed v0.5.1

- [#103](https://github.com/FuelLabs/sway-standards/pull/103) Removes standards in the `./SRC` folder in favor of `./docs`.
- [#106](https://github.com/FuelLabs/sway-standards/pull/106) Updates links from the Sway Book to Docs Hub.

### Fixed
### Fixed v0.5.1

- [#107](https://github.com/FuelLabs/sway-standards/pull/107) resolves the conflict when SRC-5's `owner()` function is used in both the proxy and target contract in the SRC-14 standard.
- [#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.

#### Breaking
#### Breaking v0.5.1

- [#110](https://github.com/FuelLabs/sway-standards/pull/110) Breaks the `SRC14` abi by adding the `proxy_target()` function. This will need to be added to any SRC14 implementation. The new abi is as follows:

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