@ckb-ccc/core 0.0.7-alpha.1 → 0.0.7-alpha.2
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.map +1 -1
- package/dist/ckb/transaction.js +2 -2
- package/dist.commonjs/address/address.advanced.d.ts +24 -29
- package/dist.commonjs/address/address.advanced.js +89 -115
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +14 -30
- package/dist.commonjs/address/index.d.ts +44 -51
- package/dist.commonjs/address/index.js +65 -84
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +22 -47
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +14 -30
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +14 -30
- package/dist.commonjs/bytes/advanced.d.ts +2 -11
- package/dist.commonjs/bytes/index.d.ts +3 -9
- package/dist.commonjs/bytes/index.js +26 -28
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +22 -47
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +14 -30
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +9 -12
- package/dist.commonjs/ckb/script.d.ts +117 -121
- package/dist.commonjs/ckb/script.js +176 -220
- package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/transaction.advanced.js +4 -4
- package/dist.commonjs/ckb/transaction.d.ts +717 -792
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +1155 -1383
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +14 -30
- package/dist.commonjs/client/client.advanced.d.ts +6 -23
- package/dist.commonjs/client/client.advanced.js +61 -89
- package/dist.commonjs/client/client.d.ts +53 -113
- package/dist.commonjs/client/client.js +181 -214
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +127 -144
- package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicMainnet.js +15 -17
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +179 -204
- package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicTestnet.js +13 -13
- package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
- package/dist.commonjs/client/clientTypes.advanced.js +1 -1
- package/dist.commonjs/client/clientTypes.d.ts +26 -51
- package/dist.commonjs/client/clientTypes.js +22 -56
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +14 -30
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
- package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
- package/dist.commonjs/client/jsonRpc/index.js +108 -135
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
- package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +3 -9
- package/dist.commonjs/fixedPoint/index.js +20 -26
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +36 -42
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +36 -36
- package/dist.commonjs/hasher/index.js +47 -54
- package/dist.commonjs/hex/index.d.ts +1 -1
- package/dist.commonjs/hex/index.js +1 -1
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +22 -47
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +27 -39
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +14 -30
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.js +66 -89
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
- package/dist.commonjs/signer/btc/verify.d.ts +2 -6
- package/dist.commonjs/signer/btc/verify.js +3 -10
- package/dist.commonjs/signer/ckb/index.d.ts +1 -1
- package/dist.commonjs/signer/ckb/index.js +14 -30
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
- package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
- package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
- package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
- package/dist.commonjs/signer/dummy/dummy.js +16 -16
- package/dist.commonjs/signer/dummy/index.d.ts +1 -1
- package/dist.commonjs/signer/dummy/index.js +14 -30
- package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
- package/dist.commonjs/signer/dummy/openLink.js +7 -7
- package/dist.commonjs/signer/evm/index.d.ts +1 -1
- package/dist.commonjs/signer/evm/index.js +14 -30
- package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
- package/dist.commonjs/signer/evm/signerEvm.js +70 -105
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
- package/dist.commonjs/signer/evm/verify.d.ts +2 -6
- package/dist.commonjs/signer/evm/verify.js +2 -7
- package/dist.commonjs/signer/index.d.ts +1 -1
- package/dist.commonjs/signer/index.js +14 -30
- package/dist.commonjs/signer/nostr/index.d.ts +1 -1
- package/dist.commonjs/signer/nostr/index.js +14 -30
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
- package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
- package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
- package/dist.commonjs/signer/nostr/verify.js +39 -50
- package/dist.commonjs/signer/signer/index.d.ts +150 -156
- package/dist.commonjs/signer/signer/index.js +181 -208
- package/dist.commonjs/utils/index.d.ts +8 -38
- package/dist.commonjs/utils/index.js +12 -18
- package/package.json +2 -2
- package/src/ckb/transaction.ts +3 -2
|
@@ -1,80 +1,40 @@
|
|
|
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";
|
|
1
|
+
import { CellDep, CellDepLike, CellInput, CellInputLike, CellOutput, CellOutputLike, DepType, DepTypeLike, HashType, HashTypeLike, OutPoint, OutPointLike, Script, ScriptLike, Transaction, TransactionLike } from "../../ckb";
|
|
19
2
|
import { Hex } from "../../hex";
|
|
20
3
|
import { NumLike } from "../../num";
|
|
21
|
-
import {
|
|
22
|
-
|
|
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";
|
|
4
|
+
import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, TransactionStatus } from "../clientTypes";
|
|
5
|
+
import { JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerSearchKey, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types";
|
|
38
6
|
export declare class JsonRpcTransformers {
|
|
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
|
-
last_cursor: string;
|
|
73
|
-
objects: {
|
|
74
|
-
out_point: JsonRpcOutPoint;
|
|
75
|
-
output: JsonRpcCellOutput;
|
|
76
|
-
output_data?: Hex;
|
|
77
|
-
}[];
|
|
78
|
-
}): ClientFindCellsResponse;
|
|
7
|
+
static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
|
|
8
|
+
static hashTypeTo(hashType: JsonRpcHashType): HashType;
|
|
9
|
+
static depTypeFrom(depType: DepTypeLike): JsonRpcDepType;
|
|
10
|
+
static depTypeTo(depType: JsonRpcDepType): DepType;
|
|
11
|
+
static scriptFrom(scriptLike: ScriptLike): JsonRpcScript;
|
|
12
|
+
static scriptTo(script: JsonRpcScript): Script;
|
|
13
|
+
static outPointFrom(outPointLike: OutPointLike): JsonRpcOutPoint;
|
|
14
|
+
static outPointTo(outPoint: JsonRpcOutPoint): OutPoint;
|
|
15
|
+
static cellInputFrom(cellInputLike: CellInputLike): JsonRpcCellInput;
|
|
16
|
+
static cellInputTo(cellInput: JsonRpcCellInput): CellInput;
|
|
17
|
+
static cellOutputFrom(cellOutput: CellOutputLike): JsonRpcCellOutput;
|
|
18
|
+
static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput;
|
|
19
|
+
static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep;
|
|
20
|
+
static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
|
|
21
|
+
static transactionFrom(txLike: TransactionLike): JsonRpcTransaction;
|
|
22
|
+
static transactionTo(tx: JsonRpcTransaction): Transaction;
|
|
23
|
+
static transactionResponseTo({ tx_status: { status }, transaction, }: {
|
|
24
|
+
tx_status: {
|
|
25
|
+
status: TransactionStatus;
|
|
26
|
+
};
|
|
27
|
+
transaction: JsonRpcTransaction | null;
|
|
28
|
+
}): ClientTransactionResponse | null;
|
|
29
|
+
static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex];
|
|
30
|
+
static indexerSearchKeyFrom(keyLike: ClientIndexerSearchKeyLike): JsonRpcIndexerSearchKey;
|
|
31
|
+
static findCellsResponseTo({ last_cursor, objects, }: {
|
|
32
|
+
last_cursor: string;
|
|
33
|
+
objects: {
|
|
34
|
+
out_point: JsonRpcOutPoint;
|
|
35
|
+
output: JsonRpcCellOutput;
|
|
36
|
+
output_data?: Hex;
|
|
37
|
+
}[];
|
|
38
|
+
}): ClientFindCellsResponse;
|
|
79
39
|
}
|
|
80
|
-
//# sourceMappingURL=transformers.d.ts.map
|
|
40
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -6,179 +6,157 @@ 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
|
-
|
|
159
|
-
|
|
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
|
-
outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
|
|
177
|
-
cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
|
|
178
|
-
outputData: cell.output_data ?? "0x",
|
|
179
|
-
}),
|
|
180
|
-
),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
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(cellInputLike) {
|
|
60
|
+
const cellInput = ckb_1.CellInput.from(cellInputLike);
|
|
61
|
+
return {
|
|
62
|
+
previous_output: JsonRpcTransformers.outPointFrom(cellInput.previousOutput),
|
|
63
|
+
since: (0, num_1.numToHex)(cellInput.since),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static cellInputTo(cellInput) {
|
|
67
|
+
return ckb_1.CellInput.from({
|
|
68
|
+
previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),
|
|
69
|
+
since: cellInput.since,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
static cellOutputFrom(cellOutput) {
|
|
73
|
+
return {
|
|
74
|
+
capacity: (0, num_1.numToHex)(cellOutput.capacity),
|
|
75
|
+
lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
|
|
76
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptFrom, cellOutput.type),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
static cellOutputTo(cellOutput) {
|
|
80
|
+
return ckb_1.CellOutput.from({
|
|
81
|
+
capacity: cellOutput.capacity,
|
|
82
|
+
lock: JsonRpcTransformers.scriptTo(cellOutput.lock),
|
|
83
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptTo, cellOutput.type),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static cellDepFrom(cellDep) {
|
|
87
|
+
return {
|
|
88
|
+
out_point: JsonRpcTransformers.outPointFrom(cellDep.outPoint),
|
|
89
|
+
dep_type: JsonRpcTransformers.depTypeFrom(cellDep.depType),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static cellDepTo(cellDep) {
|
|
93
|
+
return ckb_1.CellDep.from({
|
|
94
|
+
outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),
|
|
95
|
+
depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
static transactionFrom(txLike) {
|
|
99
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
100
|
+
return {
|
|
101
|
+
version: (0, num_1.numToHex)(tx.version),
|
|
102
|
+
cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),
|
|
103
|
+
header_deps: tx.headerDeps,
|
|
104
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),
|
|
105
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputFrom(o)),
|
|
106
|
+
outputs_data: tx.outputsData,
|
|
107
|
+
witnesses: tx.witnesses,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
static transactionTo(tx) {
|
|
111
|
+
return ckb_1.Transaction.from({
|
|
112
|
+
version: tx.version,
|
|
113
|
+
cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),
|
|
114
|
+
headerDeps: tx.header_deps,
|
|
115
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputTo(i)),
|
|
116
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputTo(o)),
|
|
117
|
+
outputsData: tx.outputs_data,
|
|
118
|
+
witnesses: tx.witnesses,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
static transactionResponseTo({ tx_status: { status }, transaction, }) {
|
|
122
|
+
if (transaction == null) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
transaction: JsonRpcTransformers.transactionTo(transaction),
|
|
127
|
+
status,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
static rangeFrom([a, b]) {
|
|
131
|
+
return [(0, num_1.numToHex)(a), (0, num_1.numToHex)(b)];
|
|
132
|
+
}
|
|
133
|
+
static indexerSearchKeyFrom(keyLike) {
|
|
134
|
+
const key = clientTypes_1.ClientIndexerSearchKey.from(keyLike);
|
|
135
|
+
return {
|
|
136
|
+
script: JsonRpcTransformers.scriptFrom(key.script),
|
|
137
|
+
script_type: key.scriptType,
|
|
138
|
+
script_search_mode: key.scriptSearchMode,
|
|
139
|
+
filter: (0, utils_1.apply)((filter) => ({
|
|
140
|
+
script: (0, utils_1.apply)(JsonRpcTransformers.scriptFrom, filter.script),
|
|
141
|
+
script_len_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.scriptLenRange),
|
|
142
|
+
output_data: filter.outputData,
|
|
143
|
+
output_data_filter_mode: filter.outputDataSearchMode,
|
|
144
|
+
output_data_len_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.outputDataLenRange),
|
|
145
|
+
output_capacity_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.outputCapacityRange),
|
|
146
|
+
block_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.blockRange),
|
|
147
|
+
}), key.filter),
|
|
148
|
+
with_data: key.withData,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
static findCellsResponseTo({ last_cursor, objects, }) {
|
|
152
|
+
return {
|
|
153
|
+
lastCursor: last_cursor,
|
|
154
|
+
cells: objects.map((cell) => ckb_1.Cell.from({
|
|
155
|
+
outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
|
|
156
|
+
cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
|
|
157
|
+
outputData: cell.output_data ?? "0x",
|
|
158
|
+
})),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
183
161
|
}
|
|
184
162
|
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,10 +21,7 @@ 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(
|
|
25
|
-
val: FixedPointLike,
|
|
26
|
-
decimals?: number,
|
|
27
|
-
): string;
|
|
24
|
+
export declare function fixedPointToString(val: FixedPointLike, decimals?: number): string;
|
|
28
25
|
/**
|
|
29
26
|
* Converts a FixedPointLike value to a FixedPoint (bigint) with fixed-point decimals.
|
|
30
27
|
*
|
|
@@ -39,10 +36,7 @@ export declare function fixedPointToString(
|
|
|
39
36
|
* const fixedPointFromNumber = fixedPointFrom(1.23456789, 8); // Outputs 123456789n
|
|
40
37
|
* ```
|
|
41
38
|
*/
|
|
42
|
-
export declare function fixedPointFrom(
|
|
43
|
-
val: FixedPointLike,
|
|
44
|
-
decimals?: number,
|
|
45
|
-
): FixedPoint;
|
|
39
|
+
export declare function fixedPointFrom(val: FixedPointLike, decimals?: number): FixedPoint;
|
|
46
40
|
/**
|
|
47
41
|
* Represents the fixed point value of zero as a bigint.
|
|
48
42
|
*/
|
|
@@ -52,4 +46,4 @@ export declare const Zero = 0n;
|
|
|
52
46
|
* Equivalent to 1 in fixed-point representation with default decimals (8).
|
|
53
47
|
*/
|
|
54
48
|
export declare const One: bigint;
|
|
55
|
-
//# sourceMappingURL=index.d.ts.map
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
* Represents a fixed point value as a bigint.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.One =
|
|
7
|
-
exports.Zero =
|
|
8
|
-
exports.fixedPointFrom =
|
|
9
|
-
exports.fixedPointToString =
|
|
10
|
-
void 0;
|
|
6
|
+
exports.One = exports.Zero = exports.fixedPointFrom = exports.fixedPointToString = void 0;
|
|
11
7
|
/**
|
|
12
8
|
* Converts a FixedPointLike value to its string representation with fixed-point decimals.
|
|
13
9
|
*
|
|
@@ -23,16 +19,16 @@ exports.One =
|
|
|
23
19
|
* ```
|
|
24
20
|
*/
|
|
25
21
|
function fixedPointToString(val, decimals = 8) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const str = fixedPointFrom(val).toString();
|
|
23
|
+
if (decimals === 0) {
|
|
24
|
+
return str;
|
|
25
|
+
}
|
|
26
|
+
const l = str.length <= decimals ? "0" : str.slice(0, -decimals);
|
|
27
|
+
const r = str.slice(-decimals).padStart(decimals, "0").replace(/0*$/, "");
|
|
28
|
+
if (r === "") {
|
|
29
|
+
return l;
|
|
30
|
+
}
|
|
31
|
+
return `${l}.${r}`;
|
|
36
32
|
}
|
|
37
33
|
exports.fixedPointToString = fixedPointToString;
|
|
38
34
|
/**
|
|
@@ -50,17 +46,15 @@ exports.fixedPointToString = fixedPointToString;
|
|
|
50
46
|
* ```
|
|
51
47
|
*/
|
|
52
48
|
function fixedPointFrom(val, decimals = 8) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return lVal;
|
|
62
|
-
}
|
|
63
|
-
return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, "0"));
|
|
49
|
+
if (typeof val === "bigint") {
|
|
50
|
+
return val;
|
|
51
|
+
}
|
|
52
|
+
const [l, r] = (typeof val === "number" ? val.toFixed(decimals) : val.toString()).split(".");
|
|
53
|
+
const lVal = BigInt(l.padEnd(l.length + decimals, "0"));
|
|
54
|
+
if (r === undefined) {
|
|
55
|
+
return lVal;
|
|
56
|
+
}
|
|
57
|
+
return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, "0"));
|
|
64
58
|
}
|
|
65
59
|
exports.fixedPointFrom = fixedPointFrom;
|
|
66
60
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=index.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=index.test.d.ts.map
|