Skip to content

feat(cli)(sphere-sdk#394): wire publishToIpfs + cidFetchGateways in buildSphereProviders#31

Merged
vrogojin merged 1 commit into
integration/all-fixesfrom
feat/issue-394-cli-publish-to-ipfs-v2
Jun 4, 2026
Merged

feat(cli)(sphere-sdk#394): wire publishToIpfs + cidFetchGateways in buildSphereProviders#31
vrogojin merged 1 commit into
integration/all-fixesfrom
feat/issue-394-cli-publish-to-ipfs-v2

Conversation

@vrogojin
Copy link
Copy Markdown
Contributor

@vrogojin vrogojin commented Jun 4, 2026

Closes the CLI half of sphere-sdk issue #394. Pairs with sphere-sdk PR #395 (branch feat/issue-394-cid-delivery-wiring).

What

buildSphereProviders now imports createUxfCarPublisher + DEFAULT_IPFS_GATEWAYS from @unicitylabs/sphere-sdk/impl/nodejs (re-exported on the SDK side as part of #394) and exposes:

  • publishToIpfs — outgoing UXF CID-delivery callback wired from createUxfCarPublisher(ipfsGateways).
  • cidFetchGateways — recipient-side fetch list so uxf-cid bundles resolve correctly on arrival.

Both flow through SphereProvidersBundle into Sphere.init:

  • src/host/sphere-init.ts adds explicit pass-through (named-field call site).
  • src/legacy/legacy-cli.ts is untouched — its three Sphere.init call sites all spread ...initProviders, inheriting the new fields automatically.

Why not just re-enable tokenSync.ipfs.enabled?

The deprecated IpfsStorageProvider (IPNS-based wallet token storage) was replaced by Profile + aggregator pointer + IPFS CAR. The UXF transfer publisher is a separate concern that survived the deprecation. Passing tokenSync.ipfs.enabled: true to createNodeProviders would re-couple them and re-activate the deprecated wallet-storage path. By importing createUxfCarPublisher directly, we wire only the publisher we need.

New config field

SphereProvidersConfig.ipfsGateways?: readonly string[] — defaults to DEFAULT_IPFS_GATEWAYS (which honors the SPHERE_IPFS_GATEWAY env override). Pass an empty array to disable the publisher entirely; large sends will then fail at the SDK's INLINE_CAR_TOO_LARGE pre-flight.

Verification

End-to-end soak (sphere-sdk:manual-test-roundtrip-391.sh with STRICT_CID_DELIVERY=1) against testnet — 4-hop A→B→A→B→A:

  • HOP 4 cleared the duplicate-bundle guard (sphere-sdk#391 invariant verified).
  • Bundle (≈121 KB) stayed inline under sphere-sdk#394b's new 512 KiB ceiling.
  • Alice received normally; balance reconciliation passed (alice −0.5 UCT, bob +0.5 UCT).
  • No DUPLICATE_BUNDLE_MEMBERSHIP, no INLINE_CAR_TOO_LARGE anywhere.
  • ALL GREEN, exit 0.

For bundles > 512 KiB the publisher path is the same mechanism end-to-end, but soak coverage for that range is pending (a separate follow-up).

Test plan

  • Build clean (npm run build)
  • End-to-end soak against testnet (round-trip 4-hop scenario)
  • CI: integration test workflow (nightly)

…uildSphereProviders

Closes the CLI half of sphere-sdk issue #394.

`buildSphereProviders` now imports `createUxfCarPublisher` +
`DEFAULT_IPFS_GATEWAYS` from `@unicitylabs/sphere-sdk/impl/nodejs`
(re-exported on the SDK side as part of #394) and exposes:
- `publishToIpfs` — outgoing UXF CID-delivery callback wired from
  `createUxfCarPublisher(ipfsGateways)`.
- `cidFetchGateways` — recipient-side fetch list so `uxf-cid` bundles
  resolve correctly on arrival.

Both flow through `SphereProvidersBundle` and into `Sphere.init`:
- `src/host/sphere-init.ts` adds explicit pass-through (the call site
  unpacks named fields, not a spread).
- `src/legacy/legacy-cli.ts` is untouched — its `Sphere.init` already
  spreads `...initProviders`, which inherits the new fields
  automatically. Same for the migration call site at line ~2240.

Crucially, this does NOT re-enable the deprecated
`IpfsStorageProvider` (deprecated for wallet token storage; replaced
by Profile). The UXF bundle publisher is a separate concern that
survives the deprecation. We avoid the coupling by importing
`createUxfCarPublisher` directly rather than passing
`tokenSync.ipfs.enabled: true` to `createNodeProviders`.

New config field `SphereProvidersConfig.ipfsGateways` lets callers
override the gateway list (defaults to `DEFAULT_IPFS_GATEWAYS` which
honors the `SPHERE_IPFS_GATEWAY` env override). Pass an empty array
to disable the publisher entirely (sends > RELAY_SAFE_CAP_BYTES
will then fail at the SDK's `INLINE_CAR_TOO_LARGE` pre-flight).

Verified end-to-end via the round-trip soak at
sphere-sdk:manual-test-roundtrip-391.sh with STRICT_CID_DELIVERY=1:
4-hop A→B→A→B→A succeeded, balance reconciliation passed
(alice -0.5 UCT, bob +0.5 UCT), no DUPLICATE_BUNDLE_MEMBERSHIP, no
INLINE_CAR_TOO_LARGE. With sphere-sdk #394b's 512 KiB cap the
realistic 121 KB bundle stays inline so CID delivery isn't actually
exercised here; for >512 KiB bundles the publisher path is the same
mechanism, end-to-end testing pending soak coverage for that range.

Pairs with sphere-sdk PR (branch feat/issue-394-cid-delivery-wiring).
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