thirdweb 5.115.3 → 5.115.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 (40) hide show
  1. package/dist/cjs/utils/base64/base64.js +4 -2
  2. package/dist/cjs/utils/base64/base64.js.map +1 -1
  3. package/dist/cjs/utils/contract/fetchContractMetadata.js +10 -0
  4. package/dist/cjs/utils/contract/fetchContractMetadata.js.map +1 -1
  5. package/dist/cjs/utils/nft/fetchTokenMetadata.js +10 -0
  6. package/dist/cjs/utils/nft/fetchTokenMetadata.js.map +1 -1
  7. package/dist/cjs/utils/utf8/utf8.js +43 -0
  8. package/dist/cjs/utils/utf8/utf8.js.map +1 -0
  9. package/dist/cjs/version.js +1 -1
  10. package/dist/cjs/wallets/utils/getWalletBalance.js +6 -1
  11. package/dist/cjs/wallets/utils/getWalletBalance.js.map +1 -1
  12. package/dist/esm/utils/base64/base64.js +4 -2
  13. package/dist/esm/utils/base64/base64.js.map +1 -1
  14. package/dist/esm/utils/contract/fetchContractMetadata.js +10 -0
  15. package/dist/esm/utils/contract/fetchContractMetadata.js.map +1 -1
  16. package/dist/esm/utils/nft/fetchTokenMetadata.js +10 -0
  17. package/dist/esm/utils/nft/fetchTokenMetadata.js.map +1 -1
  18. package/dist/esm/utils/utf8/utf8.js +39 -0
  19. package/dist/esm/utils/utf8/utf8.js.map +1 -0
  20. package/dist/esm/version.js +1 -1
  21. package/dist/esm/wallets/utils/getWalletBalance.js +6 -1
  22. package/dist/esm/wallets/utils/getWalletBalance.js.map +1 -1
  23. package/dist/scripts/bridge-widget.js +67 -67
  24. package/dist/types/utils/base64/base64.d.ts +2 -2
  25. package/dist/types/utils/base64/base64.d.ts.map +1 -1
  26. package/dist/types/utils/contract/fetchContractMetadata.d.ts.map +1 -1
  27. package/dist/types/utils/nft/fetchTokenMetadata.d.ts.map +1 -1
  28. package/dist/types/utils/utf8/utf8.d.ts +26 -0
  29. package/dist/types/utils/utf8/utf8.d.ts.map +1 -0
  30. package/dist/types/version.d.ts +1 -1
  31. package/dist/types/wallets/utils/getWalletBalance.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/utils/base64/base64.ts +5 -4
  34. package/src/utils/contract/fetchContractMetadata.ts +13 -0
  35. package/src/utils/nft/fetch-token-metadata.test.ts +38 -0
  36. package/src/utils/nft/fetchTokenMetadata.ts +13 -0
  37. package/src/utils/utf8/utf8.test.ts +93 -0
  38. package/src/utils/utf8/utf8.ts +40 -0
  39. package/src/version.ts +1 -1
  40. package/src/wallets/utils/getWalletBalance.ts +9 -1
