-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
52 lines (44 loc) · 1.18 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
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"github.com/diem/client-sdk-go/diemkeys"
"github.com/diem/client-sdk-go/examples/exampleutils"
"github.com/diem/client-sdk-go/stdlib"
"github.com/diem/client-sdk-go/testnet"
"gopkg.in/yaml.v3"
)
func main() {
parentVASP := testnet.GenAccount()
parentVASPAddress := parentVASP.AccountAddress()
account, err := exampleutils.Client.GetAccount(parentVASPAddress)
if err != nil {
panic(err)
}
print("Parent VASP account", account)
childVASPAccount := diemkeys.MustGenKeys()
childVASPAddress := childVASPAccount.AccountAddress()
childAuthKey := childVASPAccount.AuthKey()
exampleutils.SubmitAndWait(
"create child vasp account transaction",
parentVASP,
stdlib.EncodeCreateChildVaspAccountScript(
testnet.XUS,
childVASPAddress,
childAuthKey.Prefix(),
false,
uint64(1000),
),
)
child, err := exampleutils.Client.GetAccount(childVASPAddress)
if err != nil {
panic(err)
}
print("Child VASP account", child)
}
func print(title string, obj interface{}) {
fmt.Printf("====== %v ======\n", title)
yaml, _ := yaml.Marshal(obj)
fmt.Println(string(yaml))
}