Unverified Commit 88308a69 authored by Alexader's avatar Alexader Committed by GitHub

Merge pull request #33 from meshplus/refactor/remove-unused-contract

refactor(contract): remove unused contract
parents c00ffc07 3e65900e
......@@ -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/
package main
import (
"fmt"
"strconv"
"strings"
"time"
......@@ -31,21 +29,6 @@ func (ev *Event) Convert2IBTP(from 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: from,
To: ev.DstChainID,
......@@ -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
}
......@@ -177,14 +177,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 {
......@@ -196,12 +191,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