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.
Files changed (139) hide show
  1. package/dist/cjs/insight/get-nfts.js +2 -2
  2. package/dist/cjs/insight/get-nfts.js.map +1 -1
  3. package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js +1 -0
  4. package/dist/cjs/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -1
  5. package/dist/cjs/react/native/hooks/x402/useFetchWithPayment.js +1 -1
  6. package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js +2 -2
  7. package/dist/cjs/react/web/hooks/x402/useFetchWithPayment.js.map +1 -1
  8. package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js +4 -4
  9. package/dist/cjs/react/web/ui/x402/PaymentErrorModal.js.map +1 -1
  10. package/dist/cjs/version.js +1 -1
  11. package/dist/cjs/x402/encode.js +41 -2
  12. package/dist/cjs/x402/encode.js.map +1 -1
  13. package/dist/cjs/x402/fetchWithPayment.js +56 -33
  14. package/dist/cjs/x402/fetchWithPayment.js.map +1 -1
  15. package/dist/cjs/x402/schemas.js +134 -2
  16. package/dist/cjs/x402/schemas.js.map +1 -1
  17. package/dist/cjs/x402/sign.js +56 -15
  18. package/dist/cjs/x402/sign.js.map +1 -1
  19. package/dist/esm/insight/get-nfts.js +2 -2
  20. package/dist/esm/insight/get-nfts.js.map +1 -1
  21. package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js +2 -1
  22. package/dist/esm/react/core/hooks/x402/useFetchWithPaymentCore.js.map +1 -1
  23. package/dist/esm/react/native/hooks/x402/useFetchWithPayment.js +1 -1
  24. package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js +2 -2
  25. package/dist/esm/react/web/hooks/x402/useFetchWithPayment.js.map +1 -1
  26. package/dist/esm/react/web/ui/x402/PaymentErrorModal.js +5 -5
  27. package/dist/esm/react/web/ui/x402/PaymentErrorModal.js.map +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/dist/esm/x402/encode.js +40 -2
  30. package/dist/esm/x402/encode.js.map +1 -1
  31. package/dist/esm/x402/fetchWithPayment.js +57 -35
  32. package/dist/esm/x402/fetchWithPayment.js.map +1 -1
  33. package/dist/esm/x402/schemas.js +129 -1
  34. package/dist/esm/x402/schemas.js.map +1 -1
  35. package/dist/esm/x402/sign.js +57 -16
  36. package/dist/esm/x402/sign.js.map +1 -1
  37. package/dist/scripts/bridge-widget.js +64 -64
  38. package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts +1 -0
  39. package/dist/types/react/core/hooks/x402/useFetchWithPaymentCore.d.ts.map +1 -1
  40. package/dist/types/react/native/hooks/x402/useFetchWithPayment.d.ts +1 -1
  41. package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts +1 -1
  42. package/dist/types/react/web/hooks/x402/useFetchWithPayment.d.ts.map +1 -1
  43. package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts +1 -0
  44. package/dist/types/react/web/ui/x402/PaymentErrorModal.d.ts.map +1 -1
  45. package/dist/types/version.d.ts +1 -1
  46. package/dist/types/x402/encode.d.ts +7 -0
  47. package/dist/types/x402/encode.d.ts.map +1 -1
  48. package/dist/types/x402/fetchWithPayment.d.ts +10 -1
  49. package/dist/types/x402/fetchWithPayment.d.ts.map +1 -1
  50. package/dist/types/x402/schemas.d.ts +60 -2
  51. package/dist/types/x402/schemas.d.ts.map +1 -1
  52. package/dist/types/x402/sign.d.ts +13 -1
  53. package/dist/types/x402/sign.d.ts.map +1 -1
  54. package/package.json +17 -16
  55. package/src/contract/actions/resolve-abi.test.ts +3 -5
  56. package/src/extensions/airdrop/write/airdropERC721WithSignature.test.ts +4 -5
  57. package/src/extensions/erc1155/drop1155.test.ts +1 -1
  58. package/src/extensions/erc1155/write/sigMint1155.test.ts +189 -187
  59. package/src/extensions/erc20/drop20.test.ts +1 -1
  60. package/src/extensions/erc721/write/sigMint721.test.ts +4 -6
  61. package/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts +180 -178
  62. package/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts +1 -1
  63. package/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts +1 -1
  64. package/src/extensions/prebuilts/process-ref-deployments.test.ts +1 -1
  65. package/src/insight/get-nfts.ts +2 -2
  66. package/src/react/core/account/provider.test.tsx +1 -0
  67. package/src/react/core/hooks/others/useWalletBalance.test.tsx +1 -0
  68. package/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.test.tsx +1 -0
  69. package/src/react/core/hooks/useStepExecutor.test.tsx +1 -0
  70. package/src/react/core/hooks/wallets/useAddConnectedWallet.test.tsx +1 -0
  71. package/src/react/core/hooks/wallets/useAutoConnectCore.test.tsx +1 -0
  72. package/src/react/core/hooks/wallets/useConnect.test.tsx +1 -0
  73. package/src/react/core/hooks/wallets/useSetActiveWallet.test.tsx +1 -0
  74. package/src/react/core/hooks/wallets/useSwitchActiveWalletChain.test.tsx +1 -0
  75. package/src/react/core/hooks/x402/useFetchWithPaymentCore.ts +6 -1
  76. package/src/react/core/providers/connection-manager.test.tsx +1 -0
  77. package/src/react/core/wallet/provider.test.tsx +1 -0
  78. package/src/react/native/hooks/wallets/useUnlinkProfile.test.tsx +1 -0
  79. package/src/react/native/hooks/x402/useFetchWithPayment.ts +1 -1
  80. package/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx +1 -0
  81. package/src/react/web/hooks/x402/useFetchWithPayment.tsx +3 -1
  82. package/src/react/web/ui/AutoConnect/AutoConnect.test.tsx +1 -0
  83. package/src/react/web/ui/Bridge/StepRunner.test.tsx +1 -0
  84. package/src/react/web/ui/Bridge/common/token-query.test.tsx +1 -0
  85. package/src/react/web/ui/ConnectWallet/ConnectButton.test.tsx +1 -0
  86. package/src/react/web/ui/ConnectWallet/Details.test.tsx +1 -0
  87. package/src/react/web/ui/ConnectWallet/NetworkSelector.test.tsx +1 -0
  88. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.test.tsx +1 -0
  89. package/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.test.tsx +1 -0
  90. package/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.test.tsx +1 -0
  91. package/src/react/web/ui/ConnectWallet/screens/PrivateKey.test.tsx +1 -0
  92. package/src/react/web/ui/ConnectWallet/screens/ReceiveFunds.test.tsx +1 -0
  93. package/src/react/web/ui/ConnectWallet/screens/SendFunds.test.tsx +1 -0
  94. package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.test.tsx +1 -0
  95. package/src/react/web/ui/ConnectWallet/screens/StartScreen.test.tsx +1 -0
  96. package/src/react/web/ui/MediaRenderer/MediaRenderer.test.tsx +1 -0
  97. package/src/react/web/ui/MediaRenderer/icons.test.tsx +1 -0
  98. package/src/react/web/ui/MediaRenderer/useResolvedMediaType.test.tsx +1 -0
  99. package/src/react/web/ui/SiteEmbed.test.tsx +1 -0
  100. package/src/react/web/ui/SiteLink.test.tsx +1 -0
  101. package/src/react/web/ui/TransactionButton/TransactionButton.test.tsx +1 -0
  102. package/src/react/web/ui/components/ChainIcon.test.tsx +1 -0
  103. package/src/react/web/ui/hooks/useCopyClipboard.test.tsx +1 -0
  104. package/src/react/web/ui/hooks/useDebouncedValue.test.tsx +1 -0
  105. package/src/react/web/ui/hooks/useShowMore.test.tsx +28 -12
  106. package/src/react/web/ui/prebuilt/Account/address.test.tsx +1 -0
  107. package/src/react/web/ui/prebuilt/Account/avatar.test.tsx +1 -0
  108. package/src/react/web/ui/prebuilt/Account/balance.test.tsx +1 -0
  109. package/src/react/web/ui/prebuilt/Account/name.test.tsx +1 -0
  110. package/src/react/web/ui/prebuilt/Chain/icon.test.tsx +1 -0
  111. package/src/react/web/ui/prebuilt/Chain/name.test.tsx +1 -0
  112. package/src/react/web/ui/prebuilt/Chain/provider.test.tsx +1 -0
  113. package/src/react/web/ui/prebuilt/NFT/description.test.tsx +1 -0
  114. package/src/react/web/ui/prebuilt/NFT/media.test.tsx +1 -0
  115. package/src/react/web/ui/prebuilt/NFT/name.test.tsx +1 -0
  116. package/src/react/web/ui/prebuilt/NFT/provider.test.tsx +1 -0
  117. package/src/react/web/ui/prebuilt/Token/name.test.tsx +1 -0
  118. package/src/react/web/ui/prebuilt/Token/provider.test.tsx +1 -0
  119. package/src/react/web/ui/prebuilt/Token/symbol.test.tsx +1 -0
  120. package/src/react/web/ui/prebuilt/Wallet/icon.test.tsx +1 -0
  121. package/src/react/web/ui/prebuilt/Wallet/name.test.tsx +1 -0
  122. package/src/react/web/ui/prebuilt/thirdweb/BuyDirectListingButton/BuyDirectListingButton.test.tsx +1 -0
  123. package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/ClaimButton.test.tsx +1 -0
  124. package/src/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/CreateDirectListingButton.test.tsx +1 -0
  125. package/src/react/web/ui/x402/PaymentErrorModal.tsx +9 -4
  126. package/src/react/web/utils/canFitWideModal.test.tsx +1 -0
  127. package/src/react/web/wallets/in-app/CountrySelector.test.tsx +1 -0
  128. package/src/react/web/wallets/in-app/InputSelectionUI.test.tsx +1 -0
  129. package/src/react/web/wallets/shared/ConnectWalletSocialOptions.test.tsx +1 -0
  130. package/src/version.ts +1 -1
  131. package/src/wallets/in-app/web/lib/auth/redirect-state.test.tsx +1 -0
  132. package/src/wallets/in-app/web/lib/get-url-token.test.tsx +1 -0
  133. package/src/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.test.tsx +1 -0
  134. package/src/x402/encode.ts +46 -2
  135. package/src/x402/fetchWithPayment.test.ts +1173 -104
  136. package/src/x402/fetchWithPayment.ts +72 -54
  137. package/src/x402/schemas.test.ts +123 -0
  138. package/src/x402/schemas.ts +199 -6
  139. package/src/x402/sign.ts +86 -10
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { render, screen } from "../../../../../../test/src/react-render.js";
3
4
  import { TEST_CLIENT } from "../../../../../../test/src/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it, vi } from "vitest";
