@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,101 @@
|
|
|
1
|
+
import { RAMP_REF_PATTERN } from "@xochi/widget-lib";
|
|
2
|
+
import { STORAGE_KEYS } from "../../constants.js";
|
|
3
|
+
const MAX_RECORDS = 50;
|
|
4
|
+
const PREFIX = STORAGE_KEYS.localOfframpsPrefix;
|
|
5
|
+
const STAGES = /* @__PURE__ */ new Set(["before_deposit", "deposit"]);
|
|
6
|
+
const STATUSES = /* @__PURE__ */ new Set([
|
|
7
|
+
"open",
|
|
8
|
+
"in_doubt",
|
|
9
|
+
"delivered",
|
|
10
|
+
"returned",
|
|
11
|
+
"mixed",
|
|
12
|
+
"not_started"
|
|
13
|
+
]);
|
|
14
|
+
const PHASES = /* @__PURE__ */ new Set([
|
|
15
|
+
"awaiting_buyer",
|
|
16
|
+
"matched",
|
|
17
|
+
"delivering",
|
|
18
|
+
"delivered",
|
|
19
|
+
"returned"
|
|
20
|
+
]);
|
|
21
|
+
const ACTIONS = /* @__PURE__ */ new Set(["approve_usdc", "create_deposit", "withdraw_unmatched"]);
|
|
22
|
+
const keyFor = (address) => `${PREFIX}${address.toLowerCase()}`;
|
|
23
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
24
|
+
function subscribeLocalOfframps(listener) {
|
|
25
|
+
listeners.add(listener);
|
|
26
|
+
return () => listeners.delete(listener);
|
|
27
|
+
}
|
|
28
|
+
function parseOfframpRecord(value) {
|
|
29
|
+
if (!value || typeof value !== "object") return null;
|
|
30
|
+
const row = value;
|
|
31
|
+
const data = row.data;
|
|
32
|
+
if (row.type !== "offramp" || typeof row.id !== "string" || !/^[A-Za-z0-9_-]{1,96}$/.test(row.id) || typeof row.timestamp !== "number" || !Number.isFinite(row.timestamp) || typeof row.stage !== "string" || !STAGES.has(row.stage) || typeof row.status !== "string" || !STATUSES.has(row.status) || row.phase !== void 0 && (typeof row.phase !== "string" || !PHASES.has(row.phase)) || row.pendingAction !== void 0 && (typeof row.pendingAction !== "string" || !ACTIONS.has(row.pendingAction)) || !data || typeof data.rail !== "string" || !/^[a-z0-9_]{1,32}$/.test(data.rail) || typeof data.currency !== "string" || !/^[A-Z]{3}$/.test(data.currency) || typeof data.amount !== "string" || !/^[1-9][0-9]{0,30}$/.test(data.amount))
|
|
33
|
+
return null;
|
|
34
|
+
const rawTotals = row.totals;
|
|
35
|
+
let totals;
|
|
36
|
+
if (rawTotals !== void 0) {
|
|
37
|
+
const filled = rawTotals?.filled;
|
|
38
|
+
const returned = rawTotals?.returned;
|
|
39
|
+
if (typeof filled !== "string" || !/^(0|[1-9][0-9]{0,30})$/.test(filled) || typeof returned !== "string" || !/^(0|[1-9][0-9]{0,30})$/.test(returned) || BigInt(filled) + BigInt(returned) !== BigInt(data.amount))
|
|
40
|
+
return null;
|
|
41
|
+
totals = { filled, returned };
|
|
42
|
+
}
|
|
43
|
+
if (row.rampRef !== void 0 && (typeof row.rampRef !== "string" || !RAMP_REF_PATTERN.test(row.rampRef)))
|
|
44
|
+
return null;
|
|
45
|
+
if (row.status === "mixed" && (!totals || totals.filled === "0" || totals.returned === "0"))
|
|
46
|
+
return null;
|
|
47
|
+
return {
|
|
48
|
+
id: row.id,
|
|
49
|
+
type: "offramp",
|
|
50
|
+
timestamp: row.timestamp,
|
|
51
|
+
stage: row.stage,
|
|
52
|
+
status: row.status,
|
|
53
|
+
...row.phase ? { phase: row.phase } : {},
|
|
54
|
+
...row.pendingAction ? { pendingAction: row.pendingAction } : {},
|
|
55
|
+
...totals ? { totals } : {},
|
|
56
|
+
...row.rampRef ? { rampRef: row.rampRef } : {},
|
|
57
|
+
data: { rail: data.rail, currency: data.currency, amount: data.amount }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function read(address) {
|
|
61
|
+
try {
|
|
62
|
+
const raw = window.localStorage.getItem(keyFor(address));
|
|
63
|
+
if (!raw) return [];
|
|
64
|
+
const parsed = JSON.parse(raw);
|
|
65
|
+
if (!Array.isArray(parsed)) return [];
|
|
66
|
+
return parsed.map(parseOfframpRecord).filter((row) => row !== null);
|
|
67
|
+
} catch {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function listLocalOfframps(address) {
|
|
72
|
+
if (!address || typeof window === "undefined") return [];
|
|
73
|
+
return read(address).sort((a, b) => b.timestamp - a.timestamp);
|
|
74
|
+
}
|
|
75
|
+
function upsertLocalOfframp(address, item) {
|
|
76
|
+
if (!address || typeof window === "undefined") return;
|
|
77
|
+
const safe = parseOfframpRecord(item);
|
|
78
|
+
if (!safe) return;
|
|
79
|
+
const rows = read(address);
|
|
80
|
+
const existing = rows.find((r) => r.id === safe.id);
|
|
81
|
+
const next = [
|
|
82
|
+
existing ? { ...safe, timestamp: existing.timestamp } : safe,
|
|
83
|
+
...rows.filter((r) => r.id !== safe.id)
|
|
84
|
+
].sort((a, b) => b.timestamp - a.timestamp).slice(0, MAX_RECORDS);
|
|
85
|
+
try {
|
|
86
|
+
window.localStorage.setItem(keyFor(address), JSON.stringify(next));
|
|
87
|
+
} catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
for (const l of listeners) l();
|
|
91
|
+
}
|
|
92
|
+
function resumableOfframp(rows) {
|
|
93
|
+
return rows.find((r) => r.status === "open" || r.status === "in_doubt");
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
listLocalOfframps,
|
|
97
|
+
parseOfframpRecord,
|
|
98
|
+
resumableOfframp,
|
|
99
|
+
subscribeLocalOfframps,
|
|
100
|
+
upsertLocalOfframp
|
|
101
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { formatTokenAmount } from "../../utils/format.js";
|
|
2
|
+
const USDC_DECIMALS = 6;
|
|
3
|
+
function formatUsdc(atomic) {
|
|
4
|
+
return `${formatTokenAmount(BigInt(atomic), USDC_DECIMALS, USDC_DECIMALS)} USDC`;
|
|
5
|
+
}
|
|
6
|
+
function formatMixedCashOut(filled, returned) {
|
|
7
|
+
return `${formatUsdc(filled)} cashed out; ${formatUsdc(returned)} returned`;
|
|
8
|
+
}
|
|
9
|
+
function usdcDecimal(atomic) {
|
|
10
|
+
const v = atomic.padStart(USDC_DECIMALS + 1, "0");
|
|
11
|
+
const whole = v.slice(0, -USDC_DECIMALS).replace(/^0+(?=\d)/, "");
|
|
12
|
+
const fraction = v.slice(-USDC_DECIMALS).replace(/0+$/, "");
|
|
13
|
+
return fraction ? `${whole}.${fraction}` : whole;
|
|
14
|
+
}
|
|
15
|
+
function formatEstimate(atomic, currency, decimals) {
|
|
16
|
+
return `about ${formatTokenAmount(BigInt(atomic), decimals, 2)} ${currency}`;
|
|
17
|
+
}
|
|
18
|
+
function canaryCapError(amount, cap) {
|
|
19
|
+
if (amount === void 0 || cap === void 0 || BigInt(amount) <= BigInt(cap)) return void 0;
|
|
20
|
+
return `This deployment limits each cash-out to ${formatUsdc(cap)} for now. Enter ${formatUsdc(cap)} or less.`;
|
|
21
|
+
}
|
|
22
|
+
function payeeError(value) {
|
|
23
|
+
const v = value.trim();
|
|
24
|
+
if (v === "") return "Enter the account the payout goes to.";
|
|
25
|
+
if (v.length > 256) return "That account is too long.";
|
|
26
|
+
if (/[\u0000-\u001f\u007f]/.test(v)) return "Remove control characters from the account.";
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
function maskPayee(value) {
|
|
30
|
+
const v = value.trim();
|
|
31
|
+
const chars = [...v];
|
|
32
|
+
if (chars.length <= 4) return "•".repeat(Math.max(chars.length, 4));
|
|
33
|
+
return `${chars.slice(0, 2).join("")}${"•".repeat(4)}${chars.slice(-2).join("")}`;
|
|
34
|
+
}
|
|
35
|
+
function estimateSecondsLeft(preview, now) {
|
|
36
|
+
const at = Date.parse(preview.expires_at);
|
|
37
|
+
return Number.isFinite(at) ? Math.max(0, Math.ceil((at - now) / 1e3)) : 0;
|
|
38
|
+
}
|
|
39
|
+
function disclosureCodes(preview) {
|
|
40
|
+
const d = preview.disclosures;
|
|
41
|
+
return [...d.public_state, ...d.identity_visible_to, ...d.liveness_dependencies];
|
|
42
|
+
}
|
|
43
|
+
const STEP_LABELS = {
|
|
44
|
+
deposit: "Deposit created on Base",
|
|
45
|
+
awaiting_buyer: "Awaiting a buyer",
|
|
46
|
+
matched: "Matched with a buyer",
|
|
47
|
+
delivering: "Payout in progress",
|
|
48
|
+
delivered: "Payout delivered"
|
|
49
|
+
};
|
|
50
|
+
const ORDER = ["deposit", "awaiting_buyer", "matched", "delivering", "delivered"];
|
|
51
|
+
function progressSteps(phase) {
|
|
52
|
+
const at = phase === void 0 || phase === "returned" ? -1 : ORDER.indexOf(phase);
|
|
53
|
+
return ORDER.map((id, i) => ({
|
|
54
|
+
id,
|
|
55
|
+
label: STEP_LABELS[id],
|
|
56
|
+
state: phase === "delivered" || i < at || id === "deposit" && phase !== void 0 ? "done" : i === at ? "current" : "upcoming"
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
function orderHeadline(snapshot, phase, reason) {
|
|
60
|
+
const leg = snapshot.peer;
|
|
61
|
+
if (leg.state === "in_doubt")
|
|
62
|
+
return {
|
|
63
|
+
title: "Checking with Base",
|
|
64
|
+
detail: "The last wallet step's outcome is not confirmed yet. Only a status check can settle it; nothing will be sent again.",
|
|
65
|
+
tone: "attention"
|
|
66
|
+
};
|
|
67
|
+
if (snapshot.terminal && leg.partial_result)
|
|
68
|
+
return {
|
|
69
|
+
title: "Partly cashed out and returned",
|
|
70
|
+
detail: formatMixedCashOut(
|
|
71
|
+
leg.partial_result.filled_atomic,
|
|
72
|
+
leg.partial_result.returned_atomic
|
|
73
|
+
),
|
|
74
|
+
tone: "done"
|
|
75
|
+
};
|
|
76
|
+
if (phase === "delivered")
|
|
77
|
+
return {
|
|
78
|
+
title: "Payout delivered",
|
|
79
|
+
detail: "Peer verified the fiat payment for all of your USDC. The order is closed.",
|
|
80
|
+
tone: "done"
|
|
81
|
+
};
|
|
82
|
+
if (phase === "returned")
|
|
83
|
+
return {
|
|
84
|
+
title: "Returned to your wallet",
|
|
85
|
+
detail: "Unmatched USDC was withdrawn back to your wallet. Any part already paid out stays paid out.",
|
|
86
|
+
tone: "done"
|
|
87
|
+
};
|
|
88
|
+
if (phase === "delivering")
|
|
89
|
+
return {
|
|
90
|
+
title: "Partly paid out",
|
|
91
|
+
detail: "Peer verified a fiat payment for part of your USDC. The rest is still open for buyers or can be withdrawn.",
|
|
92
|
+
tone: "progress"
|
|
93
|
+
};
|
|
94
|
+
if (phase === "matched")
|
|
95
|
+
return {
|
|
96
|
+
title: "Matched with a buyer",
|
|
97
|
+
detail: "A buyer has reserved part of the deposit and must now pay your account. Peer releases USDC only after it verifies that payment.",
|
|
98
|
+
tone: "progress"
|
|
99
|
+
};
|
|
100
|
+
if (phase === "awaiting_buyer")
|
|
101
|
+
return {
|
|
102
|
+
title: "Awaiting a buyer",
|
|
103
|
+
detail: "Your USDC is in Peer’s holding contract on Base. Payments can arrive later and in parts.",
|
|
104
|
+
tone: "progress"
|
|
105
|
+
};
|
|
106
|
+
if (leg.state === "failed")
|
|
107
|
+
return {
|
|
108
|
+
title: "This step did not go through",
|
|
109
|
+
detail: failureText(leg.failure_code, reason),
|
|
110
|
+
tone: "attention"
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
title: "Wallet approval needed",
|
|
114
|
+
detail: "Review the next step in your wallet.",
|
|
115
|
+
tone: "progress"
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function failureText(code, reason) {
|
|
119
|
+
if (reason === "active_intent_blocks_withdrawal")
|
|
120
|
+
return "A buyer is mid-payment, so the whole deposit cannot be withdrawn now. You can withdraw the unmatched part.";
|
|
121
|
+
if (reason === "setup_required" || code === "capability_unavailable")
|
|
122
|
+
return "Finish setting up this account in Peer before trying again. No deposit was created.";
|
|
123
|
+
if (reason === "quote_expired" || code === "quote_expired")
|
|
124
|
+
return "The estimate expired before the wallet step. Get a new estimate; no deposit was created.";
|
|
125
|
+
if (reason === "quote_changed" || code === "quote_changed")
|
|
126
|
+
return "Peer's terms changed. Review a new estimate; no deposit was created.";
|
|
127
|
+
if (code === "approval_rejected")
|
|
128
|
+
return "You declined in your wallet. Review the cash-out again when you’re ready.";
|
|
129
|
+
return "Peer declined this step. Check the order status before trying again.";
|
|
130
|
+
}
|
|
131
|
+
const WALLET_ACTION_LABELS = {
|
|
132
|
+
approve_usdc: "Allow Peer's escrow to use exactly this USDC",
|
|
133
|
+
create_deposit: "Create the cash-out deposit on Base",
|
|
134
|
+
withdraw_unmatched: "Withdraw unmatched USDC to your wallet"
|
|
135
|
+
};
|
|
136
|
+
function canWithdraw(snapshot, phase) {
|
|
137
|
+
return !snapshot.terminal && snapshot.peer.state === "processing" && (phase === "awaiting_buyer" || phase === "matched" || phase === "delivering");
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
USDC_DECIMALS,
|
|
141
|
+
WALLET_ACTION_LABELS,
|
|
142
|
+
canWithdraw,
|
|
143
|
+
canaryCapError,
|
|
144
|
+
disclosureCodes,
|
|
145
|
+
estimateSecondsLeft,
|
|
146
|
+
formatEstimate,
|
|
147
|
+
formatMixedCashOut,
|
|
148
|
+
formatUsdc,
|
|
149
|
+
maskPayee,
|
|
150
|
+
orderHeadline,
|
|
151
|
+
payeeError,
|
|
152
|
+
progressSteps,
|
|
153
|
+
usdcDecimal
|
|
154
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { createRampClient, createBrowserRampOperationStore, createMemoryRampOperationStore } from "@xochi/client";
|
|
3
|
+
import { Zkp2pClient } from "@zkp2p/sdk";
|
|
4
|
+
import { erc20Abi, custom, createWalletClient } from "viem";
|
|
5
|
+
import { base } from "viem/chains";
|
|
6
|
+
import { TIMEOUTS, OFFRAMP_CANARY_CAP_ATOMIC, PEER_ENVIRONMENT, PEER_REFERRAL_CODE } from "../../config.js";
|
|
7
|
+
import { waitForTransactionReceipt, sendTransaction, switchChain, getAccount, getPublicClient } from "wagmi/actions";
|
|
8
|
+
import "reflect-metadata";
|
|
9
|
+
import { peerConfiguration } from "../peer/discovery.js";
|
|
10
|
+
import { createLivePeerOfframpProvider } from "../peer/liveProvider.js";
|
|
11
|
+
const BASE_CHAIN_ID = 8453;
|
|
12
|
+
const OfframpPortContext = createContext(null);
|
|
13
|
+
function rampStore() {
|
|
14
|
+
try {
|
|
15
|
+
if (typeof navigator !== "undefined" && navigator.locks && typeof localStorage !== "undefined")
|
|
16
|
+
return createBrowserRampOperationStore({ storage: localStorage, locks: navigator.locks });
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
return createMemoryRampOperationStore();
|
|
20
|
+
}
|
|
21
|
+
function unsignedWalletClient(account) {
|
|
22
|
+
return createWalletClient({
|
|
23
|
+
account,
|
|
24
|
+
chain: base,
|
|
25
|
+
transport: custom({
|
|
26
|
+
async request() {
|
|
27
|
+
throw new Error("unsigned_only");
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function liveSdk(account, publicClient) {
|
|
33
|
+
const client = new Zkp2pClient({
|
|
34
|
+
walletClient: unsignedWalletClient(account),
|
|
35
|
+
chainId: BASE_CHAIN_ID,
|
|
36
|
+
runtimeEnv: PEER_ENVIRONMENT,
|
|
37
|
+
rpcTransport: custom(publicClient)
|
|
38
|
+
});
|
|
39
|
+
return withReferralCode(
|
|
40
|
+
{
|
|
41
|
+
registerPayeeDetails: client.registerPayeeDetails.bind(client),
|
|
42
|
+
prepareCreateDeposit: client.prepareCreateDeposit.bind(client),
|
|
43
|
+
removeFunds: { prepare: client.removeFunds.prepare.bind(client.removeFunds) },
|
|
44
|
+
withdrawDeposit: { prepare: client.withdrawDeposit.prepare.bind(client.withdrawDeposit) }
|
|
45
|
+
},
|
|
46
|
+
PEER_REFERRAL_CODE
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function withReferralCode(sdk, code) {
|
|
50
|
+
if (!code) return sdk;
|
|
51
|
+
return {
|
|
52
|
+
...sdk,
|
|
53
|
+
prepareCreateDeposit: (params) => sdk.prepareCreateDeposit({ ...params, referralCode: code })
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function createLiveOfframpPort(config) {
|
|
57
|
+
const runtimes = /* @__PURE__ */ new Map();
|
|
58
|
+
return {
|
|
59
|
+
async spendable(account) {
|
|
60
|
+
const client = getPublicClient(config, { chainId: BASE_CHAIN_ID });
|
|
61
|
+
if (!client) throw new Error("balance_unavailable");
|
|
62
|
+
return client.readContract({
|
|
63
|
+
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
64
|
+
abi: erc20Abi,
|
|
65
|
+
functionName: "balanceOf",
|
|
66
|
+
args: [account]
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
runtime(account) {
|
|
70
|
+
const key = account.toLowerCase();
|
|
71
|
+
let runtime = runtimes.get(key);
|
|
72
|
+
if (!runtime) {
|
|
73
|
+
runtime = (async () => {
|
|
74
|
+
const publicClient = getPublicClient(config, { chainId: BASE_CHAIN_ID });
|
|
75
|
+
if (!publicClient) throw new Error("capability_unavailable");
|
|
76
|
+
const reads = publicClient;
|
|
77
|
+
const provider = createLivePeerOfframpProvider({
|
|
78
|
+
publicClient: reads,
|
|
79
|
+
sdk: liveSdk(account, reads),
|
|
80
|
+
wallet: account,
|
|
81
|
+
environment: PEER_ENVIRONMENT
|
|
82
|
+
});
|
|
83
|
+
return { provider, client: createRampClient({ peer: provider, store: rampStore() }) };
|
|
84
|
+
})();
|
|
85
|
+
runtime.catch(() => runtimes.delete(key));
|
|
86
|
+
runtimes.set(key, runtime);
|
|
87
|
+
}
|
|
88
|
+
return runtime;
|
|
89
|
+
},
|
|
90
|
+
wallet: {
|
|
91
|
+
chainId: () => getAccount(config).chainId,
|
|
92
|
+
async switchToBase() {
|
|
93
|
+
await switchChain(config, { chainId: BASE_CHAIN_ID });
|
|
94
|
+
},
|
|
95
|
+
send(plan) {
|
|
96
|
+
const tx = plan.transaction;
|
|
97
|
+
return sendTransaction(config, {
|
|
98
|
+
account: plan.account,
|
|
99
|
+
chainId: BASE_CHAIN_ID,
|
|
100
|
+
to: tx.to,
|
|
101
|
+
data: tx.data,
|
|
102
|
+
value: tx.value
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
async wait(hash) {
|
|
106
|
+
await waitForTransactionReceipt(config, { hash, chainId: BASE_CHAIN_ID });
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
settlement() {
|
|
110
|
+
try {
|
|
111
|
+
return peerConfiguration({ environment: PEER_ENVIRONMENT }).settlement;
|
|
112
|
+
} catch {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
canaryCap: () => OFFRAMP_CANARY_CAP_ATOMIC,
|
|
117
|
+
escrow() {
|
|
118
|
+
try {
|
|
119
|
+
return peerConfiguration({ environment: PEER_ENVIRONMENT }).escrow;
|
|
120
|
+
} catch {
|
|
121
|
+
return void 0;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
now: () => Date.now(),
|
|
125
|
+
debounceMs: TIMEOUTS.quoteDebounce,
|
|
126
|
+
pollMs: 15e3
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
BASE_CHAIN_ID,
|
|
131
|
+
OfframpPortContext,
|
|
132
|
+
createLiveOfframpPort,
|
|
133
|
+
withReferralCode
|
|
134
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createMemoryRampOperationStore, createXochiRampLeg, RampSnapshotSchema, RampMoneySchema } from "@xochi/client";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const checkpointSchema = z.object({
|
|
4
|
+
wallet: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
5
|
+
source: RampMoneySchema,
|
|
6
|
+
snapshot: RampSnapshotSchema,
|
|
7
|
+
preview: z.object({
|
|
8
|
+
quoteId: z.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
9
|
+
expiresAt: z.string().datetime(),
|
|
10
|
+
pay: RampMoneySchema,
|
|
11
|
+
receive: RampMoneySchema,
|
|
12
|
+
recipient: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
13
|
+
settlement: z.literal("public")
|
|
14
|
+
}).optional()
|
|
15
|
+
});
|
|
16
|
+
const checkpointKey = (wallet) => `xochi:w6:1:${wallet.toLowerCase()}`;
|
|
17
|
+
function browserStorage() {
|
|
18
|
+
return typeof window === "undefined" ? void 0 : window.localStorage;
|
|
19
|
+
}
|
|
20
|
+
function readOfframpPrerequisite(wallet, storage = browserStorage()) {
|
|
21
|
+
if (!storage) return;
|
|
22
|
+
const raw = storage.getItem(checkpointKey(wallet));
|
|
23
|
+
if (raw === null) return;
|
|
24
|
+
const value = checkpointSchema.parse(JSON.parse(raw));
|
|
25
|
+
if (value.wallet.toLowerCase() !== wallet.toLowerCase() || value.snapshot.direction !== "offramp" || value.snapshot.peer.state !== "not_started" || !value.snapshot.xochi || value.preview && (value.preview.recipient.toLowerCase() !== wallet.toLowerCase() || JSON.stringify(value.source) !== JSON.stringify(value.preview.pay)))
|
|
26
|
+
throw new Error("invalid_checkpoint");
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
function inspectOfframpPrerequisite(wallet) {
|
|
30
|
+
try {
|
|
31
|
+
return readOfframpPrerequisite(wallet);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function createOfframpPrerequisite(options) {
|
|
37
|
+
const storage = options.storage ?? browserStorage();
|
|
38
|
+
const restored = readOfframpPrerequisite(options.wallet, storage);
|
|
39
|
+
const id = restored?.snapshot.operation_id ?? options.id ?? crypto.randomUUID();
|
|
40
|
+
let receiptPreview = restored?.preview;
|
|
41
|
+
const store = createMemoryRampOperationStore();
|
|
42
|
+
let snapshot = restored?.snapshot ?? {
|
|
43
|
+
contract_version: "ramp/1",
|
|
44
|
+
kind: "snapshot",
|
|
45
|
+
operation_id: id,
|
|
46
|
+
revision: "0",
|
|
47
|
+
direction: "offramp",
|
|
48
|
+
leg_order: ["xochi", "peer"],
|
|
49
|
+
peer: { name: "peer", state: "not_started", recoverable: false },
|
|
50
|
+
xochi: { name: "xochi", state: "not_started", recoverable: false },
|
|
51
|
+
allowed_actions: [],
|
|
52
|
+
updated_at: new Date((options.now ?? Date.now)()).toISOString(),
|
|
53
|
+
terminal: false
|
|
54
|
+
};
|
|
55
|
+
const leg = createXochiRampLeg({
|
|
56
|
+
store,
|
|
57
|
+
driver: options.driver,
|
|
58
|
+
delivered: restored?.source ?? options.source,
|
|
59
|
+
direction: "offramp",
|
|
60
|
+
now: options.now
|
|
61
|
+
});
|
|
62
|
+
let busy = false;
|
|
63
|
+
let durable = !!restored;
|
|
64
|
+
async function save(next) {
|
|
65
|
+
const clean = checkpointSchema.parse({
|
|
66
|
+
wallet: options.wallet,
|
|
67
|
+
source: restored?.source ?? options.source,
|
|
68
|
+
snapshot: next,
|
|
69
|
+
preview: leg.preview(id) ?? receiptPreview
|
|
70
|
+
});
|
|
71
|
+
if (durable) storage?.setItem(checkpointKey(options.wallet), JSON.stringify(clean));
|
|
72
|
+
receiptPreview = clean.preview;
|
|
73
|
+
snapshot = next;
|
|
74
|
+
await store.transact(id, () => ({ record: { snapshot, receipts: {} }, result: void 0 }));
|
|
75
|
+
}
|
|
76
|
+
async function run(action) {
|
|
77
|
+
if (busy) return snapshot;
|
|
78
|
+
busy = true;
|
|
79
|
+
try {
|
|
80
|
+
const latest = readOfframpPrerequisite(options.wallet, storage);
|
|
81
|
+
if (latest && latest.snapshot.operation_id !== id) throw new Error("checkpoint_changed");
|
|
82
|
+
if (latest) {
|
|
83
|
+
snapshot = latest.snapshot;
|
|
84
|
+
receiptPreview = latest.preview;
|
|
85
|
+
}
|
|
86
|
+
await store.transact(id, () => ({ record: { snapshot, receipts: {} }, result: void 0 }));
|
|
87
|
+
const state = snapshot.xochi.state;
|
|
88
|
+
if (state === "completed") return snapshot;
|
|
89
|
+
if (action === "quote") {
|
|
90
|
+
if (!["not_started", "failed", "action_required"].includes(state)) return snapshot;
|
|
91
|
+
await save(
|
|
92
|
+
await leg.approve(id, {
|
|
93
|
+
expected_revision: snapshot.revision,
|
|
94
|
+
idempotency_key: crypto.randomUUID()
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
} else if (action === "execute") {
|
|
98
|
+
if (state !== "action_required") return snapshot;
|
|
99
|
+
const quote = leg.preview(id);
|
|
100
|
+
if (!quote || quote.recipient.toLowerCase() !== options.wallet.toLowerCase())
|
|
101
|
+
throw new Error("invalid_request");
|
|
102
|
+
durable = true;
|
|
103
|
+
await save({ ...snapshot, xochi: { name: "xochi", state: "in_doubt", recoverable: true } });
|
|
104
|
+
await save(
|
|
105
|
+
await leg.execute(id, quote.quoteId, {
|
|
106
|
+
expected_revision: snapshot.revision,
|
|
107
|
+
idempotency_key: crypto.randomUUID()
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
} else if (["processing", "in_doubt"].includes(state)) await save(await leg.status(id));
|
|
111
|
+
return snapshot;
|
|
112
|
+
} finally {
|
|
113
|
+
busy = false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
act(action) {
|
|
118
|
+
if (typeof window !== "undefined") {
|
|
119
|
+
if (!navigator.locks) return Promise.reject(new Error("checkpoint_lock_unavailable"));
|
|
120
|
+
return navigator.locks.request(checkpointKey(options.wallet), () => run(action));
|
|
121
|
+
}
|
|
122
|
+
return run(action);
|
|
123
|
+
},
|
|
124
|
+
snapshot: () => snapshot,
|
|
125
|
+
preview: () => receiptPreview,
|
|
126
|
+
/** Recheck immediately before Peer approval, including after prior success. */
|
|
127
|
+
async funded(amount) {
|
|
128
|
+
if (snapshot.xochi?.state !== "completed" || !/^[1-9][0-9]*$/.test(amount)) return false;
|
|
129
|
+
const quote = leg.preview(id) ?? receiptPreview;
|
|
130
|
+
if (!quote || BigInt(amount) > BigInt(quote.receive.atomic)) return false;
|
|
131
|
+
try {
|
|
132
|
+
return await options.spendable(options.wallet) >= BigInt(amount);
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
createOfframpPrerequisite,
|
|
141
|
+
inspectOfframpPrerequisite,
|
|
142
|
+
readOfframpPrerequisite
|
|
143
|
+
};
|