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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
157 additions
and
65 deletions
+157
-65
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
+0
-0
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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