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
6150903e
Commit
6150903e
authored
Jan 25, 2019
by
hezhengjun
Committed by
vipwzw
Jan 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support asset withdraw from parachain
parent
144f7493
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
6 deletions
+100
-6
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+90
-1
action.go
plugin/dapp/paracross/executor/action.go
+5
-3
asset.go
plugin/dapp/paracross/executor/asset.go
+4
-2
type.go
plugin/dapp/paracross/types/type.go
+1
-0
No files found.
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
6150903e
#!/usr/bin/env bash
#!/usr/bin/env bash
PARA_CLI
=
"docker exec
${
NODE3
}
/root/chain33-para-cli"
PARA_CLI
=
"docker exec
${
NODE3
}
/root/chain33-para-cli"
PARA_CLI2
=
"docker exec
${
NODE2
}
/root/chain33-para-cli"
PARA_CLI2
=
"docker exec
${
NODE2
}
/root/chain33-para-cli"
PARA_CLI1
=
"docker exec
${
NODE1
}
/root/chain33-para-cli"
PARA_CLI1
=
"docker exec
${
NODE1
}
/root/chain33-para-cli"
PARA_CLI4
=
"docker exec
${
NODE4
}
/root/chain33-para-cli"
PARA_CLI4
=
"docker exec
${
NODE4
}
/root/chain33-para-cli"
MAIN_CLI
=
"docker exec
${
NODE3
}
/root/chain33-cli"
PARANAME
=
"para"
PARANAME
=
"para"
...
@@ -246,11 +246,100 @@ function para_cross_transfer_withdraw() {
...
@@ -246,11 +246,100 @@ function para_cross_transfer_withdraw() {
done
done
}
}
function
token_create_on_mainChain
()
{
echo
"=========== # main chain token test ============="
echo
"=========== # 0.config token-blacklist ============="
hash
=
$(${
CLI
}
send config config_tx
-c
token-blacklist
-o
add
-v
BTY
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # send bty to token ============="
hash
=
$(${
CLI
}
send bty send_exec
-a
500
-e
token
-n
send2exec
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # 1.token precreate token FZM ============="
hash
=
$(${
CLI
}
send token precreate
-f
0.001
-i
test
-n
guodunjifen
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-p
0
-s
FZM
-t
10000
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
"tx hash for token precreate is:"
"
${
hash
}
"
echo
"MAIN_CLI is:"
"
${
MAIN_CLI
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
${
CLI
}
token get_precreated
owner
=
$(${
CLI
}
token get_precreated | jq
-r
".owner"
)
if
[
"
${
owner
}
"
!=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
]
;
then
echo
"wrong pre create owner"
exit
1
fi
total
=
$(${
CLI
}
token get_precreated | jq
-r
".total"
)
if
[
"
${
total
}
"
!=
10000
]
;
then
echo
"wrong pre create total"
exit
1
fi
echo
"=========== # 2.token finish ============="
hash
=
$(${
CLI
}
send token finish
-f
0.001
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-s
FZM
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
${
CLI
}
token get_finish_created
owner
=
$(${
CLI
}
token get_finish_created | jq
-r
".owner"
)
if
[
"
${
owner
}
"
!=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
]
;
then
echo
"wrong finish created owner"
exit
1
fi
total
=
$(${
CLI
}
token get_finish_created | jq
-r
".total"
)
if
[
"
${
total
}
"
!=
10000
]
;
then
echo
"wrong finish created total"
exit
1
fi
${
CLI
}
token token_balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
token
-s
FZM
balance
=
$(${
CLI
}
token token_balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
token
-s
FZM | jq
-r
'.[]|.balance'
)
if
[
"
${
balance
}
"
!=
"10000.0000"
]
;
then
echo
"wrong para token genesis create, should be 10000.0000"
exit
1
fi
}
function
para_cross_transfer_withdraw_for_token
()
{
token_create_on_mainChain
echo
"=========== # 1.transfer token:FZM to paracross ============="
hash
=
$(${
CLI
}
send token send_exec
-a
333
-s
FZM
-e
paracross
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # 2.transfer asset to para chain ============="
hash
=
$(${
CLI
}
send para asset_transfer
--title
user.p.para.
-s
FZM
-a
220
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # 3.asset_withdraw from parachain ============="
${
CLI
}
send para asset_withdraw
--title
user.p.para.
-a
111
-s
FZM
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
local times
=
100
while
true
;
do
acc
=
$(${
CLI
}
asset balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
--asset_symbol
FZM
--asset_exec
token
-e
paracross | jq
-r
".balance"
)
echo
"account balance is
${
acc
}
, expect 224 "
if
[
"
${
acc
}
"
!=
"224.0000"
]
;
then
block_wait
"
${
CLI
}
"
2
times
=
$((
times
-
1
))
if
[
$times
-le
0
]
;
then
echo
"para_cross_transfer_withdraw failed"
exit
1
fi
else
echo
"para_cross_transfer_withdraw success"
break
fi
done
}
function
para_test
()
{
function
para_test
()
{
echo
"=========== # para chain test ============="
echo
"=========== # para chain test ============="
token_create
"
${
PARA_CLI
}
"
token_create
"
${
PARA_CLI
}
"
token_transfer
"
${
PARA_CLI
}
"
token_transfer
"
${
PARA_CLI
}
"
para_cross_transfer_withdraw
para_cross_transfer_withdraw
para_cross_transfer_withdraw_for_token
}
}
function
paracross
()
{
function
paracross
()
{
...
...
plugin/dapp/paracross/executor/action.go
View file @
6150903e
...
@@ -414,8 +414,10 @@ func (a *action) AssetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
...
@@ -414,8 +414,10 @@ func (a *action) AssetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
}
}
func
(
a
*
action
)
AssetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
AssetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
)
(
*
types
.
Receipt
,
error
)
{
if
withdraw
.
Cointoken
!=
""
{
if
!
types
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
"ForkParacrossWithdrawFromParachain"
)
{
return
nil
,
types
.
ErrNotSupport
if
withdraw
.
Cointoken
!=
""
{
return
nil
,
types
.
ErrNotSupport
}
}
}
isPara
:=
types
.
IsPara
()
isPara
:=
types
.
IsPara
()
...
@@ -424,7 +426,7 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
...
@@ -424,7 +426,7 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
return
nil
,
nil
return
nil
,
nil
}
}
clog
.
Debug
(
"paracross.AssetWithdraw isPara"
,
"execer"
,
string
(
a
.
tx
.
Execer
),
clog
.
Debug
(
"paracross.AssetWithdraw isPara"
,
"execer"
,
string
(
a
.
tx
.
Execer
),
"txHash"
,
hex
.
EncodeToString
(
a
.
tx
.
Hash
()))
"txHash"
,
hex
.
EncodeToString
(
a
.
tx
.
Hash
())
,
"token name"
,
withdraw
.
Cointoken
)
receipt
,
err
:=
a
.
assetWithdraw
(
withdraw
,
a
.
tx
)
receipt
,
err
:=
a
.
assetWithdraw
(
withdraw
,
a
.
tx
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"AssetWithdraw failed"
,
"err"
,
err
)
clog
.
Error
(
"AssetWithdraw failed"
,
"err"
,
err
)
...
...
plugin/dapp/paracross/executor/asset.go
View file @
6150903e
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
func
(
a
*
action
)
assetTransfer
(
transfer
*
types
.
AssetsTransfer
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
assetTransfer
(
transfer
*
types
.
AssetsTransfer
)
(
*
types
.
Receipt
,
error
)
{
isPara
:=
types
.
IsPara
()
isPara
:=
types
.
IsPara
()
//主链处理分支
if
!
isPara
{
if
!
isPara
{
accDB
,
err
:=
createAccount
(
a
.
db
,
transfer
.
Cointoken
)
accDB
,
err
:=
createAccount
(
a
.
db
,
transfer
.
Cointoken
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -32,7 +33,7 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
...
@@ -32,7 +33,7 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
"txHash"
,
hex
.
EncodeToString
(
a
.
tx
.
Hash
()))
"txHash"
,
hex
.
EncodeToString
(
a
.
tx
.
Hash
()))
return
accDB
.
ExecTransfer
(
a
.
fromaddr
,
toAddr
,
execAddr
,
transfer
.
Amount
)
return
accDB
.
ExecTransfer
(
a
.
fromaddr
,
toAddr
,
execAddr
,
transfer
.
Amount
)
}
}
//平行链处理分支
paraTitle
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
paraTitle
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"assetTransferCoins call getTitleFrom failed"
)
return
nil
,
errors
.
Wrap
(
err
,
"assetTransferCoins call getTitleFrom failed"
)
...
@@ -53,6 +54,7 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
...
@@ -53,6 +54,7 @@ func (a *action) assetTransfer(transfer *types.AssetsTransfer) (*types.Receipt,
func
(
a
*
action
)
assetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
,
withdrawTx
*
types
.
Transaction
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
assetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
,
withdrawTx
*
types
.
Transaction
)
(
*
types
.
Receipt
,
error
)
{
isPara
:=
types
.
IsPara
()
isPara
:=
types
.
IsPara
()
//主链处理分支
if
!
isPara
{
if
!
isPara
{
accDB
,
err
:=
createAccount
(
a
.
db
,
withdraw
.
Cointoken
)
accDB
,
err
:=
createAccount
(
a
.
db
,
withdraw
.
Cointoken
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -64,7 +66,7 @@ func (a *action) assetWithdraw(withdraw *types.AssetsWithdraw, withdrawTx *types
...
@@ -64,7 +66,7 @@ func (a *action) assetWithdraw(withdraw *types.AssetsWithdraw, withdrawTx *types
"to"
,
withdraw
.
To
,
"exec"
,
execAddr
,
"withdrawTx execor"
,
string
(
withdrawTx
.
Execer
))
"to"
,
withdraw
.
To
,
"exec"
,
execAddr
,
"withdrawTx execor"
,
string
(
withdrawTx
.
Execer
))
return
accDB
.
ExecTransfer
(
fromAddr
,
withdraw
.
To
,
execAddr
,
withdraw
.
Amount
)
return
accDB
.
ExecTransfer
(
fromAddr
,
withdraw
.
To
,
execAddr
,
withdraw
.
Amount
)
}
}
//平行链处理分支
paraTitle
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
paraTitle
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"assetWithdrawCoins call getTitleFrom failed"
)
return
nil
,
errors
.
Wrap
(
err
,
"assetWithdrawCoins call getTitleFrom failed"
)
...
...
plugin/dapp/paracross/types/type.go
View file @
6150903e
...
@@ -23,6 +23,7 @@ func init() {
...
@@ -23,6 +23,7 @@ func init() {
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
ParaX
))
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
ParaX
))
types
.
RegistorExecutor
(
ParaX
,
NewType
())
types
.
RegistorExecutor
(
ParaX
,
NewType
())
types
.
RegisterDappFork
(
ParaX
,
"Enable"
,
0
)
types
.
RegisterDappFork
(
ParaX
,
"Enable"
,
0
)
types
.
RegisterDappFork
(
ParaX
,
"ForkParacrossWithdrawFromParachain"
,
1500000
)
}
}
// GetExecName get para exec name
// GetExecName get para exec name
...
...
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