Skip to content

Commit 65e09f9

Browse files
bitzoicSwayStar123IGI-111sdankelK1-R1
authored
Release v0.6.0 (#140)
* 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]>
1 parent 270350e commit 65e09f9

File tree

27 files changed

+691
-54
lines changed

27 files changed

+691
-54
lines changed

.github/workflows/ci.yaml

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
PATH_TO_SCRIPTS: .github/scripts
2222

2323
jobs:
24-
build-sway-lib:
24+
build-sway-standards:
2525
runs-on: ubuntu-latest
2626

2727
steps:
@@ -61,10 +61,60 @@ jobs:
6161
run: forc fmt --path standards --check
6262

6363
- name: Build All Standards
64-
run: forc build --error-on-warnings --path standards
64+
run: forc build --error-on-warnings --path standards --release
65+
66+
build-examples:
67+
runs-on: ubuntu-latest
68+
69+
strategy:
70+
matrix:
71+
project:
72+
[
73+
"examples/src3-mint-burn",
74+
"examples/src5-ownership",
75+
"examples/src6-vault",
76+
"examples/src7-metadata",
77+
"examples/src11-security-information",
78+
"examples/src12-contract-factory",
79+
"examples/src14-simple-proxy",
80+
"examples/src20-native-asset",
81+
]
82+
83+
steps:
84+
- name: Checkout repository
85+
uses: actions/checkout@v2
86+
87+
- name: Install Rust toolchain
88+
uses: actions-rs/toolchain@v1
89+
with:
90+
profile: minimal
91+
toolchain: ${{ env.RUST_VERSION }}
92+
override: true
93+
94+
- name: Init cache
95+
uses: Swatinem/rust-cache@v1
96+
97+
- name: Install a modern linker (mold)
98+
uses: rui314/setup-mold@v1
99+
100+
- name: Force Rust to use mold globally for compilation
101+
run: |
102+
touch ~/.cargo/config.toml
103+
echo "[target.x86_64-unknown-linux-gnu]" > ~/.cargo/config.toml
104+
echo 'linker = "clang"' >> ~/.cargo/config.toml
105+
echo 'rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]' >> ~/.cargo/config.toml
106+
107+
- name: Install rustfmt
108+
run: rustup component add rustfmt
109+
110+
- name: Install Fuel toolchain
111+
uses: FuelLabs/[email protected]
112+
with:
113+
name: my-toolchain
114+
components: forc@${{ env.FORC_VERSION }}, fuel-core@${{ env.CORE_VERSION }}
65115

66116
- name: Check Sway Formatting Examples
67-
run: forc fmt --path examples --check
117+
run: forc fmt --path ${{ matrix.project }} --check
68118

69119
- name: Build All Examples
70-
run: forc build --path examples
120+
run: forc build --path ${{ matrix.project }} --release

CHANGELOG.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
Description of the upcoming release here.
11+
1012
### Added Unreleased
1113

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

25-
### Breaking Unreleased
27+
#### Breaking Unreleased
2628

2729
- Some breaking change here 1
2830
- Some breaking change here 2
2931

32+
## [Version 0.6.0]
33+
34+
### Added v0.6.0
35+
36+
- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Adds the `SetNameEvent`, `SetSymbolEvent`, `SetDecimalsEvent` and `TotalSupplyEvent` to the SRC-20 standard.
37+
- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Adds the `SetMetadataEvent` to the SRC-7 standard.
38+
39+
### Changed v0.6.0
40+
41+
- [#130](https://github.com/FuelLabs/sway-standards/pull/130) Splits examples into seperate workspace projects for improved continuous integration.
42+
- [#139](https://github.com/FuelLabs/sway-standards/pull/139) Prepares for the v0.6.0 release.
43+
44+
### Breaking v0.6.0
45+
46+
- [#131](https://github.com/FuelLabs/sway-standards/pull/131) Makes the SRC-3 `mint()` function's `SubId` argument an `Option`.
47+
48+
Before:
49+
50+
```sway
51+
mint(Identity::Address(Address::zero()), SubId::zero(), 100);
52+
```
53+
54+
After:
55+
56+
```sway
57+
mint(Identity::Address(Address::zero()), Some(SubId::zero()), 100);
58+
```
59+
3060
## [Version 0.5.2]
3161

3262
### Changed v0.5.2

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.2"
3+
version = "0.6.0"
44
edition = "2021"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.2" }
68+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.0" }
6969
```
7070

7171
> **NOTE:**

docs/spell-check-custom-words.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,9 @@ OGA
260260
glTF
261261
GLB
262262
Uninitalized
263-
upgradeability
263+
upgradeability
264+
SetMetadataEvent
265+
SetNameEvent
266+
SetSymbolEvent
267+
SetDecimalsEvent
268+
UpdateTotalSupplyEvent

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you don't find what you're looking for, feel free to create an issue and prop
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.2" }
17+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.0" }
1818
```
1919

2020
> **NOTE:**

docs/src/src-20-native-asset.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,93 @@ Non-Fungible Tokens (NFT) or Non-Fungible Assets on Fuel are Native Assets and t
4747
* Non-Fungible Assets SHALL have a total supply of one per asset.
4848
* Non-Fungible Assets SHALL have a decimal of `0u8`.
4949

50+
### Logging
51+
52+
The following logs MUST be implemented and emitted to follow the SRC-20 standard.
53+
54+
* IF a value is updated via a function call, a log MUST be emitted.
55+
* IF a value is embedded in a contract as a constant, configurable, or other manner, an event MUST be emitted at least once.
56+
57+
#### SetNameEvent
58+
59+
The `SetNameEvent` MUST be emitted when the name of an asset has updated.
60+
61+
There SHALL be the following fields in the `SetNameEvent` struct:
62+
63+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
64+
* `name`: The `name` field SHALL be used for the corresponding `Option<String>` which represents the name of the asset.
65+
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the name of the asset.
66+
67+
Example:
68+
69+
```sway
70+
pub struct SetNameEvent {
71+
pub asset: AssetId,
72+
pub name: Option<String>,
73+
pub sender: Identity,
74+
}
75+
```
76+
77+
#### SetSymbolEvent
78+
79+
The `SetSymbolEvent` MUST be emitted when the symbol of an asset has updated.
80+
81+
There SHALL be the following fields in the `SetSymbolEvent` struct:
82+
83+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
84+
* `symbol`: The `symbol` field SHALL be used for the corresponding `Option<String>` which represents the symbol of the asset.
85+
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the symbol of the asset.
86+
87+
Example:
88+
89+
```sway
90+
pub struct SetSymbolEvent {
91+
pub asset: AssetId,
92+
pub symbol: Option<String>,
93+
pub sender: Identity,
94+
}
95+
```
96+
97+
#### SetDecimalsEvent
98+
99+
The `SetDecimalsEvent` MUST be emitted when the decimals of an asset has updated.
100+
101+
There SHALL be the following fields in the `SetDecimalsEvent` struct:
102+
103+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
104+
* `decimals`: The `decimals` field SHALL be used for the corresponding `u8` which represents the decimals of the asset.
105+
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the decimals of the asset.
106+
107+
Example:
108+
109+
```sway
110+
pub struct SetDecimalsEvent {
111+
pub asset: AssetId,
112+
pub decimals: u8,
113+
pub sender: Identity,
114+
}
115+
```
116+
117+
#### UpdateTotalSupplyEvent
118+
119+
The `UpdateTotalSupplyEvent` MUST be emitted when the total supply of an asset has updated.
120+
121+
There SHALL be the following fields in the `UpdateTotalSupplyEvent` struct:
122+
123+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
124+
* `supply`: The `supply` field SHALL be used for the corresponding `u64` which represents the total supply of the asset.
125+
* `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.
126+
127+
Example:
128+
129+
```sway
130+
pub struct UpdateTotalSupplyEvent {
131+
pub asset: AssetId,
132+
pub supply: u64,
133+
pub sender: Identity,
134+
}
135+
```
136+
50137
## Rationale
51138

52139
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.

docs/src/src-3-minting-and-burning.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ Minting and burning were initially added to the [SRC-20](./src-20-native-asset.m
1616

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

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

21-
This function MUST mint `amount` coins with sub-identifier `sub_id` and transfer them to the `recipient`.
21+
This function MUST mint `amount` coins with a sub-identifier and transfer them to the `recipient`.
22+
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`.
2223
This function MAY contain arbitrary conditions for minting, and revert if those conditions are not met.
2324

2425
##### Mint Arguments
2526

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

3031
#### `fn burn(sub_id: SubId, amount: u64)`
@@ -57,7 +58,7 @@ The burn function may also introduce a security consideration if the total suppl
5758
```sway
5859
abi MySRC3Asset {
5960
#[storage(read, write)]
60-
fn mint(recipient: Identity, sub_id: SubId, amount: u64);
61+
fn mint(recipient: Identity, sub_id: Option<SubId>, amount: u64);
6162
#[payable]
6263
#[storage(read, write)]
6364
fn burn(sub_id: SubId, amount: u64);

docs/src/src-7-asset-metadata.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,35 @@ The `String` variant SHALL be used when the stored metadata for the correspondin
4444

4545
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`.
4646

47+
### Logging
48+
49+
The following logs MUST be implemented and emitted to follow the SRC-7 standard.
50+
51+
* IF a value is updated via a function call, a log MUST be emitted.
52+
* IF a value is embedded in a contract as a constant, configurable, or other manner, an event MUST be emitted at least once.
53+
54+
#### SetMetadataEvent
55+
56+
The `SetMetadataEvent` MUST be emitted when the metadata of an asset has updated.
57+
58+
There SHALL be the following fields in the `SetMetadataEvent` struct:
59+
60+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` of the asset has been updated.
61+
* `metadata`: The `metadata` field SHALL be used for the corresponding `Option<Metadata>` which represents the metadata of the asset.
62+
* `key`: The `key` field SHALL be used for the corresponding `String` which represents the key used for storing the metadata.
63+
* `sender`: The `sender` field SHALL be used for the corresponding `Identity` which made the function call that has updated the metadata of the asset.
64+
65+
Example:
66+
67+
```sway
68+
pub struct SetMetadataEvent {
69+
pub asset: AssetId,
70+
pub metadata: Option<Metadata>,
71+
pub key: String,
72+
pub sender: Identity,
73+
}
74+
```
75+
4776
## Rationale
4877

4978
The SRC-7 standard should allow for data-rich assets to interact with one another in a safe manner.

examples/Forc.toml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)