feat(cli)(sphere-sdk#394): wire publishToIpfs + cidFetchGateways in buildSphereProviders#31
Merged
vrogojin merged 1 commit intoJun 4, 2026
Conversation
…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).
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the CLI half of sphere-sdk issue #394. Pairs with sphere-sdk PR #395 (branch
feat/issue-394-cid-delivery-wiring).What
buildSphereProvidersnow importscreateUxfCarPublisher+DEFAULT_IPFS_GATEWAYSfrom@unicitylabs/sphere-sdk/impl/nodejs(re-exported on the SDK side as part of #394) and exposes:publishToIpfs— outgoing UXF CID-delivery callback wired fromcreateUxfCarPublisher(ipfsGateways).cidFetchGateways— recipient-side fetch list souxf-cidbundles resolve correctly on arrival.Both flow through
SphereProvidersBundleintoSphere.init:src/host/sphere-init.tsadds explicit pass-through (named-field call site).src/legacy/legacy-cli.tsis untouched — its threeSphere.initcall 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. PassingtokenSync.ipfs.enabled: truetocreateNodeProviderswould re-couple them and re-activate the deprecated wallet-storage path. By importingcreateUxfCarPublisherdirectly, we wire only the publisher we need.New config field
SphereProvidersConfig.ipfsGateways?: readonly string[]— defaults toDEFAULT_IPFS_GATEWAYS(which honors theSPHERE_IPFS_GATEWAYenv override). Pass an empty array to disable the publisher entirely; large sends will then fail at the SDK'sINLINE_CAR_TOO_LARGEpre-flight.Verification
End-to-end soak (
sphere-sdk:manual-test-roundtrip-391.shwithSTRICT_CID_DELIVERY=1) against testnet — 4-hop A→B→A→B→A:DUPLICATE_BUNDLE_MEMBERSHIP, noINLINE_CAR_TOO_LARGEanywhere.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
npm run build)