diff --git a/cmd/paratime/list.go b/cmd/paratime/list.go index e3b7ce88..956d49bd 100644 --- a/cmd/paratime/list.go +++ b/cmd/paratime/list.go @@ -1,13 +1,16 @@ package paratime import ( + "fmt" "sort" + "strings" "github.com/spf13/cobra" "github.com/oasisprotocol/cli/cmd/common" cliConfig "github.com/oasisprotocol/cli/config" "github.com/oasisprotocol/cli/table" + "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config" ) var listCmd = &cobra.Command{ @@ -18,7 +21,7 @@ var listCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { cfg := cliConfig.Global() table := table.New() - table.SetHeader([]string{"Network", "Paratime", "ID"}) + table.SetHeader([]string{"Network", "Paratime", "ID", "Denomination(s)"}) var output [][]string for netName, net := range cfg.Networks.All { @@ -32,6 +35,7 @@ var listCmd = &cobra.Command{ netName, displayPtName, pt.ID, + formatDenominations(pt.Denominations), }) } } @@ -48,3 +52,22 @@ var listCmd = &cobra.Command{ table.Render() }, } + +func formatDenominations(denominations map[string]*config.DenominationInfo) string { + fmtDenomArray := []string{} + fmtDenom := "" + for nativeKey, denom := range denominations { + // NativeDenominationKey = "_" + if nativeKey == "_" { + fmtDenom = fmt.Sprintf("%s[%d] (*)", denom.Symbol, denom.Decimals) + } else { + fmtDenom = fmt.Sprintf("%s[%d]", denom.Symbol, denom.Decimals) + } + + fmtDenomArray = append(fmtDenomArray, fmtDenom) + } + sort.Slice(fmtDenomArray, func(i, j int) bool { + return fmtDenomArray[i] < fmtDenomArray[j] + }) + return (strings.Join(fmtDenomArray, "\n")) +} diff --git a/examples/paratime-remove/00-list.out b/examples/paratime-remove/00-list.out index 8df8b397..49c3f664 100644 --- a/examples/paratime-remove/00-list.out +++ b/examples/paratime-remove/00-list.out @@ -1,9 +1,10 @@ -NETWORK PARATIME ID -mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb -mainnet emerald (*) 000000000000000000000000000000000000000000000000e2eaa99fc008f87f -mainnet sapphire 000000000000000000000000000000000000000000000000f80306c9858e7279 -testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 -testnet emerald (*) 00000000000000000000000000000000000000000000000072c8215e60d5bca7 -testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 -testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c -testnet sapphire2 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6d +NETWORK PARATIME ID DENOMINATION(S) +mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb ROSE[9] (*) +mainnet emerald (*) 000000000000000000000000000000000000000000000000e2eaa99fc008f87f ROSE[18] (*) +mainnet sapphire 000000000000000000000000000000000000000000000000f80306c9858e7279 ROSE[18] (*) +testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 TEST[9] (*) +testnet emerald (*) 00000000000000000000000000000000000000000000000072c8215e60d5bca7 TEST[18] (*) +testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 EUROe[18] (*) + TEST[18] +testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c TEST[18] (*) +testnet sapphire2 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6d TEST[18] (*) diff --git a/examples/paratime-remove/02-list.out b/examples/paratime-remove/02-list.out index 73881179..aa58a438 100644 --- a/examples/paratime-remove/02-list.out +++ b/examples/paratime-remove/02-list.out @@ -1,8 +1,8 @@ -NETWORK PARATIME ID -mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb -mainnet emerald (*) 000000000000000000000000000000000000000000000000e2eaa99fc008f87f -mainnet sapphire 000000000000000000000000000000000000000000000000f80306c9858e7279 -testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 -testnet emerald (*) 00000000000000000000000000000000000000000000000072c8215e60d5bca7 -testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 -testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c +NETWORK PARATIME ID DENOMINATION(S) +mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb ROSE[9] (*) +mainnet emerald (*) 000000000000000000000000000000000000000000000000e2eaa99fc008f87f ROSE[18] (*) +mainnet sapphire 000000000000000000000000000000000000000000000000f80306c9858e7279 ROSE[18] (*) +testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 TEST[9] (*) +testnet emerald (*) 00000000000000000000000000000000000000000000000072c8215e60d5bca7 TEST[18] (*) +testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 EUROe[18] (*), TEST[18] +testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c TEST[18] (*) diff --git a/examples/paratime/00-list.out b/examples/paratime/00-list.out index 5342c394..38e45f9e 100644 --- a/examples/paratime/00-list.out +++ b/examples/paratime/00-list.out @@ -1,8 +1,9 @@ -NETWORK PARATIME ID -mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb -mainnet emerald 000000000000000000000000000000000000000000000000e2eaa99fc008f87f -mainnet sapphire (*) 000000000000000000000000000000000000000000000000f80306c9858e7279 -testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 -testnet emerald 00000000000000000000000000000000000000000000000072c8215e60d5bca7 -testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 -testnet sapphire (*) 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c +NETWORK PARATIME ID DENOMINATION(S) +mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb ROSE[9] (*) +mainnet emerald 000000000000000000000000000000000000000000000000e2eaa99fc008f87f ROSE[18] (*) +mainnet sapphire (*) 000000000000000000000000000000000000000000000000f80306c9858e7279 ROSE[18] (*) +testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 TEST[9] (*) +testnet emerald 00000000000000000000000000000000000000000000000072c8215e60d5bca7 TEST[18] (*) +testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 EUROe[18] (*) + TEST[18] +testnet sapphire (*) 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c TEST[18] (*) diff --git a/examples/paratime/02-list.out b/examples/paratime/02-list.out index e9aee536..c7ab7544 100644 --- a/examples/paratime/02-list.out +++ b/examples/paratime/02-list.out @@ -1,8 +1,8 @@ -NETWORK PARATIME ID -mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb -mainnet emerald 000000000000000000000000000000000000000000000000e2eaa99fc008f87f -mainnet sapphire (*) 000000000000000000000000000000000000000000000000f80306c9858e7279 -testnet cipher (*) 0000000000000000000000000000000000000000000000000000000000000000 -testnet emerald 00000000000000000000000000000000000000000000000072c8215e60d5bca7 -testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 -testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c +NETWORK PARATIME ID DENOMINATION(S) +mainnet cipher 000000000000000000000000000000000000000000000000e199119c992377cb ROSE[9] (*) +mainnet emerald (*) 000000000000000000000000000000000000000000000000e2eaa99fc008f87f ROSE[18] (*) +mainnet sapphire 000000000000000000000000000000000000000000000000f80306c9858e7279 ROSE[18] (*) +testnet cipher 0000000000000000000000000000000000000000000000000000000000000000 TEST[9] (*) +testnet emerald (*) 00000000000000000000000000000000000000000000000072c8215e60d5bca7 TEST[18] (*) +testnet pontusx 0000000000000000000000000000000000000000000000004febe52eb412b421 EUROe[18] (*), TEST[18] +testnet sapphire 000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c TEST[18] (*)