From 7835c97ca96deeeb31b725c153c7a371776c1abe Mon Sep 17 00:00:00 2001 From: ryanbajollari <54822716+rbajollari@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:39:19 -0500 Subject: [PATCH] fix: Memo in ibc transfer to axelar (#335) ## Description closes: #XXXX --- ### Author Checklist _All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues._ I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] added appropriate labels to the PR - [ ] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist _All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items._ I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- app/upgrades.go | 11 + proto/ojo/gmp/v1/gmp.proto | 15 ++ x/gmp/client/cli/tx.go | 2 +- x/gmp/keeper/keeper.go | 10 +- x/gmp/keeper/msg_server_test.go | 6 +- x/gmp/keeper/params_test.go | 8 +- x/gmp/types/gmp.pb.go | 353 ++++++++++++++++++++++++++++++-- x/gmp/types/msgs.go | 8 +- x/gmp/types/params.go | 17 +- 9 files changed, 391 insertions(+), 39 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 29f8ba58..f1941fd7 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -37,6 +37,7 @@ func (app App) RegisterUpgradeHandlers() { app.registerUpgrade0_3_0(upgradeInfo) app.registerUpgrade0_3_0Rc2(upgradeInfo) app.registerUpgrade0_3_0Rc3(upgradeInfo) + app.registerUpgrade0_3_0Rc4(upgradeInfo) } // performs upgrade from v0.1.3 to v0.1.4 @@ -172,6 +173,16 @@ func (app *App) registerUpgrade0_3_0Rc3(_ upgradetypes.Plan) { ) } +func (app *App) registerUpgrade0_3_0Rc4(_ upgradetypes.Plan) { + const planName = "v0.3.0-rc4" + app.UpgradeKeeper.SetUpgradeHandler(planName, + func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Upgrade handler execution", "name", planName) + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }, + ) +} + // helper function to check if the store loader should be upgraded func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) { if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) { diff --git a/proto/ojo/gmp/v1/gmp.proto b/proto/ojo/gmp/v1/gmp.proto index a9aa24c7..9d5883ef 100644 --- a/proto/ojo/gmp/v1/gmp.proto +++ b/proto/ojo/gmp/v1/gmp.proto @@ -17,6 +17,9 @@ message Params { // The amount of time we'll wait for a response from axelar before timing out. int64 gmp_timeout = 3; + + // The axelar address of the fee recipient. + string fee_recipient = 4; } // GmpMessage defines the GMP message that we encode in the @@ -35,4 +38,16 @@ message GmpMessage { // type is an enum that specifies the type of message int64 type = 4; + + // fee is the fee payed to a relayer on the Axelar network + GmpFee fee = 5; +} + +// GMPFee defines the fee field message inside of GMPMessage. +message GmpFee { + // Fee amount + string amount = 1; + + // Recipient of fee; should be fee_recipient. + string recipient = 2; } diff --git a/x/gmp/client/cli/tx.go b/x/gmp/client/cli/tx.go index b7069e91..277865e0 100644 --- a/x/gmp/client/cli/tx.go +++ b/x/gmp/client/cli/tx.go @@ -59,7 +59,7 @@ func GetCmdRelay() *cobra.Command { tokens := sdk.Coin{} // normalize the coin denom if args[4] != "" { - coin, err := sdk.ParseCoinNormalized(args[7]) + coin, err := sdk.ParseCoinNormalized(args[4]) if err != nil { return err } diff --git a/x/gmp/keeper/keeper.go b/x/gmp/keeper/keeper.go index 05da1518..c8cecc09 100644 --- a/x/gmp/keeper/keeper.go +++ b/x/gmp/keeper/keeper.go @@ -152,10 +152,10 @@ func (k Keeper) BuildGmpRequest( DestinationAddress: msg.OjoContractAddress, Payload: payload, Type: types.TypeGeneralMessage, - } - bz, err := message.Marshal() - if err != nil { - return nil, err + Fee: &types.GmpFee{ + Amount: "1000000", + Recipient: params.FeeRecipient, + }, } // submit IBC transfer @@ -167,7 +167,7 @@ func (k Keeper) BuildGmpRequest( params.GmpAddress, clienttypes.ZeroHeight(), uint64(ctx.BlockTime().Add(time.Duration(params.GmpTimeout)*time.Hour).UnixNano()), - string(bz), + message.String(), ) return transferMsg, nil } diff --git a/x/gmp/keeper/msg_server_test.go b/x/gmp/keeper/msg_server_test.go index 87b0a856..49c1767f 100644 --- a/x/gmp/keeper/msg_server_test.go +++ b/x/gmp/keeper/msg_server_test.go @@ -20,7 +20,8 @@ func (s *IntegrationTestSuite) TestMsgServer_SetParams() { gmpChannel := "channel-1" gmpAddress := "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5" timeout := int64(1) - SetParams(s, gmpAddress, gmpChannel, timeout) + feeRecipient := "axelar1zl3rxpp70lmte2xr6c4lgske2fyuj3hupcsvcd" + SetParams(s, gmpAddress, gmpChannel, timeout, feeRecipient) params := types.DefaultParams() @@ -33,15 +34,18 @@ func SetParams( gmpAddress string, gmpChannel string, gmpTimeout int64, + feeRecipient string, ) { params := types.DefaultParams() params.GmpAddress = gmpAddress + params.FeeRecipient = feeRecipient authority := s.app.GovKeeper.GetGovernanceAccount(s.ctx).GetAddress().String() msg := types.NewMsgSetParams( params.GmpAddress, params.GmpChannel, params.GmpTimeout, + params.FeeRecipient, authority, ) diff --git a/x/gmp/keeper/params_test.go b/x/gmp/keeper/params_test.go index 5fe327b9..f8c16de2 100644 --- a/x/gmp/keeper/params_test.go +++ b/x/gmp/keeper/params_test.go @@ -6,9 +6,10 @@ func (s *IntegrationTestSuite) TestSetAndGetParams() { app, ctx := s.app, s.ctx params := types.Params{ - GmpChannel: "channel-101", - GmpAddress: "gmpaddress", - GmpTimeout: int64(101), + GmpChannel: "channel-101", + GmpAddress: "gmpaddress", + GmpTimeout: int64(101), + FeeRecipient: "feerecipient", } app.GmpKeeper.SetParams(ctx, params) @@ -18,4 +19,5 @@ func (s *IntegrationTestSuite) TestSetAndGetParams() { s.Require().Equal(params2.GmpAddress, params.GmpAddress) s.Require().Equal(params2.GmpChannel, params.GmpChannel) s.Require().Equal(params2.GmpTimeout, params.GmpTimeout) + s.Require().Equal(params2.FeeRecipient, params.FeeRecipient) } diff --git a/x/gmp/types/gmp.pb.go b/x/gmp/types/gmp.pb.go index 470c196b..d680d663 100644 --- a/x/gmp/types/gmp.pb.go +++ b/x/gmp/types/gmp.pb.go @@ -31,6 +31,8 @@ type Params struct { GmpChannel string `protobuf:"bytes,2,opt,name=gmp_channel,json=gmpChannel,proto3" json:"gmp_channel,omitempty"` // The amount of time we'll wait for a response from axelar before timing out. GmpTimeout int64 `protobuf:"varint,3,opt,name=gmp_timeout,json=gmpTimeout,proto3" json:"gmp_timeout,omitempty"` + // The axelar address of the fee recipient. + FeeRecipient string `protobuf:"bytes,4,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -79,6 +81,8 @@ type GmpMessage struct { Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` // type is an enum that specifies the type of message Type int64 `protobuf:"varint,4,opt,name=type,proto3" json:"type,omitempty"` + // fee is the fee payed to a relayer on the Axelar network + Fee *GmpFee `protobuf:"bytes,5,opt,name=fee,proto3" json:"fee,omitempty"` } func (m *GmpMessage) Reset() { *m = GmpMessage{} } @@ -114,34 +118,80 @@ func (m *GmpMessage) XXX_DiscardUnknown() { var xxx_messageInfo_GmpMessage proto.InternalMessageInfo +// GMPFee defines the fee field message inside of GMPMessage. +type GmpFee struct { + // Fee amount + Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"` + // Recipient of fee; should be fee_recipient. + Recipient string `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"` +} + +func (m *GmpFee) Reset() { *m = GmpFee{} } +func (m *GmpFee) String() string { return proto.CompactTextString(m) } +func (*GmpFee) ProtoMessage() {} +func (*GmpFee) Descriptor() ([]byte, []int) { + return fileDescriptor_199820a7e9d7929f, []int{2} +} +func (m *GmpFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GmpFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GmpFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GmpFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_GmpFee.Merge(m, src) +} +func (m *GmpFee) XXX_Size() int { + return m.Size() +} +func (m *GmpFee) XXX_DiscardUnknown() { + xxx_messageInfo_GmpFee.DiscardUnknown(m) +} + +var xxx_messageInfo_GmpFee proto.InternalMessageInfo + func init() { proto.RegisterType((*Params)(nil), "ojo.gmp.v1.Params") proto.RegisterType((*GmpMessage)(nil), "ojo.gmp.v1.GmpMessage") + proto.RegisterType((*GmpFee)(nil), "ojo.gmp.v1.GmpFee") } func init() { proto.RegisterFile("ojo/gmp/v1/gmp.proto", fileDescriptor_199820a7e9d7929f) } var fileDescriptor_199820a7e9d7929f = []byte{ - // 294 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0xf3, 0x30, - 0x10, 0xc7, 0xe3, 0xaf, 0x55, 0x3f, 0x61, 0x18, 0xc0, 0x74, 0x88, 0x18, 0x4c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0xf0, 0x34, 0x98, 0x1c, 0x4d, 0x9b, 0x96, 0x10, 0xdc, 0x75, 0x5b, 0x23, 0xe2, 0x6e, - 0x10, 0x0c, 0xf5, 0xed, 0xdd, 0xee, 0x9b, 0x46, 0xbb, 0x92, 0xa2, 0x7d, 0x49, 0xd1, 0x57, 0x49, - 0xd1, 0x7b, 0x45, 0xa3, 0x7d, 0x45, 0xa3, 0xcf, 0x8a, 0x46, 0xcf, 0x17, 0x32, 0x73, 0x8b, 0xf5, - 0x2c, 0x99, 0x83, 0x62, 0x90, 0xc3, 0x95, 0x16, 0xee, 0x15, 0x8a, 0xa5, 0xaf, 0xd9, 0x5b, 0x38, - 0xbb, 0x5f, 0x62, 0x67, 0xbd, 0x70, 0xd4, 0xeb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xcc, - 0xf0, 0xf6, 0x8e, 0x01, 0x00, 0x00, + // 366 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xc1, 0x0e, 0xd2, 0x40, + 0x10, 0x86, 0xbb, 0x16, 0x6b, 0x18, 0x30, 0xd1, 0x95, 0x98, 0xc6, 0x98, 0x4a, 0xd0, 0x18, 0x12, + 0x63, 0x1b, 0xf4, 0x6e, 0xa2, 0x18, 0x39, 0x99, 0x98, 0xc6, 0x93, 0x17, 0xb2, 0xd0, 0xa1, 0x14, + 0xd9, 0x9d, 0x4d, 0xbb, 0xa0, 0xbc, 0x05, 0x4f, 0xe4, 0x99, 0x23, 0x47, 0x8f, 0x0a, 0x2f, 0x62, + 0x76, 0x4b, 0x85, 0x53, 0xe7, 0xff, 0xe7, 0x4f, 0xf7, 0x9b, 0xd9, 0x85, 0x1e, 0xad, 0x28, 0xc9, + 0xa5, 0x4e, 0xb6, 0x23, 0xfb, 0x89, 0x75, 0x49, 0x86, 0x38, 0xd0, 0x8a, 0x62, 0x2b, 0xb7, 0xa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43, 0x20, 0x24, 0x6d, 0x94, 0xb9, 0x00, 0x5f, 0x14, 0x7f, + 0x0a, 0xed, 0xeb, 0x0e, 0x6a, 0xb8, 0xab, 0xf1, 0xe1, 0xe3, 0xe1, 0x6f, 0xe4, 0x1d, 0x4e, 0x11, + 0x3b, 0x9e, 0x22, 0xf6, 0xe7, 0x14, 0xb1, 0xfd, 0x39, 0xf2, 0x8e, 0xe7, 0xc8, 0xfb, 0x7d, 0x8e, + 0xbc, 0x6f, 0x2f, 0xf3, 0xc2, 0x2c, 0x37, 0xb3, 0x78, 0x4e, 0x32, 0xa1, 0x15, 0xbd, 0x56, 0x68, + 0x7e, 0x50, 0xf9, 0xdd, 0xd6, 0xc9, 0x4f, 0xf7, 0x04, 0x2c, 0x6a, 0x35, 0x0b, 0xdc, 0x05, 0xbf, + 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x13, 0x9e, 0xc8, 0x1a, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -164,6 +214,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.FeeRecipient) > 0 { + i -= len(m.FeeRecipient) + copy(dAtA[i:], m.FeeRecipient) + i = encodeVarintGmp(dAtA, i, uint64(len(m.FeeRecipient))) + i-- + dAtA[i] = 0x22 + } if m.GmpTimeout != 0 { i = encodeVarintGmp(dAtA, i, uint64(m.GmpTimeout)) i-- @@ -206,6 +263,18 @@ func (m *GmpMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGmp(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } if m.Type != 0 { i = encodeVarintGmp(dAtA, i, uint64(m.Type)) i-- @@ -235,6 +304,43 @@ func (m *GmpMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *GmpFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GmpFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GmpFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintGmp(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x12 + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintGmp(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGmp(dAtA []byte, offset int, v uint64) int { offset -= sovGmp(v) base := offset @@ -263,6 +369,10 @@ func (m *Params) Size() (n int) { if m.GmpTimeout != 0 { n += 1 + sovGmp(uint64(m.GmpTimeout)) } + l = len(m.FeeRecipient) + if l > 0 { + n += 1 + l + sovGmp(uint64(l)) + } return n } @@ -287,6 +397,27 @@ func (m *GmpMessage) Size() (n int) { if m.Type != 0 { n += 1 + sovGmp(uint64(m.Type)) } + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovGmp(uint64(l)) + } + return n +} + +func (m *GmpFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovGmp(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovGmp(uint64(l)) + } return n } @@ -408,6 +539,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeRecipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGmp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGmp + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGmp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeRecipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGmp(dAtA[iNdEx:]) @@ -575,6 +738,156 @@ func (m *GmpMessage) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGmp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGmp + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGmp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &GmpFee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGmp(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGmp + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GmpFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGmp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GmpFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GmpFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGmp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGmp + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGmp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGmp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGmp + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGmp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGmp(dAtA[iNdEx:]) diff --git a/x/gmp/types/msgs.go b/x/gmp/types/msgs.go index 976df8e4..1c9105c0 100644 --- a/x/gmp/types/msgs.go +++ b/x/gmp/types/msgs.go @@ -14,12 +14,14 @@ func NewMsgSetParams( gmpAddress string, gmpChannel string, gmpTimeout int64, + feeRecipient string, govAddress string, ) *MsgSetParams { params := &Params{ - GmpAddress: gmpAddress, - GmpChannel: gmpChannel, - GmpTimeout: gmpTimeout, + GmpAddress: gmpAddress, + GmpChannel: gmpChannel, + GmpTimeout: gmpTimeout, + FeeRecipient: feeRecipient, } return &MsgSetParams{ Params: params, diff --git a/x/gmp/types/params.go b/x/gmp/types/params.go index 9ec33f47..39b57540 100644 --- a/x/gmp/types/params.go +++ b/x/gmp/types/params.go @@ -5,16 +5,18 @@ import ( ) var ( - DefaultGMPAddress = "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5" - DefaultChannel = "channel-1" - DefaultTimeout = int64(1) + DefaultGMPAddress = "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5" + DefaultChannel = "channel-1" + DefaultTimeout = int64(1) + DefaultFeeRecipient = "axelar1zl3rxpp70lmte2xr6c4lgske2fyuj3hupcsvcd" ) func DefaultParams() Params { return Params{ - GmpAddress: DefaultGMPAddress, - GmpChannel: DefaultChannel, - GmpTimeout: DefaultTimeout, + GmpAddress: DefaultGMPAddress, + GmpChannel: DefaultChannel, + GmpTimeout: DefaultTimeout, + FeeRecipient: DefaultFeeRecipient, } } @@ -28,5 +30,8 @@ func (p Params) Validate() error { if p.GmpAddress == "" { return fmt.Errorf("address can not be empty") } + if p.FeeRecipient == "" { + return fmt.Errorf("fee recipient can not be empty") + } return nil }