Skip to content

Commit

Permalink
Release v0.6.1 (#150)
Browse files Browse the repository at this point in the history
* 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

* Make the `SubId` an `Option` in SRC-3's `mint()` function  (#131)

* Update specifications to change SRC-3 mint sub_id to an Option

* Update SRC-3 standard for option in mint

* Update examples

* Udpate CHANGELOG

* Run formatter

* Fix spelling

* Add event logging to SRC-20 and SRC-7 standards (#130)

* Add event logging to SRC-20 and SRC-7 specification

* Add event logging structs to SRC-20 and SRC-7

* Update CHANGELOG

* Add inline docs to SRC-20 events

* Fix CI

* Require that logs of metadata are emitted even with contants

* Update standards with additional log and ordering

* Update examples to follow new specs

* Add custom word to spell checker

* Run formatter

* Fix markdown formatting

* Resolve warnings in examples

* Build CI with release

* Store srv7 metadata to storage

* Remove cancel in progress from CI

* Update name for TotalSupplyEvent

* Split examples into seperate workspace projects

* Prepare for v0.6.0 release

* Update CHANGELOG

* Resolve warnings in examples (#137)

* Resolve warnings

* Update CHANGELOG

* Run formatter

* Remove cancel in progress from CI

* Revert remove cancel in progress from CI

* fix max_depositable and max_withdrawable examples

---------

Co-authored-by: SwayStar123 <[email protected]>

* chore: update to forc 0.63.3 (#135)

* chore: update to forc 0.63.1

* chore: updated changelog

* Update to forc v0.63.3

---------

Co-authored-by: bitzoic <[email protected]>

* docs: update src14 storage recommendation and general typos (#136)

* chore: update to forc 0.63.1

* chore: updated changelog

* docs: update src14 and general typos

* Apply PR review comments

* Fix markdown

* Update CHANGELOG

* Improve CHANGELOG comment

---------

Co-authored-by: bitzoic <[email protected]>

* Add helper functions to SRC7 standard's `Metadata` (#144)

* Add helper functions to SRC7 standard

* Update CHANGELOG

* Remove metadata functions (#148)

* Fix Sway Standards inline docs (#142)

* Update sway standards inline docs

* Update CHANGELOG

* Fix typo

* Prepare for Sway-Standards `v0.6.1` release (#147)

* Prepare for Sway-Standards v0.6.1 release

* Update CHANGELOG

* Add helper functions to struct types and `Eq` implementations for all types (#149)

* Add helper functions to struct types and Eq implementations

* Add checks to enum types

* Update CHANGELOG

---------

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]>
  • Loading branch information
6 people authored Sep 10, 2024
1 parent 65e09f9 commit 792639c
Show file tree
Hide file tree
Showing 36 changed files with 2,825 additions and 386 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ concurrency:
env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.77.0
FORC_VERSION: 0.61.0
CORE_VERSION: 0.26.0
RUST_VERSION: 1.80.1
FORC_VERSION: 0.63.3
CORE_VERSION: 0.34.0
PATH_TO_SCRIPTS: .github/scripts

jobs:
Expand Down
30 changes: 26 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,48 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

Description of the upcoming release here.

### Added Unreleased
### Added

- Something new here 1
- Something new here 2

### Changed Unreleased
### Changed

- Something changed here 1
- Something changed here 2

### Fixed Unreleased
### Fixed

- Some fix here 1
- Some fix here 2

#### Breaking Unreleased
#### Breaking

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

## [Version 0.6.1]

Description of the upcoming release here.

### Added v0.6.1

- [#149](https://github.com/FuelLabs/sway-standards/pull/149) Adds struct field getters, `new()`, and `Eq` implementations to SRC-10's `DepositMessage` and `MetadataMessage` types and SRC-11's `SecurityInformation` type.
- [#149](https://github.com/FuelLabs/sway-standards/pull/149) Adds `Eq` implementation to SRC-5's `AccessError` error.
- [#149](https://github.com/FuelLabs/sway-standards/pull/149) Adds check functions and `Eq` implementation to SRC-5's `State` type and SRC-10's `DepositType` type.
- [#149](https://github.com/FuelLabs/sway-standards/pull/149) Adds struct field getters, `new()`, `log()`, and `Eq` implementations to SRC-6's `Deposit`, and `Withdraw` types, SRC-20's `SetNameEvent`, `SetSymbolEvent`, `SetDecimalsEvent`, and `TotalSupplyEvent` events, and SRC-7's `SetMetadataEvent` event.

### Changed v0.6.1

- [#135](https://github.com/FuelLabs/sway-standards/pull/135) Updates standards, examples and CI to latest forc 0.63.3.
- [#147](https://github.com/FuelLabs/sway-standards/pull/147) Prepares for the v0.6.1 release.

### Fixed v0.6.1

- [#137](https://github.com/FuelLabs/sway-standards/pull/137) Resolves warnings for SRC-6, SRC-14, and SRC-5 standard examples.
- [#136](https://github.com/FuelLabs/sway-standards/pull/136) Fixes SRC14 to recommend namespacing all non-standardized storage variables under the SRC14 namespace, fixes typos, and improves markdown in docs and inline documentation.
- [#142](https://github.com/FuelLabs/sway-standards/pull/142) Fixes errors in inline documentation for SRC-10, SRC-12, SRC-14, SRC-20, SRC-3, SRC-5, SRC-7 standards.

## [Version 0.6.0]

### Added v0.6.0
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.6.0"
version = "0.6.1"
edition = "2021"
12 changes: 6 additions & 6 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.61.0" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.61.0-orange" />
<a href="https://crates.io/crates/forc/0.63.3" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.63.3-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.6.0" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" }
```

> **NOTE:**
Expand Down Expand Up @@ -109,7 +109,7 @@ Example of the SRC-3 implementation where a contract mints multiple assets with

#### SRC-5; Ownership Examples

##### - [Uninitalized](./examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw)
##### - [Uninitialized](./examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw)

Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime.

Expand Down Expand Up @@ -162,12 +162,12 @@ 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.61.0`.
> All standards currently use `forc v0.63.3`.
<!-- TODO:
## Contributing
Check out the [book](https://fuellabs.github.io/sway-libs/book/index.html) for more info!
Check out the [book](https://fuellabs.github.io/sway-libs/book/index.html) for more info!
-->

> **Note**
Expand Down
4 changes: 2 additions & 2 deletions docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ WAV
OGA
glTF
GLB
Uninitalized
Uninitialized
upgradeability
SetMetadataEvent
SetNameEvent
SetSymbolEvent
SetDecimalsEvent
UpdateTotalSupplyEvent
UpdateTotalSupplyEvent
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.61.0`.
> All standards currently use `forc v0.63.3`.
## 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.6.0" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" }
```

> **NOTE:**
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-12-contract-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ There are no other standards that the SRC-12 requires compatibility.

## Security Considerations

This standard takes into consideration child contracts that are deployed with differentiating configurable values, however individual contract behaviors may be dependent on storage variables. As storage variables may change after the contract has been registered with the SRC-12 compliant contract, the standard suggests to check these values upon registration however it is not enforced.
This standard takes into consideration child contracts that are deployed with differentiating configurable values, however individual contract behaviours may be dependent on storage variables. As storage variables may change after the contract has been registered with the SRC-12 compliant contract, the standard suggests to check these values upon registration however it is not enforced.

## Example ABI

Expand Down
20 changes: 10 additions & 10 deletions docs/src/src-13-soulbound-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ We must also ensure every `Address` on Fuel has its own Predicate. This can be g
### Definitions

- **Soulbound Address Predicate** - The resulting predicate which owns assets on behalf of an `Address`.
- **Soulbound Address** - The computed `Address` of the *Soulbound Asset Predicate*.
- **Soulbound Asset** - Any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) sent to the *Soulbound Address*.
- **Soulbound Address** - The computed `Address` of the _Soulbound Asset Predicate_.
- **Soulbound Asset** - Any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) sent to the _Soulbound Address_.

### Soulbound Address Predicate Specification

- The *Soulbound Address Predicate* SHALL never spend the assets sent to its computed predicate `Address` or *Soulbound Address*.
- The *Soulbound Address Predicate* SHALL encode an `Address` of which it represents the soulbound address.
- The _Soulbound Address Predicate_ SHALL never spend the assets sent to its computed predicate `Address` or _Soulbound Address_.
- The _Soulbound Address Predicate_ SHALL encode an `Address` of which it represents the soulbound address.

Below we define the *Soulbound Address Predicate* where `ADDRESS` MUST be replaced with the `Address` of which the *Soulbound Address Predicate* represents.
Below we define the _Soulbound Address Predicate_ where `ADDRESS` MUST be replaced with the `Address` of which the _Soulbound Address Predicate_ represents.

```sway
predicate;
Expand All @@ -50,9 +50,9 @@ fn main() -> bool {

### Soulbound Address

The *Soulbound Address* is the *Soulbound Address Predicate*'s predicate address. A predicate's address(the bytecode root) is defined [here](https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/predicate-id.md).
The _Soulbound Address_ is the _Soulbound Address Predicate_'s predicate address. A predicate's address(the bytecode root) is defined [here](https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/predicate-id.md).

The *Soulbound Address* may be computed from the *Soulbound Address Predicate*'s bytecode both on-chain or off-chain. For off-chain computation, please refer to the fuels-rs [predicate docs](https://docs.fuel.network/docs/fuels-rs/predicates/). For on-chain computation, please refer to Sway-Lib's [Bytecode Library](https://docs.fuel.network/docs/sway-libs/bytecode/).
The _Soulbound Address_ may be computed from the _Soulbound Address Predicate_'s bytecode both on-chain or off-chain. For off-chain computation, please refer to the fuels-rs [predicate docs](https://docs.fuel.network/docs/fuels-rs/predicates/). For on-chain computation, please refer to Sway-Lib's [Bytecode Library](https://docs.fuel.network/docs/sway-libs/bytecode/).

## Rationale

Expand All @@ -66,13 +66,13 @@ This standard is compatible with Fuel's [Native Assets](https://docs.fuel.networ

This standard does not introduce any security concerns, as it does not call external contracts, nor does it define any mutations of the contract state.

It should however be noted that any Native Asset on the Fuel Network is not a Soulbound Asset until it is sent to a *Soulbound Address*.
It should however be noted that any Native Asset on the Fuel Network is not a Soulbound Asset until it is sent to a _Soulbound Address_.

## Example

The following example shows the *Soulbound Address Predicate* for the `0xe033369a522e3cd2fc19a5a705a7f119938027e8e287c0ec35b784e68dab2be6` `Address`.
The following example shows the _Soulbound Address Predicate_ for the `0xe033369a522e3cd2fc19a5a705a7f119938027e8e287c0ec35b784e68dab2be6` `Address`.

The resulting *Soulbound Address* is `0x7f28a538d06788a3d98bb72f4b41012d86abc4b0369ee5dedf56cfbaf245d609`. Any Native Assets sent to this address will become Soulbound Assets.
The resulting _Soulbound Address_ is `0x7f28a538d06788a3d98bb72f4b41012d86abc4b0369ee5dedf56cfbaf245d609`. Any Native Assets sent to this address will become Soulbound Assets.

```sway
predicate;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-14-simple-upgradeable-proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The FuelVM provides an `LDC` instruction that is used by Sway's `std::execution:
### Required Behavior

The proxy contract MUST maintain the address of its target in its storage at slot `0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55` (equivalent to `sha256("storage_SRC14_0")`).
It SHOULD base other proxy specific storage fields at `sha256("storage_SRC14")` to avoid collisions with target storage.
It SHOULD base other proxy specific storage fields in the `SRC14` namespace to avoid collisions with target storage.
It MAY have its storage definition overlap with that of its target if necessary.

The proxy contract MUST delegate any method call not part of its interface to the target contract.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-2-inline-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ This standard will improve security by providing developers with relevant inform
/// use ownable::Ownership;
///
/// storage {
/// owner: Ownership = Ownership::initalized(Identity::Address(Address::zero())),
/// owner: Ownership = Ownership::initialized(Identity::Address(Address::zero())),
/// }
///
/// fn foo() {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-5-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ abi SRC5 {

## Example Implementation

### Uninitalized
### Uninitialized

Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-6-vault.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ abi SRC6 {
#[storage(read)]
fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64;
#[storage(read)]
fn max_depositable(receiver: Identity, underlying_asset: AssetId, vault_sub_id: SubId) -> Option<u64>;
Expand Down
10 changes: 5 additions & 5 deletions docs/src/src-8-bridged-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,31 @@ impl SRC7 for Contract {
impl SRC20 for Contract {
fn total_assets() -> u64 {
1
}
}
fn total_supply(asset: AssetId) -> Option<u64> {
match asset {
match asset {
AssetId::default() => Option::Some(1),
_ => Option::None,
}
}
fn name(asset: AssetId) -> Option<String> {
match asset {
match asset {
AssetId::default() => Option::Some(String::from_ascii_str("Name")),
_ => Option::None,
}
}
fn symbol(asset: AssetId) -> Option<String> {
match asset {
match asset {
AssetId::default() => Option::Some(String::from_ascii_str("Symbol")),
_ => Option::None,
}
}
fn decimals(asset: AssetId) -> Option<u8> {
match asset {
match asset {
AssetId::default() => Option::Some(0u8),
_ => Option::None,
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-9-metadata-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ The key `link:contact` SHALL return a `String` variant of the asset's project co

#### `link:docs`

The key `link:docs` SHALL return a `String` variant of the asset's project documentation webpage.
The key `link:docs` SHALL return a `String` variant of the asset's project documentation webpage.

#### `link:forum`

Expand Down
16 changes: 11 additions & 5 deletions examples/src14-simple-proxy/minimal/src/minimal.sw
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@ use std::execution::run_external;
use standards::src14::{SRC14, SRC14_TARGET_STORAGE};

storage {
// target is at sha256("storage_SRC14_0")
target: ContractId = ContractId::zero(),
SRC14 {
/// The [ContractId] of the target contract.
///
/// # Additional Information
///
/// `target` is stored at sha256("storage_SRC14_0")
target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: ContractId = ContractId::zero(),
},
}

impl SRC14 for Contract {
#[storage(read, write)]
fn set_proxy_target(new_target: ContractId) {
storage.target.write(new_target);
storage::SRC14.target.write(new_target);
}

#[storage(read)]
fn proxy_target() -> Option<ContractId> {
storage.target.try_read()
storage::SRC14.target.try_read()
}
}

#[fallback]
#[storage(read)]
fn fallback() {
// pass through any other method call to the target
run_external(storage.target.read())
run_external(storage::SRC14.target.read())
}
22 changes: 14 additions & 8 deletions examples/src14-simple-proxy/owned/src/owned.sw
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,53 @@ use standards::src5::{AccessError, State};
use standards::src14::{SRC14, SRC14_TARGET_STORAGE, SRC14Extension};

/// The owner of this contract at deployment.
#[allow(dead_code)]
const INITIAL_OWNER: Identity = Identity::Address(Address::zero());

storage {
proxy {
// target is at sha256("storage_SRC14_0")
SRC14 {
/// The [ContractId] of the target contract.
///
/// # Additional Information
///
/// `target` is stored at sha256("storage_SRC14_0")
target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: ContractId = ContractId::zero(),
/// The [State] of the proxy owner.
owner: State = State::Initialized(INITIAL_OWNER),
},
target: ContractId = ContractId::zero(),
}

impl SRC14 for Contract {
#[storage(read, write)]
fn set_proxy_target(new_target: ContractId) {
only_owner();
storage.target.write(new_target);
storage::SRC14.target.write(new_target);
}

#[storage(read)]
fn proxy_target() -> Option<ContractId> {
storage.target.try_read()
storage::SRC14.target.try_read()
}
}

impl SRC14Extension for Contract {
#[storage(read)]
fn proxy_owner() -> State {
storage::proxy.owner.read()
storage::SRC14.owner.read()
}
}

#[fallback]
#[storage(read)]
fn fallback() {
// pass through any other method call to the target
run_external(storage.target.read())
run_external(storage::SRC14.target.read())
}

#[storage(read)]
fn only_owner() {
require(
storage::proxy
storage::SRC14
.owner
.read() == State::Initialized(msg_sender().unwrap()),
AccessError::NotOwner,
Expand Down
Loading

0 comments on commit 792639c

Please sign in to comment.