@alephium/web3 3.0.0-test.2 → 3.0.0-test.4
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/MIGRATION.md +157 -0
- package/README.md +4 -0
- package/dist/_cjs/index.d.ts +11 -11
- package/dist/_cjs/index.js +11 -11
- package/dist/_cjs/index.js.map +1 -1
- package/dist/_cjs/utils/utils.d.ts +2 -1
- package/dist/_cjs/utils/utils.js +4 -8
- package/dist/_cjs/utils/utils.js.map +1 -1
- package/dist/_esm/index.d.ts +11 -11
- package/dist/_esm/index.js +11 -11
- package/dist/_esm/index.js.map +1 -1
- package/dist/_esm/utils/utils.d.ts +2 -1
- package/dist/_esm/utils/utils.js +2 -5
- package/dist/_esm/utils/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +11 -11
- package/src/utils/utils.ts +2 -6
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Migrating from v2 to v3
|
|
2
|
+
|
|
3
|
+
## Breaking Changes
|
|
4
|
+
|
|
5
|
+
### Node.js >= 20 required
|
|
6
|
+
|
|
7
|
+
The minimum Node.js version is now 20 (was 14). Node 18 is EOL since April 2025.
|
|
8
|
+
|
|
9
|
+
### Deep imports removed
|
|
10
|
+
|
|
11
|
+
Internal `dist/` paths are no longer accessible. Use the new sub-path exports:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// ❌ v2
|
|
15
|
+
import { FungibleTokenMetadata } from '@alephium/web3/dist/src/api/api-explorer'
|
|
16
|
+
import { Transaction } from '@alephium/web3/dist/src/api/api-alephium'
|
|
17
|
+
|
|
18
|
+
// ✅ v3
|
|
19
|
+
import { FungibleTokenMetadata } from '@alephium/web3/api/explorer'
|
|
20
|
+
import { Transaction } from '@alephium/web3/api/node'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
All types and functions from the main entry point (`import { ... } from '@alephium/web3'`) continue to work unchanged.
|
|
24
|
+
|
|
25
|
+
### `BigInt.prototype.toJSON` monkey-patch removed
|
|
26
|
+
|
|
27
|
+
v2 globally mutated `BigInt.prototype.toJSON` on import, so `JSON.stringify` could handle BigInt values. v3 removes this side effect.
|
|
28
|
+
|
|
29
|
+
If your code relies on `JSON.stringify` working with BigInt values, use the `stringify` utility exported from the SDK:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// ❌ v2 — worked because of the global monkey-patch
|
|
33
|
+
JSON.stringify({ amount: 1000n })
|
|
34
|
+
|
|
35
|
+
// ✅ v3 — use the stringify utility
|
|
36
|
+
import { stringify } from '@alephium/web3'
|
|
37
|
+
stringify({ amount: 1000n })
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`stringify` is a drop-in replacement for `JSON.stringify` that converts BigInt values to strings via a replacer function.
|
|
41
|
+
|
|
42
|
+
### `password-crypto` removed from `@alephium/web3-wallet`
|
|
43
|
+
|
|
44
|
+
The `encrypt` and `decrypt` functions have been removed. If you were using them, you can implement equivalent functionality using the Web Crypto API or a library like `@metamask/browser-passworder`.
|
|
45
|
+
|
|
46
|
+
### `publicKeyFromPrivateKey` accepts `Uint8Array`
|
|
47
|
+
|
|
48
|
+
The function now accepts `string | Uint8Array` for the private key parameter. This is backward compatible — existing string-based code continues to work. Passing `Uint8Array` allows secure memory cleanup after use.
|
|
49
|
+
|
|
50
|
+
### ESM output structure changed
|
|
51
|
+
|
|
52
|
+
The package now emits dual CJS/ESM output:
|
|
53
|
+
- CJS: `dist/_cjs/` (with `{"type": "commonjs"}`)
|
|
54
|
+
- ESM: `dist/_esm/` (with `{"type": "module"}`)
|
|
55
|
+
|
|
56
|
+
If you were referencing `dist/src/` paths directly, update to use the `exports` entry points or the new sub-path exports.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Dependencies Removed
|
|
61
|
+
|
|
62
|
+
These dependencies are no longer shipped with `@alephium/web3`. If your project depended on them being available transitively, you may need to install them directly:
|
|
63
|
+
|
|
64
|
+
| Removed | Replaced by |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `elliptic` | `@noble/secp256k1`, `@noble/curves` |
|
|
67
|
+
| `bn.js` | Native `BigInt` |
|
|
68
|
+
| `blakejs` | `@noble/hashes/blake2b` |
|
|
69
|
+
| `crypto-browserify` | `globalThis.crypto` (native in Node 20+, browsers) |
|
|
70
|
+
| `stream-browserify` | Removed (not needed) |
|
|
71
|
+
| `path-browserify` | Removed (not needed) |
|
|
72
|
+
| `cross-fetch` | Native `fetch` (Node 20+, browsers) |
|
|
73
|
+
|
|
74
|
+
For `@alephium/web3-wallet`:
|
|
75
|
+
|
|
76
|
+
| Removed | Replaced by |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `elliptic` | `@noble/secp256k1` |
|
|
79
|
+
| `bip32` | `@scure/bip32` |
|
|
80
|
+
| `bip39` | `@scure/bip39` |
|
|
81
|
+
| `buffer` | Not needed (Uint8Array throughout) |
|
|
82
|
+
| `fs-extra` | Removed (unused) |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Polyfill Plugins No Longer Needed
|
|
87
|
+
|
|
88
|
+
If your project uses `vite-plugin-node-polyfills`, `rollup-plugin-node-polyfills`, or similar plugins solely for `@alephium/web3`, you can remove them. The SDK no longer requires Node.js polyfills in browser environments.
|
|
89
|
+
|
|
90
|
+
```diff
|
|
91
|
+
// vite.config.ts
|
|
92
|
+
- import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
93
|
+
|
|
94
|
+
export default defineConfig({
|
|
95
|
+
- plugins: [nodePolyfills()],
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## React Native / Expo
|
|
102
|
+
|
|
103
|
+
### Simplified setup
|
|
104
|
+
|
|
105
|
+
v2 required up to 12 workarounds for React Native. v3 requires only 2 (plus pnpm-specific config):
|
|
106
|
+
|
|
107
|
+
**1. `react-native-get-random-values`**
|
|
108
|
+
|
|
109
|
+
Install and load before any `@alephium/web3` import:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
// Entry point (index.ts)
|
|
113
|
+
require('react-native-get-random-values')
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**2. Empty `fs` shim**
|
|
117
|
+
|
|
118
|
+
`contract.ts` contains a dynamic `import('fs')` that Metro resolves statically. Create an empty shim:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
// shims/fs.js
|
|
122
|
+
module.exports = {}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Add to `metro.config.js`:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
config.resolver.extraNodeModules = {
|
|
129
|
+
...config.resolver.extraNodeModules,
|
|
130
|
+
fs: path.resolve(__dirname, 'shims/fs.js')
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**pnpm users:** Add `node-linker=hoisted` to `.npmrc` (Metro is incompatible with pnpm's strict symlink layout).
|
|
135
|
+
|
|
136
|
+
### What you can remove
|
|
137
|
+
|
|
138
|
+
The following are no longer needed for `@alephium/web3` (they may still be needed by other dependencies):
|
|
139
|
+
|
|
140
|
+
- `buffer` / `Buffer` polyfill
|
|
141
|
+
- `crypto-browserify` / `react-native-quick-crypto` (for web3 — may still be needed by WalletConnect)
|
|
142
|
+
- `stream-browserify` / `readable-stream`
|
|
143
|
+
- `path-browserify`
|
|
144
|
+
- `events`
|
|
145
|
+
- `process`
|
|
146
|
+
- Custom Metro resolver for UMD bundle
|
|
147
|
+
- `expo-dev-client` (if only needed for `react-native-quick-crypto`)
|
|
148
|
+
|
|
149
|
+
**v3 works with Expo Go** — no dev build required for the Alephium SDK itself.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## TypeScript
|
|
154
|
+
|
|
155
|
+
The SDK is now built with TypeScript 5.9 and uses `moduleResolution: "bundler"` internally. Consumers using `moduleResolution: "node"` (the default) are supported via the `typesVersions` field — no changes needed on your side.
|
|
156
|
+
|
|
157
|
+
If you upgrade your own project to `moduleResolution: "bundler"`, the `exports` field in `package.json` will be used for type resolution, which is more accurate.
|
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The core package for building decentralized applications on Alephium.
|
|
4
4
|
|
|
5
|
+
## Migrating from v2
|
|
6
|
+
|
|
7
|
+
See [MIGRATION.md](MIGRATION.md) for a complete guide to upgrading from v2 to v3, including breaking changes, removed dependencies, and React Native setup.
|
|
8
|
+
|
|
5
9
|
## Build
|
|
6
10
|
|
|
7
11
|
This package uses a tsc dual-build to produce dual CJS/ESM output with proper type declarations. See the [monorepo README](../../README.md#build-system) for details on the build system, flags, and exports configuration.
|
package/dist/_cjs/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './contract';
|
|
3
|
-
export * from './signer';
|
|
4
|
-
export * from './utils';
|
|
5
|
-
export * from './transaction';
|
|
6
|
-
export * from './token';
|
|
1
|
+
export * from './api/index';
|
|
2
|
+
export * from './contract/index';
|
|
3
|
+
export * from './signer/index';
|
|
4
|
+
export * from './utils/index';
|
|
5
|
+
export * from './transaction/index';
|
|
6
|
+
export * from './token/index';
|
|
7
7
|
export * from './constants';
|
|
8
8
|
export * as web3 from './global';
|
|
9
|
-
export * as codec from './codec';
|
|
10
|
-
export * as utils from './utils';
|
|
9
|
+
export * as codec from './codec/index';
|
|
10
|
+
export * as utils from './utils/index';
|
|
11
11
|
export * from './debug';
|
|
12
|
-
export * from './block';
|
|
13
|
-
export * from './address';
|
|
14
|
-
export * from './exchange';
|
|
12
|
+
export * from './block/index';
|
|
13
|
+
export * from './address/index';
|
|
14
|
+
export * from './exchange/index';
|
|
15
15
|
export * from './error';
|
package/dist/_cjs/index.js
CHANGED
|
@@ -37,19 +37,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.utils = exports.codec = exports.web3 = void 0;
|
|
40
|
-
__exportStar(require("./api"), exports);
|
|
41
|
-
__exportStar(require("./contract"), exports);
|
|
42
|
-
__exportStar(require("./signer"), exports);
|
|
43
|
-
__exportStar(require("./utils"), exports);
|
|
44
|
-
__exportStar(require("./transaction"), exports);
|
|
45
|
-
__exportStar(require("./token"), exports);
|
|
40
|
+
__exportStar(require("./api/index"), exports);
|
|
41
|
+
__exportStar(require("./contract/index"), exports);
|
|
42
|
+
__exportStar(require("./signer/index"), exports);
|
|
43
|
+
__exportStar(require("./utils/index"), exports);
|
|
44
|
+
__exportStar(require("./transaction/index"), exports);
|
|
45
|
+
__exportStar(require("./token/index"), exports);
|
|
46
46
|
__exportStar(require("./constants"), exports);
|
|
47
47
|
exports.web3 = __importStar(require("./global"));
|
|
48
|
-
exports.codec = __importStar(require("./codec"));
|
|
49
|
-
exports.utils = __importStar(require("./utils"));
|
|
48
|
+
exports.codec = __importStar(require("./codec/index"));
|
|
49
|
+
exports.utils = __importStar(require("./utils/index"));
|
|
50
50
|
__exportStar(require("./debug"), exports);
|
|
51
|
-
__exportStar(require("./block"), exports);
|
|
52
|
-
__exportStar(require("./address"), exports);
|
|
53
|
-
__exportStar(require("./exchange"), exports);
|
|
51
|
+
__exportStar(require("./block/index"), exports);
|
|
52
|
+
__exportStar(require("./address/index"), exports);
|
|
53
|
+
__exportStar(require("./exchange/index"), exports);
|
|
54
54
|
__exportStar(require("./error"), exports);
|
|
55
55
|
//# sourceMappingURL=index.js.map
|
package/dist/_cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,8CAA2B;AAC3B,mDAAgC;AAChC,iDAA8B;AAC9B,gDAA6B;AAC7B,sDAAmC;AACnC,gDAA6B;AAE7B,8CAA2B;AAC3B,iDAAgC;AAChC,uDAAsC;AACtC,uDAAsC;AACtC,0CAAuB;AACvB,gDAA6B;AAC7B,kDAA+B;AAC/B,mDAAgC;AAChC,0CAAuB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
2
|
+
export declare const binToHex: typeof bytesToHex;
|
|
1
3
|
export declare const networkIds: readonly ["mainnet", "testnet", "devnet"];
|
|
2
4
|
export type NetworkId = (typeof networkIds)[number];
|
|
3
5
|
export type HexString = string;
|
|
@@ -13,7 +15,6 @@ export declare function signatureDecode(signature: string): {
|
|
|
13
15
|
export declare function isHexString(input: string): boolean;
|
|
14
16
|
export declare function toNonNegativeBigInt(input: string): bigint | undefined;
|
|
15
17
|
export declare function hexToBinUnsafe(hex: string): Uint8Array;
|
|
16
|
-
export declare function binToHex(bin: Uint8Array): string;
|
|
17
18
|
export declare function blockChainIndex(blockHash: HexString): {
|
|
18
19
|
fromGroup: number;
|
|
19
20
|
toGroup: number;
|
package/dist/_cjs/utils/utils.js
CHANGED
|
@@ -33,14 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.networkIds = void 0;
|
|
36
|
+
exports.networkIds = exports.binToHex = void 0;
|
|
37
37
|
exports.encodeSignature = encodeSignature;
|
|
38
38
|
exports.encodeHexSignature = encodeHexSignature;
|
|
39
39
|
exports.signatureDecode = signatureDecode;
|
|
40
40
|
exports.isHexString = isHexString;
|
|
41
41
|
exports.toNonNegativeBigInt = toNonNegativeBigInt;
|
|
42
42
|
exports.hexToBinUnsafe = hexToBinUnsafe;
|
|
43
|
-
exports.binToHex = binToHex;
|
|
44
43
|
exports.blockChainIndex = blockChainIndex;
|
|
45
44
|
exports.stringToHex = stringToHex;
|
|
46
45
|
exports.hexToString = hexToString;
|
|
@@ -52,7 +51,9 @@ exports.concatBytes = concatBytes;
|
|
|
52
51
|
exports.xorByte = xorByte;
|
|
53
52
|
exports.assertType = assertType;
|
|
54
53
|
const secp256k1 = __importStar(require("@noble/secp256k1"));
|
|
54
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
55
55
|
const constants_1 = require("../constants");
|
|
56
|
+
exports.binToHex = utils_1.bytesToHex;
|
|
56
57
|
exports.networkIds = ['mainnet', 'testnet', 'devnet'];
|
|
57
58
|
function encodeSignature(signature) {
|
|
58
59
|
const sig = new secp256k1.Signature(signature.r, signature.s).normalizeS();
|
|
@@ -92,11 +93,6 @@ function hexToBinUnsafe(hex) {
|
|
|
92
93
|
}
|
|
93
94
|
return new Uint8Array(bytes);
|
|
94
95
|
}
|
|
95
|
-
function binToHex(bin) {
|
|
96
|
-
return Array.from(bin)
|
|
97
|
-
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
98
|
-
.join('');
|
|
99
|
-
}
|
|
100
96
|
function blockChainIndex(blockHash) {
|
|
101
97
|
if (blockHash.length != 64) {
|
|
102
98
|
throw Error(`Invalid block hash: ${blockHash}`);
|
|
@@ -146,7 +142,7 @@ function difficultyToTarget(diff) {
|
|
|
146
142
|
mantissaBytes[1] = (mantissa >> 16) & 0xff;
|
|
147
143
|
mantissaBytes[2] = (mantissa >> 8) & 0xff;
|
|
148
144
|
mantissaBytes[3] = mantissa & 0xff;
|
|
149
|
-
return binToHex(mantissaBytes);
|
|
145
|
+
return (0, exports.binToHex)(mantissaBytes);
|
|
150
146
|
}
|
|
151
147
|
function concatBytes(arrays) {
|
|
152
148
|
const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":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IAC7B,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,CAAA;AAC/C,CAAC;AAKD,SAAgB,UAAU,KAA0B,CAAC"}
|
package/dist/_esm/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './contract';
|
|
3
|
-
export * from './signer';
|
|
4
|
-
export * from './utils';
|
|
5
|
-
export * from './transaction';
|
|
6
|
-
export * from './token';
|
|
1
|
+
export * from './api/index';
|
|
2
|
+
export * from './contract/index';
|
|
3
|
+
export * from './signer/index';
|
|
4
|
+
export * from './utils/index';
|
|
5
|
+
export * from './transaction/index';
|
|
6
|
+
export * from './token/index';
|
|
7
7
|
export * from './constants';
|
|
8
8
|
export * as web3 from './global';
|
|
9
|
-
export * as codec from './codec';
|
|
10
|
-
export * as utils from './utils';
|
|
9
|
+
export * as codec from './codec/index';
|
|
10
|
+
export * as utils from './utils/index';
|
|
11
11
|
export * from './debug';
|
|
12
|
-
export * from './block';
|
|
13
|
-
export * from './address';
|
|
14
|
-
export * from './exchange';
|
|
12
|
+
export * from './block/index';
|
|
13
|
+
export * from './address/index';
|
|
14
|
+
export * from './exchange/index';
|
|
15
15
|
export * from './error';
|
package/dist/_esm/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './contract';
|
|
3
|
-
export * from './signer';
|
|
4
|
-
export * from './utils';
|
|
5
|
-
export * from './transaction';
|
|
6
|
-
export * from './token';
|
|
1
|
+
export * from './api/index';
|
|
2
|
+
export * from './contract/index';
|
|
3
|
+
export * from './signer/index';
|
|
4
|
+
export * from './utils/index';
|
|
5
|
+
export * from './transaction/index';
|
|
6
|
+
export * from './token/index';
|
|
7
7
|
export * from './constants';
|
|
8
8
|
export * as web3 from './global';
|
|
9
|
-
export * as codec from './codec';
|
|
10
|
-
export * as utils from './utils';
|
|
9
|
+
export * as codec from './codec/index';
|
|
10
|
+
export * as utils from './utils/index';
|
|
11
11
|
export * from './debug';
|
|
12
|
-
export * from './block';
|
|
13
|
-
export * from './address';
|
|
14
|
-
export * from './exchange';
|
|
12
|
+
export * from './block/index';
|
|
13
|
+
export * from './address/index';
|
|
14
|
+
export * from './exchange/index';
|
|
15
15
|
export * from './error';
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
package/dist/_esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAkBA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAkBA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAE7B,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,IAAI,MAAM,UAAU,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
2
|
+
export declare const binToHex: typeof bytesToHex;
|
|
1
3
|
export declare const networkIds: readonly ["mainnet", "testnet", "devnet"];
|
|
2
4
|
export type NetworkId = (typeof networkIds)[number];
|
|
3
5
|
export type HexString = string;
|
|
@@ -13,7 +15,6 @@ export declare function signatureDecode(signature: string): {
|
|
|
13
15
|
export declare function isHexString(input: string): boolean;
|
|
14
16
|
export declare function toNonNegativeBigInt(input: string): bigint | undefined;
|
|
15
17
|
export declare function hexToBinUnsafe(hex: string): Uint8Array;
|
|
16
|
-
export declare function binToHex(bin: Uint8Array): string;
|
|
17
18
|
export declare function blockChainIndex(blockHash: HexString): {
|
|
18
19
|
fromGroup: number;
|
|
19
20
|
toGroup: number;
|
package/dist/_esm/utils/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as secp256k1 from '@noble/secp256k1';
|
|
2
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
2
3
|
import { TOTAL_NUMBER_OF_GROUPS, TOTAL_NUMBER_OF_CHAINS } from '../constants';
|
|
4
|
+
export const binToHex = bytesToHex;
|
|
3
5
|
export const networkIds = ['mainnet', 'testnet', 'devnet'];
|
|
4
6
|
export function encodeSignature(signature) {
|
|
5
7
|
const sig = new secp256k1.Signature(signature.r, signature.s).normalizeS();
|
|
@@ -39,11 +41,6 @@ export function hexToBinUnsafe(hex) {
|
|
|
39
41
|
}
|
|
40
42
|
return new Uint8Array(bytes);
|
|
41
43
|
}
|
|
42
|
-
export function binToHex(bin) {
|
|
43
|
-
return Array.from(bin)
|
|
44
|
-
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
45
|
-
.join('');
|
|
46
|
-
}
|
|
47
44
|
export function blockChainIndex(blockHash) {
|
|
48
45
|
if (blockHash.length != 64) {
|
|
49
46
|
throw Error(`Invalid block hash: ${blockHash}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAA;AAInE,MAAM,UAAU,eAAe,CAAC,SAAmC;IACjE,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,SAA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AAM,CAAC,CAAA;QACzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAA;IACxB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,MAAM,KAAK,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACrC,MAAM,KAAK,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACrC,MAAM,KAAK,GAAG,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;IACpC,MAAM,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAA;IAC7B,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,CAAA;AAC/C,CAAC;AAKD,MAAM,UAAU,UAAU,KAA0B,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,19 +16,19 @@ You should have received a copy of the GNU Lesser General Public License
|
|
|
16
16
|
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export * from './api'
|
|
20
|
-
export * from './contract'
|
|
21
|
-
export * from './signer'
|
|
22
|
-
export * from './utils'
|
|
23
|
-
export * from './transaction'
|
|
24
|
-
export * from './token'
|
|
19
|
+
export * from './api/index'
|
|
20
|
+
export * from './contract/index'
|
|
21
|
+
export * from './signer/index'
|
|
22
|
+
export * from './utils/index'
|
|
23
|
+
export * from './transaction/index'
|
|
24
|
+
export * from './token/index'
|
|
25
25
|
|
|
26
26
|
export * from './constants'
|
|
27
27
|
export * as web3 from './global'
|
|
28
|
-
export * as codec from './codec'
|
|
29
|
-
export * as utils from './utils'
|
|
28
|
+
export * as codec from './codec/index'
|
|
29
|
+
export * as utils from './utils/index'
|
|
30
30
|
export * from './debug'
|
|
31
|
-
export * from './block'
|
|
32
|
-
export * from './address'
|
|
33
|
-
export * from './exchange'
|
|
31
|
+
export * from './block/index'
|
|
32
|
+
export * from './address/index'
|
|
33
|
+
export * from './exchange/index'
|
|
34
34
|
export * from './error'
|
package/src/utils/utils.ts
CHANGED
|
@@ -17,8 +17,10 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import * as secp256k1 from '@noble/secp256k1'
|
|
20
|
+
import { bytesToHex } from '@noble/hashes/utils'
|
|
20
21
|
import { TOTAL_NUMBER_OF_GROUPS, TOTAL_NUMBER_OF_CHAINS } from '../constants'
|
|
21
22
|
|
|
23
|
+
export const binToHex = bytesToHex
|
|
22
24
|
export const networkIds = ['mainnet', 'testnet', 'devnet'] as const
|
|
23
25
|
export type NetworkId = (typeof networkIds)[number]
|
|
24
26
|
export type HexString = string
|
|
@@ -67,12 +69,6 @@ export function hexToBinUnsafe(hex: string): Uint8Array {
|
|
|
67
69
|
return new Uint8Array(bytes)
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
export function binToHex(bin: Uint8Array): string {
|
|
71
|
-
return Array.from(bin)
|
|
72
|
-
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
73
|
-
.join('')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
export function blockChainIndex(blockHash: HexString): { fromGroup: number; toGroup: number } {
|
|
77
73
|
if (blockHash.length != 64) {
|
|
78
74
|
throw Error(`Invalid block hash: ${blockHash}`)
|