Unverified Commit da3e8cf9 authored by Alexader's avatar Alexader Committed by GitHub

Merge branch 'master' into feat/did-adaptation

parents f0044a9a eba020ca
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
release:
name: Build Release on Linux and Macos
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.13
- name: Check out code
uses: actions/checkout@v2
- name: Build Binary
run: make release-binary
- name: Release Binary
uses: softprops/action-gh-release@v1
with:
files: build/fabric-client-v*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
......@@ -8,7 +8,6 @@ bin
cover.out
cover.html
coverage.txt
/example/contracts/src/asset_exchange/vendor/
/example/contracts/src/broker/vendor/
/example/contracts/src/data_swapper/vendor/
/example/contracts/src/transfer/vendor/
SHELL := /bin/bash
CURRENT_PATH = $(shell pwd)
DISTRO = $(shell uname)
CURRENT_TAG =$(shell git describe --abbrev=0 --tags)
GO = GO111MODULE=on go
......@@ -29,6 +31,10 @@ docker:
fabric1.4-linux:
cd scripts && sh cross_compile.sh linux-amd64 ${CURRENT_PATH}
release-binary:
mkdir -p build
$(GO) build -o build/fabric-client-${CURRENT_TAG}-${DISTRO} ./*.go
## make linter: Run golanci-lint
linter:
golangci-lint run
\ No newline at end of file
package main
import (
"fmt"
"strconv"
"strings"
"time"
......@@ -31,21 +29,6 @@ func (ev *Event) Convert2IBTP(srcMethod string, ibtpType pb.IBTP_Type) *pb.IBTP
log.Fatalf("Get ibtp payload :%s", err)
}
// TODO: generate proof for init and redeem
if ev.Func == "interchainAssetExchangeInit" {
ibtpType = pb.IBTP_ASSET_EXCHANGE_INIT
ev.Extra, err = generateExtra(ev.Args, ibtpType)
if err != nil {
log.Fatalf("generate extra for asset exchange init :%s", err)
}
} else if ev.Func == "interchainAssetExchangeRedeem" {
ibtpType = pb.IBTP_ASSET_EXCHANGE_REDEEM
ev.Extra = []byte(ev.Args)
} else if ev.Func == "interchainAssetExchangeRefund" {
ibtpType = pb.IBTP_ASSET_EXCHANGE_REFUND
ev.Extra = []byte(ev.Args)
}
return &pb.IBTP{
From: srcMethod,
To: string(bitxid.DID(ev.DstContractDID).GetChainDID()),
......@@ -94,37 +77,3 @@ type Response struct {
Message string `json:"message"`
Data []byte `json:"data"`
}
func generateExtra(args string, typ pb.IBTP_Type) ([]byte, error) {
as := strings.Split(args, ",")
if typ == pb.IBTP_ASSET_EXCHANGE_INIT {
if len(as) != 8 {
return nil, fmt.Errorf("incorrect args count for asset exchange init")
}
assetOnSrc, err := strconv.ParseUint(as[4], 10, 64)
if err != nil {
return nil, err
}
assetOnDst, err := strconv.ParseUint(as[7], 10, 64)
if err != nil {
return nil, err
}
aei := &pb.AssetExchangeInfo{
Id: as[1],
SenderOnSrc: as[2],
ReceiverOnSrc: as[3],
AssetOnSrc: assetOnSrc,
SenderOnDst: as[4],
ReceiverOnDst: as[5],
AssetOnDst: assetOnDst,
}
return aei.Marshal()
}
return nil, nil
}
No preview for this file type
This diff is collapsed.
This diff is collapsed.
package main
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
)
func getUint64(stub shim.ChaincodeStubInterface, key string) (uint64, error) {
value, err := stub.GetState(key)
if err != nil {
return 0, err
}
if value == nil || string(value) == "" {
return 0, nil
}
ret, err := strconv.ParseUint(string(value), 10, 64)
if err != nil {
return 0, err
}
return ret, nil
}
func getAmountArg(arg string) (uint64, error) {
amount, err := strconv.ParseUint(arg, 10, 64)
if err != nil {
shim.Error(fmt.Errorf("amount must be an interger %w", err).Error())
return 0, err
}
if amount < 0 {
return 0, fmt.Errorf("amount must be a positive integer, got %s", arg)
}
return amount, nil
}
......@@ -178,14 +178,9 @@ func (broker *Broker) getList(stub shim.ChaincodeStubInterface) pb.Response {
func (broker *Broker) checkAdmin(stub shim.ChaincodeStubInterface, function string) bool {
checks := map[string]struct{}{
"audit": {},
"interchainCharge": {},
"interchainConfirm": {},
"interchainGet": {},
"interchainSet": {},
"interchainAssetExchangeInit": {},
"interchainAssetExchangeRedeem": {},
"interchainAssetExchangeRefund": {},
"audit": {},
"invokeInterchain": {},
"invokeIndexUpdate": {},
}
if _, ok := checks[function]; !ok {
......@@ -197,12 +192,7 @@ func (broker *Broker) checkAdmin(stub shim.ChaincodeStubInterface, function stri
func (broker *Broker) checkWhitelist(stub shim.ChaincodeStubInterface, function string) bool {
checks := map[string]struct{}{
"InterchainTransferInvoke": {},
"InterchainDataSwapInvoke": {},
"InterchainInvoke": {},
"InterchainAssetExchangeInitInvoke": {},
"InterchainAssetExchangeRedeemInvoke": {},
"InterchainAssetExchangeRefundInvoke": {},
"EmitInterchainEvent": {},
}
if _, ok := checks[function]; !ok {
......
......@@ -47,12 +47,8 @@ func (c *Client) generateCallback(original *pb.IBTP, args [][]byte, proof []byte
}
typ := pb.IBTP_RECEIPT_SUCCESS
if original.Type == pb.IBTP_INTERCHAIN {
if !status {
typ = pb.IBTP_RECEIPT_FAILURE
}
} else {
typ = pb.IBTP_ASSET_EXCHANGE_RECEIPT
if !status {
typ = pb.IBTP_RECEIPT_FAILURE
}
return &pb.IBTP{
......
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