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
87c266d9
Commit
87c266d9
authored
May 29, 2019
by
lyn
Committed by
vipwzw
May 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update linter
parent
1032e29e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
77 deletions
+33
-77
build.sh
plugin/dapp/token/cmd/build.sh
+0
-0
test-rpc.sh
plugin/dapp/token/cmd/build/test-rpc.sh
+33
-77
No files found.
plugin/dapp/token/cmd/build.sh
100644 → 100755
View file @
87c266d9
File mode changed from 100644 to 100755
plugin/dapp/token/cmd/build/test-rpc.sh
View file @
87c266d9
...
@@ -10,6 +10,7 @@ tokenSymbol="ABE"
...
@@ -10,6 +10,7 @@ tokenSymbol="ABE"
token_addr
=
""
token_addr
=
""
execName
=
"token"
execName
=
"token"
#color
#color
RED
=
'\033[1;31m'
RED
=
'\033[1;31m'
GRE
=
'\033[1;32m'
GRE
=
'\033[1;32m'
...
@@ -88,7 +89,7 @@ function signRawTx() {
...
@@ -88,7 +89,7 @@ function signRawTx() {
}
}
function
sendSignedTx
()
{
function
sendSignedTx
()
{
txHash
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"token":"","data":"'
${
signedTx
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
txHash
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"token":"","data":"'
"
${
signedTx
}
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
$txHash
"
==
"null"
]
;
then
if
[
"
$txHash
"
==
"null"
]
;
then
return
1
return
1
else
else
...
@@ -102,11 +103,11 @@ function queryTransaction() {
...
@@ -102,11 +103,11 @@ function queryTransaction() {
validator
=
$1
validator
=
$1
expectRes
=
$2
expectRes
=
$2
echo
"txhash=
${
txHash
}
"
echo
"txhash=
${
txHash
}
"
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'
${
txHash
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
"
${
validator
}
"
)
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'
"
${
txHash
}
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
"
${
validator
}
"
)
if
[
"
${
res
}
"
!=
"
${
expectRes
}
"
]
;
then
if
[
"
${
res
}
"
!=
"
${
expectRes
}
"
]
;
then
return
1
return
1
else
else
token_addr
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'
${
txHash
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.receipt.logs[1].log.contractName"
)
token_addr
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'
"
${
txHash
}
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.receipt.logs[1].log.contractName"
)
return
0
return
0
fi
fi
}
}
...
@@ -143,31 +144,17 @@ function updateConfig() {
...
@@ -143,31 +144,17 @@ function updateConfig() {
fi
fi
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
if
[
$?
-ne
0
]
;
then
echo_rst
"update config signRawTx"
"
$?
"
rst
=
$?
echo_rst
"update config signRawTx"
"
$rst
"
return
fi
sendSignedTx
sendSignedTx
if
[
$?
-ne
0
]
;
then
echo_rst
"update config sendSignedTx"
"
$?
"
rst
=
$?
echo_rst
"update config sendSignedTx"
"
$rst
"
return
fi
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
".error | not"
"true"
if
[
$?
-ne
0
]
;
then
echo_rst
"update config queryExecRes"
"
$?
"
rst
=
$?
echo_rst
"update config queryExecRes"
"
$rst
"
fi
}
}
function
token_preCreate
()
{
function
token_preCreate
()
{
validator
=
$1
expectRes
=
$2
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "yinhebib", "symbol": "'
"
${
tokenSymbol
}
"
'", "total": 100000000000, "price": 100, "category": 1,"owner":"'
${
tokenAddr
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "yinhebib", "symbol": "'
"
${
tokenSymbol
}
"
'", "total": 100000000000, "price": 100, "category": 1,"owner":"'
${
tokenAddr
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
echo_rst
"token preCreate create tx"
1
echo_rst
"token preCreate create tx"
1
...
@@ -175,43 +162,26 @@ function token_preCreate() {
...
@@ -175,43 +162,26 @@ function token_preCreate() {
fi
fi
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
if
[
$?
-ne
0
]
;
then
echo_rst
"token preCreate signRawTx"
"
$?
"
rst
=
$?
echo_rst
"token preCreate signRawTx"
"
$rst
"
return
fi
sendSignedTx
sendSignedTx
if
[
$?
-ne
0
]
;
then
echo_rst
"token preCreate sendSignedTx"
"
$?
"
rst
=
$?
echo_rst
"token preCreate sendSignedTx"
"
$rst
"
return
fi
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
".error | not"
"true"
if
[
$?
-ne
0
]
;
then
echo_rst
"token preCreate queryExecRes"
"
$?
"
rst
=
$?
echo_rst
"token preCreate queryExecRes"
"
$rst
"
fi
}
}
function
token_getPreCreated
()
{
function
token_getPreCreated
()
{
validator
=
$1
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
${
execName
}
"
'","funcName":"GetTokens","payload":{"queryAll":true,"status":0,"tokens":[],"symbolOnly":false}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error | not"
)
expectRes
=
$2
if
[
"
${
res
}
"
!=
"true"
]
;
then
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
${
execName
}
"
'","funcName":"GetTokens","payload":{"queryAll":true,"status":0,"tokens":[],"symbolOnly":false}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
${
res
}
"
!=
""
-a
""
]
;
then
echo_rst
"token preCreate create tx"
1
echo_rst
"token preCreate create tx"
1
return
return
fi
fi
}
}
function
token_finish
()
{
function
token_finish
()
{
validator
=
$1
expectRes
=
$2
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenFinishTx","params":[{"symbol": "'
"
${
tokenSymbol
}
"
'", "owner":"'
${
tokenAddr
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenFinishTx","params":[{"symbol": "'
"
${
tokenSymbol
}
"
'", "owner":"'
${
tokenAddr
}
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
echo_rst
"token finish create tx"
1
echo_rst
"token finish create tx"
1
...
@@ -219,35 +189,21 @@ function token_finish() {
...
@@ -219,35 +189,21 @@ function token_finish() {
fi
fi
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
signRawTx
"
${
unsignedTx
}
"
"
${
tokenAddr
}
"
if
[
$?
-ne
0
]
;
then
echo_rst
"token finish signRawTx"
"
$?
"
rst
=
$?
echo_rst
"token finish signRawTx"
"
$rst
"
return
fi
sendSignedTx
sendSignedTx
if
[
$?
-ne
0
]
;
then
echo_rst
"token finish sendSignedTx"
"
$?
"
rst
=
$?
echo_rst
"token finish sendSignedTx"
"
$rst
"
return
fi
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
".error | not"
"true"
if
[
$?
-ne
0
]
;
then
echo_rst
"token finish queryExecRes"
"
$?
"
rst
=
$?
echo_rst
"token finish queryExecRes"
"
$rst
"
fi
}
}
function
token_getFinishCreated
()
{
function
token_getFinishCreated
()
{
validator
=
$1
expectRes
=
$2
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
${
execName
}
"
'","funcName":"GetTokens","payload":{"queryAll":true,"status":1,"tokens":[],"symbolOnly":false}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.tokens"
|
grep
"symbol"
)
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
${
execName
}
"
'","funcName":"GetTokens","payload":{"queryAll":true,"status":1,"tokens":[],"symbolOnly":false}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.tokens"
|
grep
"symbol"
)
if
[
[
${
res
}
=
~
${
tokenSymbol
}
]
]
;
then
if
[
"
${
res
}
"
!=
""
]
;
then
echo_rst
"token get finishCreated create tx"
0
echo_rst
"token get finishCreated create tx"
0
else
else
echo_rst
"token get finishCreated create tx"
1
echo_rst
"token get finishCreated create tx"
1
...
@@ -262,11 +218,11 @@ function token_assets() {
...
@@ -262,11 +218,11 @@ function token_assets() {
return
return
fi
fi
tokenInfo
=
$(
echo
${
res
}
| jq
-r
'.result.tokenAssets'
|
grep
-A
6
-B
1
"
${
tokenSymbol
}
"
)
tokenInfo
=
$(
echo
"
${
res
}
"
| jq
-r
'.result.tokenAssets'
|
grep
-A
6
-B
1
"
${
tokenSymbol
}
"
)
addr
=
$(
echo
${
tokenInfo
}
|
awk
-F
'"'
'{print $20
}'
)
addr
=
$(
echo
"
${
tokenInfo
}
"
|
grep
"addr"
|
awk
-F
'"'
'{print $4
}'
)
balance
=
$(
echo
${
tokenInfo
}
|
awk
-F
'"'
'{print $12
}'
)
balance
=
$(
echo
"
${
tokenInfo
}
"
|
grep
"balance"
|
awk
-F
'"'
'{print $4
}'
)
if
[
"
${
addr
}
"
==
"
${
recvAddr
}
"
]
&&
[
${
balance
}
-eq
1000000000
]
;
then
if
[
"
${
addr
}
"
==
"
${
recvAddr
}
"
]
&&
[
"
${
balance
}
"
-eq
1000000000
]
;
then
echo_rst
"token get assets tx"
0
echo_rst
"token get assets tx"
0
else
else
echo_rst
"token get assets tx"
1
echo_rst
"token get assets tx"
1
...
@@ -274,17 +230,17 @@ function token_assets() {
...
@@ -274,17 +230,17 @@ function token_assets() {
}
}
function
token_balance
()
{
function
token_balance
()
{
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.GetTokenBalance","params":[{"addresses": ["'
${
tokenAddr
}
'"],"tokenSymbol":"'
"
${
tokenSymbol
}
"
'","execer": "'
"
${
execName
}
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
res
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.GetTokenBalance","params":[{"addresses": ["'
${
tokenAddr
}
'"],"tokenSymbol":"'
"
${
tokenSymbol
}
"
'","execer": "'
"
${
execName
}
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
)
if
[
"
${
res
}
"
==
""
]
;
then
if
[
"
${
res
}
"
==
""
]
;
then
echo_rst
"token get balance tx"
1
echo_rst
"token get balance tx"
1
return
return
fi
fi
addr
=
$(
echo
${
res
}
| jq
-r
".result[0].addr"
)
addr
=
$(
echo
"
${
res
}
"
| jq
-r
".result[0].addr"
)
balance
=
$(
echo
${
res
}
| jq
-r
".result[0].balance"
)
balance
=
$(
echo
"
${
res
}
"
| jq
-r
".result[0].balance"
)
if
[
"
${
addr
}
"
==
"
${
tokenAddr
}
"
-a
${
balance
}
-eq
100000000000
]
;
then
if
[
"
${
addr
}
"
==
"
${
tokenAddr
}
"
]
&&
[
"
${
balance
}
"
-eq
100000000000
]
;
then
echo_rst
"token get balance tx"
0
echo_rst
"token get balance tx"
0
else
else
echo_rst
"token get balance tx"
1
echo_rst
"token get balance tx"
1
...
@@ -322,8 +278,6 @@ function token_burn() {
...
@@ -322,8 +278,6 @@ function token_burn() {
}
}
function
token_mint
()
{
function
token_mint
()
{
validator
=
$1
expectRes
=
$2
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenMintTx","params":[{"symbol": "'
"
${
tokenSymbol
}
"
'","amount": 10000}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenMintTx","params":[{"symbol": "'
"
${
tokenSymbol
}
"
'","amount": 10000}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
echo_rst
"token mint create tx"
1
echo_rst
"token mint create tx"
1
...
@@ -375,7 +329,7 @@ function token_transfer() {
...
@@ -375,7 +329,7 @@ function token_transfer() {
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
"
.error | not"
"true
"
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
rst
=
$?
rst
=
$?
echo_rst
"token transfer queryExecRes"
"
$rst
"
echo_rst
"token transfer queryExecRes"
"
$rst
"
...
@@ -405,13 +359,14 @@ function token_sendExec() {
...
@@ -405,13 +359,14 @@ function token_sendExec() {
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
"
.error | not"
"true
"
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
rst
=
$?
rst
=
$?
echo_rst
"token sendExec queryExecRes"
"
$rst
"
echo_rst
"token sendExec queryExecRes"
"
$rst
"
fi
fi
}
}
function
token_withdraw
()
{
function
token_withdraw
()
{
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "'
"
${
execName
}
"
'","actionName":"Withdraw","payload": {"cointoken":"'
"
${
tokenSymbol
}
"
'", "amount": "10", "note": "", "to": "'
"
${
token_addr
}
"
'", "execName": "'
"
${
execName
}
"
'"}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
unsignedTx
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "'
"
${
execName
}
"
'","actionName":"Withdraw","payload": {"cointoken":"'
"
${
tokenSymbol
}
"
'", "amount": "10", "note": "", "to": "'
"
${
token_addr
}
"
'", "execName": "'
"
${
execName
}
"
'"}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
if
[
"
${
unsignedTx
}
"
==
""
]
;
then
...
@@ -435,7 +390,7 @@ function token_withdraw() {
...
@@ -435,7 +390,7 @@ function token_withdraw() {
block_wait 1
block_wait 1
queryTransaction
"
${
validator
}
"
"
${
expectRes
}
"
queryTransaction
"
.error | not"
"true
"
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
rst
=
$?
rst
=
$?
echo_rst
"token withdraw queryExecRes"
"
$rst
"
echo_rst
"token withdraw queryExecRes"
"
$rst
"
...
@@ -476,4 +431,4 @@ function main() {
...
@@ -476,4 +431,4 @@ function main() {
fi
fi
}
}
main
"
$1
"
main
"
$1
"
\ No newline at end of file
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