Skip to content

Commit

Permalink
fix marker references for scope, fix a few missed mils to mills
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Jan 24, 2024
1 parent 2b4f59e commit 5b7a805
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
6 changes: 3 additions & 3 deletions x/metadata/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func WriteScopeCmd() *cobra.Command {
requirePartyRollup,
)

usdMils, err := cmd.Flags().GetUint64(FlagUsdMills)
usdMills, err := cmd.Flags().GetUint64(FlagUsdMills)
if err != nil {
return fmt.Errorf("incorrect value for %s flag. Accepted: 0 or greater value Error: %w", FlagUsdMills, err)
}
Expand All @@ -150,11 +150,11 @@ func WriteScopeCmd() *cobra.Command {
return fmt.Errorf("incorrect value for %s flag. Accepted: 0 or greater value Error: %w", FlagVolume, err)
}

if usdMils > 0 && volume == 0 {
if usdMills > 0 && volume == 0 {
return fmt.Errorf("incorrect value for %s flag. Must be positive number if %s flag has been set to positive value", FlagVolume, FlagUsdMills)
}

msg := types.NewMsgWriteScopeRequest(scope, signers, usdMils, volume)
msg := types.NewMsgWriteScopeRequest(scope, signers, usdMills, volume)
err = msg.ValidateBasic()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/metadata/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func NetAssetValueKeyPrefix(scopeAddr MetadataAddress) []byte {
return append(NetAssetValuePrefix, address.MustLengthPrefix(scopeAddr.Bytes())...)
}

// NetAssetValueKey returns key [prefix][marker address][asset denom value] for marker net asset value by value denom
// NetAssetValueKey returns key [prefix][marker address][asset denom value] for scope's net asset value by value denom
func NetAssetValueKey(scopeAddr MetadataAddress, denom string) []byte {
return append(NetAssetValueKeyPrefix(scopeAddr), denom...)
}
2 changes: 1 addition & 1 deletion x/metadata/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ func (msg MsgAddNetAssetValuesRequest) ValidateBasic() error {
}

if nav.UpdatedBlockHeight != 0 {
return fmt.Errorf("marker net asset value must not have update height set")
return fmt.Errorf("scope net asset value must not have update height set")
}

if seen[nav.Price.Denom] {
Expand Down
2 changes: 1 addition & 1 deletion x/metadata/types/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ func TestMsgAddNetAssetValueValidateBasic(t *testing.T) {
{
name: "block height is set",
msg: MsgAddNetAssetValuesRequest{ScopeId: scopeID, NetAssetValues: []NetAssetValue{invalidNetAssetValue2}, Signers: []string{addr}},
expErr: "marker net asset value must not have update height set",
expErr: "scope net asset value must not have update height set",
},
{
name: "validation of net asset value failure",
Expand Down
2 changes: 1 addition & 1 deletion x/metadata/types/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func (mnav *NetAssetValue) Validate() error {
}

if mnav.Price.Amount.GT(sdk.NewInt(0)) && mnav.Volume < 1 {
return fmt.Errorf("marker net asset value volume must be positive value")
return fmt.Errorf("scope net asset value volume must be positive value")
}

return nil
Expand Down
10 changes: 1 addition & 9 deletions x/metadata/types/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1665,15 +1665,7 @@ func TestNetAssetValueValidate(t *testing.T) {
Price: sdk.NewInt64Coin("jackthecat", 420),
Volume: 0,
},
expErr: "marker net asset value volume must be positive value",
},
{
name: "volume must be positive if value is greater than 1",
nav: NetAssetValue{
Price: sdk.NewInt64Coin("usdcents", 1),
Volume: 0,
},
expErr: "marker net asset value volume must be positive value",
expErr: "scope net asset value volume must be positive value",
},
{
name: "successful with 0 volume and coin",
Expand Down
4 changes: 2 additions & 2 deletions x/metadata/wasm/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type WriteScope struct {
// The signers' addresses.
Signers []string `json:"signers"`
// UsdCents used to initialize the net asset value of scope
UsdMils uint64 `json:"usd_mills,omitempty"`
UsdMills uint64 `json:"usd_mills,omitempty"`
// Volume for the net asset value of scope
Volume uint64 `json:"volume,omitempty"`
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func (params *WriteScope) Encode() ([]sdk.Msg, error) {
return nil, err
}

msg := types.NewMsgWriteScopeRequest(*scope, params.Signers, params.UsdMils, params.Volume)
msg := types.NewMsgWriteScopeRequest(*scope, params.Signers, params.UsdMills, params.Volume)

return []sdk.Msg{msg}, nil
}

0 comments on commit 5b7a805

Please sign in to comment.