Commit 6d5a890a authored by suyanlong's avatar suyanlong

Add evmxgo plugin

parent de3be454
...@@ -96,3 +96,6 @@ check: aligner-check checkgofmt ...@@ -96,3 +96,6 @@ check: aligner-check checkgofmt
modmated: modmated:
@go list -u -m -json all | go-mod-outdated @go list -u -m -json all | go-mod-outdated
proto:
cd proto && protoc --go_out=. ./*.proto --proto_path=.
package main
import (
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/Rican7/retry"
"github.com/Rican7/retry/strategy"
hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"gitlab.33.cn/link33/sidecar/model/pb"
"gitlab.33.cn/link33/sidecar/pkg/plugins"
"gitlab.33.cn/link33/chain33-sdk-go/client"
broker "gitlab.33.cn/link33/chain33-sdk-go/dapp/broker"
"gitlab.33.cn/link33/chain33-sdk-go/event"
"gitlab.33.cn/link33/chain33-sdk-go/types"
"gitlab.33.cn/link33/chain33-sdk-go/util"
)
var logger = hclog.New(&hclog.LoggerOptions{
Name: "chain33-client",
Output: os.Stderr,
Level: hclog.Trace,
})
var _ plugins.Client = (*Client)(nil)
const (
GetInnerMetaMethod = "getInnerMeta" // get last index of each source chain executing tx
GetOutMetaMethod = "getOuterMeta" // get last index of each receiving chain crosschain event
GetCallbackMetaMethod = "getCallbackMeta" // get last index of each receiving chain callback tx
GetDstRollbackMeta = "getDstRollbackMeta" // get last index of each receiving chain dst roll back tx
GetChainId = "getChainId"
GetInMessageMethod = "getInMessage"
GetOutMessageMethod = "getOutMessage"
PollingEventMethod = "pollingEvent"
InvokeInterchainMethod = "invokeInterchain"
InvokeIndexUpdateMethod = "invokeIndexUpdate"
Chain33Type = "chain33"
)
type ContractMeta struct {
EventFilter string `json:"event_filter"`
CCID string `json:"ccid"`
PrivateKey string `json:"private_key"`
TimeoutHeight int64 `json:"timeout_height"`
ChainID string `json:"chain_id"`
}
type Client struct {
meta *ContractMeta
consumer *Consumer
eventC chan *pb.IBTP
appchainID string
name string
serviceMeta map[string]*pb.Interchain
ticker *time.Ticker
done chan bool
timeoutHeight int64
config *Config
}
type CallFunc struct {
Func string `json:"func"`
Args [][]byte `json:"args"`
}
func (c *Client) Kill() {
}
func (c *Client) Exited() bool {
return true
}
func (c *Client) Bind(kern plugins.Kernel) {
}
// 插件合约初始化配置
func (c *Client) Initialize(configPath, appchainID string, extra []byte) error {
eventC := make(chan *pb.IBTP)
config, err := UnmarshalConfig(configPath)
if err != nil {
return fmt.Errorf("unmarshal config for plugin :%w", err)
}
chain33Config := config.Chain33
contractmeta := &ContractMeta{
EventFilter: chain33Config.EventFilter,
PrivateKey: chain33Config.PrivateKey,
}
logger.Info("=========privateKey======", chain33Config.PrivateKey)
m := make(map[string]*pb.Interchain)
//if err := json.Unmarshal(extra, &m); err != nil {
// return fmt.Errorf("unmarshal extra for plugin :%w", err)
//}
if m == nil {
m = make(map[string]*pb.Interchain)
}
mgh, err := newChain33Handler(contractmeta.EventFilter, eventC, appchainID)
if err != nil {
return err
}
done := make(chan bool)
csm, err := NewConsumer(config, contractmeta, mgh, done)
if err != nil {
return err
}
c.consumer = csm
c.eventC = eventC
c.meta = contractmeta
c.appchainID = appchainID
c.name = chain33Config.Name
c.serviceMeta = m
c.ticker = time.NewTicker(2 * time.Second)
c.done = done
c.timeoutHeight = chain33Config.TimeoutHeight
c.config = config
return nil
}
func (c *Client) Start() error {
logger.Info("Fabric consumer started")
go c.polling()
return c.consumer.Start()
}
func (c *Client) Stop() error {
c.ticker.Stop()
c.done <- true
return c.consumer.Shutdown()
}
// polling event from broker
// 从应用链broker合约拉取跨链事件(出去的)
func (c *Client) polling() {
for {
select {
case <-c.ticker.C:
// 应用链broker合约需要适配一个查询接口,用户获取outMeta(跨到其他应用链上统计累计交易数量的索引)
outMeta, err := c.GetOutMeta()
if err != nil {
continue
}
for servicePair, index := range outMeta {
srcChainServiceID, dstChainServiceID, err := parseServicePair(servicePair)
if err != nil {
logger.Error("Polling out invalid service pair",
"servicePair", servicePair,
"index", index,
"error", err.Error())
continue
}
// 用于本地记录本应用链与其他目标链之间发送得跨链数据包及收到跨链数据包之间的统计
meta, ok := c.serviceMeta[srcChainServiceID]
if !ok {
meta = &pb.Interchain{
ID: srcChainServiceID,
InterchainCounter: make(map[string]uint64),
ReceiptCounter: make(map[string]uint64),
// SourceInterchainCounter: make(map[string]uint64),
SourceReceiptCounter: make(map[string]uint64),
}
// FIXME 临时修复无法从本地DB加载处理日志的bug
callBackMeta, err := c.GetCallbackMeta()
if err != nil {
logger.Error("get callback meta",
"error", err.Error())
}
meta.InterchainCounter[dstChainServiceID] = callBackMeta[servicePair]
c.serviceMeta[srcChainServiceID] = meta
}
for i := meta.InterchainCounter[dstChainServiceID] + 1; i <= index; i++ {
// 根据索引去查询要跨到目标链上面的具体信息,并封装成ibtp协议包
ibtp, err := c.GetOutMessage(servicePair, i)
if err != nil {
logger.Error("Polling out message",
"servicePair", servicePair,
"index", i,
"error", err.Error())
continue
}
// 将ibtp协议包发送给eventC通道,进行处理,同时跨链计数器到目标链项累计加1
c.eventC <- ibtp
meta.InterchainCounter[dstChainServiceID]++
}
}
case <-c.done:
logger.Info("Stop long polling")
return
}
}
}
// 跨链交易存在性证明
func (c *Client) getProof(txhash string) ([]byte, error) {
var proof []byte
handle := func(txhash string) ([]byte, error) {
// query proof from chain33
txDetail, err := c.consumer.jsonClient.QueryTransaction(txhash)
if err != nil {
return nil, err
}
txProof := txDetail.Proofs[0]
// FIXME 这里用json去序列化
return []byte(txProof), nil
}
if err := retry.Retry(func(attempt uint) error {
var err error
proof, err = handle(txhash)
if err != nil {
logger.Error("Can't get proof", "error", err.Error())
return err
}
return nil
}, strategy.Wait(2*time.Second)); err != nil {
logger.Error("Can't get proof", "error", err.Error())
}
return proof, nil
}
func (c *Client) Name() string {
return c.name
}
func (c *Client) Type() string {
return Chain33Type
}
// FIXME 查询ID,后面需要实现
func (c *Client) ID() string {
info, err := c.consumer.jsonClient.QueryBrokerInfo()
if err != nil {
return ""
}
return fmt.Sprintf("%s:%s", info.GetBxhId(), info.GetAppChainId())
}
func (c *Client) GetIBTP() chan *pb.IBTP {
return c.eventC
}
// 提交IBTP协议内容
func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
ret := &pb.SubmitIBTPResponse{}
pd := &pb.Payload{}
if err := pd.Unmarshal(ibtp.Payload); err != nil {
return nil, fmt.Errorf("ibtp payload unmarshal: %w", err)
}
content := &pb.Content{}
if err := content.Unmarshal(pd.Content); err != nil {
return ret, fmt.Errorf("ibtp content unmarshal: %w", err)
}
var args string
var argscb string
for _, by := range content.Args {
args = fmt.Sprintf("%s,%s", args, string(by))
}
for _, by := range content.ArgsCb {
argscb = fmt.Sprintf("%s,%s", argscb, string(by))
}
if ibtp.Category() == pb.IBTP_UNKNOWN {
return nil, fmt.Errorf("invalid ibtp category")
}
var (
err error
serviceID string
srcChainServiceID string
)
srcChainServiceID = ibtp.From
_, _, serviceID, err = parseChainServiceID(ibtp.To)
if ibtp.Category() == pb.IBTP_RESPONSE && content.Func == "" {
// 响应类型处理
logger.Info("InvokeIndexUpdate", "ibtp", ibtp.ID())
_, resp, err := c.InvokeIndexUpdate(srcChainServiceID, ibtp.Nonce, serviceID, ibtp.Category())
if err != nil {
return nil, err
}
ret.Status = resp.OK
ret.Message = resp.Message
//if ibtp.Type == pb.IBTP_ROLLBACK {
// ret.Result, err = c.generateCallback(ibtp, nil, ret.Status)
// if err != nil {
// return nil, err
// }
//}
return ret, nil
}
// FIXME 修复
var result [][]byte
var chResp string
callFunc := CallFunc{
Func: content.Func,
Args: content.Args,
}
bizData, err := json.Marshal(callFunc)
if err != nil {
ret.Status = false
ret.Message = fmt.Sprintf("marshal ibtp %s func %s and args: %s", ibtp.ID(), callFunc.Func, err.Error())
res, _, err := c.InvokeIndexUpdate(srcChainServiceID, ibtp.Nonce, serviceID, ibtp.Category())
if err != nil {
return nil, err
}
chResp = res
} else {
// ibtp.Category() 对ibtp消息进行类型转换,判断是请求消息还是响应消息,响应消息不需要执行回调
res, resp, err := c.InvokeInterchain(srcChainServiceID, ibtp.Nonce, serviceID, uint64(ibtp.Category()), bizData)
if err != nil {
return nil, fmt.Errorf("invoke interchain for ibtp %s to call %s: %w", ibtp.ID(), content.Func, err)
}
ret.Status = resp.OK
ret.Message = resp.Message
// 将查询结果,作为参数传递到回调函数中
result = util.ToChaincodeArgs(strings.Split(string(resp.Data), ",")...)
chResp = res
}
// If is response IBTP, then simply return
if ibtp.Category() == pb.IBTP_RESPONSE {
return ret, nil
}
logger.Info("SubmitIBTP", "ibtp", ibtp.ID(), "resp", chResp)
//FIXME 暂时去掉获取证明
//proof, err := c.getProof(chResp)
//if err != nil {
// return ret, err
//}
ret.Result, err = c.generateCallback(ibtp, result, ret.Status)
if err != nil {
return nil, err
}
ret.Result.Proof = nil
return ret, nil
}
// TODO InvokerInterchain 方法内实现具体的跨链交易所需的逻辑,这里我们通过SDK方式控制跨链合约的内部交换
func (c *Client) InvokeInterchain(from string, index uint64, destAddr string, reqType uint64, bizCallData []byte) (string, *Response, error) {
args := util.ToChaincodeArgs(from, strconv.FormatUint(index, 10), destAddr, strconv.FormatUint(reqType, 10))
args = append(args, bizCallData)
splitedCID := strings.Split(destAddr, "&")
if len(splitedCID) != 2 {
return "", nil, fmt.Errorf("destaddr is not expect type!")
}
request := &client.Request{
Exec: splitedCID[1],
Fcn: InvokeInterchainMethod,
Args: args,
}
// retry executing
var res *client.Response
var err error
if err := retry.Retry(func(attempt uint) error {
// TODO 改为客户端去执行
res, err = c.consumer.jsonClient.Execute(request, c.config.Chain33.PrivateKey)
if err != nil {
logger.Error("execute request failed", "err", err.Error())
return nil
}
return nil
}, strategy.Wait(2*time.Second)); err != nil {
logger.Error("Can't send rollback ibtp back to bitxhub", "error", err.Error())
}
if err != nil {
return "", nil, err
}
// logger.Info("response", "cc status", strconv.Itoa(int(res.ChaincodeStatus)), "payload", string(res.Payload))
response := &Response{res.OK, res.Message, res.Data}
return res.Message, response, nil
}
// TODO 这里应该是getOutMessage可以获取跨链交易的txhash,通过查看库跨链交易的存在性证明来判断此笔跨链交易是否存在
func (c *Client) GetOutMessage(servicePair string, idx uint64) (*pb.IBTP, error) {
// 获取txhash
event, err := c.consumer.jsonClient.QueryOutMessage(servicePair, idx)
if err != nil {
return nil, err
}
//proof, err := c.getProof(res.Message)
//if err != nil {
// return nil, err
//}
return c.unpackIBTP(event, pb.IBTP_INTERCHAIN, nil)
}
// FIXME 查看跨入交易的执行结果,是否执行成功
func (c *Client) GetInMessage(servicePair string, index uint64) ([][]byte, error) {
response, err := c.consumer.jsonClient.QueryInMessage(servicePair, index)
if err != nil {
return nil, fmt.Errorf("execute QueryInMessage: %w", err)
}
results := []string{"true"}
results = append(results, strings.Split(string(response.Status), ",")...)
return util.ToChaincodeArgs(results...), nil
}
func (c *Client) GetInMeta() (map[string]uint64, error) {
meta, err := c.consumer.jsonClient.QueryInnerMeta()
if err != nil {
return nil, err
}
return meta.Meta, nil
}
// 查看outMeta
func (c *Client) GetOutMeta() (map[string]uint64, error) {
meta, err := c.consumer.jsonClient.QueryOutterMeta()
if err != nil {
return nil, err
}
return meta.Meta, nil
}
func (c Client) GetCallbackMeta() (map[string]uint64, error) {
meta, err := c.consumer.jsonClient.QueryCallBackMeta()
if err != nil {
return nil, err
}
return meta.Meta, nil
}
func (c *Client) CommitCallback(ibtp *pb.IBTP) error {
return nil
}
// 回滚操IBTP
// @ibtp is the original ibtp merged from this appchain
func (c *Client) RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPResponse, error) {
ret := &pb.RollbackIBTPResponse{Status: true}
pd := &pb.Payload{}
if err := pd.Unmarshal(ibtp.Payload); err != nil {
return nil, fmt.Errorf("ibtp payload unmarshal: %w", err)
}
content := &pb.Content{}
if err := content.Unmarshal(pd.Content); err != nil {
return ret, fmt.Errorf("ibtp content unmarshal: %w", err)
}
if content.Rollback == "" {
logger.Info("rollback function is empty, ignore it", "func", content.Func, "callback", content.Callback, "rollback", content.Rollback)
return nil, nil
}
var (
bizData []byte
err error
serviceID string
srcChainServiceID string
rollbackFunc string
rollbackArgs [][]byte
reqType uint64
)
if isSrcChain {
rollbackFunc = content.Rollback
rollbackArgs = content.ArgsRb
srcChainServiceID = ibtp.To
_, _, serviceID, err = parseChainServiceID(ibtp.From)
reqType = 1
} else {
rollbackFunc = content.Func
rollbackArgs = content.Args
rollbackArgs[len(rollbackArgs)-1] = []byte("true")
srcChainServiceID = ibtp.From
_, _, serviceID, err = parseChainServiceID(ibtp.To)
reqType = 2
}
callFunc := CallFunc{
Func: rollbackFunc,
Args: rollbackArgs,
}
bizData, err = json.Marshal(callFunc)
if err != nil {
return ret, err
}
// pb.IBTP_RESPONSE indicates it is to update callback counter
_, resp, err := c.InvokeInterchain(srcChainServiceID, ibtp.Nonce, serviceID, reqType, bizData)
if err != nil {
return nil, fmt.Errorf("invoke interchain for ibtp %s to call %s: %w", ibtp.ID(), content.Rollback, err)
}
ret.Status = resp.OK
ret.Message = resp.Message
return ret, nil
}
func (c *Client) IncreaseInMeta(original *pb.IBTP) (*pb.IBTP, error) {
ibtp, err := c.generateCallback(original, nil, false)
if err != nil {
return nil, err
}
_, _, serviceID, err := parseChainServiceID(ibtp.To)
if err != nil {
return nil, err
}
_, _, err = c.InvokeIndexUpdate(original.From, original.Nonce, serviceID, original.Category())
if err != nil {
logger.Error("update in meta", "ibtp_id", original.ID(), "error", err.Error())
}
return ibtp, nil
}
func (c *Client) GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error) {
// FIXME servicePair
result, err := c.GetInMessage(genServicePair(ibtp.From, ibtp.To), ibtp.Nonce)
if err != nil {
return nil, err
}
status, err := strconv.ParseBool(string(result[0]))
if err != nil {
return nil, err
}
return c.generateCallback(ibtp, result[1:], status)
}
// 更新索引,正确执行的,执行失败的
func (c *Client) InvokeIndexUpdate(from string, index uint64, serviceId string, category pb.IBTP_Category) (string, *Response, error) {
// TODO 状态更新怎么说得 status 1表示执行成功
tx := broker.UpdateIndex("", from, serviceId, index, uint64(category), 1)
response, err := c.consumer.jsonClient.SendTransactionSync(c.config.Chain33.PrivateKey, tx)
if err != nil {
return "", nil, err
}
return response.Message, &Response{OK: response.OK, Message: response.Message, Data: response.Data}, nil
}
func (c *Client) GetSrcRollbackMeta() (map[string]uint64, error) {
panic("implement me")
}
// TODO 未实现
func (c *Client) GetDstRollbackMeta() (map[string]uint64, error) {
return nil, nil
}
func (c *Client) GetServices() []string {
var services []string
for _, service := range c.config.Services {
services = append(services, service.ID)
}
return services
}
// 查询chainID,后面需要实现
func (c *Client) GetChainID() (string, string) {
info, err := c.consumer.jsonClient.QueryBrokerInfo()
if err != nil {
return "", ""
}
return info.GetBxhId(), info.GetAppChainId()
}
func (c *Client) unpackIBTP(event *types.InterchainEvent, ibtpType pb.IBTP_Type, proof []byte) (*pb.IBTP, error) {
ret := &Event{}
// TODO 序列化这里要适配plugin中的序列化方式
ret.Argsrb = event.Argsrb
ret.Args = event.Args
ret.Argscb = event.Argscb
ret.Index = event.GetIndex()
ret.Func = event.Func
ret.DstFullID = event.GetDstServiceID()
ret.SrcFullID = event.GetSrcServiceID()
ibtp := ret.Convert2IBTP(c.timeoutHeight, ibtpType)
ibtp.Proof = proof
return ibtp, nil
}
type handler struct {
eventFilter string
eventC chan *pb.IBTP
ID string
}
func newChain33Handler(eventFilter string, eventC chan *pb.IBTP, pierId string) (*handler, error) {
return &handler{
eventC: eventC,
eventFilter: eventFilter,
ID: pierId,
}, nil
}
// 监听事件
func (h *handler) HandleMessage(deliveries *event.CCEvent, payload []byte) {
if deliveries.EventName == h.eventFilter {
e := &pb.IBTP{}
if err := e.Unmarshal(deliveries.Payload); err != nil {
return
}
e.Proof = payload
h.eventC <- e
}
}
func main() {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: plugins.Handshake,
Plugins: map[string]plugin.Plugin{
plugins.PluginName: &plugins.AppchainGRPCPlugin{Impl: &Client{}},
},
GRPCServer: plugin.DefaultGRPCServer,
})
logger.Info("Plugin server down")
}
func parseChainServiceID(id string) (string, string, string, error) {
splits := strings.Split(id, ":")
if len(splits) != 3 {
return "", "", "", fmt.Errorf("invalid chain service ID: %s", id)
}
return splits[0], splits[1], splits[2], nil
}
func parseServicePair(servicePair string) (string, string, error) {
splits := strings.Split(servicePair, "-")
if len(splits) != 2 {
return "", "", fmt.Errorf("invalid service pair: %s", servicePair)
}
return splits[0], splits[1], nil
}
func genServicePair(from, to string) string {
return fmt.Sprintf("%s-%s", from, to)
}
package config
import (
"path/filepath"
"strings"
"github.com/spf13/viper"
)
const (
ConfigName = "chain33.toml"
)
type Config struct {
Chain33 Chain33 `toml:"chain33" json:"chain33"`
Services []Service `mapstructure:"services" json:"services"`
}
type Chain33 struct {
Addr string `toml:"addr" json:"addr"`
Name string `toml:"name" json:"name"`
EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
PrivateKey string `mapstructure:"private_key" toml:"private_key" json:"private_key"`
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
ChainID string `mapstructure:"chain_id" json:"chain_id"`
}
type Service struct {
ID string `toml:"id" json:"id"`
Name string `toml:"name" json:"name"`
Type string `toml:"type" json:"type"`
}
func DefaultConfig() *Config {
return &Config{
Chain33: Chain33{
Addr: "40.125.164.122:8801",
Name: "chain33",
},
Services: nil,
}
}
func UnmarshalConfig(configPath string) (*Config, error) {
viper.SetConfigFile(filepath.Join(configPath, ConfigName))
viper.SetConfigType("toml")
viper.AutomaticEnv()
viper.SetEnvPrefix("CHAIN33")
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
if err := viper.ReadInConfig(); err != nil {
return nil, err
}
config := DefaultConfig()
if err := viper.Unmarshal(config); err != nil {
return nil, err
}
return config, nil
}
package main
import (
"fmt"
chain33sdk "gitlab.33.cn/link33/chain33-sdk-go/client"
"gitlab.33.cn/link33/chain33-sdk-go/event"
)
type MessageHandler interface {
HandleMessage(deliveries *event.CCEvent, payload []byte)
}
type Consumer struct {
jsonClient *chain33sdk.JSONClient
meta *ContractMeta
msgH MessageHandler
registration chan<- event.Registration
errCh <-chan error
ctx chan bool
}
func NewConsumer(config *Config, meta *ContractMeta, msgH MessageHandler, ctx chan bool) (*Consumer, error) {
client, err := chain33sdk.NewJSONClient("", config.Chain33.Addr)
if err != nil {
return nil, fmt.Errorf("create chain33 sdk jsonclient fail: %s\n", err)
}
c := &Consumer{
msgH: msgH,
jsonClient: client,
meta: meta,
ctx: ctx,
}
return c, nil
}
// 这里采用笨方法,轮循不断拉取交易去判断
func (c *Consumer) Start() error {
registration, notifier, errCh := c.jsonClient.RegisterTxEvent(0, c.meta.CCID, c.meta.EventFilter)
c.registration = registration
c.errCh = errCh
// todo: add context
go func() {
for {
select {
case ccEvent := <-notifier:
if ccEvent != nil {
c.handle(ccEvent)
}
case err := <-errCh:
fmt.Errorf("have err:", err.Error())
return
case <-c.ctx:
return
}
}
}()
return nil
}
func (c *Consumer) Shutdown() error {
c.registration <- struct{}{}
return nil
}
func (c *Consumer) handle(deliveries *event.CCEvent) {
//t, err := c.jsonClient.QueryTransaction(deliveries.TxID)
//if err != nil {
// return
//}
//var action types.BrokerAction
//if err:=types.Decode(t.Tx.Payload,&action);err !=nil {
// return
//}
//action.GetEmitInterchainEvent()
c.msgH.HandleMessage(deliveries, deliveries.Payload)
}
package main package event
import ( import (
"fmt" "fmt"
......
package evmxgo
import (
"fmt"
"math/rand"
"os"
"time"
evmxgotypes "github.com/33cn/plugin/plugin/dapp/evmxgo/types"
"github.com/hashicorp/go-hclog"
"gitlab.33.cn/link33/chain33-sdk-go/types"
"gitlab.33.cn/link33/sidecar-client-chain33/client/rpc"
"gitlab.33.cn/link33/sidecar-client-chain33/config"
typess "gitlab.33.cn/link33/sidecar-client-chain33/types"
"gitlab.33.cn/link33/sidecar/model/pb"
"gitlab.33.cn/link33/sidecar/pkg/plugins"
"gitlab.33.cn/link33/sidecar/tool"
)
var ActionMap = map[string]func(){
// 监听已铸币成功事件:异步完成
evmxgotypes.NameMintMapAction: func() {
// 铸币操作,打给用户地址【操作只能在用户公链一侧发起,被铸造入币的地址,由发起操作时带入,取之范围为:from、或者Recipient。】。
// 事件:铸币成功 <=> lock,
// 构造交易发给公链
},
// 监听已销毁代币事件:异步完成
evmxgotypes.NameBurnMapAction: func() {
// 销毁操作,销毁的地址值为:from地址或Recipient地址【默认是签名地址,实际是from地址,需要核对地址是否一致,能否销毁】。操作发起,两种情况:1、在公链发起,销毁;2、在联盟链发起,销毁from地址。
// 构造交易发给公链,
},
}
const (
PluginName = "evmxgo"
ID = "evmxgo"
execer = "evmxgo"
)
var logger = hclog.New(&hclog.LoggerOptions{
Name: "chain33-client",
Output: os.Stderr,
Level: hclog.Trace,
})
var _ plugins.Client = (*Evmxgo)(nil)
type Evmxgo struct {
eventC chan *pb.IBTP // 发送给sidecar
appChainID string
toChainID string
name string
ticker *time.Ticker
serviceMeta map[string]*pb.Interchain
done chan bool
timeoutHeight int64
// config *main.Config
client *rpc.Client
pk string // 签名,仅仅是和当前链挂钩的私钥。
height int64 // 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置
// 记录已完成的hashID、高度等信息。
}
func (e *Evmxgo) Start() error {
go e.listenAppChain()
logger.Info("Evmxgo started")
return nil
}
func (e *Evmxgo) Stop() error {
e.ticker.Stop()
e.done <- true
return nil
}
func (e *Evmxgo) Bind(kern plugins.Kernel) {
// TODO implement me
panic("not implement me")
}
func (e *Evmxgo) Name() string {
// TODO implement me
return ID
}
func (e *Evmxgo) Type() string {
return ID
}
func (e *Evmxgo) ID() string {
return ID
}
func (e *Evmxgo) Initialize(configPath string, ID string, extra []byte) error {
// TODO implement me
// 初始化e.client工作
e.eventC = make(chan *pb.IBTP, 10)
e.done = make(chan bool)
e.ticker = time.NewTicker(2 * time.Second)
chain33Config, err := config.UnmarshalConfig(configPath)
if err != nil {
return fmt.Errorf("unmarshal config for plugin :%w", err)
}
logger.Info("=========privateKey======", chain33Config.Chain33.PrivateKey)
// 加载高度,从本地磁盘加载。
return nil
}
func (e *Evmxgo) GetIBTP() chan *pb.IBTP {
return e.eventC
}
// polling event from Evmxgo
func (e *Evmxgo) polling() chan *typess.Event {
// TODO 定时获取关注的交易、日志、区块等,然后解析到关注的数据内容。
// 获取用户日志,记录对应的日志(hash)放入对应的的数据库里。或者记录本地数据库,做一一的绑定。
// 获取receipt log日志,解析,构造交易,发送交易,区块高度记录,记录已发生的交易。
// e.client.SendTransaction() //构造交易,签名,发送交易
// e.client.QueryLastHeader() //公链用的到,
// e.client.QueryBlockInfo() //查询区块,获取交易,并解析
// e.client.QueryIsSync() //验证区块服务状态
// e.client.QueryTransaction()//查询指定交易
// 1:lock <=> mint; 2 unlock <=> burn 一一绑定,通过双方的hash。把绑定关系,写入到[双方]区块链中。
// 公链事件:lock: topic + execer + transfer; unlock: topic + execer + withdraw。联盟链:mint: execer + mintMap; burn: execer + burnMap
// 公链:当前高度与最新高度相差6~15个块;联盟链:获取最新的块即可。
// 提币必须成功,绑定。公链是主链;联盟链是映射链。
// 用户在公链一侧发起锁定、解锁(销毁)操作。
// 用户在联盟链一侧解锁(销毁)操作。
// 限制:1、同一个用户,不允许连续提2笔交易。2、锁定操作只能在公链一侧发起。
// 侧链用户,只要有代币,就可以销毁,同时在公链一侧做解锁操作,不管是否有解锁。(同一账户【地址】体系,或者附带用户的公链地址)
ch := make(chan *typess.Event, 1)
// FIXME 这里实现是以联盟链方式,联盟链没有回滚,所以这里暂时按高度拉去处理
go func() {
for {
select {
case <-e.ticker.C:
header, err := e.client.QueryLastHeader()
if err != nil {
logger.Error("QueryLastHeader error: ", err)
}
lastHeight := header.Height
if lastHeight <= e.height {
time.Sleep(time.Second)
}
blockInfo, err := e.client.QueryBlockInfo(e.height+1, e.height+1, true) // TODO 分组获取
if err != nil {
logger.Error("QueryBlockInfo error: ", err)
} else {
for _, item := range blockInfo.Items {
for i, tx := range item.Block.Txs {
if tx.Execer == execer {
switch item.Receipts[i].Ty {
case types.ExecOk: // OK
if item.Receipts[i].TyName == evmxgotypes.NameMintMapAction {
var mintEvent evmxgotypes.EvmxgoMintMap
tool.ErrorCheck(types.Decode(tx.Payload, &mintEvent))
if len(mintEvent.Extra) > 0 { // 存在关联的数据
event := &typess.Event{
TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height),
Contract: &typess.Contract{
ChainID: e.appChainID,
ExecName: ID,
Address: "", // TODO 合约地址
CallMethod: evmxgotypes.NameMintMapAction,
},
Payload: &typess.MapAssetInfo{
EventType: typess.EventType_Mint,
MintAddress: mintEvent.Recipient,
MintAmount: mintEvent.Amount,
Symbol: mintEvent.Symbol,
Extra: mintEvent.Extra,
},
}
ch <- event
}
}
if item.Receipts[i].TyName == evmxgotypes.NameBurnMapAction {
var mintEvent evmxgotypes.EvmxgoBurnMap
tool.ErrorCheck(types.Decode(tx.Payload, &mintEvent))
if len(mintEvent.Extra) > 0 {
// 已销毁
event := &typess.Event{
TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height),
Contract: &typess.Contract{
ChainID: e.appChainID,
ExecName: ID,
Address: "", // TODO 合约地址
CallMethod: evmxgotypes.NameBurnMapAction,
},
Payload: &typess.MapAssetInfo{
EventType: typess.EventType_Burn,
MintAddress: tx.From, // 用户地址
MintAmount: mintEvent.Amount,
Symbol: mintEvent.Symbol,
Extra: mintEvent.Extra, // TODO
},
}
ch <- event // 需要保存这个事件,用于确认销毁成功。
} else {
// TODO 在公链一侧,用户发起注销,余额不够,交易失败.
}
}
case types.ExecErr: // Error
logger.Error("transaction error ",
"tx:", tx,
"height:", item.Block.Height,
)
case types.ExecPack:
logger.Error("exec error!",
"tx:", tx,
"height:", item.Block.Height,
)
}
}
}
}
e.height++
}
case <-e.done:
logger.Info("Stop long polling")
break
}
}
}()
return ch
}
func (e *Evmxgo) listenAppChain() {
ch := e.polling()
for event := range ch {
payload := types.Encode(event)
tmp := time.Now().UnixNano()
ibtp := &pb.IBTP{
From: e.appChainID,
To: e.toChainID,
Nonce: uint64(tmp), // TODO 唯一标识。随机nonce
Type: pb.IBTP_INTERCHAIN,
Timestamp: tmp,
Payload: payload,
Version: "1.0.0",
}
e.eventC <- ibtp
}
}
// 用户在公链发起lock -> 联盟链mint -> 回执lock ack,
// 用户在公链发起unlock -> 联盟链burn -> 回执 ack unlock
// 如果不携带extra,需要查询,对应的hash是否存在,如果携带,也需要查询。
// 用户在联盟链发起burn-> 公链unlock -> 回执 ack burn,
// 查询到的证明交易已经执行过了。
// paracorss解析note字段,与 extra字段做双向绑定。
// 交易延迟执行,
// paracorss: 转账:主链执行完成,侧链(平行链)ack确认,否则回滚。
// paracorss: 提币:主链并未执行,侧链(平行链)ack确认,通过索引查询,在最新高度重新执行。状态复制。
// 这个就是延迟交易:1、一个是设置固定高度,一定时间自动出发,2、外界触发。
// 模拟链上数据,数据存在在平行链上,做关联数据,
// 规定:
// 用户在公链发起铸币。逻辑决定。
// 销毁在联盟链一侧发起。evmxgo合约决定。
// 每个插件必持久化数据,否则,很容易丢失的。
func (e *Evmxgo) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
// TODO implement me
// 得到铸币请求
// 得到销币请求
ibtpRes := &pb.SubmitIBTPResponse{}
ibtpRes = nil
switch ibtp.Type {
case pb.IBTP_INTERCHAIN:
// 上链之前,先查询,是否存在
data := &typess.Event{}
err := types.Decode(ibtp.Payload, data)
if err != nil {
logger.Error("decode error", err)
}
if len(data.Payload.Extra) > 0 {
// 1、已上链存在重复发送。
// 2、正在执行的交易重复发送。
// 3、失败的交易重复发送。
event := &typess.Event{}
err := types.Decode(data.Payload.Extra, event)
if err != nil {
logger.Error("decode error", err)
}
// TODO
} else {
// 未上链
tx := &types.Transaction{
Execer: []byte(execer),
Fee: 1e5, // TODO
Nonce: rand.Int63n(time.Now().UnixNano()),
}
if data.Payload.EventType == typess.EventType_Lock {
// 构造交易,请求
mint := &evmxgotypes.EvmxgoMintMap{
Symbol: data.Payload.Symbol,
Amount: data.Payload.MintAmount,
Recipient: data.Payload.LockAddress,
Extra: ibtp.Payload, // TODO 附加已经完成的事件
}
tx.Payload = types.Encode(mint)
} else if data.Payload.EventType == typess.EventType_UnLock {
// 请求与应答
// 解锁操作,存在限制问题,用户在公链一侧发起解锁时,容易出错,
// 因此,需要限制,只能在联盟链一侧,用户发起销毁操作。
// 公链一侧发起撤销的事件。
// 构造交易,请求
//mint := &evmxgotypes.EvmxgoBurnMap{
// Symbol: data.Payload.Symbol,
// Amount: data.Payload.MintAmount,
// Extra: ibtp.Payload, //TODO 附加已经完成的事件
//}
//tx.Payload = types.Encode(mint)
}
res, err := e.client.SendTransactionSync(e.pk, tx)
if err != nil {
logger.Error("e.client.SendTransactionSync(e.pk,tx) error", err)
ibtpRes.Status = false
} else {
ibtpRes.Status = true
}
ibtpRes.Result = ibtp
ibtpRes.Message = res.Message // TODO 返回一个ack,主链确认。
}
// case pb.IBTP_RECEIPT_SUCCESS:
// case pb.IBTP_RECEIPT_FAILURE:
// case pb.IBTP_ROLLBACK:
// case pb.IBTP_RECEIPT_ROLLBACK:
default:
logger.Error("ibtp.Type error: ", "type", ibtp.Type)
}
// 返回结果是一个状态。并不是回执。需要保证对应的状态。或者请求持久化。
return ibtpRes, nil
}
func (e *Evmxgo) RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPResponse, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) IncreaseInMeta(ibtp *pb.IBTP) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetOutMessage(to string, idx uint64) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetInMessage(from string, idx uint64) ([][]byte, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetInMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetOutMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetCallbackMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) CommitCallback(ibtp *pb.IBTP) error {
// TODO implement me
panic("implement me")
}
func (e *Evmxgo) GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
module gitlab.33.cn/link33/sidecar-client-chain33 module gitlab.33.cn/link33/sidecar-client-chain33
go 1.13 go 1.18
replace github.com/33cn/plugin v1.66.3 => /Users/suyanlong/fuzhamei/plugin
require ( require (
github.com/Rican7/retry v0.1.0 github.com/33cn/plugin v1.66.3
github.com/Rican7/retry v0.3.1
github.com/bitly/go-simplejson v0.5.0 github.com/bitly/go-simplejson v0.5.0
github.com/cloudflare/cfssl v0.0.0-20190409034051-768cd563887f github.com/cloudflare/cfssl v1.6.1
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd github.com/hashicorp/go-hclog v1.2.0
github.com/hashicorp/go-plugin v1.3.0 github.com/hashicorp/go-plugin v1.4.3
github.com/spf13/viper v1.7.0 github.com/spf13/viper v1.10.1
gitlab.33.cn/link33/chain33-sdk-go v0.0.0-20211208090718-d6e59899ef37 gitlab.33.cn/link33/chain33-sdk-go v0.0.0-20211208090718-d6e59899ef37
gitlab.33.cn/link33/sidecar v0.0.0-20211213060412-f3eee2232093 gitlab.33.cn/link33/sidecar v0.0.0-20220120062340-04eb4a2e720f
go.starlark.net v0.0.0-20220302181546-5411bad688d1 // indirect go.starlark.net v0.0.0-20220302181546-5411bad688d1
) )
replace ( require (
github.com/go-kit/kit => github.com/go-kit/kit v0.8.0 github.com/33cn/chain33 v1.67.0 // indirect
github.com/golang/protobuf => github.com/golang/protobuf v1.3.2 github.com/BurntSushi/toml v0.3.1 // indirect
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.3 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/bxcodec/faker/v3 v3.6.0 // indirect
github.com/cbergoon/merkletree v0.2.0 // indirect
github.com/creasty/defaults v1.5.2 // indirect
github.com/decred/base58 v1.0.3 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.10.16 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobuffalo/envy v1.7.0 // indirect
github.com/gobuffalo/packd v1.0.0 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/goccy/go-json v0.7.10 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gookit/goutil v0.3.15 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac // indirect
github.com/jinzhu/copier v0.3.2 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/juju/errors v0.0.0-20210818161939-5560c4c073ff // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/meshplus/bitxhub-kit v1.2.1-0.20210524063043-9afae78ac098 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/thoas/go-funk v0.9.1 // indirect
github.com/tjfoc/gmsm v1.3.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect
golang.org/x/exp v0.0.0-20220317015231-48e79f11773a // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
) )
This source diff could not be displayed because it is too large. You can view the blob instead.
package main
import (
"fmt"
"github.com/hashicorp/go-plugin"
"gitlab.33.cn/link33/sidecar-client-chain33/evmxgo"
"gitlab.33.cn/link33/sidecar-client-chain33/paracross"
"gitlab.33.cn/link33/sidecar/pkg/plugins"
)
func main() {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: plugins.Handshake,
Plugins: map[string]plugin.Plugin{
// plugins.PluginName: &plugins.AppchainGRPCPlugin{Impl: &Client{}},
evmxgo.PluginName: &plugins.AppchainGRPCPlugin{Impl: &evmxgo.Evmxgo{}},
paracross.PluginParacross: &plugins.AppchainGRPCPlugin{Impl: &paracross.Paracross{}},
},
GRPCServer: plugin.DefaultGRPCServer,
})
fmt.Println("Plugin server down")
}
package paracross
import (
"gitlab.33.cn/link33/sidecar/model/pb"
"gitlab.33.cn/link33/sidecar/pkg/plugins"
)
const (
PluginParacross = "paracross"
)
type Paracross struct{}
func (p *Paracross) Start() error {
// TODO implement me
panic("implement me")
}
func (p *Paracross) Stop() error {
// TODO implement me
panic("implement me")
}
func (p *Paracross) Bind(kern plugins.Kernel) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetIBTP() chan *pb.IBTP {
// TODO implement me
panic("implement me")
}
func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPResponse, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) IncreaseInMeta(ibtp *pb.IBTP) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetOutMessage(to string, idx uint64) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetInMessage(from string, idx uint64) ([][]byte, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetInMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetOutMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetCallbackMeta() (map[string]uint64, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) CommitCallback(ibtp *pb.IBTP) error {
// TODO implement me
panic("implement me")
}
func (p *Paracross) GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error) {
// TODO implement me
panic("implement me")
}
func (p *Paracross) Name() string {
// TODO implement me
panic("implement me")
}
func (p *Paracross) Type() string {
// TODO implement me
panic("implement me")
}
func (p *Paracross) ID() string {
// TODO implement me
panic("implement me")
}
syntax = "proto3";
package types;
option go_package = "../types";
enum Status {
True = 0;
False = 1;
TimeOut = 2;
}
message Req {
Event event = 1;
}
message Res {
Event event = 1;
Status status = 2;
}
message Ret {
Event event = 1;
uint32 status = 2;
}
message Record {
string ID = 1;
string fromChainID = 2;
string toChainID = 3;
Event event = 4;
}
message Event {
string txID = 1;
uint64 blockNumber = 2;
Contract contract = 3;
MapAssetInfo payload = 4;
}
enum EventType {
Lock = 0;
Mint = 1;
UnLock = 2;
Burn = 3;
}
message MapAssetInfo {
EventType eventType = 1;
string lockAddress = 4;
int64 lockAmount = 5;
string mintAddress = 6;
int64 mintAmount = 7;
string unlockAddress = 8;
int64 unlockAmount = 9;
string burnAddress = 10;
int64 burnAmount = 11;
string symbol = 12;
bytes extra = 13;
}
message Contract {
string chainID = 1;
string execName = 2;
string address = 3;
string callMethod = 4;
}
message EventPair {
Event fromEvent = 1;
Event toEvent = 2;
}
package main
import (
"fmt"
"gitlab.33.cn/link33/sidecar/model/pb"
)
func (c *Client) generateCallback(original *pb.IBTP, args [][]byte, status bool) (result *pb.IBTP, err error) {
if original == nil {
return nil, fmt.Errorf("got nil ibtp To generate receipt: %w", err)
}
pd := &pb.Payload{}
if err := pd.Unmarshal(original.Payload); err != nil {
return nil, fmt.Errorf("ibtp payload unmarshal: %w", err)
}
originalContent := &pb.Content{}
if err := originalContent.Unmarshal(pd.Content); err != nil {
return nil, fmt.Errorf("ibtp payload unmarshal: %w", err)
}
content := &pb.Content{}
typ := pb.IBTP_RECEIPT_SUCCESS
if status {
content.Func = originalContent.Callback
content.Args = append(originalContent.ArgsCb, args...)
} else {
content.Func = originalContent.Rollback
content.Args = originalContent.ArgsRb
typ = pb.IBTP_RECEIPT_FAILURE
}
// TODO
if original.Type == pb.IBTP_ROLLBACK {
typ = pb.IBTP_RECEIPT_ROLLBACK
}
b, err := content.Marshal()
if err != nil {
return nil, err
}
retPd := &pb.Payload{
Content: b,
}
pdb, err := retPd.Marshal()
if err != nil {
return nil, err
}
return &pb.IBTP{
From: original.From,
To: original.To,
Nonce: original.Nonce,
Type: typ,
Proof: original.Proof,
Payload: pdb,
Version: original.Version,
}, nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.17.3
// source: proto.proto
package types
import (
reflect "reflect"
sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Status int32
const (
Status_True Status = 0
Status_False Status = 1
Status_TimeOut Status = 2
)
// Enum value maps for Status.
var (
Status_name = map[int32]string{
0: "True",
1: "False",
2: "TimeOut",
}
Status_value = map[string]int32{
"True": 0,
"False": 1,
"TimeOut": 2,
}
)
func (x Status) Enum() *Status {
p := new(Status)
*p = x
return p
}
func (x Status) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Status) Descriptor() protoreflect.EnumDescriptor {
return file_proto_proto_enumTypes[0].Descriptor()
}
func (Status) Type() protoreflect.EnumType {
return &file_proto_proto_enumTypes[0]
}
func (x Status) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Status.Descriptor instead.
func (Status) EnumDescriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{0}
}
type EventType int32
const (
EventType_Lock EventType = 0
EventType_Mint EventType = 1
EventType_UnLock EventType = 2
EventType_Burn EventType = 3
)
// Enum value maps for EventType.
var (
EventType_name = map[int32]string{
0: "Lock",
1: "Mint",
2: "UnLock",
3: "Burn",
}
EventType_value = map[string]int32{
"Lock": 0,
"Mint": 1,
"UnLock": 2,
"Burn": 3,
}
)
func (x EventType) Enum() *EventType {
p := new(EventType)
*p = x
return p
}
func (x EventType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (EventType) Descriptor() protoreflect.EnumDescriptor {
return file_proto_proto_enumTypes[1].Descriptor()
}
func (EventType) Type() protoreflect.EnumType {
return &file_proto_proto_enumTypes[1]
}
func (x EventType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use EventType.Descriptor instead.
func (EventType) EnumDescriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{1}
}
type Req struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
}
func (x *Req) Reset() {
*x = Req{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Req) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Req) ProtoMessage() {}
func (x *Req) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Req.ProtoReflect.Descriptor instead.
func (*Req) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{0}
}
func (x *Req) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
type Res struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=types.Status" json:"status,omitempty"`
}
func (x *Res) Reset() {
*x = Res{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Res) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Res) ProtoMessage() {}
func (x *Res) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Res.ProtoReflect.Descriptor instead.
func (*Res) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{1}
}
func (x *Res) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
func (x *Res) GetStatus() Status {
if x != nil {
return x.Status
}
return Status_True
}
type Ret struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
Status uint32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *Ret) Reset() {
*x = Ret{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Ret) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Ret) ProtoMessage() {}
func (x *Ret) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Ret.ProtoReflect.Descriptor instead.
func (*Ret) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{2}
}
func (x *Ret) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
func (x *Ret) GetStatus() uint32 {
if x != nil {
return x.Status
}
return 0
}
type Record struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
FromChainID string `protobuf:"bytes,2,opt,name=fromChainID,proto3" json:"fromChainID,omitempty"`
ToChainID string `protobuf:"bytes,3,opt,name=toChainID,proto3" json:"toChainID,omitempty"`
Event *Event `protobuf:"bytes,4,opt,name=event,proto3" json:"event,omitempty"`
}
func (x *Record) Reset() {
*x = Record{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Record) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Record) ProtoMessage() {}
func (x *Record) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Record.ProtoReflect.Descriptor instead.
func (*Record) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{3}
}
func (x *Record) GetID() string {
if x != nil {
return x.ID
}
return ""
}
func (x *Record) GetFromChainID() string {
if x != nil {
return x.FromChainID
}
return ""
}
func (x *Record) GetToChainID() string {
if x != nil {
return x.ToChainID
}
return ""
}
func (x *Record) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
type Event struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TxID string `protobuf:"bytes,1,opt,name=txID,proto3" json:"txID,omitempty"`
BlockNumber uint64 `protobuf:"varint,2,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"`
Contract *Contract `protobuf:"bytes,3,opt,name=contract,proto3" json:"contract,omitempty"`
Payload *MapAssetInfo `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
}
func (x *Event) Reset() {
*x = Event{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Event) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Event) ProtoMessage() {}
func (x *Event) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Event.ProtoReflect.Descriptor instead.
func (*Event) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{4}
}
func (x *Event) GetTxID() string {
if x != nil {
return x.TxID
}
return ""
}
func (x *Event) GetBlockNumber() uint64 {
if x != nil {
return x.BlockNumber
}
return 0
}
func (x *Event) GetContract() *Contract {
if x != nil {
return x.Contract
}
return nil
}
func (x *Event) GetPayload() *MapAssetInfo {
if x != nil {
return x.Payload
}
return nil
}
type MapAssetInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
EventType EventType `protobuf:"varint,1,opt,name=eventType,proto3,enum=types.EventType" json:"eventType,omitempty"`
LockAddress string `protobuf:"bytes,4,opt,name=lockAddress,proto3" json:"lockAddress,omitempty"`
LockAmount int64 `protobuf:"varint,5,opt,name=lockAmount,proto3" json:"lockAmount,omitempty"`
MintAddress string `protobuf:"bytes,6,opt,name=mintAddress,proto3" json:"mintAddress,omitempty"`
MintAmount int64 `protobuf:"varint,7,opt,name=mintAmount,proto3" json:"mintAmount,omitempty"`
UnlockAddress string `protobuf:"bytes,8,opt,name=unlockAddress,proto3" json:"unlockAddress,omitempty"`
UnlockAmount int64 `protobuf:"varint,9,opt,name=unlockAmount,proto3" json:"unlockAmount,omitempty"`
BurnAddress string `protobuf:"bytes,10,opt,name=burnAddress,proto3" json:"burnAddress,omitempty"`
BurnAmount int64 `protobuf:"varint,11,opt,name=burnAmount,proto3" json:"burnAmount,omitempty"`
Symbol string `protobuf:"bytes,12,opt,name=symbol,proto3" json:"symbol,omitempty"`
Extra []byte `protobuf:"bytes,13,opt,name=extra,proto3" json:"extra,omitempty"`
}
func (x *MapAssetInfo) Reset() {
*x = MapAssetInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MapAssetInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MapAssetInfo) ProtoMessage() {}
func (x *MapAssetInfo) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use MapAssetInfo.ProtoReflect.Descriptor instead.
func (*MapAssetInfo) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{5}
}
func (x *MapAssetInfo) GetEventType() EventType {
if x != nil {
return x.EventType
}
return EventType_Lock
}
func (x *MapAssetInfo) GetLockAddress() string {
if x != nil {
return x.LockAddress
}
return ""
}
func (x *MapAssetInfo) GetLockAmount() int64 {
if x != nil {
return x.LockAmount
}
return 0
}
func (x *MapAssetInfo) GetMintAddress() string {
if x != nil {
return x.MintAddress
}
return ""
}
func (x *MapAssetInfo) GetMintAmount() int64 {
if x != nil {
return x.MintAmount
}
return 0
}
func (x *MapAssetInfo) GetUnlockAddress() string {
if x != nil {
return x.UnlockAddress
}
return ""
}
func (x *MapAssetInfo) GetUnlockAmount() int64 {
if x != nil {
return x.UnlockAmount
}
return 0
}
func (x *MapAssetInfo) GetBurnAddress() string {
if x != nil {
return x.BurnAddress
}
return ""
}
func (x *MapAssetInfo) GetBurnAmount() int64 {
if x != nil {
return x.BurnAmount
}
return 0
}
func (x *MapAssetInfo) GetSymbol() string {
if x != nil {
return x.Symbol
}
return ""
}
func (x *MapAssetInfo) GetExtra() []byte {
if x != nil {
return x.Extra
}
return nil
}
type Contract struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"`
ExecName string `protobuf:"bytes,2,opt,name=execName,proto3" json:"execName,omitempty"`
Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
CallMethod string `protobuf:"bytes,4,opt,name=callMethod,proto3" json:"callMethod,omitempty"`
}
func (x *Contract) Reset() {
*x = Contract{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Contract) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Contract) ProtoMessage() {}
func (x *Contract) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Contract.ProtoReflect.Descriptor instead.
func (*Contract) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{6}
}
func (x *Contract) GetChainID() string {
if x != nil {
return x.ChainID
}
return ""
}
func (x *Contract) GetExecName() string {
if x != nil {
return x.ExecName
}
return ""
}
func (x *Contract) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
func (x *Contract) GetCallMethod() string {
if x != nil {
return x.CallMethod
}
return ""
}
type EventPair struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FromEvent *Event `protobuf:"bytes,1,opt,name=fromEvent,proto3" json:"fromEvent,omitempty"`
ToEvent *Event `protobuf:"bytes,2,opt,name=toEvent,proto3" json:"toEvent,omitempty"`
}
func (x *EventPair) Reset() {
*x = EventPair{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EventPair) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EventPair) ProtoMessage() {}
func (x *EventPair) ProtoReflect() protoreflect.Message {
mi := &file_proto_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EventPair.ProtoReflect.Descriptor instead.
func (*EventPair) Descriptor() ([]byte, []int) {
return file_proto_proto_rawDescGZIP(), []int{7}
}
func (x *EventPair) GetFromEvent() *Event {
if x != nil {
return x.FromEvent
}
return nil
}
func (x *EventPair) GetToEvent() *Event {
if x != nil {
return x.ToEvent
}
return nil
}
var File_proto_proto protoreflect.FileDescriptor
var file_proto_proto_rawDesc = []byte{
0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x74,
0x79, 0x70, 0x65, 0x73, 0x22, 0x29, 0x0a, 0x03, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x05, 0x65,
0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22,
0x50, 0x0a, 0x03, 0x52, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x22, 0x41, 0x0a, 0x03, 0x52, 0x65, 0x74, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x22, 0x7c, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e,
0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x20,
0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44,
0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x12, 0x22,
0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e,
0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65,
0x6e, 0x74, 0x22, 0x99, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x78, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44,
0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18,
0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x12, 0x2b, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6e,
0x74, 0x72, 0x61, 0x63, 0x74, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x12,
0x2d, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x13, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4d, 0x61, 0x70, 0x41, 0x73, 0x73, 0x65,
0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xfc,
0x02, 0x0a, 0x0c, 0x4d, 0x61, 0x70, 0x41, 0x73, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12,
0x2e, 0x0a, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x10, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12,
0x20, 0x0a, 0x0b, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73,
0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18,
0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
0x74, 0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72,
0x65, 0x73, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6d, 0x6f,
0x75, 0x6e, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x64, 0x64,
0x72, 0x65, 0x73, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x75, 0x6e, 0x6c, 0x6f,
0x63, 0x6b, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x6e, 0x6c,
0x6f, 0x63, 0x6b, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,
0x0c, 0x75, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x20, 0x0a,
0x0b, 0x62, 0x75, 0x72, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x62, 0x75, 0x72, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12,
0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x72, 0x6e, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0a, 0x62, 0x75, 0x72, 0x6e, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12,
0x16, 0x0a, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61,
0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x7a, 0x0a,
0x08, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61,
0x69, 0x6e, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69,
0x6e, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x78, 0x65, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x61, 0x6c,
0x6c, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63,
0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22, 0x5f, 0x0a, 0x09, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x50, 0x61, 0x69, 0x72, 0x12, 0x2a, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x74, 0x79, 0x70, 0x65,
0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x74, 0x6f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x52, 0x07, 0x74, 0x6f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2a, 0x2a, 0x0a, 0x06, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x72, 0x75, 0x65, 0x10, 0x00, 0x12, 0x09,
0x0a, 0x05, 0x46, 0x61, 0x6c, 0x73, 0x65, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x54, 0x69, 0x6d,
0x65, 0x4f, 0x75, 0x74, 0x10, 0x02, 0x2a, 0x35, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54,
0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x6f, 0x63, 0x6b, 0x10, 0x00, 0x12, 0x08, 0x0a,
0x04, 0x4d, 0x69, 0x6e, 0x74, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x6e, 0x4c, 0x6f, 0x63,
0x6b, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x75, 0x72, 0x6e, 0x10, 0x03, 0x42, 0x0a, 0x5a,
0x08, 0x2e, 0x2e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
file_proto_proto_rawDescOnce sync.Once
file_proto_proto_rawDescData = file_proto_proto_rawDesc
)
func file_proto_proto_rawDescGZIP() []byte {
file_proto_proto_rawDescOnce.Do(func() {
file_proto_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_proto_rawDescData)
})
return file_proto_proto_rawDescData
}
var (
file_proto_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
file_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
file_proto_proto_goTypes = []interface{}{
(Status)(0), // 0: types.Status
(EventType)(0), // 1: types.EventType
(*Req)(nil), // 2: types.Req
(*Res)(nil), // 3: types.Res
(*Ret)(nil), // 4: types.Ret
(*Record)(nil), // 5: types.Record
(*Event)(nil), // 6: types.Event
(*MapAssetInfo)(nil), // 7: types.MapAssetInfo
(*Contract)(nil), // 8: types.Contract
(*EventPair)(nil), // 9: types.EventPair
}
)
var file_proto_proto_depIdxs = []int32{
6, // 0: types.Req.event:type_name -> types.Event
6, // 1: types.Res.event:type_name -> types.Event
0, // 2: types.Res.status:type_name -> types.Status
6, // 3: types.Ret.event:type_name -> types.Event
6, // 4: types.Record.event:type_name -> types.Event
8, // 5: types.Event.contract:type_name -> types.Contract
7, // 6: types.Event.payload:type_name -> types.MapAssetInfo
1, // 7: types.MapAssetInfo.eventType:type_name -> types.EventType
6, // 8: types.EventPair.fromEvent:type_name -> types.Event
6, // 9: types.EventPair.toEvent:type_name -> types.Event
10, // [10:10] is the sub-list for method output_type
10, // [10:10] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_proto_proto_init() }
func file_proto_proto_init() {
if File_proto_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Req); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Res); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Ret); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Record); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Event); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MapAssetInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Contract); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventPair); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_proto_rawDesc,
NumEnums: 2,
NumMessages: 8,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_proto_proto_goTypes,
DependencyIndexes: file_proto_proto_depIdxs,
EnumInfos: file_proto_proto_enumTypes,
MessageInfos: file_proto_proto_msgTypes,
}.Build()
File_proto_proto = out.File
file_proto_proto_rawDesc = nil
file_proto_proto_goTypes = nil
file_proto_proto_depIdxs = nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment