From bffefdfc9acf0b02ba21999e1a632f74b197f8d1 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 27 Sep 2023 14:27:51 +0800 Subject: [PATCH] Apply suggestions from code review --- .../contracts/contracts/TestICA.sol | 1 + .../precompile/ica/i_ica_module.abigen.go | 23 +------------------ x/cronos/events/bindings/src/ICA.sol | 1 - 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/integration_tests/contracts/contracts/TestICA.sol b/integration_tests/contracts/contracts/TestICA.sol index a1d7797493..bb54100539 100644 --- a/integration_tests/contracts/contracts/TestICA.sol +++ b/integration_tests/contracts/contracts/TestICA.sol @@ -103,6 +103,7 @@ contract TestICA { } function onPacketResultCallback(uint64 seq, bytes calldata ack) external payable returns (bool) { + // To prevent called by arbitrary user // require(msg.sender == module_address); lastAckSeq = seq; lastAck = ack; diff --git a/x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go b/x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go index 2709567df8..7f05447446 100644 --- a/x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go +++ b/x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go @@ -30,7 +30,7 @@ var ( // ICAModuleMetaData contains all meta data concerning the ICAModule contract. var ICAModuleMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"seq\",\"type\":\"uint64\"}],\"name\":\"SubmitMsgsResult\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"seq\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"packetSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"ack\",\"type\":\"bytes\"}],\"name\":\"onPacketResult\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"queryAccount\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"version\",\"type\":\"string\"}],\"name\":\"registerAccount\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"timeout\",\"type\":\"uint256\"}],\"name\":\"submitMsgs\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"seq\",\"type\":\"uint64\"}],\"name\":\"SubmitMsgsResult\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"queryAccount\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"version\",\"type\":\"string\"}],\"name\":\"registerAccount\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"connectionID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"timeout\",\"type\":\"uint256\"}],\"name\":\"submitMsgs\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", } // ICAModuleABI is the input ABI used to generate the binding from. @@ -210,27 +210,6 @@ func (_ICAModule *ICAModuleCallerSession) QueryAccount(connectionID string, addr return _ICAModule.Contract.QueryAccount(&_ICAModule.CallOpts, connectionID, addr) } -// OnPacketResult is a paid mutator transaction binding the contract method 0x15400f96. -// -// Solidity: function onPacketResult(uint64 seq, address packetSenderAddress, bytes ack) payable returns(bool) -func (_ICAModule *ICAModuleTransactor) OnPacketResult(opts *bind.TransactOpts, seq uint64, packetSenderAddress common.Address, ack []byte) (*types.Transaction, error) { - return _ICAModule.contract.Transact(opts, "onPacketResult", seq, packetSenderAddress, ack) -} - -// OnPacketResult is a paid mutator transaction binding the contract method 0x15400f96. -// -// Solidity: function onPacketResult(uint64 seq, address packetSenderAddress, bytes ack) payable returns(bool) -func (_ICAModule *ICAModuleSession) OnPacketResult(seq uint64, packetSenderAddress common.Address, ack []byte) (*types.Transaction, error) { - return _ICAModule.Contract.OnPacketResult(&_ICAModule.TransactOpts, seq, packetSenderAddress, ack) -} - -// OnPacketResult is a paid mutator transaction binding the contract method 0x15400f96. -// -// Solidity: function onPacketResult(uint64 seq, address packetSenderAddress, bytes ack) payable returns(bool) -func (_ICAModule *ICAModuleTransactorSession) OnPacketResult(seq uint64, packetSenderAddress common.Address, ack []byte) (*types.Transaction, error) { - return _ICAModule.Contract.OnPacketResult(&_ICAModule.TransactOpts, seq, packetSenderAddress, ack) -} - // RegisterAccount is a paid mutator transaction binding the contract method 0xddc7b6a7. // // Solidity: function registerAccount(string connectionID, string version) payable returns(bool) diff --git a/x/cronos/events/bindings/src/ICA.sol b/x/cronos/events/bindings/src/ICA.sol index 2b68f92243..31f10530a7 100644 --- a/x/cronos/events/bindings/src/ICA.sol +++ b/x/cronos/events/bindings/src/ICA.sol @@ -6,5 +6,4 @@ interface IICAModule { function registerAccount(string calldata connectionID, string calldata version) external payable returns (bool); function queryAccount(string calldata connectionID, address addr) external view returns (string memory); function submitMsgs(string calldata connectionID, bytes calldata data, uint256 timeout) external payable returns (uint64); - function onPacketResult(uint64 seq, address packetSenderAddress, bytes calldata ack) external payable returns (bool); }