Skip to content

core/utils: accept json.Number in ToDecimal - #23427

Open
riba2534 wants to merge 1 commit into
smartcontractkit:developfrom
riba2534:fix/issue-8504
Open

core/utils: accept json.Number in ToDecimal#23427
riba2534 wants to merge 1 commit into
smartcontractkit:developfrom
riba2534:fix/issue-8504

Conversation

@riba2534

Copy link
Copy Markdown

Fixes #8504

Description

ETHABIEncode converts integer ABI values (including each element of uint256[]) through convertToETHABIIntegerutils.ToDecimal. JSON unmarshalling produces json.Number for numeric tokens, and ToDecimal previously rejected that type with:

type json.Number cannot be converted to decimal.Decimal

This matches the job-run failure in #8504 (ETHABIEncode of a uint256[] from JSON numbers).

Changes

  • Accept json.Number in utils.ToDecimal (same conversion as a numeric string).
  • Add unit tests for valid/invalid json.Number inputs.
  • Add a pipeline regression test: encoding uint256[] from []json.Number succeeds and matches the int64 encoding.

Requires

None.

Supports

None.

Test plan

  • go test ./core/utils -count=1
  • go test ./core/services/pipeline -count=1 -run 'TestETHABIEncode'

ETHABIEncode converts integer ABI values through ToDecimal. JSON
unmarshalling yields json.Number for numeric tokens, so encoding
uint256[] (and other integer types) failed with:

  type json.Number cannot be converted to decimal.Decimal

Handle json.Number the same way as numeric strings.

Fixes smartcontractkit#8504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NODE] ETHABIEncode: type json.Number cannot be converted to decimal.Decimal

1 participant