Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update src14 storage recommendation and general typos #136

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

bitzoic marked this conversation as resolved.
Show resolved Hide resolved
### 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 and general typos and markdown in docs and inline documentation.

#### Breaking Unreleased

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
bitzoic marked this conversation as resolved.
Show resolved Hide resolved

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.

Expand Down
4 changes: 2 additions & 2 deletions docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ WAV
OGA
glTF
GLB
Uninitalized
Uninitialized
upgradeability
SetMetadataEvent
SetNameEvent
SetSymbolEvent
SetDecimalsEvent
UpdateTotalSupplyEvent
UpdateTotalSupplyEvent
2 changes: 1 addition & 1 deletion docs/src/src-12-contract-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 10 additions & 10 deletions docs/src/src-13-soulbound-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-14-simple-upgradeable-proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-2-inline-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-5-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-6-vault.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>;

Expand Down
10 changes: 5 additions & 5 deletions docs/src/src-8-bridged-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,31 @@ impl SRC7 for Contract {
impl SRC20 for Contract {
fn total_assets() -> u64 {
1
}
}

fn total_supply(asset: AssetId) -> Option<u64> {
match asset {
match asset {
AssetId::default() => Option::Some(1),
_ => Option::None,
}
}

fn name(asset: AssetId) -> Option<String> {
match asset {
match asset {
AssetId::default() => Option::Some(String::from_ascii_str("Name")),
_ => Option::None,
}
}

fn symbol(asset: AssetId) -> Option<String> {
match asset {
match asset {
AssetId::default() => Option::Some(String::from_ascii_str("Symbol")),
_ => Option::None,
}
}

fn decimals(asset: AssetId) -> Option<u8> {
match asset {
match asset {
AssetId::default() => Option::Some(0u8),
_ => Option::None,
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src-9-metadata-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion standards/src/src14.sw
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
/// }
Expand Down
2 changes: 1 addition & 1 deletion standards/src/src5.sw
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
/// }
Expand Down
Loading