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
a8ab5352
Commit
a8ab5352
authored
Dec 03, 2018
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix unfreeze cli
parent
8f13412b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
10 deletions
+36
-10
unfreeze.go
plugin/dapp/unfreeze/commands/unfreeze.go
+36
-10
No files found.
plugin/dapp/unfreeze/commands/unfreeze.go
View file @
a8ab5352
...
...
@@ -8,6 +8,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math"
"os"
"strings"
...
...
@@ -64,22 +65,34 @@ func createFlag(cmd *cobra.Command) *cobra.Command {
return
cmd
}
func
getCreateFlags
(
cmd
*
cobra
.
Command
)
*
pty
.
UnfreezeCreate
{
func
checkAmount
(
amount
float64
)
error
{
if
amount
<
0
||
amount
>
float64
(
types
.
MaxCoin
/
types
.
Coin
)
{
return
types
.
ErrAmount
}
return
nil
}
func
getCreateFlags
(
cmd
*
cobra
.
Command
)
(
*
pty
.
UnfreezeCreate
,
error
)
{
beneficiary
,
_
:=
cmd
.
Flags
()
.
GetString
(
"beneficiary"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"asset_exec"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"asset_symbol"
)
total
,
_
:=
cmd
.
Flags
()
.
Get
In
t64
(
"total"
)
total
,
_
:=
cmd
.
Flags
()
.
Get
Floa
t64
(
"total"
)
startTs
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"start_ts"
)
if
err
:=
checkAmount
(
total
);
err
!=
nil
{
return
nil
,
types
.
ErrAmount
}
totalInt64
:=
int64
(
math
.
Trunc
((
total
+
0.0000001
)
*
1e4
))
*
1e4
unfreeze
:=
&
pty
.
UnfreezeCreate
{
StartTime
:
startTs
,
AssetExec
:
exec
,
AssetSymbol
:
symbol
,
TotalCount
:
total
,
TotalCount
:
total
Int64
,
Beneficiary
:
beneficiary
,
Means
:
""
,
}
return
unfreeze
return
unfreeze
,
nil
}
func
fixAmountCmd
()
*
cobra
.
Command
{
...
...
@@ -89,7 +102,7 @@ func fixAmountCmd() *cobra.Command {
Run
:
fixAmount
,
}
cmd
=
createFlag
(
cmd
)
cmd
.
Flags
()
.
In
t64P
(
"amount"
,
"a"
,
0
,
"amount every period"
)
cmd
.
Flags
()
.
Floa
t64P
(
"amount"
,
"a"
,
0
,
"amount every period"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
Int64P
(
"period"
,
"p"
,
0
,
"period in second"
)
...
...
@@ -98,12 +111,21 @@ func fixAmountCmd() *cobra.Command {
}
func
fixAmount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
create
:=
getCreateFlags
(
cmd
)
create
,
err
:=
getCreateFlags
(
cmd
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
if
err
=
checkAmount
(
amount
);
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
amountInt64
:=
int64
(
math
.
Trunc
((
amount
+
0.0000001
)
*
1e4
))
*
1e4
period
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"period"
)
create
.
Means
=
pty
.
FixAmountX
create
.
MeansOpt
=
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
period
,
Amount
:
amount
}}
create
.
MeansOpt
=
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
period
,
Amount
:
amount
Int64
}}
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
tx
,
err
:=
pty
.
CreateUnfreezeCreateTx
(
paraName
,
create
)
...
...
@@ -135,7 +157,11 @@ func leftCmd() *cobra.Command {
}
func
left
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
create
:=
getCreateFlags
(
cmd
)
create
,
err
:=
getCreateFlags
(
cmd
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
tenThousandth
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"ten_thousandth"
)
period
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"period"
)
...
...
@@ -190,7 +216,7 @@ func showCmd() *cobra.Command {
func
queryWithdrawCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"show"
,
Use
:
"show
_withdraw
"
,
Short
:
"show available withdraw amount of one unfreeze construct"
,
Run
:
queryWithdraw
,
}
...
...
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