@ckb-ccc/core 0.0.8-alpha.3 → 0.0.8-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ckb/script.js +2 -2
- package/dist/ckb/transaction.js +2 -2
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +1 -0
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +35 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +20 -0
- package/dist/hasher/index.d.ts +17 -2
- package/dist/hasher/index.d.ts.map +1 -1
- package/dist/hasher/index.js +19 -2
- package/dist/signer/nostr/signerNostr.js +2 -2
- package/dist.commonjs/address/address.advanced.d.ts +24 -29
- package/dist.commonjs/address/address.advanced.js +89 -115
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +14 -30
- package/dist.commonjs/address/index.d.ts +44 -51
- package/dist.commonjs/address/index.js +65 -84
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +22 -47
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +14 -30
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +14 -30
- package/dist.commonjs/bytes/advanced.d.ts +2 -11
- package/dist.commonjs/bytes/index.d.ts +3 -9
- package/dist.commonjs/bytes/index.js +26 -28
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +22 -47
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +14 -30
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +9 -12
- package/dist.commonjs/ckb/script.d.ts +117 -121
- package/dist.commonjs/ckb/script.js +176 -220
- package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/transaction.advanced.js +4 -4
- package/dist.commonjs/ckb/transaction.d.ts +717 -792
- package/dist.commonjs/ckb/transaction.js +1155 -1383
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +14 -30
- package/dist.commonjs/client/client.advanced.d.ts +6 -23
- package/dist.commonjs/client/client.advanced.js +61 -89
- package/dist.commonjs/client/client.d.ts +54 -113
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +182 -214
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +161 -144
- package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicMainnet.js +15 -17
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -204
- package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicTestnet.js +13 -13
- package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
- package/dist.commonjs/client/clientTypes.advanced.js +1 -1
- package/dist.commonjs/client/clientTypes.d.ts +26 -51
- package/dist.commonjs/client/clientTypes.js +22 -56
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +14 -30
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
- package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
- package/dist.commonjs/client/jsonRpc/index.js +108 -135
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
- package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +3 -9
- package/dist.commonjs/fixedPoint/index.js +20 -26
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +36 -42
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +53 -38
- package/dist.commonjs/hasher/index.d.ts.map +1 -1
- package/dist.commonjs/hasher/index.js +69 -58
- package/dist.commonjs/hex/index.d.ts +1 -1
- package/dist.commonjs/hex/index.js +1 -1
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +22 -47
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +27 -39
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +14 -30
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.js +66 -89
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
- package/dist.commonjs/signer/btc/verify.d.ts +2 -6
- package/dist.commonjs/signer/btc/verify.js +3 -10
- package/dist.commonjs/signer/ckb/index.d.ts +1 -1
- package/dist.commonjs/signer/ckb/index.js +14 -30
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
- package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
- package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
- package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
- package/dist.commonjs/signer/dummy/dummy.js +16 -16
- package/dist.commonjs/signer/dummy/index.d.ts +1 -1
- package/dist.commonjs/signer/dummy/index.js +14 -30
- package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
- package/dist.commonjs/signer/dummy/openLink.js +7 -7
- package/dist.commonjs/signer/evm/index.d.ts +1 -1
- package/dist.commonjs/signer/evm/index.js +14 -30
- package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
- package/dist.commonjs/signer/evm/signerEvm.js +70 -105
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
- package/dist.commonjs/signer/evm/verify.d.ts +2 -6
- package/dist.commonjs/signer/evm/verify.js +2 -7
- package/dist.commonjs/signer/index.d.ts +1 -1
- package/dist.commonjs/signer/index.js +14 -30
- package/dist.commonjs/signer/nostr/index.d.ts +1 -1
- package/dist.commonjs/signer/nostr/index.js +14 -30
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
- package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
- package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
- package/dist.commonjs/signer/nostr/verify.js +39 -50
- package/dist.commonjs/signer/signer/index.d.ts +150 -156
- package/dist.commonjs/signer/signer/index.js +181 -208
- package/dist.commonjs/utils/index.d.ts +8 -38
- package/dist.commonjs/utils/index.js +12 -18
- package/package.json +3 -3
- package/src/ckb/script.ts +2 -2
- package/src/ckb/transaction.ts +2 -2
- package/src/client/client.ts +1 -0
- package/src/client/clientPublicMainnet.advanced.ts +40 -1
- package/src/client/clientPublicTestnet.advanced.ts +23 -0
- package/src/hasher/index.ts +27 -2
- package/src/signer/nostr/signerNostr.ts +2 -2
|
@@ -6,64 +6,30 @@ const hex_1 = require("../hex");
|
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const clientTypes_advanced_1 = require("./clientTypes.advanced");
|
|
8
8
|
class ClientIndexerSearchKeyFilter {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.outputDataSearchMode = outputDataSearchMode;
|
|
22
|
-
this.outputDataLenRange = outputDataLenRange;
|
|
23
|
-
this.outputCapacityRange = outputCapacityRange;
|
|
24
|
-
this.blockRange = blockRange;
|
|
25
|
-
}
|
|
26
|
-
static from(filterLike) {
|
|
27
|
-
return new ClientIndexerSearchKeyFilter(
|
|
28
|
-
(0, utils_1.apply)(ckb_1.Script.from, filterLike.script),
|
|
29
|
-
(0, utils_1.apply)(
|
|
30
|
-
clientTypes_advanced_1.clientSearchKeyRangeFrom,
|
|
31
|
-
filterLike.scriptLenRange,
|
|
32
|
-
),
|
|
33
|
-
(0, utils_1.apply)(hex_1.hexFrom, filterLike.outputData),
|
|
34
|
-
filterLike.outputDataSearchMode,
|
|
35
|
-
(0, utils_1.apply)(
|
|
36
|
-
clientTypes_advanced_1.clientSearchKeyRangeFrom,
|
|
37
|
-
filterLike.outputDataLenRange,
|
|
38
|
-
),
|
|
39
|
-
(0, utils_1.apply)(
|
|
40
|
-
clientTypes_advanced_1.clientSearchKeyRangeFrom,
|
|
41
|
-
filterLike.outputCapacityRange,
|
|
42
|
-
),
|
|
43
|
-
(0, utils_1.apply)(
|
|
44
|
-
clientTypes_advanced_1.clientSearchKeyRangeFrom,
|
|
45
|
-
filterLike.blockRange,
|
|
46
|
-
),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
9
|
+
constructor(script, scriptLenRange, outputData, outputDataSearchMode, outputDataLenRange, outputCapacityRange, blockRange) {
|
|
10
|
+
this.script = script;
|
|
11
|
+
this.scriptLenRange = scriptLenRange;
|
|
12
|
+
this.outputData = outputData;
|
|
13
|
+
this.outputDataSearchMode = outputDataSearchMode;
|
|
14
|
+
this.outputDataLenRange = outputDataLenRange;
|
|
15
|
+
this.outputCapacityRange = outputCapacityRange;
|
|
16
|
+
this.blockRange = blockRange;
|
|
17
|
+
}
|
|
18
|
+
static from(filterLike) {
|
|
19
|
+
return new ClientIndexerSearchKeyFilter((0, utils_1.apply)(ckb_1.Script.from, filterLike.script), (0, utils_1.apply)(clientTypes_advanced_1.clientSearchKeyRangeFrom, filterLike.scriptLenRange), (0, utils_1.apply)(hex_1.hexFrom, filterLike.outputData), filterLike.outputDataSearchMode, (0, utils_1.apply)(clientTypes_advanced_1.clientSearchKeyRangeFrom, filterLike.outputDataLenRange), (0, utils_1.apply)(clientTypes_advanced_1.clientSearchKeyRangeFrom, filterLike.outputCapacityRange), (0, utils_1.apply)(clientTypes_advanced_1.clientSearchKeyRangeFrom, filterLike.blockRange));
|
|
20
|
+
}
|
|
49
21
|
}
|
|
50
22
|
exports.ClientIndexerSearchKeyFilter = ClientIndexerSearchKeyFilter;
|
|
51
23
|
class ClientIndexerSearchKey {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
keyLike.scriptType,
|
|
63
|
-
keyLike.scriptSearchMode,
|
|
64
|
-
(0, utils_1.apply)(ClientIndexerSearchKeyFilter.from, keyLike.filter),
|
|
65
|
-
keyLike.withData,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
24
|
+
constructor(script, scriptType, scriptSearchMode, filter, withData) {
|
|
25
|
+
this.script = script;
|
|
26
|
+
this.scriptType = scriptType;
|
|
27
|
+
this.scriptSearchMode = scriptSearchMode;
|
|
28
|
+
this.filter = filter;
|
|
29
|
+
this.withData = withData;
|
|
30
|
+
}
|
|
31
|
+
static from(keyLike) {
|
|
32
|
+
return new ClientIndexerSearchKey(ckb_1.Script.from(keyLike.script), keyLike.scriptType, keyLike.scriptSearchMode, (0, utils_1.apply)(ClientIndexerSearchKeyFilter.from, keyLike.filter), keyLike.withData);
|
|
33
|
+
}
|
|
68
34
|
}
|
|
69
35
|
exports.ClientIndexerSearchKey = ClientIndexerSearchKey;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
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
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./client"), exports);
|
|
34
18
|
__exportStar(require("./clientPublicMainnet"), exports);
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
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
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./transformers"), exports);
|
|
34
18
|
__exportStar(require("./types"), exports);
|
|
@@ -2,104 +2,85 @@ import { TransactionLike } from "../../ckb";
|
|
|
2
2
|
import { Hex, HexLike } from "../../hex";
|
|
3
3
|
import { Num, NumLike } from "../../num";
|
|
4
4
|
import { Client } from "../client";
|
|
5
|
-
import {
|
|
6
|
-
ClientFindCellsResponse,
|
|
7
|
-
ClientIndexerSearchKeyLike,
|
|
8
|
-
ClientTransactionResponse,
|
|
9
|
-
OutputsValidator,
|
|
10
|
-
} from "../clientTypes";
|
|
5
|
+
import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, OutputsValidator } from "../clientTypes";
|
|
11
6
|
import { JsonRpcPayload } from "./advanced";
|
|
12
7
|
/**
|
|
13
8
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
14
9
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
15
10
|
*/
|
|
16
11
|
export declare abstract class ClientJsonRpc extends Client {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* @param payload - The JSON-RPC payload to send.
|
|
91
|
-
* @returns The result of the JSON-RPC request.
|
|
92
|
-
*
|
|
93
|
-
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
94
|
-
*/
|
|
95
|
-
send(payload: JsonRpcPayload): Promise<unknown>;
|
|
96
|
-
/**
|
|
97
|
-
* Builds a JSON-RPC payload for the given method and parameters.
|
|
98
|
-
*
|
|
99
|
-
* @param method - The JSON-RPC method name.
|
|
100
|
-
* @param req - The parameters for the JSON-RPC method.
|
|
101
|
-
* @returns The JSON-RPC payload.
|
|
102
|
-
*/
|
|
103
|
-
static buildPayload(method: string, req: unknown[]): JsonRpcPayload;
|
|
12
|
+
private readonly url_;
|
|
13
|
+
private readonly timeout;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of ClientJsonRpc.
|
|
16
|
+
*
|
|
17
|
+
* @param url - The URL of the JSON-RPC server.
|
|
18
|
+
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
19
|
+
*/
|
|
20
|
+
constructor(url_: string, timeout?: number);
|
|
21
|
+
/**
|
|
22
|
+
* Returns the URL of the JSON-RPC server.
|
|
23
|
+
*
|
|
24
|
+
* @returns The URL of the JSON-RPC server.
|
|
25
|
+
*/
|
|
26
|
+
get url(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Send a transaction to node.
|
|
29
|
+
*
|
|
30
|
+
* @param transaction - The transaction to send.
|
|
31
|
+
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
32
|
+
* @returns Transaction hash.
|
|
33
|
+
*/
|
|
34
|
+
sendTransactionNoCache: (transaction: TransactionLike, validator?: OutputsValidator | undefined) => Promise<Hex>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a transaction from node.
|
|
37
|
+
*
|
|
38
|
+
* @param txHash - The hash of the transaction.
|
|
39
|
+
* @returns The transaction with status.
|
|
40
|
+
*/
|
|
41
|
+
getTransactionNoCache: (txHash: HexLike) => Promise<ClientTransactionResponse | null>;
|
|
42
|
+
/**
|
|
43
|
+
* find cells from node.
|
|
44
|
+
*
|
|
45
|
+
* @param key - The search key of cells.
|
|
46
|
+
* @param order - The order of cells.
|
|
47
|
+
* @param limit - The max return size of cells.
|
|
48
|
+
* @param after - Pagination parameter.
|
|
49
|
+
* @returns The found cells.
|
|
50
|
+
*/
|
|
51
|
+
findCellsPagedNoCache: (key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string) => Promise<ClientFindCellsResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* get cells capacity from node.
|
|
54
|
+
*
|
|
55
|
+
* @param key - The search key of cells.
|
|
56
|
+
* @returns The sum of cells capacity.
|
|
57
|
+
*/
|
|
58
|
+
getCellsCapacity: (key: ClientIndexerSearchKeyLike) => Promise<Num>;
|
|
59
|
+
/**
|
|
60
|
+
* Builds a sender function for a JSON-RPC method.
|
|
61
|
+
*
|
|
62
|
+
* @param rpcMethod - The JSON-RPC method.
|
|
63
|
+
* @param inTransformers - An array of input transformers.
|
|
64
|
+
* @param outTransformer - An output transformer function.
|
|
65
|
+
* @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
|
|
66
|
+
*/
|
|
67
|
+
buildSender(rpcMethod: string, inTransformers: (((_: any) => unknown) | undefined)[], outTransformer?: (_: any) => unknown): (...req: unknown[]) => Promise<unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* Sends a JSON-RPC request to the server.
|
|
70
|
+
*
|
|
71
|
+
* @param payload - The JSON-RPC payload to send.
|
|
72
|
+
* @returns The result of the JSON-RPC request.
|
|
73
|
+
*
|
|
74
|
+
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
75
|
+
*/
|
|
76
|
+
send(payload: JsonRpcPayload): Promise<unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Builds a JSON-RPC payload for the given method and parameters.
|
|
79
|
+
*
|
|
80
|
+
* @param method - The JSON-RPC method name.
|
|
81
|
+
* @param req - The parameters for the JSON-RPC method.
|
|
82
|
+
* @returns The JSON-RPC payload.
|
|
83
|
+
*/
|
|
84
|
+
static buildPayload(method: string, req: unknown[]): JsonRpcPayload;
|
|
104
85
|
}
|
|
105
|
-
//# sourceMappingURL=index.d.ts.map
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
7
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
6
|
exports.ClientJsonRpc = void 0;
|
|
9
7
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
@@ -25,155 +23,130 @@ const advanced_1 = require("./advanced");
|
|
|
25
23
|
* ```
|
|
26
24
|
*/
|
|
27
25
|
async function transform(value, transformer) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
if (transformer) {
|
|
27
|
+
return transformer(value);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
35
33
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
36
34
|
*/
|
|
37
35
|
class ClientJsonRpc extends client_1.Client {
|
|
38
|
-
/**
|
|
39
|
-
* Creates an instance of ClientJsonRpc.
|
|
40
|
-
*
|
|
41
|
-
* @param url - The URL of the JSON-RPC server.
|
|
42
|
-
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
43
|
-
*/
|
|
44
|
-
constructor(url_, timeout = 30000) {
|
|
45
|
-
super();
|
|
46
|
-
this.url_ = url_;
|
|
47
|
-
this.timeout = timeout;
|
|
48
36
|
/**
|
|
49
|
-
*
|
|
37
|
+
* Creates an instance of ClientJsonRpc.
|
|
50
38
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @returns Transaction hash.
|
|
39
|
+
* @param url - The URL of the JSON-RPC server.
|
|
40
|
+
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
54
41
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
constructor(url_, timeout = 30000) {
|
|
43
|
+
super();
|
|
44
|
+
this.url_ = url_;
|
|
45
|
+
this.timeout = timeout;
|
|
46
|
+
/**
|
|
47
|
+
* Send a transaction to node.
|
|
48
|
+
*
|
|
49
|
+
* @param transaction - The transaction to send.
|
|
50
|
+
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
51
|
+
* @returns Transaction hash.
|
|
52
|
+
*/
|
|
53
|
+
this.sendTransactionNoCache = this.buildSender("send_transaction", [advanced_1.JsonRpcTransformers.transactionFrom], hex_1.hexFrom);
|
|
54
|
+
/**
|
|
55
|
+
* Get a transaction from node.
|
|
56
|
+
*
|
|
57
|
+
* @param txHash - The hash of the transaction.
|
|
58
|
+
* @returns The transaction with status.
|
|
59
|
+
*/
|
|
60
|
+
this.getTransactionNoCache = this.buildSender("get_transaction", [hex_1.hexFrom], advanced_1.JsonRpcTransformers.transactionResponseTo);
|
|
61
|
+
/**
|
|
62
|
+
* find cells from node.
|
|
63
|
+
*
|
|
64
|
+
* @param key - The search key of cells.
|
|
65
|
+
* @param order - The order of cells.
|
|
66
|
+
* @param limit - The max return size of cells.
|
|
67
|
+
* @param after - Pagination parameter.
|
|
68
|
+
* @returns The found cells.
|
|
69
|
+
*/
|
|
70
|
+
this.findCellsPagedNoCache = this.buildSender("get_cells", [
|
|
71
|
+
advanced_1.JsonRpcTransformers.indexerSearchKeyFrom,
|
|
72
|
+
(order) => order ?? "asc",
|
|
73
|
+
(limit) => (0, num_1.numToHex)(limit ?? 10),
|
|
74
|
+
], advanced_1.JsonRpcTransformers.findCellsResponseTo);
|
|
75
|
+
/**
|
|
76
|
+
* get cells capacity from node.
|
|
77
|
+
*
|
|
78
|
+
* @param key - The search key of cells.
|
|
79
|
+
* @returns The sum of cells capacity.
|
|
80
|
+
*/
|
|
81
|
+
this.getCellsCapacity = this.buildSender("get_cells_capacity", [advanced_1.JsonRpcTransformers.indexerSearchKeyFrom], ({ capacity }) => (0, num_1.numFrom)(capacity));
|
|
82
|
+
}
|
|
60
83
|
/**
|
|
61
|
-
*
|
|
84
|
+
* Returns the URL of the JSON-RPC server.
|
|
62
85
|
*
|
|
63
|
-
* @
|
|
64
|
-
* @returns The transaction with status.
|
|
86
|
+
* @returns The URL of the JSON-RPC server.
|
|
65
87
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
advanced_1.JsonRpcTransformers.transactionResponseTo,
|
|
70
|
-
);
|
|
88
|
+
get url() {
|
|
89
|
+
return this.url_;
|
|
90
|
+
}
|
|
71
91
|
/**
|
|
72
|
-
*
|
|
92
|
+
* Builds a sender function for a JSON-RPC method.
|
|
73
93
|
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @
|
|
78
|
-
* @returns The found cells.
|
|
94
|
+
* @param rpcMethod - The JSON-RPC method.
|
|
95
|
+
* @param inTransformers - An array of input transformers.
|
|
96
|
+
* @param outTransformer - An output transformer function.
|
|
97
|
+
* @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
|
|
79
98
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
99
|
+
buildSender(rpcMethod, inTransformers, outTransformer) {
|
|
100
|
+
return async (...req) => {
|
|
101
|
+
const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req
|
|
102
|
+
.concat(Array.from(new Array(Math.max(inTransformers.length - req.length, 0))))
|
|
103
|
+
.map((v, i) => transform(v, inTransformers[i]))));
|
|
104
|
+
return transform(await this.send(payload), outTransformer);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
89
107
|
/**
|
|
90
|
-
*
|
|
108
|
+
* Sends a JSON-RPC request to the server.
|
|
91
109
|
*
|
|
92
|
-
* @param
|
|
93
|
-
* @returns The
|
|
110
|
+
* @param payload - The JSON-RPC payload to send.
|
|
111
|
+
* @returns The result of the JSON-RPC request.
|
|
112
|
+
*
|
|
113
|
+
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
94
114
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
|
|
116
|
-
*/
|
|
117
|
-
buildSender(rpcMethod, inTransformers, outTransformer) {
|
|
118
|
-
return async (...req) => {
|
|
119
|
-
const payload = ClientJsonRpc.buildPayload(
|
|
120
|
-
rpcMethod,
|
|
121
|
-
await Promise.all(
|
|
122
|
-
req
|
|
123
|
-
.concat(
|
|
124
|
-
Array.from(
|
|
125
|
-
new Array(Math.max(inTransformers.length - req.length, 0)),
|
|
126
|
-
),
|
|
127
|
-
)
|
|
128
|
-
.map((v, i) => transform(v, inTransformers[i])),
|
|
129
|
-
),
|
|
130
|
-
);
|
|
131
|
-
return transform(await this.send(payload), outTransformer);
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Sends a JSON-RPC request to the server.
|
|
136
|
-
*
|
|
137
|
-
* @param payload - The JSON-RPC payload to send.
|
|
138
|
-
* @returns The result of the JSON-RPC request.
|
|
139
|
-
*
|
|
140
|
-
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
141
|
-
*/
|
|
142
|
-
async send(payload) {
|
|
143
|
-
const aborter = new AbortController();
|
|
144
|
-
const abortTimer = setTimeout(() => aborter.abort(), this.timeout);
|
|
145
|
-
const raw = await (0, cross_fetch_1.default)(this.url, {
|
|
146
|
-
method: "POST",
|
|
147
|
-
headers: {
|
|
148
|
-
"content-type": "application/json",
|
|
149
|
-
},
|
|
150
|
-
body: JSON.stringify(payload),
|
|
151
|
-
signal: aborter.signal,
|
|
152
|
-
});
|
|
153
|
-
clearTimeout(abortTimer);
|
|
154
|
-
const res = await raw.json();
|
|
155
|
-
if (res.id !== payload.id) {
|
|
156
|
-
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
115
|
+
async send(payload) {
|
|
116
|
+
const aborter = new AbortController();
|
|
117
|
+
const abortTimer = setTimeout(() => aborter.abort(), this.timeout);
|
|
118
|
+
const raw = await (0, cross_fetch_1.default)(this.url, {
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: {
|
|
121
|
+
"content-type": "application/json",
|
|
122
|
+
},
|
|
123
|
+
body: JSON.stringify(payload),
|
|
124
|
+
signal: aborter.signal,
|
|
125
|
+
});
|
|
126
|
+
clearTimeout(abortTimer);
|
|
127
|
+
const res = (await raw.json());
|
|
128
|
+
if (res.id !== payload.id) {
|
|
129
|
+
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
130
|
+
}
|
|
131
|
+
if (res.error) {
|
|
132
|
+
throw res.error;
|
|
133
|
+
}
|
|
134
|
+
return res.result;
|
|
157
135
|
}
|
|
158
|
-
|
|
159
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Builds a JSON-RPC payload for the given method and parameters.
|
|
138
|
+
*
|
|
139
|
+
* @param method - The JSON-RPC method name.
|
|
140
|
+
* @param req - The parameters for the JSON-RPC method.
|
|
141
|
+
* @returns The JSON-RPC payload.
|
|
142
|
+
*/
|
|
143
|
+
static buildPayload(method, req) {
|
|
144
|
+
return {
|
|
145
|
+
id: Math.round(Math.random() * 10000),
|
|
146
|
+
method,
|
|
147
|
+
params: req,
|
|
148
|
+
jsonrpc: "2.0",
|
|
149
|
+
};
|
|
160
150
|
}
|
|
161
|
-
return res.result;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Builds a JSON-RPC payload for the given method and parameters.
|
|
165
|
-
*
|
|
166
|
-
* @param method - The JSON-RPC method name.
|
|
167
|
-
* @param req - The parameters for the JSON-RPC method.
|
|
168
|
-
* @returns The JSON-RPC payload.
|
|
169
|
-
*/
|
|
170
|
-
static buildPayload(method, req) {
|
|
171
|
-
return {
|
|
172
|
-
id: Math.round(Math.random() * 10000),
|
|
173
|
-
method,
|
|
174
|
-
params: req,
|
|
175
|
-
jsonrpc: "2.0",
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
151
|
}
|
|
179
152
|
exports.ClientJsonRpc = ClientJsonRpc;
|