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
3e65900e
Commit
3e65900e
authored
Apr 08, 2021
by
zhourong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(contract): remove unused contract
parent
c00ffc07
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
6 additions
and
112 deletions
+6
-112
.gitignore
.gitignore
+0
-1
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.
.gitignore
View file @
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/
event.go
View file @
3e65900e
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
}
example/contracts.zip
View file @
3e65900e
No preview for this file type
example/contracts/src/asset_exchange/asset_exchange.go
deleted
100644 → 0
View file @
c00ffc07
This diff is collapsed.
Click to expand it.
example/contracts/src/asset_exchange/go.sum
deleted
100644 → 0
View file @
c00ffc07
This diff is collapsed.
Click to expand it.
example/contracts/src/asset_exchange/helper.go
deleted
100644 → 0
View file @
c00ffc07
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 @
3e65900e
...
...
@@ -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
{
...
...
receipt.go
View file @
3e65900e
...
...
@@ -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