cmds

package
v0.0.0-...-1b3d248 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package cmds provides command line tools.

Index

Constants

This section is empty.

Variables

View Source
var (
	Hinters []hint.Hinter
	Types   []hint.Type
)
View Source
var (
	GenesisAccountKey = "genesis_account"
	GenesisBalanceKey = "genesis_balance"
)
View Source
var (
	ProcessorDigestAPI      pm.Process
	ProcessorStartDigestAPI pm.Process
)
View Source
var (
	ProcessorDigester      pm.Process
	ProcessorStartDigester pm.Process
)
View Source
var BaseNodeCommandHooks = func(cmd *BaseNodeCommand) []pm.Hook {
	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameEncoders,
			process.HookNameAddHinters, process.HookAddHinters(Types, Hinters)).
			SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			"load_digest_config", cmd.hookLoadDigestConfig).
			SetOverride(true).
			SetDir(process.HookNameConfigGenesisOperations, pm.HookDirAfter),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			"validate_digest_config", cmd.hookValidateDigestConfig).
			SetOverride(true).
			SetDir(process.HookNameValidateConfig, pm.HookDirAfter),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			process.HookNameConfigVerbose, hookVerboseConfig).
			SetOverride(true),
	}
}
View Source
var InitCommandHooks = func(cmd *InitCommand) []pm.Hook {
	genesisOperationHandlers := map[string]process.HookHandlerGenesisOperations{
		"genesis-currencies": GenesisOperationsHandlerGenesisCurrencies,
	}

	for k, v := range process.DefaultHookHandlersGenesisOperations {
		genesisOperationHandlers[k] = v
	}

	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPre, process.ProcessNameProposalProcessor,
			"initialize_proposal_processor", cmd.hookInitializeProposalProcessor).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameConfig,
			process.HookNameConfigGenesisOperations, process.HookGenesisOperationFunc(genesisOperationHandlers)).
			SetOverride(true),
	}
}
View Source
var ProcessorDigestDatabase pm.Process
View Source
var RunCommandHooks = func(cmd *RunCommand) []pm.Hook {
	return []pm.Hook{
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameDatabase,
			"set_database", HookLoadCurrencies).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, process.ProcessNameNetwork,
			"set_currency_network_handlers", cmd.hookSetNetworkHandlers).SetOverride(true),
		pm.NewHook(pm.HookPrefixPre, process.ProcessNameProposalProcessor,
			"initialize_proposal_processor", HookInitializeProposalProcessor).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, currencycmds.ProcessNameDigestAPI,
			"set_digest_api_handlers", cmd.hookDigestAPIHandlers).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, currencycmds.ProcessNameDigester,
			"set_state_handler", cmd.hookSetStateHandler).SetOverride(true),
		pm.NewHook(pm.HookPrefixPost, currencycmds.ProcessNameDigester,
			currencycmds.HookNameDigesterFollowUp, HookDigesterFollowUp).SetOverride(true),
		pm.NewHook(pm.HookPrefixPre, currencycmds.ProcessNameDigestAPI,
			currencycmds.HookNameSetLocalChannel, currencycmds.HookSetLocalChannel).SetOverride(true),
	}
}
View Source
var SendVars = kong.Vars{
	"node_url": "quic://localhost:54321",
}

Functions

func AttachProposalProcessor

func AttachProposalProcessor(
	policy *isaac.LocalPolicy,
	nodepool *network.Nodepool,
	suffrage base.Suffrage,
	cp *extensioncurrency.CurrencyPool,
) (*collection.OperationProcessor, error)

func GenesisOperationsHandlerGenesisCurrencies

func GenesisOperationsHandlerGenesisCurrencies(
	ctx context.Context,
	m map[string]interface{},
) (operation.Operation, error)

func HookDigesterFollowUp

func HookDigesterFollowUp(ctx context.Context) (context.Context, error)

func HookInitializeProposalProcessor

func HookInitializeProposalProcessor(ctx context.Context) (context.Context, error)

func HookLoadCurrencies

