Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar-client-fabric
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar-client-fabric
Commits
da3e8cf9
Unverified
Commit
da3e8cf9
authored
Apr 19, 2021
by
Alexader
Committed by
GitHub
Apr 19, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feat/did-adaptation
parents
f0044a9a
eba020ca
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
112 deletions
+46
-112
release.yml
.github/workflows/release.yml
+33
-0
.gitignore
.gitignore
+0
-1
Makefile
Makefile
+7
-0
event.go
event.go
+0
-51
contracts.zip
example/contracts.zip
+0
-0
asset_exchange.go
example/contracts/src/asset_exchange/asset_exchange.go
+0
-0
go.sum
example/contracts/src/asset_exchange/go.sum
+0
-0
helper.go
example/contracts/src/asset_exchange/helper.go
+0
-40
helper.go
example/contracts/src/broker/helper.go
+4
-14
receipt.go
receipt.go
+2
-6
No files found.
.github/workflows/release.yml
0 → 100644
View file @
da3e8cf9
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
.gitignore
View file @
da3e8cf9
...
...
@@ -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/
Makefile
View file @
da3e8cf9
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
event.go
View file @
da3e8cf9
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
}
example/contracts.zip
View file @
da3e8cf9
No preview for this file type
example/contracts/src/asset_exchange/asset_exchange.go
deleted
100644 → 0
View file @
f0044a9a
This diff is collapsed.
Click to expand it.
example/contracts/src/asset_exchange/go.sum
deleted
100644 → 0
View file @
f0044a9a
This diff is collapsed.
Click to expand it.
example/contracts/src/asset_exchange/helper.go
deleted
100644 → 0
View file @
f0044a9a
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
}
example/contracts/src/broker/helper.go
View file @
da3e8cf9
...
...
@@ -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
{
...
...
receipt.go
View file @
da3e8cf9
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment