Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Command = &cobra.Command{ Use: "registry", Short: "Registry utilities", } DeployCommand = &cobra.Command{ Use: "deploy", Short: "Deploys a new registry contract", Example: "t0ken registry deploy --keystoreAddress owner", Args: cobra.NoArgs, PreRun: commands.ConnectWithKeyStore, Run: func(cmd *cobra.Command, args []string) { addr, tx, _, err := registry.DeployRegistry(cli.Conn.Opts, cli.Conn.Client) cli.CheckErr(cmd, err) cmd.Println(" Contract:", addr.String()) cli.PrintTransactionFn(cmd)(tx, nil) }, } AuditCommand = &cobra.Command{ Use: "audit [kind]", Short: "Audit the accounts of <kind>, outputting CSV to <stdout>", Example: `t0ken registry audit t0ken token audit 4, t0ken token audit 4 --block 8658083`, Args: cobra.MaximumNArgs(1), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { var kind *uint8 if len(args) > 0 { if cli.IsIntArg("kind", args, 0) == nil { k, err := strconv.Atoi(args[0]) if err != nil || k == 0 { cli.CheckErr(cmd, errors.New("invalid value for [kind] arg")) } kind = new(uint8) *kind = uint8(k) } } if callSession.CallOpts.BlockNumber == nil { header, err := cli.Conn.HeaderByNumber(context.Background(), nil) cli.CheckErr(cmd, err) callSession.CallOpts.BlockNumber = header.Number } n, err := callSession.Accounts() cli.CheckErr(cmd, err) one := big.NewInt(1) index := big.NewInt(0) cmd.Printf("Block: %s\n", callSession.CallOpts.BlockNumber.String()) fmt.Println("index,address,kind,frozen,parent") for i := int64(0); i < n.Int64(); i++ { addr, k, frozen, parent, hash, err := callSession.AccountAt(index) cli.CheckErr(cmd, err) if kind == nil || k == *kind { fmt.Printf("%d,%s,%d,%t,%s,%x\n", i, addr.String(), k, frozen, parent.String(), hash) } index.Add(index, one) } }, } )
View Source
var GetterCommands = []*cobra.Command{ &cobra.Command{ Use: "abi", Short: "Outputs the Registry ABI", Example: "t0ken investor abi", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { cmd.Println(registry.RegistryABI) }, }, &cobra.Command{ Use: "bin", Short: "Outputs the Registry Binary", Example: "t0ken investor bin", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { cmd.Println(registry.RegistryBin) }, }, &cobra.Command{ Use: "accountAt <index>", Short: "Gets account at the given <index>", Example: "t0ken registry accountAt 5", Args: cli.BigIntArgFunc("index", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { index, _ := new(big.Int).SetString(args[0], 10) cli.CheckGetter(cmd)(accountStr(callSession.AccountAt(index))) }, }, &cobra.Command{ Use: "accountExists <address>", Short: "Checks if the <address> exists", Example: "t0ken registry accountExists 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.AccountExists(addr)) }, }, &cobra.Command{ Use: "accountKindExists <address>", Short: "Checks if the <address> exists for the given kind", Example: "t0ken registry accountKindExists 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 4", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.UintArgFunc("kind", 1, 8)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) kind, _ := strconv.ParseInt(args[1], 10, 8) cli.CheckGetter(cmd)(callSession.AccountKindExists(addr, uint8(kind))) }, }, &cobra.Command{ Use: "accountFrozen <address>", Short: "Checks if the <address> is frozen", Example: "t0ken registry accountFrozen 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.AccountFrozen(addr)) }, }, &cobra.Command{ Use: "accountGet <address>", Short: "Gets the account for the given <address>", Example: "t0ken registry accountGet 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(accountGetStr(callSession.AccountGet(addr))) }, }, &cobra.Command{ Use: "accountIndexOf <address>", Short: "Gets the index of the <address>", Example: "t0ken registry indexOf 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.AccountIndexOf(addr)) }, }, &cobra.Command{ Use: "accountKind <address>", Short: "Gets the kind for the <address>", Example: "t0ken registry accountKind 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.AccountKind(addr)) }, }, &cobra.Command{ Use: "accountParent <address>", Short: "Gets the parent of the <address>", Example: "t0ken registry accountParent 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.AddressArgFunc("address", 0), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.CheckGetter(cmd)(callSession.AccountParent(addr)) }, }, &cobra.Command{ Use: "accounts", Short: "Gets the total number of accounts", Example: "t0ken registry accounts", Args: cobra.NoArgs, PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { cli.CheckGetter(cmd)(callSession.Accounts()) }, }, &cobra.Command{ Use: "data <address> <index>", Short: "Gets the data for the <address> at the given <index>", Example: "t0ken registry data 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 1", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.UintArgFunc("index", 1, 8)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) index, _ := strconv.ParseInt(args[1], 10, 8) cli.CheckGetter(cmd)(dataStr(callSession.Data(addr, uint8(index)))) }, }, &cobra.Command{ Use: "permissionAt <kind> <index>", Short: "Gets the address for the <kind> permission at <index>", Example: "t0ken permissionAt 4, 1", Args: cli.ChainArgs(cli.UintArgFunc("kind", 0, 8), cli.BigIntArgFunc("index", 1)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { kind, _ := strconv.ParseInt(args[0], 10, 8) index, _ := new(big.Int).SetString(args[1], 10) cli.CheckAddressGetter(cmd)(callSession.PermissionAt(uint8(kind), index)) }, }, &cobra.Command{ Use: "permissionExists <kind> <address>", Short: "Checks if <kind> permission exists for the <address>", Example: "t0ken registry permissionExists 4 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.ChainArgs(cli.UintArgFunc("kind", 0, 8), cli.AddressArgFunc("address", 1)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { kind, _ := strconv.ParseInt(args[0], 10, 8) addr := common.HexToAddress(args[1]) cli.CheckGetter(cmd)(callSession.PermissionExists(uint8(kind), addr)) }, }, &cobra.Command{ Use: "permissionIndexOf <kind> <address>", Short: "Checks if <kind> permission exists for the <address>", Example: "t0ken registry permissionIndexOf 4 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b", Args: cli.ChainArgs(cli.UintArgFunc("kind", 0, 8), cli.AddressArgFunc("address", 1)), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { kind, _ := strconv.ParseInt(args[0], 10, 8) addr := common.HexToAddress(args[1]) cli.CheckGetter(cmd)(callSession.PermissionIndexOf(uint8(kind), addr)) }, }, &cobra.Command{ Use: "permissions <kind>", Short: "Gets the total number of permissions for the <kind>", Example: "t0ken registry permissions 4", Args: cli.UintArgFunc("kind", 0, 8), PreRun: connectCaller, Run: func(cmd *cobra.Command, args []string) { kind, _ := strconv.ParseInt(args[0], 10, 8) cli.CheckGetter(cmd)(callSession.Permissions(uint8(kind))) }, }, }
View Source
var SetterCommands = []*cobra.Command{ &cobra.Command{ Use: "setPermission <kind> <address> <grant>", Short: "Grants/Revokes <kind> permissions for <address>", Example: "t0ken registry grantPermission 4 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b true --keystoreAddress owner", Args: cli.ChainArgs(cli.UintArgFunc("kind", 0, 8), cli.AddressArgFunc("address", 1), cli.BoolArgFunc("grant", 2)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { kind, _ := strconv.ParseInt(args[0], 10, 8) addr := common.HexToAddress(args[1]) grant, _ := strconv.ParseBool(args[2]) cli.PrintTransactionFn(cmd)(transSession.SetPermission(uint8(kind), addr, grant)) }, }, &cobra.Command{ Use: "addAccount <address> <kind> <frozen> <parent>", Short: "Adds the <address> under the <kind>, set as <frozen>, for the <parent>", Example: "t0ken registry addAccount 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 4 false 0xb01ba0d19cc9cd613253bad489b69e583dbfd4da --keystoreAddress owner", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.UintArgFunc("kind", 1, 8), cli.BoolArgFunc("frozen", 2), cli.AddressArgFunc("parent", 3), cli.HexArgLenFunc("hash", 4, 16)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) kind, _ := strconv.ParseInt(args[1], 10, 8) frozen, _ := strconv.ParseBool(args[2]) parent := common.HexToAddress(args[3]) hash, _ := cli.Bytes32FromArg(args[4]) cli.PrintTransactionFn(cmd)(transSession.AddAccount(addr, uint8(kind), frozen, parent, hash)) }, }, &cobra.Command{ Use: "removeAccount <address>", Short: "Removes the <address>", Example: "t0ken registry removeAccount 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b --keystoreAddress owner", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) cli.PrintTransactionFn(cmd)(transSession.RemoveAccount(addr)) }, }, &cobra.Command{ Use: "setAccountData <address> <index> <data>", Short: "Sets the hex <data>, excluding '0x' prefix, at the <index> for the <address>", Example: "t0ken registry setAccountData 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xa1896382c22b03c562b0241324cfca19505cc5c78eb06751d9cee690e21ed6a1 --keystoreAddress owner", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.UintArgFunc("index", 1, 8), cli.HexArgLenFunc("data", 2, 32)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) index, _ := strconv.ParseInt(args[0], 10, 8) h, _ := hexutil.Decode(args[2]) // Convert data to fixed size byte array var data [32]byte copy(data[:], h) cli.PrintTransactionFn(cmd)(transSession.SetAccountData(addr, uint8(index), data)) }, }, &cobra.Command{ Use: "setAccountFrozen <address> <frozen>", Short: "Set the <address> state to <frozen>", Example: "t0ken registry setAccountFrozen 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b true --keystoreAddress owner", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.BoolArgFunc("frozen", 1)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) frozen, _ := strconv.ParseBool(args[1]) cli.PrintTransactionFn(cmd)(transSession.SetAccountFrozen(addr, frozen)) }, }, &cobra.Command{ Use: "setAccountParent <address> <parent>", Short: "Sets <parent> of the <address>", Example: "t0ken registry setAccountParent 0xf01ff29dcbee147e9ca151a281bfdf136f66a45b 0xb01ba0d19cc9cd613253bad489b69e583dbfd4da --keystoreAddress owner", Args: cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.AddressArgFunc("parent", 1)), PreRun: connectTransactor, Run: func(cmd *cobra.Command, args []string) { addr := common.HexToAddress(args[0]) parent := common.HexToAddress(args[1]) cli.PrintTransactionFn(cmd)(transSession.SetAccountParent(addr, parent)) }, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.