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

change the way to create any obj #542

Merged
merged 1 commit into from
Jun 5, 2023
Merged
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
18 changes: 12 additions & 6 deletions x/derivatives/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,26 @@ $ %s tx %s open-position perpetual-futures --from myKeyName --chain-id ununifi-x
Leverage: uint32(leverage),
}

positionInstBz, err := positionInstVal.Marshal()
// positionInstBz, err := positionInstVal.Marshal()
// if err != nil {
// return err
// }
// positionInstI, err :=
piAny, err := codecType.NewAnyWithValue(&positionInstVal)
if err != nil {
return err
}
positionInstance := codecType.Any{
TypeUrl: "/ununifi.derivatives.PerpetualFuturesPositionInstance",
Value: positionInstBz,
}

// positionInstance := codecType.Any{
// TypeUrl: "/ununifi.derivatives.PerpetualFuturesPositionInstance",
// Value: positionInstBz,
// }

market := types.Market{
BaseDenom: baseDenom,
QuoteDenom: quoteDenom,
}
msg := types.NewMsgOpenPosition(sender, margin, market, positionInstance)
msg := types.NewMsgOpenPosition(sender, margin, market, *piAny)
if err := msg.ValidateBasic(); err != nil {
return err
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code appears to be making changes in a blockchain application, specifically in the open-position function of the perpetual-futures transaction.

As for the specific review points:

  • The commented out code block suggests that the previous approach using positionInstBz has been replaced with piAny. This is likely done to improve efficiency since Any is Protobuf's way of handling arbitrary types.
  • There are no apparent bug risks on the updated lines of code.
  • One suggestion for improvement could be to comment why the previous code block was commented out, just for clarity purposes.

Expand Down