compliance

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	DeployCommand = &cobra.Command{
		Use:     "deploy <registry> <storage>",
		Short:   "Deploys a new t0ken-compliance contract",
		Example: "t0ken compliance deploy 0x5bd5b4e1a2c9b12812795e7217201b78c8c10b78 0x0f18bbc1ae1c5ab891a7feb06d65388ba6b4cd07 --keystoreAddress owner",
		Args:    cli.ChainArgs(cli.AddressArgFunc("registry", 0), cli.AddressArgFunc("complianceStorage", 1)),
		PreRun:  commands.ConnectWithKeyStore,

		Run: func(cmd *cobra.Command, args []string) {

			r := common.HexToAddress(args[0])
			s := common.HexToAddress(args[1])
			addr, tx, _, err := c.DeployCompliance(cli.Conn.Opts, cli.Conn.Client, r, s)
			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 Compliance ABI",
		Example: "t0ken investor abi",
		Args:    cobra.NoArgs,
		Run:     func(cmd *cobra.Command, args []string) { cmd.Println(compliance.ComplianceABI) },
	},
	&cobra.Command{
		Use:     "bin",
		Short:   "Outputs the Compliance Binary",
		Example: "t0ken investor bin",
		Args:    cobra.NoArgs,
		Run:     func(cmd *cobra.Command, args []string) { cmd.Println(compliance.ComplianceBin) },
	},
	&cobra.Command{
		Use:     "registry",
		Short:   "Gets the Registry contract address",
		Example: "t0ken compliance registry",
		Args:    cobra.NoArgs,
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			cli.CheckAddressGetter(cmd)(callSession.Registry())
		},
	},
	&cobra.Command{
		Use:     "store",
		Short:   "Gets the ComplianceStorage contract address",
		Example: "t0ken compliance store",
		Args:    cobra.NoArgs,
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			cli.CheckAddressGetter(cmd)(callSession.Store())
		},
	},
	&cobra.Command{
		Use:     "getRules <token> <kind>",
		Short:   "Gets the addresses that exist for the given kind",
		Example: "t0ken compliance getRules 0x47acdf4eac45ba7d819be0c6c96c3ebda5283405 4",
		Args:    cli.ChainArgs(cli.AddressArgFunc("token", 0), cli.UintArgFunc("kind", 1, 8)),
		PreRun:  connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			token := common.HexToAddress(args[0])
			k, _ := strconv.ParseInt(args[1], 10, 8)
			kind := uint8(k)
			cli.CheckAddressesGetter(cmd)(callSession.GetRules(token, kind))
		},
	},
	&cobra.Command{
		Use:   "canTransfer <token> <initiator> <from> <to> <quantity>",
		Short: "Checks if the <initiator> can transfer <from> <to> in the amount of <tokens>",
		Example: `t0ken compliance canTransferTest \
	0x0000d6abc75370f48b42024371b07b4506885a55 \
	0xf01ff29dcbee147e9ca151a281bfdf136f66a45b \
	0xf02f537578d03f6aece28f249eac19542d848f20 \
	5`,
		Args:   cli.ChainArgs(cli.AddressArgFunc("token", 0), cli.AddressArgFunc("from", 1), cli.AddressArgFunc("to", 2), cli.BigIntArgFunc("quantity", 3)),
		PreRun: connectCaller,
		Run: func(cmd *cobra.Command, args []string) {
			token := common.HexToAddress(args[0])
			from := common.HexToAddress(args[1])
			to := common.HexToAddress(args[2])
			qty, _ := new(big.Int).SetString(args[3], 10)

			initiator, err := cli.OptionalFlagAddress(cmd, "initiator")
			cli.CheckErr(cmd, err)
			if bytes.Equal(initiator.Bytes(), make([]byte, 20)) {
				initiator = from
			}

			s, err := callSession.CanTransferTest(token, initiator, from, to, qty)
			cli.CheckErr(cmd, err)
			cmd.Println(s)
		},
	},
}
View Source
var SetterCommands = []*cobra.Command{
	&cobra.Command{
		Use:     "setRegistryAndStore <registry> <storage>",
		Short:   "Sets the registry and compaliance-storage addresses",
		Example: "t0ken compliance setRegistryAndStore 0x397e7b9c15ff22ba67ec6e78f46f1e21540bcb36 0x0f18bbc1ae1c5ab891a7feb06d65388ba6b4cd07 --keystoreAddress owner",
		Args:    cli.ChainArgs(cli.AddressArgFunc("registry", 0), cli.AddressArgFunc("storage", 0)),
		PreRun:  connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			r := common.HexToAddress(args[0])
			s := common.HexToAddress(args[1])
			cli.PrintTransactionFn(cmd)(transSession.SetRegistryAndComplianceStore(r, s))
		},
	},
	&cobra.Command{
		Use:     "setRules <token> <kind> [address args]",
		Short:   "Sets the <token> <kind> rules to [address args]",
		Example: "t0ken compliance setRules 0x5bd5b4e1a2c9b12812795e7217201b78c8c10b78 4 0x397e7b9c15ff22ba67ec6e78f46f1e21540bcb36 --keystoreAddress admin",
		Args:    cli.ChainArgs(cli.AddressArgFunc("token", 0), cli.UintArgFunc("kind", 1, 8)),
		PreRun:  connectTransactor,
		Run: func(cmd *cobra.Command, args []string) {
			// Read in all rule address args
			var rules []common.Address
			var err error
			for i := 2; i < len(args); i++ {
				if !common.IsHexAddress(args[i]) {
					err = errors.New("Address args must be valid addresses")
				}
				rules = append(rules, common.HexToAddress(args[i]))
			}

			cli.CheckErr(cmd, err)

			token := common.HexToAddress(args[0])
			kind, _ := strconv.ParseInt(args[1], 10, 8)
			cli.PrintTransactionFn(cmd)(transSession.SetRules(token, uint8(kind), rules))
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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