@ckb-ccc/core 0.0.9-alpha.1 → 0.0.10-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/transaction.d.ts +19 -15
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +44 -10
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +30 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +3 -3
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/clientTypes.advanced.d.ts +8 -8
- package/dist/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist/client/clientTypes.d.ts +2 -2
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +2 -2
- package/dist/signer/ckb/index.d.ts +3 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +3 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts +12 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
- package/dist/signer/ckb/signerCkbPrivateKey.js +38 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts +18 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
- package/dist/signer/ckb/signerCkbPublicKey.js +44 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +5 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.js +14 -0
- package/dist/signer/evm/signerEvm.d.ts +2 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +2 -2
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/signer/index.d.ts +8 -6
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +9 -5
- package/dist/utils/index.d.ts +18 -9
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist.commonjs/address/address.advanced.d.ts +29 -24
- package/dist.commonjs/address/address.advanced.js +115 -89
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +30 -14
- package/dist.commonjs/address/index.d.ts +51 -44
- package/dist.commonjs/address/index.js +84 -65
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +47 -22
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/bytes/advanced.d.ts +11 -2
- package/dist.commonjs/bytes/index.d.ts +9 -3
- package/dist.commonjs/bytes/index.js +28 -26
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +47 -22
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +30 -14
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +12 -9
- package/dist.commonjs/ckb/script.d.ts +121 -117
- package/dist.commonjs/ckb/script.js +220 -176
- 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 +806 -718
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +1425 -1158
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +30 -14
- package/dist.commonjs/client/client.advanced.d.ts +23 -6
- package/dist.commonjs/client/client.advanced.js +89 -61
- package/dist.commonjs/client/client.d.ts +114 -54
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +215 -182
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +8 -4
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +215 -161
- package/dist.commonjs/client/clientPublicMainnet.d.ts +8 -6
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +17 -15
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +6 -3
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +227 -199
- package/dist.commonjs/client/clientPublicTestnet.d.ts +8 -6
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +13 -13
- package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
- package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.advanced.js +1 -1
- package/dist.commonjs/client/clientTypes.d.ts +52 -27
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +56 -22
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +30 -14
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
- package/dist.commonjs/client/jsonRpc/index.d.ts +94 -75
- package/dist.commonjs/client/jsonRpc/index.js +135 -108
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +76 -36
- package/dist.commonjs/client/jsonRpc/transformers.js +174 -152
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +9 -3
- package/dist.commonjs/fixedPoint/index.js +26 -20
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +42 -36
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +40 -37
- package/dist.commonjs/hasher/index.js +58 -48
- 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 +47 -22
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +39 -27
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +30 -14
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.js +89 -66
- 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 +6 -2
- package/dist.commonjs/signer/btc/verify.js +10 -3
- package/dist.commonjs/signer/ckb/index.d.ts +4 -1
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +33 -14
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +12 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +56 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +18 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +58 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +11 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +27 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -2
- package/dist.commonjs/signer/ckb/verifyJoyId.js +11 -8
- 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 +30 -14
- 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 +30 -14
- package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -38
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +105 -70
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +38 -38
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
- package/dist.commonjs/signer/evm/verify.d.ts +6 -2
- package/dist.commonjs/signer/evm/verify.js +7 -2
- package/dist.commonjs/signer/index.d.ts +1 -1
- package/dist.commonjs/signer/index.js +30 -14
- package/dist.commonjs/signer/nostr/index.d.ts +1 -1
- package/dist.commonjs/signer/nostr/index.js +30 -14
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
- package/dist.commonjs/signer/nostr/signerNostr.js +100 -71
- package/dist.commonjs/signer/nostr/verify.d.ts +9 -3
- package/dist.commonjs/signer/nostr/verify.js +50 -39
- package/dist.commonjs/signer/signer/index.d.ts +171 -160
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +235 -195
- package/dist.commonjs/utils/index.d.ts +56 -14
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +19 -13
- package/package.json +2 -2
- package/src/ckb/transaction.ts +87 -33
- package/src/client/client.ts +1 -1
- package/src/client/clientPublicMainnet.advanced.ts +34 -2
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.advanced.ts +3 -3
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/clientTypes.advanced.ts +8 -8
- package/src/client/clientTypes.ts +4 -4
- package/src/signer/ckb/index.ts +3 -0
- package/src/signer/ckb/signerCkbPrivateKey.ts +58 -0
- package/src/signer/ckb/signerCkbPublicKey.ts +63 -0
- package/src/signer/ckb/verifyCkbSecp256k1.ts +27 -0
- package/src/signer/evm/signerEvm.ts +2 -2
- package/src/signer/evm/signerEvmAddressReadonly.ts +1 -1
- package/src/signer/signer/index.ts +17 -9
- package/src/utils/index.ts +24 -12
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
exports.ClientJsonRpc = void 0;
|
|
7
9
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
@@ -23,130 +25,155 @@ const advanced_1 = require("./advanced");
|
|
|
23
25
|
* ```
|
|
24
26
|
*/
|
|
25
27
|
async function transform(value, transformer) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (transformer) {
|
|
29
|
+
return transformer(value);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
33
35
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
34
36
|
*/
|
|
35
37
|
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;
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* Send a transaction to node.
|
|
38
50
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
51
|
+
* @param transaction - The transaction to send.
|
|
52
|
+
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
53
|
+
* @returns Transaction hash.
|
|
41
54
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}
|
|
55
|
+
this.sendTransactionNoCache = this.buildSender(
|
|
56
|
+
"send_transaction",
|
|
57
|
+
[advanced_1.JsonRpcTransformers.transactionFrom],
|
|
58
|
+
hex_1.hexFrom,
|
|
59
|
+
);
|
|
83
60
|
/**
|
|
84
|
-
*
|
|
61
|
+
* Get a transaction from node.
|
|
85
62
|
*
|
|
86
|
-
* @
|
|
63
|
+
* @param txHash - The hash of the transaction.
|
|
64
|
+
* @returns The transaction with status.
|
|
87
65
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
66
|
+
this.getTransactionNoCache = this.buildSender(
|
|
67
|
+
"get_transaction",
|
|
68
|
+
[hex_1.hexFrom],
|
|
69
|
+
advanced_1.JsonRpcTransformers.transactionResponseTo,
|
|
70
|
+
);
|
|
91
71
|
/**
|
|
92
|
-
*
|
|
72
|
+
* find cells from node.
|
|
93
73
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @
|
|
74
|
+
* @param key - The search key of cells.
|
|
75
|
+
* @param order - The order of cells.
|
|
76
|
+
* @param limit - The max return size of cells.
|
|
77
|
+
* @param after - Pagination parameter.
|
|
78
|
+
* @returns The found cells.
|
|
98
79
|
*/
|
|
99
|
-
buildSender(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
this.findCellsPagedNoCache = this.buildSender(
|
|
81
|
+
"get_cells",
|
|
82
|
+
[
|
|
83
|
+
advanced_1.JsonRpcTransformers.indexerSearchKeyFrom,
|
|
84
|
+
(order) => order ?? "asc",
|
|
85
|
+
(limit) => (0, num_1.numToHex)(limit ?? 10),
|
|
86
|
+
],
|
|
87
|
+
advanced_1.JsonRpcTransformers.findCellsResponseTo,
|
|
88
|
+
);
|
|
107
89
|
/**
|
|
108
|
-
*
|
|
90
|
+
* get cells capacity from node.
|
|
109
91
|
*
|
|
110
|
-
* @param
|
|
111
|
-
* @returns The
|
|
112
|
-
*
|
|
113
|
-
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
92
|
+
* @param key - The search key of cells.
|
|
93
|
+
* @returns The sum of cells capacity.
|
|
114
94
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
95
|
+
this.getCellsCapacity = this.buildSender(
|
|
96
|
+
"get_cells_capacity",
|
|
97
|
+
[advanced_1.JsonRpcTransformers.indexerSearchKeyFrom],
|
|
98
|
+
({ capacity }) => (0, num_1.numFrom)(capacity),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the URL of the JSON-RPC server.
|
|
103
|
+
*
|
|
104
|
+
* @returns The URL of the JSON-RPC server.
|
|
105
|
+
*/
|
|
106
|
+
get url() {
|
|
107
|
+
return this.url_;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Builds a sender function for a JSON-RPC method.
|
|
111
|
+
*
|
|
112
|
+
* @param rpcMethod - The JSON-RPC method.
|
|
113
|
+
* @param inTransformers - An array of input transformers.
|
|
114
|
+
* @param outTransformer - An output transformer function.
|
|
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}`);
|
|
135
157
|
}
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
};
|
|
158
|
+
if (res.error) {
|
|
159
|
+
throw res.error;
|
|
150
160
|
}
|
|
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
|
+
}
|
|
151
178
|
}
|
|
152
179
|
exports.ClientJsonRpc = ClientJsonRpc;
|
|
@@ -1,40 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CellDep,
|
|
3
|
+
CellDepLike,
|
|
4
|
+
CellInput,
|
|
5
|
+
CellInputLike,
|
|
6
|
+
CellOutput,
|
|
7
|
+
CellOutputLike,
|
|
8
|
+
DepType,
|
|
9
|
+
DepTypeLike,
|
|
10
|
+
HashType,
|
|
11
|
+
HashTypeLike,
|
|
12
|
+
OutPoint,
|
|
13
|
+
OutPointLike,
|
|
14
|
+
Script,
|
|
15
|
+
ScriptLike,
|
|
16
|
+
Transaction,
|
|
17
|
+
TransactionLike,
|
|
18
|
+
} from "../../ckb";
|
|
2
19
|
import { Hex } from "../../hex";
|
|
3
20
|
import { NumLike } from "../../num";
|
|
4
|
-
import {
|
|
5
|
-
|
|
21
|
+
import {
|
|
22
|
+
ClientFindCellsResponse,
|
|
23
|
+
ClientIndexerSearchKeyLike,
|
|
24
|
+
ClientTransactionResponse,
|
|
25
|
+
TransactionStatus,
|
|
26
|
+
} from "../clientTypes";
|
|
27
|
+
import {
|
|
28
|
+
JsonRpcCellDep,
|
|
29
|
+
JsonRpcCellInput,
|
|
30
|
+
JsonRpcCellOutput,
|
|
31
|
+
JsonRpcDepType,
|
|
32
|
+
JsonRpcHashType,
|
|
33
|
+
JsonRpcIndexerSearchKey,
|
|
34
|
+
JsonRpcOutPoint,
|
|
35
|
+
JsonRpcScript,
|
|
36
|
+
JsonRpcTransaction,
|
|
37
|
+
} from "./types";
|
|
6
38
|
export declare class JsonRpcTransformers {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
|
|
40
|
+
static hashTypeTo(hashType: JsonRpcHashType): HashType;
|
|
41
|
+
static depTypeFrom(depType: DepTypeLike): JsonRpcDepType;
|
|
42
|
+
static depTypeTo(depType: JsonRpcDepType): DepType;
|
|
43
|
+
static scriptFrom(scriptLike: ScriptLike): JsonRpcScript;
|
|
44
|
+
static scriptTo(script: JsonRpcScript): Script;
|
|
45
|
+
static outPointFrom(outPointLike: OutPointLike): JsonRpcOutPoint;
|
|
46
|
+
static outPointTo(outPoint: JsonRpcOutPoint): OutPoint;
|
|
47
|
+
static cellInputFrom(cellInputLike: CellInputLike): JsonRpcCellInput;
|
|
48
|
+
static cellInputTo(cellInput: JsonRpcCellInput): CellInput;
|
|
49
|
+
static cellOutputFrom(cellOutput: CellOutputLike): JsonRpcCellOutput;
|
|
50
|
+
static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput;
|
|
51
|
+
static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep;
|
|
52
|
+
static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
|
|
53
|
+
static transactionFrom(txLike: TransactionLike): JsonRpcTransaction;
|
|
54
|
+
static transactionTo(tx: JsonRpcTransaction): Transaction;
|
|
55
|
+
static transactionResponseTo({
|
|
56
|
+
tx_status: { status },
|
|
57
|
+
transaction,
|
|
58
|
+
}: {
|
|
59
|
+
tx_status: {
|
|
60
|
+
status: TransactionStatus;
|
|
61
|
+
};
|
|
62
|
+
transaction: JsonRpcTransaction | null;
|
|
63
|
+
}): ClientTransactionResponse | null;
|
|
64
|
+
static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex];
|
|
65
|
+
static indexerSearchKeyFrom(
|
|
66
|
+
keyLike: ClientIndexerSearchKeyLike,
|
|
67
|
+
): JsonRpcIndexerSearchKey;
|
|
68
|
+
static findCellsResponseTo({
|
|
69
|
+
last_cursor,
|
|
70
|
+
objects,
|
|
71
|
+
}: {
|
|
72
|
+
last_cursor: string;
|
|
73
|
+
objects: {
|
|
74
|
+
out_point: JsonRpcOutPoint;
|
|
75
|
+
output: JsonRpcCellOutput;
|
|
76
|
+
output_data?: Hex;
|
|
77
|
+
}[];
|
|
78
|
+
}): ClientFindCellsResponse;
|
|
39
79
|
}
|
|
40
|
-
//# sourceMappingURL=transformers.d.ts.map
|
|
80
|
+
//# sourceMappingURL=transformers.d.ts.map
|