@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,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientJsonRpc = void 0;
|
|
4
|
+
const index_js_1 = require("../../ckb/index.js");
|
|
5
|
+
const index_js_2 = require("../../hex/index.js");
|
|
6
|
+
const index_js_3 = require("../../num/index.js");
|
|
7
|
+
const index_js_4 = require("../../utils/index.js");
|
|
8
|
+
const client_js_1 = require("../client.js");
|
|
9
|
+
const clientTypes_js_1 = require("../clientTypes.js");
|
|
10
|
+
const advanced_js_1 = require("../transports/advanced.js");
|
|
11
|
+
const advanced_js_2 = require("./advanced.js");
|
|
9
12
|
/**
|
|
10
13
|
* Applies a transformation function to a value if the transformer is provided.
|
|
11
14
|
*
|
|
@@ -28,11 +31,11 @@ function transform(value, transformer) {
|
|
|
28
31
|
const ERROR_PARSERS = [
|
|
29
32
|
[
|
|
30
33
|
"Resolve\\(Unknown\\(OutPoint\\((0x.*)\\)\\)\\)",
|
|
31
|
-
(error, match) => new ErrorClientResolveUnknown(error, OutPoint.fromBytes(match[1])),
|
|
34
|
+
(error, match) => new clientTypes_js_1.ErrorClientResolveUnknown(error, index_js_1.OutPoint.fromBytes(match[1])),
|
|
32
35
|
],
|
|
33
36
|
[
|
|
34
37
|
"Verification\\(Error { kind: Script, inner: TransactionScriptError { source: (Inputs|Outputs)\\[([0-9]*)\\].(Lock|Type), cause: ValidationFailure: see error code (-?[0-9])* on page https://nervosnetwork\\.github\\.io/ckb-script-error-codes/by-(type|data)-hash/(.*)\\.html",
|
|
35
|
-
(error, match) => new ErrorClientVerification(error, match[3] === "Lock"
|
|
38
|
+
(error, match) => new clientTypes_js_1.ErrorClientVerification(error, match[3] === "Lock"
|
|
36
39
|
? "lock"
|
|
37
40
|
: match[1] === "Inputs"
|
|
38
41
|
? "inputType"
|
|
@@ -40,18 +43,18 @@ const ERROR_PARSERS = [
|
|
|
40
43
|
],
|
|
41
44
|
[
|
|
42
45
|
"Duplicated\\(Byte32\\((0x.*)\\)\\)",
|
|
43
|
-
(error, match) => new ErrorClientDuplicatedTransaction(error, match[1]),
|
|
46
|
+
(error, match) => new clientTypes_js_1.ErrorClientDuplicatedTransaction(error, match[1]),
|
|
44
47
|
],
|
|
45
48
|
[
|
|
46
49
|
'RBFRejected\\("Tx\'s current fee is ([0-9]*), expect it to >= ([0-9]*) to replace old txs"\\)',
|
|
47
|
-
(error, match) => new ErrorClientRBFRejected(error, match[1], match[2]),
|
|
50
|
+
(error, match) => new clientTypes_js_1.ErrorClientRBFRejected(error, match[1], match[2]),
|
|
48
51
|
],
|
|
49
52
|
];
|
|
50
53
|
/**
|
|
51
54
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
52
55
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
53
56
|
*/
|
|
54
|
-
|
|
57
|
+
class ClientJsonRpc extends client_js_1.Client {
|
|
55
58
|
/**
|
|
56
59
|
* Creates an instance of ClientJsonRpc.
|
|
57
60
|
*
|
|
@@ -67,23 +70,23 @@ export class ClientJsonRpc extends Client {
|
|
|
67
70
|
*
|
|
68
71
|
* @returns Fee rate statistics
|
|
69
72
|
*/
|
|
70
|
-
this.getFeeRateStatistics = this.buildSender("get_fee_rate_statistics", [(n) => apply(numFrom, n)], ({ mean, median }) => ({
|
|
71
|
-
mean: numFrom(mean),
|
|
72
|
-
median: numFrom(median),
|
|
73
|
+
this.getFeeRateStatistics = this.buildSender("get_fee_rate_statistics", [(n) => (0, index_js_4.apply)(index_js_3.numFrom, n)], ({ mean, median }) => ({
|
|
74
|
+
mean: (0, index_js_3.numFrom)(mean),
|
|
75
|
+
median: (0, index_js_3.numFrom)(median),
|
|
73
76
|
}));
|
|
74
77
|
/**
|
|
75
78
|
* Get tip block number
|
|
76
79
|
*
|
|
77
80
|
* @returns Tip block number
|
|
78
81
|
*/
|
|
79
|
-
this.getTip = this.buildSender("get_tip_block_number", [], numFrom);
|
|
82
|
+
this.getTip = this.buildSender("get_tip_block_number", [], index_js_3.numFrom);
|
|
80
83
|
/**
|
|
81
84
|
* Get tip block header
|
|
82
85
|
*
|
|
83
86
|
* @param verbosity - result format which allows 0 and 1. (Optional, the default is 1.)
|
|
84
87
|
* @returns BlockHeader
|
|
85
88
|
*/
|
|
86
|
-
this.getTipHeader = this.buildSender("get_tip_header", [], (b) => apply(JsonRpcTransformers.blockHeaderTo, b));
|
|
89
|
+
this.getTipHeader = this.buildSender("get_tip_header", [], (b) => (0, index_js_4.apply)(advanced_js_2.JsonRpcTransformers.blockHeaderTo, b));
|
|
87
90
|
/**
|
|
88
91
|
* Get block by block number
|
|
89
92
|
*
|
|
@@ -92,7 +95,7 @@ export class ClientJsonRpc extends Client {
|
|
|
92
95
|
* @param withCycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
93
96
|
* @returns Block
|
|
94
97
|
*/
|
|
95
|
-
this.getBlockByNumber = this.buildSender("get_block_by_number", [(v) => numToHex(numFrom(v))], (b) => apply(JsonRpcTransformers.blockTo, b));
|
|
98
|
+
this.getBlockByNumber = this.buildSender("get_block_by_number", [(v) => (0, index_js_3.numToHex)((0, index_js_3.numFrom)(v))], (b) => (0, index_js_4.apply)(advanced_js_2.JsonRpcTransformers.blockTo, b));
|
|
96
99
|
/**
|
|
97
100
|
* Get block by block hash
|
|
98
101
|
*
|
|
@@ -101,7 +104,7 @@ export class ClientJsonRpc extends Client {
|
|
|
101
104
|
* @param withCycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
102
105
|
* @returns Block
|
|
103
106
|
*/
|
|
104
|
-
this.getBlockByHash = this.buildSender("get_block", [hexFrom], (b) => apply(JsonRpcTransformers.blockTo, b));
|
|
107
|
+
this.getBlockByHash = this.buildSender("get_block", [index_js_2.hexFrom], (b) => (0, index_js_4.apply)(advanced_js_2.JsonRpcTransformers.blockTo, b));
|
|
105
108
|
/**
|
|
106
109
|
* Get header by block number
|
|
107
110
|
*
|
|
@@ -109,7 +112,7 @@ export class ClientJsonRpc extends Client {
|
|
|
109
112
|
* @param verbosity - result format which allows 0 and 1. (Optional, the default is 1.)
|
|
110
113
|
* @returns BlockHeader
|
|
111
114
|
*/
|
|
112
|
-
this.getHeaderByNumber = this.buildSender("get_header_by_number", [(v) => numToHex(numFrom(v))], (b) => apply(JsonRpcTransformers.blockHeaderTo, b));
|
|
115
|
+
this.getHeaderByNumber = this.buildSender("get_header_by_number", [(v) => (0, index_js_3.numToHex)((0, index_js_3.numFrom)(v))], (b) => (0, index_js_4.apply)(advanced_js_2.JsonRpcTransformers.blockHeaderTo, b));
|
|
113
116
|
/**
|
|
114
117
|
* Get header by block hash
|
|
115
118
|
*
|
|
@@ -117,14 +120,14 @@ export class ClientJsonRpc extends Client {
|
|
|
117
120
|
* @param verbosity - result format which allows 0 and 1. (Optional, the default is 1.)
|
|
118
121
|
* @returns BlockHeader
|
|
119
122
|
*/
|
|
120
|
-
this.getHeaderByHash = this.buildSender("get_header", [hexFrom], (b) => apply(JsonRpcTransformers.blockHeaderTo, b));
|
|
123
|
+
this.getHeaderByHash = this.buildSender("get_header", [index_js_2.hexFrom], (b) => (0, index_js_4.apply)(advanced_js_2.JsonRpcTransformers.blockHeaderTo, b));
|
|
121
124
|
/**
|
|
122
125
|
* Estimate cycles of a transaction.
|
|
123
126
|
*
|
|
124
127
|
* @param transaction - The transaction to estimate.
|
|
125
128
|
* @returns Consumed cycles
|
|
126
129
|
*/
|
|
127
|
-
this.estimateCycles = this.buildSender("estimate_cycles", [JsonRpcTransformers.transactionFrom], ({ cycles }) => numFrom(cycles));
|
|
130
|
+
this.estimateCycles = this.buildSender("estimate_cycles", [advanced_js_2.JsonRpcTransformers.transactionFrom], ({ cycles }) => (0, index_js_3.numFrom)(cycles));
|
|
128
131
|
/**
|
|
129
132
|
* Test a transaction.
|
|
130
133
|
*
|
|
@@ -132,7 +135,7 @@ export class ClientJsonRpc extends Client {
|
|
|
132
135
|
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
133
136
|
* @returns Consumed cycles
|
|
134
137
|
*/
|
|
135
|
-
this.sendTransactionDry = this.buildSender("test_tx_pool_accept", [JsonRpcTransformers.transactionFrom], ({ cycles }) => numFrom(cycles));
|
|
138
|
+
this.sendTransactionDry = this.buildSender("test_tx_pool_accept", [advanced_js_2.JsonRpcTransformers.transactionFrom], ({ cycles }) => (0, index_js_3.numFrom)(cycles));
|
|
136
139
|
/**
|
|
137
140
|
* Send a transaction to node.
|
|
138
141
|
*
|
|
@@ -140,14 +143,14 @@ export class ClientJsonRpc extends Client {
|
|
|
140
143
|
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
141
144
|
* @returns Transaction hash.
|
|
142
145
|
*/
|
|
143
|
-
this.sendTransactionNoCache = this.buildSender("send_transaction", [JsonRpcTransformers.transactionFrom], hexFrom);
|
|
146
|
+
this.sendTransactionNoCache = this.buildSender("send_transaction", [advanced_js_2.JsonRpcTransformers.transactionFrom], index_js_2.hexFrom);
|
|
144
147
|
/**
|
|
145
148
|
* Get a transaction from node.
|
|
146
149
|
*
|
|
147
150
|
* @param txHash - The hash of the transaction.
|
|
148
151
|
* @returns The transaction with status.
|
|
149
152
|
*/
|
|
150
|
-
this.getTransactionNoCache = this.buildSender("get_transaction", [hexFrom], JsonRpcTransformers.transactionResponseTo);
|
|
153
|
+
this.getTransactionNoCache = this.buildSender("get_transaction", [index_js_2.hexFrom], advanced_js_2.JsonRpcTransformers.transactionResponseTo);
|
|
151
154
|
/**
|
|
152
155
|
* find cells from node.
|
|
153
156
|
*
|
|
@@ -158,10 +161,10 @@ export class ClientJsonRpc extends Client {
|
|
|
158
161
|
* @returns The found cells.
|
|
159
162
|
*/
|
|
160
163
|
this.findCellsPagedNoCache = this.buildSender("get_cells", [
|
|
161
|
-
JsonRpcTransformers.indexerSearchKeyFrom,
|
|
164
|
+
advanced_js_2.JsonRpcTransformers.indexerSearchKeyFrom,
|
|
162
165
|
(order) => order ?? "asc",
|
|
163
|
-
(limit) => numToHex(limit ?? 10),
|
|
164
|
-
], JsonRpcTransformers.findCellsResponseTo);
|
|
166
|
+
(limit) => (0, index_js_3.numToHex)(limit ?? 10),
|
|
167
|
+
], advanced_js_2.JsonRpcTransformers.findCellsResponseTo);
|
|
165
168
|
/**
|
|
166
169
|
* find transactions from node.
|
|
167
170
|
*
|
|
@@ -172,18 +175,18 @@ export class ClientJsonRpc extends Client {
|
|
|
172
175
|
* @returns The found transactions.
|
|
173
176
|
*/
|
|
174
177
|
this.findTransactionsPaged = this.buildSender("get_transactions", [
|
|
175
|
-
JsonRpcTransformers.indexerSearchKeyTransactionFrom,
|
|
178
|
+
advanced_js_2.JsonRpcTransformers.indexerSearchKeyTransactionFrom,
|
|
176
179
|
(order) => order ?? "asc",
|
|
177
|
-
(limit) => numToHex(limit ?? 10),
|
|
178
|
-
], JsonRpcTransformers.findTransactionsResponseTo);
|
|
180
|
+
(limit) => (0, index_js_3.numToHex)(limit ?? 10),
|
|
181
|
+
], advanced_js_2.JsonRpcTransformers.findTransactionsResponseTo);
|
|
179
182
|
/**
|
|
180
183
|
* get cells capacity from node.
|
|
181
184
|
*
|
|
182
185
|
* @param key - The search key of cells.
|
|
183
186
|
* @returns The sum of cells capacity.
|
|
184
187
|
*/
|
|
185
|
-
this.getCellsCapacity = this.buildSender("get_cells_capacity", [JsonRpcTransformers.indexerSearchKeyFrom], ({ capacity }) => numFrom(capacity));
|
|
186
|
-
this.transport = transportFromUri(url_, config);
|
|
188
|
+
this.getCellsCapacity = this.buildSender("get_cells_capacity", [advanced_js_2.JsonRpcTransformers.indexerSearchKeyFrom], ({ capacity }) => (0, index_js_3.numFrom)(capacity));
|
|
189
|
+
this.transport = (0, advanced_js_1.transportFromUri)(url_, config);
|
|
187
190
|
}
|
|
188
191
|
/**
|
|
189
192
|
* Returns the URL of the JSON-RPC server.
|
|
@@ -202,8 +205,8 @@ export class ClientJsonRpc extends Client {
|
|
|
202
205
|
* @returns The cell
|
|
203
206
|
*/
|
|
204
207
|
getCellLiveNoCache(outPoint, withData, includeTxPool) {
|
|
205
|
-
return this.buildSender("get_live_cell", [JsonRpcTransformers.outPointFrom], ({ cell, }) => apply(({ output, data, }) => Cell.from({
|
|
206
|
-
cellOutput: JsonRpcTransformers.cellOutputTo(output),
|
|
208
|
+
return this.buildSender("get_live_cell", [advanced_js_2.JsonRpcTransformers.outPointFrom], ({ cell, }) => (0, index_js_4.apply)(({ output, data, }) => index_js_1.Cell.from({
|
|
209
|
+
cellOutput: advanced_js_2.JsonRpcTransformers.cellOutputTo(output),
|
|
207
210
|
outputData: data?.content ?? "0x",
|
|
208
211
|
outPoint,
|
|
209
212
|
}), cell))(outPoint, withData ?? true, includeTxPool);
|
|
@@ -242,7 +245,7 @@ export class ClientJsonRpc extends Client {
|
|
|
242
245
|
throw builder(err, match);
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
|
-
throw new ErrorClientBase(err);
|
|
248
|
+
throw new clientTypes_js_1.ErrorClientBase(err);
|
|
246
249
|
}
|
|
247
250
|
};
|
|
248
251
|
}
|
|
@@ -280,3 +283,4 @@ export class ClientJsonRpc extends Client {
|
|
|
280
283
|
};
|
|
281
284
|
}
|
|
282
285
|
}
|
|
286
|
+
exports.ClientJsonRpc = ClientJsonRpc;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonRpcTransformers = void 0;
|
|
4
|
+
const index_js_1 = require("../../bytes/index.js");
|
|
5
|
+
const index_js_2 = require("../../ckb/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 clientTypes_js_1 = require("../clientTypes.js");
|
|
10
|
+
class JsonRpcTransformers {
|
|
8
11
|
static hashTypeFrom(hashType) {
|
|
9
|
-
return hashTypeFrom(hashType);
|
|
12
|
+
return (0, index_js_2.hashTypeFrom)(hashType);
|
|
10
13
|
}
|
|
11
14
|
static hashTypeTo(hashType) {
|
|
12
15
|
return hashType;
|
|
13
16
|
}
|
|
14
17
|
static depTypeFrom(depType) {
|
|
15
|
-
switch (depTypeFrom(depType)) {
|
|
18
|
+
switch ((0, index_js_2.depTypeFrom)(depType)) {
|
|
16
19
|
case "code":
|
|
17
20
|
return "code";
|
|
18
21
|
case "depGroup":
|
|
@@ -28,7 +31,7 @@ export class JsonRpcTransformers {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
static scriptFrom(scriptLike) {
|
|
31
|
-
const script = Script.from(scriptLike);
|
|
34
|
+
const script = index_js_2.Script.from(scriptLike);
|
|
32
35
|
return {
|
|
33
36
|
code_hash: script.codeHash,
|
|
34
37
|
hash_type: JsonRpcTransformers.hashTypeFrom(script.hashType),
|
|
@@ -36,50 +39,50 @@ export class JsonRpcTransformers {
|
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
static scriptTo(script) {
|
|
39
|
-
return Script.from({
|
|
42
|
+
return index_js_2.Script.from({
|
|
40
43
|
codeHash: script.code_hash,
|
|
41
44
|
hashType: JsonRpcTransformers.hashTypeTo(script.hash_type),
|
|
42
45
|
args: script.args,
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
static outPointFrom(outPointLike) {
|
|
46
|
-
const outPoint = OutPoint.from(outPointLike);
|
|
49
|
+
const outPoint = index_js_2.OutPoint.from(outPointLike);
|
|
47
50
|
return {
|
|
48
|
-
index: numToHex(outPoint.index),
|
|
51
|
+
index: (0, index_js_4.numToHex)(outPoint.index),
|
|
49
52
|
tx_hash: outPoint.txHash,
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
55
|
static outPointTo(outPoint) {
|
|
53
|
-
return OutPoint.from({
|
|
56
|
+
return index_js_2.OutPoint.from({
|
|
54
57
|
index: outPoint.index,
|
|
55
58
|
txHash: outPoint.tx_hash,
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
61
|
static cellInputFrom(cellInputLike) {
|
|
59
|
-
const cellInput = CellInput.from(cellInputLike);
|
|
62
|
+
const cellInput = index_js_2.CellInput.from(cellInputLike);
|
|
60
63
|
return {
|
|
61
64
|
previous_output: JsonRpcTransformers.outPointFrom(cellInput.previousOutput),
|
|
62
|
-
since: numToHex(cellInput.since),
|
|
65
|
+
since: (0, index_js_4.numToHex)(cellInput.since),
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
static cellInputTo(cellInput) {
|
|
66
|
-
return CellInput.from({
|
|
69
|
+
return index_js_2.CellInput.from({
|
|
67
70
|
previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),
|
|
68
71
|
since: cellInput.since,
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
static cellOutputFrom(cellOutput) {
|
|
72
75
|
return {
|
|
73
|
-
capacity: numToHex(cellOutput.capacity),
|
|
76
|
+
capacity: (0, index_js_4.numToHex)(cellOutput.capacity),
|
|
74
77
|
lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
|
|
75
|
-
type: apply(JsonRpcTransformers.scriptFrom, cellOutput.type),
|
|
78
|
+
type: (0, index_js_5.apply)(JsonRpcTransformers.scriptFrom, cellOutput.type),
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
static cellOutputTo(cellOutput) {
|
|
79
|
-
return CellOutput.from({
|
|
82
|
+
return index_js_2.CellOutput.from({
|
|
80
83
|
capacity: cellOutput.capacity,
|
|
81
84
|
lock: JsonRpcTransformers.scriptTo(cellOutput.lock),
|
|
82
|
-
type: apply(JsonRpcTransformers.scriptTo, cellOutput.type),
|
|
85
|
+
type: (0, index_js_5.apply)(JsonRpcTransformers.scriptTo, cellOutput.type),
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
88
|
static cellDepFrom(cellDep) {
|
|
@@ -89,15 +92,15 @@ export class JsonRpcTransformers {
|
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
static cellDepTo(cellDep) {
|
|
92
|
-
return CellDep.from({
|
|
95
|
+
return index_js_2.CellDep.from({
|
|
93
96
|
outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),
|
|
94
97
|
depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
static transactionFrom(txLike) {
|
|
98
|
-
const tx = Transaction.from(txLike);
|
|
101
|
+
const tx = index_js_2.Transaction.from(txLike);
|
|
99
102
|
return {
|
|
100
|
-
version: numToHex(tx.version),
|
|
103
|
+
version: (0, index_js_4.numToHex)(tx.version),
|
|
101
104
|
cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),
|
|
102
105
|
header_deps: tx.headerDeps,
|
|
103
106
|
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),
|
|
@@ -107,7 +110,7 @@ export class JsonRpcTransformers {
|
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
112
|
static transactionTo(tx) {
|
|
110
|
-
return Transaction.from({
|
|
113
|
+
return index_js_2.Transaction.from({
|
|
111
114
|
version: tx.version,
|
|
112
115
|
cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),
|
|
113
116
|
headerDeps: tx.header_deps,
|
|
@@ -124,33 +127,33 @@ export class JsonRpcTransformers {
|
|
|
124
127
|
return {
|
|
125
128
|
transaction: JsonRpcTransformers.transactionTo(transaction),
|
|
126
129
|
status,
|
|
127
|
-
cycles: apply(numFrom, cycles),
|
|
128
|
-
blockHash: apply(hexFrom, block_hash),
|
|
129
|
-
blockNumber: apply(numFrom, block_number),
|
|
130
|
-
txIndex: apply(numFrom, tx_index),
|
|
130
|
+
cycles: (0, index_js_5.apply)(index_js_4.numFrom, cycles),
|
|
131
|
+
blockHash: (0, index_js_5.apply)(index_js_3.hexFrom, block_hash),
|
|
132
|
+
blockNumber: (0, index_js_5.apply)(index_js_4.numFrom, block_number),
|
|
133
|
+
txIndex: (0, index_js_5.apply)(index_js_4.numFrom, tx_index),
|
|
131
134
|
reason,
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
static blockHeaderTo(header) {
|
|
135
|
-
const dao = bytesFrom(header.dao);
|
|
138
|
+
const dao = (0, index_js_1.bytesFrom)(header.dao);
|
|
136
139
|
return {
|
|
137
|
-
compactTarget: numFrom(header.compact_target),
|
|
140
|
+
compactTarget: (0, index_js_4.numFrom)(header.compact_target),
|
|
138
141
|
dao: {
|
|
139
|
-
c: numLeFromBytes(dao.slice(0, 8)),
|
|
140
|
-
ar: numLeFromBytes(dao.slice(8, 16)),
|
|
141
|
-
s: numLeFromBytes(dao.slice(16, 24)),
|
|
142
|
-
u: numLeFromBytes(dao.slice(24, 32)),
|
|
142
|
+
c: (0, index_js_4.numLeFromBytes)(dao.slice(0, 8)),
|
|
143
|
+
ar: (0, index_js_4.numLeFromBytes)(dao.slice(8, 16)),
|
|
144
|
+
s: (0, index_js_4.numLeFromBytes)(dao.slice(16, 24)),
|
|
145
|
+
u: (0, index_js_4.numLeFromBytes)(dao.slice(24, 32)),
|
|
143
146
|
},
|
|
144
|
-
epoch: epochFromHex(header.epoch),
|
|
147
|
+
epoch: (0, index_js_2.epochFromHex)(header.epoch),
|
|
145
148
|
extraHash: header.extra_hash,
|
|
146
149
|
hash: header.hash,
|
|
147
|
-
nonce: numFrom(header.nonce),
|
|
148
|
-
number: numFrom(header.number),
|
|
150
|
+
nonce: (0, index_js_4.numFrom)(header.nonce),
|
|
151
|
+
number: (0, index_js_4.numFrom)(header.number),
|
|
149
152
|
parentHash: header.parent_hash,
|
|
150
153
|
proposalsHash: header.proposals_hash,
|
|
151
|
-
timestamp: numFrom(header.timestamp),
|
|
154
|
+
timestamp: (0, index_js_4.numFrom)(header.timestamp),
|
|
152
155
|
transactionsRoot: header.transactions_root,
|
|
153
|
-
version: numFrom(header.version),
|
|
156
|
+
version: (0, index_js_4.numFrom)(header.version),
|
|
154
157
|
};
|
|
155
158
|
}
|
|
156
159
|
static blockUncleTo(block) {
|
|
@@ -168,33 +171,33 @@ export class JsonRpcTransformers {
|
|
|
168
171
|
};
|
|
169
172
|
}
|
|
170
173
|
static rangeFrom([a, b]) {
|
|
171
|
-
return [numToHex(a), numToHex(b)];
|
|
174
|
+
return [(0, index_js_4.numToHex)(a), (0, index_js_4.numToHex)(b)];
|
|
172
175
|
}
|
|
173
176
|
static indexerSearchKeyFilterFrom(filter) {
|
|
174
177
|
return {
|
|
175
|
-
script: apply(JsonRpcTransformers.scriptFrom, filter.script),
|
|
176
|
-
script_len_range: apply(JsonRpcTransformers.rangeFrom, filter.scriptLenRange),
|
|
178
|
+
script: (0, index_js_5.apply)(JsonRpcTransformers.scriptFrom, filter.script),
|
|
179
|
+
script_len_range: (0, index_js_5.apply)(JsonRpcTransformers.rangeFrom, filter.scriptLenRange),
|
|
177
180
|
output_data: filter.outputData,
|
|
178
181
|
output_data_filter_mode: filter.outputDataSearchMode,
|
|
179
|
-
output_data_len_range: apply(JsonRpcTransformers.rangeFrom, filter.outputDataLenRange),
|
|
180
|
-
output_capacity_range: apply(JsonRpcTransformers.rangeFrom, filter.outputCapacityRange),
|
|
181
|
-
block_range: apply(JsonRpcTransformers.rangeFrom, filter.blockRange),
|
|
182
|
+
output_data_len_range: (0, index_js_5.apply)(JsonRpcTransformers.rangeFrom, filter.outputDataLenRange),
|
|
183
|
+
output_capacity_range: (0, index_js_5.apply)(JsonRpcTransformers.rangeFrom, filter.outputCapacityRange),
|
|
184
|
+
block_range: (0, index_js_5.apply)(JsonRpcTransformers.rangeFrom, filter.blockRange),
|
|
182
185
|
};
|
|
183
186
|
}
|
|
184
187
|
static indexerSearchKeyFrom(keyLike) {
|
|
185
|
-
const key = ClientIndexerSearchKey.from(keyLike);
|
|
188
|
+
const key = clientTypes_js_1.ClientIndexerSearchKey.from(keyLike);
|
|
186
189
|
return {
|
|
187
190
|
script: JsonRpcTransformers.scriptFrom(key.script),
|
|
188
191
|
script_type: key.scriptType,
|
|
189
192
|
script_search_mode: key.scriptSearchMode,
|
|
190
|
-
filter: apply(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),
|
|
193
|
+
filter: (0, index_js_5.apply)(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),
|
|
191
194
|
with_data: key.withData,
|
|
192
195
|
};
|
|
193
196
|
}
|
|
194
197
|
static findCellsResponseTo({ last_cursor, objects, }) {
|
|
195
198
|
return {
|
|
196
199
|
lastCursor: last_cursor,
|
|
197
|
-
cells: objects.map((cell) => Cell.from({
|
|
200
|
+
cells: objects.map((cell) => index_js_2.Cell.from({
|
|
198
201
|
outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
|
|
199
202
|
cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
|
|
200
203
|
outputData: cell.output_data ?? "0x",
|
|
@@ -202,12 +205,12 @@ export class JsonRpcTransformers {
|
|
|
202
205
|
};
|
|
203
206
|
}
|
|
204
207
|
static indexerSearchKeyTransactionFrom(keyLike) {
|
|
205
|
-
const key = ClientIndexerSearchKeyTransaction.from(keyLike);
|
|
208
|
+
const key = clientTypes_js_1.ClientIndexerSearchKeyTransaction.from(keyLike);
|
|
206
209
|
return {
|
|
207
210
|
script: JsonRpcTransformers.scriptFrom(key.script),
|
|
208
211
|
script_type: key.scriptType,
|
|
209
212
|
script_search_mode: key.scriptSearchMode,
|
|
210
|
-
filter: apply(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),
|
|
213
|
+
filter: (0, index_js_5.apply)(JsonRpcTransformers.indexerSearchKeyFilterFrom, key.filter),
|
|
211
214
|
group_by_transaction: key.groupByTransaction,
|
|
212
215
|
};
|
|
213
216
|
}
|
|
@@ -223,9 +226,9 @@ export class JsonRpcTransformers {
|
|
|
223
226
|
lastCursor: last_cursor,
|
|
224
227
|
transactions: objects.map((tx) => ({
|
|
225
228
|
txHash: tx.tx_hash,
|
|
226
|
-
blockNumber: numFrom(tx.block_number),
|
|
227
|
-
txIndex: numFrom(tx.tx_index),
|
|
228
|
-
cellIndex: numFrom(tx.io_index),
|
|
229
|
+
blockNumber: (0, index_js_4.numFrom)(tx.block_number),
|
|
230
|
+
txIndex: (0, index_js_4.numFrom)(tx.tx_index),
|
|
231
|
+
cellIndex: (0, index_js_4.numFrom)(tx.io_index),
|
|
229
232
|
isInput: tx.io_type === "input",
|
|
230
233
|
})),
|
|
231
234
|
};
|
|
@@ -234,13 +237,14 @@ export class JsonRpcTransformers {
|
|
|
234
237
|
lastCursor: last_cursor,
|
|
235
238
|
transactions: objects.map((tx) => ({
|
|
236
239
|
txHash: tx.tx_hash,
|
|
237
|
-
blockNumber: numFrom(tx.block_number),
|
|
238
|
-
txIndex: numFrom(tx.tx_index),
|
|
240
|
+
blockNumber: (0, index_js_4.numFrom)(tx.block_number),
|
|
241
|
+
txIndex: (0, index_js_4.numFrom)(tx.tx_index),
|
|
239
242
|
cells: tx.cells.map(([type, i]) => ({
|
|
240
243
|
isInput: type === "input",
|
|
241
|
-
cellIndex: numFrom(i),
|
|
244
|
+
cellIndex: (0, index_js_4.numFrom)(i),
|
|
242
245
|
})),
|
|
243
246
|
})),
|
|
244
247
|
};
|
|
245
248
|
}
|
|
246
249
|
}
|
|
250
|
+
exports.JsonRpcTransformers = JsonRpcTransformers;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,11 +1,28 @@
|
|
|
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
|
+
exports.transportFromUri = transportFromUri;
|
|
18
|
+
const http_js_1 = require("./http.js");
|
|
19
|
+
const webSocket_js_1 = require("./webSocket.js");
|
|
20
|
+
__exportStar(require("./http.js"), exports);
|
|
21
|
+
__exportStar(require("./transport.js"), exports);
|
|
22
|
+
__exportStar(require("./webSocket.js"), exports);
|
|
23
|
+
function transportFromUri(uri, config) {
|
|
7
24
|
if (uri.startsWith("wss://")) {
|
|
8
|
-
return new TransportWebSocket(uri, config?.timeout);
|
|
25
|
+
return new webSocket_js_1.TransportWebSocket(uri, config?.timeout);
|
|
9
26
|
}
|
|
10
|
-
return new TransportHttp(uri, config?.timeout);
|
|
27
|
+
return new http_js_1.TransportHttp(uri, config?.timeout);
|
|
11
28
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransportHttp = void 0;
|
|
4
|
+
class TransportHttp {
|
|
2
5
|
constructor(url, timeout = 30000) {
|
|
3
6
|
this.url = url;
|
|
4
7
|
this.timeout = timeout;
|
|
@@ -20,3 +23,4 @@ export class TransportHttp {
|
|
|
20
23
|
return raw;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
26
|
+
exports.TransportHttp = TransportHttp;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.TransportWebSocket = void 0;
|
|
7
|
+
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
8
|
+
class TransportWebSocket {
|
|
3
9
|
constructor(url, timeout = 30000) {
|
|
4
10
|
this.url = url;
|
|
5
11
|
this.timeout = timeout;
|
|
@@ -13,7 +19,7 @@ export class TransportWebSocket {
|
|
|
13
19
|
this.openSocket) {
|
|
14
20
|
return this.openSocket;
|
|
15
21
|
}
|
|
16
|
-
const socket = new
|
|
22
|
+
const socket = new isomorphic_ws_1.default(this.url);
|
|
17
23
|
const onMessage = ({ data }) => {
|
|
18
24
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
19
25
|
const res = JSON.parse(data);
|
|
@@ -81,3 +87,4 @@ export class TransportWebSocket {
|
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
exports.TransportWebSocket = TransportWebSocket;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Represents a fixed point value as a bigint.
|
|
3
4
|
* @public
|
|
4
5
|
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.One = exports.Zero = void 0;
|
|
8
|
+
exports.fixedPointToString = fixedPointToString;
|
|
9
|
+
exports.fixedPointFrom = fixedPointFrom;
|
|
5
10
|
/**
|
|
6
11
|
* Converts a FixedPointLike value to its string representation with fixed-point decimals.
|
|
7
12
|
* @public
|
|
@@ -17,7 +22,7 @@
|
|
|
17
22
|
* const strFromNumber = fixedPointToString(1.23456789, 8); // Outputs "1.23456789"
|
|
18
23
|
* ```
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
function fixedPointToString(val, decimals = 8) {
|
|
21
26
|
const str = fixedPointFrom(val).toString();
|
|
22
27
|
if (decimals === 0) {
|
|
23
28
|
return str;
|
|
@@ -44,7 +49,7 @@ export function fixedPointToString(val, decimals = 8) {
|
|
|
44
49
|
* const fixedPointFromNumber = fixedPointFrom(1.23456789, 8); // Outputs 123456789n
|
|
45
50
|
* ```
|
|
46
51
|
*/
|
|
47
|
-
|
|
52
|
+
function fixedPointFrom(val, decimals = 8) {
|
|
48
53
|
if (typeof val === "bigint") {
|
|
49
54
|
return val;
|
|
50
55
|
}
|
|
@@ -59,10 +64,10 @@ export function fixedPointFrom(val, decimals = 8) {
|
|
|
59
64
|
* Represents the fixed point value of zero as a bigint.
|
|
60
65
|
* @public
|
|
61
66
|
*/
|
|
62
|
-
|
|
67
|
+
exports.Zero = 0n;
|
|
63
68
|
/**
|
|
64
69
|
* Represents the fixed point value of one as a FixedPoint (bigint).
|
|
65
70
|
* Equivalent to 1 in fixed-point representation with default decimals (8).
|
|
66
71
|
* @public
|
|
67
72
|
*/
|
|
68
|
-
|
|
73
|
+
exports.One = fixedPointFrom("1");
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|