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
02765635
Commit
02765635
authored
Feb 02, 2026
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update token info
parent
d7eccbcb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
22 deletions
+30
-22
chainlist.go
chainlist/chainlist.go
+6
-5
db.go
dao/db.go
+5
-5
tokenrepo.go
tokenrepo/tokenrepo.go
+9
-7
types.go
types/types.go
+10
-5
No files found.
chainlist/chainlist.go
View file @
02765635
...
@@ -73,11 +73,12 @@ func (cr *ChainRepo) parseChainDataToMap(data []byte) (map[int]types.ChainInfo,
...
@@ -73,11 +73,12 @@ func (cr *ChainRepo) parseChainDataToMap(data []byte) (map[int]types.ChainInfo,
newMap
:=
make
(
map
[
int
]
types
.
ChainInfo
)
newMap
:=
make
(
map
[
int
]
types
.
ChainInfo
)
for
_
,
cd
:=
range
chainList
{
for
_
,
cd
:=
range
chainList
{
ci
:=
types
.
ChainInfo
{
ci
:=
types
.
ChainInfo
{
ChainId
:
int64
(
cd
.
ChainId
),
ChainId
:
int64
(
cd
.
ChainId
),
Chain
:
cd
.
Chain
,
Chain
:
cd
.
Chain
,
Name
:
cd
.
Name
,
Name
:
cd
.
Name
,
Explorer
:
""
,
Explorer
:
""
,
Rpc
:
""
,
Rpc
:
""
,
NativeCurrency
:
cd
.
NativeCurrency
,
}
}
if
len
(
cd
.
Rpc
)
>
0
{
if
len
(
cd
.
Rpc
)
>
0
{
ci
.
Rpc
=
cd
.
Rpc
[
0
]
.
Url
ci
.
Rpc
=
cd
.
Rpc
[
0
]
.
Url
...
...
dao/db.go
View file @
02765635
...
@@ -284,7 +284,7 @@ func (d *Dao) GetBridgeTokenBalance(chainId int64, user string) (balances apiMod
...
@@ -284,7 +284,7 @@ func (d *Dao) GetBridgeTokenBalance(chainId int64, user string) (balances apiMod
if
token
.
ChainId
!=
chainId
{
if
token
.
ChainId
!=
chainId
{
continue
continue
}
}
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainClient
,
token
.
Token
,
user
)
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainClient
,
chainId
,
token
.
Token
,
user
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"chain_id"
:
token
.
ChainId
,
"chain_id"
:
token
.
ChainId
,
...
@@ -330,7 +330,7 @@ func (d *Dao) GetTokenBalance(chainId int64, user string, tokens []string) (bala
...
@@ -330,7 +330,7 @@ func (d *Dao) GetTokenBalance(chainId int64, user string, tokens []string) (bala
var
innerBalance
=
make
([]
tokenBalance
,
0
)
var
innerBalance
=
make
([]
tokenBalance
,
0
)
for
_
,
token
:=
range
tokens
{
for
_
,
token
:=
range
tokens
{
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainClient
,
token
,
user
)
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainClient
,
chainId
,
token
,
user
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"chain_id"
:
chainId
,
"chain_id"
:
chainId
,
...
@@ -384,7 +384,7 @@ func (d *Dao) QuoteBridge(param apiModel.QuoteBridgeParam) (quote apiModel.Quote
...
@@ -384,7 +384,7 @@ func (d *Dao) QuoteBridge(param apiModel.QuoteBridgeParam) (quote apiModel.Quote
})
.
Error
(
"get out config failed"
)
})
.
Error
(
"get out config failed"
)
return
quote
,
fmt
.
Errorf
(
"internal error"
)
return
quote
,
fmt
.
Errorf
(
"internal error"
)
}
}
_
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainInfo
.
cli
,
param
.
FromToken
,
param
.
User
)
_
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainInfo
.
cli
,
chainInfo
.
conf
.
ChainId
,
param
.
FromToken
,
param
.
User
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"chain_id"
:
param
.
FromChainId
,
"chain_id"
:
param
.
FromChainId
,
...
@@ -586,7 +586,7 @@ func (d *Dao) GetSwapTokenBalance(chainId int64, user string) (balances apiModel
...
@@ -586,7 +586,7 @@ func (d *Dao) GetSwapTokenBalance(chainId int64, user string) (balances apiModel
innerBalance
:=
make
([]
tokenBalance
,
0
)
innerBalance
:=
make
([]
tokenBalance
,
0
)
for
_
,
token
:=
range
chainSwapConfig
.
SupportTokens
{
for
_
,
token
:=
range
chainSwapConfig
.
SupportTokens
{
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainInfo
.
cli
,
token
.
TokenContract
,
user
)
tokenInfo
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
chainInfo
.
cli
,
chainId
,
token
.
TokenContract
,
user
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"chain_id"
:
chainId
,
"chain_id"
:
chainId
,
...
@@ -631,7 +631,7 @@ func (d *Dao) QuoteSwap(param apiModel.QuoteSwapParam) (quote apiModel.QuoteResu
...
@@ -631,7 +631,7 @@ func (d *Dao) QuoteSwap(param apiModel.QuoteSwapParam) (quote apiModel.QuoteResu
return
quote
,
fmt
.
Errorf
(
"not found chain for chain id"
)
return
quote
,
fmt
.
Errorf
(
"not found chain for chain id"
)
}
}
_
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
fromChainInfo
.
cli
,
param
.
Path
.
SwapFromToken
,
param
.
User
)
_
,
balance
,
err
:=
d
.
tokenRepo
.
RetriveTokenInfoAndBalance
(
fromChainInfo
.
cli
,
fromChainInfo
.
conf
.
ChainId
,
param
.
Path
.
SwapFromToken
,
param
.
User
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"chain_id"
:
param
.
FromChainId
,
"chain_id"
:
param
.
FromChainId
,
...
...
tokenrepo/tokenrepo.go
View file @
02765635
...
@@ -52,10 +52,11 @@ func (tr *TokenRepo) RetriveTokenInfo(chainId int64, address string) (TokenInfo,
...
@@ -52,10 +52,11 @@ func (tr *TokenRepo) RetriveTokenInfo(chainId int64, address string) (TokenInfo,
return
info
,
nil
return
info
,
nil
}
}
if
strings
.
Compare
(
strings
.
ToLower
(
address
),
strings
.
ToLower
(
constant
.
CoinAddress
))
==
0
{
if
strings
.
Compare
(
strings
.
ToLower
(
address
),
strings
.
ToLower
(
constant
.
CoinAddress
))
==
0
{
cinfo
,
_
:=
tr
.
chainRepo
.
Get
(
chainId
)
info
:=
TokenInfo
{
info
:=
TokenInfo
{
Name
:
"MOVA"
,
Name
:
cinfo
.
NativeCurrency
.
Name
,
Symbol
:
"MOVA"
,
Symbol
:
cinfo
.
NativeCurrency
.
Symbol
,
Decimals
:
18
,
Decimals
:
int64
(
cinfo
.
NativeCurrency
.
Decimals
)
,
Address
:
address
,
Address
:
address
,
}
}
tr
.
SetTokenInfo
(
address
,
info
)
tr
.
SetTokenInfo
(
address
,
info
)
...
@@ -101,15 +102,16 @@ func (tr *TokenRepo) RetriveTokenInfo(chainId int64, address string) (TokenInfo,
...
@@ -101,15 +102,16 @@ func (tr *TokenRepo) RetriveTokenInfo(chainId int64, address string) (TokenInfo,
return
info
,
nil
return
info
,
nil
}
}
func
(
tr
*
TokenRepo
)
RetriveTokenInfoAndBalance
(
client
*
ethclient
.
Client
,
address
string
,
user
string
)
(
TokenInfo
,
*
big
.
Int
,
error
)
{
func
(
tr
*
TokenRepo
)
RetriveTokenInfoAndBalance
(
client
*
ethclient
.
Client
,
chainId
int64
,
address
string
,
user
string
)
(
TokenInfo
,
*
big
.
Int
,
error
)
{
info
:=
TokenInfo
{}
info
:=
TokenInfo
{}
balance
:=
big
.
NewInt
(
0
)
balance
:=
big
.
NewInt
(
0
)
cinfo
,
_
:=
tr
.
chainRepo
.
Get
(
chainId
)
if
strings
.
Compare
(
strings
.
ToLower
(
address
),
strings
.
ToLower
(
constant
.
CoinAddress
))
==
0
{
if
strings
.
Compare
(
strings
.
ToLower
(
address
),
strings
.
ToLower
(
constant
.
CoinAddress
))
==
0
{
info
=
TokenInfo
{
info
=
TokenInfo
{
Name
:
"MOVA"
,
Name
:
cinfo
.
NativeCurrency
.
Name
,
Symbol
:
"MOVA"
,
Symbol
:
cinfo
.
NativeCurrency
.
Symbol
,
Decimals
:
18
,
Decimals
:
int64
(
cinfo
.
NativeCurrency
.
Decimals
)
,
Address
:
address
,
Address
:
address
,
}
}
tr
.
SetTokenInfo
(
address
,
info
)
tr
.
SetTokenInfo
(
address
,
info
)
...
...
types/types.go
View file @
02765635
package
types
package
types
type
ChainInfo
struct
{
type
ChainInfo
struct
{
ChainId
int64
`json:"chainId,omitempty"`
ChainId
int64
`json:"chainId,omitempty"`
Chain
string
`json:"chain,omitempty"`
Chain
string
`json:"chain,omitempty"`
Name
string
`json:"name,omitempty"`
Name
string
`json:"name,omitempty"`
Rpc
string
`json:"rpc,omitempty"`
Rpc
string
`json:"rpc,omitempty"`
Explorer
string
`json:"explorer,omitempty"`
Explorer
string
`json:"explorer,omitempty"`
NativeCurrency
struct
{
Name
string
`json:"name"`
Symbol
string
`json:"symbol"`
Decimals
int
`json:"decimals"`
}
`json:"nativeCurrency"`
}
}
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