@xochi/widget 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +420 -2
- package/THIRD_PARTY_NOTICES.txt +44 -0
- package/dist/ConfiguratorApp.js +19 -0
- package/dist/EmbedApp.js +57 -0
- package/dist/assets/MonaspaceArgon-Bold-D9kWRRK5.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Light-Dt_6qXbW.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Medium-B1gMZwrU.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-Regular-RS-2TGNg.woff2 +0 -0
- package/dist/assets/MonaspaceArgon-SemiBold-PYusZXE_.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Italic-C9u9eioB.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Light-CJkxpyfT.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Medium-DCChELAx.woff2 +0 -0
- package/dist/assets/MonaspaceNeon-Regular-BZtV1wRa.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Bold-KacFhGOf.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Medium-Dqqg-cnL.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-Regular-BRsdKART.woff2 +0 -0
- package/dist/assets/MonaspaceXenon-SemiBold-DNjPl3uE.woff2 +0 -0
- package/dist/assets/alipay-3tx9-HPp.svg +1 -0
- package/dist/assets/arb-CCfLcB_X.svg +7 -0
- package/dist/assets/arc-Dy98eSCd.svg +10 -0
- package/dist/assets/aztec-DiLp9qTG.svg +4 -0
- package/dist/assets/base-Ch0ino36.svg +4 -0
- package/dist/assets/cashapp-lOg0DIt8.svg +1 -0
- package/dist/assets/chains/arbitrum.svg.js +4 -0
- package/dist/assets/chains/arc.svg.js +4 -0
- package/dist/assets/chains/aztec.svg.js +4 -0
- package/dist/assets/chains/base.svg.js +4 -0
- package/dist/assets/chains/ethereum.svg.js +4 -0
- package/dist/assets/chains/gnosis.png.js +4 -0
- package/dist/assets/chains/index.js +31 -0
- package/dist/assets/chains/optimism.svg.js +4 -0
- package/dist/assets/chains/polygon.svg.js +4 -0
- package/dist/assets/chains/robinhood.svg.js +4 -0
- package/dist/assets/chains/tron.svg.js +4 -0
- package/dist/assets/chains/xochi.svg.js +4 -0
- package/dist/assets/dai-XuyZLceZ.png +0 -0
- package/dist/assets/defillama-BU037Unq.svg +1 -0
- package/dist/assets/defillama.svg.js +4 -0
- package/dist/assets/eth-Dvbng9UB.svg +8 -0
- package/dist/assets/eurc-NI9zNgOQ.png +0 -0
- package/dist/assets/eure-BH9vpwcv.png +0 -0
- package/dist/assets/gnosis-fRzAZQFj.png +0 -0
- package/dist/assets/mercadopago-gjsFb6F7.svg +1 -0
- package/dist/assets/monzo-B9XD4bL5.png +0 -0
- package/dist/assets/monzo-SZnIdUKN.svg +1 -0
- package/dist/assets/monzo-dark-Bwzg90UC.png +0 -0
- package/dist/assets/n26-cANcjY2T.svg +1 -0
- package/dist/assets/op-DF67SbB6.png +0 -0
- package/dist/assets/optimism-B3cTNxEQ.svg +4 -0
- package/dist/assets/paypal-D8xqXEtN.svg +1 -0
- package/dist/assets/pol-uLmSo2O8.svg +3 -0
- package/dist/assets/rails/SOURCES.md +50 -0
- package/dist/assets/rails/alipay.svg.js +4 -0
- package/dist/assets/rails/cashapp.svg.js +4 -0
- package/dist/assets/rails/index.js +59 -0
- package/dist/assets/rails/mercadopago.svg.js +4 -0
- package/dist/assets/rails/monzo-dark.png.js +4 -0
- package/dist/assets/rails/monzo.png.js +4 -0
- package/dist/assets/rails/monzo.svg.js +4 -0
- package/dist/assets/rails/n26.svg.js +4 -0
- package/dist/assets/rails/paypal.svg.js +4 -0
- package/dist/assets/rails/revolut-dark.png.js +4 -0
- package/dist/assets/rails/revolut.png.js +4 -0
- package/dist/assets/rails/revolut.svg.js +4 -0
- package/dist/assets/rails/venmo.svg.js +4 -0
- package/dist/assets/rails/wise-dark.png.js +4 -0
- package/dist/assets/rails/wise.png.js +4 -0
- package/dist/assets/rails/wise.svg.js +4 -0
- package/dist/assets/rails/xmoney.svg.js +4 -0
- package/dist/assets/rails/zelle.svg.js +4 -0
- package/dist/assets/raxol-86FmC34h.png +0 -0
- package/dist/assets/revolut-CiBtyALA.png +0 -0
- package/dist/assets/revolut-D7qr5Vzs.svg +1 -0
- package/dist/assets/revolut-dark-RQdWGM_p.png +0 -0
- package/dist/assets/robinhood-DgdGTQ1I.svg +8 -0
- package/dist/assets/tokens/arb.svg.js +4 -0
- package/dist/assets/tokens/dai.png.js +4 -0
- package/dist/assets/tokens/eth.svg.js +4 -0
- package/dist/assets/tokens/eurc.png.js +4 -0
- package/dist/assets/tokens/eure.png.js +4 -0
- package/dist/assets/tokens/index.js +36 -0
- package/dist/assets/tokens/op.png.js +4 -0
- package/dist/assets/tokens/pol.svg.js +4 -0
- package/dist/assets/tokens/raxol.png.js +4 -0
- package/dist/assets/tokens/usdc.png.js +4 -0
- package/dist/assets/tokens/usdg.png.js +4 -0
- package/dist/assets/tokens/usdt.png.js +4 -0
- package/dist/assets/tokens/wbtc.png.js +4 -0
- package/dist/assets/tokens/wsteth.png.js +4 -0
- package/dist/assets/tokens/zchf.png.js +4 -0
- package/dist/assets/tron-Dtumyzha.svg +4 -0
- package/dist/assets/usdc-UHSd0FoM.png +0 -0
- package/dist/assets/usdg-Cd5nCzbC.png +0 -0
- package/dist/assets/usdt-3G3YdPq8.png +0 -0
- package/dist/assets/venmo-CMHeCn-D.svg +1 -0
- package/dist/assets/wbtc-CV8uE44Q.png +0 -0
- package/dist/assets/wise-BUOflsWL.svg +1 -0
- package/dist/assets/wise-JLpDvCdq.png +0 -0
- package/dist/assets/wise-dark-_Q8pbCom.png +0 -0
- package/dist/assets/wsteth-BamwtTCR.png +0 -0
- package/dist/assets/xmoney-CwY9KVlD.svg +1 -0
- package/dist/assets/xochi-DL2f8G4R.svg +4 -0
- package/dist/assets/zchf-BLBNdTGJ.png +0 -0
- package/dist/assets/zelle-t15cG4SB.svg +1 -0
- package/dist/browser.js +4 -0
- package/dist/components/AccountChip.js +29 -0
- package/dist/components/ActivityFeed.js +710 -0
- package/dist/components/AssetsStrip.js +133 -0
- package/dist/components/AuthorizedAgents.js +197 -0
- package/dist/components/Chevron.js +22 -0
- package/dist/components/ErrorDisplay.js +68 -0
- package/dist/components/InfoButton.js +27 -0
- package/dist/components/IntentTimeline.js +202 -0
- package/dist/components/LinksSignIn.js +26 -0
- package/dist/components/MobileSigningBanner.js +44 -0
- package/dist/components/PrivacyBars.js +44 -0
- package/dist/components/PrivacyPanel.js +99 -0
- package/dist/components/QuoteDetails.js +327 -0
- package/dist/components/ReceiptCommand.js +46 -0
- package/dist/components/SessionReloadBanner.js +19 -0
- package/dist/components/SolverRace.js +62 -0
- package/dist/components/StealthClaims.js +179 -0
- package/dist/components/SwapFlowModal.js +408 -0
- package/dist/components/Toast.js +40 -0
- package/dist/components/TokenIcon.js +21 -0
- package/dist/components/TokenSearchModal.js +331 -0
- package/dist/components/TransactionPreview.js +230 -0
- package/dist/components/WalletProvider.js +41 -0
- package/dist/components/WrapModal.js +192 -0
- package/dist/components/swap-flow/CantonEscrowPanel.js +28 -0
- package/dist/components/swap-flow/CantonEscrowStatus.js +160 -0
- package/dist/components/swap-flow/DepositInstructions.js +156 -0
- package/dist/components/swap-flow/QrCode.js +22 -0
- package/dist/components/swap-flow/SwapResult.js +325 -0
- package/dist/components/swap-flow/depositScreen.js +36 -0
- package/dist/components/widgetTabsContext.js +17 -0
- package/dist/config.js +132 -0
- package/dist/configurator-model.js +71 -0
- package/dist/configurator.js +11 -0
- package/dist/constants.js +53 -0
- package/dist/hooks/applyTheme.js +10 -0
- package/dist/hooks/useAgentRegistry.js +28 -0
- package/dist/hooks/useAgentStream.js +89 -0
- package/dist/hooks/useCantonEscrow.js +89 -0
- package/dist/hooks/useCapabilities.js +86 -0
- package/dist/hooks/useEmbedLook.js +23 -0
- package/dist/hooks/useFocusTrap.js +44 -0
- package/dist/hooks/useIntent.js +485 -0
- package/dist/hooks/useIntentStatusPoll.js +71 -0
- package/dist/hooks/useIntentStream.js +95 -0
- package/dist/hooks/useLocalActivity.js +114 -0
- package/dist/hooks/useLocalSends.js +15 -0
- package/dist/hooks/useLocalStorage.js +26 -0
- package/dist/hooks/useOrderHistory.js +307 -0
- package/dist/hooks/usePermit.js +203 -0
- package/dist/hooks/usePrices.js +49 -0
- package/dist/hooks/usePublicBalances.js +186 -0
- package/dist/hooks/useRampSummaries.js +19 -0
- package/dist/hooks/useRecipientBalance.js +98 -0
- package/dist/hooks/useSettlements.js +33 -0
- package/dist/hooks/useStealth.js +324 -0
- package/dist/hooks/useStealthClaim.js +183 -0
- package/dist/hooks/useStealthScanner.js +259 -0
- package/dist/hooks/useTheme.js +48 -0
- package/dist/hooks/useTierInfo.js +20 -0
- package/dist/hooks/useTrustScore.js +16 -0
- package/dist/hooks/useWalletSession.js +70 -0
- package/dist/hooks/useWrapEth.js +60 -0
- package/dist/index.js +41 -0
- package/dist/integration.js +19 -0
- package/dist/lib/activityValue.js +20 -0
- package/dist/lib/agentConnect.js +11 -0
- package/dist/lib/agentRegistry.js +83 -0
- package/dist/lib/agentStreamVerify.js +47 -0
- package/dist/lib/api.js +67 -0
- package/dist/lib/auth.js +8 -0
- package/dist/lib/authFetch.js +33 -0
- package/dist/lib/aztecTokens.js +13 -0
- package/dist/lib/balances.js +77 -0
- package/dist/lib/capabilities.js +40 -0
- package/dist/lib/claimSubmitPoll.js +63 -0
- package/dist/lib/debug.js +7 -0
- package/dist/lib/declineGuidance.js +31 -0
- package/dist/lib/displayFallbacks.js +25 -0
- package/dist/lib/eip712.js +38 -0
- package/dist/lib/errorCategory.js +202 -0
- package/dist/lib/errorReport.js +19 -0
- package/dist/lib/explorerLinks.js +30 -0
- package/dist/lib/feesLabel.js +19 -0
- package/dist/lib/glyphs.js +58 -0
- package/dist/lib/hostBridge.js +41 -0
- package/dist/lib/hostOrigin.js +52 -0
- package/dist/lib/intentAPI.js +39 -0
- package/dist/lib/linksSignIn.js +9 -0
- package/dist/lib/localActivity.js +247 -0
- package/dist/lib/localSends.js +129 -0
- package/dist/lib/mobileWallet.js +17 -0
- package/dist/lib/pairAvailability.js +29 -0
- package/dist/lib/paymentSummary.js +23 -0
- package/dist/lib/permits.js +27 -0
- package/dist/lib/priceImpact.js +101 -0
- package/dist/lib/providers.js +124 -0
- package/dist/lib/qr.js +20 -0
- package/dist/lib/quoteCost.js +34 -0
- package/dist/lib/quoteCountdown.js +24 -0
- package/dist/lib/rampHostGate.js +24 -0
- package/dist/lib/rampLifecycle.js +63 -0
- package/dist/lib/receiptCost.js +64 -0
- package/dist/lib/recipient/index.js +302 -0
- package/dist/lib/recipient/recent.js +47 -0
- package/dist/lib/recipientReceipt.js +16 -0
- package/dist/lib/reportClient.js +32 -0
- package/dist/lib/sessionExpiry.js +11 -0
- package/dist/lib/settlementAvailability.js +34 -0
- package/dist/lib/stealth.js +110 -0
- package/dist/lib/swapFlowPhase.js +52 -0
- package/dist/lib/swapStatusCopy.js +59 -0
- package/dist/lib/tradeLifecycle.js +40 -0
- package/dist/lib/tronlink.js +71 -0
- package/dist/lib/walletSession.js +87 -0
- package/dist/pages/Configurator.js +390 -0
- package/dist/pages/Trade.js +635 -0
- package/dist/pages/configurator/AllowedAssetsSection.js +98 -0
- package/dist/pages/configurator/AppearanceSection.js +44 -0
- package/dist/pages/configurator/CodeDock.js +140 -0
- package/dist/pages/configurator/DeveloperSection.js +40 -0
- package/dist/pages/configurator/IntegrationSection.js +105 -0
- package/dist/pages/configurator/LayoutSection.js +83 -0
- package/dist/pages/configurator/PolicyNote.js +7 -0
- package/dist/pages/configurator/PreviewStage.js +165 -0
- package/dist/pages/configurator/PrivacySection.js +54 -0
- package/dist/pages/configurator/RouteSection.js +211 -0
- package/dist/pages/configurator/Settings.js +35 -0
- package/dist/pages/configurator/SharedLinkBanner.js +25 -0
- package/dist/pages/configurator/SurfaceSection.js +124 -0
- package/dist/pages/configurator/WhatUsersSee.js +268 -0
- package/dist/pages/configurator/codeShown.js +8 -0
- package/dist/pages/configurator/configuratorUrl.js +33 -0
- package/dist/pages/configurator/paramsDraft.js +82 -0
- package/dist/pages/configurator/previewModel.js +10 -0
- package/dist/pages/configurator/previewQuote.js +109 -0
- package/dist/pages/configurator/routePicks.js +131 -0
- package/dist/pages/configurator/snippets.js +98 -0
- package/dist/pages/configurator/surfaceParams.js +51 -0
- package/dist/pages/configurator/useCodeCheck.js +79 -0
- package/dist/pages/configurator/useConfiguratorUrl.js +24 -0
- package/dist/pages/configurator/useMediaQuery.js +20 -0
- package/dist/pages/configurator/useParamsDraft.js +33 -0
- package/dist/pages/configurator/usePreviewFee.js +100 -0
- package/dist/pages/send/MetaAddressValue.js +28 -0
- package/dist/pages/send/Receive.js +168 -0
- package/dist/pages/send/RecentRecipients.js +23 -0
- package/dist/pages/send/RecipientChip.js +26 -0
- package/dist/pages/send/ScanRecipient.js +85 -0
- package/dist/pages/send/SendForm.js +516 -0
- package/dist/pages/send/SendPanel.js +30 -0
- package/dist/pages/send/ShieldedDisclosure.js +12 -0
- package/dist/pages/send/StealthInvite.js +27 -0
- package/dist/pages/send/addressSend.js +92 -0
- package/dist/pages/send/sendCopy.js +10 -0
- package/dist/pages/send/sendRetry.js +24 -0
- package/dist/pages/send/stealthRecipient.js +65 -0
- package/dist/pages/send/stealthSend.js +15 -0
- package/dist/pages/send/useAddressSend.js +257 -0
- package/dist/pages/send/useSendRecipient.js +61 -0
- package/dist/pages/trade/BuyPanel.js +70 -0
- package/dist/pages/trade/RampRecovery.js +41 -0
- package/dist/pages/trade/RecipientSheet.js +182 -0
- package/dist/pages/trade/Selectors.js +152 -0
- package/dist/pages/trade/SwapPanel.js +972 -0
- package/dist/pages/trade/WidgetTabs.js +109 -0
- package/dist/pages/trade/canton.js +122 -0
- package/dist/pages/trade/config.js +70 -0
- package/dist/pages/trade/embedNarrowing.js +25 -0
- package/dist/pages/trade/embedParams.js +532 -0
- package/dist/pages/trade/embedTheme.js +9 -0
- package/dist/pages/trade/orderMinimum.js +8 -0
- package/dist/pages/trade/resumeSwap.js +55 -0
- package/dist/pages/trade/settlementCopy.js +32 -0
- package/dist/pages/trade/useAmountFit.js +31 -0
- package/dist/pages/trade/useEmbedDefaults.js +18 -0
- package/dist/pages/trade/useSettlementGating.js +289 -0
- package/dist/pages/trade/useSwapAmount.js +191 -0
- package/dist/pages/trade/useSwapFlow.js +511 -0
- package/dist/pages/trade/useSwapPanel.js +475 -0
- package/dist/pages/trade/useSwapRoute.js +634 -0
- package/dist/pages/trade/useTronLinkFill.js +34 -0
- package/dist/pages/trade/zkMoney.js +46 -0
- package/dist/promiseWithResolvers.js +20 -0
- package/dist/ramp/availability/RailTiles.js +156 -0
- package/dist/ramp/availability/RampDisclosure.js +38 -0
- package/dist/ramp/availability/RampRails.js +170 -0
- package/dist/ramp/availability/model.js +207 -0
- package/dist/ramp/availability/useRampDiscovery.js +83 -0
- package/dist/ramp/offramp/CompletedPrerequisite.js +23 -0
- package/dist/ramp/offramp/OfframpActivityList.js +16 -0
- package/dist/ramp/offramp/OfframpRoute.js +222 -0
- package/dist/ramp/offramp/OfframpRouteReview.js +94 -0
- package/dist/ramp/offramp/PaymentAppSend.js +765 -0
- package/dist/ramp/offramp/localOfframps.js +101 -0
- package/dist/ramp/offramp/model.js +154 -0
- package/dist/ramp/offramp/port.js +134 -0
- package/dist/ramp/offramp/prerequisite.js +143 -0
- package/dist/ramp/offramp/useOfframp.js +505 -0
- package/dist/ramp/offramp/useOfframpRails.js +73 -0
- package/dist/ramp/peer/BuyOnramp.js +292 -0
- package/dist/ramp/peer/OnrampSteps.js +148 -0
- package/dist/ramp/peer/buyerDriver.js +461 -0
- package/dist/ramp/peer/discovery.js +231 -0
- package/dist/ramp/peer/environment.js +7 -0
- package/dist/ramp/peer/liveProvider.js +87 -0
- package/dist/ramp/peer/liveReads.js +488 -0
- package/dist/ramp/peer/maker.js +92 -0
- package/dist/ramp/peer/normalization.js +184 -0
- package/dist/ramp/peer/offramp.js +648 -0
- package/dist/ramp/peer/onramp.js +353 -0
- package/dist/ramp/peer/preview.js +52 -0
- package/dist/ramp/peer/protectedMapping.js +67 -0
- package/dist/ramp/peer/runtime.js +55 -0
- package/dist/ramp/peer/sdkMaker.js +107 -0
- package/dist/ramp/recovery/ResumeOnramp.js +153 -0
- package/dist/ramp/recovery/summaries.js +173 -0
- package/dist/ramp/route/OnrampRoute.js +255 -0
- package/dist/ramp/route/RampRouteSteps.js +148 -0
- package/dist/ramp/route/routeActivity.js +12 -0
- package/dist/ramp/route/useXochiRampDriver.js +203 -0
- package/dist/styles.css +17473 -0
- package/dist/styles.js +2 -0
- package/dist/types/ConfiguratorApp.d.ts +6 -0
- package/dist/types/EmbedApp.d.ts +2 -0
- package/dist/types/activity.js +50 -0
- package/dist/types/asset.d.ts +2 -0
- package/dist/types/assets/chains/index.d.ts +3 -0
- package/dist/types/assets/rails/index.d.ts +12 -0
- package/dist/types/assets/tokens/index.d.ts +1 -0
- package/dist/types/browser.d.ts +1 -0
- package/dist/types/components/AccountChip.d.ts +10 -0
- package/dist/types/components/ActivityFeed.d.ts +46 -0
- package/dist/types/components/AssetsStrip.d.ts +14 -0
- package/dist/types/components/AuthorizedAgents.d.ts +15 -0
- package/dist/types/components/Chevron.d.ts +16 -0
- package/dist/types/components/ErrorDisplay.d.ts +46 -0
- package/dist/types/components/InfoButton.d.ts +6 -0
- package/dist/types/components/IntentTimeline.d.ts +41 -0
- package/dist/types/components/LinksSignIn.d.ts +13 -0
- package/dist/types/components/MobileSigningBanner.d.ts +16 -0
- package/dist/types/components/PermitBadge.d.ts +17 -0
- package/dist/types/components/PrivacyBars.d.ts +12 -0
- package/dist/types/components/PrivacyPanel.d.ts +33 -0
- package/dist/types/components/QuoteDetails.d.ts +56 -0
- package/dist/types/components/RampActivityList.d.ts +14 -0
- package/dist/types/components/ReceiptCommand.d.ts +12 -0
- package/dist/types/components/SessionReloadBanner.d.ts +8 -0
- package/dist/types/components/SolverRace.d.ts +35 -0
- package/dist/types/components/StealthClaims.d.ts +51 -0
- package/dist/types/components/SwapFlowModal.d.ts +142 -0
- package/dist/types/components/Toast.d.ts +10 -0
- package/dist/types/components/TokenIcon.d.ts +17 -0
- package/dist/types/components/TokenSearchModal.d.ts +28 -0
- package/dist/types/components/TransactionPreview.d.ts +37 -0
- package/dist/types/components/WalletProvider.d.ts +12 -0
- package/dist/types/components/WrapModal.d.ts +19 -0
- package/dist/types/components/swap-flow/CantonEscrowPanel.d.ts +14 -0
- package/dist/types/components/swap-flow/CantonEscrowStatus.d.ts +30 -0
- package/dist/types/components/swap-flow/DepositInstructions.d.ts +75 -0
- package/dist/types/components/swap-flow/QrCode.d.ts +18 -0
- package/dist/types/components/swap-flow/SwapResult.d.ts +68 -0
- package/dist/types/components/swap-flow/depositScreen.d.ts +67 -0
- package/dist/types/components/widgetTabsContext.d.ts +21 -0
- package/dist/types/config.d.ts +104 -0
- package/dist/types/configurator-model.d.ts +9 -0
- package/dist/types/configurator.d.ts +3 -0
- package/dist/types/constants.d.ts +52 -0
- package/dist/types/hooks/applyTheme.d.ts +7 -0
- package/dist/types/hooks/useAgentRegistry.d.ts +13 -0
- package/dist/types/hooks/useAgentStream.d.ts +15 -0
- package/dist/types/hooks/useCantonEscrow.d.ts +40 -0
- package/dist/types/hooks/useCapabilities.d.ts +83 -0
- package/dist/types/hooks/useEmbedLook.d.ts +4 -0
- package/dist/types/hooks/useFocusTrap.d.ts +7 -0
- package/dist/types/hooks/useIntent.d.ts +161 -0
- package/dist/types/hooks/useIntentStatusPoll.d.ts +107 -0
- package/dist/types/hooks/useIntentStream.d.ts +34 -0
- package/dist/types/hooks/useLocalActivity.d.ts +22 -0
- package/dist/types/hooks/useLocalSends.d.ts +8 -0
- package/dist/types/hooks/useLocalStorage.d.ts +8 -0
- package/dist/types/hooks/useOrderHistory.d.ts +52 -0
- package/dist/types/hooks/usePermit.d.ts +90 -0
- package/dist/types/hooks/usePrices.d.ts +72 -0
- package/dist/types/hooks/usePublicBalances.d.ts +19 -0
- package/dist/types/hooks/useRampSummaries.d.ts +9 -0
- package/dist/types/hooks/useRecipientBalance.d.ts +58 -0
- package/dist/types/hooks/useSettlements.d.ts +14 -0
- package/dist/types/hooks/useStealth.d.ts +72 -0
- package/dist/types/hooks/useStealthClaim.d.ts +96 -0
- package/dist/types/hooks/useStealthScanner.d.ts +44 -0
- package/dist/types/hooks/useTheme.d.ts +29 -0
- package/dist/types/hooks/useTierInfo.d.ts +23 -0
- package/dist/types/hooks/useTrustScore.d.ts +16 -0
- package/dist/types/hooks/useWalletSession.d.ts +21 -0
- package/dist/types/hooks/useWrapEth.d.ts +21 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +8 -0
- package/dist/types/integration.d.ts +9 -0
- package/dist/types/intent.js +85 -0
- package/dist/types/lib/activityValue.d.ts +16 -0
- package/dist/types/lib/agentConnect.d.ts +23 -0
- package/dist/types/lib/agentRegistry.d.ts +47 -0
- package/dist/types/lib/agentStreamVerify.d.ts +29 -0
- package/dist/types/lib/api.d.ts +41 -0
- package/dist/types/lib/auth.d.ts +6 -0
- package/dist/types/lib/authFetch.d.ts +14 -0
- package/dist/types/lib/aztecTokens.d.ts +15 -0
- package/dist/types/lib/balances.d.ts +88 -0
- package/dist/types/lib/capabilities.d.ts +3 -0
- package/dist/types/lib/claimSubmitPoll.d.ts +114 -0
- package/dist/types/lib/debug.d.ts +13 -0
- package/dist/types/lib/declineGuidance.d.ts +55 -0
- package/dist/types/lib/displayFallbacks.d.ts +7 -0
- package/dist/types/lib/eip712.d.ts +61 -0
- package/dist/types/lib/errorCategory.d.ts +50 -0
- package/dist/types/lib/errorReport.d.ts +15 -0
- package/dist/types/lib/explorerLinks.d.ts +67 -0
- package/dist/types/lib/feesLabel.d.ts +20 -0
- package/dist/types/lib/glyphs.d.ts +52 -0
- package/dist/types/lib/hostBridge.d.ts +11 -0
- package/dist/types/lib/hostOrigin.d.ts +30 -0
- package/dist/types/lib/intentAPI.d.ts +15 -0
- package/dist/types/lib/linksSignIn.d.ts +13 -0
- package/dist/types/lib/localActivity.d.ts +135 -0
- package/dist/types/lib/localSends.d.ts +55 -0
- package/dist/types/lib/mobileWallet.d.ts +27 -0
- package/dist/types/lib/pairAvailability.d.ts +106 -0
- package/dist/types/lib/paymentSummary.d.ts +18 -0
- package/dist/types/lib/permits.d.ts +25 -0
- package/dist/types/lib/priceImpact.d.ts +165 -0
- package/dist/types/lib/providers.d.ts +14 -0
- package/dist/types/lib/qr.d.ts +19 -0
- package/dist/types/lib/quoteCost.d.ts +45 -0
- package/dist/types/lib/quoteCountdown.d.ts +34 -0
- package/dist/types/lib/rampHostGate.d.ts +15 -0
- package/dist/types/lib/rampLifecycle.d.ts +20 -0
- package/dist/types/lib/receiptCost.d.ts +64 -0
- package/dist/types/lib/recipient/index.d.ts +33 -0
- package/dist/types/lib/recipient/recent.d.ts +5 -0
- package/dist/types/lib/recipientReceipt.d.ts +25 -0
- package/dist/types/lib/reportClient.d.ts +9 -0
- package/dist/types/lib/sessionExpiry.d.ts +11 -0
- package/dist/types/lib/settlementAvailability.d.ts +61 -0
- package/dist/types/lib/stealth.d.ts +75 -0
- package/dist/types/lib/swapFlowPhase.d.ts +76 -0
- package/dist/types/lib/swapStatusCopy.d.ts +57 -0
- package/dist/types/lib/tierProgressDisplay.d.ts +35 -0
- package/dist/types/lib/tierUnlock.d.ts +25 -0
- package/dist/types/lib/tradeLifecycle.d.ts +32 -0
- package/dist/types/lib/tronlink.d.ts +62 -0
- package/dist/types/lib/walletSession.d.ts +38 -0
- package/dist/types/pages/Configurator.d.ts +25 -0
- package/dist/types/pages/Trade.d.ts +36 -0
- package/dist/types/pages/configurator/AllowedAssetsSection.d.ts +17 -0
- package/dist/types/pages/configurator/AppearanceSection.d.ts +22 -0
- package/dist/types/pages/configurator/CodeDock.d.ts +19 -0
- package/dist/types/pages/configurator/DeveloperSection.d.ts +12 -0
- package/dist/types/pages/configurator/IntegrationSection.d.ts +20 -0
- package/dist/types/pages/configurator/LayoutSection.d.ts +20 -0
- package/dist/types/pages/configurator/PolicyNote.d.ts +6 -0
- package/dist/types/pages/configurator/PreviewStage.d.ts +22 -0
- package/dist/types/pages/configurator/PrivacySection.d.ts +16 -0
- package/dist/types/pages/configurator/RouteSection.d.ts +30 -0
- package/dist/types/pages/configurator/Settings.d.ts +25 -0
- package/dist/types/pages/configurator/SharedLinkBanner.d.ts +16 -0
- package/dist/types/pages/configurator/SurfaceSection.d.ts +5 -0
- package/dist/types/pages/configurator/WhatUsersSee.d.ts +30 -0
- package/dist/types/pages/configurator/codeShown.d.ts +15 -0
- package/dist/types/pages/configurator/configuratorUrl.d.ts +38 -0
- package/dist/types/pages/configurator/paramsDraft.d.ts +32 -0
- package/dist/types/pages/configurator/previewModel.d.ts +20 -0
- package/dist/types/pages/configurator/previewQuote.d.ts +96 -0
- package/dist/types/pages/configurator/routePicks.d.ts +75 -0
- package/dist/types/pages/configurator/snippets.d.ts +23 -0
- package/dist/types/pages/configurator/surfaceParams.d.ts +9 -0
- package/dist/types/pages/configurator/useCodeCheck.d.ts +56 -0
- package/dist/types/pages/configurator/useConfiguratorUrl.d.ts +21 -0
- package/dist/types/pages/configurator/useMediaQuery.d.ts +5 -0
- package/dist/types/pages/configurator/useParamsDraft.d.ts +29 -0
- package/dist/types/pages/configurator/usePreviewFee.d.ts +74 -0
- package/dist/types/pages/send/MetaAddressValue.d.ts +9 -0
- package/dist/types/pages/send/Receive.d.ts +3 -0
- package/dist/types/pages/send/RecentRecipients.d.ts +3 -0
- package/dist/types/pages/send/RecipientChip.d.ts +4 -0
- package/dist/types/pages/send/ScanRecipient.d.ts +3 -0
- package/dist/types/pages/send/SendForm.d.ts +17 -0
- package/dist/types/pages/send/SendPanel.d.ts +19 -0
- package/dist/types/pages/send/ShieldedDisclosure.d.ts +1 -0
- package/dist/types/pages/send/StealthInvite.d.ts +1 -0
- package/dist/types/pages/send/addressSend.d.ts +62 -0
- package/dist/types/pages/send/sendCopy.d.ts +9 -0
- package/dist/types/pages/send/sendRetry.d.ts +10 -0
- package/dist/types/pages/send/stealthRecipient.d.ts +37 -0
- package/dist/types/pages/send/stealthSend.d.ts +18 -0
- package/dist/types/pages/send/useAddressSend.d.ts +61 -0
- package/dist/types/pages/send/useSendRecipient.d.ts +13 -0
- package/dist/types/pages/trade/BuyPanel.d.ts +22 -0
- package/dist/types/pages/trade/RampRecovery.d.ts +22 -0
- package/dist/types/pages/trade/RecipientSheet.d.ts +11 -0
- package/dist/types/pages/trade/Selectors.d.ts +24 -0
- package/dist/types/pages/trade/SwapPanel.d.ts +34 -0
- package/dist/types/pages/trade/WidgetTabs.d.ts +46 -0
- package/dist/types/pages/trade/canton.d.ts +94 -0
- package/dist/types/pages/trade/config.d.ts +185 -0
- package/dist/types/pages/trade/embedNarrowing.d.ts +28 -0
- package/dist/types/pages/trade/embedParams.d.ts +299 -0
- package/dist/types/pages/trade/embedTheme.d.ts +14 -0
- package/dist/types/pages/trade/harness.d.ts +120 -0
- package/dist/types/pages/trade/orderMinimum.d.ts +5 -0
- package/dist/types/pages/trade/resumeSwap.d.ts +139 -0
- package/dist/types/pages/trade/settlementCopy.d.ts +42 -0
- package/dist/types/pages/trade/useAmountFit.d.ts +25 -0
- package/dist/types/pages/trade/useEmbedDefaults.d.ts +28 -0
- package/dist/types/pages/trade/useSettlementGating.d.ts +152 -0
- package/dist/types/pages/trade/useSwapAmount.d.ts +93 -0
- package/dist/types/pages/trade/useSwapFlow.d.ts +152 -0
- package/dist/types/pages/trade/useSwapPanel.d.ts +170 -0
- package/dist/types/pages/trade/useSwapRoute.d.ts +215 -0
- package/dist/types/pages/trade/useTronLinkFill.d.ts +13 -0
- package/dist/types/pages/trade/zkMoney.d.ts +28 -0
- package/dist/types/promiseWithResolvers.d.ts +12 -0
- package/dist/types/ramp/availability/RailTiles.d.ts +26 -0
- package/dist/types/ramp/availability/RampDisclosure.d.ts +9 -0
- package/dist/types/ramp/availability/RampRails.d.ts +27 -0
- package/dist/types/ramp/availability/model.d.ts +51 -0
- package/dist/types/ramp/availability/useRampDiscovery.d.ts +60 -0
- package/dist/types/ramp/offramp/CompletedPrerequisite.d.ts +5 -0
- package/dist/types/ramp/offramp/OfframpActivityList.d.ts +12 -0
- package/dist/types/ramp/offramp/OfframpRoute.d.ts +8 -0
- package/dist/types/ramp/offramp/OfframpRouteReview.d.ts +12 -0
- package/dist/types/ramp/offramp/PaymentAppSend.d.ts +27 -0
- package/dist/types/ramp/offramp/localOfframps.d.ts +58 -0
- package/dist/types/ramp/offramp/model.d.ts +46 -0
- package/dist/types/ramp/offramp/port.d.ts +55 -0
- package/dist/types/ramp/offramp/prerequisite.d.ts +271 -0
- package/dist/types/ramp/offramp/useOfframp.d.ts +87 -0
- package/dist/types/ramp/offramp/useOfframpRails.d.ts +36 -0
- package/dist/types/ramp/peer/BuyOnramp.d.ts +21 -0
- package/dist/types/ramp/peer/OnrampSteps.d.ts +32 -0
- package/dist/types/ramp/peer/buyerDriver.d.ts +48 -0
- package/dist/types/ramp/peer/discovery.d.ts +17 -0
- package/dist/types/ramp/peer/environment.d.ts +2 -0
- package/dist/types/ramp/peer/index.d.ts +14 -0
- package/dist/types/ramp/peer/liveProvider.d.ts +15 -0
- package/dist/types/ramp/peer/liveReads.d.ts +102 -0
- package/dist/types/ramp/peer/maker.d.ts +4 -0
- package/dist/types/ramp/peer/normalization.d.ts +33 -0
- package/dist/types/ramp/peer/offramp.d.ts +130 -0
- package/dist/types/ramp/peer/onramp.d.ts +134 -0
- package/dist/types/ramp/peer/preview.d.ts +14 -0
- package/dist/types/ramp/peer/protectedMapping.d.ts +22 -0
- package/dist/types/ramp/peer/runtime.d.ts +15 -0
- package/dist/types/ramp/peer/sdkMaker.d.ts +67 -0
- package/dist/types/ramp/peer/types.d.ts +64 -0
- package/dist/types/ramp/recovery/ResumeOnramp.d.ts +37 -0
- package/dist/types/ramp/recovery/summaries.d.ts +71 -0
- package/dist/types/ramp/route/OnrampRoute.d.ts +12 -0
- package/dist/types/ramp/route/RampRouteSteps.d.ts +16 -0
- package/dist/types/ramp/route/routeActivity.d.ts +4 -0
- package/dist/types/ramp/route/useXochiRampDriver.d.ts +22 -0
- package/dist/types/result.js +14 -0
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/types/activity.d.ts +184 -0
- package/dist/types/types/index.d.ts +20 -0
- package/dist/types/types/intent.d.ts +85 -0
- package/dist/types/types/result.d.ts +53 -0
- package/dist/types/utils/format.d.ts +88 -0
- package/dist/types/wagmi.d.ts +143 -0
- package/dist/types/widgetLibModule.d.ts +8 -0
- package/dist/utils/format.js +109 -0
- package/dist/wagmi.js +210 -0
- package/dist/widgetLibModule.js +4 -0
- package/licenses/Monaspace-OFL-1.1.txt +93 -0
- package/licenses/assets.json +132 -0
- package/licenses/rainbowkit-MIT.txt +9 -0
- package/licenses/xochi-shared-MIT.txt +21 -0
- package/package.json +115 -4
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { Chevron } from "../../components/Chevron.js";
|
|
4
|
+
import { PrivacyBars } from "../../components/PrivacyBars.js";
|
|
5
|
+
import { formatTokenAmount, safeBigInt } from "../../utils/format.js";
|
|
6
|
+
import { isSettlementAvailable } from "@xochi/client";
|
|
7
|
+
import { quoteCost } from "../../lib/quoteCost.js";
|
|
8
|
+
import { amountTooSmallGuidance, truncateServedReason } from "../../lib/declineGuidance.js";
|
|
9
|
+
import { stealthFixFor } from "../../lib/settlementAvailability.js";
|
|
10
|
+
import { STEALTH_SETTLEMENT_LIVE } from "../trade/config.js";
|
|
11
|
+
import { MODE_META, PAYOUT_GUARANTEE, SETTLEMENT_FIX_LINE } from "../trade/settlementCopy.js";
|
|
12
|
+
import { useMediaQuery } from "./useMediaQuery.js";
|
|
13
|
+
import { usePreviewFee } from "./usePreviewFee.js";
|
|
14
|
+
import { VISITOR_TRUST_SCORE } from "./previewQuote.js";
|
|
15
|
+
import { getErrorInfo } from "../../lib/errorCategory.js";
|
|
16
|
+
import { useCountdown } from "../../components/ErrorDisplay.js";
|
|
17
|
+
const SEES_COLUMN_MEDIA = "(min-width: 1280px)";
|
|
18
|
+
const MODES = [
|
|
19
|
+
{ mode: "public", name: "Public", bars: 1 },
|
|
20
|
+
{ mode: "stealth", name: "Stealth", bars: 2 },
|
|
21
|
+
{ mode: "shielded", name: "Shielded", bars: 3 }
|
|
22
|
+
];
|
|
23
|
+
function WhatUsersSee({ config }) {
|
|
24
|
+
const headingId = useId();
|
|
25
|
+
const bodyId = useId();
|
|
26
|
+
const column = useMediaQuery(SEES_COLUMN_MEDIA, true);
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const shown = column || open;
|
|
29
|
+
const {
|
|
30
|
+
fee,
|
|
31
|
+
prices,
|
|
32
|
+
routePrivacyModes,
|
|
33
|
+
capabilityState,
|
|
34
|
+
trustEconomicsLive,
|
|
35
|
+
retry,
|
|
36
|
+
retryingRoutes
|
|
37
|
+
} = usePreviewFee(config, shown);
|
|
38
|
+
const quote = fee.kind === "ready" ? fee.quote : null;
|
|
39
|
+
return /* @__PURE__ */ jsxs("section", { className: "config-sees", "aria-labelledby": headingId, children: [
|
|
40
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "config-sees__title", children: column ? "What users see" : /* @__PURE__ */ jsxs(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
type: "button",
|
|
44
|
+
className: "config-sees__toggle",
|
|
45
|
+
"aria-expanded": open,
|
|
46
|
+
"aria-controls": bodyId,
|
|
47
|
+
onClick: () => setOpen((v) => !v),
|
|
48
|
+
children: [
|
|
49
|
+
"What users see",
|
|
50
|
+
/* @__PURE__ */ jsx(Chevron, { open, className: "config-sees__chevron" })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
) }),
|
|
54
|
+
/* @__PURE__ */ jsxs("div", { id: bodyId, className: "config-sees__body", hidden: !shown, children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("section", { className: "config-sees__part", "aria-label": "Fee", children: [
|
|
56
|
+
/* @__PURE__ */ jsx("h3", { className: "config-sees__head", children: "Fee" }),
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
FeeBody,
|
|
59
|
+
{
|
|
60
|
+
fee,
|
|
61
|
+
config,
|
|
62
|
+
prices,
|
|
63
|
+
retry,
|
|
64
|
+
retryingRoutes,
|
|
65
|
+
trustEconomicsLive
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsxs("section", { className: "config-sees__part", "aria-label": "Privacy", children: [
|
|
70
|
+
/* @__PURE__ */ jsx("h3", { className: "config-sees__head", children: "Privacy" }),
|
|
71
|
+
/* @__PURE__ */ jsx("ul", { className: "config-sees__modes", children: MODES.map(({ mode, name, bars }) => /* @__PURE__ */ jsxs("li", { className: "config-sees__mode", "data-mode": mode, children: [
|
|
72
|
+
/* @__PURE__ */ jsx(PrivacyBars, { count: bars, active: mode === config.settlement }),
|
|
73
|
+
/* @__PURE__ */ jsxs("span", { className: "config-sees__mode-text", children: [
|
|
74
|
+
name,
|
|
75
|
+
": ",
|
|
76
|
+
MODE_META[mode],
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
ModeStatus,
|
|
79
|
+
{
|
|
80
|
+
mode,
|
|
81
|
+
config,
|
|
82
|
+
quote,
|
|
83
|
+
routePrivacyModes,
|
|
84
|
+
capabilityState
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] })
|
|
88
|
+
] }, mode)) })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsxs("section", { className: "config-sees__part", "aria-label": "Payout", children: [
|
|
91
|
+
/* @__PURE__ */ jsx("h3", { className: "config-sees__head", children: "Payout" }),
|
|
92
|
+
/* @__PURE__ */ jsx("p", { className: "config-sees__payout", children: PAYOUT_GUARANTEE })
|
|
93
|
+
] })
|
|
94
|
+
] })
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
function amountLabel(amount, symbol) {
|
|
98
|
+
return `${amount.text} ${symbol}`;
|
|
99
|
+
}
|
|
100
|
+
function FailedFee({ amount, symbol, error, retry }) {
|
|
101
|
+
const info = getErrorInfo(error);
|
|
102
|
+
const countdown = useCountdown(info.retryAfter);
|
|
103
|
+
const waiting = countdown !== null && countdown > 0;
|
|
104
|
+
return /* @__PURE__ */ jsxs("div", { className: "config-sees__failed", role: "status", children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
106
|
+
"Couldn't price ",
|
|
107
|
+
amountLabel(amount, symbol),
|
|
108
|
+
".",
|
|
109
|
+
" ",
|
|
110
|
+
[info.suggestion?.startsWith(info.message) ? void 0 : info.message, info.suggestion].filter((line) => Boolean(line)).map((line) => line.endsWith(".") ? line : `${line}.`).join(" ")
|
|
111
|
+
] }),
|
|
112
|
+
info.canRetry ? /* @__PURE__ */ jsx(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
className: "btn btn--secondary btn--sm",
|
|
117
|
+
onClick: retry,
|
|
118
|
+
disabled: waiting,
|
|
119
|
+
children: waiting ? `Retry in ${countdown}s` : "Retry"
|
|
120
|
+
}
|
|
121
|
+
) : null
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
function FeeBody({ fee, config, prices, retry, retryingRoutes, trustEconomicsLive }) {
|
|
125
|
+
const { fromToken, toToken } = config;
|
|
126
|
+
switch (fee.kind) {
|
|
127
|
+
case "no_amount":
|
|
128
|
+
return /* @__PURE__ */ jsx("p", { className: "config-sees__note", children: "Set an amount in Route to see the fee." });
|
|
129
|
+
case "needs_recipient":
|
|
130
|
+
return /* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
131
|
+
"Priced once the user enters a ",
|
|
132
|
+
fee.chainName,
|
|
133
|
+
" recipient address."
|
|
134
|
+
] });
|
|
135
|
+
case "unconfirmed": {
|
|
136
|
+
const copy = {
|
|
137
|
+
stale: "Route data is stale.",
|
|
138
|
+
fallback: "Live routes have not loaded.",
|
|
139
|
+
failed: "Routes could not be loaded.",
|
|
140
|
+
route: "This route does not advertise the selected privacy mode.",
|
|
141
|
+
private: "Stealth pricing starts after the visitor connects a wallet."
|
|
142
|
+
}[fee.reason];
|
|
143
|
+
const retryable = fee.reason === "stale" || fee.reason === "fallback" || fee.reason === "failed";
|
|
144
|
+
return /* @__PURE__ */ jsxs("div", { className: "config-sees__failed", role: "status", children: [
|
|
145
|
+
/* @__PURE__ */ jsx("p", { className: "config-sees__note", children: copy }),
|
|
146
|
+
retryable ? /* @__PURE__ */ jsx(
|
|
147
|
+
"button",
|
|
148
|
+
{
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "btn btn--secondary btn--sm",
|
|
151
|
+
onClick: retry,
|
|
152
|
+
disabled: retryingRoutes,
|
|
153
|
+
children: retryingRoutes ? "Retrying..." : "Retry routes"
|
|
154
|
+
}
|
|
155
|
+
) : null
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
case "out_of_bounds":
|
|
159
|
+
return /* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
160
|
+
"At ",
|
|
161
|
+
amountLabel(fee.amount, fromToken.symbol),
|
|
162
|
+
": ",
|
|
163
|
+
fee.notice
|
|
164
|
+
] });
|
|
165
|
+
case "loading":
|
|
166
|
+
return /* @__PURE__ */ jsxs("p", { className: "config-sees__note", role: "status", children: [
|
|
167
|
+
"Pricing ",
|
|
168
|
+
amountLabel(fee.amount, fromToken.symbol),
|
|
169
|
+
"..."
|
|
170
|
+
] });
|
|
171
|
+
case "failed":
|
|
172
|
+
return /* @__PURE__ */ jsx(FailedFee, { amount: fee.amount, symbol: fromToken.symbol, error: fee.error, retry });
|
|
173
|
+
case "declined": {
|
|
174
|
+
const guidance = amountTooSmallGuidance({
|
|
175
|
+
quote: fee.quote,
|
|
176
|
+
fromSymbol: fromToken.symbol,
|
|
177
|
+
fromPriceUsd: prices[fromToken.symbol]
|
|
178
|
+
});
|
|
179
|
+
return /* @__PURE__ */ jsxs("div", { role: "status", children: [
|
|
180
|
+
/* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
181
|
+
"No fill at ",
|
|
182
|
+
amountLabel(fee.amount, fromToken.symbol),
|
|
183
|
+
fee.quote.error ? `: ${truncateServedReason(fee.quote.error)}` : "."
|
|
184
|
+
] }),
|
|
185
|
+
guidance?.minimumUsd != null ? /* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
186
|
+
"Minimum right now: about $",
|
|
187
|
+
guidance.minimumUsd.toFixed(2),
|
|
188
|
+
"."
|
|
189
|
+
] }) : null
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
case "ready": {
|
|
193
|
+
const cost = quoteCost(fee.quote, {
|
|
194
|
+
fromAmount: fee.amount.baseUnits,
|
|
195
|
+
fromSymbol: fromToken.symbol,
|
|
196
|
+
fromDecimals: fromToken.decimals,
|
|
197
|
+
toSymbol: toToken.symbol,
|
|
198
|
+
toDecimals: toToken.decimals,
|
|
199
|
+
trustScore: VISITOR_TRUST_SCORE,
|
|
200
|
+
fromPriceUsd: prices[fromToken.symbol]
|
|
201
|
+
});
|
|
202
|
+
const receives = `${formatTokenAmount(safeBigInt(fee.quote.toAmount), toToken.decimals, 6)} ${toToken.symbol}`;
|
|
203
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
204
|
+
/* @__PURE__ */ jsxs("dl", { className: "config-sees__rows", "aria-live": "polite", children: [
|
|
205
|
+
/* @__PURE__ */ jsxs("div", { className: "config-sees__row", children: [
|
|
206
|
+
/* @__PURE__ */ jsx("dt", { children: "They send" }),
|
|
207
|
+
/* @__PURE__ */ jsx("dd", { children: amountLabel(fee.amount, fromToken.symbol) })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ jsxs("div", { className: "config-sees__row", children: [
|
|
210
|
+
/* @__PURE__ */ jsx("dt", { children: "They receive" }),
|
|
211
|
+
/* @__PURE__ */ jsx("dd", { children: receives })
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ jsxs("div", { className: "config-sees__row config-sees__row--total", children: [
|
|
214
|
+
/* @__PURE__ */ jsx("dt", { children: "Indicative fees (incl. network)" }),
|
|
215
|
+
/* @__PURE__ */ jsx("dd", { children: cost.feesLabel })
|
|
216
|
+
] })
|
|
217
|
+
] }),
|
|
218
|
+
/* @__PURE__ */ jsxs("p", { className: "config-sees__note", children: [
|
|
219
|
+
"Indicative, for",
|
|
220
|
+
" ",
|
|
221
|
+
fee.amount.referenceUsd === null ? "the default amount" : `a $${fee.amount.referenceUsd} reference order`,
|
|
222
|
+
" ",
|
|
223
|
+
"at the Standard tier",
|
|
224
|
+
trustEconomicsLive ? "; higher tiers pay less" : "",
|
|
225
|
+
". The signed quote is priced again.",
|
|
226
|
+
config.settlement === "stealth" ? " Stealth is priced after the user sets up stealth keys." : ""
|
|
227
|
+
] })
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function ModeStatus({ mode, config, quote, routePrivacyModes, capabilityState }) {
|
|
233
|
+
const routeAvailable = isSettlementAvailable(quote?.settlementOptions, mode);
|
|
234
|
+
const exactRouteKnown = capabilityState === "live";
|
|
235
|
+
const routeAdvertisesPublic = exactRouteKnown && routePrivacyModes.includes("public");
|
|
236
|
+
const routeAdvertisesStealth = exactRouteKnown && routePrivacyModes.includes("stealth");
|
|
237
|
+
exactRouteKnown && routePrivacyModes.includes("shielded");
|
|
238
|
+
const routeFix = exactRouteKnown ? "route" : "route_unavailable";
|
|
239
|
+
const fixes = mode === "public" ? [routeAdvertisesPublic ? null : routeFix] : mode === "stealth" ? [false, true].map(
|
|
240
|
+
(connected) => stealthFixFor({
|
|
241
|
+
live: STEALTH_SETTLEMENT_LIVE,
|
|
242
|
+
stealthChainsKnown: exactRouteKnown,
|
|
243
|
+
capabilitiesLoading: false,
|
|
244
|
+
hasStealthChains: routeAdvertisesStealth,
|
|
245
|
+
connected,
|
|
246
|
+
metaAddressReady: false,
|
|
247
|
+
destinationSupported: routeAdvertisesStealth,
|
|
248
|
+
routeAvailable
|
|
249
|
+
})
|
|
250
|
+
) : [
|
|
251
|
+
"unavailable"
|
|
252
|
+
];
|
|
253
|
+
const steps = fixes.filter((fix) => fix !== null).map((fix) => SETTLEMENT_FIX_LINE[fix]);
|
|
254
|
+
const unique = steps.filter((line, i) => steps.indexOf(line) === i);
|
|
255
|
+
const opens = mode === config.settlement;
|
|
256
|
+
if (!opens && unique.length === 0) return null;
|
|
257
|
+
return /* @__PURE__ */ jsxs("span", { className: "config-sees__mode-status", children: [
|
|
258
|
+
opens ? /* @__PURE__ */ jsx("span", { className: "config-sees__badge", children: "Default" }) : null,
|
|
259
|
+
unique.length > 0 ? (
|
|
260
|
+
// One clause each: `Connect a wallet, then choose a Stealth chain`.
|
|
261
|
+
/* @__PURE__ */ jsx("span", { children: unique.map((line, i) => i === 0 ? line : line[0].toLowerCase() + line.slice(1)).join(", then ") })
|
|
262
|
+
) : null
|
|
263
|
+
] });
|
|
264
|
+
}
|
|
265
|
+
export {
|
|
266
|
+
SEES_COLUMN_MEDIA,
|
|
267
|
+
WhatUsersSee
|
|
268
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { embedOverrides } from "../trade/embedParams.js";
|
|
2
|
+
import { encodeEmbedParams, parseEmbedParams } from "@xochi/widget-lib";
|
|
3
|
+
import { DEFAULT_BACKDROP, PREVIEW_DEVICES, BACKDROP_KINDS } from "./previewModel.js";
|
|
4
|
+
const VIEW_PARAM = { backdrop: "bg", color: "bgColor", device: "device" };
|
|
5
|
+
const HEX = /^[0-9a-f]{6}$/i;
|
|
6
|
+
function readConfiguratorSearch(search) {
|
|
7
|
+
const query = new URLSearchParams(search);
|
|
8
|
+
const kind = BACKDROP_KINDS.find((k) => k === query.get(VIEW_PARAM.backdrop));
|
|
9
|
+
const color = query.get(VIEW_PARAM.color) ?? "";
|
|
10
|
+
return {
|
|
11
|
+
params: parseEmbedParams(search),
|
|
12
|
+
backdrop: {
|
|
13
|
+
kind: kind ?? DEFAULT_BACKDROP.kind,
|
|
14
|
+
custom: HEX.test(color) ? `#${color.toLowerCase()}` : DEFAULT_BACKDROP.custom
|
|
15
|
+
},
|
|
16
|
+
device: PREVIEW_DEVICES.find((d) => d === query.get(VIEW_PARAM.device)) ?? PREVIEW_DEVICES[0]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function configuratorSearch(config, backdrop, device, params = embedOverrides(config)) {
|
|
20
|
+
const query = new URLSearchParams(encodeEmbedParams(params));
|
|
21
|
+
if (backdrop.kind !== DEFAULT_BACKDROP.kind) query.set(VIEW_PARAM.backdrop, backdrop.kind);
|
|
22
|
+
if (backdrop.custom !== DEFAULT_BACKDROP.custom) {
|
|
23
|
+
query.set(VIEW_PARAM.color, backdrop.custom.replace(/^#/, ""));
|
|
24
|
+
}
|
|
25
|
+
if (device !== PREVIEW_DEVICES[0]) query.set(VIEW_PARAM.device, device);
|
|
26
|
+
const search = query.toString();
|
|
27
|
+
return search === "" ? "" : `?${search}`;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
VIEW_PARAM,
|
|
31
|
+
configuratorSearch,
|
|
32
|
+
readConfiguratorSearch
|
|
33
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { embedOverrides, EMBED_PARAM_HINT, explainEmbedDefaults, FRAME_FIELDS } from "../trade/embedParams.js";
|
|
2
|
+
import { encodeEmbedParams, parseEmbedParams, EMBED_PARAM } from "@xochi/widget-lib";
|
|
3
|
+
import { surfaceParams, SURFACE_FIELDS } from "./surfaceParams.js";
|
|
4
|
+
const EMPTY_NARROWING_FIELDS = [
|
|
5
|
+
"tabs",
|
|
6
|
+
"modes",
|
|
7
|
+
"sendDestinations",
|
|
8
|
+
"rampProviders"
|
|
9
|
+
];
|
|
10
|
+
const PARAM_HINT = {
|
|
11
|
+
...EMBED_PARAM_HINT,
|
|
12
|
+
initialTab: { takes: "a visible tab", example: "initialTab=trade" },
|
|
13
|
+
tabs: { takes: "visible tabs", example: "tabs=trade,send" },
|
|
14
|
+
initialMode: { takes: "a visible Trade mode", example: "initialMode=offramp" },
|
|
15
|
+
modes: { takes: "Trade modes", example: "modes=onramp,swap,offramp" },
|
|
16
|
+
sendDestinations: {
|
|
17
|
+
takes: "Send destination kinds",
|
|
18
|
+
example: "sendDestinations=address,stealth"
|
|
19
|
+
},
|
|
20
|
+
fiatCurrency: { takes: "a three-letter currency code", example: "fiatCurrency=USD" },
|
|
21
|
+
rampProviders: { takes: "provider identifiers", example: "rampProviders=peer" }
|
|
22
|
+
};
|
|
23
|
+
const FIELD_BY_KEY = Object.fromEntries(
|
|
24
|
+
[...FRAME_FIELDS, ...SURFACE_FIELDS].map((field) => [EMBED_PARAM[field], field])
|
|
25
|
+
);
|
|
26
|
+
const PARAM_KEYS = [...FRAME_FIELDS, ...SURFACE_FIELDS].map((field) => EMBED_PARAM[field]).join(", ");
|
|
27
|
+
function paramsText(config, params = embedOverrides(config)) {
|
|
28
|
+
return Array.from(
|
|
29
|
+
new URLSearchParams(encodeEmbedParams(params)),
|
|
30
|
+
([key, value]) => `${key}=${value}`
|
|
31
|
+
).join("\n");
|
|
32
|
+
}
|
|
33
|
+
function draftEntries(text) {
|
|
34
|
+
return text.split("\n").flatMap((raw) => {
|
|
35
|
+
const line = raw.replace(/#.*$/, "").trim();
|
|
36
|
+
const query = line.includes("?") ? line.slice(line.indexOf("?") + 1) : /^(?:[a-z][a-z0-9+.-]*:\/\/|\/)/i.test(line) ? "" : line;
|
|
37
|
+
return Array.from(new URLSearchParams(query), ([key, value]) => [
|
|
38
|
+
key.trim(),
|
|
39
|
+
value.trim()
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function readParamsDraft(text, offer) {
|
|
44
|
+
const problems = [];
|
|
45
|
+
const accepted = new URLSearchParams();
|
|
46
|
+
for (const [key, value] of draftEntries(text)) {
|
|
47
|
+
const field = Object.prototype.hasOwnProperty.call(FIELD_BY_KEY, key) ? FIELD_BY_KEY[key] : void 0;
|
|
48
|
+
if (field === void 0) {
|
|
49
|
+
problems.push(`Unknown parameter "${key}". The widget reads ${PARAM_KEYS}.`);
|
|
50
|
+
} else if (accepted.has(key)) {
|
|
51
|
+
problems.push(`${key} is set twice. Keep one.`);
|
|
52
|
+
} else if (value === "" && !EMPTY_NARROWING_FIELDS.includes(field)) {
|
|
53
|
+
const { takes, example } = PARAM_HINT[field];
|
|
54
|
+
problems.push(`${key} needs a value: ${takes}, like ${example}.`);
|
|
55
|
+
} else if (parseEmbedParams(new URLSearchParams([[key, value]]).toString())[field] === void 0) {
|
|
56
|
+
const { takes, example } = PARAM_HINT[field];
|
|
57
|
+
problems.push(`${key}=${value} is not valid. It takes ${takes}, like ${example}.`);
|
|
58
|
+
} else {
|
|
59
|
+
accepted.set(key, value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const params = parseEmbedParams(accepted.toString());
|
|
63
|
+
const normalized = surfaceParams(params);
|
|
64
|
+
for (const field of ["initialTab", "initialMode"]) {
|
|
65
|
+
if (params[field] !== normalized[field])
|
|
66
|
+
problems.push(`${field} must belong to its visible options.`);
|
|
67
|
+
}
|
|
68
|
+
const { ignored } = explainEmbedDefaults(params, offer);
|
|
69
|
+
for (const field of FRAME_FIELDS) {
|
|
70
|
+
const why = ignored[field];
|
|
71
|
+
if (why === void 0) continue;
|
|
72
|
+
const key = EMBED_PARAM[field];
|
|
73
|
+
problems.push(`The widget would ignore ${key}=${accepted.get(key) ?? ""}: ${why}.`);
|
|
74
|
+
}
|
|
75
|
+
return { params, problems };
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
FIELD_BY_KEY,
|
|
79
|
+
PARAM_KEYS,
|
|
80
|
+
paramsText,
|
|
81
|
+
readParamsDraft
|
|
82
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const PHONE_WIDTH = 390;
|
|
2
|
+
const BACKDROP_KINDS = ["light", "dark", "checker", "custom"];
|
|
3
|
+
const DEFAULT_BACKDROP = { kind: "checker", custom: "#58a1c6" };
|
|
4
|
+
const PREVIEW_DEVICES = ["desktop", "phone"];
|
|
5
|
+
export {
|
|
6
|
+
BACKDROP_KINDS,
|
|
7
|
+
DEFAULT_BACKDROP,
|
|
8
|
+
PHONE_WIDTH,
|
|
9
|
+
PREVIEW_DEVICES
|
|
10
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { EXTENDED_CHAIN_NAMES, orderBounds, buildQuoteRequest, DEFAULT_SLIPPAGE_BPS, validateSwapParams, resolveRouteModel, isStableSymbol } from "@xochi/client";
|
|
2
|
+
import { parseTokenAmount } from "../../utils/format.js";
|
|
3
|
+
import { estimateUsdFrom } from "../../hooks/usePrices.js";
|
|
4
|
+
import { TOKENS, chainEnabledForRole } from "../trade/config.js";
|
|
5
|
+
import { minimumOrderNotice } from "../trade/orderMinimum.js";
|
|
6
|
+
import { legVmType } from "../trade/useSwapRoute.js";
|
|
7
|
+
const VISITOR_TRUST_SCORE = 0;
|
|
8
|
+
const PREVIEW_DEADLINE_SECS = 3600;
|
|
9
|
+
const REFERENCE_ORDER_USD = 100;
|
|
10
|
+
const CHAIN_NAMES = EXTENDED_CHAIN_NAMES;
|
|
11
|
+
function toBaseUnits(text, decimals) {
|
|
12
|
+
try {
|
|
13
|
+
const units = parseTokenAmount(text, decimals);
|
|
14
|
+
return units > 0n ? units.toString() : null;
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function referenceAmount(token, bounds, inputs) {
|
|
20
|
+
const usd = Math.min(Math.max(REFERENCE_ORDER_USD, bounds.min), bounds.max);
|
|
21
|
+
if (!Number.isFinite(usd) || usd <= 0) return null;
|
|
22
|
+
if (isStableSymbol(token.symbol)) return { text: String(usd), usd };
|
|
23
|
+
const price = inputs.pricesLive ? inputs.prices[token.symbol] : void 0;
|
|
24
|
+
if (price === void 0 || !Number.isFinite(price) || price <= 0) return null;
|
|
25
|
+
const exact = usd / price;
|
|
26
|
+
const step = 10 ** (Math.floor(Math.log10(exact)) - 1);
|
|
27
|
+
const round = usd >= bounds.max ? Math.floor : Math.ceil;
|
|
28
|
+
const tokens = Number((round(exact / step) * step).toPrecision(2));
|
|
29
|
+
const text = tokens.toLocaleString("en-US", {
|
|
30
|
+
useGrouping: false,
|
|
31
|
+
maximumFractionDigits: Math.min(token.decimals, 8)
|
|
32
|
+
});
|
|
33
|
+
return { text, usd };
|
|
34
|
+
}
|
|
35
|
+
function previewRouteAvailability(config, inputs) {
|
|
36
|
+
return resolveRouteModel(inputs.capabilities, inputs.capabilityState, {
|
|
37
|
+
chainEnabledForRole,
|
|
38
|
+
presentationTokens: TOKENS
|
|
39
|
+
}).resolve(
|
|
40
|
+
{ chainId: config.fromChainId, token: config.fromToken },
|
|
41
|
+
{ kind: "chain", chainId: config.toChainId, token: config.toToken }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function previewPlan(config, inputs) {
|
|
45
|
+
const availability = previewRouteAvailability(config, inputs);
|
|
46
|
+
const routePrivacyModes = availability.status === "available" ? availability.privacyModes : [];
|
|
47
|
+
if (availability.status !== "available") {
|
|
48
|
+
return {
|
|
49
|
+
kind: "unconfirmed",
|
|
50
|
+
reason: inputs.capabilityState === "live" ? "route" : inputs.capabilityState,
|
|
51
|
+
routePrivacyModes
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!routePrivacyModes.includes(config.settlement)) {
|
|
55
|
+
return { kind: "unconfirmed", reason: "route", routePrivacyModes };
|
|
56
|
+
}
|
|
57
|
+
if (config.settlement === "stealth") {
|
|
58
|
+
return { kind: "unconfirmed", reason: "private", routePrivacyModes };
|
|
59
|
+
}
|
|
60
|
+
if (legVmType(inputs.capabilities, config.toChainId) !== "evm") {
|
|
61
|
+
return {
|
|
62
|
+
kind: "needs_recipient",
|
|
63
|
+
chainName: CHAIN_NAMES[config.toChainId] ?? "that chain",
|
|
64
|
+
routePrivacyModes
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const { symbol, decimals } = config.fromToken;
|
|
68
|
+
const bounds = orderBounds(inputs.capabilities);
|
|
69
|
+
const reference = config.amount === "" ? referenceAmount(config.fromToken, bounds, inputs) : null;
|
|
70
|
+
const text = config.amount === "" ? reference?.text ?? null : config.amount;
|
|
71
|
+
const baseUnits = text === null ? null : toBaseUnits(text, decimals);
|
|
72
|
+
if (text === null || baseUnits === null) {
|
|
73
|
+
return { kind: "no_amount", routePrivacyModes };
|
|
74
|
+
}
|
|
75
|
+
const amount = { text, baseUnits, referenceUsd: reference?.usd ?? null };
|
|
76
|
+
const notice = reference === null ? minimumOrderNotice(estimateUsdFrom(inputs.prices, text, symbol) ?? 0, bounds.min) : null;
|
|
77
|
+
if (notice !== null) return { kind: "out_of_bounds", amount, notice, routePrivacyModes };
|
|
78
|
+
const key = [
|
|
79
|
+
config.fromChainId,
|
|
80
|
+
config.toChainId,
|
|
81
|
+
config.fromToken.address.toLowerCase(),
|
|
82
|
+
config.toToken.address.toLowerCase(),
|
|
83
|
+
baseUnits
|
|
84
|
+
].join(":");
|
|
85
|
+
return { kind: "quote", amount, key, routePrivacyModes };
|
|
86
|
+
}
|
|
87
|
+
function previewQuoteRequest(config, amount, nowMs) {
|
|
88
|
+
const request = buildQuoteRequest({
|
|
89
|
+
preview: true,
|
|
90
|
+
fromChainId: config.fromChainId,
|
|
91
|
+
toChainId: config.toChainId,
|
|
92
|
+
fromToken: config.fromToken.address,
|
|
93
|
+
toToken: config.toToken.address,
|
|
94
|
+
fromAmount: amount.baseUnits,
|
|
95
|
+
deadline: Math.floor(nowMs / 1e3) + PREVIEW_DEADLINE_SECS,
|
|
96
|
+
slippageBps: DEFAULT_SLIPPAGE_BPS,
|
|
97
|
+
trustScore: VISITOR_TRUST_SCORE,
|
|
98
|
+
settlementPreference: "public"
|
|
99
|
+
});
|
|
100
|
+
const validation = validateSwapParams(request, nowMs);
|
|
101
|
+
return validation.isValid ? { ok: true, request } : { ok: false, error: validation.errors[0] ?? "Invalid swap parameters" };
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
REFERENCE_ORDER_USD,
|
|
105
|
+
VISITOR_TRUST_SCORE,
|
|
106
|
+
previewPlan,
|
|
107
|
+
previewQuoteRequest,
|
|
108
|
+
previewRouteAvailability
|
|
109
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { legTokens, chainName, legTokenAllowed, routeFills } from "../trade/embedParams.js";
|
|
2
|
+
import { routeFlipBlockedReason, pickDefaultToken } from "../trade/useSwapRoute.js";
|
|
3
|
+
function buyTokens(offer, fromChainId, fromToken, toChainId) {
|
|
4
|
+
return legTokens(offer, toChainId, "buy").filter(
|
|
5
|
+
(toToken) => routeFills(offer, { fromChainId, toChainId, fromToken, toToken })
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
function changeRoute(offer, current, change) {
|
|
9
|
+
const fromChainId = change.fromChainId ?? current.fromChainId;
|
|
10
|
+
const toChainId = change.toChainId ?? current.toChainId;
|
|
11
|
+
const sells = legTokens(offer, fromChainId, "sell");
|
|
12
|
+
if (sells.length === 0) return null;
|
|
13
|
+
const sellSymbol = change.sellSymbol ?? current.fromToken.symbol;
|
|
14
|
+
const fromToken = sells.find((t) => t.symbol === sellSymbol) ?? pickDefaultToken(sells, offer.originSymbols);
|
|
15
|
+
const buys = buyTokens(offer, fromChainId, fromToken, toChainId);
|
|
16
|
+
const buySymbol = change.buySymbol ?? current.toToken.symbol;
|
|
17
|
+
const toToken = buys.find((t) => t.symbol === buySymbol) ?? buys.find((t) => t.symbol === fromToken.symbol) ?? buys[0];
|
|
18
|
+
if (!toToken) return null;
|
|
19
|
+
return { fromChainId, toChainId, sellSymbol: fromToken.symbol, buySymbol: toToken.symbol };
|
|
20
|
+
}
|
|
21
|
+
function routeRefusal(offer, route) {
|
|
22
|
+
const resolution = offer.routeModel.resolve(
|
|
23
|
+
{ chainId: route.fromChainId, token: route.fromToken },
|
|
24
|
+
{ kind: "chain", chainId: route.toChainId, token: route.toToken }
|
|
25
|
+
);
|
|
26
|
+
return resolution.status === "available" ? null : resolution.reason;
|
|
27
|
+
}
|
|
28
|
+
const unsupported = (reason) => reason === void 0 ? { state: "unsupported" } : { state: "unsupported", reason };
|
|
29
|
+
function offeredChain(offer, leg, chainId) {
|
|
30
|
+
const chains = leg === "sell" ? offer.sourceChainIds : offer.destinationChainIds;
|
|
31
|
+
return chains.find((id) => id === chainId) ?? null;
|
|
32
|
+
}
|
|
33
|
+
function allowListPolicy(config) {
|
|
34
|
+
return {
|
|
35
|
+
locks: [],
|
|
36
|
+
fromChains: config.fromChains,
|
|
37
|
+
toChains: config.toChains,
|
|
38
|
+
sellTokens: config.sellTokens,
|
|
39
|
+
buyTokens: config.buyTokens
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function tokenAvailability(offer, config, leg, token) {
|
|
43
|
+
if (!legTokenAllowed(allowListPolicy(config), leg, token, token.chainId)) {
|
|
44
|
+
return unsupported(
|
|
45
|
+
`Allowed assets leave ${token.symbol} out of the ${leg === "sell" ? "send" : "receive"} tokens.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const chainId = offeredChain(offer, leg, token.chainId);
|
|
49
|
+
if (chainId === null) return unsupported();
|
|
50
|
+
if (leg === "sell") {
|
|
51
|
+
const route = {
|
|
52
|
+
fromChainId: chainId,
|
|
53
|
+
toChainId: config.toChainId,
|
|
54
|
+
fromToken: token,
|
|
55
|
+
toToken: config.toToken
|
|
56
|
+
};
|
|
57
|
+
if (!legTokens(offer, chainId, "sell").some((t) => t.symbol === token.symbol)) {
|
|
58
|
+
return unsupported(routeRefusal(offer, route) ?? void 0);
|
|
59
|
+
}
|
|
60
|
+
const next = changeRoute(offer, config, { fromChainId: chainId, sellSymbol: token.symbol });
|
|
61
|
+
return next === null ? unsupported(routeRefusal(offer, route) ?? void 0) : { state: "available" };
|
|
62
|
+
}
|
|
63
|
+
if (!legTokens(offer, chainId, "buy").some((t) => t.symbol === token.symbol)) {
|
|
64
|
+
return unsupported();
|
|
65
|
+
}
|
|
66
|
+
const refusal = routeRefusal(offer, {
|
|
67
|
+
fromChainId: config.fromChainId,
|
|
68
|
+
toChainId: chainId,
|
|
69
|
+
fromToken: config.fromToken,
|
|
70
|
+
toToken: token
|
|
71
|
+
});
|
|
72
|
+
return refusal === null ? { state: "available" } : unsupported(refusal);
|
|
73
|
+
}
|
|
74
|
+
function chainRefusal(offer, config, leg, chainId) {
|
|
75
|
+
const id = offeredChain(offer, leg, chainId);
|
|
76
|
+
const nothing = `Nothing can be ${leg === "sell" ? "sent from" : "delivered to"} ${chainName(chainId)} here.`;
|
|
77
|
+
if (id === null) return nothing;
|
|
78
|
+
const change = leg === "sell" ? { fromChainId: id } : { toChainId: id };
|
|
79
|
+
if (changeRoute(offer, config, change) !== null) return null;
|
|
80
|
+
const current = leg === "sell" ? config.fromToken : config.toToken;
|
|
81
|
+
const tokens = legTokens(offer, id, leg);
|
|
82
|
+
if (tokens.length === 0) return nothing;
|
|
83
|
+
const moved = tokens.find((t) => t.symbol === current.symbol) ?? pickDefaultToken(tokens, leg === "sell" ? offer.originSymbols : offer.destinationSymbols);
|
|
84
|
+
const route = leg === "sell" ? { ...config, fromChainId: id, fromToken: moved } : { ...config, toChainId: id, toToken: moved };
|
|
85
|
+
return routeRefusal(offer, route) ?? nothing;
|
|
86
|
+
}
|
|
87
|
+
function flipRoute(offer, config) {
|
|
88
|
+
const pair = {
|
|
89
|
+
fromChainId: config.fromChainId,
|
|
90
|
+
toChainId: config.toChainId,
|
|
91
|
+
fromSymbol: config.fromToken.symbol,
|
|
92
|
+
toSymbol: config.toToken.symbol
|
|
93
|
+
};
|
|
94
|
+
const policyBlocked = routeFlipBlockedReason(config, pair);
|
|
95
|
+
if (policyBlocked !== null) {
|
|
96
|
+
return {
|
|
97
|
+
route: null,
|
|
98
|
+
blocked: config.locks.length > 0 ? "Locked fields hold the route. Unlock them to flip it." : "Allowed assets leave the reversed route out. Widen them to flip it."
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const fromChainId = offeredChain(offer, "sell", config.toChainId);
|
|
102
|
+
const toChainId = offeredChain(offer, "buy", config.fromChainId);
|
|
103
|
+
const fromToken = fromChainId === null ? void 0 : legTokens(offer, fromChainId, "sell").find((t) => t.symbol === config.toToken.symbol);
|
|
104
|
+
const toToken = toChainId === null ? void 0 : legTokens(offer, toChainId, "buy").find((t) => t.symbol === config.fromToken.symbol);
|
|
105
|
+
if (fromChainId === null || toChainId === null || !fromToken || !toToken) {
|
|
106
|
+
return {
|
|
107
|
+
route: null,
|
|
108
|
+
blocked: routeRefusal(offer, {
|
|
109
|
+
fromChainId: config.toChainId,
|
|
110
|
+
toChainId: config.fromChainId,
|
|
111
|
+
fromToken: config.toToken,
|
|
112
|
+
toToken: config.fromToken
|
|
113
|
+
}) ?? "The reversed route is not one this widget offers."
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const refusal = routeRefusal(offer, { fromChainId, toChainId, fromToken, toToken });
|
|
117
|
+
if (refusal !== null) return { route: null, blocked: refusal };
|
|
118
|
+
return {
|
|
119
|
+
route: { fromChainId, toChainId, sellSymbol: fromToken.symbol, buySymbol: toToken.symbol },
|
|
120
|
+
blocked: null
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
allowListPolicy,
|
|
125
|
+
chainRefusal,
|
|
126
|
+
changeRoute,
|
|
127
|
+
flipRoute,
|
|
128
|
+
offeredChain,
|
|
129
|
+
routeRefusal,
|
|
130
|
+
tokenAvailability
|
|
131
|
+
};
|