-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client/v2/autocli): add CoinDec flag (#22817)
Co-authored-by: Marko <[email protected]> Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 57b4d30) # Conflicts: # client/v2/go.mod # client/v2/go.sum # go.mod # go.sum # indexer/postgres/go.mod # indexer/postgres/tests/go.mod # runtime/v2/go.mod # runtime/v2/go.sum # schema/testing/go.mod # server/v2/cometbft/go.mod # server/v2/cometbft/go.sum # server/v2/go.mod # server/v2/go.sum # server/v2/stf/go.mod # server/v2/stf/go.sum # simapp/go.mod # simapp/go.sum # simapp/v2/go.mod # simapp/v2/go.sum # tests/go.mod # tests/go.sum # x/accounts/defaults/base/go.mod # x/accounts/defaults/base/go.sum # x/accounts/defaults/lockup/go.mod # x/accounts/defaults/lockup/go.sum # x/accounts/defaults/multisig/go.mod # x/accounts/defaults/multisig/go.sum # x/accounts/go.mod # x/accounts/go.sum # x/authz/go.mod # x/authz/go.sum # x/bank/go.mod # x/bank/go.sum # x/circuit/go.mod # x/circuit/go.sum # x/consensus/go.mod # x/consensus/go.sum # x/distribution/go.mod # x/distribution/go.sum # x/epochs/go.mod # x/epochs/go.sum # x/evidence/go.mod # x/evidence/go.sum # x/feegrant/go.mod # x/feegrant/go.sum # x/gov/go.mod # x/gov/go.sum # x/group/go.mod # x/group/go.sum # x/mint/go.mod # x/mint/go.sum # x/nft/go.mod # x/nft/go.sum # x/params/go.mod # x/params/go.sum # x/protocolpool/go.mod # x/protocolpool/go.sum # x/slashing/go.mod # x/slashing/go.sum # x/staking/go.mod # x/staking/go.sum # x/upgrade/go.mod # x/upgrade/go.sum
- Loading branch information
1 parent
0cf6cd8
commit f7f07fb
Showing
69 changed files
with
1,710 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package flag | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"strings" | ||
|
||
"google.golang.org/protobuf/reflect/protoreflect" | ||
|
||
basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" | ||
"cosmossdk.io/client/v2/internal/coins" | ||
) | ||
|
||
type decCoinType struct{} | ||
|
||
type decCoinValue struct { | ||
value *basev1beta1.DecCoin | ||
} | ||
|
||
func (c decCoinType) NewValue(*context.Context, *Builder) Value { | ||
return &decCoinValue{} | ||
} | ||
|
||
func (c decCoinType) DefaultValue() string { | ||
return "zero" | ||
} | ||
|
||
func (c *decCoinValue) Get(protoreflect.Value) (protoreflect.Value, error) { | ||
if c.value == nil { | ||
return protoreflect.Value{}, nil | ||
} | ||
return protoreflect.ValueOfMessage(c.value.ProtoReflect()), nil | ||
} | ||
|
||
func (c *decCoinValue) String() string { | ||
if c.value == nil { | ||
return "" | ||
} | ||
|
||
return c.value.String() | ||
} | ||
|
||
func (c *decCoinValue) Set(stringValue string) error { | ||
if strings.Contains(stringValue, ",") { | ||
return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") | ||
} | ||
|
||
coin, err := coins.ParseDecCoin(stringValue) | ||
if err != nil { | ||
return err | ||
} | ||
c.value = coin | ||
return nil | ||
} | ||
|
||
func (c *decCoinValue) Type() string { | ||
return "cosmos.base.v1beta1.DecCoin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module cosmossdk.io/indexer/postgres | ||
|
||
// NOTE: we are staying on an earlier version of golang to avoid problems building | ||
// with older codebases. | ||
go 1.12 | ||
|
||
// NOTE: cosmossdk.io/schema should be the only dependency here | ||
// so there are no problems building this with any version of the SDK. | ||
// This module should only use the golang standard library (database/sql) | ||
// and cosmossdk.io/indexer/base. | ||
require cosmossdk.io/schema v0.4.0 | ||
|
||
replace cosmossdk.io/schema => ../../schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module cosmossdk.io/indexer/postgres/testing | ||
|
||
go 1.23 | ||
|
||
require ( | ||
cosmossdk.io/indexer/postgres v0.0.0-00010101000000-000000000000 | ||
cosmossdk.io/schema v0.4.0 | ||
cosmossdk.io/schema/testing v0.0.0 | ||
github.com/fergusstrange/embedded-postgres v1.29.0 | ||
github.com/hashicorp/consul/sdk v0.16.1 | ||
github.com/jackc/pgx/v5 v5.7.1 | ||
github.com/stretchr/testify v1.10.0 | ||
gotest.tools/v3 v3.5.1 | ||
) | ||
|
||
require ( | ||
github.com/cockroachdb/apd/v3 v3.2.1 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect | ||
github.com/jackc/puddle/v2 v2.2.2 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/lib/pq v1.10.9 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/rogpeppe/go-internal v1.12.0 // indirect | ||
github.com/tidwall/btree v1.7.0 // indirect | ||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect | ||
golang.org/x/crypto v0.29.0 // indirect | ||
golang.org/x/sync v0.9.0 // indirect | ||
golang.org/x/sys v0.27.0 // indirect | ||
golang.org/x/text v0.20.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
pgregory.net/rapid v1.1.0 // indirect | ||
) | ||
|
||
replace cosmossdk.io/indexer/postgres => ../. | ||
|
||
replace cosmossdk.io/schema => ../../../schema | ||
|
||
replace cosmossdk.io/schema/testing => ../../../schema/testing |
Oops, something went wrong.