Skip to content

Commit

Permalink
IBC transfer precompile for default timeout height and timestamp (sei…
Browse files Browse the repository at this point in the history
…-protocol#1622)

* working draft of ibc with default timeouts

* fixed draft

* tests for transferWithDefaultTimeout method

* move common args validation to a common method

* formatting

* more tests

* get time from block
  • Loading branch information
dssei authored May 6, 2024
1 parent bbac7c2 commit 502a560
Show file tree
Hide file tree
Showing 7 changed files with 674 additions and 61 deletions.
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ func New(
app.DistrKeeper,
app.OracleKeeper,
app.TransferKeeper,
app.IBCKeeper.ClientKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ChannelKeeper,
); err != nil {
panic(err)
}
Expand Down
17 changes: 17 additions & 0 deletions precompiles/common/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package common
import (
"context"

connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
"github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
Expand Down Expand Up @@ -79,3 +83,16 @@ type TransferKeeper interface {
timeoutTimestamp uint64,
) error
}

type ClientKeeper interface {
GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool)
GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
}

type ConnectionKeeper interface {
GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, bool)
}

type ChannelKeeper interface {
GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool)
}
8 changes: 8 additions & 0 deletions precompiles/ibc/IBC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ interface IBC {
uint64 revisionHeight,
uint64 timeoutTimestamp
) external returns (bool success);

function transferWithDefaultTimeout(
string toAddress,
string memory port,
string memory channel,
string memory denom,
uint256 amount
) external returns (bool success);
}
41 changes: 40 additions & 1 deletion precompiles/ibc/abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,46 @@
"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"
}
]
Loading

0 comments on commit 502a560

Please sign in to comment.