From 4a1bb207cadcdca56082a0fb5f2a7e14c79cfaec Mon Sep 17 00:00:00 2001 From: brucexc <108378464+brucexc@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:27:11 -0500 Subject: [PATCH] fix: transfer value is zero (#643) --- .../decentralized/core/ethereum/worker.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/internal/engine/worker/decentralized/core/ethereum/worker.go b/internal/engine/worker/decentralized/core/ethereum/worker.go index 00c3e340..49a20644 100644 --- a/internal/engine/worker/decentralized/core/ethereum/worker.go +++ b/internal/engine/worker/decentralized/core/ethereum/worker.go @@ -538,6 +538,11 @@ func (w *worker) buildTransactionTransferAction(ctx context.Context, task *sourc return nil, fmt.Errorf("lookup token %s: %w", tokenAddress, err) } + // If the token value is nil, set it to zero. + if tokenValue == nil { + tokenValue = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(tokenValue, 0)) var actionType typex.TransactionType @@ -572,6 +577,11 @@ func (w *worker) buildTransactionApprovalAction(ctx context.Context, task *sourc return nil, fmt.Errorf("lookup token %s: %w", tokenAddress, err) } + // If the token value is nil, set it to zero. + if tokenValue == nil { + tokenValue = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(tokenValue, 0)) // Use the token value to determine the action type. @@ -604,6 +614,11 @@ func (w *worker) buildCollectibleTransferAction(ctx context.Context, task *sourc return nil, fmt.Errorf("lookup token %s: %w", tokenAddress, err) } + // If the token value is nil, set it to zero. + if tokenValue == nil { + tokenValue = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(tokenValue, 0)) var actionType typex.CollectibleType @@ -672,6 +687,11 @@ func (w *worker) buildExchangeStakingVSLAction(ctx context.Context, task *source return nil, fmt.Errorf("lookup token: %w", err) } + // If the token value is nil, set it to zero. + if tokenValue == nil { + tokenValue = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(tokenValue, 0)) action := activityx.Action{ @@ -695,6 +715,11 @@ func (w *worker) buildChipsMintAction(ctx context.Context, task *source.Task, fr return nil, fmt.Errorf("lookup token metadata: %w", err) } + // If the token value is nil, set it to zero. + if value == nil { + value = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(value, 0)) return &activityx.Action{ @@ -712,6 +737,11 @@ func (w *worker) buildTransactionBridgeAction(ctx context.Context, chainID uint6 return nil, fmt.Errorf("lookup token %s: %w", tokenAddress, err) } + // If the token value is nil, set it to zero. + if tokenValue == nil { + tokenValue = big.NewInt(0) + } + tokenMetadata.Value = lo.ToPtr(decimal.NewFromBigInt(tokenValue, 0)) action := activityx.Action{