thirdweb 5.121.2 → 5.121.4
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/insight/get-nfts.js +2 -2
- package/dist/cjs/insight/get-nfts.js.map +1 -1
- package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js +1 -0
- package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -1
- package/dist/cjs/react/native/hooks/x402/useFetchWithPayment.js +1 -1
- package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js +2 -2
- package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js.map +1 -1
- package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js +4 -4
- package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/x402/encode.js +41 -2
- package/dist/cjs/x402/encode.js.map +1 -1
- package/dist/cjs/x402/fetchWithPayment.js +56 -33
- package/dist/cjs/x402/fetchWithPayment.js.map +1 -1
- package/dist/cjs/x402/schemas.js +134 -2
- package/dist/cjs/x402/schemas.js.map +1 -1
- package/dist/cjs/x402/sign.js +56 -15
- package/dist/cjs/x402/sign.js.map +1 -1
- package/dist/esm/insight/get-nfts.js +2 -2
- package/dist/esm/insight/get-nfts.js.map +1 -1
- package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js +2 -1
- package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -1
- package/dist/esm/react/native/hooks/x402/useFetchWithPayment.js +1 -1
- package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js +2 -2
- package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js.map +1 -1
- package/dist/esm/react/web/ui/x402/PaymentErrorModal.js +5 -5
- package/dist/esm/react/web/ui/x402/PaymentErrorModal.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/x402/encode.js +40 -2
- package/dist/esm/x402/encode.js.map +1 -1
- package/dist/esm/x402/fetchWithPayment.js +57 -35
- package/dist/esm/x402/fetchWithPayment.js.map +1 -1
- package/dist/esm/x402/schemas.js +129 -1
- package/dist/esm/x402/schemas.js.map +1 -1
- package/dist/esm/x402/sign.js +57 -16
- package/dist/esm/x402/sign.js.map +1 -1
- package/dist/scripts/bridge-widget.js +64 -64
- package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts +1 -0
- package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts.map +1 -1
- package/dist/types/react/native/hooks/x402/useFetchWithPayment.d.ts +1 -1
- package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts +1 -1
- package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts.map +1 -1
- package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts +1 -0
- package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/x402/encode.d.ts +7 -0
- package/dist/types/x402/encode.d.ts.map +1 -1
- package/dist/types/x402/fetchWithPayment.d.ts +10 -1
- package/dist/types/x402/fetchWithPayment.d.ts.map +1 -1
- package/dist/types/x402/schemas.d.ts +60 -2
- package/dist/types/x402/schemas.d.ts.map +1 -1
- package/dist/types/x402/sign.d.ts +13 -1
- package/dist/types/x402/sign.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/contract/actions/resolve-abi.test.ts +3 -5
- package/src/extensions/airdrop/write/airdropERC721WithSignature.test.ts +4 -5
- package/src/extensions/erc1155/drop1155.test.ts +1 -1
- package/src/extensions/erc1155/write/sigMint1155.test.ts +189 -187
- package/src/extensions/erc20/drop20.test.ts +1 -1
- package/src/extensions/erc721/write/sigMint721.test.ts +4 -6
- package/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts +180 -178
- package/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts +1 -1
- package/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts +1 -1
- package/src/extensions/prebuilts/process-ref-deployments.test.ts +1 -1
- package/src/insight/get-nfts.ts +2 -2
- package/src/react/core/account/provider.test.tsx +1 -0
- package/src/react/core/hooks/others/useWalletBalance.test.tsx +1 -0
- package/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.test.tsx +1 -0
- package/src/react/core/hooks/useStepExecutor.test.tsx +1 -0
- package/src/react/core/hooks/wallets/useAddConnectedWallet.test.tsx +1 -0
- package/src/react/core/hooks/wallets/useAutoConnectCore.test.tsx +1 -0
- package/src/react/core/hooks/wallets/useConnect.test.tsx +1 -0
- package/src/react/core/hooks/wallets/useSetActiveWallet.test.tsx +1 -0
- package/src/react/core/hooks/wallets/useSwitchActiveWalletChain.test.tsx +1 -0
- package/src/react/core/hooks/x402/useFetchWithPaymentCore.ts +6 -1
- package/src/react/core/providers/connection-manager.test.tsx +1 -0
- package/src/react/core/wallet/provider.test.tsx +1 -0
- package/src/react/native/hooks/wallets/useUnlinkProfile.test.tsx +1 -0
- package/src/react/native/hooks/x402/useFetchWithPayment.ts +1 -1
- package/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx +1 -0
- package/src/react/web/hooks/x402/useFetchWithPayment.tsx +3 -1
- package/src/react/web/ui/AutoConnect/AutoConnect.test.tsx +1 -0
- package/src/react/web/ui/Bridge/StepRunner.test.tsx +1 -0
- package/src/react/web/ui/Bridge/common/token-query.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/ConnectButton.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/Details.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/NetworkSelector.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/PrivateKey.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/ReceiveFunds.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/SendFunds.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.test.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/StartScreen.test.tsx +1 -0
- package/src/react/web/ui/MediaRenderer/MediaRenderer.test.tsx +1 -0
- package/src/react/web/ui/MediaRenderer/icons.test.tsx +1 -0
- package/src/react/web/ui/MediaRenderer/useResolvedMediaType.test.tsx +1 -0
- package/src/react/web/ui/SiteEmbed.test.tsx +1 -0
- package/src/react/web/ui/SiteLink.test.tsx +1 -0
- package/src/react/web/ui/TransactionButton/TransactionButton.test.tsx +1 -0
- package/src/react/web/ui/components/ChainIcon.test.tsx +1 -0
- package/src/react/web/ui/hooks/useCopyClipboard.test.tsx +1 -0
- package/src/react/web/ui/hooks/useDebouncedValue.test.tsx +1 -0
- package/src/react/web/ui/hooks/useShowMore.test.tsx +28 -12
- package/src/react/web/ui/prebuilt/Account/address.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Account/avatar.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Account/balance.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Account/name.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Chain/icon.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Chain/name.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Chain/provider.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/NFT/description.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/NFT/media.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/NFT/name.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/NFT/provider.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Token/name.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Token/provider.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Token/symbol.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Wallet/icon.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/Wallet/name.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/BuyDirectListingButton.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/ClaimButton.test.tsx +1 -0
- package/src/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/CreateDirectListingButton.test.tsx +1 -0
- package/src/react/web/ui/x402/PaymentErrorModal.tsx +9 -4
- package/src/react/web/utils/canFitWideModal.test.tsx +1 -0
- package/src/react/web/wallets/in-app/CountrySelector.test.tsx +1 -0
- package/src/react/web/wallets/in-app/InputSelectionUI.test.tsx +1 -0
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.test.tsx +1 -0
- package/src/version.ts +1 -1
- package/src/wallets/in-app/web/lib/auth/redirect-state.test.tsx +1 -0
- package/src/wallets/in-app/web/lib/get-url-token.test.tsx +1 -0
- package/src/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.test.tsx +1 -0
- package/src/x402/encode.ts +46 -2
- package/src/x402/fetchWithPayment.test.ts +1173 -104
- package/src/x402/fetchWithPayment.ts +72 -54
- package/src/x402/schemas.test.ts +123 -0
- package/src/x402/schemas.ts +199 -6
- package/src/x402/sign.ts +86 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
1
2
|
import { describe, expect, it, vi } from "vitest";
|
|
2
3
|
import { act, renderHook } from "~test/react-render.js";
|
|
3
4
|
import { useShowMore } from "./useShowMore.js";
|
|
@@ -16,10 +17,15 @@ describe("useShowMore", () => {
|
|
|
16
17
|
const observerCallback = vi.fn();
|
|
17
18
|
|
|
18
19
|
const observer = new IntersectionObserver(observerCallback);
|
|
19
|
-
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
21
|
+
class {
|
|
22
|
+
constructor(callback: IntersectionObserverCallback) {
|
|
23
|
+
observerCallback.mockImplementation(callback);
|
|
24
|
+
// biome-ignore lint/correctness/noConstructorReturn: test mock
|
|
25
|
+
return observer;
|
|
26
|
+
}
|
|
27
|
+
} as unknown as typeof IntersectionObserver,
|
|
28
|
+
);
|
|
23
29
|
|
|
24
30
|
act(() => {
|
|
25
31
|
result.current.lastItemRef(lastItem);
|
|
@@ -38,10 +44,15 @@ describe("useShowMore", () => {
|
|
|
38
44
|
const observerCallback = vi.fn();
|
|
39
45
|
|
|
40
46
|
const observer = new IntersectionObserver(observerCallback);
|
|
41
|
-
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
48
|
+
class {
|
|
49
|
+
constructor(callback: IntersectionObserverCallback) {
|
|
50
|
+
observerCallback.mockImplementation(callback);
|
|
51
|
+
// biome-ignore lint/correctness/noConstructorReturn: test mock
|
|
52
|
+
return observer;
|
|
53
|
+
}
|
|
54
|
+
} as unknown as typeof IntersectionObserver,
|
|
55
|
+
);
|
|
45
56
|
|
|
46
57
|
act(() => {
|
|
47
58
|
result.current.lastItemRef(lastItem);
|
|
@@ -60,10 +71,15 @@ describe("useShowMore", () => {
|
|
|
60
71
|
const observerCallback = vi.fn();
|
|
61
72
|
|
|
62
73
|
const observer = new IntersectionObserver(observerCallback);
|
|
63
|
-
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
vi.spyOn(window, "IntersectionObserver").mockImplementation(
|
|
75
|
+
class {
|
|
76
|
+
constructor(callback: IntersectionObserverCallback) {
|
|
77
|
+
observerCallback.mockImplementation(callback);
|
|
78
|
+
// biome-ignore lint/correctness/noConstructorReturn: test mock
|
|
79
|
+
return observer;
|
|
80
|
+
}
|
|
81
|
+
} as unknown as typeof IntersectionObserver,
|
|
82
|
+
);
|
|
67
83
|
|
|
68
84
|
act(() => {
|
|
69
85
|
result.current.lastItemRef(lastItem);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
1
2
|
/** biome-ignore-all lint/nursery/useUniqueElementIds: "id" is not a html attribute here - TODO: stop using 'id' as a prop on JSX elements */
|
|
2
3
|
import { describe, expect, it } from "vitest";
|
|
3
4
|
import { render, waitFor } from "~test/react-render.js";
|
|
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
|
5
5
|
import {
|
|
6
6
|
extractEvmChainId,
|
|
7
7
|
networkToCaip2ChainId,
|
|
8
|
+
parsePaymentRequirementsForDisplay,
|
|
8
9
|
type RequestedPaymentRequirements,
|
|
9
10
|
} from "../../../../x402/schemas.js";
|
|
10
11
|
import type { PaymentRequiredResult } from "../../../../x402/types.js";
|
|
@@ -25,6 +26,7 @@ import { Text } from "../components/text.js";
|
|
|
25
26
|
type PaymentErrorModalProps = {
|
|
26
27
|
client: ThirdwebClient;
|
|
27
28
|
errorData: PaymentRequiredResult["responseBody"];
|
|
29
|
+
requestUrl?: string;
|
|
28
30
|
onRetry: () => void;
|
|
29
31
|
onCancel: () => void;
|
|
30
32
|
theme: Theme | "light" | "dark";
|
|
@@ -54,6 +56,7 @@ export function PaymentErrorModal(props: PaymentErrorModalProps) {
|
|
|
54
56
|
const {
|
|
55
57
|
client,
|
|
56
58
|
errorData,
|
|
59
|
+
requestUrl,
|
|
57
60
|
onRetry,
|
|
58
61
|
onCancel,
|
|
59
62
|
theme,
|
|
@@ -66,13 +69,15 @@ export function PaymentErrorModal(props: PaymentErrorModalProps) {
|
|
|
66
69
|
|
|
67
70
|
// Extract chain and token info from errorData for BuyWidget
|
|
68
71
|
const getBuyWidgetConfig = () => {
|
|
69
|
-
|
|
72
|
+
// Get payment requirements from errorData
|
|
73
|
+
const parsedPaymentRequirements = parsePaymentRequirementsForDisplay(
|
|
74
|
+
errorData,
|
|
75
|
+
requestUrl,
|
|
76
|
+
);
|
|
77
|
+
if (parsedPaymentRequirements.length === 0) {
|
|
70
78
|
return null;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
// Get payment requirements from errorData
|
|
74
|
-
const parsedPaymentRequirements = errorData.accepts;
|
|
75
|
-
|
|
76
81
|
// Get the current chain from wallet
|
|
77
82
|
const currentChain = wallet?.getChain();
|
|
78
83
|
const currentChainId = currentChain?.id;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.121.
|
|
1
|
+
export const version = "5.121.4";
|
package/src/x402/encode.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ExactEvmPayload } from "x402/types";
|
|
2
|
+
import { cachedTextDecoder } from "../utils/text-decoder.js";
|
|
3
|
+
import { cachedTextEncoder } from "../utils/text-encoder.js";
|
|
2
4
|
import type {
|
|
3
5
|
RequestedPaymentPayload,
|
|
4
6
|
RequestedPaymentRequirements,
|
|
@@ -27,7 +29,7 @@ export function encodePayment(payment: RequestedPaymentPayload): string {
|
|
|
27
29
|
) as ExactEvmPayload["authorization"],
|
|
28
30
|
},
|
|
29
31
|
};
|
|
30
|
-
return
|
|
32
|
+
return base64EncodeUtf8(JSON.stringify(safe));
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -37,7 +39,7 @@ export function encodePayment(payment: RequestedPaymentPayload): string {
|
|
|
37
39
|
* @returns The decoded and validated PaymentPayload object
|
|
38
40
|
*/
|
|
39
41
|
export function decodePayment(payment: string): RequestedPaymentPayload {
|
|
40
|
-
const decoded =
|
|
42
|
+
const decoded = base64DecodeUtf8(payment);
|
|
41
43
|
const parsed = JSON.parse(decoded);
|
|
42
44
|
|
|
43
45
|
const obj: RequestedPaymentPayload = {
|
|
@@ -93,3 +95,45 @@ export function safeBase64Decode(data: string): string {
|
|
|
93
95
|
}
|
|
94
96
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Encodes a string as UTF-8 and then to base64
|
|
101
|
+
*
|
|
102
|
+
* @param data - The string to encode
|
|
103
|
+
* @returns The base64 encoded UTF-8 bytes
|
|
104
|
+
*/
|
|
105
|
+
function base64EncodeUtf8(data: string): string {
|
|
106
|
+
if (
|
|
107
|
+
typeof globalThis !== "undefined" &&
|
|
108
|
+
typeof globalThis.btoa === "function"
|
|
109
|
+
) {
|
|
110
|
+
const bytes = cachedTextEncoder().encode(data);
|
|
111
|
+
let binary = "";
|
|
112
|
+
for (const byte of bytes) {
|
|
113
|
+
binary += String.fromCharCode(byte);
|
|
114
|
+
}
|
|
115
|
+
return globalThis.btoa(binary);
|
|
116
|
+
}
|
|
117
|
+
return Buffer.from(data, "utf-8").toString("base64");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Decodes a base64 string and interprets the bytes as UTF-8
|
|
122
|
+
*
|
|
123
|
+
* @param data - The base64 encoded string
|
|
124
|
+
* @returns The decoded string
|
|
125
|
+
*/
|
|
126
|
+
export function base64DecodeUtf8(data: string): string {
|
|
127
|
+
if (
|
|
128
|
+
typeof globalThis !== "undefined" &&
|
|
129
|
+
typeof globalThis.atob === "function"
|
|
130
|
+
) {
|
|
131
|
+
const binary = globalThis.atob(data);
|
|
132
|
+
const bytes = new Uint8Array(binary.length);
|
|
133
|
+
for (let i = 0; i < binary.length; i++) {
|
|
134
|
+
bytes[i] = binary.charCodeAt(i);
|
|
135
|
+
}
|
|
136
|
+
return cachedTextDecoder().decode(bytes);
|
|
137
|
+
}
|
|
138
|
+
return Buffer.from(data, "base64").toString("utf-8");
|
|
139
|
+
}
|