Skip to content

Commit

Permalink
Merge pull request #47 from FuelLabs/bitzoic-reorg-standards
Browse files Browse the repository at this point in the history
Reorg Standards Folders and Imports
  • Loading branch information
bitzoic authored Dec 21, 2023
2 parents 1e06d12 + 7ab50cc commit 718d51f
Show file tree
Hide file tree
Showing 61 changed files with 104 additions and 98 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ use standard::<standard_abi>;
For example, to import the SRC-20 Token Standard use the following statements in your `Forc.toml` and Sway Smart Contract file respectively:

```rust
src_20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.1.1" }
src20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.1.1" }
```

```rust
use src_20::SRC20;
use src20::SRC20;
```

### Examples of Standards
Expand All @@ -70,41 +70,41 @@ Minimal example implementations for every standard can be found in the [`example

#### SRC-20; Token Standard Examples

##### - [Single Native Assset](./examples/src_20/single_asset/src/single_asset.sw)
##### - [Single Native Assset](./examples/src20-token/single_asset/src/single_asset.sw)

Example of the SRC-20 implementation where a contract contains a single asset with one `SubId`. This implementation is recommended for users that intend to deploy a single asset with their contract.

##### - [Multi Native Asset](./examples/src_20/multi_asset/src/multi_asset.sw)
##### - [Multi Native Asset](./examples/src20-token/multi_asset/src/multi_asset.sw)

Example of the SRC-20 implementation where a contract contains multiple assets with differing `SubId`s. This implementation is recommended for users that intend to deploy multiple assets with their contract.

#### SRC-3; Mint and Burn Standard Examples

##### - [Single Native Asset](./examples/src_3/single_asset/src/single_asset.sw)
##### - [Single Native Asset](./examples/src3-mint-burn/single_asset/src/single_asset.sw)

Example of the SRC-3 implementation where a contract only mints a single asset with one `SubId`.

##### - [Multi Native Asset](./examples/src_3/multi_asset/src/multi_asset.sw)
##### - [Multi Native Asset](./examples/src3-mint-burn/multi_asset/src/multi_asset.sw)

Example of the SRC-3 implementation where a contract mints multiple assets with differing `SubId`s.

#### SRC-5; Ownership Examples

##### - [Uninitalized](./examples/src_5/uninitialized_example/src/uninitialized_example.sw)
##### - [Uninitalized](./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.

##### - [Initialized](./examples/src_5/initialized_example/src/initialized_example.sw)
##### - [Initialized](./examples/src5-ownership/initialized_example/src/initialized_example.sw)

Example of the SRC-5 implementation where a contract has an owner set at compile time.

#### SRC-7; Arbitrary Asset Metadata Standard Examples

##### - [Single Native Asset](./examples/src_7/single_asset/src/single_asset.sw)
##### - [Single Native Asset](./examples/src7-metadata/single_asset/src/single_asset.sw)

Example of the SRC-7 implementation where metadata exists for only a single asset with one `SubId`.

##### - [Mutli Native Asset](./examples/src_7/multi_asset/src/multi_asset.sw)
##### - [Mutli Native Asset](./examples/src7-metadata/multi_asset/src/multi_asset.sw)

Example of the SRC-7 implementation where metadata exists for multiple assets with differing `SubId`s.

Expand Down
16 changes: 8 additions & 8 deletions examples/Forc.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
members = [
"src_3/single_asset",
"src_3/multi_asset",
"src_5/initialized_example",
"src_5/uninitialized_example",
"src_7/single_asset",
"src_7/multi_asset",
"src_20/single_asset",
"src_20/multi_asset",
"src3-mint-burn/single_asset",
"src3-mint-burn/multi_asset",
"src5-ownership/initialized_example",
"src5-ownership/uninitialized_example",
"src7-metadata/single_asset",
"src7-metadata/multi_asset",
"src20-token/single_asset",
"src20-token/multi_asset",
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "multi_src20_asset"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src20 = { path = "../../../standards/src20-token" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use src_20::SRC20;
use src20::SRC20;
use std::{hash::Hash, storage::storage_string::*, string::String};

storage {
Expand Down Expand Up @@ -34,7 +34,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
///
/// fn foo(contract_id: ContractId) {
/// let src_20_abi = abi(SRC20, contract_id);
Expand Down Expand Up @@ -64,7 +64,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -95,7 +95,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -126,7 +126,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "single_src20_asset"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src20 = { path = "../../../standards/src20-token" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use src_20::SRC20;
use src20::SRC20;
use std::{call_frames::contract_id, string::String};

configurable {
Expand Down Expand Up @@ -28,7 +28,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
///
/// fn foo(contract_id: ContractId) {
/// let src_20_abi = abi(SRC20, contract_id);
Expand All @@ -54,7 +54,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -85,7 +85,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -116,7 +116,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down Expand Up @@ -147,7 +147,7 @@ impl SRC20 for Contract {
/// # Examples
///
/// ```sway
/// use src_20::SRC20;
/// use src20::SRC20;
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "multi_src3_asset"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_3 = { path = "../../../standards/src_3" }
src20 = { path = "../../../standards/src20-token" }
src3 = { path = "../../../standards/src3-mint-burn" }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contract;

use src_3::SRC3;
use src_20::SRC20;
use src3::SRC3;
use src20::SRC20;
use std::{
call_frames::{
contract_id,
Expand Down Expand Up @@ -55,7 +55,7 @@ impl SRC3 for Contract {
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
/// let contract_abi = abi(SR3, contract_id);
/// let contract_abi = abi(SRC3, contract_id);
/// contract_abi.mint(Identity::ContractId(contract_id), DEFAULT_SUB_ID, 100);
/// }
/// ```
Expand Down Expand Up @@ -105,7 +105,7 @@ impl SRC3 for Contract {
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId, asset_id: AssetId) {
/// let contract_abi = abi(SR3, contract_id);
/// let contract_abi = abi(SRC3, contract_id);
/// contract_abi {
/// gas: 10000,
/// coins: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "single_src3_asset"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_3 = { path = "../../../standards/src_3" }
src20 = { path = "../../../standards/src20-token" }
src3 = { path = "../../../standards/src3-mint-burn" }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contract;

use src_3::SRC3;
use src_20::SRC20;
use src3::SRC3;
use src20::SRC20;
use std::{
call_frames::{
contract_id,
Expand Down Expand Up @@ -55,7 +55,7 @@ impl SRC3 for Contract {
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId) {
/// let contract_abi = abi(SR3, contract);
/// let contract_abi = abi(SRC3, contract);
/// contract_abi.mint(Identity::ContractId(contract_id), DEFAULT_SUB_ID, 100);
/// }
/// ```
Expand Down Expand Up @@ -95,7 +95,7 @@ impl SRC3 for Contract {
/// use std::constants::DEFAULT_SUB_ID;
///
/// fn foo(contract_id: ContractId, asset_id: AssetId) {
/// let contract_abi = abi(SR3, contract_id);
/// let contract_abi = abi(SRC3, contract_id);
/// contract_abi {
/// gas: 10000,
/// coins: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "initialized_src5_example"

[dependencies]
src_5 = { path = "../../../standards/src_5" }
src5 = { path = "../../../standards/src5-ownership" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use src_5::{SRC5, State};
use src5::{SRC5, State};
use std::constants::ZERO_B256;

configurable {
Expand All @@ -27,7 +27,7 @@ impl SRC5 for Contract {
/// # Examples
///
/// ```sway
/// use src_5::SRC_5;
/// use src5::SRC5;
///
/// fn foo(contract_id: ContractId) {
/// let ownership_abi = abi(contract_id, SRC_5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "uninitialized_src5_example"

[dependencies]
src_5 = { path = "../../../standards/src_5" }
src5 = { path = "../../../standards/src5-ownership" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use src_5::{SRC5, State};
use src5::{SRC5, State};

storage {
/// The owner in storage.
Expand All @@ -21,7 +21,7 @@ impl SRC5 for Contract {
/// # Examples
///
/// ```sway
/// use src_5::SRC_5;
/// use src5::SRC5;
///
/// fn foo(contract_id: ContractId) {
/// let ownership_abi = abi(contract_id, SRC_5);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "multi_token_vault"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_6 = { path = "../../../standards/src_6" }
src20 = { path = "../../../standards/src20-token" }
src6 = { path = "../../../standards/src6-vault" }
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::{
token::transfer,
};

use src_6::{Deposit, SRC6, Withdraw};
use src_20::SRC20;
use src6::{Deposit, SRC6, Withdraw};
use src20::SRC20;

pub struct VaultInfo {
/// Amount of assets currently managed by this vault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "single_token_single_sub_vault"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_6 = { path = "../../../standards/src_6" }
src20 = { path = "../../../standards/src20-token" }
src6 = { path = "../../../standards/src6-vault" }
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::{
token::transfer,
};

use src_6::{Deposit, SRC6, Withdraw};
use src_20::SRC20;
use src6::{Deposit, SRC6, Withdraw};
use src20::SRC20;

configurable {
/// The only asset that can be deposited and withdrawn from this vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "single_token_vault"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_6 = { path = "../../../standards/src_6" }
src20 = { path = "../../../standards/src20-token" }
src6 = { path = "../../../standards/src6-vault" }
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::{
token::transfer,
};

use src_6::{Deposit, SRC6, Withdraw};
use src_20::SRC20;
use src6::{Deposit, SRC6, Withdraw};
use src20::SRC20;

pub struct VaultInfo {
/// Amount of assets currently managed by this vault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "multi_src7_asset"

[dependencies]
src_20 = { path = "../../../standards/src_20" }
src_7 = { path = "../../../standards/src_7" }
src20 = { path = "../../../standards/src20-token" }
src7 = { path = "../../../standards/src7-metadata" }
Loading

0 comments on commit 718d51f

Please sign in to comment.