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
42827c44
Commit
42827c44
authored
Nov 27, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add api for tx status
parent
deeb57a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
0 deletions
+55
-0
db.go
dao/db.go
+30
-0
model.go
model/api/model.go
+5
-0
controller.go
server/controller.go
+19
-0
router.go
server/router.go
+1
-0
No files found.
dao/db.go
View file @
42827c44
...
@@ -215,6 +215,36 @@ func (d *Dao) GetHistoryInfo(user string) (history apiModel.History, err error)
...
@@ -215,6 +215,36 @@ func (d *Dao) GetHistoryInfo(user string) (history apiModel.History, err error)
return
history
,
nil
return
history
,
nil
}
}
func
(
d
*
Dao
)
GetTxStatus
(
tx
string
)
(
result
apiModel
.
TxStatusResult
,
err
error
)
{
collection
:=
d
.
db
.
Collection
(
new
(
dbModel
.
BridgeEvent
)
.
TableName
())
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
defer
cancel
()
result
=
apiModel
.
TxStatusResult
{
Status
:
constant
.
TransferChainNoProcess
.
String
(),
}
cursor
,
err
:=
collection
.
Find
(
ctx
,
bson
.
M
{
"from_chain_tx_hash"
:
tx
})
if
err
!=
nil
{
return
result
,
nil
}
defer
cursor
.
Close
(
ctx
)
var
events
[]
dbModel
.
BridgeEvent
err
=
cursor
.
All
(
ctx
,
&
events
)
if
err
!=
nil
{
return
result
,
nil
}
if
len
(
events
)
==
0
{
return
result
,
nil
}
event
:=
events
[
0
]
result
.
Status
=
constant
.
TransferStatus
(
event
.
ToChainStatus
)
.
String
()
return
result
,
nil
}
type
tokenBalance
struct
{
type
tokenBalance
struct
{
Name
string
Name
string
Decimals
int
Decimals
int
...
...
model/api/model.go
View file @
42827c44
...
@@ -129,11 +129,16 @@ type QuoteResult struct {
...
@@ -129,11 +129,16 @@ type QuoteResult struct {
Payload
string
`json:"payload"`
Payload
string
`json:"payload"`
}
}
type
TxStatusResult
struct
{
Status
string
`json:"status"`
}
type
Querier
interface
{
type
Querier
interface
{
GetBridgeConfig
()
(
config
BridgeConfig
,
err
error
)
GetBridgeConfig
()
(
config
BridgeConfig
,
err
error
)
GetAllChainSwapConfig
()
(
map
[
int64
]
*
ChainSwapConfig
,
error
)
GetAllChainSwapConfig
()
(
map
[
int64
]
*
ChainSwapConfig
,
error
)
GetSwapConfig
(
int64
)
(
*
ChainSwapConfig
,
error
)
GetSwapConfig
(
int64
)
(
*
ChainSwapConfig
,
error
)
GetHistoryInfo
(
user
string
)
(
history
History
,
err
error
)
GetHistoryInfo
(
user
string
)
(
history
History
,
err
error
)
GetTxStatus
(
tx
string
)
(
result
TxStatusResult
,
err
error
)
GetTokenBalance
(
chainId
int64
,
user
string
,
tokens
[]
string
)
(
balances
TokenBalances
,
err
error
)
GetTokenBalance
(
chainId
int64
,
user
string
,
tokens
[]
string
)
(
balances
TokenBalances
,
err
error
)
GetBridgeTokenBalance
(
chainId
int64
,
user
string
)
(
balances
TokenBalances
,
err
error
)
GetBridgeTokenBalance
(
chainId
int64
,
user
string
)
(
balances
TokenBalances
,
err
error
)
QuoteBridge
(
param
QuoteBridgeParam
)
(
quote
QuoteResult
,
err
error
)
QuoteBridge
(
param
QuoteBridgeParam
)
(
quote
QuoteResult
,
err
error
)
...
...
server/controller.go
View file @
42827c44
...
@@ -48,6 +48,25 @@ func getHistory(c *gin.Context) {
...
@@ -48,6 +48,25 @@ func getHistory(c *gin.Context) {
c
.
JSON
(
200
,
withSuccess
(
history
))
c
.
JSON
(
200
,
withSuccess
(
history
))
}
}
func
getTxStatus
(
c
*
gin
.
Context
)
{
txHashStr
:=
c
.
DefaultQuery
(
"txhash"
,
""
)
txHash
:=
common
.
HexToHash
(
txHashStr
)
if
_querier
==
nil
{
log
.
Error
(
"querier is nil"
)
c
.
JSON
(
500
,
withError
(
constant
.
InternalError
))
return
}
status
,
err
:=
_querier
.
GetTxStatus
(
strings
.
ToLower
(
txHash
.
String
()))
if
err
!=
nil
{
log
.
Errorf
(
"get history error: %v"
,
err
)
c
.
JSON
(
500
,
withError
(
constant
.
InternalError
))
return
}
c
.
JSON
(
200
,
withSuccess
(
status
))
}
func
bridgeRouters
(
c
*
gin
.
Context
)
{
func
bridgeRouters
(
c
*
gin
.
Context
)
{
if
_querier
==
nil
{
if
_querier
==
nil
{
log
.
Error
(
"querier is nil"
)
log
.
Error
(
"querier is nil"
)
...
...
server/router.go
View file @
42827c44
...
@@ -17,6 +17,7 @@ func initRouter(conf *config.Config, e *gin.Engine) {
...
@@ -17,6 +17,7 @@ func initRouter(conf *config.Config, e *gin.Engine) {
{
{
user
:=
v1
.
Group
(
"/user"
)
user
:=
v1
.
Group
(
"/user"
)
user
.
GET
(
"/history"
,
getHistory
)
user
.
GET
(
"/history"
,
getHistory
)
user
.
GET
(
"/txstatus"
,
getTxStatus
)
}
}
{
{
bridge
:=
v1
.
Group
(
"/bridge"
)
bridge
:=
v1
.
Group
(
"/bridge"
)
...
...
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