/
updateauth.go
41 lines (37 loc) · 1.19 KB
/
updateauth.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
package system
import "github.com/eoscanada/eos-go"
// NewUpdateAuth creates an action from the `eosio.system` contract
// called `updateauth`.
//
// usingPermission needs to be `owner` if you want to modify the
// `owner` authorization, otherwise `active` will do for the rest.
func NewUpdateAuth(account eos.AccountName, permission, parent eos.PermissionName, authority eos.Authority, usingPermission eos.PermissionName) *eos.Action {
a := &eos.Action{
Account: AN("eosio"),
Name: ActN("updateauth"),
Authorization: []eos.PermissionLevel{
{
Actor: account,
Permission: usingPermission,
},
},
ActionData: eos.NewActionData(UpdateAuth{
Account: account,
Permission: permission,
Parent: parent,
Auth: authority,
}),
}
return a
}
// UpdateAuth represents the hard-coded `updateauth` action.
//
// If you change the `active` permission, `owner` is the required parent.
//
// If you change the `owner` permission, there should be no parent.
type UpdateAuth struct {
Account eos.AccountName `json:"account"`
Permission eos.PermissionName `json:"permission"`
Parent eos.PermissionName `json:"parent"`
Auth eos.Authority `json:"auth"`
}