Skip to content

Commit

Permalink
set chain_id in test runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrill Leutwiler <[email protected]>
  • Loading branch information
xermicus committed Sep 28, 2024
1 parent 287272b commit 066acc4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions crates/integration/contracts/Context.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ pragma solidity ^0.8;
},
"data": "fc9c8d39"
}
},
{
"Call": {
"dest": {
"Instantiated": 0
},
"data": "3af973b1"
}
}
]
}
Expand All @@ -43,4 +51,12 @@ contract Context {
function caller() public view returns (address ret) {
ret = msg.sender;
}

function chain_id() public view returns (uint) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
}
2 changes: 1 addition & 1 deletion crates/llvm-context/src/polkavm/evm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn chain_id<'ctx, D>(
where
D: Dependency + Clone,
{
Ok(context.word_const(0).as_basic_value_enum())
context.build_runtime_call_to_getter(runtime_api::imports::CHAIN_ID)
}

/// Translates the `block_number` instruction.
Expand Down
1 change: 1 addition & 0 deletions crates/runner/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ impl pallet_revive::Config for Runtime {
type InstantiateOrigin = EnsureSigned<AccountId32>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type ChainId = ConstU64<420_420_420>;
}

0 comments on commit 066acc4

Please sign in to comment.