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

Support setting a nav attribute on metadata scopes #1791

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
82f7160
add nav protos to metadata module for scopes
nullpointer0x00 Jan 2, 2024
b33ec18
refactor proto, add scope-id to add nav tx
nullpointer0x00 Jan 2, 2024
d63a70c
add validations, add msg interface
nullpointer0x00 Jan 2, 2024
244791c
add nav key
nullpointer0x00 Jan 2, 2024
ccba0a7
add keeper methods, update typed event
nullpointer0x00 Jan 3, 2024
f77ce00
add usd_mils and volume to write scope
nullpointer0x00 Jan 3, 2024
1c2818c
Merge branch 'main' into 1749-support-setting-a-NAV-attribute-on-meta…
nullpointer0x00 Jan 16, 2024
c1eec18
add net asset value keeper call to msg server
nullpointer0x00 Jan 16, 2024
539bdd4
add nav when writing scope
nullpointer0x00 Jan 16, 2024
012eba4
add new parameters to write scope msg, add command line flags for usd…
nullpointer0x00 Jan 16, 2024
959988e
add genesis navs
nullpointer0x00 Jan 16, 2024
0fec3e9
add change log
nullpointer0x00 Jan 17, 2024
439b894
Merge branch 'main' into 1749-support-setting-a-NAV-attribute-on-meta…
nullpointer0x00 Jan 21, 2024
5c2c45c
rename mils to mills, add net asset values command
nullpointer0x00 Jan 21, 2024
42c157c
change some naming, add validate basic tests, cmdline test
nullpointer0x00 Jan 22, 2024
babcba6
fix property name
nullpointer0x00 Jan 22, 2024
b259445
add validation test
nullpointer0x00 Jan 22, 2024
f11c3da
add msg server test, remove check of scope id, move metadata app init…
nullpointer0x00 Jan 23, 2024
c219d33
add scope net asset value query
nullpointer0x00 Jan 23, 2024
9f1b48e
fix test
nullpointer0x00 Jan 23, 2024
8f9e6a0
add better error handling
nullpointer0x00 Jan 23, 2024
3ce60b4
remove unneeded check, add tests for keeper
nullpointer0x00 Jan 23, 2024
4bb85d4
Add ParseNetAssertValueString test
nullpointer0x00 Jan 23, 2024
e022773
add query server tests
nullpointer0x00 Jan 23, 2024
19a4da5
add more tests, refactor method name
nullpointer0x00 Jan 23, 2024
2b4f59e
fix test
nullpointer0x00 Jan 24, 2024
5b7a805
fix marker references for scope, fix a few missed mils to mills
nullpointer0x00 Jan 24, 2024
bae57a5
Merge branch 'main' into 1749-support-setting-a-NAV-attribute-on-meta…
nullpointer0x00 Jan 24, 2024
601f14b
ugh missed test assert
nullpointer0x00 Jan 24, 2024
a0f7cc3
fix proto doc
nullpointer0x00 Jan 24, 2024
0e4cb85
merge main
nullpointer0x00 Jan 24, 2024
4949743
remove volume from scope net asset value, update code and tests, add …
nullpointer0x00 Jan 25, 2024
ecd81aa
merge main
nullpointer0x00 Jan 25, 2024
d2e956a
better error logging
nullpointer0x00 Jan 25, 2024
3b89fc5
error changes, lint fix
nullpointer0x00 Jan 25, 2024
38ce700
change error message again
nullpointer0x00 Jan 26, 2024
ae5647e
Merge branch 'main' into 1749-support-setting-a-NAV-attribute-on-meta…
iramiller Jan 26, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* Add the ibcratelimit module [#1498](https://github.com/provenance-io/provenance/issues/1498).
* Add NAV support for metadata scopes [#1749](https://github.com/provenance-io/provenance/issues/1749).
* Add fix for NAV units to tourmaline upgrade handler [#1815](https://github.com/provenance-io/provenance/issues/1815).

### Improvements

Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39701,12 +39701,6 @@ paths:
custom method

signatures required by gogoproto.
volume:
type: string
format: uint64
title: >-
volume is the number of tokens of that the scope was
purchased for the price
updated_block_height:
type: string
format: uint64
Expand Down Expand Up @@ -85888,12 +85882,6 @@ definitions:

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
volume:
type: string
format: uint64
title: >-
volume is the number of tokens of that the scope was purchased for the
price
updated_block_height:
type: string
format: uint64
Expand Down Expand Up @@ -86739,12 +86727,6 @@ definitions:
method

signatures required by gogoproto.
volume:
type: string
format: uint64
title: >-
volume is the number of tokens of that the scope was purchased
for the price
updated_block_height:
type: string
format: uint64
Expand Down
2 changes: 0 additions & 2 deletions docs/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5895,7 +5895,6 @@ NetAssetValue defines a scope's net asset value
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `price` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | price is the complete value of the asset's volume |
| `volume` | [uint64](#uint64) | | volume is the number of tokens of that the scope was purchased for the price |
| `updated_block_height` | [uint64](#uint64) | | updated_block_height is the block height of last update |


Expand Down Expand Up @@ -8313,7 +8312,6 @@ MsgWriteScopeRequest is the request type for the Msg/WriteScope RPC method.
| `scope_uuid` | [string](#string) | | scope_uuid is an optional uuid string, e.g. "91978ba2-5f35-459a-86a7-feca1b0512e0" If provided, it will be used to generate the MetadataAddress for the scope which will override the scope_id in the provided scope. If not provided (or it is an empty string), nothing special happens. If there is a value in scope.scope_id that is different from the one created from this uuid, an error is returned. |
| `spec_uuid` | [string](#string) | | spec_uuid is an optional scope specification uuid string, e.g. "dc83ea70-eacd-40fe-9adf-1cf6148bf8a2" If provided, it will be used to generate the MetadataAddress for the scope specification which will override the specification_id in the provided scope. If not provided (or it is an empty string), nothing special happens. If there is a value in scope.specification_id that is different from the one created from this uuid, an error is returned. |
| `usd_mills` | [uint64](#uint64) | | usd_mills value of scope in usd mills (1234 = $1.234) used for net asset value |
| `volume` | [uint64](#uint64) | | volume value of scope used for net asset value |



Expand Down
3 changes: 1 addition & 2 deletions proto/provenance/metadata/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,5 @@ message EventOSLocatorDeleted {
message EventSetNetAssetValue {
string scope_id = 1;
string price = 2;
string volume = 3;
string source = 4;
string source = 3;
}
4 changes: 1 addition & 3 deletions proto/provenance/metadata/v1/scope.proto
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ message AuditFields {
message NetAssetValue {
// price is the complete value of the asset's volume
cosmos.base.v1beta1.Coin price = 1 [(gogoproto.nullable) = false];
// volume is the number of tokens of that the scope was purchased for the price
uint64 volume = 2;
// updated_block_height is the block height of last update
uint64 updated_block_height = 3;
uint64 updated_block_height = 2;
}
4 changes: 1 addition & 3 deletions proto/provenance/metadata/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ message MsgWriteScopeRequest {
string spec_uuid = 4 [(gogoproto.moretags) = "yaml:\"spec_uuid\""];

// usd_mills value of scope in usd mills (1234 = $1.234) used for net asset value
uint64 usd_mills = 12;
// volume value of scope used for net asset value
uint64 volume = 13;
uint64 usd_mills = 5;
}

// MsgWriteScopeResponse is the response type for the Msg/WriteScope RPC method.
Expand Down
2 changes: 1 addition & 1 deletion x/marker/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ func ParseAccessGrantFromString(addressPermissionString string) []types.AccessGr
return grants
}

// ParseNetAssetValueString splits string (example address1,perm1,perm2...;address2, perm1...) to list of NetAssetValue's
// ParseNetAssetValueString splits string (example 1hotdog,1;2jackthecat100,...) to list of NetAssetValue's
func ParseNetAssetValueString(netAssetValuesString string) ([]types.NetAssetValue, error) {
navs := strings.Split(netAssetValuesString, ";")
if len(navs) == 1 && len(navs[0]) == 0 {
Expand Down
71 changes: 12 additions & 59 deletions x/metadata/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2148,24 +2148,6 @@ func (s *IntegrationCLITestSuite) TestScopeTxCommands() {
},
expectErrMsg: "parties can only be optional when require_party_rollup = true",
},
{
name: "usd mills present without volume",
cmd: cli.WriteScopeCmd(),
args: []string{
metadatatypes.ScopeMetadataAddress(uuid.New()).String(),
scopeSpecID,
fmt.Sprintf("%s,servicer,opt;%s,owner", s.accountAddrStr, s.accountAddrStr),
s.accountAddrStr,
s.accountAddrStr,
fmt.Sprintf("--%s", cli.FlagRequirePartyRollup),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountAddrStr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--%s=%s", cli.FlagUsdMills, "10"),
},
expectErrMsg: "incorrect value for volume flag. Must be positive number if usd-mills flag has been set to positive value",
},
{
name: "should successfully write scope with optional party and rollup",
cmd: cli.WriteScopeCmd(),
Expand All @@ -2181,7 +2163,6 @@ func (s *IntegrationCLITestSuite) TestScopeTxCommands() {
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--%s=%s", cli.FlagUsdMills, "blah"),
fmt.Sprintf("--%s=%s", cli.FlagVolume, "1"),
},
expectErrMsg: `invalid argument "blah" for "--usd-mills" flag: strconv.ParseUint: parsing "blah": invalid syntax`,
},
Expand All @@ -2200,26 +2181,6 @@ func (s *IntegrationCLITestSuite) TestScopeTxCommands() {
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--%s=%s", cli.FlagUsdMills, "10"),
fmt.Sprintf("--%s=%s", cli.FlagVolume, "blah"),
},
expectErrMsg: `invalid argument "blah" for "--volume" flag: strconv.ParseUint: parsing "blah": invalid syntax`,
},
{
name: "should successfully write scope with optional party and rollup",
cmd: cli.WriteScopeCmd(),
args: []string{
metadatatypes.ScopeMetadataAddress(uuid.New()).String(),
scopeSpecID,
fmt.Sprintf("%s,servicer,opt;%s,owner", s.accountAddrStr, s.accountAddrStr),
s.accountAddrStr,
s.accountAddrStr,
fmt.Sprintf("--%s", cli.FlagRequirePartyRollup),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.accountAddrStr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
fmt.Sprintf("--%s=%s", cli.FlagUsdMills, "10"),
fmt.Sprintf("--%s=%s", cli.FlagVolume, "1"),
},
expectErrMsg: "",
expectedCode: 0,
Expand Down Expand Up @@ -3919,11 +3880,11 @@ func (s *IntegrationCLITestSuite) TestGetCmdAddNetAssetValues() {
{
name: "invalid net asset string",
args: argsWStdFlags(scopeID, "invalid"),
expErr: "invalid net asset value, expected coin,volume",
expErr: "invalid coin invalid",
Taztingo marked this conversation as resolved.
Show resolved Hide resolved
},
{
name: "address not meta address",
args: argsWStdFlags("notmetaaddress", "1usd,1"),
args: argsWStdFlags("notmetaaddress", "1usd"),
expErr: `invalid metadata address "notmetaaddress": decoding bech32 failed: invalid separator index -1`,
},
{
Expand All @@ -3933,7 +3894,11 @@ func (s *IntegrationCLITestSuite) TestGetCmdAddNetAssetValues() {
},
{
name: "successful",
args: argsWStdFlags(scopeID, "1usd,1"),
args: argsWStdFlags(scopeID, "1usd"),
},
{
name: "successful with multi net asset values",
args: argsWStdFlags(scopeID, "1usd,2jackthecat"),
},
}

Expand Down Expand Up @@ -4003,33 +3968,21 @@ func (s *IntegrationCLITestSuite) TestParseNetAssertValueString() {
},
{
name: "invalid coin",
netAssetValues: "notacoin,1",
netAssetValues: "notacoin",
expErr: "invalid coin notacoin",
expResult: []types.NetAssetValue{},
},
{
name: "invalid volume string",
netAssetValues: "1hotdog,invalidvolume",
expErr: "invalid volume invalidvolume",
expResult: []types.NetAssetValue{},
},
{
name: "invalid amount of args",
netAssetValues: "1hotdog,invalidvolume,notsupposedtobehere",
expErr: "invalid net asset value, expected coin,volume",
expResult: []types.NetAssetValue{},
},
{
name: "successfully parse single nav",
netAssetValues: "1hotdog,10",
netAssetValues: "1hotdog",
expErr: "",
expResult: []types.NetAssetValue{{Price: sdk.NewInt64Coin("hotdog", 1), Volume: 10}},
expResult: []types.NetAssetValue{{Price: sdk.NewInt64Coin("hotdog", 1)}},
},
{
name: "successfully parse multi nav",
netAssetValues: "1hotdog,10;20jackthecat,40",
netAssetValues: "1hotdog,20jackthecat",
expErr: "",
expResult: []types.NetAssetValue{{Price: sdk.NewInt64Coin("hotdog", 1), Volume: 10}, {Price: sdk.NewInt64Coin("jackthecat", 20), Volume: 40}},
expResult: []types.NetAssetValue{{Price: sdk.NewInt64Coin("hotdog", 1)}, {Price: sdk.NewInt64Coin("jackthecat", 20)}},
},
}
for _, tc := range testCases {
Expand Down
34 changes: 7 additions & 27 deletions x/metadata/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import (
"encoding/base64"
"errors"
"fmt"
"strconv"
"strings"

"github.com/google/uuid"
Expand All @@ -26,7 +24,6 @@
AddSwitch = "add"
RemoveSwitch = "remove"
FlagUsdMills = "usd-mills"
FlagVolume = "volume"
)

// NewTxCmd is the top-level command for Metadata CLI transactions.
Expand Down Expand Up @@ -70,8 +67,8 @@
RemoveRecordCmd(),

SetAccountDataCmd(),

GetCmdAddNetAssetValues(),

Check warning on line 71 in x/metadata/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/client/cli/tx.go#L70-L71

Added lines #L70 - L71 were not covered by tests
)

return txCmd
Expand Down Expand Up @@ -142,19 +139,10 @@

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)
}

Check warning on line 143 in x/metadata/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/client/cli/tx.go#L142-L143

Added lines #L142 - L143 were not covered by tests

volume, err := cmd.Flags().GetUint64(FlagVolume)
if err != nil {
return fmt.Errorf("incorrect value for %s flag. Accepted: 0 or greater value Error: %w", FlagVolume, err)
}

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, usdMills, volume)
msg := types.NewMsgWriteScopeRequest(scope, signers, usdMills)
err = msg.ValidateBasic()
if err != nil {
return err
Expand All @@ -168,7 +156,6 @@
addSignersFlagToCmd(cmd)
flags.AddTxFlagsToCmd(cmd)
cmd.Flags().Uint64(FlagUsdMills, 0, "Indicates the net asset value of scope in usd mills, i.e. 1234 = $1.234")
cmd.Flags().Uint64(FlagVolume, 0, "Indicates the volume of the net asset value")
return cmd
}

Expand Down Expand Up @@ -1283,8 +1270,8 @@
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

Check warning on line 1274 in x/metadata/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/client/cli/tx.go#L1273-L1274

Added lines #L1273 - L1274 were not covered by tests

scopeID, err := types.MetadataAddressFromBech32(args[0])
if err != nil {
Expand All @@ -1300,13 +1287,13 @@
}
signers, err := parseSigners(cmd, &clientCtx)
if err != nil {
return err
}

Check warning on line 1291 in x/metadata/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/client/cli/tx.go#L1290-L1291

Added lines #L1290 - L1291 were not covered by tests

msg := types.NewMsgAddNetAssetValuesRequest(scopeID.String(), signers, netAssetValues)
if err := msg.ValidateBasic(); err != nil {
return err
}

Check warning on line 1296 in x/metadata/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/client/cli/tx.go#L1295-L1296

Added lines #L1295 - L1296 were not covered by tests

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
Expand Down Expand Up @@ -1352,27 +1339,20 @@
return addr, nil
}

// ParseNetAssetValueString splits string (example address1,perm1,perm2...;address2, perm1...) to list of NetAssetValue's
// ParseNetAssetValueString splits string (example 1hotdog,2jackthecat) to list of NetAssetValue's
func ParseNetAssetValueString(netAssetValuesString string) ([]types.NetAssetValue, error) {
navs := strings.Split(netAssetValuesString, ";")
navs := strings.Split(netAssetValuesString, ",")
if len(navs) == 1 && len(navs[0]) == 0 {
return []types.NetAssetValue{}, nil
}
netAssetValues := make([]types.NetAssetValue, len(navs))
for i, nav := range navs {
parts := strings.Split(nav, ",")
if len(parts) != 2 {
return []types.NetAssetValue{}, errors.New("invalid net asset value, expected coin,volume")
}
coin, err := sdk.ParseCoinNormalized(parts[0])
if err != nil {
return []types.NetAssetValue{}, fmt.Errorf("invalid coin %s", parts[0])
}
volume, err := strconv.ParseUint(parts[1], 10, 64)

coin, err := sdk.ParseCoinNormalized(nav)
if err != nil {
return []types.NetAssetValue{}, fmt.Errorf("invalid volume %s", parts[1])
return []types.NetAssetValue{}, fmt.Errorf("invalid coin %s", nav)
Taztingo marked this conversation as resolved.
Show resolved Hide resolved
}
netAssetValues[i] = types.NewNetAssetValue(coin, volume)
netAssetValues[i] = types.NewNetAssetValue(coin)
}
return netAssetValues, nil
}
4 changes: 2 additions & 2 deletions x/metadata/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *MetadataHandlerTestSuite) TestAddAndDeleteScopeDataAccess() {
},
{
"setup test with new scope",
types.NewMsgWriteScopeRequest(*scope, []string{s.user1}, 0, 0),
types.NewMsgWriteScopeRequest(*scope, []string{s.user1}, 0),
[]string{s.user1},
"",
},
Expand Down Expand Up @@ -277,7 +277,7 @@ func (s *MetadataHandlerTestSuite) TestAddAndDeleteScopeOwners() {
},
{
"setup test with new scope",
types.NewMsgWriteScopeRequest(*scope, []string{s.user1}, 0, 0),
types.NewMsgWriteScopeRequest(*scope, []string{s.user1}, 0),
[]string{s.user1},
"",
},
Expand Down
2 changes: 1 addition & 1 deletion x/metadata/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
}

for _, mNavs := range data.NetAssetValues {
for _, nav := range mNavs.NetAssetValues {
address, err := types.MetadataAddressFromBech32(mNavs.Address)
if err != nil {
panic(err)

Check warning on line 69 in x/metadata/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/genesis.go#L66-L69

Added lines #L66 - L69 were not covered by tests
}
err = k.SetNetAssetValue(ctx, address, types.NewNetAssetValue(nav.Price, nav.Volume), types.ModuleName)
err = k.SetNetAssetValue(ctx, address, types.NewNetAssetValue(nav.Price), types.ModuleName)
if err != nil {
panic(err)

Check warning on line 73 in x/metadata/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/genesis.go#L71-L73

Added lines #L71 - L73 were not covered by tests
}
}
}
Expand Down Expand Up @@ -147,21 +147,21 @@
panic(err)
}

markerNetAssetValues := make([]types.MarkerNetAssetValues, len(scopes))
for i := range scopes {
var markerNavs types.MarkerNetAssetValues
var navs []types.NetAssetValue
err := k.IterateNetAssetValues(ctx, scopes[i].ScopeId, func(nav types.NetAssetValue) (stop bool) {
navs = append(navs, nav)
return false
})
if err != nil {
panic(err)

Check warning on line 159 in x/metadata/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/genesis.go#L150-L159

Added lines #L150 - L159 were not covered by tests
}
markerNavs.Address = scopes[i].ScopeId.String()
markerNavs.NetAssetValues = navs
markerNetAssetValues[i] = markerNavs

Check warning on line 163 in x/metadata/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/genesis.go#L161-L163

Added lines #L161 - L163 were not covered by tests
}

return types.NewGenesisState(params, oslocatorparams, scopes, sessions, records, scopeSpecs, contractSpecs, recordSpecs, objectStoreLocators, markerNetAssetValues)

Check warning on line 166 in x/metadata/keeper/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/genesis.go#L166

Added line #L166 was not covered by tests
}
4 changes: 3 additions & 1 deletion x/metadata/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
}

nav := types.NewNetAssetValue(sdk.NewInt64Coin(types.UsdDenom, int64(msg.UsdMills)), msg.Volume)
nav := types.NewNetAssetValue(sdk.NewInt64Coin(types.UsdDenom, int64(msg.UsdMills)))
err := k.AddSetNetAssetValues(ctx, msg.Scope.ScopeId, []types.NetAssetValue{nav}, types.ModuleName)
if err != nil {
return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
}

Check warning on line 51 in x/metadata/keeper/msg_server.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/msg_server.go#L47-L51

Added lines #L47 - L51 were not covered by tests

k.SetScope(ctx, msg.Scope)

Expand All @@ -70,6 +70,8 @@

k.RemoveScope(ctx, msg.ScopeId)

k.RemoveNetAssetValues(ctx, msg.ScopeId)

Check warning on line 74 in x/metadata/keeper/msg_server.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/msg_server.go#L73-L74

Added lines #L73 - L74 were not covered by tests
k.EmitEvent(ctx, types.NewEventTxCompleted(types.TxEndpoint_DeleteScope, msg.GetSignerStrs()))
return types.NewMsgDeleteScopeResponse(), nil
}
Expand Down Expand Up @@ -741,8 +743,8 @@

scopeID, err := types.MetadataAddressFromBech32(msg.ScopeId)
if err != nil {
return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
}

Check warning on line 747 in x/metadata/keeper/msg_server.go

View check run for this annotation

Codecov / codecov/patch

x/metadata/keeper/msg_server.go#L746-L747

Added lines #L746 - L747 were not covered by tests

scope, found := k.GetScope(ctx, scopeID)
if !found {
Expand Down
6 changes: 1 addition & 5 deletions x/metadata/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ func (s *MsgServerTestSuite) TestAddNetAssetValue() {
ScopeId: scopeSpecIDNF.String(),
NetAssetValues: []types.NetAssetValue{
{
Price: sdk.NewInt64Coin("navcoin", 1),
Volume: 1,
Price: sdk.NewInt64Coin("navcoin", 1),
}},
Signers: []string{user1},
},
Expand All @@ -99,7 +98,6 @@ func (s *MsgServerTestSuite) TestAddNetAssetValue() {
NetAssetValues: []types.NetAssetValue{
{
Price: sdk.NewInt64Coin("hotdog", 100),
Volume: uint64(100),
UpdatedBlockHeight: 1,
},
},
Expand All @@ -114,7 +112,6 @@ func (s *MsgServerTestSuite) TestAddNetAssetValue() {
NetAssetValues: []types.NetAssetValue{
{
Price: sdk.NewInt64Coin(types.UsdDenom, 100),
Volume: uint64(100),
UpdatedBlockHeight: 1,
},
},
Expand All @@ -129,7 +126,6 @@ func (s *MsgServerTestSuite) TestAddNetAssetValue() {
NetAssetValues: []types.NetAssetValue{
{
Price: sdk.NewInt64Coin(types.UsdDenom, 100),
Volume: uint64(100),
UpdatedBlockHeight: 1,
},
},
Expand Down
1 change: 0 additions & 1 deletion x/metadata/keeper/query_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,6 @@ func (s *QueryServerTestSuite) TestScopeNetAssetValuesQuery() {
Denom: fmt.Sprintf("usd%v", i),
Amount: sdk.NewInt(100 * int64(i+1)),
},
Volume: uint64(100 * (i + 1)),
}
err := app.MetadataKeeper.SetNetAssetValue(ctx, scopeID, netAssetValues[i], "source")
s.Require().NoError(err)
Expand Down
Loading
Loading