Skip to content

Commit

Permalink
update bcos-c-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust committed Jan 25, 2024
1 parent 08cae70 commit 6175c89
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 107 deletions.
76 changes: 0 additions & 76 deletions v3/abi/bind/util.go

This file was deleted.

20 changes: 6 additions & 14 deletions v3/client/go_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package client

import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/FISCO-BCOS/go-sdk/v3/types"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)

Expand Down Expand Up @@ -106,17 +106,17 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
"to": strings.ToLower(msg.To.String()[2:]),
}
if len(msg.Data) > 0 {
arg["data"] = hexutil.Bytes(msg.Data).String()
arg["data"] = hex.EncodeToString(msg.Data)
}
if msg.Value != nil {
arg["value"] = (*hexutil.Big)(msg.Value).String()
arg["value"] = fmt.Sprintf("%#x", msg.Value)
}

if msg.Gas != 0 {
arg["gas"] = hexutil.Uint64(msg.Gas)
arg["gas"] = fmt.Sprintf("%#x", msg.Gas)
}
if msg.GasPrice != nil {
arg["gasPrice"] = (*hexutil.Big)(msg.GasPrice)
arg["gasPrice"] = fmt.Sprintf("%#x", msg.GasPrice)
}

return arg
Expand Down Expand Up @@ -148,11 +148,6 @@ func (c *Client) GetCallOpts() *bind.CallOpts {
return c.callOpts
}

// WaitMined is wrapper of bind.WaitMined
func (c *Client) WaitMined(tx *types.Transaction) (*types.Receipt, error) {
return bind.WaitMined(context.Background(), c, tx)
}

// SMCrypto returns true if use sm crypto
func (c *Client) SMCrypto() bool {
return c.conn.GetCSDK().SMCrypto()
Expand Down Expand Up @@ -199,7 +194,7 @@ func (c *Client) PendingCodeAt(ctx context.Context, address common.Address) ([]b

// CallContract invoke the call method of rpc api
func (c *Client) CallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) {
var hexBytes hexutil.Bytes
var hexBytes []byte
var cr *callResult
err := c.conn.CallContext(ctx, &cr, "call", toCallArg(msg))
if err != nil {
Expand Down Expand Up @@ -386,7 +381,6 @@ func (c *Client) GetBlockNumber(ctx context.Context) (int64, error) {
}

// GetPBFTView returns the latest PBFT view(hex format) of the specific group and it will returns a wrong sentence
// if the consensus algorithm is not the PBFT.
func (c *Client) GetPBFTView(ctx context.Context) ([]byte, error) {
var raw interface{}
err := c.conn.CallContext(ctx, &raw, "getPbftView")
Expand All @@ -395,8 +389,6 @@ func (c *Client) GetPBFTView(ctx context.Context) ([]byte, error) {
}
js, err := json.MarshalIndent(raw, "", indent)
return js, err
// TODO
// Raft consensus
}

type ConsensusNodeInfo struct {
Expand Down
6 changes: 3 additions & 3 deletions v3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ module github.com/FISCO-BCOS/go-sdk/v3

go 1.21.5

//replace github.com/FISCO-BCOS/bcos-c-sdk => ../../bcos-c-sdk
// replace github.com/FISCO-BCOS/bcos-c-sdk => ../../bcos-c-sdk

require (
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240122125257-ba87131d4c17
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240125020548-dbdab210fe92
github.com/FISCO-BCOS/crypto v0.0.0-20200202032121-bd8ab0b5d4f1
github.com/TarsCloud/TarsGo v1.4.5
github.com/deckarep/golang-set/v2 v2.6.0
github.com/ethereum/go-ethereum v1.13.10
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/schollz/progressbar/v3 v3.14.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.5.0
Expand Down Expand Up @@ -80,7 +81,6 @@ require (
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions v3/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EF
github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240122125257-ba87131d4c17 h1:Sl9134y03PD98vO3fSMqABhUT6JFQJZiEOXHvLRuejE=
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240122125257-ba87131d4c17/go.mod h1:n2KxbYa73MW3xdLVu2vpPpoblZMms+CwPmvFkubO9xM=
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240125020548-dbdab210fe92 h1:w9THq2E9Al5IEbpxXgRFkZLK7jbWN5QRPFpfO6MIdNc=
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20240125020548-dbdab210fe92/go.mod h1:n2KxbYa73MW3xdLVu2vpPpoblZMms+CwPmvFkubO9xM=
github.com/FISCO-BCOS/crypto v0.0.0-20200202032121-bd8ab0b5d4f1 h1:ThPht4qK10+cMZC5COIjHPq0INm5HAMVYqrez5zEgFI=
github.com/FISCO-BCOS/crypto v0.0.0-20200202032121-bd8ab0b5d4f1/go.mod h1:UrLdwsFrjiaCsvdcPLcH6B7s/FUmym3qfM93u2ziR+4=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
Expand Down
9 changes: 2 additions & 7 deletions v3/ios/contract_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
)

const (
Expand Down Expand Up @@ -50,14 +49,10 @@ func (c *ContractProxy) PendingCodeAt(ctx context.Context, account common.Addres
// SendTransaction injects the transaction into the pending pool for execution.
// todo ios 怎么处理?
func (c *ContractProxy) SendTransaction(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) {
data, err := rlp.EncodeToBytes(tx)
if err != nil {
fmt.Printf("rlp encode tx error!")
return nil, err
}
data := tx.Bytes()
msg, err := c.newMessage("sendTransaction", c.groupID, hexutil.Encode(data))
if err != nil {
fmt.Printf("rlp encode tx error!")
fmt.Printf("encode tx error!")
return nil, err
}
respString := c.callback.SendRequest(msg.String())
Expand Down
2 changes: 1 addition & 1 deletion v3/precompiled/config/system_config_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewSystemConfigService(client *client.Client) (*SystemConfigService, error)
func (s *SystemConfigService) SetValueByKey(key string, value string) (int64, error) {
_, _, receipt, err := s.systemConfig.SetValueByKey(s.client.GetTransactOpts(), key, value)
if err != nil {
return types.PrecompiledError, fmt.Errorf("client.WaitMined failed, err: %v", err)
return types.PrecompiledError, fmt.Errorf("SetValueByKey failed, err: %v", err)
}
errorMessage := receipt.GetErrorMessage()
if errorMessage != "" {
Expand Down
5 changes: 1 addition & 4 deletions v3/precompiled/sharding/sharding_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ package sharding
import (
"context"
"encoding/hex"
"math/big"
"os"
"testing"

// "fmt"
"math/big"
"time"

"github.com/FISCO-BCOS/go-sdk/v3/client"
"github.com/FISCO-BCOS/go-sdk/v3/precompiled"
"github.com/FISCO-BCOS/go-sdk/v3/types"
// "github.com/ethereum/go-ethereum/common"
)

const (
Expand Down

0 comments on commit 6175c89

Please sign in to comment.