-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathactionsender.go
56 lines (47 loc) · 1.58 KB
/
actionsender.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
package chaintester
import (
"fmt"
"github.com/uuosio/chaintester/interfaces"
)
type ActionSender struct {
tester *ChainTester
actions []*interfaces.Action
}
func NewActionSender(tester *ChainTester) *ActionSender {
return &ActionSender{tester, nil}
}
func (sender *ActionSender) AddAction(account string, action string, args string, permissions string) {
_args := interfaces.NewActionArguments()
_args.JSONArgs_ = &args
_action := interfaces.Action{
Account: account,
Action: action,
Arguments: _args,
Permissions: permissions,
}
sender.actions = append(sender.actions, &_action)
}
func (sender *ActionSender) AddActionEx(account string, action string, rawArgs []byte, permissions string) {
_args := interfaces.NewActionArguments()
_rawArgs := make([]byte, len(rawArgs))
copy(_rawArgs, rawArgs)
_args.RawArgs_ = _rawArgs
_action := interfaces.Action{
Account: account,
Action: action,
Arguments: _args,
Permissions: permissions,
}
sender.actions = append(sender.actions, &_action)
}
func (sender *ActionSender) AddActionWithSigner(account string, action string, jsonArgs string, signer string) {
permissions := fmt.Sprintf(`{"%s": "active"}`, signer)
sender.AddAction(account, action, jsonArgs, permissions)
}
func (sender *ActionSender) AddActionWithSignerEx(account string, action string, rawArgs []byte, signer string) {
permissions := fmt.Sprintf(`{"%s": "active"}`, signer)
sender.AddActionEx(account, action, rawArgs, permissions)
}
func (sender *ActionSender) Send() (*JsonValue, error) {
return sender.tester.PushActions(sender.actions)
}