@ckb-ccc/core 0.0.11-alpha.2 → 0.0.12-alpha.0
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/dist/address/index.d.ts.map +1 -1
- package/dist/ckb/script.d.ts +1 -5
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/transaction.d.ts +32 -39
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +58 -16
- package/dist/client/client.advanced.d.ts.map +1 -1
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +10 -4
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +22 -2
- package/dist/client/clientPublicMainnet.d.ts +4 -1
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +3 -2
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +22 -2
- package/dist/client/clientPublicTestnet.d.ts +4 -1
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +3 -2
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/fixedPoint/index.d.ts +2 -2
- package/dist/fixedPoint/index.d.ts.map +1 -1
- package/dist/hasher/hasher.d.ts +32 -0
- package/dist/hasher/hasher.d.ts.map +1 -0
- package/dist/hasher/hasher.js +1 -0
- package/dist/hasher/hasherCkb.d.ts +68 -0
- package/dist/hasher/hasherCkb.d.ts.map +1 -0
- package/dist/hasher/hasherCkb.js +83 -0
- package/dist/hasher/hasherKeecak256.d.ts +38 -0
- package/dist/hasher/hasherKeecak256.d.ts.map +1 -0
- package/dist/hasher/hasherKeecak256.js +43 -0
- package/dist/hasher/index.d.ts +3 -66
- package/dist/hasher/index.d.ts.map +1 -1
- package/dist/hasher/index.js +3 -79
- package/dist/keystore/index.d.ts +2 -2
- package/dist/keystore/index.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.d.ts +13 -4
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +63 -11
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.d.ts +1 -5
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.d.ts +32 -39
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +57 -15
- package/dist.commonjs/client/client.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/client.d.ts +1 -0
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +10 -4
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +22 -2
- package/dist.commonjs/client/clientPublicMainnet.d.ts +4 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +3 -2
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +22 -2
- package/dist.commonjs/client/clientPublicTestnet.d.ts +4 -1
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +3 -2
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/fixedPoint/index.d.ts +2 -2
- package/dist.commonjs/fixedPoint/index.d.ts.map +1 -1
- package/dist.commonjs/hasher/hasher.d.ts +32 -0
- package/dist.commonjs/hasher/hasher.d.ts.map +1 -0
- package/dist.commonjs/hasher/hasher.js +2 -0
- package/dist.commonjs/hasher/hasherCkb.d.ts +68 -0
- package/dist.commonjs/hasher/hasherCkb.d.ts.map +1 -0
- package/dist.commonjs/hasher/hasherCkb.js +89 -0
- package/dist.commonjs/hasher/hasherKeecak256.d.ts +38 -0
- package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +1 -0
- package/dist.commonjs/hasher/hasherKeecak256.js +47 -0
- package/dist.commonjs/hasher/index.d.ts +3 -66
- package/dist.commonjs/hasher/index.d.ts.map +1 -1
- package/dist.commonjs/hasher/index.js +16 -85
- package/dist.commonjs/keystore/index.d.ts +2 -2
- package/dist.commonjs/keystore/index.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.d.ts +13 -4
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +72 -20
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.d.ts +1 -1
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/address/index.ts +1 -1
- package/src/ckb/script.ts +1 -1
- package/src/ckb/transaction.ts +75 -22
- package/src/client/client.advanced.ts +1 -1
- package/src/client/client.ts +15 -4
- package/src/client/clientPublicMainnet.advanced.ts +25 -2
- package/src/client/clientPublicMainnet.ts +6 -2
- package/src/client/clientPublicTestnet.advanced.ts +25 -2
- package/src/client/clientPublicTestnet.ts +6 -2
- package/src/client/jsonRpc/index.ts +3 -3
- package/src/fixedPoint/index.ts +2 -2
- package/src/hasher/hasher.ts +35 -0
- package/src/hasher/hasherCkb.ts +102 -0
- package/src/hasher/hasherKeecak256.ts +52 -0
- package/src/hasher/index.ts +3 -103
- package/src/keystore/index.ts +19 -1
- package/src/signer/evm/signerEvm.ts +131 -24
- package/src/signer/signer/index.ts +1 -1
- package/src/utils/index.ts +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BytesLike } from "../bytes/index.js";
|
|
2
|
+
import { Hex } from "../hex/index.js";
|
|
3
|
+
export interface Hasher {
|
|
4
|
+
/**
|
|
5
|
+
* Updates the hash with the given data.
|
|
6
|
+
*
|
|
7
|
+
* @param data - The data to update the hash with.
|
|
8
|
+
* @returns The current Hasher instance for chaining.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const hasher = new Hasher();
|
|
13
|
+
* hasher.update("some data").update("more data");
|
|
14
|
+
* const hash = hasher.digest();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
update(data: BytesLike): Hasher;
|
|
18
|
+
/**
|
|
19
|
+
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
20
|
+
*
|
|
21
|
+
* @returns The hexadecimal string representation of the hash.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const hasher = new Hasher();
|
|
26
|
+
* hasher.update("some data");
|
|
27
|
+
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
digest(): Hex;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=hasher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../../src/hasher/hasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;OAYG;IAEH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAEhC;;;;;;;;;;;OAWG;IAEH,MAAM,IAAI,GAAG,CAAC;CACf"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BytesLike } from "../bytes/index.js";
|
|
2
|
+
import { CellInputLike } from "../ckb/index.js";
|
|
3
|
+
import { Hex } from "../hex/index.js";
|
|
4
|
+
import { NumLike } from "../num/index.js";
|
|
5
|
+
import { Hasher } from "./hasher.js";
|
|
6
|
+
export declare class HasherCkb implements Hasher {
|
|
7
|
+
private readonly hasher;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Hasher.
|
|
10
|
+
*
|
|
11
|
+
* @param outLength - The output length of the hash in bytes. Default is 32.
|
|
12
|
+
* @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
|
|
13
|
+
*/
|
|
14
|
+
constructor(outLength?: number, personal?: string);
|
|
15
|
+
/**
|
|
16
|
+
* Updates the hash with the given data.
|
|
17
|
+
*
|
|
18
|
+
* @param data - The data to update the hash with.
|
|
19
|
+
* @returns The current Hasher instance for chaining.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const hasher = new Hasher();
|
|
24
|
+
* hasher.update("some data").update("more data");
|
|
25
|
+
* const hash = hasher.digest();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
update(data: BytesLike): HasherCkb;
|
|
29
|
+
/**
|
|
30
|
+
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
31
|
+
*
|
|
32
|
+
* @returns The hexadecimal string representation of the hash.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const hasher = new Hasher();
|
|
37
|
+
* hasher.update("some data");
|
|
38
|
+
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
digest(): Hex;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Computes the CKB hash of the given data using the Blake2b algorithm.
|
|
45
|
+
*
|
|
46
|
+
* @param data - The data to hash.
|
|
47
|
+
* @returns The hexadecimal string representation of the hash.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const hash = hashCkb("some data"); // Outputs something like "0x..."
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function hashCkb(...data: BytesLike[]): Hex;
|
|
55
|
+
/**
|
|
56
|
+
* Computes the Type ID hash of the given data.
|
|
57
|
+
*
|
|
58
|
+
* @param cellInput - The first cell input of the transaction.
|
|
59
|
+
* @param outputIndex - The output index of the Type ID cell.
|
|
60
|
+
* @returns The hexadecimal string representation of the hash.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function hashTypeId(cellInputLike: CellInputLike, outputIndex: NumLike): Hex;
|
|
68
|
+
//# sourceMappingURL=hasherCkb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasherCkb.d.ts","sourceRoot":"","sources":["../../src/hasher/hasherCkb.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAgB,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,SAAU,YAAW,MAAM;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEhE;;;;;OAKG;gBAES,SAAS,SAAK,EAAE,QAAQ,SAAuB;IAO3D;;;;;;;;;;;;OAYG;IAEH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAKlC;;;;;;;;;;;OAWG;IAEH,MAAM,IAAI,GAAG;CAGd;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,CAIjD;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,OAAO,GACnB,GAAG,CAKL"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashTypeId = exports.hashCkb = exports.HasherCkb = void 0;
|
|
4
|
+
const blake2b_1 = require("@noble/hashes/blake2b");
|
|
5
|
+
const index_js_1 = require("../bytes/index.js");
|
|
6
|
+
const index_js_2 = require("../ckb/index.js");
|
|
7
|
+
const index_js_3 = require("../hex/index.js");
|
|
8
|
+
const index_js_4 = require("../num/index.js");
|
|
9
|
+
const advanced_js_1 = require("./advanced.js");
|
|
10
|
+
class HasherCkb {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of Hasher.
|
|
13
|
+
*
|
|
14
|
+
* @param outLength - The output length of the hash in bytes. Default is 32.
|
|
15
|
+
* @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
|
|
16
|
+
*/
|
|
17
|
+
constructor(outLength = 32, personal = advanced_js_1.CKB_BLAKE2B_PERSONAL) {
|
|
18
|
+
this.hasher = blake2b_1.blake2b.create({
|
|
19
|
+
personalization: personal,
|
|
20
|
+
dkLen: outLength,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Updates the hash with the given data.
|
|
25
|
+
*
|
|
26
|
+
* @param data - The data to update the hash with.
|
|
27
|
+
* @returns The current Hasher instance for chaining.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const hasher = new Hasher();
|
|
32
|
+
* hasher.update("some data").update("more data");
|
|
33
|
+
* const hash = hasher.digest();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
update(data) {
|
|
37
|
+
this.hasher.update((0, index_js_1.bytesFrom)(data));
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
42
|
+
*
|
|
43
|
+
* @returns The hexadecimal string representation of the hash.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const hasher = new Hasher();
|
|
48
|
+
* hasher.update("some data");
|
|
49
|
+
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
digest() {
|
|
53
|
+
return (0, index_js_3.hexFrom)(this.hasher.digest());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.HasherCkb = HasherCkb;
|
|
57
|
+
/**
|
|
58
|
+
* Computes the CKB hash of the given data using the Blake2b algorithm.
|
|
59
|
+
*
|
|
60
|
+
* @param data - The data to hash.
|
|
61
|
+
* @returns The hexadecimal string representation of the hash.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const hash = hashCkb("some data"); // Outputs something like "0x..."
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
function hashCkb(...data) {
|
|
69
|
+
const hasher = new HasherCkb();
|
|
70
|
+
data.forEach((d) => hasher.update(d));
|
|
71
|
+
return hasher.digest();
|
|
72
|
+
}
|
|
73
|
+
exports.hashCkb = hashCkb;
|
|
74
|
+
/**
|
|
75
|
+
* Computes the Type ID hash of the given data.
|
|
76
|
+
*
|
|
77
|
+
* @param cellInput - The first cell input of the transaction.
|
|
78
|
+
* @param outputIndex - The output index of the Type ID cell.
|
|
79
|
+
* @returns The hexadecimal string representation of the hash.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function hashTypeId(cellInputLike, outputIndex) {
|
|
87
|
+
return hashCkb(index_js_2.CellInput.from(cellInputLike).toBytes(), (0, index_js_4.numLeToBytes)(outputIndex, 8));
|
|
88
|
+
}
|
|
89
|
+
exports.hashTypeId = hashTypeId;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BytesLike } from "../bytes/index.js";
|
|
2
|
+
import { Hex } from "../hex/index.js";
|
|
3
|
+
import { Hasher } from "./hasher.js";
|
|
4
|
+
export declare class HasherKeecak256 implements Hasher {
|
|
5
|
+
private readonly hasher;
|
|
6
|
+
/**
|
|
7
|
+
* Creates an instance of Hasher.
|
|
8
|
+
*/
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Updates the hash with the given data.
|
|
12
|
+
*
|
|
13
|
+
* @param data - The data to update the hash with.
|
|
14
|
+
* @returns The current Hasher instance for chaining.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const hasher = new Hasher();
|
|
19
|
+
* hasher.update("some data").update("more data");
|
|
20
|
+
* const hash = hasher.digest();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
update(data: BytesLike): HasherKeecak256;
|
|
24
|
+
/**
|
|
25
|
+
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
26
|
+
*
|
|
27
|
+
* @returns The hexadecimal string representation of the hash.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const hasher = new Hasher();
|
|
32
|
+
* hasher.update("some data");
|
|
33
|
+
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
digest(): Hex;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=hasherKeecak256.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasherKeecak256.d.ts","sourceRoot":"","sources":["../../src/hasher/hasherKeecak256.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,eAAgB,YAAW,MAAM;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IAEnE;;OAEG;;IAMH;;;;;;;;;;;;OAYG;IAEH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe;IAKxC;;;;;;;;;;;OAWG;IAEH,MAAM,IAAI,GAAG;CAGd"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HasherKeecak256 = void 0;
|
|
4
|
+
const sha3_1 = require("@noble/hashes/sha3");
|
|
5
|
+
const index_js_1 = require("../bytes/index.js");
|
|
6
|
+
const index_js_2 = require("../hex/index.js");
|
|
7
|
+
class HasherKeecak256 {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Hasher.
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
this.hasher = sha3_1.keccak_256.create();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Updates the hash with the given data.
|
|
16
|
+
*
|
|
17
|
+
* @param data - The data to update the hash with.
|
|
18
|
+
* @returns The current Hasher instance for chaining.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const hasher = new Hasher();
|
|
23
|
+
* hasher.update("some data").update("more data");
|
|
24
|
+
* const hash = hasher.digest();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
update(data) {
|
|
28
|
+
this.hasher.update((0, index_js_1.bytesFrom)(data));
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
33
|
+
*
|
|
34
|
+
* @returns The hexadecimal string representation of the hash.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const hasher = new Hasher();
|
|
39
|
+
* hasher.update("some data");
|
|
40
|
+
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
digest() {
|
|
44
|
+
return (0, index_js_2.hexFrom)(this.hasher.digest());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.HasherKeecak256 = HasherKeecak256;
|
|
@@ -1,67 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { NumLike } from "../num/index.js";
|
|
5
|
-
export declare class Hasher {
|
|
6
|
-
private readonly hasher;
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of Hasher.
|
|
9
|
-
*
|
|
10
|
-
* @param outLength - The output length of the hash in bytes. Default is 32.
|
|
11
|
-
* @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
|
|
12
|
-
*/
|
|
13
|
-
constructor(outLength?: number, personal?: string);
|
|
14
|
-
/**
|
|
15
|
-
* Updates the hash with the given data.
|
|
16
|
-
*
|
|
17
|
-
* @param data - The data to update the hash with.
|
|
18
|
-
* @returns The current Hasher instance for chaining.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const hasher = new Hasher();
|
|
23
|
-
* hasher.update("some data").update("more data");
|
|
24
|
-
* const hash = hasher.digest();
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
update(data: BytesLike): Hasher;
|
|
28
|
-
/**
|
|
29
|
-
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
30
|
-
*
|
|
31
|
-
* @returns The hexadecimal string representation of the hash.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const hasher = new Hasher();
|
|
36
|
-
* hasher.update("some data");
|
|
37
|
-
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
digest(): Hex;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Computes the CKB hash of the given data using the Blake2b algorithm.
|
|
44
|
-
*
|
|
45
|
-
* @param data - The data to hash.
|
|
46
|
-
* @returns The hexadecimal string representation of the hash.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const hash = hashCkb("some data"); // Outputs something like "0x..."
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export declare function hashCkb(...data: BytesLike[]): Hex;
|
|
54
|
-
/**
|
|
55
|
-
* Computes the Type ID hash of the given data.
|
|
56
|
-
*
|
|
57
|
-
* @param cellInput - The first cell input of the transaction.
|
|
58
|
-
* @param outputIndex - The output index of the Type ID cell.
|
|
59
|
-
* @returns The hexadecimal string representation of the hash.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export declare function hashTypeId(cellInputLike: CellInputLike, outputIndex: NumLike): Hex;
|
|
1
|
+
export * from "./hasher.js";
|
|
2
|
+
export * from "./hasherCkb.js";
|
|
3
|
+
export * from "./hasherKeecak256.js";
|
|
67
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,88 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const index_js_2 = require("../ckb/index.js");
|
|
10
|
-
const index_js_3 = require("../num/index.js");
|
|
11
|
-
const advanced_js_1 = require("./advanced.js");
|
|
12
|
-
class Hasher {
|
|
13
|
-
/**
|
|
14
|
-
* Creates an instance of Hasher.
|
|
15
|
-
*
|
|
16
|
-
* @param outLength - The output length of the hash in bytes. Default is 32.
|
|
17
|
-
* @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
|
|
18
|
-
*/
|
|
19
|
-
constructor(outLength = 32, personal = advanced_js_1.CKB_BLAKE2B_PERSONAL) {
|
|
20
|
-
this.hasher = (0, blake2b_1.default)(outLength, undefined, undefined, (0, index_js_1.bytesFrom)(personal, "utf8"));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Updates the hash with the given data.
|
|
24
|
-
*
|
|
25
|
-
* @param data - The data to update the hash with.
|
|
26
|
-
* @returns The current Hasher instance for chaining.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const hasher = new Hasher();
|
|
31
|
-
* hasher.update("some data").update("more data");
|
|
32
|
-
* const hash = hasher.digest();
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
update(data) {
|
|
36
|
-
this.hasher.update((0, index_js_1.bytesFrom)(data));
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Finalizes the hash and returns the digest as a hexadecimal string.
|
|
41
|
-
*
|
|
42
|
-
* @returns The hexadecimal string representation of the hash.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const hasher = new Hasher();
|
|
47
|
-
* hasher.update("some data");
|
|
48
|
-
* const hash = hasher.digest(); // Outputs something like "0x..."
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
digest() {
|
|
52
|
-
return `0x${this.hasher.digest("hex")}`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.Hasher = Hasher;
|
|
56
|
-
/**
|
|
57
|
-
* Computes the CKB hash of the given data using the Blake2b algorithm.
|
|
58
|
-
*
|
|
59
|
-
* @param data - The data to hash.
|
|
60
|
-
* @returns The hexadecimal string representation of the hash.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const hash = hashCkb("some data"); // Outputs something like "0x..."
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
function hashCkb(...data) {
|
|
68
|
-
const hasher = new Hasher();
|
|
69
|
-
data.forEach((d) => hasher.update(d));
|
|
70
|
-
return hasher.digest();
|
|
71
|
-
}
|
|
72
|
-
exports.hashCkb = hashCkb;
|
|
73
|
-
/**
|
|
74
|
-
* Computes the Type ID hash of the given data.
|
|
75
|
-
*
|
|
76
|
-
* @param cellInput - The first cell input of the transaction.
|
|
77
|
-
* @param outputIndex - The output index of the Type ID cell.
|
|
78
|
-
* @returns The hexadecimal string representation of the hash.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
function hashTypeId(cellInputLike, outputIndex) {
|
|
86
|
-
return hashCkb(index_js_2.CellInput.from(cellInputLike).toBytes(), (0, index_js_3.numLeToBytes)(outputIndex, 8));
|
|
87
|
-
}
|
|
88
|
-
exports.hashTypeId = hashTypeId;
|
|
17
|
+
__exportStar(require("./hasher.js"), exports);
|
|
18
|
+
__exportStar(require("./hasherCkb.js"), exports);
|
|
19
|
+
__exportStar(require("./hasherKeecak256.js"), exports);
|
|
@@ -9,11 +9,11 @@ export declare function keystoreEncrypt(privateKeyLike: BytesLike, chainCodeLike
|
|
|
9
9
|
cipher: string;
|
|
10
10
|
kdf: string;
|
|
11
11
|
kdfparams: {
|
|
12
|
-
dklen: number;
|
|
13
|
-
salt: string;
|
|
14
12
|
n: number;
|
|
15
13
|
r: number;
|
|
16
14
|
p: number;
|
|
15
|
+
dklen: number;
|
|
16
|
+
salt: string;
|
|
17
17
|
};
|
|
18
18
|
mac: string;
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keystore/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,SAAS,EAA0B,MAAM,mBAAmB,CAAC;AAgB7E,wBAAsB,eAAe,CACnC,cAAc,EAAE,SAAS,EACzB,aAAa,EAAE,SAAS,EACxB,QAAQ,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keystore/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,SAAS,EAA0B,MAAM,mBAAmB,CAAC;AAgB7E,wBAAsB,eAAe,CACnC,cAAc,EAAE,SAAS,EACzB,aAAa,EAAE,SAAS,EACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE;YACZ,EAAE,EAAE,MAAM,CAAC;SACZ,CAAC;QACF,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE;YACT,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;YACV,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC,CAqCD;AAED,wBAAsB,eAAe,CACnC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IACT,UAAU,EAAE,KAAK,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC;CAClB,CAAC,CAoED"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Address } from "../../address/index.js";
|
|
2
|
-
import { BytesLike } from "../../bytes/index.js";
|
|
2
|
+
import { Bytes, BytesLike } from "../../bytes/index.js";
|
|
3
3
|
import { Script, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Hasher } from "../../hasher/index.js";
|
|
5
|
+
import { Hex, HexLike } from "../../hex/index.js";
|
|
5
6
|
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
@@ -28,8 +29,11 @@ export declare abstract class SignerEvm extends Signer {
|
|
|
28
29
|
* @returns A promise that resolves to an array of Address objects.
|
|
29
30
|
*/
|
|
30
31
|
getAddressObjs(): Promise<Address[]>;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
_getOmniLockAddresses(account: HexLike): Promise<Address[]>;
|
|
33
|
+
_getPWLockAddresses(account: HexLike): Promise<Address[]>;
|
|
34
|
+
_getOmniLockEvmAddressObj(account: HexLike): Promise<Address>;
|
|
35
|
+
_getOmniLockOldEvmAddressObj(account: HexLike): Promise<Address>;
|
|
36
|
+
_getPWLockEvmAddressObj(account: HexLike): Promise<Address | undefined>;
|
|
33
37
|
/**
|
|
34
38
|
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
35
39
|
*
|
|
@@ -45,5 +49,10 @@ export declare abstract class SignerEvm extends Signer {
|
|
|
45
49
|
*/
|
|
46
50
|
signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
47
51
|
_signOmniLockScriptForTransaction(tx: Transaction, script: Script, messageTransformer: (hash: string) => BytesLike): Promise<Transaction>;
|
|
52
|
+
_signPWLockScriptForTransaction(tx: Transaction, script: Script, messageTransformer: (hash: string) => BytesLike): Promise<Transaction>;
|
|
53
|
+
_signPersonalEvmForTransaction(tx: Transaction, script: Script, messageTransformer: (hash: string) => BytesLike, hasher?: Hasher): Promise<{
|
|
54
|
+
signature: Bytes;
|
|
55
|
+
position: number;
|
|
56
|
+
} | undefined>;
|
|
48
57
|
}
|
|
49
58
|
//# sourceMappingURL=signerEvm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAA0B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,SAAS,EAA0B,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,MAAM,EACN,WAAW,EACX,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAmB,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;IAEtC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAU1C,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAOrD,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAQzD,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7D,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQhE,uBAAuB,CAC3B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAW/B;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAsCvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IA+BlE,iCAAiC,CACrC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;IA2BjB,+BAA+B,CACnC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;IAkBjB,8BAA8B,CAClC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,EAC/C,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;QAAE,SAAS,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAe/D"}
|