Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0606bae
test: assets precompile integration test
Daanvdplas Oct 21, 2025
55470d5
fix: fmt
Daanvdplas Oct 22, 2025
ae40b0a
feat: test events in sandbox environment
Daanvdplas Oct 23, 2025
c46d9f2
last minor changes
Daanvdplas Oct 23, 2025
62deaf4
fix: compilation error for custom sandbox usage
Daanvdplas Oct 24, 2025
11c5687
chore: Cargo.toml file edit precompile crate
Daanvdplas Oct 24, 2025
615b111
test: assets apis tests
Daanvdplas Oct 24, 2025
cbd8c66
refactor: account handling e2e framework
Daanvdplas Oct 24, 2025
3656075
test: test macro helpers
Daanvdplas Oct 27, 2025
2a5bb22
fix: remove benchmark in sandbox
Daanvdplas Oct 27, 2025
30ec400
small place changes
Daanvdplas Oct 27, 2025
28968be
fmt
Daanvdplas Oct 27, 2025
0035549
fix ci and resolve copilot comment
Daanvdplas Oct 27, 2025
7ed1765
fmt
Daanvdplas Oct 27, 2025
f695d19
refactor: copy assert_last_event functionality as in frame
Daanvdplas Oct 31, 2025
47d6015
fix: ci
Daanvdplas Oct 31, 2025
f71102f
Merge branch 'master' into daan/test-assets_precompile_integration_test
Daanvdplas Nov 3, 2025
eeecb2d
Merge remote-tracking branch 'origin/master' into daan/test-assets_pr…
cmichi Nov 9, 2025
bdcf5f0
Revert `pub`
cmichi Nov 9, 2025
a4fc09b
Fix links and doc comment
cmichi Nov 9, 2025
8bdff3d
Revert "Revert `pub`"
cmichi Nov 9, 2025
a0df1c2
Update lockfile
cmichi Nov 9, 2025
7d98db0
Merge remote-tracking branch 'origin/master' into daan/test-assets_pr…
cmichi Nov 10, 2025
f13b8a8
Add trust-backed + pool-assets config to `Environment`
cmichi Nov 10, 2025
f9275fa
Merge remote-tracking branch 'origin/master' into daan/test-assets_pr…
cmichi Nov 10, 2025
1627411
Add missing env props
cmichi Nov 10, 2025
a8ea0e3
Fix config
cmichi Nov 10, 2025
f5e1704
Fix tests
cmichi Nov 10, 2025
d2c3c43
Reexport `ink_precompiles`
cmichi Nov 10, 2025
418d789
Reexport `ink_precompiles` from `ink`
cmichi Nov 10, 2025
dff5f9c
Revert "Reexport `ink_precompiles` from `ink`"
cmichi Nov 10, 2025
dc62213
Fix tests
cmichi Nov 10, 2025
8449e34
Revert "Fix tests"
cmichi Nov 11, 2025
a20f80e
Revert "Reexport `ink_precompiles`"
cmichi Nov 11, 2025
8edeb01
Fix CI
cmichi Nov 11, 2025
9f0bdc4
Fix tests
cmichi Nov 11, 2025
05bdd67
Fix doc tests
cmichi Nov 11, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657)
- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655)
- Implement XCM precompile, stabilize XCM API - [#2687](https://github.com/use-ink/ink/pull/2687)
- Add `ink_precompiles` crate with ERC-20 assets precompile interface - [#2686](https://github.com/use-ink/ink/pull/2686)

### Changed
- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578)
Expand Down
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/ink/ir",
"crates/ink/macro",
"crates/metadata",
"crates/precompiles",
"crates/revive-types",
"crates/prelude",
"crates/primitives",
Expand Down Expand Up @@ -115,6 +116,7 @@ ink_env = { version = "=6.0.0-beta", path = "crates/env", default-features = fal
ink_ir = { version = "=6.0.0-beta", path = "crates/ink/ir", default-features = false }
ink_macro = { version = "=6.0.0-beta", path = "crates/ink/macro", default-features = false }
ink_metadata = { version = "=6.0.0-beta", path = "crates/metadata", default-features = false }
ink_precompiles = { version = "=6.0.0-beta", path = "crates/precompiles", default-features = false }
ink_prelude = { version = "=6.0.0-beta", path = "crates/prelude", default-features = false }
ink_primitives = { version = "=6.0.0-beta", path = "crates/primitives", default-features = false }
ink_revive_types = { version = "=6.0.0-beta", path = "crates/revive-types", default-features = false }
Expand Down
25 changes: 25 additions & 0 deletions crates/e2e/src/contract_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,31 @@ impl<E: Environment, V, EventLog, Abi> CallResult<E, V, EventLog, Abi> {
pub fn return_data(&self) -> &[u8] {
&self.dry_run.exec_return_value().data
}

/// Returns the error from nested contract calls (e.g., precompile errors)
/// if available in the trace, otherwise returns the raw error data.
pub fn extract_error(&self) -> Option<String> {
if !self.dry_run.did_revert() {
return None;
}

// Check trace for error information
if let Some(trace) = &self.trace {
// // Check nested calls first (more specific errors)
for call in &trace.calls {
if let Some(error) = &call.error {
return Some(error.clone());
}
}

// Then check top-level error
if let Some(error) = &trace.error {
return Some(error.clone());
}
}
// Fallback to raw data
Some(format!("{:?}", self.return_data()))
}
}

// TODO(#xxx) Improve the `Debug` implementation.
Expand Down
19 changes: 19 additions & 0 deletions crates/e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,22 @@ where
{
<<Contract as ContractCallBuilder>::Type<Abi> as FromAddr>::from_addr(acc_id)
}

/// Extension trait for converting various types to Address (H160).
pub trait IntoAddress {
/// Convert to an Address (H160).
fn address(&self) -> Address;
}
Comment thread
Daanvdplas marked this conversation as resolved.

impl IntoAddress for Keypair {
fn address(&self) -> Address {
AccountIdMapper::to_address(&self.public_key().0)
}
}

impl IntoAddress for ink_primitives::AccountId {
fn address(&self) -> Address {
let bytes = *AsRef::<[u8; 32]>::as_ref(self);
AccountIdMapper::to_address(&bytes)
}
}
4 changes: 3 additions & 1 deletion crates/ink/codegen/src/generator/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ impl GenerateCode for Env<'_> {
type Hash = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::Hash;
type Timestamp = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::Timestamp;
type BlockNumber = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::BlockNumber;
const NATIVE_TO_ETH_RATIO: u32 = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::NATIVE_TO_ETH_RATIO;
type EventRecord = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::EventRecord;
const NATIVE_TO_ETH_RATIO: u32 = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::NATIVE_TO_ETH_RATIO;
const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::TRUST_BACKED_ASSETS_PRECOMPILE_INDEX;
const POOL_ASSETS_PRECOMPILE_INDEX: u16 = <<#storage_ident as ::ink::env::ContractEnv>::Env as ::ink::env::Environment>::POOL_ASSETS_PRECOMPILE_INDEX;

type Address = ::ink::primitives::Address;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/ink/codegen/src/generator/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ impl Metadata<'_> {
.timestamp(#timestamp)
.block_number(#block_number)
.native_to_eth_ratio(NATIVE_TO_ETH_RATIO)
.trust_backed_assets_precompile_index(
TRUST_BACKED_ASSETS_PRECOMPILE_INDEX,
)
.pool_assets_precompile_index(POOL_ASSETS_PRECOMPILE_INDEX)
.static_buffer_size(#buffer_size_const)
.done()
)
Expand Down
8 changes: 8 additions & 0 deletions crates/ink/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream {
///
/// impl ink_env::Environment for MyEnvironment {
/// const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// type AccountId = [u8; 16];
/// type Balance = u128;
/// type Hash = [u8; 32];
Expand All @@ -187,6 +189,8 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream {
/// #
/// # impl ink_env::Environment for MyEnvironment {
/// # const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// # const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// # const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// # type AccountId = [u8; 16];
/// # type Balance = u128;
/// # type Hash = [u8; 32];
Expand Down Expand Up @@ -776,6 +780,8 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// impl ink_env::Environment for MyEnvironment {
/// const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// type AccountId = [u8; 16];
/// type Balance = u128;
/// type Hash = [u8; 32];
Expand All @@ -800,6 +806,8 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// #
/// # impl ink_env::Environment for MyEnvironment {
/// # const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// # const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// # const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// # type AccountId = [u8; 16];
/// # type Balance = u128;
/// # type Hash = [u8; 32];
Expand Down
2 changes: 2 additions & 0 deletions crates/ink/src/contract_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ use ink_primitives::Address;
///
/// impl ink_env::Environment for CustomEnv {
/// const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// type AccountId = [u8; 32];
/// type Balance = u64;
/// type Hash = [u8; 32];
Expand Down
2 changes: 2 additions & 0 deletions crates/ink/src/message_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
///
/// impl ink_env::Environment for CustomEnv {
/// const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
/// const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
/// const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
/// type AccountId = [u8; 32];
/// type Balance = u64;
/// type Hash = [u8; 32];
Expand Down
2 changes: 2 additions & 0 deletions crates/ink/tests/ui/contract/pass/config-custom-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pub struct CustomEnv;

impl ink_env::Environment for CustomEnv {
const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
const TRUST_BACKED_ASSETS_PRECOMPILE_INDEX: u16 = 0x0120;
const POOL_ASSETS_PRECOMPILE_INDEX: u16 = 0x0320;
type AccountId = [u8; 32];
type Balance = u64;
type Hash = [u8; 32];
Expand Down
Loading
Loading