Skip to content

feat(tmpnetjs): SDK ergonomics — relayer in artifacts, chain-time helpers, library linking, expectRevert#5

Merged
owenwahlgren merged 1 commit into
mainfrom
feature/tmpnetjs-sdk-ergonomics
Jun 12, 2026
Merged

feat(tmpnetjs): SDK ergonomics — relayer in artifacts, chain-time helpers, library linking, expectRevert#5
owenwahlgren merged 1 commit into
mainfrom
feature/tmpnetjs-sdk-ergonomics

Conversation

@owenwahlgren

Copy link
Copy Markdown
Collaborator

Problem

Gaps hit while building an e2e validation of third-party ICTT contracts on tmpnet — each required hand-rolling something the SDK should provide:

  • the relayer EOA isn't in network.json or exported, so testing Teleporter allowedRelayerAddresses means hardcoding the Anvil[0] address
  • local chains mint blocks on demand, so block.timestamp freezes between txs and gas estimation rejects any time-guarded call (timelocks, vesting) forever — even after wall-clock time has passed
  • loadArtifact only reads contracts/out/, and there's no way to deploy contracts that link external libraries (solc __$hash$__ placeholders)
  • every negative-path e2e assertion re-implements simulate-and-match-custom-error

Changes

  • Relayer in artifacts: network.json gains relayer.address, addresses.ts gains RELAYER, .env gains RELAYER_ADDRESS; DEFAULT_RELAYER_ADDRESS / DEFAULT_RELAYER_KEY exported from the package. Also fixes the constant's EIP-55 checksum (cfFFbcffFb) — viem 2.50+ rejects the old casing — and drops the getAddress() workaround that bug forced in commands.ts.
  • sdk/chain-time.ts: mineBlock(clients) (zero-value self-transfer to mint a fresh block) and waitForChainTime(clients, targetUnixSeconds) (sleep to target wall-clock, then nudge blocks until the head is stamped past it).
  • loadArtifact(name, { dir }): load artifacts from an explicit directory (forge nested or flat layout); returns linkReferences. New linkLibraries(artifact, { LibName: address }) splices deployed library addresses over solc placeholders, validating nothing unresolved remains.
  • sdk/expect.ts: expectRevert(publicClient, call, expectedError) — eth_call simulation, asserts the decoded revert matches; throws with the original error text when it doesn't.
  • Test infra: repairs the package test script (node --test can't import a bare directory — it was broken since it was added) and adds 8 unit tests for loadArtifact/linkLibraries.
  • README: documents that the deployed icm-contracts v1.0.9 Teleporter stack interoperates with contracts compiled against newer icm-services releases (verified empirically with v1.4.1-built ICTT subclasses).

Verification

  • pnpm --filter tmpnetjs test: 8/8 pass
  • mineBlock / waitForChainTime / expectRevert exercised against a live local network (block advance, chain-time catch-up past a future target, revert capture)
  • buildArtifactDoc emits the relayer block with the corrected checksum

…nking, expectRevert

Gaps hit while building a real third-party-contract validation on tmpnet:

- network.json / addresses.ts / .env now include the relayer EOA
  (relayer.address, RELAYER, RELAYER_ADDRESS), and DEFAULT_RELAYER_ADDRESS
  / DEFAULT_RELAYER_KEY are exported from the package. Anyone testing
  Teleporter allowedRelayerAddresses needs this and previously had to
  hardcode the Anvil[0] address. Also fixes the constant's EIP-55
  checksum (cfFFb -> cffFb), which viem 2.50+ rejects, and drops the
  getAddress() workaround it forced in commands.ts.

- sdk/chain-time.ts: mineBlock + waitForChainTime. Local chains mint
  blocks on demand, so block.timestamp stays frozen between txs and gas
  estimation rejects any time-guarded call (timelocks, vesting) forever
  even after wall-clock time has passed. waitForChainTime sleeps to the
  target, then nudges empty blocks until the head is stamped past it.

- loadArtifact(name, { dir }) loads artifacts from an explicit directory
  (forge nested or flat layout) instead of only contracts/out, returns
  linkReferences, and the new linkLibraries() splices deployed library
  addresses over solc's __$hash$__ placeholders using those references.

- sdk/expect.ts: expectRevert — simulate a call and assert it reverts
  with the expected custom error / reason, via eth_call (no gas, no
  on-chain trace).

- Repairs the package test script (node --test cannot import a bare
  directory) and adds unit tests for loadArtifact/linkLibraries.

- README: note that the deployed icm-contracts v1.0.9 Teleporter stack
  interoperates with contracts compiled against newer icm-services
  releases (wire protocol + registry ABI are stable).
@owenwahlgren owenwahlgren merged commit 557cad1 into main Jun 12, 2026
7 checks passed
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.

2 participants