Skip to content

Commit

Permalink
feat(axelarnet)!: refactor call-contract (axelarnetwork#1921)
Browse files Browse the repository at this point in the history
* feat(axelarnet)!: refactor call-contract

* change message status from processing to approved
* add optional fee

* review

* review

* fix ci

* review
  • Loading branch information
cjcobb23 authored Mar 31, 2023
1 parent a5fc8fe commit 929391b
Show file tree
Hide file tree
Showing 14 changed files with 712 additions and 157 deletions.
6 changes: 3 additions & 3 deletions client/docs/static/openapi/index.html

Large diffs are not rendered by default.

82 changes: 70 additions & 12 deletions client/docs/static/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,26 @@ paths:
payload:
type: string
format: byte
fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom method

signatures required by gogoproto.
recipient:
type: string
format: byte
required: true
tags:
- MsgService
Expand Down Expand Up @@ -38555,6 +38575,26 @@ components:
payload:
type: string
format: byte
fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom method

signatures required by gogoproto.
recipient:
type: string
format: byte
axelar.axelarnet.v1beta1.CallContractResponse:
type: object
axelar.axelarnet.v1beta1.ConfirmDepositRequest:
Expand Down Expand Up @@ -38582,6 +38622,24 @@ components:
pending transfers
axelar.axelarnet.v1beta1.ExecutePendingTransfersResponse:
type: object
axelar.axelarnet.v1beta1.Fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
recipient:
type: string
format: byte
axelar.axelarnet.v1beta1.LinkRequest:
type: object
properties:
Expand Down Expand Up @@ -38728,6 +38786,18 @@ components:
- KEY_TYPE_THRESHOLD
- KEY_TYPE_MULTISIG
default: KEY_TYPE_UNSPECIFIED
cosmos.base.v1beta1.Coin:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
axelar.evm.v1beta1.AddChainRequest:
type: object
properties:
Expand Down Expand Up @@ -40558,18 +40628,6 @@ components:
repeated Bar results = 1;
PageResponse page = 2;
}
cosmos.base.v1beta1.Coin:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
axelar.snapshot.v1beta1.DeactivateProxyRequest:
type: object
properties:
Expand Down
84 changes: 72 additions & 12 deletions client/docs/static/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,27 @@ paths:
payload:
type: string
format: byte
fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the
custom method

signatures required by gogoproto.
recipient:
type: string
format: byte
tags:
- MsgService
/axelar/axelarnet/confirm_deposit:
Expand Down Expand Up @@ -41930,6 +41951,27 @@ definitions:
payload:
type: string
format: byte
fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
recipient:
type: string
format: byte
axelar.axelarnet.v1beta1.CallContractResponse:
type: object
axelar.axelarnet.v1beta1.ConfirmDepositRequest:
Expand Down Expand Up @@ -41957,6 +41999,24 @@ definitions:
pending transfers
axelar.axelarnet.v1beta1.ExecutePendingTransfersResponse:
type: object
axelar.axelarnet.v1beta1.Fee:
type: object
properties:
amount:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
recipient:
type: string
format: byte
axelar.axelarnet.v1beta1.LinkRequest:
type: object
properties:
Expand Down Expand Up @@ -42099,6 +42159,18 @@ definitions:
- KEY_TYPE_THRESHOLD
- KEY_TYPE_MULTISIG
default: KEY_TYPE_UNSPECIFIED
cosmos.base.v1beta1.Coin:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
axelar.evm.v1beta1.AddChainRequest:
type: object
properties:
Expand Down Expand Up @@ -43929,18 +44001,6 @@ definitions:
repeated Bar results = 1;
PageResponse page = 2;
}
cosmos.base.v1beta1.Coin:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
axelar.snapshot.v1beta1.DeactivateProxyRequest:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/cli/axelard_tx_axelarnet_call-contract.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions docs/proto/proto-docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proto/axelar/axelarnet/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ message CallContractRequest {
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
string contract_address = 3;
bytes payload = 4;
Fee fee = 5;
}

message CallContractResponse {}
6 changes: 6 additions & 0 deletions proto/axelar/axelarnet/v1beta1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ message Asset {
(gogoproto.nullable) = false
];
}

message Fee {
cosmos.base.v1beta1.Coin amount = 1 [ (gogoproto.nullable) = false ];
bytes recipient = 2 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
}
37 changes: 36 additions & 1 deletion x/axelarnet/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
flagIsNativeAsset = "is-native-asset"
flagLimit = "limit"
flagWindow = "window"
flagFeeAmount = "fee-amount"
flagFeeRecipient = "fee-recipient"
)

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

msg := types.NewCallContractRequest(clientCtx.GetFromAddress(), args[0], args[1], payload)
feeAmount, err := cmd.Flags().GetString(flagFeeAmount)
if err != nil {
return err
}

feeRecipient, err := cmd.Flags().GetString(flagFeeRecipient)
if err != nil {
return err
}

var fee *types.Fee = nil
if feeAmount != "" && feeRecipient != "" {

amount, err := sdk.ParseCoinNormalized(feeAmount)
if err != nil {
return err
}

recipient, err := sdk.AccAddressFromBech32(feeRecipient)
if err != nil {
return err
}

fee = &types.Fee{
Amount: amount,
Recipient: recipient,
}
} else if feeAmount != "" || feeRecipient != "" {
return fmt.Errorf("need both %s and %s", flagFeeAmount, flagFeeRecipient)
}

msg := types.NewCallContractRequest(clientCtx.GetFromAddress(), args[0], args[1], payload, fee)
if err := msg.ValidateBasic(); err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
cmd.Flags().String(flagFeeAmount, "", "fee to pay for the contract call")
cmd.Flags().String(flagFeeRecipient, "", "recipient of the fee")
flags.AddTxFlagsToCmd(cmd)
return cmd
}
Loading

0 comments on commit 929391b

Please sign in to comment.