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
abde63ec
Commit
abde63ec
authored
Nov 10, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make getunpack more generally
parent
61100ffc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
31 deletions
+31
-31
test-rpc.sh
plugin/dapp/evm/cmd/test/test-rpc.sh
+5
-4
query.go
plugin/dapp/evm/executor/query.go
+2
-7
evmcontract.proto
plugin/dapp/evm/proto/evmcontract.proto
+1
-1
evmcontract.pb.go
plugin/dapp/evm/types/evmcontract.pb.go
+23
-19
No files found.
plugin/dapp/evm/cmd/test/test-rpc.sh
View file @
abde63ec
...
...
@@ -54,6 +54,7 @@ function evm_callQuery() {
local
parameter
=
$1
local
callerAddr
=
$2
local
resok
=
$3
local
methodName
=
$4
req
=
'{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"GetPackData","payload":{"abi":"'
${
erc20_abi
}
'","parameter":"'
${
parameter
}
'"}}]}'
chain33_Http
"
$req
"
"
${
MAIN_HTTP
}
"
'(.result != null)'
"GetPackData"
".result.packData"
...
...
@@ -63,7 +64,7 @@ function evm_callQuery() {
chain33_Http
"
$req
"
"
${
MAIN_HTTP
}
"
'(.result != null)'
"Query"
".result.rawData"
echo
"
$RETURN_RESP
"
req
=
'{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"GetUnpackData","payload":{"abi":"'
${
erc20_abi
}
'","
parameter":"'
${
parameter
}
'","data":"'
${
RETURN_RESP
}
'"}}]}'
req
=
'{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"GetUnpackData","payload":{"abi":"'
${
erc20_abi
}
'","
methodName":"'
${
methodName
}
'","data":"'
${
RETURN_RESP
}
'"}}]}'
chain33_Http
"
$req
"
"
${
MAIN_HTTP
}
"
'(.result != null)'
"GetUnpackData"
".result.unpackData[0]"
echo
"
$RETURN_RESP
"
...
...
@@ -77,7 +78,7 @@ function evm_addressCheck() {
resok
=
'(.result.contract == true) and (.result.contractAddr == "'
"
$evm_contractAddr
"
'")'
chain33_Http
"
$req
"
"
${
MAIN_HTTP
}
"
"
${
resok
}
"
"CheckAddrExists"
evm_callQuery
"symbol()"
"
${
evm_creatorAddr
}
"
"zbc"
evm_callQuery
"symbol()"
"
${
evm_creatorAddr
}
"
"zbc"
"symbol"
}
function
evm_transfer
()
{
...
...
@@ -90,8 +91,8 @@ function evm_transfer() {
tx
=
$(
curl
-ksd
'{"method":"evm.CreateCallTx","params":[{"abi":"'
"
${
erc20_abi
}
"
'", "fee":'
${
gas
}
', "note": "evm transfer rpc test", "parameter": "transfer('
${
evm_transferAddr
}
', 20)", "expire":"'
${
expire
}
'", "contractAddr":"'
"
${
evm_contractAddr
}
"
'", "paraName":"'
"
${
paraName
}
"
'"}]}'
"
${
MAIN_HTTP
}
"
| jq
-r
".result"
)
chain33_SignAndSendTx
"
${
tx
}
"
"
${
evm_creatorAddr_key
}
"
"
$MAIN_HTTP
"
"
${
expire
}
"
"
${
gas
}
"
evm_callQuery
"balanceOf(
${
evm_creatorAddr
}
)"
"
${
evm_creatorAddr
}
"
"3280"
evm_callQuery
"balanceOf(
${
evm_transferAddr
}
)"
"
${
evm_transferAddr
}
"
"20"
evm_callQuery
"balanceOf(
${
evm_creatorAddr
}
)"
"
${
evm_creatorAddr
}
"
"3280"
"balanceOf"
evm_callQuery
"balanceOf(
${
evm_transferAddr
}
)"
"
${
evm_transferAddr
}
"
"20"
"balanceOf"
}
# 查询交易的执行结果
...
...
plugin/dapp/evm/executor/query.go
View file @
abde63ec
...
...
@@ -188,7 +188,7 @@ func (evm *EVMExecutor) Query_GetNonce(in *evmtypes.EvmGetNonceReq) (types.Messa
func
(
evm
*
EVMExecutor
)
Query_GetPackData
(
in
*
evmtypes
.
EvmGetPackDataReq
)
(
types
.
Message
,
error
)
{
evm
.
CheckInit
()
_
,
packData
,
err
:=
evmAbi
.
Pack
(
in
.
Parameter
,
in
.
Abi
,
tru
e
)
_
,
packData
,
err
:=
evmAbi
.
Pack
(
in
.
Parameter
,
in
.
Abi
,
fals
e
)
if
nil
!=
err
{
return
nil
,
errors
.
New
(
"Failed to do evmAbi.Pack"
+
err
.
Error
())
}
...
...
@@ -199,17 +199,12 @@ func (evm *EVMExecutor) Query_GetPackData(in *evmtypes.EvmGetPackDataReq) (types
func
(
evm
*
EVMExecutor
)
Query_GetUnpackData
(
in
*
evmtypes
.
EvmGetUnpackDataReq
)
(
types
.
Message
,
error
)
{
evm
.
CheckInit
()
methodName
,
_
,
err
:=
evmAbi
.
Pack
(
in
.
Parameter
,
in
.
Abi
,
true
)
if
nil
!=
err
{
return
nil
,
errors
.
New
(
"Failed to do evmAbi.Pack"
+
err
.
Error
())
}
data
,
err
:=
common
.
FromHex
(
in
.
Data
)
if
nil
!=
err
{
return
nil
,
errors
.
New
(
"common.FromHex failed due to:"
+
err
.
Error
())
}
outputs
,
err
:=
evmAbi
.
Unpack
(
data
,
m
ethodName
,
in
.
Abi
)
outputs
,
err
:=
evmAbi
.
Unpack
(
data
,
in
.
M
ethodName
,
in
.
Abi
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"unpack evm return error"
+
err
.
Error
())
}
...
...
plugin/dapp/evm/proto/evmcontract.proto
View file @
abde63ec
...
...
@@ -202,7 +202,7 @@ message EvmGetPackDataRespose {
message
EvmGetUnpackDataReq
{
string
abi
=
1
;
string
parameter
=
2
;
string
methodName
=
2
;
string
data
=
3
;
}
...
...
plugin/dapp/evm/types/evmcontract.pb.go
View file @
abde63ec
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.2
6
.0
// protoc-gen-go v1.2
3
.0
// protoc v3.9.1
// source: evmcontract.proto
package
types
import
(
reflect
"reflect"
sync
"sync"
proto
"github.com/golang/protobuf/proto"
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
reflect
"reflect"
sync
"sync"
)
const
(
...
...
@@ -21,6 +21,10 @@ const (
_
=
protoimpl
.
EnforceVersion
(
protoimpl
.
MaxVersion
-
20
)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const
_
=
proto
.
ProtoPackageIsVersion4
//合约对象信息
type
EVMContractObject
struct
{
state
protoimpl
.
MessageState
...
...
@@ -1862,9 +1866,9 @@ type EvmGetUnpackDataReq struct {
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
Abi
string
`protobuf:"bytes,1,opt,name=abi,proto3" json:"abi,omitempty"`
Parameter
string
`protobuf:"bytes,2,opt,name=parameter,proto3" json:"parameter
,omitempty"`
Data
string
`protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
Abi
string
`protobuf:"bytes,1,opt,name=abi,proto3" json:"abi,omitempty"`
MethodName
string
`protobuf:"bytes,2,opt,name=methodName,proto3" json:"methodName
,omitempty"`
Data
string
`protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
}
func
(
x
*
EvmGetUnpackDataReq
)
Reset
()
{
...
...
@@ -1906,9 +1910,9 @@ func (x *EvmGetUnpackDataReq) GetAbi() string {
return
""
}
func
(
x
*
EvmGetUnpackDataReq
)
Get
Parameter
()
string
{
func
(
x
*
EvmGetUnpackDataReq
)
Get
MethodName
()
string
{
if
x
!=
nil
{
return
x
.
Parameter
return
x
.
MethodName
}
return
""
}
...
...
@@ -2169,18 +2173,18 @@ var file_evmcontract_proto_rawDesc = []byte{
0x61
,
0x6d
,
0x65
,
0x74
,
0x65
,
0x72
,
0x22
,
0x33
,
0x0a
,
0x15
,
0x45
,
0x76
,
0x6d
,
0x47
,
0x65
,
0x74
,
0x50
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6f
,
0x73
,
0x65
,
0x12
,
0x1a
,
0x0a
,
0x08
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x08
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x22
,
0x5
9
,
0x0a
,
0x13
,
0x45
,
0x09
,
0x52
,
0x08
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x22
,
0x5
b
,
0x0a
,
0x13
,
0x45
,
0x76
,
0x6d
,
0x47
,
0x65
,
0x74
,
0x55
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x71
,
0x12
,
0x10
,
0x0a
,
0x03
,
0x61
,
0x62
,
0x69
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x03
,
0x61
,
0x62
,
0x69
,
0x12
,
0x1
c
,
0x0a
,
0x09
,
0x70
,
0x61
,
0x72
,
0x61
,
0x6d
,
0x65
,
0x74
,
0x65
,
0x
72
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x09
,
0x70
,
0x61
,
0x72
,
0x61
,
0x6d
,
0x65
,
0x7
4
,
0x
65
,
0x72
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x64
,
0x61
,
0x74
,
0x61
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x
52
,
0x04
,
0x64
,
0x61
,
0x74
,
0x61
,
0x22
,
0x39
,
0x0a
,
0x17
,
0x45
,
0x76
,
0x6d
,
0x47
,
0x65
,
0x74
,
0x
55
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6f
,
0x73
,
0x6
5
,
0x12
,
0x1e
,
0x0a
,
0x0a
,
0x75
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x18
,
0x
01
,
0x20
,
0x03
,
0x28
,
0x09
,
0x52
,
0x0a
,
0x75
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x7
4
,
0x61
,
0x
42
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
0x03
,
0x61
,
0x62
,
0x69
,
0x12
,
0x1
e
,
0x0a
,
0x0a
,
0x6d
,
0x65
,
0x74
,
0x68
,
0x6f
,
0x64
,
0x4e
,
0x61
,
0x
6d
,
0x65
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0a
,
0x6d
,
0x65
,
0x74
,
0x68
,
0x6f
,
0x6
4
,
0x
4e
,
0x61
,
0x6d
,
0x65
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x64
,
0x61
,
0x74
,
0x61
,
0x18
,
0x03
,
0x20
,
0x01
,
0x
28
,
0x09
,
0x52
,
0x04
,
0x64
,
0x61
,
0x74
,
0x61
,
0x22
,
0x39
,
0x0a
,
0x17
,
0x45
,
0x76
,
0x6d
,
0x47
,
0x
65
,
0x74
,
0x55
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6
f
,
0x73
,
0x65
,
0x12
,
0x1e
,
0x0a
,
0x0a
,
0x75
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x44
,
0x61
,
0x74
,
0x
61
,
0x18
,
0x01
,
0x20
,
0x03
,
0x28
,
0x09
,
0x52
,
0x0a
,
0x75
,
0x6e
,
0x70
,
0x61
,
0x63
,
0x6b
,
0x4
4
,
0x61
,
0x
74
,
0x61
,
0x42
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x
06
,
0x70
,
0x
72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
(
...
...
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