Skip to content

Commit

Permalink
fix: transfer value is zero (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
brucexc authored Nov 13, 2024
1 parent b0a74f9 commit 4a1bb20
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/engine/worker/decentralized/core/ethereum/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit 4a1bb20

Please sign in to comment.