Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
plugin
Commits
fab9bc10
Commit
fab9bc10
authored
Dec 14, 2021
by
hezhengjun
Committed by
33cn
Dec 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add show locked balance
parent
b1845825
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
155 additions
and
11 deletions
+155
-11
ethereumRelayerCmd.go
plugin/dapp/cross2eth/ebcli/ethereumRelayerCmd.go
+33
-0
relayer.proto
plugin/dapp/cross2eth/ebrelayer/proto/relayer.proto
+6
-0
ethereum.go
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
+19
-0
manager.go
plugin/dapp/cross2eth/ebrelayer/relayer/manager.go
+15
-0
config.pb.go
plugin/dapp/cross2eth/ebrelayer/types/config.pb.go
+2
-3
relayer.pb.go
plugin/dapp/cross2eth/ebrelayer/types/relayer.pb.go
+80
-8
No files found.
plugin/dapp/cross2eth/ebcli/ethereumRelayerCmd.go
View file @
fab9bc10
...
@@ -45,6 +45,7 @@ func EthereumRelayerCmd() *cobra.Command {
...
@@ -45,6 +45,7 @@ func EthereumRelayerCmd() *cobra.Command {
LockAsyncCmd
(),
LockAsyncCmd
(),
ShowBridgeBankAddrCmd
(),
ShowBridgeBankAddrCmd
(),
ShowBridgeRegistryAddrCmd
(),
ShowBridgeRegistryAddrCmd
(),
ShowBalanceLockedCmd
(),
DeployERC20Cmd
(),
DeployERC20Cmd
(),
TokenCmd
(),
TokenCmd
(),
MultiSignEthCmd
(),
MultiSignEthCmd
(),
...
@@ -714,6 +715,38 @@ func ShowBridgeRegistryAddr(cmd *cobra.Command, args []string) {
...
@@ -714,6 +715,38 @@ func ShowBridgeRegistryAddr(cmd *cobra.Command, args []string) {
}
}
//GetBalanceCmd ...
//GetBalanceCmd ...
func
ShowBalanceLockedCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showBalanceLocked"
,
Short
:
"show Balance Locked in BridgeBank"
,
Run
:
ShowBalanceLocked
,
}
ShowBalanceLockedFlags
(
cmd
)
return
cmd
}
func
ShowBalanceLockedFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"bridgeBank"
,
"b"
,
""
,
"bridgeBank address"
)
_
=
cmd
.
MarkFlagRequired
(
"bridgeBank"
)
cmd
.
Flags
()
.
StringP
(
"tokenAddr"
,
"t"
,
""
,
"token address, optional, nil for Eth"
)
}
//GetBalance ...
func
ShowBalanceLocked
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
bridgeBank
,
_
:=
cmd
.
Flags
()
.
GetString
(
"bridgeBank"
)
tokenAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenAddr"
)
para
:=
&
ebTypes
.
BalanceLockedReq
{
BridgeBank
:
bridgeBank
,
TokenAddr
:
tokenAddr
,
}
var
res
ebTypes
.
ReplyBalance
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Manager.ShowBalanceLocked"
,
para
,
&
res
)
ctx
.
Run
()
}
//GetBalanceCmd ...
func
GetBalanceCmd
()
*
cobra
.
Command
{
func
GetBalanceCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"balance"
,
Use
:
"balance"
,
...
...
plugin/dapp/cross2eth/ebrelayer/proto/relayer.proto
View file @
fab9bc10
...
@@ -236,3 +236,8 @@ message ETHConfigLockedTokenOffline {
...
@@ -236,3 +236,8 @@ message ETHConfigLockedTokenOffline {
string
threshold
=
3
;
string
threshold
=
3
;
uint32
percents
=
4
;
uint32
percents
=
4
;
}
}
message
BalanceLockedReq
{
string
bridgeBank
=
1
;
string
tokenAddr
=
2
;
}
\ No newline at end of file
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
View file @
fab9bc10
...
@@ -252,6 +252,25 @@ func (ethRelayer *Relayer4Ethereum) DeployContrcts() (bridgeRegistry string, err
...
@@ -252,6 +252,25 @@ func (ethRelayer *Relayer4Ethereum) DeployContrcts() (bridgeRegistry string, err
}
}
//GetBalance :获取某一个币种的余额
//GetBalance :获取某一个币种的余额
func
(
ethRelayer
*
Relayer4Ethereum
)
ShowBalanceLocked
(
tokenAddr
,
bridgeBank
string
)
(
string
,
error
)
{
bridgeBankAddrInt
:=
common
.
HexToAddress
(
bridgeBank
)
bridgeBankHandle
,
err
:=
generated
.
NewBridgeBank
(
bridgeBankAddrInt
,
ethRelayer
.
clientSpec
)
if
nil
!=
err
{
return
""
,
errors
.
New
(
"failed to NewBridgeBank"
)
}
opts
:=
&
bind
.
CallOpts
{
Pending
:
true
,
From
:
common
.
HexToAddress
(
bridgeBank
),
Context
:
context
.
Background
(),
}
balance
,
err
:=
bridgeBankHandle
.
LockedFunds
(
opts
,
common
.
HexToAddress
(
tokenAddr
))
if
nil
!=
err
{
return
""
,
err
}
return
balance
.
String
(),
nil
}
func
(
ethRelayer
*
Relayer4Ethereum
)
GetBalance
(
tokenAddr
,
owner
string
)
(
string
,
error
)
{
func
(
ethRelayer
*
Relayer4Ethereum
)
GetBalance
(
tokenAddr
,
owner
string
)
(
string
,
error
)
{
return
ethtxs
.
GetBalance
(
ethRelayer
.
clientSpec
,
tokenAddr
,
owner
)
return
ethtxs
.
GetBalance
(
ethRelayer
.
clientSpec
,
tokenAddr
,
owner
)
}
}
...
...
plugin/dapp/cross2eth/ebrelayer/relayer/manager.go
View file @
fab9bc10
...
@@ -668,6 +668,21 @@ func (manager *Manager) IsProphecyPending(claimID [32]byte, result *interface{})
...
@@ -668,6 +668,21 @@ func (manager *Manager) IsProphecyPending(claimID [32]byte, result *interface{})
return
nil
return
nil
}
}
func
(
manager
*
Manager
)
ShowBalanceLocked
(
BalanceLockedReq
*
relayerTypes
.
BalanceLockedReq
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
balance
,
err
:=
manager
.
ethRelayer
.
ShowBalanceLocked
(
BalanceLockedReq
.
TokenAddr
,
BalanceLockedReq
.
BridgeBank
)
if
nil
!=
err
{
return
err
}
*
result
=
relayerTypes
.
ReplyBalance
{
IsOK
:
true
,
Balance
:
balance
,
}
return
nil
}
//GetBalance ...
//GetBalance ...
func
(
manager
*
Manager
)
GetBalance
(
balanceAddr
relayerTypes
.
BalanceAddr
,
result
*
interface
{})
error
{
func
(
manager
*
Manager
)
GetBalance
(
balanceAddr
relayerTypes
.
BalanceAddr
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
manager
.
mtx
.
Lock
()
...
...
plugin/dapp/cross2eth/ebrelayer/types/config.pb.go
View file @
fab9bc10
...
@@ -7,12 +7,11 @@
...
@@ -7,12 +7,11 @@
package
types
package
types
import
(
import
(
reflect
"reflect"
sync
"sync"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
reflect
"reflect"
sync
"sync"
)
)
const
(
const
(
...
...
plugin/dapp/cross2eth/ebrelayer/types/relayer.pb.go
View file @
fab9bc10
...
@@ -7,12 +7,11 @@
...
@@ -7,12 +7,11 @@
package
types
package
types
import
(
import
(
reflect
"reflect"
sync
"sync"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
reflect
"reflect"
sync
"sync"
)
)
const
(
const
(
...
@@ -2330,6 +2329,61 @@ func (x *ETHConfigLockedTokenOffline) GetPercents() uint32 {
...
@@ -2330,6 +2329,61 @@ func (x *ETHConfigLockedTokenOffline) GetPercents() uint32 {
return
0
return
0
}
}
type
BalanceLockedReq
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
BridgeBank
string
`protobuf:"bytes,1,opt,name=bridgeBank,proto3" json:"bridgeBank,omitempty"`
TokenAddr
string
`protobuf:"bytes,2,opt,name=tokenAddr,proto3" json:"tokenAddr,omitempty"`
}
func
(
x
*
BalanceLockedReq
)
Reset
()
{
*
x
=
BalanceLockedReq
{}
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_relayer_proto_msgTypes
[
34
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
}
func
(
x
*
BalanceLockedReq
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
func
(
*
BalanceLockedReq
)
ProtoMessage
()
{}
func
(
x
*
BalanceLockedReq
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_relayer_proto_msgTypes
[
34
]
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
if
ms
.
LoadMessageInfo
()
==
nil
{
ms
.
StoreMessageInfo
(
mi
)
}
return
ms
}
return
mi
.
MessageOf
(
x
)
}
// Deprecated: Use BalanceLockedReq.ProtoReflect.Descriptor instead.
func
(
*
BalanceLockedReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_relayer_proto_rawDescGZIP
(),
[]
int
{
34
}
}
func
(
x
*
BalanceLockedReq
)
GetBridgeBank
()
string
{
if
x
!=
nil
{
return
x
.
BridgeBank
}
return
""
}
func
(
x
*
BalanceLockedReq
)
GetTokenAddr
()
string
{
if
x
!=
nil
{
return
x
.
TokenAddr
}
return
""
}
var
File_relayer_proto
protoreflect
.
FileDescriptor
var
File_relayer_proto
protoreflect
.
FileDescriptor
var
file_relayer_proto_rawDesc
=
[]
byte
{
var
file_relayer_proto_rawDesc
=
[]
byte
{
...
@@ -2598,9 +2652,14 @@ var file_relayer_proto_rawDesc = []byte{
...
@@ -2598,9 +2652,14 @@ var file_relayer_proto_rawDesc = []byte{
0x79
,
0x6d
,
0x62
,
0x6f
,
0x6c
,
0x12
,
0x1c
,
0x0a
,
0x09
,
0x74
,
0x68
,
0x72
,
0x65
,
0x73
,
0x68
,
0x6f
,
0x79
,
0x6d
,
0x62
,
0x6f
,
0x6c
,
0x12
,
0x1c
,
0x0a
,
0x09
,
0x74
,
0x68
,
0x72
,
0x65
,
0x73
,
0x68
,
0x6f
,
0x6c
,
0x64
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x09
,
0x74
,
0x68
,
0x72
,
0x65
,
0x73
,
0x68
,
0x6c
,
0x64
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x09
,
0x74
,
0x68
,
0x72
,
0x65
,
0x73
,
0x68
,
0x6f
,
0x6c
,
0x64
,
0x12
,
0x1a
,
0x0a
,
0x08
,
0x70
,
0x65
,
0x72
,
0x63
,
0x65
,
0x6e
,
0x74
,
0x73
,
0x18
,
0x6f
,
0x6c
,
0x64
,
0x12
,
0x1a
,
0x0a
,
0x08
,
0x70
,
0x65
,
0x72
,
0x63
,
0x65
,
0x6e
,
0x74
,
0x73
,
0x18
,
0x04
,
0x20
,
0x01
,
0x28
,
0x0d
,
0x52
,
0x08
,
0x70
,
0x65
,
0x72
,
0x63
,
0x65
,
0x6e
,
0x74
,
0x73
,
0x42
,
0x04
,
0x20
,
0x01
,
0x28
,
0x0d
,
0x52
,
0x08
,
0x70
,
0x65
,
0x72
,
0x63
,
0x65
,
0x6e
,
0x74
,
0x73
,
0x22
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x50
,
0x0a
,
0x10
,
0x42
,
0x61
,
0x6c
,
0x61
,
0x6e
,
0x63
,
0x65
,
0x4c
,
0x6f
,
0x63
,
0x6b
,
0x65
,
0x64
,
0x74
,
0x6f
,
0x33
,
0x52
,
0x65
,
0x71
,
0x12
,
0x1e
,
0x0a
,
0x0a
,
0x62
,
0x72
,
0x69
,
0x64
,
0x67
,
0x65
,
0x42
,
0x61
,
0x6e
,
0x6b
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0a
,
0x62
,
0x72
,
0x69
,
0x64
,
0x67
,
0x65
,
0x42
,
0x61
,
0x6e
,
0x6b
,
0x12
,
0x1c
,
0x0a
,
0x09
,
0x74
,
0x6f
,
0x6b
,
0x65
,
0x6e
,
0x41
,
0x64
,
0x64
,
0x72
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x09
,
0x74
,
0x6f
,
0x6b
,
0x65
,
0x6e
,
0x41
,
0x64
,
0x64
,
0x72
,
0x42
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
}
var
(
var
(
...
@@ -2615,7 +2674,7 @@ func file_relayer_proto_rawDescGZIP() []byte {
...
@@ -2615,7 +2674,7 @@ func file_relayer_proto_rawDescGZIP() []byte {
return
file_relayer_proto_rawDescData
return
file_relayer_proto_rawDescData
}
}
var
file_relayer_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
4
)
var
file_relayer_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
5
)
var
file_relayer_proto_goTypes
=
[]
interface
{}{
var
file_relayer_proto_goTypes
=
[]
interface
{}{
(
*
Account4Relayer
)(
nil
),
// 0: types.Account4Relayer
(
*
Account4Relayer
)(
nil
),
// 0: types.Account4Relayer
(
*
ValidatorAddr4EthRelayer
)(
nil
),
// 1: types.ValidatorAddr4EthRelayer
(
*
ValidatorAddr4EthRelayer
)(
nil
),
// 1: types.ValidatorAddr4EthRelayer
...
@@ -2651,6 +2710,7 @@ var file_relayer_proto_goTypes = []interface{}{
...
@@ -2651,6 +2710,7 @@ var file_relayer_proto_goTypes = []interface{}{
(
*
ERC20Token
)(
nil
),
// 31: types.ERC20Token
(
*
ERC20Token
)(
nil
),
// 31: types.ERC20Token
(
*
ETHTokenLockAddress
)(
nil
),
// 32: types.ETHTokenLockAddress
(
*
ETHTokenLockAddress
)(
nil
),
// 32: types.ETHTokenLockAddress
(
*
ETHConfigLockedTokenOffline
)(
nil
),
// 33: types.ETHConfigLockedTokenOffline
(
*
ETHConfigLockedTokenOffline
)(
nil
),
// 33: types.ETHConfigLockedTokenOffline
(
*
BalanceLockedReq
)(
nil
),
// 34: types.BalanceLockedReq
}
}
var
file_relayer_proto_depIdxs
=
[]
int32
{
var
file_relayer_proto_depIdxs
=
[]
int32
{
25
,
// 0: types.TokenAddressArray.tokenAddress:type_name -> types.TokenAddress
25
,
// 0: types.TokenAddressArray.tokenAddress:type_name -> types.TokenAddress
...
@@ -3077,6 +3137,18 @@ func file_relayer_proto_init() {
...
@@ -3077,6 +3137,18 @@ func file_relayer_proto_init() {
return
nil
return
nil
}
}
}
}
file_relayer_proto_msgTypes
[
34
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
BalanceLockedReq
);
i
{
case
0
:
return
&
v
.
state
case
1
:
return
&
v
.
sizeCache
case
2
:
return
&
v
.
unknownFields
default
:
return
nil
}
}
}
}
type
x
struct
{}
type
x
struct
{}
out
:=
protoimpl
.
TypeBuilder
{
out
:=
protoimpl
.
TypeBuilder
{
...
@@ -3084,7 +3156,7 @@ func file_relayer_proto_init() {
...
@@ -3084,7 +3156,7 @@ func file_relayer_proto_init() {
GoPackagePath
:
reflect
.
TypeOf
(
x
{})
.
PkgPath
(),
GoPackagePath
:
reflect
.
TypeOf
(
x
{})
.
PkgPath
(),
RawDescriptor
:
file_relayer_proto_rawDesc
,
RawDescriptor
:
file_relayer_proto_rawDesc
,
NumEnums
:
0
,
NumEnums
:
0
,
NumMessages
:
3
4
,
NumMessages
:
3
5
,
NumExtensions
:
0
,
NumExtensions
:
0
,
NumServices
:
0
,
NumServices
:
0
,
},
},
...
...
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