Skip to content

Commit 270350e

Browse files
bitzoicSwayStar123IGI-111sdankelK1-R1
authored
Release v0.5.2 (#127)
* Hotfix: Update Cargo.toml to v0.5.1 (#115) * Hotfix: Update Cargo.toml to v0.5.1 * Udpate CHANGELOG * fix vault reads * add changelog * move changelog to new empty changelog * add "unreleased" to changelog heads * remove date * add v0.5.1 * 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 * Use new namespace syntax for storage (#120) * chore: fix compiler warnings * remove for examples * Update changelog * Prepare master for v0.5.2 release (#126) * Prepare for v0.5.2 release * Update CHANGELOG * Update CHANGELOG formatting --------- Co-authored-by: SwayStar123 <[email protected]> Co-authored-by: SwayStar123 <[email protected]> Co-authored-by: IGI-111 <[email protected]> Co-authored-by: Sophie <[email protected]> Co-authored-by: K1-R1 <[email protected]>
1 parent e2d5ac4 commit 270350e

File tree

11 files changed

+94
-30
lines changed

11 files changed

+94
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
CARGO_TERM_COLOR: always
1717
REGISTRY: ghcr.io
1818
RUST_VERSION: 1.77.0
19-
FORC_VERSION: 0.60.0
19+
FORC_VERSION: 0.61.0
2020
CORE_VERSION: 0.26.0
2121
PATH_TO_SCRIPTS: .github/scripts
2222

@@ -61,7 +61,7 @@ jobs:
6161
run: forc fmt --path standards --check
6262

6363
- name: Build All Standards
64-
run: forc build --path standards
64+
run: forc build --error-on-warnings --path standards
6565

6666
- name: Check Sway Formatting Examples
6767
run: forc fmt --path examples --check

CHANGELOG.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,63 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [Version 0.5.1]
8+
## [Unreleased]
9+
10+
### Added Unreleased
11+
12+
- Something new here 1
13+
- Something new here 2
14+
15+
### Changed Unreleased
16+
17+
- Something changed here 1
18+
- Something changed here 2
19+
20+
### Fixed Unreleased
21+
22+
- Some fix here 1
23+
- Some fix here 2
24+
25+
### Breaking Unreleased
926

10-
Description of the upcoming release here.
27+
- Some breaking change here 1
28+
- Some breaking change here 2
29+
30+
## [Version 0.5.2]
31+
32+
### Changed v0.5.2
33+
34+
- [#126](https://github.com/FuelLabs/sway-standards/pull/126) Prepares for v0.5.2 release.
35+
36+
### Fixed v0.5.2
37+
38+
- [#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.
39+
- [#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.
40+
- [#124](https://github.com/FuelLabs/sway-standards/pull/124) Fixes compiler warnings for libraries
41+
42+
## [Version 0.5.1]
1143

12-
### Added
44+
### Added v0.5.1
1345

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

19-
### Changed
51+
### Changed v0.5.1
2052

2153
- [#103](https://github.com/FuelLabs/sway-standards/pull/103) Removes standards in the `./SRC` folder in favor of `./docs`.
2254
- [#106](https://github.com/FuelLabs/sway-standards/pull/106) Updates links from the Sway Book to Docs Hub.
55+
- [#120](https://github.com/FuelLabs/sway-standards/pull/120) Updates repository to forc v0.61.0 and uses new namespace in SRC-14 example.
2356

24-
### Fixed
57+
### Fixed v0.5.1
2558

2659
- [#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.
2760
- [#99](https://github.com/FuelLabs/sway-standards/pull/99) Fixes links and typos in the SRC-14 standard.
2861
- [#112](https://github.com/FuelLabs/sway-standards/pull/112) Fixes inline documentation code in the SRC-3 standard.
2962
- [#115](https://github.com/FuelLabs/sway-standards/pull/115) Hotfixes the Cargo.toml version to the v0.5.1 release.
3063

31-
#### Breaking
64+
### Breaking v0.5.1
3265

3366
- [#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:
3467

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "sway-standards"
3-
version = "0.5.1"
3+
version = "0.5.2"
44
edition = "2021"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml" alt="CI">
1010
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml/badge.svg" />
1111
</a>
12-
<a href="https://crates.io/crates/forc/0.60.0" alt="forc">
13-
<img src="https://img.shields.io/badge/forc-v0.60.0-orange" />
12+
<a href="https://crates.io/crates/forc/0.61.0" alt="forc">
13+
<img src="https://img.shields.io/badge/forc-v0.61.0-orange" />
1414
</a>
1515
<a href="./LICENSE" alt="forc">
1616
<img src="https://img.shields.io/github/license/FuelLabs/sway-standards" />
@@ -65,7 +65,7 @@ If you don't find what you're looking for, feel free to create an issue and prop
6565
To import a standard the following should be added to the project's `Forc.toml` file under `[dependencies]` with the most recent release:
6666

6767
```toml
68-
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.1" }
68+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.2" }
6969
```
7070

7171
> **NOTE:**
@@ -162,7 +162,7 @@ Example of a minimal SRC-14 implementation with no access control.
162162
Example of a SRC-14 implementation that also implements [SRC-5](https://docs.fuel.network/docs/sway-standards/src-5-ownership/).
163163

164164
> **Note**
165-
> All standards currently use `forc v0.60.0`.
165+
> All standards currently use `forc v0.61.0`.
166166
167167
<!-- TODO:
168168
## Contributing

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Standards in this repository may be in various stages of development. Use of dra
77
If you don't find what you're looking for, feel free to create an issue and propose a new standard!
88

99
> **Note**
10-
> All standards currently use `forc v0.60.0`.
10+
> All standards currently use `forc v0.61.0`.
1111
1212
## Using a standard
1313

1414
To import a standard the following should be added to the project's `Forc.toml` file under `[dependencies]` with the most recent release:
1515

1616
```toml
17-
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.1" }
17+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.2" }
1818
```
1919

2020
> **NOTE:**

examples/src14-simple-proxy/minimal/src/minimal.sw

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
contract;
22

33
use std::execution::run_external;
4-
use standards::src14::SRC14;
4+
use standards::src14::{SRC14, SRC14_TARGET_STORAGE};
55

6-
// use sha256("storage_SRC14") as base to avoid collisions
7-
#[namespace(SRC14)]
86
storage {
97
// target is at sha256("storage_SRC14_0")
108
target: ContractId = ContractId::zero(),

examples/src14-simple-proxy/owned/src/owned.sw

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ contract;
22

33
use std::execution::run_external;
44
use standards::src5::{AccessError, State};
5-
use standards::src14::{SRC14, SRC14Extension};
5+
use standards::src14::{SRC14, SRC14_TARGET_STORAGE, SRC14Extension};
66

77
/// The owner of this contract at deployment.
88
const INITIAL_OWNER: Identity = Identity::Address(Address::zero());
99

10-
// use sha256("storage_SRC14") as base to avoid collisions
11-
#[namespace(SRC14)]
1210
storage {
13-
// target is at sha256("storage_SRC14_0")
11+
proxy {
12+
// target is at sha256("storage_SRC14_0")
13+
owner: State = State::Initialized(INITIAL_OWNER),
14+
},
1415
target: ContractId = ContractId::zero(),
15-
owner: State = State::Initialized(INITIAL_OWNER),
1616
}
1717

1818
impl SRC14 for Contract {
@@ -31,7 +31,7 @@ impl SRC14 for Contract {
3131
impl SRC14Extension for Contract {
3232
#[storage(read)]
3333
fn proxy_owner() -> State {
34-
storage.owner.read()
34+
storage::proxy.owner.read()
3535
}
3636
}
3737

@@ -45,7 +45,7 @@ fn fallback() {
4545
#[storage(read)]
4646
fn only_owner() {
4747
require(
48-
storage
48+
storage::proxy
4949
.owner
5050
.read() == State::Initialized(msg_sender().unwrap()),
5151
AccessError::NotOwner,

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ impl SRC6 for Contract {
5050

5151
_mint(receiver, share_asset, share_asset_vault_sub_id, shares);
5252

53-
let mut vault_info = storage.vault_info.get(share_asset).read();
53+
let mut vault_info = match storage.vault_info.get(share_asset).try_read() {
54+
Some(vault_info) => vault_info,
55+
None => VaultInfo {
56+
managed_assets: 0,
57+
vault_sub_id,
58+
asset: underlying_asset,
59+
},
60+
};
5461
vault_info.managed_assets = vault_info.managed_assets + asset_amount;
5562
storage.vault_info.insert(share_asset, vault_info);
5663

@@ -81,6 +88,10 @@ impl SRC6 for Contract {
8188
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
8289
let assets = preview_withdraw(share_asset_id, shares);
8390

91+
let mut vault_info = storage.vault_info.get(share_asset_id).read();
92+
vault_info.managed_assets = vault_info.managed_assets - shares;
93+
storage.vault_info.insert(share_asset_id, vault_info);
94+
8495
_burn(share_asset_id, share_asset_vault_sub_id, shares);
8596

8697
transfer(receiver, underlying_asset, assets);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ impl SRC6 for Contract {
7878
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
7979
let assets = preview_withdraw(shares);
8080

81+
storage
82+
.managed_assets
83+
.write(storage.managed_assets.read() - shares);
84+
8185
_burn(share_asset_id, shares);
8286

8387
transfer(receiver, underlying_asset, assets);

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ impl SRC6 for Contract {
5151

5252
_mint(receiver, share_asset, share_asset_vault_sub_id, shares);
5353

54-
let mut vault_info = storage.vault_info.get(share_asset).read();
54+
let mut vault_info = match storage.vault_info.get(share_asset).try_read() {
55+
Some(vault_info) => vault_info,
56+
None => VaultInfo {
57+
managed_assets: 0,
58+
vault_sub_id,
59+
asset: underlying_asset,
60+
},
61+
};
5562
vault_info.managed_assets = vault_info.managed_assets + asset_amount;
5663
storage.vault_info.insert(share_asset, vault_info);
5764

@@ -82,6 +89,10 @@ impl SRC6 for Contract {
8289
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
8390
let assets = preview_withdraw(share_asset_id, shares);
8491

92+
let mut vault_info = storage.vault_info.get(share_asset_id).read();
93+
vault_info.managed_assets = vault_info.managed_assets - shares;
94+
storage.vault_info.insert(share_asset_id, vault_info);
95+
8596
_burn(share_asset_id, share_asset_vault_sub_id, shares);
8697

8798
transfer(receiver, underlying_asset, assets);

0 commit comments

Comments
 (0)