@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,98 @@
|
|
|
1
|
+
import { embedUrl, EMBED_PARAM, parseEmbedParams, encodeEmbedParams } from "@xochi/widget-lib";
|
|
2
|
+
import widgetLibPackage from "@xochi/widget-lib/package.json";
|
|
3
|
+
import { widgetLibModuleDir } from "../../widgetLibModule.js";
|
|
4
|
+
const widgetLibModuleUrl = (origin) => `${origin}/${widgetLibModuleDir(widgetLibPackage.version)}/index.js`;
|
|
5
|
+
const CODE_FORMATS = [
|
|
6
|
+
{ id: "html", tab: "HTML", label: "HTML code" },
|
|
7
|
+
{ id: "react", tab: "React", label: "React code" },
|
|
8
|
+
{ id: "ramp", tab: "Ramp", label: "Ramp helper code" },
|
|
9
|
+
{ id: "url", tab: "URL", label: "Embed URL" }
|
|
10
|
+
];
|
|
11
|
+
function frameParams(params) {
|
|
12
|
+
return Object.fromEntries(
|
|
13
|
+
Object.entries(params).filter(
|
|
14
|
+
([key]) => Object.prototype.hasOwnProperty.call(EMBED_PARAM, key)
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function paramsLiteral(params, indent) {
|
|
19
|
+
const entries = Object.entries(parseEmbedParams(encodeEmbedParams(frameParams(params))));
|
|
20
|
+
if (entries.length === 0) return "{}";
|
|
21
|
+
return [
|
|
22
|
+
"{",
|
|
23
|
+
...entries.map(
|
|
24
|
+
([key, value], index) => `${indent} ${key}: ${JSON.stringify(value)}${index === entries.length - 1 ? "" : ","}`
|
|
25
|
+
),
|
|
26
|
+
`${indent}}`
|
|
27
|
+
].join("\n");
|
|
28
|
+
}
|
|
29
|
+
function htmlSnippet(origin, params) {
|
|
30
|
+
return [
|
|
31
|
+
'<div id="xochi-swap"></div>',
|
|
32
|
+
'<script type="module">',
|
|
33
|
+
` import { createXochiWidget } from "${widgetLibModuleUrl(origin)}";`,
|
|
34
|
+
"",
|
|
35
|
+
' const widget = createXochiWidget(document.getElementById("xochi-swap"), {',
|
|
36
|
+
` origin: ${JSON.stringify(origin)},`,
|
|
37
|
+
` params: ${paramsLiteral(params, " ")},`,
|
|
38
|
+
" });",
|
|
39
|
+
"<\/script>"
|
|
40
|
+
].join("\n");
|
|
41
|
+
}
|
|
42
|
+
function reactSnippet(origin, params) {
|
|
43
|
+
return [
|
|
44
|
+
'import { useEffect, useRef } from "react";',
|
|
45
|
+
'import { createXochiWidget } from "@xochi/widget-lib";',
|
|
46
|
+
"",
|
|
47
|
+
"export function XochiSwap() {",
|
|
48
|
+
" const container = useRef<HTMLDivElement>(null);",
|
|
49
|
+
"",
|
|
50
|
+
" useEffect(() => {",
|
|
51
|
+
" if (container.current === null) return;",
|
|
52
|
+
" const widget = createXochiWidget(container.current, {",
|
|
53
|
+
` origin: ${JSON.stringify(origin)},`,
|
|
54
|
+
` params: ${paramsLiteral(params, " ")},`,
|
|
55
|
+
" });",
|
|
56
|
+
" return () => widget.destroy();",
|
|
57
|
+
" }, []);",
|
|
58
|
+
"",
|
|
59
|
+
" return <div ref={container} />;",
|
|
60
|
+
"}"
|
|
61
|
+
].join("\n");
|
|
62
|
+
}
|
|
63
|
+
function codeFor(format, origin, params) {
|
|
64
|
+
switch (format) {
|
|
65
|
+
case "html":
|
|
66
|
+
return htmlSnippet(origin, params);
|
|
67
|
+
case "react":
|
|
68
|
+
return reactSnippet(origin, params);
|
|
69
|
+
case "ramp":
|
|
70
|
+
return rampSnippet(origin, params);
|
|
71
|
+
case "url":
|
|
72
|
+
return embedUrl(origin, frameParams(params));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function rampSnippet(origin, params) {
|
|
76
|
+
const onlyMode = params.modes?.length === 1 ? params.modes[0] : void 0;
|
|
77
|
+
const direction = (params.initialMode ?? onlyMode) === "offramp" ? "offramp" : "onramp";
|
|
78
|
+
return [
|
|
79
|
+
'<div id="xochi-swap"></div>',
|
|
80
|
+
'<script type="module">',
|
|
81
|
+
` import { createXochiRampWidget } from "${widgetLibModuleUrl(origin)}";`,
|
|
82
|
+
"",
|
|
83
|
+
' const widget = createXochiRampWidget(document.getElementById("xochi-swap"), {',
|
|
84
|
+
` origin: ${JSON.stringify(origin)},`,
|
|
85
|
+
` direction: ${JSON.stringify(direction)},`,
|
|
86
|
+
" });",
|
|
87
|
+
` widget.updateParams(${paramsLiteral(params, " ")});`,
|
|
88
|
+
"<\/script>"
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
CODE_FORMATS,
|
|
93
|
+
codeFor,
|
|
94
|
+
htmlSnippet,
|
|
95
|
+
rampSnippet,
|
|
96
|
+
reactSnippet,
|
|
97
|
+
widgetLibModuleUrl
|
|
98
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { parseEmbedParams, encodeEmbedParams, TRADE_MODES } from "@xochi/widget-lib";
|
|
2
|
+
import { SEND_DESTINATIONS, TRADE_MODES as TRADE_MODES2, WIDGET_TABS } from "@xochi/widget-lib";
|
|
3
|
+
import { widgetSurfaces } from "../trade/embedNarrowing.js";
|
|
4
|
+
const SURFACE_FIELDS = [
|
|
5
|
+
"initialTab",
|
|
6
|
+
"tabs",
|
|
7
|
+
"initialMode",
|
|
8
|
+
"modes",
|
|
9
|
+
"sendDestinations",
|
|
10
|
+
"fiatCurrency",
|
|
11
|
+
"rampProviders"
|
|
12
|
+
];
|
|
13
|
+
function surfaceParams(params) {
|
|
14
|
+
const selected = Object.fromEntries(
|
|
15
|
+
SURFACE_FIELDS.filter((key) => params[key] !== void 0).map((key) => [key, params[key]])
|
|
16
|
+
);
|
|
17
|
+
const clean = { ...parseEmbedParams(encodeEmbedParams(selected)) };
|
|
18
|
+
const surfaces = widgetSurfaces(clean);
|
|
19
|
+
if (clean.initialTab !== void 0) clean.initialTab = surfaces.initialTab;
|
|
20
|
+
const modes = clean.modes ?? TRADE_MODES;
|
|
21
|
+
if (clean.initialMode !== void 0 && !modes.includes(clean.initialMode))
|
|
22
|
+
clean.initialMode = modes.includes("swap") ? "swap" : modes[0];
|
|
23
|
+
return clean;
|
|
24
|
+
}
|
|
25
|
+
function withSurfaceParams(base, asked) {
|
|
26
|
+
const surface = { ...surfaceParams(asked) };
|
|
27
|
+
if (base.layout === "swap") {
|
|
28
|
+
surface.tabs = ["trade"];
|
|
29
|
+
surface.initialTab = "trade";
|
|
30
|
+
surface.modes = ["swap"];
|
|
31
|
+
surface.initialMode = "swap";
|
|
32
|
+
}
|
|
33
|
+
return { ...base, ...surface };
|
|
34
|
+
}
|
|
35
|
+
function replaceSurfaceParams(previous, next) {
|
|
36
|
+
const retained = Object.fromEntries(
|
|
37
|
+
Object.entries(previous).filter(
|
|
38
|
+
([key]) => !SURFACE_FIELDS.includes(key)
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
return { ...retained, ...surfaceParams(next), layout: "full" };
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
SEND_DESTINATIONS as DESTINATIONS,
|
|
45
|
+
TRADE_MODES2 as MODES,
|
|
46
|
+
SURFACE_FIELDS,
|
|
47
|
+
WIDGET_TABS as TABS,
|
|
48
|
+
replaceSurfaceParams,
|
|
49
|
+
surfaceParams,
|
|
50
|
+
withSurfaceParams
|
|
51
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { parseUnits } from "viem";
|
|
3
|
+
import { DEFAULT_SLIPPAGE_BPS, ApiError } from "@xochi/client";
|
|
4
|
+
import { anonymousIntentAPI } from "../../lib/intentAPI.js";
|
|
5
|
+
import "../trade/config.js";
|
|
6
|
+
const CHECK_DEADLINE_SECS = 3600;
|
|
7
|
+
function probeAmount(config) {
|
|
8
|
+
if (config.amount !== "") return config.amount;
|
|
9
|
+
return /^W?ETH$/.test(config.fromToken.symbol) ? "0.05" : "100";
|
|
10
|
+
}
|
|
11
|
+
function codeCheckRequest(config, nowMs) {
|
|
12
|
+
if (config.promo === null) return null;
|
|
13
|
+
return {
|
|
14
|
+
preview: true,
|
|
15
|
+
fromChainId: config.fromChainId,
|
|
16
|
+
toChainId: config.toChainId,
|
|
17
|
+
fromToken: config.fromToken.address,
|
|
18
|
+
toToken: config.toToken.address,
|
|
19
|
+
fromAmount: parseUnits(probeAmount(config), config.fromToken.decimals).toString(),
|
|
20
|
+
deadline: Math.floor(nowMs / 1e3) + CHECK_DEADLINE_SECS,
|
|
21
|
+
slippageBps: DEFAULT_SLIPPAGE_BPS,
|
|
22
|
+
trustScore: 0,
|
|
23
|
+
// A preview is public: private settlement needs a wallet's keys.
|
|
24
|
+
settlementPreference: "public",
|
|
25
|
+
ref: config.ref ?? void 0,
|
|
26
|
+
promo: config.promo ?? void 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function readCodeCheck(quote) {
|
|
30
|
+
if (!quote.success || !quote.canSolve) {
|
|
31
|
+
return {
|
|
32
|
+
kind: "no_bid",
|
|
33
|
+
reason: quote.error ?? "no solver priced this route at this amount"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const { promo, promoNote } = quote;
|
|
37
|
+
return { kind: "checked", outcome: { promo, promoNote } };
|
|
38
|
+
}
|
|
39
|
+
function checkFailure(err) {
|
|
40
|
+
return {
|
|
41
|
+
kind: "failed",
|
|
42
|
+
reason: err instanceof ApiError ? `the preview quote failed (HTTP ${err.code})` : "the quote service couldn't be reached"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function useCodeCheck(config, delayMs) {
|
|
46
|
+
const probe = codeCheckRequest(config, 0);
|
|
47
|
+
const key = probe === null ? null : JSON.stringify(probe);
|
|
48
|
+
const [result, setResult] = useState(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (key === null) return;
|
|
51
|
+
let live = true;
|
|
52
|
+
const timer = setTimeout(() => {
|
|
53
|
+
const request = codeCheckRequest(config, Date.now());
|
|
54
|
+
if (request === null) return;
|
|
55
|
+
anonymousIntentAPI.getQuote(request).then(
|
|
56
|
+
(quote) => {
|
|
57
|
+
if (live) setResult({ key, check: readCodeCheck(quote) });
|
|
58
|
+
},
|
|
59
|
+
(err) => {
|
|
60
|
+
console.warn("[configurator] code check failed:", err);
|
|
61
|
+
if (live) setResult({ key, check: checkFailure(err) });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}, delayMs);
|
|
65
|
+
return () => {
|
|
66
|
+
live = false;
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
};
|
|
69
|
+
}, [key, delayMs]);
|
|
70
|
+
if (key === null) return { kind: "none" };
|
|
71
|
+
return result?.key === key ? result.check : { kind: "checking" };
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
checkFailure,
|
|
75
|
+
codeCheckRequest,
|
|
76
|
+
probeAmount,
|
|
77
|
+
readCodeCheck,
|
|
78
|
+
useCodeCheck
|
|
79
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { readConfiguratorSearch } from "./configuratorUrl.js";
|
|
3
|
+
function useOpenedConfiguration() {
|
|
4
|
+
const [opened] = useState(() => readConfiguratorSearch(window.location.search));
|
|
5
|
+
return opened;
|
|
6
|
+
}
|
|
7
|
+
function useConfiguratorUrl(search, writable, delayMs) {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!writable || window.location.search === search) return;
|
|
10
|
+
const timer = setTimeout(() => {
|
|
11
|
+
const { pathname, hash } = window.location;
|
|
12
|
+
try {
|
|
13
|
+
window.history.replaceState(window.history.state, "", `${pathname}${search}${hash}`);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error("[configurator] writing the configuration into the page URL failed:", error);
|
|
16
|
+
}
|
|
17
|
+
}, delayMs);
|
|
18
|
+
return () => clearTimeout(timer);
|
|
19
|
+
}, [search, writable, delayMs]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useConfiguratorUrl,
|
|
23
|
+
useOpenedConfiguration
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
2
|
+
function useMediaQuery(query, fallback) {
|
|
3
|
+
const subscribe = useCallback(
|
|
4
|
+
(onChange) => {
|
|
5
|
+
if (typeof window.matchMedia !== "function") return () => void 0;
|
|
6
|
+
const mql = window.matchMedia(query);
|
|
7
|
+
mql.addEventListener("change", onChange);
|
|
8
|
+
return () => mql.removeEventListener("change", onChange);
|
|
9
|
+
},
|
|
10
|
+
[query]
|
|
11
|
+
);
|
|
12
|
+
return useSyncExternalStore(
|
|
13
|
+
subscribe,
|
|
14
|
+
() => typeof window.matchMedia === "function" ? window.matchMedia(query).matches : fallback,
|
|
15
|
+
() => fallback
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
useMediaQuery
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useMemo } from "react";
|
|
2
|
+
import { resolveEmbedDefaults, embedOverrides } from "../trade/embedParams.js";
|
|
3
|
+
import { withSurfaceParams } from "./surfaceParams.js";
|
|
4
|
+
import { paramsText, readParamsDraft } from "./paramsDraft.js";
|
|
5
|
+
function useParamsDraft(config, offer, apply, publicParams) {
|
|
6
|
+
const canonical = paramsText(config, publicParams);
|
|
7
|
+
const [draft, setDraft] = useState(canonical);
|
|
8
|
+
const [draftBase, setDraftBase] = useState(canonical);
|
|
9
|
+
if (canonical !== draftBase) {
|
|
10
|
+
setDraftBase(canonical);
|
|
11
|
+
setDraft(canonical);
|
|
12
|
+
}
|
|
13
|
+
const problems = useMemo(() => readParamsDraft(draft, offer).problems, [draft, offer]);
|
|
14
|
+
return {
|
|
15
|
+
draft,
|
|
16
|
+
problems,
|
|
17
|
+
edit: (text) => {
|
|
18
|
+
setDraft(text);
|
|
19
|
+
const read = readParamsDraft(text, offer);
|
|
20
|
+
if (read.problems.length > 0) return;
|
|
21
|
+
apply(read.params);
|
|
22
|
+
const next = resolveEmbedDefaults(read.params, offer);
|
|
23
|
+
setDraftBase(paramsText(next, withSurfaceParams(embedOverrides(next), read.params)));
|
|
24
|
+
},
|
|
25
|
+
settle: () => {
|
|
26
|
+
if (problems.length === 0) setDraft(canonical);
|
|
27
|
+
},
|
|
28
|
+
clear: () => setDraft("")
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
useParamsDraft
|
|
33
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useMemo, useRef, useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { QUOTE_DEBOUNCE_MS, ApiError } from "@xochi/client";
|
|
3
|
+
import { useCapabilities } from "../../hooks/useCapabilities.js";
|
|
4
|
+
import { usePrices } from "../../hooks/usePrices.js";
|
|
5
|
+
import { anonymousIntentAPI } from "../../lib/intentAPI.js";
|
|
6
|
+
import { previewPlan, previewQuoteRequest } from "./previewQuote.js";
|
|
7
|
+
const PREVIEW_REFRESH_MS = 6e4;
|
|
8
|
+
function structuredError(error) {
|
|
9
|
+
if (error instanceof ApiError) {
|
|
10
|
+
return { message: error.message, code: error.code, retryAfter: error.retryAfter };
|
|
11
|
+
}
|
|
12
|
+
return { message: error instanceof Error ? error.message : String(error) };
|
|
13
|
+
}
|
|
14
|
+
function usePreviewFee(config, enabled) {
|
|
15
|
+
const {
|
|
16
|
+
capabilities,
|
|
17
|
+
state: capabilityState,
|
|
18
|
+
features,
|
|
19
|
+
retry: retryCapabilities,
|
|
20
|
+
isFetching: retryingRoutes
|
|
21
|
+
} = useCapabilities();
|
|
22
|
+
const { prices, isLive: pricesLive } = usePrices();
|
|
23
|
+
const plan = useMemo(
|
|
24
|
+
() => previewPlan(config, { capabilities, capabilityState, prices, pricesLive }),
|
|
25
|
+
[config, capabilities, capabilityState, prices, pricesLive]
|
|
26
|
+
);
|
|
27
|
+
const key = plan.kind === "quote" ? plan.key : null;
|
|
28
|
+
const latest = useRef({ config, plan });
|
|
29
|
+
latest.current = { config, plan };
|
|
30
|
+
const [settledKey, setSettledKey] = useState(null);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (key === null) return;
|
|
33
|
+
const timer = setTimeout(() => setSettledKey(key), QUOTE_DEBOUNCE_MS);
|
|
34
|
+
return () => clearTimeout(timer);
|
|
35
|
+
}, [key]);
|
|
36
|
+
const [answer, setAnswer] = useState(
|
|
37
|
+
null
|
|
38
|
+
);
|
|
39
|
+
const [attempt, setAttempt] = useState(0);
|
|
40
|
+
const [refresh, setRefresh] = useState(0);
|
|
41
|
+
const priced = answer !== null && answer.key === key && answer.outcome.ok;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!enabled || !priced) return;
|
|
44
|
+
const timer = setInterval(() => setRefresh((n) => n + 1), PREVIEW_REFRESH_MS);
|
|
45
|
+
return () => clearInterval(timer);
|
|
46
|
+
}, [enabled, priced, key]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!enabled || key === null || settledKey !== key) return;
|
|
49
|
+
const { config: asked, plan: current } = latest.current;
|
|
50
|
+
if (current.kind !== "quote") return;
|
|
51
|
+
const built = previewQuoteRequest(asked, current.amount, Date.now());
|
|
52
|
+
if (!built.ok) {
|
|
53
|
+
setAnswer({ key, attempt, outcome: { ok: false, error: { message: built.error } } });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let live = true;
|
|
57
|
+
anonymousIntentAPI.getQuote(built.request).then(
|
|
58
|
+
(quote) => {
|
|
59
|
+
if (live) setAnswer({ key, attempt, outcome: { ok: true, quote } });
|
|
60
|
+
},
|
|
61
|
+
(error) => {
|
|
62
|
+
const structured = structuredError(error);
|
|
63
|
+
console.warn("[configurator] Preview quote failed:", structured.message);
|
|
64
|
+
if (live) setAnswer({ key, attempt, outcome: { ok: false, error: structured } });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
return () => {
|
|
68
|
+
live = false;
|
|
69
|
+
};
|
|
70
|
+
}, [enabled, key, settledKey, attempt, refresh]);
|
|
71
|
+
const retry = useCallback(() => {
|
|
72
|
+
if (plan.kind === "unconfirmed" && (plan.reason === "stale" || plan.reason === "fallback" || plan.reason === "failed")) {
|
|
73
|
+
retryCapabilities();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setAttempt((n) => n + 1);
|
|
77
|
+
}, [plan, retryCapabilities]);
|
|
78
|
+
const fee = (() => {
|
|
79
|
+
if (plan.kind !== "quote") return plan;
|
|
80
|
+
if (answer === null || answer.key !== plan.key || answer.attempt !== attempt) {
|
|
81
|
+
return { kind: "loading", amount: plan.amount };
|
|
82
|
+
}
|
|
83
|
+
const { outcome } = answer;
|
|
84
|
+
if (!outcome.ok) return { kind: "failed", amount: plan.amount, error: outcome.error };
|
|
85
|
+
return outcome.quote.success && outcome.quote.canSolve ? { kind: "ready", amount: plan.amount, quote: outcome.quote } : { kind: "declined", amount: plan.amount, quote: outcome.quote };
|
|
86
|
+
})();
|
|
87
|
+
return {
|
|
88
|
+
fee,
|
|
89
|
+
prices,
|
|
90
|
+
routePrivacyModes: plan.routePrivacyModes,
|
|
91
|
+
retryingRoutes,
|
|
92
|
+
capabilityState,
|
|
93
|
+
trustEconomicsLive: features.trustEconomicsLive,
|
|
94
|
+
retry
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
PREVIEW_REFRESH_MS,
|
|
99
|
+
usePreviewFee
|
|
100
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import { TIMEOUTS } from "../../config.js";
|
|
4
|
+
import { abbreviateMetaAddress } from "./stealthRecipient.js";
|
|
5
|
+
function MetaAddressValue({ encoded }) {
|
|
6
|
+
const [copyState, setCopyState] = useState("idle");
|
|
7
|
+
const codeRef = useRef(null);
|
|
8
|
+
const copy = async () => {
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(encoded);
|
|
11
|
+
setCopyState("copied");
|
|
12
|
+
setTimeout(() => setCopyState("idle"), TIMEOUTS.clipboardFeedback);
|
|
13
|
+
} catch {
|
|
14
|
+
setCopyState("fallback");
|
|
15
|
+
requestAnimationFrame(() => {
|
|
16
|
+
if (codeRef.current) window.getSelection()?.selectAllChildren(codeRef.current);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsxs("span", { className: "send-meta", children: [
|
|
21
|
+
/* @__PURE__ */ jsx("code", { ref: codeRef, className: "send-review__mono", title: encoded, children: copyState === "fallback" ? encoded : abbreviateMetaAddress(encoded) }),
|
|
22
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "send-secondary send-meta__copy", onClick: () => void copy(), children: copyState === "copied" ? "Copied" : "Copy full" }),
|
|
23
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: copyState === "copied" ? "Meta-address copied" : copyState === "fallback" ? "Copy did not work. The full meta-address is shown and selected." : "" })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
MetaAddressValue
|
|
28
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useEffect } from "react";
|
|
3
|
+
import { getAccount, sendTransaction, waitForTransactionReceipt } from "@wagmi/core";
|
|
4
|
+
import { useAccount, useConfig } from "wagmi";
|
|
5
|
+
import { readStealthRegistration, buildRegisterStealthMetaAddressTx } from "../../lib/recipient/index.js";
|
|
6
|
+
import { chainName } from "./addressSend.js";
|
|
7
|
+
import { useRecipientDeps } from "./useSendRecipient.js";
|
|
8
|
+
import { buildQrSvg } from "../../lib/qr.js";
|
|
9
|
+
import { StealthInvite } from "./StealthInvite.js";
|
|
10
|
+
import { useStealth } from "../../hooks/useStealth.js";
|
|
11
|
+
function ReceiveValue({ label, value }) {
|
|
12
|
+
const { path, size } = buildQrSvg(value);
|
|
13
|
+
const [feedback, setFeedback] = useState("");
|
|
14
|
+
const copy = async () => {
|
|
15
|
+
try {
|
|
16
|
+
await navigator.clipboard.writeText(value);
|
|
17
|
+
setFeedback("Copied");
|
|
18
|
+
} catch {
|
|
19
|
+
setFeedback("Select the address to copy it");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsxs("div", { className: "send-receive__value", children: [
|
|
23
|
+
/* @__PURE__ */ jsx("strong", { children: label }),
|
|
24
|
+
/* @__PURE__ */ jsx("code", { className: "send-review__mono", children: value }),
|
|
25
|
+
/* @__PURE__ */ jsxs(
|
|
26
|
+
"svg",
|
|
27
|
+
{
|
|
28
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
29
|
+
width: "110",
|
|
30
|
+
height: "110",
|
|
31
|
+
role: "img",
|
|
32
|
+
"aria-label": `${label} QR code`,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("rect", { width: size, height: size, fill: "white" }),
|
|
35
|
+
/* @__PURE__ */ jsx("path", { d: path, fill: "black", shapeRendering: "crispEdges" })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "send-secondary", onClick: () => void copy(), children: "Copy" }),
|
|
40
|
+
/* @__PURE__ */ jsx("span", { role: "status", children: feedback })
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
function Receive({ onConnect }) {
|
|
44
|
+
const { address, chainId, status: walletStatus } = useAccount();
|
|
45
|
+
const config = useConfig();
|
|
46
|
+
const stealth = useStealth();
|
|
47
|
+
const deps = useRecipientDeps();
|
|
48
|
+
const pending = useRef(false);
|
|
49
|
+
const [revision, refresh] = useState(0);
|
|
50
|
+
const [checked, setChecked] = useState();
|
|
51
|
+
const [review, setReview] = useState();
|
|
52
|
+
const [submission, setSubmission] = useState("idle");
|
|
53
|
+
const meta = stealth.encodedMetaAddress;
|
|
54
|
+
const status = checked?.address === address ? checked?.status : void 0;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!address || !deps) return;
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const { signal } = controller;
|
|
59
|
+
void readStealthRegistration(address, deps, signal).then((value) => {
|
|
60
|
+
if (!signal.aborted) setChecked({ address, status: value });
|
|
61
|
+
});
|
|
62
|
+
return () => controller.abort();
|
|
63
|
+
}, [address, deps, revision]);
|
|
64
|
+
let tx;
|
|
65
|
+
if (chainId && meta) {
|
|
66
|
+
try {
|
|
67
|
+
tx = buildRegisterStealthMetaAddressTx(meta, chainId);
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const approve = async () => {
|
|
72
|
+
if (!review || !tx || pending.current) return;
|
|
73
|
+
const account = getAccount(config);
|
|
74
|
+
if (account.status !== "connected" || review.address !== account.address || review.chainId !== account.chainId || review.meta !== meta)
|
|
75
|
+
return;
|
|
76
|
+
pending.current = true;
|
|
77
|
+
setSubmission("pending");
|
|
78
|
+
try {
|
|
79
|
+
const chainId2 = review.chainId;
|
|
80
|
+
const hash = await sendTransaction(config, { ...tx, chainId: chainId2, account: review.address });
|
|
81
|
+
const receipt = await waitForTransactionReceipt(config, { hash, chainId: chainId2 });
|
|
82
|
+
if (receipt.status !== "success") throw new Error("Registration reverted");
|
|
83
|
+
setChecked({ address: review.address, status: "published" });
|
|
84
|
+
setReview(void 0);
|
|
85
|
+
setSubmission("idle");
|
|
86
|
+
} catch {
|
|
87
|
+
setSubmission("failed");
|
|
88
|
+
refresh((previous) => previous + 1);
|
|
89
|
+
} finally {
|
|
90
|
+
pending.current = false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (!address)
|
|
94
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
95
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", children: "Connect your wallet so people can send to you with Stealth." }),
|
|
96
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "submit-btn send-cta", onClick: onConnect, children: "Connect wallet" }),
|
|
97
|
+
/* @__PURE__ */ jsx(StealthInvite, {})
|
|
98
|
+
] });
|
|
99
|
+
return /* @__PURE__ */ jsxs("section", { className: "send-review", "aria-label": "Receive", children: [
|
|
100
|
+
/* @__PURE__ */ jsx(StealthInvite, {}),
|
|
101
|
+
/* @__PURE__ */ jsx(ReceiveValue, { label: "Wallet address", value: address }, address),
|
|
102
|
+
meta ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", children: "Share this so people can send to you with Stealth." }),
|
|
104
|
+
/* @__PURE__ */ jsx(ReceiveValue, { label: "Stealth address", value: meta }, meta),
|
|
105
|
+
status !== "published" && chainId && tx && (review && review.address === address && review.chainId === chainId && review.meta === meta ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", children: "Your Stealth receiving details become public and linked to this wallet." }),
|
|
107
|
+
/* @__PURE__ */ jsxs("p", { className: "send-note", children: [
|
|
108
|
+
"On ",
|
|
109
|
+
chainName(chainId)
|
|
110
|
+
] }),
|
|
111
|
+
submission === "failed" && /* @__PURE__ */ jsx("p", { role: "alert", children: "Registration could not be confirmed" }),
|
|
112
|
+
/* @__PURE__ */ jsxs("div", { className: "send-review__actions", children: [
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
type: "button",
|
|
117
|
+
className: "send-secondary",
|
|
118
|
+
disabled: submission === "pending",
|
|
119
|
+
onClick: () => setReview(void 0),
|
|
120
|
+
children: "Back"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
className: "submit-btn send-cta",
|
|
128
|
+
disabled: walletStatus !== "connected" || submission === "pending",
|
|
129
|
+
onClick: () => void approve(),
|
|
130
|
+
children: submission === "pending" ? "Waiting for wallet or network…" : "Confirm in wallet"
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] })
|
|
134
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
135
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", children: "Publish your Stealth receiving details so people can find them from your wallet address." }),
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
type: "button",
|
|
140
|
+
className: "send-secondary",
|
|
141
|
+
onClick: () => {
|
|
142
|
+
setSubmission("idle");
|
|
143
|
+
setReview({ address, chainId, meta });
|
|
144
|
+
},
|
|
145
|
+
children: "Publish Stealth details"
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] }))
|
|
149
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
150
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", children: "Sign a message in your wallet to set up Stealth." }),
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
"button",
|
|
153
|
+
{
|
|
154
|
+
type: "button",
|
|
155
|
+
className: "send-secondary",
|
|
156
|
+
disabled: walletStatus !== "connected" || stealth.isLoading,
|
|
157
|
+
onClick: () => void stealth.initializeKeys(),
|
|
158
|
+
children: "Set up Stealth"
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
stealth.error && /* @__PURE__ */ jsx("p", { role: "alert", children: "Stealth setup could not finish" })
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ jsx("p", { className: "send-note", role: "status", children: status === "published" ? "Stealth details published" : status === "not_published" ? "Stealth details unpublished" : status === "unknown" || !deps ? "Registration status unavailable" : "Checking registration…" })
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
Receive
|
|
168
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { readRecentRecipientEntries } from "../../lib/recipient/recent.js";
|
|
3
|
+
import { RecipientChip } from "./RecipientChip.js";
|
|
4
|
+
function RecentRecipients({ onSelect }) {
|
|
5
|
+
const recent = readRecentRecipientEntries();
|
|
6
|
+
if (!recent.length) return null;
|
|
7
|
+
return /* @__PURE__ */ jsxs("section", { className: "recent-recipients", "aria-label": "Recent recipients", children: [
|
|
8
|
+
/* @__PURE__ */ jsx("p", { children: "Recent" }),
|
|
9
|
+
recent.map((recipient) => /* @__PURE__ */ jsx(
|
|
10
|
+
"button",
|
|
11
|
+
{
|
|
12
|
+
className: "recent-recipients__pick",
|
|
13
|
+
type: "button",
|
|
14
|
+
onClick: () => onSelect(recipient.input),
|
|
15
|
+
children: /* @__PURE__ */ jsx(RecipientChip, { recipient })
|
|
16
|
+
},
|
|
17
|
+
recipient.input
|
|
18
|
+
))
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
RecentRecipients
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { abbreviateMetaAddress } from "./stealthRecipient.js";
|
|
3
|
+
function RecipientChip({ recipient }) {
|
|
4
|
+
const value = recipient.address ?? recipient.stealthMetaAddress ?? recipient.shieldedAlias ?? recipient.input;
|
|
5
|
+
const short = value.startsWith("0x") ? `${value.slice(0, 6)}…${value.slice(-4)}` : value.startsWith("st:eth:") ? abbreviateMetaAddress(value) : value;
|
|
6
|
+
const hue = [...value].reduce((sum, char) => (sum * 31 + char.charCodeAt(0)) % 360, 0);
|
|
7
|
+
return /* @__PURE__ */ jsxs("span", { className: "send-recipient", children: [
|
|
8
|
+
/* @__PURE__ */ jsx(
|
|
9
|
+
"span",
|
|
10
|
+
{
|
|
11
|
+
className: "send-identicon",
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
style: {
|
|
14
|
+
background: `conic-gradient(from ${hue}deg, hsl(${hue} 60% 45%) 25%, hsl(${(hue + 100) % 360} 65% 68%) 0 50%, hsl(${hue} 60% 45%) 0 75%, hsl(${(hue + 100) % 360} 65% 68%) 0)`
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
19
|
+
recipient.name && /* @__PURE__ */ jsx("strong", { children: recipient.name }),
|
|
20
|
+
short !== recipient.name && /* @__PURE__ */ jsx("small", { title: value, children: short })
|
|
21
|
+
] })
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
RecipientChip
|
|
26
|
+
};
|