Skip to content

Commit 929391b

Browse files
authored
feat(axelarnet)!: refactor call-contract (#1921)
* feat(axelarnet)!: refactor call-contract * change message status from processing to approved * add optional fee * review * review * fix ci * review
1 parent a5fc8fe commit 929391b

File tree

14 files changed

+712
-157
lines changed

14 files changed

+712
-157
lines changed

client/docs/static/openapi/index.html

+3-3
Large diffs are not rendered by default.

client/docs/static/openapi/openapi.yaml

+70-12
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,26 @@ paths:
433433
payload:
434434
type: string
435435
format: byte
436+
fee:
437+
type: object
438+
properties:
439+
amount:
440+
type: object
441+
properties:
442+
denom:
443+
type: string
444+
amount:
445+
type: string
446+
description: >-
447+
Coin defines a token with a denomination and an amount.
448+
449+
450+
NOTE: The amount field is an Int which implements the custom method
451+
452+
signatures required by gogoproto.
453+
recipient:
454+
type: string
455+
format: byte
436456
required: true
437457
tags:
438458
- MsgService
@@ -38555,6 +38575,26 @@ components:
3855538575
payload:
3855638576
type: string
3855738577
format: byte
38578+
fee:
38579+
type: object
38580+
properties:
38581+
amount:
38582+
type: object
38583+
properties:
38584+
denom:
38585+
type: string
38586+
amount:
38587+
type: string
38588+
description: >-
38589+
Coin defines a token with a denomination and an amount.
38590+
38591+
38592+
NOTE: The amount field is an Int which implements the custom method
38593+
38594+
signatures required by gogoproto.
38595+
recipient:
38596+
type: string
38597+
format: byte
3855838598
axelar.axelarnet.v1beta1.CallContractResponse:
3855938599
type: object
3856038600
axelar.axelarnet.v1beta1.ConfirmDepositRequest:
@@ -38582,6 +38622,24 @@ components:
3858238622
pending transfers
3858338623
axelar.axelarnet.v1beta1.ExecutePendingTransfersResponse:
3858438624
type: object
38625+
axelar.axelarnet.v1beta1.Fee:
38626+
type: object
38627+
properties:
38628+
amount:
38629+
type: object
38630+
properties:
38631+
denom:
38632+
type: string
38633+
amount:
38634+
type: string
38635+
description: |-
38636+
Coin defines a token with a denomination and an amount.
38637+
38638+
NOTE: The amount field is an Int which implements the custom method
38639+
signatures required by gogoproto.
38640+
recipient:
38641+
type: string
38642+
format: byte
3858538643
axelar.axelarnet.v1beta1.LinkRequest:
3858638644
type: object
3858738645
properties:
@@ -38728,6 +38786,18 @@ components:
3872838786
- KEY_TYPE_THRESHOLD
3872938787
- KEY_TYPE_MULTISIG
3873038788
default: KEY_TYPE_UNSPECIFIED
38789+
cosmos.base.v1beta1.Coin:
38790+
type: object
38791+
properties:
38792+
denom:
38793+
type: string
38794+
amount:
38795+
type: string
38796+
description: |-
38797+
Coin defines a token with a denomination and an amount.
38798+
38799+
NOTE: The amount field is an Int which implements the custom method
38800+
signatures required by gogoproto.
3873138801
axelar.evm.v1beta1.AddChainRequest:
3873238802
type: object
3873338803
properties:
@@ -40558,18 +40628,6 @@ components:
4055840628
repeated Bar results = 1;
4055940629
PageResponse page = 2;
4056040630
}
40561-
cosmos.base.v1beta1.Coin:
40562-
type: object
40563-
properties:
40564-
denom:
40565-
type: string
40566-
amount:
40567-
type: string
40568-
description: |-
40569-
Coin defines a token with a denomination and an amount.
40570-
40571-
NOTE: The amount field is an Int which implements the custom method
40572-
signatures required by gogoproto.
4057340631
axelar.snapshot.v1beta1.DeactivateProxyRequest:
4057440632
type: object
4057540633
properties:

client/docs/static/swagger/swagger.yaml

