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

DO NOT MERGE: Osmo v28/0.50.11 #632

Open
wants to merge 27 commits into
base: osmo-v27/0.50.10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
35f8d05
docs: update gov docs (backport #22048) (#22050)
mergify[bot] Oct 2, 2024
8df6800
docs(keys): remove unsupported `--dry-run` flag description for `keys…
mergify[bot] Oct 3, 2024
d3ee514
chore: Revert "docs: update gov docs (backport #22048)" (#22064)
julienrbrt Oct 3, 2024
b57ce4d
docs(x/genutil): fix `genesis migrate` command examples (backport #22…
mergify[bot] Oct 3, 2024
27f1f78
chore(simapp): be consistent with runtime (#22203)
julienrbrt Oct 10, 2024
955304a
docs: add docs boilerplate (backport #22202) (#22210)
mergify[bot] Oct 10, 2024
9efec42
fix(x/tx): sort with oneof field name in amino-json (backport #21782)…
mergify[bot] Oct 11, 2024
751e5ec
chore(x/group): update supported flags (backport #22229) (#22231)
mergify[bot] Oct 11, 2024
6be4b79
fix(x/group): proper address rendering in error (backport #22425) (#2…
mergify[bot] Nov 5, 2024
3b72e77
feat(client/v2): add keyring flags in query commands (backport #22443…
mergify[bot] Nov 6, 2024
0ab5319
build(deps): Bump cosmossdk.io/depinject from 1.0.0 to 1.1.0 (#22463)
dependabot[bot] Nov 7, 2024
d8d7eb0
build(deps): Bump actions/xxx-artifact from v3 to v4 (#22473)
auricom Nov 8, 2024
47874ac
fix(server): fix fallback genesis path (backport #22564) (#22573)
mergify[bot] Nov 20, 2024
56c2c7d
build(deps): Bump cosmossdk.io/math from 1.3.0 to 1.4.0 (#22607)
dependabot[bot] Nov 21, 2024
8210b50
fix(client/v2/autocli): prevent duplicate addition of customCommands …
mergify[bot] Nov 21, 2024
7bb2a3d
build(deps): Bump github.com/cosmos/cosmos-db from 1.0.2 to 1.1.0 (#2…
dependabot[bot] Nov 25, 2024
43ac3df
build(deps): Bump github.com/cosmos/iavl from 1.2.0 to 1.2.2 (#22662)
dependabot[bot] Nov 27, 2024
96a3016
chore: prepare v0.50.11 (#22643)
julienrbrt Dec 2, 2024
4a73a1e
fix(client/v2/autocli): add CoinDec flag (backport #22817) (#22821)
mergify[bot] Dec 10, 2024
d62bcbd
fix(x/tx): fix amino json drift from legacy spec (backport #21825) (#…
mergify[bot] Dec 12, 2024
3b082b5
build(deps): Bump cosmossdk.io/x/tx from 0.13.6-0.20241003112805-ff87…
dependabot[bot] Dec 12, 2024
679ca5e
chore: edit changelog store (partial backport #22864) (#22884)
mergify[bot] Dec 16, 2024
ba7ac45
Merge commit from fork
alpe Dec 16, 2024
eb1a8e8
chore: prep v0.50.11 release notes (#22898)
julienrbrt Dec 16, 2024
1a5cb64
Merge remote-tracking branch 'upstream/release/v0.50.x' into osmo-v28…
PaddyMc Dec 18, 2024
a359383
chore: add changelog (#633)
PaddyMc Dec 19, 2024
08e95fc
chore: bump IAVL to latest version for speed up (#634)
PaddyMc Jan 10, 2025
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
40 changes: 26 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ jobs:
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
run: split -d -n l/4 pkgs.txt pkgs.txt.part.
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-00"
path: ./pkgs.txt.part.00
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-01"
path: ./pkgs.txt.part.01
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-02"
path: ./pkgs.txt.part.02
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-03"
path: ./pkgs.txt.part.03
Expand Down Expand Up @@ -70,14 +70,14 @@ jobs:
**/go.sum
**/Makefile
Makefile
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-${{ matrix.part }}"
- name: test & coverage report creation
if: env.GIT_DIFF
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -race -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock'
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
if: env.GIT_DIFF
run: |
make test-integration-cov
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-integration-coverage"
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
if: env.GIT_DIFF
run: |
make test-e2e-cov
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-e2e-coverage"
Expand All @@ -159,27 +159,27 @@ jobs:
go.sum
**/go.mod
**/go.sum
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-00-coverage"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-01-coverage"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-02-coverage"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-03-coverage"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-integration-coverage"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-e2e-coverage"
Expand Down Expand Up @@ -838,3 +838,15 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/upgrade/

test-system: # no system tests in v0.50, set to match required job
runs-on: ubuntu-latest
steps:
- name: do nothing
run: echo "no system tests in v0.50"

test-system-v2: # no system tests in v0.50, set to match required job
runs-on: ubuntu-latest
steps:
- name: do nothing
run: echo "no system tests in v0.50"
70 changes: 16 additions & 54 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Osmosis Specific Info

## v27
## v28

## [v0.50.10-v27-osmo-1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/TODO)
## [v0.50.11-v28-osmo-1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.50.11-v28-osmo-1)

This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89](https://github.com/cosmos/cosmos-sdk/commit/bd886bb4b03fdfc52bdc1fa2f98e960316604f89) commit of the [release/v0.50.x](https://github.com/cosmos/cosmos-sdk/commits/release/v0.50.x/) branch. If you catch this fork up with the latest changes from upstream, please start at the commit after the one mentioned above, and work your way to the tip (or desired commit) of the upstream branch. Then, update this message with the new commit hash. Also, when you add a new PRs to this branch on Osmosis and it is not yet upstreamed, make sure you add it both directly below AND in the respective release section of this file.
This v0.50.x branch was created at the [eb1a8e88a4ddf77bc2fe235fc07c57016b7386f0](https://github.com/cosmos/cosmos-sdk/commit/eb1a8e88a4ddf77bc2fe235fc07c57016b7386f0) commit of the [release/v0.50.x](https://github.com/cosmos/cosmos-sdk/commits/release/v0.50.x/) branch. If you catch this fork up with the latest changes from upstream, please start at the commit after the one mentioned above, and work your way to the tip (or desired commit) of the upstream branch. Then, update this message with the new commit hash. Also, when you add a new PRs to this branch on Osmosis and it is not yet upstreamed, make sure you add it both directly below AND in the respective release section of this file.

### Osmosis Specific PRs (should upstream)

Expand Down Expand Up @@ -86,6 +86,7 @@ This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89
* [#572](https://github.com/osmosis-labs/cosmos-sdk/pull/572) Fix fast nodes whitelist parsing

* IAVL
* [#634](https://github.com/osmosis-labs/cosmos-sdk/pull/634) Bump IAVL to v1.2.4 for speed ups in block sync
* [#593](https://github.com/osmosis-labs/cosmos-sdk/pull/593) Async pruning IAVL v1

### Osmosis Specific PRs (unknown upstream status)
Expand All @@ -101,65 +102,22 @@ This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89
* Cliff Vesting
* [#271](https://github.com/osmosis-labs/cosmos-sdk/pull/271) Bring back cliff vesting CLI command

## v26
## v27

## [v0.50.x-v26-osmo-1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/TODO)
## [v0.50.10-v27-osmo-1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.50.10-v27-osmo-1)

This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89](https://github.com/cosmos/cosmos-sdk/commit/bd886bb4b03fdfc52bdc1fa2f98e960316604f89) commit of the [release/v0.50.x](https://github.com/cosmos/cosmos-sdk/commits/release/v0.50.x/) branch. If you catch this fork up with the latest changes from upstream, please start at the commit after the one mentioned above, and work your way to the tip (or desired commit) of the upstream branch. Then, update this message with the new commit hash. Also, when you add a new PRs to this branch on Osmosis and it is not yet upstreamed, make sure you add it both directly below AND in the respective release section of this file.

### Osmosis Specific PRs (should upstream)

* Instant Undelegate
* [5046a6d](https://github.com/osmosis-labs/cosmos-sdk/commit/5046a6d19a5e1127ef106b0318740cd1bccb429e) InstantUndelegate + basic test

* Supply Offsets
* [#119](https://github.com/osmosis-labs/cosmos-sdk/pull/119) Add SupplyOffsets to bank module
* [#295](https://github.com/osmosis-labs/cosmos-sdk/pull/295) Negative supplyWithOffset returns 0

* Clawback Vesting Account
* [#171](https://github.com/osmosis-labs/cosmos-sdk/pull/171) Add proto for clawback vesting Account
* [#178](https://github.com/osmosis-labs/cosmos-sdk/pull/178) Add clawback vesting account
* [5b03258](https://github.com/osmosis-labs/cosmos-sdk/commit/5b032581d579eac710ce0acb62edd84fe9679c18) Add more clawback vesting tests

* Track Before Send and Block Before Send
* [#278](https://github.com/osmosis-labs/cosmos-sdk/pull/278) Add a BeforeSend hook to the bank module
* [#421](https://github.com/osmosis-labs/cosmos-sdk/pull/421) Add TrackBeforeSend, BlockBeforeSend hooks. Deprecate BeforeSend hook

### Osmosis Specific PRs (should not upstream)

* Slashing
* [0609929](https://github.com/osmosis-labs/cosmos-sdk/commit/0609929d2ddfd845aebfe53622176660f8392fcb) Osmosis specific key migration slashing changes, due to implementing it early in v0.47.x

* Distribution
* [#527](https://github.com/osmosis-labs/cosmos-sdk/pull/527) Distribute every 50 blocks

* Performance (Already upstreamed but not in this version)
* [#538](https://github.com/osmosis-labs/cosmos-sdk/pull/538) Slight speedup to Slashing BeginBlock logic
* [#570](https://github.com/osmosis-labs/cosmos-sdk/pull/570) Removal of regex usage on denom validation

* Per module fast nodes
* [#552](https://github.com/osmosis-labs/cosmos-sdk/pull/552) Per module fast nodes implementation
* [715f32](https://github.com/osmosis-labs/cosmos-sdk/commit/715f3216416030f5b1bb30f02882ee38e238c1a2) Replace store imports with fast nodes
* [#572](https://github.com/osmosis-labs/cosmos-sdk/pull/572) Fix fast nodes whitelist parsing

* IAVL
* [#593](https://github.com/osmosis-labs/cosmos-sdk/pull/593) Async pruning IAVL v1

### Osmosis Specific PRs (unknown upstream status)
## v26

* Performance Improvements
* [b9a3e8f](https://github.com/osmosis-labs/cosmos-sdk/commit/b9a3e8fa12229200b31a1e7c1805ab5a495fbd11) Lower event emission from Osmosis epoch sends
* [bbb9a48](https://github.com/osmosis-labs/cosmos-sdk/commit/bbb9a4898aa46cb27d2b482a74259687afe4ab16) Remove GetAccount calls in epoch
* [8628b48](https://github.com/osmosis-labs/cosmos-sdk/commit/8628b4869dcbf7427d4de8a5a6f8e40d9fa86e66) Types speedups
* [3ef7ba4](https://github.com/osmosis-labs/cosmos-sdk/commit/3ef7ba4964b74154eb9d394dbe25fd967b31fbed) Replace amino json encoder with stdlib
* [#601](https://github.com/osmosis-labs/cosmos-sdk/pull/601) Don't run ValidateBasic on recheck
* [#603](https://github.com/osmosis-labs/cosmos-sdk/pull/603) Remove IAVL per-get/delete timing info
## [v0.50.x-v26-osmo-1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/TODO)

* Cliff Vesting
* [#271](https://github.com/osmosis-labs/cosmos-sdk/pull/271) Bring back cliff vesting CLI command
This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89](https://github.com/cosmos/cosmos-sdk/commit/bd886bb4b03fdfc52bdc1fa2f98e960316604f89) commit of the [release/v0.50.x](https://github.com/cosmos/cosmos-sdk/commits/release/v0.50.x/) branch. If you catch this fork up with the latest changes from upstream, please start at the commit after the one mentioned above, and work your way to the tip (or desired commit) of the upstream branch. Then, update this message with the new commit hash. Also, when you add a new PRs to this branch on Osmosis and it is not yet upstreamed, make sure you add it both directly below AND in the respective release section of this file.

## [Unreleased]

## [v0.50.11](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.11) - 2024-12-16

### Features

* (crypto/keyring) [#21653](https://github.com/cosmos/cosmos-sdk/pull/21653) New Linux-only backend that adds Linux kernel's `keyctl` support.
Expand All @@ -170,8 +128,12 @@ This v0.50.x branch was created at the [bd886bb4b03fdfc52bdc1fa2f98e960316604f89

### Bug Fixes

* (sims) [21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* Fix [ABS-0043/ABS-0044](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-8wcc-m6j2-qxvm) Limit recursion depth for unknown field detection and unpack any
* (server) [#22564](https://github.com/cosmos/cosmos-sdk/pull/22564) Fix fallback genesis path in server
* (x/group) [#22425](https://github.com/cosmos/cosmos-sdk/pull/22425) Proper address rendering in error
* (sims) [#21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* (cli) [#21919](https://github.com/cosmos/cosmos-sdk/pull/21919) Query address-by-acc-num by account_id instead of id.
* (x/group) [#22229](https://github.com/cosmos/cosmos-sdk/pull/22229) Accept `1` and `try` in CLI for group proposal exec.

## [v0.50.10](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.10) - 2024-09-20

Expand Down
24 changes: 15 additions & 9 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# Cosmos SDK v0.50.10 Release Notes
# Cosmos SDK v0.50.11 Release Notes

💬 [**Release Discussion**](https://github.com/orgs/cosmos/discussions/58)

## 🚀 Highlights

For this month patch release of the v0.50.x line, some bugs were fixed.
We are back on schedule for our monthly v0.50.x patch releases.
The last two months, next to ramping up on v0.52 and v2, we added a few bug fixes and (UX) improvements.

Notably, we fixed the following:
Notable changes:

* Add the root command `module-hash-by-height` to query and retrieve module hashes at a specific height
* `PreBlock` events (mainly `x/upgrade`) are now emitted (this time, for real)
* A fix in runtime baseapp option ordering, giving issue when other modules were having options
* Fix [ABS-0043/ABS-0044](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-8wcc-m6j2-qxvm).
* New Linux-only backend that adds Linux kernel's `keyctl` support
* Skip sims test when running dry on validators

## 📝 Changelog

Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/CHANGELOG.md) for an exhaustive list of changes, or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/v0.50.9...v0.50.10) from the last release.
Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.50.11/CHANGELOG.md) for an exhaustive list of changes, or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/v0.50.10...v0.50.11) from the last release.

Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.50.x/UPGRADING.md) when migrating from `v0.47.x` to `v0.50.1`.
Note, that the next SDK release, v0.52, will not include `x/params` migration, when migrating from < v0.47, v0.50.x **or** v0.47.x, is a mandatory migration.
## Maintenance Policy

Cosmos SDK Olympus (v0.52) final release is approaching really soon. That means the Eden line (v0.50.x) will soon only be supported for bug fixes only, as per our release policy. Earlier versions are not maintained.

Note, that the next SDK release, v0.52, does not include `x/params` migration, when migrating from < v0.47, v0.50.x **or** v0.47.x, is a mandatory migration.

Start integrating with [Cosmos SDK Eden (v0.52)](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#v052x) and enjoy and the new features and performance improvements.
2 changes: 0 additions & 2 deletions client/keys/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Otherwise, we try to deserialize it using Amino into LegacyInfo. If this attempt
LegacyInfo to Protobuf serialization format and overwrite the keyring entry. If any error occurred, it will be
outputted in CLI and migration will be continued until all keys in the keyring DB are exhausted.
See https://github.com/cosmos/cosmos-sdk/pull/9695 for more details.

It is recommended to run in 'dry-run' mode first to verify all key migration material.
`,
Args: cobra.NoArgs,
RunE: runMigrateCmd,
Expand Down
10 changes: 10 additions & 0 deletions client/v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v2.0.0-beta.7] - 2024-12-10

