thirdweb 5.121.1 → 5.121.3
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/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/Bridge/common/token-query.js +4 -1
- package/dist/cjs/react/web/ui/Bridge/common/token-query.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/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/Bridge/common/token-query.js +4 -1
- package/dist/esm/react/web/ui/Bridge/common/token-query.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 +3 -3
- 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/Bridge/common/token-query.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 +3 -3
- 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/react/core/hooks/x402/useFetchWithPaymentCore.ts +6 -1
- package/src/react/native/hooks/x402/useFetchWithPayment.ts +1 -1
- package/src/react/web/hooks/x402/useFetchWithPayment.tsx +3 -1
- package/src/react/web/ui/Bridge/common/token-query.test.tsx +117 -0
- package/src/react/web/ui/Bridge/common/token-query.ts +4 -1
- package/src/react/web/ui/x402/PaymentErrorModal.tsx +9 -4
- package/src/version.ts +1 -1
- 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
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.121.
|
|
1
|
+
export const version = "5.121.3";
|
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
|
+
}
|