forked from 33cn/plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rpc.go
72 lines (65 loc) · 2.01 KB
/
rpc.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
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc
import (
context "golang.org/x/net/context"
"github.com/33cn/chain33/types"
bw "github.com/33cn/plugin/plugin/dapp/blackwhite/types"
)
func (c *channelClient) Create(ctx context.Context, head *bw.BlackwhiteCreate) (*types.UnsignTx, error) {
val := &bw.BlackwhiteAction{
Ty: bw.BlackwhiteActionCreate,
Value: &bw.BlackwhiteAction_Create{Create: head},
}
tx := &types.Transaction{
Payload: types.Encode(val),
}
data, err := types.FormatTxEncode(string(bw.ExecerBlackwhite), tx)
if err != nil {
return nil, err
}
return &types.UnsignTx{Data: data}, nil
}
func (c *channelClient) Show(ctx context.Context, head *bw.BlackwhiteShow) (*types.UnsignTx, error) {
val := &bw.BlackwhiteAction{
Ty: bw.BlackwhiteActionShow,
Value: &bw.BlackwhiteAction_Show{Show: head},
}
tx := &types.Transaction{
Payload: types.Encode(val),
}
data, err := types.FormatTxEncode(string(bw.ExecerBlackwhite), tx)
if err != nil {
return nil, err
}
return &types.UnsignTx{Data: data}, nil
}
func (c *channelClient) Play(ctx context.Context, head *bw.BlackwhitePlay) (*types.UnsignTx, error) {
val := &bw.BlackwhiteAction{
Ty: bw.BlackwhiteActionPlay,
Value: &bw.BlackwhiteAction_Play{Play: head},
}
tx := &types.Transaction{
Payload: types.Encode(val),
}
data, err := types.FormatTxEncode(string(bw.ExecerBlackwhite), tx)
if err != nil {
return nil, err
}
return &types.UnsignTx{Data: data}, nil
}
func (c *channelClient) TimeoutDone(ctx context.Context, head *bw.BlackwhiteTimeoutDone) (*types.UnsignTx, error) {
val := &bw.BlackwhiteAction{
Ty: bw.BlackwhiteActionTimeoutDone,
Value: &bw.BlackwhiteAction_TimeoutDone{TimeoutDone: head},
}
tx := &types.Transaction{
Payload: types.Encode(val),
}
data, err := types.FormatTxEncode(string(bw.ExecerBlackwhite), tx)
if err != nil {
return nil, err
}
return &types.UnsignTx{Data: data}, nil
}