Skip to content

Commit

Permalink
Release v0.6.2 (#164)
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

* 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
7 people authored Jan 6, 2025
1 parent 792639c commit ba788b2
Show file tree
Hide file tree
Showing 26 changed files with 870 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
"examples/src11-security-information",
"examples/src12-contract-factory",
"examples/src14-simple-proxy",
"examples/src15-offchain-metadata",
"examples/src20-native-asset",
]

Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
35 changes: 30 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.

### Added

- Something new here 1
Expand All @@ -24,14 +22,39 @@ Description of the upcoming release here.
- Some fix here 1
- Some fix here 2

#### Breaking
### Breaking

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

## [Version 0.6.1]
## [Version 0.6.2]

### New Standards v0.6.2

- [#159](https://github.com/FuelLabs/sway-standards/pull/159) Defines the SRC-15; Offchain Metadata Standard.

### Added v0.6.2

- [#152](https://github.com/FuelLabs/sway-standards/pull/152) Adds inline documentation examples to the SRC-6 standard.
- [#159](https://github.com/FuelLabs/sway-standards/pull/159) Adds the SRC-15 standard files and docs.
- [#162](https://github.com/FuelLabs/sway-standards/pull/162) Adds link checker to CI.

### Changed v0.6.2

Description of the upcoming release here.
- [#154](https://github.com/FuelLabs/sway-standards/pull/154) Updates the examples in the standards specififcations to use the offical abi name.
- [#157](https://github.com/FuelLabs/sway-standards/pull/157) Updates the name of the SRC-7 standard to "Onchain Native Asset Metadata Standard".
- [#163](https://github.com/FuelLabs/sway-standards/pull/163) Prepares for the v0.6.2 release.

### Fixed v0.6.2

- [#153](https://github.com/FuelLabs/sway-standards/pull/153) Actually write to storage in `set_src20_data()` in the SRC-20 multi asset example.
- [#160](https://github.com/FuelLabs/sway-standards/pull/160) Fixes a typo in the SRC-7 inline docs.

#### Breaking v0.6.2

- None

## [Version 0.6.1]

### Added v0.6.1

Expand All @@ -50,6 +73,8 @@ Description of the upcoming release here.
- [#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.
- [#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.
- [#151](https://github.com/FuelLabs/sway-standards/pull/151) Formats code of SRC-6 examples, and fixes some comments.

## [Version 0.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.1"
version = "0.6.2"
edition = "2021"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</p>

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

- [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.
- [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.
- [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).
- [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).
- [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.
- [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.
- [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.
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.1" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.2" }
```

> **NOTE:**
Expand Down
5 changes: 5 additions & 0 deletions docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,8 @@ SetNameEvent
SetSymbolEvent
SetDecimalsEvent
UpdateTotalSupplyEvent
Onchain
onchain
Offchain
offchain
MetadataEvent
3 changes: 2 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
- [SRC-3: Minting and Burning](./src-3-minting-and-burning.md)
- [SRC-5: Ownership](./src-5-ownership.md)
- [SRC-6: Vault](./src-6-vault.md)
- [SRC-7: Asset Metadata](./src-7-asset-metadata.md)
- [SRC-7: Onchain Asset Metadata](./src-7-asset-metadata.md)
- [SRC-8: Bridged Asset](./src-8-bridged-asset.md)
- [SRC-9: Metadata Keys](./src-9-metadata-keys.md)
- [SRC-10: Native Bridge](./src-10-native-bridge.md)
- [SRC-11: Security Information](./src-11-security-information.md)
- [SRC-12: Contract Factory](./src-12-contract-factory.md)
- [SRC-13: Soulbound Address](./src-13-soulbound-address.md)
- [SRC-14: Simple Upgradeable Contract](./src-14-simple-upgradeable-proxies.md)
- [SRC-15: Offchain Asset Metadata](./src-15-offchain-asset-metadata.md)
- [SRC-20: Native Asset](./src-20-native-asset.md)
5 changes: 3 additions & 2 deletions 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.6.1" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.2" }
```

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

- [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.
- [SRC-3; Mint and Burn](./src-3-minting-and-burning.md) is used to enable mint and burn functionality for fungible assets.
- [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).
- [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).
- [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.
- [SRC-6; Vault Standard](./src-6-vault.md) defines the implementation of a standard API for asset vaults developed in Sway.
- [SRC-13; Soulbound Address](./src-13-soulbound-address.md) defines the implementation of a soulbound address.
- [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.

### Security and Access Control

Expand Down
73 changes: 73 additions & 0 deletions docs/src/src-15-offchain-asset-metadata.md
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}}
```
2 changes: 1 addition & 1 deletion docs/src/src-20-native-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ This standard does not introduce any security concerns, as it does not call exte
## Example ABI

```sway
abi MyAsset {
abi SRC20 {
#[storage(read)]
fn total_assets() -> u64;
#[storage(read)]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-3-minting-and-burning.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The burn function may also introduce a security consideration if the total suppl
## Example ABI

```sway
abi MySRC3Asset {
abi SRC3 {
#[storage(read, write)]
fn mint(recipient: Identity, sub_id: Option<SubId>, amount: u64);
#[payable]
Expand Down
12 changes: 6 additions & 6 deletions docs/src/src-7-asset-metadata.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SRC-7: Arbitrary Native Asset Metadata
# SRC-7: Onchain Native Asset Metadata

The following standard attempts to define the retrieval of on-chain arbitrary metadata for any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). Any contract that implements the SRC-7 standard MUST implement the [SRC-20](./src-20-native-asset.md) standard.
The following standard attempts to define the retrieval of on-chain arbitrary metadata for any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets). This standard should be used if a stateful approach is needed. Any contract that implements the SRC-7 standard MUST implement the [SRC-20](./src-20-native-asset.md) standard.

## Motivation

The SRC-7 standard seeks to enable data-rich assets on the Fuel Network while maintaining compatibility between multiple assets minted by the same contract. The standard ensures type safety with the use of an `enum` and an `Option`. All metadata queries are done through a single function to facilitate cross-contract calls.
The SRC-7 standard seeks to enable stateful data-rich assets on the Fuel Network while maintaining compatibility between multiple assets minted by the same contract. The standard ensures type safety with the use of an `enum` and an `Option`. All metadata queries are done through a single function to facilitate cross-contract calls.

## Prior Art

Expand Down Expand Up @@ -57,7 +57,7 @@ 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.
* `asset`: The `asset` field SHALL be used for the corresponding `AssetId` for the asset that 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.
Expand All @@ -75,7 +75,7 @@ pub struct SetMetadataEvent {

## Rationale

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

## Backwards Compatibility

Expand All @@ -88,7 +88,7 @@ This standard does not introduce any security concerns, as it does not call exte
## Example ABI

```sway
abi SRC7Metadata {
abi SRC7 {
#[storage(read)]
fn metadata(asset: AssetId, key: String) -> Option<Metadata>;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/src15-offchain-metadata/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["single_asset", "multi_asset"]
8 changes: 8 additions & 0 deletions examples/src15-offchain-metadata/multi_asset/Forc.toml
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" }
Loading

0 comments on commit ba788b2

Please sign in to comment.