Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreExec tx return gasUsed and process slice parameters when invoke evm contract #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions xuper/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"regexp"

"github.com/xuperchain/xuper-sdk-go/v2/account"
"github.com/xuperchain/xuper-sdk-go/v2/common"
Expand Down Expand Up @@ -337,10 +338,20 @@ func convertToXuper3EvmArgs(args map[string]interface{}) (map[string][]byte, err

func generateInvokeArgs(arg map[string]string, module string) (map[string][]byte, error) {
if module == EvmContractModule {
// todo
argsTmp := make(map[string]interface{}, len(arg))
for k, v := range arg {
argsTmp[k] = v
// 对evm合约请求中的切片参数进行处理
reg := regexp.MustCompile(`\[.*,?.*]`)
if reg.MatchString(v) {
sliceArg := make([]interface{}, 0)
err := json.Unmarshal([]byte(v), &sliceArg)
if err != nil {
return nil, err
}
argsTmp[k] = sliceArg
} else {
argsTmp[k] = v
}
}
return convertToXuper3EvmArgs(argsTmp)

Expand Down
3 changes: 2 additions & 1 deletion xuper/xuperclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (x *XClient) initConn() error {
if x.opt.useGrpcGZIP { // gzip enabled
grpcOpts = append(grpcOpts, grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)))
}
maxRecvMshSize := 64<<20-1
maxRecvMshSize := 64<<20 - 1
if x.cfg.MaxRecvMsgSize != 0 {
maxRecvMshSize = x.cfg.MaxRecvMsgSize
}
Expand Down Expand Up @@ -467,6 +467,7 @@ func (x *XClient) PreExecTx(req *Request) (*Transaction, error) {

return &Transaction{
ContractResponse: cr,
GasUsed: proposal.preResp.GetResponse().GetGasUsed(),
}, nil
}

Expand Down