@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,302 @@
|
|
|
1
|
+
import { validateAddressForVm } from "@xochi/client";
|
|
2
|
+
import { getAddress, BaseError, ContractFunctionRevertedError, parseAbi, encodeFunctionData } from "viem";
|
|
3
|
+
import { mainnet } from "viem/chains";
|
|
4
|
+
import { normalize } from "viem/ens";
|
|
5
|
+
import { parseStealthMetaAddress } from "../../pages/send/stealthRecipient.js";
|
|
6
|
+
import { normalizeZkMoneyTag, zkMoneyTagValid } from "../../pages/trade/zkMoney.js";
|
|
7
|
+
const REGISTRY = "0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538";
|
|
8
|
+
const REGISTRY_CHAINS = [
|
|
9
|
+
1,
|
|
10
|
+
8453,
|
|
11
|
+
42161,
|
|
12
|
+
10,
|
|
13
|
+
100,
|
|
14
|
+
137,
|
|
15
|
+
534352,
|
|
16
|
+
11155111,
|
|
17
|
+
84532,
|
|
18
|
+
421614,
|
|
19
|
+
11155420
|
|
20
|
+
];
|
|
21
|
+
const registryAbi = parseAbi([
|
|
22
|
+
"function stealthMetaAddressOf(address registrant, uint256 schemeId) view returns (bytes)",
|
|
23
|
+
"function registerKeys(uint256 schemeId, bytes stealthMetaAddress)"
|
|
24
|
+
]);
|
|
25
|
+
const SCHEME_ID = 1n;
|
|
26
|
+
const STEALTH_PREFIX = "st:eth:";
|
|
27
|
+
const STEALTH_TEXT_KEY = "stealth-meta-address[1]";
|
|
28
|
+
const nameRegistries = {
|
|
29
|
+
gns: "0x9D51D507BC7264d4fE8Ad1cf7Fe191933A0a81d6",
|
|
30
|
+
wns: "0x0000000000696760E15f265e828DB644A0c242EB"
|
|
31
|
+
};
|
|
32
|
+
const nameRegistryAbi = parseAbi([
|
|
33
|
+
"function computeId(string fullName) pure returns (uint256)",
|
|
34
|
+
"function resolve(uint256 tokenId) view returns (address)"
|
|
35
|
+
]);
|
|
36
|
+
const ENS_RESOLVER = mainnet.contracts.ensUniversalResolver.address;
|
|
37
|
+
const ZK_MONEY_SUFFIX = ".zk.money";
|
|
38
|
+
const ZK_MONEY_RESOLVER = "0x64969fb44091A7E5fA1213D30D7A7e8488edf693";
|
|
39
|
+
const USER_NOT_FOUND = "0x9a66e130";
|
|
40
|
+
function classifyRecipientInput(input) {
|
|
41
|
+
const value = input.trim().toLowerCase();
|
|
42
|
+
if (value.startsWith("st:")) return "stealth_meta";
|
|
43
|
+
if (value.startsWith("0x") && !value.includes(".")) return "address";
|
|
44
|
+
if (value.startsWith("@") || value.endsWith(ZK_MONEY_SUFFIX)) return "zkmoney";
|
|
45
|
+
if (value.endsWith(".eth")) return "ens";
|
|
46
|
+
if (value.endsWith(".gwei")) return "gns";
|
|
47
|
+
if (value.endsWith(".wei")) return "wns";
|
|
48
|
+
return "unknown";
|
|
49
|
+
}
|
|
50
|
+
async function abortable(run, signal) {
|
|
51
|
+
if (!signal) return run();
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
let onAbort;
|
|
54
|
+
const aborted = new Promise((_, reject) => {
|
|
55
|
+
onAbort = () => reject(signal.reason);
|
|
56
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
return await Promise.race([aborted, run()]);
|
|
60
|
+
} finally {
|
|
61
|
+
signal.removeEventListener("abort", onAbort);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function validAddress(value) {
|
|
65
|
+
if (!value || !validateAddressForVm(value, "evm").valid) return void 0;
|
|
66
|
+
return getAddress(value);
|
|
67
|
+
}
|
|
68
|
+
function validMetaAddress(value) {
|
|
69
|
+
const parsed = parseStealthMetaAddress(value);
|
|
70
|
+
return parsed.ok ? parsed.recipient.encoded : void 0;
|
|
71
|
+
}
|
|
72
|
+
async function ensRecord(read, signal, zkMoney = false) {
|
|
73
|
+
try {
|
|
74
|
+
return await abortable(read, signal);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
signal?.throwIfAborted();
|
|
77
|
+
const revert = error instanceof BaseError && error.walk((cause) => cause instanceof ContractFunctionRevertedError);
|
|
78
|
+
if (revert instanceof ContractFunctionRevertedError) {
|
|
79
|
+
const { errorName, args } = revert.data ?? {};
|
|
80
|
+
if (errorName === "ResolverNotFound" || errorName === "UnsupportedResolverProfile" || errorName === "ReverseAddressMismatch" || zkMoney && errorName === "ResolverError" && args?.[0] === USER_NOT_FOUND) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function reverseName(address, client, signal) {
|
|
88
|
+
const name = await ensRecord(
|
|
89
|
+
() => client.getEnsName({ address, universalResolverAddress: ENS_RESOLVER, strict: true }),
|
|
90
|
+
signal
|
|
91
|
+
);
|
|
92
|
+
return name ? normalize(name) : void 0;
|
|
93
|
+
}
|
|
94
|
+
async function httpsAvatar(name, client, signal) {
|
|
95
|
+
try {
|
|
96
|
+
const avatar = await abortable(
|
|
97
|
+
() => client.getEnsAvatar({ name, universalResolverAddress: ENS_RESOLVER }),
|
|
98
|
+
signal
|
|
99
|
+
);
|
|
100
|
+
if (avatar && new URL(avatar).protocol === "https:") return avatar;
|
|
101
|
+
} catch {
|
|
102
|
+
signal?.throwIfAborted();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function registryMetaAddress(address, deps, signal) {
|
|
106
|
+
let failed = false;
|
|
107
|
+
for (const chainId of REGISTRY_CHAINS) {
|
|
108
|
+
signal?.throwIfAborted();
|
|
109
|
+
const client = chainId === 1 ? deps.mainnetClient : deps.clientFor(chainId);
|
|
110
|
+
if (!client) continue;
|
|
111
|
+
try {
|
|
112
|
+
const code = await abortable(() => client.getCode({ address: REGISTRY }), signal);
|
|
113
|
+
if (!code || code === "0x") continue;
|
|
114
|
+
const bytes = await abortable(
|
|
115
|
+
() => client.readContract({
|
|
116
|
+
address: REGISTRY,
|
|
117
|
+
abi: registryAbi,
|
|
118
|
+
functionName: "stealthMetaAddressOf",
|
|
119
|
+
args: [address, SCHEME_ID]
|
|
120
|
+
}),
|
|
121
|
+
signal
|
|
122
|
+
);
|
|
123
|
+
const metaAddress = validMetaAddress(`${STEALTH_PREFIX}${bytes}`);
|
|
124
|
+
if (metaAddress) return metaAddress;
|
|
125
|
+
} catch {
|
|
126
|
+
signal?.throwIfAborted();
|
|
127
|
+
failed = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (failed) throw new Error("Registry lookup unavailable.");
|
|
131
|
+
}
|
|
132
|
+
async function ensMetaAddress(name, client, signal) {
|
|
133
|
+
const text = await ensRecord(
|
|
134
|
+
() => client.getEnsText({
|
|
135
|
+
name,
|
|
136
|
+
key: STEALTH_TEXT_KEY,
|
|
137
|
+
universalResolverAddress: ENS_RESOLVER,
|
|
138
|
+
strict: true
|
|
139
|
+
}),
|
|
140
|
+
signal
|
|
141
|
+
);
|
|
142
|
+
return text ? validMetaAddress(text) : void 0;
|
|
143
|
+
}
|
|
144
|
+
async function addressMetaAddress(address, deps, signal) {
|
|
145
|
+
const registered = await registryMetaAddress(address, deps, signal);
|
|
146
|
+
if (registered) return registered;
|
|
147
|
+
const name = await reverseName(address, deps.mainnetClient, signal);
|
|
148
|
+
return name ? ensMetaAddress(name, deps.mainnetClient, signal) : void 0;
|
|
149
|
+
}
|
|
150
|
+
async function readStealthRegistration(address, deps, signal) {
|
|
151
|
+
try {
|
|
152
|
+
if (!validAddress(address)) return "unknown";
|
|
153
|
+
return await addressMetaAddress(address, deps, signal) ? "published" : "not_published";
|
|
154
|
+
} catch {
|
|
155
|
+
return "unknown";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function buildRegisterStealthMetaAddressTx(metaAddress, chainId) {
|
|
159
|
+
if (!REGISTRY_CHAINS.includes(chainId)) throw new Error("Unsupported registry chain.");
|
|
160
|
+
const parsed = parseStealthMetaAddress(metaAddress);
|
|
161
|
+
if (!parsed.ok) throw new Error("Invalid stealth meta-address.");
|
|
162
|
+
return {
|
|
163
|
+
to: REGISTRY,
|
|
164
|
+
data: encodeFunctionData({
|
|
165
|
+
abi: registryAbi,
|
|
166
|
+
functionName: "registerKeys",
|
|
167
|
+
args: [
|
|
168
|
+
SCHEME_ID,
|
|
169
|
+
`0x${parsed.recipient.spendingPubKey.slice(2)}${parsed.recipient.viewingPubKey.slice(2)}`
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
value: 0n
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function resolveRegistryName(kind, name, client, signal) {
|
|
176
|
+
const address = nameRegistries[kind];
|
|
177
|
+
const tokenId = await abortable(
|
|
178
|
+
() => client.readContract({
|
|
179
|
+
address,
|
|
180
|
+
abi: nameRegistryAbi,
|
|
181
|
+
functionName: "computeId",
|
|
182
|
+
args: [name]
|
|
183
|
+
}),
|
|
184
|
+
signal
|
|
185
|
+
);
|
|
186
|
+
if (!tokenId) return null;
|
|
187
|
+
return abortable(
|
|
188
|
+
() => client.readContract({
|
|
189
|
+
address,
|
|
190
|
+
abi: nameRegistryAbi,
|
|
191
|
+
functionName: "resolve",
|
|
192
|
+
args: [tokenId]
|
|
193
|
+
}),
|
|
194
|
+
signal
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const NOT_FOUND = { status: "not_found", reason: "Recipient not found." };
|
|
198
|
+
async function resolveRecipient(input, deps, signal) {
|
|
199
|
+
const value = input.trim();
|
|
200
|
+
const kind = classifyRecipientInput(value);
|
|
201
|
+
try {
|
|
202
|
+
signal?.throwIfAborted();
|
|
203
|
+
if (kind === "unknown") {
|
|
204
|
+
if (/^[^\s.]+(?:\.[^\s.]+)+$/u.test(value)) {
|
|
205
|
+
return { status: "unsupported", reason: "Unsupported name suffix." };
|
|
206
|
+
}
|
|
207
|
+
return { status: "invalid", reason: "Enter a recipient name or address." };
|
|
208
|
+
}
|
|
209
|
+
if (kind === "stealth_meta") {
|
|
210
|
+
const parsed = parseStealthMetaAddress(value);
|
|
211
|
+
if (!parsed.ok) return { status: "invalid", reason: "Invalid stealth meta-address." };
|
|
212
|
+
const encoded = parsed.recipient.encoded;
|
|
213
|
+
return {
|
|
214
|
+
status: "resolved",
|
|
215
|
+
recipient: { kind, input: encoded, stealthMetaAddress: encoded }
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const client = deps.mainnetClient;
|
|
219
|
+
if (kind === "zkmoney") {
|
|
220
|
+
const bareAlias = normalizeZkMoneyTag(value);
|
|
221
|
+
const alias = bareAlias.endsWith(ZK_MONEY_SUFFIX) ? bareAlias.slice(0, -ZK_MONEY_SUFFIX.length) : bareAlias;
|
|
222
|
+
if (!zkMoneyTagValid(alias)) return { status: "invalid", reason: "Invalid zk.money alias." };
|
|
223
|
+
const name2 = `${alias}${ZK_MONEY_SUFFIX}`;
|
|
224
|
+
const deposit = await ensRecord(
|
|
225
|
+
() => client.getEnsAddress({
|
|
226
|
+
name: normalize(name2),
|
|
227
|
+
universalResolverAddress: ZK_MONEY_RESOLVER,
|
|
228
|
+
strict: true
|
|
229
|
+
}),
|
|
230
|
+
signal,
|
|
231
|
+
true
|
|
232
|
+
);
|
|
233
|
+
if (!validAddress(deposit)) return NOT_FOUND;
|
|
234
|
+
return { status: "resolved", recipient: { kind, input: alias, name: name2, shieldedAlias: alias } };
|
|
235
|
+
}
|
|
236
|
+
let address;
|
|
237
|
+
let name;
|
|
238
|
+
let normalizedInput;
|
|
239
|
+
if (kind === "address") {
|
|
240
|
+
const validation = validateAddressForVm(value, "evm");
|
|
241
|
+
if (!validation.valid) {
|
|
242
|
+
return { status: "invalid", reason: validation.error ?? "Invalid Ethereum address" };
|
|
243
|
+
}
|
|
244
|
+
address = getAddress(value);
|
|
245
|
+
normalizedInput = address;
|
|
246
|
+
} else {
|
|
247
|
+
try {
|
|
248
|
+
name = normalize(value);
|
|
249
|
+
} catch {
|
|
250
|
+
return { status: "invalid", reason: "Invalid recipient name." };
|
|
251
|
+
}
|
|
252
|
+
const canonicalName = name;
|
|
253
|
+
normalizedInput = name;
|
|
254
|
+
const resolved = kind === "ens" ? await ensRecord(
|
|
255
|
+
() => client.getEnsAddress({
|
|
256
|
+
name: canonicalName,
|
|
257
|
+
universalResolverAddress: ENS_RESOLVER,
|
|
258
|
+
strict: true
|
|
259
|
+
}),
|
|
260
|
+
signal
|
|
261
|
+
) : await resolveRegistryName(kind, canonicalName, client, signal);
|
|
262
|
+
address = validAddress(resolved);
|
|
263
|
+
if (!address) return NOT_FOUND;
|
|
264
|
+
}
|
|
265
|
+
const registered = await registryMetaAddress(address, deps, signal);
|
|
266
|
+
let ensName = kind === "ens" ? name : void 0;
|
|
267
|
+
if (kind === "address") {
|
|
268
|
+
try {
|
|
269
|
+
name = ensName = await reverseName(address, client, signal);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (!registered) throw error;
|
|
272
|
+
}
|
|
273
|
+
} else if (kind !== "ens" && !registered) {
|
|
274
|
+
ensName = await reverseName(address, client, signal);
|
|
275
|
+
}
|
|
276
|
+
const stealthMetaAddress = registered ?? (ensName && await ensMetaAddress(ensName, client, signal));
|
|
277
|
+
const avatarUrl = ensName && await httpsAvatar(ensName, client, signal);
|
|
278
|
+
signal?.throwIfAborted();
|
|
279
|
+
return {
|
|
280
|
+
status: "resolved",
|
|
281
|
+
recipient: {
|
|
282
|
+
kind,
|
|
283
|
+
input: normalizedInput,
|
|
284
|
+
address,
|
|
285
|
+
...name && { name },
|
|
286
|
+
...avatarUrl && { avatarUrl },
|
|
287
|
+
...stealthMetaAddress && { stealthMetaAddress }
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
} catch {
|
|
291
|
+
return {
|
|
292
|
+
status: "unavailable",
|
|
293
|
+
reason: signal?.aborted ? "Recipient lookup cancelled." : "Recipient lookup unavailable."
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export {
|
|
298
|
+
buildRegisterStealthMetaAddressTx,
|
|
299
|
+
classifyRecipientInput,
|
|
300
|
+
readStealthRegistration,
|
|
301
|
+
resolveRecipient
|
|
302
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isAddress } from "viem";
|
|
2
|
+
import { classifyRecipientInput } from "./index.js";
|
|
3
|
+
const KEY = "xochi.swap.recentRecipients";
|
|
4
|
+
const LIMIT = 5;
|
|
5
|
+
function parseRecent(value) {
|
|
6
|
+
const input = typeof value === "string" ? value : value && typeof value === "object" && "input" in value ? value.input : void 0;
|
|
7
|
+
if (typeof input !== "string" || input.length > 255) return;
|
|
8
|
+
const kind = classifyRecipientInput(input);
|
|
9
|
+
if (kind === "unknown") return;
|
|
10
|
+
const details = value && typeof value === "object" ? value : void 0;
|
|
11
|
+
const name = details && "name" in details && typeof details.name === "string" && details.name.length <= 255 ? details.name : kind !== "address" && kind !== "stealth_meta" ? input : void 0;
|
|
12
|
+
const address = details && "address" in details && typeof details.address === "string" && isAddress(details.address) ? details.address : void 0;
|
|
13
|
+
return { kind, input, name, address };
|
|
14
|
+
}
|
|
15
|
+
function readRecentRecipientEntries() {
|
|
16
|
+
try {
|
|
17
|
+
const values = JSON.parse(localStorage.getItem(KEY) ?? "[]");
|
|
18
|
+
if (!Array.isArray(values)) return [];
|
|
19
|
+
const recent = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const value of values) {
|
|
21
|
+
const recipient = parseRecent(value);
|
|
22
|
+
if (!recipient) continue;
|
|
23
|
+
const key = recipient.input.toLowerCase();
|
|
24
|
+
if (!recent.has(key)) recent.set(key, recipient);
|
|
25
|
+
if (recent.size === LIMIT) break;
|
|
26
|
+
}
|
|
27
|
+
return [...recent.values()];
|
|
28
|
+
} catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function rememberRecipient(recipient) {
|
|
33
|
+
const input = recipient.shieldedAlias ? `${recipient.shieldedAlias}.zk.money` : recipient.input;
|
|
34
|
+
const entry = parseRecent({ input, name: recipient.name, address: recipient.address });
|
|
35
|
+
if (!entry) return;
|
|
36
|
+
const recent = readRecentRecipientEntries().filter(
|
|
37
|
+
(value) => value.input.toLowerCase() !== input.toLowerCase()
|
|
38
|
+
);
|
|
39
|
+
try {
|
|
40
|
+
localStorage.setItem(KEY, JSON.stringify([entry, ...recent].slice(0, LIMIT)));
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
readRecentRecipientEntries,
|
|
46
|
+
rememberRecipient
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const AWAITING_RECIPIENT_SUBSTATUS = "awaiting_recipient";
|
|
2
|
+
const CLI_INTENT_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
3
|
+
function isAwaitingRecipient(status, substatus) {
|
|
4
|
+
return status === "settling" && substatus === AWAITING_RECIPIENT_SUBSTATUS;
|
|
5
|
+
}
|
|
6
|
+
function receiptCommand(item, live) {
|
|
7
|
+
if (!live || !isAwaitingRecipient(item.intentStatus, item.data.substatus)) return null;
|
|
8
|
+
const { settlementType } = item.data;
|
|
9
|
+
if (settlementType !== void 0 && settlementType !== "shielded") return null;
|
|
10
|
+
return CLI_INTENT_ID.test(item.id) ? `xochi-recipient receipt ${item.id}` : null;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
AWAITING_RECIPIENT_SUBSTATUS,
|
|
14
|
+
isAwaitingRecipient,
|
|
15
|
+
receiptCommand
|
|
16
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { API_URL } from "../config.js";
|
|
2
|
+
async function reportSwapFailure(ref) {
|
|
3
|
+
try {
|
|
4
|
+
await fetch(`${API_URL}/api/report`, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: { "Content-Type": "application/json" },
|
|
7
|
+
body: JSON.stringify({
|
|
8
|
+
intent_id: ref.intentId ?? void 0,
|
|
9
|
+
quote_id: ref.quoteId ?? void 0,
|
|
10
|
+
status: ref.status,
|
|
11
|
+
reason: ref.reason,
|
|
12
|
+
from_chain_id: ref.fromChainId,
|
|
13
|
+
to_chain_id: ref.toChainId,
|
|
14
|
+
from_token: ref.fromToken,
|
|
15
|
+
to_token: ref.toToken,
|
|
16
|
+
from_amount: ref.fromAmount,
|
|
17
|
+
wallet: ref.wallet,
|
|
18
|
+
app_version: ref.appVersion,
|
|
19
|
+
// navigator.userAgent is intentionally NOT sent: binding a high-entropy
|
|
20
|
+
// UA string to wallet + trade in an unauthenticated payload is a privacy
|
|
21
|
+
// fingerprint. The server records a bounded UA from the request header
|
|
22
|
+
// instead (still untrusted, but not a client-body injection vector).
|
|
23
|
+
client_ts: ref.timestamp
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.warn("[report] failed to send failure report:", err);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
reportSwapFailure
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const SESSION_EXPIRED_EVENT = "xochi:session-expired";
|
|
2
|
+
let fired = false;
|
|
3
|
+
function notifySessionExpired() {
|
|
4
|
+
if (fired || typeof window === "undefined") return;
|
|
5
|
+
fired = true;
|
|
6
|
+
window.dispatchEvent(new Event(SESSION_EXPIRED_EVENT));
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
SESSION_EXPIRED_EVENT,
|
|
10
|
+
notifySessionExpired
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function defaultSettlementSelection(selected, stealthEligible) {
|
|
2
|
+
return selected ?? (stealthEligible ? "stealth" : null);
|
|
3
|
+
}
|
|
4
|
+
function stealthFixFor(input) {
|
|
5
|
+
if (!input.live) return "unavailable";
|
|
6
|
+
if (!input.stealthChainsKnown) {
|
|
7
|
+
return input.capabilitiesLoading ? "route_loading" : "route_unavailable";
|
|
8
|
+
}
|
|
9
|
+
if (!input.hasStealthChains) return "route";
|
|
10
|
+
if (!input.connected) return "wallet";
|
|
11
|
+
if (!input.destinationSupported) return "destination";
|
|
12
|
+
if (input.routeAvailable === false) return "route";
|
|
13
|
+
if (input.metaAddressReady === false) return "setup";
|
|
14
|
+
return input.quotedSettlement !== void 0 && input.quotedSettlement !== "stealth" ? "quote" : null;
|
|
15
|
+
}
|
|
16
|
+
function shieldedFixFor(input) {
|
|
17
|
+
if (!input.live) return "unavailable";
|
|
18
|
+
return input.routeAvailable === false ? "route" : null;
|
|
19
|
+
}
|
|
20
|
+
function settlementSelectionDecision(input) {
|
|
21
|
+
if (input.next === "shielded") {
|
|
22
|
+
if (input.shieldedPreLive) return "show_shielded_soon";
|
|
23
|
+
if (!input.connected) return "show_wallet_nudge";
|
|
24
|
+
return input.shieldedSelectable ? "select_shielded" : "ignore";
|
|
25
|
+
}
|
|
26
|
+
if (input.next !== "stealth") return "select_public";
|
|
27
|
+
return "select_stealth";
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
defaultSettlementSelection,
|
|
31
|
+
settlementSelectionDecision,
|
|
32
|
+
shieldedFixFor,
|
|
33
|
+
stealthFixFor
|
|
34
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { parseAbi } from "viem";
|
|
2
|
+
import { checkViewTag, deriveStealthOwner, decodeAnnouncementMetadata } from "@xochi/signer";
|
|
3
|
+
import { isTrustedStealthFactory, SIMPLE_ACCOUNT_FACTORY } from "@xochi/client";
|
|
4
|
+
const SIMPLE_ACCOUNT_FACTORY_ABI = [
|
|
5
|
+
{
|
|
6
|
+
type: "function",
|
|
7
|
+
name: "getAddress",
|
|
8
|
+
stateMutability: "view",
|
|
9
|
+
inputs: [
|
|
10
|
+
{ name: "owner", type: "address" },
|
|
11
|
+
{ name: "salt", type: "uint256" }
|
|
12
|
+
],
|
|
13
|
+
outputs: [{ name: "", type: "address" }]
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
async function computeCounterfactualAddress(params) {
|
|
17
|
+
const { owner, client, factory = SIMPLE_ACCOUNT_FACTORY, salt = 0n, chainId } = params;
|
|
18
|
+
if (!isTrustedStealthFactory(factory, chainId)) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Refusing to derive a stealth payout against an untrusted SimpleAccountFactory (${factory} on chain ${chainId}). See TRUSTED_STEALTH_FACTORIES.`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const address = await client.readContract({
|
|
24
|
+
address: factory,
|
|
25
|
+
abi: SIMPLE_ACCOUNT_FACTORY_ABI,
|
|
26
|
+
functionName: "getAddress",
|
|
27
|
+
args: [owner, salt]
|
|
28
|
+
});
|
|
29
|
+
return address;
|
|
30
|
+
}
|
|
31
|
+
async function canSpendFromAddress(announcement, spendingPrivKey, viewingPrivKey, client, factory, chainId) {
|
|
32
|
+
const { stealthPrivKey, stealthEOA } = deriveStealthOwner(
|
|
33
|
+
announcement,
|
|
34
|
+
spendingPrivKey,
|
|
35
|
+
viewingPrivKey
|
|
36
|
+
);
|
|
37
|
+
const counterfactual = await computeCounterfactualAddress({
|
|
38
|
+
owner: stealthEOA,
|
|
39
|
+
client,
|
|
40
|
+
factory,
|
|
41
|
+
chainId
|
|
42
|
+
});
|
|
43
|
+
if (counterfactual.toLowerCase() !== announcement.stealthAddress.toLowerCase()) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
announcement,
|
|
48
|
+
stealthPrivKey
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const ERC20_BALANCE_OF_ABI = parseAbi([
|
|
52
|
+
"function balanceOf(address account) view returns (uint256)"
|
|
53
|
+
]);
|
|
54
|
+
async function readSettledBalance(announcement, client) {
|
|
55
|
+
const metadata = decodeAnnouncementMetadata(announcement.metadata);
|
|
56
|
+
if (!metadata) return void 0;
|
|
57
|
+
try {
|
|
58
|
+
const balance = await client.readContract({
|
|
59
|
+
address: metadata.token,
|
|
60
|
+
abi: ERC20_BALANCE_OF_ABI,
|
|
61
|
+
functionName: "balanceOf",
|
|
62
|
+
args: [announcement.stealthAddress]
|
|
63
|
+
});
|
|
64
|
+
return { token: metadata.token, balance };
|
|
65
|
+
} catch {
|
|
66
|
+
console.warn(
|
|
67
|
+
"[stealth] balanceOf failed for",
|
|
68
|
+
announcement.stealthAddress,
|
|
69
|
+
"- keeping the payment in the list"
|
|
70
|
+
);
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function scanAnnouncements(announcements, spendingPrivKey, viewingPrivKey, client, factories, chainId) {
|
|
75
|
+
const candidates = typeof factories === "string" || factories === void 0 ? [factories] : factories;
|
|
76
|
+
const payments = [];
|
|
77
|
+
for (const announcement of announcements) {
|
|
78
|
+
if (!checkViewTag(announcement, viewingPrivKey)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
let payment = null;
|
|
82
|
+
for (const factory of candidates) {
|
|
83
|
+
payment = await canSpendFromAddress(
|
|
84
|
+
announcement,
|
|
85
|
+
spendingPrivKey,
|
|
86
|
+
viewingPrivKey,
|
|
87
|
+
client,
|
|
88
|
+
factory,
|
|
89
|
+
chainId
|
|
90
|
+
);
|
|
91
|
+
if (payment) break;
|
|
92
|
+
}
|
|
93
|
+
if (!payment) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const settled = await readSettledBalance(announcement, client);
|
|
97
|
+
if (settled?.balance === 0n) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
payments.push(
|
|
101
|
+
settled === void 0 ? payment : { ...payment, tokenAddress: settled.token, amount: settled.balance.toString() }
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return payments;
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
canSpendFromAddress,
|
|
108
|
+
computeCounterfactualAddress,
|
|
109
|
+
scanAnnouncements
|
|
110
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getTokenInfoForChain } from "@xochi/client";
|
|
2
|
+
const SETTLING_DELIVERED_MS = 3e4;
|
|
3
|
+
const SUBSTATUS_FILLED = "filled";
|
|
4
|
+
function isDeliveredWhileSettling(input) {
|
|
5
|
+
const delivered = input.hasSettlementReceipt || input.substatus === SUBSTATUS_FILLED;
|
|
6
|
+
return input.status === "settling" && delivered && input.elapsedMs >= (input.thresholdMs ?? SETTLING_DELIVERED_MS);
|
|
7
|
+
}
|
|
8
|
+
function buildFailureRef(input) {
|
|
9
|
+
return { ...input, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
10
|
+
}
|
|
11
|
+
function formatFailureRef(ref) {
|
|
12
|
+
return [
|
|
13
|
+
"Xochi swap issue",
|
|
14
|
+
`time: ${ref.timestamp}`,
|
|
15
|
+
`intent: ${ref.intentId ?? "-"}`,
|
|
16
|
+
`quote: ${ref.quoteId ?? "-"}`,
|
|
17
|
+
`route: ${ref.fromChainId} ${ref.fromToken} -> ${ref.toChainId} ${ref.toToken}`,
|
|
18
|
+
`amount: ${ref.fromAmount}`,
|
|
19
|
+
`status: ${ref.status}`,
|
|
20
|
+
`reason: ${ref.reason}`,
|
|
21
|
+
ref.wallet ? `wallet: ${ref.wallet}` : "",
|
|
22
|
+
`version: ${ref.appVersion}`
|
|
23
|
+
].filter(Boolean).join("\n");
|
|
24
|
+
}
|
|
25
|
+
function buildHistoryFailureRef(item, wallet, appVersion) {
|
|
26
|
+
return buildFailureRef({
|
|
27
|
+
intentId: item.id,
|
|
28
|
+
quoteId: null,
|
|
29
|
+
status: item.intentStatus,
|
|
30
|
+
reason: `history_${item.intentStatus}`,
|
|
31
|
+
fromChainId: item.data.fromChainId,
|
|
32
|
+
toChainId: item.data.toChainId,
|
|
33
|
+
fromToken: getTokenInfoForChain(item.data.fromToken, item.data.fromChainId)?.symbol ?? item.data.fromToken,
|
|
34
|
+
toToken: getTokenInfoForChain(item.data.toToken, item.data.toChainId)?.symbol ?? item.data.toToken,
|
|
35
|
+
fromAmount: item.data.fromAmount,
|
|
36
|
+
wallet,
|
|
37
|
+
appVersion
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function supportMailto(ref) {
|
|
41
|
+
const subject = encodeURIComponent(`Xochi swap issue (${ref.intentId ?? "no-id"})`);
|
|
42
|
+
const body = encodeURIComponent(formatFailureRef(ref));
|
|
43
|
+
return `mailto:hello@xochi.fi?subject=${subject}&body=${body}`;
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
SETTLING_DELIVERED_MS,
|
|
47
|
+
buildFailureRef,
|
|
48
|
+
buildHistoryFailureRef,
|
|
49
|
+
formatFailureRef,
|
|
50
|
+
isDeliveredWhileSettling,
|
|
51
|
+
supportMailto
|
|
52
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isAwaitingRecipient } from "./recipientReceipt.js";
|
|
2
|
+
import { truncateAddress } from "../utils/format.js";
|
|
3
|
+
const CROSS_CHAIN_HINT = "Cross-chain settlement usually takes 30-60s.";
|
|
4
|
+
const SLOW_THRESHOLD_MS = 9e4;
|
|
5
|
+
const REASSURANCE = "This is taking longer than usual. The funds are safe.";
|
|
6
|
+
const STUCK_THRESHOLD_MS = 6e5;
|
|
7
|
+
const STUCK = "Still settling. The funds are safe. If it does not clear soon, email hello@xochi.fi.";
|
|
8
|
+
const DELIVERED_STUCK_THRESHOLD_MS = 36e5;
|
|
9
|
+
const DELIVERED_STUCK = "Funds arrived. The last step is taking longer than usual. If it has not cleared soon, email hello@xochi.fi.";
|
|
10
|
+
const AWAITING_RECIPIENT = "Shielded payout sent. Waiting for the recipient to confirm receipt.";
|
|
11
|
+
const IN_FLIGHT = /* @__PURE__ */ new Set([
|
|
12
|
+
"awaiting_deposit",
|
|
13
|
+
"executing",
|
|
14
|
+
"bridging",
|
|
15
|
+
"settling"
|
|
16
|
+
]);
|
|
17
|
+
function describeSwapState(status, input = {}) {
|
|
18
|
+
const { isCrossChain, destChainName, elapsedMs, amount, refundReason } = input;
|
|
19
|
+
const dest = destChainName ?? "the destination chain";
|
|
20
|
+
const inFlight = IN_FLIGHT.has(status);
|
|
21
|
+
const elapsed = elapsedMs ?? 0;
|
|
22
|
+
const settled = input.hasSettlementReceipt === true || input.substatus === "filled";
|
|
23
|
+
const stuck = inFlight && !settled && elapsed >= STUCK_THRESHOLD_MS;
|
|
24
|
+
const slow = inFlight && !settled && elapsed >= SLOW_THRESHOLD_MS;
|
|
25
|
+
const deliveredStuck = inFlight && settled && elapsed >= DELIVERED_STUCK_THRESHOLD_MS;
|
|
26
|
+
const crossChainNote = stuck ? STUCK : deliveredStuck ? DELIVERED_STUCK : slow ? REASSURANCE : isCrossChain ? CROSS_CHAIN_HINT : void 0;
|
|
27
|
+
switch (status) {
|
|
28
|
+
case "awaiting_deposit":
|
|
29
|
+
return { tone: "progress", headline: "Waiting for the deposit", detail: crossChainNote };
|
|
30
|
+
case "executing":
|
|
31
|
+
return { tone: "progress", headline: "Payment received -- settling", detail: crossChainNote };
|
|
32
|
+
case "bridging":
|
|
33
|
+
return { tone: "progress", headline: `Bridging to ${dest}`, detail: crossChainNote };
|
|
34
|
+
case "settling":
|
|
35
|
+
if (isAwaitingRecipient(status, input.substatus)) {
|
|
36
|
+
return { tone: "progress", headline: AWAITING_RECIPIENT };
|
|
37
|
+
}
|
|
38
|
+
return { tone: "progress", headline: `Settling on ${dest}`, detail: crossChainNote };
|
|
39
|
+
case "completed":
|
|
40
|
+
return { tone: "success", headline: "Complete" };
|
|
41
|
+
case "refunded": {
|
|
42
|
+
const target = input.refundAddress ? truncateAddress(input.refundAddress) : input.depositRoute ? null : "the sending wallet";
|
|
43
|
+
return {
|
|
44
|
+
tone: "refund",
|
|
45
|
+
headline: amount ? `Refunded -- ${amount}${target ? ` returned to ${target}` : ""}` : `Refunded${target ? ` to ${target}` : ""}`,
|
|
46
|
+
detail: target ? refundReason ?? void 0 : `${refundReason ? `${refundReason} ` : ""}If you sent from an exchange, contact it if the refund is not credited.`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case "failed":
|
|
50
|
+
return { tone: "error", headline: "Swap failed" };
|
|
51
|
+
case "expired":
|
|
52
|
+
return { tone: "neutral", headline: "Quote expired before it was signed" };
|
|
53
|
+
default:
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
describeSwapState
|
|
59
|
+
};
|