Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Cmd = &cobra.Command{ Use: "show [address]", Short: "Show balance and other information", Aliases: []string{"s", "balance", "b"}, Args: cobra.MaximumNArgs(1), ValidArgsFunction: common.CompleteAccountAndAddressBookNames, Run: func(_ *cobra.Command, args []string) { cfg := cliConfig.Global() npa := common.GetNPASelection(cfg) var out accountShowOutput out.NetworkName = npa.NetworkName // Determine which address to show. If an explicit argument was given, use that // otherwise use the default account. var targetAddress string switch { case len(args) >= 1: targetAddress = args[0] case npa.Account != nil: targetAddress = npa.Account.Address default: cobra.CheckErr("no address given and no wallet configured") } ctx := context.Background() c, err := connection.Connect(ctx, npa.Network) cobra.CheckErr(err) nativeAddr, ethAddr, err := common.ResolveLocalAccountOrAddress(npa.Network, targetAddress) cobra.CheckErr(err) out.NativeAddress = nativeAddr addrCtx := common.GenAddressFormatContext() out.Name = addrCtx.Names[nativeAddr.String()] if ethAddr == nil { if ethHex := addrCtx.Eth[nativeAddr.String()]; ethHex != "" && ethCommon.IsHexAddress(ethHex) { eth := ethCommon.HexToAddress(ethHex) ethAddr = ð } } out.EthereumAddress = ethAddr height, err := common.GetActualHeight( ctx, c.Consensus().Core(), ) cobra.CheckErr(err) out.Height = height ownerQuery := &staking.OwnerQuery{ Owner: nativeAddr.ConsensusAddress(), Height: height, } consensusAccount, err := c.Consensus().Staking().Account(ctx, ownerQuery) cobra.CheckErr(err) out.EscrowAccount = &consensusAccount.Escrow out.GeneralAccount = &consensusAccount.General out.Nonce = consensusAccount.General.Nonce if showDelegations { out.OutgoingDelegations, err = c.Consensus().Staking().DelegationInfosFor(ctx, ownerQuery) cobra.CheckErr(err) out.OutgoingDebondingDelegations, err = c.Consensus().Staking().DebondingDelegationInfosFor(ctx, ownerQuery) cobra.CheckErr(err) out.IncomingDelegations, err = c.Consensus().Staking().DelegationsTo(ctx, ownerQuery) cobra.CheckErr(err) out.IncomingDebondingDelegations, err = c.Consensus().Staking().DebondingDelegationsTo(ctx, ownerQuery) cobra.CheckErr(err) } if npa.ParaTime != nil { out.ParaTimeName = npa.ParaTimeName round := client.RoundLatest if h := common.GetHeight(); h != consensus.HeightLatest { blk, err := c.Consensus().RootHash().GetLatestBlock( ctx, &roothash.RuntimeRequest{ RuntimeID: npa.ParaTime.Namespace(), Height: height, }, ) cobra.CheckErr(err) round = blk.Header.Round } rtBalances, err := c.Runtime(npa.ParaTime).Accounts.Balances(ctx, round, *nativeAddr) cobra.CheckErr(err) out.ParaTimeBalances = rtBalances.Balances out.ParaTimeNonce, err = c.Runtime(npa.ParaTime).Accounts.Nonce(ctx, round, *nativeAddr) cobra.CheckErr(err) if showDelegations { out.ParaTimeDelegations, err = c.Runtime(npa.ParaTime).ConsensusAccounts.Delegations( ctx, round, &consensusaccounts.DelegationsQuery{ From: *nativeAddr, }, ) cobra.CheckErr(err) out.ParaTimeUndelegations, err = c.Runtime(npa.ParaTime).ConsensusAccounts.Undelegations( ctx, round, &consensusaccounts.UndelegationsQuery{ To: *nativeAddr, }, ) cobra.CheckErr(err) } } if common.OutputFormat() == common.FormatJSON { data, err := json.MarshalIndent(out, "", " ") cobra.CheckErr(err) fmt.Printf("%s\n", data) } else { prettyPrintAccount(ctx, c, npa.Network, npa.ParaTime, &out) } }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.