-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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]>
- Loading branch information
1 parent
792639c
commit ba788b2
Showing
26 changed files
with
870 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,19 @@ on: | |
pull_request: | ||
|
||
jobs: | ||
test: | ||
spell-check: | ||
name: Spell Check | ||
uses: FuelLabs/github-actions/.github/workflows/mdbook-docs.yml@master | ||
with: | ||
docs-src-path: 'docs/src' | ||
spellcheck-config-path: 'docs/.spellcheck.yml' | ||
docs-src-path: "docs/src" | ||
spellcheck-config-path: "docs/.spellcheck.yml" | ||
|
||
link-check: | ||
name: Link Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run Markdown Link Check | ||
uses: gaurav-nelson/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[package] | ||
name = "sway-standards" | ||
version = "0.6.1" | ||
version = "0.6.2" | ||
edition = "2021" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SRC-15: Off-Chain Native Asset Metadata | ||
|
||
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. | ||
|
||
## Motivation | ||
|
||
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. | ||
|
||
## Prior Art | ||
|
||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
## Specification | ||
|
||
### Metadata Type | ||
|
||
The `Metadata` enum from the SRC-7 standard is also used to represent the metadata in the SRC-15 standard. | ||
|
||
### Logging | ||
|
||
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. | ||
|
||
#### SRC15MetadataEvent | ||
|
||
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. | ||
|
||
There SHALL be the following fields in the `SRC15MetadataEvent` struct: | ||
|
||
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` for the metadata. | ||
* `metadata`: The `metadata` field SHALL be used for the corresponding `Metadata` which represents the metadata of the asset. | ||
|
||
Example: | ||
|
||
```sway | ||
pub struct SRC15MetadataEvent { | ||
pub asset: AssetId, | ||
pub metadata: Metadata, | ||
} | ||
``` | ||
|
||
## Rationale | ||
|
||
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. | ||
|
||
## Backwards Compatibility | ||
|
||
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. | ||
|
||
## Security Considerations | ||
|
||
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. | ||
|
||
## Example Implementation | ||
|
||
### Single Native Asset | ||
|
||
Example of the SRC-15 implementation where metadata exists for only a single asset with one `SubId`. | ||
|
||
```sway | ||
{{#include ../examples/src15-offchain-metadata/single_asset/src/single_asset.sw}} | ||
``` | ||
|
||
### Multi Native Asset | ||
|
||
Example of the SRC-15 implementation where metadata exists for multiple assets with differing `SubId` values. | ||
|
||
```sway | ||
{{#include ../examples/src15-offchain-metadata/multi_asset/src/multi_asset.sw}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[workspace] | ||
members = ["single_asset", "multi_asset"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "multi_asset.sw" | ||
license = "Apache-2.0" | ||
name = "multi_src15_asset" | ||
|
||
[dependencies] | ||
standards = { path = "../../../standards" } |
Oops, something went wrong.