Skip to content

spregistry: fix UnpackIntoInterface bug for getProvider*#16

Merged
parkan merged 1 commit into
masterfrom
fix/spregistry-unpack-tuple
May 1, 2026
Merged

spregistry: fix UnpackIntoInterface bug for getProvider*#16
parkan merged 1 commit into
masterfrom
fix/spregistry-unpack-tuple

Conversation

@parkan
Copy link
Copy Markdown
Collaborator

@parkan parkan commented May 1, 2026

Calibnet repro:

abi: cannot unmarshal struct { ProviderId *big.Int ...; Info struct {...} }
in to *big.Int

go-ethereum's UnpackIntoInterface mishandles single-output tuples with named subfields -- it tries to assign the entire decoded tuple struct into the destination's first field (*big.Int), which fails. The bytes themselves decode fine via abi.Unpack into an anonymous struct.

Switch GetProvider and GetProviderByAddress to abi.Unpack + json round-trip into json-tagged result structs. Add a synthetic-payload unit test that locks in the fix without needing live RPC.

Also runs gofmt over contract.go (pre-existing alignment drift).

Calibnet repro:

  abi: cannot unmarshal struct { ProviderId *big.Int ...; Info struct {...} }
  in to *big.Int

go-ethereum's UnpackIntoInterface mishandles single-output tuples with
named subfields -- it tries to assign the entire decoded tuple struct
into the destination's first field (*big.Int), which fails. The bytes
themselves decode fine via abi.Unpack into an anonymous struct.

Switch GetProvider and GetProviderByAddress to abi.Unpack + json
round-trip into json-tagged result structs. Add a synthetic-payload
unit test that locks in the fix without needing live RPC.

Also runs gofmt over contract.go (pre-existing alignment drift).
@parkan parkan merged commit d91ba0c into master May 1, 2026
6 checks passed
@parkan parkan deleted the fix/spregistry-unpack-tuple branch May 3, 2026 11:32
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.

1 participant