func HookLoadCurrencies(ctx context.Context) (context.Context, error)

func InitializeProposalProcessor

func InitializeProposalProcessor(ctx context.Context, opr *collection.OperationProcessor) (context.Context, error)

func LoadCurrencyPoolContextValue

func LoadCurrencyPoolContextValue(ctx context.Context, l **extensioncurrency.CurrencyPool) error

func LoadDigestDatabaseContextValue

func LoadDigestDatabaseContextValue(ctx context.Context, l **digest.Database) error

func LoadDigesterContextValue

func LoadDigesterContextValue(ctx context.Context, l **digest.Digester) error

func LoadSeal

func LoadSeal(b []byte, networkID base.NetworkID) (seal.Seal, error)

func LoadSealAndAddOperation

func LoadSealAndAddOperation(
	b []byte,
	privatekey key.Privatekey,
	networkID base.NetworkID,
	op operation.Operation,
) (operation.Seal, error)

func PrettyPrint

func PrettyPrint(out io.Writer, pretty bool, i interface{})

func ProcessDigestAPI

func ProcessDigestAPI(ctx context.Context) (context.Context, error)

func ProcessDigestDatabase

func ProcessDigestDatabase(ctx context.Context) (context.Context, error)

func ProcessDigester

func ProcessDigester(ctx context.Context) (context.Context, error)

func ProcessStartDigestAPI

func ProcessStartDigestAPI(ctx context.Context) (context.Context, error)

func ProcessStartDigester

func ProcessStartDigester(ctx context.Context) (context.Context, error)

Types

type AddressFlag

type AddressFlag struct {
	// contains filtered or unexported fields
}

func (*AddressFlag) Encode

func (v *AddressFlag) Encode(enc encoder.Encoder) (base.Address, error)

func (*AddressFlag) String

func (v *AddressFlag) String() string

func (*AddressFlag) UnmarshalText

func (v *AddressFlag) UnmarshalText(b []byte) error

type ApproveCommand

type ApproveCommand struct {
	*BaseCommand
	OperationFlags
	Sender   AddressFlag                 `arg:"" name:"sender" help:"sender address" required:"true"`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	Approved AddressFlag                 `arg:"" name:"approved" help:"approved account address" required:"true"`
	NFT      NFTIDFlag                   `arg:"" name:"nft" help:"target nft to approve; \"<symbol>,<idx>\""`
	// contains filtered or unexported fields
}

func NewApproveCommand

func NewApproveCommand() ApproveCommand

func (*ApproveCommand) Run

func (cmd *ApproveCommand) Run(version util.Version) error

type BaseCommand

type BaseCommand struct {
	*mitumcmds.BaseCommand
	Out io.Writer `kong:"-"`
}

func NewBaseCommand

func NewBaseCommand(name string) *BaseCommand

type BaseNodeCommand

type BaseNodeCommand struct {
	*logging.Logging
}

func NewBaseNodeCommand

func NewBaseNodeCommand(l *logging.Logging) *BaseNodeCommand

func (*BaseNodeCommand) BaseProcesses

func (cmd *BaseNodeCommand) BaseProcesses(ps *pm.Processes) (*pm.Processes, error)

type BurnCommand

type BurnCommand struct {
	*BaseCommand
	OperationFlags
	Sender   AddressFlag                 `arg:"" name:"sender" help:"sender address; nft owner or agent" required:"true"`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	NFT      NFTIDFlag                   `arg:"" name:"nft" help:"target nft; \"<symbol>,<idx>\""`
	// contains filtered or unexported fields
}

func NewBurnCommand

func NewBurnCommand() BurnCommand

func (*BurnCommand) Run

func (cmd *BurnCommand) Run(version util.Version) error

type CleanByHeightStorageCommand

type CleanByHeightStorageCommand struct {
	*mitumcmds.CleanByHeightStorageCommand
	*BaseNodeCommand
}

type CleanStorageCommand

type CleanStorageCommand struct {
	*mitumcmds.CleanStorageCommand
	*BaseNodeCommand
}

