@layerzerolabs/chain-utils 0.0.67 → 0.0.73

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.
@@ -1 +1 @@
1
- {"version":3,"file":"addressParser.d.ts","sourceRoot":"","sources":["../src/addressParser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAUxF,OAAO,KAAK,EACR,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,2BAA2B,EAC3B,0BAA0B,EAC1B,YAAY,EACZ,aAAa,EACb,4BAA4B,EAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,KAAK,cAAc,CAAC,CAAC,SAAS,SAAS,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC;AAEnG,oBAAY,eAAe;IACvB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,MAAM,WAAW;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,GAAG,EAAE;QACD,eAAe,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,mBAAmB,CAAC;KACjE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,SAAS,IACrD,0BAA0B,CAAC,CAAC,CAAC,SAAS,MAAM,oBAAoB,GAC1D,oBAAoB,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,GACnD,EAAE,CAAC;AAEb,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,SAAS,IAAI;IAC7C,kBAAkB,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,kBAAkB,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AM,gBAAgB,GACzB,WAAW,gBAAgB,CAAC,SAAS,CAAC,KACvC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CA4D3C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,CAC/B,SAAS,EAAE,2BAA2B,CAAC,SAAS,CAAC,OAAO,CAAC,KACxD,aAAa,CAAC,2BAA2B,CAAC,SAAS,CAAC,OAAO,CAAC,CAqIhE,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAC9B,WAAW,gBAAgB,CAAC,SAAS,CAAC,KACvC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CA2B3C,CAAC"}
@@ -1,4 +1,4 @@
1
- export { AddressEncoding, addressParser, base58AddressParser, hexAddressParser, initiaAddressParser, tonAddressParser } from './MR2I35UU.js';
1
+ export { AddressEncoding, addressParser, base58AddressParser, hexAddressParser, initiaAddressParser, starknetAddressParser, stellarAddressParser, tonAddressParser } from './L4WCMHVM.js';
2
2
  import './YXE7PREU.js';
3
3
  //# sourceMappingURL=addressParser.js.map
4
4
  //# sourceMappingURL=addressParser.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var K6ILVJZQ_cjs = require('./K6ILVJZQ.cjs');
3
+ var QOTVRPBZ_cjs = require('./QOTVRPBZ.cjs');
4
4
  var J6P5K7DC_cjs = require('./J6P5K7DC.cjs');
5
5
  var bs58 = require('bs58');
6
6
  var tty = require('tty');
@@ -18025,7 +18025,7 @@ describe("addressParser - hex/EVM chains", () => {
18025
18025
  ];
18026
18026
  evmChains.forEach((chain) => {
18027
18027
  describe(chain, () => {
18028
- const parser = K6ILVJZQ_cjs.addressParser(chain);
18028
+ const parser = QOTVRPBZ_cjs.addressParser(chain);
18029
18029
  it("maintains roundtrip invariant: hex -> native -> hex", () => {
18030
18030
  runPropertyTest(() => {
18031
18031
  const input = randomHex(20);
@@ -18058,13 +18058,13 @@ describe("addressParser - hex/EVM chains", () => {
18058
18058
  runPropertyTest(() => {
18059
18059
  const byteLength = Math.floor(Math.random() * 32) + 1;
18060
18060
  const input = randomHex(byteLength);
18061
- const padded = K6ILVJZQ_cjs.addressParser.normalizedToBytes32Hex(input);
18061
+ const padded = QOTVRPBZ_cjs.addressParser.normalizedToBytes32Hex(input);
18062
18062
  globalExpect(padded.length).toBe(66);
18063
18063
  globalExpect(padded).toBe(commonUtils.hexZeroPad(input, 32));
18064
18064
  });
18065
18065
  });
18066
18066
  it("handles edge cases", () => {
18067
- const parser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18067
+ const parser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18068
18068
  const empty = commonChainModel.normalizeHex("0x");
18069
18069
  globalExpect(parser.normalizedToNative(empty).nativeAddress.length).toBe(42);
18070
18070
  const max = commonChainModel.normalizeHex("0x" + "ff".repeat(20));
@@ -18074,7 +18074,7 @@ describe("addressParser - hex/EVM chains", () => {
18074
18074
  });
18075
18075
  });
18076
18076
  describe("addressParser - base58 chains (Solana)", () => {
18077
- const parser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
18077
+ const parser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
18078
18078
  it("maintains roundtrip invariant: hex -> base58 -> hex", () => {
18079
18079
  runPropertyTest(() => {
18080
18080
  const byteLength = Math.floor(Math.random() * 32) + 1;
@@ -18117,15 +18117,15 @@ describe("addressParser - base58 chains (Solana)", () => {
18117
18117
  });
18118
18118
  describe("addressParser - chain validation", () => {
18119
18119
  it("validates chain names for nativeToBytes32Hex", () => {
18120
- const evmParser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18121
- const solanaParser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
18120
+ const evmParser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18121
+ const solanaParser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.SOLANA);
18122
18122
  const evmAddress = evmParser.normalizedToNative(randomHex(20));
18123
18123
  const solanaAddress = solanaParser.normalizedToNative(randomHex(32));
18124
18124
  globalExpect(() => solanaParser.nativeToBytes32Hex(evmAddress)).toThrow(/Cannot convert/);
18125
18125
  globalExpect(() => evmParser.nativeToBytes32Hex(solanaAddress)).toThrow(/Cannot convert/);
18126
18126
  });
18127
18127
  it("accepts string addresses without validation", () => {
18128
- const parser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18128
+ const parser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.ETHEREUM);
18129
18129
  const randomAddress = "0x" + "ab".repeat(20);
18130
18130
  const result = parser.nativeToNormalized(randomAddress);
18131
18131
  globalExpect(result).toBe(commonChainModel.normalizeHex(randomAddress));
@@ -18136,7 +18136,7 @@ describe("addressParser - chain validation", () => {
18136
18136
  });
18137
18137
  });
18138
18138
  describe("addressParser - TON", () => {
18139
- const parser = K6ILVJZQ_cjs.addressParser(layerzeroDefinitions.ChainName.TON);
18139
+ const parser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.TON);
18140
18140
  it("maintains roundtrip invariant: hex -> ton address -> hex", () => {
18141
18141
  runPropertyTest(() => {
18142
18142
  const byteLength = Math.floor(Math.random() * 32) + 1;
@@ -18196,6 +18196,273 @@ describe("addressParser - TON", () => {
18196
18196
  globalExpect(parser.validateNative("invalid-ton-address")).toBe(false);
18197
18197
  });
18198
18198
  });
18199
+ describe("addressParser - Stellar", () => {
18200
+ const parser = QOTVRPBZ_cjs.addressParser(layerzeroDefinitions.ChainName.STELLAR);
18201
+ const validTestAddresses = {
18202
+ // Account address (G...)
18203
+ account: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
18204
+ // Contract address (C...)
18205
+ contract: "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA",
18206
+ // Muxed address (M...)
18207
+ muxed: "MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAACJUQ",
18208
+ // Liquidity pool address (L...)
18209
+ liquidityPool: "LA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUPJN",
18210
+ // Claimable balance address (B...)
18211
+ claimableBalance: "BAAD6DBUX6J22DMZOHIEZTEQ64CVCHEDRKWZONFEUL5Q26QD7R76RGR4TU",
18212
+ // Signed payload (P...)
18213
+ signedPayload: "PA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAQACAQDAQCQMBYIBEFAWDANBYHRAEISCMKBKFQXDAMRUGY4DUPB6IBZGM"
18214
+ };
18215
+ describe("roundtrip conversions", () => {
18216
+ it("maintains roundtrip invariant for account addresses (G...)", () => {
18217
+ const stellarAddress = validTestAddresses.account;
18218
+ const normalized = parser.nativeToNormalized(stellarAddress);
18219
+ const native = parser.normalizedToNative(normalized);
18220
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18221
+ globalExpect(native.chainName).toBe(layerzeroDefinitions.ChainName.STELLAR);
18222
+ });
18223
+ it("maintains roundtrip invariant for contract addresses (C...)", () => {
18224
+ const stellarAddress = validTestAddresses.contract;
18225
+ const normalized = parser.nativeToNormalized(stellarAddress);
18226
+ const native = parser.normalizedToNative(normalized);
18227
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18228
+ });
18229
+ it("maintains roundtrip invariant for muxed addresses (M...)", () => {
18230
+ const stellarAddress = validTestAddresses.muxed;
18231
+ const normalized = parser.nativeToNormalized(stellarAddress);
18232
+ const native = parser.normalizedToNative(normalized);
18233
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18234
+ });
18235
+ it("maintains roundtrip invariant for liquidity pool addresses (L...)", () => {
18236
+ const stellarAddress = validTestAddresses.liquidityPool;
18237
+ const normalized = parser.nativeToNormalized(stellarAddress);
18238
+ const native = parser.normalizedToNative(normalized);
18239
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18240
+ });
18241
+ it("maintains roundtrip invariant for claimable balance addresses (B...)", () => {
18242
+ const stellarAddress = validTestAddresses.claimableBalance;
18243
+ const normalized = parser.nativeToNormalized(stellarAddress);
18244
+ const native = parser.normalizedToNative(normalized);
18245
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18246
+ });
18247
+ it("maintains roundtrip invariant for signed payload (P...)", () => {
18248
+ const stellarAddress = validTestAddresses.signedPayload;
18249
+ const normalized = parser.nativeToNormalized(stellarAddress);
18250
+ const native = parser.normalizedToNative(normalized);
18251
+ globalExpect(native.nativeAddress).toBe(stellarAddress);
18252
+ });
18253
+ });
18254
+ describe("validation", () => {
18255
+ it("validates all valid Stellar address types", () => {
18256
+ globalExpect(parser.validateNative(validTestAddresses.account)).toBe(true);
18257
+ globalExpect(parser.validateNative(validTestAddresses.contract)).toBe(true);
18258
+ globalExpect(parser.validateNative(validTestAddresses.muxed)).toBe(true);
18259
+ globalExpect(parser.validateNative(validTestAddresses.liquidityPool)).toBe(true);
18260
+ globalExpect(parser.validateNative(validTestAddresses.claimableBalance)).toBe(true);
18261
+ globalExpect(parser.validateNative(validTestAddresses.signedPayload)).toBe(true);
18262
+ });
18263
+ it("rejects invalid Stellar addresses", () => {
18264
+ const invalidAddresses = [
18265
+ "GAAAAAAAACGC6",
18266
+ "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZA",
18267
+ "G47QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVP2I",
18268
+ "invalid-stellar-address",
18269
+ "",
18270
+ "0x1234567890abcdef"
18271
+ ];
18272
+ invalidAddresses.forEach((addr) => {
18273
+ globalExpect(parser.validateNative(addr)).toBe(false);
18274
+ });
18275
+ });
18276
+ it("rejects undefined addresses", () => {
18277
+ globalExpect(parser.validateNative(void 0)).toBe(false);
18278
+ });
18279
+ });
18280
+ describe("ASCII encoding/decoding", () => {
18281
+ it("converts Stellar address to UTF-8 bytes correctly", () => {
18282
+ const stellarAddress = validTestAddresses.account;
18283
+ const bytes = parser.nativeToBytes(stellarAddress);
18284
+ const decoder = new TextDecoder();
18285
+ const decoded = decoder.decode(bytes);
18286
+ globalExpect(decoded).toBe(stellarAddress);
18287
+ });
18288
+ it("preserves address length in byte representation", () => {
18289
+ const accountBytes = parser.nativeToBytes(validTestAddresses.account);
18290
+ globalExpect(accountBytes.length).toBe(56);
18291
+ const muxedBytes = parser.nativeToBytes(validTestAddresses.muxed);
18292
+ globalExpect(muxedBytes.length).toBe(69);
18293
+ const payloadBytes = parser.nativeToBytes(validTestAddresses.signedPayload);
18294
+ globalExpect(payloadBytes.length).toBeGreaterThan(56);
18295
+ });
18296
+ it("normalizedToNativeString returns the address string", () => {
18297
+ const stellarAddress = validTestAddresses.account;
18298
+ const normalized = parser.nativeToNormalized(stellarAddress);
18299
+ const nativeString = parser.normalizedToNativeString(normalized);
18300
+ globalExpect(nativeString).toBe(stellarAddress);
18301
+ });
18302
+ });
18303
+ describe("parseNative", () => {
18304
+ it("parses valid Stellar addresses", () => {
18305
+ const stellarAddress = validTestAddresses.account;
18306
+ const normalized = parser.parseNative(stellarAddress);
18307
+ globalExpect(normalized).toMatch(/^0x[0-9a-f]+$/);
18308
+ });
18309
+ it("throws on invalid addresses", () => {
18310
+ globalExpect(() => parser.parseNative("invalid-stellar-address")).toThrow(/Cannot convert/);
18311
+ });
18312
+ it("parseNativeToUnpaddedHex returns hex string", () => {
18313
+ const stellarAddress = validTestAddresses.account;
18314
+ const hex3 = parser.parseNativeToUnpaddedHex(stellarAddress);
18315
+ globalExpect(hex3).toMatch(/^0x[0-9a-f]+$/);
18316
+ globalExpect(hex3).toBe(parser.parseNative(stellarAddress));
18317
+ });
18318
+ });
18319
+ describe("bytes32 operations", () => {
18320
+ it("decodes account address (G...) to 32 bytes", () => {
18321
+ const stellarAddress = validTestAddresses.account;
18322
+ const bytes32Hex = parser.nativeToBytes32Hex(stellarAddress);
18323
+ const bytes32 = parser.nativeToBytes32(stellarAddress);
18324
+ globalExpect(bytes32Hex.length).toBe(66);
18325
+ globalExpect(bytes32Hex).toMatch(/^0x[0-9a-f]{64}$/);
18326
+ globalExpect(bytes32.length).toBe(32);
18327
+ globalExpect(commonUtils.bytesToHexPrefixed(bytes32)).toBe(bytes32Hex);
18328
+ });
18329
+ it("decodes contract address (C...) to 32 bytes", () => {
18330
+ const stellarAddress = validTestAddresses.contract;
18331
+ const bytes32Hex = parser.nativeToBytes32Hex(stellarAddress);
18332
+ const bytes32 = parser.nativeToBytes32(stellarAddress);
18333
+ globalExpect(bytes32Hex.length).toBe(66);
18334
+ globalExpect(bytes32.length).toBe(32);
18335
+ globalExpect(commonUtils.bytesToHexPrefixed(bytes32)).toBe(bytes32Hex);
18336
+ });
18337
+ it("decodes liquidity pool address (L...) to 32 bytes", () => {
18338
+ const stellarAddress = validTestAddresses.liquidityPool;
18339
+ const bytes32Hex = parser.nativeToBytes32Hex(stellarAddress);
18340
+ const bytes32 = parser.nativeToBytes32(stellarAddress);
18341
+ globalExpect(bytes32Hex.length).toBe(66);
18342
+ globalExpect(bytes32.length).toBe(32);
18343
+ globalExpect(commonUtils.bytesToHexPrefixed(bytes32)).toBe(bytes32Hex);
18344
+ });
18345
+ it("decodes claimable balance address (B...) to 32 bytes (skipping version byte)", () => {
18346
+ const stellarAddress = validTestAddresses.claimableBalance;
18347
+ const bytes32Hex = parser.nativeToBytes32Hex(stellarAddress);
18348
+ const bytes32 = parser.nativeToBytes32(stellarAddress);
18349
+ globalExpect(bytes32Hex.length).toBe(66);
18350
+ globalExpect(bytes32Hex).toMatch(/^0x[0-9a-f]{64}$/);
18351
+ globalExpect(bytes32.length).toBe(32);
18352
+ globalExpect(commonUtils.bytesToHexPrefixed(bytes32)).toBe(bytes32Hex);
18353
+ });
18354
+ it("throws error for muxed address (M...) - not 32 bytes", () => {
18355
+ const stellarAddress = validTestAddresses.muxed;
18356
+ globalExpect(() => parser.nativeToBytes32Hex(stellarAddress)).toThrow(/nativeToBytes32 is not supported for Stellar muxed addresses/);
18357
+ globalExpect(() => parser.nativeToBytes32(stellarAddress)).toThrow(/nativeToBytes32 is not supported for Stellar muxed addresses/);
18358
+ });
18359
+ it("throws error for signed payload (P...) - variable length", () => {
18360
+ const stellarAddress = validTestAddresses.signedPayload;
18361
+ globalExpect(() => parser.nativeToBytes32Hex(stellarAddress)).toThrow(/nativeToBytes32 is not supported for Stellar signed payload addresses/);
18362
+ globalExpect(() => parser.nativeToBytes32(stellarAddress)).toThrow(/nativeToBytes32 is not supported for Stellar signed payload addresses/);
18363
+ });
18364
+ it("returns undefined for undefined input", () => {
18365
+ globalExpect(parser.nativeToBytes32Hex(void 0)).toBeUndefined();
18366
+ globalExpect(parser.nativeToBytes32(void 0)).toBeUndefined();
18367
+ });
18368
+ it("decodes all supported address types to 32 bytes", () => {
18369
+ const accountBytes = parser.nativeToBytes32(validTestAddresses.account);
18370
+ const contractBytes = parser.nativeToBytes32(validTestAddresses.contract);
18371
+ const poolBytes = parser.nativeToBytes32(validTestAddresses.liquidityPool);
18372
+ const balanceBytes = parser.nativeToBytes32(validTestAddresses.claimableBalance);
18373
+ globalExpect(accountBytes.length).toBe(32);
18374
+ globalExpect(contractBytes.length).toBe(32);
18375
+ globalExpect(poolBytes.length).toBe(32);
18376
+ globalExpect(balanceBytes.length).toBe(32);
18377
+ const accountHex = parser.nativeToBytes32Hex(validTestAddresses.account);
18378
+ const contractHex = parser.nativeToBytes32Hex(validTestAddresses.contract);
18379
+ const poolHex = parser.nativeToBytes32Hex(validTestAddresses.liquidityPool);
18380
+ const balanceHex = parser.nativeToBytes32Hex(validTestAddresses.claimableBalance);
18381
+ globalExpect(commonUtils.bytesToHexPrefixed(accountBytes)).toBe(accountHex);
18382
+ globalExpect(commonUtils.bytesToHexPrefixed(contractBytes)).toBe(contractHex);
18383
+ globalExpect(commonUtils.bytesToHexPrefixed(poolBytes)).toBe(poolHex);
18384
+ globalExpect(commonUtils.bytesToHexPrefixed(balanceBytes)).toBe(balanceHex);
18385
+ });
18386
+ it("handles ChainNativeAddress objects for bytes32 operations", () => {
18387
+ const nativeObj = {
18388
+ chainName: layerzeroDefinitions.ChainName.STELLAR,
18389
+ nativeAddress: validTestAddresses.account
18390
+ };
18391
+ const bytes32Hex = parser.nativeToBytes32Hex(nativeObj);
18392
+ const bytes32 = parser.nativeToBytes32(nativeObj);
18393
+ globalExpect(bytes32Hex.length).toBe(66);
18394
+ globalExpect(bytes32.length).toBe(32);
18395
+ });
18396
+ });
18397
+ describe("address type preservation", () => {
18398
+ it("preserves address type information through conversion", () => {
18399
+ const addresses = [
18400
+ {
18401
+ addr: validTestAddresses.account,
18402
+ prefix: "G"
18403
+ },
18404
+ {
18405
+ addr: validTestAddresses.contract,
18406
+ prefix: "C"
18407
+ },
18408
+ {
18409
+ addr: validTestAddresses.muxed,
18410
+ prefix: "M"
18411
+ },
18412
+ {
18413
+ addr: validTestAddresses.liquidityPool,
18414
+ prefix: "L"
18415
+ },
18416
+ {
18417
+ addr: validTestAddresses.claimableBalance,
18418
+ prefix: "B"
18419
+ },
18420
+ {
18421
+ addr: validTestAddresses.signedPayload,
18422
+ prefix: "P"
18423
+ }
18424
+ ];
18425
+ addresses.forEach(({ addr, prefix }) => {
18426
+ const normalized = parser.nativeToNormalized(addr);
18427
+ const recovered = parser.normalizedToNative(normalized);
18428
+ globalExpect(recovered.nativeAddress.startsWith(prefix)).toBe(true);
18429
+ globalExpect(recovered.nativeAddress).toBe(addr);
18430
+ });
18431
+ });
18432
+ });
18433
+ describe("edge cases", () => {
18434
+ it("handles ChainNativeAddress objects", () => {
18435
+ const nativeObj = {
18436
+ chainName: layerzeroDefinitions.ChainName.STELLAR,
18437
+ nativeAddress: validTestAddresses.account
18438
+ };
18439
+ const normalized = parser.nativeToNormalized(nativeObj);
18440
+ globalExpect(normalized).toMatch(/^0x[0-9a-f]+$/);
18441
+ });
18442
+ it("returns undefined for undefined inputs", () => {
18443
+ globalExpect(parser.normalizedToNative(void 0)).toBeUndefined();
18444
+ globalExpect(parser.normalizedToNativeString(void 0)).toBeUndefined();
18445
+ globalExpect(parser.nativeToNormalized(void 0)).toBeUndefined();
18446
+ globalExpect(parser.nativeToBytes(void 0)).toBeUndefined();
18447
+ });
18448
+ it("handles different address lengths correctly", () => {
18449
+ const short = validTestAddresses.account;
18450
+ const shortBytes = parser.nativeToBytes(short);
18451
+ globalExpect(shortBytes.length).toBe(56);
18452
+ const medium = validTestAddresses.muxed;
18453
+ const mediumBytes = parser.nativeToBytes(medium);
18454
+ globalExpect(mediumBytes.length).toBe(69);
18455
+ const long = validTestAddresses.signedPayload;
18456
+ const longBytes = parser.nativeToBytes(long);
18457
+ globalExpect(longBytes.length).toBeGreaterThan(69);
18458
+ });
18459
+ });
18460
+ describe("encoding type", () => {
18461
+ it("has STELLAR encoding type", () => {
18462
+ globalExpect(parser.encoding).toBe("stellar");
18463
+ });
18464
+ });
18465
+ });
18199
18466
  /*! Bundled license information:
18200
18467
 
18201
18468
  @vitest/pretty-format/dist/index.js: