Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/move-interface-storage' into mov…
Browse files Browse the repository at this point in the history
…e-interface-storage
  • Loading branch information
cgorenflo committed Dec 6, 2024
2 parents bedd403 + c3f1369 commit ebb5c82
Show file tree
Hide file tree
Showing 23 changed files with 223 additions and 182 deletions.
179 changes: 117 additions & 62 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ edition = "2021"
rust-version = "1.81.0"

[workspace.dependencies]
soroban-sdk = { version = "22.0.0-rc.3" }
soroban-token-sdk = { version = "22.0.0-rc.3" }
soroban-sdk = { version = "22.0.0" }
soroban-token-sdk = { version = "22.0.0" }
cfg-if = { version = "1.0" }
axelar-soroban-std = { version = "^0.1.0", path = "packages/axelar-soroban-std" }
axelar-gas-service = { version = "^0.1.0", path = "contracts/axelar-gas-service" }
axelar-gateway = { version = "^0.1.0", path = "contracts/axelar-gateway" }
axelar-operators = { version = "^0.1.0", path = "contracts/axelar-operators" }
interchain-token = { version = "^0.1.0", path = "contracts/interchain-token" }
interchain-token-service = { version = "^0.1.0", path = "contracts/interchain-token-service" }
alloy-primitives = { version = "0.7.6", default-features = false, features = [
alloy-primitives = { version = "0.8.14", default-features = false, features = [
"std",
] }
alloy-sol-types = { version = "0.7.6", default-features = false, features = [
alloy-sol-types = { version = "0.8.14", default-features = false, features = [
"std",
] }
goldie = "0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion contracts/axelar-gas-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ cfg_if::cfg_if! {
} else {
mod event;
mod storage_types;
mod contract;

pub mod contract;
pub use contract::{AxelarGasService, AxelarGasServiceClient};
}
}
2 changes: 1 addition & 1 deletion contracts/axelar-gas-service/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ extern crate std;

use std::format;

use axelar_gas_service::contract::{AxelarGasService, AxelarGasServiceClient};
use axelar_gas_service::error::ContractError;
use axelar_gas_service::{AxelarGasService, AxelarGasServiceClient};
use axelar_soroban_std::{
assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event, types::Token,
};
Expand Down
2 changes: 1 addition & 1 deletion contracts/axelar-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ cfg_if::cfg_if! {
mod auth;
mod event;
mod storage_types;
mod contract;

pub mod contract;
pub use contract::{AxelarGateway, AxelarGatewayClient};
}
}
4 changes: 2 additions & 2 deletions contracts/axelar-operators/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod event;
mod storage_types;

pub mod contract;
mod contract;
pub mod error;

pub use contract::AxelarOperatorsClient;
pub use contract::{AxelarOperators, AxelarOperatorsClient};
2 changes: 1 addition & 1 deletion contracts/axelar-operators/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use axelar_soroban_std::{
testutils::assert_invocation,
};

use axelar_operators::contract::{AxelarOperators, AxelarOperatorsClient};
use axelar_operators::{AxelarOperators, AxelarOperatorsClient};
use soroban_sdk::{
contract, contractimpl, symbol_short, testutils::Address as _, Address, Env, Symbol, Val, Vec,
};
Expand Down
5 changes: 2 additions & 3 deletions contracts/example/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![no_std]

mod contract;
mod event;
mod storage_types;

pub mod contract;

pub use contract::ExampleClient;
pub use contract::{Example, ExampleClient};
4 changes: 2 additions & 2 deletions contracts/example/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![cfg(test)]
extern crate std;

use axelar_gas_service::contract::AxelarGasService;
use axelar_gas_service::AxelarGasService;
use axelar_gas_service::AxelarGasServiceClient;
use axelar_gateway::testutils::{self, generate_proof, get_approve_hash, TestSignerSet};
use axelar_gateway::types::Message;
use axelar_gateway::AxelarGatewayClient;
use axelar_soroban_std::types::Token;
use axelar_soroban_std::{assert_last_emitted_event, auth_invocation};
use example::contract::Example;
use example::Example;
use example::ExampleClient;
use soroban_sdk::testutils::{AuthorizedFunction, AuthorizedInvocation};
use soroban_sdk::token::StellarAssetClient;
Expand Down
87 changes: 38 additions & 49 deletions contracts/interchain-token-service/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ mod tests {
use super::*;
use alloc::vec;
use axelar_soroban_std::assert_ok;
use core::u128;
use soroban_sdk::{Bytes, BytesN, Env, String};
use std::vec::Vec;

Expand All @@ -264,28 +263,28 @@ mod tests {
let env = Env::default();

let plain_string = "hello world";
let plain_string_soroban = String::from_str(&env, &plain_string);
let plain_string_soroban = String::from_str(&env, plain_string);
assert_eq!(
to_std_string(plain_string_soroban).unwrap(),
StdString::from(plain_string)
);

let var_length_chars = "🎉中🚀π🌈€";
let var_length_chars_soroban = String::from_str(&env, &var_length_chars);
let var_length_chars_soroban = String::from_str(&env, var_length_chars);
assert_eq!(
to_std_string(var_length_chars_soroban).unwrap(),
StdString::from(var_length_chars)
);

let null_bytes = "Hello\x00World";
let null_bytes_soroban = String::from_str(&env, &null_bytes);
let null_bytes_soroban = String::from_str(&env, null_bytes);
assert_eq!(
to_std_string(null_bytes_soroban).unwrap(),
StdString::from(null_bytes)
);

let escape_char = "Hello\tWorld";
let escape_char_soroban = String::from_str(&env, &escape_char);
let escape_char_soroban = String::from_str(&env, escape_char);
assert_eq!(
to_std_string(escape_char_soroban).unwrap(),
StdString::from(escape_char)
Expand All @@ -297,11 +296,11 @@ mod tests {
let env = Env::default();

let invalid_sequences = vec![
String::from_bytes(&env, &vec![0xF5, 0x90, 0x80]), // not valid utf-8
String::from_bytes(&env, &vec![0x00, 0x01, 0x02, 0xC0]), // valid ASCII characters followed by an invalid UTF-8 starting byte
String::from_bytes(&env, &vec![0xC0, 0x80, 0xF5, 0x90]), // invalid UTF-8 starting byte followed by valid UTF-8 sequences
String::from_bytes(&env, &vec![0xF0, 0x90, 0x80, 0xDF, 0xFB, 0xBF]), // surrogate pairs with invalid charaters "\uD800\uDDFF"
String::from_bytes(&env, &vec![0xF4, 0x90, 0x80, 0x80]), // outside the Basic Multilingual Plane
String::from_bytes(&env, &[0xF5, 0x90, 0x80]), // not valid utf-8
String::from_bytes(&env, &[0x00, 0x01, 0x02, 0xC0]), // valid ASCII characters followed by an invalid UTF-8 starting byte
String::from_bytes(&env, &[0xC0, 0x80, 0xF5, 0x90]), // invalid UTF-8 starting byte followed by valid UTF-8 sequences
String::from_bytes(&env, &[0xF0, 0x90, 0x80, 0xDF, 0xFB, 0xBF]), // surrogate pairs with invalid charaters "\uD800\uDDFF"
String::from_bytes(&env, &[0xF4, 0x90, 0x80, 0x80]), // outside the Basic Multilingual Plane
];

for sequence in invalid_sequences {
Expand Down Expand Up @@ -358,7 +357,7 @@ mod tests {
#[test]
fn interchain_transfer_encode_decode() {
let env = Env::default();
let remote_chain = String::from_str(&env, &"chain");
let remote_chain = String::from_str(&env, "chain");

let cases = vec![
types::HubMessage::SendToHub {
Expand All @@ -367,10 +366,9 @@ mod tests {
token_id: BytesN::from_array(&env, &[0u8; 32]),
source_address: bytes_from_hex(&env, "00"),
destination_address: bytes_from_hex(&env, "00"),
amount: 1u64.try_into().unwrap(),
amount: 1u64.into(),
data: None,
})
.into(),
}),
},
types::HubMessage::SendToHub {
destination_chain: remote_chain.clone(),
Expand All @@ -386,22 +384,20 @@ mod tests {
),
amount: i128::MAX,
data: Some(bytes_from_hex(&env, "abcd")),
})
.into(),
}),
},
types::HubMessage::ReceiveFromHub {
source_chain: remote_chain.clone(),
message: types::Message::InterchainTransfer(types::InterchainTransfer {
token_id: BytesN::from_array(&env, &[0u8; 32]),
source_address: bytes_from_hex(&env, "00"),
destination_address: bytes_from_hex(&env, "00"),
amount: 1u64.try_into().unwrap(),
amount: 1u64.into(),
data: None,
})
.into(),
}),
},
types::HubMessage::ReceiveFromHub {
source_chain: remote_chain.clone(),
source_chain: remote_chain,
message: types::Message::InterchainTransfer(types::InterchainTransfer {
token_id: BytesN::from_array(&env, &[255u8; 32]),
source_address: bytes_from_hex(
Expand All @@ -414,8 +410,7 @@ mod tests {
),
amount: i128::MAX,
data: Some(bytes_from_hex(&env, "abcd")),
})
.into(),
}),
},
];

