Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bridge-backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
movabridge
bridge-backend
Commits
c3edc3cd
Commit
c3edc3cd
authored
Nov 21, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fee and limit info.
parent
b0d6c0b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
1 deletion
+42
-1
sync.go
chain/sync.go
+13
-0
builder.go
dao/builder.go
+1
-0
dao.go
dao/dao.go
+17
-0
db.go
dao/db.go
+9
-1
model.go
model/api/model.go
+2
-0
No files found.
chain/sync.go
View file @
c3edc3cd
...
...
@@ -71,6 +71,19 @@ func (s *ChainSync) GetReceiveToken(token common.Address, toChainId int64) (stri
return
strings
.
ToLower
(
param
.
ReceiveToken
.
Hex
()),
nil
}
func
(
s
*
ChainSync
)
GetOutConfig
(
token
common
.
Address
,
toChainId
int64
)
(
outConfig
bridge
.
BridgeOutConfig
,
err
error
)
{
callOpt
:=
&
bind
.
CallOpts
{
BlockNumber
:
nil
,
From
:
common
.
HexToAddress
(
s
.
chain
.
BridgeContract
),
Context
:
context
.
TODO
(),
}
outConfig
,
err
=
s
.
bridgeCa
.
OutConfiguration
(
callOpt
,
token
,
big
.
NewInt
(
toChainId
))
if
err
!=
nil
{
return
outConfig
,
err
}
return
outConfig
,
nil
}
func
NewChainSync
(
_chain
*
config
.
ChainConfig
,
_d
*
dao
.
Dao
)
(
sync
*
ChainSync
)
{
bridgeCa
,
err
:=
bridge
.
NewBridgeContract
(
common
.
HexToAddress
(
_chain
.
BridgeContract
),
_d
.
ChainClient
(
_chain
.
ChainId
))
if
err
!=
nil
{
...
...
dao/builder.go
View file @
c3edc3cd
...
...
@@ -25,6 +25,7 @@ type ChainInterface interface {
ParseTokenConfigChanged
(
log
*
types
.
Log
)
(
*
bridge
.
BridgeContractTokenOutConfigChanged
,
error
)
ParseSwapConfigChanged
(
log
*
types
.
Log
)
(
*
bridge
.
BridgeContractSwapConfigChanged
,
error
)
GetReceiveToken
(
token
common
.
Address
,
toChainId
int64
)
(
string
,
error
)
GetOutConfig
(
token
common
.
Address
,
toChainId
int64
)
(
outConfig
bridge
.
BridgeOutConfig
,
err
error
)
}
var
(
...
...
dao/dao.go
View file @
c3edc3cd
...
...
@@ -3,10 +3,12 @@ package dao
import
(
"code.wuban.net.cn/movabridge/bridge-backend/chainlist"
"code.wuban.net.cn/movabridge/bridge-backend/config"
"code.wuban.net.cn/movabridge/bridge-backend/contract/bridge"
"code.wuban.net.cn/movabridge/bridge-backend/tokenrepo"
"context"
"crypto/ecdsa"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
...
...
@@ -107,3 +109,18 @@ func (d *Dao) AddSyncer(chainId int64, syncer ChainInterface) {
defer
d
.
handleMux
.
Unlock
()
d
.
syncer
[
chainId
]
=
syncer
}
func
(
d
*
Dao
)
GetSyncer
(
chainId
int64
)
(
syncer
ChainInterface
,
ok
bool
)
{
d
.
handleMux
.
Lock
()
defer
d
.
handleMux
.
Unlock
()
syncer
,
ok
=
d
.
syncer
[
chainId
]
return
}
func
(
d
*
Dao
)
GetOutConfig
(
chainId
int64
,
token
common
.
Address
,
toChainId
int64
)
(
bridge
.
BridgeOutConfig
,
error
)
{
syncer
,
ok
:=
d
.
GetSyncer
(
chainId
)
if
!
ok
{
return
bridge
.
BridgeOutConfig
{},
fmt
.
Errorf
(
"chain %d syncer not found"
,
chainId
)
}
return
syncer
.
GetOutConfig
(
token
,
toChainId
)
}
dao/db.go
View file @
c3edc3cd
...
...
@@ -4,6 +4,7 @@ import (
"code.wuban.net.cn/movabridge/bridge-backend/constant"
apiModel
"code.wuban.net.cn/movabridge/bridge-backend/model/api"
"context"
"github.com/ethereum/go-ethereum/common"
log
"github.com/sirupsen/logrus"
"sort"
"time"
...
...
@@ -115,12 +116,19 @@ func (d *Dao) GetBridgeConfig() (config apiModel.BridgeConfig, err error) {
"error"
:
err
,
})
.
Error
(
"not found token info with tokenrepo, skip symbol info"
)
}
chainConfig
.
SupportTokens
[
info
.
TokenName
]
=
apiModel
.
ToToken
{
tokenInfo
:=
apiModel
.
ToToken
{
TokenContract
:
info
.
Token
,
ToChainId
:
info
.
ToChainId
,
ToToken
:
info
.
ToToken
,
ToTokenSymbol
:
toTokenInfo
.
Symbol
,
}
outConfig
,
err
:=
d
.
GetOutConfig
(
info
.
ChainId
,
common
.
HexToAddress
(
info
.
Token
),
info
.
ToChainId
)
if
err
==
nil
{
tokenInfo
.
Fee
=
outConfig
.
Fee
.
String
()
tokenInfo
.
MaxLimit
=
outConfig
.
Limit
.
String
()
}
chainConfig
.
SupportTokens
[
info
.
TokenName
]
=
tokenInfo
config
.
Chains
[
chainInfo
.
Name
]
=
chainConfig
}
...
...
model/api/model.go
View file @
c3edc3cd
...
...
@@ -5,6 +5,8 @@ type ToToken struct {
ToChainId
int64
`json:"to_chain_id" bson:"to_chain_id"`
ToToken
string
`json:"to_token" bson:"to_token"`
ToTokenSymbol
string
`json:"to_token_symbol" bson:"to_token_symbol"`
Fee
string
`json:"fee" bson:"fee"`
MaxLimit
string
`json:"max_limit" bson:"max_limit"`
}
type
ChainConfig
struct
{
Chain
string
`json:"chain" bson:"chain"`
...
...
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