Skip to content

Commit

Permalink
Update protos to use mills and update cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taztingo committed Jan 17, 2024
1 parent 5b3271a commit cee360f
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 151 deletions.
4 changes: 2 additions & 2 deletions docs/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4623,7 +4623,7 @@ MsgAddFinalizeActivateMarkerRequest defines the Msg/AddFinalizeActivateMarker re
| `allow_governance_control` | [bool](#bool) | | |
| `allow_forced_transfer` | [bool](#bool) | | |
| `required_attributes` | [string](#string) | repeated | |
| `usd_cents` | [uint64](#uint64) | | |
| `usd_mills` | [uint64](#uint64) | | |
| `volume` | [uint64](#uint64) | | |


Expand Down Expand Up @@ -4660,7 +4660,7 @@ If being provided as a governance proposal, set the from_address to the gov modu
| `allow_governance_control` | [bool](#bool) | | |
| `allow_forced_transfer` | [bool](#bool) | | |
| `required_attributes` | [string](#string) | repeated | |
| `usd_cents` | [uint64](#uint64) | | |
| `usd_mills` | [uint64](#uint64) | | |
| `volume` | [uint64](#uint64) | | |


Expand Down
4 changes: 2 additions & 2 deletions proto/provenance/marker/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ message MsgAddMarkerRequest {
bool allow_governance_control = 9;
bool allow_forced_transfer = 10;
repeated string required_attributes = 11;
uint64 usd_cents = 12;
uint64 usd_mills = 12;

Check failure on line 99 in proto/provenance/marker/v1/tx.proto

View workflow job for this annotation

GitHub Actions / Protobuf Checks

Field "12" with name "usd_mills" on message "MsgAddMarkerRequest" changed option "json_name" from "usdCents" to "usdMills".

Check failure on line 99 in proto/provenance/marker/v1/tx.proto

View workflow job for this annotation

GitHub Actions / Protobuf Checks

Field "12" on message "MsgAddMarkerRequest" changed name from "usd_cents" to "usd_mills".
uint64 volume = 13;
}

Expand Down Expand Up @@ -229,7 +229,7 @@ message MsgAddFinalizeActivateMarkerRequest {
bool allow_governance_control = 8;
bool allow_forced_transfer = 9;
repeated string required_attributes = 10;
uint64 usd_cents = 11;
uint64 usd_mills = 11;

Check failure on line 232 in proto/provenance/marker/v1/tx.proto

View workflow job for this annotation

GitHub Actions / Protobuf Checks

Field "11" with name "usd_mills" on message "MsgAddFinalizeActivateMarkerRequest" changed option "json_name" from "usdCents" to "usdMills".

Check failure on line 232 in proto/provenance/marker/v1/tx.proto

View workflow job for this annotation

GitHub Actions / Protobuf Checks

Field "11" on message "MsgAddFinalizeActivateMarkerRequest" changed name from "usd_cents" to "usd_mills".
uint64 volume = 12;
}

Expand Down
18 changes: 9 additions & 9 deletions x/marker/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ func TestParseNewMarkerFlags(t *testing.T) {
argGov := "--" + markercli.FlagAllowGovernanceControl
argForce := "--" + markercli.FlagAllowForceTransfer
argRequiredAtt := "--" + markercli.FlagRequiredAttributes
argUsdCents := "--" + markercli.FlagUsdCents
argUsdMills := "--" + markercli.FlagUsdMills
argVolume := "--" + markercli.FlagVolume

tests := []struct {
Expand Down Expand Up @@ -2155,10 +2155,10 @@ func TestParseNewMarkerFlags(t *testing.T) {
},
},
{
name: "usd cents present without volume",
name: "usd mills present without volume",
cmd: getTestCmd(),
args: []string{argUsdCents + "=10"},
expErr: []string{"incorrect value for volume flag. Must be positive number if usd-cents flag has been set to positive value"},
args: []string{argUsdMills + "=10"},
expErr: []string{"incorrect value for volume flag. Must be positive number if usd-mills flag has been set to positive value"},
},
{
name: "volume present",
Expand All @@ -2170,35 +2170,35 @@ func TestParseNewMarkerFlags(t *testing.T) {
AllowGovControl: false,
AllowForceTransfer: false,
RequiredAttributes: []string{},
UsdCents: 0,
UsdMills: 0,
Volume: 11,
},
},
{
name: "usd-cents and volume present",
cmd: getTestCmd(),
args: []string{argVolume + "=11", argUsdCents + "=1"},
args: []string{argVolume + "=11", argUsdMills + "=1"},
exp: &markercli.NewMarkerFlagValues{
MarkerType: types.MarkerType_Coin,
SupplyFixed: false,
AllowGovControl: false,
AllowForceTransfer: false,
RequiredAttributes: []string{},
UsdCents: 1,
UsdMills: 1,
Volume: 11,
},
},
{
name: "everything",
cmd: getTestCmd(),
args: []string{argForce, argGov, argType, "RESTRICTED", argFixed, argRequiredAtt, "jack.the.cat.io,george.the.dog.io", argUsdCents, "10", argVolume, "12"},
args: []string{argForce, argGov, argType, "RESTRICTED", argFixed, argRequiredAtt, "jack.the.cat.io,george.the.dog.io", argUsdMills, "10", argVolume, "12"},
exp: &markercli.NewMarkerFlagValues{
MarkerType: types.MarkerType_RestrictedCoin,
SupplyFixed: true,
AllowGovControl: true,
AllowForceTransfer: true,
RequiredAttributes: []string{"jack.the.cat.io", "george.the.dog.io"},
UsdCents: 10,
UsdMills: 10,
Volume: 12,
},
},
Expand Down
18 changes: 9 additions & 9 deletions x/marker/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const (
FlagAdd = "add"
FlagRemove = "remove"
FlagGovProposal = "gov-proposal"
FlagUsdCents = "usd-cents"
FlagUsdMills = "usd-mills"
FlagVolume = "volume"
)

Expand Down Expand Up @@ -151,7 +151,7 @@ with the given supply amount and denomination provided in the coin argument
flagVals.AllowGovControl,
flagVals.AllowForceTransfer,
flagVals.RequiredAttributes,
flagVals.UsdCents,
flagVals.UsdMills,
flagVals.Volume,
)

Expand Down Expand Up @@ -870,7 +870,7 @@ with the given supply amount and denomination provided in the coin argument
msg := types.NewMsgAddFinalizeActivateMarkerRequest(
coin.Denom, coin.Amount, callerAddr, callerAddr, flagVals.MarkerType,
flagVals.SupplyFixed, flagVals.AllowGovControl,
flagVals.AllowForceTransfer, flagVals.RequiredAttributes, accessGrants, flagVals.UsdCents, flagVals.Volume,
flagVals.AllowForceTransfer, flagVals.RequiredAttributes, accessGrants, flagVals.UsdMills, flagVals.Volume,
)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
Expand Down Expand Up @@ -1146,7 +1146,7 @@ func AddNewMarkerFlags(cmd *cobra.Command) {
cmd.Flags().Bool(FlagAllowGovernanceControl, false, "Indicates that governance control is allowed")
cmd.Flags().Bool(FlagAllowForceTransfer, false, "Indicates that force transfer is allowed")
cmd.Flags().StringSlice(FlagRequiredAttributes, []string{}, "comma delimited list of required attributes needed for a restricted marker to have send authority")
cmd.Flags().Uint64(FlagUsdCents, 0, "Indicates the net asset value of marker in usd cents, i.e. 1234 = $1.234")
cmd.Flags().Uint64(FlagUsdMills, 0, "Indicates the net asset value of marker in usd mills, i.e. 12345 = $1.2345")
cmd.Flags().Uint64(FlagVolume, 0, "Indicates the volume of the net asset value")
}

Expand All @@ -1157,7 +1157,7 @@ type NewMarkerFlagValues struct {
AllowGovControl bool
AllowForceTransfer bool
RequiredAttributes []string
UsdCents uint64
UsdMills uint64
Volume uint64
}

Expand Down Expand Up @@ -1198,18 +1198,18 @@ func ParseNewMarkerFlags(cmd *cobra.Command) (*NewMarkerFlagValues, error) {
return nil, fmt.Errorf("incorrect value for %s flag. Accepted: comma delimited list of attributes Error: %w", FlagRequiredAttributes, err)
}

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

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

if rv.UsdCents > 0 && rv.Volume == 0 {
return nil, fmt.Errorf("incorrect value for %s flag. Must be positive number if %s flag has been set to positive value", FlagVolume, FlagUsdCents)
if rv.UsdMills > 0 && rv.Volume == 0 {
return nil, fmt.Errorf("incorrect value for %s flag. Must be positive number if %s flag has been set to positive value", FlagVolume, FlagUsdMills)
}

return rv, nil
Expand Down
Loading

0 comments on commit cee360f

Please sign in to comment.