type CollectionPolicyUpdaterCommand

type CollectionPolicyUpdaterCommand struct {
	*BaseCommand
	OperationFlags
	Sender   AddressFlag                 `arg:"" name:"sender" help:"sender address" required:"true"`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	CSymbol  string                      `arg:"" name:"symbol" help:"collection symbol" required:"true"`
	Name     string                      `arg:"" name:"name" help:"collection name" required:"true"`
	Royalty  uint                        `arg:"" name:"royalty" help:"royalty parameter; 0 <= royalty param < 100" required:"true"`
	Uri      string                      `name:"uri" help:"collection uri" optional:""`
	White    AddressFlag                 `name:"white" help:"whitelisted address" optional:""`
	// contains filtered or unexported fields
}

func NewCollectionPolicyUpdaterCommand

func NewCollectionPolicyUpdaterCommand() CollectionPolicyUpdaterCommand

func (*CollectionPolicyUpdaterCommand) Run

type CollectionRegisterCommand

type CollectionRegisterCommand struct {
	*BaseCommand
	OperationFlags
	Sender   AddressFlag                 `arg:"" name:"sender" help:"sender address" required:"true"`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	Target   AddressFlag                 `arg:"" name:"target" help:"target account to register policy" required:"true"`
	CSymbol  string                      `arg:"" name:"symbol" help:"collection symbol" required:"true"`
	Name     string                      `arg:"" name:"name" help:"collection name" required:"true"`
	Royalty  uint                        `arg:"" name:"royalty" help:"royalty parameter; 0 <= royalty param < 100" required:"true"`
	Uri      string                      `name:"uri" help:"collection uri" optional:""`
	White    AddressFlag                 `name:"white" help:"whitelisted address" optional:""`
	// contains filtered or unexported fields
}

func NewCollectionRegisterCommand

func NewCollectionRegisterCommand() CollectionRegisterCommand

func (*CollectionRegisterCommand) Run

func (cmd *CollectionRegisterCommand) Run(version util.Version) error

type DelegateCommand

type DelegateCommand struct {
	*BaseCommand
	OperationFlags
	Sender     AddressFlag                 `arg:"" name:"sender" help:"sender address" required:"true"`
	Currency   currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	Collection string                      `arg:"" name:"collection" help:"collection symbol" required:"true"`
	Agent      AddressFlag                 `arg:"" name:"agent" help:"agent account address"`
	Mode       string                      `name:"mode" help:"delegate mode" optional:""`
	// contains filtered or unexported fields
}

func NewDelegateCommand

func NewDelegateCommand() DelegateCommand

func (*DelegateCommand) Run

func (cmd *DelegateCommand) Run(version util.Version) error

type InitCommand

type InitCommand struct {
	*BaseNodeCommand
	*mitumcmds.InitCommand
}

func NewInitCommand

func NewInitCommand(dryrun bool) (InitCommand, error)

type MintCommand

type MintCommand struct {
	*BaseCommand
	OperationFlags
	Sender           AddressFlag                 `arg:"" name:"sender" help:"sender address" required:"true"`
	Currency         currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	CSymbol          string                      `arg:"" name:"collection" help:"collection symbol" required:"true"`
	Hash             string                      `arg:"" name:"hash" help:"nft hash" required:"true"`
	Uri              string                      `arg:"" name:"uri" help:"nft uri" required:"true"`
	Creator          SignerFlag                  `name:"creator" help:"nft contents creator \"<address>,<share>\"" optional:""`
	Copyrighter      SignerFlag                  `name:"copyrighter" help:"nft contents copyrighter \"<address>,<share>\"" optional:""`
	CreatorTotal     uint                        `name:"creator-total" help:"creators total share" optional:""`
	CopyrighterTotal uint                        `name:"copyrighter-total" help:"copyrighters total share" optional:""`
	// contains filtered or unexported fields
}

func NewMintCommand

func NewMintCommand() MintCommand

func (*MintCommand) Run

func (cmd *MintCommand) Run(version util.Version) error

type NFTIDFlag

