-
Notifications
You must be signed in to change notification settings - Fork 207
/
main.go
57 lines (49 loc) · 1.06 KB
/
main.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
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"os/exec"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func main() {
date, err := time.Parse(time.RFC3339Nano, "2022-02-17T17:00:00Z")
if err != nil {
panic(err)
}
fmt.Println("genesis time", date)
csv_file, _ := os.Open("double-double-1/accounts/accounts.csv")
r := csv.NewReader(csv_file)
denom := "ustars"
total := sdk.NewCoin(denom, sdk.ZeroInt())
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
amount, ok := sdk.NewIntFromString(record[1])
if !ok {
panic(fmt.Sprintf("invalid amount %s", record[1]))
}
address := record[0]
total = total.Add(sdk.NewCoin(denom, amount))
cmd := exec.Command("starsd",
"add-genesis-account", address, sdk.NewCoin(denom, amount).String(),
"--home", "tmp/stargaze",
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
log.Fatal(err)
}
}
fmt.Println("--Supply--")
fmt.Println("total", total.Amount.Quo(sdk.NewInt(1_000_000)).String())
}