@layerzerolabs/address-utils-ton 0.2.67 → 0.2.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/address-utils-ton",
3
- "version": "0.2.67",
3
+ "version": "0.2.69",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,23 +13,31 @@
13
13
  "main": "./dist/index.cjs",
14
14
  "module": "./dist/index.js",
15
15
  "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist/**/*"
18
+ ],
16
19
  "dependencies": {
17
20
  "@layerzerolabs/ton-sdk-tools": "3.0.167",
18
21
  "@ton/ton": "npm:@layerzerolabs/ton@15.1.0-rc.9",
19
22
  "bs58": "^5.0.0",
20
- "@layerzerolabs/common-chain-model": "0.2.67",
21
- "@layerzerolabs/common-encoding-utils": "0.2.67"
23
+ "@layerzerolabs/common-chain-model": "0.2.69",
24
+ "@layerzerolabs/common-encoding-utils": "0.2.69"
22
25
  },
23
26
  "devDependencies": {
24
27
  "tsup": "^8.4.0",
25
28
  "vitest": "^3.2.3",
26
- "@layerzerolabs/typescript-configuration": "0.2.67",
27
- "@layerzerolabs/tsup-configuration": "0.2.67"
29
+ "@layerzerolabs/typescript-configuration": "0.2.69",
30
+ "@layerzerolabs/tsup-configuration": "0.2.69"
28
31
  },
29
32
  "publishConfig": {
30
33
  "access": "public",
31
34
  "registry": "https://registry.npmjs.org/"
32
35
  },
