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
403997db
Commit
403997db
authored
Nov 15, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unpackInput
parent
77762595
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
50 deletions
+4
-50
api.go
plugin/dapp/evm/executor/abi/api.go
+3
-49
parse.go
plugin/dapp/evmxgo/executor/parse.go
+1
-1
No files found.
plugin/dapp/evm/executor/abi/api.go
View file @
403997db
package
abi
import
(
"bytes"
"errors"
"fmt"
"math/big"
...
...
@@ -154,54 +153,6 @@ func Unpack(data []byte, methodName, abiData string) (output []*Param, err error
return
}
func
UnpackInput
(
data
[]
byte
,
methodName
,
abiData
string
)
(
output
[]
*
Param
,
err
error
)
{
if
len
(
data
)
<=
4
{
log
.
Info
(
"UnpackInput"
,
"Data len is not correct"
,
len
(
data
),
"methodName"
,
methodName
)
return
output
,
err
}
// 解析ABI数据结构,获取本次调用的方法对象
abi
,
err
:=
JSON
(
strings
.
NewReader
(
abiData
))
if
err
!=
nil
{
return
output
,
err
}
var
method
Method
var
ok
bool
if
method
,
ok
=
abi
.
Methods
[
methodName
];
!
ok
{
return
output
,
fmt
.
Errorf
(
"function %v not exists"
,
methodName
)
}
if
bytes
.
Compare
(
method
.
ID
,
data
[
:
4
])
!=
0
{
log
.
Info
(
"UnpackInput"
,
"methodID is not consistent method.ID"
,
common
.
Bytes2Hex
(
method
.
ID
),
"data[:4]"
,
common
.
Bytes2Hex
(
data
[
:
4
]))
return
output
,
errors
.
New
(
"Not consistent method"
)
}
if
len
(
data
[
4
:
])
%
32
!=
0
{
return
output
,
errors
.
New
(
"UnpackOutputOrEvent: improperly formatted output"
)
}
values
,
err
:=
method
.
Inputs
.
UnpackValues
(
data
[
4
:
])
if
err
!=
nil
{
return
output
,
err
}
output
=
[]
*
Param
{}
for
i
,
v
:=
range
values
{
arg
:=
method
.
Inputs
[
i
]
pval
:=
&
Param
{
Name
:
arg
.
Name
,
Type
:
arg
.
Type
.
String
(),
Value
:
v
}
if
arg
.
Type
.
String
()
==
"address"
{
pval
.
Value
=
v
.
(
common
.
Hash160Address
)
.
ToAddress
()
.
String
()
log
.
Info
(
"Unpack address"
,
"address"
,
pval
.
Value
)
}
output
=
append
(
output
,
pval
)
}
return
}
//同时支持input,output和event三种数据的unpack
func
UnpackAllTypes
(
data
[]
byte
,
name
,
abiData
string
)
(
output
[]
*
Param
,
err
error
)
{
if
len
(
data
)
==
0
{
...
...
@@ -226,6 +177,9 @@ func UnpackAllTypes(data []byte, name, abiData string) (output []*Param, err err
}
else
{
return
output
,
errors
.
New
(
"UnpackAllTypes: improperly formatted data"
)
}
if
arguments
.
LengthNonIndexed
()
==
0
{
return
output
,
nil
}
}
else
if
event
,
ok
:=
abi
.
Events
[
name
];
ok
{
values
,
err
=
event
.
Inputs
.
UnpackValues
(
data
)
arguments
=
event
.
Inputs
...
...
plugin/dapp/evmxgo/executor/parse.go
View file @
403997db
...
...
@@ -35,7 +35,7 @@ func checkMintPara(mint *evmxgotypes.EvmxgoMint, tx2lock *types.Transaction, db
return
errors
.
New
(
"Not consistent bridgevmxgo address configured by manager"
)
}
unpack
,
err
:=
chain33Abi
.
Unpack
Input
(
action
.
Para
,
LockMethod
,
bridgevmxgo
.
BridgeBankABI
)
unpack
,
err
:=
chain33Abi
.
Unpack
AllTypes
(
action
.
Para
,
LockMethod
,
bridgevmxgo
.
BridgeBankABI
)
if
err
!=
nil
{
return
err
}
...
...
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