@xochi/widget 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +420 -2
- package/THIRD_PARTY_NOTICES.txt +44 -0
- package/dist/ConfiguratorApp.js +19 -0
- package/dist/EmbedApp.js +57 -0
- package/dist/assets/MonaspaceArgon-Bold-D9kWRRK5.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Light-Dt_6qXbW.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Medium-B1gMZwrU.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Regular-RS-2TGNg.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-SemiBold-PYusZXE_.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Italic-C9u9eioB.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Light-CJkxpyfT.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Medium-DCChELAx.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Regular-BZtV1wRa.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Bold-KacFhGOf.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Medium-Dqqg-cnL.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Regular-BRsdKART.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-SemiBold-DNjPl3uE.woff2 +0 -0
- package/dist/assets/alipay-3tx9-HPp.svg +1 -0
- package/dist/assets/arb-CCfLcB_X.svg +7 -0
- package/dist/assets/arc-Dy98eSCd.svg +10 -0
- package/dist/assets/aztec-DiLp9qTG.svg +4 -0
- package/dist/assets/base-Ch0ino36.svg +4 -0
- package/dist/assets/cashapp-lOg0DIt8.svg +1 -0
- package/dist/assets/chains/arbitrum.svg.js +4 -0
- package/dist/assets/chains/arc.svg.js +4 -0
- package/dist/assets/chains/aztec.svg.js +4 -0
- package/dist/assets/chains/base.svg.js +4 -0
- package/dist/assets/chains/ethereum.svg.js +4 -0
- package/dist/assets/chains/gnosis.png.js +4 -0
- package/dist/assets/chains/index.js +31 -0
- package/dist/assets/chains/optimism.svg.js +4 -0
- package/dist/assets/chains/polygon.svg.js +4 -0
- package/dist/assets/chains/robinhood.svg.js +4 -0
- package/dist/assets/chains/tron.svg.js +4 -0
- package/dist/assets/chains/xochi.svg.js +4 -0
- package/dist/assets/dai-XuyZLceZ.png +0 -0
- package/dist/assets/defillama-BU037Unq.svg +1 -0
- package/dist/assets/defillama.svg.js +4 -0
- package/dist/assets/eth-Dvbng9UB.svg +8 -0
- package/dist/assets/eurc-NI9zNgOQ.png +0 -0
- package/dist/assets/eure-BH9vpwcv.png +0 -0
- package/dist/assets/gnosis-fRzAZQFj.png +0 -0
- package/dist/assets/mercadopago-gjsFb6F7.svg +1 -0
- package/dist/assets/monzo-B9XD4bL5.png +0 -0
- package/dist/assets/monzo-SZnIdUKN.svg +1 -0
- package/dist/assets/monzo-dark-Bwzg90UC.png +0 -0
- package/dist/assets/n26-cANcjY2T.svg +1 -0
- package/dist/assets/op-DF67SbB6.png +0 -0
- package/dist/assets/optimism-B3cTNxEQ.svg +4 -0
- package/dist/assets/paypal-D8xqXEtN.svg +1 -0
- package/dist/assets/pol-uLmSo2O8.svg +3 -0
- package/dist/assets/rails/SOURCES.md +50 -0
- package/dist/assets/rails/alipay.svg.js +4 -0
- package/dist/assets/rails/cashapp.svg.js +4 -0
- package/dist/assets/rails/index.js +59 -0
- package/dist/assets/rails/mercadopago.svg.js +4 -0
- package/dist/assets/rails/monzo-dark.png.js +4 -0
- package/dist/assets/rails/monzo.png.js +4 -0
- package/dist/assets/rails/monzo.svg.js +4 -0
- package/dist/assets/rails/n26.svg.js +4 -0
- package/dist/assets/rails/paypal.svg.js +4 -0
- package/dist/assets/rails/revolut-dark.png.js +4 -0
- package/dist/assets/rails/revolut.png.js +4 -0
- package/dist/assets/rails/revolut.svg.js +4 -0
- package/dist/assets/rails/venmo.svg.js +4 -0
- package/dist/assets/rails/wise-dark.png.js +4 -0
- package/dist/assets/rails/wise.png.js +4 -0
- package/dist/assets/rails/wise.svg.js +4 -0
- package/dist/assets/rails/xmoney.svg.js +4 -0
- package/dist/assets/rails/zelle.svg.js +4 -0
- package/dist/assets/raxol-86FmC34h.png +0 -0
- package/dist/assets/revolut-CiBtyALA.png +0 -0
- package/dist/assets/revolut-D7qr5Vzs.svg +1 -0
- package/dist/assets/revolut-dark-RQdWGM_p.png +0 -0
- package/dist/assets/robinhood-DgdGTQ1I.svg +8 -0
- package/dist/assets/tokens/arb.svg.js +4 -0
- package/dist/assets/tokens/dai.png.js +4 -0
- package/dist/assets/tokens/eth.svg.js +4 -0
- package/dist/assets/tokens/eurc.png.js +4 -0
- package/dist/assets/tokens/eure.png.js +4 -0
- package/dist/assets/tokens/index.js +36 -0
- package/dist/assets/tokens/op.png.js +4 -0
- package/dist/assets/tokens/pol.svg.js +4 -0
- package/dist/assets/tokens/raxol.png.js +4 -0
- package/dist/assets/tokens/usdc.png.js +4 -0
- package/dist/assets/tokens/usdg.png.js +4 -0
- package/dist/assets/tokens/usdt.png.js +4 -0
- package/dist/assets/tokens/wbtc.png.js +4 -0
- package/dist/assets/tokens/wsteth.png.js +4 -0
- package/dist/assets/tokens/zchf.png.js +4 -0
- package/dist/assets/tron-Dtumyzha.svg +4 -0
- package/dist/assets/usdc-UHSd0FoM.png +0 -0
- package/dist/assets/usdg-Cd5nCzbC.png +0 -0
- package/dist/assets/usdt-3G3YdPq8.png +0 -0
- package/dist/assets/venmo-CMHeCn-D.svg +1 -0
- package/dist/assets/wbtc-CV8uE44Q.png +0 -0
- package/dist/assets/wise-BUOflsWL.svg +1 -0
- package/dist/assets/wise-JLpDvCdq.png +0 -0
- package/dist/assets/wise-dark-_Q8pbCom.png +0 -0
- package/dist/assets/wsteth-BamwtTCR.png +0 -0
- package/dist/assets/xmoney-CwY9KVlD.svg +1 -0
- package/dist/assets/xochi-DL2f8G4R.svg +4 -0
- package/dist/assets/zchf-BLBNdTGJ.png +0 -0
- package/dist/assets/zelle-t15cG4SB.svg +1 -0
- package/dist/browser.js +4 -0
- package/dist/components/AccountChip.js +29 -0
- package/dist/components/ActivityFeed.js +710 -0
- package/dist/components/AssetsStrip.js +133 -0
- package/dist/components/AuthorizedAgents.js +197 -0
- package/dist/components/Chevron.js +22 -0
- package/dist/components/ErrorDisplay.js +68 -0
- package/dist/components/InfoButton.js +27 -0
- package/dist/components/IntentTimeline.js +202 -0
- package/dist/components/LinksSignIn.js +26 -0
- package/dist/components/MobileSigningBanner.js +44 -0
- package/dist/components/PrivacyBars.js +44 -0
- package/dist/components/PrivacyPanel.js +99 -0
- package/dist/components/QuoteDetails.js +327 -0
- package/dist/components/ReceiptCommand.js +46 -0
- package/dist/components/SessionReloadBanner.js +19 -0
- package/dist/components/SolverRace.js +62 -0
- package/dist/components/StealthClaims.js +179 -0
- package/dist/components/SwapFlowModal.js +408 -0
- package/dist/components/Toast.js +40 -0
- package/dist/components/TokenIcon.js +21 -0
- package/dist/components/TokenSearchModal.js +331 -0
- package/dist/components/TransactionPreview.js +230 -0
- package/dist/components/WalletProvider.js +41 -0
- package/dist/components/WrapModal.js +192 -0
- package/dist/components/swap-flow/CantonEscrowPanel.js +28 -0
- package/dist/components/swap-flow/CantonEscrowStatus.js +160 -0
- package/dist/components/swap-flow/DepositInstructions.js +156 -0
- package/dist/components/swap-flow/QrCode.js +22 -0
- package/dist/components/swap-flow/SwapResult.js +325 -0
- package/dist/components/swap-flow/depositScreen.js +36 -0
- package/dist/components/widgetTabsContext.js +17 -0
- package/dist/config.js +132 -0
- package/dist/configurator-model.js +71 -0
- package/dist/configurator.js +11 -0
- package/dist/constants.js +53 -0
- package/dist/hooks/applyTheme.js +10 -0
- package/dist/hooks/useAgentRegistry.js +28 -0
- package/dist/hooks/useAgentStream.js +89 -0
- package/dist/hooks/useCantonEscrow.js +89 -0
- package/dist/hooks/useCapabilities.js +86 -0
- package/dist/hooks/useEmbedLook.js +23 -0
- package/dist/hooks/useFocusTrap.js +44 -0
- package/dist/hooks/useIntent.js +485 -0
- package/dist/hooks/useIntentStatusPoll.js +71 -0
- package/dist/hooks/useIntentStream.js +95 -0
- package/dist/hooks/useLocalActivity.js +114 -0
- package/dist/hooks/useLocalSends.js +15 -0
- package/dist/hooks/useLocalStorage.js +26 -0
- package/dist/hooks/useOrderHistory.js +307 -0
- package/dist/hooks/usePermit.js +203 -0
- package/dist/hooks/usePrices.js +49 -0
- package/dist/hooks/usePublicBalances.js +186 -0
- package/dist/hooks/useRampSummaries.js +19 -0
- package/dist/hooks/useRecipientBalance.js +98 -0
- package/dist/hooks/useSettlements.js +33 -0
- package/dist/hooks/useStealth.js +324 -0
- package/dist/hooks/useStealthClaim.js +183 -0
- package/dist/hooks/useStealthScanner.js +259 -0
- package/dist/hooks/useTheme.js +48 -0
- package/dist/hooks/useTierInfo.js +20 -0
- package/dist/hooks/useTrustScore.js +16 -0
- package/dist/hooks/useWalletSession.js +70 -0
- package/dist/hooks/useWrapEth.js +60 -0
- package/dist/index.js +41 -0
- package/dist/integration.js +19 -0
- package/dist/lib/activityValue.js +20 -0
- package/dist/lib/agentConnect.js +11 -0
- package/dist/lib/agentRegistry.js +83 -0
- package/dist/lib/agentStreamVerify.js +47 -0
- package/dist/lib/api.js +67 -0
- package/dist/lib/auth.js +8 -0
- package/dist/lib/authFetch.js +33 -0
- package/dist/lib/aztecTokens.js +13 -0
- package/dist/lib/balances.js +77 -0
- package/dist/lib/capabilities.js +40 -0
- package/dist/lib/claimSubmitPoll.js +63 -0
- package/dist/lib/debug.js +7 -0
- package/dist/lib/declineGuidance.js +31 -0
- package/dist/lib/displayFallbacks.js +25 -0
- package/dist/lib/eip712.js +38 -0
- package/dist/lib/errorCategory.js +202 -0
- package/dist/lib/errorReport.js +19 -0
- package/dist/lib/explorerLinks.js +30 -0
- package/dist/lib/feesLabel.js +19 -0
- package/dist/lib/glyphs.js +58 -0
- package/dist/lib/hostBridge.js +41 -0
- package/dist/lib/hostOrigin.js +52 -0
- package/dist/lib/intentAPI.js +39 -0
- package/dist/lib/linksSignIn.js +9 -0
- package/dist/lib/localActivity.js +247 -0
- package/dist/lib/localSends.js +129 -0
- package/dist/lib/mobileWallet.js +17 -0
- package/dist/lib/pairAvailability.js +29 -0
- package/dist/lib/paymentSummary.js +23 -0
- package/dist/lib/permits.js +27 -0
- package/dist/lib/priceImpact.js +101 -0
- package/dist/lib/providers.js +124 -0
- package/dist/lib/qr.js +20 -0
- package/dist/lib/quoteCost.js +34 -0
- package/dist/lib/quoteCountdown.js +24 -0
- package/dist/lib/rampHostGate.js +24 -0
- package/dist/lib/rampLifecycle.js +63 -0
- package/dist/lib/receiptCost.js +64 -0
- package/dist/lib/recipient/index.js +302 -0
- package/dist/lib/recipient/recent.js +47 -0
- package/dist/lib/recipientReceipt.js +16 -0
- package/dist/lib/reportClient.js +32 -0
- package/dist/lib/sessionExpiry.js +11 -0
- package/dist/lib/settlementAvailability.js +34 -0
- package/dist/lib/stealth.js +110 -0
- package/dist/lib/swapFlowPhase.js +52 -0
- package/dist/lib/swapStatusCopy.js +59 -0
- package/dist/lib/tradeLifecycle.js +40 -0
- package/dist/lib/tronlink.js +71 -0
- package/dist/lib/walletSession.js +87 -0
- package/dist/pages/Configurator.js +390 -0
- package/dist/pages/Trade.js +635 -0
- package/dist/pages/configurator/AllowedAssetsSection.js +98 -0
- package/dist/pages/configurator/AppearanceSection.js +44 -0
- package/dist/pages/configurator/CodeDock.js +140 -0
- package/dist/pages/configurator/DeveloperSection.js +40 -0
- package/dist/pages/configurator/IntegrationSection.js +105 -0
- package/dist/pages/configurator/LayoutSection.js +83 -0
- package/dist/pages/configurator/PolicyNote.js +7 -0
- package/dist/pages/configurator/PreviewStage.js +165 -0
- package/dist/pages/configurator/PrivacySection.js +54 -0
- package/dist/pages/configurator/RouteSection.js +211 -0
- package/dist/pages/configurator/Settings.js +35 -0
- package/dist/pages/configurator/SharedLinkBanner.js +25 -0
- package/dist/pages/configurator/SurfaceSection.js +124 -0
- package/dist/pages/configurator/WhatUsersSee.js +268 -0
- package/dist/pages/configurator/codeShown.js +8 -0
- package/dist/pages/configurator/configuratorUrl.js +33 -0
- package/dist/pages/configurator/paramsDraft.js +82 -0
- package/dist/pages/configurator/previewModel.js +10 -0
- package/dist/pages/configurator/previewQuote.js +109 -0
- package/dist/pages/configurator/routePicks.js +131 -0
- package/dist/pages/configurator/snippets.js +98 -0
- package/dist/pages/configurator/surfaceParams.js +51 -0
- package/dist/pages/configurator/useCodeCheck.js +79 -0
- package/dist/pages/configurator/useConfiguratorUrl.js +24 -0
- package/dist/pages/configurator/useMediaQuery.js +20 -0
- package/dist/pages/configurator/useParamsDraft.js +33 -0
- package/dist/pages/configurator/usePreviewFee.js +100 -0
- package/dist/pages/send/MetaAddressValue.js +28 -0
- package/dist/pages/send/Receive.js +168 -0
- package/dist/pages/send/RecentRecipients.js +23 -0
- package/dist/pages/send/RecipientChip.js +26 -0
- package/dist/pages/send/ScanRecipient.js +85 -0
- package/dist/pages/send/SendForm.js +516 -0
- package/dist/pages/send/SendPanel.js +30 -0
- package/dist/pages/send/ShieldedDisclosure.js +12 -0
- package/dist/pages/send/StealthInvite.js +27 -0
- package/dist/pages/send/addressSend.js +92 -0
- package/dist/pages/send/sendCopy.js +10 -0
- package/dist/pages/send/sendRetry.js +24 -0
- package/dist/pages/send/stealthRecipient.js +65 -0
- package/dist/pages/send/stealthSend.js +15 -0
- package/dist/pages/send/useAddressSend.js +257 -0
- package/dist/pages/send/useSendRecipient.js +61 -0
- package/dist/pages/trade/BuyPanel.js +70 -0
- package/dist/pages/trade/RampRecovery.js +41 -0
- package/dist/pages/trade/RecipientSheet.js +182 -0
- package/dist/pages/trade/Selectors.js +152 -0
- package/dist/pages/trade/SwapPanel.js +972 -0
- package/dist/pages/trade/WidgetTabs.js +109 -0
- package/dist/pages/trade/canton.js +122 -0
- package/dist/pages/trade/config.js +70 -0
- package/dist/pages/trade/embedNarrowing.js +25 -0
- package/dist/pages/trade/embedParams.js +532 -0
- package/dist/pages/trade/embedTheme.js +9 -0
- package/dist/pages/trade/orderMinimum.js +8 -0
- package/dist/pages/trade/resumeSwap.js +55 -0
- package/dist/pages/trade/settlementCopy.js +32 -0
- package/dist/pages/trade/useAmountFit.js +31 -0
- package/dist/pages/trade/useEmbedDefaults.js +18 -0
- package/dist/pages/trade/useSettlementGating.js +289 -0
- package/dist/pages/trade/useSwapAmount.js +191 -0
- package/dist/pages/trade/useSwapFlow.js +511 -0
- package/dist/pages/trade/useSwapPanel.js +475 -0
- package/dist/pages/trade/useSwapRoute.js +634 -0
- package/dist/pages/trade/useTronLinkFill.js +34 -0
- package/dist/pages/trade/zkMoney.js +46 -0
- package/dist/promiseWithResolvers.js +20 -0
- package/dist/ramp/availability/RailTiles.js +156 -0
- package/dist/ramp/availability/RampDisclosure.js +38 -0
- package/dist/ramp/availability/RampRails.js +170 -0
- package/dist/ramp/availability/model.js +207 -0
- package/dist/ramp/availability/useRampDiscovery.js +83 -0
- package/dist/ramp/offramp/CompletedPrerequisite.js +23 -0
- package/dist/ramp/offramp/OfframpActivityList.js +16 -0
- package/dist/ramp/offramp/OfframpRoute.js +222 -0
- package/dist/ramp/offramp/OfframpRouteReview.js +94 -0
- package/dist/ramp/offramp/PaymentAppSend.js +765 -0
- package/dist/ramp/offramp/localOfframps.js +101 -0
- package/dist/ramp/offramp/model.js +154 -0
- package/dist/ramp/offramp/port.js +134 -0
- package/dist/ramp/offramp/prerequisite.js +143 -0
- package/dist/ramp/offramp/useOfframp.js +505 -0
- package/dist/ramp/offramp/useOfframpRails.js +73 -0
- package/dist/ramp/peer/BuyOnramp.js +292 -0
- package/dist/ramp/peer/OnrampSteps.js +148 -0
- package/dist/ramp/peer/buyerDriver.js +461 -0
- package/dist/ramp/peer/discovery.js +231 -0
- package/dist/ramp/peer/environment.js +7 -0
- package/dist/ramp/peer/liveProvider.js +87 -0
- package/dist/ramp/peer/liveReads.js +488 -0
- package/dist/ramp/peer/maker.js +92 -0
- package/dist/ramp/peer/normalization.js +184 -0
- package/dist/ramp/peer/offramp.js +648 -0
- package/dist/ramp/peer/onramp.js +353 -0
- package/dist/ramp/peer/preview.js +52 -0
- package/dist/ramp/peer/protectedMapping.js +67 -0
- package/dist/ramp/peer/runtime.js +55 -0
- package/dist/ramp/peer/sdkMaker.js +107 -0
- package/dist/ramp/recovery/ResumeOnramp.js +153 -0
- package/dist/ramp/recovery/summaries.js +173 -0
- package/dist/ramp/route/OnrampRoute.js +255 -0
- package/dist/ramp/route/RampRouteSteps.js +148 -0
- package/dist/ramp/route/routeActivity.js +12 -0
- package/dist/ramp/route/useXochiRampDriver.js +203 -0
- package/dist/styles.css +17473 -0
- package/dist/styles.js +2 -0
- package/dist/types/ConfiguratorApp.d.ts +6 -0
- package/dist/types/EmbedApp.d.ts +2 -0
- package/dist/types/activity.js +50 -0
- package/dist/types/asset.d.ts +2 -0
- package/dist/types/assets/chains/index.d.ts +3 -0
- package/dist/types/assets/rails/index.d.ts +12 -0
- package/dist/types/assets/tokens/index.d.ts +1 -0
- package/dist/types/browser.d.ts +1 -0
- package/dist/types/components/AccountChip.d.ts +10 -0
- package/dist/types/components/ActivityFeed.d.ts +46 -0
- package/dist/types/components/AssetsStrip.d.ts +14 -0
- package/dist/types/components/AuthorizedAgents.d.ts +15 -0
- package/dist/types/components/Chevron.d.ts +16 -0
- package/dist/types/components/ErrorDisplay.d.ts +46 -0
- package/dist/types/components/InfoButton.d.ts +6 -0
- package/dist/types/components/IntentTimeline.d.ts +41 -0
- package/dist/types/components/LinksSignIn.d.ts +13 -0
- package/dist/types/components/MobileSigningBanner.d.ts +16 -0
- package/dist/types/components/PermitBadge.d.ts +17 -0
- package/dist/types/components/PrivacyBars.d.ts +12 -0
- package/dist/types/components/PrivacyPanel.d.ts +33 -0
- package/dist/types/components/QuoteDetails.d.ts +56 -0
- package/dist/types/components/RampActivityList.d.ts +14 -0
- package/dist/types/components/ReceiptCommand.d.ts +12 -0
- package/dist/types/components/SessionReloadBanner.d.ts +8 -0
- package/dist/types/components/SolverRace.d.ts +35 -0
- package/dist/types/components/StealthClaims.d.ts +51 -0
- package/dist/types/components/SwapFlowModal.d.ts +142 -0
- package/dist/types/components/Toast.d.ts +10 -0
- package/dist/types/components/TokenIcon.d.ts +17 -0
- package/dist/types/components/TokenSearchModal.d.ts +28 -0
- package/dist/types/components/TransactionPreview.d.ts +37 -0
- package/dist/types/components/WalletProvider.d.ts +12 -0
- package/dist/types/components/WrapModal.d.ts +19 -0
- package/dist/types/components/swap-flow/CantonEscrowPanel.d.ts +14 -0
- package/dist/types/components/swap-flow/CantonEscrowStatus.d.ts +30 -0
- package/dist/types/components/swap-flow/DepositInstructions.d.ts +75 -0
- package/dist/types/components/swap-flow/QrCode.d.ts +18 -0
- package/dist/types/components/swap-flow/SwapResult.d.ts +68 -0
- package/dist/types/components/swap-flow/depositScreen.d.ts +67 -0
- package/dist/types/components/widgetTabsContext.d.ts +21 -0
- package/dist/types/config.d.ts +104 -0
- package/dist/types/configurator-model.d.ts +9 -0
- package/dist/types/configurator.d.ts +3 -0
- package/dist/types/constants.d.ts +52 -0
- package/dist/types/hooks/applyTheme.d.ts +7 -0
- package/dist/types/hooks/useAgentRegistry.d.ts +13 -0
- package/dist/types/hooks/useAgentStream.d.ts +15 -0
- package/dist/types/hooks/useCantonEscrow.d.ts +40 -0
- package/dist/types/hooks/useCapabilities.d.ts +83 -0
- package/dist/types/hooks/useEmbedLook.d.ts +4 -0
- package/dist/types/hooks/useFocusTrap.d.ts +7 -0
- package/dist/types/hooks/useIntent.d.ts +161 -0
- package/dist/types/hooks/useIntentStatusPoll.d.ts +107 -0
- package/dist/types/hooks/useIntentStream.d.ts +34 -0
- package/dist/types/hooks/useLocalActivity.d.ts +22 -0
- package/dist/types/hooks/useLocalSends.d.ts +8 -0
- package/dist/types/hooks/useLocalStorage.d.ts +8 -0
- package/dist/types/hooks/useOrderHistory.d.ts +52 -0
- package/dist/types/hooks/usePermit.d.ts +90 -0
- package/dist/types/hooks/usePrices.d.ts +72 -0
- package/dist/types/hooks/usePublicBalances.d.ts +19 -0
- package/dist/types/hooks/useRampSummaries.d.ts +9 -0
- package/dist/types/hooks/useRecipientBalance.d.ts +58 -0
- package/dist/types/hooks/useSettlements.d.ts +14 -0
- package/dist/types/hooks/useStealth.d.ts +72 -0
- package/dist/types/hooks/useStealthClaim.d.ts +96 -0
- package/dist/types/hooks/useStealthScanner.d.ts +44 -0
- package/dist/types/hooks/useTheme.d.ts +29 -0
- package/dist/types/hooks/useTierInfo.d.ts +23 -0
- package/dist/types/hooks/useTrustScore.d.ts +16 -0
- package/dist/types/hooks/useWalletSession.d.ts +21 -0
- package/dist/types/hooks/useWrapEth.d.ts +21 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +8 -0
- package/dist/types/integration.d.ts +9 -0
- package/dist/types/intent.js +85 -0
- package/dist/types/lib/activityValue.d.ts +16 -0
- package/dist/types/lib/agentConnect.d.ts +23 -0
- package/dist/types/lib/agentRegistry.d.ts +47 -0
- package/dist/types/lib/agentStreamVerify.d.ts +29 -0
- package/dist/types/lib/api.d.ts +41 -0
- package/dist/types/lib/auth.d.ts +6 -0
- package/dist/types/lib/authFetch.d.ts +14 -0
- package/dist/types/lib/aztecTokens.d.ts +15 -0
- package/dist/types/lib/balances.d.ts +88 -0
- package/dist/types/lib/capabilities.d.ts +3 -0
- package/dist/types/lib/claimSubmitPoll.d.ts +114 -0
- package/dist/types/lib/debug.d.ts +13 -0
- package/dist/types/lib/declineGuidance.d.ts +55 -0
- package/dist/types/lib/displayFallbacks.d.ts +7 -0
- package/dist/types/lib/eip712.d.ts +61 -0
- package/dist/types/lib/errorCategory.d.ts +50 -0
- package/dist/types/lib/errorReport.d.ts +15 -0
- package/dist/types/lib/explorerLinks.d.ts +67 -0
- package/dist/types/lib/feesLabel.d.ts +20 -0
- package/dist/types/lib/glyphs.d.ts +52 -0
- package/dist/types/lib/hostBridge.d.ts +11 -0
- package/dist/types/lib/hostOrigin.d.ts +30 -0
- package/dist/types/lib/intentAPI.d.ts +15 -0
- package/dist/types/lib/linksSignIn.d.ts +13 -0
- package/dist/types/lib/localActivity.d.ts +135 -0
- package/dist/types/lib/localSends.d.ts +55 -0
- package/dist/types/lib/mobileWallet.d.ts +27 -0
- package/dist/types/lib/pairAvailability.d.ts +106 -0
- package/dist/types/lib/paymentSummary.d.ts +18 -0
- package/dist/types/lib/permits.d.ts +25 -0
- package/dist/types/lib/priceImpact.d.ts +165 -0
- package/dist/types/lib/providers.d.ts +14 -0
- package/dist/types/lib/qr.d.ts +19 -0
- package/dist/types/lib/quoteCost.d.ts +45 -0
- package/dist/types/lib/quoteCountdown.d.ts +34 -0
- package/dist/types/lib/rampHostGate.d.ts +15 -0
- package/dist/types/lib/rampLifecycle.d.ts +20 -0
- package/dist/types/lib/receiptCost.d.ts +64 -0
- package/dist/types/lib/recipient/index.d.ts +33 -0
- package/dist/types/lib/recipient/recent.d.ts +5 -0
- package/dist/types/lib/recipientReceipt.d.ts +25 -0
- package/dist/types/lib/reportClient.d.ts +9 -0
- package/dist/types/lib/sessionExpiry.d.ts +11 -0
- package/dist/types/lib/settlementAvailability.d.ts +61 -0
- package/dist/types/lib/stealth.d.ts +75 -0
- package/dist/types/lib/swapFlowPhase.d.ts +76 -0
- package/dist/types/lib/swapStatusCopy.d.ts +57 -0
- package/dist/types/lib/tierProgressDisplay.d.ts +35 -0
- package/dist/types/lib/tierUnlock.d.ts +25 -0
- package/dist/types/lib/tradeLifecycle.d.ts +32 -0
- package/dist/types/lib/tronlink.d.ts +62 -0
- package/dist/types/lib/walletSession.d.ts +38 -0
- package/dist/types/pages/Configurator.d.ts +25 -0
- package/dist/types/pages/Trade.d.ts +36 -0
- package/dist/types/pages/configurator/AllowedAssetsSection.d.ts +17 -0
- package/dist/types/pages/configurator/AppearanceSection.d.ts +22 -0
- package/dist/types/pages/configurator/CodeDock.d.ts +19 -0
- package/dist/types/pages/configurator/DeveloperSection.d.ts +12 -0
- package/dist/types/pages/configurator/IntegrationSection.d.ts +20 -0
- package/dist/types/pages/configurator/LayoutSection.d.ts +20 -0
- package/dist/types/pages/configurator/PolicyNote.d.ts +6 -0
- package/dist/types/pages/configurator/PreviewStage.d.ts +22 -0
- package/dist/types/pages/configurator/PrivacySection.d.ts +16 -0
- package/dist/types/pages/configurator/RouteSection.d.ts +30 -0
- package/dist/types/pages/configurator/Settings.d.ts +25 -0
- package/dist/types/pages/configurator/SharedLinkBanner.d.ts +16 -0
- package/dist/types/pages/configurator/SurfaceSection.d.ts +5 -0
- package/dist/types/pages/configurator/WhatUsersSee.d.ts +30 -0
- package/dist/types/pages/configurator/codeShown.d.ts +15 -0
- package/dist/types/pages/configurator/configuratorUrl.d.ts +38 -0
- package/dist/types/pages/configurator/paramsDraft.d.ts +32 -0
- package/dist/types/pages/configurator/previewModel.d.ts +20 -0
- package/dist/types/pages/configurator/previewQuote.d.ts +96 -0
- package/dist/types/pages/configurator/routePicks.d.ts +75 -0
- package/dist/types/pages/configurator/snippets.d.ts +23 -0
- package/dist/types/pages/configurator/surfaceParams.d.ts +9 -0
- package/dist/types/pages/configurator/useCodeCheck.d.ts +56 -0
- package/dist/types/pages/configurator/useConfiguratorUrl.d.ts +21 -0
- package/dist/types/pages/configurator/useMediaQuery.d.ts +5 -0
- package/dist/types/pages/configurator/useParamsDraft.d.ts +29 -0
- package/dist/types/pages/configurator/usePreviewFee.d.ts +74 -0
- package/dist/types/pages/send/MetaAddressValue.d.ts +9 -0
- package/dist/types/pages/send/Receive.d.ts +3 -0
- package/dist/types/pages/send/RecentRecipients.d.ts +3 -0
- package/dist/types/pages/send/RecipientChip.d.ts +4 -0
- package/dist/types/pages/send/ScanRecipient.d.ts +3 -0
- package/dist/types/pages/send/SendForm.d.ts +17 -0
- package/dist/types/pages/send/SendPanel.d.ts +19 -0
- package/dist/types/pages/send/ShieldedDisclosure.d.ts +1 -0
- package/dist/types/pages/send/StealthInvite.d.ts +1 -0
- package/dist/types/pages/send/addressSend.d.ts +62 -0
- package/dist/types/pages/send/sendCopy.d.ts +9 -0
- package/dist/types/pages/send/sendRetry.d.ts +10 -0
- package/dist/types/pages/send/stealthRecipient.d.ts +37 -0
- package/dist/types/pages/send/stealthSend.d.ts +18 -0
- package/dist/types/pages/send/useAddressSend.d.ts +61 -0
- package/dist/types/pages/send/useSendRecipient.d.ts +13 -0
- package/dist/types/pages/trade/BuyPanel.d.ts +22 -0
- package/dist/types/pages/trade/RampRecovery.d.ts +22 -0
- package/dist/types/pages/trade/RecipientSheet.d.ts +11 -0
- package/dist/types/pages/trade/Selectors.d.ts +24 -0
- package/dist/types/pages/trade/SwapPanel.d.ts +34 -0
- package/dist/types/pages/trade/WidgetTabs.d.ts +46 -0
- package/dist/types/pages/trade/canton.d.ts +94 -0
- package/dist/types/pages/trade/config.d.ts +185 -0
- package/dist/types/pages/trade/embedNarrowing.d.ts +28 -0
- package/dist/types/pages/trade/embedParams.d.ts +299 -0
- package/dist/types/pages/trade/embedTheme.d.ts +14 -0
- package/dist/types/pages/trade/harness.d.ts +120 -0
- package/dist/types/pages/trade/orderMinimum.d.ts +5 -0
- package/dist/types/pages/trade/resumeSwap.d.ts +139 -0
- package/dist/types/pages/trade/settlementCopy.d.ts +42 -0
- package/dist/types/pages/trade/useAmountFit.d.ts +25 -0
- package/dist/types/pages/trade/useEmbedDefaults.d.ts +28 -0
- package/dist/types/pages/trade/useSettlementGating.d.ts +152 -0
- package/dist/types/pages/trade/useSwapAmount.d.ts +93 -0
- package/dist/types/pages/trade/useSwapFlow.d.ts +152 -0
- package/dist/types/pages/trade/useSwapPanel.d.ts +170 -0
- package/dist/types/pages/trade/useSwapRoute.d.ts +215 -0
- package/dist/types/pages/trade/useTronLinkFill.d.ts +13 -0
- package/dist/types/pages/trade/zkMoney.d.ts +28 -0
- package/dist/types/promiseWithResolvers.d.ts +12 -0
- package/dist/types/ramp/availability/RailTiles.d.ts +26 -0
- package/dist/types/ramp/availability/RampDisclosure.d.ts +9 -0
- package/dist/types/ramp/availability/RampRails.d.ts +27 -0
- package/dist/types/ramp/availability/model.d.ts +51 -0
- package/dist/types/ramp/availability/useRampDiscovery.d.ts +60 -0
- package/dist/types/ramp/offramp/CompletedPrerequisite.d.ts +5 -0
- package/dist/types/ramp/offramp/OfframpActivityList.d.ts +12 -0
- package/dist/types/ramp/offramp/OfframpRoute.d.ts +8 -0
- package/dist/types/ramp/offramp/OfframpRouteReview.d.ts +12 -0
- package/dist/types/ramp/offramp/PaymentAppSend.d.ts +27 -0
- package/dist/types/ramp/offramp/localOfframps.d.ts +58 -0
- package/dist/types/ramp/offramp/model.d.ts +46 -0
- package/dist/types/ramp/offramp/port.d.ts +55 -0
- package/dist/types/ramp/offramp/prerequisite.d.ts +271 -0
- package/dist/types/ramp/offramp/useOfframp.d.ts +87 -0
- package/dist/types/ramp/offramp/useOfframpRails.d.ts +36 -0
- package/dist/types/ramp/peer/BuyOnramp.d.ts +21 -0
- package/dist/types/ramp/peer/OnrampSteps.d.ts +32 -0
- package/dist/types/ramp/peer/buyerDriver.d.ts +48 -0
- package/dist/types/ramp/peer/discovery.d.ts +17 -0
- package/dist/types/ramp/peer/environment.d.ts +2 -0
- package/dist/types/ramp/peer/index.d.ts +14 -0
- package/dist/types/ramp/peer/liveProvider.d.ts +15 -0
- package/dist/types/ramp/peer/liveReads.d.ts +102 -0
- package/dist/types/ramp/peer/maker.d.ts +4 -0
- package/dist/types/ramp/peer/normalization.d.ts +33 -0
- package/dist/types/ramp/peer/offramp.d.ts +130 -0
- package/dist/types/ramp/peer/onramp.d.ts +134 -0
- package/dist/types/ramp/peer/preview.d.ts +14 -0
- package/dist/types/ramp/peer/protectedMapping.d.ts +22 -0
- package/dist/types/ramp/peer/runtime.d.ts +15 -0
- package/dist/types/ramp/peer/sdkMaker.d.ts +67 -0
- package/dist/types/ramp/peer/types.d.ts +64 -0
- package/dist/types/ramp/recovery/ResumeOnramp.d.ts +37 -0
- package/dist/types/ramp/recovery/summaries.d.ts +71 -0
- package/dist/types/ramp/route/OnrampRoute.d.ts +12 -0
- package/dist/types/ramp/route/RampRouteSteps.d.ts +16 -0
- package/dist/types/ramp/route/routeActivity.d.ts +4 -0
- package/dist/types/ramp/route/useXochiRampDriver.d.ts +22 -0
- package/dist/types/result.js +14 -0
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/types/activity.d.ts +184 -0
- package/dist/types/types/index.d.ts +20 -0
- package/dist/types/types/intent.d.ts +85 -0
- package/dist/types/types/result.d.ts +53 -0
- package/dist/types/utils/format.d.ts +88 -0
- package/dist/types/wagmi.d.ts +143 -0
- package/dist/types/widgetLibModule.d.ts +8 -0
- package/dist/utils/format.js +109 -0
- package/dist/wagmi.js +210 -0
- package/dist/widgetLibModule.js +4 -0
- package/licenses/Monaspace-OFL-1.1.txt +93 -0
- package/licenses/assets.json +132 -0
- package/licenses/rainbowkit-MIT.txt +9 -0
- package/licenses/xochi-shared-MIT.txt +21 -0
- package/package.json +115 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const ZKMONEY_ACTIVITY_URL = "https://wallet.zk.money/activity";
|
|
2
|
+
const ZKMONEY_ACCOUNT_URL = "https://wallet.zk.money/";
|
|
3
|
+
const ZKMONEY_PRIVACY_COPY = "Amounts and participants hidden inside zk.money.";
|
|
4
|
+
const ZKMONEY_ARRIVAL_NOTE = "zk.money charges about $0.35 on arrival";
|
|
5
|
+
const ZKMONEY_FLOOR_DAI = 1;
|
|
6
|
+
const ZKMONEY_CAP_DAI = 4900;
|
|
7
|
+
const TAG_PATTERN = /^[a-z0-9-]{1,63}$/;
|
|
8
|
+
function normalizeZkMoneyTag(input) {
|
|
9
|
+
const trimmed = input.trim();
|
|
10
|
+
return (trimmed.startsWith("@") ? trimmed.slice(1) : trimmed).toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
function zkMoneyTagValid(tag) {
|
|
13
|
+
return TAG_PATTERN.test(tag);
|
|
14
|
+
}
|
|
15
|
+
function zkMoneyTagError(tag) {
|
|
16
|
+
if (tag.length === 0 || zkMoneyTagValid(tag)) return null;
|
|
17
|
+
return "Use 1 to 63 letters, numbers or hyphens.";
|
|
18
|
+
}
|
|
19
|
+
function zkMoneyRefusal(errorCategory, tag) {
|
|
20
|
+
switch (errorCategory) {
|
|
21
|
+
case "tag_unresolved":
|
|
22
|
+
return `We couldn't find @${tag}. Check the spelling.`;
|
|
23
|
+
case "tag_resolution_unavailable":
|
|
24
|
+
return `We can't look up @${tag} right now. Please try again.`;
|
|
25
|
+
case "tag_destination_unsupported":
|
|
26
|
+
return "zk.money can only receive DAI on Ethereum, sent public.";
|
|
27
|
+
case "amount_below_floor":
|
|
28
|
+
return `@${tag} must receive at least ${ZKMONEY_FLOOR_DAI} DAI.`;
|
|
29
|
+
case "amount_above_cap":
|
|
30
|
+
return `@${tag} can receive at most ${ZKMONEY_CAP_DAI.toLocaleString("en-US")} DAI per send.`;
|
|
31
|
+
default:
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
ZKMONEY_ACCOUNT_URL,
|
|
37
|
+
ZKMONEY_ACTIVITY_URL,
|
|
38
|
+
ZKMONEY_ARRIVAL_NOTE,
|
|
39
|
+
ZKMONEY_CAP_DAI,
|
|
40
|
+
ZKMONEY_FLOOR_DAI,
|
|
41
|
+
ZKMONEY_PRIVACY_COPY,
|
|
42
|
+
normalizeZkMoneyTag,
|
|
43
|
+
zkMoneyRefusal,
|
|
44
|
+
zkMoneyTagError,
|
|
45
|
+
zkMoneyTagValid
|
|
46
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function installPromiseWithResolvers() {
|
|
2
|
+
const constructor = Promise;
|
|
3
|
+
if (typeof constructor.withResolvers === "function") return;
|
|
4
|
+
Object.defineProperty(Promise, "withResolvers", {
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: () => {
|
|
8
|
+
let resolve;
|
|
9
|
+
let reject;
|
|
10
|
+
const promise = new Promise((res, rej) => {
|
|
11
|
+
resolve = res;
|
|
12
|
+
reject = rej;
|
|
13
|
+
});
|
|
14
|
+
return { promise, resolve, reject };
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
installPromiseWithResolvers
|
|
20
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { railLogo, selectedRailIcon } from "../../assets/rails/index.js";
|
|
3
|
+
import { RAIL_NAMES, formatRampTime } from "./model.js";
|
|
4
|
+
function RailLogo({ id }) {
|
|
5
|
+
const logo = railLogo(id);
|
|
6
|
+
if (!logo) return /* @__PURE__ */ jsx("span", { className: "ramp-tile__icon-slot", "aria-hidden": "true" });
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
className: "ramp-tile__icon-slot ramp-tile__logo",
|
|
11
|
+
style: {
|
|
12
|
+
"--rail-logo": `url("${logo.light}")`,
|
|
13
|
+
"--rail-icon-dim": selectedRailIcon(logo.brandColor, "#12121a"),
|
|
14
|
+
"--rail-icon-dark": selectedRailIcon(logo.brandColor, "#080808"),
|
|
15
|
+
"--rail-icon-light": selectedRailIcon(logo.brandColor, "#f5f3ef")
|
|
16
|
+
},
|
|
17
|
+
"aria-hidden": "true"
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function RailTileContent({
|
|
22
|
+
id,
|
|
23
|
+
name,
|
|
24
|
+
status,
|
|
25
|
+
selected
|
|
26
|
+
}) {
|
|
27
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28
|
+
/* @__PURE__ */ jsx(RailLogo, { id }),
|
|
29
|
+
/* @__PURE__ */ jsxs("span", { className: "ramp-tile__text", children: [
|
|
30
|
+
/* @__PURE__ */ jsx("strong", { className: "ramp-tile__name", children: name }),
|
|
31
|
+
status && /* @__PURE__ */ jsx("span", { className: "ramp-tile__status", children: /* @__PURE__ */ jsx("small", { children: status }) })
|
|
32
|
+
] }),
|
|
33
|
+
selected && /* @__PURE__ */ jsx("span", { className: "ramp-tile__check", "aria-hidden": "true", children: "✓" })
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
function RailTiles({
|
|
37
|
+
title,
|
|
38
|
+
untested,
|
|
39
|
+
guest,
|
|
40
|
+
children
|
|
41
|
+
}) {
|
|
42
|
+
if (guest) {
|
|
43
|
+
const rails = Object.keys(RAIL_NAMES);
|
|
44
|
+
const logos = rails.filter((id) => railLogo(id)).slice(0, 6);
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", { className: "ramp-guest-apps", role: "img", "aria-label": Object.values(RAIL_NAMES).join(", "), children: [
|
|
46
|
+
logos.map((id) => /* @__PURE__ */ jsx(RailLogo, { id }, id)),
|
|
47
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", children: [
|
|
48
|
+
"+",
|
|
49
|
+
rails.length - logos.length
|
|
50
|
+
] })
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsxs("fieldset", { className: "ramp-tile-group", children: [
|
|
54
|
+
/* @__PURE__ */ jsx("legend", { children: title }),
|
|
55
|
+
/* @__PURE__ */ jsxs("div", { className: "ramp-tile-grid", children: [
|
|
56
|
+
untested && Object.entries(RAIL_NAMES).map(([id, name]) => /* @__PURE__ */ jsx("div", { className: "ramp-tile", "aria-disabled": "true", children: /* @__PURE__ */ jsx(RailTileContent, { id, name }) }, id)),
|
|
57
|
+
children
|
|
58
|
+
] })
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
function RailChoice({
|
|
62
|
+
card,
|
|
63
|
+
name,
|
|
64
|
+
group,
|
|
65
|
+
status,
|
|
66
|
+
selected,
|
|
67
|
+
disabled,
|
|
68
|
+
onSelect
|
|
69
|
+
}) {
|
|
70
|
+
return /* @__PURE__ */ jsxs(
|
|
71
|
+
"label",
|
|
72
|
+
{
|
|
73
|
+
className: "ramp-tile",
|
|
74
|
+
style: { "--rail-brand": railLogo(card.id)?.brandColor },
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
className: "sr-only",
|
|
80
|
+
type: "radio",
|
|
81
|
+
"aria-label": name,
|
|
82
|
+
"aria-description": status ?? card.status,
|
|
83
|
+
name: group,
|
|
84
|
+
value: card.id,
|
|
85
|
+
checked: selected,
|
|
86
|
+
disabled,
|
|
87
|
+
onChange: onSelect
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
RailTileContent,
|
|
92
|
+
{
|
|
93
|
+
id: card.id,
|
|
94
|
+
name,
|
|
95
|
+
status: status ?? card.status,
|
|
96
|
+
selected
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const SHORT_REASONS = {
|
|
104
|
+
available: "",
|
|
105
|
+
setup_required: "Set up in Peer",
|
|
106
|
+
temporarily_unavailable: "No offer",
|
|
107
|
+
not_supported: "Unsupported",
|
|
108
|
+
availability_unknown: "Unconfirmed",
|
|
109
|
+
expired: "Expired"
|
|
110
|
+
};
|
|
111
|
+
function UnavailableRails({ cards }) {
|
|
112
|
+
if (!cards.length) return null;
|
|
113
|
+
const unconfirmed = cards.filter((card) => card.state === "availability_unknown");
|
|
114
|
+
return /* @__PURE__ */ jsxs("section", { className: "ramp-unavailable", "aria-label": "Unavailable payment apps", children: [
|
|
115
|
+
unconfirmed.length > 0 && /* @__PURE__ */ jsxs("details", { children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("summary", { children: [
|
|
117
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
118
|
+
"Unconfirmed: ",
|
|
119
|
+
unconfirmed.map((card) => card.name).join(", ")
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsx("small", { className: "ramp-unavailable__reason", children: "Peer has yet to confirm these apps. Check again later." })
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ jsx("ul", { children: unconfirmed.map((card) => /* @__PURE__ */ jsxs("li", { children: [
|
|
124
|
+
/* @__PURE__ */ jsx("strong", { children: card.name }),
|
|
125
|
+
" ",
|
|
126
|
+
card.reason
|
|
127
|
+
] }, card.id)) })
|
|
128
|
+
] }),
|
|
129
|
+
cards.filter((card) => card.state !== "availability_unknown").map((card) => /* @__PURE__ */ jsxs("details", { children: [
|
|
130
|
+
/* @__PURE__ */ jsxs("summary", { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(RailLogo, { id: card.id }),
|
|
132
|
+
/* @__PURE__ */ jsx("strong", { children: card.name }),
|
|
133
|
+
/* @__PURE__ */ jsx("span", { children: SHORT_REASONS[card.state] }),
|
|
134
|
+
card.retryAfter && /* @__PURE__ */ jsxs("span", { children: [
|
|
135
|
+
"Retry after ",
|
|
136
|
+
formatRampTime(card.retryAfter)
|
|
137
|
+
] })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
140
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
141
|
+
card.status,
|
|
142
|
+
"."
|
|
143
|
+
] }),
|
|
144
|
+
" ",
|
|
145
|
+
card.reason
|
|
146
|
+
] }),
|
|
147
|
+
card.next && /* @__PURE__ */ jsx("p", { children: card.next })
|
|
148
|
+
] }, card.id))
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
RailChoice,
|
|
153
|
+
RailTileContent,
|
|
154
|
+
RailTiles,
|
|
155
|
+
UnavailableRails
|
|
156
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { InfoButton } from "../../components/InfoButton.js";
|
|
4
|
+
import { rampFacts } from "./model.js";
|
|
5
|
+
const summaries = {
|
|
6
|
+
onramp: "Public on Base. The seller sees your payment details and name.",
|
|
7
|
+
offramp: "Your own account. Base deposit is public."
|
|
8
|
+
};
|
|
9
|
+
function RampFacts({
|
|
10
|
+
direction,
|
|
11
|
+
id,
|
|
12
|
+
hidden
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx("ul", { id, hidden, className: "ramp-facts__list", children: rampFacts(direction).map((fact) => /* @__PURE__ */ jsx("li", { children: fact }, fact)) });
|
|
15
|
+
}
|
|
16
|
+
function RampDisclosure({ direction }) {
|
|
17
|
+
const id = useId();
|
|
18
|
+
const [expanded, setExpanded] = useState(false);
|
|
19
|
+
return /* @__PURE__ */ jsxs("section", { className: "ramp-facts", "aria-label": "Before you choose", children: [
|
|
20
|
+
/* @__PURE__ */ jsxs("div", { className: "ramp-facts__summary", children: [
|
|
21
|
+
/* @__PURE__ */ jsx("span", { children: summaries[direction] }),
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
InfoButton,
|
|
24
|
+
{
|
|
25
|
+
label: direction === "onramp" ? "Buy disclosures" : "Cash out disclosures",
|
|
26
|
+
controls: id,
|
|
27
|
+
expanded,
|
|
28
|
+
onClick: () => setExpanded((open) => !open)
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsx(RampFacts, { id, direction, hidden: !expanded })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
RampDisclosure,
|
|
37
|
+
RampFacts
|
|
38
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RampDisclosure } from "./RampDisclosure.js";
|
|
3
|
+
import { RailTiles, RailChoice, UnavailableRails } from "./RailTiles.js";
|
|
4
|
+
import { isPeerMobileWeb } from "../peer/environment.js";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { parseRampAmount, railCard, overallCard, formatRampTime } from "./model.js";
|
|
7
|
+
import { useRampDiscovery } from "./useRampDiscovery.js";
|
|
8
|
+
import { formatUsdc } from "../offramp/model.js";
|
|
9
|
+
const COPY = {
|
|
10
|
+
onramp: {
|
|
11
|
+
title: "Buy USDC on Base",
|
|
12
|
+
amountLabel: "USDC to receive",
|
|
13
|
+
currencyLabel: "Pay in",
|
|
14
|
+
selected: "This view cannot start a purchase; nothing will be charged."
|
|
15
|
+
},
|
|
16
|
+
offramp: {
|
|
17
|
+
title: "Cash out",
|
|
18
|
+
amountLabel: "USDC to cash out",
|
|
19
|
+
currencyLabel: "Receive in",
|
|
20
|
+
selected: "This view cannot start a cash-out; nothing will be sent."
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function RampRails({
|
|
24
|
+
direction,
|
|
25
|
+
account,
|
|
26
|
+
fiatCurrency = "USD",
|
|
27
|
+
active,
|
|
28
|
+
onConnectRequest,
|
|
29
|
+
renderSelected
|
|
30
|
+
}) {
|
|
31
|
+
const id = useId();
|
|
32
|
+
const [locked, setLocked] = useState();
|
|
33
|
+
const copy = COPY[direction];
|
|
34
|
+
const [amountText, setAmountText] = useState("");
|
|
35
|
+
const [currency, setCurrency] = useState(fiatCurrency);
|
|
36
|
+
const [selected, setSelected] = useState();
|
|
37
|
+
const mobile = direction === "onramp" && isPeerMobileWeb();
|
|
38
|
+
const amount = parseRampAmount(amountText);
|
|
39
|
+
const amountInvalid = amountText.trim() !== "" && amount === void 0;
|
|
40
|
+
const { state, now, settlement, refresh, cap } = useRampDiscovery({
|
|
41
|
+
direction,
|
|
42
|
+
amount,
|
|
43
|
+
currency,
|
|
44
|
+
account,
|
|
45
|
+
enabled: active && !mobile
|
|
46
|
+
});
|
|
47
|
+
const cards = state.status === "done" && settlement && account && amount !== void 0 && !mobile && state.intent.exact.money.atomic === amount && state.intent.fiat.currency === currency && state.intent.recipient === account ? state.result.offers.map((offer) => railCard(offer, state.intent, settlement, now)) : [];
|
|
48
|
+
const selectable = cards.filter((c) => c.selectable);
|
|
49
|
+
const blocked = cards.filter((c) => !c.selectable);
|
|
50
|
+
const chosen = selectable.find((c) => c.id === selected);
|
|
51
|
+
const lost = selected !== void 0 && chosen === void 0 && state.status === "done";
|
|
52
|
+
const currencies = [.../* @__PURE__ */ new Set([fiatCurrency, "USD"])];
|
|
53
|
+
let status;
|
|
54
|
+
if (!account)
|
|
55
|
+
status = onConnectRequest ? void 0 : "Connect a wallet and enter an amount to check availability.";
|
|
56
|
+
else if (!settlement)
|
|
57
|
+
status = "Peer’s Base USDC configuration is unavailable. Check again later.";
|
|
58
|
+
else if (lost) status = "That app is unavailable. Choose again.";
|
|
59
|
+
else if (account && amount === void 0 && !amountInvalid)
|
|
60
|
+
status = "Enter an amount to check payment apps.";
|
|
61
|
+
else if (cap !== void 0) status = `Purchase limit: ${formatUsdc(cap)}.`;
|
|
62
|
+
else if (state.status === "loading") status = "Checking payment apps…";
|
|
63
|
+
return /* @__PURE__ */ jsxs("section", { className: "ramp-rails", "aria-label": copy.title, children: [
|
|
64
|
+
mobile && /* @__PURE__ */ jsx("p", { className: "send-note", role: "status", children: "Buy in desktop Chrome or Brave with the Peer extension, or use the Peer app." }),
|
|
65
|
+
!mobile && /* @__PURE__ */ jsxs("div", { className: "send-form__row", children: [
|
|
66
|
+
/* @__PURE__ */ jsxs("label", { className: "send-field", children: [
|
|
67
|
+
/* @__PURE__ */ jsx("span", { className: "send-field__label", children: copy.amountLabel }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"input",
|
|
70
|
+
{
|
|
71
|
+
className: "send-field__control",
|
|
72
|
+
disabled: locked !== void 0,
|
|
73
|
+
inputMode: "decimal",
|
|
74
|
+
autoComplete: "off",
|
|
75
|
+
placeholder: "0.00",
|
|
76
|
+
value: amountText,
|
|
77
|
+
"aria-invalid": amountInvalid,
|
|
78
|
+
"aria-describedby": amountInvalid ? `${id}-amount-error` : void 0,
|
|
79
|
+
onChange: (e) => {
|
|
80
|
+
setAmountText(e.target.value);
|
|
81
|
+
setSelected(void 0);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
amountInvalid && /* @__PURE__ */ jsx("span", { id: `${id}-amount-error`, className: "send-field__error", children: "Enter a positive amount with at most 6 decimals." })
|
|
86
|
+
] }),
|
|
87
|
+
currencies.length > 1 && /* @__PURE__ */ jsxs("label", { className: "send-field", children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "send-field__label", children: copy.currencyLabel }),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
"select",
|
|
91
|
+
{
|
|
92
|
+
className: "send-field__control",
|
|
93
|
+
value: currency,
|
|
94
|
+
disabled: locked !== void 0,
|
|
95
|
+
onChange: (e) => {
|
|
96
|
+
setCurrency(e.target.value);
|
|
97
|
+
setSelected(void 0);
|
|
98
|
+
},
|
|
99
|
+
children: currencies.map((c) => /* @__PURE__ */ jsx("option", { value: c, children: c }, c))
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
] })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsx(RampDisclosure, { direction }),
|
|
105
|
+
!mobile && status && /* @__PURE__ */ jsx("p", { className: "send-note", role: "status", children: status }),
|
|
106
|
+
state.status === "done" && cards.length === 0 && /* @__PURE__ */ jsx(OverallCard, { ...overallCard(state.result.availability, direction) }),
|
|
107
|
+
/* @__PURE__ */ jsx(RailTiles, { title: "Payment apps", guest: !account, untested: mobile || state.status !== "done", children: selectable.map((card) => /* @__PURE__ */ jsx(
|
|
108
|
+
RailChoice,
|
|
109
|
+
{
|
|
110
|
+
card,
|
|
111
|
+
name: card.name,
|
|
112
|
+
group: `${id}-rail`,
|
|
113
|
+
selected: chosen?.id === card.id,
|
|
114
|
+
disabled: locked !== void 0,
|
|
115
|
+
onSelect: () => setSelected(card.id)
|
|
116
|
+
},
|
|
117
|
+
card.id
|
|
118
|
+
)) }),
|
|
119
|
+
/* @__PURE__ */ jsx(UnavailableRails, { cards: blocked }),
|
|
120
|
+
!account && !mobile && onConnectRequest && /* @__PURE__ */ jsx(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
className: "submit-btn send-cta ramp-bottom-action",
|
|
125
|
+
onClick: onConnectRequest,
|
|
126
|
+
children: "Connect wallet"
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
state.status === "done" && /* @__PURE__ */ jsx(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
type: "button",
|
|
133
|
+
className: "send-secondary",
|
|
134
|
+
disabled: locked !== void 0,
|
|
135
|
+
onClick: refresh,
|
|
136
|
+
children: "Check again"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
renderSelected && (locked ? renderSelected(locked.intent, locked.offer, (value = true) => {
|
|
140
|
+
if (!value) {
|
|
141
|
+
setLocked(void 0);
|
|
142
|
+
setSelected(void 0);
|
|
143
|
+
refresh();
|
|
144
|
+
}
|
|
145
|
+
}) : chosen && state.status === "done" ? renderSelected(
|
|
146
|
+
state.intent,
|
|
147
|
+
state.result.offers.find((offer) => offer.rail.id === chosen.id),
|
|
148
|
+
() => setLocked({
|
|
149
|
+
intent: state.intent,
|
|
150
|
+
offer: state.result.offers.find((offer) => offer.rail.id === chosen.id)
|
|
151
|
+
})
|
|
152
|
+
) : null),
|
|
153
|
+
chosen && !renderSelected && /* @__PURE__ */ jsx("p", { className: "send-note", role: "note", children: `${chosen.name} selected. ${copy.selected}` })
|
|
154
|
+
] });
|
|
155
|
+
}
|
|
156
|
+
function OverallCard(card) {
|
|
157
|
+
return /* @__PURE__ */ jsx("div", { className: "ramp-rail", role: "note", children: /* @__PURE__ */ jsxs("span", { className: "ramp-rail__body", children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("span", { className: "ramp-rail__head", children: [
|
|
159
|
+
/* @__PURE__ */ jsx("span", { className: "ramp-rail__name", children: "Peer" }),
|
|
160
|
+
/* @__PURE__ */ jsx("span", { className: `ramp-rail__status ramp-rail__status--${card.state}`, children: card.status })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ jsx("span", { className: "ramp-rail__text", children: card.reason }),
|
|
163
|
+
card.retryAfter && /* @__PURE__ */ jsx("span", { className: "ramp-rail__text", children: `Retry after ${formatRampTime(card.retryAfter)}.` }),
|
|
164
|
+
card.next && /* @__PURE__ */ jsx("span", { className: "ramp-rail__text", children: `Next: ${card.next}` })
|
|
165
|
+
] }) });
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
OverallCard,
|
|
169
|
+
RampRails
|
|
170
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { checkRampOffer, atomic } from "@xochi/client";
|
|
2
|
+
const RAMP_DECIMALS = 6;
|
|
3
|
+
function parseRampAmount(input) {
|
|
4
|
+
const value = input.trim();
|
|
5
|
+
const match = /^(\d{1,24})(?:\.(\d{0,6}))?$/.exec(value);
|
|
6
|
+
if (!match) return void 0;
|
|
7
|
+
const whole = match[1].replace(/^0+(?=\d)/, "");
|
|
8
|
+
const fraction = (match[2] ?? "").padEnd(RAMP_DECIMALS, "0");
|
|
9
|
+
const digits = `${whole}${fraction}`.replace(/^0+(?=\d)/, "");
|
|
10
|
+
return digits === "0" ? void 0 : digits;
|
|
11
|
+
}
|
|
12
|
+
function buildRampIntent(input) {
|
|
13
|
+
return {
|
|
14
|
+
contract_version: "ramp/1",
|
|
15
|
+
kind: "intent",
|
|
16
|
+
direction: input.direction,
|
|
17
|
+
exact: {
|
|
18
|
+
side: "crypto",
|
|
19
|
+
money: { asset: input.settlement, atomic: atomic(input.amount) }
|
|
20
|
+
},
|
|
21
|
+
fiat: { kind: "fiat", currency: input.currency, decimals: RAMP_DECIMALS },
|
|
22
|
+
crypto: input.settlement,
|
|
23
|
+
recipient: input.recipient
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const RAIL_NAMES = {
|
|
27
|
+
venmo: "Venmo",
|
|
28
|
+
revolut: "Revolut",
|
|
29
|
+
wise: "Wise",
|
|
30
|
+
zelle: "Zelle",
|
|
31
|
+
cashapp: "Cash App",
|
|
32
|
+
paypal: "PayPal",
|
|
33
|
+
monzo: "Monzo",
|
|
34
|
+
mercadopago: "Mercado Pago",
|
|
35
|
+
chime: "Chime",
|
|
36
|
+
n26: "N26",
|
|
37
|
+
monobank: "Monobank",
|
|
38
|
+
upi: "UPI",
|
|
39
|
+
xmoney: "X Money",
|
|
40
|
+
alipay: "Alipay"
|
|
41
|
+
};
|
|
42
|
+
function railName(offer) {
|
|
43
|
+
return Object.hasOwn(RAIL_NAMES, offer.rail.id) ? RAIL_NAMES[offer.rail.id] : offer.rail.label;
|
|
44
|
+
}
|
|
45
|
+
const STATUS = {
|
|
46
|
+
available: "Available",
|
|
47
|
+
setup_required: "Setup required",
|
|
48
|
+
temporarily_unavailable: "Temporarily unavailable",
|
|
49
|
+
not_supported: "Not supported",
|
|
50
|
+
availability_unknown: "Availability unknown",
|
|
51
|
+
expired: "Offer expired"
|
|
52
|
+
};
|
|
53
|
+
const REQUIREMENTS = {
|
|
54
|
+
peer_desktop_extension_or_app: {
|
|
55
|
+
reason: "Buying through Peer works only in desktop Chrome or Brave with the Peer extension, or in the Peer app.",
|
|
56
|
+
next: "Open this page in desktop Chrome or Brave with the Peer extension, or use the Peer app."
|
|
57
|
+
},
|
|
58
|
+
peer_dispute_stake: {
|
|
59
|
+
reason: "This rail needs Peer stake on your account. Without it, Peer can hold the payout for up to 14 days.",
|
|
60
|
+
next: "Add stake in Peer, then check again."
|
|
61
|
+
},
|
|
62
|
+
peer_wallet_linked_session: {
|
|
63
|
+
reason: "Peer needs an account session linked to this wallet before it will quote a purchase. This widget cannot sign you in to Peer.",
|
|
64
|
+
next: "Sign in to Peer with this wallet and finish its account setup, then check again."
|
|
65
|
+
},
|
|
66
|
+
maker_account_setup: {
|
|
67
|
+
reason: "Peer needs your payment-app account set up for this rail before you can cash out.",
|
|
68
|
+
next: "Set up your account below, then check again."
|
|
69
|
+
},
|
|
70
|
+
maker_seller_credential: {
|
|
71
|
+
reason: "Peer has not verified a payment-app account of yours for this rail.",
|
|
72
|
+
next: "Verify your own account in Peer, then check again."
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const NEEDS = {
|
|
76
|
+
peer_extension: "The Peer browser extension or app",
|
|
77
|
+
user_payment: "A payment you make from your own payment-app account",
|
|
78
|
+
own_payment_account: "A payment-app account that belongs to you",
|
|
79
|
+
maker_estimate: "Accepting an estimated, not locked, rate",
|
|
80
|
+
asynchronous_partial_fills: "Waiting for fills, which can arrive in parts"
|
|
81
|
+
};
|
|
82
|
+
function reasonFor(availability, direction) {
|
|
83
|
+
if (availability.state === "setup_required") {
|
|
84
|
+
const known = availability.requirement_codes.map((c) => REQUIREMENTS[c]?.reason).filter((r) => r !== void 0);
|
|
85
|
+
return known.length ? known.join(" ") : "Peer needs a setup step first.";
|
|
86
|
+
}
|
|
87
|
+
const code = availability.reason_code;
|
|
88
|
+
switch (availability.state) {
|
|
89
|
+
case "temporarily_unavailable":
|
|
90
|
+
return code === "capabilities_unavailable" ? "Peer could not be reached, so this rail cannot be used right now." : "Peer reports no usable liquidity on this rail for this amount right now.";
|
|
91
|
+
case "not_supported":
|
|
92
|
+
return "Peer does not support this rail for this currency and amount.";
|
|
93
|
+
case "availability_unknown":
|
|
94
|
+
if (code === "capability_unavailable" && direction === "offramp")
|
|
95
|
+
return "Peer has not confirmed live cash-out limits, rate and account status for this rail, so it cannot be chosen.";
|
|
96
|
+
if (code === "capability_unavailable")
|
|
97
|
+
return "Peer returned no fresh, verifiable offer for this rail, so it cannot be chosen.";
|
|
98
|
+
if (code === "capabilities_unavailable")
|
|
99
|
+
return "Peer could not be reached, so availability is unknown.";
|
|
100
|
+
if (code === "invalid_request")
|
|
101
|
+
return "Peer cannot quote this request; only USD to Base USDC is supported now.";
|
|
102
|
+
return "Availability could not be confirmed.";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function nextFor(availability) {
|
|
106
|
+
switch (availability.state) {
|
|
107
|
+
case "setup_required": {
|
|
108
|
+
const steps = availability.requirement_codes.map((c) => REQUIREMENTS[c]?.next).filter((r) => r !== void 0);
|
|
109
|
+
return steps.length ? steps.join(" ") : "Complete the step in Peer, then check again.";
|
|
110
|
+
}
|
|
111
|
+
case "temporarily_unavailable":
|
|
112
|
+
return availability.retry_after ? "Check again after the time shown." : "Check again in a moment, or choose another rail.";
|
|
113
|
+
case "not_supported":
|
|
114
|
+
return "Choose another rail or a different amount.";
|
|
115
|
+
case "availability_unknown":
|
|
116
|
+
return "Check again later; it stays unselectable until Peer confirms it.";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function formatRampTime(value, dateOnly = false) {
|
|
120
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
121
|
+
return Number.isNaN(date.getTime()) ? "Time unavailable" : dateOnly ? date.toLocaleDateString(void 0, { dateStyle: "medium", timeZone: "UTC" }) : date.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
122
|
+
}
|
|
123
|
+
function railCard(offer, intent, settlement, now) {
|
|
124
|
+
const needs = offer.interaction.requirement_codes.map((c) => NEEDS[c]).filter((n) => n !== void 0);
|
|
125
|
+
const base = { id: offer.rail.id, name: railName(offer), needs };
|
|
126
|
+
const { availability } = offer;
|
|
127
|
+
if (availability.state === "available") {
|
|
128
|
+
const check = checkRampOffer(offer, intent, settlement, now);
|
|
129
|
+
if (check.ok)
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
state: "available",
|
|
133
|
+
selectable: true,
|
|
134
|
+
status: STATUS.available,
|
|
135
|
+
reason: offer.direction === "offramp" ? `Live Peer estimate for this amount, not a locked rate; can be chosen until ${formatRampTime(availability.valid_until)}.` : `Fresh Peer offer for this exact amount, valid until ${formatRampTime(availability.valid_until)}.`
|
|
136
|
+
};
|
|
137
|
+
const expired = check.code === "quote_expired";
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
state: expired ? "expired" : "availability_unknown",
|
|
141
|
+
selectable: false,
|
|
142
|
+
status: expired ? STATUS.expired : STATUS.availability_unknown,
|
|
143
|
+
reason: expired ? "This offer is past its validity window and can no longer be chosen." : "This offer no longer matches the request, so it cannot be chosen.",
|
|
144
|
+
next: "Check again for a fresh offer."
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
...base,
|
|
149
|
+
state: availability.state,
|
|
150
|
+
selectable: false,
|
|
151
|
+
status: STATUS[availability.state],
|
|
152
|
+
reason: reasonFor(availability, offer.direction),
|
|
153
|
+
next: nextFor(availability),
|
|
154
|
+
...availability.state === "temporarily_unavailable" && availability.retry_after ? { retryAfter: availability.retry_after } : {}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function overallCard(availability, direction) {
|
|
158
|
+
if (availability.state === "available")
|
|
159
|
+
return {
|
|
160
|
+
state: "availability_unknown",
|
|
161
|
+
selectable: false,
|
|
162
|
+
status: STATUS.availability_unknown,
|
|
163
|
+
reason: "Peer returned no rails for this request.",
|
|
164
|
+
next: "Check again later."
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
state: availability.state,
|
|
168
|
+
selectable: false,
|
|
169
|
+
status: STATUS[availability.state],
|
|
170
|
+
reason: reasonFor(availability, direction),
|
|
171
|
+
next: nextFor(availability),
|
|
172
|
+
...availability.state === "temporarily_unavailable" && availability.retry_after ? { retryAfter: availability.retry_after } : {}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function nextExpiry(offers, now) {
|
|
176
|
+
let next;
|
|
177
|
+
for (const offer of offers) {
|
|
178
|
+
if (offer.availability.state !== "available") continue;
|
|
179
|
+
const at = Date.parse(offer.availability.valid_until);
|
|
180
|
+
if (Number.isFinite(at) && at > now && (next === void 0 || at < next)) next = at;
|
|
181
|
+
}
|
|
182
|
+
return next;
|
|
183
|
+
}
|
|
184
|
+
function rampFacts(direction) {
|
|
185
|
+
const shared = [
|
|
186
|
+
"Base transfers, amounts and wallet addresses are public.",
|
|
187
|
+
`The ${direction === "offramp" ? "buyer" : "seller"} sees your payment details and name.`,
|
|
188
|
+
"Peer handles required payment data. Its access checks and secure verifier must be online."
|
|
189
|
+
];
|
|
190
|
+
return direction === "onramp" ? [
|
|
191
|
+
...shared,
|
|
192
|
+
"Expired or unverifiable purchases have no protocol refund. Check the active intent before paying.",
|
|
193
|
+
"Without Peer stake, Venmo or PayPal payouts can be held for 14 days. Held funds cannot start a swap."
|
|
194
|
+
] : [...shared, "Rates can change. Payments can arrive later in parts."];
|
|
195
|
+
}
|
|
196
|
+
export {
|
|
197
|
+
RAIL_NAMES,
|
|
198
|
+
RAMP_DECIMALS,
|
|
199
|
+
buildRampIntent,
|
|
200
|
+
formatRampTime,
|
|
201
|
+
nextExpiry,
|
|
202
|
+
overallCard,
|
|
203
|
+
parseRampAmount,
|
|
204
|
+
railCard,
|
|
205
|
+
railName,
|
|
206
|
+
rampFacts
|
|
207
|
+
};
|