type NFTIDFlag struct {
	// contains filtered or unexported fields
}

func (*NFTIDFlag) String

func (v *NFTIDFlag) String() string

func (*NFTIDFlag) UnmarshalText

func (v *NFTIDFlag) UnmarshalText(b []byte) error

type NodeCommand

type NodeCommand struct {
	Init          InitCommand                    `cmd:"" help:"initialize node"`
	Run           RunCommand                     `cmd:"" help:"run node"`
	Info          currencycmds.NodeInfoCommand   `cmd:"" help:"node information"`
	StartHandover mitumcmds.StartHandoverCommand `cmd:"" name:"start-handover" help:"start handover"`
}

func NewNodeCommand

func NewNodeCommand() (NodeCommand, error)

type OperationFlags

type OperationFlags struct {
	Privatekey currencycmds.PrivatekeyFlag `arg:"" name:"privatekey" help:"privatekey to sign operation" required:"true"`
	Token      string                      `help:"token for operation" optional:""`
	NetworkID  mitumcmds.NetworkIDFlag     `name:"network-id" help:"network-id" required:"true"`
	Memo       string                      `name:"memo" help:"memo"`
	Pretty     bool                        `name:"pretty" help:"pretty format"`
}

func (*OperationFlags) IsValid

func (op *OperationFlags) IsValid([]byte) error

type RunCommand

type RunCommand struct {
	*mitumcmds.RunCommand
	*BaseNodeCommand
}

func NewRunCommand

func NewRunCommand(dryrun bool) (RunCommand, error)

type SealCommand

type SealCommand struct {
	Send                    SendCommand                                `cmd:"" name:"send" help:"send seal to remote mitum node"`
	CreateAccount           currencycmds.CreateAccountCommand          `cmd:"" name:"create-account" help:"create new account"`
	CreateContractAccount   extensioncmds.CreateContractAccountCommand `cmd:"" name:"create-contract-account" help:"create new contract account"`
	Withdraw                extensioncmds.WithdrawCommand              `cmd:"" name:"withdraw" help:"withdraw contract account"`
	Delegate                DelegateCommand                            `cmd:"" name:"delegate" help:"delegate agent or cancel agent delegation"`
	Approve                 ApproveCommand                             `cmd:"" name:"approve" help:"approve account for nft"`
	CollectionRegister      CollectionRegisterCommand                  `cmd:"" name:"collection-register" help:"register collection to contract account"`
	CollectionPolicyUpdater CollectionPolicyUpdaterCommand             `cmd:"" name:"collection-policy-updater" help:"update collection policy"`
	Mint                    MintCommand                                `cmd:"" name:"mint" help:"mint nft to collection"`
	TransferNFTs            TransferCommand                            `cmd:"" name:"transfer-nfts" help:"transfer nfts"`
	Burn                    BurnCommand                                `cmd:"" name:"burn" help:"burn nfts"`
	SignNFTs                SignCommand                                `cmd:"" name:"sign-nfts" help:"sign nfts; creator | copyrighter"`
	Transfer                currencycmds.TransferCommand               `cmd:"" name:"transfer" help:"transfer big"`
	KeyUpdater              currencycmds.KeyUpdaterCommand             `cmd:"" name:"key-updater" help:"update keys"`
	CurrencyRegister        extensioncmds.CurrencyRegisterCommand      `cmd:"" name:"currency-register" help:"register new currency"`
	CurrencyPolicyUpdater   extensioncmds.CurrencyPolicyUpdaterCommand `cmd:"" name:"currency-policy-updater" help:"update currency policy"`  // revive:disable-line:line-length-limit
	SuffrageInflation       currencycmds.SuffrageInflationCommand      `cmd:"" name:"suffrage-inflation" help:"suffrage inflation operation"` // revive:disable-line:line-length-limit
	Sign                    currencycmds.SignSealCommand               `cmd:"" name:"sign" help:"sign seal"`
	SignFact                currencycmds.SignFactCommand               `cmd:"" name:"sign-fact" help:"sign facts of operation seal"`
}

