thirdweb 5.112.3 → 5.113.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/dist/cjs/exports/react.js +4 -1
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/exports/react.native.js +4 -1
- package/dist/cjs/exports/react.native.js.map +1 -1
- package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js +110 -0
- package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -0
- package/dist/cjs/react/native/hooks/x402/useFetchWithPayment.js +89 -0
- package/dist/cjs/react/native/hooks/x402/useFetchWithPayment.js.map +1 -0
- package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js +168 -0
- package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js.map +1 -0
- package/dist/cjs/react/web/ui/components/basic.js +1 -1
- package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js +107 -0
- package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js.map +1 -0
- package/dist/cjs/react/web/ui/x402/SignInRequiredModal.js +28 -0
- package/dist/cjs/react/web/ui/x402/SignInRequiredModal.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/coinbase/coinbase-web.js +9 -0
- package/dist/cjs/wallets/coinbase/coinbase-web.js.map +1 -1
- package/dist/cjs/x402/facilitator.js +1 -1
- package/dist/cjs/x402/fetchWithPayment.js +9 -7
- package/dist/cjs/x402/fetchWithPayment.js.map +1 -1
- package/dist/cjs/x402/schemas.js +2 -0
- package/dist/cjs/x402/schemas.js.map +1 -1
- package/dist/cjs/x402/settle-payment.js +2 -1
- package/dist/cjs/x402/settle-payment.js.map +1 -1
- package/dist/cjs/x402/verify-payment.js +2 -1
- package/dist/cjs/x402/verify-payment.js.map +1 -1
- package/dist/esm/exports/react.js +2 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/react.native.js +2 -0
- package/dist/esm/exports/react.native.js.map +1 -1
- package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js +107 -0
- package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -0
- package/dist/esm/react/native/hooks/x402/useFetchWithPayment.js +86 -0
- package/dist/esm/react/native/hooks/x402/useFetchWithPayment.js.map +1 -0
- package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js +165 -0
- package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js.map +1 -0
- package/dist/esm/react/web/ui/components/basic.js +1 -1
- package/dist/esm/react/web/ui/x402/PaymentErrorModal.js +104 -0
- package/dist/esm/react/web/ui/x402/PaymentErrorModal.js.map +1 -0
- package/dist/esm/react/web/ui/x402/SignInRequiredModal.js +25 -0
- package/dist/esm/react/web/ui/x402/SignInRequiredModal.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/coinbase/coinbase-web.js +9 -0
- package/dist/esm/wallets/coinbase/coinbase-web.js.map +1 -1
- package/dist/esm/x402/facilitator.js +1 -1
- package/dist/esm/x402/fetchWithPayment.js +9 -7
- package/dist/esm/x402/fetchWithPayment.js.map +1 -1
- package/dist/esm/x402/schemas.js +2 -0
- package/dist/esm/x402/schemas.js.map +1 -1
- package/dist/esm/x402/settle-payment.js +2 -1
- package/dist/esm/x402/settle-payment.js.map +1 -1
- package/dist/esm/x402/verify-payment.js +2 -1
- package/dist/esm/x402/verify-payment.js.map +1 -1
- package/dist/scripts/bridge-widget.js +50 -50
- package/dist/types/exports/react.d.ts +1 -0
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +1 -0
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts +131 -0
- package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts.map +1 -0
- package/dist/types/react/native/hooks/x402/useFetchWithPayment.d.ts +189 -0
- package/dist/types/react/native/hooks/x402/useFetchWithPayment.d.ts.map +1 -0
- package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts +248 -0
- package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts.map +1 -0
- package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts +20 -0
- package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts.map +1 -0
- package/dist/types/react/web/ui/x402/SignInRequiredModal.d.ts +12 -0
- package/dist/types/react/web/ui/x402/SignInRequiredModal.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/x402/facilitator.d.ts +1 -1
- package/dist/types/x402/fetchWithPayment.d.ts +7 -3
- package/dist/types/x402/fetchWithPayment.d.ts.map +1 -1
- package/dist/types/x402/schemas.d.ts +8 -2
- package/dist/types/x402/schemas.d.ts.map +1 -1
- package/dist/types/x402/settle-payment.d.ts +1 -1
- package/dist/types/x402/settle-payment.d.ts.map +1 -1
- package/dist/types/x402/types.d.ts +2 -0
- package/dist/types/x402/types.d.ts.map +1 -1
- package/dist/types/x402/verify-payment.d.ts +1 -1
- package/dist/types/x402/verify-payment.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/exports/react.native.ts +5 -0
- package/src/exports/react.ts +5 -0
- package/src/react/core/hooks/x402/useFetchWithPaymentCore.ts +160 -0
- package/src/react/native/hooks/x402/useFetchWithPayment.ts +96 -0
- package/src/react/web/hooks/x402/useFetchWithPayment.tsx +238 -0
- package/src/react/web/ui/components/basic.tsx +1 -1
- package/src/react/web/ui/x402/PaymentErrorModal.tsx +261 -0
- package/src/react/web/ui/x402/SignInRequiredModal.tsx +75 -0
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbase-web.ts +10 -0
- package/src/x402/facilitator.ts +1 -1
- package/src/x402/fetchWithPayment.ts +19 -12
- package/src/x402/schemas.ts +2 -0
- package/src/x402/settle-payment.ts +2 -1
- package/src/x402/types.ts +2 -0
- package/src/x402/verify-payment.ts +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useWalletImage = exports.useEnsName = exports.useEnsAvatar = exports.getDefaultToken = exports.defaultTokens = exports.createContractQuery = exports.useSocialProfiles = exports.useConnectionManager = exports.useWaitForCallsReceipt = exports.useSwitchActiveWalletChain = exports.useSetActiveWalletConnectionStatus = exports.useSetActiveWallet = exports.useSendCalls = exports.useSendAndConfirmCalls = exports.useIsAutoConnecting = exports.useDisconnect = exports.useConnectedWallets = exports.useConnect = exports.useCapabilities = exports.useAuthToken = exports.useAdminWallet = exports.useAddConnectedWallet = exports.useActiveWalletConnectionStatus = exports.useActiveWalletChain = exports.useActiveWallet = exports.useActiveAccount = exports.useSimulateTransaction = exports.useSendBatchTransaction = exports.useEstimateGasCost = exports.useEstimateGas = exports.useBlockNumber = exports.usePostOnRampQuote = exports.useBuyWithFiatStatus = exports.useBuyWithFiatQuote = exports.useBuyWithFiatHistory = exports.useBuyWithCryptoStatus = exports.useBuyWithCryptoQuote = exports.useBuyWithCryptoHistory = exports.useBuyHistory = exports.useWalletBalance = exports.useInvalidateContractQuery = exports.useInvalidateBalances = exports.useChainMetadata = exports.useWaitForReceipt = exports.useReadContract = exports.useContractEvents = exports.useSiweAuth = exports.lightTheme = exports.darkTheme = exports.AccountProvider = void 0;
|
|
4
|
-
exports.getLastAuthProvider = exports.TransactionButton = exports.SiteLink = exports.SiteEmbed = exports.WalletName = exports.WalletIcon = exports.SocialIcon = exports.CreateDirectListingButton = exports.ClaimButton = exports.BuyDirectListingButton = exports.TokenSymbol = exports.TokenProvider = exports.TokenName = exports.TokenIcon = exports.NFTProvider = exports.NFTName = exports.NFTMedia = exports.NFTDescription = exports.ChainProvider = exports.ChainName = exports.ChainIcon = exports.AccountName = exports.AccountBlobbie = exports.AccountBalance = exports.AccountAvatar = exports.AccountAddress = exports.PayEmbed = exports.MediaRenderer = exports.useConnectModal = exports.useNetworkSwitcherModal = exports.ConnectEmbed = exports.useWalletDetailsModal = exports.ConnectButton = exports.Blobbie = exports.TransactionWidget = exports.SwapWidget = exports.CheckoutWidget = exports.BridgeWidget = exports.BuyWidget = exports.AutoConnect = exports.ThirdwebProvider = exports.useUnlinkProfile = exports.useProfiles = exports.useLinkProfile = exports.useAutoConnect = exports.useSendTransaction = exports.useSendAndConfirmTransaction = exports.WalletProvider = exports.useWalletInfo = void 0;
|
|
4
|
+
exports.getLastAuthProvider = exports.TransactionButton = exports.SiteLink = exports.SiteEmbed = exports.WalletName = exports.WalletIcon = exports.SocialIcon = exports.CreateDirectListingButton = exports.ClaimButton = exports.BuyDirectListingButton = exports.TokenSymbol = exports.TokenProvider = exports.TokenName = exports.TokenIcon = exports.NFTProvider = exports.NFTName = exports.NFTMedia = exports.NFTDescription = exports.ChainProvider = exports.ChainName = exports.ChainIcon = exports.AccountName = exports.AccountBlobbie = exports.AccountBalance = exports.AccountAvatar = exports.AccountAddress = exports.PayEmbed = exports.MediaRenderer = exports.useConnectModal = exports.useNetworkSwitcherModal = exports.ConnectEmbed = exports.useWalletDetailsModal = exports.ConnectButton = exports.Blobbie = exports.TransactionWidget = exports.SwapWidget = exports.CheckoutWidget = exports.BridgeWidget = exports.BuyWidget = exports.AutoConnect = exports.ThirdwebProvider = exports.useFetchWithPayment = exports.useUnlinkProfile = exports.useProfiles = exports.useLinkProfile = exports.useAutoConnect = exports.useSendTransaction = exports.useSendAndConfirmTransaction = exports.WalletProvider = exports.useWalletInfo = void 0;
|
|
5
5
|
var provider_js_1 = require("../react/core/account/provider.js");
|
|
6
6
|
Object.defineProperty(exports, "AccountProvider", { enumerable: true, get: function () { return provider_js_1.AccountProvider; } });
|
|
7
7
|
var index_js_1 = require("../react/core/design-system/index.js");
|
|
@@ -124,6 +124,9 @@ var useProfiles_js_1 = require("../react/web/hooks/wallets/useProfiles.js");
|
|
|
124
124
|
Object.defineProperty(exports, "useProfiles", { enumerable: true, get: function () { return useProfiles_js_1.useProfiles; } });
|
|
125
125
|
var useUnlinkProfile_js_1 = require("../react/web/hooks/wallets/useUnlinkProfile.js");
|
|
126
126
|
Object.defineProperty(exports, "useUnlinkProfile", { enumerable: true, get: function () { return useUnlinkProfile_js_1.useUnlinkProfile; } });
|
|
127
|
+
// x402
|
|
128
|
+
var useFetchWithPayment_js_1 = require("../react/web/hooks/x402/useFetchWithPayment.js");
|
|
129
|
+
Object.defineProperty(exports, "useFetchWithPayment", { enumerable: true, get: function () { return useFetchWithPayment_js_1.useFetchWithPayment; } });
|
|
127
130
|
var thirdweb_provider_js_1 = require("../react/web/providers/thirdweb-provider.js");
|
|
128
131
|
Object.defineProperty(exports, "ThirdwebProvider", { enumerable: true, get: function () { return thirdweb_provider_js_1.ThirdwebProvider; } });
|
|
129
132
|
var AutoConnect_js_1 = require("../react/web/ui/AutoConnect/AutoConnect.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/exports/react.ts"],"names":[],"mappings":";;;;AAAA,iEAG2C;AAFzC,8GAAA,eAAe,OAAA;AAOjB,iEAA6E;AAApE,qGAAA,SAAS,OAAA;AAAE,sGAAA,UAAU,OAAA;AAG9B,0EAAsE;AAA7D,6GAAA,WAAW,OAAA;AAepB,0FAAsF;AAA7E,yHAAA,iBAAiB,OAAA;AAC1B,WAAW;AACX,sFAAkF;AAAzE,qHAAA,eAAe,OAAA;AACxB,0FAAsF;AAA7E,yHAAA,iBAAiB,OAAA;AAC1B,cAAc;AACd,gFAA+E;AAAtE,oHAAA,gBAAgB,OAAA;AACzB,gGAA4F;AAAnF,iIAAA,qBAAqB,OAAA;AAC9B,8FAAgG;AAAvF,qIAAA,0BAA0B,OAAA;AACnC,sFAAkF;AAAzE,uHAAA,gBAAgB,OAAA;AACzB,6EAGkD;AADhD,iHAAA,aAAa,OAAA;AAEf,iGAG4D;AAD1D,qIAAA,uBAAuB,OAAA;AAEzB,MAAM;AACN,6FAG0D;AADxD,iIAAA,qBAAqB,OAAA;AAEvB,+FAA2F;AAAlF,mIAAA,sBAAsB,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GAAA,QAAQ,OAAA;AAIV,gEAG8C;AAF5C,kGAAA,OAAO,OAAA;AAGT,2BAA2B;AAC3B,wEAGkD;AAFhD,0GAAA,WAAW,OAAA;AAGb,kEAGgD;AAF9C,oGAAA,SAAS,OAAA;AAGX,kEAGgD;AAF9C,oGAAA,SAAS,OAAA;AAGX,QAAQ;AACR,0EAGoD;AAFlD,4GAAA,aAAa,OAAA;AAGf,sEAGkD;AAFhD,wGAAA,WAAW,OAAA;AAGb,8FAG2E;AAFzE,kHAAA,sBAAsB,OAAA;AAGxB;;GAEG;AACH,mFAAqF;AAA5E,uGAAA,WAAW,OAAA;AAEpB,iGAG8E;AAF5E,qHAAA,yBAAyB,OAAA;AAG3B,mEAKiD;AAJ/C,qGAAA,UAAU,OAAA;AAEV,qGAAA,UAAU,OAAA;AAGZ,mEAGiD;AAF/C,qGAAA,UAAU,OAAA;AAGZ,yBAAyB;AACzB,6DAAyD;AAAhD,yGAAA,SAAS,OAAA;AAClB,2DAAuD;AAA9C,uGAAA,QAAQ,OAAA;AACjB,uEAA+E;AAAtE,6GAAA,iBAAiB,OAAA;AAE1B,QAAQ;AACR,4DAAoE;AAA3D,iHAAA,mBAAmB,OAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAutoConnect = exports.useSendTransaction = exports.WalletProvider = exports.useWalletInfo = exports.useWalletImage = exports.createContractQuery = exports.useSocialProfiles = exports.useConnectionManager = exports.useWaitForCallsReceipt = exports.useSwitchActiveWalletChain = exports.useSetActiveWalletConnectionStatus = exports.useSetActiveWallet = exports.useSendCalls = exports.useSendAndConfirmCalls = exports.useIsAutoConnecting = exports.useDisconnect = exports.useConnectedWallets = exports.useConnect = exports.useCapabilities = exports.useAuthToken = exports.useAdminWallet = exports.useAddConnectedWallet = exports.useActiveWalletConnectionStatus = exports.useActiveWalletChain = exports.useActiveWallet = exports.useActiveAccount = exports.useSimulateTransaction = exports.useSendBatchTransaction = exports.useSendAndConfirmTransaction = exports.useEstimateGasCost = exports.useEstimateGas = exports.useBlockNumber = exports.usePostOnRampQuote = exports.useBuyWithFiatStatus = exports.useBuyWithFiatQuote = exports.useBuyWithFiatHistory = exports.useBuyWithCryptoStatus = exports.useBuyWithCryptoQuote = exports.useBuyWithCryptoHistory = exports.useBuyHistory = exports.useWalletBalance = exports.useInvalidateContractQuery = exports.useInvalidateBalances = exports.useWaitForReceipt = exports.useReadContract = exports.useContractEvents = exports.useSiweAuth = exports.lightTheme = exports.darkTheme = exports.AccountProvider = void 0;
|
|
4
|
-
exports.TransactionButton = exports.WalletName = exports.WalletIcon = exports.SocialIcon = exports.AccountName = exports.Blobbie = exports.AccountBlobbie = exports.AccountBalance = exports.AccountAvatar = exports.AccountAddress = exports.ConnectEmbed = exports.ConnectButton = exports.AutoConnect = exports.ThirdwebProvider = exports.useUnlinkProfile = exports.useProfiles = exports.useLinkProfile = void 0;
|
|
4
|
+
exports.TransactionButton = exports.WalletName = exports.WalletIcon = exports.SocialIcon = exports.AccountName = exports.Blobbie = exports.AccountBlobbie = exports.AccountBalance = exports.AccountAvatar = exports.AccountAddress = exports.ConnectEmbed = exports.ConnectButton = exports.AutoConnect = exports.ThirdwebProvider = exports.useFetchWithPayment = exports.useUnlinkProfile = exports.useProfiles = exports.useLinkProfile = void 0;
|
|
5
5
|
var provider_js_1 = require("../react/core/account/provider.js");
|
|
6
6
|
Object.defineProperty(exports, "AccountProvider", { enumerable: true, get: function () { return provider_js_1.AccountProvider; } });
|
|
7
7
|
// theme
|
|
@@ -118,6 +118,9 @@ var useProfiles_js_1 = require("../react/native/hooks/wallets/useProfiles.js");
|
|
|
118
118
|
Object.defineProperty(exports, "useProfiles", { enumerable: true, get: function () { return useProfiles_js_1.useProfiles; } });
|
|
119
119
|
var useUnlinkProfile_js_1 = require("../react/native/hooks/wallets/useUnlinkProfile.js");
|
|
120
120
|
Object.defineProperty(exports, "useUnlinkProfile", { enumerable: true, get: function () { return useUnlinkProfile_js_1.useUnlinkProfile; } });
|
|
121
|
+
// x402
|
|
122
|
+
var useFetchWithPayment_js_1 = require("../react/native/hooks/x402/useFetchWithPayment.js");
|
|
123
|
+
Object.defineProperty(exports, "useFetchWithPayment", { enumerable: true, get: function () { return useFetchWithPayment_js_1.useFetchWithPayment; } });
|
|
121
124
|
var thirdweb_provider_js_1 = require("../react/native/providers/thirdweb-provider.js");
|
|
122
125
|
Object.defineProperty(exports, "ThirdwebProvider", { enumerable: true, get: function () { return thirdweb_provider_js_1.ThirdwebProvider; } });
|
|
123
126
|
// Components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.native.js","sourceRoot":"","sources":["../../../src/exports/react.native.ts"],"names":[],"mappings":";;;;AAAA,iEAG2C;AAFzC,8GAAA,eAAe,OAAA;AAOjB,QAAQ;AACR,iEAA6E;AAApE,qGAAA,SAAS,OAAA;AAAE,sGAAA,UAAU,OAAA;AAG9B,0EAAsE;AAA7D,6GAAA,WAAW,OAAA;AAepB,0FAAsF;AAA7E,yHAAA,iBAAiB,OAAA;AAC1B,WAAW;AACX,sFAAkF;AAAzE,qHAAA,eAAe,OAAA;AACxB,0FAAsF;AAA7E,yHAAA,iBAAiB,OAAA;AAC1B,gGAA4F;AAAnF,iIAAA,qBAAqB,OAAA;AAC9B,8FAAgG;AAAvF,qIAAA,0BAA0B,OAAA;AACnC,sFAAkF;AAAzE,uHAAA,gBAAgB,OAAA;AACzB,6EAGkD;AADhD,iHAAA,aAAa,OAAA;AAEf,iGAG4D;AAD1D,qIAAA,uBAAuB,OAAA;AAEzB,MAAM;AACN,6FAG0D;AADxD,iIAAA,qBAAqB,OAAA;AAEvB,+FAA2F;AAAlF,mIAAA,sBAAsB,OAAA;AAC/B,6FAG0D;AADxD,iIAAA,qBAAqB,OAAA;AAEvB,yFAGwD;AADtD,6HAAA,mBAAmB,OAAA;AAErB,2FAAuF;AAA9E,+HAAA,oBAAoB,OAAA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6EAGwD;AAFtD,4GAAA,cAAc,OAAA;AAGhB;;GAEG;AACH,6EAIwD;AAHtD,4GAAA,cAAc,OAAA;AACd,qGAAA,OAAO,OAAA;AAGT,uEAGqD;AAFnD,sGAAA,WAAW,OAAA;AAGb,sEAKoD;AAJlD,qGAAA,UAAU,OAAA;AAEV,qGAAA,UAAU,OAAA;AAGZ,sEAGoD;AAFlD,qGAAA,UAAU,OAAA;AAGZ,4FAAwF;AAA/E,yHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useFetchWithPaymentCore = useFetchWithPaymentCore;
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const fetchWithPayment_js_1 = require("../../../../x402/fetchWithPayment.js");
|
|
7
|
+
const useActiveWallet_js_1 = require("../wallets/useActiveWallet.js");
|
|
8
|
+
/**
|
|
9
|
+
* Core hook for fetch with payment functionality.
|
|
10
|
+
* This is the platform-agnostic implementation used by both web and native versions.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function useFetchWithPaymentCore(client, options, showErrorModal, showConnectModal) {
|
|
14
|
+
const wallet = (0, useActiveWallet_js_1.useActiveWallet)();
|
|
15
|
+
const mutation = (0, react_query_1.useMutation)({
|
|
16
|
+
mutationFn: async ({ input, init, }) => {
|
|
17
|
+
// Recursive function that handles fetch + 402 error + retry
|
|
18
|
+
const executeFetch = async (currentWallet = wallet) => {
|
|
19
|
+
if (!currentWallet) {
|
|
20
|
+
// If a connect modal handler is provided, show the connect modal
|
|
21
|
+
if (showConnectModal) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
showConnectModal({
|
|
24
|
+
onConnect: async (newWallet) => {
|
|
25
|
+
// After connection, retry the fetch with the newly connected wallet
|
|
26
|
+
try {
|
|
27
|
+
const result = await executeFetch(newWallet);
|
|
28
|
+
resolve(result);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
reject(error);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
onCancel: () => {
|
|
35
|
+
reject(new Error("Wallet connection cancelled by user"));
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// If no connect modal handler, throw an error
|
|
41
|
+
throw new Error("No wallet connected. Please connect your wallet to make paid API calls.");
|
|
42
|
+
}
|
|
43
|
+
const wrappedFetch = (0, fetchWithPayment_js_1.wrapFetchWithPayment)(globalThis.fetch, client, currentWallet, options);
|
|
44
|
+
const response = await wrappedFetch(input, init);
|
|
45
|
+
// Check if we got a 402 response (payment error)
|
|
46
|
+
if (response.status === 402) {
|
|
47
|
+
try {
|
|
48
|
+
const errorBody = (await response.json());
|
|
49
|
+
// If a modal handler is provided, show the modal and handle retry/cancel
|
|
50
|
+
if (showErrorModal) {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
showErrorModal({
|
|
53
|
+
errorData: errorBody,
|
|
54
|
+
onRetry: async () => {
|
|
55
|
+
// Retry the entire fetch+error handling logic recursively
|
|
56
|
+
try {
|
|
57
|
+
const result = await executeFetch();
|
|
58
|
+
resolve(result);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
reject(error);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
onCancel: () => {
|
|
65
|
+
reject(new Error("Payment cancelled by user"));
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// If no modal handler, throw the error with details
|
|
71
|
+
throw new Error(errorBody.errorMessage || `Payment failed: ${errorBody.error}`);
|
|
72
|
+
}
|
|
73
|
+
catch (_parseError) {
|
|
74
|
+
// If we can't parse the error body, throw a generic error
|
|
75
|
+
throw new Error("Payment failed with status 402");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const errorText = await response.text();
|
|
80
|
+
throw new Error(`Payment failed with status ${response.status} ${response.statusText} - ${errorText || "Unknown error"}`);
|
|
81
|
+
}
|
|
82
|
+
const parseAs = options?.parseAs ?? "json";
|
|
83
|
+
return parseResponse(response, parseAs);
|
|
84
|
+
};
|
|
85
|
+
// Start the fetch process
|
|
86
|
+
return executeFetch();
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
fetchWithPayment: async (input, init) => {
|
|
91
|
+
return mutation.mutateAsync({ input, init });
|
|
92
|
+
},
|
|
93
|
+
...mutation,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function parseResponse(response, parseAs) {
|
|
97
|
+
if (parseAs === "json") {
|
|
98
|
+
return response.json();
|
|
99
|
+
}
|
|
100
|
+
else if (parseAs === "text") {
|
|
101
|
+
return response.text();
|
|
102
|
+
}
|
|
103
|
+
else if (parseAs === "raw") {
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw new Error(`Invalid parseAs option: ${parseAs}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=useFetchWithPaymentCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchWithPaymentCore.js","sourceRoot":"","sources":["../../../../../../src/react/core/hooks/x402/useFetchWithPaymentCore.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAkCb,0DAiHC;AAjJD,uDAAoD;AAGpD,8EAA4E;AAG5E,sEAAgE;AAqBhE;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,MAAsB,EACtB,OAAoC,EACpC,cAAuC,EACvC,gBAA2C;IAE3C,MAAM,MAAM,GAAG,IAAA,oCAAe,GAAE,CAAC;IAEjC,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC;QAC3B,UAAU,EAAE,KAAK,EAAE,EACjB,KAAK,EACL,IAAI,GAIL,EA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L,gBAAgB,EAAE,KAAK,EAAE,KAAkB,EAAE,IAAkB,EAAE,EAAE;YACjE,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,QAAkB,EAAE,OAAgC;IACzE,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useFetchWithPayment = useFetchWithPayment;
|
|
5
|
+
const useFetchWithPaymentCore_js_1 = require("../../../core/hooks/x402/useFetchWithPaymentCore.js");
|
|
6
|
+
/**
|
|
7
|
+
* A React hook that wraps the native fetch API to automatically handle 402 Payment Required responses
|
|
8
|
+
* using the x402 payment protocol with the currently connected wallet.
|
|
9
|
+
*
|
|
10
|
+
* This hook enables you to make API calls that require payment without manually handling the payment flow.
|
|
11
|
+
* Responses are automatically parsed as JSON by default (can be customized with `parseAs` option).
|
|
12
|
+
*
|
|
13
|
+
* When a 402 response is received, it will automatically:
|
|
14
|
+
* 1. Parse the payment requirements
|
|
15
|
+
* 2. Verify the payment amount is within the allowed maximum
|
|
16
|
+
* 3. Create a payment header using the connected wallet
|
|
17
|
+
* 4. Retry the request with the payment header
|
|
18
|
+
*
|
|
19
|
+
* Note: This is the React Native version which does not include modal UI.
|
|
20
|
+
* Payment errors will be thrown and should be handled by your application.
|
|
21
|
+
*
|
|
22
|
+
* @param client - The thirdweb client used to access RPC infrastructure
|
|
23
|
+
* @param options - Optional configuration for payment handling
|
|
24
|
+
* @param options.maxValue - The maximum allowed payment amount in base units
|
|
25
|
+
* @param options.paymentRequirementsSelector - Custom function to select payment requirements from available options
|
|
26
|
+
* @param options.parseAs - How to parse the response: "json" (default), "text", or "raw"
|
|
27
|
+
* @returns An object containing:
|
|
28
|
+
* - `fetchWithPayment`: Function to make fetch requests with automatic payment handling (returns parsed data)
|
|
29
|
+
* - `isPending`: Boolean indicating if a request is in progress
|
|
30
|
+
* - `error`: Any error that occurred during the request
|
|
31
|
+
* - `data`: The parsed response data (JSON by default, or based on `parseAs` option)
|
|
32
|
+
* - Other mutation properties from React Query
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { useFetchWithPayment } from "thirdweb/react";
|
|
37
|
+
* import { createThirdwebClient } from "thirdweb";
|
|
38
|
+
*
|
|
39
|
+
* const client = createThirdwebClient({ clientId: "your-client-id" });
|
|
40
|
+
*
|
|
41
|
+
* function MyComponent() {
|
|
42
|
+
* const { fetchWithPayment, isPending, error } = useFetchWithPayment(client);
|
|
43
|
+
*
|
|
44
|
+
* const handleApiCall = async () => {
|
|
45
|
+
* try {
|
|
46
|
+
* // Response is automatically parsed as JSON
|
|
47
|
+
* const data = await fetchWithPayment('https://api.example.com/paid-endpoint');
|
|
48
|
+
* console.log(data);
|
|
49
|
+
* } catch (err) {
|
|
50
|
+
* // Handle payment errors manually in React Native
|
|
51
|
+
* console.error("Payment failed:", err);
|
|
52
|
+
* }
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <button onClick={handleApiCall} disabled={isPending}>
|
|
57
|
+
* {isPending ? 'Loading...' : 'Make Paid API Call'}
|
|
58
|
+
* </button>
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* ### Customize response parsing
|
|
64
|
+
* ```tsx
|
|
65
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
66
|
+
* parseAs: "text", // Get response as text instead of JSON
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* const textData = await fetchWithPayment('https://api.example.com/endpoint');
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* ### Customize payment options
|
|
73
|
+
* ```tsx
|
|
74
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
75
|
+
* maxValue: 5000000n, // 5 USDC in base units
|
|
76
|
+
* paymentRequirementsSelector: (requirements) => {
|
|
77
|
+
* // Custom logic to select preferred payment method
|
|
78
|
+
* return requirements[0];
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @x402
|
|
84
|
+
*/
|
|
85
|
+
function useFetchWithPayment(client, options) {
|
|
86
|
+
// Native version doesn't show modal, errors bubble up naturally
|
|
87
|
+
return (0, useFetchWithPaymentCore_js_1.useFetchWithPaymentCore)(client, options);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=useFetchWithPayment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchWithPayment.js","sourceRoot":"","sources":["../../../../../../src/react/native/hooks/x402/useFetchWithPayment.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAyFb,kDAMC;AA5FD,oGAG6D;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,SAAgB,mBAAmB,CACjC,MAAsB,EACtB,OAAoC;IAEpC,gEAAgE;IAChE,OAAO,IAAA,oDAAuB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useFetchWithPayment = useFetchWithPayment;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useFetchWithPaymentCore_js_1 = require("../../../core/hooks/x402/useFetchWithPaymentCore.js");
|
|
8
|
+
const RootElementContext_js_1 = require("../../../core/providers/RootElementContext.js");
|
|
9
|
+
const useConnectModal_js_1 = require("../../ui/ConnectWallet/useConnectModal.js");
|
|
10
|
+
const PaymentErrorModal_js_1 = require("../../ui/x402/PaymentErrorModal.js");
|
|
11
|
+
const SignInRequiredModal_js_1 = require("../../ui/x402/SignInRequiredModal.js");
|
|
12
|
+
/**
|
|
13
|
+
* A React hook that wraps the native fetch API to automatically handle 402 Payment Required responses
|
|
14
|
+
* using the x402 payment protocol with the currently connected wallet.
|
|
15
|
+
*
|
|
16
|
+
* This hook enables you to make API calls that require payment without manually handling the payment flow.
|
|
17
|
+
* Responses are automatically parsed as JSON by default (can be customized with `parseAs` option).
|
|
18
|
+
*
|
|
19
|
+
* When a 402 response is received, it will automatically:
|
|
20
|
+
* 1. Parse the payment requirements
|
|
21
|
+
* 2. Verify the payment amount is within the allowed maximum
|
|
22
|
+
* 3. Create a payment header using the connected wallet
|
|
23
|
+
* 4. Retry the request with the payment header
|
|
24
|
+
*
|
|
25
|
+
* If payment fails (e.g. insufficient funds), a modal will be shown to help the user resolve the issue.
|
|
26
|
+
* If no wallet is connected, a sign-in modal will be shown to connect a wallet.
|
|
27
|
+
*
|
|
28
|
+
* @param client - The thirdweb client used to access RPC infrastructure
|
|
29
|
+
* @param options - Optional configuration for payment handling
|
|
30
|
+
* @param options.maxValue - The maximum allowed payment amount in base units
|
|
31
|
+
* @param options.paymentRequirementsSelector - Custom function to select payment requirements from available options
|
|
32
|
+
* @param options.parseAs - How to parse the response: "json" (default), "text", or "raw"
|
|
33
|
+
* @param options.uiEnabled - Whether to show the UI for connection, funding or payment retries (defaults to true). Set to false to handle errors yourself
|
|
34
|
+
* @param options.theme - Theme for the payment error modal (defaults to "dark")
|
|
35
|
+
* @param options.fundWalletOptions - Customize the BuyWidget shown when user needs to fund their wallet
|
|
36
|
+
* @param options.connectOptions - Customize the ConnectModal shown when user needs to sign in
|
|
37
|
+
* @returns An object containing:
|
|
38
|
+
* - `fetchWithPayment`: Function to make fetch requests with automatic payment handling (returns parsed data)
|
|
39
|
+
* - `isPending`: Boolean indicating if a request is in progress
|
|
40
|
+
* - `error`: Any error that occurred during the request
|
|
41
|
+
* - `data`: The parsed response data (JSON by default, or based on `parseAs` option)
|
|
42
|
+
* - Other mutation properties from React Query
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { useFetchWithPayment } from "thirdweb/react";
|
|
47
|
+
* import { createThirdwebClient } from "thirdweb";
|
|
48
|
+
*
|
|
49
|
+
* const client = createThirdwebClient({ clientId: "your-client-id" });
|
|
50
|
+
*
|
|
51
|
+
* function MyComponent() {
|
|
52
|
+
* const { fetchWithPayment, isPending } = useFetchWithPayment(client);
|
|
53
|
+
*
|
|
54
|
+
* const handleApiCall = async () => {
|
|
55
|
+
* // Response is automatically parsed as JSON
|
|
56
|
+
* const data = await fetchWithPayment('https://api.example.com/paid-endpoint');
|
|
57
|
+
* console.log(data);
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* return (
|
|
61
|
+
* <button onClick={handleApiCall} disabled={isPending}>
|
|
62
|
+
* {isPending ? 'Loading...' : 'Make Paid API Call'}
|
|
63
|
+
* </button>
|
|
64
|
+
* );
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* ### Customize response parsing
|
|
69
|
+
* ```tsx
|
|
70
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
71
|
+
* parseAs: "text", // Get response as text instead of JSON
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* const textData = await fetchWithPayment('https://api.example.com/endpoint');
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* ### Customize payment options
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
80
|
+
* maxValue: 5000000n, // 5 USDC in base units
|
|
81
|
+
* theme: "light",
|
|
82
|
+
* paymentRequirementsSelector: (requirements) => {
|
|
83
|
+
* // Custom logic to select preferred payment method
|
|
84
|
+
* return requirements[0];
|
|
85
|
+
* }
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* ### Customize the fund wallet widget
|
|
90
|
+
* ```tsx
|
|
91
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
92
|
+
* fundWalletOptions: {
|
|
93
|
+
* title: "Add Funds",
|
|
94
|
+
* description: "You need more tokens to complete this payment",
|
|
95
|
+
* buttonLabel: "Get Tokens",
|
|
96
|
+
* }
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* ### Customize the connect modal
|
|
101
|
+
* ```tsx
|
|
102
|
+
* const { fetchWithPayment } = useFetchWithPayment(client, {
|
|
103
|
+
* connectOptions: {
|
|
104
|
+
* wallets: [inAppWallet(), createWallet("io.metamask")],
|
|
105
|
+
* title: "Sign in to continue",
|
|
106
|
+
* }
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* ### Disable the UI and handle errors yourself
|
|
111
|
+
* ```tsx
|
|
112
|
+
* const { fetchWithPayment, error } = useFetchWithPayment(client, {
|
|
113
|
+
* uiEnabled: false,
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Handle the error manually
|
|
117
|
+
* if (error) {
|
|
118
|
+
* console.error("Payment failed:", error);
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @x402
|
|
123
|
+
*/
|
|
124
|
+
function useFetchWithPayment(client, options) {
|
|
125
|
+
const setRootEl = (0, react_1.useContext)(RootElementContext_js_1.SetRootElementContext);
|
|
126
|
+
const { connect } = (0, useConnectModal_js_1.useConnectModal)();
|
|
127
|
+
const theme = options?.theme || "dark";
|
|
128
|
+
const showModal = options?.uiEnabled !== false; // Default to true
|
|
129
|
+
const showErrorModal = showModal
|
|
130
|
+
? (data) => {
|
|
131
|
+
setRootEl((0, jsx_runtime_1.jsx)(PaymentErrorModal_js_1.PaymentErrorModal, { client: client, errorData: data.errorData, onCancel: () => {
|
|
132
|
+
setRootEl(null);
|
|
133
|
+
data.onCancel();
|
|
134
|
+
}, onRetry: () => {
|
|
135
|
+
setRootEl(null);
|
|
136
|
+
data.onRetry();
|
|
137
|
+
}, theme: theme, fundWalletOptions: options?.fundWalletOptions, paymentRequirementsSelector: options?.paymentRequirementsSelector }));
|
|
138
|
+
}
|
|
139
|
+
: undefined;
|
|
140
|
+
const showConnectModal = showModal
|
|
141
|
+
? (data) => {
|
|
142
|
+
// First, show the SignInRequiredModal
|
|
143
|
+
setRootEl((0, jsx_runtime_1.jsx)(SignInRequiredModal_js_1.SignInRequiredModal, { theme: theme, onSignIn: async () => {
|
|
144
|
+
// Close the SignInRequiredModal
|
|
145
|
+
setRootEl(null);
|
|
146
|
+
// Open the ConnectModal
|
|
147
|
+
try {
|
|
148
|
+
const connectedWallet = await connect({
|
|
149
|
+
client,
|
|
150
|
+
theme,
|
|
151
|
+
...options?.connectOptions,
|
|
152
|
+
});
|
|
153
|
+
// On successful connection, trigger onConnect callback with the wallet
|
|
154
|
+
data.onConnect(connectedWallet);
|
|
155
|
+
}
|
|
156
|
+
catch (_error) {
|
|
157
|
+
// User cancelled the connection
|
|
158
|
+
data.onCancel();
|
|
159
|
+
}
|
|
160
|
+
}, onCancel: () => {
|
|
161
|
+
setRootEl(null);
|
|
162
|
+
data.onCancel();
|
|
163
|
+
} }));
|
|
164
|
+
}
|
|
165
|
+
: undefined;
|
|
166
|
+
return (0, useFetchWithPaymentCore_js_1.useFetchWithPaymentCore)(client, options, showErrorModal, showConnectModal);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=useFetchWithPayment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchWithPayment.js","sourceRoot":"","sources":["../../../../../../src/react/web/hooks/x402/useFetchWithPayment.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAkKb,kDA2EC;;AA3OD,iCAAmC;AAInC,oGAG6D;AAC7D,yFAAsF;AAEtF,kFAGmD;AACnD,6EAAuE;AACvE,iFAA2E;AAiC3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+GG;AACH,SAAgB,mBAAmB,CACjC,MAAsB,EACtB,OAAmC;IAEnC,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,6CAAqB,CAAC,CAAC;IACpD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,oCAAe,GAAE,CAAC;IACtC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,KAAK,KAAK,CAAC,CAAC,kBAAkB;IAElE,MAAM,cAAc,GAAG,SAAS;QAC9B,CAAC,CAAC,CAAC,IAIA,EAAE,EAAE;YACH,SAAS,CACP,uBAAC,wCAAiB,IAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,GAAG,EAAE;oBACb,SAAS,CAAC,IAAI,CAAC,CAAC;oBAChB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACZ,SAAS,CAAC,IAAI,CAAC,CAAC;oBAChB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC,EACD,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,EAC7C,2BAA2B,EAAE,OAAO,EAAE,2BAA2B,GACjE,CACH,CAAC;QACJ,CAAC;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,gBAAgB,GAAG,SAAS;QAChC,CAAC,CAAC,CAAC,IAAmE,EAAE,EAAE;YACtE,sCAAsC;YACtC,SAAS,CACP,uBAAC,4CAAmB,IAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,gCAAgC;oBAChC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAEhB,wBAAwB;oBACxB,IAAI,CAAC;wBACH,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC;4BACpC,MAAM;4BACN,KAAK;4BACL,GAAG,OAAO,EAAE,cAAc;yBAC3B,CAAC,CAAC;wBAEH,uEAAuE;wBACvE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;oBAClC,CAAC;oBAAC,OAAO,MAAM,EAAE,CAAC;wBAChB,gCAAgC;wBAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,CAAC;gBACH,CAAC,EACD,QAAQ,EAAE,GAAG,EAAE;oBACb,SAAS,CAAC,IAAI,CAAC,CAAC;oBAChB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC,GACD,CACH,CAAC;QACJ,CAAC;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,IAAA,oDAAuB,EAC5B,MAAM,EACN,OAAO,EACP,cAAc,EACd,gBAAgB,CACjB,CAAC;AACJ,CAAC"}
|
|
@@ -17,7 +17,7 @@ exports.ScreenBottomContainer = (0, elements_js_1.StyledDiv)((_) => {
|
|
|
17
17
|
borderTop: `1px solid ${theme.colors.separatorLine}`,
|
|
18
18
|
display: "flex",
|
|
19
19
|
flexDirection: "column",
|
|
20
|
-
gap: index_js_1.spacing.
|
|
20
|
+
gap: index_js_1.spacing.md,
|
|
21
21
|
padding: index_js_1.spacing.lg,
|
|
22
22
|
};
|
|
23
23
|
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PaymentErrorModal = PaymentErrorModal;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const utils_js_1 = require("../../../../chains/utils.js");
|
|
8
|
+
const schemas_js_1 = require("../../../../x402/schemas.js");
|
|
9
|
+
const CustomThemeProvider_js_1 = require("../../../core/design-system/CustomThemeProvider.js");
|
|
10
|
+
const index_js_1 = require("../../../core/design-system/index.js");
|
|
11
|
+
const useActiveWallet_js_1 = require("../../../core/hooks/wallets/useActiveWallet.js");
|
|
12
|
+
const BuyWidget_js_1 = require("../Bridge/BuyWidget.js");
|
|
13
|
+
const basic_js_1 = require("../components/basic.js");
|
|
14
|
+
const buttons_js_1 = require("../components/buttons.js");
|
|
15
|
+
const Modal_js_1 = require("../components/Modal.js");
|
|
16
|
+
const text_js_1 = require("../components/text.js");
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function PaymentErrorModal(props) {
|
|
21
|
+
const { client, errorData, onRetry, onCancel, theme, fundWalletOptions, paymentRequirementsSelector, } = props;
|
|
22
|
+
const [screen, setScreen] = (0, react_1.useState)("error");
|
|
23
|
+
const isInsufficientFunds = errorData.error === "insufficient_funds";
|
|
24
|
+
const wallet = (0, useActiveWallet_js_1.useActiveWallet)();
|
|
25
|
+
// Extract chain and token info from errorData for BuyWidget
|
|
26
|
+
const getBuyWidgetConfig = () => {
|
|
27
|
+
if (!errorData.accepts || errorData.accepts.length === 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// Get payment requirements from errorData
|
|
31
|
+
const parsedPaymentRequirements = errorData.accepts;
|
|
32
|
+
// Get the current chain from wallet
|
|
33
|
+
const currentChain = wallet?.getChain();
|
|
34
|
+
const currentChainId = currentChain?.id;
|
|
35
|
+
// Select payment requirement using the same logic as wrapFetchWithPayment
|
|
36
|
+
const selectedRequirement = paymentRequirementsSelector
|
|
37
|
+
? paymentRequirementsSelector(parsedPaymentRequirements)
|
|
38
|
+
: defaultPaymentRequirementsSelector(parsedPaymentRequirements, currentChainId, "exact", errorData.error);
|
|
39
|
+
if (!selectedRequirement)
|
|
40
|
+
return null;
|
|
41
|
+
const caip2ChainId = (0, schemas_js_1.networkToCaip2ChainId)(selectedRequirement.network);
|
|
42
|
+
const chainId = (0, schemas_js_1.extractEvmChainId)(caip2ChainId);
|
|
43
|
+
if (!chainId)
|
|
44
|
+
return null;
|
|
45
|
+
const chain = (0, utils_js_1.getCachedChain)(chainId);
|
|
46
|
+
const tokenAddress = selectedRequirement.asset;
|
|
47
|
+
return {
|
|
48
|
+
chain,
|
|
49
|
+
tokenAddress,
|
|
50
|
+
amount: undefined,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const buyWidgetConfig = isInsufficientFunds ? getBuyWidgetConfig() : null;
|
|
54
|
+
if (screen === "buy-widget" && buyWidgetConfig) {
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(CustomThemeProvider_js_1.CustomThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(Modal_js_1.Modal, { className: "tw-payment-error-modal", hideCloseIcon: false, open: true, setOpen: (open) => {
|
|
56
|
+
if (!open) {
|
|
57
|
+
onCancel();
|
|
58
|
+
}
|
|
59
|
+
}, size: "compact", title: "Top up your wallet", crossContainerStyles: {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
right: index_js_1.spacing.lg,
|
|
62
|
+
top: index_js_1.spacing.lg,
|
|
63
|
+
zIndex: 1,
|
|
64
|
+
}, children: (0, jsx_runtime_1.jsx)(BuyWidget_js_1.BuyWidget, { client: client, theme: theme, chain: buyWidgetConfig.chain, tokenAddress: buyWidgetConfig.tokenAddress, amount: buyWidgetConfig.amount, style: {
|
|
65
|
+
border: "none",
|
|
66
|
+
width: "100%",
|
|
67
|
+
}, buttonLabel: "Continue", title: "Get funds", description: "Top up your wallet to complete your payment.", ...fundWalletOptions, onSuccess: () => {
|
|
68
|
+
// Close modal and retry the payment
|
|
69
|
+
onRetry();
|
|
70
|
+
}, onCancel: () => {
|
|
71
|
+
// Go back to error screen
|
|
72
|
+
setScreen("error");
|
|
73
|
+
} }) }) }));
|
|
74
|
+
}
|
|
75
|
+
// Error screen (default)
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(CustomThemeProvider_js_1.CustomThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(Modal_js_1.Modal, { className: "tw-payment-error-modal", hideCloseIcon: true, open: true, setOpen: (open) => {
|
|
77
|
+
if (!open) {
|
|
78
|
+
onCancel();
|
|
79
|
+
}
|
|
80
|
+
}, size: "compact", title: "Payment Failed", children: [(0, jsx_runtime_1.jsxs)(basic_js_1.Container, { p: "lg", children: [(0, jsx_runtime_1.jsx)(basic_js_1.ModalHeader, { title: "Payment failed" }), (0, jsx_runtime_1.jsx)(basic_js_1.Container, { flex: "column", gap: "lg", style: {
|
|
81
|
+
paddingTop: index_js_1.spacing.lg,
|
|
82
|
+
}, children: (0, jsx_runtime_1.jsx)(text_js_1.Text, { size: "sm", style: {
|
|
83
|
+
color: "inherit",
|
|
84
|
+
lineHeight: 1.5,
|
|
85
|
+
}, children: isInsufficientFunds
|
|
86
|
+
? "Your wallet doesn't have enough funds to complete this payment. Please top up your wallet and try again."
|
|
87
|
+
: errorData.errorMessage ||
|
|
88
|
+
"An error occurred while processing your payment." }) })] }), (0, jsx_runtime_1.jsx)(basic_js_1.ScreenBottomContainer, { children: isInsufficientFunds && buyWidgetConfig ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: () => setScreen("buy-widget"), variant: "accent", children: "Top up your wallet" }), (0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: onCancel, variant: "secondary", children: "Cancel" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: onRetry, variant: "accent", children: "Try Again" }), (0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: onCancel, variant: "secondary", children: "Cancel" })] })) })] }) }));
|
|
89
|
+
}
|
|
90
|
+
// Default payment requirement selector - same logic as in fetchWithPayment.ts
|
|
91
|
+
function defaultPaymentRequirementsSelector(paymentRequirements, chainId, scheme, _error) {
|
|
92
|
+
if (!paymentRequirements.length) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
// If we have a chainId, find matching payment requirements
|
|
96
|
+
if (chainId !== undefined) {
|
|
97
|
+
const matchingPaymentRequirements = paymentRequirements.find((x) => (0, schemas_js_1.extractEvmChainId)((0, schemas_js_1.networkToCaip2ChainId)(x.network)) === chainId &&
|
|
98
|
+
x.scheme === scheme);
|
|
99
|
+
if (matchingPaymentRequirements) {
|
|
100
|
+
return matchingPaymentRequirements;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// If no matching payment requirements, use the first payment requirement
|
|
104
|
+
const firstPaymentRequirement = paymentRequirements.find((x) => x.scheme === scheme);
|
|
105
|
+
return firstPaymentRequirement;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=PaymentErrorModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentErrorModal.js","sourceRoot":"","sources":["../../../../../../src/react/web/ui/x402/PaymentErrorModal.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAoDb,8CAiLC;;AApOD,iCAAiC;AACjC,0DAA6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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SignInRequiredModal = SignInRequiredModal;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const CustomThemeProvider_js_1 = require("../../../core/design-system/CustomThemeProvider.js");
|
|
7
|
+
const index_js_1 = require("../../../core/design-system/index.js");
|
|
8
|
+
const basic_js_1 = require("../components/basic.js");
|
|
9
|
+
const buttons_js_1 = require("../components/buttons.js");
|
|
10
|
+
const Modal_js_1 = require("../components/Modal.js");
|
|
11
|
+
const text_js_1 = require("../components/text.js");
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
function SignInRequiredModal(props) {
|
|
16
|
+
const { theme, onSignIn, onCancel } = props;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(CustomThemeProvider_js_1.CustomThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(Modal_js_1.Modal, { className: "tw-signin-required-modal", hideCloseIcon: true, open: true, setOpen: (open) => {
|
|
18
|
+
if (!open) {
|
|
19
|
+
onCancel();
|
|
20
|
+
}
|
|
21
|
+
}, size: "compact", title: "Sign in required", children: [(0, jsx_runtime_1.jsxs)(basic_js_1.Container, { p: "lg", children: [(0, jsx_runtime_1.jsx)(basic_js_1.ModalHeader, { title: "Sign in required" }), (0, jsx_runtime_1.jsx)(basic_js_1.Container, { flex: "column", gap: "lg", style: {
|
|
22
|
+
paddingTop: index_js_1.spacing.lg,
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)(text_js_1.Text, { size: "sm", style: {
|
|
24
|
+
color: "inherit",
|
|
25
|
+
lineHeight: 1.5,
|
|
26
|
+
}, children: "Account required to complete payment, please sign in to continue." }) })] }), (0, jsx_runtime_1.jsxs)(basic_js_1.ScreenBottomContainer, { children: [(0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: onSignIn, variant: "accent", children: "Sign in" }), (0, jsx_runtime_1.jsx)(buttons_js_1.Button, { fullWidth: true, gap: "xs", onClick: onCancel, variant: "secondary", children: "Cancel" })] })] }) }));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=SignInRequiredModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignInRequiredModal.js","sourceRoot":"","sources":["../../../../../../src/react/web/ui/x402/SignInRequiredModal.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAsBb,kDAoDC;;AAzED,+FAAyF;AAEzF,mEAA+D;AAC/D,qDAIgC;AAChC,yDAAkD;AAClD,qDAA+C;AAC/C,mDAA6C;AAQ7C;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE5C,OAAO,CACL,uBAAC,4CAAmB,IAAC,KAAK,EAAE,KAAK,YAC/B,wBAAC,gBAAK,IACJ,SAAS,EAAC,0BAA0B,EACpC,aAAa,EAAE,IAAI,EACnB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,QAAQ,EAAE,CAAC;gBACb,CAAC;YACH,CAAC,EACD,IAAI,EAAC,SAAS,EACd,KAAK,EAAC,kBAAkB,aAExB,wBAAC,oBAAS,IAAC,CAAC,EAAC,IAAI,aACf,uBAAC,sBAAW,IAAC,KAAK,EAAC,kBAAkB,GAAG,EAExC,uBAAC,oBAAS,IACR,IAAI,EAAC,QAAQ,EACb,GAAG,EAAC,IAAI,EACR,KAAK,EAAE;gCACL,UAAU,EAAE,kBAAO,CAAC,EAAE;6BACvB,YAGD,uBAAC,cAAI,IACH,IAAI,EAAC,IAAI,EACT,KAAK,EAAE;oCACL,KAAK,EAAE,SAAS;oCAChB,UAAU,EAAE,GAAG;iCAChB,kFAGI,GACG,IACF,EAGZ,wBAAC,gCAAqB,eACpB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