Skip to content

Commit

Permalink
IBC precompile with default timeout height and timestamp (#167)
Browse files Browse the repository at this point in the history
* - ibc precompile with default timeout height and timestamp

* generate changeset

* update to patch
  • Loading branch information
dssei authored May 6, 2024
1 parent 2acf2d2 commit 4a934b7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-gorillas-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sei-js/evm": patch
---

IBC precompile transfer with default timeout height/timestamp
7 changes: 4 additions & 3 deletions packages/evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 28 additions & 2 deletions packages/evm/src/precompiles/ibc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>;

}

/**
Expand Down Expand Up @@ -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'
},

];

/**
Expand Down

0 comments on commit 4a934b7

Please sign in to comment.