@layerzerolabs/lz-core 2.3.43 → 2.3.45-initia-oft.5
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/CHANGELOG.md +408 -0
- package/dist/index.cjs +0 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +8 -40
- package/dist/index.d.ts +8 -40
- package/dist/index.mjs +1 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# @layerzerolabs/lz-core
|
|
2
|
+
|
|
3
|
+
## 2.3.45-initia-oft.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Build Initia,aptos,movement,bsc snapshot images with newest images
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.5
|
|
10
|
+
|
|
11
|
+
## 2.3.45-initia-oft.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Build initia images with newest contracts
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.4
|
|
18
|
+
|
|
19
|
+
## 2.3.45-initia-oft.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Fix Aptos OFT SDK to fit newest contracts
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.3
|
|
26
|
+
|
|
27
|
+
## 2.3.45-initia-oft.2
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Fix bug in Initia OFT sdk
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.2
|
|
34
|
+
|
|
35
|
+
## 2.3.45-initia-oft.1
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Build new initia images with newest contracts
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.1
|
|
42
|
+
|
|
43
|
+
## 2.3.45-initia-oft.0
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Build new initia images with testnet deployments
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
- @layerzerolabs/lz-foundation@2.3.45-initia-oft.0
|
|
50
|
+
|
|
51
|
+
## 2.3.44
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- aded88c: Fix issue with workspace:^ protocol in package.json for packages version 2.3.43.
|
|
56
|
+
|
|
57
|
+
## 2.3.43
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- eced6b4: mainnet: Hedera, testnet: bevm
|
|
62
|
+
|
|
63
|
+
## 2.3.42
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 515ca0a: mainnets: Bitlayer, DM2Verse. testnets: morph, ozean
|
|
68
|
+
|
|
69
|
+
## 2.3.41
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- b01c51c: mainnet: Reya
|
|
74
|
+
|
|
75
|
+
## 2.3.40
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- c631c6e: mainnet: Ape chain endpoint
|
|
80
|
+
|
|
81
|
+
## 2.3.39
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- 01a6cb7: testnets: bitlayer, dm2verse, story
|
|
86
|
+
|
|
87
|
+
## 2.3.38
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- 5ddfb3b: remove `OFT_DEFAULT_PROGRAM_ID` from soalan sdk
|
|
92
|
+
|
|
93
|
+
## 2.3.37
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 883c143: mainnet endpoints: Lyra, Codex, testnets: root redeploy, reya
|
|
98
|
+
|
|
99
|
+
## 2.3.36
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- 291ef75: fix solana sdk
|
|
104
|
+
|
|
105
|
+
## 2.3.35
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- 9913f53: new endpoints
|
|
110
|
+
- 21a267f: testnets: otherworld, abstract, root
|
|
111
|
+
|
|
112
|
+
## 2.3.35-aptos.0
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- 7744b25: Add Aptos v1 support in testify, all tests passed.
|
|
117
|
+
|
|
118
|
+
## 2.3.34
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 5a99681: Fix an issue in Solana
|
|
123
|
+
|
|
124
|
+
## 2.3.33
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- d9c0c10: testnets: new solana devnet, codex(evm), bahamut (evm)
|
|
129
|
+
- 1099b5f: testnets: lif3,iota,lyra,lightlink
|
|
130
|
+
|
|
131
|
+
## 2.3.32
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- e846939: testnets: lif3,iota,lyra,lightlink
|
|
136
|
+
- 334b51e: endpoints, including flare mainnet
|
|
137
|
+
- 334b51e: zklink mainnet, and testnets
|
|
138
|
+
- 334b51e: testnet endpoints
|
|
139
|
+
|
|
140
|
+
## 2.3.31
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- 29fecfc: testnets: zksyncsep v2 redeploy, curtis
|
|
145
|
+
|
|
146
|
+
## 2.3.30
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- 32f8ebd: peaq,zircuit mainnet, and plume testnet
|
|
151
|
+
- b602b9f: peaq,zircuit mainnet, and plume testnet
|
|
152
|
+
|
|
153
|
+
## 2.3.29
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- a42fff0: endpoints, including flare mainnet
|
|
158
|
+
- a42fff0: zklink mainnet, and testnets
|
|
159
|
+
- a42fff0: testnet endpoints
|
|
160
|
+
|
|
161
|
+
## 2.3.28
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- 23d7ea0: endpoints, including flare mainnet
|
|
166
|
+
- 23d7ea0: zklink mainnet, and testnets
|
|
167
|
+
- 8a40261: Fix some known issues in Solana
|
|
168
|
+
- 23d7ea0: testnet endpoints
|
|
169
|
+
|
|
170
|
+
## 2.3.27
|
|
171
|
+
|
|
172
|
+
### Patch Changes
|
|
173
|
+
|
|
174
|
+
- e382bef: Update the access property of the `hardhat-tron` package
|
|
175
|
+
- d41cbe9: endpoints, including flare mainnet
|
|
176
|
+
- d41cbe9: testnet endpoints
|
|
177
|
+
|
|
178
|
+
## 2.3.26
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- 92a9a2e: upgrade solana mainnet executor/uln
|
|
183
|
+
|
|
184
|
+
## 2.3.25
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- 003371b: endpoints, including flare mainnet
|
|
189
|
+
- 003371b: testnet endpoints
|
|
190
|
+
|
|
191
|
+
## 2.3.24
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- 255da39: Fix some known issues in the OFT SDK
|
|
196
|
+
|
|
197
|
+
## 2.3.23
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- 1e42a63: bump version: default distribution tag is `latest`
|
|
202
|
+
- 43c0e8f: endpoints: bouncebit, gravity ... testnet: bartio bera chain
|
|
203
|
+
|
|
204
|
+
## 2.3.22
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- 571e2c2: update oft sdk
|
|
209
|
+
|
|
210
|
+
## 2.3.21
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- 2a5e6c8: fix some bugs & public lz-solana-sdk-v2 & upgrade @solana/web3.js
|
|
215
|
+
|
|
216
|
+
## 2.3.20
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- 1b332c1: endpoints: taiko,joc,xchain,etherlink, testnet:bouncebit
|
|
221
|
+
|
|
222
|
+
## 2.3.19
|
|
223
|
+
|
|
224
|
+
### Patch Changes
|
|
225
|
+
|
|
226
|
+
- 5fce234: minor update & fix some bugs
|
|
227
|
+
|
|
228
|
+
## 2.3.18
|
|
229
|
+
|
|
230
|
+
### Patch Changes
|
|
231
|
+
|
|
232
|
+
- d7ddb1e: Make `solana-sdk` compatible with browsers
|
|
233
|
+
|
|
234
|
+
## 2.3.17
|
|
235
|
+
|
|
236
|
+
### Patch Changes
|
|
237
|
+
|
|
238
|
+
- 7e1d72a: minor update & fix some bugs
|
|
239
|
+
- a255697: SEI mainnet
|
|
240
|
+
|
|
241
|
+
## 2.3.16
|
|
242
|
+
|
|
243
|
+
### Patch Changes
|
|
244
|
+
|
|
245
|
+
- b0ac3fe: deploy & config oft
|
|
246
|
+
|
|
247
|
+
## 2.3.15
|
|
248
|
+
|
|
249
|
+
### Patch Changes
|
|
250
|
+
|
|
251
|
+
- 66c554b: minor update & fix some bugs
|
|
252
|
+
|
|
253
|
+
## 2.3.14
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- minor update
|
|
258
|
+
|
|
259
|
+
## 2.3.13
|
|
260
|
+
|
|
261
|
+
### Patch Changes
|
|
262
|
+
|
|
263
|
+
- c294e0e: add missing artifacts
|
|
264
|
+
|
|
265
|
+
## 2.3.12
|
|
266
|
+
|
|
267
|
+
### Patch Changes
|
|
268
|
+
|
|
269
|
+
- 2761d43: minor update & fix some bugs
|
|
270
|
+
|
|
271
|
+
## 2.3.11
|
|
272
|
+
|
|
273
|
+
### Patch Changes
|
|
274
|
+
|
|
275
|
+
- a7ee3c1: mainnet endpoints, cyber, iota
|
|
276
|
+
|
|
277
|
+
## 2.3.10
|
|
278
|
+
|
|
279
|
+
### Patch Changes
|
|
280
|
+
|
|
281
|
+
- b9804e1: export tron and zksync artifacts to sdk
|
|
282
|
+
|
|
283
|
+
## 2.3.9
|
|
284
|
+
|
|
285
|
+
### Patch Changes
|
|
286
|
+
|
|
287
|
+
- c208955: minor update & fix some bugs
|
|
288
|
+
|
|
289
|
+
## 2.3.8
|
|
290
|
+
|
|
291
|
+
### Patch Changes
|
|
292
|
+
|
|
293
|
+
- e0f5d04: deploy contracts to Ebi mainnet
|
|
294
|
+
|
|
295
|
+
## 2.3.7
|
|
296
|
+
|
|
297
|
+
### Patch Changes
|
|
298
|
+
|
|
299
|
+
- 5fa1b78: fix some solana bugs
|
|
300
|
+
|
|
301
|
+
## 2.3.6
|
|
302
|
+
|
|
303
|
+
### Patch Changes
|
|
304
|
+
|
|
305
|
+
- 4a92ba6: send and receive with ULN on solana
|
|
306
|
+
|
|
307
|
+
## 2.3.5
|
|
308
|
+
|
|
309
|
+
### Patch Changes
|
|
310
|
+
|
|
311
|
+
- 20c33bb: tron v2
|
|
312
|
+
|
|
313
|
+
## 2.3.4
|
|
314
|
+
|
|
315
|
+
### Patch Changes
|
|
316
|
+
|
|
317
|
+
- efcf65d: testnet endpoint deployments: Botanix, xchain, ebi
|
|
318
|
+
|
|
319
|
+
## 2.3.3
|
|
320
|
+
|
|
321
|
+
### Patch Changes
|
|
322
|
+
|
|
323
|
+
- 44f13a2: endpoints (mainnet): Skale, Bob, Sanko
|
|
324
|
+
|
|
325
|
+
## 2.3.2
|
|
326
|
+
|
|
327
|
+
### Patch Changes
|
|
328
|
+
|
|
329
|
+
- bd47f83: testnet endpoints: Bob, Cyber
|
|
330
|
+
|
|
331
|
+
## 2.3.1
|
|
332
|
+
|
|
333
|
+
### Patch Changes
|
|
334
|
+
|
|
335
|
+
- c467a80: update RUST_TOOL version and catch errors when checking if chain is ready
|
|
336
|
+
|
|
337
|
+
## 2.3.0
|
|
338
|
+
|
|
339
|
+
### Minor Changes
|
|
340
|
+
|
|
341
|
+
- 211e282: add solana to belowzero & build solana snapshot image
|
|
342
|
+
|
|
343
|
+
## 2.2.6
|
|
344
|
+
|
|
345
|
+
### Patch Changes
|
|
346
|
+
|
|
347
|
+
- 8ecd2dc: endpoints
|
|
348
|
+
|
|
349
|
+
## 2.2.5
|
|
350
|
+
|
|
351
|
+
### Patch Changes
|
|
352
|
+
|
|
353
|
+
- fc047bc: endpoints
|
|
354
|
+
|
|
355
|
+
## 2.2.4
|
|
356
|
+
|
|
357
|
+
### Patch Changes
|
|
358
|
+
|
|
359
|
+
- f525086: add non-tron chain back to testify
|
|
360
|
+
|
|
361
|
+
## 2.2.3
|
|
362
|
+
|
|
363
|
+
### Patch Changes
|
|
364
|
+
|
|
365
|
+
- 4c53623: empty version
|
|
366
|
+
|
|
367
|
+
## 2.2.2
|
|
368
|
+
|
|
369
|
+
### Patch Changes
|
|
370
|
+
|
|
371
|
+
- b04320e: empty version
|
|
372
|
+
|
|
373
|
+
## 2.2.1
|
|
374
|
+
|
|
375
|
+
### Patch Changes
|
|
376
|
+
|
|
377
|
+
- fb15753: new endpoints. 4 testnets xlayer, form, ll1, mantasep, 2 mainnet Merlin, Degen
|
|
378
|
+
|
|
379
|
+
## 2.2.0
|
|
380
|
+
|
|
381
|
+
### Minor Changes
|
|
382
|
+
|
|
383
|
+
- aa51c78: updated sandbox chain keys for frontend
|
|
384
|
+
|
|
385
|
+
## 2.1.27
|
|
386
|
+
|
|
387
|
+
### Patch Changes
|
|
388
|
+
|
|
389
|
+
- 099e19b: internalize common functions and add public onlyOwner passthroughs
|
|
390
|
+
|
|
391
|
+
## 2.1.25
|
|
392
|
+
|
|
393
|
+
### Patch Changes
|
|
394
|
+
|
|
395
|
+
- 57fe209: wire ulnv2 during snapshot build
|
|
396
|
+
|
|
397
|
+
## 2.1.24
|
|
398
|
+
|
|
399
|
+
### Patch Changes
|
|
400
|
+
|
|
401
|
+
- c663d78: remove duplicate `sleep` func
|
|
402
|
+
|
|
403
|
+
## 2.1.23
|
|
404
|
+
|
|
405
|
+
### Patch Changes
|
|
406
|
+
|
|
407
|
+
- c2fc9fe: - update dvn config on blast chain for some dvn partners
|
|
408
|
+
- update OApp, OFT contracts
|
package/dist/index.cjs
CHANGED
|
@@ -1,117 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var blake2b$1 = require('@noble/hashes/blake2b');
|
|
4
|
-
var sha256 = require('@noble/hashes/sha256');
|
|
5
|
-
var sha3 = require('@noble/hashes/sha3');
|
|
6
|
-
var ed25519 = require('@noble/ed25519');
|
|
7
|
-
var secp256k1 = require('@noble/secp256k1');
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var ed25519__namespace = /*#__PURE__*/_interopNamespace(ed25519);
|
|
28
|
-
var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
29
|
-
|
|
30
|
-
var __defProp = Object.defineProperty;
|
|
31
|
-
var __export = (target, all) => {
|
|
32
|
-
for (var name in all)
|
|
33
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
34
|
-
};
|
|
35
|
-
function keccak_256(message) {
|
|
36
|
-
return sha3.keccak_256(message);
|
|
37
|
-
}
|
|
38
|
-
function blake2b(message) {
|
|
39
|
-
return blake2b$1.blake2b(message);
|
|
40
|
-
}
|
|
41
|
-
function sha3_256(message) {
|
|
42
|
-
return sha3.sha3_256(message);
|
|
43
|
-
}
|
|
44
|
-
function sha2_256(message) {
|
|
45
|
-
return sha256.sha256(message);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// src/sign/constant.ts
|
|
49
|
-
var SignAlgorithm = /* @__PURE__ */ ((SignAlgorithm2) => {
|
|
50
|
-
SignAlgorithm2[SignAlgorithm2["NATIVE"] = 0] = "NATIVE";
|
|
51
|
-
SignAlgorithm2[SignAlgorithm2["SECP256K1"] = 1] = "SECP256K1";
|
|
52
|
-
SignAlgorithm2[SignAlgorithm2["ED25519"] = 2] = "ED25519";
|
|
53
|
-
return SignAlgorithm2;
|
|
54
|
-
})(SignAlgorithm || {});
|
|
55
|
-
|
|
56
|
-
// src/sign/ed25519.ts
|
|
57
|
-
var ed25519_exports = {};
|
|
58
|
-
__export(ed25519_exports, {
|
|
59
|
-
signHash: () => signHash
|
|
60
|
-
});
|
|
61
|
-
async function signHash(hash, privateKey) {
|
|
62
|
-
if (hash.length !== 32) {
|
|
63
|
-
throw new Error("Hash must be 32 bytes long");
|
|
64
|
-
}
|
|
65
|
-
const pubKey = await ed25519__namespace.getPublicKey(privateKey);
|
|
66
|
-
const signature = await ed25519__namespace.sign(hash, privateKey);
|
|
67
|
-
const isValid = await ed25519__namespace.verify(signature, hash, pubKey);
|
|
68
|
-
if (!isValid) {
|
|
69
|
-
throw new Error("Invalid signature");
|
|
70
|
-
}
|
|
71
|
-
return signature;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/sign/secp256k1.ts
|
|
75
|
-
var secp256k1_exports = {};
|
|
76
|
-
__export(secp256k1_exports, {
|
|
77
|
-
signHash: () => signHash2
|
|
78
|
-
});
|
|
79
|
-
async function signHash2(hash, privateKey) {
|
|
80
|
-
if (hash.length !== 32) {
|
|
81
|
-
throw new Error("Hash must be 32 bytes long");
|
|
82
|
-
}
|
|
83
|
-
const privKey = privateKey.replace("0x", "");
|
|
84
|
-
const pubKey = secp256k1__namespace.getPublicKey(privKey, false);
|
|
85
|
-
const [signature, recoveryId] = await secp256k1__namespace.sign(hash, privKey, {
|
|
86
|
-
// recovered - true indicates the recovered bit should be included in the result
|
|
87
|
-
recovered: true,
|
|
88
|
-
// canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl
|
|
89
|
-
canonical: true,
|
|
90
|
-
// der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)
|
|
91
|
-
der: false,
|
|
92
|
-
// extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:
|
|
93
|
-
extraEntropy: true
|
|
94
|
-
});
|
|
95
|
-
const isValid = secp256k1__namespace.verify(signature, hash, pubKey, { strict: true });
|
|
96
|
-
if (!isValid) {
|
|
97
|
-
throw new Error("Invalid signature");
|
|
98
|
-
}
|
|
99
|
-
return signature;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/sign/index.ts
|
|
103
|
-
async function signHash3(hash, privateKey, algorithm) {
|
|
104
|
-
const privKey = typeof privateKey === "string" ? privateKey.replace(/^0x/, "") : Buffer.from(privateKey).toString("hex");
|
|
105
|
-
switch (algorithm) {
|
|
106
|
-
case 1 /* SECP256K1 */:
|
|
107
|
-
return signHash2(hash, privKey);
|
|
108
|
-
case 2 /* ED25519 */:
|
|
109
|
-
return signHash(hash, privKey);
|
|
110
|
-
default:
|
|
111
|
-
throw new Error(`Unsupported algorithm: ${algorithm}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
3
|
// src/transaction.ts
|
|
116
4
|
var Block = class _Block {
|
|
117
5
|
constructor(block) {
|
|
@@ -187,19 +75,11 @@ function isConnectable(obj) {
|
|
|
187
75
|
|
|
188
76
|
exports.Block = Block;
|
|
189
77
|
exports.BlockWithTransactions = BlockWithTransactions;
|
|
190
|
-
exports.SignAlgorithm = SignAlgorithm;
|
|
191
78
|
exports.SignedTransaction = SignedTransaction;
|
|
192
79
|
exports.TransactionPending = TransactionPending;
|
|
193
80
|
exports.TransactionReceipt = TransactionReceipt;
|
|
194
81
|
exports.TransactionRequest = TransactionRequest;
|
|
195
82
|
exports.TransactionResponse = TransactionResponse;
|
|
196
|
-
exports.blake2b = blake2b;
|
|
197
|
-
exports.ed25519 = ed25519_exports;
|
|
198
83
|
exports.isConnectable = isConnectable;
|
|
199
|
-
exports.keccak_256 = keccak_256;
|
|
200
|
-
exports.secp256k1 = secp256k1_exports;
|
|
201
|
-
exports.sha2_256 = sha2_256;
|
|
202
|
-
exports.sha3_256 = sha3_256;
|
|
203
|
-
exports.signHash = signHash3;
|
|
204
84
|
//# sourceMappingURL=out.js.map
|
|
205
85
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hash/index.ts","../src/sign/constant.ts","../src/sign/ed25519.ts","../src/sign/secp256k1.ts","../src/sign/index.ts","../src/transaction.ts","../src/signer.ts"],"names":["SignAlgorithm","signHash"],"mappings":";;;;;;;AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,eAAe;AAClC,SAAS,cAAc,aAAa,YAAY,iBAAiB;AAE1D,SAAS,WAAW,SAA0C;AACjE,SAAO,YAAY,OAAO;AAC9B;AAEO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,SAAS,OAAO;AAC3B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,UAAU,OAAO;AAC5B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,QAAQ,OAAO;AAC1B;;;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AC7E,WAAO,IAAI,mBAAkB,GAAG;AAAA,EACpC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAmE;AAC9E,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;;;AC7DO,SAAS,cAAiB,KAAqC;AAClE,MAAI,OAAO,QAAQ,YAAY,QAAQ;AAAM,WAAO;AACpD,QAAM,KAAM,IAA8B;AAC1C,SAAO,OAAO,OAAO,cAAc,OAAO,GAAG,WAAW,YAAY,GAAG,WAAW;AACtF","sourcesContent":["import { blake2b as _blake2b } from '@noble/hashes/blake2b'\nimport { sha256 as _sha256 } from '@noble/hashes/sha256'\nimport { keccak_256 as _keccak_256, sha3_256 as _sha3_256 } from '@noble/hashes/sha3'\n\nexport function keccak_256(message: Uint8Array | string): Uint8Array {\n return _keccak_256(message)\n}\n\nexport function blake2b(message: Uint8Array | string): Uint8Array {\n return _blake2b(message)\n}\n\nexport function sha3_256(message: Uint8Array | string): Uint8Array {\n return _sha3_256(message)\n}\n\nexport function sha2_256(message: Uint8Array | string): Uint8Array {\n return _sha256(message)\n}\n","export enum SignAlgorithm {\n NATIVE,\n SECP256K1,\n ED25519,\n}\n","import * as ed25519 from '@noble/ed25519'\n\n/**\n * Sign a hash using ed25519\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n const pubKey = await ed25519.getPublicKey(privateKey)\n const signature = await ed25519.sign(hash, privateKey)\n const isValid = await ed25519.verify(signature, hash, pubKey)\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n","import * as secp256k1 from '@noble/secp256k1'\n\n/**\n * Sign a hash using secp256k1\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n const privKey = privateKey.replace('0x', '')\n const pubKey = secp256k1.getPublicKey(privKey, false)\n\n // refer to: https://github.com/paulmillr/noble-secp256k1/tree/1.7.1#signmsghash-privatekey\n const [signature, recoveryId] = await secp256k1.sign(hash, privKey, {\n // recovered - true indicates the recovered bit should be included in the result\n recovered: true,\n // canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl\n canonical: true,\n // der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)\n der: false,\n // extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:\n extraEntropy: true,\n })\n\n const isValid = secp256k1.verify(signature, hash, pubKey, { strict: true })\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n","import { SignAlgorithm } from './constant'\nexport * from './constant'\nimport * as ed25519 from './ed25519'\nimport * as secp256k1 from './secp256k1'\n\nexport async function signHash(\n hash: Uint8Array,\n privateKey: string | Uint8Array,\n algorithm: SignAlgorithm\n): Promise<Uint8Array> {\n // privKey should be a hex string without 0x prefix\n // refer to: https://github.com/paulmillr/noble-secp256k1/blob/5ed251242bf065aeb22a54bb42eee1f67e7c77ce/index.ts#L130\n const privKey =\n typeof privateKey === 'string' ? privateKey.replace(/^0x/, '') : Buffer.from(privateKey).toString('hex')\n switch (algorithm) {\n case SignAlgorithm.SECP256K1:\n return secp256k1.signHash(hash, privKey)\n break\n case SignAlgorithm.ED25519:\n return ed25519.signHash(hash, privKey)\n break\n default:\n throw new Error(`Unsupported algorithm: ${algorithm}`)\n }\n}\n\nexport { secp256k1, ed25519 }\n","import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport interface Signer {\n /**\n * Connect to a provider\n * @param provider\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction\n * @param transaction\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\nexport interface Connectable<T> {\n connect<U>(provider: U): T\n}\n\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBO,IAAM,QAAN,MAAM,OAAM;AAAA,EAEP,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2B;AACtC,WAAO,IAAI,OAAM,GAAG;AAAA,EACxB;AACJ;AAKO,IAAM,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AAO,cAAc,OAAO,GAAG,WAAW,YAAY,GAAG,WAAW;AACtF","sourcesContent":["import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport interface Signer<T = unknown> {\n /**\n * Connect to a provider\n * @param provider\n */\n connect(provider: Provider): Signer<T>\n\n /**\n * Sign a transaction\n * @param buildTxRequest\n */\n buildTransaction(buildTxRequest: T): Promise<TransactionRequest>\n\n /**\n * Sign a transaction\n * @param transaction\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\nexport interface Connectable<T> {\n connect<U>(provider: U): T\n}\n\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
declare function keccak_256(message: Uint8Array | string): Uint8Array;
|
|
2
|
-
declare function blake2b(message: Uint8Array | string): Uint8Array;
|
|
3
|
-
declare function sha3_256(message: Uint8Array | string): Uint8Array;
|
|
4
|
-
declare function sha2_256(message: Uint8Array | string): Uint8Array;
|
|
5
|
-
|
|
6
|
-
declare enum SignAlgorithm {
|
|
7
|
-
NATIVE = 0,
|
|
8
|
-
SECP256K1 = 1,
|
|
9
|
-
ED25519 = 2
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Sign a hash using ed25519
|
|
14
|
-
* @param hash - 32 bytes long
|
|
15
|
-
* @param privateKey - private key in hex format
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
declare function signHash$2(hash: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
19
|
-
|
|
20
|
-
declare namespace ed25519 {
|
|
21
|
-
export { signHash$2 as signHash };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Sign a hash using secp256k1
|
|
26
|
-
* @param hash - 32 bytes long
|
|
27
|
-
* @param privateKey - private key in hex format
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
declare function signHash$1(hash: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
31
|
-
|
|
32
|
-
declare namespace secp256k1 {
|
|
33
|
-
export { signHash$1 as signHash };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare function signHash(hash: Uint8Array, privateKey: string | Uint8Array, algorithm: SignAlgorithm): Promise<Uint8Array>;
|
|
37
|
-
|
|
38
1
|
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
39
2
|
|
|
40
3
|
/**
|
|
@@ -193,12 +156,17 @@ interface Provider {
|
|
|
193
156
|
readonly native: unknown;
|
|
194
157
|
}
|
|
195
158
|
|
|
196
|
-
interface Signer {
|
|
159
|
+
interface Signer<T = unknown> {
|
|
197
160
|
/**
|
|
198
161
|
* Connect to a provider
|
|
199
162
|
* @param provider
|
|
200
163
|
*/
|
|
201
|
-
connect(provider: Provider): Signer
|
|
164
|
+
connect(provider: Provider): Signer<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Sign a transaction
|
|
167
|
+
* @param buildTxRequest
|
|
168
|
+
*/
|
|
169
|
+
buildTransaction(buildTxRequest: T): Promise<TransactionRequest>;
|
|
202
170
|
/**
|
|
203
171
|
* Sign a transaction
|
|
204
172
|
* @param transaction
|
|
@@ -234,4 +202,4 @@ interface Connectable<T> {
|
|
|
234
202
|
}
|
|
235
203
|
declare function isConnectable<T>(obj: unknown): obj is Connectable<T>;
|
|
236
204
|
|
|
237
|
-
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider,
|
|
205
|
+
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
declare function keccak_256(message: Uint8Array | string): Uint8Array;
|
|
2
|
-
declare function blake2b(message: Uint8Array | string): Uint8Array;
|
|
3
|
-
declare function sha3_256(message: Uint8Array | string): Uint8Array;
|
|
4
|
-
declare function sha2_256(message: Uint8Array | string): Uint8Array;
|
|
5
|
-
|
|
6
|
-
declare enum SignAlgorithm {
|
|
7
|
-
NATIVE = 0,
|
|
8
|
-
SECP256K1 = 1,
|
|
9
|
-
ED25519 = 2
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Sign a hash using ed25519
|
|
14
|
-
* @param hash - 32 bytes long
|
|
15
|
-
* @param privateKey - private key in hex format
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
declare function signHash$2(hash: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
19
|
-
|
|
20
|
-
declare namespace ed25519 {
|
|
21
|
-
export { signHash$2 as signHash };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Sign a hash using secp256k1
|
|
26
|
-
* @param hash - 32 bytes long
|
|
27
|
-
* @param privateKey - private key in hex format
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
declare function signHash$1(hash: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
31
|
-
|
|
32
|
-
declare namespace secp256k1 {
|
|
33
|
-
export { signHash$1 as signHash };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare function signHash(hash: Uint8Array, privateKey: string | Uint8Array, algorithm: SignAlgorithm): Promise<Uint8Array>;
|
|
37
|
-
|
|
38
1
|
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
39
2
|
|
|
40
3
|
/**
|
|
@@ -193,12 +156,17 @@ interface Provider {
|
|
|
193
156
|
readonly native: unknown;
|
|
194
157
|
}
|
|
195
158
|
|
|
196
|
-
interface Signer {
|
|
159
|
+
interface Signer<T = unknown> {
|
|
197
160
|
/**
|
|
198
161
|
* Connect to a provider
|
|
199
162
|
* @param provider
|
|
200
163
|
*/
|
|
201
|
-
connect(provider: Provider): Signer
|
|
164
|
+
connect(provider: Provider): Signer<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Sign a transaction
|
|
167
|
+
* @param buildTxRequest
|
|
168
|
+
*/
|
|
169
|
+
buildTransaction(buildTxRequest: T): Promise<TransactionRequest>;
|
|
202
170
|
/**
|
|
203
171
|
* Sign a transaction
|
|
204
172
|
* @param transaction
|
|
@@ -234,4 +202,4 @@ interface Connectable<T> {
|
|
|
234
202
|
}
|
|
235
203
|
declare function isConnectable<T>(obj: unknown): obj is Connectable<T>;
|
|
236
204
|
|
|
237
|
-
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider,
|
|
205
|
+
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
package/dist/index.mjs
CHANGED
|
@@ -1,94 +1,3 @@
|
|
|
1
|
-
import { blake2b as blake2b$1 } from '@noble/hashes/blake2b';
|
|
2
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
-
import { keccak_256 as keccak_256$1, sha3_256 as sha3_256$1 } from '@noble/hashes/sha3';
|
|
4
|
-
import * as ed25519 from '@noble/ed25519';
|
|
5
|
-
import * as secp256k1 from '@noble/secp256k1';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
function keccak_256(message) {
|
|
13
|
-
return keccak_256$1(message);
|
|
14
|
-
}
|
|
15
|
-
function blake2b(message) {
|
|
16
|
-
return blake2b$1(message);
|
|
17
|
-
}
|
|
18
|
-
function sha3_256(message) {
|
|
19
|
-
return sha3_256$1(message);
|
|
20
|
-
}
|
|
21
|
-
function sha2_256(message) {
|
|
22
|
-
return sha256(message);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/sign/constant.ts
|
|
26
|
-
var SignAlgorithm = /* @__PURE__ */ ((SignAlgorithm2) => {
|
|
27
|
-
SignAlgorithm2[SignAlgorithm2["NATIVE"] = 0] = "NATIVE";
|
|
28
|
-
SignAlgorithm2[SignAlgorithm2["SECP256K1"] = 1] = "SECP256K1";
|
|
29
|
-
SignAlgorithm2[SignAlgorithm2["ED25519"] = 2] = "ED25519";
|
|
30
|
-
return SignAlgorithm2;
|
|
31
|
-
})(SignAlgorithm || {});
|
|
32
|
-
|
|
33
|
-
// src/sign/ed25519.ts
|
|
34
|
-
var ed25519_exports = {};
|
|
35
|
-
__export(ed25519_exports, {
|
|
36
|
-
signHash: () => signHash
|
|
37
|
-
});
|
|
38
|
-
async function signHash(hash, privateKey) {
|
|
39
|
-
if (hash.length !== 32) {
|
|
40
|
-
throw new Error("Hash must be 32 bytes long");
|
|
41
|
-
}
|
|
42
|
-
const pubKey = await ed25519.getPublicKey(privateKey);
|
|
43
|
-
const signature = await ed25519.sign(hash, privateKey);
|
|
44
|
-
const isValid = await ed25519.verify(signature, hash, pubKey);
|
|
45
|
-
if (!isValid) {
|
|
46
|
-
throw new Error("Invalid signature");
|
|
47
|
-
}
|
|
48
|
-
return signature;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/sign/secp256k1.ts
|
|
52
|
-
var secp256k1_exports = {};
|
|
53
|
-
__export(secp256k1_exports, {
|
|
54
|
-
signHash: () => signHash2
|
|
55
|
-
});
|
|
56
|
-
async function signHash2(hash, privateKey) {
|
|
57
|
-
if (hash.length !== 32) {
|
|
58
|
-
throw new Error("Hash must be 32 bytes long");
|
|
59
|
-
}
|
|
60
|
-
const privKey = privateKey.replace("0x", "");
|
|
61
|
-
const pubKey = secp256k1.getPublicKey(privKey, false);
|
|
62
|
-
const [signature, recoveryId] = await secp256k1.sign(hash, privKey, {
|
|
63
|
-
// recovered - true indicates the recovered bit should be included in the result
|
|
64
|
-
recovered: true,
|
|
65
|
-
// canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl
|
|
66
|
-
canonical: true,
|
|
67
|
-
// der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)
|
|
68
|
-
der: false,
|
|
69
|
-
// extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:
|
|
70
|
-
extraEntropy: true
|
|
71
|
-
});
|
|
72
|
-
const isValid = secp256k1.verify(signature, hash, pubKey, { strict: true });
|
|
73
|
-
if (!isValid) {
|
|
74
|
-
throw new Error("Invalid signature");
|
|
75
|
-
}
|
|
76
|
-
return signature;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// src/sign/index.ts
|
|
80
|
-
async function signHash3(hash, privateKey, algorithm) {
|
|
81
|
-
const privKey = typeof privateKey === "string" ? privateKey.replace(/^0x/, "") : Buffer.from(privateKey).toString("hex");
|
|
82
|
-
switch (algorithm) {
|
|
83
|
-
case 1 /* SECP256K1 */:
|
|
84
|
-
return signHash2(hash, privKey);
|
|
85
|
-
case 2 /* ED25519 */:
|
|
86
|
-
return signHash(hash, privKey);
|
|
87
|
-
default:
|
|
88
|
-
throw new Error(`Unsupported algorithm: ${algorithm}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
1
|
// src/transaction.ts
|
|
93
2
|
var Block = class _Block {
|
|
94
3
|
constructor(block) {
|
|
@@ -162,6 +71,6 @@ function isConnectable(obj) {
|
|
|
162
71
|
return typeof fn === "function" && typeof fn.length === "number" && fn.length === 1;
|
|
163
72
|
}
|
|
164
73
|
|
|
165
|
-
export { Block, BlockWithTransactions,
|
|
74
|
+
export { Block, BlockWithTransactions, SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
|
166
75
|
//# sourceMappingURL=out.js.map
|
|
167
76
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hash/index.ts","../src/sign/constant.ts","../src/sign/ed25519.ts","../src/sign/secp256k1.ts","../src/sign/index.ts","../src/transaction.ts","../src/signer.ts"],"names":["SignAlgorithm","signHash"],"mappings":";;;;;;;AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,eAAe;AAClC,SAAS,cAAc,aAAa,YAAY,iBAAiB;AAE1D,SAAS,WAAW,SAA0C;AACjE,SAAO,YAAY,OAAO;AAC9B;AAEO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,SAAS,OAAO;AAC3B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,UAAU,OAAO;AAC5B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,QAAQ,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KAAQ,KAAkE;AAC7E,WAAO,IAAI,mBAAkB,GAAG;AAAA,EACpC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAmE;AAC9E,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;;;AC7DO,SAAS,cAAiB,KAAqC;AAClE,MAAI,OAAO,QAAQ,YAAY,QAAQ;AAAM,WAAO;AACpD,QAAM,KAAM,IAA8B;AAC1C,SAAO,OAAO,OAAO,cAAc,OAAO,GAAG,WAAW,YAAY,GAAG,WAAW;AACtF","sourcesContent":["import { blake2b as _blake2b } from '@noble/hashes/blake2b'\nimport { sha256 as _sha256 } from '@noble/hashes/sha256'\nimport { keccak_256 as _keccak_256, sha3_256 as _sha3_256 } from '@noble/hashes/sha3'\n\nexport function keccak_256(message: Uint8Array | string): Uint8Array {\n return _keccak_256(message)\n}\n\nexport function blake2b(message: Uint8Array | string): Uint8Array {\n return _blake2b(message)\n}\n\nexport function sha3_256(message: Uint8Array | string): Uint8Array {\n return _sha3_256(message)\n}\n\nexport function sha2_256(message: Uint8Array | string): Uint8Array {\n return _sha256(message)\n}\n","export enum SignAlgorithm {\n NATIVE,\n SECP256K1,\n ED25519,\n}\n","import * as ed25519 from '@noble/ed25519'\n\n/**\n * Sign a hash using ed25519\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n const pubKey = await ed25519.getPublicKey(privateKey)\n const signature = await ed25519.sign(hash, privateKey)\n const isValid = await ed25519.verify(signature, hash, pubKey)\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n","import * as secp256k1 from '@noble/secp256k1'\n\n/**\n * Sign a hash using secp256k1\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n const privKey = privateKey.replace('0x', '')\n const pubKey = secp256k1.getPublicKey(privKey, false)\n\n // refer to: https://github.com/paulmillr/noble-secp256k1/tree/1.7.1#signmsghash-privatekey\n const [signature, recoveryId] = await secp256k1.sign(hash, privKey, {\n // recovered - true indicates the recovered bit should be included in the result\n recovered: true,\n // canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl\n canonical: true,\n // der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)\n der: false,\n // extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:\n extraEntropy: true,\n })\n\n const isValid = secp256k1.verify(signature, hash, pubKey, { strict: true })\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n","import { SignAlgorithm } from './constant'\nexport * from './constant'\nimport * as ed25519 from './ed25519'\nimport * as secp256k1 from './secp256k1'\n\nexport async function signHash(\n hash: Uint8Array,\n privateKey: string | Uint8Array,\n algorithm: SignAlgorithm\n): Promise<Uint8Array> {\n // privKey should be a hex string without 0x prefix\n // refer to: https://github.com/paulmillr/noble-secp256k1/blob/5ed251242bf065aeb22a54bb42eee1f67e7c77ce/index.ts#L130\n const privKey =\n typeof privateKey === 'string' ? privateKey.replace(/^0x/, '') : Buffer.from(privateKey).toString('hex')\n switch (algorithm) {\n case SignAlgorithm.SECP256K1:\n return secp256k1.signHash(hash, privKey)\n break\n case SignAlgorithm.ED25519:\n return ed25519.signHash(hash, privKey)\n break\n default:\n throw new Error(`Unsupported algorithm: ${algorithm}`)\n }\n}\n\nexport { secp256k1, ed25519 }\n","import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport interface Signer {\n /**\n * Connect to a provider\n * @param provider\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction\n * @param transaction\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\nexport interface Connectable<T> {\n connect<U>(provider: U): T\n}\n\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBO,IAAM,QAAN,MAAM,OAAM;AAAA,EAEP,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2B;AACtC,WAAO,IAAI,OAAM,GAAG;AAAA,EACxB;AAC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C,SAAO,OAAO,OAAO,cAAc,OAAO,GAAG,WAAW,YAAY,GAAG,WAAW;AACtF","sourcesContent":["import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport interface Signer<T = unknown> {\n /**\n * Connect to a provider\n * @param provider\n */\n connect(provider: Provider): Signer<T>\n\n /**\n * Sign a transaction\n * @param buildTxRequest\n */\n buildTransaction(buildTxRequest: T): Promise<TransactionRequest>\n\n /**\n * Sign a transaction\n * @param transaction\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\nexport interface Connectable<T> {\n connect<U>(provider: U): T\n}\n\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/lz-core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.45-initia-oft.5",
|
|
4
4
|
"description": "LayerZero Core Library",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"exports": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"clean-prebuild": "rimraf dist"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@layerzerolabs/lz-foundation": "^2.3.45-initia-oft.5",
|
|
26
27
|
"@noble/ed25519": "^1.7.1",
|
|
27
28
|
"@noble/hashes": "^1.3.2",
|
|
28
29
|
"@noble/secp256k1": "^1.7.1",
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@jest/globals": "^29.7.0",
|
|
33
|
-
"@layerzerolabs/tsup-config-next": "
|
|
34
|
-
"@layerzerolabs/typescript-config-next": "
|
|
34
|
+
"@layerzerolabs/tsup-config-next": "^2.3.45-initia-oft.5",
|
|
35
|
+
"@layerzerolabs/typescript-config-next": "^2.3.45-initia-oft.5",
|
|
35
36
|
"@types/jest": "^29.5.10",
|
|
36
37
|
"jest": "^29.7.0",
|
|
37
38
|
"rimraf": "^5.0.5",
|
|
@@ -42,4 +43,4 @@
|
|
|
42
43
|
"publishConfig": {
|
|
43
44
|
"access": "public"
|
|
44
45
|
}
|
|
45
|
-
}
|
|
46
|
+
}
|