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
32bffbbb
Commit
32bffbbb
authored
Mar 08, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rpc, command
parent
81752197
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
0 deletions
+96
-0
token.go
plugin/dapp/token/commands/token.go
+83
-0
rpc.go
plugin/dapp/token/rpc/rpc.go
+13
-0
No files found.
plugin/dapp/token/commands/token.go
View file @
32bffbbb
...
@@ -42,6 +42,8 @@ func TokenCmd() *cobra.Command {
...
@@ -42,6 +42,8 @@ func TokenCmd() *cobra.Command {
CreateRawTokenFinishTxCmd
(),
CreateRawTokenFinishTxCmd
(),
CreateRawTokenRevokeTxCmd
(),
CreateRawTokenRevokeTxCmd
(),
CreateTokenTransferExecCmd
(),
CreateTokenTransferExecCmd
(),
CreateRawTokenMintTxCmd
(),
GetTokenLogsCmd
(),
)
)
return
cmd
return
cmd
...
@@ -465,3 +467,84 @@ func tokenRevoke(cmd *cobra.Command, args []string) {
...
@@ -465,3 +467,84 @@ func tokenRevoke(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"token.CreateRawTokenRevokeTx"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"token.CreateRawTokenRevokeTx"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
// CreateRawTokenMintTxCmd create raw token finish create transaction
func
CreateRawTokenMintTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"mint"
,
Short
:
"Create a mint token transaction"
,
Run
:
tokenMint
,
}
addTokenMintFlags
(
cmd
)
return
cmd
}
func
addTokenMintFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"a"
,
""
,
"token symbol"
)
cmd
.
MarkFlagRequired
(
"symbol"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0
,
"amount of mintage"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
0
,
"token transaction fee"
)
}
func
tokenMint
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"owner_addr"
)
params
:=
&
tokenty
.
TokenMint
{
Symbol
:
symbol
,
Amount
:
int64
((
amount
+
0.000001
)
*
1e4
)
*
1e4
,
}
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"token.CreateRawTokenMintTx"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
// GetTokenLogsCmd get logs of token
func
GetTokenLogsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"get_token_logs"
,
Short
:
"Get logs of token"
,
Run
:
getTokenLogs
,
}
getTokenLogsFlags
(
cmd
)
return
cmd
}
func
getTokenLogs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
getRealExecName
(
paraName
,
"token"
)
params
.
FuncName
=
"GetTokenHistory"
params
.
Payload
=
types
.
MustPBToJSON
(
&
types
.
ReqString
{
Data
:
symbol
})
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcLaddr
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
var
res
tokenty
.
ReplyTokenLogs
err
=
rpc
.
Call
(
"Chain33.Query"
,
params
,
&
res
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
data
,
err
:=
json
.
MarshalIndent
(
res
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
fmt
.
Println
(
string
(
data
))
}
func
getTokenLogsFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
""
,
"token symbol"
)
cmd
.
MarkFlagRequired
(
"symbol"
)
}
plugin/dapp/token/rpc/rpc.go
View file @
32bffbbb
...
@@ -121,3 +121,16 @@ func (c *Jrpc) CreateRawTokenRevokeTx(param *tokenty.TokenRevokeCreate, result *
...
@@ -121,3 +121,16 @@ func (c *Jrpc) CreateRawTokenRevokeTx(param *tokenty.TokenRevokeCreate, result *
*
result
=
hex
.
EncodeToString
(
data
)
*
result
=
hex
.
EncodeToString
(
data
)
return
nil
return
nil
}
}
// CreateRawTokenMintTx 创建未签名的mint Token交易
func
(
c
*
Jrpc
)
CreateRawTokenMintTx
(
param
*
tokenty
.
TokenMint
,
result
*
interface
{})
error
{
if
param
==
nil
||
param
.
Symbol
==
""
||
param
.
Amount
>
0
{
return
types
.
ErrInvalidParam
}
data
,
err
:=
types
.
CallCreateTx
(
types
.
ExecName
(
tokenty
.
TokenX
),
"TokenMint"
,
param
)
if
err
!=
nil
{
return
err
}
*
result
=
hex
.
EncodeToString
(
data
)
return
nil
}
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