From 5b7a805306462bad1fb78a67a6c099167cc67199 Mon Sep 17 00:00:00 2001 From: Carlton N Hanna Date: Wed, 24 Jan 2024 07:49:11 -0700 Subject: [PATCH] fix marker references for scope, fix a few missed mils to mills --- x/metadata/client/cli/tx.go | 6 +++--- x/metadata/types/keys.go | 2 +- x/metadata/types/msg.go | 2 +- x/metadata/types/msg_test.go | 2 +- x/metadata/types/scope.go | 2 +- x/metadata/types/scope_test.go | 10 +--------- x/metadata/wasm/encode.go | 4 ++-- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/x/metadata/client/cli/tx.go b/x/metadata/client/cli/tx.go index 8f170db794..20b80a57f6 100644 --- a/x/metadata/client/cli/tx.go +++ b/x/metadata/client/cli/tx.go @@ -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) } @@ -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 diff --git a/x/metadata/types/keys.go b/x/metadata/types/keys.go index 9c71432199..b59db78b9d 100644 --- a/x/metadata/types/keys.go +++ b/x/metadata/types/keys.go @@ -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...) } diff --git a/x/metadata/types/msg.go b/x/metadata/types/msg.go index 0e7f12074f..254d45991d 100644 --- a/x/metadata/types/msg.go +++ b/x/metadata/types/msg.go @@ -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] { diff --git a/x/metadata/types/msg_test.go b/x/metadata/types/msg_test.go index 25bf3b79b0..8367807420 100644 --- a/x/metadata/types/msg_test.go +++ b/x/metadata/types/msg_test.go @@ -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", diff --git a/x/metadata/types/scope.go b/x/metadata/types/scope.go index f68f56ddc2..c4106cdfbf 100644 --- a/x/metadata/types/scope.go +++ b/x/metadata/types/scope.go @@ -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 diff --git a/x/metadata/types/scope_test.go b/x/metadata/types/scope_test.go index d138a7acee..06d5584035 100644 --- a/x/metadata/types/scope_test.go +++ b/x/metadata/types/scope_test.go @@ -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", diff --git a/x/metadata/wasm/encode.go b/x/metadata/wasm/encode.go index 190c5960d5..b72fcbe1d0 100644 --- a/x/metadata/wasm/encode.go +++ b/x/metadata/wasm/encode.go @@ -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"` } @@ -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 }