complianceStorage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = &cobra.Command{
		Use:   "complianceStorage",
		Short: "ComplianceStorage utilities",
	}

	DeployCommand = &cobra.Command{
		Use:     "deploy",
		Short:   "Deploys a new compliance-storage contract",
		Example: "t0ken complianceStorage deploy --keystoreAddress owner",
		Args:    cobra.NoArgs,
		PreRun:  commands.ConnectWithKeyStore,

		Run: func(cmd *cobra.Command, args []string) {
			addr, tx, _, err := compliance.DeployStorage(cli.Conn.Opts, cli.Conn.Client)
			cli.CheckErr(cmd, err)
			cmd.Println("   Contract:", addr.String())
			cli.PrintTransactionFn(cmd)(tx, nil)
		},
	}
)
View Source
var GetterCommands = []*cobra.Command{
	&cobra.Command{
		Use:     "abi",
		Short:   "Outputs the ComplianceStorage ABI",
		Example: "t0ken complianceStorage abi",
		Args:    cobra.NoArgs,
		Run:     func(cmd *cobra.Command, args []string) { cmd.Println(compliance.StorageABI) },
	},
	&cobra.Command{
		Use:     "bin",
		Short:   "Outputs the ComplianceStorage Binary",
		Example: "t0ken complianceStorage bin",
		Args:    cobra.NoArgs,
		Run:     func(cmd *cobra.Command, args []string) { cmd.Println(compliance.StorageBin) },
	},
	&cobra.Command{
		Use:   "key <params>...",
		Short: "Generates the key for the given <params>",
		Example: `t0ken complianceStorage key "Compliance.rules" 8166409948e8827a8fdcb0e7365013e968a6dfa1 04 
t0ken complianceStorage key "Compliance.rules" 8166409948e8827a8fdcb0e7365013e968a6dfa1 04 | xargs t0ken complianceStorage getBytes`,
		Args: cobra.MinimumNArgs(1),
		Run: func(cmd *cobra.Command, args []string) {
			var data [][]byte
			for _, s := range args {
				b, err := hex.DecodeString(s)
				if err != nil {
					b = []byte(s)
				}
				data = append(data, b)
			}
			cmd.Printf("0x%x\n", crypto.Keccak256(data...))
		},
	},
	&cobra.Command{
		Use:     "permissions",
		Short:   "Gets the total number of permissions",
		Example: "t0ken complianceStorage permissions",
		Args:    cobra.NoArgs,
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			cli.CheckGetter(cmd)(callSession.Permissions())
		},
	},
	&cobra.Command{
		Use:     "permissionAt <index>",
		Short:   "Gets the address with permission at the given <index>",
		Example: "t0ken complianceStorage permissionAt 0",
		Args:    cli.ChainArgs(cli.BigIntArgFunc("index", 0)),
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			index, _ := new(big.Int).SetString(args[0], 10)
			cli.CheckAddressGetter(cmd)(callSession.PermissionAt(index))
		},
	},
	&cobra.Command{
		Use:     "permissionIndexOf <address>",
		Short:   "Gets the permission index of the given <address>",
		Example: "t0ken complianceStorage permissionIndexOf 0x82ABc653f36Ce78E6290AF8D7e83823c8613bc47",
		Args:    cli.ChainArgs(cli.AddressArgFunc("address", 0)),
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			addr := common.HexToAddress(args[0])
			cli.CheckGetter(cmd)(callSession.PermissionIndexOf(addr))
		},
	},
	&cobra.Command{
		Use:    "getAddress <key>",
		Short:  "Gets the address for the given key",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckAddressGetter(cmd)(callSession.GetAddress(key))
		},
	},
	&cobra.Command{
		Use:    "getBool <key>",
		Short:  "Gets the bool for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckGetter(cmd)(callSession.GetBool(key))
		},
	},
	&cobra.Command{
		Use:    "getBytes <key>",
		Short:  "Gets the bytes for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckBytesGetter(cmd)(callSession.GetBytes(key))
		},
	},
	&cobra.Command{
		Use:    "getBytes32 <key>",
		Short:  "Gets the bytes32 for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckGetter(cmd)(callSession.GetBytes32(key))
		},
	},
	&cobra.Command{
		Use:    "getString <key>",
		Short:  "Gets the string for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckGetter(cmd)(callSession.GetString(key))
		},
	},
	&cobra.Command{
		Use:    "getInt256 <key>",
		Short:  "Gets the int256 for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckGetter(cmd)(callSession.GetInt256(key))
		},
	},
	&cobra.Command{
		Use:    "getUint256 <key>",
		Short:  "Gets the uint256 for the given key",
		Args:   cli.HexArgLenFunc("hash", 0, 16),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.CheckGetter(cmd)(callSession.GetUint256(key))
		},
	},
}
View Source
var SetterCommands = []*cobra.Command{
	&cobra.Command{
		Use:    "setPermission <address> <grant>",
		Short:  "Grants/Revokes permission for the <addr>",
		Args:   cli.ChainArgs(cli.AddressArgFunc("address", 0), cli.BoolArgFunc("grant", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			addr := common.HexToAddress(args[0])
			grant, _ := strconv.ParseBool(args[1])
			cli.PrintTransactionFn(cmd)(transSession.SetPermission(addr, grant))
		},
	},

	&cobra.Command{
		Use:    "setAddress <key> <value>",
		Short:  "Sets the address at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.AddressArgFunc("value", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value := common.HexToAddress(args[1])
			cli.PrintTransactionFn(cmd)(transSession.SetAddress(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteAddress <key>",
		Short:  "Deletes the address for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteAddress(key))
		},
	},

	&cobra.Command{
		Use:    "setBool <key> <value>",
		Short:  "Sets the bool at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.BoolArgFunc("value", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value, _ := strconv.ParseBool(args[1])
			cli.PrintTransactionFn(cmd)(transSession.SetBool(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteBool <key>",
		Short:  "Deletes the bool for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteBool(key))
		},
	},

	&cobra.Command{
		Use:    "setBytes32 <key> <value>",
		Short:  "Sets the bytes32 at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.HexArgLenFunc("value", 1, 16)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value, _ := cli.Bytes32FromArg(args[1])
			cli.PrintTransactionFn(cmd)(transSession.SetBytes32(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteBytes32 <key>",
		Short:  "Deletes the bytes32 for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteBytes32(key))
		},
	},

	&cobra.Command{
		Use:    "setBytes <key> <value>",
		Short:  "Sets the bytes at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.HexArgFunc("value", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value, _ := hex.DecodeString(args[0])
			cli.PrintTransactionFn(cmd)(transSession.SetBytes(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteBytes <key>",
		Short:  "Deletes the bytes for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteBytes(key))
		},
	},

	&cobra.Command{
		Use:    "setint256 <key> <value>",
		Short:  "Sets the int256 at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.BigIntArgFunc("value", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value, _ := new(big.Int).SetString(args[1], 10)
			cli.PrintTransactionFn(cmd)(transSession.SetInt256(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteint256 <key>",
		Short:  "Deletes the int256 for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteInt256(key))
		},
	},

	&cobra.Command{
		Use:    "setString <key> <value>",
		Short:  "Sets the string at <key> to the <value>",
		Args:   cli.ChainArgs(cobra.ExactArgs(2), cli.HexArgLenFunc("key", 0, 16)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value := args[1]
			cli.PrintTransactionFn(cmd)(transSession.SetString(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteString <key>",
		Short:  "Deletes the string for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteString(key))
		},
	},

	&cobra.Command{
		Use:    "setUint256 <key> <value>",
		Short:  "Sets the uint256 at <key> to the <value>",
		Args:   cli.ChainArgs(cli.HexArgLenFunc("key", 0, 16), cli.BigIntArgFunc("value", 1)),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			value, _ := new(big.Int).SetString(args[1], 10)
			cli.PrintTransactionFn(cmd)(transSession.SetUint256(key, value))
		},
	},
	&cobra.Command{
		Use:    "deleteUint256 <key>",
		Short:  "Deletes the uint256 for the <key>",
		Args:   cli.HexArgLenFunc("key", 0, 16),
		PreRun: connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			key, _ := cli.Bytes32FromArg(args[0])
			cli.PrintTransactionFn(cmd)(transSession.DeleteUint256(key))
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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