Skip to content

Commit ba788b2

Browse files
bitzoicSwayStar123IGI-111sdankelK1-R1
authored
Release v0.6.2 (#164)
* 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 * init * remove unused param from SetSRC20Data impl * fix import * fix some get calls * fmt 2 * unwrap -> read * remove get from sasbv * init * ujpdate changelog pr number * resolve comments * fmt * get(asset) for maps * add write permission * move changelog * add sotrage writes to set_src20_data * add changelog * add write to storage annotation * Update abi names in standards docs (#154) * Update abi names in standards docs * Update CHANGELOG * Rename SRC-7 to Onchain Native Asset Metadata Standard (#157) * Update SRC-7 to Onchain Native Asset Metadata Standard * Add onchain to spellcheck * Update CHANGELOG * Fix typo in SRC-7 inline docs (#160) * Fix typo in SRC-7 inline docs * Update CHANGELOG * docs: Add CI link check (#162) * add * r * r * SRC-15; Offchain Metadata Standard (#159) * Create SRC-15 specifications * Create SRC-15 standard * Create SRC-15 examples * Add SRC-15 examples to CI * Update CHANGELOG * Run formatter * Fix markdown * Update custom words spellcheck * Remove sender and add nonce to SRC15 event * Update standards and examples with nonce * Resolve review comments * Add comment on restricting who may emit * Remove nonce from SRC-15 log * Update master from v0.6.1 to v0.6.2 (#163) * Update from v0.6.1 to v0.6.2 * Update CHANGELOG * Add PR #162 * Resolve merge conflicts * Resolve merge conflicts --------- 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]> Co-authored-by: Call Delegation <[email protected]>
1 parent 792639c commit ba788b2

File tree

26 files changed

+870
-47
lines changed

26 files changed

+870
-47
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
"examples/src11-security-information",
7878
"examples/src12-contract-factory",
7979
"examples/src14-simple-proxy",
80+
"examples/src15-offchain-metadata",
8081
"examples/src20-native-asset",
8182
]
8283

.github/workflows/docs.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ on:
44
pull_request:
55

66
jobs:
7-
test:
7+
spell-check:
8+
name: Spell Check
89
uses: FuelLabs/github-actions/.github/workflows/mdbook-docs.yml@master
910
with:
10-
docs-src-path: 'docs/src'
11-
spellcheck-config-path: 'docs/.spellcheck.yml'
11+
docs-src-path: "docs/src"
12+
spellcheck-config-path: "docs/.spellcheck.yml"
13+
14+
link-check:
15+
name: Link Check
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v3
20+
21+
- name: Run Markdown Link Check
22+
uses: gaurav-nelson/[email protected]

CHANGELOG.md

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

88
## [Unreleased]
99

10-
Description of the upcoming release here.
11-
1210
### Added
1311

1412
- Something new here 1
@@ -24,14 +22,39 @@ Description of the upcoming release here.
2422
- Some fix here 1
2523
- Some fix here 2
2624

27-
#### Breaking
25+
### Breaking
2826

2927
- Some breaking change here 1
3028
- Some breaking change here 2
3129

32-
## [Version 0.6.1]
30+
## [Version 0.6.2]
31+
32+
### New Standards v0.6.2
33+
34+
- [#159](https://github.com/FuelLabs/sway-standards/pull/159) Defines the SRC-15; Offchain Metadata Standard.
35+
36+
### Added v0.6.2
37+
38+
- [#152](https://github.com/FuelLabs/sway-standards/pull/152) Adds inline documentation examples to the SRC-6 standard.
39+
- [#159](https://github.com/FuelLabs/sway-standards/pull/159) Adds the SRC-15 standard files and docs.
40+
- [#162](https://github.com/FuelLabs/sway-standards/pull/162) Adds link checker to CI.
41+
42+
### Changed v0.6.2
3343

34-
Description of the upcoming release here.
44+
- [#154](https://github.com/FuelLabs/sway-standards/pull/154) Updates the examples in the standards specififcations to use the offical abi name.
45+
- [#157](https://github.com/FuelLabs/sway-standards/pull/157) Updates the name of the SRC-7 standard to "Onchain Native Asset Metadata Standard".
46+
- [#163](https://github.com/FuelLabs/sway-standards/pull/163) Prepares for the v0.6.2 release.
47+
48+
### Fixed v0.6.2
49+
50+
- [#153](https://github.com/FuelLabs/sway-standards/pull/153) Actually write to storage in `set_src20_data()` in the SRC-20 multi asset example.
51+
- [#160](https://github.com/FuelLabs/sway-standards/pull/160) Fixes a typo in the SRC-7 inline docs.
52+
53+
#### Breaking v0.6.2
54+
55+
- None
56+
57+
## [Version 0.6.1]
3558

3659
### Added v0.6.1
3760

@@ -50,6 +73,8 @@ Description of the upcoming release here.
5073
- [#137](https://github.com/FuelLabs/sway-standards/pull/137) Resolves warnings for SRC-6, SRC-14, and SRC-5 standard examples.
5174
- [#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.
5275
- [#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.
76+
- [#151](https://github.com/FuelLabs/sway-standards/pull/151) Fixes SRC-6 standard examples conform to the latest SRC-20 spec of logging values after updates.
77+
- [#151](https://github.com/FuelLabs/sway-standards/pull/151) Formats code of SRC-6 examples, and fixes some comments.
5378

5479
## [Version 0.6.0]
5580

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

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</p>
77

88
<p align="center">
9-
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml" alt="CI">
10-
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yml/badge.svg" />
9+
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml" alt="CI">
10+
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml/badge.svg" />
1111
</a>
1212
<a href="https://crates.io/crates/forc/0.63.3" alt="forc">
1313
<img src="https://img.shields.io/badge/forc-v0.63.3-orange" />
@@ -37,7 +37,7 @@ If you don't find what you're looking for, feel free to create an issue and prop
3737

3838
- [SRC-20; Native Asset Standard](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) defines the implementation of a standard API for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) using the Sway Language.
3939
- [SRC-3; Mint and Burn](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) is used to enable mint and burn functionality for fungible assets.
40-
- [SRC-7; Arbitrary Asset Metadata Standard](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
40+
- [SRC-7; Onchain Asset Metadata Standard](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
4141
- [SRC-9; Metadata Keys Standard](https://docs.fuel.network/docs/sway-standards/src-9-metadata-keys/) is used to store standardized metadata keys for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) in combination with the SRC-7 standard.
4242
- [SRC-6; Vault Standard](https://docs.fuel.network/docs/sway-standards/src-6-vault/) defines the implementation of a standard API for asset vaults developed in Sway.
4343
- [SRC-13; Soulbound Address](https://docs.fuel.network/docs/sway-standards/src-13-soulbound-address/) provides a predicate interface to lock [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) as soulbound.
@@ -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.6.1" }
68+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.2" }
6969
```
7070

7171
> **NOTE:**

docs/spell-check-custom-words.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,8 @@ SetNameEvent
266266
SetSymbolEvent
267267
SetDecimalsEvent
268268
UpdateTotalSupplyEvent
269+
Onchain
270+
onchain
271+
Offchain
272+
offchain
273+
MetadataEvent

docs/src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
- [SRC-3: Minting and Burning](./src-3-minting-and-burning.md)
77
- [SRC-5: Ownership](./src-5-ownership.md)
88
- [SRC-6: Vault](./src-6-vault.md)
9-
- [SRC-7: Asset Metadata](./src-7-asset-metadata.md)
9+
- [SRC-7: Onchain Asset Metadata](./src-7-asset-metadata.md)
1010
- [SRC-8: Bridged Asset](./src-8-bridged-asset.md)
1111
- [SRC-9: Metadata Keys](./src-9-metadata-keys.md)
1212
- [SRC-10: Native Bridge](./src-10-native-bridge.md)
1313
- [SRC-11: Security Information](./src-11-security-information.md)
1414
- [SRC-12: Contract Factory](./src-12-contract-factory.md)
1515
- [SRC-13: Soulbound Address](./src-13-soulbound-address.md)
1616
- [SRC-14: Simple Upgradeable Contract](./src-14-simple-upgradeable-proxies.md)
17+
- [SRC-15: Offchain Asset Metadata](./src-15-offchain-asset-metadata.md)
1718
- [SRC-20: Native Asset](./src-20-native-asset.md)

docs/src/index.md

Lines changed: 3 additions & 2 deletions
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.6.1" }
17+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.2" }
1818
```
1919

2020
> **NOTE:**
@@ -38,10 +38,11 @@ use standards::src20::SRC20;
3838

3939
- [SRC-20; Native Asset Standard](./src-20-native-asset.md) defines the implementation of a standard API for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) using the Sway Language.
4040
- [SRC-3; Mint and Burn](./src-3-minting-and-burning.md) is used to enable mint and burn functionality for fungible assets.
41-
- [SRC-7; Arbitrary Asset Metadata Standard](./src-7-asset-metadata.md) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
41+
- [SRC-7; Onchain Asset Metadata Standard](./src-7-asset-metadata.md) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
4242
- [SRC-9; Metadata Keys Standard](./src-9-metadata-keys.md) is used to store standardized metadata keys for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) in combination with the SRC-7 standard.
4343
- [SRC-6; Vault Standard](./src-6-vault.md) defines the implementation of a standard API for asset vaults developed in Sway.
4444
- [SRC-13; Soulbound Address](./src-13-soulbound-address.md) defines the implementation of a soulbound address.
45+
- [SRC-15; Offchain Asset Metadata Standard](./src-15-offchain-asset-metadata.md) is used to associated metadata with [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) offchain.
4546

4647
### Security and Access Control
4748

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SRC-15: Off-Chain Native Asset Metadata
2+
3+
The following standard attempts to define arbitrary metadata for any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) that is not required by other contracts onchain, in a stateless manner. Any contract that implements the SRC-15 standard MUST implement the [SRC-20](./src-20-native-asset.md) standard.
4+
5+
## Motivation
6+
7+
The SRC-15 standard seeks to enable data-rich assets on the Fuel Network while maintaining a stateless solution. All metadata queries are done off-chain using the indexer.
8+
9+
## Prior Art
10+
11+
The SRC-7 standard exists prior to the SRC-15 standard and is a stateful solution. The SRC-15 builds off the SRC-7 standard by using the `Metadata` enum however provides a stateless solution.
12+
13+
The use of generic metadata was originally found in the Sway-Lib's [NFT Library](https://github.com/FuelLabs/sway-libs/tree/v0.12.0/libs/nft) which did not use Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). This library has since been deprecated.
14+
15+
A previous definition for a metadata standard was written in the original edit of the now defunct [SRC-721](https://github.com/FuelLabs/sway-standards/issues/2). This has since been replaced with the [SRC-20](./src-20-native-asset.md) standard as `SubId` was introduced to enable multiple assets to be minted from a single contract.
16+
17+
## Specification
18+
19+
### Metadata Type
20+
21+
The `Metadata` enum from the SRC-7 standard is also used to represent the metadata in the SRC-15 standard.
22+
23+
### Logging
24+
25+
The following logs MUST be implemented and emitted to follow the SRC-15 standard. Logging MUST be emitted from the contract which minted the asset.
26+
27+
#### SRC15MetadataEvent
28+
29+
The `SRC15MetadataEvent` MUST be emitted at least once for each distinct piece of metadata. The latest emitted `SRC15MetadataEvent` is determined to be the current metadata.
30+
31+
There SHALL be the following fields in the `SRC15MetadataEvent` struct:
32+
33+
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` for the metadata.
34+
* `metadata`: The `metadata` field SHALL be used for the corresponding `Metadata` which represents the metadata of the asset.
35+
36+
Example:
37+
38+
```sway
39+
pub struct SRC15MetadataEvent {
40+
pub asset: AssetId,
41+
pub metadata: Metadata,
42+
}
43+
```
44+
45+
## Rationale
46+
47+
The SRC-15 standard allows for data-rich assets in a stateless manner by associating an asset with some metadata that may later be fetched by the indexer.
48+
49+
## Backwards Compatibility
50+
51+
This standard is compatible with Fuel's [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) and the [SRC-20](./src-20-native-asset.md) standard. This standard is also compatible with the SRC-7 standard which defines a stateful solution. It also maintains compatibility with existing standards in other ecosystems.
52+
53+
## Security Considerations
54+
55+
When indexing for SRC-15 metadata, developers should confirm that the contract that emitted the `SRC15MetadataEvent` is also the contract that minted the asset that the metadata associates with. Additionally, restrictions via access control on who may emit the Metadata should be considered.
56+
57+
## Example Implementation
58+
59+
### Single Native Asset
60+
61+
Example of the SRC-15 implementation where metadata exists for only a single asset with one `SubId`.
62+
63+
```sway
64+
{{#include ../examples/src15-offchain-metadata/single_asset/src/single_asset.sw}}
65+
```
66+
67+
### Multi Native Asset
68+
69+
Example of the SRC-15 implementation where metadata exists for multiple assets with differing `SubId` values.
70+
71+
```sway
72+
{{#include ../examples/src15-offchain-metadata/multi_asset/src/multi_asset.sw}}
73+
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ This standard does not introduce any security concerns, as it does not call exte
151151
## Example ABI
152152

153153
```sway
154-
abi MyAsset {
154+
abi SRC20 {
155155
#[storage(read)]
156156
fn total_assets() -> u64;
157157
#[storage(read)]

0 commit comments

Comments
 (0)