Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use block time to create relay msg in process payment #535

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions x/gmp/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetTxCmd() *cobra.Command {

func GetCmdRelay() *cobra.Command {
cmd := &cobra.Command{
Use: `relay [destination-chain] [ojo-contract-address] [timestamp] [denoms] [amount]`,
Use: `relay [destination-chain] [ojo-contract-address] [denoms] [amount]`,
Args: cobra.ExactArgs(5),
Short: "Relay oracle data via Axelar GMP",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -52,9 +52,6 @@ func GetCmdRelay() *cobra.Command {
return fmt.Errorf("ojo-contract-address cannot be empty")
}
if args[2] == "" {
return fmt.Errorf("timestamp cannot be empty")
}
if args[3] == "" {
return fmt.Errorf("denoms cannot be empty")
}

Expand All @@ -73,13 +70,7 @@ func GetCmdRelay() *cobra.Command {
}

// convert denoms to string array
denoms := strings.Split(args[3], ",")

// convert timestamp string to int64
timestamp, err := strconv.ParseInt(args[2], 10, 64)
if err != nil {
return err
}
denoms := strings.Split(args[2], ",")

commandSelector, err := base64.StdEncoding.DecodeString("")
if err != nil {
Expand All @@ -99,7 +90,7 @@ func GetCmdRelay() *cobra.Command {
denoms, // denoms
commandSelector, // command-selector
commandParams, // command-params
timestamp, // timestamp
0,
)
err = msg.ValidateBasic()
if err != nil {
Expand All @@ -118,7 +109,7 @@ func GetCmdRelay() *cobra.Command {
func GetCmdRelayWithContractCall() *cobra.Command {
cmd := &cobra.Command{
Use: `relay-with-contract-call [destination-chain] [ojo-contract-address] [client-contract-address] ` +
`[command-selector] [command-params] [timestamp] [denoms] [amount]`,
`[command-selector] [command-params] [denoms] [amount]`,
Args: cobra.ExactArgs(8),
Short: "Relay oracle data via Axelar GMP and call contract method with oracle data",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -143,9 +134,6 @@ func GetCmdRelayWithContractCall() *cobra.Command {
return fmt.Errorf("command-params cannot be empty")
}
if args[5] == "" {
return fmt.Errorf("timestamp cannot be empty")
}
if args[6] == "" {
return fmt.Errorf("denoms cannot be empty")
}

Expand All @@ -164,13 +152,7 @@ func GetCmdRelayWithContractCall() *cobra.Command {
}

// convert denoms to string array
denoms := strings.Split(args[6], ",")

// convert timestamp string to int64
timestamp, err := strconv.ParseInt(args[5], 10, 64)
if err != nil {
return err
}
denoms := strings.Split(args[5], ",")

commandSelector, err := base64.StdEncoding.DecodeString(args[3])
if err != nil {
Expand All @@ -190,7 +172,7 @@ func GetCmdRelayWithContractCall() *cobra.Command {
denoms, // denoms
commandSelector, // command-selector
commandParams, // command-params
timestamp, // timestamp
0,
)
err = msg.ValidateBasic()
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion x/gmp/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (k Keeper) RelayPrice(
ctx := sdk.UnwrapSDKContext(goCtx)
params := k.GetParams(ctx)

// set the timestamp to the current block time
msg.Timestamp = ctx.BlockTime().Unix()

bz, err := msg.Marshal()
if err != nil {
return nil, err
Expand Down Expand Up @@ -299,7 +302,7 @@ func (k Keeper) ProcessPayment(
[]string{payment.Denom},
types.EmptyByteSlice,
types.EmptyByteSlice,
ctx.BlockHeight(),
0,
)
_, err = k.RelayPrice(goCtx, msg)
if err != nil {
Expand Down
Loading