-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bridge-history): bridge batch deposit (#1310)
Co-authored-by: zimpha <[email protected]> Co-authored-by: georgehao <[email protected]> Co-authored-by: colin <[email protected]> Co-authored-by: colinlyguo <[email protected]> Co-authored-by: colinlyguo <[email protected]>
- Loading branch information
1 parent
e64bb77
commit f2fd896
Showing
26 changed files
with
1,017 additions
and
413 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 0 additions & 94 deletions
94
bridge-history-api/internal/controller/api/history_controller.go
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
bridge-history-api/internal/controller/api/l2unclaimed_withdrawals_by_address.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/go-redis/redis/v8" | ||
"gorm.io/gorm" | ||
|
||
"scroll-tech/bridge-history-api/internal/logic" | ||
"scroll-tech/bridge-history-api/internal/types" | ||
) | ||
|
||
// L2UnclaimedWithdrawalsByAddressController the controller of GetL2UnclaimedWithdrawalsByAddress | ||
type L2UnclaimedWithdrawalsByAddressController struct { | ||
historyLogic *logic.HistoryLogic | ||
} | ||
|
||
// NewL2UnclaimedWithdrawalsByAddressController create new L2UnclaimedWithdrawalsByAddressController | ||
func NewL2UnclaimedWithdrawalsByAddressController(db *gorm.DB, redisClient *redis.Client) *L2UnclaimedWithdrawalsByAddressController { | ||
return &L2UnclaimedWithdrawalsByAddressController{ | ||
historyLogic: logic.NewHistoryLogic(db, redisClient), | ||
} | ||
} | ||
|
||
// GetL2UnclaimedWithdrawalsByAddress defines the http get method behavior | ||
func (c *L2UnclaimedWithdrawalsByAddressController) GetL2UnclaimedWithdrawalsByAddress(ctx *gin.Context) { | ||
var req types.QueryByAddressRequest | ||
if err := ctx.ShouldBind(&req); err != nil { | ||
types.RenderFailure(ctx, types.ErrParameterInvalidNo, err) | ||
return | ||
} | ||
|
||
pagedTxs, total, err := c.historyLogic.GetL2UnclaimedWithdrawalsByAddress(ctx, req.Address, req.Page, req.PageSize) | ||
if err != nil { | ||
types.RenderFailure(ctx, types.ErrGetL2ClaimableWithdrawalsError, err) | ||
return | ||
} | ||
|
||
resultData := &types.ResultData{Results: pagedTxs, Total: total} | ||
types.RenderSuccess(ctx, resultData) | ||
} |
40 changes: 40 additions & 0 deletions
40
bridge-history-api/internal/controller/api/l2withdrawals_by_address.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/go-redis/redis/v8" | ||
"gorm.io/gorm" | ||
|
||
"scroll-tech/bridge-history-api/internal/logic" | ||
"scroll-tech/bridge-history-api/internal/types" | ||
) | ||
|
||
// L2WithdrawalsByAddressController the controller of GetL2WithdrawalsByAddress | ||
type L2WithdrawalsByAddressController struct { | ||
historyLogic *logic.HistoryLogic | ||
} | ||
|
||
// NewL2WithdrawalsByAddressController create new L2WithdrawalsByAddressController | ||
func NewL2WithdrawalsByAddressController(db *gorm.DB, redisClient *redis.Client) *L2WithdrawalsByAddressController { | ||
return &L2WithdrawalsByAddressController{ | ||
historyLogic: logic.NewHistoryLogic(db, redisClient), | ||
} | ||
} | ||
|
||
// GetL2WithdrawalsByAddress defines the http get method behavior | ||
func (c *L2WithdrawalsByAddressController) GetL2WithdrawalsByAddress(ctx *gin.Context) { | ||
var req types.QueryByAddressRequest | ||
if err := ctx.ShouldBind(&req); err != nil { | ||
types.RenderFailure(ctx, types.ErrParameterInvalidNo, err) | ||
return | ||
} | ||
|
||
pagedTxs, total, err := c.historyLogic.GetL2WithdrawalsByAddress(ctx, req.Address, req.Page, req.PageSize) | ||
if err != nil { | ||
types.RenderFailure(ctx, types.ErrGetL2WithdrawalsError, err) | ||
return | ||
} | ||
|
||
resultData := &types.ResultData{Results: pagedTxs, Total: total} | ||
types.RenderSuccess(ctx, resultData) | ||
} |
40 changes: 40 additions & 0 deletions
40
bridge-history-api/internal/controller/api/txs_by_address.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/go-redis/redis/v8" | ||
"gorm.io/gorm" | ||
|
||
"scroll-tech/bridge-history-api/internal/logic" | ||
"scroll-tech/bridge-history-api/internal/types" | ||
) | ||
|
||
// TxsByAddressController the controller of GetTxsByAddress | ||
type TxsByAddressController struct { | ||
historyLogic *logic.HistoryLogic | ||
} | ||
|
||
// NewTxsByAddressController create new TxsByAddressController | ||
func NewTxsByAddressController(db *gorm.DB, redisClient *redis.Client) *TxsByAddressController { | ||
return &TxsByAddressController{ | ||
historyLogic: logic.NewHistoryLogic(db, redisClient), | ||
} | ||
} | ||
|
||
// GetTxsByAddress defines the http get method behavior | ||
func (c *TxsByAddressController) GetTxsByAddress(ctx *gin.Context) { | ||
var req types.QueryByAddressRequest | ||
if err := ctx.ShouldBind(&req); err != nil { | ||
types.RenderFailure(ctx, types.ErrParameterInvalidNo, err) | ||
return | ||
} | ||
|
||
pagedTxs, total, err := c.historyLogic.GetTxsByAddress(ctx, req.Address, req.Page, req.PageSize) | ||
if err != nil { | ||
types.RenderFailure(ctx, types.ErrGetTxsError, err) | ||
return | ||
} | ||
|
||
resultData := &types.ResultData{Results: pagedTxs, Total: total} | ||
types.RenderSuccess(ctx, resultData) | ||
} |
40 changes: 40 additions & 0 deletions
40
bridge-history-api/internal/controller/api/txs_by_hashes.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/go-redis/redis/v8" | ||
"gorm.io/gorm" | ||
|
||
"scroll-tech/bridge-history-api/internal/logic" | ||
"scroll-tech/bridge-history-api/internal/types" | ||
) | ||
|
||
// TxsByHashesController the controller of PostQueryTxsByHashes | ||
type TxsByHashesController struct { | ||
historyLogic *logic.HistoryLogic | ||
} | ||
|
||
// NewTxsByHashesController create a new TxsByHashesController | ||
func NewTxsByHashesController(db *gorm.DB, redisClient *redis.Client) *TxsByHashesController { | ||
return &TxsByHashesController{ | ||
historyLogic: logic.NewHistoryLogic(db, redisClient), | ||
} | ||
} | ||
|
||
// PostQueryTxsByHashes query the txs by hashes | ||
func (c *TxsByHashesController) PostQueryTxsByHashes(ctx *gin.Context) { | ||
var req types.QueryByHashRequest | ||
if err := ctx.ShouldBindJSON(&req); err != nil { | ||
types.RenderFailure(ctx, types.ErrParameterInvalidNo, err) | ||
return | ||
} | ||
|
||
results, err := c.historyLogic.GetTxsByHashes(ctx, req.Txs) | ||
if err != nil { | ||
types.RenderFailure(ctx, types.ErrGetTxsByHashError, err) | ||
return | ||
} | ||
|
||
resultData := &types.ResultData{Results: results, Total: uint64(len(results))} | ||
types.RenderSuccess(ctx, resultData) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.