From 278f4e9433ea28a45edc38eb9baa7d718570703e Mon Sep 17 00:00:00 2001 From: polebug Date: Thu, 24 Oct 2024 21:53:14 +0800 Subject: [PATCH] fix(component): fix forced convert account encoding format (#604) --- .../decentralized/handler_activity.go | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/internal/node/component/decentralized/handler_activity.go b/internal/node/component/decentralized/handler_activity.go index 0f25ce7c..4dd852d3 100644 --- a/internal/node/component/decentralized/handler_activity.go +++ b/internal/node/component/decentralized/handler_activity.go @@ -82,6 +82,10 @@ func (c *Component) GetAccountActivities(ctx echo.Context) (err error) { return response.BadRequestError(ctx, err) } + if common.IsHexAddress(request.Account) { + request.Account = common.HexToAddress(request.Account).String() + } + if request.Type, err = c.parseTypes(ctx.QueryParams()["type"], request.Tag); err != nil { return response.BadRequestError(ctx, err) } @@ -110,7 +114,7 @@ func (c *Component) GetAccountActivities(ctx echo.Context) (err error) { Cursor: cursor, StartTimestamp: request.SinceTimestamp, EndTimestamp: request.UntilTimestamp, - Owner: lo.ToPtr(common.HexToAddress(request.Account).String()), + Owner: lo.ToPtr(request.Account), Limit: request.Limit, ActionLimit: request.ActionLimit, Status: request.Status, @@ -143,6 +147,12 @@ func (c *Component) BatchGetAccountsActivities(ctx echo.Context) (err error) { return response.BadRequestError(ctx, err) } + for i := range request.Accounts { + if common.IsHexAddress(request.Accounts[i]) { + request.Accounts[i] = common.HexToAddress(request.Accounts[i]).String() + } + } + types, err := c.parseTypes(request.Type, request.Tag) if err != nil { return response.BadRequestError(ctx, err) @@ -172,17 +182,15 @@ func (c *Component) BatchGetAccountsActivities(ctx echo.Context) (err error) { Cursor: cursor, StartTimestamp: request.SinceTimestamp, EndTimestamp: request.UntilTimestamp, - Owners: lo.Uniq(lo.Map(request.Accounts, func(account string, _ int) string { - return common.HexToAddress(account).String() - })), - Limit: request.Limit, - ActionLimit: request.ActionLimit, - Status: request.Status, - Direction: request.Direction, - Network: lo.Uniq(request.Network), - Tags: lo.Uniq(request.Tag), - Types: lo.Uniq(types), - Platforms: lo.Uniq(request.Platform), + Owners: lo.Uniq(request.Accounts), + Limit: request.Limit, + ActionLimit: request.ActionLimit, + Status: request.Status, + Direction: request.Direction, + Network: lo.Uniq(request.Network), + Tags: lo.Uniq(request.Tag), + Types: lo.Uniq(types), + Platforms: lo.Uniq(request.Platform), } activities, last, err := c.getActivities(ctx.Request().Context(), databaseRequest)