@layerzerolabs/chain-utils 0.2.65 → 0.2.66
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/.turbo/turbo-build.log +11 -11
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/dist/{X46YPLVF.cjs → C2R7HHH3.cjs} +7 -7
- package/dist/C2R7HHH3.cjs.map +1 -0
- package/dist/{OVN7SCH2.js → YMF6LH6C.js} +3 -3
- package/dist/YMF6LH6C.js.map +1 -0
- package/dist/addressParser.cjs +9 -9
- package/dist/addressParser.d.ts.map +1 -1
- package/dist/addressParser.js +1 -1
- package/dist/addressParser.test.cjs +28 -28
- package/dist/addressParser.test.cjs.map +1 -1
- package/dist/addressParser.test.js +8 -8
- package/dist/addressParser.test.js.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.js +1 -1
- package/package.json +9 -9
- package/src/addressParser.ts +1 -1
- package/dist/OVN7SCH2.js.map +0 -1
- package/dist/X46YPLVF.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var C2R7HHH3_cjs = require('./C2R7HHH3.cjs');
|
|
4
4
|
var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
|
|
5
5
|
var bs58 = require('bs58');
|
|
6
6
|
var tty = require('tty');
|
|
@@ -590,10 +590,10 @@ var require_dist = KHVGLVR5_cjs.__commonJS({
|
|
|
590
590
|
// src/addressParser.test.ts
|
|
591
591
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
592
592
|
|
|
593
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
593
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/index.js
|
|
594
594
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
595
595
|
|
|
596
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
596
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
|
597
597
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
598
598
|
|
|
599
599
|
// ../../../node_modules/.pnpm/@vitest+expect@3.2.4/node_modules/@vitest/expect/dist/index.js
|
|
@@ -12950,7 +12950,7 @@ KHVGLVR5_cjs.__name(createTestHook, "createTestHook");
|
|
|
12950
12950
|
// ../../../node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/utils.js
|
|
12951
12951
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
12952
12952
|
|
|
12953
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
12953
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
|
|
12954
12954
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
12955
12955
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
|
12956
12956
|
function getWorkerState() {
|
|
@@ -13007,7 +13007,7 @@ async function waitForImportsToResolve() {
|
|
|
13007
13007
|
}
|
|
13008
13008
|
KHVGLVR5_cjs.__name(waitForImportsToResolve, "waitForImportsToResolve");
|
|
13009
13009
|
|
|
13010
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
13010
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
|
13011
13011
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
13012
13012
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
13013
13013
|
function getDefaultExportFromCjs3(x2) {
|
|
@@ -15297,7 +15297,7 @@ var SnapshotClient = class SnapshotClient2 {
|
|
|
15297
15297
|
}
|
|
15298
15298
|
};
|
|
15299
15299
|
|
|
15300
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
15300
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
|
|
15301
15301
|
KHVGLVR5_cjs.init_cjs_shims();
|
|
15302
15302
|
var RealDate = Date;
|
|
15303
15303
|
var now2 = null;
|
|
@@ -15351,7 +15351,7 @@ function resetDate() {
|
|
|
15351
15351
|
}
|
|
15352
15352
|
KHVGLVR5_cjs.__name(resetDate, "resetDate");
|
|
15353
15353
|
|
|
15354
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
15354
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
|
15355
15355
|
var unsupported = [
|
|
15356
15356
|
"matchSnapshot",
|
|
15357
15357
|
"toMatchSnapshot",
|
|
@@ -18094,7 +18094,7 @@ function getImporter(name) {
|
|
|
18094
18094
|
}
|
|
18095
18095
|
KHVGLVR5_cjs.__name(getImporter, "getImporter");
|
|
18096
18096
|
|
|
18097
|
-
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@
|
|
18097
|
+
// ../../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@25.5.0_jiti@2.6.1_lightningcss@1.30.1_terser@5.44.1_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/index.js
|
|
18098
18098
|
KHVGLVR5_cjs.__toESM(require_dist(), 1);
|
|
18099
18099
|
var randomBytes = /* @__PURE__ */ KHVGLVR5_cjs.__name((length) => {
|
|
18100
18100
|
const bytes = new Uint8Array(length);
|
|
@@ -18120,7 +18120,7 @@ describe("addressParser - hex/EVM chains", () => {
|
|
|
18120
18120
|
];
|
|
18121
18121
|
evmChains.forEach((chain) => {
|
|
18122
18122
|
describe(chain, () => {
|
|
18123
|
-
const parser =
|
|
18123
|
+
const parser = C2R7HHH3_cjs.addressParser(chain);
|
|
18124
18124
|
it("maintains roundtrip invariant: hex -> native -> hex", () => {
|
|
18125
18125
|
runPropertyTest(() => {
|
|
18126
18126
|
const input = randomHex(20);
|
|
@@ -18153,13 +18153,13 @@ describe("addressParser - hex/EVM chains", () => {
|
|
|
18153
18153
|
runPropertyTest(() => {
|
|
18154
18154
|
const byteLength = Math.floor(Math.random() * 32) + 1;
|
|
18155
18155
|
const input = randomHex(byteLength);
|
|
18156
|
-
const padded =
|
|
18156
|
+
const padded = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM).normalizedToBytes32Hex(input);
|
|
18157
18157
|
globalExpect(padded.length).toBe(66);
|
|
18158
18158
|
globalExpect(padded).toBe(commonEncodingUtils.hexZeroPad(input, 32));
|
|
18159
18159
|
});
|
|
18160
18160
|
});
|
|
18161
18161
|
it("handles edge cases", () => {
|
|
18162
|
-
const parser =
|
|
18162
|
+
const parser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18163
18163
|
const empty = commonChainModel.normalizeHex("0x");
|
|
18164
18164
|
globalExpect(parser.normalizedToNative(empty).nativeAddress.length).toBe(42);
|
|
18165
18165
|
const max = commonChainModel.normalizeHex("0x" + "ff".repeat(20));
|
|
@@ -18169,7 +18169,7 @@ describe("addressParser - hex/EVM chains", () => {
|
|
|
18169
18169
|
});
|
|
18170
18170
|
});
|
|
18171
18171
|
describe("addressParser - base58 chains (Solana)", () => {
|
|
18172
|
-
const parser =
|
|
18172
|
+
const parser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
|
|
18173
18173
|
it("maintains roundtrip invariant: hex -> base58 -> hex", () => {
|
|
18174
18174
|
runPropertyTest(() => {
|
|
18175
18175
|
const byteLength = Math.floor(Math.random() * 32) + 1;
|
|
@@ -18212,15 +18212,15 @@ describe("addressParser - base58 chains (Solana)", () => {
|
|
|
18212
18212
|
});
|
|
18213
18213
|
describe("addressParser - chain validation", () => {
|
|
18214
18214
|
it("validates chain names for nativeToBytes32Hex", () => {
|
|
18215
|
-
const evmParser =
|
|
18216
|
-
const solanaParser =
|
|
18215
|
+
const evmParser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18216
|
+
const solanaParser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
|
|
18217
18217
|
const evmAddress = evmParser.normalizedToNative(randomHex(20));
|
|
18218
18218
|
const solanaAddress = solanaParser.normalizedToNative(randomHex(32));
|
|
18219
18219
|
globalExpect(() => solanaParser.nativeToBytes32Hex(evmAddress)).toThrow(/Cannot convert/);
|
|
18220
18220
|
globalExpect(() => evmParser.nativeToBytes32Hex(solanaAddress)).toThrow(/Cannot convert/);
|
|
18221
18221
|
});
|
|
18222
18222
|
it("accepts string addresses without validation", () => {
|
|
18223
|
-
const parser =
|
|
18223
|
+
const parser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18224
18224
|
const randomAddress = "0x" + "ab".repeat(20);
|
|
18225
18225
|
const result = parser.nativeToNormalized(randomAddress);
|
|
18226
18226
|
globalExpect(result).toBe(commonChainModel.normalizeHex(randomAddress));
|
|
@@ -18231,7 +18231,7 @@ describe("addressParser - chain validation", () => {
|
|
|
18231
18231
|
});
|
|
18232
18232
|
});
|
|
18233
18233
|
describe("addressParser - TON", () => {
|
|
18234
|
-
const parser =
|
|
18234
|
+
const parser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.TON);
|
|
18235
18235
|
it("maintains roundtrip invariant: hex -> ton address -> hex", () => {
|
|
18236
18236
|
runPropertyTest(() => {
|
|
18237
18237
|
const byteLength = Math.floor(Math.random() * 32) + 1;
|
|
@@ -18292,7 +18292,7 @@ describe("addressParser - TON", () => {
|
|
|
18292
18292
|
});
|
|
18293
18293
|
});
|
|
18294
18294
|
describe("addressParser - Stellar", () => {
|
|
18295
|
-
const parser =
|
|
18295
|
+
const parser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.STELLAR);
|
|
18296
18296
|
const validTestAddresses = {
|
|
18297
18297
|
// Account address (G...)
|
|
18298
18298
|
account: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
|
|
@@ -18615,7 +18615,7 @@ describe("addressParser - normalizedToBytes32Hex (cross-chain)", () => {
|
|
|
18615
18615
|
];
|
|
18616
18616
|
testCases.forEach(({ name, chainName, nativeAddr }) => {
|
|
18617
18617
|
it(`${name}: normalizedToBytes32Hex(normalized) === nativeToBytes32Hex(native)`, () => {
|
|
18618
|
-
const p3 =
|
|
18618
|
+
const p3 = C2R7HHH3_cjs.addressParser(chainName);
|
|
18619
18619
|
const normalized = p3.nativeToNormalized(nativeAddr);
|
|
18620
18620
|
const fromNormalized = p3.normalizedToBytes32Hex(normalized);
|
|
18621
18621
|
const fromNative = p3.nativeToBytes32Hex(nativeAddr);
|
|
@@ -18625,13 +18625,13 @@ describe("addressParser - normalizedToBytes32Hex (cross-chain)", () => {
|
|
|
18625
18625
|
});
|
|
18626
18626
|
});
|
|
18627
18627
|
it("normalizedToBytes32Hex is consistent across chain parsers for \u226432 byte hex", () => {
|
|
18628
|
-
const evmParser =
|
|
18629
|
-
const solanaParser =
|
|
18628
|
+
const evmParser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18629
|
+
const solanaParser = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
|
|
18630
18630
|
const normalized = commonChainModel.normalizeHex("0x1234567890abcdef1234567890abcdef12345678");
|
|
18631
18631
|
globalExpect(evmParser.normalizedToBytes32Hex(normalized)).toBe(solanaParser.normalizedToBytes32Hex(normalized));
|
|
18632
18632
|
});
|
|
18633
18633
|
it("normalizedToBytes32 returns correct Uint8Array", () => {
|
|
18634
|
-
const p3 =
|
|
18634
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18635
18635
|
const normalized = commonChainModel.normalizeHex("0x1234567890abcdef1234567890abcdef12345678");
|
|
18636
18636
|
const bytes32Hex = p3.normalizedToBytes32Hex(normalized);
|
|
18637
18637
|
const bytes32 = p3.normalizedToBytes32(normalized);
|
|
@@ -18639,7 +18639,7 @@ describe("addressParser - normalizedToBytes32Hex (cross-chain)", () => {
|
|
|
18639
18639
|
globalExpect(commonEncodingUtils.bytesToHexPrefixed(bytes32)).toBe(bytes32Hex);
|
|
18640
18640
|
});
|
|
18641
18641
|
it("returns undefined for undefined input", () => {
|
|
18642
|
-
const p3 =
|
|
18642
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18643
18643
|
globalExpect(p3.normalizedToBytes32Hex(void 0)).toBeUndefined();
|
|
18644
18644
|
globalExpect(p3.normalizedToBytes32(void 0)).toBeUndefined();
|
|
18645
18645
|
});
|
|
@@ -18681,14 +18681,14 @@ describe("addressParser - bytes32ToNormalized", () => {
|
|
|
18681
18681
|
];
|
|
18682
18682
|
cases.forEach(({ name, chainName, native }) => {
|
|
18683
18683
|
it(`${name}: round-trip`, () => {
|
|
18684
|
-
const p3 =
|
|
18684
|
+
const p3 = C2R7HHH3_cjs.addressParser(chainName);
|
|
18685
18685
|
const normalized = p3.nativeToNormalized(native);
|
|
18686
18686
|
const bytes32Hex = p3.nativeToBytes32Hex(native);
|
|
18687
18687
|
globalExpect(p3.bytes32ToNormalized(bytes32Hex)).toBe(normalized);
|
|
18688
18688
|
});
|
|
18689
18689
|
});
|
|
18690
18690
|
it("Stellar contract: round-trip", () => {
|
|
18691
|
-
const p3 =
|
|
18691
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.STELLAR);
|
|
18692
18692
|
const contractAddr = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
|
|
18693
18693
|
const normalized = p3.nativeToNormalized(contractAddr);
|
|
18694
18694
|
const bytes32Hex = p3.nativeToBytes32Hex(contractAddr);
|
|
@@ -18696,7 +18696,7 @@ describe("addressParser - bytes32ToNormalized", () => {
|
|
|
18696
18696
|
});
|
|
18697
18697
|
});
|
|
18698
18698
|
it("undefined input returns undefined", () => {
|
|
18699
|
-
const p3 =
|
|
18699
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18700
18700
|
globalExpect(p3.bytes32ToNormalized(void 0)).toBeUndefined();
|
|
18701
18701
|
});
|
|
18702
18702
|
it("non-Stellar: bytes32ToNative === normalizeHex for same input", () => {
|
|
@@ -18708,15 +18708,15 @@ describe("addressParser - bytes32ToNormalized", () => {
|
|
|
18708
18708
|
];
|
|
18709
18709
|
const bytes32 = "0x0000000000000000000000001234567890abcdef1234567890abcdef12345678";
|
|
18710
18710
|
chains.forEach((chainName) => {
|
|
18711
|
-
globalExpect(
|
|
18711
|
+
globalExpect(C2R7HHH3_cjs.addressParser(chainName).bytes32ToNormalized(bytes32)).toBe(commonChainModel.normalizeHex(bytes32));
|
|
18712
18712
|
});
|
|
18713
18713
|
});
|
|
18714
18714
|
it("zero bytes32: EVM returns NORMALIZED_HEX_ZERO", () => {
|
|
18715
|
-
const p3 =
|
|
18715
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
|
|
18716
18716
|
globalExpect(p3.bytes32ToNormalized(ZERO_BYTES32)).toBe(commonChainModel.NORMALIZED_HEX_ZERO);
|
|
18717
18717
|
});
|
|
18718
18718
|
it("zero bytes32: Stellar returns C-address for zero contract ID (not undefined)", () => {
|
|
18719
|
-
const p3 =
|
|
18719
|
+
const p3 = C2R7HHH3_cjs.addressParser(layerzeroDefinitions.ChainName.STELLAR);
|
|
18720
18720
|
const result = p3.bytes32ToNormalized(ZERO_BYTES32);
|
|
18721
18721
|
globalExpect(result).toBeDefined();
|
|
18722
18722
|
globalExpect(result).not.toBe(commonChainModel.NORMALIZED_HEX_ZERO);
|