-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query for pointer in registry (#1508)
- Loading branch information
Showing
13 changed files
with
884 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
package seiprotocol.seichain.evm; | ||
|
||
option go_package = "github.com/sei-protocol/sei-chain/x/evm/types"; | ||
|
||
enum PointerType { | ||
ERC20 = 0; | ||
ERC721 = 1; | ||
NATIVE = 2; | ||
CW20 = 3; | ||
CW721 = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" | ||
"github.com/sei-protocol/sei-chain/x/evm/artifacts/cw20" | ||
"github.com/sei-protocol/sei-chain/x/evm/artifacts/cw721" | ||
"github.com/sei-protocol/sei-chain/x/evm/artifacts/erc20" | ||
"github.com/sei-protocol/sei-chain/x/evm/artifacts/erc721" | ||
"github.com/sei-protocol/sei-chain/x/evm/artifacts/native" | ||
"github.com/sei-protocol/sei-chain/x/evm/keeper" | ||
"github.com/sei-protocol/sei-chain/x/evm/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestQueryPointer(t *testing.T) { | ||
k, ctx := testkeeper.MockEVMKeeper() | ||
seiAddr1, evmAddr1 := testkeeper.MockAddressPair() | ||
seiAddr2, evmAddr2 := testkeeper.MockAddressPair() | ||
seiAddr3, evmAddr3 := testkeeper.MockAddressPair() | ||
seiAddr4, evmAddr4 := testkeeper.MockAddressPair() | ||
seiAddr5, evmAddr5 := testkeeper.MockAddressPair() | ||
goCtx := sdk.WrapSDKContext(ctx) | ||
k.SetERC20NativePointer(ctx, seiAddr1.String(), evmAddr1) | ||
k.SetERC20CW20Pointer(ctx, seiAddr2.String(), evmAddr2) | ||
k.SetERC721CW721Pointer(ctx, seiAddr3.String(), evmAddr3) | ||
k.SetCW20ERC20Pointer(ctx, evmAddr4, seiAddr4.String()) | ||
k.SetCW721ERC721Pointer(ctx, evmAddr5, seiAddr5.String()) | ||
q := keeper.Querier{k} | ||
res, err := q.Pointer(goCtx, &types.QueryPointerRequest{PointerType: types.PointerType_NATIVE, Pointee: seiAddr1.String()}) | ||
require.Nil(t, err) | ||
require.Equal(t, types.QueryPointerResponse{Pointer: evmAddr1.Hex(), Version: uint32(native.CurrentVersion), Exists: true}, *res) | ||
res, err = q.Pointer(goCtx, &types.QueryPointerRequest{PointerType: types.PointerType_CW20, Pointee: seiAddr2.String()}) | ||
require.Nil(t, err) | ||
require.Equal(t, types.QueryPointerResponse{Pointer: evmAddr2.Hex(), Version: uint32(cw20.CurrentVersion), Exists: true}, *res) | ||
res, err = q.Pointer(goCtx, &types.QueryPointerRequest{PointerType: types.PointerType_CW721, Pointee: seiAddr3.String()}) | ||
require.Nil(t, err) | ||
require.Equal(t, types.QueryPointerResponse{Pointer: evmAddr3.Hex(), Version: uint32(cw721.CurrentVersion), Exists: true}, *res) | ||
res, err = q.Pointer(goCtx, &types.QueryPointerRequest{PointerType: types.PointerType_ERC20, Pointee: evmAddr4.Hex()}) | ||
require.Nil(t, err) | ||
require.Equal(t, types.QueryPointerResponse{Pointer: seiAddr4.String(), Version: uint32(erc20.CurrentVersion), Exists: true}, *res) | ||
res, err = q.Pointer(goCtx, &types.QueryPointerRequest{PointerType: types.PointerType_ERC721, Pointee: evmAddr5.Hex()}) | ||
require.Nil(t, err) | ||
require.Equal(t, types.QueryPointerResponse{Pointer: seiAddr5.String(), Version: uint32(erc721.CurrentVersion), Exists: true}, *res) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.