36
+ "externalRepoConfig": {
37
+ "targets": [
38
+ "onesig-client"
39
+ ]
40
+ },
33
41
  "scripts": {
34
42
  "build": "tsup",
35
43
  "lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
@@ -1,19 +0,0 @@
1
-  WARN  Issue while reading "/home/runner/work/monorepo-internal/monorepo-internal/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
2
-
3
- > @layerzerolabs/address-utils-ton@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/ton/address-utils-ton
4
- > tsup
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.1
9
- CLI Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/ton/address-utils-ton/tsup.config.ts
10
- CLI Target: ES2023
11
- CLI Cleaning output folder
12
- CJS Build start
13
- ESM Build start
14
- CJS dist/index.cjs 3.42 KB
15
- CJS dist/index.cjs.map 7.22 KB
16
- CJS ⚡️ Build success in 189ms
17
- ESM dist/index.js 3.00 KB
18
- ESM dist/index.js.map 7.21 KB
19
- ESM ⚡️ Build success in 189ms
@@ -1,8 +0,0 @@
1
-
2
- > @layerzerolabs/address-utils-ton@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/ton/address-utils-ton
3
- > eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
4
-
5
- (node:68458) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1775770562286 is not specified and it doesn't parse as CommonJS.
6
- Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
7
- To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
8
- (Use `node --trace-warnings ...` to show where the warning was created)
@@ -1,16 +0,0 @@
1
-
2
- > @layerzerolabs/address-utils-ton@0.0.0 test /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/ton/address-utils-ton
3
- > vitest --run --pass-with-no-tests --typecheck
4
-
5
- Testing types with tsc and vue-tsc is an experimental feature.
6
- Breaking changes might not follow SemVer, please pin Vitest's version when using it.
7
-
8
-  RUN  v3.2.4 /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/ton/address-utils-ton
9
-
10
- No test files found, exiting with code 0
11
-
12
- include: **/*.{test,spec}.?(c|m)[jt]s?(x)
13
- 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.*
14
- typecheck include: **/*.{test,spec}-d.?(c|m)[jt]s?(x)
15
- typecheck 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.*
16
-
package/src/index.ts DELETED
@@ -1,105 +0,0 @@
1
- import { Address } from '@ton/ton';
2
- import base58 from 'bs58';
3
-
4
- import type { HexString } from '@layerzerolabs/common-chain-model';
5
- import { isBase58, isHexString, trim0x } from '@layerzerolabs/common-encoding-utils';
6
- import { bigintToSizedBuffer, bufferToBigInt } from '@layerzerolabs/ton-sdk-tools';
7
-
8
- export type AddressTypeLike = Address | string | bigint;
9
-
10
- const to32ByteBuffer = (
11
- value: bigint | number | string | Uint8Array,
12
- maxIntermediateBufferSize = 66,
13
- ): Buffer => {
14
- if (typeof value === 'string') {
15
- if (!isHexString(value)) {
16
- throw new Error('only hex string is supported');
17
- }
18
- let hex = trim0x(value);
19
- if (hex.length % 2 !== 0) {
20
- hex = '0' + hex;
21
- }
22
- value = bufferToBigInt(Buffer.from(hex, 'hex'));
23
- }
24
- if (value instanceof Uint8Array) {
25
- value = bufferToBigInt(Buffer.from(value));
26
- }
27
- const bf = bigintToSizedBuffer(BigInt(value), maxIntermediateBufferSize);
28
- // trim from the left, keep the right 32 bytes
29
- return bf.subarray(-32);
30
- };
31
-
32
- export const bigintToAddress = (value: bigint): Address => {
33
- const buf = to32ByteBuffer(value);
34
- return Address.parse(`0:${buf.toString('hex')}`);
35
- };
36
-
37
- export const parseTonAddress = (address: AddressTypeLike): Address => {
38
- if (address instanceof Address) {
39
- return address;
40
- }
41
-
42
- try {
43
- if (typeof address === 'bigint' || typeof address === 'number') {
44
- return bigintToAddress(BigInt(address));
45
- }
46
-
47
- if (address.startsWith('0x')) {
48
- // If it's a hex address format it to ton format
49
- return bigintToAddress(BigInt(address));
50
- }
51
-
52
- try {
53
- return Address.parse(address);
54
- } catch {
55
- //at this point, our address is either hex without a '0x', or base58
56
- const _isBase58 = isBase58(address);
57
- const _isHex = isHexString(address);
58
-
59
- //this includes the case where the address is both base58 and hex
60
- //but nearly every address generated this way is hex (only 1/(~5.5e12) are b58)
61
- if (_isHex) {
62
- return bigintToAddress(BigInt(`0x${address}`));
63
- }
64
-
65
- if (_isBase58) {
66
- return bigintToAddress(
67
- BigInt(`0x${Buffer.from(base58.decode(address)).toString('hex')}`),
68
- );
69
- }
70
-
71
- //this is the case where the address is invalid in any encoding
72
- throw new Error(`The address ${address} cannot be decoded as TON, hex, or base58`);
73
- }
74
- } catch (err: any) {
75
- console.error('Error parsing address', {
76
- address,
77
- error: err?.message ?? err,
78
- });
79
- throw err;
80
- }
81
- };
82
-
83
- const _addressToNotPaddedHex = (address: AddressTypeLike) => {
84
- return `0x${parseTonAddress(address).hash.toString('hex')}`;
85
- };
86
-
87
- export const addressToHex = (address: AddressTypeLike): HexString => {
88
- return `0x${to32ByteBuffer(_addressToNotPaddedHex(address)).toString('hex').toLowerCase()}`;
89
- };
90
-
91
- export const addressToBigInt = (address: AddressTypeLike) => {
92
- return BigInt(_addressToNotPaddedHex(address));
93
- };
94
-
95
- export const compareAddresses = (addressA: AddressTypeLike, addressB: AddressTypeLike) => {
96
- return parseTonAddress(addressA).equals(parseTonAddress(addressB));
97
- };
98
-
99
- /**
100
- * Since toString(2) does not include leading zeros, we can calculate the leading zeros by subtracting
101
- * the total length of address in binary from the total length of addresses in TON in bits (32 bytes * 8)
102
- */
103
- export const numberOfLeadingZeroBitsInAddress = (address: AddressTypeLike) => {
104
- return 32 * 8 - addressToBigInt(address).toString(2).length;
105
- };
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
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
- }
package/tsup.config.ts DELETED
@@ -1,8 +0,0 @@
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
- }));