### Bug Fixes

* [#22817](https://github.com/cosmos/cosmos-sdk/pull/22817) Add DecCoin support in autocli flag builder.

## [v2.0.0-beta.6] - 2024-11-21

### Improvements

* [#22443](https://github.com/cosmos/cosmos-sdk/pull/22443) Add keyring flags in query commands.
* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided.

### Bug Fixes

* [#21809](https://github.com/cosmos/cosmos-sdk/pull/21809) Correctly handle enhanced sub commands.
* [#22576](https://github.com/cosmos/cosmos-sdk/pull/22576) Fix duplicate command addition in `autocli` when custom enhanced command has a different name than module name

## [v2.0.0-beta.5] - 2024-09-18

Expand Down
7 changes: 5 additions & 2 deletions client/v2/autocli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error {
GetClientConn: func(cmd *cobra.Command) (grpc.ClientConnInterface, error) {
return client.GetClientQueryContext(cmd)
},
AddQueryConnFlags: sdkflags.AddQueryFlagsToCmd,
AddTxConnFlags: sdkflags.AddTxFlagsToCmd,
AddQueryConnFlags: func(c *cobra.Command) {
sdkflags.AddQueryFlagsToCmd(c)
sdkflags.AddKeyringFlags(c.Flags())
},
AddTxConnFlags: sdkflags.AddTxFlagsToCmd,
}

return appOptions.EnhanceRootCommandWithBuilder(rootCmd, builder)
Expand Down
11 changes: 10 additions & 1 deletion client/v2/autocli/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,16 @@ func (b *Builder) enhanceCommandCommon(

// if we have a custom command use that instead of generating one
if custom, ok := customCmds[moduleName]; ok {
if hasModuleOptions { // check if we need to enhance the existing command
// Custom may not be called the same as its module, so we need to have a separate check here
if subCmd := findSubCommand(cmd, custom.Name()); subCmd != nil {
if hasModuleOptions { // check if we need to enhance the existing command
if err := enhanceCustomCmd(b, subCmd, cmdType, modOpts); err != nil {
return err
}
}
continue
}
if hasModuleOptions { // check if we need to enhance the new command
if err := enhanceCustomCmd(b, custom, cmdType, modOpts); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions client/v2/autocli/flag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (b *Builder) init() {
b.messageFlagTypes["google.protobuf.Timestamp"] = timestampType{}
b.messageFlagTypes["google.protobuf.Duration"] = durationType{}
b.messageFlagTypes["cosmos.base.v1beta1.Coin"] = coinType{}
b.messageFlagTypes["cosmos.base.v1beta1.DecCoin"] = decCoinType{}
}

if b.scalarFlagTypes == nil {
Expand Down
13 changes: 8 additions & 5 deletions client/v2/autocli/flag/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package flag

import (
"context"
"fmt"
"errors"
"strings"

"google.golang.org/protobuf/reflect/protoreflect"

basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
"cosmossdk.io/core/coins"
"cosmossdk.io/client/v2/internal/coins"
)

type coinType struct{}
Expand All @@ -22,8 +22,7 @@ func (c coinType) NewValue(*context.Context, *Builder) Value {
}

func (c coinType) DefaultValue() string {
stringCoin, _ := coins.FormatCoins([]*basev1beta1.Coin{}, nil)
return stringCoin
return "zero"
}

func (c *coinValue) Get(protoreflect.Value) (protoreflect.Value, error) {
Expand All @@ -34,12 +33,16 @@ func (c *coinValue) Get(protoreflect.Value) (protoreflect.Value, error) {
}

func (c *coinValue) String() string {
if c.value == nil {
return ""
}

return c.value.String()
}

func (c *coinValue) Set(stringValue string) error {
if strings.Contains(stringValue, ",") {
return fmt.Errorf("coin flag must be a single coin, specific multiple coins with multiple flags or spaces")
return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces")
}

coin, err := coins.ParseCoin(stringValue)
Expand Down
Loading
Loading