-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_test_deploy_token.go
63 lines (53 loc) · 1.62 KB
/
cmd_test_deploy_token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"fmt"
"io"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/zeebo/clingy"
"storj.io/briskitall/internal/token"
)
type cmdTestDeployToken struct {
client depClient
sender depSender
output depOutput
owner common.Address
name string
symbol string
totalSupply *big.Int
decimals int64
}
func (cmd *cmdTestDeployToken) Setup(params clingy.Parameters) {
cmd.client.setup(params)
cmd.sender.setup(params)
cmd.output.setup(params)
cmd.name = stringFlag(params, "name", "Name of the token", "Test Token")
cmd.symbol = stringFlag(params, "symbol", "Symbol of the token", "TEST")
cmd.totalSupply = bigIntFlag(params, "supply", "Total supply of the token", big.NewInt(10000000000))
cmd.decimals = int64Flag(params, "decimals", "Number of decimals in the token", 8)
cmd.owner = addressArg(params, "OWNER", "Address of the contract owner")
}
func (cmd *cmdTestDeployToken) Execute(ctx context.Context) error {
client, err := cmd.client.open(ctx)
if err != nil {
return err
}
opts, done, err := cmd.sender.transactOpts(ctx, cmd.client.nicknames, client)
if err != nil {
return err
}
defer done()
contractAddress, err := token.DeployContract(opts, client, cmd.owner, cmd.name, cmd.symbol, cmd.totalSupply, cmd.decimals, waiter(ctx, client))
if err != nil {
return err
}
cmd.output.out(ctx, outTestDeployToken{ContractAddress: contractAddress})
return nil
}
type outTestDeployToken struct {
ContractAddress common.Address
}
func (out outTestDeployToken) TextOut(w io.Writer) {
fmt.Fprintln(w, "Token contract address:", out.ContractAddress)
}