Skip to content

Commit

Permalink
Release v0.6.0 (#140)
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

* Add trailing line in 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 Aug 27, 2024
1 parent 270350e commit 65e09f9
Show file tree
Hide file tree
Showing 27 changed files with 691 additions and 54 deletions.
58 changes: 54 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
PATH_TO_SCRIPTS: .github/scripts

jobs:
build-sway-lib:
build-sway-standards:
runs-on: ubuntu-latest

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

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

build-examples:
runs-on: ubuntu-latest

strategy:
matrix:
project:
[
"examples/src3-mint-burn",
"examples/src5-ownership",
"examples/src6-vault",
"examples/src7-metadata",
"examples/src11-security-information",
"examples/src12-contract-factory",
"examples/src14-simple-proxy",
"examples/src20-native-asset",
]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true

- name: Init cache
uses: Swatinem/rust-cache@v1

- name: Install a modern linker (mold)
uses: rui314/setup-mold@v1

- name: Force Rust to use mold globally for compilation
run: |
touch ~/.cargo/config.toml
echo "[target.x86_64-unknown-linux-gnu]" > ~/.cargo/config.toml
echo 'linker = "clang"' >> ~/.cargo/config.toml
echo 'rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]' >> ~/.cargo/config.toml
- name: Install rustfmt
run: rustup component add rustfmt

- name: Install Fuel toolchain
uses: FuelLabs/[email protected]
with:
name: my-toolchain
components: forc@${{ env.FORC_VERSION }}, fuel-core@${{ env.CORE_VERSION }}

- name: Check Sway Formatting Examples
run: forc fmt --path examples --check
run: forc fmt --path ${{ matrix.project }} --check

- name: Build All Examples
run: forc build --path examples
run: forc build --path ${{ matrix.project }} --release
32 changes: 31 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.

### Added Unreleased

- Something new here 1
Expand All @@ -22,11 +24,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Some fix here 1
- Some fix here 2

### Breaking Unreleased
#### Breaking Unreleased

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

## [Version 0.6.0]

### Added v0.6.0

- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Adds the `SetNameEvent`, `SetSymbolEvent`, `SetDecimalsEvent` and `TotalSupplyEvent` to the SRC-20 standard.
- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Adds the `SetMetadataEvent` to the SRC-7 standard.

### Changed v0.6.0

- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Splits examples into seperate workspace projects for improved continuous integration.
- [#139](https://github.com/FuelLabs/sway-standards/pull/139) Prepares for the v0.6.0 release.

### Breaking v0.6.0

- [#131](https://github.com/FuelLabs/sway-standards/pull/131) Makes the SRC-3 `mint()` function's `SubId` argument an `Option`.

Before:

```sway
mint(Identity::Address(Address::zero()), SubId::zero(), 100);
```

After:

```sway
mint(Identity::Address(Address::zero()), Some(SubId::zero()), 100);
```

## [Version 0.5.2]

### Changed v0.5.2
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.2"
version = "0.6.0"
edition = "2021"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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.2" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.0" }
```

> **NOTE:**
Expand Down
7 changes: 6 additions & 1 deletion docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,9 @@ OGA
glTF
GLB
Uninitalized
upgradeability
upgradeability
SetMetadataEvent
SetNameEvent
SetSymbolEvent
SetDecimalsEvent
UpdateTotalSupplyEvent
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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.2" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.0" }
```

> **NOTE:**
Expand Down
87 changes: 87 additions & 0 deletions docs/src/src-20-native-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,93 @@ Non-Fungible Tokens (NFT) or Non-Fungible Assets on Fuel are Native Assets and t
* Non-Fungible Assets SHALL have a total supply of one per asset.
* Non-Fungible Assets SHALL have a decimal of `0u8`.

### Logging

The following logs MUST be implemented and emitted to follow the SRC-20 standard.

* IF a value is updated via a function call, a log MUST be emitted.
* IF a value is embedded in a contract as a constant, configurable, or other manner, an event MUST be emitted at least once.

#### SetNameEvent

The `SetNameEvent` MUST be emitted when the name of an asset has updated.

There SHALL be the following fields in the `SetNameEvent` struct:

* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
* `name`: The `name` field SHALL be used for the corresponding `Option<String>` which represents the name of the asset.
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the name of the asset.

Example:

```sway
pub struct SetNameEvent {
pub asset: AssetId,
pub name: Option<String>,
pub sender: Identity,
}
```

#### SetSymbolEvent

The `SetSymbolEvent` MUST be emitted when the symbol of an asset has updated.

There SHALL be the following fields in the `SetSymbolEvent` struct:

* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
* `symbol`: The `symbol` field SHALL be used for the corresponding `Option<String>` which represents the symbol of the asset.
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the symbol of the asset.

Example:

```sway
pub struct SetSymbolEvent {
pub asset: AssetId,
pub symbol: Option<String>,
pub sender: Identity,
}
```

#### SetDecimalsEvent

The `SetDecimalsEvent` MUST be emitted when the decimals of an asset has updated.

There SHALL be the following fields in the `SetDecimalsEvent` struct:

* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
* `decimals`: The `decimals` field SHALL be used for the corresponding `u8` which represents the decimals of the asset.
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the decimals of the asset.

Example:

```sway
pub struct SetDecimalsEvent {
pub asset: AssetId,
pub decimals: u8,
pub sender: Identity,
}
```

#### UpdateTotalSupplyEvent

The `UpdateTotalSupplyEvent` MUST be emitted when the total supply of an asset has updated.

There SHALL be the following fields in the `UpdateTotalSupplyEvent` struct:

* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
* `supply`: The `supply` field SHALL be used for the corresponding `u64` which represents the total supply of the asset.
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the total supply of the asset.

Example:

```sway
pub struct UpdateTotalSupplyEvent {
pub asset: AssetId,
pub supply: u64,
pub sender: Identity,
}
```

## Rationale

As the SRC-20 Native Asset Standard leverages Native Assets on Fuel, we do not require the implementation of certain functions such as transfer or approval. This is done directly within the FuelVM and there is no smart contract that requires updating of balances. As Fuel is UTXO based, any transfer events may be indexed on transaction receipts.
Expand Down
9 changes: 5 additions & 4 deletions docs/src/src-3-minting-and-burning.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ Minting and burning were initially added to the [SRC-20](./src-20-native-asset.m

The following functions MUST be implemented to follow the SRC-3 standard:

#### `fn mint(recipient: Identity, sub_id: SubId, amount: u64)`
#### `fn mint(recipient: Identity, sub_id: Option<SubId>, amount: u64)`

This function MUST mint `amount` coins with sub-identifier `sub_id` and transfer them to the `recipient`.
This function MUST mint `amount` coins with a sub-identifier and transfer them to the `recipient`.
This function MUST use the `sub_id` as the sub-identifier IF `sub_id` is `Some`, otherwise this function MUST assign a `SubId` if the `sub_id` argument is `None`.
This function MAY contain arbitrary conditions for minting, and revert if those conditions are not met.

##### Mint Arguments

* `recipient` - The `Identity` to which the newly minted asset is transferred to.
* `sub_id` - The sub-identifier of the asset to mint.
* `sub_id` - The sub-identifier of the asset to mint. If this is `None`, a `SubId` MUST be assigned.
* `amount` - The quantity of coins to mint.

#### `fn burn(sub_id: SubId, amount: u64)`
Expand Down Expand Up @@ -57,7 +58,7 @@ The burn function may also introduce a security consideration if the total suppl
```sway
abi MySRC3Asset {
#[storage(read, write)]
fn mint(recipient: Identity, sub_id: SubId, amount: u64);
fn mint(recipient: Identity, sub_id: Option<SubId>, amount: u64);
#[payable]
#[storage(read, write)]
fn burn(sub_id: SubId, amount: u64);
Expand Down
29 changes: 29 additions & 0 deletions docs/src/src-7-asset-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,35 @@ The `String` variant SHALL be used when the stored metadata for the correspondin

This function MUST return valid metadata for the corresponding `asset` and `key`, where the data is either a `B256`, `Bytes`, `Int`, or `String` variant. If the asset does not exist or no metadata exists, the function MUST return `None`.

### Logging

The following logs MUST be implemented and emitted to follow the SRC-7 standard.

* IF a value is updated via a function call, a log MUST be emitted.
* IF a value is embedded in a contract as a constant, configurable, or other manner, an event MUST be emitted at least once.

#### SetMetadataEvent

The `SetMetadataEvent` MUST be emitted when the metadata of an asset has updated.

There SHALL be the following fields in the `SetMetadataEvent` struct:

* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
* `metadata`: The `metadata` field SHALL be used for the corresponding `Option<Metadata>` which represents the metadata of the asset.
* `key`: The `key` field SHALL be used for the corresponding `String` which represents the key used for storing the metadata.
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the metadata of the asset.

Example:

```sway
pub struct SetMetadataEvent {
pub asset: AssetId,
pub metadata: Option<Metadata>,
pub key: String,
pub sender: Identity,
}
```

## Rationale

The SRC-7 standard should allow for data-rich assets to interact with one another in a safe manner.
Expand Down
20 changes: 0 additions & 20 deletions examples/Forc.toml

This file was deleted.

2 changes: 2 additions & 0 deletions examples/src11-security-information/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["hardcoded-information", "variable-information"]
2 changes: 2 additions & 0 deletions examples/src12-contract-factory/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["with_configurables", "without_configurables"]
2 changes: 2 additions & 0 deletions examples/src14-simple-proxy/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["owned", "minimal"]
2 changes: 2 additions & 0 deletions examples/src20-native-asset/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["single_asset", "multi_asset"]
Loading

0 comments on commit 65e09f9

Please sign in to comment.