2
3
  import { render } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { userEvent } from "@testing-library/user-event";
2
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
4
  import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import React from "react";
2
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render } from "~test/react-render.js";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { TEST_CLIENT } from "~test/test-clients.js";
3
4
  import { resolveMediaTypeFromUri } from "./useResolvedMediaType.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, waitFor } from "../../../../test/src/react-render.js";
3
4
  import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, waitFor } from "../../../../test/src/react-render.js";
3
4
  import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import {
2
3
  afterAll,
3
4
  afterEach,
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
3
4
  import { render } from "~test/react-render.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { act, renderHook } from "~test/react-render.js";
3
4
  import { useClipboard } from "./useCopyClipboard.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { act, renderHook } from "~test/react-render.js";
3
4
  import { useDebouncedValue } from "./useDebouncedValue.js";
@@ -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((callback) => {
20
- observerCallback.mockImplementation(callback);
21
- return observer;
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((callback) => {
42
- observerCallback.mockImplementation(callback);
43
- return observer;
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((callback) => {
64
- observerCallback.mockImplementation(callback);
65
- return observer;
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
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2
3
  import { describe, expect, it } from "vitest";
3
4
  import { VITALIK_WALLET } from "~test/addresses.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, waitFor } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import {
3
4
  DOODLES_CONTRACT,
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import {
3
4
  DOODLES_CONTRACT,
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import {
3
4
  DOODLES_CONTRACT,
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { type FC, useContext } from "react";
2
3
  import { describe, expect, it, vi } from "vitest";
3
4
  import { render, renderHook, screen, waitFor } from "~test/react-render.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { ANVIL_CHAIN } from "~test/chains.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen, waitFor } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { ANVIL_CHAIN } from "~test/chains.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -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";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  /** biome-ignore-all lint/nursery/useUniqueElementIds: FIXME: do not use "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";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { ANVIL_CHAIN } from "~test/chains.js";
3
4
  import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { render, screen } from "~test/react-render.js";
3
4
  import { TEST_CLIENT } from "~test/test-clients.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
- if (!errorData.accepts || errorData.accepts.length === 0) {
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;
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it } from "vitest";
2
3
  import { wideModalScreenThreshold } from "../ui/ConnectWallet/constants.js";
3
4
  import { canFitWideModal } from "./canFitWideModal.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it, vi } from "vitest";
2
3
  import {
3
4
  fireEvent,
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it, vi } from "vitest";
2
3
  import { render, screen } from "../../../../../test/src/react-render.js";
3
4
  import { getCountrySelector } from "./CountrySelector.js";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { describe, expect, it, vi } from "vitest";
2
3
  import {
3
4
  fireEvent,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.121.2";
1
+ export const version = "5.121.4";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { beforeEach, describe, expect, it } from "vitest";
2
3
  import { consumeRedirectState, storeRedirectState } from "./redirect-state.js";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { getUrlToken } from "./get-url-token.js";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @vitest-environment happy-dom
1
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
2
3
  import { IframeCommunicator } from "./IframeCommunicator.js";
3
4
 
@@ -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 safeBase64Encode(JSON.stringify(safe));
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 = safeBase64Decode(payment);
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
+ }