+72-12
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,27 @@ paths:
474474
payload:
475475
type: string
476476
format: byte
477+
fee:
478+
type: object
479+
properties:
480+
amount:
481+
type: object
482+
properties:
483+
denom:
484+
type: string
485+
amount:
486+
type: string
487+
description: >-
488+
Coin defines a token with a denomination and an amount.
489+
490+
491+
NOTE: The amount field is an Int which implements the
492+
custom method
493+
494+
signatures required by gogoproto.
495+
recipient:
496+
type: string
497+
format: byte
477498
tags:
478499
- MsgService
479500
/axelar/axelarnet/confirm_deposit:
@@ -41930,6 +41951,27 @@ definitions:
4193041951
payload:
4193141952
type: string
4193241953
format: byte
41954+
fee:
41955+
type: object
41956+
properties:
41957+
amount:
41958+
type: object
41959+
properties:
41960+
denom:
41961+
type: string
41962+
amount:
41963+
type: string
41964+
description: >-
41965+
Coin defines a token with a denomination and an amount.
41966+
41967+
41968+
NOTE: The amount field is an Int which implements the custom
41969+
method
41970+
41971+
signatures required by gogoproto.
41972+
recipient:
41973+
type: string
41974+
format: byte
4193341975
axelar.axelarnet.v1beta1.CallContractResponse:
4193441976
type: object
4193541977
axelar.axelarnet.v1beta1.ConfirmDepositRequest:
@@ -41957,6 +41999,24 @@ definitions:
4195741999
pending transfers
4195842000
axelar.axelarnet.v1beta1.ExecutePendingTransfersResponse:
4195942001
type: object
42002+
axelar.axelarnet.v1beta1.Fee:
42003+
type: object
42004+
properties:
42005+
amount:
42006+
type: object
42007+
properties:
42008+
denom:
42009+
type: string
42010+
amount:
42011+
type: string
42012+
description: |-
42013+
Coin defines a token with a denomination and an amount.
42014+
42015+
NOTE: The amount field is an Int which implements the custom method
42016+
signatures required by gogoproto.
42017+
recipient:
42018+
type: string
42019+
format: byte
4196042020
axelar.axelarnet.v1beta1.LinkRequest:
4196142021
type: object
4196242022
properties:
@@ -42099,6 +42159,18 @@ definitions:
4209942159
- KEY_TYPE_THRESHOLD
4210042160
- KEY_TYPE_MULTISIG
4210142161
default: KEY_TYPE_UNSPECIFIED
42162+
cosmos.base.v1beta1.Coin:
42163+
type: object
42164+
properties:
42165+
denom:
42166+
type: string
42167+
amount:
42168+
type: string
42169+
description: |-
42170+
Coin defines a token with a denomination and an amount.
42171+
42172+
NOTE: The amount field is an Int which implements the custom method
42173+
signatures required by gogoproto.
4210242174
axelar.evm.v1beta1.AddChainRequest:
4210342175
type: object
4210442176
properties:
@@ -43929,18 +44001,6 @@ definitions:
4392944001
repeated Bar results = 1;
4393044002
PageResponse page = 2;
4393144003
}
43932-
cosmos.base.v1beta1.Coin:
43933-
type: object
43934-
properties:
43935-
denom:
43936-
type: string
43937-
amount:
43938-
type: string
43939-
description: |-
43940-
Coin defines a token with a denomination and an amount.
43941-
43942-
NOTE: The amount field is an Int which implements the custom method
43943-
signatures required by gogoproto.
4394444004
axelar.snapshot.v1beta1.DeactivateProxyRequest:
4394544005
type: object
4394644006
properties:

client/docs/statik/statik.go

+1-1
Large diffs are not rendered by default.

docs/cli/axelard_tx_axelarnet_call-contract.md

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/proto/proto-docs.md

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/axelar/axelarnet/v1beta1/tx.proto

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ message CallContractRequest {
178178
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
179179
string contract_address = 3;
180180
bytes payload = 4;
181+
Fee fee = 5;
181182
}
182183

183184
message CallContractResponse {}

proto/axelar/axelarnet/v1beta1/types.proto

+6
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ message Asset {
5151
(gogoproto.nullable) = false
5252
];
5353
}
54+
55+
message Fee {
56+
cosmos.base.v1beta1.Coin amount = 1 [ (gogoproto.nullable) = false ];
57+
bytes recipient = 2 [ (gogoproto.casttype) =
58+
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
59+
}

x/axelarnet/client/cli/tx.go

+36-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const (
2222
flagIsNativeAsset = "is-native-asset"
2323
flagLimit = "limit"
2424
flagWindow = "window"
25+
flagFeeAmount = "fee-amount"
26+
flagFeeRecipient = "fee-recipient"
2527
)
2628

2729
// GetTxCmd returns the transaction commands for this module
@@ -345,14 +347,47 @@ func getCmdCallContract() *cobra.Command {
345347
return err
346348
}
347349

348-
msg := types.NewCallContractRequest(clientCtx.GetFromAddress(), args[0], args[1], payload)
350+
feeAmount, err := cmd.Flags().GetString(flagFeeAmount)
351+
if err != nil {
352+
return err
353+
}
354+
355+
feeRecipient, err := cmd.Flags().GetString(flagFeeRecipient)
356+
if err != nil {
357+
return err
358+
}
359+
360+
var fee *types.Fee = nil
361+
if feeAmount != "" && feeRecipient != "" {
362+
363+
amount, err := sdk.ParseCoinNormalized(feeAmount)
364+
if err != nil {
365+
return err
366+
}
367+
368+
recipient, err := sdk.AccAddressFromBech32(feeRecipient)
369+
if err != nil {
370+
return err
371+
}
372+
373+
fee = &types.Fee{
374+
Amount: amount,
375+
Recipient: recipient,
376+
}
377+
} else if feeAmount != "" || feeRecipient != "" {
378+
return fmt.Errorf("need both %s and %s", flagFeeAmount, flagFeeRecipient)
379+
}
380+
381+
msg := types.NewCallContractRequest(clientCtx.GetFromAddress(), args[0], args[1], payload, fee)
349382
if err := msg.ValidateBasic(); err != nil {
350383
return err
351384
}
352385

353386
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
354387
},
355388
}
389+
cmd.Flags().String(flagFeeAmount, "", "fee to pay for the contract call")
390+
cmd.Flags().String(flagFeeRecipient, "", "recipient of the fee")
356391
flags.AddTxFlagsToCmd(cmd)
357392
return cmd
358393
}

0 commit comments

Comments
 (0)