From d26404127419bc13674af8786916039208203f98 Mon Sep 17 00:00:00 2001 From: K1-R1 <77465250+K1-R1@users.noreply.github.com> Date: Fri, 30 Aug 2024 06:58:25 +0100 Subject: [PATCH] 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 --- CHANGELOG.md | 2 +- README.md | 2 +- docs/spell-check-custom-words.txt | 4 ++-- docs/src/src-12-contract-factory.md | 2 +- docs/src/src-13-soulbound-address.md | 20 +++++++++---------- docs/src/src-14-simple-upgradeable-proxies.md | 2 +- docs/src/src-2-inline-documentation.md | 2 +- docs/src/src-5-ownership.md | 2 +- docs/src/src-6-vault.md | 2 +- docs/src/src-8-bridged-asset.md | 10 +++++----- docs/src/src-9-metadata-keys.md | 2 +- .../src/uninitialized_example.sw | 2 +- standards/src/src14.sw | 2 +- standards/src/src5.sw | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf67050..49b5fbb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,11 +17,11 @@ Description of the upcoming release here. ### Changed Unreleased - [#135](https://github.com/FuelLabs/sway-standards/pull/135) Updates standards, examples and CI to latest forc 0.63.3. -- Something changed here 2 ### Fixed Unreleased - [#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. #### Breaking Unreleased diff --git a/README.md b/README.md index c8b2a985..2f22af90 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Example of the SRC-3 implementation where a contract mints multiple assets with #### SRC-5; Ownership Examples -##### - [Uninitalized](./examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw) +##### - [Uninitialized](./examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw) Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime. diff --git a/docs/spell-check-custom-words.txt b/docs/spell-check-custom-words.txt index e2cb87cd..65384a7b 100644 --- a/docs/spell-check-custom-words.txt +++ b/docs/spell-check-custom-words.txt @@ -259,10 +259,10 @@ WAV OGA glTF GLB -Uninitalized +Uninitialized upgradeability SetMetadataEvent SetNameEvent SetSymbolEvent SetDecimalsEvent -UpdateTotalSupplyEvent \ No newline at end of file +UpdateTotalSupplyEvent diff --git a/docs/src/src-12-contract-factory.md b/docs/src/src-12-contract-factory.md index aca899c0..52c062fc 100644 --- a/docs/src/src-12-contract-factory.md +++ b/docs/src/src-12-contract-factory.md @@ -62,7 +62,7 @@ There are no other standards that the SRC-12 requires compatibility. ## Security Considerations -This standard takes into consideration child contracts that are deployed with differentiating configurable values, however individual contract behaviors may be dependent on storage variables. As storage variables may change after the contract has been registered with the SRC-12 compliant contract, the standard suggests to check these values upon registration however it is not enforced. +This standard takes into consideration child contracts that are deployed with differentiating configurable values, however individual contract behaviours may be dependent on storage variables. As storage variables may change after the contract has been registered with the SRC-12 compliant contract, the standard suggests to check these values upon registration however it is not enforced. ## Example ABI diff --git a/docs/src/src-13-soulbound-address.md b/docs/src/src-13-soulbound-address.md index 5a7b89c5..20a2c315 100644 --- a/docs/src/src-13-soulbound-address.md +++ b/docs/src/src-13-soulbound-address.md @@ -25,15 +25,15 @@ We must also ensure every `Address` on Fuel has its own Predicate. This can be g ### Definitions - **Soulbound Address Predicate** - The resulting predicate which owns assets on behalf of an `Address`. -- **Soulbound Address** - The computed `Address` of the *Soulbound Asset Predicate*. -- **Soulbound Asset** - Any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) sent to the *Soulbound Address*. +- **Soulbound Address** - The computed `Address` of the _Soulbound Asset Predicate_. +- **Soulbound Asset** - Any [Native Asset](https://docs.fuel.network/docs/sway/blockchain-development/native_assets) sent to the _Soulbound Address_. ### Soulbound Address Predicate Specification -- The *Soulbound Address Predicate* SHALL never spend the assets sent to its computed predicate `Address` or *Soulbound Address*. -- The *Soulbound Address Predicate* SHALL encode an `Address` of which it represents the soulbound address. +- The _Soulbound Address Predicate_ SHALL never spend the assets sent to its computed predicate `Address` or _Soulbound Address_. +- The _Soulbound Address Predicate_ SHALL encode an `Address` of which it represents the soulbound address. -Below we define the *Soulbound Address Predicate* where `ADDRESS` MUST be replaced with the `Address` of which the *Soulbound Address Predicate* represents. +Below we define the _Soulbound Address Predicate_ where `ADDRESS` MUST be replaced with the `Address` of which the _Soulbound Address Predicate_ represents. ```sway predicate; @@ -50,9 +50,9 @@ fn main() -> bool { ### Soulbound Address -The *Soulbound Address* is the *Soulbound Address Predicate*'s predicate address. A predicate's address(the bytecode root) is defined [here](https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/predicate-id.md). +The _Soulbound Address_ is the _Soulbound Address Predicate_'s predicate address. A predicate's address(the bytecode root) is defined [here](https://github.com/FuelLabs/fuel-specs/blob/master/src/identifiers/predicate-id.md). -The *Soulbound Address* may be computed from the *Soulbound Address Predicate*'s bytecode both on-chain or off-chain. For off-chain computation, please refer to the fuels-rs [predicate docs](https://docs.fuel.network/docs/fuels-rs/predicates/). For on-chain computation, please refer to Sway-Lib's [Bytecode Library](https://docs.fuel.network/docs/sway-libs/bytecode/). +The _Soulbound Address_ may be computed from the _Soulbound Address Predicate_'s bytecode both on-chain or off-chain. For off-chain computation, please refer to the fuels-rs [predicate docs](https://docs.fuel.network/docs/fuels-rs/predicates/). For on-chain computation, please refer to Sway-Lib's [Bytecode Library](https://docs.fuel.network/docs/sway-libs/bytecode/). ## Rationale @@ -66,13 +66,13 @@ This standard is compatible with Fuel's [Native Assets](https://docs.fuel.networ This standard does not introduce any security concerns, as it does not call external contracts, nor does it define any mutations of the contract state. -It should however be noted that any Native Asset on the Fuel Network is not a Soulbound Asset until it is sent to a *Soulbound Address*. +It should however be noted that any Native Asset on the Fuel Network is not a Soulbound Asset until it is sent to a _Soulbound Address_. ## Example -The following example shows the *Soulbound Address Predicate* for the `0xe033369a522e3cd2fc19a5a705a7f119938027e8e287c0ec35b784e68dab2be6` `Address`. +The following example shows the _Soulbound Address Predicate_ for the `0xe033369a522e3cd2fc19a5a705a7f119938027e8e287c0ec35b784e68dab2be6` `Address`. -The resulting *Soulbound Address* is `0x7f28a538d06788a3d98bb72f4b41012d86abc4b0369ee5dedf56cfbaf245d609`. Any Native Assets sent to this address will become Soulbound Assets. +The resulting _Soulbound Address_ is `0x7f28a538d06788a3d98bb72f4b41012d86abc4b0369ee5dedf56cfbaf245d609`. Any Native Assets sent to this address will become Soulbound Assets. ```sway predicate; diff --git a/docs/src/src-14-simple-upgradeable-proxies.md b/docs/src/src-14-simple-upgradeable-proxies.md index a15e5046..21ee8e63 100644 --- a/docs/src/src-14-simple-upgradeable-proxies.md +++ b/docs/src/src-14-simple-upgradeable-proxies.md @@ -25,7 +25,7 @@ The FuelVM provides an `LDC` instruction that is used by Sway's `std::execution: ### Required Behavior The proxy contract MUST maintain the address of its target in its storage at slot `0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55` (equivalent to `sha256("storage_SRC14_0")`). -It SHOULD base other proxy specific storage fields at `sha256("storage_SRC14")` to avoid collisions with target storage. +It SHOULD base other proxy specific storage fields in the `SRC14` namespace to avoid collisions with target storage. It MAY have its storage definition overlap with that of its target if necessary. The proxy contract MUST delegate any method call not part of its interface to the target contract. diff --git a/docs/src/src-2-inline-documentation.md b/docs/src/src-2-inline-documentation.md index 247bfa3a..80045f34 100644 --- a/docs/src/src-2-inline-documentation.md +++ b/docs/src/src-2-inline-documentation.md @@ -325,7 +325,7 @@ This standard will improve security by providing developers with relevant inform /// use ownable::Ownership; /// /// storage { -/// owner: Ownership = Ownership::initalized(Identity::Address(Address::zero())), +/// owner: Ownership = Ownership::initialized(Identity::Address(Address::zero())), /// } /// /// fn foo() { diff --git a/docs/src/src-5-ownership.md b/docs/src/src-5-ownership.md index 3ce9c8dd..2884f65b 100644 --- a/docs/src/src-5-ownership.md +++ b/docs/src/src-5-ownership.md @@ -81,7 +81,7 @@ abi SRC5 { ## Example Implementation -### Uninitalized +### Uninitialized Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime. diff --git a/docs/src/src-6-vault.md b/docs/src/src-6-vault.md index 04ac75f0..cd84b7fa 100644 --- a/docs/src/src-6-vault.md +++ b/docs/src/src-6-vault.md @@ -157,7 +157,7 @@ abi SRC6 { #[storage(read)] fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64; - + #[storage(read)] fn max_depositable(receiver: Identity, underlying_asset: AssetId, vault_sub_id: SubId) -> Option; diff --git a/docs/src/src-8-bridged-asset.md b/docs/src/src-8-bridged-asset.md index 5409998c..dab11cc1 100644 --- a/docs/src/src-8-bridged-asset.md +++ b/docs/src/src-8-bridged-asset.md @@ -88,31 +88,31 @@ impl SRC7 for Contract { impl SRC20 for Contract { fn total_assets() -> u64 { 1 - } + } fn total_supply(asset: AssetId) -> Option { - match asset { + match asset { AssetId::default() => Option::Some(1), _ => Option::None, } } fn name(asset: AssetId) -> Option { - match asset { + match asset { AssetId::default() => Option::Some(String::from_ascii_str("Name")), _ => Option::None, } } fn symbol(asset: AssetId) -> Option { - match asset { + match asset { AssetId::default() => Option::Some(String::from_ascii_str("Symbol")), _ => Option::None, } } fn decimals(asset: AssetId) -> Option { - match asset { + match asset { AssetId::default() => Option::Some(0u8), _ => Option::None, } diff --git a/docs/src/src-9-metadata-keys.md b/docs/src/src-9-metadata-keys.md index 9558b3cd..cc220ca4 100644 --- a/docs/src/src-9-metadata-keys.md +++ b/docs/src/src-9-metadata-keys.md @@ -135,7 +135,7 @@ The key `link:contact` SHALL return a `String` variant of the asset's project co #### `link:docs` - The key `link:docs` SHALL return a `String` variant of the asset's project documentation webpage. +The key `link:docs` SHALL return a `String` variant of the asset's project documentation webpage. #### `link:forum` diff --git a/examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw b/examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw index 454f975e..6811305d 100644 --- a/examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw +++ b/examples/src5-ownership/uninitialized_example/src/uninitialized_example.sw @@ -27,7 +27,7 @@ impl SRC5 for Contract { /// let ownership_abi = abi(contract_id, SRC_5); /// /// match ownership_abi.owner() { - /// State::Uninitalized => log("The ownership is uninitalized"), + /// State::Uninitialized => log("The ownership is uninitialized"), /// _ => log("This example will never reach this statement"), /// } /// } diff --git a/standards/src/src14.sw b/standards/src/src14.sw index 51d00e56..ec62a3c3 100644 --- a/standards/src/src14.sw +++ b/standards/src/src14.sw @@ -55,7 +55,7 @@ abi SRC14Extension { /// ```sway /// fn foo() { /// match owner() { - /// State::Uninitalized => log("The ownership is uninitalized"), + /// State::Uninitialized => log("The ownership is uninitialized"), /// State::Initialized(owner) => log("The ownership is initalized"), /// State::Revoked => log("The ownership is revoked"), /// } diff --git a/standards/src/src5.sw b/standards/src/src5.sw index 5e8ce62e..0cedac05 100644 --- a/standards/src/src5.sw +++ b/standards/src/src5.sw @@ -41,7 +41,7 @@ abi SRC5 { /// ```sway /// fn foo() { /// match owner() { - /// State::Uninitalized => log("The ownership is uninitalized"), + /// State::Uninitialized => log("The ownership is uninitialized"), /// State::Initialized(owner) => log("The ownership is initalized"), /// State::Revoked => log("The ownership is revoked"), /// }