@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,30 @@
|
|
|
1
|
+
import { isCantonDestinationChainId, getExplorerTxUrl, isSelectableChainId } from "@xochi/client";
|
|
2
|
+
function settlementTxChainId(fromChainId, toChainId, receivingTxHash, isRefunded = false) {
|
|
3
|
+
return isRefunded || receivingTxHash ? fromChainId : toChainId;
|
|
4
|
+
}
|
|
5
|
+
function swapExplorerLinks(input) {
|
|
6
|
+
if (isCantonDestinationChainId(input.toChainId)) {
|
|
7
|
+
return {
|
|
8
|
+
source: input.txHash ? getExplorerTxUrl(input.fromChainId, input.txHash) : null,
|
|
9
|
+
destination: input.cantonUpdateId ? getExplorerTxUrl(input.toChainId, input.cantonUpdateId) : null
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (input.settlementTxHash && isSelectableChainId(input.settlementChainId) && !input.isRefunded) {
|
|
13
|
+
const destination2 = getExplorerTxUrl(input.settlementChainId, input.settlementTxHash);
|
|
14
|
+
const source2 = input.txHash && input.txHash !== input.settlementTxHash ? getExplorerTxUrl(input.fromChainId, input.txHash) : null;
|
|
15
|
+
return { source: source2, destination: destination2 };
|
|
16
|
+
}
|
|
17
|
+
const settleChain = settlementTxChainId(
|
|
18
|
+
input.fromChainId,
|
|
19
|
+
input.toChainId,
|
|
20
|
+
input.receivingTxHash,
|
|
21
|
+
input.isRefunded
|
|
22
|
+
);
|
|
23
|
+
const source = input.txHash ? getExplorerTxUrl(settleChain, input.txHash) : null;
|
|
24
|
+
const destination = input.receivingTxHash && input.toChainId !== input.fromChainId ? getExplorerTxUrl(input.toChainId, input.receivingTxHash) : null;
|
|
25
|
+
return { source, destination };
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
settlementTxChainId,
|
|
29
|
+
swapExplorerLinks
|
|
30
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { costOf } from "@xochi/client";
|
|
2
|
+
import { totalCostUsd, formatUsd, approxUsd } from "./receiptCost.js";
|
|
3
|
+
import { formatCostPct } from "./priceImpact.js";
|
|
4
|
+
function servedFees(quote, inputTokens, inputPriceUsd) {
|
|
5
|
+
const cost = costOf(quote);
|
|
6
|
+
const bps = cost.kind === "served" ? cost.bps : null;
|
|
7
|
+
const usd = totalCostUsd({
|
|
8
|
+
servedTotalUsd: cost.kind === "served" ? cost.totalUsd ?? void 0 : void 0,
|
|
9
|
+
costBps: bps,
|
|
10
|
+
inputTokens,
|
|
11
|
+
inputPriceUsd
|
|
12
|
+
});
|
|
13
|
+
const usdText = formatUsd(usd);
|
|
14
|
+
const label = bps === null ? "Unavailable" : usdText ? `${approxUsd(usdText)} (${formatCostPct(bps)})` : formatCostPct(bps);
|
|
15
|
+
return { bps, usd, label };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
servedFees
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const GLYPH = {
|
|
2
|
+
/** A relates to / becomes B: "USDC -> WETH", "Swap X -> Y". */
|
|
3
|
+
flow: "→",
|
|
4
|
+
// ->
|
|
5
|
+
/** Opens elsewhere (new tab, block explorer). */
|
|
6
|
+
external: "↗",
|
|
7
|
+
// north-east arrow
|
|
8
|
+
/** Separates facts on one compact line: "Base -> Robinhood . Public". */
|
|
9
|
+
sep: "·",
|
|
10
|
+
// middle dot
|
|
11
|
+
/** The quote reprices on its own: "(refresh) 23s". */
|
|
12
|
+
refresh: "↻",
|
|
13
|
+
// clockwise open circle arrow
|
|
14
|
+
/** Trails a line of text that opens more detail (rotated by CSS on open). */
|
|
15
|
+
more: "›"
|
|
16
|
+
// single right-pointing angle quotation mark
|
|
17
|
+
};
|
|
18
|
+
const SEVERITY_GLYPH = {
|
|
19
|
+
warning: "!",
|
|
20
|
+
severe: "!!"
|
|
21
|
+
};
|
|
22
|
+
const PAIR_GLYPH = {
|
|
23
|
+
available: ">",
|
|
24
|
+
locked: "[*]",
|
|
25
|
+
unsupported: "[/]"
|
|
26
|
+
};
|
|
27
|
+
const STATUS_GLYPH = {
|
|
28
|
+
rejected: "[x]",
|
|
29
|
+
// canceled / refused
|
|
30
|
+
funds: "[0]",
|
|
31
|
+
// insufficient balance
|
|
32
|
+
network: "[≈]",
|
|
33
|
+
// approx wave -- connectivity
|
|
34
|
+
expired: "[○]",
|
|
35
|
+
// empty circle -- timed out
|
|
36
|
+
liquidity: "[≡]",
|
|
37
|
+
// stacked lines -- no depth
|
|
38
|
+
slippage: "[±]",
|
|
39
|
+
// plus/minus -- price moved
|
|
40
|
+
rate: "[#]",
|
|
41
|
+
// rate limited
|
|
42
|
+
forbidden: "[/]",
|
|
43
|
+
// blocked
|
|
44
|
+
notfound: "[?]",
|
|
45
|
+
// not found
|
|
46
|
+
unavail: "[·]",
|
|
47
|
+
// offline dot
|
|
48
|
+
auth: "[=]",
|
|
49
|
+
// locked
|
|
50
|
+
generic: "[!]"
|
|
51
|
+
// fallback
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
GLYPH,
|
|
55
|
+
PAIR_GLYPH,
|
|
56
|
+
SEVERITY_GLYPH,
|
|
57
|
+
STATUS_GLYPH
|
|
58
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FIRST_PARTY_HOST_ORIGINS } from "../config.js";
|
|
2
|
+
import { watchHostOrigin } from "./hostOrigin.js";
|
|
3
|
+
import { connectToHost } from "@xochi/widget-lib";
|
|
4
|
+
let hostBridge = null;
|
|
5
|
+
let mounted = false;
|
|
6
|
+
const origins = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function isFirstPartyHost(bridge) {
|
|
8
|
+
return origins.get(bridge)?.firstParty() === true;
|
|
9
|
+
}
|
|
10
|
+
function startHostBridge(options, firstPartyHosts = FIRST_PARTY_HOST_ORIGINS) {
|
|
11
|
+
if (mounted) throw new Error("A widget bridge is already mounted in this document.");
|
|
12
|
+
const win = options?.window ?? (typeof window === "undefined" ? void 0 : window);
|
|
13
|
+
const bridge = connectToHost(options);
|
|
14
|
+
const originWatch = bridge && win ? watchHostOrigin(win, firstPartyHosts) : null;
|
|
15
|
+
if (bridge && originWatch) origins.set(bridge, originWatch);
|
|
16
|
+
hostBridge = bridge;
|
|
17
|
+
mounted = true;
|
|
18
|
+
let stopped = false;
|
|
19
|
+
return {
|
|
20
|
+
bridge,
|
|
21
|
+
get active() {
|
|
22
|
+
return !stopped;
|
|
23
|
+
},
|
|
24
|
+
stop() {
|
|
25
|
+
if (stopped) return;
|
|
26
|
+
stopped = true;
|
|
27
|
+
originWatch?.stop();
|
|
28
|
+
if (bridge) {
|
|
29
|
+
origins.delete(bridge);
|
|
30
|
+
bridge.destroy();
|
|
31
|
+
}
|
|
32
|
+
hostBridge = null;
|
|
33
|
+
mounted = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
hostBridge,
|
|
39
|
+
isFirstPartyHost,
|
|
40
|
+
startHostBridge
|
|
41
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const LOOPBACK = ["localhost", "127.0.0.1", "[::1]"];
|
|
2
|
+
const DNS_HOST = /^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
|
|
3
|
+
function toOrigin(token) {
|
|
4
|
+
let url;
|
|
5
|
+
try {
|
|
6
|
+
url = new URL(token);
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (url.href !== `${url.origin}/`) return null;
|
|
11
|
+
if (url.protocol === "https:") return DNS_HOST.test(url.hostname) ? url.origin : null;
|
|
12
|
+
return url.protocol === "http:" && LOOPBACK.includes(url.hostname) ? url.origin : null;
|
|
13
|
+
}
|
|
14
|
+
function firstPartyOrigins(value) {
|
|
15
|
+
const tokens = value.trim().split(/\s+/).filter(Boolean);
|
|
16
|
+
const origins = tokens.map(toOrigin);
|
|
17
|
+
const bad = tokens.filter((_, i) => origins[i] === null);
|
|
18
|
+
if (bad.length > 0) {
|
|
19
|
+
console.error(`[hostOrigin] Not an explicit first-party origin, ignored: ${bad.join(" ")}`);
|
|
20
|
+
}
|
|
21
|
+
return [...new Set(origins.filter((origin) => origin !== null))];
|
|
22
|
+
}
|
|
23
|
+
function reportedParentOrigin(win) {
|
|
24
|
+
if (!("ancestorOrigins" in win.location)) return void 0;
|
|
25
|
+
const ancestors = win.location.ancestorOrigins;
|
|
26
|
+
return ancestors.length > 0 ? ancestors[0] : void 0;
|
|
27
|
+
}
|
|
28
|
+
function watchHostOrigin(win, allowed) {
|
|
29
|
+
const parent = win.parent;
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
const onMessage = (event) => {
|
|
32
|
+
if (event.source === null || event.source !== parent) return;
|
|
33
|
+
seen.add(event.origin);
|
|
34
|
+
};
|
|
35
|
+
win.addEventListener("message", onMessage);
|
|
36
|
+
return {
|
|
37
|
+
firstParty() {
|
|
38
|
+
if (seen.size === 0) return false;
|
|
39
|
+
const reported = reportedParentOrigin(win);
|
|
40
|
+
return [...seen].every(
|
|
41
|
+
(origin) => allowed.includes(origin) && (reported === void 0 || origin === reported)
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
stop() {
|
|
45
|
+
win.removeEventListener("message", onMessage);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
firstPartyOrigins,
|
|
51
|
+
watchHostOrigin
|
|
52
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createXochiClient } from "@xochi/client";
|
|
2
|
+
import { RETRY, TIMEOUTS, API_URL } from "../config.js";
|
|
3
|
+
import { getActiveToken } from "./authFetch.js";
|
|
4
|
+
import { getWalletSessionGeneration, getWalletToken, clearWalletSession } from "./walletSession.js";
|
|
5
|
+
import { debugLog } from "./debug.js";
|
|
6
|
+
import { notifySessionExpired } from "./sessionExpiry.js";
|
|
7
|
+
const log = (level, message, ...data) => {
|
|
8
|
+
if (level === "debug") debugLog(message, ...data);
|
|
9
|
+
else if (level === "warn") console.warn(message, ...data);
|
|
10
|
+
else console.error(message, ...data);
|
|
11
|
+
};
|
|
12
|
+
const transport = {
|
|
13
|
+
baseUrl: API_URL,
|
|
14
|
+
log,
|
|
15
|
+
timeouts: {
|
|
16
|
+
quoteCacheTtlMs: TIMEOUTS.quoteCacheTtl,
|
|
17
|
+
requestTimeoutMs: TIMEOUTS.requestTimeout,
|
|
18
|
+
executeTimeoutMs: TIMEOUTS.executeTimeout
|
|
19
|
+
},
|
|
20
|
+
retry: {
|
|
21
|
+
maxAttempts: RETRY.maxAttempts,
|
|
22
|
+
baseDelayMs: RETRY.baseDelay,
|
|
23
|
+
maxDelayMs: RETRY.maxDelay
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const intentAPI = createXochiClient({
|
|
27
|
+
...transport,
|
|
28
|
+
getAuthToken: getActiveToken,
|
|
29
|
+
getAuthGeneration: getWalletSessionGeneration,
|
|
30
|
+
onAuthExpired: (event) => {
|
|
31
|
+
if (event.reason === "expired") notifySessionExpired();
|
|
32
|
+
else if (getWalletToken()) clearWalletSession();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const anonymousIntentAPI = createXochiClient(transport);
|
|
36
|
+
export {
|
|
37
|
+
anonymousIntentAPI,
|
|
38
|
+
intentAPI
|
|
39
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function linksRecoveryKind(facts) {
|
|
2
|
+
if (!facts.legsWithheld || !facts.ownerWallet) return "none";
|
|
3
|
+
const owner = facts.ownerWallet.toLowerCase();
|
|
4
|
+
if (facts.sessionWallet?.toLowerCase() === owner) return "none";
|
|
5
|
+
return facts.connectedWallet?.toLowerCase() === owner ? "sign_in" : "switch_wallet";
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
linksRecoveryKind
|
|
9
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { AWAITING_RECIPIENT_SUBSTATUS } from "./recipientReceipt.js";
|
|
2
|
+
import { isOfferedChainId } from "../pages/trade/canton.js";
|
|
3
|
+
import { isTerminalIntentStatus, canTransitionTo, decodeWireStatus, NOT_EXECUTED_SUBSTATUS, GRANULAR_WIRE_STATUS } from "@xochi/client";
|
|
4
|
+
import { STORAGE_KEYS } from "../constants.js";
|
|
5
|
+
const MAX_RECORDS = 50;
|
|
6
|
+
const HEALABLE_SERVER_STATUSES = /* @__PURE__ */ new Set([
|
|
7
|
+
"executing",
|
|
8
|
+
"bridging",
|
|
9
|
+
"settling",
|
|
10
|
+
"completed",
|
|
11
|
+
"refunded"
|
|
12
|
+
]);
|
|
13
|
+
function isHealableServerStatus(status) {
|
|
14
|
+
return HEALABLE_SERVER_STATUSES.has(status);
|
|
15
|
+
}
|
|
16
|
+
const SWEEPABLE_PRE_DISPATCH_STATUSES = /* @__PURE__ */ new Set([
|
|
17
|
+
"idle",
|
|
18
|
+
"pending",
|
|
19
|
+
"quoting",
|
|
20
|
+
"quoted",
|
|
21
|
+
"signing"
|
|
22
|
+
]);
|
|
23
|
+
function isSweepablePreDispatch(status) {
|
|
24
|
+
return SWEEPABLE_PRE_DISPATCH_STATUSES.has(status);
|
|
25
|
+
}
|
|
26
|
+
function toActivityStatus(status) {
|
|
27
|
+
if (status === "completed") return "completed";
|
|
28
|
+
if (status === "failed" || status === "expired") return "failed";
|
|
29
|
+
if (status === "refunded") return "failed";
|
|
30
|
+
return "pending";
|
|
31
|
+
}
|
|
32
|
+
const sameHistoryToken = (left, right) => left === right || left.startsWith("0x") && right.startsWith("0x") && left.toLowerCase() === right.toLowerCase();
|
|
33
|
+
function mergeHistorySwap(server, local) {
|
|
34
|
+
const compatible = local !== void 0 && server.id === local.id && server.data.fromChainId === local.data.fromChainId && server.data.toChainId === local.data.toChainId && sameHistoryToken(server.data.fromToken, local.data.fromToken) && sameHistoryToken(server.data.toToken, local.data.toToken) && server.data.fromAmount === local.data.fromAmount && (!server.ownerWallet || !local.ownerWallet || server.ownerWallet.toLowerCase() === local.ownerWallet.toLowerCase());
|
|
35
|
+
if (!compatible) return server;
|
|
36
|
+
const recipientTag = server.data.recipientTag ?? (server.data.settlementType === "public" ? local.data.recipientTag : void 0);
|
|
37
|
+
return {
|
|
38
|
+
...server,
|
|
39
|
+
ownerWallet: local?.ownerWallet ?? server.ownerWallet,
|
|
40
|
+
legsWithheld: local?.legsWithheld,
|
|
41
|
+
data: {
|
|
42
|
+
...server.data,
|
|
43
|
+
...recipientTag !== void 0 && { recipientTag },
|
|
44
|
+
...local.data.deposit && { deposit: local.data.deposit }
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const keyFor = (address) => `${STORAGE_KEYS.localActivityPrefix}${address.toLowerCase()}`;
|
|
49
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
50
|
+
function subscribeLocalActivity(listener) {
|
|
51
|
+
listeners.add(listener);
|
|
52
|
+
return () => listeners.delete(listener);
|
|
53
|
+
}
|
|
54
|
+
function notify() {
|
|
55
|
+
for (const l of listeners) l();
|
|
56
|
+
}
|
|
57
|
+
function read(address) {
|
|
58
|
+
if (typeof window === "undefined") return [];
|
|
59
|
+
try {
|
|
60
|
+
const raw = window.localStorage.getItem(keyFor(address));
|
|
61
|
+
if (!raw) return [];
|
|
62
|
+
const parsed = JSON.parse(raw);
|
|
63
|
+
if (!Array.isArray(parsed)) return [];
|
|
64
|
+
const stored = parsed;
|
|
65
|
+
const items = stored.map(({ readToken: _readToken, ...item }) => ({
|
|
66
|
+
...item,
|
|
67
|
+
ownerWallet: address
|
|
68
|
+
}));
|
|
69
|
+
if (stored.some((item) => "readToken" in item)) write(address, items);
|
|
70
|
+
return items;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error("[localActivity] read failed", err);
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function write(address, items) {
|
|
77
|
+
if (typeof window === "undefined") return false;
|
|
78
|
+
try {
|
|
79
|
+
const persisted = items.map(({ ownerWallet: _ownerWallet, ...item }) => item);
|
|
80
|
+
window.localStorage.setItem(keyFor(address), JSON.stringify(persisted));
|
|
81
|
+
return true;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.error("[localActivity] write failed", err);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function listLocalSwaps(address) {
|
|
88
|
+
if (!address) return [];
|
|
89
|
+
return read(address).sort((a, b) => b.timestamp - a.timestamp);
|
|
90
|
+
}
|
|
91
|
+
const KNOWN_SUBSTATUSES = /* @__PURE__ */ new Set([
|
|
92
|
+
...Object.keys(GRANULAR_WIRE_STATUS),
|
|
93
|
+
NOT_EXECUTED_SUBSTATUS,
|
|
94
|
+
AWAITING_RECIPIENT_SUBSTATUS
|
|
95
|
+
]);
|
|
96
|
+
function isKnownSubstatus(substatus) {
|
|
97
|
+
return KNOWN_SUBSTATUSES.has(substatus);
|
|
98
|
+
}
|
|
99
|
+
function resolveStoredStatus(stored) {
|
|
100
|
+
const decoded = decodeWireStatus(stored);
|
|
101
|
+
return decoded.kind === "mapped" ? decoded.status : null;
|
|
102
|
+
}
|
|
103
|
+
function canAdoptStatus(record, to) {
|
|
104
|
+
const from = resolveStoredStatus(record.intentStatus);
|
|
105
|
+
if (from === null) return true;
|
|
106
|
+
if (from === to) return true;
|
|
107
|
+
if (canTransitionTo(from, to)) return true;
|
|
108
|
+
return from === "failed" && !record.data.txHash && isHealableServerStatus(to);
|
|
109
|
+
}
|
|
110
|
+
function reconcileLocalSwap(record, polled) {
|
|
111
|
+
if (!polled) return null;
|
|
112
|
+
if ("notFound" in polled) {
|
|
113
|
+
if (!isSweepablePreDispatch(record.intentStatus)) return null;
|
|
114
|
+
return {
|
|
115
|
+
...record,
|
|
116
|
+
intentStatus: "expired",
|
|
117
|
+
status: toActivityStatus("expired")
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (polled.intentId && polled.intentId !== record.id) {
|
|
121
|
+
console.warn(
|
|
122
|
+
`[localActivity] status for ${polled.intentId} arrived for record ${record.id}; ignored`
|
|
123
|
+
);
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (!canAdoptStatus(record, polled.status)) {
|
|
127
|
+
console.warn(
|
|
128
|
+
`[localActivity] illegal status move ${record.intentStatus} -> ${polled.status} for ${record.id}; ignored`
|
|
129
|
+
);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const substatus = polled.substatus && isKnownSubstatus(polled.substatus) ? polled.substatus : null;
|
|
133
|
+
const settlementChainId = isOfferedChainId(polled.settlementChainId) ? polled.settlementChainId : null;
|
|
134
|
+
const cantonUpdateId = polled.escrow?.cantonUpdateId ?? null;
|
|
135
|
+
return {
|
|
136
|
+
...record,
|
|
137
|
+
intentStatus: polled.status,
|
|
138
|
+
status: toActivityStatus(polled.status),
|
|
139
|
+
// The latest read's verdict, replaced every time. A wallet-session read
|
|
140
|
+
// carrying the legs clears the withheld state.
|
|
141
|
+
legsWithheld: polled.legsWithheld,
|
|
142
|
+
data: {
|
|
143
|
+
...record.data,
|
|
144
|
+
txHash: polled.txHash ?? record.data.txHash,
|
|
145
|
+
receivingTxHash: polled.receivingTxHash ?? record.data.receivingTxHash,
|
|
146
|
+
substatus: substatus ?? record.data.substatus,
|
|
147
|
+
settlementTxHash: polled.settlementTxHash ?? record.data.settlementTxHash,
|
|
148
|
+
settlementChainId: settlementChainId ?? record.data.settlementChainId,
|
|
149
|
+
cantonUpdateId: cantonUpdateId ?? record.data.cantonUpdateId,
|
|
150
|
+
// The client sets it only on a withheld read that is not a refund or a
|
|
151
|
+
// terminal failure; an owner read carries the hash instead.
|
|
152
|
+
settlementConfirmed: polled.legsWithheld === true ? polled.settlementConfirmed === true : record.data.settlementConfirmed
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function isSameWallet(a, b) {
|
|
157
|
+
return !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
158
|
+
}
|
|
159
|
+
async function refreshLocalSwaps(owner, getStatus, isCurrentOwner) {
|
|
160
|
+
const current = listLocalSwaps(owner);
|
|
161
|
+
const pending = current.filter((s) => !isTerminalIntentStatus(s.intentStatus));
|
|
162
|
+
if (pending.length === 0) return isCurrentOwner() ? current : null;
|
|
163
|
+
await Promise.all(
|
|
164
|
+
pending.map(async (s) => {
|
|
165
|
+
const next = await getStatus(s.id);
|
|
166
|
+
const reconciled = reconcileLocalSwap(s, next);
|
|
167
|
+
if (reconciled && isCurrentOwner()) upsertLocalSwap(owner, reconciled);
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
return isCurrentOwner() ? listLocalSwaps(owner) : null;
|
|
171
|
+
}
|
|
172
|
+
function upsertLocalSwap(address, item) {
|
|
173
|
+
if (!address) return;
|
|
174
|
+
const { substatus } = item.data;
|
|
175
|
+
const incoming = substatus && !isKnownSubstatus(substatus) ? { ...item, data: { ...item.data, substatus: void 0 } } : item;
|
|
176
|
+
const existing = read(address);
|
|
177
|
+
const idx = existing.findIndex((r) => r.id === incoming.id);
|
|
178
|
+
const next = idx >= 0 ? [...existing] : [incoming, ...existing];
|
|
179
|
+
if (idx >= 0) next[idx] = { ...existing[idx], ...incoming, timestamp: existing[idx].timestamp };
|
|
180
|
+
const capped = next.sort((a, b) => b.timestamp - a.timestamp).slice(0, MAX_RECORDS);
|
|
181
|
+
if (!write(address, capped)) return;
|
|
182
|
+
notify();
|
|
183
|
+
}
|
|
184
|
+
const RESUMABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
185
|
+
"awaiting_deposit",
|
|
186
|
+
"executing",
|
|
187
|
+
"bridging",
|
|
188
|
+
"settling"
|
|
189
|
+
]);
|
|
190
|
+
function isResumableIntentStatus(status) {
|
|
191
|
+
return RESUMABLE_STATUSES.has(status);
|
|
192
|
+
}
|
|
193
|
+
const RESUME_MAX_AGE_MS = 12 * 60 * 60 * 1e3;
|
|
194
|
+
const MAX_DISMISSED = 50;
|
|
195
|
+
const dismissKeyFor = (address) => `${STORAGE_KEYS.resumeDismissedPrefix}${address.toLowerCase()}`;
|
|
196
|
+
function readDismissed(address) {
|
|
197
|
+
if (typeof window === "undefined") return [];
|
|
198
|
+
try {
|
|
199
|
+
const raw = window.localStorage.getItem(dismissKeyFor(address));
|
|
200
|
+
if (!raw) return [];
|
|
201
|
+
const parsed = JSON.parse(raw);
|
|
202
|
+
return Array.isArray(parsed) ? parsed.filter((v) => typeof v === "string") : [];
|
|
203
|
+
} catch (err) {
|
|
204
|
+
console.error("[localActivity] dismissed read failed", err);
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function dismissResumableSwap(address, intentId, status) {
|
|
209
|
+
if (!address || !intentId || typeof window === "undefined") return;
|
|
210
|
+
if (!isResumableIntentStatus(status)) return;
|
|
211
|
+
const existing = readDismissed(address);
|
|
212
|
+
if (existing.includes(intentId)) return;
|
|
213
|
+
try {
|
|
214
|
+
window.localStorage.setItem(
|
|
215
|
+
dismissKeyFor(address),
|
|
216
|
+
JSON.stringify([intentId, ...existing].slice(0, MAX_DISMISSED))
|
|
217
|
+
);
|
|
218
|
+
} catch (err) {
|
|
219
|
+
console.error("[localActivity] dismissed write failed", err);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function findResumableSwap(address, now = Date.now()) {
|
|
223
|
+
if (!address) return null;
|
|
224
|
+
const dismissed = new Set(readDismissed(address));
|
|
225
|
+
return listLocalSwaps(address).find(
|
|
226
|
+
(s) => isResumableIntentStatus(s.intentStatus) && !dismissed.has(s.id) && now - s.timestamp <= RESUME_MAX_AGE_MS && // A chain the widget does not offer (Canton while its corridor is off)
|
|
227
|
+
// is never reopened into the panel.
|
|
228
|
+
isOfferedChainId(s.data.fromChainId) && isOfferedChainId(s.data.toChainId)
|
|
229
|
+
) ?? null;
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
RESUME_MAX_AGE_MS,
|
|
233
|
+
dismissResumableSwap,
|
|
234
|
+
findResumableSwap,
|
|
235
|
+
isHealableServerStatus,
|
|
236
|
+
isKnownSubstatus,
|
|
237
|
+
isResumableIntentStatus,
|
|
238
|
+
isSameWallet,
|
|
239
|
+
isSweepablePreDispatch,
|
|
240
|
+
listLocalSwaps,
|
|
241
|
+
mergeHistorySwap,
|
|
242
|
+
reconcileLocalSwap,
|
|
243
|
+
refreshLocalSwaps,
|
|
244
|
+
subscribeLocalActivity,
|
|
245
|
+
toActivityStatus,
|
|
246
|
+
upsertLocalSwap
|
|
247
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { isAddress, isHash } from "viem";
|
|
2
|
+
import { STORAGE_KEYS } from "../constants.js";
|
|
3
|
+
const MAX_RECORDS = 50;
|
|
4
|
+
const keyFor = (address) => `${STORAGE_KEYS.localSendsPrefix}${address.toLowerCase()}`;
|
|
5
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
6
|
+
function subscribeLocalSends(listener) {
|
|
7
|
+
listeners.add(listener);
|
|
8
|
+
return () => listeners.delete(listener);
|
|
9
|
+
}
|
|
10
|
+
function notify() {
|
|
11
|
+
for (const l of listeners) l();
|
|
12
|
+
}
|
|
13
|
+
const STATUSES = /* @__PURE__ */ new Set(["pending", "completed", "failed"]);
|
|
14
|
+
function parseSendRecord(value) {
|
|
15
|
+
if (!value || typeof value !== "object") return null;
|
|
16
|
+
const row = value;
|
|
17
|
+
const data = row.data;
|
|
18
|
+
if (row.type !== "send" || typeof row.id !== "string" || typeof row.timestamp !== "number" || typeof row.status !== "string" || !STATUSES.has(row.status) || !data || typeof data !== "object" || typeof data.chainId !== "number" || typeof data.token !== "string" || !isAddress(data.token, { strict: false }) || typeof data.symbol !== "string" || typeof data.decimals !== "number" || typeof data.amount !== "string" || !/^\d+$/.test(data.amount) || typeof data.recipient !== "string" || !isAddress(data.recipient, { strict: false }) || typeof data.txHash !== "string" || !isHash(data.txHash) || data.txHash !== row.id) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
id: row.id,
|
|
23
|
+
type: "send",
|
|
24
|
+
timestamp: row.timestamp,
|
|
25
|
+
status: row.status,
|
|
26
|
+
data: {
|
|
27
|
+
chainId: data.chainId,
|
|
28
|
+
token: data.token,
|
|
29
|
+
symbol: data.symbol,
|
|
30
|
+
decimals: data.decimals,
|
|
31
|
+
amount: data.amount,
|
|
32
|
+
recipient: data.recipient,
|
|
33
|
+
txHash: data.txHash
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function read(address) {
|
|
38
|
+
if (typeof window === "undefined") return [];
|
|
39
|
+
try {
|
|
40
|
+
const raw = window.localStorage.getItem(keyFor(address));
|
|
41
|
+
if (!raw) return [];
|
|
42
|
+
const parsed = JSON.parse(raw);
|
|
43
|
+
if (!Array.isArray(parsed)) return [];
|
|
44
|
+
return parsed.map(parseSendRecord).filter((row) => row !== null);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error("[localSends] read failed", err);
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function write(address, items) {
|
|
51
|
+
if (typeof window === "undefined") return false;
|
|
52
|
+
try {
|
|
53
|
+
window.localStorage.setItem(keyFor(address), JSON.stringify(items));
|
|
54
|
+
return true;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error("[localSends] write failed", err);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function listLocalSends(address) {
|
|
61
|
+
if (!address) return [];
|
|
62
|
+
return read(address).sort((a, b) => b.timestamp - a.timestamp);
|
|
63
|
+
}
|
|
64
|
+
function upsertLocalSend(address, item) {
|
|
65
|
+
if (!address || parseSendRecord(item) === null) return false;
|
|
66
|
+
const existing = read(address);
|
|
67
|
+
const idx = existing.findIndex((r) => r.id === item.id);
|
|
68
|
+
const next = idx >= 0 ? [...existing] : [item, ...existing];
|
|
69
|
+
if (idx >= 0) next[idx] = { ...item, timestamp: existing[idx].timestamp };
|
|
70
|
+
const capped = next.sort((a, b) => b.timestamp - a.timestamp).slice(0, MAX_RECORDS);
|
|
71
|
+
if (!write(address, capped)) return false;
|
|
72
|
+
notify();
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
const attemptKey = (wallet) => `${keyFor(wallet)}:attempt`;
|
|
76
|
+
function readSendAttempt(wallet) {
|
|
77
|
+
const raw = window.localStorage.getItem(attemptKey(wallet));
|
|
78
|
+
if (raw === null) return null;
|
|
79
|
+
const value = JSON.parse(raw);
|
|
80
|
+
const hash = value.hash ?? `0x${"0".repeat(64)}`;
|
|
81
|
+
const row = parseSendRecord({
|
|
82
|
+
id: hash,
|
|
83
|
+
type: "send",
|
|
84
|
+
timestamp: value.timestamp,
|
|
85
|
+
status: "pending",
|
|
86
|
+
data: { ...value.data, txHash: hash }
|
|
87
|
+
});
|
|
88
|
+
if (!row || value.candidateHash !== void 0 && (typeof value.candidateHash !== "string" || !isHash(value.candidateHash)) || !Number.isSafeInteger(row.timestamp) || row.timestamp <= 0 || value.wallet.toLowerCase() !== wallet.toLowerCase() || !/^(0|[1-9][0-9]*)$/.test(row.data.amount))
|
|
89
|
+
throw new Error("Invalid send checkpoint");
|
|
90
|
+
const { txHash: _hash, ...data } = row.data;
|
|
91
|
+
return {
|
|
92
|
+
wallet: wallet.toLowerCase(),
|
|
93
|
+
timestamp: row.timestamp,
|
|
94
|
+
data,
|
|
95
|
+
...value.hash ? { hash: value.hash } : {},
|
|
96
|
+
...value.candidateHash ? { candidateHash: value.candidateHash } : {}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function saveSendAttempt(attempt) {
|
|
100
|
+
const { chainId, token, symbol, decimals, amount, recipient } = attempt.data;
|
|
101
|
+
const projected = {
|
|
102
|
+
wallet: attempt.wallet.toLowerCase(),
|
|
103
|
+
timestamp: attempt.timestamp,
|
|
104
|
+
data: { chainId, token, symbol, decimals, amount, recipient },
|
|
105
|
+
...attempt.hash ? { hash: attempt.hash } : {},
|
|
106
|
+
...attempt.candidateHash ? { candidateHash: attempt.candidateHash } : {}
|
|
107
|
+
};
|
|
108
|
+
window.localStorage.setItem(attemptKey(attempt.wallet), JSON.stringify(projected));
|
|
109
|
+
if (!readSendAttempt(attempt.wallet)) throw new Error("Send checkpoint unavailable");
|
|
110
|
+
}
|
|
111
|
+
function clearSendAttempt(wallet) {
|
|
112
|
+
window.localStorage.removeItem(attemptKey(wallet));
|
|
113
|
+
}
|
|
114
|
+
async function withSendAttemptLock(wallet, run) {
|
|
115
|
+
if (!navigator.locks) return run();
|
|
116
|
+
await navigator.locks.request(attemptKey(wallet), { ifAvailable: true }, async (lock) => {
|
|
117
|
+
if (lock) await run();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
clearSendAttempt,
|
|
122
|
+
listLocalSends,
|
|
123
|
+
parseSendRecord,
|
|
124
|
+
readSendAttempt,
|
|
125
|
+
saveSendAttempt,
|
|
126
|
+
subscribeLocalSends,
|
|
127
|
+
upsertLocalSend,
|
|
128
|
+
withSendAttemptLock
|
|
129
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const MOBILE_UA = /Android|iPhone|iPad|iPod|Mobile/i;
|
|
2
|
+
function isMobileUserAgent(ua) {
|
|
3
|
+
const agent = typeof navigator !== "undefined" ? navigator.userAgent : "";
|
|
4
|
+
return MOBILE_UA.test(agent);
|
|
5
|
+
}
|
|
6
|
+
function isInjectedWalletBrowser(win = typeof window !== "undefined" ? window : void 0) {
|
|
7
|
+
const eth = win?.ethereum;
|
|
8
|
+
return !!eth && (eth.isMetaMask === true || eth.isCoinbaseWallet === true || Array.isArray(eth.providers));
|
|
9
|
+
}
|
|
10
|
+
function shouldOfferInAppBrowser(win = typeof window !== "undefined" ? window : void 0, ua) {
|
|
11
|
+
return isMobileUserAgent() && !isInjectedWalletBrowser(win);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
isInjectedWalletBrowser,
|
|
15
|
+
isMobileUserAgent,
|
|
16
|
+
shouldOfferInAppBrowser
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "@xochi/client";
|
|
2
|
+
function isSelectable(availability) {
|
|
3
|
+
return availability.state === "available";
|
|
4
|
+
}
|
|
5
|
+
function pairBadgeLabel(availability) {
|
|
6
|
+
switch (availability.state) {
|
|
7
|
+
case "available":
|
|
8
|
+
return null;
|
|
9
|
+
case "trust_locked":
|
|
10
|
+
return availability.requiredTier;
|
|
11
|
+
case "unsupported":
|
|
12
|
+
return "Unavailable";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function pairAvailabilityHint(availability, symbol) {
|
|
16
|
+
switch (availability.state) {
|
|
17
|
+
case "available":
|
|
18
|
+
return null;
|
|
19
|
+
case "trust_locked":
|
|
20
|
+
return `Reach ${availability.requiredTier} (${availability.requiredScore}) to trade ${symbol}`;
|
|
21
|
+
case "unsupported":
|
|
22
|
+
return availability.reason ?? `${symbol} can't be traded`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
isSelectable,
|
|
27
|
+
pairAvailabilityHint,
|
|
28
|
+
pairBadgeLabel
|
|
29
|
+
};
|