Skip to content

Commit

Permalink
Remove workspace (#72)
Browse files Browse the repository at this point in the history
* Move SRCs to seperate folder

* Remove workspace from standards

* Update examples

* Update source README
  • Loading branch information
bitzoic authored Mar 29, 2024
1 parent 376c92a commit bb3b425
Show file tree
Hide file tree
Showing 71 changed files with 57 additions and 102 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,46 @@ If you don't find what you're looking for, feel free to create an issue and prop

### Native Assets

- [SRC-20; Native Asset Standard](./standards/src20-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](./standards/src3-mint-burn/) is used to enable mint and burn functionality for Native Assets.
- [SRC-7; Arbitrary Asset Metadata Standard](./standards/src7-metadata/) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
- [SRC-9; Metadata Keys Standard](./standards/src9-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](./standards/src6-vault/) defines the implementation of a standard API for asset vaults developed in Sway.
- [SRC-20; Native Asset Standard](./SRCs/src20/) 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](./SRCs/src3/) is used to enable mint and burn functionality for Native Assets.
- [SRC-7; Arbitrary Asset Metadata Standard](./SRCs/src7/) is used to store metadata for [Native Assets](https://docs.fuel.network/docs/sway/blockchain-development/native_assets).
- [SRC-9; Metadata Keys Standard](./SRCs/src9/) 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](./SRCs/src6/) defines the implementation of a standard API for asset vaults developed in Sway.

### Access Control

- [SRC-5; Ownership Standard](./standards/src5-ownership/) is used to restrict function calls to admin users in contracts.
- [SRC-5; Ownership Standard](./SRCs/src5/) is used to restrict function calls to admin users in contracts.

### Bridge

- [SRC-8; Bridged Asset](./standards/src8-bridged-asset/) defines the metadata required for an asset bridged to the Fuel Network.
- [SRC-10; Native Bridge Standard](./standards/src10-native-bridge/) defines the standard API for the Native Bridge between the Fuel Chain and the canonical base chain.
- [SRC-8; Bridged Asset](./SRCs/src8/) defines the metadata required for an asset bridged to the Fuel Network.
- [SRC-10; Native Bridge Standard](./SRCs/src10/) defines the standard API for the Native Bridge between the Fuel Chain and the canonical base chain.

### Documentation

- [SRC-2; Inline Documentation](./standards/src2-inline-docs/) defines how to document your Sway files.
- [SRC-2; Inline Documentation](./SRCs/src2/) defines how to document your Sway files.

## Using a standard

To import a standard the following should be added to the project's `Forc.toml` file under `[dependencies]` with the most recent release:

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

> **NOTE:**
> Be sure to set the tag to the latest release.
You may then import your desired standard in your Sway Smart Contract as so:

```rust
use standard::<standard_abi>;
use standards::<standard>::<standard_abi>;
```

For example, to import the SRC-20 Native Asset Standard use the following statements in your `Forc.toml` and Sway Smart Contract file respectively:

```rust
src20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" }
```
For example, to import the SRC-20 Native Asset Standard use the following statement in your Sway Smart Contract file:

```rust
use src20::SRC20;
use standards::src20::SRC20;
```

### Examples of Standards
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion standards/src2-inline-docs/README.md → SRCs/src-2.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset=".docs/src-2-logo-dark-theme.png">
<img alt="SRC-5 logo" width="400px" src=".docs/src-2-logo-light-theme.png">
<img alt="SRC-2 logo" width="400px" src=".docs/src-2-logo-light-theme.png">
</picture>
</p>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "hardcoded-information"

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

use src11::{SecurityInformation, SRC11};
use standards::src11::{SecurityInformation, SRC11};

use std::{string::String, vec::Vec,};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "variable-information"

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

use src11::{SecurityInformation, SRC11};
use standards::src11::{SecurityInformation, SRC11};

use std::{storage::{storage_string::*, storage_vec::*,}, string::String, vec::Vec,};

Expand Down
2 changes: 1 addition & 1 deletion examples/src20-native-asset/multi_asset/Forc.toml
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]
src20 = { path = "../../../standards/src20-native-asset" }
standards = { path = "../../../standards" }
2 changes: 1 addition & 1 deletion examples/src20-native-asset/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

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

storage {
Expand Down
2 changes: 1 addition & 1 deletion examples/src20-native-asset/single_asset/Forc.toml
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]
src20 = { path = "../../../standards/src20-native-asset" }
standards = { path = "../../../standards" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

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

configurable {
Expand Down
3 changes: 1 addition & 2 deletions examples/src3-mint-burn/multi_asset/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "multi_src3_asset"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src3 = { path = "../../../standards/src3-mint-burn" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src3-mint-burn/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
contract;

use src3::SRC3;
use src20::SRC20;
use standards::{src20::SRC20, src3::SRC3};
use std::{
asset::{
burn,
Expand Down
3 changes: 1 addition & 2 deletions examples/src3-mint-burn/single_asset/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "single_src3_asset"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src3 = { path = "../../../standards/src3-mint-burn" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src3-mint-burn/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
contract;

use src3::SRC3;
use src20::SRC20;
use standards::{src20::SRC20, src3::SRC3};
use std::{
asset::{
burn,
Expand Down
2 changes: 1 addition & 1 deletion examples/src5-ownership/initialized_example/Forc.toml
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]
src5 = { path = "../../../standards/src5-ownership" }
standards = { path = "../../../standards" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

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

configurable {
Expand Down
2 changes: 1 addition & 1 deletion examples/src5-ownership/uninitialized_example/Forc.toml
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]
src5 = { path = "../../../standards/src5-ownership" }
standards = { path = "../../../standards" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

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

storage {
/// The owner in storage.
Expand Down
3 changes: 1 addition & 2 deletions examples/src6-vault/multi_asset_vault/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "multi_asset_vault"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src6 = { path = "../../../standards/src6-vault" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src6-vault/multi_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use std::{
string::String,
};

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

pub struct VaultInfo {
/// Amount of assets currently managed by this vault
Expand Down
3 changes: 1 addition & 2 deletions examples/src6-vault/single_asset_single_sub_vault/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "single_asset_single_sub_vault"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src6 = { path = "../../../standards/src6-vault" }
standards = { path = "../../../standards" }
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use std::{
string::String,
};

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

configurable {
/// The only asset that can be deposited and withdrawn from this vault.
Expand Down
3 changes: 1 addition & 2 deletions examples/src6-vault/single_asset_vault/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "single_asset_vault"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src6 = { path = "../../../standards/src6-vault" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src6-vault/single_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use std::{
string::String,
};

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

pub struct VaultInfo {
/// Amount of assets currently managed by this vault
Expand Down
3 changes: 1 addition & 2 deletions examples/src7-metadata/multi_asset/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "multi_src7_asset"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src7 = { path = "../../../standards/src7-metadata" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src7-metadata/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
contract;

use src7::{Metadata, SRC7};
use src20::SRC20;
use standards::{src20::SRC20, src7::{Metadata, SRC7}};

use std::{call_frames::contract_id, hash::Hash, storage::storage_string::*, string::String};

Expand Down
3 changes: 1 addition & 2 deletions examples/src7-metadata/single_asset/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ license = "Apache-2.0"
name = "single_src7_asset"

[dependencies]
src20 = { path = "../../../standards/src20-native-asset" }
src7 = { path = "../../../standards/src7-metadata" }
standards = { path = "../../../standards" }
3 changes: 1 addition & 2 deletions examples/src7-metadata/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
contract;

use src7::{Metadata, SRC7};
use src20::SRC20;
use standards::{src20::SRC20, src7::{Metadata, SRC7}};

use std::{call_frames::contract_id, string::String};

Expand Down
14 changes: 5 additions & 9 deletions standards/Forc.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[workspace]
members = [
"src3-mint-burn",
"src5-ownership",
"src6-vault",
"src7-metadata",
"src10-native-bridge",
"src20-native-asset",
]
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "standards.sw"
license = "Apache-2.0"
name = "standards"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions standards/src/standards.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library;

pub mod src3;
pub mod src5;
pub mod src6;
pub mod src7;
pub mod src10;
pub mod src11;
pub mod src20;
5 changes: 0 additions & 5 deletions standards/src10-native-bridge/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src11-security-information/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src20-native-asset/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src3-mint-burn/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src5-ownership/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src6-vault/Forc.toml

This file was deleted.

5 changes: 0 additions & 5 deletions standards/src7-metadata/Forc.toml

This file was deleted.

0 comments on commit bb3b425

Please sign in to comment.