From 4a934b7b9e6c6cfeda830cfce09748045e2a8e05 Mon Sep 17 00:00:00 2001 From: Denys S <150304777+dssei@users.noreply.github.com> Date: Mon, 6 May 2024 10:41:07 -0700 Subject: [PATCH] IBC precompile with default timeout height and timestamp (#167) * - ibc precompile with default timeout height and timestamp * generate changeset * update to patch --- .changeset/proud-gorillas-call.md | 5 +++++ packages/evm/README.md | 7 ++++--- packages/evm/src/precompiles/ibc.ts | 30 +++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 .changeset/proud-gorillas-call.md diff --git a/.changeset/proud-gorillas-call.md b/.changeset/proud-gorillas-call.md new file mode 100644 index 00000000..157f592c --- /dev/null +++ b/.changeset/proud-gorillas-call.md @@ -0,0 +1,5 @@ +--- +"@sei-js/evm": patch +--- + +IBC precompile transfer with default timeout height/timestamp diff --git a/packages/evm/README.md b/packages/evm/README.md index dbe6ef71..caaa781c 100644 --- a/packages/evm/README.md +++ b/packages/evm/README.md @@ -230,9 +230,10 @@ The WASM precompile contract facilitates execution, instantiation, and querying The IBC precompile contract facilitates messages exchange between Sei and other IBC compatible blockchains. #### Functions -| Function Name | Input Parameters | Return Value | Description | -|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|----------------------------------------------------------------------------------------------| -| [`transfer`](/sei-js/docs/interfaces/evm.IbcPrecompileFunctions.html#transfer) | `toAddress: ` `string`, `port: ` `string`, `channel: ` `string`, `denom: ` `string`, `amount: ` `ethers.BigNumberish`, `revisionNumber: ` `BigInt`, `revisionHeight: ` `BigInt`, `timeoutTimestamp: ` `BigInt` | `{ success: boolean }` | Transfers tokens from the caller's address to another on a different (IBC compatible) chain. | +| Function Name | Input Parameters | Return Value | Description | +|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`transfer`](/sei-js/docs/interfaces/evm.IbcPrecompileFunctions.html#transfer) | `toAddress: ` `string`, `port: ` `string`, `channel: ` `string`, `denom: ` `string`, `amount: ` `ethers.BigNumberish`, `revisionNumber: ` `BigInt`, `revisionHeight: ` `BigInt`, `timeoutTimestamp: ` `BigInt` | `{ success: boolean }` | Transfers tokens from the caller's address to another on a different (IBC compatible) chain. | +| [`transferWithDefaultTimeout`](/sei-js/docs/interfaces/evm.IbcPrecompileFunctions.html#transferWithDefaultTimeout) | `toAddress: ` `string`, `port: ` `string`, `channel: ` `string`, `denom: ` `string`, `amount: ` `ethers.BigNumberish`| `{ success: boolean }` | Transfers tokens from the caller's address to another on a different (IBC compatible) chain. Calculates default timeout height as opposed to `transfer` function | #### Precompile Addresses 0x0000000000000000000000000000000000001009 diff --git a/packages/evm/src/precompiles/ibc.ts b/packages/evm/src/precompiles/ibc.ts index 9392985e..52b221a3 100644 --- a/packages/evm/src/precompiles/ibc.ts +++ b/packages/evm/src/precompiles/ibc.ts @@ -21,6 +21,18 @@ export interface IbcPrecompileFunctions { transfer(toAddress: string, port: string, channel: string, denom: string, amount: ethers.BigNumberish, revisionNumber: BigInt, revisionHeight: BigInt, timeoutTimestamp: BigInt): Promise<{ success: boolean }>; + /** + * Transfers tokens from the caller's address to another on a different (IBC compatible) chain. + * Calculates the timeout height/timestamp based on the current block timestamp. + * @param toAddress The recipient's address on the other chain + * @param port IBC port in source chain (e.g. 'transfer') + * @param channel IBC channel in source chain (e.g. 'channel-0') + * @param denom The denomination of the tokens to send + * @param amount The amount of tokens to send + */ + transferWithDefaultTimeout(toAddress: string, port: string, channel: string, denom: string, + amount: ethers.BigNumberish): Promise<{ success: boolean }>; + } /** @@ -103,9 +115,23 @@ export const IBC_PRECOMPILE_ABI: Abi = [ ], name: 'transfer', outputs: [{ internalType: 'bool', name: 'success', type: 'bool' }], - stateMutability: 'view', + stateMutability: 'payable', type: 'function' - } + }, + { + inputs: [ + { internalType: 'string', name: 'toAddress', type: 'string' }, + { internalType: 'string', name: 'port', type: 'string' }, + { internalType: 'string', name: 'channel', type: 'string' }, + { internalType: 'string', name: 'denom', type: 'string' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferWithDefaultTimeout', + outputs: [{ internalType: 'bool', name: 'success', type: 'bool' }], + stateMutability: 'payable', + type: 'function' + }, + ]; /**