From 8ceb5eecf816fce117b9e8e7b9b4078eac8ffea6 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 29 Feb 2024 23:30:32 +0800 Subject: [PATCH] Execute with command decoded --- contracts/src/AgentExecutor.sol | 3 +-- contracts/src/Gateway.sol | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/src/AgentExecutor.sol b/contracts/src/AgentExecutor.sol index 459bec5950..bbfc295c73 100644 --- a/contracts/src/AgentExecutor.sol +++ b/contracts/src/AgentExecutor.sol @@ -19,8 +19,7 @@ contract AgentExecutor { /// @dev Execute a message which originated from the Polkadot side of the bridge. In other terms, /// the `data` parameter is constructed by the BridgeHub parachain. /// - function execute(bytes memory data) external { - (AgentExecuteCommand command, bytes memory params) = abi.decode(data, (AgentExecuteCommand, bytes)); + function execute(AgentExecuteCommand command, bytes memory params) external { if (command == AgentExecuteCommand.TransferToken) { (address token, address recipient, uint128 amount) = abi.decode(params, (address, address, uint128)); _transferToken(token, recipient, amount); diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index 055afc8e47..626b401a4d 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -282,7 +282,7 @@ contract Gateway is IGateway, IInitializable { } } - bytes memory call = abi.encodeCall(AgentExecutor.execute, params.payload); + bytes memory call = abi.encodeCall(AgentExecutor.execute, (command, commandParams)); (bool success, bytes memory returndata) = Agent(payable(agent)).invoke(AGENT_EXECUTOR, call); if (!success) {