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
960d2433
Commit
960d2433
authored
Nov 03, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 add chain33cfg
parent
47977460
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
217 additions
and
115 deletions
+217
-115
cmd.go
plugin/dapp/collateralize/commands/cmd.go
+49
-7
collateralize.go
plugin/dapp/collateralize/executor/collateralize.go
+6
-4
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+60
-50
cmd.go
plugin/dapp/issuance/commands/cmd.go
+42
-6
issuance.go
plugin/dapp/issuance/executor/issuance.go
+6
-4
issuance.go
plugin/dapp/issuance/types/issuance.go
+54
-44
No files found.
plugin/dapp/collateralize/commands/cmd.go
View file @
960d2433
...
...
@@ -49,11 +49,17 @@ func addCollateralizeCreateFlags(cmd *cobra.Command) {
}
func
CollateralizeCreate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
balance
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"balance"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeCreate"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
totalBalance
\"
:%d}"
,
balance
)),
}
...
...
@@ -82,12 +88,18 @@ func addCollateralizeBorrowFlags(cmd *cobra.Command) {
}
func
CollateralizeBorrow
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
collateralizeID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"collateralizeID"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeBorrow"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
collateralizeID
\"
:
\"
%s
\"
,
\"
value
\"
:%d}"
,
collateralizeID
,
value
)),
}
...
...
@@ -118,13 +130,19 @@ func addCollateralizeAppendFlags(cmd *cobra.Command) {
}
func
CollateralizeAppend
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
collateralizeID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"collateralizeID"
)
recordID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"recordID"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeAppend"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
collateralizeID
\"
:
\"
%s
\"
,
\"
recordID
\"
:
\"
%s
\"
,
\"
value
\"
:%d}"
,
collateralizeID
,
recordID
,
value
)),
}
...
...
@@ -153,12 +171,18 @@ func addCollateralizeRepayFlags(cmd *cobra.Command) {
}
func
CollateralizeRepay
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
collateralizeID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"collateralizeID"
)
recordID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"recordID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeRepay"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
collateralizeID
\"
:
\"
%s
\"
,
\"
recordID
\"
:
\"
%s
\"
}"
,
collateralizeID
,
recordID
)),
}
...
...
@@ -187,12 +211,18 @@ func addCollateralizePriceFeedFlags(cmd *cobra.Command) {
}
func
CollateralizePriceFeed
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
price
,
_
:=
cmd
.
Flags
()
.
GetFloat32
(
"price"
)
volume
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"volume"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizePriceFeed"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
price
\"
:[ %f ],
\"
volume
\"
:[ %d ]}"
,
price
,
volume
)),
}
...
...
@@ -219,11 +249,17 @@ func addCollateralizeCloseFlags(cmd *cobra.Command) {
}
func
CollateralizeClose
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
collateralizeID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"collateralizeID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeClose"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
collateralizeID
\"
:
\"
%s
\"
}"
,
collateralizeID
)),
}
...
...
@@ -252,6 +288,12 @@ func addCollateralizeManageFlags(cmd *cobra.Command) {
}
func
CollateralizeManage
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
debtCeiling
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"debtCeiling"
)
liquidationRatio
,
_
:=
cmd
.
Flags
()
.
GetFloat32
(
"liquidationRatio"
)
...
...
@@ -259,7 +301,7 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
period
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"period"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
CollateralizeX
),
Execer
:
cfg
.
ExecName
(
pkt
.
CollateralizeX
),
ActionName
:
"CollateralizeManage"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
debtCeiling
\"
:%d,
\"
liquidationRatio
\"
:%f,
\"
stabilityFeeRatio
\"
:%f,
\"
period
\"
:%d}"
,
debtCeiling
,
liquidationRatio
,
stabilityFeeRatio
,
period
)),
...
...
plugin/dapp/collateralize/executor/collateralize.go
View file @
960d2433
...
...
@@ -14,7 +14,7 @@ import (
var
clog
=
log
.
New
(
"module"
,
"execs.collateralize"
)
var
driverName
=
pty
.
CollateralizeX
func
init
()
{
func
InitExecType
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Collateralize
{}))
}
...
...
@@ -26,7 +26,7 @@ type subConfig struct {
var
cfg
subConfig
// Init collateralize
func
Init
(
name
string
,
sub
[]
byte
)
{
func
Init
(
name
string
,
cfg
*
types
.
Chain33Config
,
sub
[]
byte
)
{
driverName
:=
GetName
()
if
name
!=
driverName
{
panic
(
"system dapp can't be rename"
)
...
...
@@ -34,7 +34,8 @@ func Init(name string, sub []byte) {
if
sub
!=
nil
{
types
.
MustDecode
(
sub
,
&
cfg
)
}
drivers
.
Register
(
driverName
,
newCollateralize
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
drivers
.
Register
(
cfg
,
driverName
,
newCollateralize
,
cfg
.
GetDappFork
(
driverName
,
"Enable"
))
InitExecType
()
}
// GetName for Collateralize
...
...
@@ -170,7 +171,8 @@ func (c *Collateralize) CheckReceiptExecOk() bool {
// ExecutorOrder 设置localdb的EnableRead
func
(
c
*
Collateralize
)
ExecutorOrder
()
int64
{
if
types
.
IsFork
(
c
.
GetHeight
(),
"ForkLocalDBAccess"
)
{
cfg
:=
c
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsFork
(
c
.
GetHeight
(),
"ForkLocalDBAccess"
)
{
return
drivers
.
ExecLocalSameTime
}
return
c
.
DriverBase
.
ExecutorOrder
()
...
...
plugin/dapp/collateralize/types/collateralize.go
View file @
960d2433
...
...
@@ -19,8 +19,16 @@ var (
func
init
()
{
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
CollateralizeX
))
types
.
RegistorExecutor
(
CollateralizeX
,
NewType
())
types
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
types
.
RegFork
(
CollateralizeX
,
InitFork
)
types
.
RegExec
(
CollateralizeX
,
InitExecutor
)
}
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
types
.
RegistorExecutor
(
CollateralizeX
,
NewType
(
cfg
))
}
// CollateralizeType def
...
...
@@ -29,19 +37,20 @@ type CollateralizeType struct {
}
// NewType method
func
NewType
()
*
CollateralizeType
{
func
NewType
(
cfg
*
types
.
Chain33Config
)
*
CollateralizeType
{
c
:=
&
CollateralizeType
{}
c
.
SetChild
(
c
)
c
.
SetConfig
(
cfg
)
return
c
}
// GetName 获取执行器名称
func
(
C
ollateralize
*
CollateralizeType
)
GetName
()
string
{
func
(
c
ollateralize
*
CollateralizeType
)
GetName
()
string
{
return
CollateralizeX
}
// GetLogMap method
func
(
C
ollateralize
*
CollateralizeType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
c
ollateralize
*
CollateralizeType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogCollateralizeCreate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptCollateralize
{}),
Name
:
"LogCollateralizeCreate"
},
TyLogCollateralizeBorrow
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptCollateralize
{}),
Name
:
"LogCollateralizeBorrow"
},
...
...
@@ -53,13 +62,14 @@ func (Collateralize *CollateralizeType) GetLogMap() map[int64]*types.LogInfo {
}
// GetPayload method
func
(
C
ollateralize
*
CollateralizeType
)
GetPayload
()
types
.
Message
{
func
(
c
ollateralize
*
CollateralizeType
)
GetPayload
()
types
.
Message
{
return
&
CollateralizeAction
{}
}
// CreateTx method
func
(
C
ollateralize
CollateralizeType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
func
(
c
ollateralize
CollateralizeType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
llog
.
Debug
(
"Collateralize.CreateTx"
,
"action"
,
action
)
cfg
:=
collateralize
.
GetConfig
()
if
action
==
"CollateralizeCreate"
{
var
param
CollateralizeCreateTx
...
...
@@ -68,7 +78,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeCreateTx
(
&
param
)
return
CreateRawCollateralizeCreateTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizeBorrow"
{
var
param
CollateralizeBorrowTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -76,7 +86,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeBorrowTx
(
&
param
)
return
CreateRawCollateralizeBorrowTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizeRepay"
{
var
param
CollateralizeRepayTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -84,7 +94,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeRepayTx
(
&
param
)
return
CreateRawCollateralizeRepayTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizeAppend"
{
var
param
CollateralizeAppendTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -92,7 +102,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeAppendTx
(
&
param
)
return
CreateRawCollateralizeAppendTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizePriceFeed"
{
var
param
CollateralizeFeedTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -100,7 +110,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeFeedTx
(
&
param
)
return
CreateRawCollateralizeFeedTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizeClose"
{
var
param
CollateralizeCloseTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -108,7 +118,7 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeCloseTx
(
&
param
)
return
CreateRawCollateralizeCloseTx
(
cfg
,
&
param
)
}
else
if
action
==
"CollateralizeManage"
{
var
param
CollateralizeManageTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -116,14 +126,14 @@ func (Collateralize CollateralizeType) CreateTx(action string, message json.RawM
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCollateralizeManageTx
(
&
param
)
return
CreateRawCollateralizeManageTx
(
cfg
,
&
param
)
}
else
{
return
nil
,
types
.
ErrNotSupport
}
}
// GetTypeMap method
func
(
C
ollateralize
CollateralizeType
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
c
ollateralize
CollateralizeType
)
GetTypeMap
()
map
[
string
]
int32
{
return
map
[
string
]
int32
{
"Create"
:
CollateralizeActionCreate
,
"Borrow"
:
CollateralizeActionBorrow
,
...
...
@@ -136,7 +146,7 @@ func (Collateralize CollateralizeType) GetTypeMap() map[string]int32 {
}
// CreateRawCollateralizeCreateTx method
func
CreateRawCollateralizeCreateTx
(
parm
*
CollateralizeCreateTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeCreateTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeCreateTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeCreateTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -150,13 +160,13 @@ func CreateRawCollateralizeCreateTx(parm *CollateralizeCreateTx) (*types.Transac
Value
:
&
CollateralizeAction_Create
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
create
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -164,7 +174,7 @@ func CreateRawCollateralizeCreateTx(parm *CollateralizeCreateTx) (*types.Transac
}
// CreateRawCollateralizeBorrowTx method
func
CreateRawCollateralizeBorrowTx
(
parm
*
CollateralizeBorrowTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeBorrowTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeBorrowTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeBorrowTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -179,13 +189,13 @@ func CreateRawCollateralizeBorrowTx(parm *CollateralizeBorrowTx) (*types.Transac
Value
:
&
CollateralizeAction_Borrow
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
borrow
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -193,7 +203,7 @@ func CreateRawCollateralizeBorrowTx(parm *CollateralizeBorrowTx) (*types.Transac
}
// CreateRawCollateralizeRepayTx method
func
CreateRawCollateralizeRepayTx
(
parm
*
CollateralizeRepayTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeRepayTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeRepayTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeRepayTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -208,13 +218,13 @@ func CreateRawCollateralizeRepayTx(parm *CollateralizeRepayTx) (*types.Transacti
Value
:
&
CollateralizeAction_Repay
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
repay
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -222,7 +232,7 @@ func CreateRawCollateralizeRepayTx(parm *CollateralizeRepayTx) (*types.Transacti
}
// CreateRawCollateralizeAppendTx method
func
CreateRawCollateralizeAppendTx
(
parm
*
CollateralizeAppendTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeAppendTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeAppendTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeAppendTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -238,13 +248,13 @@ func CreateRawCollateralizeAppendTx(parm *CollateralizeAppendTx) (*types.Transac
Value
:
&
CollateralizeAction_Append
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
append
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -252,7 +262,7 @@ func CreateRawCollateralizeAppendTx(parm *CollateralizeAppendTx) (*types.Transac
}
// CreateRawCollateralizeFeedTx method
func
CreateRawCollateralizeFeedTx
(
parm
*
CollateralizeFeedTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeFeedTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeFeedTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizePriceFeedTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -267,13 +277,13 @@ func CreateRawCollateralizeFeedTx(parm *CollateralizeFeedTx) (*types.Transaction
Value
:
&
CollateralizeAction_Feed
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
feed
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -281,7 +291,7 @@ func CreateRawCollateralizeFeedTx(parm *CollateralizeFeedTx) (*types.Transaction
}
// CreateRawCollateralizeCloseTx method
func
CreateRawCollateralizeCloseTx
(
parm
*
CollateralizeCloseTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeCloseTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeCloseTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeCloseTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -295,14 +305,14 @@ func CreateRawCollateralizeCloseTx(parm *CollateralizeCloseTx) (*types.Transacti
Value
:
&
CollateralizeAction_Close
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
close
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -310,7 +320,7 @@ func CreateRawCollateralizeCloseTx(parm *CollateralizeCloseTx) (*types.Transacti
}
// CreateRawCollateralizeManageTx method
func
CreateRawCollateralizeManageTx
(
parm
*
CollateralizeManageTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawCollateralizeManageTx
(
cfg
*
types
.
Chain33Config
,
parm
*
CollateralizeManageTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawCollateralizeManageTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -328,14 +338,14 @@ func CreateRawCollateralizeManageTx(parm *CollateralizeManageTx) (*types.Transac
Value
:
&
CollateralizeAction_Manage
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
CollateralizeX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
CollateralizeX
)),
Payload
:
types
.
Encode
(
manage
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
CollateralizeX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
CollateralizeX
)),
}
name
:=
types
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
CollateralizeX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/issuance/commands/cmd.go
View file @
960d2433
...
...
@@ -51,6 +51,12 @@ func addIssuanceCreateFlags(cmd *cobra.Command) {
}
func
IssuanceCreate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
balance
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"balance"
)
debtCeiling
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"debtCeiling"
)
...
...
@@ -58,7 +64,7 @@ func IssuanceCreate(cmd *cobra.Command, args []string) {
period
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"period"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuanceCreate"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
totalBalance
\"
:%d,
\"
debtCeiling
\"
:%d,
\"
liquidationRatio
\"
:%f,
\"
period
\"
:%d}"
,
balance
,
debtCeiling
,
liquidationRatio
,
period
)),
...
...
@@ -88,12 +94,18 @@ func addIssuanceDebtFlags(cmd *cobra.Command) {
}
func
IssuanceDebt
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
issuanceID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"issuanceID"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuanceDebt"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
issuanceID
\"
:
\"
%s
\"
,
\"
value
\"
:%d}"
,
issuanceID
,
value
)),
}
...
...
@@ -122,12 +134,18 @@ func addIssuanceRepayFlags(cmd *cobra.Command) {
}
func
IssuanceRepay
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
issuanceID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"issuanceID"
)
debtID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"debtID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuanceRepay"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
issuanceID
\"
:
\"
%s
\"
,
\"
debtID
\"
:
\"
%s
\"
}"
,
issuanceID
,
debtID
)),
}
...
...
@@ -156,12 +174,18 @@ func addIssuancePriceFeedFlags(cmd *cobra.Command) {
}
func
IssuancePriceFeed
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
price
,
_
:=
cmd
.
Flags
()
.
GetFloat32
(
"price"
)
volume
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"volume"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuancePriceFeed"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
price
\"
:[ %f ],
\"
volume
\"
:[ %d ]}"
,
price
,
volume
)),
}
...
...
@@ -188,11 +212,17 @@ func addIssuanceCloseFlags(cmd *cobra.Command) {
}
func
IssuanceClose
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
issuanceID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"issuanceID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuanceClose"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
issuanceId
\"
:
\"
%s
\"
}"
,
issuanceID
)),
}
...
...
@@ -219,11 +249,17 @@ func addIssuanceManageFlags(cmd *cobra.Command) {
}
func
IssuanceManage
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
IssuanceX
),
Execer
:
cfg
.
ExecName
(
pkt
.
IssuanceX
),
ActionName
:
"IssuanceManage"
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
addr
\"
:[
\"
%s
\"
]}"
,
addr
)),
}
...
...
plugin/dapp/issuance/executor/issuance.go
View file @
960d2433
...
...
@@ -14,7 +14,7 @@ import (
var
clog
=
log
.
New
(
"module"
,
"execs.issuance"
)
var
driverName
=
pty
.
IssuanceX
func
init
()
{
func
InitExecType
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Issuance
{}))
}
...
...
@@ -26,7 +26,7 @@ type subConfig struct {
var
cfg
subConfig
// Init issuance
func
Init
(
name
string
,
sub
[]
byte
)
{
func
Init
(
name
string
,
cfg
*
types
.
Chain33Config
,
sub
[]
byte
)
{
driverName
:=
GetName
()
if
name
!=
driverName
{
panic
(
"system dapp can't be rename"
)
...
...
@@ -34,7 +34,8 @@ func Init(name string, sub []byte) {
if
sub
!=
nil
{
types
.
MustDecode
(
sub
,
&
cfg
)
}
drivers
.
Register
(
driverName
,
newIssuance
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
drivers
.
Register
(
cfg
,
driverName
,
newIssuance
,
cfg
.
GetDappFork
(
driverName
,
"Enable"
))
InitExecType
()
}
// GetName for Issuance
...
...
@@ -170,7 +171,8 @@ func (c *Issuance) CheckReceiptExecOk() bool {
// ExecutorOrder 设置localdb的EnableRead
func
(
c
*
Issuance
)
ExecutorOrder
()
int64
{
if
types
.
IsFork
(
c
.
GetHeight
(),
"ForkLocalDBAccess"
)
{
cfg
:=
c
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsFork
(
c
.
GetHeight
(),
"ForkLocalDBAccess"
)
{
return
drivers
.
ExecLocalSameTime
}
return
c
.
DriverBase
.
ExecutorOrder
()
...
...
plugin/dapp/issuance/types/issuance.go
View file @
960d2433
...
...
@@ -19,8 +19,16 @@ var (
func
init
()
{
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
IssuanceX
))
types
.
RegistorExecutor
(
IssuanceX
,
NewType
())
types
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
types
.
RegFork
(
IssuanceX
,
InitFork
)
types
.
RegExec
(
IssuanceX
,
InitExecutor
)
}
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
types
.
RegistorExecutor
(
IssuanceX
,
NewType
(
cfg
))
}
// IssuanceType def
...
...
@@ -29,19 +37,20 @@ type IssuanceType struct {
}
// NewType method
func
NewType
()
*
IssuanceType
{
func
NewType
(
cfg
*
types
.
Chain33Config
)
*
IssuanceType
{
c
:=
&
IssuanceType
{}
c
.
SetChild
(
c
)
c
.
SetConfig
(
cfg
)
return
c
}
// GetName 获取执行器名称
func
(
I
ssuance
*
IssuanceType
)
GetName
()
string
{
func
(
i
ssuance
*
IssuanceType
)
GetName
()
string
{
return
IssuanceX
}
// GetLogMap method
func
(
I
ssuance
*
IssuanceType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
i
ssuance
*
IssuanceType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogIssuanceCreate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptIssuance
{}),
Name
:
"LogIssuanceCreate"
},
TyLogIssuanceDebt
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptIssuance
{}),
Name
:
"LogIssuanceDebt"
},
...
...
@@ -52,13 +61,14 @@ func (Issuance *IssuanceType) GetLogMap() map[int64]*types.LogInfo {
}
// GetPayload method
func
(
I
ssuance
*
IssuanceType
)
GetPayload
()
types
.
Message
{
func
(
i
ssuance
*
IssuanceType
)
GetPayload
()
types
.
Message
{
return
&
IssuanceAction
{}
}
// CreateTx method
func
(
I
ssuance
IssuanceType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
func
(
i
ssuance
IssuanceType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
llog
.
Debug
(
"Issuance.CreateTx"
,
"action"
,
action
)
cfg
:=
issuance
.
GetConfig
()
if
action
==
"IssuanceCreate"
{
var
param
IssuanceCreateTx
...
...
@@ -67,7 +77,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceCreateTx
(
&
param
)
return
CreateRawIssuanceCreateTx
(
cfg
,
&
param
)
}
else
if
action
==
"IssuanceDebt"
{
var
param
IssuanceDebtTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -75,7 +85,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceDebtTx
(
&
param
)
return
CreateRawIssuanceDebtTx
(
cfg
,
&
param
)
}
else
if
action
==
"IssuanceRepay"
{
var
param
IssuanceRepayTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -83,7 +93,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceRepayTx
(
&
param
)
return
CreateRawIssuanceRepayTx
(
cfg
,
&
param
)
}
else
if
action
==
"IssuancePriceFeed"
{
var
param
IssuanceFeedTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -91,7 +101,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceFeedTx
(
&
param
)
return
CreateRawIssuanceFeedTx
(
cfg
,
&
param
)
}
else
if
action
==
"IssuanceClose"
{
var
param
IssuanceCloseTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -99,7 +109,7 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceCloseTx
(
&
param
)
return
CreateRawIssuanceCloseTx
(
cfg
,
&
param
)
}
else
if
action
==
"IssuanceManage"
{
var
param
IssuanceManageTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
...
@@ -107,14 +117,14 @@ func (Issuance IssuanceType) CreateTx(action string, message json.RawMessage) (*
llog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawIssuanceManageTx
(
&
param
)
return
CreateRawIssuanceManageTx
(
cfg
,
&
param
)
}
else
{
return
nil
,
types
.
ErrNotSupport
}
}
// GetTypeMap method
func
(
I
ssuance
IssuanceType
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
i
ssuance
IssuanceType
)
GetTypeMap
()
map
[
string
]
int32
{
return
map
[
string
]
int32
{
"Create"
:
IssuanceActionCreate
,
"Debt"
:
IssuanceActionDebt
,
...
...
@@ -126,7 +136,7 @@ func (Issuance IssuanceType) GetTypeMap() map[string]int32 {
}
// CreateRawIssuanceCreateTx method
func
CreateRawIssuanceCreateTx
(
parm
*
IssuanceCreateTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceCreateTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceCreateTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuanceCreateTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -140,13 +150,13 @@ func CreateRawIssuanceCreateTx(parm *IssuanceCreateTx) (*types.Transaction, erro
Value
:
&
IssuanceAction_Create
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
create
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -154,7 +164,7 @@ func CreateRawIssuanceCreateTx(parm *IssuanceCreateTx) (*types.Transaction, erro
}
// CreateRawIssuanceDebtTx method
func
CreateRawIssuanceDebtTx
(
parm
*
IssuanceDebtTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceDebtTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceDebtTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuanceBorrowTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -169,13 +179,13 @@ func CreateRawIssuanceDebtTx(parm *IssuanceDebtTx) (*types.Transaction, error) {
Value
:
&
IssuanceAction_Debt
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
debt
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -183,7 +193,7 @@ func CreateRawIssuanceDebtTx(parm *IssuanceDebtTx) (*types.Transaction, error) {
}
// CreateRawIssuanceRepayTx method
func
CreateRawIssuanceRepayTx
(
parm
*
IssuanceRepayTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceRepayTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceRepayTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuanceRepayTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -198,13 +208,13 @@ func CreateRawIssuanceRepayTx(parm *IssuanceRepayTx) (*types.Transaction, error)
Value
:
&
IssuanceAction_Repay
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
repay
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -212,7 +222,7 @@ func CreateRawIssuanceRepayTx(parm *IssuanceRepayTx) (*types.Transaction, error)
}
// CreateRawIssuanceFeedTx method
func
CreateRawIssuanceFeedTx
(
parm
*
IssuanceFeedTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceFeedTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceFeedTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuancePriceFeedTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -227,13 +237,13 @@ func CreateRawIssuanceFeedTx(parm *IssuanceFeedTx) (*types.Transaction, error) {
Value
:
&
IssuanceAction_Feed
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
feed
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -241,7 +251,7 @@ func CreateRawIssuanceFeedTx(parm *IssuanceFeedTx) (*types.Transaction, error) {
}
// CreateRawIssuanceCloseTx method
func
CreateRawIssuanceCloseTx
(
parm
*
IssuanceCloseTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceCloseTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceCloseTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuanceCloseTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -255,14 +265,14 @@ func CreateRawIssuanceCloseTx(parm *IssuanceCloseTx) (*types.Transaction, error)
Value
:
&
IssuanceAction_Close
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
close
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -270,7 +280,7 @@ func CreateRawIssuanceCloseTx(parm *IssuanceCloseTx) (*types.Transaction, error)
}
// CreateRawIssuanceManageTx method
func
CreateRawIssuanceManageTx
(
parm
*
IssuanceManageTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawIssuanceManageTx
(
cfg
*
types
.
Chain33Config
,
parm
*
IssuanceManageTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawIssuanceManageTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -283,14 +293,14 @@ func CreateRawIssuanceManageTx(parm *IssuanceManageTx) (*types.Transaction, erro
Value
:
&
IssuanceAction_Manage
{
v
},
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
IssuanceX
)),
Execer
:
[]
byte
(
cfg
.
ExecName
(
IssuanceX
)),
Payload
:
types
.
Encode
(
manage
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
types
.
ExecName
(
IssuanceX
)),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
IssuanceX
)),
}
name
:=
types
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
name
:=
cfg
.
ExecName
(
IssuanceX
)
tx
,
err
:=
types
.
FormatTx
(
cfg
,
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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