@layerzerolabs/chain-utils 0.0.8

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.
@@ -0,0 +1,38 @@
1
+
2
+ > @layerzerolabs/chain-utils@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/chain-utils
3
+ > tsup
4
+
5
+ CLI Building entry: src/addresses.ts, src/index.ts, src/utils.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.4.0
8
+ CLI Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/chain-utils/tsup.config.ts
9
+ CLI Target: es2022
10
+ CLI Cleaning output folder
11
+ CJS Build start
12
+ ESM Build start
13
+ CJS dist/addresses.cjs 628.00 B
14
+ CJS dist/utils.cjs 296.00 B
15
+ CJS dist/223VIKVV.cjs 435.00 B
16
+ CJS dist/YJF4D23A.cjs 245.00 B
17
+ CJS dist/64O6QIFK.cjs 1.62 KB
18
+ CJS dist/index.cjs 802.00 B
19
+ CJS dist/addresses.cjs.map 74.00 B
20
+ CJS dist/utils.cjs.map 70.00 B
21
+ CJS dist/223VIKVV.cjs.map 624.00 B
22
+ CJS dist/YJF4D23A.cjs.map 73.00 B
23
+ CJS dist/64O6QIFK.cjs.map 2.70 KB
24
+ CJS dist/index.cjs.map 70.00 B
25
+ CJS ⚡️ Build success in 181ms
26
+ ESM dist/addresses.js 206.00 B
27
+ ESM dist/index.js 246.00 B
28
+ ESM dist/SY7CRNZB.js 1.28 KB
29
+ ESM dist/UXYWZBHJ.js 385.00 B
30
+ ESM dist/utils.js 139.00 B
31
+ ESM dist/VUOMXK5T.js 222.00 B
32
+ ESM dist/index.js.map 69.00 B
33
+ ESM dist/addresses.js.map 73.00 B
34
+ ESM dist/UXYWZBHJ.js.map 610.00 B
35
+ ESM dist/utils.js.map 69.00 B
36
+ ESM dist/VUOMXK5T.js.map 72.00 B
37
+ ESM dist/SY7CRNZB.js.map 2.68 KB
38
+ ESM ⚡️ Build success in 182ms
@@ -0,0 +1,4 @@
1
+
2
+ > @layerzerolabs/chain-utils@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/chain-utils
3
+ > eslint . --max-warnings 0
4
+
@@ -0,0 +1,12 @@
1
+
2
+ > @layerzerolabs/chain-utils@0.0.0 test /home/runner/work/monorepo-internal/monorepo-internal/packages/chain-utils
3
+ > vitest --run --pass-with-no-tests
4
+
5
+
6
+  RUN  v3.2.3 /home/runner/work/monorepo-internal/monorepo-internal/packages/chain-utils
7
+
8
+ No test files found, exiting with code 0
9
+
10
+ include: **/*.{test,spec}.?(c|m)[jt]s?(x)
11
+ exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
12
+
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var YJF4D23A_cjs = require('./YJF4D23A.cjs');
4
+
5
+ // src/utils.ts
6
+ var getNetworkName = /* @__PURE__ */ YJF4D23A_cjs.__name((chainName, environment) => {
7
+ return [
8
+ "localnet",
9
+ "sandbox"
10
+ ].includes(environment) ? `${chainName}-sandbox-local` : `${chainName}-${environment}`;
11
+ }, "getNetworkName");
12
+
13
+ exports.getNetworkName = getNetworkName;
14
+ //# sourceMappingURL=223VIKVV.cjs.map
15
+ //# sourceMappingURL=223VIKVV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.ts"],"names":["getNetworkName","__name","chainName","environment","includes"],"mappings":";;;;;AAAO,IAAMA,cAAAA,mBAAiBC,mBAAA,CAAA,CAACC,SAAAA,EAAmBC,WAAAA,KAAAA;AAC9C,EAAA,OAAO;AAAC,IAAA,UAAA;AAAY,IAAA;IAAWC,QAAAA,CAASD,WAAAA,IAClC,CAAA,EAAGD,SAAAA,mBACH,CAAA,EAAGA,SAAAA,IAAaC,WAAAA,CAAAA,CAAAA;AAC1B,CAAA,EAJ8B,gBAAA","file":"223VIKVV.cjs","sourcesContent":["export const getNetworkName = (chainName: string, environment: string) => {\n return ['localnet', 'sandbox'].includes(environment)\n ? `${chainName}-sandbox-local`\n : `${chainName}-${environment}`;\n};\n"]}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var YJF4D23A_cjs = require('./YJF4D23A.cjs');
4
+ var utils = require('@noble/hashes/utils');
5
+ var base58 = require('bs58');
6
+ var viem = require('viem');
7
+ var commonUtils = require('@layerzerolabs/common-utils');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var base58__default = /*#__PURE__*/_interopDefault(base58);
12
+
13
+ function formatTxHashByEncoding(txHash) {
14
+ if (commonUtils.isHexString(txHash)) {
15
+ return txHash.toLowerCase();
16
+ }
17
+ if (commonUtils.isBase58(txHash)) {
18
+ return txHash;
19
+ }
20
+ if (commonUtils.isBase64(txHash)) {
21
+ return txHash;
22
+ }
23
+ throw "Unknown encoding";
24
+ }
25
+ YJF4D23A_cjs.__name(formatTxHashByEncoding, "formatTxHashByEncoding");
26
+ function getAddressAsBytes32HexString(address) {
27
+ if (commonUtils.isHexString(address)) {
28
+ return viem.pad(commonUtils.ensure0xPrefixed(address), {
29
+ size: 32
30
+ });
31
+ }
32
+ if (commonUtils.isBase58(address)) {
33
+ const bytes = base58__default.default.decode(address);
34
+ return commonUtils.bytesToHexPrefixed(bytes);
35
+ }
36
+ throw new Error(`Invalid input for address ${address}`);
37
+ }
38
+ YJF4D23A_cjs.__name(getAddressAsBytes32HexString, "getAddressAsBytes32HexString");
39
+ function getAddressAsBytes32(address) {
40
+ const bytes32Hex = getAddressAsBytes32HexString(address);
41
+ return utils.hexToBytes(commonUtils.trim0x(bytes32Hex));
42
+ }
43
+ YJF4D23A_cjs.__name(getAddressAsBytes32, "getAddressAsBytes32");
44
+
45
+ exports.formatTxHashByEncoding = formatTxHashByEncoding;
46
+ exports.getAddressAsBytes32 = getAddressAsBytes32;
47
+ exports.getAddressAsBytes32HexString = getAddressAsBytes32HexString;
48
+ //# sourceMappingURL=64O6QIFK.cjs.map
49
+ //# sourceMappingURL=64O6QIFK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/addresses.ts"],"names":["formatTxHashByEncoding","txHash","isHexString","toLowerCase","isBase58","isBase64","getAddressAsBytes32HexString","address","pad","ensure0xPrefixed","size","bytes","base58","decode","bytesToHexPrefixed","Error","getAddressAsBytes32","bytes32Hex","hexToBytes","trim0x"],"mappings":";;;;;;;;;;;;AAcO,SAASA,uBAAuBC,MAAAA,EAAc;AACjD,EAAA,IAAIC,uBAAAA,CAAYD,MAAAA,CAAAA,EAAS;AACrB,IAAA,OAAOA,OAAOE,WAAAA,EAAW;AAC7B,EAAA;AACA,EAAA,IAAIC,oBAAAA,CAASH,MAAAA,CAAAA,EAAS;AAClB,IAAA,OAAOA,MAAAA;AACX,EAAA;AACA,EAAA,IAAII,oBAAAA,CAASJ,MAAAA,CAAAA,EAAS;AAClB,IAAA,OAAOA,MAAAA;AACX,EAAA;AACA,EAAA,MAAM,kBAAA;AACV;AAXgBD,mBAAAA,CAAAA,sBAAAA,EAAAA,wBAAAA,CAAAA;AAaT,SAASM,6BAA6BC,OAAAA,EAAe;AACxD,EAAA,IAAIL,uBAAAA,CAAYK,OAAAA,CAAAA,EAAU;AACtB,IAAA,OAAOC,QAAAA,CAAIC,4BAAAA,CAAiBF,OAAAA,CAAAA,EAAU;MAAEG,IAAAA,EAAM;KAAG,CAAA;AACrD,EAAA;AACA,EAAA,IAAIN,oBAAAA,CAASG,OAAAA,CAAAA,EAAU;AACnB,IAAA,MAAMI,KAAAA,GAAQC,uBAAAA,CAAOC,MAAAA,CAAON,OAAAA,CAAAA;AAC5B,IAAA,OAAOO,+BAAmBH,KAAAA,CAAAA;AAC9B,EAAA;AACA,EAAA,MAAM,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BR,OAAAA,CAAAA,CAAS,CAAA;AAC1D;AATgBD,mBAAAA,CAAAA,4BAAAA,EAAAA,8BAAAA,CAAAA;AAgBT,SAASU,oBAAoBT,OAAAA,EAAe;AAC/C,EAAA,MAAMU,UAAAA,GAAaX,6BAA6BC,OAAAA,CAAAA;AAChD,EAAA,OAAOW,gBAAAA,CAAWC,kBAAAA,CAAOF,UAAAA,CAAAA,CAAAA;AAC7B;AAHgBD,mBAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"64O6QIFK.cjs","sourcesContent":["import { hexToBytes } from '@noble/hashes/utils';\nimport base58 from 'bs58';\nimport { pad } from 'viem';\n\nimport type { HexAddress } from '@layerzerolabs/common-chain-model';\nimport {\n bytesToHexPrefixed,\n ensure0xPrefixed,\n isBase58,\n isBase64,\n isHexString,\n trim0x,\n} from '@layerzerolabs/common-utils';\n\nexport function formatTxHashByEncoding(txHash: string): string {\n if (isHexString(txHash)) {\n return txHash.toLowerCase();\n }\n if (isBase58(txHash)) {\n return txHash;\n }\n if (isBase64(txHash)) {\n return txHash;\n }\n throw 'Unknown encoding';\n}\n\nexport function getAddressAsBytes32HexString(address: string): HexAddress {\n if (isHexString(address)) {\n return pad(ensure0xPrefixed(address), { size: 32 });\n }\n if (isBase58(address)) {\n const bytes = base58.decode(address);\n return bytesToHexPrefixed(bytes);\n }\n throw new Error(`Invalid input for address ${address}`);\n}\n\n/**\n * Return a Uint8Array of the address that covers our supported encoding types\n * - Currently supports base58 and hex (0x prefixed 20-32 bytes)\n * @param address\n */\nexport function getAddressAsBytes32(address: string): Uint8Array {\n const bytes32Hex = getAddressAsBytes32HexString(address);\n return hexToBytes(trim0x(bytes32Hex));\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { __name } from './VUOMXK5T.js';
2
+ import { hexToBytes } from '@noble/hashes/utils';
3
+ import base58 from 'bs58';
4
+ import { pad } from 'viem';
5
+ import { isHexString, isBase58, isBase64, ensure0xPrefixed, bytesToHexPrefixed, trim0x } from '@layerzerolabs/common-utils';
6
+
7
+ function formatTxHashByEncoding(txHash) {
8
+ if (isHexString(txHash)) {
9
+ return txHash.toLowerCase();
10
+ }
11
+ if (isBase58(txHash)) {
12
+ return txHash;
13
+ }
14
+ if (isBase64(txHash)) {
15
+ return txHash;
16
+ }
17
+ throw "Unknown encoding";
18
+ }
19
+ __name(formatTxHashByEncoding, "formatTxHashByEncoding");
20
+ function getAddressAsBytes32HexString(address) {
21
+ if (isHexString(address)) {
22
+ return pad(ensure0xPrefixed(address), {
23
+ size: 32
24
+ });
25
+ }
26
+ if (isBase58(address)) {
27
+ const bytes = base58.decode(address);
28
+ return bytesToHexPrefixed(bytes);
29
+ }
30
+ throw new Error(`Invalid input for address ${address}`);
31
+ }
32
+ __name(getAddressAsBytes32HexString, "getAddressAsBytes32HexString");
33
+ function getAddressAsBytes32(address) {
34
+ const bytes32Hex = getAddressAsBytes32HexString(address);
35
+ return hexToBytes(trim0x(bytes32Hex));
36
+ }
37
+ __name(getAddressAsBytes32, "getAddressAsBytes32");
38
+
39
+ export { formatTxHashByEncoding, getAddressAsBytes32, getAddressAsBytes32HexString };
40
+ //# sourceMappingURL=SY7CRNZB.js.map
41
+ //# sourceMappingURL=SY7CRNZB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/addresses.ts"],"names":["formatTxHashByEncoding","txHash","isHexString","toLowerCase","isBase58","isBase64","getAddressAsBytes32HexString","address","pad","ensure0xPrefixed","size","bytes","base58","decode","bytesToHexPrefixed","Error","getAddressAsBytes32","bytes32Hex","hexToBytes","trim0x"],"mappings":";;;;;;AAcO,SAASA,uBAAuBC,MAAAA,EAAc;AACjD,EAAA,IAAIC,WAAAA,CAAYD,MAAAA,CAAAA,EAAS;AACrB,IAAA,OAAOA,OAAOE,WAAAA,EAAW;AAC7B,EAAA;AACA,EAAA,IAAIC,QAAAA,CAASH,MAAAA,CAAAA,EAAS;AAClB,IAAA,OAAOA,MAAAA;AACX,EAAA;AACA,EAAA,IAAII,QAAAA,CAASJ,MAAAA,CAAAA,EAAS;AAClB,IAAA,OAAOA,MAAAA;AACX,EAAA;AACA,EAAA,MAAM,kBAAA;AACV;AAXgBD,MAAAA,CAAAA,sBAAAA,EAAAA,wBAAAA,CAAAA;AAaT,SAASM,6BAA6BC,OAAAA,EAAe;AACxD,EAAA,IAAIL,WAAAA,CAAYK,OAAAA,CAAAA,EAAU;AACtB,IAAA,OAAOC,GAAAA,CAAIC,gBAAAA,CAAiBF,OAAAA,CAAAA,EAAU;MAAEG,IAAAA,EAAM;KAAG,CAAA;AACrD,EAAA;AACA,EAAA,IAAIN,QAAAA,CAASG,OAAAA,CAAAA,EAAU;AACnB,IAAA,MAAMI,KAAAA,GAAQC,MAAAA,CAAOC,MAAAA,CAAON,OAAAA,CAAAA;AAC5B,IAAA,OAAOO,mBAAmBH,KAAAA,CAAAA;AAC9B,EAAA;AACA,EAAA,MAAM,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BR,OAAAA,CAAAA,CAAS,CAAA;AAC1D;AATgBD,MAAAA,CAAAA,4BAAAA,EAAAA,8BAAAA,CAAAA;AAgBT,SAASU,oBAAoBT,OAAAA,EAAe;AAC/C,EAAA,MAAMU,UAAAA,GAAaX,6BAA6BC,OAAAA,CAAAA;AAChD,EAAA,OAAOW,UAAAA,CAAWC,MAAAA,CAAOF,UAAAA,CAAAA,CAAAA;AAC7B;AAHgBD,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"SY7CRNZB.js","sourcesContent":["import { hexToBytes } from '@noble/hashes/utils';\nimport base58 from 'bs58';\nimport { pad } from 'viem';\n\nimport type { HexAddress } from '@layerzerolabs/common-chain-model';\nimport {\n bytesToHexPrefixed,\n ensure0xPrefixed,\n isBase58,\n isBase64,\n isHexString,\n trim0x,\n} from '@layerzerolabs/common-utils';\n\nexport function formatTxHashByEncoding(txHash: string): string {\n if (isHexString(txHash)) {\n return txHash.toLowerCase();\n }\n if (isBase58(txHash)) {\n return txHash;\n }\n if (isBase64(txHash)) {\n return txHash;\n }\n throw 'Unknown encoding';\n}\n\nexport function getAddressAsBytes32HexString(address: string): HexAddress {\n if (isHexString(address)) {\n return pad(ensure0xPrefixed(address), { size: 32 });\n }\n if (isBase58(address)) {\n const bytes = base58.decode(address);\n return bytesToHexPrefixed(bytes);\n }\n throw new Error(`Invalid input for address ${address}`);\n}\n\n/**\n * Return a Uint8Array of the address that covers our supported encoding types\n * - Currently supports base58 and hex (0x prefixed 20-32 bytes)\n * @param address\n */\nexport function getAddressAsBytes32(address: string): Uint8Array {\n const bytes32Hex = getAddressAsBytes32HexString(address);\n return hexToBytes(trim0x(bytes32Hex));\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { __name } from './VUOMXK5T.js';
2
+
3
+ // src/utils.ts
4
+ var getNetworkName = /* @__PURE__ */ __name((chainName, environment) => {
5
+ return [
6
+ "localnet",
7
+ "sandbox"
8
+ ].includes(environment) ? `${chainName}-sandbox-local` : `${chainName}-${environment}`;
9
+ }, "getNetworkName");
10
+
11
+ export { getNetworkName };
12
+ //# sourceMappingURL=UXYWZBHJ.js.map
13
+ //# sourceMappingURL=UXYWZBHJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.ts"],"names":["getNetworkName","chainName","environment","includes"],"mappings":";;;AAAO,IAAMA,cAAAA,mBAAiB,MAAA,CAAA,CAACC,SAAAA,EAAmBC,WAAAA,KAAAA;AAC9C,EAAA,OAAO;AAAC,IAAA,UAAA;AAAY,IAAA;IAAWC,QAAAA,CAASD,WAAAA,IAClC,CAAA,EAAGD,SAAAA,mBACH,CAAA,EAAGA,SAAAA,IAAaC,WAAAA,CAAAA,CAAAA;AAC1B,CAAA,EAJ8B,gBAAA","file":"UXYWZBHJ.js","sourcesContent":["export const getNetworkName = (chainName: string, environment: string) => {\n return ['localnet', 'sandbox'].includes(environment)\n ? `${chainName}-sandbox-local`\n : `${chainName}-${environment}`;\n};\n"]}
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ export { __name };
5
+ //# sourceMappingURL=VUOMXK5T.js.map
6
+ //# sourceMappingURL=VUOMXK5T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"VUOMXK5T.js"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ exports.__name = __name;
7
+ //# sourceMappingURL=YJF4D23A.cjs.map
8
+ //# sourceMappingURL=YJF4D23A.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"YJF4D23A.cjs"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var _64O6QIFK_cjs = require('./64O6QIFK.cjs');
4
+ require('./YJF4D23A.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "formatTxHashByEncoding", {
9
+ enumerable: true,
10
+ get: function () { return _64O6QIFK_cjs.formatTxHashByEncoding; }
11
+ });
12
+ Object.defineProperty(exports, "getAddressAsBytes32", {
13
+ enumerable: true,
14
+ get: function () { return _64O6QIFK_cjs.getAddressAsBytes32; }
15
+ });
16
+ Object.defineProperty(exports, "getAddressAsBytes32HexString", {
17
+ enumerable: true,
18
+ get: function () { return _64O6QIFK_cjs.getAddressAsBytes32HexString; }
19
+ });
20
+ //# sourceMappingURL=addresses.cjs.map
21
+ //# sourceMappingURL=addresses.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"addresses.cjs"}
@@ -0,0 +1,10 @@
1
+ import type { HexAddress } from '@layerzerolabs/common-chain-model';
2
+ export declare function formatTxHashByEncoding(txHash: string): string;
3
+ export declare function getAddressAsBytes32HexString(address: string): HexAddress;
4
+ /**
5
+ * Return a Uint8Array of the address that covers our supported encoding types
6
+ * - Currently supports base58 and hex (0x prefixed 20-32 bytes)
7
+ * @param address
8
+ */
9
+ export declare function getAddressAsBytes32(address: string): Uint8Array;
10
+ //# sourceMappingURL=addresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAUpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CASxE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAG/D"}
@@ -0,0 +1,4 @@
1
+ export { formatTxHashByEncoding, getAddressAsBytes32, getAddressAsBytes32HexString } from './SY7CRNZB.js';
2
+ import './VUOMXK5T.js';
3
+ //# sourceMappingURL=addresses.js.map
4
+ //# sourceMappingURL=addresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"addresses.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var _64O6QIFK_cjs = require('./64O6QIFK.cjs');
4
+ var _223VIKVV_cjs = require('./223VIKVV.cjs');
5
+ require('./YJF4D23A.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "formatTxHashByEncoding", {
10
+ enumerable: true,
11
+ get: function () { return _64O6QIFK_cjs.formatTxHashByEncoding; }
12
+ });
13
+ Object.defineProperty(exports, "getAddressAsBytes32", {
14
+ enumerable: true,
15
+ get: function () { return _64O6QIFK_cjs.getAddressAsBytes32; }
16
+ });
17
+ Object.defineProperty(exports, "getAddressAsBytes32HexString", {
18
+ enumerable: true,
19
+ get: function () { return _64O6QIFK_cjs.getAddressAsBytes32HexString; }
20
+ });
21
+ Object.defineProperty(exports, "getNetworkName", {
22
+ enumerable: true,
23
+ get: function () { return _223VIKVV_cjs.getNetworkName; }
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
26
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,3 @@
1
+ export * from './addresses';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { formatTxHashByEncoding, getAddressAsBytes32, getAddressAsBytes32HexString } from './SY7CRNZB.js';
2
+ export { getNetworkName } from './UXYWZBHJ.js';
3
+ import './VUOMXK5T.js';
4
+ //# sourceMappingURL=index.js.map
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/dist/utils.cjs ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var _223VIKVV_cjs = require('./223VIKVV.cjs');
4
+ require('./YJF4D23A.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "getNetworkName", {
9
+ enumerable: true,
10
+ get: function () { return _223VIKVV_cjs.getNetworkName; }
11
+ });
12
+ //# sourceMappingURL=utils.cjs.map
13
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"utils.cjs"}
@@ -0,0 +1,2 @@
1
+ export declare const getNetworkName: (chainName: string, environment: string) => string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,EAAE,aAAa,MAAM,WAIpE,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,4 @@
1
+ export { getNetworkName } from './UXYWZBHJ.js';
2
+ import './VUOMXK5T.js';
3
+ //# sourceMappingURL=utils.js.map
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@layerzerolabs/chain-utils",
3
+ "version": "0.0.8",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ "types": "./dist/index.d.ts",
9
+ "require": "./dist/index.cjs",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.cjs"
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "dependencies": {
17
+ "@noble/hashes": "^1.1.5",
18
+ "bs58": "^5.0.0",
19
+ "viem": "2.28.0",
20
+ "@layerzerolabs/common-chain-model": "0.0.8",
21
+ "@layerzerolabs/common-utils": "0.0.8"
22
+ },
23
+ "devDependencies": {
24
+ "tsup": "^8.4.0",
25
+ "vitest": "^3.2.3",
26
+ "@layerzerolabs/tsup-configuration": "0.0.8",
27
+ "@layerzerolabs/typescript-configuration": "0.0.8"
28
+ },
29
+ "publishConfig": {
30
+ "access": "restricted",
31
+ "registry": "https://registry.npmjs.org/"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "clean": "rm -rf ./node_modules .turbo ./dist",
36
+ "dev": "tsup --watch",
37
+ "lint": "eslint . --max-warnings 0",
38
+ "lint:fix": "eslint . --fix --max-warnings 0",
39
+ "test": "vitest --run --pass-with-no-tests"
40
+ }
41
+ }
@@ -0,0 +1,47 @@
1
+ import { hexToBytes } from '@noble/hashes/utils';
2
+ import base58 from 'bs58';
3
+ import { pad } from 'viem';
4
+
5
+ import type { HexAddress } from '@layerzerolabs/common-chain-model';
6
+ import {
7
+ bytesToHexPrefixed,
8
+ ensure0xPrefixed,
9
+ isBase58,
10
+ isBase64,
11
+ isHexString,
12
+ trim0x,
13
+ } from '@layerzerolabs/common-utils';
14
+
15
+ export function formatTxHashByEncoding(txHash: string): string {
16
+ if (isHexString(txHash)) {
17
+ return txHash.toLowerCase();
18
+ }
19
+ if (isBase58(txHash)) {
20
+ return txHash;
21
+ }
22
+ if (isBase64(txHash)) {
23
+ return txHash;
24
+ }
25
+ throw 'Unknown encoding';
26
+ }
27
+
28
+ export function getAddressAsBytes32HexString(address: string): HexAddress {
29
+ if (isHexString(address)) {
30
+ return pad(ensure0xPrefixed(address), { size: 32 });
31
+ }
32
+ if (isBase58(address)) {
33
+ const bytes = base58.decode(address);
34
+ return bytesToHexPrefixed(bytes);
35
+ }
36
+ throw new Error(`Invalid input for address ${address}`);
37
+ }
38
+
39
+ /**
40
+ * Return a Uint8Array of the address that covers our supported encoding types
41
+ * - Currently supports base58 and hex (0x prefixed 20-32 bytes)
42
+ * @param address
43
+ */
44
+ export function getAddressAsBytes32(address: string): Uint8Array {
45
+ const bytes32Hex = getAddressAsBytes32HexString(address);
46
+ return hexToBytes(trim0x(bytes32Hex));
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './addresses';
2
+ export * from './utils';
package/src/utils.ts ADDED
@@ -0,0 +1,5 @@
1
+ export const getNetworkName = (chainName: string, environment: string) => {
2
+ return ['localnet', 'sandbox'].includes(environment)
3
+ ? `${chainName}-sandbox-local`
4
+ : `${chainName}-${environment}`;
5
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": "@layerzerolabs/typescript-configuration/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "strictPropertyInitialization": false,
7
+ "noUnusedLocals": false,
8
+ "noUnusedParameters": false,
9
+ "jsx": "react-jsx"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "**/__mocks__/*",
14
+ "**/__tests__/*",
15
+ "**/*.spec.ts",
16
+ "**/*.test.ts",
17
+ "dist"
18
+ ],
19
+ "include": ["src/**/*"],
20
+ "ts-node": {
21
+ "files": true,
22
+ "experimentalResolverFeatures": true,
23
+ "compilerOptions": {
24
+ "module": "CommonJS",
25
+ "types": ["node"]
26
+ }
27
+ }
28
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ import { createPackageTsupConfig } from '@layerzerolabs/tsup-configuration';
4
+
5
+ export default defineConfig(({ watch }) => ({
6
+ ...createPackageTsupConfig(),
7
+ clean: !watch,
8
+ }));