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

Update to use forc v0.66.6 and fuel core v0.40.0 #166

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.80.1
FORC_VERSION: 0.63.3
CORE_VERSION: 0.34.0
FORC_VERSION: 0.66.6
CORE_VERSION: 0.40.0
PATH_TO_SCRIPTS: .github/scripts

jobs:
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### New Standards

- [#161](https://github.com/FuelLabs/sway-standards/pull/161) Defines the SRC-16; Typed Structured Data Standard.

### Added

- Something new here 1
- Something new here 2

### Changed

- Something changed here 1
- Something changed here 2
- [#166](https://github.com/FuelLabs/sway-standards/pull/166) Updates standards, examples, and CI to forc `v0.66.6` and fuel-core `v0.40.0`.

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<a href="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml" alt="CI">
<img src="https://github.com/FuelLabs/sway-standards/actions/workflows/ci.yaml/badge.svg" />
</a>
<a href="https://crates.io/crates/forc/0.63.3" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.63.3-orange" />
<a href="https://crates.io/crates/forc/0.66.6" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.66.6-orange" />
</a>
<a href="./LICENSE" alt="forc">
<img src="https://img.shields.io/github/license/FuelLabs/sway-standards" />
Expand Down Expand Up @@ -163,7 +163,7 @@ Example of a minimal SRC-14 implementation with no access control.
Example of a SRC-14 implementation that also implements [SRC-5](https://docs.fuel.network/docs/sway-standards/src-5-ownership/).

> **Note**
> All standards currently use `forc v0.63.3`.
> All standards currently use `forc v0.66.6`.

<!-- TODO:
## Contributing
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Standards in this repository may be in various stages of development. Use of dra
If you don't find what you're looking for, feel free to create an issue and propose a new standard!

> **Note**
> All standards currently use `forc v0.63.3`.
> All standards currently use `forc v0.66.6`.

## Using a standard

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contract;

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

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

/// The name of the project
const NAME: str[7] = __to_str_array("Example");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contract;

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

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

/// The name of the project
const NAME: str[7] = __to_str_array("Example");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library;

use std::{alloc::{alloc, alloc_bytes, realloc_bytes}, bytes::Bytes,};
use std::{alloc::{alloc, alloc_bytes, realloc_bytes}, bytes::Bytes};

/// Pre-defined number of bytes of a leaf in a bytecode merkle tree.
const LEAF_SIZE = 16 * 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod utils;

use utils::{_compute_bytecode_root, _swap_configurables};
use standards::src12::*;
use std::{external::bytecode_root, hash::{Hash, sha256,}, storage::storage_vec::*,};
use std::{external::bytecode_root, hash::{Hash, sha256}, storage::storage_vec::*};

configurable {
TEMPLATE_BYTECODE_ROOT: b256 = b256::zero(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contract;

use standards::src12::*;
use std::{external::bytecode_root, hash::Hash,};
use std::{external::bytecode_root, hash::Hash};

configurable {
TEMPLATE_BYTECODE_ROOT: b256 = b256::zero(),
Expand Down
5 changes: 1 addition & 4 deletions examples/src16-typed-data/Forc.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[workspace]
members = [
"fuel_example",
"ethereum_example",
]
members = ["fuel_example", "ethereum_example"]
2 changes: 1 addition & 1 deletion examples/src16-typed-data/ethereum_example/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "src16_ethereum_typed_data"

[dependencies]
standards = { path = "../../../standards" }
standards = { path = "../../../standards" }
66 changes: 16 additions & 50 deletions examples/src16-typed-data/ethereum_example/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
contract;

use standards::src16::{
SRC16Base,
DataEncoder,
DomainHash,
EIP712,
EIP712Domain,
DomainHash,
TypedDataHash,
DataEncoder,
SRC16Payload,
SRC16Base,
SRC16Encode,
SRC16Payload,
TypedDataHash,
};
use std::{
bytes::Bytes,
string::String,
hash::*,
contract_id::*,
};

use std::{bytes::Bytes, contract_id::*, hash::*, string::String};

configurable {
/// The name of the signing domain.
Expand All @@ -27,7 +21,6 @@ configurable {
CHAIN_ID: u64 = 9889u64,
}


/// A demo struct representing a mail message
pub struct Mail {
/// The sender's address
Expand All @@ -47,7 +40,6 @@ pub struct Mail {
const MAIL_TYPE_HASH: b256 = 0xcfc972d321844e0304c5a752957425d5df13c3b09c563624a806b517155d7056;

impl TypedDataHash for Mail {

fn type_hash() -> b256 {
MAIL_TYPE_HASH
}
Expand All @@ -56,19 +48,11 @@ impl TypedDataHash for Mail {
let mut encoded = Bytes::new();

// Add the Mail type hash.
encoded.append(
MAIL_TYPE_HASH.to_be_bytes()
);
encoded.append(MAIL_TYPE_HASH.to_be_bytes());
// Use the DataEncoder to encode each field for known types
encoded.append(
DataEncoder::encode_b256(self.from).to_be_bytes()
);
encoded.append(
DataEncoder::encode_b256(self.to).to_be_bytes()
);
encoded.append(
DataEncoder::encode_string(self.contents).to_be_bytes()
);
encoded.append(DataEncoder::encode_b256(self.from).to_be_bytes());
encoded.append(DataEncoder::encode_b256(self.to).to_be_bytes());
encoded.append(DataEncoder::encode_string(self.contents).to_be_bytes());

keccak256(encoded)
}
Expand All @@ -86,9 +70,7 @@ impl TypedDataHash for Mail {
/// SRC16Payload::encode_hash()
///
impl SRC16Encode<Mail> for Mail {

fn encode(s: Mail) -> b256 {

// encodeData hash
let data_hash = s.struct_hash();
// setup payload
Expand All @@ -105,9 +87,7 @@ impl SRC16Encode<Mail> for Mail {
}
}


impl SRC16Base for Contract {

fn domain_separator_hash() -> b256 {
_get_domain_separator().domain_hash()
}
Expand All @@ -118,24 +98,16 @@ impl SRC16Base for Contract {
}

impl EIP712 for Contract {

fn domain_separator() -> EIP712Domain {
_get_domain_separator()
}

}


abi MailMe {
fn send_mail_get_hash(
from_addr: b256,
to_addr: b256,
contents: String,
) -> b256;
fn send_mail_get_hash(from_addr: b256, to_addr: b256, contents: String) -> b256;
}

impl MailMe for Contract {

/// Sends a some mail and returns its encoded hash
///
/// # Arguments
Expand All @@ -148,11 +120,7 @@ impl MailMe for Contract {
///
/// * [b256] - The encoded hash of the mail data
///
fn send_mail_get_hash(
from_addr: b256,
to_addr: b256,
contents: String,
) -> b256 {
fn send_mail_get_hash(from_addr: b256, to_addr: b256, contents: String) -> b256 {
// Create the mail struct from data passed in call
let some_mail = Mail {
from: from_addr,
Expand All @@ -162,7 +130,6 @@ impl MailMe for Contract {

Mail::encode(some_mail)
}

}

/// A program specific implementation to get the Ethereum EIP712Domain
Expand All @@ -177,10 +144,9 @@ fn _get_domain_separator() -> EIP712Domain {
EIP712Domain::new(
String::from_ascii_str(from_str_array(DOMAIN)),
String::from_ascii_str(from_str_array(VERSION)),
(asm(r1: (0, 0, 0, CHAIN_ID)) { r1: u256 }),
ContractId::this()
(asm(r1: (0, 0, 0, CHAIN_ID)) {
r1: u256
}),
ContractId::this(),
)
}



2 changes: 1 addition & 1 deletion examples/src16-typed-data/fuel_example/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "src16_fuel_typed_data"

[dependencies]
standards = { path = "../../../standards" }
standards = { path = "../../../standards" }
Loading
Loading