Skip to content

Commit

Permalink
Add gov proposal v2 for native pointer (#1711)
Browse files Browse the repository at this point in the history
* Add gov proposal v2 for native pointer

* disable upgrade test

* test
  • Loading branch information
codchen authored Jun 5, 2024
1 parent 3862f3b commit 083588f
Show file tree
Hide file tree
Showing 14 changed files with 623 additions and 515 deletions.
6 changes: 5 additions & 1 deletion contracts/test/CW20toERC20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ describe("CW20 to ERC20 Pointer", function () {
1: 1000000000000
});

describe("Pointer Upgrade", function () {
// Pointer version is going to be coupled with seid version going forward (as in,
// given a seid version, it's impossible to have multiple versions of pointer).
// We need to recreate the equivalent of the following test once we have a framework
// for simulating chain-level upgrade.
describe.skip("Pointer Upgrade", function () {
let newPointer;

before(async function () {
Expand Down
6 changes: 5 additions & 1 deletion contracts/test/ERC20toCW20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ describe("ERC20 to CW20 Pointer", function () {
account1: 3000000
});

describe("Pointer Upgrade", function () {
// Pointer version is going to be coupled with seid version going forward (as in,
// given a seid version, it's impossible to have multiple versions of pointer).
// We need to recreate the equivalent of the following test once we have a framework
// for simulating chain-level upgrade.
describe.skip("Pointer Upgrade", function () {
let newPointer;

before(async function () {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.16
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.0
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-17
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-20
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.38
// Latest goleveldb is broken, we have to stick to this version
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1343,8 +1343,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod
github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI=
github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sei-protocol/go-ethereum v1.13.5-sei-17 h1:NQcNuL/nmLCzVJFj6Za4ZrNj1ODTmNKDH6ELrJIEpkY=
github.com/sei-protocol/go-ethereum v1.13.5-sei-17/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ=
github.com/sei-protocol/go-ethereum v1.13.5-sei-20 h1:EA/+30FdFbwAvbkNfkFh1FvjTN1tkZxrFxwzEJ948C0=
github.com/sei-protocol/go-ethereum v1.13.5-sei-20/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.3.16 h1:NVTpiSVExPeETJSLbARB5g3xkOG++/bgSvVtxUZHDNo=
Expand Down
13 changes: 13 additions & 0 deletions proto/evm/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ message AddCWERC721PointerProposal {
string pointer = 4 [(gogoproto.moretags) = "yaml:\"pointer\""];
uint32 version = 5 [(gogoproto.moretags) = "yaml:\"version\""];
}

message AddERCNativePointerProposalV2 {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
string token = 3 [(gogoproto.moretags) = "yaml:\"token\""];
string name = 4 [(gogoproto.moretags) = "yaml:\"name\""];
string symbol = 5 [(gogoproto.moretags) = "yaml:\"symbol\""];
uint32 decimals = 6 [(gogoproto.moretags) = "yaml:\"decimals\""];
}
235 changes: 10 additions & 225 deletions x/evm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,253 +17,38 @@ import (

func NewAddERCNativePointerProposalTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-erc-native-pointer title description token version deposit [pointer address]",
Args: cobra.RangeArgs(5, 6),
Use: "add-erc-native-pointer title description token name symbol decimals deposit",
Args: cobra.ExactArgs(7),
Short: "Submit an add ERC-native pointer proposal",
Long: strings.TrimSpace(`
Submit a proposal to register an ERC pointer contract address for a native token.
Not specifying the pointer address means a proposal that deletes the existing pointer.
Submit a proposal to register an ERC pointer contract for a native token with
provided metadata.
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

version, err := strconv.ParseUint(args[3], 10, 16)
decimals, err := strconv.ParseUint(args[5], 10, 8)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(args[4])
deposit, err := sdk.ParseCoinsNormalized(args[6])
if err != nil {
return err
}
var pointer string
if len(args) == 6 {
pointer = args[5]
}

// Convert proposal to RegisterPairsProposal Type
from := clientCtx.GetFromAddress()

content := types.AddERCNativePointerProposal{
content := types.AddERCNativePointerProposalV2{
Title: args[0],
Description: args[1],
Token: args[2],
Version: uint32(version),
Pointer: pointer,
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewAddERCCW20PointerProposalTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-erc-cw20-pointer title description cw20address version deposit [pointer address]",
Args: cobra.RangeArgs(5, 6),
Short: "Submit an add ERC-CW20 pointer proposal",
Long: strings.TrimSpace(`
Submit a proposal to register an ERC pointer contract address for a CW20 token.
Not specifying the pointer address means a proposal that deletes the existing pointer.
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

version, err := strconv.ParseUint(args[3], 10, 16)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(args[4])
if err != nil {
return err
}
var pointer string
if len(args) == 6 {
pointer = args[5]
}

// Convert proposal to RegisterPairsProposal Type
from := clientCtx.GetFromAddress()

content := types.AddERCCW20PointerProposal{
Title: args[0],
Description: args[1],
Pointee: args[2],
Version: uint32(version),
Pointer: pointer,
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewAddERCCW721PointerProposalTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-erc-cw721-pointer title description cw721address version deposit [pointer address]",
Args: cobra.RangeArgs(5, 6),
Short: "Submit an add ERC-CW721 pointer proposal",
Long: strings.TrimSpace(`
Submit a proposal to register an ERC pointer contract address for a CW721 token.
Not specifying the pointer address means a proposal that deletes the existing pointer.
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

version, err := strconv.ParseUint(args[3], 10, 16)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(args[4])
if err != nil {
return err
}
var pointer string
if len(args) == 6 {
pointer = args[5]
}

// Convert proposal to RegisterPairsProposal Type
from := clientCtx.GetFromAddress()

content := types.AddERCCW721PointerProposal{
Title: args[0],
Description: args[1],
Pointee: args[2],
Version: uint32(version),
Pointer: pointer,
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewAddCWERC20PointerProposalTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-cw-erc20-pointer title description erc20address version deposit [pointer address]",
Args: cobra.RangeArgs(5, 6),
Short: "Submit an add CW-ERC20 pointer proposal",
Long: strings.TrimSpace(`
Submit a proposal to register an CW pointer contract address for a ERC20 token.
Not specifying the pointer address means a proposal that deletes the existing pointer.
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

version, err := strconv.ParseUint(args[3], 10, 16)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(args[4])
if err != nil {
return err
}
var pointer string
if len(args) == 6 {
pointer = args[5]
}

// Convert proposal to RegisterPairsProposal Type
from := clientCtx.GetFromAddress()

content := types.AddCWERC20PointerProposal{
Title: args[0],
Description: args[1],
Pointee: args[2],
Version: uint32(version),
Pointer: pointer,
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewAddCWERC721PointerProposalTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-cw-erc721-pointer title description erc721address version deposit [pointer address]",
Args: cobra.RangeArgs(5, 6),
Short: "Submit an add CW-ERC721 pointer proposal",
Long: strings.TrimSpace(`
Submit a proposal to register an CW pointer contract address for a ERC721 token.
Not specifying the pointer address means a proposal that deletes the existing pointer.
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

version, err := strconv.ParseUint(args[3], 10, 16)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(args[4])
if err != nil {
return err
}
var pointer string
if len(args) == 6 {
pointer = args[5]
}

// Convert proposal to RegisterPairsProposal Type
from := clientCtx.GetFromAddress()

content := types.AddCWERC721PointerProposal{
Title: args[0],
Description: args[1],
Pointee: args[2],
Version: uint32(version),
Pointer: pointer,
Name: args[3],
Symbol: args[4],
Decimals: uint32(decimals),
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from)
Expand Down
4 changes: 0 additions & 4 deletions x/evm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ func GetTxCmd() *cobra.Command {
cmd.AddCommand(RegisterCwPointerCmd())
cmd.AddCommand(RegisterEvmPointerCmd())
cmd.AddCommand(NewAddERCNativePointerProposalTxCmd())
cmd.AddCommand(NewAddERCCW20PointerProposalTxCmd())
cmd.AddCommand(NewAddERCCW721PointerProposalTxCmd())
cmd.AddCommand(NewAddCWERC20PointerProposalTxCmd())
cmd.AddCommand(NewAddCWERC721PointerProposalTxCmd())
cmd.AddCommand(AssociateContractAddressCmd())
cmd.AddCommand(NativeAssociateCmd())

Expand Down
Loading

0 comments on commit 083588f

Please sign in to comment.