forked from VIZ-Blockchain/viz-go-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.go
55 lines (44 loc) · 1.39 KB
/
helper.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
package viz
import (
"github.com/VIZ-Blockchain/viz-go-lib/operations"
"github.com/VIZ-Blockchain/viz-go-lib/transactions"
"github.com/VIZ-Blockchain/viz-go-lib/types"
)
//SetAsyncProtocol enables or disables the asynchronous operation protocol
func (client *Client) SetAsyncProtocol(value bool) {
client.asyncProtocol = value
}
//SetKeys you can specify keys for signing transactions.
func (client *Client) SetKeys(keys *Keys) {
client.CurrentKeys = keys
}
//SetAsset returns data of type Asset
func SetAsset(amount float64, symbol string) *types.Asset {
return &types.Asset{Amount: amount, Symbol: symbol}
}
//JSONTrxString generate Trx to String
func JSONTrxString(v *transactions.SignedTransaction) (string, error) {
ans, err := types.JSONMarshal(v)
if err != nil {
return "", err
}
return string(ans), nil
}
//JSONOpString generate Operations to String
func JSONOpString(v []operations.Operation) (string, error) {
var tx operations.Operations
tx = append(tx, v...)
ans, err := types.JSONMarshal(tx)
if err != nil {
return "", err
}
return string(ans), nil
}
//GenerateProposalOperation generate []Operation to ProposalOperations
func GenerateProposalOperation(ops []operations.Operation) operations.ProposalObjects {
var ans operations.ProposalObjects
for _, val := range ops {
ans = append(ans, operations.ProposalObject{Operation: val, OperationType: val.Type()})
}
return ans
}