Skip to content

refactor: add BzzAddress to ChainConfig and remove postagecontract.LookupERC20Address #5475

@martinconic

Description

@martinconic

Context

Follow-up from PR #5468 and the existing TODO at pkg/config/chain.go:14.

The BZZ token address is deterministic per chain, yet today it is resolved on-chain twice during node bootstrap:

  • via the chequebook factory ERC20Address(ctx) → feeds erc20Service (used by /wallet and chequebook), and
  • via postagecontract.LookupERC20Address at pkg/node/node.go:726 → feeds the postage stamp and staking contracts.

Proposal

  • Add BzzAddress common.Address to ChainConfig (pkg/config/chain.go), populated for mainnet and testnet.
  • Add a corresponding CLI/config override (e.g. --bzz-token-address) so custom/unknown chains can supply it.
  • Replace the LookupERC20Address call site with chainCfg.BzzAddress and remove the function (and TestLookupERC20Address).
  • Build erc20Service from the static address, decoupling /wallet from the chequebook factory entirely (simplifies the best-effort init added in fix(api): allow GET /wallet when swap or chequebook is disabled #5468).

AI Disclosure

  • This issue contains suggestions and text generated by an LLM.
  • I have reviewed the AI generated content thoroughly.
  • I possess the technical expertise to responsibly review the AI generated content mentioned in this issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions