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

Release v0.5.2 #127

Merged
merged 16 commits into from
Aug 6, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
run: forc fmt --path standards --check

- name: Build All Standards
run: forc build --path standards
run: forc build --error-on-warnings --path standards

- name: Check Sway Formatting Examples
run: forc fmt --path examples --check
Expand Down
51 changes: 42 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,63 @@ 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/).

## [Version 0.5.1]
## [Unreleased]

### Added Unreleased

- Something new here 1
- Something new here 2

### Changed Unreleased

- Something changed here 1
- Something changed here 2

### Fixed Unreleased

- Some fix here 1
- Some fix here 2

### Breaking Unreleased

Description of the upcoming release here.
- Some breaking change here 1
- Some breaking change here 2

## [Version 0.5.2]

### Changed v0.5.2

- [#126](https://github.com/FuelLabs/sway-standards/pull/126) Prepares for v0.5.2 release.

### Fixed v0.5.2

- [#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.
- [#124](https://github.com/FuelLabs/sway-standards/pull/124) Fixes compiler warnings for libraries

## [Version 0.5.1]

### 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.
- [#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/).
- [#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.
- [#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
### 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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "sway-standards"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml" alt="CI">
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml/badge.svg" />
</a>
<a href="https://crates.io/crates/forc/0.60.0" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.60.0-orange" />
<a href="https://crates.io/crates/forc/0.61.0" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.61.0-orange" />
</a>
<a href="./LICENSE" alt="forc">
<img src="https://img.shields.io/github/license/FuelLabs/sway-standards" />
Expand Down Expand Up @@ -65,7 +65,7 @@ If you don't find what you're looking for, feel free to create an issue and prop
To import a standard the following should be added to the project's `Forc.toml` file under `[dependencies]` with the most recent release:

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

> **NOTE:**
Expand Down Expand Up @@ -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`.

<!-- TODO:
## Contributing
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Standards in this repository may be in various stages of development. Use of dra
If you don't find what you're looking for, feel free to create an issue and propose a new standard!

> **Note**
> All standards currently use `forc v0.60.0`.
> All standards currently use `forc v0.61.0`.

## Using a standard

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

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

> **NOTE:**
Expand Down
4 changes: 1 addition & 3 deletions examples/src14-simple-proxy/minimal/src/minimal.sw
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
contract;

use std::execution::run_external;
use standards::src14::SRC14;
use standards::src14::{SRC14, SRC14_TARGET_STORAGE};

// use sha256("storage_SRC14") as base to avoid collisions
#[namespace(SRC14)]
storage {
// target is at sha256("storage_SRC14_0")
target: ContractId = ContractId::zero(),
Expand Down
14 changes: 7 additions & 7 deletions examples/src14-simple-proxy/owned/src/owned.sw
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ contract;

use std::execution::run_external;
use standards::src5::{AccessError, State};
use standards::src14::{SRC14, SRC14Extension};
use standards::src14::{SRC14, SRC14_TARGET_STORAGE, SRC14Extension};

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

// use sha256("storage_SRC14") as base to avoid collisions
#[namespace(SRC14)]
storage {
// target is at sha256("storage_SRC14_0")
proxy {
// target is at sha256("storage_SRC14_0")
owner: State = State::Initialized(INITIAL_OWNER),
},
target: ContractId = ContractId::zero(),
owner: State = State::Initialized(INITIAL_OWNER),
}

impl SRC14 for Contract {
Expand All @@ -31,7 +31,7 @@ impl SRC14 for Contract {
impl SRC14Extension for Contract {
#[storage(read)]
fn proxy_owner() -> State {
storage.owner.read()
storage::proxy.owner.read()
}
}

Expand All @@ -45,7 +45,7 @@ fn fallback() {
#[storage(read)]
fn only_owner() {
require(
storage
storage::proxy
.owner
.read() == State::Initialized(msg_sender().unwrap()),
AccessError::NotOwner,
Expand Down
13 changes: 12 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 Expand Up @@ -81,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);
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
13 changes: 12 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 Expand Up @@ -82,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);
Expand Down
7 changes: 7 additions & 0 deletions standards/src/src10.sw
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ pub enum DepositType {
/// Enscapsultes metadata sent between the canonical chain and Fuel when a deposit is made.
struct DepositMessage {
/// The number of tokens.
#[allow(dead_code)]
pub amount: b256,
/// The user's address on the canonical chain.
#[allow(dead_code)]
pub from: b256,
/// The bridging target destination on the Fuel chain.
#[allow(dead_code)]
pub to: Identity,
/// The bridged token's address on the canonical chain.
#[allow(dead_code)]
pub token_address: b256,
/// The token's ID on the canonical chain.
#[allow(dead_code)]
pub token_id: b256,
/// The decimals of the token.
#[allow(dead_code)]
pub decimals: u8,
/// The type of deposit made.
#[allow(dead_code)]
pub deposit_type: DepositType,
}

Expand Down
Loading