feat(paywall): offer xBull, LOBSTR, Albedo and Rabet, and make the list configurable - #81
Open
pedro-pelicioni wants to merge 3 commits into
Open
feat(paywall): offer xBull, LOBSTR, Albedo and Rabet, and make the list configurable#81pedro-pelicioni wants to merge 3 commits into
pedro-pelicioni wants to merge 3 commits into
Conversation
Kept free of any Stellar Wallets Kit import on purpose: the SWK modules are browser-only and throw on `@stellar/freighter-api`'s ESM interop when loaded under Node, so selection logic that imports them cannot be unit-tested at all. Unknown ids are dropped with a warning rather than thrown, and a list with no usable id falls back to every wallet — a paywall offering no wallets cannot be paid. Ledger, Trezor and WalletConnect are left out: their modules need per-integrator configuration and cannot be enabled by id alone. Co-authored-by: Nearx-Labs <nearxlabs@nearx.com.br>
The kit was initialised with four modules. Anyone holding USDC in xBull, LOBSTR, Albedo or Rabet could not pay, and the modal gave no hint their wallet was never an option — SWK ships a zero-config module for each. Now eight, Freighter first. Ids map to modules through a `Record<WalletId, ...>`, so adding an id without wiring its module is a build error rather than a crash inside the modal. Costs about 99 KB uncompressed. Co-authored-by: Nearx-Labs <nearxlabs@nearx.com.br>
`stellarWallets` on `PaywallConfig` reaches the browser as `window.x402.config.wallets`, the same path `stellarRpcUrl` already takes. Omitting it keeps every supported wallet. Co-authored-by: Nearx-Labs <nearxlabs@nearx.com.br>
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.
feat(paywall): offer xBull, LOBSTR, Albedo and Rabet, and make the list configurable
Branch:
fix/74-wallet-coverageScreenshots:
harness/shots/before-wallet-modal.png→harness/shots/after-wallet-modal.pngThe gap
useSWKConnectioninitialises Stellar Wallets Kit with four modules:Anyone holding USDC in xBull, LOBSTR, Albedo or Rabet cannot pay, and the modal
gives no hint that their wallet was never an option. SWK ships a zero-config
module for each of them (
@creit.tech/stellar-wallets-kit/modules/{xbull,lobstr,albedo,rabet}).Opening the real modal against each version confirms the difference:
The change
stellarWalletsonPaywallConfigflows through to
window.x402.config.wallets, the same pathstellarRpcUrlalready takes. Omitting it keeps every wallet.
falls back to all wallets, so a config typo degrades instead of leaving a
paywall nobody can pay.
Structure
The id list and the resolution logic live in
walletIds.tswith no SWKimport. The SWK modules are browser-only — importing one under Node throws on
@stellar/freighter-api's ESM interop — so keeping them apart is what makesthe selection logic unit-testable at all.
walletModules.tsmaps ids to modulesthrough a
Record<WalletId, ...>, so adding an id without wiring up its moduleis a build error rather than a crash inside the modal.
Ledger, Trezor and WalletConnect are deliberately excluded: their modules need
per-integrator configuration (a transport, a project id) and cannot be enabled
by id alone.
Cost
~99 KB uncompressed for the four added wallets (3,749,116 → 3,850,869 bytes).
If that is too much for the default, the same mechanism supports shipping four
by default and letting hosts opt into the rest — say the word and I will flip it.
Tests
9 new cases covering the default list, explicit ordering, case/whitespace
tolerance, de-duplication, unknown-id warning, and the all-unknown fallback.
Part of #74.