@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,532 @@
|
|
|
1
|
+
import { resolveRouteModel, destinationTokenSymbols, originTokenSymbols, EXTENDED_CHAIN_NAMES, stealthDestinationChains, CANTON_MAINNET_CHAIN_ID, isSelectableChainId, isCantonDestinationChainId } from "@xochi/client";
|
|
2
|
+
import { EMBED_ALLOW_FIELDS, EMBED_LOCKS, EMBED_HEIGHT, parseEmbedHeight, normalizeEmbedCode, EMBED_PATH, encodeEmbedParams } from "@xochi/widget-lib";
|
|
3
|
+
import { TOKENS, chainEnabledForRole, DEFAULT_TO_TOKEN, DEFAULT_FROM_TOKEN, DEFAULT_TO_CHAIN_ID, DEFAULT_CHAIN_ID } from "./config.js";
|
|
4
|
+
import { pickDefaultToken } from "./useSwapRoute.js";
|
|
5
|
+
const FRAME_FIELDS = [
|
|
6
|
+
"fromChainId",
|
|
7
|
+
"toChainId",
|
|
8
|
+
"sellSymbol",
|
|
9
|
+
"buySymbol",
|
|
10
|
+
"amount",
|
|
11
|
+
"settlement",
|
|
12
|
+
"theme",
|
|
13
|
+
"layout",
|
|
14
|
+
"howItWorks",
|
|
15
|
+
"height",
|
|
16
|
+
"locks",
|
|
17
|
+
"fromChains",
|
|
18
|
+
"toChains",
|
|
19
|
+
"sellTokens",
|
|
20
|
+
"buyTokens",
|
|
21
|
+
"ref",
|
|
22
|
+
"promo"
|
|
23
|
+
];
|
|
24
|
+
const CODE_TAKES = "3 to 32 letters, digits, _ or -, starting with a letter or digit";
|
|
25
|
+
function codeProblem(text) {
|
|
26
|
+
return text.trim() === "" || normalizeEmbedCode(text) !== null ? null : `Use ${CODE_TAKES}.`;
|
|
27
|
+
}
|
|
28
|
+
const EMBED_PARAM_HINT = {
|
|
29
|
+
fromChainId: { takes: "a chain id", example: "fromChain=8453" },
|
|
30
|
+
toChainId: { takes: "a chain id", example: "toChain=1" },
|
|
31
|
+
sellSymbol: { takes: "a token symbol", example: "sell=USDC" },
|
|
32
|
+
buySymbol: { takes: "a token symbol", example: "buy=USDC" },
|
|
33
|
+
amount: { takes: "a plain number", example: "amount=250" },
|
|
34
|
+
settlement: { takes: "public or stealth", example: "settlement=public" },
|
|
35
|
+
theme: { takes: "light, dim, contrast or auto", example: "theme=light" },
|
|
36
|
+
layout: { takes: "full or swap", example: "layout=swap" },
|
|
37
|
+
howItWorks: { takes: "0 or 1", example: "howItWorks=0" },
|
|
38
|
+
height: {
|
|
39
|
+
takes: `a whole number of pixels from ${EMBED_HEIGHT.min} to ${EMBED_HEIGHT.max}`,
|
|
40
|
+
example: "height=640"
|
|
41
|
+
},
|
|
42
|
+
locks: { takes: `a comma list of ${EMBED_LOCKS.join(", ")}`, example: "lock=sell" },
|
|
43
|
+
fromChains: { takes: "a comma list of chain ids", example: "fromChains=8453" },
|
|
44
|
+
toChains: { takes: "a comma list of chain ids", example: "toChains=42161" },
|
|
45
|
+
sellTokens: { takes: "a comma list of token symbols", example: "sellTokens=USDC" },
|
|
46
|
+
buyTokens: { takes: "a comma list of token symbols", example: "buyTokens=USDC" },
|
|
47
|
+
ref: { takes: CODE_TAKES, example: "ref=PARTNER" },
|
|
48
|
+
promo: { takes: CODE_TAKES, example: "promo=LAUNCH10" }
|
|
49
|
+
};
|
|
50
|
+
const FRAME_DEFAULTS = {
|
|
51
|
+
fromChainId: DEFAULT_CHAIN_ID,
|
|
52
|
+
toChainId: DEFAULT_TO_CHAIN_ID,
|
|
53
|
+
fromToken: DEFAULT_FROM_TOKEN,
|
|
54
|
+
toToken: DEFAULT_TO_TOKEN,
|
|
55
|
+
amount: "",
|
|
56
|
+
settlement: "public",
|
|
57
|
+
theme: "auto",
|
|
58
|
+
layout: "full",
|
|
59
|
+
howItWorks: true,
|
|
60
|
+
height: null,
|
|
61
|
+
locks: [],
|
|
62
|
+
fromChains: null,
|
|
63
|
+
toChains: null,
|
|
64
|
+
sellTokens: null,
|
|
65
|
+
buyTokens: null,
|
|
66
|
+
ref: null,
|
|
67
|
+
promo: null
|
|
68
|
+
};
|
|
69
|
+
const AMOUNT = /^(\d{1,30})(?:\.(\d{1,30}))?$/;
|
|
70
|
+
function heightProblem(text) {
|
|
71
|
+
const trimmed = text.trim();
|
|
72
|
+
if (trimmed === "" || parseEmbedHeight(trimmed) !== void 0) return null;
|
|
73
|
+
return `Use ${EMBED_PARAM_HINT.height.takes}.`;
|
|
74
|
+
}
|
|
75
|
+
function embedLook(params) {
|
|
76
|
+
return {
|
|
77
|
+
theme: params.theme ?? FRAME_DEFAULTS.theme,
|
|
78
|
+
layout: params.layout ?? FRAME_DEFAULTS.layout,
|
|
79
|
+
howItWorks: params.howItWorks ?? FRAME_DEFAULTS.howItWorks,
|
|
80
|
+
height: params.height ?? FRAME_DEFAULTS.height
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function embedCodes(params) {
|
|
84
|
+
return { ref: params.ref ?? null, promo: params.promo ?? null };
|
|
85
|
+
}
|
|
86
|
+
const FULL_LOOK = embedLook({});
|
|
87
|
+
function amountProblem(amount, token) {
|
|
88
|
+
const match = AMOUNT.exec(amount);
|
|
89
|
+
if (!match) return "Use a plain number, like 250 or 0.5.";
|
|
90
|
+
const fraction = match[2] ?? "";
|
|
91
|
+
if (fraction.length > token.decimals) {
|
|
92
|
+
return `${token.symbol} takes at most ${token.decimals} decimals.`;
|
|
93
|
+
}
|
|
94
|
+
if (!/[1-9]/.test(amount)) return "Use an amount above zero.";
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function embedOffer(capabilities, state) {
|
|
98
|
+
const capabilityState = typeof state === "boolean" ? state ? "live" : "fallback" : state;
|
|
99
|
+
const routeModel = resolveRouteModel(capabilities, capabilityState, {
|
|
100
|
+
chainEnabledForRole,
|
|
101
|
+
presentationTokens: TOKENS
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
sourceChainIds: routeModel.originChainIds,
|
|
105
|
+
destinationChainIds: routeModel.destinationChainIds,
|
|
106
|
+
originSymbols: originTokenSymbols(capabilities),
|
|
107
|
+
destinationSymbols: destinationTokenSymbols(capabilities),
|
|
108
|
+
capabilities,
|
|
109
|
+
live: capabilityState === "live",
|
|
110
|
+
restricted: capabilities.raw.restricted === true,
|
|
111
|
+
routeModel
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function stealthDisplayOffer(full) {
|
|
115
|
+
const inventory = (role) => {
|
|
116
|
+
const advertised = role === "origin" ? full.routeModel.originTokens : full.routeModel.destinationTokens;
|
|
117
|
+
const tokensByChain = new Map(advertised);
|
|
118
|
+
tokensByChain.delete(CANTON_MAINNET_CHAIN_ID);
|
|
119
|
+
for (const tokens of Object.values(TOKENS)) {
|
|
120
|
+
const chainId = tokens[0]?.chainId;
|
|
121
|
+
if (chainId === void 0 || !isSelectableChainId(chainId) || isCantonDestinationChainId(chainId) || !chainEnabledForRole(chainId, role))
|
|
122
|
+
continue;
|
|
123
|
+
const live = advertised.get(chainId) ?? [];
|
|
124
|
+
tokensByChain.set(chainId, [
|
|
125
|
+
...live,
|
|
126
|
+
...tokens.filter((token) => !live.some((candidate) => candidate.symbol === token.symbol))
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
return tokensByChain;
|
|
130
|
+
};
|
|
131
|
+
const originTokens = inventory("origin");
|
|
132
|
+
const destinationTokens = inventory("destination");
|
|
133
|
+
return {
|
|
134
|
+
...full,
|
|
135
|
+
sourceChainIds: [...originTokens.keys()],
|
|
136
|
+
destinationChainIds: [...destinationTokens.keys()],
|
|
137
|
+
originSymbols: [],
|
|
138
|
+
destinationSymbols: [],
|
|
139
|
+
// resolve retains the exact original capability closure.
|
|
140
|
+
routeModel: { ...full.routeModel, originTokens, destinationTokens }
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function legTokens(offer, chainId, leg) {
|
|
144
|
+
const tokensByChain = leg === "sell" ? offer.routeModel.originTokens : offer.routeModel.destinationTokens;
|
|
145
|
+
const symbols = leg === "sell" ? offer.originSymbols : offer.destinationSymbols;
|
|
146
|
+
return (tokensByChain.get(chainId) ?? []).filter(
|
|
147
|
+
(token) => symbols.length === 0 || symbols.includes(token.symbol)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function defaultToken(offer, chainId, leg) {
|
|
151
|
+
const frameDefault = leg === "sell" ? FRAME_DEFAULTS.fromToken : FRAME_DEFAULTS.toToken;
|
|
152
|
+
const symbols = leg === "sell" ? offer.originSymbols : offer.destinationSymbols;
|
|
153
|
+
const tokens = legTokens(offer, chainId, leg);
|
|
154
|
+
if (chainId === frameDefault.chainId) {
|
|
155
|
+
const preferred = tokens.find((token) => token.symbol === frameDefault.symbol);
|
|
156
|
+
if (preferred) return preferred;
|
|
157
|
+
}
|
|
158
|
+
return pickDefaultToken(tokens, symbols);
|
|
159
|
+
}
|
|
160
|
+
function requestedToken(offer, chainId, leg, symbol) {
|
|
161
|
+
if (symbol === void 0) return null;
|
|
162
|
+
const wanted = symbol.toLowerCase();
|
|
163
|
+
return legTokens(offer, chainId, leg).find((t) => t.symbol.toLowerCase() === wanted) ?? null;
|
|
164
|
+
}
|
|
165
|
+
function routeAvailability(offer, route) {
|
|
166
|
+
return offer.routeModel.resolve(
|
|
167
|
+
{ chainId: route.fromChainId, token: route.fromToken },
|
|
168
|
+
{ kind: "chain", chainId: route.toChainId, token: route.toToken }
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
function routeFills(offer, route) {
|
|
172
|
+
return routeAvailability(offer, route).status !== "unavailable";
|
|
173
|
+
}
|
|
174
|
+
function routeSupportsEmbedSettlement(offer, route) {
|
|
175
|
+
const availability = routeAvailability(offer, route);
|
|
176
|
+
if (availability.status === "unknown") return true;
|
|
177
|
+
if (availability.status === "unavailable") return false;
|
|
178
|
+
return availability.privacyModes.includes("public") || availability.privacyModes.includes("stealth");
|
|
179
|
+
}
|
|
180
|
+
function stealthOffered(route, capabilities, capabilityState) {
|
|
181
|
+
const availability = resolveRouteModel(capabilities, capabilityState, {
|
|
182
|
+
chainEnabledForRole,
|
|
183
|
+
presentationTokens: TOKENS
|
|
184
|
+
}).resolve(
|
|
185
|
+
{ chainId: route.fromChainId, token: route.fromToken },
|
|
186
|
+
{ kind: "chain", chainId: route.toChainId, token: route.toToken }
|
|
187
|
+
);
|
|
188
|
+
return availability.status === "available" && availability.privacyModes.includes("stealth");
|
|
189
|
+
}
|
|
190
|
+
const CHAIN_NAMES = EXTENDED_CHAIN_NAMES;
|
|
191
|
+
const CHAIN_TOKENS = TOKENS;
|
|
192
|
+
const chainName = (id) => CHAIN_NAMES[id] ?? `chain ${id}`;
|
|
193
|
+
function legSymbols(offer, chainIds, leg) {
|
|
194
|
+
return [...new Set(chainIds.flatMap((id) => legTokens(offer, id, leg).map((t) => t.symbol)))];
|
|
195
|
+
}
|
|
196
|
+
function restrictOffer(offer, asked) {
|
|
197
|
+
const ignored = {};
|
|
198
|
+
const keepChains = (offered, wanted, field) => {
|
|
199
|
+
if (wanted === void 0 || wanted.length === 0) return null;
|
|
200
|
+
const kept = wanted.flatMap((id) => offered.find((offeredId) => offeredId === id) ?? []);
|
|
201
|
+
if (kept.length > 0) return kept;
|
|
202
|
+
ignored[field] = `the widget ${field === "fromChains" ? "sends from" : "delivers to"} none of ${wanted.map(chainName).join(", ")}`;
|
|
203
|
+
return null;
|
|
204
|
+
};
|
|
205
|
+
const keepSymbols = (leg, wanted, field) => {
|
|
206
|
+
if (wanted === void 0 || wanted.length === 0) return null;
|
|
207
|
+
const upper = wanted.map((s) => s.toUpperCase());
|
|
208
|
+
const chains = leg === "sell" ? offer.sourceChainIds : offer.destinationChainIds;
|
|
209
|
+
const kept = legSymbols(offer, chains, leg).filter((s) => upper.includes(s.toUpperCase()));
|
|
210
|
+
if (kept.length > 0) return kept;
|
|
211
|
+
ignored[field] = `the widget ${leg === "sell" ? "takes" : "delivers"} none of ${upper.join(", ")}`;
|
|
212
|
+
return null;
|
|
213
|
+
};
|
|
214
|
+
const fromKept = keepChains(offer.sourceChainIds, asked.fromChains, "fromChains");
|
|
215
|
+
const toKept = keepChains(offer.destinationChainIds, asked.toChains, "toChains");
|
|
216
|
+
const sellKept = keepSymbols("sell", asked.sellTokens, "sellTokens");
|
|
217
|
+
const buyKept = keepSymbols("buy", asked.buyTokens, "buyTokens");
|
|
218
|
+
if (fromKept === null && toKept === null && sellKept === null && buyKept === null) {
|
|
219
|
+
return {
|
|
220
|
+
offer,
|
|
221
|
+
lists: { fromChains: null, toChains: null, sellTokens: null, buyTokens: null },
|
|
222
|
+
ignored
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const symbolsOnly = {
|
|
226
|
+
...offer,
|
|
227
|
+
originSymbols: sellKept ?? offer.originSymbols,
|
|
228
|
+
destinationSymbols: buyKept ?? offer.destinationSymbols,
|
|
229
|
+
restricted: true
|
|
230
|
+
};
|
|
231
|
+
const narrowed = {
|
|
232
|
+
...symbolsOnly,
|
|
233
|
+
sourceChainIds: (fromKept ?? offer.sourceChainIds).filter(
|
|
234
|
+
(id) => legTokens(symbolsOnly, id, "sell").length > 0
|
|
235
|
+
),
|
|
236
|
+
destinationChainIds: (toKept ?? offer.destinationChainIds).filter(
|
|
237
|
+
(id) => legTokens(symbolsOnly, id, "buy").length > 0
|
|
238
|
+
)
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
offer: narrowed,
|
|
242
|
+
lists: {
|
|
243
|
+
fromChains: fromKept === null ? null : narrowed.sourceChainIds,
|
|
244
|
+
toChains: toKept === null ? null : narrowed.destinationChainIds,
|
|
245
|
+
sellTokens: sellKept,
|
|
246
|
+
buyTokens: buyKept
|
|
247
|
+
},
|
|
248
|
+
ignored
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function firstRoute(offer) {
|
|
252
|
+
const allowed = (route) => offer.sourceChainIds.includes(route.fromChainId) && offer.destinationChainIds.includes(route.toChainId) && legTokens(offer, route.fromChainId, "sell").includes(route.fromToken) && legTokens(offer, route.toChainId, "buy").includes(route.toToken);
|
|
253
|
+
if (allowed(FRAME_DEFAULTS) && routeFills(offer, FRAME_DEFAULTS) && routeSupportsEmbedSettlement(offer, FRAME_DEFAULTS)) {
|
|
254
|
+
return FRAME_DEFAULTS;
|
|
255
|
+
}
|
|
256
|
+
for (const fromChainId of offer.sourceChainIds) {
|
|
257
|
+
for (const toChainId of offer.destinationChainIds) {
|
|
258
|
+
for (const fromToken of legTokens(offer, fromChainId, "sell")) {
|
|
259
|
+
for (const toToken of legTokens(offer, toChainId, "buy")) {
|
|
260
|
+
const route = { fromChainId, toChainId, fromToken, toToken };
|
|
261
|
+
if (routeFills(offer, route) && routeSupportsEmbedSettlement(offer, route)) return route;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
function firstStealthRoute(offer) {
|
|
269
|
+
if (!offer.live) return null;
|
|
270
|
+
const sourceChains = [
|
|
271
|
+
...offer.sourceChainIds.filter((chainId) => chainId === DEFAULT_CHAIN_ID),
|
|
272
|
+
...offer.sourceChainIds.filter((chainId) => chainId !== DEFAULT_CHAIN_ID)
|
|
273
|
+
];
|
|
274
|
+
for (const fromChainId of sourceChains) {
|
|
275
|
+
const preferredFrom = defaultToken(offer, fromChainId, "sell");
|
|
276
|
+
const fromTokens = [
|
|
277
|
+
preferredFrom,
|
|
278
|
+
...legTokens(offer, fromChainId, "sell").filter((token) => token !== preferredFrom)
|
|
279
|
+
];
|
|
280
|
+
for (const fromToken of fromTokens) {
|
|
281
|
+
let firstEligible = null;
|
|
282
|
+
for (const toChainId of stealthDestinationChains(offer.capabilities)) {
|
|
283
|
+
if (!offer.destinationChainIds.includes(toChainId)) continue;
|
|
284
|
+
const preferredTo = defaultToken(offer, toChainId, "buy");
|
|
285
|
+
const toTokens = [
|
|
286
|
+
preferredTo,
|
|
287
|
+
...legTokens(offer, toChainId, "buy").filter((token) => token !== preferredTo)
|
|
288
|
+
];
|
|
289
|
+
for (const toToken of toTokens) {
|
|
290
|
+
const route = { fromChainId, toChainId, fromToken, toToken };
|
|
291
|
+
const availability = routeAvailability(offer, route);
|
|
292
|
+
if (availability.status !== "available" || !availability.privacyModes.includes("stealth"))
|
|
293
|
+
continue;
|
|
294
|
+
if (toToken.symbol === fromToken.symbol) return route;
|
|
295
|
+
firstEligible ??= route;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (firstEligible) return firstEligible;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
function resolveEmbedDefaults(params, offer) {
|
|
304
|
+
return explainEmbedDefaults(params, offer).defaults;
|
|
305
|
+
}
|
|
306
|
+
function explainEmbedDefaults(params, full) {
|
|
307
|
+
const explicitStealth = params.settlement === "stealth";
|
|
308
|
+
const restriction = restrictOffer(explicitStealth ? stealthDisplayOffer(full) : full, params);
|
|
309
|
+
const ignored = { ...restriction.ignored };
|
|
310
|
+
let offer = restriction.offer;
|
|
311
|
+
let lists = restriction.lists;
|
|
312
|
+
let first = firstRoute(offer);
|
|
313
|
+
if (!explicitStealth && offer.restricted && first === null) {
|
|
314
|
+
for (const field of EMBED_ALLOW_FIELDS) {
|
|
315
|
+
if (lists[field] !== null) {
|
|
316
|
+
ignored[field] = "the allow-lists together leave no route the solver fills";
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
offer = full;
|
|
320
|
+
lists = restrictOffer(full, {}).lists;
|
|
321
|
+
first = firstRoute(offer);
|
|
322
|
+
}
|
|
323
|
+
if (first === null && (!explicitStealth || offer.sourceChainIds.length === 0 || offer.destinationChainIds.length === 0)) {
|
|
324
|
+
const reason = "the solver advertises no route the widget can use";
|
|
325
|
+
for (const field of [
|
|
326
|
+
"fromChainId",
|
|
327
|
+
"toChainId",
|
|
328
|
+
"sellSymbol",
|
|
329
|
+
"buySymbol",
|
|
330
|
+
"amount"
|
|
331
|
+
]) {
|
|
332
|
+
if (params[field] !== void 0) ignored[field] = reason;
|
|
333
|
+
}
|
|
334
|
+
if ((params.locks?.length ?? 0) > 0) ignored.locks = reason;
|
|
335
|
+
return {
|
|
336
|
+
defaults: {
|
|
337
|
+
...FRAME_DEFAULTS,
|
|
338
|
+
settlement: params.settlement ?? FRAME_DEFAULTS.settlement,
|
|
339
|
+
...embedLook(params),
|
|
340
|
+
...lists,
|
|
341
|
+
...embedCodes(params)
|
|
342
|
+
},
|
|
343
|
+
ignored
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
const fallback = first ?? {
|
|
347
|
+
fromChainId: offer.sourceChainIds[0],
|
|
348
|
+
toChainId: offer.destinationChainIds[0],
|
|
349
|
+
fromToken: defaultToken(offer, offer.sourceChainIds[0], "sell"),
|
|
350
|
+
toToken: defaultToken(offer, offer.destinationChainIds[0], "buy")
|
|
351
|
+
};
|
|
352
|
+
const homeFrom = offer.sourceChainIds.includes(FRAME_DEFAULTS.fromChainId) ? FRAME_DEFAULTS.fromChainId : fallback.fromChainId;
|
|
353
|
+
const homeTo = offer.destinationChainIds.includes(FRAME_DEFAULTS.toChainId) ? FRAME_DEFAULTS.toChainId : fallback.toChainId;
|
|
354
|
+
const fromChainId = offer.sourceChainIds.find((id) => id === params.fromChainId) ?? homeFrom;
|
|
355
|
+
const toChainId = offer.destinationChainIds.find((id) => id === params.toChainId) ?? homeTo;
|
|
356
|
+
const askedSell = requestedToken(offer, fromChainId, "sell", params.sellSymbol);
|
|
357
|
+
const askedBuy = requestedToken(offer, toChainId, "buy", params.buySymbol);
|
|
358
|
+
const chainDefaults = {
|
|
359
|
+
fromChainId,
|
|
360
|
+
toChainId,
|
|
361
|
+
fromToken: defaultToken(offer, fromChainId, "sell"),
|
|
362
|
+
toToken: defaultToken(offer, toChainId, "buy")
|
|
363
|
+
};
|
|
364
|
+
const asked = {
|
|
365
|
+
...chainDefaults,
|
|
366
|
+
fromToken: askedSell ?? chainDefaults.fromToken,
|
|
367
|
+
toToken: askedBuy ?? chainDefaults.toToken
|
|
368
|
+
};
|
|
369
|
+
const routeConfigured = params.fromChainId !== void 0 || params.toChainId !== void 0 || params.sellSymbol !== void 0 || params.buySymbol !== void 0 || params.amount !== void 0 || (params.locks?.length ?? 0) > 0 || EMBED_ALLOW_FIELDS.some((field) => params[field] !== void 0);
|
|
370
|
+
const route = params.settlement === "stealth" && routeConfigured ? asked : (!routeConfigured && params.settlement !== "public" ? firstStealthRoute(offer) : null) ?? [asked, chainDefaults].find(
|
|
371
|
+
(candidate) => routeFills(offer, candidate) && routeSupportsEmbedSettlement(offer, candidate)
|
|
372
|
+
) ?? fallback;
|
|
373
|
+
const meantSell = params.sellSymbol !== void 0 ? askedSell : fromChainId === (params.fromChainId ?? homeFrom) ? chainDefaults.fromToken : null;
|
|
374
|
+
const amount = params.amount !== void 0 && meantSell !== null && route.fromToken === meantSell && amountProblem(params.amount, route.fromToken) === null ? params.amount.replace(/^0+(?=\d)/, "") : "";
|
|
375
|
+
const selectedAvailability = routeAvailability(offer, route);
|
|
376
|
+
const selectedPrivacyModes = selectedAvailability.status === "available" ? selectedAvailability.privacyModes : [];
|
|
377
|
+
const stealthAvailable = selectedPrivacyModes.includes("stealth");
|
|
378
|
+
const settlement = params.settlement ?? (stealthAvailable ? "stealth" : "public");
|
|
379
|
+
const lockAsks = params.locks ?? [];
|
|
380
|
+
const amountLocked = lockAsks.includes("amount") && amount !== "";
|
|
381
|
+
const locks = EMBED_LOCKS.filter(
|
|
382
|
+
(lock) => lock === "amount" ? amountLocked : lockAsks.includes(lock) || amountLocked && (lock === "fromChain" || lock === "sell")
|
|
383
|
+
);
|
|
384
|
+
if (lockAsks.includes("amount") && !amountLocked) {
|
|
385
|
+
ignored.locks = "the amount can only be locked with an amount the widget opens on";
|
|
386
|
+
}
|
|
387
|
+
const fromName = chainName(fromChainId);
|
|
388
|
+
const toName = chainName(toChainId);
|
|
389
|
+
const listed = "it is outside the allow-lists";
|
|
390
|
+
const noRoute = `no route the solver fills goes from ${asked.fromToken?.symbol ?? params.sellSymbol?.toUpperCase() ?? "a supported token"} on ${fromName} to ${asked.toToken?.symbol ?? params.buySymbol?.toUpperCase() ?? "a supported token"} on ${toName}`;
|
|
391
|
+
if (params.fromChainId !== void 0 && route.fromChainId !== params.fromChainId) {
|
|
392
|
+
ignored.fromChainId = fromChainId === params.fromChainId ? noRoute : full.sourceChainIds.some((id) => id === params.fromChainId) ? listed : `the widget doesn't send from ${chainName(params.fromChainId)}`;
|
|
393
|
+
}
|
|
394
|
+
if (params.toChainId !== void 0 && route.toChainId !== params.toChainId) {
|
|
395
|
+
ignored.toChainId = toChainId === params.toChainId ? noRoute : full.destinationChainIds.some((id) => id === params.toChainId) ? listed : `the widget doesn't deliver to ${chainName(params.toChainId)}`;
|
|
396
|
+
}
|
|
397
|
+
const sameSymbol = (token, symbol) => token.symbol.toLowerCase() === symbol.toLowerCase();
|
|
398
|
+
if (params.sellSymbol !== void 0 && !sameSymbol(route.fromToken, params.sellSymbol)) {
|
|
399
|
+
ignored.sellSymbol = askedSell !== null ? noRoute : requestedToken(full, fromChainId, "sell", params.sellSymbol) !== null ? listed : `${params.sellSymbol.toUpperCase()} can't be sent on ${fromName}`;
|
|
400
|
+
}
|
|
401
|
+
if (params.buySymbol !== void 0 && !sameSymbol(route.toToken, params.buySymbol)) {
|
|
402
|
+
ignored.buySymbol = askedBuy !== null ? noRoute : requestedToken(full, toChainId, "buy", params.buySymbol) !== null ? listed : `${params.buySymbol.toUpperCase()} can't be received on ${toName}`;
|
|
403
|
+
}
|
|
404
|
+
if (params.amount !== void 0 && amount === "") {
|
|
405
|
+
ignored.amount = meantSell !== null && route.fromToken === meantSell ? (amountProblem(params.amount, route.fromToken) ?? "").replace(/\.$/, "") : "it is in a sell token the widget doesn't open on";
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
defaults: {
|
|
409
|
+
fromChainId: route.fromChainId,
|
|
410
|
+
toChainId: route.toChainId,
|
|
411
|
+
fromToken: route.fromToken,
|
|
412
|
+
toToken: route.toToken,
|
|
413
|
+
amount,
|
|
414
|
+
settlement,
|
|
415
|
+
...embedLook(params),
|
|
416
|
+
locks,
|
|
417
|
+
...lists,
|
|
418
|
+
...embedCodes(params)
|
|
419
|
+
},
|
|
420
|
+
ignored
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function sameEmbedDefaults(a, b) {
|
|
424
|
+
return a.fromChainId === b.fromChainId && a.toChainId === b.toChainId && a.fromToken.address === b.fromToken.address && a.toToken.address === b.toToken.address && a.amount === b.amount && a.settlement === b.settlement;
|
|
425
|
+
}
|
|
426
|
+
function embedOverrides(defaults) {
|
|
427
|
+
const params = {};
|
|
428
|
+
if (defaults.fromChainId !== FRAME_DEFAULTS.fromChainId)
|
|
429
|
+
params.fromChainId = defaults.fromChainId;
|
|
430
|
+
params.toChainId = defaults.toChainId;
|
|
431
|
+
if (defaults.fromToken.symbol !== FRAME_DEFAULTS.fromToken.symbol) {
|
|
432
|
+
params.sellSymbol = defaults.fromToken.symbol;
|
|
433
|
+
}
|
|
434
|
+
if (defaults.toToken.symbol !== FRAME_DEFAULTS.toToken.symbol) {
|
|
435
|
+
params.buySymbol = defaults.toToken.symbol;
|
|
436
|
+
}
|
|
437
|
+
if (defaults.amount !== "") params.amount = defaults.amount;
|
|
438
|
+
params.settlement = defaults.settlement;
|
|
439
|
+
if (defaults.theme !== FRAME_DEFAULTS.theme) params.theme = defaults.theme;
|
|
440
|
+
if (defaults.layout !== FRAME_DEFAULTS.layout) params.layout = defaults.layout;
|
|
441
|
+
if (!defaults.howItWorks) params.howItWorks = false;
|
|
442
|
+
if (defaults.height !== null) params.height = defaults.height;
|
|
443
|
+
const locks = defaults.locks.includes("amount") ? defaults.locks.filter((lock) => lock !== "fromChain" && lock !== "sell") : defaults.locks;
|
|
444
|
+
if (locks.length > 0) params.locks = locks;
|
|
445
|
+
if (defaults.fromChains !== null) params.fromChains = defaults.fromChains;
|
|
446
|
+
if (defaults.toChains !== null) params.toChains = defaults.toChains;
|
|
447
|
+
if (defaults.sellTokens !== null) params.sellTokens = defaults.sellTokens;
|
|
448
|
+
if (defaults.buyTokens !== null) params.buyTokens = defaults.buyTokens;
|
|
449
|
+
if (defaults.ref !== null) params.ref = defaults.ref;
|
|
450
|
+
if (defaults.promo !== null) params.promo = defaults.promo;
|
|
451
|
+
return params;
|
|
452
|
+
}
|
|
453
|
+
const OPEN_POLICY = {
|
|
454
|
+
locks: FRAME_DEFAULTS.locks,
|
|
455
|
+
fromChains: null,
|
|
456
|
+
toChains: null,
|
|
457
|
+
sellTokens: null,
|
|
458
|
+
buyTokens: null
|
|
459
|
+
};
|
|
460
|
+
function policyAdmits(policy, route) {
|
|
461
|
+
return (policy.fromChains?.some((id) => id === route.fromChainId) ?? true) && (policy.toChains?.some((id) => id === route.toChainId) ?? true) && (policy.sellTokens?.includes(route.fromSymbol) ?? true) && (policy.buyTokens?.includes(route.toSymbol) ?? true);
|
|
462
|
+
}
|
|
463
|
+
function policyHolds(opened, route, amount) {
|
|
464
|
+
const keeps = {
|
|
465
|
+
fromChain: route.fromChainId === opened.fromChainId,
|
|
466
|
+
toChain: route.toChainId === opened.toChainId,
|
|
467
|
+
sell: route.fromSymbol === opened.fromToken.symbol,
|
|
468
|
+
buy: route.toSymbol === opened.toToken.symbol,
|
|
469
|
+
amount: amount === opened.amount
|
|
470
|
+
};
|
|
471
|
+
return opened.locks.every((lock) => keeps[lock]) && policyAdmits(opened, route);
|
|
472
|
+
}
|
|
473
|
+
function narrowSymbols(offered, allowed) {
|
|
474
|
+
if (allowed === null) return offered;
|
|
475
|
+
return offered.length === 0 ? allowed : offered.filter((s) => allowed.includes(s));
|
|
476
|
+
}
|
|
477
|
+
function legPolicy(policy, leg) {
|
|
478
|
+
return leg === "sell" ? {
|
|
479
|
+
chainLocked: policy.locks.includes("fromChain"),
|
|
480
|
+
tokenLocked: policy.locks.includes("sell"),
|
|
481
|
+
chains: policy.fromChains,
|
|
482
|
+
symbols: policy.sellTokens
|
|
483
|
+
} : {
|
|
484
|
+
chainLocked: policy.locks.includes("toChain"),
|
|
485
|
+
tokenLocked: policy.locks.includes("buy"),
|
|
486
|
+
chains: policy.toChains,
|
|
487
|
+
symbols: policy.buyTokens
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function legChainAllowed(policy, leg, chainId, current) {
|
|
491
|
+
const { chainLocked, tokenLocked, chains, symbols } = legPolicy(policy, leg);
|
|
492
|
+
const carried = (CHAIN_TOKENS[chainId] ?? []).map((t) => t.symbol);
|
|
493
|
+
return (!chainLocked || chainId === current.chainId) && (chains?.some((id) => id === chainId) ?? true) && (symbols === null || carried.some((s) => symbols.includes(s))) && (!tokenLocked || carried.includes(current.symbol));
|
|
494
|
+
}
|
|
495
|
+
function legTokenAllowed(policy, leg, token, currentChainId) {
|
|
496
|
+
const { chainLocked, tokenLocked, chains, symbols } = legPolicy(policy, leg);
|
|
497
|
+
return !tokenLocked && (!chainLocked || token.chainId === currentChainId) && (chains?.some((id) => id === token.chainId) ?? true) && (symbols?.includes(token.symbol) ?? true);
|
|
498
|
+
}
|
|
499
|
+
const CLAIMS_HASH = "#claims";
|
|
500
|
+
function claimsPath(theme) {
|
|
501
|
+
return `${EMBED_PATH}${encodeEmbedParams(theme === "auto" ? {} : { theme })}${CLAIMS_HASH}`;
|
|
502
|
+
}
|
|
503
|
+
export {
|
|
504
|
+
CLAIMS_HASH,
|
|
505
|
+
EMBED_PARAM_HINT,
|
|
506
|
+
FRAME_DEFAULTS,
|
|
507
|
+
FRAME_FIELDS,
|
|
508
|
+
FULL_LOOK,
|
|
509
|
+
OPEN_POLICY,
|
|
510
|
+
amountProblem,
|
|
511
|
+
chainName,
|
|
512
|
+
claimsPath,
|
|
513
|
+
codeProblem,
|
|
514
|
+
embedCodes,
|
|
515
|
+
embedLook,
|
|
516
|
+
embedOffer,
|
|
517
|
+
embedOverrides,
|
|
518
|
+
explainEmbedDefaults,
|
|
519
|
+
heightProblem,
|
|
520
|
+
legChainAllowed,
|
|
521
|
+
legSymbols,
|
|
522
|
+
legTokenAllowed,
|
|
523
|
+
legTokens,
|
|
524
|
+
narrowSymbols,
|
|
525
|
+
policyAdmits,
|
|
526
|
+
policyHolds,
|
|
527
|
+
resolveEmbedDefaults,
|
|
528
|
+
restrictOffer,
|
|
529
|
+
routeFills,
|
|
530
|
+
sameEmbedDefaults,
|
|
531
|
+
stealthOffered
|
|
532
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { orderBoundsViolation } from "@xochi/client";
|
|
2
|
+
const formatUsdBound = (amount) => `$${amount.toLocaleString("en-US", { maximumFractionDigits: 0 })}`;
|
|
3
|
+
function minimumOrderNotice(amountUsd, minimumUsd) {
|
|
4
|
+
return orderBoundsViolation(amountUsd, { min: minimumUsd, max: Infinity }) === "below_min" ? `Minimum order is ${formatUsdBound(minimumUsd)}.` : null;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
minimumOrderNotice
|
|
8
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isCantonDestinationChainId, getTokenInfoForChain } from "@xochi/client";
|
|
2
|
+
import { formatTokenAmount } from "../../utils/format.js";
|
|
3
|
+
import { findTokenBySymbol } from "./config.js";
|
|
4
|
+
import { DEFAULT_DESTINATION, STEALTH_DESTINATION } from "../../types/intent.js";
|
|
5
|
+
import { normalizeZkMoneyTag, zkMoneyTagValid } from "./zkMoney.js";
|
|
6
|
+
import { isOfferedChainId } from "./canton.js";
|
|
7
|
+
function planResume(record) {
|
|
8
|
+
if (!record?.id) return null;
|
|
9
|
+
const { fromChainId, toChainId, fromToken, toToken, fromAmount } = record.data;
|
|
10
|
+
if (!isOfferedChainId(fromChainId) || !isOfferedChainId(toChainId)) return null;
|
|
11
|
+
if (isCantonDestinationChainId(fromChainId)) return null;
|
|
12
|
+
const fromInfo = getTokenInfoForChain(fromToken, fromChainId);
|
|
13
|
+
const toInfo = getTokenInfoForChain(toToken, toChainId);
|
|
14
|
+
const nextFromToken = fromInfo ? findTokenBySymbol(fromChainId, fromInfo.symbol) : void 0;
|
|
15
|
+
const nextToToken = toInfo ? findTokenBySymbol(toChainId, toInfo.symbol) : void 0;
|
|
16
|
+
if (!nextFromToken || !nextToToken) return null;
|
|
17
|
+
const storedTag = record.data.recipientTag;
|
|
18
|
+
const recipientTag = typeof storedTag === "string" ? normalizeZkMoneyTag(storedTag) : void 0;
|
|
19
|
+
if (storedTag !== void 0 && (recipientTag === void 0 || !zkMoneyTagValid(recipientTag) || toChainId !== 1 || nextToToken.symbol !== "DAI" || record.data.settlementType !== void 0 && record.data.settlementType !== "public")) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
let amount;
|
|
23
|
+
try {
|
|
24
|
+
amount = formatTokenAmount(BigInt(fromAmount), nextFromToken.decimals, 6);
|
|
25
|
+
} catch {
|
|
26
|
+
amount = "";
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
intentId: record.id,
|
|
30
|
+
status: record.intentStatus,
|
|
31
|
+
fromChainId,
|
|
32
|
+
toChainId,
|
|
33
|
+
fromToken: nextFromToken,
|
|
34
|
+
toToken: nextToToken,
|
|
35
|
+
amount,
|
|
36
|
+
toAmount: record.data.toAmount ?? null,
|
|
37
|
+
deposit: record.data.deposit ?? null,
|
|
38
|
+
destination: recipientTag ? { ...DEFAULT_DESTINATION, recipientTag } : record.data.settlementType === "stealth" ? STEALTH_DESTINATION : DEFAULT_DESTINATION,
|
|
39
|
+
stealthPayee: record.data.stealthPayee === "other" ? "other" : "self",
|
|
40
|
+
startedAt: record.timestamp
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function selectPayoutSource(quote, resumed, currentIntentId) {
|
|
44
|
+
if (quote) return quote.canSolve ? quote.toAmount ?? null : null;
|
|
45
|
+
if (!resumed || !currentIntentId || resumed.intentId !== currentIntentId) return null;
|
|
46
|
+
return resumed.toAmount;
|
|
47
|
+
}
|
|
48
|
+
function shouldCaptureToActivity(input) {
|
|
49
|
+
return input.hasOwner && input.hasIntentId && input.isCapturedStatus && !input.isResumedIntent;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
planResume,
|
|
53
|
+
selectPayoutSource,
|
|
54
|
+
shouldCaptureToActivity
|
|
55
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ZKMONEY_PRIVACY_COPY } from "./zkMoney.js";
|
|
2
|
+
import { CANTON_PUBLIC_ONLY_LINE } from "./canton.js";
|
|
3
|
+
const SHIELDED_DESCRIPTION = ZKMONEY_PRIVACY_COPY;
|
|
4
|
+
const MODE_META = {
|
|
5
|
+
public: "Recipient and amount visible",
|
|
6
|
+
stealth: "Recipient hidden, amount visible",
|
|
7
|
+
shielded: SHIELDED_DESCRIPTION
|
|
8
|
+
};
|
|
9
|
+
const STEALTH_PRIVACY_LIMITS = "Stealth hides the recipient from public view. Xochi sees the recipient's meta-address and uses it to derive the one-time address, so it can link the payment to them. Stealth does not hide your funding transaction, amount or timing.";
|
|
10
|
+
const SETTLEMENT_FIX_LINE = {
|
|
11
|
+
wallet: "Wallet required",
|
|
12
|
+
setup: "Set up Stealth",
|
|
13
|
+
quote: "Updating quote",
|
|
14
|
+
destination: "Choose a Stealth chain",
|
|
15
|
+
route: "Try another route",
|
|
16
|
+
unavailable: "Unavailable",
|
|
17
|
+
route_loading: "Loading routes",
|
|
18
|
+
route_unavailable: "Route data unavailable",
|
|
19
|
+
public_only: CANTON_PUBLIC_ONLY_LINE
|
|
20
|
+
};
|
|
21
|
+
const payoutHeadline = (payout) => `Receive ${payout}, paid as quoted or fully refunded.`;
|
|
22
|
+
const PAYOUT_GUARANTEE = "Receive exactly the quoted amount, or a full refund.";
|
|
23
|
+
const SHIELDED_DEPOSIT_NOTE = "Deposit is public on Ethereum.";
|
|
24
|
+
export {
|
|
25
|
+
MODE_META,
|
|
26
|
+
PAYOUT_GUARANTEE,
|
|
27
|
+
SETTLEMENT_FIX_LINE,
|
|
28
|
+
SHIELDED_DEPOSIT_NOTE,
|
|
29
|
+
SHIELDED_DESCRIPTION,
|
|
30
|
+
STEALTH_PRIVACY_LIMITS,
|
|
31
|
+
payoutHeadline
|
|
32
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useRef, useState, useLayoutEffect, useEffect, useCallback } from "react";
|
|
2
|
+
function useAmountFit(value) {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
const [truncated, setTruncated] = useState(false);
|
|
5
|
+
const [expanded, setExpanded] = useState(false);
|
|
6
|
+
useLayoutEffect(() => {
|
|
7
|
+
const el = ref.current;
|
|
8
|
+
if (!el) return;
|
|
9
|
+
const measure = () => setTruncated(el.scrollWidth > el.clientWidth + 1);
|
|
10
|
+
measure();
|
|
11
|
+
let live = true;
|
|
12
|
+
void document.fonts?.ready.then(() => {
|
|
13
|
+
if (live) measure();
|
|
14
|
+
});
|
|
15
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
16
|
+
observer?.observe(el);
|
|
17
|
+
return () => {
|
|
18
|
+
live = false;
|
|
19
|
+
observer?.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, [value, expanded]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!value) setExpanded(false);
|
|
24
|
+
}, [value]);
|
|
25
|
+
const toggle = useCallback(() => setExpanded((open) => !open), []);
|
|
26
|
+
const style = { "--amount-chars": Math.max(value.length, 7) };
|
|
27
|
+
return { ref, truncated, expanded, toggle, style };
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
useAmountFit
|
|
31
|
+
};
|