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
08482cde
Commit
08482cde
authored
Jan 08, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix create transferToExec
parent
60651391
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
30 deletions
+26
-30
paracross.go
plugin/dapp/paracross/types/paracross.go
+22
-27
type.go
plugin/dapp/paracross/types/type.go
+4
-3
No files found.
plugin/dapp/paracross/types/paracross.go
View file @
08482cde
...
...
@@ -5,7 +5,8 @@
package
types
import
(
fmt
"fmt"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/log/log15"
...
...
@@ -187,34 +188,28 @@ func CreateRawMinerTx(status *ParacrossNodeStatus) (*types.Transaction, error) {
}
// CreateRawTransferTx create paracross asset transfer tx with transfer and withdraw
func
CreateRawTransferTx
(
param
*
types
.
CreateTx
)
(
*
types
.
Transaction
,
error
)
{
if
!
types
.
IsParaExecName
(
param
.
GetExecName
())
{
tlog
.
Error
(
"CreateRawTransferTx"
,
"exec"
,
param
.
GetExecName
())
return
nil
,
types
.
ErrInvalidParam
}
transfer
:=
&
ParacrossAction
{}
if
!
param
.
IsWithdraw
{
v
:=
&
ParacrossAction_Transfer
{
Transfer
:
&
types
.
AssetsTransfer
{
Amount
:
param
.
Amount
,
Note
:
param
.
GetNote
(),
To
:
param
.
GetTo
(),
Cointoken
:
param
.
TokenSymbol
}}
transfer
.
Value
=
v
transfer
.
Ty
=
ParacrossActionTransfer
}
else
{
v
:=
&
ParacrossAction_Withdraw
{
Withdraw
:
&
types
.
AssetsWithdraw
{
Amount
:
param
.
Amount
,
Note
:
param
.
GetNote
(),
To
:
param
.
GetTo
(),
Cointoken
:
param
.
TokenSymbol
}}
transfer
.
Value
=
v
transfer
.
Ty
=
ParacrossActionWithdraw
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
param
.
GetExecName
()),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
param
.
GetExecName
()),
Fee
:
param
.
Fee
,
}
var
err
error
tx
,
err
=
types
.
FormatTx
(
param
.
GetExecName
(),
tx
)
func
(
p
ParacrossType
)
CreateRawTransferTx
(
action
string
,
param
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
tlog
.
Error
(
"ParacrossType CreateTx failed"
,
"action"
,
action
,
"msg"
,
string
(
param
))
tx
,
err
:=
p
.
ExecTypeBase
.
CreateTx
(
action
,
param
)
if
err
!=
nil
{
tlog
.
Error
(
"ParacrossType CreateTx failed"
,
"err"
,
err
,
"action"
,
action
,
"msg"
,
string
(
param
))
return
nil
,
err
}
if
!
types
.
IsPara
()
{
var
transfer
ParacrossAction
err
=
types
.
Decode
(
tx
.
Payload
,
&
transfer
)
if
err
!=
nil
{
tlog
.
Error
(
"ParacrossType CreateTx failed"
,
"decode payload err"
,
err
,
"action"
,
action
,
"msg"
,
string
(
param
))
return
nil
,
err
}
if
action
==
"Transfer"
{
tx
.
To
=
transfer
.
GetTransfer
()
.
To
}
else
if
action
==
"Withdraw"
{
tx
.
To
=
transfer
.
GetWithdraw
()
.
To
}
else
if
action
==
"TransferToExec"
{
tx
.
To
=
transfer
.
GetTransferToExec
()
.
To
}
}
return
tx
,
nil
}
plugin/dapp/paracross/types/type.go
View file @
08482cde
...
...
@@ -98,15 +98,16 @@ func (p ParacrossType) CreateTx(action string, message json.RawMessage) (*types.
}
return
CreateRawAssetTransferTx
(
&
param
)
}
else
if
action
==
"ParacrossTransfer"
||
action
==
"ParacrossWithdraw"
||
action
==
"ParacrossTransferToExec"
{
}
else
if
action
==
"ParacrossTransfer"
||
action
==
"Transfer"
||
action
==
"ParacrossWithdraw"
||
action
==
"Withdraw"
||
action
==
"ParacrossTransferToExec"
||
action
==
"TransferToExec"
{
var
param
types
.
CreateTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawTransferTx
(
&
param
)
return
p
.
CreateRawTransferTx
(
action
,
message
)
}
return
nil
,
types
.
ErrNotSupport
...
...
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