@@ -1,5 +1,5 @@
1
- type Base64Prefix = "data:application/json;base64";
2
- type Base64String = `${Base64Prefix},${string}`;
1
+ declare const Base64Prefix: "data:application/json;base64";
2
+ type Base64String = `${typeof Base64Prefix},${string}`;
3
3
  /**
4
4
  * Checks if a given string is a base64 encoded JSON string.
5
5
  * @param input - The string to be checked.
@@ -1 +1 @@
1
- {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/utils/base64/base64.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,8BAA8B,CAAC;AACnD,KAAK,YAAY,GAAG,GAAG,YAAY,IAAI,MAAM,EAAE,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAKjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,UAGpD"}
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/utils/base64/base64.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY,EAAG,8BAAuC,CAAC;AAC7D,KAAK,YAAY,GAAG,GAAG,OAAO,YAAY,IAAI,MAAM,EAAE,CAAC;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAKjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,UAIpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchContractMetadata.d.ts","sourceRoot":"","sources":["../../../../src/utils/contract/fetchContractMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAqBjD"}
1
+ {"version":3,"file":"fetchContractMetadata.d.ts","sourceRoot":"","sources":["../../../../src/utils/contract/fetchContractMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAiCjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchTokenMetadata.d.ts","sourceRoot":"","sources":["../../../../src/utils/nft/fetchTokenMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CAuDtB"}
1
+ {"version":3,"file":"fetchTokenMetadata.d.ts","sourceRoot":"","sources":["../../../../src/utils/nft/fetchTokenMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CAmEtB"}
@@ -0,0 +1,26 @@
1
+ declare const UTF8Prefix: "data:application/json;utf-8";
2
+ type UTF8String = `${typeof UTF8Prefix},${string}`;
3
+ /**
4
+ * Checks if a given string is a UTF-8 encoded JSON string.
5
+ * @param input - The string to be checked.
6
+ * @returns True if the input string starts with "data:application/json;utf-8", false otherwise.
7
+ * @example
8
+ * ```ts
9
+ * isUTF8JSONString("data:application/json;utf-8,{ \"test\": \"utf8\" }")
10
+ * // true
11
+ * ```
12
+ */
13
+ export declare function isUTF8JSONString(input: string): input is UTF8String;
14
+ /**
15
+ * Parses a UTF-8 string and returns the decoded string.
16
+ * @param input - The UTF-8 string to parse.
17
+ * @returns The decoded string.
18
+ * @example
19
+ * ```ts
20
+ * parseUTF8String("data:application/json;utf-8,{ \"test\": \"utf8\" }")
21
+ * // '{"test":"utf8"}'
22
+ * ```
23
+ */
24
+ export declare function parseUTF8String(input: UTF8String): string;
25
+ export {};
26
+ //# sourceMappingURL=utf8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../../../src/utils/utf8/utf8.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,EAAG,6BAAsC,CAAC;AAC1D,KAAK,UAAU,GAAG,GAAG,OAAO,UAAU,IAAI,MAAM,EAAE,CAAC;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAKnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,UAShD"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.115.3";
1
+ export declare const version = "5.115.4";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWalletBalance.d.ts","sourceRoot":"","sources":["../../../../src/wallets/utils/getWalletBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAMlF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAoC3B"}
1
+ {"version":3,"file":"getWalletBalance.d.ts","sourceRoot":"","sources":["../../../../src/wallets/utils/getWalletBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAMlF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CA4C3B"}
package/package.json CHANGED
@@ -399,7 +399,7 @@
399
399
  }
400
400
  },
401
401
  "typings": "./dist/types/exports/thirdweb.d.ts",
402
- "version": "5.115.3",
402
+ "version": "5.115.4",
403
403
  "scripts": {
404
404
  "bench": "vitest -c ./test/vitest.config.ts bench",
405
405
  "bench:compare": "bun run ./benchmarks/run.ts",
@@ -1,7 +1,7 @@
1
1
  import { base64ToString } from "../uint8-array.js";
2
2
 
3
- type Base64Prefix = "data:application/json;base64";
4
- type Base64String = `${Base64Prefix},${string}`;
3
+ const Base64Prefix = "data:application/json;base64" as const;
4
+ type Base64String = `${typeof Base64Prefix},${string}`;
5
5
 
6
6
  /**
7
7
  * Checks if a given string is a base64 encoded JSON string.
@@ -14,7 +14,7 @@ type Base64String = `${Base64Prefix},${string}`;
14
14
  * ```
15
15
  */
16
16
  export function isBase64JSON(input: string): input is Base64String {
17
- if (input.startsWith("data:application/json;base64")) {
17
+ if (input.toLowerCase().startsWith(Base64Prefix)) {
18
18
  return true;
19
19
  }
20
20
  return false;
@@ -31,6 +31,7 @@ export function isBase64JSON(input: string): input is Base64String {
31
31
  * ```
32
32
  */
33
33
  export function parseBase64String(input: Base64String) {
34
- const [, base64] = input.split(",") as [Base64Prefix, string];
34
+ const commaIndex = input.indexOf(",");
35
+ const base64 = input.slice(commaIndex + 1);
35
36
  return base64ToString(base64);
36
37
  }
@@ -1,5 +1,6 @@
1
1
  import type { ThirdwebClient } from "../../client/client.js";
2
2
  import { isBase64JSON, parseBase64String } from "../base64/base64.js";
3
+ import { isUTF8JSONString, parseUTF8String } from "../utf8/utf8.js";
3
4
 
4
5
  /**
5
6
  * @internal
@@ -34,6 +35,18 @@ export async function fetchContractMetadata(
34
35
  return undefined;
35
36
  }
36
37
  }
38
+ if (isUTF8JSONString(uri)) {
39
+ try {
40
+ return JSON.parse(parseUTF8String(uri));
41
+ } catch (e) {
42
+ console.error(
43
+ "Failed to fetch utf8 encoded contract metadata",
44
+ { uri },
45
+ e,
46
+ );
47
+ return undefined;
48
+ }
49
+ }
37
50
 
38
51
  // in all other cases we will need the `download` function from storage
39
52
 
@@ -34,4 +34,42 @@ describe("fetchTokenMetadata", () => {
34
34
  };
35
35
  await expect(fetchTokenMetadata(options)).rejects.toThrowError();
36
36
  });
37
+
38
+ it("should return a json object from a valid UTF-8 encoded json", async () => {
39
+ const validJson = { name: "NFT Name", description: "NFT Description" };
40
+ const validUtf8Json = `data:application/json;utf-8,${stringify(validJson)}`;
41
+
42
+ const options: FetchTokenMetadataOptions = {
43
+ client: TEST_CLIENT,
44
+ tokenId: 1n,
45
+ tokenUri: validUtf8Json,
46
+ };
47
+ const result = await fetchTokenMetadata(options);
48
+ expect(result).toEqual(validJson);
49
+ });
50
+
51
+ it("should return a json object from UTF-8 encoded json with unicode characters", async () => {
52
+ const validJson = { name: "🎉 NFT", emoji: "🚀", text: "Hello World" };
53
+ const validUtf8Json = `data:application/json;utf-8,${stringify(validJson)}`;
54
+
55
+ const options: FetchTokenMetadataOptions = {
56
+ client: TEST_CLIENT,
57
+ tokenId: 2n,
58
+ tokenUri: validUtf8Json,
59
+ };
60
+ const result = await fetchTokenMetadata(options);
61
+ expect(result).toEqual(validJson);
62
+ });
63
+
64
+ it("should throw an error for INVALID UTF-8 encoded json", async () => {
65
+ // Malformed JSON: { "foo": "bar" (missing closing brace)
66
+ const invalidUtf8Json = 'data:application/json;utf-8,{"foo": "bar"';
67
+
68
+ const options: FetchTokenMetadataOptions = {
69
+ client: TEST_CLIENT,
70
+ tokenId: 3n,
71
+ tokenUri: invalidUtf8Json,
72
+ };
73
+ await expect(fetchTokenMetadata(options)).rejects.toThrowError();
74
+ });
37
75
  });
@@ -1,6 +1,7 @@
1
1
  import type { ThirdwebClient } from "../../client/client.js";
2
2
  import { isBase64JSON, parseBase64String } from "../base64/base64.js";
3
3
  import { numberToHex } from "../encoding/hex.js";
4
+ import { isUTF8JSONString, parseUTF8String } from "../utf8/utf8.js";
4
5
  import type { NFTMetadata } from "./parseNft.js";
5
6
 
6
7
  /**
@@ -37,6 +38,18 @@ export async function fetchTokenMetadata(
37
38
  }
38
39
  }
39
40
 
41
+ if (isUTF8JSONString(tokenUri)) {
42
+ try {
43
+ return JSON.parse(parseUTF8String(tokenUri));
44
+ } catch (e) {
45
+ console.error(
46
+ "Failed to fetch utf8 encoded NFT",
47
+ { tokenId, tokenUri },
48
+ e,
49
+ );
50
+ throw e;
51
+ }
52
+ }
40
53
  // in all other cases we will need the `download` function from storage
41
54
  const { download } = await import("../../storage/download.js");
42
55
 
@@ -0,0 +1,93 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { isUTF8JSONString, parseUTF8String } from "./utf8.js";
3
+
4
+ describe("isUTF8JSONString", () => {
5
+ it("should return true for valid UTF-8 JSON string", () => {
6
+ const input = 'data:application/json;utf-8,{"test":"value"}';
7
+ const result = isUTF8JSONString(input);
8
+ expect(result).toBe(true);
9
+ });
10
+
11
+ it("should return true for UTF-8 JSON string with special text", () => {
12
+ const input = 'data:application/json;utf-8,{"text":"Hello World!"}';
13
+ const result = isUTF8JSONString(input);
14
+ expect(result).toBe(true);
15
+ });
16
+
17
+ it("should return false for plain string without prefix", () => {
18
+ const input = "Hello world";
19
+ const result = isUTF8JSONString(input);
20
+ expect(result).toBe(false);
21
+ });
22
+
23
+ it("should return false for base64 JSON string", () => {
24
+ const input = "data:application/json;base64,eyJ0ZXN0IjoidmFsdWUifQ==";
25
+ const result = isUTF8JSONString(input);
26
+ expect(result).toBe(false);
27
+ });
28
+
29
+ it("should return false for different data type with utf-8", () => {
30
+ const input = "data:text/plain;utf-8,Hello world";
31
+ const result = isUTF8JSONString(input);
32
+ expect(result).toBe(false);
33
+ });
34
+
35
+ it("should return false for empty string", () => {
36
+ const input = "";
37
+ const result = isUTF8JSONString(input);
38
+ expect(result).toBe(false);
39
+ });
40
+
41
+ it("should return false for string with similar but wrong prefix", () => {
42
+ const input = "data:application/json;utf8,{}";
43
+ const result = isUTF8JSONString(input);
44
+ expect(result).toBe(false);
45
+ });
46
+ });
47
+
48
+ describe("parseUTF8String", () => {
49
+ it("should parse UTF-8 string and return the JSON portion", () => {
50
+ const input = 'data:application/json;utf-8,{"test":"value"}';
51
+ const result = parseUTF8String(input);
52
+ expect(result).toBe('{"test":"value"}');
53
+ });
54
+
55
+ it("should parse UTF-8 string with URL-encoded unicode characters", () => {
56
+ const input =
57
+ "data:application/json;utf-8,%7B%22name%22%3A%22test%22%2C%22value%22%3A123%7D";
58
+ const result = parseUTF8String(input);
59
+ expect(result).toBe('{"name":"test","value":123}');
60
+ });
61
+
62
+ it("should parse UTF-8 string with special characters", () => {
63
+ const input =
64
+ 'data:application/json;utf-8,{"text":"Hello, World!","special":"@#$%"}';
65
+ const result = parseUTF8String(input);
66
+ expect(result).toBe('{"text":"Hello, World!","special":"@#$%"}');
67
+ });
68
+
69
+ it("should parse UTF-8 string with nested JSON", () => {
70
+ const input =
71
+ 'data:application/json;utf-8,{"outer":{"inner":"value"},"array":[1,2,3]}';
72
+ const result = parseUTF8String(input);
73
+ expect(result).toBe('{"outer":{"inner":"value"},"array":[1,2,3]}');
74
+ });
75
+
76
+ it("should parse UTF-8 string with empty JSON object", () => {
77
+ const input = "data:application/json;utf-8,{}";
78
+ const result = parseUTF8String(input);
79
+ expect(result).toBe("{}");
80
+ });
81
+
82
+ it("should parse UTF-8 string with commas in the JSON value", () => {
83
+ const input = 'data:application/json;utf-8,{"list":"a,b,c"}';
84
+ const result = parseUTF8String(input);
85
+ expect(result).toBe('{"list":"a,b,c"}');
86
+ });
87
+
88
+ it("should handle URL-encoded characters", () => {
89
+ const input = 'data:application/json;utf-8,{"url":"https://example.com"}';
90
+ const result = parseUTF8String(input);
91
+ expect(result).toBe('{"url":"https://example.com"}');
92
+ });
93
+ });
@@ -0,0 +1,40 @@
1
+ const UTF8Prefix = "data:application/json;utf-8" as const;
2
+ type UTF8String = `${typeof UTF8Prefix},${string}`;
3
+
4
+ /**
5
+ * Checks if a given string is a UTF-8 encoded JSON string.
6
+ * @param input - The string to be checked.
7
+ * @returns True if the input string starts with "data:application/json;utf-8", false otherwise.
8
+ * @example
9
+ * ```ts
10
+ * isUTF8JSONString("data:application/json;utf-8,{ \"test\": \"utf8\" }")
11
+ * // true
12
+ * ```
13
+ */
14
+ export function isUTF8JSONString(input: string): input is UTF8String {
15
+ if (input.toLowerCase().startsWith(UTF8Prefix)) {
16
+ return true;
17
+ }
18
+ return false;
19
+ }
20
+
21
+ /**
22
+ * Parses a UTF-8 string and returns the decoded string.
23
+ * @param input - The UTF-8 string to parse.
24
+ * @returns The decoded string.
25
+ * @example
26
+ * ```ts
27
+ * parseUTF8String("data:application/json;utf-8,{ \"test\": \"utf8\" }")
28
+ * // '{"test":"utf8"}'
29
+ * ```
30
+ */
31
+ export function parseUTF8String(input: UTF8String) {
32
+ const commaIndex = input.indexOf(",");
33
+ const utf8 = input.slice(commaIndex + 1);
34
+ try {
35
+ // try to decode the UTF-8 string, if it fails, return the original string
36
+ return decodeURIComponent(utf8);
37
+ } catch {
38
+ return utf8;
39
+ }
40
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.115.3";
1
+ export const version = "5.115.4";
@@ -43,7 +43,15 @@ export type GetWalletBalanceResult = GetBalanceResult;
43
43
  export async function getWalletBalance(
44
44
  options: GetWalletBalanceOptions,
45
45
  ): Promise<GetBalanceResult> {
46
- const { address, client, chain, tokenAddress } = options;
46
+ const { address, client, chain } = options;
47
+
48
+ // Scipper chain (42429) uses a wrapped native token for balance queries
49
+ const tokenAddress =
50
+ options.tokenAddress ||
51
+ (chain.id === 42429
52
+ ? "0x20c0000000000000000000000000000000000000"
53
+ : undefined);
54
+
47
55
  // erc20 case
48
56
  if (
49
57
  tokenAddress &&