Expand All @@ -442,74 +437,68 @@ mod tests {
#[test]
fn deploy_interchain_token_encode_decode() {
let env = Env::default();
let remote_chain = String::from_str(&env, &"chain");
let remote_chain = String::from_str(&env, "chain");

let cases = vec![
types::HubMessage::SendToHub {
destination_chain: remote_chain.clone(),
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[0u8; 32]),
name: String::from_str(&env, &"t"),
symbol: String::from_str(&env, &"T"),
name: String::from_str(&env, "t"),
symbol: String::from_str(&env, "T"),
decimals: 0,
minter: None,
})
.into(),
}),
},
types::HubMessage::SendToHub {
destination_chain: remote_chain.clone(),
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[1u8; 32]),
name: String::from_str(&env, &"Test Token"),
symbol: String::from_str(&env, &"TST"),
name: String::from_str(&env, "Test Token"),
symbol: String::from_str(&env, "TST"),
decimals: 18,
minter: Some(bytes_from_hex(&env, "1234")),
})
.into(),
}),
},
types::HubMessage::SendToHub {
destination_chain: remote_chain.clone(),
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[0u8; 32]),
name: String::from_str(&env, &"Unicode Token 🪙"),
symbol: String::from_str(&env, &"UNI🔣"),
name: String::from_str(&env, "Unicode Token 🪙"),
symbol: String::from_str(&env, "UNI🔣"),
decimals: 255,
minter: Some(bytes_from_hex(&env, "abcd")),
})
.into(),
}),
},
types::HubMessage::ReceiveFromHub {
source_chain: remote_chain.clone(),
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[0u8; 32]),
name: String::from_str(&env, &"t"),
symbol: String::from_str(&env, &"T"),
name: String::from_str(&env, "t"),
symbol: String::from_str(&env, "T"),
decimals: 0,
minter: None,
})
.into(),
}),
},
types::HubMessage::ReceiveFromHub {
source_chain: remote_chain.clone(),
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[1u8; 32]),
name: String::from_str(&env, &"Test Token"),
symbol: String::from_str(&env, &"TST"),
name: String::from_str(&env, "Test Token"),
symbol: String::from_str(&env, "TST"),
decimals: 18,
minter: Some(bytes_from_hex(&env, "1234")),
})
.into(),
}),
},
types::HubMessage::ReceiveFromHub {
source_chain: remote_chain.clone(),
source_chain: remote_chain,
message: types::Message::DeployInterchainToken(types::DeployInterchainToken {
token_id: BytesN::from_array(&env, &[0u8; 32]),
name: String::from_str(&env, &"Unicode Token 🪙"),
symbol: String::from_str(&env, &"UNI🔣"),
name: String::from_str(&env, "Unicode Token 🪙"),
symbol: String::from_str(&env, "UNI🔣"),
decimals: 255,
minter: Some(bytes_from_hex(&env, "abcd")),
})
.into(),
}),
},
];

