@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/address/index.d.ts +1 -1
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +4 -4
- package/dist/ckb/transaction.d.ts +2 -2
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +2 -3
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +2 -1
- package/dist/client/clientPublicMainnet.d.ts +1 -1
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.d.ts +1 -1
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/jsonRpc/index.d.ts +3 -3
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +4 -4
- package/dist/signer/btc/index.d.ts +1 -0
- package/dist/signer/btc/index.d.ts.map +1 -1
- package/dist/signer/btc/index.js +1 -0
- package/dist/signer/btc/signerBtc.d.ts +9 -1
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +19 -3
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
- package/dist/signer/btc/verify.d.ts +3 -0
- package/dist/signer/btc/verify.d.ts.map +1 -0
- package/dist/signer/btc/verify.js +6 -0
- package/dist/signer/ckb/index.d.ts +1 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +1 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -7
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -10
- package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist/signer/ckb/verifyJoyId.js +12 -0
- package/dist/signer/dummy/alwaysError.d.ts +9 -0
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist/signer/dummy/alwaysError.js +10 -0
- package/dist/signer/dummy/dummy.d.ts +12 -0
- package/dist/signer/dummy/dummy.d.ts.map +1 -0
- package/dist/signer/dummy/dummy.js +19 -0
- package/dist/signer/dummy/index.d.ts +4 -0
- package/dist/signer/dummy/index.d.ts.map +1 -0
- package/dist/signer/dummy/index.js +3 -0
- package/dist/signer/dummy/openLink.d.ts +9 -0
- package/dist/signer/dummy/openLink.d.ts.map +1 -0
- package/dist/signer/dummy/openLink.js +10 -0
- package/dist/signer/evm/index.d.ts +1 -0
- package/dist/signer/evm/index.d.ts.map +1 -1
- package/dist/signer/evm/index.js +1 -0
- package/dist/signer/evm/signerEvm.d.ts +3 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +10 -4
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
- package/dist/signer/evm/verify.d.ts +3 -0
- package/dist/signer/evm/verify.d.ts.map +1 -0
- package/dist/signer/evm/verify.js +6 -0
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/{dist.commonjs/signer/signer.d.ts → dist/signer/signer/index.d.ts} +69 -25
- package/dist/signer/signer/index.d.ts.map +1 -0
- package/dist/signer/{signer.js → signer/index.js} +101 -16
- package/dist/utils/index.d.ts +60 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +20 -0
- package/dist.commonjs/address/address.advanced.d.ts +29 -24
- package/dist.commonjs/address/address.advanced.js +114 -92
- 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.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +87 -68
- 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 +76 -76
- package/dist.commonjs/ckb/script.js +166 -126
- 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 +570 -532
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +839 -723
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +30 -14
- package/dist.commonjs/client/client.d.ts +52 -21
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +67 -57
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +5 -2
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -24
- package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -4
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +9 -9
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +5 -2
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -24
- package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -4
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +9 -9
- package/dist.commonjs/client/clientTypes.d.ts +51 -36
- package/dist.commonjs/client/clientTypes.js +34 -19
- 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 +92 -75
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +135 -108
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +78 -38
- package/dist.commonjs/client/jsonRpc/transformers.js +175 -150
- 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 +36 -36
- package/dist.commonjs/hasher/index.js +52 -45
- 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 +30 -19
- package/dist.commonjs/signer/btc/index.d.ts +2 -1
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/index.js +31 -14
- package/dist.commonjs/signer/btc/signerBtc.d.ts +48 -40
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +85 -49
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
- package/dist.commonjs/signer/btc/verify.d.ts +7 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/verify.js +13 -0
- package/dist.commonjs/signer/ckb/index.d.ts +2 -1
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +31 -14
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +46 -50
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -58
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +7 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.js +19 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +9 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/alwaysError.js +14 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/dummy.js +23 -0
- package/dist.commonjs/signer/dummy/index.d.ts +4 -0
- package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/index.js +35 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts +9 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/openLink.js +14 -0
- package/dist.commonjs/signer/evm/index.d.ts +2 -1
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/index.js +31 -14
- package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -37
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +101 -63
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
- package/dist.commonjs/signer/evm/verify.d.ts +7 -0
- package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/verify.js +15 -0
- package/dist.commonjs/signer/index.d.ts +2 -1
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +31 -14
- package/dist.commonjs/signer/signer/index.d.ts +190 -0
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/signer/index.js +234 -0
- package/dist.commonjs/utils/index.d.ts +94 -6
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +33 -5
- package/package.json +6 -3
- package/src/address/index.ts +4 -7
- package/src/ckb/transaction.ts +4 -5
- package/src/client/client.ts +7 -6
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/jsonRpc/index.ts +3 -3
- package/src/signer/btc/index.ts +1 -0
- package/src/signer/btc/signerBtc.ts +22 -7
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
- package/src/signer/btc/verify.ts +14 -0
- package/src/signer/ckb/index.ts +1 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -11
- package/src/signer/ckb/verifyJoyId.ts +20 -0
- package/src/signer/dummy/alwaysError.ts +17 -0
- package/src/signer/dummy/dummy.ts +28 -0
- package/src/signer/dummy/index.ts +3 -0
- package/src/signer/dummy/openLink.ts +17 -0
- package/src/signer/evm/index.ts +1 -0
- package/src/signer/evm/signerEvm.ts +16 -10
- package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
- package/src/signer/evm/verify.ts +16 -0
- package/src/signer/index.ts +1 -0
- package/src/signer/{signer.ts → signer/index.ts} +135 -25
- package/src/utils/index.ts +108 -0
- package/dist/signer/signer.d.ts +0 -140
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.js +0 -125
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
|
@@ -1,42 +1,82 @@
|
|
|
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
|
-
|
|
40
|
-
|
|
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(cellInput: 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, block_number },
|
|
57
|
+
transaction,
|
|
58
|
+
}: {
|
|
59
|
+
tx_status: {
|
|
60
|
+
status: TransactionStatus;
|
|
61
|
+
block_number: Hex;
|
|
62
|
+
};
|
|
63
|
+
transaction: JsonRpcTransaction;
|
|
64
|
+
}): ClientTransactionResponse;
|
|
65
|
+
static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex];
|
|
66
|
+
static indexerSearchKeyFrom(
|
|
67
|
+
keyLike: ClientIndexerSearchKeyLike,
|
|
68
|
+
): JsonRpcIndexerSearchKey;
|
|
69
|
+
static findCellsResponseTo({
|
|
70
|
+
last_cursor,
|
|
71
|
+
objects,
|
|
72
|
+
}: {
|
|
73
|
+
last_cursor: string;
|
|
74
|
+
objects: {
|
|
75
|
+
block_number: Hex;
|
|
76
|
+
out_point: JsonRpcOutPoint;
|
|
77
|
+
output: JsonRpcCellOutput;
|
|
78
|
+
output_data: Hex;
|
|
79
|
+
}[];
|
|
80
|
+
}): ClientFindCellsResponse;
|
|
41
81
|
}
|
|
42
|
-
//# sourceMappingURL=transformers.d.ts.map
|
|
82
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -6,155 +6,180 @@ const num_1 = require("../../num");
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const clientTypes_1 = require("../clientTypes");
|
|
8
8
|
class JsonRpcTransformers {
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
9
|
+
static hashTypeFrom(hashType) {
|
|
10
|
+
return (0, ckb_1.hashTypeFrom)(hashType);
|
|
11
|
+
}
|
|
12
|
+
static hashTypeTo(hashType) {
|
|
13
|
+
return hashType;
|
|
14
|
+
}
|
|
15
|
+
static depTypeFrom(depType) {
|
|
16
|
+
switch ((0, ckb_1.depTypeFrom)(depType)) {
|
|
17
|
+
case "code":
|
|
18
|
+
return "code";
|
|
19
|
+
case "depGroup":
|
|
20
|
+
return "dep_group";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
static depTypeTo(depType) {
|
|
24
|
+
switch (depType) {
|
|
25
|
+
case "code":
|
|
26
|
+
return "code";
|
|
27
|
+
case "dep_group":
|
|
28
|
+
return "depGroup";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
static scriptFrom(scriptLike) {
|
|
32
|
+
const script = ckb_1.Script.from(scriptLike);
|
|
33
|
+
return {
|
|
34
|
+
code_hash: script.codeHash,
|
|
35
|
+
hash_type: JsonRpcTransformers.hashTypeFrom(script.hashType),
|
|
36
|
+
args: script.args,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static scriptTo(script) {
|
|
40
|
+
return ckb_1.Script.from({
|
|
41
|
+
codeHash: script.code_hash,
|
|
42
|
+
hashType: JsonRpcTransformers.hashTypeTo(script.hash_type),
|
|
43
|
+
args: script.args,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
static outPointFrom(outPointLike) {
|
|
47
|
+
const outPoint = ckb_1.OutPoint.from(outPointLike);
|
|
48
|
+
return {
|
|
49
|
+
index: (0, num_1.numToHex)(outPoint.index),
|
|
50
|
+
tx_hash: outPoint.txHash,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static outPointTo(outPoint) {
|
|
54
|
+
return ckb_1.OutPoint.from({
|
|
55
|
+
index: outPoint.index,
|
|
56
|
+
txHash: outPoint.tx_hash,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
static cellInputFrom(cellInput) {
|
|
60
|
+
return {
|
|
61
|
+
previous_output: JsonRpcTransformers.outPointFrom(
|
|
62
|
+
cellInput.previousOutput,
|
|
63
|
+
),
|
|
64
|
+
since: (0, num_1.numToHex)(cellInput.since),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
static cellInputTo(cellInput) {
|
|
68
|
+
return ckb_1.CellInput.from({
|
|
69
|
+
previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),
|
|
70
|
+
since: cellInput.since,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
static cellOutputFrom(cellOutput) {
|
|
74
|
+
return {
|
|
75
|
+
capacity: (0, num_1.numToHex)(cellOutput.capacity),
|
|
76
|
+
lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
|
|
77
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptFrom, cellOutput.type),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
static cellOutputTo(cellOutput) {
|
|
81
|
+
return ckb_1.CellOutput.from({
|
|
82
|
+
capacity: cellOutput.capacity,
|
|
83
|
+
lock: JsonRpcTransformers.scriptTo(cellOutput.lock),
|
|
84
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptTo, cellOutput.type),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
static cellDepFrom(cellDep) {
|
|
88
|
+
return {
|
|
89
|
+
out_point: JsonRpcTransformers.outPointFrom(cellDep.outPoint),
|
|
90
|
+
dep_type: JsonRpcTransformers.depTypeFrom(cellDep.depType),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
static cellDepTo(cellDep) {
|
|
94
|
+
return ckb_1.CellDep.from({
|
|
95
|
+
outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),
|
|
96
|
+
depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
static transactionFrom(txLike) {
|
|
100
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
101
|
+
return {
|
|
102
|
+
version: (0, num_1.numToHex)(tx.version),
|
|
103
|
+
cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),
|
|
104
|
+
header_deps: tx.headerDeps,
|
|
105
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),
|
|
106
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputFrom(o)),
|
|
107
|
+
outputs_data: tx.outputsData,
|
|
108
|
+
witnesses: tx.witnesses,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static transactionTo(tx) {
|
|
112
|
+
return ckb_1.Transaction.from({
|
|
113
|
+
version: tx.version,
|
|
114
|
+
cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),
|
|
115
|
+
headerDeps: tx.header_deps,
|
|
116
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputTo(i)),
|
|
117
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputTo(o)),
|
|
118
|
+
outputsData: tx.outputs_data,
|
|
119
|
+
witnesses: tx.witnesses,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
static transactionResponseTo({
|
|
123
|
+
tx_status: { status, block_number },
|
|
124
|
+
transaction,
|
|
125
|
+
}) {
|
|
126
|
+
return {
|
|
127
|
+
transaction: JsonRpcTransformers.transactionTo(transaction),
|
|
128
|
+
status,
|
|
129
|
+
blockNumber: (0, num_1.numFrom)(block_number),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
static rangeFrom([a, b]) {
|
|
133
|
+
return [(0, num_1.numToHex)(a), (0, num_1.numToHex)(b)];
|
|
134
|
+
}
|
|
135
|
+
static indexerSearchKeyFrom(keyLike) {
|
|
136
|
+
const key = clientTypes_1.ClientIndexerSearchKey.from(keyLike);
|
|
137
|
+
return {
|
|
138
|
+
script: JsonRpcTransformers.scriptFrom(key.script),
|
|
139
|
+
script_type: key.scriptType,
|
|
140
|
+
script_search_mode: key.scriptSearchMode,
|
|
141
|
+
filter: (0, utils_1.apply)(
|
|
142
|
+
(filter) => ({
|
|
143
|
+
script: (0, utils_1.apply)(
|
|
144
|
+
JsonRpcTransformers.scriptFrom,
|
|
145
|
+
filter.script,
|
|
146
|
+
),
|
|
147
|
+
script_len_range: (0, utils_1.apply)(
|
|
148
|
+
JsonRpcTransformers.rangeFrom,
|
|
149
|
+
filter.scriptLenRange,
|
|
150
|
+
),
|
|
151
|
+
output_data: filter.outputData,
|
|
152
|
+
output_data_filter_mode: filter.outputDataSearchMode,
|
|
153
|
+
output_data_len_range: (0, utils_1.apply)(
|
|
154
|
+
JsonRpcTransformers.rangeFrom,
|
|
155
|
+
filter.outputDataLenRange,
|
|
156
|
+
),
|
|
157
|
+
output_capacity_range: (0, utils_1.apply)(
|
|
158
|
+
JsonRpcTransformers.rangeFrom,
|
|
159
|
+
filter.outputCapacityRange,
|
|
160
|
+
),
|
|
161
|
+
block_range: (0, utils_1.apply)(
|
|
162
|
+
JsonRpcTransformers.rangeFrom,
|
|
163
|
+
filter.blockRange,
|
|
164
|
+
),
|
|
165
|
+
}),
|
|
166
|
+
key.filter,
|
|
167
|
+
),
|
|
168
|
+
with_data: key.withData,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
static findCellsResponseTo({ last_cursor, objects }) {
|
|
172
|
+
return {
|
|
173
|
+
lastCursor: last_cursor,
|
|
174
|
+
cells: objects.map((cell) =>
|
|
175
|
+
ckb_1.Cell.from({
|
|
176
|
+
blockNumber: cell.block_number,
|
|
177
|
+
outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
|
|
178
|
+
cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
|
|
179
|
+
outputData: cell.output_data,
|
|
180
|
+
}),
|
|
181
|
+
),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
159
184
|
}
|
|
160
185
|
exports.JsonRpcTransformers = JsonRpcTransformers;
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
import { Hex } from "../../hex";
|
|
2
2
|
export type JsonRpcPayload = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
id: number;
|
|
4
|
+
jsonrpc: "2.0";
|
|
5
|
+
method: string;
|
|
6
|
+
params: unknown[] | Record<string, unknown>;
|
|
7
7
|
};
|
|
8
8
|
export type JsonRpcHashType = "type" | "data" | "data1" | "data2";
|
|
9
9
|
export type JsonRpcDepType = "dep_group" | "code";
|
|
10
10
|
export type JsonRpcScript = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
code_hash: Hex;
|
|
12
|
+
hash_type: JsonRpcHashType;
|
|
13
|
+
args: Hex;
|
|
14
14
|
};
|
|
15
15
|
export type JsonRpcOutPoint = {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
index: Hex;
|
|
17
|
+
tx_hash: Hex;
|
|
18
18
|
};
|
|
19
19
|
export type JsonRpcCellInput = {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
previous_output: JsonRpcOutPoint;
|
|
21
|
+
since: Hex;
|
|
22
22
|
};
|
|
23
23
|
export type JsonRpcCellOutput = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
capacity: Hex;
|
|
25
|
+
lock: JsonRpcScript;
|
|
26
|
+
type?: JsonRpcScript;
|
|
27
27
|
};
|
|
28
28
|
export type JsonRpcCellDep = {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
out_point: JsonRpcOutPoint;
|
|
30
|
+
dep_type: JsonRpcDepType;
|
|
31
31
|
};
|
|
32
32
|
export type JsonRpcTransaction = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
version: Hex;
|
|
34
|
+
cell_deps: JsonRpcCellDep[];
|
|
35
|
+
header_deps: Hex[];
|
|
36
|
+
inputs: JsonRpcCellInput[];
|
|
37
|
+
outputs: JsonRpcCellOutput[];
|
|
38
|
+
outputs_data: Hex[];
|
|
39
|
+
witnesses: Hex[];
|
|
40
40
|
};
|
|
41
41
|
export type JsonRpcIndexerSearchKey = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=types.d.ts.map
|
|
42
|
+
script: JsonRpcScript;
|
|
43
|
+
script_type: "lock" | "type";
|
|
44
|
+
script_search_mode?: "prefix" | "exact" | "partial";
|
|
45
|
+
filter?: {
|
|
46
|
+
script?: JsonRpcScript;
|
|
47
|
+
script_len_range?: [Hex, Hex];
|
|
48
|
+
output_data?: Hex;
|
|
49
|
+
output_data_filter_mode?: "prefix" | "exact" | "partial";
|
|
50
|
+
output_data_len_range?: [Hex, Hex];
|
|
51
|
+
output_capacity_range?: [Hex, Hex];
|
|
52
|
+
block_range?: [Hex, Hex];
|
|
53
|
+
};
|
|
54
|
+
with_data?: boolean;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -21,7 +21,10 @@ export type FixedPointLike = bigint | string | number;
|
|
|
21
21
|
* const strFromNumber = fixedPointToString(123456789, 8); // Outputs "1.23456789"
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export declare function fixedPointToString(
|
|
24
|
+
export declare function fixedPointToString(
|
|
25
|
+
val: FixedPointLike,
|
|
26
|
+
decimals?: number,
|
|
27
|
+
): string;
|
|
25
28
|
/**
|
|
26
29
|
* Converts a FixedPointLike value to a FixedPoint (bigint) with fixed-point decimals.
|
|
27
30
|
*
|
|
@@ -36,7 +39,10 @@ export declare function fixedPointToString(val: FixedPointLike, decimals?: numbe
|
|
|
36
39
|
* const fixedPointFromNumber = fixedPointFrom(1.23456789, 8); // Outputs 123456789n
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
|
-
export declare function fixedPointFrom(
|
|
42
|
+
export declare function fixedPointFrom(
|
|
43
|
+
val: FixedPointLike,
|
|
44
|
+
decimals?: number,
|
|
45
|
+
): FixedPoint;
|
|
40
46
|
/**
|
|
41
47
|
* Represents the fixed point value of zero as a bigint.
|
|
42
48
|
*/
|
|
@@ -46,4 +52,4 @@ export declare const Zero = 0n;
|
|
|
46
52
|
* Equivalent to 1 in fixed-point representation with default decimals (8).
|
|
47
53
|
*/
|
|
48
54
|
export declare const One: bigint;
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Represents a fixed point value as a bigint.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.One =
|
|
6
|
+
exports.One =
|
|
7
|
+
exports.Zero =
|
|
8
|
+
exports.fixedPointFrom =
|
|
9
|
+
exports.fixedPointToString =
|
|
10
|
+
void 0;
|
|
7
11
|
/**
|
|
8
12
|
* Converts a FixedPointLike value to its string representation with fixed-point decimals.
|
|
9
13
|
*
|
|
@@ -19,16 +23,16 @@ exports.One = exports.Zero = exports.fixedPointFrom = exports.fixedPointToString
|
|
|
19
23
|
* ```
|
|
20
24
|
*/
|
|
21
25
|
function fixedPointToString(val, decimals = 8) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const str = fixedPointFrom(val).toString();
|
|
27
|
+
if (decimals === 0) {
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
const l = str.length <= decimals ? "0" : str.slice(0, -decimals);
|
|
31
|
+
const r = str.slice(-decimals).padStart(decimals, "0").replace(/0*$/, "");
|
|
32
|
+
if (r === "") {
|
|
33
|
+
return l;
|
|
34
|
+
}
|
|
35
|
+
return `${l}.${r}`;
|
|
32
36
|
}
|
|
33
37
|
exports.fixedPointToString = fixedPointToString;
|
|
34
38
|
/**
|
|
@@ -46,15 +50,17 @@ exports.fixedPointToString = fixedPointToString;
|
|
|
46
50
|
* ```
|
|
47
51
|
*/
|
|
48
52
|
function fixedPointFrom(val, decimals = 8) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return lVal
|
|
53
|
+
if (typeof val === "bigint") {
|
|
54
|
+
return val;
|
|
55
|
+
}
|
|
56
|
+
const [l, r] = (
|
|
57
|
+
typeof val === "number" ? val.toFixed(decimals) : val.toString()
|
|
58
|
+
).split(".");
|
|
59
|
+
const lVal = BigInt(l.padEnd(l.length + decimals, "0"));
|
|
60
|
+
if (r === undefined) {
|
|
61
|
+
return lVal;
|
|
62
|
+
}
|
|
63
|
+
return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, "0"));
|
|
58
64
|
}
|
|
59
65
|
exports.fixedPointFrom = fixedPointFrom;
|
|
60
66
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=index.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=index.test.d.ts.map
|