@ckb-ccc/core 0.1.1 → 1.0.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/CHANGELOG.md +12 -0
- package/dist/barrel.d.ts +1 -1
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +1 -1
- package/dist/bytes/index.d.ts +14 -0
- package/dist/bytes/index.d.ts.map +1 -1
- package/dist/bytes/index.js +29 -0
- package/dist/ckb/advanced.d.ts +0 -1
- package/dist/ckb/advanced.d.ts.map +1 -1
- package/dist/ckb/advanced.js +0 -1
- package/dist/ckb/script.d.ts +17 -58
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/script.js +31 -78
- package/dist/ckb/transaction.d.ts +114 -260
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +162 -358
- package/dist/molecule/barrel.d.ts +4 -0
- package/dist/molecule/barrel.d.ts.map +1 -0
- package/dist/molecule/barrel.js +3 -0
- package/dist/molecule/codec.d.ts.map +1 -1
- package/dist/molecule/codec.js +6 -3
- package/dist/molecule/entity.d.ts +98 -0
- package/dist/molecule/entity.d.ts.map +1 -0
- package/dist/molecule/entity.js +113 -0
- package/dist/molecule/index.d.ts +1 -2
- package/dist/molecule/index.d.ts.map +1 -1
- package/dist/molecule/index.js +1 -2
- package/dist/molecule/predefined.d.ts +13 -20
- package/dist/molecule/predefined.d.ts.map +1 -1
- package/dist/molecule/predefined.js +14 -54
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist.commonjs/address/address.advanced.js +28 -23
- package/dist.commonjs/address/advanced.js +17 -1
- package/dist.commonjs/address/index.js +15 -11
- package/dist.commonjs/advanced.js +31 -2
- package/dist.commonjs/advancedBarrel.js +21 -5
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +28 -12
- package/dist.commonjs/bytes/advanced.js +2 -1
- package/dist.commonjs/bytes/index.d.ts +14 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -1
- package/dist.commonjs/bytes/index.js +42 -7
- package/dist.commonjs/ckb/advanced.d.ts +0 -1
- package/dist.commonjs/ckb/advanced.d.ts.map +1 -1
- package/dist.commonjs/ckb/advanced.js +18 -3
- package/dist.commonjs/ckb/index.js +19 -3
- package/dist.commonjs/ckb/script.advanced.js +6 -3
- package/dist.commonjs/ckb/script.d.ts +17 -58
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.js +49 -90
- package/dist.commonjs/ckb/transaction.advanced.js +6 -3
- package/dist.commonjs/ckb/transaction.d.ts +114 -260
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +249 -434
- package/dist.commonjs/ckb/transactionLumos.js +2 -1
- package/dist.commonjs/client/advanced.js +22 -6
- package/dist.commonjs/client/cache/advanced.js +17 -1
- package/dist.commonjs/client/cache/cache.js +7 -3
- package/dist.commonjs/client/cache/index.js +18 -2
- package/dist.commonjs/client/cache/memory.advanced.js +28 -21
- package/dist.commonjs/client/cache/memory.js +23 -19
- package/dist.commonjs/client/client.js +25 -21
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +25 -22
- package/dist.commonjs/client/clientPublicMainnet.js +15 -8
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +25 -22
- package/dist.commonjs/client/clientPublicTestnet.js +15 -8
- package/dist.commonjs/client/clientTypes.advanced.js +6 -3
- package/dist.commonjs/client/clientTypes.js +43 -29
- package/dist.commonjs/client/index.js +22 -6
- package/dist.commonjs/client/jsonRpc/advanced.js +18 -2
- package/dist.commonjs/client/jsonRpc/index.js +41 -37
- package/dist.commonjs/client/jsonRpc/transformers.js +61 -57
- package/dist.commonjs/client/jsonRpc/types.js +2 -1
- package/dist.commonjs/client/transports/advanced.js +25 -8
- package/dist.commonjs/client/transports/http.js +5 -1
- package/dist.commonjs/client/transports/transport.js +2 -1
- package/dist.commonjs/client/transports/webSocket.js +10 -3
- package/dist.commonjs/fixedPoint/index.js +9 -4
- package/dist.commonjs/hasher/advanced.js +4 -1
- package/dist.commonjs/hasher/hasher.js +2 -1
- package/dist.commonjs/hasher/hasherCkb.js +20 -14
- package/dist.commonjs/hasher/hasherKeecak256.js +11 -7
- package/dist.commonjs/hasher/index.js +19 -3
- package/dist.commonjs/hex/index.js +6 -3
- package/dist.commonjs/index.js +31 -2
- package/dist.commonjs/keystore/index.js +25 -21
- package/dist.commonjs/molecule/barrel.d.ts +4 -0
- package/dist.commonjs/molecule/barrel.d.ts.map +1 -0
- package/dist.commonjs/molecule/barrel.js +19 -0
- package/dist.commonjs/molecule/codec.d.ts.map +1 -1
- package/dist.commonjs/molecule/codec.js +69 -51
- package/dist.commonjs/molecule/entity.d.ts +98 -0
- package/dist.commonjs/molecule/entity.d.ts.map +1 -0
- package/dist.commonjs/molecule/entity.js +118 -0
- package/dist.commonjs/molecule/index.d.ts +1 -2
- package/dist.commonjs/molecule/index.d.ts.map +1 -1
- package/dist.commonjs/molecule/index.js +27 -2
- package/dist.commonjs/molecule/predefined.d.ts +13 -20
- package/dist.commonjs/molecule/predefined.d.ts.map +1 -1
- package/dist.commonjs/molecule/predefined.js +54 -91
- package/dist.commonjs/num/index.js +29 -17
- package/dist.commonjs/signer/btc/index.js +19 -3
- package/dist.commonjs/signer/btc/signerBtc.js +24 -20
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +8 -4
- package/dist.commonjs/signer/btc/verify.js +26 -17
- package/dist.commonjs/signer/ckb/index.js +21 -5
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +20 -16
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +24 -20
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +12 -8
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +16 -12
- package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -5
- package/dist.commonjs/signer/doge/index.js +20 -4
- package/dist.commonjs/signer/doge/signerDoge.js +26 -19
- package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +6 -2
- package/dist.commonjs/signer/doge/signerDogePrivateKey.js +17 -13
- package/dist.commonjs/signer/doge/verify.js +15 -12
- package/dist.commonjs/signer/dummy/alwaysError.js +6 -2
- package/dist.commonjs/signer/dummy/dummy.js +7 -3
- package/dist.commonjs/signer/dummy/index.js +19 -3
- package/dist.commonjs/signer/dummy/openLink.js +6 -2
- package/dist.commonjs/signer/evm/index.js +19 -3
- package/dist.commonjs/signer/evm/signerEvm.js +35 -31
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +8 -4
- package/dist.commonjs/signer/evm/verify.js +7 -4
- package/dist.commonjs/signer/index.js +23 -7
- package/dist.commonjs/signer/nostr/index.js +18 -2
- package/dist.commonjs/signer/nostr/signerNostr.js +25 -21
- package/dist.commonjs/signer/nostr/verify.js +16 -12
- package/dist.commonjs/signer/signer/index.js +25 -19
- package/dist.commonjs/utils/index.d.ts +3 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +12 -6
- package/package.json +1 -2
- package/src/barrel.ts +1 -1
- package/src/bytes/index.ts +34 -0
- package/src/ckb/advanced.ts +0 -1
- package/src/ckb/script.ts +22 -85
- package/src/ckb/transaction.ts +134 -412
- package/src/molecule/barrel.ts +3 -0
- package/src/molecule/codec.ts +9 -5
- package/src/molecule/entity.ts +163 -0
- package/src/molecule/index.ts +1 -2
- package/src/molecule/predefined.ts +20 -69
- package/src/utils/index.ts +5 -0
- package/dist/ckb/molecule.advanced/generated.d.ts +0 -355
- package/dist/ckb/molecule.advanced/generated.d.ts.map +0 -1
- package/dist/ckb/molecule.advanced/generated.js +0 -1468
- package/dist/ckb/molecule.advanced/index.d.ts +0 -6
- package/dist/ckb/molecule.advanced/index.d.ts.map +0 -1
- package/dist/ckb/molecule.advanced/index.js +0 -7
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +0 -355
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts.map +0 -1
- package/dist.commonjs/ckb/molecule.advanced/generated.js +0 -1468
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +0 -6
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +0 -1
- package/dist.commonjs/ckb/molecule.advanced/index.js +0 -7
- package/src/ckb/molecule.advanced/blockchain.mol +0 -118
- package/src/ckb/molecule.advanced/generated.d.ts +0 -444
- package/src/ckb/molecule.advanced/generated.js +0 -1804
- package/src/ckb/molecule.advanced/index.ts +0 -11
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cache/advanced.js"), exports);
|
|
18
|
+
__exportStar(require("./clientPublicMainnet.advanced.js"), exports);
|
|
19
|
+
__exportStar(require("./clientPublicTestnet.advanced.js"), exports);
|
|
20
|
+
__exportStar(require("./clientTypes.advanced.js"), exports);
|
|
21
|
+
__exportStar(require("./jsonRpc/advanced.js"), exports);
|
|
22
|
+
__exportStar(require("./transports/advanced.js"), exports);
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./memory.advanced.js"), exports);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientCache = void 0;
|
|
4
|
+
const index_js_1 = require("../../ckb/index.js");
|
|
5
|
+
class ClientCache {
|
|
3
6
|
async markTransactions(...transactionLike) {
|
|
4
7
|
await Promise.all([
|
|
5
8
|
this.recordTransactions(...transactionLike),
|
|
6
9
|
...transactionLike.flat().map((transactionLike) => {
|
|
7
|
-
const tx = Transaction.from(transactionLike);
|
|
10
|
+
const tx = index_js_1.Transaction.from(transactionLike);
|
|
8
11
|
const txHash = tx.hash();
|
|
9
12
|
return Promise.all([
|
|
10
13
|
...tx.inputs.map((i) => this.markUnusable(i.previousOutput)),
|
|
@@ -41,3 +44,4 @@ export class ClientCache {
|
|
|
41
44
|
*/
|
|
42
45
|
async recordCells(..._cells) { }
|
|
43
46
|
}
|
|
47
|
+
exports.ClientCache = ClientCache;
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cache.js"), exports);
|
|
18
|
+
__exportStar(require("./memory.js"), exports);
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterData = filterData;
|
|
4
|
+
exports.filterScript = filterScript;
|
|
5
|
+
exports.filterNumByRange = filterNumByRange;
|
|
6
|
+
exports.filterScriptByLenRange = filterScriptByLenRange;
|
|
7
|
+
exports.filterCell = filterCell;
|
|
8
|
+
const index_js_1 = require("../../bytes/index.js");
|
|
9
|
+
const index_js_2 = require("../../ckb/index.js");
|
|
10
|
+
const index_js_3 = require("../../hex/index.js");
|
|
11
|
+
const index_js_4 = require("../../num/index.js");
|
|
12
|
+
const clientTypes_advanced_js_1 = require("../clientTypes.advanced.js");
|
|
13
|
+
const clientTypes_js_1 = require("../clientTypes.js");
|
|
14
|
+
function filterData(dataLike, filterLike, filterMode) {
|
|
8
15
|
if (!filterLike) {
|
|
9
16
|
return true;
|
|
10
17
|
}
|
|
11
|
-
const data = hexFrom(dataLike);
|
|
12
|
-
const filter = hexFrom(filterLike);
|
|
18
|
+
const data = (0, index_js_3.hexFrom)(dataLike);
|
|
19
|
+
const filter = (0, index_js_3.hexFrom)(filterLike);
|
|
13
20
|
if ((filterMode === "exact" && data !== filter) ||
|
|
14
21
|
(filterMode === "prefix" && !data.startsWith(filter)) ||
|
|
15
22
|
(filterMode === "partial" && data.search(filter) === -1)) {
|
|
@@ -17,30 +24,30 @@ export function filterData(dataLike, filterLike, filterMode) {
|
|
|
17
24
|
}
|
|
18
25
|
return true;
|
|
19
26
|
}
|
|
20
|
-
|
|
27
|
+
function filterScript(valueLike, filterLike, filterMode) {
|
|
21
28
|
if (!filterLike) {
|
|
22
29
|
return true;
|
|
23
30
|
}
|
|
24
31
|
if (!valueLike) {
|
|
25
32
|
return false;
|
|
26
33
|
}
|
|
27
|
-
const value = Script.from(valueLike);
|
|
28
|
-
const filter = Script.from(filterLike);
|
|
34
|
+
const value = index_js_2.Script.from(valueLike);
|
|
35
|
+
const filter = index_js_2.Script.from(filterLike);
|
|
29
36
|
if (value.codeHash !== filter.codeHash ||
|
|
30
37
|
value.hashType !== filter.hashType) {
|
|
31
38
|
return false;
|
|
32
39
|
}
|
|
33
40
|
return filterData(value.args, filter?.args, filterMode);
|
|
34
41
|
}
|
|
35
|
-
|
|
42
|
+
function filterNumByRange(lengthLike, range) {
|
|
36
43
|
if (!range) {
|
|
37
44
|
return true;
|
|
38
45
|
}
|
|
39
|
-
const length = numFrom(lengthLike);
|
|
40
|
-
const [lower, upper] = clientSearchKeyRangeFrom(range);
|
|
46
|
+
const length = (0, index_js_4.numFrom)(lengthLike);
|
|
47
|
+
const [lower, upper] = (0, clientTypes_advanced_js_1.clientSearchKeyRangeFrom)(range);
|
|
41
48
|
return lower <= length && length < upper;
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
function filterScriptByLenRange(valueLike, scriptLenRange) {
|
|
44
51
|
if (!scriptLenRange) {
|
|
45
52
|
return true;
|
|
46
53
|
}
|
|
@@ -48,13 +55,13 @@ export function filterScriptByLenRange(valueLike, scriptLenRange) {
|
|
|
48
55
|
if (!valueLike) {
|
|
49
56
|
return 0;
|
|
50
57
|
}
|
|
51
|
-
return bytesFrom(Script.from(valueLike).args).length + 33;
|
|
58
|
+
return (0, index_js_1.bytesFrom)(index_js_2.Script.from(valueLike).args).length + 33;
|
|
52
59
|
})();
|
|
53
60
|
return filterNumByRange(len, scriptLenRange);
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
const key = ClientIndexerSearchKey.from(searchKeyLike);
|
|
57
|
-
const cell = Cell.from(cellLike);
|
|
62
|
+
function filterCell(searchKeyLike, cellLike) {
|
|
63
|
+
const key = clientTypes_js_1.ClientIndexerSearchKey.from(searchKeyLike);
|
|
64
|
+
const cell = index_js_2.Cell.from(cellLike);
|
|
58
65
|
if (key.scriptType === "lock") {
|
|
59
66
|
if (!filterScript(cell.cellOutput.lock, key.script, key.scriptSearchMode) ||
|
|
60
67
|
!filterScript(cell.cellOutput.type, key.filter?.script, "prefix") ||
|
|
@@ -70,7 +77,7 @@ export function filterCell(searchKeyLike, cellLike) {
|
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
if (!filterData(cell.outputData, key.filter?.outputData, key.filter?.outputDataSearchMode ?? "prefix") ||
|
|
73
|
-
!filterNumByRange(bytesFrom(cell.outputData).length, key.filter?.outputDataLenRange)) {
|
|
80
|
+
!filterNumByRange((0, index_js_1.bytesFrom)(cell.outputData).length, key.filter?.outputDataLenRange)) {
|
|
74
81
|
return false;
|
|
75
82
|
}
|
|
76
83
|
if (!filterNumByRange(cell.cellOutput.capacity, key.filter?.outputCapacityRange)) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientCacheMemory = void 0;
|
|
4
|
+
const index_js_1 = require("../../ckb/index.js");
|
|
5
|
+
const index_js_2 = require("../../hex/index.js");
|
|
6
|
+
const cache_js_1 = require("./cache.js");
|
|
7
|
+
const memory_advanced_js_1 = require("./memory.advanced.js");
|
|
8
|
+
class ClientCacheMemory extends cache_js_1.ClientCache {
|
|
6
9
|
constructor() {
|
|
7
10
|
super(...arguments);
|
|
8
11
|
/**
|
|
@@ -16,15 +19,15 @@ export class ClientCacheMemory extends ClientCache {
|
|
|
16
19
|
}
|
|
17
20
|
async markUsable(...cellLikes) {
|
|
18
21
|
cellLikes.flat().forEach((cellLike) => {
|
|
19
|
-
const cell = Cell.from(cellLike).clone();
|
|
20
|
-
const outPointStr = hexFrom(cell.outPoint.toBytes());
|
|
22
|
+
const cell = index_js_1.Cell.from(cellLike).clone();
|
|
23
|
+
const outPointStr = (0, index_js_2.hexFrom)(cell.outPoint.toBytes());
|
|
21
24
|
this.cells.set(outPointStr, [true, cell]);
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
async markUnusable(...outPointLikes) {
|
|
25
28
|
outPointLikes.flat().forEach((outPointLike) => {
|
|
26
|
-
const outPoint = OutPoint.from(outPointLike);
|
|
27
|
-
const outPointStr = hexFrom(outPoint.toBytes());
|
|
29
|
+
const outPoint = index_js_1.OutPoint.from(outPointLike);
|
|
30
|
+
const outPointStr = (0, index_js_2.hexFrom)(outPoint.toBytes());
|
|
28
31
|
const existed = this.cells.get(outPointStr);
|
|
29
32
|
if (existed) {
|
|
30
33
|
existed[0] = false;
|
|
@@ -43,37 +46,37 @@ export class ClientCacheMemory extends ClientCache {
|
|
|
43
46
|
if (!isLive) {
|
|
44
47
|
continue;
|
|
45
48
|
}
|
|
46
|
-
if (!filterCell(keyLike, cell)) {
|
|
49
|
+
if (!(0, memory_advanced_js_1.filterCell)(keyLike, cell)) {
|
|
47
50
|
continue;
|
|
48
51
|
}
|
|
49
52
|
yield cell.clone();
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
async getCell(outPointLike) {
|
|
53
|
-
const outPoint = OutPoint.from(outPointLike);
|
|
54
|
-
const cell = this.cells.get(hexFrom(outPoint.toBytes()))?.[1];
|
|
56
|
+
const outPoint = index_js_1.OutPoint.from(outPointLike);
|
|
57
|
+
const cell = this.cells.get((0, index_js_2.hexFrom)(outPoint.toBytes()))?.[1];
|
|
55
58
|
if (cell && cell.cellOutput && cell.outputData) {
|
|
56
|
-
return Cell.from(cell.clone());
|
|
59
|
+
return index_js_1.Cell.from(cell.clone());
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
async isUnusable(outPointLike) {
|
|
60
|
-
const outPoint = OutPoint.from(outPointLike);
|
|
61
|
-
return !(this.cells.get(hexFrom(outPoint.toBytes()))?.[0] ?? true);
|
|
63
|
+
const outPoint = index_js_1.OutPoint.from(outPointLike);
|
|
64
|
+
return !(this.cells.get((0, index_js_2.hexFrom)(outPoint.toBytes()))?.[0] ?? true);
|
|
62
65
|
}
|
|
63
66
|
async recordTransactions(...transactions) {
|
|
64
67
|
transactions.flat().map((txLike) => {
|
|
65
|
-
const tx = Transaction.from(txLike);
|
|
68
|
+
const tx = index_js_1.Transaction.from(txLike);
|
|
66
69
|
this.knownTransactions.set(tx.hash(), tx);
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
async getTransaction(txHashLike) {
|
|
70
|
-
const txHash = hexFrom(txHashLike);
|
|
73
|
+
const txHash = (0, index_js_2.hexFrom)(txHashLike);
|
|
71
74
|
return this.knownTransactions.get(txHash)?.clone();
|
|
72
75
|
}
|
|
73
76
|
async recordCells(...cells) {
|
|
74
77
|
cells.flat().map((cellLike) => {
|
|
75
|
-
const cell = Cell.from(cellLike);
|
|
76
|
-
const outPointStr = hexFrom(cell.outPoint.toBytes());
|
|
78
|
+
const cell = index_js_1.Cell.from(cellLike);
|
|
79
|
+
const outPointStr = (0, index_js_2.hexFrom)(cell.outPoint.toBytes());
|
|
77
80
|
if (this.cells.get(outPointStr)) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
@@ -81,3 +84,4 @@ export class ClientCacheMemory extends ClientCache {
|
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
exports.ClientCacheMemory = ClientCacheMemory;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = void 0;
|
|
4
|
+
const index_js_1 = require("../ckb/index.js");
|
|
5
|
+
const index_js_2 = require("../fixedPoint/index.js");
|
|
6
|
+
const index_js_3 = require("../hex/index.js");
|
|
7
|
+
const index_js_4 = require("../num/index.js");
|
|
8
|
+
const index_js_5 = require("../utils/index.js");
|
|
9
|
+
const memory_js_1 = require("./cache/memory.js");
|
|
10
|
+
const clientTypes_js_1 = require("./clientTypes.js");
|
|
8
11
|
/**
|
|
9
12
|
* @public
|
|
10
13
|
*/
|
|
11
|
-
|
|
14
|
+
class Client {
|
|
12
15
|
constructor(config) {
|
|
13
|
-
this.cache = config?.cache ?? new ClientCacheMemory();
|
|
16
|
+
this.cache = config?.cache ?? new memory_js_1.ClientCacheMemory();
|
|
14
17
|
}
|
|
15
18
|
async getFeeRate(blockRange) {
|
|
16
|
-
return numMax((await this.getFeeRateStatistics(blockRange)).median, 1000);
|
|
19
|
+
return (0, index_js_4.numMax)((await this.getFeeRateStatistics(blockRange)).median, 1000);
|
|
17
20
|
}
|
|
18
21
|
async getCell(outPointLike) {
|
|
19
|
-
const outPoint = OutPoint.from(outPointLike);
|
|
22
|
+
const outPoint = index_js_1.OutPoint.from(outPointLike);
|
|
20
23
|
const cached = await this.cache.getCell(outPoint);
|
|
21
24
|
if (cached) {
|
|
22
25
|
return cached;
|
|
@@ -25,11 +28,11 @@ export class Client {
|
|
|
25
28
|
if (!transaction) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
|
-
const index = Number(numFrom(outPoint.index));
|
|
31
|
+
const index = Number((0, index_js_4.numFrom)(outPoint.index));
|
|
29
32
|
if (index >= transaction.transaction.outputs.length) {
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
|
-
const cell = Cell.from({
|
|
35
|
+
const cell = index_js_1.Cell.from({
|
|
33
36
|
outPoint,
|
|
34
37
|
cellOutput: transaction.transaction.outputs[index],
|
|
35
38
|
outputData: transaction.transaction.outputsData[index] ?? "0x",
|
|
@@ -69,7 +72,7 @@ export class Client {
|
|
|
69
72
|
* @returns A async generator for yielding cells.
|
|
70
73
|
*/
|
|
71
74
|
async *findCells(keyLike, order, limit = 10) {
|
|
72
|
-
const key = ClientIndexerSearchKey.from(keyLike);
|
|
75
|
+
const key = clientTypes_js_1.ClientIndexerSearchKey.from(keyLike);
|
|
73
76
|
const foundedOutPoints = [];
|
|
74
77
|
for await (const cell of this.cache.findCells(key)) {
|
|
75
78
|
foundedOutPoints.push(cell.outPoint);
|
|
@@ -109,7 +112,7 @@ export class Client {
|
|
|
109
112
|
}
|
|
110
113
|
async getCellDeps(...cellDepsInfoLike) {
|
|
111
114
|
return Promise.all(cellDepsInfoLike.flat().map(async (infoLike) => {
|
|
112
|
-
const { cellDep, type } = CellDepInfo.from(infoLike);
|
|
115
|
+
const { cellDep, type } = clientTypes_js_1.CellDepInfo.from(infoLike);
|
|
113
116
|
if (type === undefined) {
|
|
114
117
|
return cellDep;
|
|
115
118
|
}
|
|
@@ -117,7 +120,7 @@ export class Client {
|
|
|
117
120
|
if (!found) {
|
|
118
121
|
return cellDep;
|
|
119
122
|
}
|
|
120
|
-
return CellDep.from({
|
|
123
|
+
return index_js_1.CellDep.from({
|
|
121
124
|
outPoint: found.outPoint,
|
|
122
125
|
depType: cellDep.depType,
|
|
123
126
|
});
|
|
@@ -167,17 +170,17 @@ export class Client {
|
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
172
|
async getBalance(locks) {
|
|
170
|
-
return reduceAsync(locks, async (acc, lock) => acc + (await this.getBalanceSingle(lock)), Zero);
|
|
173
|
+
return (0, index_js_5.reduceAsync)(locks, async (acc, lock) => acc + (await this.getBalanceSingle(lock)), index_js_2.Zero);
|
|
171
174
|
}
|
|
172
175
|
async sendTransaction(transaction, validator) {
|
|
173
|
-
const tx = Transaction.from(transaction);
|
|
176
|
+
const tx = index_js_1.Transaction.from(transaction);
|
|
174
177
|
const txHash = await this.sendTransactionNoCache(tx, validator);
|
|
175
178
|
await this.cache.recordTransactions(tx);
|
|
176
179
|
await this.cache.markTransactions(tx);
|
|
177
180
|
return txHash;
|
|
178
181
|
}
|
|
179
182
|
async getTransaction(txHashLike) {
|
|
180
|
-
const txHash = hexFrom(txHashLike);
|
|
183
|
+
const txHash = (0, index_js_3.hexFrom)(txHashLike);
|
|
181
184
|
const res = await this.getTransactionNoCache(txHash);
|
|
182
185
|
if (res?.transaction) {
|
|
183
186
|
return res;
|
|
@@ -224,9 +227,10 @@ export class Client {
|
|
|
224
227
|
return tx;
|
|
225
228
|
}
|
|
226
229
|
if (Date.now() - startTime + interval >= timeout) {
|
|
227
|
-
throw new ErrorClientWaitTransactionTimeout();
|
|
230
|
+
throw new clientTypes_js_1.ErrorClientWaitTransactionTimeout();
|
|
228
231
|
}
|
|
229
|
-
await sleep(interval);
|
|
232
|
+
await (0, index_js_5.sleep)(interval);
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
}
|
|
236
|
+
exports.Client = Client;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAINNET_SCRIPTS = void 0;
|
|
4
|
+
const clientTypes_js_1 = require("./clientTypes.js");
|
|
5
|
+
exports.MAINNET_SCRIPTS = Object.freeze({
|
|
6
|
+
[clientTypes_js_1.KnownScript.NervosDao]: {
|
|
4
7
|
codeHash: "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
|
|
5
8
|
hashType: "type",
|
|
6
9
|
cellDeps: [
|
|
@@ -15,7 +18,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
15
18
|
},
|
|
16
19
|
],
|
|
17
20
|
},
|
|
18
|
-
[KnownScript.Secp256k1Blake160]: {
|
|
21
|
+
[clientTypes_js_1.KnownScript.Secp256k1Blake160]: {
|
|
19
22
|
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
20
23
|
hashType: "type",
|
|
21
24
|
cellDeps: [
|
|
@@ -30,7 +33,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
30
33
|
},
|
|
31
34
|
],
|
|
32
35
|
},
|
|
33
|
-
[KnownScript.Secp256k1Multisig]: {
|
|
36
|
+
[clientTypes_js_1.KnownScript.Secp256k1Multisig]: {
|
|
34
37
|
codeHash: "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
|
|
35
38
|
hashType: "type",
|
|
36
39
|
cellDeps: [
|
|
@@ -45,7 +48,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
45
48
|
},
|
|
46
49
|
],
|
|
47
50
|
},
|
|
48
|
-
[KnownScript.AnyoneCanPay]: {
|
|
51
|
+
[clientTypes_js_1.KnownScript.AnyoneCanPay]: {
|
|
49
52
|
codeHash: "0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354",
|
|
50
53
|
hashType: "type",
|
|
51
54
|
cellDeps: [
|
|
@@ -60,12 +63,12 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
60
63
|
},
|
|
61
64
|
],
|
|
62
65
|
},
|
|
63
|
-
[KnownScript.TypeId]: {
|
|
66
|
+
[clientTypes_js_1.KnownScript.TypeId]: {
|
|
64
67
|
codeHash: "0x00000000000000000000000000000000000000000000000000545950455f4944",
|
|
65
68
|
hashType: "type",
|
|
66
69
|
cellDeps: [],
|
|
67
70
|
},
|
|
68
|
-
[KnownScript.XUdt]: {
|
|
71
|
+
[clientTypes_js_1.KnownScript.XUdt]: {
|
|
69
72
|
codeHash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95",
|
|
70
73
|
hashType: "data1",
|
|
71
74
|
cellDeps: [
|
|
@@ -80,7 +83,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
80
83
|
},
|
|
81
84
|
],
|
|
82
85
|
},
|
|
83
|
-
[KnownScript.JoyId]: {
|
|
86
|
+
[clientTypes_js_1.KnownScript.JoyId]: {
|
|
84
87
|
codeHash: "0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323",
|
|
85
88
|
hashType: "type",
|
|
86
89
|
cellDeps: [
|
|
@@ -95,7 +98,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
95
98
|
},
|
|
96
99
|
],
|
|
97
100
|
},
|
|
98
|
-
[KnownScript.COTA]: {
|
|
101
|
+
[clientTypes_js_1.KnownScript.COTA]: {
|
|
99
102
|
codeHash: "0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df",
|
|
100
103
|
hashType: "type",
|
|
101
104
|
cellDeps: [
|
|
@@ -110,7 +113,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
110
113
|
},
|
|
111
114
|
],
|
|
112
115
|
},
|
|
113
|
-
[KnownScript.PWLock]: {
|
|
116
|
+
[clientTypes_js_1.KnownScript.PWLock]: {
|
|
114
117
|
codeHash: "0xbf43c3602455798c1a61a596e0d95278864c552fafe231c063b3fabf97a8febc",
|
|
115
118
|
hashType: "type",
|
|
116
119
|
cellDeps: [
|
|
@@ -139,7 +142,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
139
142
|
},
|
|
140
143
|
],
|
|
141
144
|
},
|
|
142
|
-
[KnownScript.OmniLock]: {
|
|
145
|
+
[clientTypes_js_1.KnownScript.OmniLock]: {
|
|
143
146
|
codeHash: "0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26",
|
|
144
147
|
hashType: "type",
|
|
145
148
|
cellDeps: [
|
|
@@ -168,7 +171,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
168
171
|
},
|
|
169
172
|
],
|
|
170
173
|
},
|
|
171
|
-
[KnownScript.NostrLock]: {
|
|
174
|
+
[clientTypes_js_1.KnownScript.NostrLock]: {
|
|
172
175
|
codeHash: "0x641a89ad2f77721b803cd50d01351c1f308444072d5fa20088567196c0574c68",
|
|
173
176
|
hashType: "type",
|
|
174
177
|
cellDeps: [
|
|
@@ -188,7 +191,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
188
191
|
},
|
|
189
192
|
],
|
|
190
193
|
},
|
|
191
|
-
[KnownScript.UniqueType]: {
|
|
194
|
+
[clientTypes_js_1.KnownScript.UniqueType]: {
|
|
192
195
|
codeHash: "0x2c8c11c985da60b0a330c61a85507416d6382c130ba67f0c47ab071e00aec628",
|
|
193
196
|
hashType: "data1",
|
|
194
197
|
cellDeps: [
|
|
@@ -203,7 +206,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
203
206
|
},
|
|
204
207
|
],
|
|
205
208
|
},
|
|
206
|
-
[KnownScript.AlwaysSuccess]: {
|
|
209
|
+
[clientTypes_js_1.KnownScript.AlwaysSuccess]: {
|
|
207
210
|
codeHash: "0x3b521cc4b552f109d092d8cc468a8048acb53c5952dbe769d2b2f9cf6e47f7f1",
|
|
208
211
|
hashType: "data1",
|
|
209
212
|
cellDeps: [
|
|
@@ -218,7 +221,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
218
221
|
},
|
|
219
222
|
],
|
|
220
223
|
},
|
|
221
|
-
[KnownScript.InputTypeProxyLock]: {
|
|
224
|
+
[clientTypes_js_1.KnownScript.InputTypeProxyLock]: {
|
|
222
225
|
codeHash: "0x5123908965c711b0ffd8aec642f1ede329649bda1ebdca6bd24124d3796f768a",
|
|
223
226
|
hashType: "data1",
|
|
224
227
|
cellDeps: [
|
|
@@ -233,7 +236,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
233
236
|
},
|
|
234
237
|
],
|
|
235
238
|
},
|
|
236
|
-
[KnownScript.OutputTypeProxyLock]: {
|
|
239
|
+
[clientTypes_js_1.KnownScript.OutputTypeProxyLock]: {
|
|
237
240
|
codeHash: "0x2df53b592db3ae3685b7787adcfef0332a611edb83ca3feca435809964c3aff2",
|
|
238
241
|
hashType: "data1",
|
|
239
242
|
cellDeps: [
|
|
@@ -248,7 +251,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
248
251
|
},
|
|
249
252
|
],
|
|
250
253
|
},
|
|
251
|
-
[KnownScript.LockProxyLock]: {
|
|
254
|
+
[clientTypes_js_1.KnownScript.LockProxyLock]: {
|
|
252
255
|
codeHash: "0x5d41e32e224c15f152b7e6529100ebeac83b162f5f692a5365774dad2c1a1d02",
|
|
253
256
|
hashType: "data1",
|
|
254
257
|
cellDeps: [
|
|
@@ -263,7 +266,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
263
266
|
},
|
|
264
267
|
],
|
|
265
268
|
},
|
|
266
|
-
[KnownScript.SingleUseLock]: {
|
|
269
|
+
[clientTypes_js_1.KnownScript.SingleUseLock]: {
|
|
267
270
|
codeHash: "0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf",
|
|
268
271
|
hashType: "data1",
|
|
269
272
|
cellDeps: [
|
|
@@ -278,7 +281,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
278
281
|
},
|
|
279
282
|
],
|
|
280
283
|
},
|
|
281
|
-
[KnownScript.TypeBurnLock]: {
|
|
284
|
+
[clientTypes_js_1.KnownScript.TypeBurnLock]: {
|
|
282
285
|
codeHash: "0xff78bae0abf17d7a404c0be0f9ad9c9185b3f88dcc60403453d5ba8e1f22f53a",
|
|
283
286
|
hashType: "data1",
|
|
284
287
|
cellDeps: [
|
|
@@ -293,7 +296,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
293
296
|
},
|
|
294
297
|
],
|
|
295
298
|
},
|
|
296
|
-
[KnownScript.EasyToDiscoverType]: {
|
|
299
|
+
[clientTypes_js_1.KnownScript.EasyToDiscoverType]: {
|
|
297
300
|
codeHash: "0xaba4430cc7110d699007095430a1faa72973edf2322ddbfd4d1d219cacf237af",
|
|
298
301
|
hashType: "data1",
|
|
299
302
|
cellDeps: [
|
|
@@ -308,7 +311,7 @@ export const MAINNET_SCRIPTS = Object.freeze({
|
|
|
308
311
|
},
|
|
309
312
|
],
|
|
310
313
|
},
|
|
311
|
-
[KnownScript.TimeLock]: {
|
|
314
|
+
[clientTypes_js_1.KnownScript.TimeLock]: {
|
|
312
315
|
codeHash: "0x6fac4b2e89360a1e692efcddcb3a28656d8446549fb83da6d896db8b714f4451",
|
|
313
316
|
hashType: "data1",
|
|
314
317
|
cellDeps: [
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClientPublicMainnet = void 0;
|
|
7
|
+
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
8
|
+
const clientPublicMainnet_advanced_js_1 = require("./clientPublicMainnet.advanced.js");
|
|
9
|
+
const clientTypes_js_1 = require("./clientTypes.js");
|
|
10
|
+
const index_js_1 = require("./jsonRpc/index.js");
|
|
5
11
|
/**
|
|
6
12
|
* @public
|
|
7
13
|
*/
|
|
8
|
-
|
|
14
|
+
class ClientPublicMainnet extends index_js_1.ClientJsonRpc {
|
|
9
15
|
constructor(config) {
|
|
10
16
|
super(config?.url ??
|
|
11
|
-
(typeof
|
|
17
|
+
(typeof isomorphic_ws_1.default !== "undefined"
|
|
12
18
|
? "wss://mainnet.ckb.dev/ws"
|
|
13
19
|
: "https://mainnet.ckb.dev/"), config);
|
|
14
20
|
this.config = config;
|
|
15
21
|
}
|
|
16
22
|
get scripts() {
|
|
17
|
-
return this.config?.scripts ?? MAINNET_SCRIPTS;
|
|
23
|
+
return this.config?.scripts ?? clientPublicMainnet_advanced_js_1.MAINNET_SCRIPTS;
|
|
18
24
|
}
|
|
19
25
|
get addressPrefix() {
|
|
20
26
|
return "ckb";
|
|
@@ -24,6 +30,7 @@ export class ClientPublicMainnet extends ClientJsonRpc {
|
|
|
24
30
|
if (!found) {
|
|
25
31
|
throw new Error(`No script information was found for ${script} on ${this.addressPrefix}`);
|
|
26
32
|
}
|
|
27
|
-
return ScriptInfo.from(found);
|
|
33
|
+
return clientTypes_js_1.ScriptInfo.from(found);
|
|
28
34
|
}
|
|
29
35
|
}
|
|
36
|
+
exports.ClientPublicMainnet = ClientPublicMainnet;
|