From 9c85a02e5ba5a8c6f520727287e84b474895b743 Mon Sep 17 00:00:00 2001 From: Cameron Carstens Date: Thu, 27 Jun 2024 19:34:29 +0800 Subject: [PATCH 01/18] Hotfix: Update Cargo.toml to v0.5.1 (#115) * Hotfix: Update Cargo.toml to v0.5.1 * Udpate CHANGELOG --- CHANGELOG.md | 1 + Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6492fb..b99f637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Description of the upcoming release here. - [#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 diff --git a/Cargo.toml b/Cargo.toml index e76a377..b24d5d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,4 @@ [package] name = "sway-standards" -version = "0.5.0" +version = "0.5.1" edition = "2021" From f0b5631d9b64980fc02a7a58ff5994ab6a53996f Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Tue, 2 Jul 2024 14:32:46 +0000 Subject: [PATCH 02/18] fix vault reads --- examples/src6-vault/multi_asset_vault/src/main.sw | 9 ++++++++- examples/src6-vault/single_asset_vault/src/main.sw | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/src6-vault/multi_asset_vault/src/main.sw b/examples/src6-vault/multi_asset_vault/src/main.sw index 26d3428..ede9e40 100644 --- a/examples/src6-vault/multi_asset_vault/src/main.sw +++ b/examples/src6-vault/multi_asset_vault/src/main.sw @@ -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); diff --git a/examples/src6-vault/single_asset_vault/src/main.sw b/examples/src6-vault/single_asset_vault/src/main.sw index 16d1d76..c910eb6 100644 --- a/examples/src6-vault/single_asset_vault/src/main.sw +++ b/examples/src6-vault/single_asset_vault/src/main.sw @@ -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); From 050977c54cbd522131917444d639c2d08a94e4ee Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Tue, 2 Jul 2024 14:38:33 +0000 Subject: [PATCH 03/18] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b99f637..1513cfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. #### Breaking From 7edb337ccc5f953bc6405ab852728339e63ab901 Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Mon, 8 Jul 2024 16:27:51 +0530 Subject: [PATCH 04/18] move changelog to new empty changelog --- CHANGELOG.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1513cfe..d1d2316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,29 @@ 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] - yyyy-mm-dd + +Description of the upcoming release here. + +### Added + +- Something new here 1 +- Something new here 2 + +### Changed + +- Something changed here 1 +- Something changed here 2 + +### Fixed + +- [#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 + +- Some breaking change here 1 +- Some breaking change here 2 + ## [Version 0.5.1] Description of the upcoming release here. @@ -27,7 +50,6 @@ 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. #### Breaking From cb4dbab61c279c78a010fdc75d40e0278d96297e Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Mon, 8 Jul 2024 16:32:05 +0530 Subject: [PATCH 05/18] add "unreleased" to changelog heads --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d2316..87528a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,21 +9,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Description of the upcoming release here. -### Added +### Added Unreleased - Something new here 1 - Something new here 2 -### Changed +### Changed Unreleased - Something changed here 1 - Something changed here 2 -### Fixed +### 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 +#### Breaking Unreleased - Some breaking change here 1 - Some breaking change here 2 From b70a650d2c39426371c5b288c67bc8e24d89d2a5 Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Mon, 8 Jul 2024 16:36:04 +0530 Subject: [PATCH 06/18] remove date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87528a5..f0439db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ 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] - yyyy-mm-dd +## [Unreleased] Description of the upcoming release here. From babc929b3bf35ba3af8718833252dacfeafca16b Mon Sep 17 00:00:00 2001 From: SwayStar123 Date: Mon, 8 Jul 2024 16:37:19 +0530 Subject: [PATCH 07/18] add v0.5.1 --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0439db..5d6103c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,26 +32,26 @@ Description of the upcoming release here. 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: From 3acac2b057b6a318dd79848f08f70280bf2a647a Mon Sep 17 00:00:00 2001 From: Cameron Carstens Date: Tue, 9 Jul 2024 22:24:50 +0800 Subject: [PATCH 08/18] SRC-6 example contract does not update managed assets (#122) * Update SRC-6 example with decrementation of managed assets * Update CHANGELOG * Fix link on CHANGELOG.md * Update CHANGELOG to resolve markdown error with duplicate headers * Write to storage --- CHANGELOG.md | 6 +++--- examples/src6-vault/multi_asset_vault/src/main.sw | 4 ++++ .../src6-vault/single_asset_single_sub_vault/src/main.sw | 4 ++++ examples/src6-vault/single_asset_vault/src/main.sw | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6103c..a3a1fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,7 @@ Description of the upcoming release here. ### Added Unreleased -- Something new here 1 -- Something new here 2 +- Something new here ### Changed Unreleased @@ -22,8 +21,9 @@ Description of the upcoming release here. ### 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. +- [#122](https://github.com/FuelLabs/sway-standards/pull/122) Fixes the SRC-6 example contract from a critical bug where the contract can be drained. -#### Breaking Unreleased +### Breaking Unreleased - Some breaking change here 1 - Some breaking change here 2 diff --git a/examples/src6-vault/multi_asset_vault/src/main.sw b/examples/src6-vault/multi_asset_vault/src/main.sw index ede9e40..b0a8f05 100644 --- a/examples/src6-vault/multi_asset_vault/src/main.sw +++ b/examples/src6-vault/multi_asset_vault/src/main.sw @@ -88,6 +88,10 @@ impl SRC6 for Contract { require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID"); let assets = preview_withdraw(share_asset_id, shares); + let mut vault_info = storage.vault_info.get(share_asset_id).read(); + vault_info.managed_assets = vault_info.managed_assets - shares; + storage.vault_info.insert(share_asset_id, vault_info); + _burn(share_asset_id, share_asset_vault_sub_id, shares); transfer(receiver, underlying_asset, assets); diff --git a/examples/src6-vault/single_asset_single_sub_vault/src/main.sw b/examples/src6-vault/single_asset_single_sub_vault/src/main.sw index fedd56d..51c2c48 100644 --- a/examples/src6-vault/single_asset_single_sub_vault/src/main.sw +++ b/examples/src6-vault/single_asset_single_sub_vault/src/main.sw @@ -78,6 +78,10 @@ impl SRC6 for Contract { require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID"); let assets = preview_withdraw(shares); + storage + .managed_assets + .write(storage.managed_assets.read() - shares); + _burn(share_asset_id, shares); transfer(receiver, underlying_asset, assets); diff --git a/examples/src6-vault/single_asset_vault/src/main.sw b/examples/src6-vault/single_asset_vault/src/main.sw index c910eb6..c1f52e0 100644 --- a/examples/src6-vault/single_asset_vault/src/main.sw +++ b/examples/src6-vault/single_asset_vault/src/main.sw @@ -89,6 +89,10 @@ impl SRC6 for Contract { require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID"); let assets = preview_withdraw(share_asset_id, shares); + let mut vault_info = storage.vault_info.get(share_asset_id).read(); + vault_info.managed_assets = vault_info.managed_assets - shares; + storage.vault_info.insert(share_asset_id, vault_info); + _burn(share_asset_id, share_asset_vault_sub_id, shares); transfer(receiver, underlying_asset, assets); From ade6077a83657498deb2f9bf46aa02ced03c3b01 Mon Sep 17 00:00:00 2001 From: IGI-111 Date: Mon, 22 Jul 2024 07:53:53 +0200 Subject: [PATCH 09/18] Use new namespace syntax for storage (#120) --- .github/workflows/ci.yaml | 2 +- CHANGELOG.md | 1 + README.md | 6 +++--- docs/src/index.md | 2 +- examples/src14-simple-proxy/minimal/src/minimal.sw | 4 +--- examples/src14-simple-proxy/owned/src/owned.sw | 14 +++++++------- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 08621d4..22316f8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io RUST_VERSION: 1.77.0 - FORC_VERSION: 0.60.0 + FORC_VERSION: 0.61.0 CORE_VERSION: 0.26.0 PATH_TO_SCRIPTS: .github/scripts diff --git a/CHANGELOG.md b/CHANGELOG.md index a3a1fc0..6e4bcea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Description of the upcoming release here. - [#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. +- [#120](https://github.com/FuelLabs/sway-standards/pull/120) Updates repository to forc v0.61.0 and uses new namespace in SRC-14 example. ### Fixed v0.5.1 diff --git a/README.md b/README.md index ff0a73b..73e4c5b 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ - - + + @@ -162,7 +162,7 @@ Example of a minimal SRC-14 implementation with no access control. Example of a SRC-14 implementation that also implements [SRC-5](https://docs.fuel.network/docs/sway-standards/src-5-ownership/). > **Note** -> All standards currently use `forc v0.60.0`. +> All standards currently use `forc v0.61.0`.