Unverified Commit c20c7e19 authored by Aiden X's avatar Aiden X Committed by GitHub

Merge pull request #2 from meshplus/chore/update-version

chore(*): update bitxhub sdk and kit version
parents 1786b2c7 08071845
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
# - deadcode
- depguard
- dogsled
- dupl
- errcheck
# - funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
# - golint
# - gomnd
- goprintffuncname
# - gosec
- gosimple
- govet
- ineffassign
# - interfacer
# - lll
- misspell
- nakedret
- rowserrcheck
# - scopelint
- staticcheck
- structcheck
# - stylecheck
- typecheck
- unconvert
# - unparam
# - unused
- varcheck
# - whitespace
......@@ -7,6 +7,9 @@ help: Makefile
@echo "Choose a command run:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
prepare:
cd scripts && bash prepare.sh
## make fabric1.4: build fabric(1.4) client plugin
fabric1.4:
mkdir -p build
......@@ -17,5 +20,5 @@ fabric1.4-linux:
## make linter: Run golanci-lint
linter:
golangci-lint run -E goimports --skip-dirs-use-default -D staticcheck
golangci-lint run
......@@ -383,44 +383,6 @@ func (c *Client) CommitCallback(ibtp *pb.IBTP) error {
return nil
}
func (c *Client) unpackRet(response *channel.Response) (*peer.ChaincodeAction, error) {
txHash := response.Payload
l, err := ledger.New(c.consumer.channelProvider)
if err != nil {
return nil, fmt.Errorf("new ledger: %w", err)
}
t, err := l.QueryTransaction(fab.TransactionID(txHash))
if err != nil {
return nil, fmt.Errorf("query tx: %w", err)
}
pd := &common.Payload{}
if err := proto.Unmarshal(t.TransactionEnvelope.Payload, pd); err != nil {
return nil, fmt.Errorf("unmarshal envelope: %w", err)
}
pt := &peer.Transaction{}
if err := proto.Unmarshal(pd.Data, pt); err != nil {
return nil, fmt.Errorf("unmarshal peer tx: %w", err)
}
action := &peer.ChaincodeActionPayload{}
if err := proto.Unmarshal(pt.Actions[0].Payload, action); err != nil {
return nil, fmt.Errorf("unmarshal action: %w", err)
}
payload := &peer.ProposalResponsePayload{}
if err := proto.Unmarshal(action.Action.ProposalResponsePayload, payload); err != nil {
return nil, fmt.Errorf("unmarshal proposal: %w", err)
}
result := &peer.ChaincodeAction{}
if err := proto.Unmarshal(payload.Extension, result); err != nil {
return nil, fmt.Errorf("unmarshal chaincode action: %w", err)
}
return result, nil
}
func (c *Client) unpackIBTP(response *channel.Response, ibtpType pb.IBTP_Type) (*pb.IBTP, error) {
ret := &Event{}
if err := json.Unmarshal(response.Payload, ret); err != nil {
......
......@@ -196,6 +196,9 @@ func (broker *Broker) InterchainInvoke(stub shim.ChaincodeStubInterface, args []
}
txValue, err := json.Marshal(tx)
if err != nil {
return shim.Error(err.Error())
}
// persist out message
key := broker.outMsgKey(tx.DstChainID, strconv.FormatUint(tx.Index, 10))
......
......@@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
)
func getUint64(stub shim.ChaincodeStubInterface, key string) (uint64, error) {
......@@ -27,9 +28,5 @@ func getAmountArg(arg string) (uint64, error) {
return 0, err
}
if amount < 0 {
return 0, fmt.Errorf("amount must be a positive integer, got %s", arg)
}
return amount, nil
}
......@@ -10,19 +10,20 @@ require (
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004
github.com/fsouza/go-dockerclient v1.6.3 // indirect
github.com/golang/protobuf v1.3.2
github.com/golangci/golangci-lint v1.23.0 // indirect
github.com/google/certificate-transparency-go v1.1.0 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hyperledger/fabric v1.4.6
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a // indirect
github.com/hyperledger/fabric-lib-go v1.0.0 // indirect
github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5
github.com/meshplus/bitxhub-kit v0.0.0-20200329124935-585edb85ca63
github.com/meshplus/bitxhub-model v0.0.0-20200329125320-a37501c7a13e
github.com/meshplus/bitxhub-kit v1.0.0-rc1
github.com/meshplus/bitxhub-model v1.0.0-rc1
github.com/meshplus/pier v0.0.0-00010101000000-000000000000
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/viper v1.4.0
github.com/spf13/viper v1.6.1
github.com/sykesm/zap-logfmt v0.0.3 // indirect
)
......
This diff is collapsed.
......@@ -4,8 +4,6 @@ import (
"fmt"
"time"
"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/meshplus/bitxhub-model/pb"
)
......@@ -40,43 +38,3 @@ func (c *Client) generateCallback(toExecute *pb.IBTP, args [][]byte, proof []byt
Version: toExecute.Version,
}, nil
}
func (c *Client) interchainCharge(toExecute *pb.IBTP, response channel.Response) (*pb.IBTP, error) {
pd := &pb.Payload{}
if err := pd.Unmarshal(toExecute.Payload); err != nil {
return nil, fmt.Errorf("toExecute payload unmarshal: %w", err)
}
newArgs := [][]byte{[]byte("false"), pd.Args[0]}
if response.ChaincodeStatus == shim.OK {
newArgs[0] = []byte("true")
}
newArgs = append(newArgs, pd.Args[2:]...)
newPayload := &pb.Payload{
SrcContractId: pd.DstContractId,
DstContractId: pd.SrcContractId,
Func: "interchainConfirm",
Args: newArgs,
}
logger.Info("ack ibtp is:", newPayload)
pdb, err := newPayload.Marshal()
if err != nil {
return nil, err
}
proof, err := c.getProof(response)
if err != nil {
return nil, err
}
return &pb.IBTP{
From: toExecute.From,
To: toExecute.To,
Index: toExecute.Index,
Type: pb.IBTP_RECEIPT,
Timestamp: time.Now().UnixNano(),
Proof: proof,
Payload: pdb,
Version: toExecute.Version,
}, nil
}
#!/usr/bin/env bash
BLUE='\033[0;34m'
NC='\033[0m'
function print_blue() {
printf "${BLUE}%s${NC}\n" "$1"
}
print_blue "===> 1. Install golangci-lint"
if ! type golanci-lint >/dev/null 2>&1; then
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.0
fi
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment