Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
9dbe6796
Commit
9dbe6796
authored
Nov 20, 2018
by
gitlab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
cee84df9
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
67 additions
and
14 deletions
+67
-14
trade.go
plugin/dapp/trade/commands/trade.go
+1
-0
trade.go
plugin/dapp/trade/executor/trade.go
+2
-0
jrpc.go
plugin/dapp/trade/rpc/jrpc.go
+5
-0
rpc.go
plugin/dapp/trade/rpc/rpc.go
+6
-0
types.go
plugin/dapp/trade/rpc/types.go
+4
-0
const.go
plugin/dapp/trade/types/const.go
+4
-0
errors.go
plugin/dapp/trade/types/errors.go
+14
-14
rpctrade.go
plugin/dapp/trade/types/rpctrade.go
+1
-0
trade.go
plugin/dapp/trade/types/trade.go
+24
-0
tx.go
plugin/dapp/trade/types/tx.go
+6
-0
No files found.
plugin/dapp/trade/commands/trade.go
View file @
9dbe6796
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
// TradeCmd : cmd related to trade,安装trade合约相关命令
// TradeCmd : cmd related to trade,安装trade合约相关命令
func
TradeCmd
()
*
cobra
.
Command
{
func
TradeCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
plugin/dapp/trade/executor/trade.go
View file @
9dbe6796
...
@@ -34,10 +34,12 @@ func init() {
...
@@ -34,10 +34,12 @@ func init() {
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
trade
{}))
ety
.
InitFuncList
(
types
.
ListMethod
(
&
trade
{}))
}
}
// Init : 注册当前trade合约
// Init : 注册当前trade合约
func
Init
(
name
string
,
sub
[]
byte
)
{
func
Init
(
name
string
,
sub
[]
byte
)
{
drivers
.
Register
(
GetName
(),
newTrade
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
drivers
.
Register
(
GetName
(),
newTrade
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
}
}
// GetName : 获取trade合约名字
// GetName : 获取trade合约名字
func
GetName
()
string
{
func
GetName
()
string
{
return
newTrade
()
.
GetName
()
return
newTrade
()
.
GetName
()
...
...
plugin/dapp/trade/rpc/jrpc.go
View file @
9dbe6796
...
@@ -37,6 +37,7 @@ func (jrpc *Jrpc) CreateRawTradeSellTx(in *ptypes.TradeSellTx, result *interface
...
@@ -37,6 +37,7 @@ func (jrpc *Jrpc) CreateRawTradeSellTx(in *ptypes.TradeSellTx, result *interface
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
return
nil
return
nil
}
}
//CreateRawTradeBuyTx : 创建购买token的未签名交易,向指定卖单发起购买
//CreateRawTradeBuyTx : 创建购买token的未签名交易,向指定卖单发起购买
func
(
jrpc
*
Jrpc
)
CreateRawTradeBuyTx
(
in
*
ptypes
.
TradeBuyTx
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
CreateRawTradeBuyTx
(
in
*
ptypes
.
TradeBuyTx
,
result
*
interface
{})
error
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -54,6 +55,7 @@ func (jrpc *Jrpc) CreateRawTradeBuyTx(in *ptypes.TradeBuyTx, result *interface{}
...
@@ -54,6 +55,7 @@ func (jrpc *Jrpc) CreateRawTradeBuyTx(in *ptypes.TradeBuyTx, result *interface{}
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
return
nil
return
nil
}
}
//CreateRawTradeRevokeTx : 取消指定卖单
//CreateRawTradeRevokeTx : 取消指定卖单
func
(
jrpc
*
Jrpc
)
CreateRawTradeRevokeTx
(
in
*
ptypes
.
TradeRevokeTx
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
CreateRawTradeRevokeTx
(
in
*
ptypes
.
TradeRevokeTx
,
result
*
interface
{})
error
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -70,6 +72,7 @@ func (jrpc *Jrpc) CreateRawTradeRevokeTx(in *ptypes.TradeRevokeTx, result *inter
...
@@ -70,6 +72,7 @@ func (jrpc *Jrpc) CreateRawTradeRevokeTx(in *ptypes.TradeRevokeTx, result *inter
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
return
nil
return
nil
}
}
//CreateRawTradeBuyLimitTx : 挂买单购买token
//CreateRawTradeBuyLimitTx : 挂买单购买token
func
(
jrpc
*
Jrpc
)
CreateRawTradeBuyLimitTx
(
in
*
ptypes
.
TradeBuyLimitTx
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
CreateRawTradeBuyLimitTx
(
in
*
ptypes
.
TradeBuyLimitTx
,
result
*
interface
{})
error
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -91,6 +94,7 @@ func (jrpc *Jrpc) CreateRawTradeBuyLimitTx(in *ptypes.TradeBuyLimitTx, result *i
...
@@ -91,6 +94,7 @@ func (jrpc *Jrpc) CreateRawTradeBuyLimitTx(in *ptypes.TradeBuyLimitTx, result *i
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
return
nil
return
nil
}
}
//CreateRawTradeSellMarketTx : 向指定买单出售token
//CreateRawTradeSellMarketTx : 向指定买单出售token
func
(
jrpc
*
Jrpc
)
CreateRawTradeSellMarketTx
(
in
*
ptypes
.
TradeSellMarketTx
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
CreateRawTradeSellMarketTx
(
in
*
ptypes
.
TradeSellMarketTx
,
result
*
interface
{})
error
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -108,6 +112,7 @@ func (jrpc *Jrpc) CreateRawTradeSellMarketTx(in *ptypes.TradeSellMarketTx, resul
...
@@ -108,6 +112,7 @@ func (jrpc *Jrpc) CreateRawTradeSellMarketTx(in *ptypes.TradeSellMarketTx, resul
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
*
result
=
hex
.
EncodeToString
(
reply
.
Data
)
return
nil
return
nil
}
}
//CreateRawTradeRevokeBuyTx : 取消指定买单
//CreateRawTradeRevokeBuyTx : 取消指定买单
func
(
jrpc
*
Jrpc
)
CreateRawTradeRevokeBuyTx
(
in
*
ptypes
.
TradeRevokeBuyTx
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
CreateRawTradeRevokeBuyTx
(
in
*
ptypes
.
TradeRevokeBuyTx
,
result
*
interface
{})
error
{
if
in
==
nil
{
if
in
==
nil
{
...
...
plugin/dapp/trade/rpc/rpc.go
View file @
9dbe6796
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/trade/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/trade/types"
)
)
//CreateRawTradeSellTx :
//CreateRawTradeSellTx :
func
(
cc
*
channelClient
)
CreateRawTradeSellTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForSell
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeSellTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForSell
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -26,6 +27,7 @@ func (cc *channelClient) CreateRawTradeSellTx(ctx context.Context, in *ptypes.Tr
...
@@ -26,6 +27,7 @@ func (cc *channelClient) CreateRawTradeSellTx(ctx context.Context, in *ptypes.Tr
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
//CreateRawTradeBuyTx :
//CreateRawTradeBuyTx :
func
(
cc
*
channelClient
)
CreateRawTradeBuyTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForBuy
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeBuyTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForBuy
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -42,6 +44,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra
...
@@ -42,6 +44,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
//CreateRawTradeRevokeTx :
//CreateRawTradeRevokeTx :
func
(
cc
*
channelClient
)
CreateRawTradeRevokeTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForRevokeSell
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeRevokeTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForRevokeSell
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -58,6 +61,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes.
...
@@ -58,6 +61,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes.
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
//CreateRawTradeBuyLimitTx :
//CreateRawTradeBuyLimitTx :
func
(
cc
*
channelClient
)
CreateRawTradeBuyLimitTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForBuyLimit
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeBuyLimitTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForBuyLimit
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -74,6 +78,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype
...
@@ -74,6 +78,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
//CreateRawTradeSellMarketTx :
//CreateRawTradeSellMarketTx :
func
(
cc
*
channelClient
)
CreateRawTradeSellMarketTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForSellMarket
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeSellMarketTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForSellMarket
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
@@ -90,6 +95,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty
...
@@ -90,6 +95,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
//CreateRawTradeRevokeBuyTx :
//CreateRawTradeRevokeBuyTx :
func
(
cc
*
channelClient
)
CreateRawTradeRevokeBuyTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForRevokeBuy
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
cc
*
channelClient
)
CreateRawTradeRevokeBuyTx
(
ctx
context
.
Context
,
in
*
ptypes
.
TradeForRevokeBuy
)
(
*
types
.
UnsignTx
,
error
)
{
if
in
==
nil
{
if
in
==
nil
{
...
...
plugin/dapp/trade/rpc/types.go
View file @
9dbe6796
...
@@ -13,14 +13,17 @@ import (
...
@@ -13,14 +13,17 @@ import (
type
channelClient
struct
{
type
channelClient
struct
{
rpctypes
.
ChannelClient
rpctypes
.
ChannelClient
}
}
//Jrpc : Jrpc struct definition
//Jrpc : Jrpc struct definition
type
Jrpc
struct
{
type
Jrpc
struct
{
cli
*
channelClient
cli
*
channelClient
}
}
//Grpc : Grpc struct definition
//Grpc : Grpc struct definition
type
Grpc
struct
{
type
Grpc
struct
{
*
channelClient
*
channelClient
}
}
//Init : do the init operation
//Init : do the init operation
func
Init
(
name
string
,
s
rpctypes
.
RPCServer
)
{
func
Init
(
name
string
,
s
rpctypes
.
RPCServer
)
{
cli
:=
&
channelClient
{}
cli
:=
&
channelClient
{}
...
@@ -28,6 +31,7 @@ func Init(name string, s rpctypes.RPCServer) {
...
@@ -28,6 +31,7 @@ func Init(name string, s rpctypes.RPCServer) {
cli
.
Init
(
name
,
s
,
&
Jrpc
{
cli
:
cli
},
grpc
)
cli
.
Init
(
name
,
s
,
&
Jrpc
{
cli
:
cli
},
grpc
)
ptypes
.
RegisterTradeServer
(
s
.
GRPC
(),
grpc
)
ptypes
.
RegisterTradeServer
(
s
.
GRPC
(),
grpc
)
}
}
//GetLastMemPool : get the last memory pool
//GetLastMemPool : get the last memory pool
func
(
jrpc
*
Jrpc
)
GetLastMemPool
(
in
types
.
ReqNil
,
result
*
interface
{})
error
{
func
(
jrpc
*
Jrpc
)
GetLastMemPool
(
in
types
.
ReqNil
,
result
*
interface
{})
error
{
reply
,
err
:=
jrpc
.
cli
.
GetLastMempool
()
reply
,
err
:=
jrpc
.
cli
.
GetLastMempool
()
...
...
plugin/dapp/trade/types/const.go
View file @
9dbe6796
...
@@ -36,6 +36,7 @@ const (
...
@@ -36,6 +36,7 @@ const (
TradeOrderStatusBoughtOut
TradeOrderStatusBoughtOut
TradeOrderStatusBuyRevoked
TradeOrderStatusBuyRevoked
)
)
//SellOrderStatus : sell order status map
//SellOrderStatus : sell order status map
var
SellOrderStatus
=
map
[
int32
]
string
{
var
SellOrderStatus
=
map
[
int32
]
string
{
TradeOrderStatusNotStart
:
"NotStart"
,
TradeOrderStatusNotStart
:
"NotStart"
,
...
@@ -47,6 +48,7 @@ var SellOrderStatus = map[int32]string{
...
@@ -47,6 +48,7 @@ var SellOrderStatus = map[int32]string{
TradeOrderStatusBoughtOut
:
"BoughtOut"
,
TradeOrderStatusBoughtOut
:
"BoughtOut"
,
TradeOrderStatusBuyRevoked
:
"BuyRevoked"
,
TradeOrderStatusBuyRevoked
:
"BuyRevoked"
,
}
}
//SellOrderStatus2Int : SellOrderStatus info to value in int32
//SellOrderStatus2Int : SellOrderStatus info to value in int32
var
SellOrderStatus2Int
=
map
[
string
]
int32
{
var
SellOrderStatus2Int
=
map
[
string
]
int32
{
"NotStart"
:
TradeOrderStatusNotStart
,
"NotStart"
:
TradeOrderStatusNotStart
,
...
@@ -58,12 +60,14 @@ var SellOrderStatus2Int = map[string]int32{
...
@@ -58,12 +60,14 @@ var SellOrderStatus2Int = map[string]int32{
"BoughtOut"
:
TradeOrderStatusBoughtOut
,
"BoughtOut"
:
TradeOrderStatusBoughtOut
,
"BuyRevoked"
:
TradeOrderStatusBuyRevoked
,
"BuyRevoked"
:
TradeOrderStatusBuyRevoked
,
}
}
//MapSellOrderStatusStr2Int :
//MapSellOrderStatusStr2Int :
var
MapSellOrderStatusStr2Int
=
map
[
string
]
int32
{
var
MapSellOrderStatusStr2Int
=
map
[
string
]
int32
{
"onsale"
:
TradeOrderStatusOnSale
,
"onsale"
:
TradeOrderStatusOnSale
,
"soldout"
:
TradeOrderStatusSoldOut
,
"soldout"
:
TradeOrderStatusSoldOut
,
"revoked"
:
TradeOrderStatusRevoked
,
"revoked"
:
TradeOrderStatusRevoked
,
}
}
//MapBuyOrderStatusStr2Int :
//MapBuyOrderStatusStr2Int :
var
MapBuyOrderStatusStr2Int
=
map
[
string
]
int32
{
var
MapBuyOrderStatusStr2Int
=
map
[
string
]
int32
{
"onbuy"
:
TradeOrderStatusOnBuy
,
"onbuy"
:
TradeOrderStatusOnBuy
,
...
...
plugin/dapp/trade/types/errors.go
View file @
9dbe6796
...
@@ -8,33 +8,33 @@ import "errors"
...
@@ -8,33 +8,33 @@ import "errors"
var
(
var
(
//ErrTSellBalanceNotEnough :
//ErrTSellBalanceNotEnough :
ErrTSellBalanceNotEnough
=
errors
.
New
(
"ErrTradeSellBalanceNotEnough"
)
ErrTSellBalanceNotEnough
=
errors
.
New
(
"ErrTradeSellBalanceNotEnough"
)
//ErrTSellOrderNotExist :
//ErrTSellOrderNotExist :
ErrTSellOrderNotExist
=
errors
.
New
(
"ErrTradeSellOrderNotExist"
)
ErrTSellOrderNotExist
=
errors
.
New
(
"ErrTradeSellOrderNotExist"
)
//ErrTSellOrderNotStart :
//ErrTSellOrderNotStart :
ErrTSellOrderNotStart
=
errors
.
New
(
"ErrTradeSellOrderNotStart"
)
ErrTSellOrderNotStart
=
errors
.
New
(
"ErrTradeSellOrderNotStart"
)
//ErrTSellOrderNotEnough :
//ErrTSellOrderNotEnough :
ErrTSellOrderNotEnough
=
errors
.
New
(
"ErrTradeSellOrderNotEnough"
)
ErrTSellOrderNotEnough
=
errors
.
New
(
"ErrTradeSellOrderNotEnough"
)
//ErrTSellOrderSoldout :
//ErrTSellOrderSoldout :
ErrTSellOrderSoldout
=
errors
.
New
(
"ErrTradeSellOrderSoldout"
)
ErrTSellOrderSoldout
=
errors
.
New
(
"ErrTradeSellOrderSoldout"
)
//ErrTSellOrderRevoked :
//ErrTSellOrderRevoked :
ErrTSellOrderRevoked
=
errors
.
New
(
"ErrTradeSellOrderRevoked"
)
ErrTSellOrderRevoked
=
errors
.
New
(
"ErrTradeSellOrderRevoked"
)
//ErrTSellOrderExpired :
//ErrTSellOrderExpired :
ErrTSellOrderExpired
=
errors
.
New
(
"ErrTradeSellOrderExpired"
)
ErrTSellOrderExpired
=
errors
.
New
(
"ErrTradeSellOrderExpired"
)
//ErrTSellOrderRevoke :
//ErrTSellOrderRevoke :
ErrTSellOrderRevoke
=
errors
.
New
(
"ErrTradeSellOrderRevokeNotAllowed"
)
ErrTSellOrderRevoke
=
errors
.
New
(
"ErrTradeSellOrderRevokeNotAllowed"
)
//ErrTSellNoSuchOrder :
//ErrTSellNoSuchOrder :
ErrTSellNoSuchOrder
=
errors
.
New
(
"ErrTradeSellNoSuchOrder"
)
ErrTSellNoSuchOrder
=
errors
.
New
(
"ErrTradeSellNoSuchOrder"
)
//ErrTBuyOrderNotExist :
//ErrTBuyOrderNotExist :
ErrTBuyOrderNotExist
=
errors
.
New
(
"ErrTradeBuyOrderNotExist"
)
ErrTBuyOrderNotExist
=
errors
.
New
(
"ErrTradeBuyOrderNotExist"
)
//ErrTBuyOrderNotEnough :
//ErrTBuyOrderNotEnough :
ErrTBuyOrderNotEnough
=
errors
.
New
(
"ErrTradeBuyOrderNotEnough"
)
ErrTBuyOrderNotEnough
=
errors
.
New
(
"ErrTradeBuyOrderNotEnough"
)
//ErrTBuyOrderSoldout :
//ErrTBuyOrderSoldout :
ErrTBuyOrderSoldout
=
errors
.
New
(
"ErrTradeBuyOrderSoldout"
)
ErrTBuyOrderSoldout
=
errors
.
New
(
"ErrTradeBuyOrderSoldout"
)
//ErrTBuyOrderRevoked :
//ErrTBuyOrderRevoked :
ErrTBuyOrderRevoked
=
errors
.
New
(
"ErrTradeBuyOrderRevoked"
)
ErrTBuyOrderRevoked
=
errors
.
New
(
"ErrTradeBuyOrderRevoked"
)
//ErrTBuyOrderRevoke :
//ErrTBuyOrderRevoke :
ErrTBuyOrderRevoke
=
errors
.
New
(
"ErrTradeBuyOrderRevokeNotAllowed"
)
ErrTBuyOrderRevoke
=
errors
.
New
(
"ErrTradeBuyOrderRevokeNotAllowed"
)
//ErrTCntLessThanMinBoardlot :
//ErrTCntLessThanMinBoardlot :
ErrTCntLessThanMinBoardlot
=
errors
.
New
(
"ErrTradeCountLessThanMinBoardlot"
)
ErrTCntLessThanMinBoardlot
=
errors
.
New
(
"ErrTradeCountLessThanMinBoardlot"
)
)
)
plugin/dapp/trade/types/rpctrade.go
View file @
9dbe6796
...
@@ -27,6 +27,7 @@ type RPCReplyTradeOrder struct {
...
@@ -27,6 +27,7 @@ type RPCReplyTradeOrder struct {
IsSellOrder
bool
`protobuf:"varint,15,opt,name=isSellOrder" json:"isSellOrder"`
IsSellOrder
bool
`protobuf:"varint,15,opt,name=isSellOrder" json:"isSellOrder"`
AssetExec
string
`protobuf:"bytes,16,opt,name=assetExec" json:"assetExec"`
AssetExec
string
`protobuf:"bytes,16,opt,name=assetExec" json:"assetExec"`
}
}
//MarshalJSON :
//MarshalJSON :
func
(
reply
*
ReplyTradeOrder
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
reply
*
ReplyTradeOrder
)
MarshalJSON
()
([]
byte
,
error
)
{
r
:=
(
*
RPCReplyTradeOrder
)(
reply
)
r
:=
(
*
RPCReplyTradeOrder
)(
reply
)
...
...
plugin/dapp/trade/types/trade.go
View file @
9dbe6796
...
@@ -69,6 +69,7 @@ func newType() *tradeType {
...
@@ -69,6 +69,7 @@ func newType() *tradeType {
func
(
t
*
tradeType
)
GetPayload
()
types
.
Message
{
func
(
t
*
tradeType
)
GetPayload
()
types
.
Message
{
return
&
Trade
{}
return
&
Trade
{}
}
}
//ActionName :
//ActionName :
func
(
t
*
tradeType
)
ActionName
(
tx
*
types
.
Transaction
)
string
{
func
(
t
*
tradeType
)
ActionName
(
tx
*
types
.
Transaction
)
string
{
var
action
Trade
var
action
Trade
...
@@ -166,6 +167,7 @@ func (t *tradeType) CreateTx(action string, message json.RawMessage) (*types.Tra
...
@@ -166,6 +167,7 @@ func (t *tradeType) CreateTx(action string, message json.RawMessage) (*types.Tra
return
tx
,
nil
return
tx
,
nil
}
}
//CreateRawTradeSellTx : 创建卖单交易
//CreateRawTradeSellTx : 创建卖单交易
func
CreateRawTradeSellTx
(
parm
*
TradeSellTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeSellTx
(
parm
*
TradeSellTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -188,6 +190,7 @@ func CreateRawTradeSellTx(parm *TradeSellTx) (*types.Transaction, error) {
...
@@ -188,6 +190,7 @@ func CreateRawTradeSellTx(parm *TradeSellTx) (*types.Transaction, error) {
}
}
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
sell
))
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
sell
))
}
}
//CreateRawTradeBuyTx :创建想指定卖单发起的买单交易
//CreateRawTradeBuyTx :创建想指定卖单发起的买单交易
func
CreateRawTradeBuyTx
(
parm
*
TradeBuyTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeBuyTx
(
parm
*
TradeBuyTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -200,6 +203,7 @@ func CreateRawTradeBuyTx(parm *TradeBuyTx) (*types.Transaction, error) {
...
@@ -200,6 +203,7 @@ func CreateRawTradeBuyTx(parm *TradeBuyTx) (*types.Transaction, error) {
}
}
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buy
))
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buy
))
}
}
//CreateRawTradeRevokeTx :创建取消卖单的交易
//CreateRawTradeRevokeTx :创建取消卖单的交易
func
CreateRawTradeRevokeTx
(
parm
*
TradeRevokeTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeRevokeTx
(
parm
*
TradeRevokeTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -213,6 +217,7 @@ func CreateRawTradeRevokeTx(parm *TradeRevokeTx) (*types.Transaction, error) {
...
@@ -213,6 +217,7 @@ func CreateRawTradeRevokeTx(parm *TradeRevokeTx) (*types.Transaction, error) {
}
}
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buy
))
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buy
))
}
}
//CreateRawTradeBuyLimitTx :创建买单交易
//CreateRawTradeBuyLimitTx :创建买单交易
func
CreateRawTradeBuyLimitTx
(
parm
*
TradeBuyLimitTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeBuyLimitTx
(
parm
*
TradeBuyLimitTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -232,6 +237,7 @@ func CreateRawTradeBuyLimitTx(parm *TradeBuyLimitTx) (*types.Transaction, error)
...
@@ -232,6 +237,7 @@ func CreateRawTradeBuyLimitTx(parm *TradeBuyLimitTx) (*types.Transaction, error)
}
}
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buyLimit
))
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
buyLimit
))
}
}
//CreateRawTradeSellMarketTx : 创建向指定买单出售token的卖单交易
//CreateRawTradeSellMarketTx : 创建向指定买单出售token的卖单交易
func
CreateRawTradeSellMarketTx
(
parm
*
TradeSellMarketTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeSellMarketTx
(
parm
*
TradeSellMarketTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -244,6 +250,7 @@ func CreateRawTradeSellMarketTx(parm *TradeSellMarketTx) (*types.Transaction, er
...
@@ -244,6 +250,7 @@ func CreateRawTradeSellMarketTx(parm *TradeSellMarketTx) (*types.Transaction, er
}
}
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
sellMarket
))
return
types
.
CreateFormatTx
(
types
.
ExecName
(
TradeX
),
types
.
Encode
(
sellMarket
))
}
}
//CreateRawTradeRevokeBuyTx : 取消发起的买单交易
//CreateRawTradeRevokeBuyTx : 取消发起的买单交易
func
CreateRawTradeRevokeBuyTx
(
parm
*
TradeRevokeBuyTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawTradeRevokeBuyTx
(
parm
*
TradeRevokeBuyTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
...
@@ -261,10 +268,12 @@ func CreateRawTradeRevokeBuyTx(parm *TradeRevokeBuyTx) (*types.Transaction, erro
...
@@ -261,10 +268,12 @@ func CreateRawTradeRevokeBuyTx(parm *TradeRevokeBuyTx) (*types.Transaction, erro
// TradeSellLimitLog :
// TradeSellLimitLog :
type
TradeSellLimitLog
struct
{
type
TradeSellLimitLog
struct
{
}
}
//Name : get name string of TradeSellLimitLog
//Name : get name string of TradeSellLimitLog
func
(
l
TradeSellLimitLog
)
Name
()
string
{
func
(
l
TradeSellLimitLog
)
Name
()
string
{
return
"LogTradeSell"
return
"LogTradeSell"
}
}
//Decode : decode the log
//Decode : decode the log
func
(
l
TradeSellLimitLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeSellLimitLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptTradeSellLimit
var
logTmp
ReceiptTradeSellLimit
...
@@ -274,13 +283,16 @@ func (l TradeSellLimitLog) Decode(msg []byte) (interface{}, error) {
...
@@ -274,13 +283,16 @@ func (l TradeSellLimitLog) Decode(msg []byte) (interface{}, error) {
}
}
return
logTmp
,
err
return
logTmp
,
err
}
}
//TradeSellMarketLog :
//TradeSellMarketLog :
type
TradeSellMarketLog
struct
{
type
TradeSellMarketLog
struct
{
}
}
//Name :
//Name :
func
(
l
TradeSellMarketLog
)
Name
()
string
{
func
(
l
TradeSellMarketLog
)
Name
()
string
{
return
"LogTradeSellMarket"
return
"LogTradeSellMarket"
}
}
//Decode :
//Decode :
func
(
l
TradeSellMarketLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeSellMarketLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptSellMarket
var
logTmp
ReceiptSellMarket
...
@@ -290,13 +302,16 @@ func (l TradeSellMarketLog) Decode(msg []byte) (interface{}, error) {
...
@@ -290,13 +302,16 @@ func (l TradeSellMarketLog) Decode(msg []byte) (interface{}, error) {
}
}
return
logTmp
,
err
return
logTmp
,
err
}
}
//TradeBuyMarketLog :
//TradeBuyMarketLog :
type
TradeBuyMarketLog
struct
{
type
TradeBuyMarketLog
struct
{
}
}
//Name :
//Name :
func
(
l
TradeBuyMarketLog
)
Name
()
string
{
func
(
l
TradeBuyMarketLog
)
Name
()
string
{
return
"LogTradeBuyMarket"
return
"LogTradeBuyMarket"
}
}
//Decode :
//Decode :
func
(
l
TradeBuyMarketLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeBuyMarketLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptTradeBuyMarket
var
logTmp
ReceiptTradeBuyMarket
...
@@ -306,13 +321,16 @@ func (l TradeBuyMarketLog) Decode(msg []byte) (interface{}, error) {
...
@@ -306,13 +321,16 @@ func (l TradeBuyMarketLog) Decode(msg []byte) (interface{}, error) {
}
}
return
logTmp
,
err
return
logTmp
,
err
}
}
//TradeBuyLimitLog :
//TradeBuyLimitLog :
type
TradeBuyLimitLog
struct
{
type
TradeBuyLimitLog
struct
{
}
}
//Name :
//Name :
func
(
l
TradeBuyLimitLog
)
Name
()
string
{
func
(
l
TradeBuyLimitLog
)
Name
()
string
{
return
"LogTradeBuyLimit"
return
"LogTradeBuyLimit"
}
}
//Decode :
//Decode :
func
(
l
TradeBuyLimitLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeBuyLimitLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptTradeBuyLimit
var
logTmp
ReceiptTradeBuyLimit
...
@@ -322,13 +340,16 @@ func (l TradeBuyLimitLog) Decode(msg []byte) (interface{}, error) {
...
@@ -322,13 +340,16 @@ func (l TradeBuyLimitLog) Decode(msg []byte) (interface{}, error) {
}
}
return
logTmp
,
err
return
logTmp
,
err
}
}
//TradeBuyRevokeLog :
//TradeBuyRevokeLog :
type
TradeBuyRevokeLog
struct
{
type
TradeBuyRevokeLog
struct
{
}
}
//Name :
//Name :
func
(
l
TradeBuyRevokeLog
)
Name
()
string
{
func
(
l
TradeBuyRevokeLog
)
Name
()
string
{
return
"LogTradeBuyRevoke"
return
"LogTradeBuyRevoke"
}
}
//Decode :
//Decode :
func
(
l
TradeBuyRevokeLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeBuyRevokeLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptTradeBuyRevoke
var
logTmp
ReceiptTradeBuyRevoke
...
@@ -338,13 +359,16 @@ func (l TradeBuyRevokeLog) Decode(msg []byte) (interface{}, error) {
...
@@ -338,13 +359,16 @@ func (l TradeBuyRevokeLog) Decode(msg []byte) (interface{}, error) {
}
}
return
logTmp
,
err
return
logTmp
,
err
}
}
//TradeSellRevokeLog :
//TradeSellRevokeLog :
type
TradeSellRevokeLog
struct
{
type
TradeSellRevokeLog
struct
{
}
}
//Name :
//Name :
func
(
l
TradeSellRevokeLog
)
Name
()
string
{
func
(
l
TradeSellRevokeLog
)
Name
()
string
{
return
"LogTradeSellRevoke"
return
"LogTradeSellRevoke"
}
}
//Decode :
//Decode :
func
(
l
TradeSellRevokeLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
func
(
l
TradeSellRevokeLog
)
Decode
(
msg
[]
byte
)
(
interface
{},
error
)
{
var
logTmp
ReceiptTradeSellRevoke
var
logTmp
ReceiptTradeSellRevoke
...
...
plugin/dapp/trade/types/tx.go
View file @
9dbe6796
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
types
package
types
//TradeSellTx : info for sell order
//TradeSellTx : info for sell order
type
TradeSellTx
struct
{
type
TradeSellTx
struct
{
TokenSymbol
string
`json:"tokenSymbol"`
TokenSymbol
string
`json:"tokenSymbol"`
...
@@ -13,17 +14,20 @@ type TradeSellTx struct {
...
@@ -13,17 +14,20 @@ type TradeSellTx struct {
Fee
int64
`json:"fee"`
Fee
int64
`json:"fee"`
AssetExec
string
`json:"assetExec"`
AssetExec
string
`json:"assetExec"`
}
}
//TradeBuyTx :info for buy order to speficied order
//TradeBuyTx :info for buy order to speficied order
type
TradeBuyTx
struct
{
type
TradeBuyTx
struct
{
SellID
string
`json:"sellID"`
SellID
string
`json:"sellID"`
BoardlotCnt
int64
`json:"boardlotCnt"`
BoardlotCnt
int64
`json:"boardlotCnt"`
Fee
int64
`json:"fee"`
Fee
int64
`json:"fee"`
}
}
//TradeRevokeTx :用于取消卖单的信息
//TradeRevokeTx :用于取消卖单的信息
type
TradeRevokeTx
struct
{
type
TradeRevokeTx
struct
{
SellID
string
`json:"sellID,"`
SellID
string
`json:"sellID,"`
Fee
int64
`json:"fee"`
Fee
int64
`json:"fee"`
}
}
//TradeBuyLimitTx :用于挂买单的信息
//TradeBuyLimitTx :用于挂买单的信息
type
TradeBuyLimitTx
struct
{
type
TradeBuyLimitTx
struct
{
TokenSymbol
string
`json:"tokenSymbol"`
TokenSymbol
string
`json:"tokenSymbol"`
...
@@ -34,12 +38,14 @@ type TradeBuyLimitTx struct {
...
@@ -34,12 +38,14 @@ type TradeBuyLimitTx struct {
Fee
int64
`json:"fee"`
Fee
int64
`json:"fee"`
AssetExec
string
`json:"assetExec"`
AssetExec
string
`json:"assetExec"`
}
}
//TradeSellMarketTx :用于向指定买单出售token的信息
//TradeSellMarketTx :用于向指定买单出售token的信息
type
TradeSellMarketTx
struct
{
type
TradeSellMarketTx
struct
{
BuyID
string
`json:"buyID"`
BuyID
string
`json:"buyID"`
BoardlotCnt
int64
`json:"boardlotCnt"`
BoardlotCnt
int64
`json:"boardlotCnt"`
Fee
int64
`json:"fee"`
Fee
int64
`json:"fee"`
}
}
//TradeRevokeBuyTx :取消指定买单
//TradeRevokeBuyTx :取消指定买单
type
TradeRevokeBuyTx
struct
{
type
TradeRevokeBuyTx
struct
{
BuyID
string
`json:"buyID,"`
BuyID
string
`json:"buyID,"`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment