Skip to content

Commit 5cb07af

Browse files
authored
Sync with master (#202)
1 parent 21cb842 commit 5cb07af

File tree

29 files changed

+5138
-28
lines changed

29 files changed

+5138
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ env:
1616
CARGO_TERM_COLOR: always
1717
REGISTRY: ghcr.io
1818
RUST_VERSION: 1.80.1
19-
FORC_VERSION: 0.68.7
20-
CORE_VERSION: 0.43.1
19+
FORC_VERSION: 0.69.0
20+
CORE_VERSION: 0.44.0
2121
PATH_TO_SCRIPTS: .github/scripts
2222

2323
jobs:

.github/workflows/publish-standards.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ env:
1414
CARGO_TERM_COLOR: always
1515
REGISTRY: ghcr.io
1616
RUST_VERSION: 1.84.0
17-
FORC_VERSION: 0.68.7
18-
CORE_VERSION: 0.43.2
17+
FORC_VERSION: 0.69.0
18+
CORE_VERSION: 0.44.0
1919

2020
jobs:
2121
verify-branch:
@@ -50,6 +50,7 @@ jobs:
5050
"src14",
5151
"src15",
5252
"src16",
53+
"src17",
5354
"src20",
5455
]
5556
steps:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml" alt="CI">
1010
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml/badge.svg" />
1111
</a>
12-
<a href="https://crates.io/crates/forc/0.68.7" alt="forc">
13-
<img src="https://img.shields.io/badge/forc-v0.68.7-orange" />
12+
<a href="https://crates.io/crates/forc/0.69.0" alt="forc">
13+
<img src="https://img.shields.io/badge/forc-v0.69.0-orange" />
1414
</a>
1515
<a href="./LICENSE" alt="forc">
1616
<img src="https://img.shields.io/github/license/FuelLabs/sway-standards" />
@@ -184,7 +184,7 @@ Example of a minimal SRC-14 implementation with no access control.
184184
Example of a SRC-14 implementation that also implements [SRC-5](https://docs.fuel.network/docs/sway-standards/src-5-ownership/).
185185

186186
> **Note**
187-
> All standards currently use `forc v0.68.7`.
187+
> All standards currently use `forc v0.69.0`.
188188
189189
<!-- TODO:
190190
## Contributing

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Standards in this repository may be in various stages of development. Use of dra
77
If you don't find what you're looking for, feel free to create an issue and propose a new standard!
88

99
> **Note**
10-
> All standards currently use `forc v0.68.7`.
10+
> All standards currently use `forc v0.69.0`.
1111
1212
## Using a standard
1313

examples/src17-naming-verification/sparse_merkle_proof/Forc.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ name = "sparse_merkle_proof"
66

77
[dependencies]
88
src17 = { path = "../../../standards/src17" }
9-
merkle = { git = "https://github.com/FuelLabs/sway-libs", branch = "master" }
9+
merkle = "0.26.0"

standards/src10/Forc.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ authors = ["Fuel Labs <[email protected]>"]
33
entry = "src10.sw"
44
license = "Apache-2.0"
55
name = "src10"
6-
version = "0.8.0"
6+
version = "0.8.1"
77
description = "The SRC-10 Standard allows for the implementation of a standard API for Native Bridges using the Sway Language."
88
homepage = "https://github.com/FuelLabs/sway-standards"
99
repository = "https://github.com/FuelLabs/sway-standards"

standards/src10/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# SRC-10: Native Bridge
2+
3+
The following standard allows for the implementation of a standard API for Native Bridges using the Sway Language. The standardized design has the bridge contract send a message to the origin chain to register which token it accepts to prevent a loss of funds.
4+
5+
## Motivation
6+
7+
A standard interface for bridges intends to provide a safe and efficient bridge between the settlement or canonical chain and the Fuel Network.
8+
9+
## Prior Art
10+
11+
The standard is centered on Fuel’s [Bridge Architecture](https://github.com/FuelLabs/fuel-bridge/blob/main/docs/ARCHITECTURE.md). Fuel's bridge system is built on a message protocol that allows to send (and receive) messages between entities located in two different blockchains.
12+
13+
The following standard takes reference from the [`FungibleBridge`](https://github.com/FuelLabs/fuel-bridge/blob/3971081850e7961d9b649edda4cad8a848ee248e/packages/fungible-token/bridge-fungible-token/src/interface.sw#L22) ABI defined in the fuel-bridge repository.
14+
15+
## Specification
16+
17+
The following functions MUST be implemented to follow the SRC-10; Native Bridge Standard:
18+
19+
### Required Functions
20+
21+
**`fn process_message(message_index: u64)`**
22+
23+
The `process_message()` function accepts incoming deposit messages from the canonical chain and issues the corresponding bridged asset.
24+
25+
- This function MUST parse a message at the given `message_index` index.
26+
- This function SHALL mint an asset that follows the [SRC-8; Bridged Asset Standard](https://docs.fuel.network/docs/sway-standards/src-8-bridged-asset/).
27+
- This function SHALL issue a refund if there is an error in the bridging process.
28+
29+
**`fn withdraw(to_address: b256)`**
30+
31+
The `withdraw()` function accepts and burns a bridged Native Asset on Fuel and sends a message to the bridge contract on the canonical chain to release the originally deposited tokens to the `to_address` address.
32+
33+
- This function SHALL send a message to the bridge contract to release the bridged tokens to the `to_address` address on the canonical chain.
34+
- This function MUST ensure the asset's `AssetId` sent in the transaction matches a bridged asset.
35+
- This function SHALL burn all coins sent in the transaction.
36+
37+
**`fn claim_refund(to_address: b256, token_address: b256, token_id: b256, gateway_contract: b256)`**
38+
39+
The `claim_refund()` function is called if something goes wrong in the bridging process and an error occurs. It sends a message to the `gateway_contract` contract on the canonical chain to release the `token_address` token with token id `token_id` to the `to_address` address.
40+
41+
- This function SHALL send a message to the `gateway_contract` contract to release the `token_address` token with id `token_id` to the `to_address` address on the canonical chain.
42+
- This function MUST ensure a refund was issued.
43+
44+
### Required Data Types
45+
46+
#### `DepositType`
47+
48+
The `DepositType` enum describes whether the bridged deposit is made to a address, contract, or contract and contains additional metadata. There MUST be the following variants in the `DepositType` enum:
49+
50+
**`Address`: `()`**
51+
52+
The `Address` variant MUST represent when the deposit is made to an address on the Fuel chain.
53+
54+
**`Contract`: `()`**
55+
56+
The `Contract` variant MUST represent when the deposit is made to an contract on the Fuel chain.
57+
58+
**`ContractWithData`: `()`**
59+
60+
The `ContractWithData` variant MUST represent when the deposit is made to an contract and contains additional metadata for the Fuel chain.
61+
62+
##### Example Deposit Type
63+
64+
```sway
65+
pub enum DepositType {
66+
Address: (),
67+
Contract: (),
68+
ContractWithData: (),
69+
}
70+
```
71+
72+
#### `DepositMessage`
73+
74+
The following describes a struct that encapsulates various deposit message metadata to a single type. There MUST be the following fields in the `DepositMessage` struct:
75+
76+
**`amount`: `u256`**
77+
78+
The `amount` field MUST represent the number of tokens.
79+
80+
**`from`: `b256`**
81+
82+
The `from` field MUST represent the bridging user’s address on the canonical chain.
83+
84+
**`to`: `Identity`**
85+
86+
The `to` field MUST represent the bridging target destination `Address` or `ContractId` on the Fuel Chain.
87+
88+
**`token_address`: `b256`**
89+
90+
The `token_address` field MUST represent the bridged token's address on the canonical chain.
91+
92+
**`token_id`: `b256`**
93+
94+
The `token_id` field MUST represent the token's ID on the canonical chain. The `b256::zero()` MUST be used if this is a fungible token and no token ID exists.
95+
96+
**`decimals`: `u8`**
97+
98+
The `decimals` field MUST represent the bridged token's decimals on the canonical chain.
99+
100+
**`deposit_type`: `DepositType`**
101+
102+
The `deposit_type` field MUST represent the type of bridge deposit made on the canonical chain.
103+
104+
##### Example Deposit Message
105+
106+
```sway
107+
pub struct DepositMessage {
108+
pub amount: b256,
109+
pub from: b256,
110+
pub to: Identity,
111+
pub token_address: b256,
112+
pub token_id: b256,
113+
pub decimals: u8,
114+
pub deposit_type: DepositType,
115+
}
116+
```
117+
118+
#### `MetadataMessage`
119+
120+
The following describes a struct that encapsulates the metadata of token on the canonical chain to a single type. There MUST be the following fields in the `MetadataMessage` struct:
121+
122+
**`token_address`: `b256`**
123+
124+
The `token_address` field MUST represent the bridged token's address on the canonical chain.
125+
126+
**`token_id`: `b256`**
127+
128+
The `token_id` field MUST represent the token's ID on the canonical chain. The `b256::zero()` MUST be used if this is a fungible token and no token ID exists.
129+
130+
**`name`: `String`**
131+
132+
The `name` field MUST represent the bridged token's name field on the canonical chain.
133+
134+
**`symbol`: `String`**
135+
136+
The `symbol` field MUST represent the bridged token's symbol field on the canonical chain.
137+
138+
##### Example Metadata Message
139+
140+
```sway
141+
pub struct MetadataMessage {
142+
pub token_address: b256,
143+
pub token_id: b256,
144+
pub name: String,
145+
pub symbol: String,
146+
}
147+
```
148+
149+
## Required Standards
150+
151+
Any contract that implements the SRC-10; Native Bridge Standard MUST implement the [SRC-8; Bridged Asset Standard](https://docs.fuel.network/docs/sway-standards/src-8-bridged-asset/) for all bridged assets.
152+
153+
## Rationale
154+
155+
The SRC-10; Native Bridge Standard is designed to standardize the native bridge interface between all Fuel instances.
156+
157+
## Backwards Compatibility
158+
159+
This standard is compatible with the SRC-20 and SRC-8 standards.
160+
161+
## Example ABI
162+
163+
```sway
164+
abi SRC10 {
165+
fn process_message(message_index: u64);
166+
fn withdraw(to_address: b256);
167+
fn claim_refund(to_address: b256, token_address: b256, token_id: b256, gateway_contract: b256);
168+
}
169+
```

standards/src11/Forc.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ authors = ["Fuel Labs <[email protected]>"]
33
entry = "src11.sw"
44
license = "Apache-2.0"
55
name = "src11"
6-
version = "0.8.0"
6+
version = "0.8.1"
77
description = "The SRC-11 Standard allows for contract creators to make communication information readily available to everyone, with the primary purpose of allowing white hat hackers to coordinate a bug-fix or securing of funds."
88
homepage = "https://github.com/FuelLabs/sway-standards"
99
repository = "https://github.com/FuelLabs/sway-standards"

0 commit comments

Comments
 (0)