Expand Down Expand Up @@ -547,7 +536,7 @@ mod tests {
token_id: BytesN::from_array(&env, &[0u8; 32]),
source_address: bytes_from_hex(&env, "00"),
destination_address: bytes_from_hex(&env, "00"),
amount: 1u64.try_into().unwrap(),
amount: 1u64.into(),
data: None,
}
)
Expand Down
1 change: 1 addition & 0 deletions contracts/interchain-token-service/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use soroban_sdk::{contractclient, Address, Bytes, BytesN, Env, String};

use crate::error::ContractError;

#[allow(dead_code)]
#[contractclient(name = "InterchainTokenServiceClient")]
pub trait InterchainTokenServiceInterface: AxelarExecutableInterface {
fn trusted_address(env: &Env, chain: String) -> Option<String>;
Expand Down
5 changes: 2 additions & 3 deletions contracts/interchain-token-service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![no_std]

mod abi;
mod contract;
pub mod error;
mod event;
mod interface;
mod storage_types;
mod types;

pub mod contract;

#[cfg(test)]
extern crate std;

pub use contract::InterchainTokenServiceClient;
pub use contract::{InterchainTokenService, InterchainTokenServiceClient};
4 changes: 2 additions & 2 deletions contracts/interchain-token-service/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use axelar_gas_service::{AxelarGasService, AxelarGasServiceClient};
use axelar_gateway::testutils;
use axelar_gateway::AxelarGatewayClient;
use interchain_token_service::contract::{InterchainTokenService, InterchainTokenServiceClient};
use interchain_token_service::error::ContractError;
use interchain_token_service::{InterchainTokenService, InterchainTokenServiceClient};

use axelar_soroban_std::{assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event};

Expand All @@ -16,7 +16,7 @@ fn setup_gateway<'a>(env: &Env) -> AxelarGatewayClient<'a> {

fn setup_gas_service<'a>(env: &Env) -> AxelarGasServiceClient<'a> {
let owner: Address = Address::generate(env);
let gas_collector: Address = Address::generate(&env);
let gas_collector: Address = Address::generate(env);
let gas_service_id = env.register(AxelarGasService, (&owner, &gas_collector));
let gas_service_client = AxelarGasServiceClient::new(env, &gas_service_id);

Expand Down
1 change: 1 addition & 0 deletions contracts/interchain-token/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use soroban_sdk::{contractclient, token, Address, BytesN, Env};

use crate::error::ContractError;

#[allow(dead_code)]
#[contractclient(name = "InterchainTokenClient")]
pub trait InterchainTokenInterface: token::Interface {
fn token_id(env: &Env) -> BytesN<32>;
Expand Down
2 changes: 1 addition & 1 deletion contracts/interchain-token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ cfg_if::cfg_if! {
} else {
mod event;
mod storage_types;
mod contract;

pub mod contract;
pub use contract::{InterchainToken, InterchainTokenClient};
}
}
Loading

0 comments on commit ebb5c82

Please sign in to comment.