/
contract.go
91 lines (78 loc) · 1.9 KB
/
contract.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @copyright defined in eosgo-client/LICENSE.txt
* @author Romain Pellerin - romain@slyseed.com
*
* Donation appreciated :)
* EOS wallet: 0x8d39307d9a0687c894058115365f6ad0f03b9ff9
* ETH wallet: 0x317b60152f0a90c10cea52d751ccb4dfad2fe9e7
* BTC wallet: 3HdFx8C3WNA6RyyGYKygECGbLD1BxyeqTN
* BCH wallet: 14e9fnmcHSZxxd3fnrkaG6EYph9JuWcF9T
*/
package rpc
import (
"eosgo-client/model"
"eosgo-client/errors"
"eosgo-client/common"
)
/**
The following methods are implementing low level contracts that you can control with EOS CLI (cleos):
- newaccount: cleos create account
- //TODO: setcontract: cleos set contract
*/
func ContractNewAccount(creator string, accountName string, ownerKey string, activeKey string, recoveryKey string) (*model.Transaction, *errors.AppError) {
if activeKey == "" {
activeKey = ownerKey
}
if recoveryKey == "" {
recoveryKey = ownerKey
}
auth := model.Authorization{
common.Config.NODE_PRODUCER_NAME,
"active",
}
ownerAuthority := model.NewAuthority(ownerKey, 1)
activeAuthority := model.NewAuthority(activeKey, 1)
recoveryAuthority := model.NewAuthority(recoveryKey, 1)
action := model.Action{
common.Config.NODE_PRODUCER_NAME,
common.Config.NODE_PRODUCER_NAME,
"newaccount",
[]string{common.Config.NODE_PRODUCER_NAME, creator},
[]model.Authorization{auth},
"",
map[string]interface{}{
"creator": creator,
"name": accountName,
"owner": ownerAuthority,
"active": activeAuthority,
"recovery": recoveryAuthority,
},
}
trx := model.Transaction{
0,
0,
0,
"",
[]string{},
[]string{},
[]model.Action{action},
[]string{},
[]model.Authorization{auth},
"",
0,
0,
0,
"",
"none",
[]map[string]interface{}{},
0,
0,
[]model.Action{},
}
//right call
trxPushed, err := ChainPushTransaction(trx, []string{common.Config.NODE_PUB_KEY}, "")
if err != nil {
return nil, err
}
return trxPushed, nil
}