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

SRC-6 example contract does not update managed assets #122

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
24 changes: 20 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,46 @@ 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

### Changed Unreleased

- Something new here

### Fixed Unreleased

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

## [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
3 changes: 3 additions & 0 deletions examples/src6-vault/multi_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ 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;
bitzoic marked this conversation as resolved.
Show resolved Hide resolved

_burn(share_asset_id, share_asset_vault_sub_id, shares);

transfer(receiver, underlying_asset, assets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions examples/src6-vault/single_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ 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;
bitzoic marked this conversation as resolved.
Show resolved Hide resolved

_burn(share_asset_id, share_asset_vault_sub_id, shares);

transfer(receiver, underlying_asset, assets);
Expand Down
Loading