@xochi/widget 0.0.0-stage → 0.1.0
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 +76 -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 +66 -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 +398 -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 +207 -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 +323 -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 +435 -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 +131 -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 +200 -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 +971 -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 +17448 -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 +44 -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 +138 -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 +34 -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 +66 -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 +156 -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 +84 -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 +48 -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 +142 -0
- package/dist/types/widgetLibModule.d.ts +8 -0
- package/dist/utils/format.js +109 -0
- package/dist/wagmi.js +188 -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,511 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { useSwitchChain } from "wagmi";
|
|
3
|
+
import { useToast } from "../../components/Toast.js";
|
|
4
|
+
import { GLYPH } from "../../lib/glyphs.js";
|
|
5
|
+
import { formatTokenAmount } from "../../utils/format.js";
|
|
6
|
+
import { presetAmountText } from "./useSwapAmount.js";
|
|
7
|
+
import { UI } from "../../constants.js";
|
|
8
|
+
import { getTokenInfoForChain, verifyStoredDeposit, NOT_EXECUTED_SUBSTATUS, isChainId, EXTENDED_CHAIN_NAMES, MAX_PRICE_IMPACT_PERCENT, getStatusLabel } from "@xochi/client";
|
|
9
|
+
import { findTokenBySymbol } from "./config.js";
|
|
10
|
+
import { rememberRecipient } from "../../lib/recipient/recent.js";
|
|
11
|
+
import { rememberSendIntent } from "../send/sendRetry.js";
|
|
12
|
+
import { planResume, shouldCaptureToActivity } from "./resumeSwap.js";
|
|
13
|
+
import { findResumableSwap, upsertLocalSwap, toActivityStatus, dismissResumableSwap } from "../../lib/localActivity.js";
|
|
14
|
+
import { DEPOSIT_ATTESTATION_PIN } from "../../config.js";
|
|
15
|
+
import { normalizeZkMoneyTag, zkMoneyTagValid } from "./zkMoney.js";
|
|
16
|
+
const SETTLEMENT_FIX_BUTTON = {
|
|
17
|
+
wallet: "Connect wallet",
|
|
18
|
+
setup: "Set up Stealth",
|
|
19
|
+
quote: "Updating quote...",
|
|
20
|
+
destination: "Choose a Stealth destination",
|
|
21
|
+
route: "Choose another privacy mode",
|
|
22
|
+
unavailable: "Choose an available privacy mode",
|
|
23
|
+
route_loading: "Loading routes",
|
|
24
|
+
route_unavailable: "Retry route data",
|
|
25
|
+
public_only: "Use Public for Canton"
|
|
26
|
+
};
|
|
27
|
+
const CAPTURED_STATUSES = /* @__PURE__ */ new Set([
|
|
28
|
+
"awaiting_deposit",
|
|
29
|
+
"executing",
|
|
30
|
+
"bridging",
|
|
31
|
+
"settling",
|
|
32
|
+
"completed",
|
|
33
|
+
"refunded",
|
|
34
|
+
"failed"
|
|
35
|
+
]);
|
|
36
|
+
function useSwapFlow({
|
|
37
|
+
prefill,
|
|
38
|
+
sendRecipient,
|
|
39
|
+
intent,
|
|
40
|
+
isConnected,
|
|
41
|
+
address,
|
|
42
|
+
connectedChainId,
|
|
43
|
+
fromChainId,
|
|
44
|
+
toChainId,
|
|
45
|
+
fromToken,
|
|
46
|
+
toToken,
|
|
47
|
+
routeCheck,
|
|
48
|
+
applyRoute,
|
|
49
|
+
amount,
|
|
50
|
+
amountBigInt,
|
|
51
|
+
insufficientBalance,
|
|
52
|
+
currentBalance,
|
|
53
|
+
excessiveSlippage,
|
|
54
|
+
orderOutOfBounds,
|
|
55
|
+
setAmount,
|
|
56
|
+
settlement,
|
|
57
|
+
settlementFix,
|
|
58
|
+
destination,
|
|
59
|
+
swapRecipientLabel,
|
|
60
|
+
swapRecipient,
|
|
61
|
+
swapRecipientRetryInput,
|
|
62
|
+
restoreSwapRecipient,
|
|
63
|
+
recipientMissing,
|
|
64
|
+
recipientInvalid,
|
|
65
|
+
restoreSettlement,
|
|
66
|
+
clearRecipient,
|
|
67
|
+
restoreRecipientTag,
|
|
68
|
+
restoreRefundAddress,
|
|
69
|
+
stealthPayee,
|
|
70
|
+
restoreStealthRecipient,
|
|
71
|
+
flowOpen,
|
|
72
|
+
setFlowOpen,
|
|
73
|
+
resumed,
|
|
74
|
+
setResumed
|
|
75
|
+
}) {
|
|
76
|
+
const { showToast } = useToast();
|
|
77
|
+
const { switchChainAsync } = useSwitchChain();
|
|
78
|
+
const [executionStartTime, setExecutionStartTime] = useState(null);
|
|
79
|
+
const [executedDestination, setExecutedDestination] = useState(null);
|
|
80
|
+
const [executedPayee, setExecutedPayee] = useState(null);
|
|
81
|
+
const isResumedIntent = resumed !== null && resumed.intentId === intent.intentId;
|
|
82
|
+
const sendRecipientDisplay = sendRecipient && prefill?.fromSend ? prefill.sendRecipientDisplay : void 0;
|
|
83
|
+
const quotedDestination = {
|
|
84
|
+
...destination,
|
|
85
|
+
recipientTag: intent.quote ? intent.quote.recipientTag : destination.recipientTag,
|
|
86
|
+
...sendRecipientDisplay && { sendRecipientDisplay, sendRecipient },
|
|
87
|
+
...swapRecipientLabel && { swapRecipientLabel, swapRecipientRetryInput, swapRecipient }
|
|
88
|
+
};
|
|
89
|
+
const resumedDeposit = isResumedIntent ? resumed.deposit : null;
|
|
90
|
+
const resumedDestination = isResumedIntent ? resumed.destination : null;
|
|
91
|
+
const appliedPrefillNonce = useRef(null);
|
|
92
|
+
const routeBeforeSend = useRef(null);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!prefill || prefill.nonce === appliedPrefillNonce.current) return;
|
|
95
|
+
appliedPrefillNonce.current = prefill.nonce;
|
|
96
|
+
const fromInfo = getTokenInfoForChain(prefill.fromToken, prefill.fromChainId);
|
|
97
|
+
const toInfo = getTokenInfoForChain(prefill.toToken, prefill.toChainId);
|
|
98
|
+
const nextFromToken = fromInfo ? findTokenBySymbol(prefill.fromChainId, fromInfo.symbol) : void 0;
|
|
99
|
+
const nextToToken = toInfo ? findTokenBySymbol(prefill.toChainId, toInfo.symbol) : void 0;
|
|
100
|
+
if (!nextFromToken || !nextToToken) {
|
|
101
|
+
showToast("Couldn't reload that trade. Set it up again.", "error");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const recipientTag = typeof prefill.recipientTag === "string" ? normalizeZkMoneyTag(prefill.recipientTag) : void 0;
|
|
105
|
+
if (prefill.recipientTag !== void 0 && (recipientTag === void 0 || !zkMoneyTagValid(recipientTag) || prefill.toChainId !== 1 || nextToToken.symbol !== "DAI" || prefill.settlement !== void 0 && prefill.settlement !== "public")) {
|
|
106
|
+
showToast("Couldn't reload that trade. Set it up again.", "error");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (prefill.stealthPayee === "other" && prefill.stealthRecipient === void 0 && !prefill.swapRecipientRetry) {
|
|
110
|
+
showToast("That send paid someone else's stealth keys. Start it again from Send.", "error");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (prefill.stealthRecipient !== void 0 && prefill.settlement !== "stealth") {
|
|
114
|
+
showToast("Couldn't reload that trade. Set it up again.", "error");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
routeBeforeSend.current = prefill.fromSend ? routeBeforeSend.current ?? { fromChainId, toChainId, fromToken, toToken } : null;
|
|
118
|
+
intent.reset();
|
|
119
|
+
restoreSettlement(
|
|
120
|
+
prefill.settlement === "stealth" ? "stealth" : prefill.settlement === "shielded" ? "shielded" : "public"
|
|
121
|
+
);
|
|
122
|
+
clearRecipient();
|
|
123
|
+
restoreSwapRecipient?.(prefill.swapRecipientRetry);
|
|
124
|
+
restoreStealthRecipient(prefill.stealthRecipient ?? null);
|
|
125
|
+
restoreRecipientTag(recipientTag ?? "");
|
|
126
|
+
restoreRefundAddress(prefill.refundAddress ?? "");
|
|
127
|
+
applyRoute({
|
|
128
|
+
fromChainId: prefill.fromChainId,
|
|
129
|
+
toChainId: prefill.toChainId,
|
|
130
|
+
fromToken: nextFromToken,
|
|
131
|
+
toToken: nextToToken,
|
|
132
|
+
zkMoneyDestination: recipientTag !== void 0 || prefill.swapRecipientRetry?.zkMoneyDestination === true
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
setAmount(
|
|
136
|
+
formatTokenAmount(
|
|
137
|
+
BigInt(prefill.fromAmount),
|
|
138
|
+
nextFromToken.decimals,
|
|
139
|
+
nextFromToken.decimals
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
} catch {
|
|
143
|
+
setAmount("");
|
|
144
|
+
}
|
|
145
|
+
}, [prefill, showToast]);
|
|
146
|
+
const resumedForAddress = useRef(null);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (!address || resumedForAddress.current === address) return;
|
|
149
|
+
if (flowOpen || intent.status !== "idle") return;
|
|
150
|
+
const record = findResumableSwap(address);
|
|
151
|
+
const plan = planResume(record);
|
|
152
|
+
if (!plan) return;
|
|
153
|
+
const display = record?.data;
|
|
154
|
+
const send = display?.sendRecipientDisplay;
|
|
155
|
+
const swapLabel = display?.swapRecipientLabel;
|
|
156
|
+
resumedForAddress.current = address;
|
|
157
|
+
applyRoute({
|
|
158
|
+
fromChainId: plan.fromChainId,
|
|
159
|
+
toChainId: plan.toChainId,
|
|
160
|
+
fromToken: plan.fromToken,
|
|
161
|
+
toToken: plan.toToken,
|
|
162
|
+
zkMoneyDestination: plan.destination.recipientTag !== void 0
|
|
163
|
+
});
|
|
164
|
+
setAmount(plan.amount);
|
|
165
|
+
const destination2 = {
|
|
166
|
+
...plan.destination,
|
|
167
|
+
sendRecipientDisplay: (send?.mode === "Stealth" || send?.mode === "Shielded") && typeof send.label === "string" && send.label.length <= 255 ? send : void 0,
|
|
168
|
+
swapRecipientLabel: typeof swapLabel === "string" && swapLabel.length <= 255 ? swapLabel : void 0
|
|
169
|
+
};
|
|
170
|
+
setResumed({
|
|
171
|
+
intentId: plan.intentId,
|
|
172
|
+
toAmount: plan.toAmount,
|
|
173
|
+
deposit: null,
|
|
174
|
+
destination: destination2,
|
|
175
|
+
stealthPayee: plan.stealthPayee
|
|
176
|
+
});
|
|
177
|
+
setExecutionStartTime(plan.startedAt);
|
|
178
|
+
const adopt = (deposit) => {
|
|
179
|
+
intent.resume(
|
|
180
|
+
plan.intentId,
|
|
181
|
+
plan.status,
|
|
182
|
+
address,
|
|
183
|
+
deposit?.attested.deposit_deadline ?? null
|
|
184
|
+
);
|
|
185
|
+
if (deposit) {
|
|
186
|
+
setResumed(
|
|
187
|
+
(prev) => prev && prev.intentId === plan.intentId ? { ...prev, deposit } : prev
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
setFlowOpen(true);
|
|
191
|
+
};
|
|
192
|
+
Promise.resolve().then(
|
|
193
|
+
() => verifyStoredDeposit(plan.deposit, DEPOSIT_ATTESTATION_PIN.signer || null, {
|
|
194
|
+
intentId: plan.intentId,
|
|
195
|
+
owner: address
|
|
196
|
+
})
|
|
197
|
+
).then((result) => {
|
|
198
|
+
if (result.ok) {
|
|
199
|
+
adopt(result.stored);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (plan.deposit) {
|
|
203
|
+
console.error(
|
|
204
|
+
"[useSwapFlow] Refusing a stored deposit binding that does not verify; resuming without a deposit address.",
|
|
205
|
+
{ intentId: plan.intentId, kind: result.kind, reason: result.reason }
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
adopt(null);
|
|
209
|
+
});
|
|
210
|
+
}, [address, flowOpen, intent.status]);
|
|
211
|
+
const recentSwapId = useRef(null);
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
const owner = intent.quotedAddress ?? address;
|
|
214
|
+
if (!shouldCaptureToActivity({
|
|
215
|
+
hasOwner: Boolean(owner),
|
|
216
|
+
hasIntentId: Boolean(intent.intentId),
|
|
217
|
+
isCapturedStatus: CAPTURED_STATUSES.has(intent.status),
|
|
218
|
+
isResumedIntent
|
|
219
|
+
})) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (!owner || !intent.intentId) return;
|
|
223
|
+
if (intent.intentId && executedDestination?.sendRecipientDisplay) {
|
|
224
|
+
rememberSendIntent(intent.intentId, executedDestination.sendRecipientDisplay);
|
|
225
|
+
if (intent.status === "completed" && executedDestination.sendRecipient) {
|
|
226
|
+
rememberRecipient(executedDestination.sendRecipient);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (executedDestination?.swapRecipient && recentSwapId.current !== intent.intentId && (intent.status !== "failed" || intent.receipt.phase === "may-have-moved")) {
|
|
230
|
+
recentSwapId.current = intent.intentId;
|
|
231
|
+
rememberRecipient(executedDestination.swapRecipient);
|
|
232
|
+
}
|
|
233
|
+
upsertLocalSwap(owner, {
|
|
234
|
+
id: intent.intentId,
|
|
235
|
+
type: "swap",
|
|
236
|
+
timestamp: Date.now(),
|
|
237
|
+
status: toActivityStatus(intent.status),
|
|
238
|
+
intentStatus: intent.status,
|
|
239
|
+
// Null (no status read of this intent yet) writes nothing: a capture write
|
|
240
|
+
// must not clear a withheld verdict the feed's own poll stored.
|
|
241
|
+
...intent.legsWithheld === null ? {} : { legsWithheld: intent.legsWithheld },
|
|
242
|
+
data: {
|
|
243
|
+
fromChainId,
|
|
244
|
+
toChainId,
|
|
245
|
+
fromToken: fromToken.address,
|
|
246
|
+
toToken: toToken.address,
|
|
247
|
+
fromAmount: amountBigInt.toString(),
|
|
248
|
+
toAmount: intent.quote?.toAmount ?? null,
|
|
249
|
+
tier: intent.tierName,
|
|
250
|
+
feeRate: intent.quote?.xochiFeeRate ? parseFloat(intent.quote.xochiFeeRate) : 0,
|
|
251
|
+
txHash: intent.txHash,
|
|
252
|
+
receivingTxHash: intent.receivingTxHash,
|
|
253
|
+
settlementTxHash: intent.settlementTxHash,
|
|
254
|
+
settlementChainId: intent.settlementChainId,
|
|
255
|
+
// The machine keeps a failure's verdict, not its substatus. A `failed` it
|
|
256
|
+
// does not end on `may-have-moved` is one the Worker marked `not_executed`
|
|
257
|
+
// or one that was never sent: nothing moved, so the feed may retry it.
|
|
258
|
+
substatus: intent.status === "failed" ? intent.receipt.phase === "may-have-moved" ? null : NOT_EXECUTED_SUBSTATUS : intent.substatus,
|
|
259
|
+
// The dispatched order's own mode (bound at confirm), never the live
|
|
260
|
+
// toggle: this effect re-runs on later status/tx-hash transitions, and
|
|
261
|
+
// the toggle can change in between (close the flow, tap Public, or
|
|
262
|
+
// change the route).
|
|
263
|
+
// Re-capturing with the live value would strip a completed stealth
|
|
264
|
+
// row's "Go to claims" action, or fabricate one on a public row. The
|
|
265
|
+
// live value is only the fallback for a capture no confirm preceded.
|
|
266
|
+
settlementType: executedDestination ? executedDestination.type === "stealth" ? "stealth" : "public" : settlement,
|
|
267
|
+
recipientTag: executedDestination?.recipientTag ?? intent.quote?.recipientTag,
|
|
268
|
+
...{
|
|
269
|
+
sendRecipientDisplay: executedDestination?.sendRecipientDisplay,
|
|
270
|
+
swapRecipientLabel: executedDestination?.swapRecipientLabel,
|
|
271
|
+
swapRecipientRetryInput: executedDestination?.swapRecipientRetryInput
|
|
272
|
+
},
|
|
273
|
+
// The marker only, never the keys (see SwapActivity.stealthPayee).
|
|
274
|
+
...(executedDestination ? executedPayee : stealthPayee) === "other" && {
|
|
275
|
+
stealthPayee: "other"
|
|
276
|
+
},
|
|
277
|
+
isCrossChain: fromChainId !== toChainId,
|
|
278
|
+
// The VERIFIED deposit binding, stored verbatim, so a resumed swap gets
|
|
279
|
+
// a usable screen back rather than a modal with no address on it.
|
|
280
|
+
//
|
|
281
|
+
// Not a set of loose display fields: localStorage is same-origin
|
|
282
|
+
// mutable state, so whatever is written here has to be re-provable on
|
|
283
|
+
// the way back out, and only the signed fields plus their signature
|
|
284
|
+
// are. `verifyStoredDeposit` is what does that proving.
|
|
285
|
+
//
|
|
286
|
+
// Written only while the quote is still in hand. Once the panel is
|
|
287
|
+
// resumed there IS no quote, and `shouldCaptureToActivity` refuses the
|
|
288
|
+
// write entirely for that case, so this cannot blank an existing block.
|
|
289
|
+
deposit: intent.attestedDeposit
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}, [
|
|
293
|
+
intent.quotedAddress,
|
|
294
|
+
address,
|
|
295
|
+
isResumedIntent,
|
|
296
|
+
intent.intentId,
|
|
297
|
+
intent.status,
|
|
298
|
+
intent.legsWithheld,
|
|
299
|
+
intent.txHash,
|
|
300
|
+
intent.receivingTxHash,
|
|
301
|
+
intent.settlementTxHash,
|
|
302
|
+
intent.settlementChainId
|
|
303
|
+
]);
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
if (flowOpen) setFlowOpen(false);
|
|
306
|
+
}, [address, connectedChainId]);
|
|
307
|
+
const wrongChain = isConnected && isChainId(fromChainId) && connectedChainId !== fromChainId;
|
|
308
|
+
const needsChainSwitch = wrongChain && (settlementFix === "setup" || intent.canSign && !insufficientBalance && !excessiveSlippage);
|
|
309
|
+
const flowReopenable = !flowOpen && (intent.status === "executing" || intent.status === "bridging" || intent.status === "settling" || intent.status === "awaiting_deposit" || intent.receipt.phase === "may-have-moved");
|
|
310
|
+
const quoteStale = intent.quotedFromAmount !== null && intent.quotedFromAmount !== amountBigInt.toString();
|
|
311
|
+
const hasCurrentSettlementAuthority = routeCheck.status === "supported" && settlementFix === null && !recipientInvalid;
|
|
312
|
+
const invalidateHeldQuote = useCallback(() => {
|
|
313
|
+
let cancellable = intent.status === "pending" || intent.status === "quoting" || intent.status === "quoted";
|
|
314
|
+
if (intent.status === "signing") cancellable = intent.cancelSign();
|
|
315
|
+
if (!cancellable) return false;
|
|
316
|
+
intent.reset();
|
|
317
|
+
setFlowOpen(false);
|
|
318
|
+
setExecutionStartTime(null);
|
|
319
|
+
setExecutedDestination(null);
|
|
320
|
+
setExecutedPayee(null);
|
|
321
|
+
return true;
|
|
322
|
+
}, [intent.status, intent.cancelSign, intent.reset, setFlowOpen]);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (flowOpen && (!hasCurrentSettlementAuthority || quoteStale)) invalidateHeldQuote();
|
|
325
|
+
}, [flowOpen, hasCurrentSettlementAuthority, quoteStale, invalidateHeldQuote]);
|
|
326
|
+
const handleMarketSubmit = useCallback(async () => {
|
|
327
|
+
if (flowReopenable) {
|
|
328
|
+
setFlowOpen(true);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (!isConnected) {
|
|
332
|
+
showToast(UI.CONNECT_PROMPT, "error");
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (settlementFix !== null && !(settlementFix === "setup" && needsChainSwitch)) return;
|
|
336
|
+
if (needsChainSwitch && isChainId(fromChainId)) {
|
|
337
|
+
try {
|
|
338
|
+
await switchChainAsync({ chainId: fromChainId });
|
|
339
|
+
} catch {
|
|
340
|
+
showToast(`Switch the wallet to ${EXTENDED_CHAIN_NAMES[fromChainId]} to continue`, "error");
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!hasCurrentSettlementAuthority) {
|
|
345
|
+
invalidateHeldQuote();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (intent.canAllocateDepositRoute) {
|
|
349
|
+
if (insufficientBalance) {
|
|
350
|
+
showToast(`Not enough ${fromToken.symbol} to cover this swap`, "error");
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (excessiveSlippage) {
|
|
354
|
+
showToast(
|
|
355
|
+
`This trade would lose over ${MAX_PRICE_IMPACT_PERCENT}% to fees and price. Increase the amount.`,
|
|
356
|
+
"error"
|
|
357
|
+
);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
setExecutedDestination(quotedDestination);
|
|
361
|
+
setExecutedPayee(stealthPayee);
|
|
362
|
+
if (await intent.allocateDepositRoute()) {
|
|
363
|
+
setFlowOpen(true);
|
|
364
|
+
} else {
|
|
365
|
+
setExecutedDestination(null);
|
|
366
|
+
setExecutedPayee(null);
|
|
367
|
+
}
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (!intent.canSign) {
|
|
371
|
+
showToast("Get a quote first", "error");
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (quoteStale) {
|
|
375
|
+
showToast("Updating the quote for the new amount", "info");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (insufficientBalance) {
|
|
379
|
+
showToast(`Not enough ${fromToken.symbol} to cover this swap`, "error");
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (excessiveSlippage) {
|
|
383
|
+
showToast(
|
|
384
|
+
`This trade would lose over ${MAX_PRICE_IMPACT_PERCENT}% to fees and price. Increase the amount.`,
|
|
385
|
+
"error"
|
|
386
|
+
);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
setFlowOpen(true);
|
|
390
|
+
}, [
|
|
391
|
+
isConnected,
|
|
392
|
+
flowReopenable,
|
|
393
|
+
needsChainSwitch,
|
|
394
|
+
fromChainId,
|
|
395
|
+
switchChainAsync,
|
|
396
|
+
intent.canSign,
|
|
397
|
+
quoteStale,
|
|
398
|
+
quotedDestination,
|
|
399
|
+
stealthPayee,
|
|
400
|
+
intent.canAllocateDepositRoute,
|
|
401
|
+
intent.allocateDepositRoute,
|
|
402
|
+
insufficientBalance,
|
|
403
|
+
fromToken.symbol,
|
|
404
|
+
excessiveSlippage,
|
|
405
|
+
settlementFix,
|
|
406
|
+
hasCurrentSettlementAuthority,
|
|
407
|
+
invalidateHeldQuote,
|
|
408
|
+
showToast,
|
|
409
|
+
setFlowOpen
|
|
410
|
+
]);
|
|
411
|
+
useEffect(() => {
|
|
412
|
+
const previousRoute = routeBeforeSend.current;
|
|
413
|
+
if (previousRoute && prefill == null) {
|
|
414
|
+
const cancelled = invalidateHeldQuote();
|
|
415
|
+
if (executedDestination && !cancelled) return;
|
|
416
|
+
routeBeforeSend.current = null;
|
|
417
|
+
restoreSettlement("public");
|
|
418
|
+
clearRecipient();
|
|
419
|
+
restoreSwapRecipient?.(void 0);
|
|
420
|
+
restoreStealthRecipient(null);
|
|
421
|
+
restoreRecipientTag("");
|
|
422
|
+
applyRoute(previousRoute);
|
|
423
|
+
setAmount("");
|
|
424
|
+
}
|
|
425
|
+
}, [
|
|
426
|
+
prefill,
|
|
427
|
+
invalidateHeldQuote,
|
|
428
|
+
executedDestination,
|
|
429
|
+
restoreSettlement,
|
|
430
|
+
clearRecipient,
|
|
431
|
+
restoreSwapRecipient,
|
|
432
|
+
restoreStealthRecipient,
|
|
433
|
+
restoreRecipientTag,
|
|
434
|
+
applyRoute,
|
|
435
|
+
setAmount
|
|
436
|
+
]);
|
|
437
|
+
const handleConfirmSwap = useCallback(() => {
|
|
438
|
+
if (!hasCurrentSettlementAuthority || !intent.canSign || quoteStale) {
|
|
439
|
+
invalidateHeldQuote();
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
setExecutionStartTime(Date.now());
|
|
443
|
+
setExecutedDestination(quotedDestination);
|
|
444
|
+
setExecutedPayee(stealthPayee);
|
|
445
|
+
intent.sign();
|
|
446
|
+
}, [
|
|
447
|
+
hasCurrentSettlementAuthority,
|
|
448
|
+
intent.canSign,
|
|
449
|
+
quoteStale,
|
|
450
|
+
intent.sign,
|
|
451
|
+
invalidateHeldQuote,
|
|
452
|
+
quotedDestination,
|
|
453
|
+
stealthPayee
|
|
454
|
+
]);
|
|
455
|
+
const handleCancelSign = useCallback(() => {
|
|
456
|
+
if (!intent.cancelSign()) return;
|
|
457
|
+
setExecutionStartTime(null);
|
|
458
|
+
setExecutedDestination(null);
|
|
459
|
+
setExecutedPayee(null);
|
|
460
|
+
}, [intent]);
|
|
461
|
+
const handleCloseFlow = useCallback(() => {
|
|
462
|
+
setFlowOpen(false);
|
|
463
|
+
const owner = intent.quotedAddress ?? address;
|
|
464
|
+
if (intent.intentId) dismissResumableSwap(owner, intent.intentId, intent.status);
|
|
465
|
+
const phase = intent.receipt.phase;
|
|
466
|
+
if (phase === "success" || phase === "refunded" || phase === "failed" || phase === "may-have-moved" || phase === "pending") {
|
|
467
|
+
intent.reset();
|
|
468
|
+
setExecutionStartTime(null);
|
|
469
|
+
setExecutedDestination(null);
|
|
470
|
+
setExecutedPayee(null);
|
|
471
|
+
}
|
|
472
|
+
}, [intent, address, setFlowOpen]);
|
|
473
|
+
const handleStartOver = useCallback(() => {
|
|
474
|
+
setFlowOpen(false);
|
|
475
|
+
const owner = intent.quotedAddress ?? address;
|
|
476
|
+
if (intent.intentId) dismissResumableSwap(owner, intent.intentId, intent.status);
|
|
477
|
+
intent.reset();
|
|
478
|
+
setExecutionStartTime(null);
|
|
479
|
+
setExecutedDestination(null);
|
|
480
|
+
setExecutedPayee(null);
|
|
481
|
+
}, [intent, address, setFlowOpen]);
|
|
482
|
+
const useMaxCta = currentBalance !== null && currentBalance > 0n ? {
|
|
483
|
+
label: `Use max (${presetAmountText(currentBalance, fromToken.decimals)} ${fromToken.symbol})`,
|
|
484
|
+
action: "useMax"
|
|
485
|
+
} : null;
|
|
486
|
+
const namedSwapLabel = swapRecipientLabel ? `Swap to ${swapRecipientLabel}` : void 0;
|
|
487
|
+
const ctaChoice = flowReopenable ? "View order progress" : !isConnected ? intent.quote?.preview && intent.quote.canSolve ? "Connect wallet to continue" : UI.CONNECT_WALLET : intent.isLoading ? getStatusLabel(intent.status) : routeCheck.status === "unsupported" ? "Route not supported" : orderOutOfBounds ? "Adjust amount" : settlementFix !== null ? settlementFix === "setup" && needsChainSwitch ? `Switch to ${EXTENDED_CHAIN_NAMES[fromChainId]}` : SETTLEMENT_FIX_BUTTON[settlementFix] : recipientMissing ? destination.recipientTag !== void 0 ? "Add a zk.money tag" : "Add recipient address" : recipientInvalid ? destination.recipientTag !== void 0 ? "Check the tag" : "Check recipient address" : !amount || amountBigInt === 0n ? "Enter amount" : insufficientBalance ? useMaxCta ?? (currentBalance === null ? "Balance not loaded" : "Insufficient balance") : excessiveSlippage ? "Amount too small" : needsChainSwitch ? `Switch to ${EXTENDED_CHAIN_NAMES[fromChainId]}` : intent.canAllocateDepositRoute ? intent.error ? "Try reserving route again" : namedSwapLabel ?? "Review & reserve route" : intent.error ? "Quote failed" : intent.canSign ? quoteStale ? "Updating quote..." : sendRecipientDisplay ? `Send ${formatTokenAmount(amountBigInt, fromToken.decimals, fromToken.decimals)} ${fromToken.symbol} with ${sendRecipientDisplay.mode}` : namedSwapLabel ?? (fromChainId !== toChainId && fromToken.symbol === toToken.symbol ? `Bridge ${fromToken.symbol}` : `Swap ${fromToken.symbol} ${GLYPH.flow} ${toToken.symbol}`) : "Getting quote...";
|
|
488
|
+
const cta = typeof ctaChoice === "string" ? { label: ctaChoice, action: "submit" } : ctaChoice;
|
|
489
|
+
return {
|
|
490
|
+
handleMarketSubmit,
|
|
491
|
+
cta,
|
|
492
|
+
quoteStale,
|
|
493
|
+
handleConfirmSwap,
|
|
494
|
+
handleCancelSign,
|
|
495
|
+
handleCloseFlow,
|
|
496
|
+
handleStartOver,
|
|
497
|
+
flowReopenable,
|
|
498
|
+
// What the flow modal renders: the dispatched order's own destination
|
|
499
|
+
// while one is in flight (bound at confirm, or restored from the record on
|
|
500
|
+
// a resume), the live form's otherwise. Never the live toggle for an
|
|
501
|
+
// executed order (see executedDestination above).
|
|
502
|
+
flowDestination: executedDestination ?? resumedDestination ?? quotedDestination,
|
|
503
|
+
flowStealthPayee: executedPayee ?? (isResumedIntent ? resumed.stealthPayee ?? "self" : null) ?? stealthPayee,
|
|
504
|
+
executionStartTime,
|
|
505
|
+
resumedDeposit,
|
|
506
|
+
needsChainSwitch
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
export {
|
|
510
|
+
useSwapFlow
|
|
511
|
+
};
|