Skip to content

Commit

Permalink
add cb signature
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Sep 27, 2023
1 parent 9a2f531 commit 5052c3b
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 98 deletions.
22 changes: 14 additions & 8 deletions integration_tests/contracts/contracts/TestICA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ contract TestICA {
address constant icaContract = 0x0000000000000000000000000000000000000066;
IICAModule ica = IICAModule(icaContract);
address account;
// sha256('cronos-evm')[:20]
address constant module_address = 0x89A7EF2F08B1c018D5Cc88836249b84Dd5392905;
uint64 lastAckSeq;
event OnAcknowledgementPacketResult(uint64 seq, bytes acknowledgement);
event OnTimeoutPacketResult(uint64 seq);
bytes lastAck;
mapping (uint64 => bytes) public acknowledgement;
event OnPacketResult(uint64 seq, bytes ack);

function encodeRegister(string memory connectionID, string memory version) internal view returns (bytes memory) {
return abi.encodeWithSignature(
Expand Down Expand Up @@ -95,13 +98,16 @@ contract TestICA {
return lastAckSeq;
}

function onAcknowledgementPacketCallback(uint64 seq, address packetSenderAddress, bytes calldata acknowledgement) public {
require(packetSenderAddress == address(this), "different sender");
emit OnAcknowledgementPacketResult(seq, acknowledgement);
function getLastAck() public view returns (bytes memory) {
return lastAck;
}

function onTimeoutPacketCallback(uint64 seq, address packetSenderAddress) public {
require(packetSenderAddress == address(this), "different sender");
emit OnTimeoutPacketResult(seq);
function onPacketResultCallback(uint64 seq, bytes calldata ack) external payable returns (bool) {
// require(msg.sender == module_address);
lastAckSeq = seq;
lastAck = ack;
acknowledgement[seq] = ack;
emit OnPacketResult(seq, ack);
return true;
}
}
4 changes: 4 additions & 0 deletions integration_tests/test_ica_precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def submit_msgs_ro(func, str):
submit_msgs_ro(tcontract.functions.staticSubmitMsgs, str)
assert tcontract.caller.getLastAckSeq() == seq
balance -= amt
ack = tcontract.caller.getLastAck()
assert ack == tcontract.caller.acknowledgement(seq)
assert cli_host.balance(ica_address, denom=denom) == balance
seq = 2
str = submit_msgs(
Expand All @@ -206,3 +208,5 @@ def submit_msgs_ro(func, str):
balance -= amt
balance -= amt1
assert cli_host.balance(ica_address, denom=denom) == balance
ack = tcontract.caller.getLastAck()
assert ack == tcontract.caller.acknowledgement(seq)
2 changes: 2 additions & 0 deletions scripts/gen-bindings-contracts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ solc08 --abi --bin x/cronos/events/bindings/src/CosmosTypes.sol -o build --overw
solc08 --abi --bin x/cronos/events/bindings/src/Relayer.sol -o build --overwrite
solc08 --abi --bin x/cronos/events/bindings/src/Bank.sol -o build --overwrite
solc08 --abi --bin x/cronos/events/bindings/src/ICA.sol -o build --overwrite
solc08 --abi --bin x/cronos/events/bindings/src/ICACallback.sol -o build --overwrite


abigen --pkg lib --abi build/CosmosTypes.abi --bin build/CosmosTypes.bin --out x/cronos/events/bindings/cosmos/lib/cosmos_types.abigen.go --type CosmosTypes
abigen --pkg relayer --abi build/IRelayerModule.abi --bin build/IRelayerModule.bin --out x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_module.abigen.go --type RelayerModule
abigen --pkg bank --abi build/IBankModule.abi --bin build/IBankModule.bin --out x/cronos/events/bindings/cosmos/precompile/bank/i_bank_module.abigen.go --type BankModule
abigen --pkg ica --abi build/IICAModule.abi --bin build/IICAModule.bin --out x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go --type ICAModule
abigen --pkg icacallback --abi build/ICACallback.abi --bin build/ICACallback.bin --out x/cronos/events/bindings/cosmos/precompile/icacallback/icacallback.abigen.go --type ICACallback

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

Loading

0 comments on commit 5052c3b

Please sign in to comment.