func NewSealCommand

func NewSealCommand() SealCommand

type SendCommand

type SendCommand struct {
	*BaseCommand
	URL        []*url.URL                  `name:"node" help:"remote mitum url (default: ${node_url})" default:"${node_url}"` // nolint
	NetworkID  mitumcmds.NetworkIDFlag     `name:"network-id" help:"network-id" `
	Seal       mitumcmds.FileLoad          `help:"seal" optional:""`
	DryRun     bool                        `help:"dry-run, print operation" optional:"" default:"false"`
	Pretty     bool                        `name:"pretty" help:"pretty format"`
	Privatekey currencycmds.PrivatekeyFlag `arg:"" name:"privatekey" help:"privatekey for sign"`
	Timeout    time.Duration               `name:"timeout" help:"timeout; default: 5s"`
	TLSInscure bool                        `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
	From       string                      `name:"from" help:"from conninfo; default is empty"`
}

func NewSendCommand

func NewSendCommand() SendCommand

func (*SendCommand) Run

func (cmd *SendCommand) Run(version util.Version) error

type SignCommand

type SignCommand struct {
	*BaseCommand
	OperationFlags
	Sender        AddressFlag                 `arg:"" name:"sender" help:"sender address; nft owner or agent" required:"true"`
	Currency      currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	NFT           NFTIDFlag                   `arg:"" name:"nft" help:"target nft; \"<symbol>,<idx>\""`
	Qualification string                      `name:"qualification" help:"target qualification; creator | copyrighter" optional:""`
	// contains filtered or unexported fields
}

func NewSignCommand

func NewSignCommand() SignCommand

func (*SignCommand) Run

func (cmd *SignCommand) Run(version util.Version) error

type SignerFlag

type SignerFlag struct {
	// contains filtered or unexported fields
}

func (*SignerFlag) Encode

func (v *SignerFlag) Encode(enc encoder.Encoder) (base.Address, error)

func (*SignerFlag) String

func (v *SignerFlag) String() string

func (*SignerFlag) UnmarshalText

func (v *SignerFlag) UnmarshalText(b []byte) error

type StorageCommand

type StorageCommand struct {
	Download                    mitumcmds.BlockDownloadCommand    `cmd:"" name:"download" help:"download block data"`
	BlockdataVerify             mitumcmds.BlockdataVerifyCommand  `cmd:"" name:"verify-blockdata" help:"verify block data"` // revive:disable-line:line-length-limit
	DatabaseVerify              mitumcmds.DatabaseVerifyCommand   `cmd:"" name:"verify-database" help:"verify database"`    // revive:disable-line:line-length-limit
	CleanStorage                CleanStorageCommand               `cmd:"" name:"clean" help:"clean storage"`
	CleanByHeightStorageCommand CleanByHeightStorageCommand       `cmd:"" name:"clean-by-height" help:"clean storage by height"` // revive:disable-line:line-length-limit
	Restore                     restoreCommand                    `cmd:"" help:"restore blocks from blockdata"`
	SetBlockdataMaps            mitumcmds.SetBlockdataMapsCommand `cmd:"" name:"set-blockdatamaps" help:"set blockdatamaps"` // revive:disable-line:line-length-limit
}

func NewStorageCommand

func NewStorageCommand() (StorageCommand, error)

type TransferCommand

type TransferCommand struct {
	*BaseCommand
	OperationFlags
	Sender   AddressFlag                 `arg:"" name:"sender" help:"sender address; nft owner or agent" required:"true"`
	Currency currencycmds.CurrencyIDFlag `arg:"" name:"currency" help:"currency id" required:"true"`
	Receiver AddressFlag                 `arg:"" name:"receiver" help:"nft owner" required:"true"`
	NFT      NFTIDFlag                   `arg:"" name:"nft" help:"target nft; \"<symbol>,<idx>\""`
	// contains filtered or unexported fields
}

func NewTransferCommand

func NewTransferCommand() TransferCommand

func (*TransferCommand) Run

func (cmd *TransferCommand) Run(version util.Version) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL