thirdweb 5.67.1-nightly-9584885f42ba6d7fec7dd4e1b3d7e0b677cf6afc-20241112000327 → 5.67.1-nightly-040e478ad6cf630dedf666eac7abeb668d323666-20241113000339
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/auth/verify-hash.js +1 -1
- package/dist/cjs/auth/verify-hash.js.map +1 -1
- package/dist/cjs/react/core/utils/walletIcon.js +10 -1
- package/dist/cjs/react/core/utils/walletIcon.js.map +1 -1
- package/dist/cjs/utils/encoding/from-bytes.js +5 -27
- package/dist/cjs/utils/encoding/from-bytes.js.map +1 -1
- package/dist/cjs/utils/encoding/helpers/byte-size.js +2 -2
- package/dist/cjs/utils/encoding/helpers/byte-size.js.map +1 -1
- package/dist/cjs/utils/encoding/helpers/concat-hex.js +2 -1
- package/dist/cjs/utils/encoding/helpers/concat-hex.js.map +1 -1
- package/dist/cjs/utils/encoding/helpers/is-hex.js +2 -9
- package/dist/cjs/utils/encoding/helpers/is-hex.js.map +1 -1
- package/dist/cjs/utils/encoding/hex.js +13 -134
- package/dist/cjs/utils/encoding/hex.js.map +1 -1
- package/dist/cjs/utils/encoding/to-bytes.js +5 -59
- package/dist/cjs/utils/encoding/to-bytes.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/enclave-wallet.js +11 -7
- package/dist/cjs/wallets/in-app/core/wallet/enclave-wallet.js.map +1 -1
- package/dist/esm/auth/verify-hash.js +1 -1
- package/dist/esm/auth/verify-hash.js.map +1 -1
- package/dist/esm/react/core/utils/walletIcon.js +10 -1
- package/dist/esm/react/core/utils/walletIcon.js.map +1 -1
- package/dist/esm/utils/encoding/from-bytes.js +6 -28
- package/dist/esm/utils/encoding/from-bytes.js.map +1 -1
- package/dist/esm/utils/encoding/helpers/byte-size.js +1 -1
- package/dist/esm/utils/encoding/helpers/byte-size.js.map +1 -1
- package/dist/esm/utils/encoding/helpers/concat-hex.js +2 -1
- package/dist/esm/utils/encoding/helpers/concat-hex.js.map +1 -1
- package/dist/esm/utils/encoding/helpers/is-hex.js +2 -9
- package/dist/esm/utils/encoding/helpers/is-hex.js.map +1 -1
- package/dist/esm/utils/encoding/hex.js +13 -134
- package/dist/esm/utils/encoding/hex.js.map +1 -1
- package/dist/esm/utils/encoding/to-bytes.js +5 -58
- package/dist/esm/utils/encoding/to-bytes.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/in-app/core/wallet/enclave-wallet.js +11 -7
- package/dist/esm/wallets/in-app/core/wallet/enclave-wallet.js.map +1 -1
- package/dist/types/react/core/utils/walletIcon.d.ts +11 -1
- package/dist/types/react/core/utils/walletIcon.d.ts.map +1 -1
- package/dist/types/utils/encoding/from-bytes.d.ts +4 -9
- package/dist/types/utils/encoding/from-bytes.d.ts.map +1 -1
- package/dist/types/utils/encoding/helpers/byte-size.d.ts +1 -1
- package/dist/types/utils/encoding/helpers/byte-size.d.ts.map +1 -1
- package/dist/types/utils/encoding/helpers/concat-hex.d.ts +1 -1
- package/dist/types/utils/encoding/helpers/concat-hex.d.ts.map +1 -1
- package/dist/types/utils/encoding/helpers/is-hex.d.ts +3 -5
- package/dist/types/utils/encoding/helpers/is-hex.d.ts.map +1 -1
- package/dist/types/utils/encoding/hex.d.ts +11 -42
- package/dist/types/utils/encoding/hex.d.ts.map +1 -1
- package/dist/types/utils/encoding/to-bytes.d.ts +5 -19
- package/dist/types/utils/encoding/to-bytes.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/in-app/core/wallet/enclave-wallet.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/auth/verify-hash.ts +1 -1
- package/src/extensions/prebuilts/deploy-published.test.ts +0 -36
- package/src/extensions/unstoppable-domains/read/resolveAddress.test.ts +25 -22
- package/src/react/core/utils/walletIcon.ts +11 -2
- package/src/react/web/ui/SiteEmbed.test.tsx +3 -18
- package/src/utils/encoding/from-bytes.ts +8 -38
- package/src/utils/encoding/helpers/byte-size.ts +1 -1
- package/src/utils/encoding/helpers/concat-hex.ts +3 -5
- package/src/utils/encoding/helpers/is-hex.ts +4 -14
- package/src/utils/encoding/hex.ts +23 -214
- package/src/utils/encoding/to-bytes.test.ts +3 -51
- package/src/utils/encoding/to-bytes.ts +10 -82
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/wallet/enclave-wallet.ts +23 -18
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +15 -15
- package/src/wallets/smart/smart-wallet-integration.test.ts +3 -8
- package/dist/cjs/utils/encoding/helpers/assert-size.js +0 -23
- package/dist/cjs/utils/encoding/helpers/assert-size.js.map +0 -1
- package/dist/cjs/utils/encoding/helpers/charcode-to-base-16.js +0 -27
- package/dist/cjs/utils/encoding/helpers/charcode-to-base-16.js.map +0 -1
- package/dist/cjs/utils/encoding/helpers/trim.js +0 -36
- package/dist/cjs/utils/encoding/helpers/trim.js.map +0 -1
- package/dist/esm/utils/encoding/helpers/assert-size.js +0 -20
- package/dist/esm/utils/encoding/helpers/assert-size.js.map +0 -1
- package/dist/esm/utils/encoding/helpers/charcode-to-base-16.js +0 -24
- package/dist/esm/utils/encoding/helpers/charcode-to-base-16.js.map +0 -1
- package/dist/esm/utils/encoding/helpers/trim.js +0 -33
- package/dist/esm/utils/encoding/helpers/trim.js.map +0 -1
- package/dist/types/utils/encoding/helpers/assert-size.d.ts +0 -17
- package/dist/types/utils/encoding/helpers/assert-size.d.ts.map +0 -1
- package/dist/types/utils/encoding/helpers/charcode-to-base-16.d.ts +0 -5
- package/dist/types/utils/encoding/helpers/charcode-to-base-16.d.ts.map +0 -1
- package/dist/types/utils/encoding/helpers/trim.d.ts +0 -16
- package/dist/types/utils/encoding/helpers/trim.d.ts.map +0 -1
- package/src/utils/encoding/helpers/assert-size.test.ts +0 -47
- package/src/utils/encoding/helpers/assert-size.ts +0 -24
- package/src/utils/encoding/helpers/charcode-to-base-16.test.ts +0 -39
- package/src/utils/encoding/helpers/charcode-to-base-16.ts +0 -24
- package/src/utils/encoding/helpers/trim.ts +0 -48
- /package/src/utils/encoding/helpers/{is-hext.test.ts → is-hex.test.ts} +0 -0
@@ -80,7 +80,7 @@ async function verifyHash({ hash, signature, address, client, chain, accountFact
|
|
80
80
|
data: verificationData,
|
81
81
|
});
|
82
82
|
const hexResult = (0, hex_js_1.isHex)(result) ? (0, to_bytes_js_1.toBytes)(result) : result;
|
83
|
-
return (0, utils_1.equalBytes)(hexResult, (0, to_bytes_js_1.toBytes)(
|
83
|
+
return (0, utils_1.equalBytes)(hexResult, (0, to_bytes_js_1.toBytes)(true));
|
84
84
|
}
|
85
85
|
catch {
|
86
86
|
// Some chains do not support the eth_call simulation and will fail, so we fall back to regular EIP1271 validation
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"verify-hash.js","sourceRoot":"","sources":["../../../src/auth/verify-hash.ts"],"names":[],"mappings":";;AA4DA,gCAuEC;AAnID,wDAA0D;AAC1D,+BAMc;AAGd,yDAA6E;AAC7E,uHAAiH;AACjH,4DAAsD;AACtD,0CAA6C;AAC7C,mEAA4D;AAC5D,qDAA2D;AAC3D,+DAAwD;AACxD,uEAA+D;AAC/D,qFAA6E;AAc7E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,UAAU,CAAC,EAC/B,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,cAAc,GACG;IACjB,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE;QACzB,IAAI,IAAA,cAAK,EAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS;YACvE,OAAO,IAAA,yBAAkB,EAAC,SAAS,CAAC,CAAC;QACvC,IAAI,SAAS,YAAY,UAAU;YAAE,OAAO,IAAA,yBAAS,EAAC,SAAS,EAAE,KAAK,CA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oBAAoB,CAAC;AACzC,CAAC"}
|
@@ -33,7 +33,16 @@ exports.socialIcons = {
|
|
33
33
|
twitch: twitchIconUri,
|
34
34
|
github: githubIconUri,
|
35
35
|
};
|
36
|
-
|
36
|
+
/**
|
37
|
+
* Gets the icon URI for a given social authentication provider
|
38
|
+
* @param provider - The authentication provider to get the icon for
|
39
|
+
* @returns A data URI containing the SVG icon for the provider, or a generic wallet icon if the provider is not recognized
|
40
|
+
* @example
|
41
|
+
* ```tsx
|
42
|
+
* const googleIcon = getSocialIcon("google")
|
43
|
+
* const appleIcon = getSocialIcon("apple")
|
44
|
+
* ```
|
45
|
+
*/
|
37
46
|
function getSocialIcon(provider) {
|
38
47
|
switch (provider) {
|
39
48
|
case "google":
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"walletIcon.js","sourceRoot":"","sources":["../../../../../src/react/core/utils/walletIcon.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"walletIcon.js","sourceRoot":"","sources":["../../../../../src/react/core/utils/walletIcon.ts"],"names":[],"mappings":";;;AA8DA,sCAmCC;AA/FD,8CAA8C;AAC9C,MAAM,aAAa,GACjB,ojDAAojD,CAAC;AACvjD,MAAM,eAAe,GACnB,g9BAAg9B,CAAC;AACn9B,MAAM,YAAY,GAChB,w5BAAw5B,CAAC;AAC35B,MAAM,cAAc,GAClB,w1CAAw1C,CAAC;AAC31C,MAAM,eAAe,GACnB,oiCAAoiC,CAAC;AACviC,MAAM,WAAW,GACf,g8DAAg8D,CAAC;AACn8D,MAAM,gBAAgB,GACpB,45CAA45C,CAAC;AAC/5C,MAAM,eAAe,GACnB,4sFAA4sF,CAAC;AAC/sF,MAAM,aAAa,GACjB,gkCAAgkC,CAAC;AACnkC,MAAM,aAAa,GACjB,4pDAA4pD,CAAC;AAC/pD,MAAM,KAAK,GACT,opBAAopB,CAAC;AACvpB,MAAM,SAAS,GACb,o2BAAo2B,CAAC;AACv2B,MAAM,SAAS,GACb,w7DAAw7D,CAA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C;AACH,CAAC"}
|
@@ -5,8 +5,7 @@ exports.bytesToBigInt = bytesToBigInt;
|
|
5
5
|
exports.bytesToBool = bytesToBool;
|
6
6
|
exports.bytesToNumber = bytesToNumber;
|
7
7
|
exports.bytesToString = bytesToString;
|
8
|
-
const
|
9
|
-
const trim_js_1 = require("./helpers/trim.js");
|
8
|
+
const ox__Bytes = require("ox/Bytes");
|
10
9
|
const hex_js_1 = require("./hex.js");
|
11
10
|
/**
|
12
11
|
* Converts a Uint8Array to the specified type.
|
@@ -52,11 +51,7 @@ function fromBytes(bytes, toOrOpts) {
|
|
52
51
|
* @utils
|
53
52
|
*/
|
54
53
|
function bytesToBigInt(bytes, opts = {}) {
|
55
|
-
|
56
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
57
|
-
}
|
58
|
-
const hex = (0, hex_js_1.uint8ArrayToHex)(bytes, opts);
|
59
|
-
return (0, hex_js_1.hexToBigInt)(hex, opts);
|
54
|
+
return ox__Bytes.toBigInt(bytes, opts);
|
60
55
|
}
|
61
56
|
/**
|
62
57
|
* Converts a byte array to a boolean value.
|
@@ -74,15 +69,7 @@ function bytesToBigInt(bytes, opts = {}) {
|
|
74
69
|
* @utils
|
75
70
|
*/
|
76
71
|
function bytesToBool(bytes_, opts = {}) {
|
77
|
-
|
78
|
-
if (typeof opts.size !== "undefined") {
|
79
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
80
|
-
bytes = (0, trim_js_1.trim)(bytes);
|
81
|
-
}
|
82
|
-
if (bytes.length > 1 || (bytes[0] && bytes[0] > 1)) {
|
83
|
-
throw new Error(`Invalid boolean representation: ${bytes}`);
|
84
|
-
}
|
85
|
-
return Boolean(bytes[0]);
|
72
|
+
return ox__Bytes.toBoolean(bytes_, opts);
|
86
73
|
}
|
87
74
|
/**
|
88
75
|
* Converts a Uint8Array of bytes to a number.
|
@@ -99,11 +86,7 @@ function bytesToBool(bytes_, opts = {}) {
|
|
99
86
|
* @utils
|
100
87
|
*/
|
101
88
|
function bytesToNumber(bytes, opts = {}) {
|
102
|
-
|
103
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
104
|
-
}
|
105
|
-
const hex = (0, hex_js_1.uint8ArrayToHex)(bytes, opts);
|
106
|
-
return (0, hex_js_1.hexToNumber)(hex, opts);
|
89
|
+
return ox__Bytes.toNumber(bytes, opts);
|
107
90
|
}
|
108
91
|
/**
|
109
92
|
* Converts an array of bytes to a string using UTF-8 encoding.
|
@@ -120,11 +103,6 @@ function bytesToNumber(bytes, opts = {}) {
|
|
120
103
|
* @utils
|
121
104
|
*/
|
122
105
|
function bytesToString(bytes_, opts = {}) {
|
123
|
-
|
124
|
-
if (typeof opts.size !== "undefined") {
|
125
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
126
|
-
bytes = (0, trim_js_1.trim)(bytes, { dir: "right" });
|
127
|
-
}
|
128
|
-
return new TextDecoder().decode(bytes);
|
106
|
+
return ox__Bytes.toString(bytes_, opts);
|
129
107
|
}
|
130
108
|
//# sourceMappingURL=from-bytes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"from-bytes.js","sourceRoot":"","sources":["../../../../src/utils/encoding/from-bytes.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"from-bytes.js","sourceRoot":"","sources":["../../../../src/utils/encoding/from-bytes.ts"],"names":[],"mappings":";;AAwCA,8BAmBC;AAuBD,sCAKC;AAmBD,kCAKC;AAkBD,sCAKC;AAkBD,sCAKC;AA7JD,sCAAsC;AACtC,qCAAqD;AAyBrD;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAGvB,KAAiB,EACjB,QAAkC;IAElC,MAAM,IAAI,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxE,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAA6B,CAAC;QAChE,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAA6B,CAAC;QAChE,KAAK,SAAS;YACZ,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,CAA6B,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAA6B,CAAC;QAChE;YACE,OAAO,IAAA,wBAAe,EAAC,KAAK,EAAE,IAAI,CAA6B,CAAC;IACpE,CAAC;AACH,CAAC;AASD;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAC3B,KAAiB,EACjB,OAA0B,EAAE;IAE5B,OAAO,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAID;;;;;;;;;;;;;;GAcG;AACH,SAAgB,WAAW,CACzB,MAAkB,EAClB,OAAwB,EAAE;IAE1B,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAID;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAC3B,KAAiB,EACjB,OAA0B,EAAE;IAE5B,OAAO,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAID;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAC3B,MAAkB,EAClB,OAA0B,EAAE;IAE5B,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.byteSize = byteSize;
|
4
|
-
const
|
4
|
+
const hex_js_1 = require("../hex.js");
|
5
5
|
/**
|
6
6
|
* Calculates the byte size of a Hex string or Uint8Array.
|
7
7
|
* If the value is a Hex string, it accounts for the leading "0x" prefix.
|
@@ -15,7 +15,7 @@ const is_hex_js_1 = require("./is-hex.js");
|
|
15
15
|
* ```
|
16
16
|
*/
|
17
17
|
function byteSize(value) {
|
18
|
-
if ((0,
|
18
|
+
if ((0, hex_js_1.isHex)(value, { strict: false })) {
|
19
19
|
return Math.ceil((value.length - 2) / 2);
|
20
20
|
}
|
21
21
|
return value.length;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"byte-size.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/byte-size.ts"],"names":[],"mappings":";;AAcA,4BAKC;AAnBD,
|
1
|
+
{"version":3,"file":"byte-size.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/byte-size.ts"],"names":[],"mappings":";;AAcA,4BAKC;AAnBD,sCAA4C;AAE5C;;;;;;;;;;;GAWG;AACH,SAAgB,QAAQ,CAAC,KAAuB;IAC9C,IAAI,IAAA,cAAK,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.concatHex = concatHex;
|
4
|
+
const ox__Hex = require("ox/Hex");
|
4
5
|
/**
|
5
6
|
* Concatenates an array of hexadecimal values into a single hexadecimal value.
|
6
7
|
*
|
@@ -9,6 +10,6 @@ exports.concatHex = concatHex;
|
|
9
10
|
* @utils
|
10
11
|
*/
|
11
12
|
function concatHex(values) {
|
12
|
-
return
|
13
|
+
return ox__Hex.concat(...values);
|
13
14
|
}
|
14
15
|
//# sourceMappingURL=concat-hex.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"concat-hex.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/concat-hex.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"concat-hex.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/concat-hex.ts"],"names":[],"mappings":";;AAUA,8BAEC;AAZD,kCAAkC;AAGlC;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,MAAsB;IAC9C,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AACnC,CAAC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isHex = isHex;
|
4
|
+
const ox__Hex = require("ox/Hex");
|
4
5
|
/**
|
5
6
|
* Checks if a value is a valid hexadecimal string.
|
6
7
|
* @param value - The value to be checked.
|
@@ -15,14 +16,6 @@ exports.isHex = isHex;
|
|
15
16
|
* @utils
|
16
17
|
*/
|
17
18
|
function isHex(value, options = {}) {
|
18
|
-
|
19
|
-
return false;
|
20
|
-
}
|
21
|
-
if (typeof value !== "string") {
|
22
|
-
return false;
|
23
|
-
}
|
24
|
-
return options.strict
|
25
|
-
? /^0x[0-9a-fA-F]*$/.test(value)
|
26
|
-
: value.startsWith("0x");
|
19
|
+
return ox__Hex.validate(value, options);
|
27
20
|
}
|
28
21
|
//# sourceMappingURL=is-hex.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"is-hex.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/is-hex.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"is-hex.js","sourceRoot":"","sources":["../../../../../src/utils/encoding/helpers/is-hex.ts"],"names":[],"mappings":";;AAkBA,sBAKC;AAvBD,kCAAkC;AAKlC;;;;;;;;;;;;GAYG;AACH,SAAgB,KAAK,CACnB,KAAc,EACd,UAAwB,EAAE;IAE1B,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
@@ -13,38 +13,9 @@ exports.uint8ArrayToHex = uint8ArrayToHex;
|
|
13
13
|
exports.numberToHex = numberToHex;
|
14
14
|
exports.stringToHex = stringToHex;
|
15
15
|
exports.toHex = toHex;
|
16
|
-
const
|
17
|
-
const text_encoder_js_1 = require("../text-encoder.js");
|
18
|
-
// slightly tweaked re-exports from viem for the moment
|
19
|
-
const assert_size_js_1 = require("./helpers/assert-size.js");
|
20
|
-
const charcode_to_base_16_js_1 = require("./helpers/charcode-to-base-16.js");
|
16
|
+
const ox__Hex = require("ox/Hex");
|
21
17
|
var is_hex_js_1 = require("./helpers/is-hex.js");
|
22
18
|
Object.defineProperty(exports, "isHex", { enumerable: true, get: function () { return is_hex_js_1.isHex; } });
|
23
|
-
function trim(hexOrBytes, options = {}) {
|
24
|
-
const dir = options.dir || "left";
|
25
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix any
|
26
|
-
let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
|
27
|
-
let sliceLength = 0;
|
28
|
-
for (let i = 0; i < data.length - 1; i++) {
|
29
|
-
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0") {
|
30
|
-
sliceLength++;
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
break;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
data =
|
37
|
-
dir === "left"
|
38
|
-
? data.slice(sliceLength)
|
39
|
-
: data.slice(0, data.length - sliceLength);
|
40
|
-
if (typeof hexOrBytes === "string") {
|
41
|
-
if (data.length === 1 && dir === "right") {
|
42
|
-
data = `${data}0`;
|
43
|
-
}
|
44
|
-
return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
|
45
|
-
}
|
46
|
-
return data;
|
47
|
-
}
|
48
19
|
/**
|
49
20
|
* Pads a hexadecimal string with zeros to a specified size.
|
50
21
|
* @param hex_ The hexadecimal string to pad.
|
@@ -64,11 +35,10 @@ function padHex(hex_, options = {}) {
|
|
64
35
|
if (size === null) {
|
65
36
|
return hex_;
|
66
37
|
}
|
67
|
-
|
68
|
-
|
69
|
-
throw new Error(`Size overflow: ${Math.ceil(hex.length / 2)} > ${size}`);
|
38
|
+
if (dir === "right") {
|
39
|
+
return ox__Hex.padRight(hex_, size);
|
70
40
|
}
|
71
|
-
return
|
41
|
+
return ox__Hex.padLeft(hex_, size);
|
72
42
|
}
|
73
43
|
/**
|
74
44
|
* Converts a hexadecimal string to a UTF-8 string.
|
@@ -84,12 +54,7 @@ function padHex(hex_, options = {}) {
|
|
84
54
|
* @utils
|
85
55
|
*/
|
86
56
|
function hexToString(hex, opts = {}) {
|
87
|
-
|
88
|
-
if (opts.size) {
|
89
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
90
|
-
bytes = trim(bytes, { dir: "right" });
|
91
|
-
}
|
92
|
-
return (0, text_decoder_js_1.cachedTextDecoder)().decode(bytes);
|
57
|
+
return ox__Hex.toString(hex, opts);
|
93
58
|
}
|
94
59
|
/**
|
95
60
|
* Converts a hexadecimal string to a BigInt.
|
@@ -105,20 +70,7 @@ function hexToString(hex, opts = {}) {
|
|
105
70
|
* @utils
|
106
71
|
*/
|
107
72
|
function hexToBigInt(hex, opts = {}) {
|
108
|
-
|
109
|
-
if (opts.size) {
|
110
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
111
|
-
}
|
112
|
-
const value = BigInt(hex);
|
113
|
-
if (!signed) {
|
114
|
-
return value;
|
115
|
-
}
|
116
|
-
const size = (hex.length - 2) / 2;
|
117
|
-
const max = (1n << (BigInt(size) * 8n - 1n)) - 1n;
|
118
|
-
if (value <= max) {
|
119
|
-
return value;
|
120
|
-
}
|
121
|
-
return value - BigInt(`0x${"f".padStart(size * 2, "f")}`) - 1n;
|
73
|
+
return ox__Hex.toBigInt(hex, opts);
|
122
74
|
}
|
123
75
|
/**
|
124
76
|
* Converts a hexadecimal string to a number.
|
@@ -134,7 +86,7 @@ function hexToBigInt(hex, opts = {}) {
|
|
134
86
|
* @utils
|
135
87
|
*/
|
136
88
|
function hexToNumber(hex, opts = {}) {
|
137
|
-
return
|
89
|
+
return ox__Hex.toNumber(hex, opts);
|
138
90
|
}
|
139
91
|
/**
|
140
92
|
* Converts a hexadecimal string to a boolean value.
|
@@ -151,18 +103,7 @@ function hexToNumber(hex, opts = {}) {
|
|
151
103
|
* @utils
|
152
104
|
*/
|
153
105
|
function hexToBool(hex, opts = {}) {
|
154
|
-
|
155
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
156
|
-
// biome-ignore lint/style/noParameterAssign: for perf
|
157
|
-
hex = trim(hex);
|
158
|
-
}
|
159
|
-
if (trim(hex) === "0x00") {
|
160
|
-
return false;
|
161
|
-
}
|
162
|
-
if (trim(hex) === "0x01") {
|
163
|
-
return true;
|
164
|
-
}
|
165
|
-
throw new Error(`Invalid hex boolean: ${hex}`);
|
106
|
+
return ox__Hex.toBoolean(hex, opts);
|
166
107
|
}
|
167
108
|
/**
|
168
109
|
* Converts a hexadecimal string to a Uint8Array.
|
@@ -178,26 +119,7 @@ function hexToBool(hex, opts = {}) {
|
|
178
119
|
* @utils
|
179
120
|
*/
|
180
121
|
function hexToUint8Array(hex, opts = {}) {
|
181
|
-
|
182
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
183
|
-
// biome-ignore lint/style/noParameterAssign: for perf
|
184
|
-
hex = padHex(hex, { dir: "right", size: opts.size });
|
185
|
-
}
|
186
|
-
let hexString = hex.slice(2);
|
187
|
-
if (hexString.length % 2) {
|
188
|
-
hexString = `0${hexString}`;
|
189
|
-
}
|
190
|
-
const length = hexString.length / 2;
|
191
|
-
const bytes = new Uint8Array(length);
|
192
|
-
for (let index = 0, j = 0; index < length; index++) {
|
193
|
-
const nibbleLeft = (0, charcode_to_base_16_js_1.charCodeToBase16)(hexString.charCodeAt(j++));
|
194
|
-
const nibbleRight = (0, charcode_to_base_16_js_1.charCodeToBase16)(hexString.charCodeAt(j++));
|
195
|
-
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
196
|
-
throw new Error(`Invalid hex character: ${hexString}`);
|
197
|
-
}
|
198
|
-
bytes[index] = nibbleLeft * 16 + nibbleRight;
|
199
|
-
}
|
200
|
-
return bytes;
|
122
|
+
return ox__Hex.toBytes(hex, opts);
|
201
123
|
}
|
202
124
|
/**
|
203
125
|
* Converts a hexadecimal string to the specified type.
|
@@ -227,10 +149,6 @@ function fromHex(hex, toOrOpts) {
|
|
227
149
|
return hexToUint8Array(hex, opts);
|
228
150
|
}
|
229
151
|
}
|
230
|
-
//--------------------------------------------------------------------------
|
231
|
-
// TO HEX
|
232
|
-
//--------------------------------------------------------------------------
|
233
|
-
const hexes = /* @__PURE__ */ (() => Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0")))();
|
234
152
|
/**
|
235
153
|
* Converts a boolean value to a hexadecimal string representation.
|
236
154
|
* @param value - The boolean value to convert.
|
@@ -245,12 +163,7 @@ const hexes = /* @__PURE__ */ (() => Array.from({ length: 256 }, (_v, i) => i.to
|
|
245
163
|
* @utils
|
246
164
|
*/
|
247
165
|
function boolToHex(value, opts = {}) {
|
248
|
-
|
249
|
-
if (typeof opts.size === "number") {
|
250
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
251
|
-
return padHex(hex, { size: opts.size });
|
252
|
-
}
|
253
|
-
return hex;
|
166
|
+
return ox__Hex.fromBoolean(value, opts);
|
254
167
|
}
|
255
168
|
/**
|
256
169
|
* Converts an array of bytes to a hexadecimal string.
|
@@ -266,17 +179,7 @@ function boolToHex(value, opts = {}) {
|
|
266
179
|
* @utils
|
267
180
|
*/
|
268
181
|
function uint8ArrayToHex(value, opts = {}) {
|
269
|
-
|
270
|
-
for (let i = 0; i < value.length; i++) {
|
271
|
-
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
272
|
-
string += hexes[value[i]];
|
273
|
-
}
|
274
|
-
const hex = `0x${string}`;
|
275
|
-
if (typeof opts.size === "number") {
|
276
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
277
|
-
return padHex(hex, { dir: "right", size: opts.size });
|
278
|
-
}
|
279
|
-
return hex;
|
182
|
+
return ox__Hex.fromBytes(value, opts);
|
280
183
|
}
|
281
184
|
/**
|
282
185
|
* Converts a number or bigint to a hexadecimal string.
|
@@ -293,30 +196,7 @@ function uint8ArrayToHex(value, opts = {}) {
|
|
293
196
|
* @utils
|
294
197
|
*/
|
295
198
|
function numberToHex(value_, opts = {}) {
|
296
|
-
|
297
|
-
const value = BigInt(value_);
|
298
|
-
let maxValue;
|
299
|
-
if (size) {
|
300
|
-
if (signed) {
|
301
|
-
maxValue = (1n << (BigInt(size) * 8n - 1n)) - 1n;
|
302
|
-
}
|
303
|
-
else {
|
304
|
-
maxValue = 2n ** (BigInt(size) * 8n) - 1n;
|
305
|
-
}
|
306
|
-
}
|
307
|
-
else if (typeof value_ === "number") {
|
308
|
-
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
309
|
-
}
|
310
|
-
const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
|
311
|
-
if ((maxValue && value > maxValue) || value < minValue) {
|
312
|
-
const suffix = typeof value_ === "bigint" ? "n" : "";
|
313
|
-
throw new Error(`Number "${value_}${suffix}" is not in safe ${size ? `${size * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${maxValue ? `(${minValue} to ${maxValue})` : `(above ${minValue})`}`);
|
314
|
-
}
|
315
|
-
const hex = `0x${(signed && value < 0 ? (1n << BigInt(size * 8)) + BigInt(value) : value).toString(16)}`;
|
316
|
-
if (size) {
|
317
|
-
return padHex(hex, { size });
|
318
|
-
}
|
319
|
-
return hex;
|
199
|
+
return ox__Hex.fromNumber(value_, opts);
|
320
200
|
}
|
321
201
|
/**
|
322
202
|
* Converts a string to its hexadecimal representation.
|
@@ -332,8 +212,7 @@ function numberToHex(value_, opts = {}) {
|
|
332
212
|
* @utils
|
333
213
|
*/
|
334
214
|
function stringToHex(value_, opts = {}) {
|
335
|
-
|
336
|
-
return uint8ArrayToHex(value, opts);
|
215
|
+
return ox__Hex.fromString(value_, opts);
|
337
216
|
}
|
338
217
|
/**
|
339
218
|
* Converts a value to its hexadecimal representation.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../../../src/utils/encoding/hex.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../../../src/utils/encoding/hex.ts"],"names":[],"mappings":";;;AAwBA,wBASC;AAqBD,kCAEC;AAiBD,kCAEC;AAgBD,kCAEC;AAkBD,8BAEC;AAiBD,0CAKC;AAsCD,0BAiBC;AAqBD,8BAEC;AAiBD,0CAKC;AAkBD,kCAKC;AAiBD,kCAEC;AAoBD,sBAeC;AAxTD,kCAAkC;AAClC,iDAA+D;AAAtD,kGAAA,KAAK,OAAA;AASd;;;;;;;;;;;;;GAaG;AACH,SAAgB,MAAM,CAAC,IAAS,EAAE,UAAsB,EAAE;IACxD,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IACnC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAQD;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,GAAQ,EAAE,OAAwB,EAAE;IAC9D,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAID;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,GAAQ,EAAE,O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C,KAAc,EAAE,OAAsB,EAAE;IAChE,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC;AAID;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAC7B,KAAiB,EACjB,OAA4B,EAAE;IAE9B,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAID;;;;;;;;;;;;;GAaG;AACH,SAAgB,WAAW,CACzB,MAAuB,EACvB,OAAwB,EAAE;IAE1B,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC;AAID;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,MAAc,EAAE,OAAwB,EAAE;IACpE,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC;AAOD;;;;;;;;;;;;GAYG;AACH,SAAgB,KAAK,CACnB,KAAsD,EACtD,OAAwB,EAAE;IAE1B,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClC,KAAK,QAAQ;YACX,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClC,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChC;YACE,OAAO,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
|
@@ -1,35 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.padBytes = padBytes;
|
4
3
|
exports.toBytes = toBytes;
|
5
4
|
exports.boolToBytes = boolToBytes;
|
6
5
|
exports.hexToBytes = hexToBytes;
|
7
6
|
exports.numberToBytes = numberToBytes;
|
8
7
|
exports.stringToBytes = stringToBytes;
|
9
|
-
const
|
10
|
-
const assert_size_js_1 = require("./helpers/assert-size.js");
|
11
|
-
const charcode_to_base_16_js_1 = require("./helpers/charcode-to-base-16.js");
|
8
|
+
const ox__Bytes = require("ox/Bytes");
|
12
9
|
const is_hex_js_1 = require("./helpers/is-hex.js");
|
13
|
-
const hex_js_1 = require("./hex.js");
|
14
|
-
/**
|
15
|
-
* @internal Exported for test
|
16
|
-
*/
|
17
|
-
function padBytes(bytes, { dir, size = 32 } = {}) {
|
18
|
-
if (size === null) {
|
19
|
-
return bytes;
|
20
|
-
}
|
21
|
-
if (bytes.length > size) {
|
22
|
-
throw new Error(`Size overflow: ${bytes.length} > ${size}`);
|
23
|
-
}
|
24
|
-
const paddedBytes = new Uint8Array(size);
|
25
|
-
for (let i = 0; i < size; i++) {
|
26
|
-
const padEnd = dir === "right";
|
27
|
-
paddedBytes[padEnd ? i : size - i - 1] =
|
28
|
-
// biome-ignore lint/style/noNonNullAssertion: we know its there
|
29
|
-
bytes[padEnd ? i : bytes.length - i - 1];
|
30
|
-
}
|
31
|
-
return paddedBytes;
|
32
|
-
}
|
33
10
|
/**
|
34
11
|
* Converts a value to an array of bytes.
|
35
12
|
* @param value - The value to convert.
|
@@ -71,13 +48,7 @@ function toBytes(value, opts = {}) {
|
|
71
48
|
* @utils
|
72
49
|
*/
|
73
50
|
function boolToBytes(value, opts = {}) {
|
74
|
-
|
75
|
-
bytes[0] = Number(value);
|
76
|
-
if (typeof opts.size === "number") {
|
77
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
78
|
-
return padBytes(bytes, { size: opts.size });
|
79
|
-
}
|
80
|
-
return bytes;
|
51
|
+
return ox__Bytes.fromBoolean(value, opts);
|
81
52
|
}
|
82
53
|
/**
|
83
54
|
* Converts a hexadecimal string to a Uint8Array of bytes.
|
@@ -94,26 +65,7 @@ function boolToBytes(value, opts = {}) {
|
|
94
65
|
* @utils
|
95
66
|
*/
|
96
67
|
function hexToBytes(hex_, opts = {}) {
|
97
|
-
|
98
|
-
if (opts.size) {
|
99
|
-
(0, assert_size_js_1.assertSize)(hex, { size: opts.size });
|
100
|
-
hex = (0, hex_js_1.padHex)(hex, { dir: "right", size: opts.size });
|
101
|
-
}
|
102
|
-
let hexString = hex.slice(2);
|
103
|
-
if (hexString.length % 2) {
|
104
|
-
hexString = `0${hexString}`;
|
105
|
-
}
|
106
|
-
const length = hexString.length / 2;
|
107
|
-
const bytes = new Uint8Array(length);
|
108
|
-
for (let index = 0, j = 0; index < length; index++) {
|
109
|
-
const nibbleLeft = (0, charcode_to_base_16_js_1.charCodeToBase16)(hexString.charCodeAt(j++));
|
110
|
-
const nibbleRight = (0, charcode_to_base_16_js_1.charCodeToBase16)(hexString.charCodeAt(j++));
|
111
|
-
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
112
|
-
throw new Error(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
113
|
-
}
|
114
|
-
bytes[index] = nibbleLeft * 16 + nibbleRight;
|
115
|
-
}
|
116
|
-
return bytes;
|
68
|
+
return ox__Bytes.fromHex(hex_, opts);
|
117
69
|
}
|
118
70
|
/**
|
119
71
|
* Converts a number to bytes.
|
@@ -129,8 +81,7 @@ function hexToBytes(hex_, opts = {}) {
|
|
129
81
|
* @utils
|
130
82
|
*/
|
131
83
|
function numberToBytes(value, opts) {
|
132
|
-
|
133
|
-
return hexToBytes(hex);
|
84
|
+
return ox__Bytes.fromNumber(value, opts);
|
134
85
|
}
|
135
86
|
/**
|
136
87
|
* Converts a string to an array of bytes.
|
@@ -146,11 +97,6 @@ function numberToBytes(value, opts) {
|
|
146
97
|
* @utils
|
147
98
|
*/
|
148
99
|
function stringToBytes(value, opts = {}) {
|
149
|
-
|
150
|
-
if (typeof opts.size === "number") {
|
151
|
-
(0, assert_size_js_1.assertSize)(bytes, { size: opts.size });
|
152
|
-
return padBytes(bytes, { dir: "right", size: opts.size });
|
153
|
-
}
|
154
|
-
return bytes;
|
100
|
+
return ox__Bytes.fromString(value, opts);
|
155
101
|
}
|
156
102
|
//# sourceMappingURL=to-bytes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"to-bytes.js","sourceRoot":"","sources":["../../../../src/utils/encoding/to-bytes.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"to-bytes.js","sourceRoot":"","sources":["../../../../src/utils/encoding/to-bytes.ts"],"names":[],"mappings":";;AAuBA,0BAgBC;AAiBD,kCAEC;AAkBD,gCAEC;AAeD,sCAEC;AAoBD,sCAKC;AAxHD,sCAAsC;AACtC,mDAA4C;AAS5C;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CACrB,KAA+C,EAC/C,OAA0B,EAAE;IAE5B,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpC,KAAK,SAAS;YACZ,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClC;YACE,IAAI,IAAA,iBAAK,EAAC,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACjC,CAAC;YACD,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAID;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,KAAc,EAAE,OAAwB,EAAE;IACpE,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAID;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,IAAS,EAAE,OAAuB,EAAE;IAC7D,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,KAAsB,EAAE,IAAsB;IAC1E,OAAO,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAOD;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,KAAa,EACb,OAA0B,EAAE;IAE5B,OAAO,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/cjs/version.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.version = void 0;
|
4
|
-
exports.version = "5.67.1-nightly-
|
4
|
+
exports.version = "5.67.1-nightly-040e478ad6cf630dedf666eac7abeb668d323666-20241113000339";
|
5
5
|
//# sourceMappingURL=version.js.map
|
@@ -106,9 +106,11 @@ class EnclaveWallet {
|
|
106
106
|
const transaction = {
|
107
107
|
to: tx.to ? (0, address_js_1.getAddress)(tx.to) : undefined,
|
108
108
|
data: tx.data,
|
109
|
-
value: tx.value ? (0, hex_js_1.toHex)(tx.value) : undefined,
|
110
|
-
gas:
|
111
|
-
|
109
|
+
value: typeof tx.value === "bigint" ? (0, hex_js_1.toHex)(tx.value) : undefined,
|
110
|
+
gas: typeof tx.gas === "bigint"
|
111
|
+
? (0, hex_js_1.toHex)(tx.gas + tx.gas / BigInt(10))
|
112
|
+
: undefined, // Add a 10% buffer to gas
|
113
|
+
nonce: typeof tx.nonce === "number"
|
112
114
|
? (0, hex_js_1.toHex)(tx.nonce)
|
113
115
|
: (0, hex_js_1.toHex)(await Promise.resolve().then(() => require("../../../../rpc/actions/eth_getTransactionCount.js")).then(({ eth_getTransactionCount }) => eth_getTransactionCount(rpcRequest, {
|
114
116
|
address: this.address,
|
@@ -118,13 +120,15 @@ class EnclaveWallet {
|
|
118
120
|
};
|
119
121
|
if (tx.maxFeePerGas) {
|
120
122
|
transaction.maxFeePerGas = (0, hex_js_1.toHex)(tx.maxFeePerGas);
|
121
|
-
transaction.maxPriorityFeePerGas =
|
122
|
-
|
123
|
-
|
123
|
+
transaction.maxPriorityFeePerGas =
|
124
|
+
typeof tx.maxPriorityFeePerGas === "bigint"
|
125
|
+
? (0, hex_js_1.toHex)(tx.maxPriorityFeePerGas)
|
126
|
+
: undefined;
|
124
127
|
transaction.type = 2;
|
125
128
|
}
|
126
129
|
else {
|
127
|
-
transaction.gasPrice =
|
130
|
+
transaction.gasPrice =
|
131
|
+
typeof tx.gasPrice === "bigint" ? (0, hex_js_1.toHex)(tx.gasPrice) : undefined;
|
128
132
|
transaction.type = 0;
|
129
133
|
}
|
130
134
|
return (0, sign_transaction_enclave_js_1.signTransaction)({
|