@ckb-ccc/core 0.0.11-alpha.0 → 0.0.11-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/client/client.d.ts +7 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +3 -3
- package/dist/client/clientTypes.d.ts +24 -0
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.d.ts +26 -2
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +25 -0
- package/dist/client/jsonRpc/transformers.d.ts +6 -3
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +31 -1
- package/dist/client/jsonRpc/types.d.ts +24 -0
- package/dist/client/jsonRpc/types.d.ts.map +1 -1
- 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/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/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +2 -1
- package/dist.commonjs/client/client.d.ts +7 -4
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +3 -3
- package/dist.commonjs/client/clientTypes.d.ts +24 -0
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts +26 -2
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +25 -0
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +6 -3
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +31 -1
- package/dist.commonjs/client/jsonRpc/types.d.ts +24 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.d.ts +1 -0
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.js +16 -0
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +2 -1
- package/package.json +3 -2
- package/src/client/client.ts +19 -6
- package/src/client/clientTypes.ts +27 -0
- package/src/client/jsonRpc/index.ts +41 -1
- package/src/client/jsonRpc/transformers.ts +40 -2
- package/src/client/jsonRpc/types.ts +27 -0
- package/src/signer/ckb/index.ts +1 -0
- package/src/signer/ckb/verifyJoyId.ts +20 -0
- package/src/signer/signer/index.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;AA0BpE;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;IAS9C,OAAO,CAAC,QAAQ,CAAC,IAAI;IAC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importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ClientJsonRpc = void 0;
|
|
7
7
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const barrel_js_1 = require("../../barrel.js");
|
|
8
9
|
const index_js_1 = require("../../hex/index.js");
|
|
9
10
|
const index_js_2 = require("../../num/index.js");
|
|
10
11
|
const client_js_1 = require("../client.js");
|
|
@@ -43,6 +44,30 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
43
44
|
super();
|
|
44
45
|
this.url_ = url_;
|
|
45
46
|
this.timeout = timeout;
|
|
47
|
+
/**
|
|
48
|
+
* Get tip block number
|
|
49
|
+
*
|
|
50
|
+
* @returns Tip block number
|
|
51
|
+
*/
|
|
52
|
+
this.getTip = this.buildSender("get_tip_block_number", [], index_js_2.numFrom);
|
|
53
|
+
/**
|
|
54
|
+
* Get block by block hash
|
|
55
|
+
*
|
|
56
|
+
* @param blockNumber - The block number.
|
|
57
|
+
* @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
|
|
58
|
+
* @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
59
|
+
* @returns Block
|
|
60
|
+
*/
|
|
61
|
+
this.getBlockByNumber = this.buildSender("get_block_by_number", [(v) => (0, index_js_2.numToHex)((0, index_js_2.numFrom)(v))], (b) => (0, barrel_js_1.apply)(advanced_js_1.JsonRpcTransformers.blockTo, b));
|
|
62
|
+
/**
|
|
63
|
+
* Get block by block hash
|
|
64
|
+
*
|
|
65
|
+
* @param blockHash - The block hash.
|
|
66
|
+
* @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
|
|
67
|
+
* @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
68
|
+
* @returns Block
|
|
69
|
+
*/
|
|
70
|
+
this.getBlockByHash = this.buildSender("get_block", [index_js_1.hexFrom], (b) => (0, barrel_js_1.apply)(advanced_js_1.JsonRpcTransformers.blockTo, b));
|
|
46
71
|
/**
|
|
47
72
|
* Send a transaction to node.
|
|
48
73
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CellDep, CellDepLike, CellInput, CellInputLike, CellOutput, CellOutputLike, DepType, DepTypeLike, HashType, HashTypeLike, OutPoint, OutPointLike, Script, ScriptLike, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
2
2
|
import { Hex } from "../../hex/index.js";
|
|
3
3
|
import { NumLike } from "../../num/index.js";
|
|
4
|
-
import { ClientFindCellsResponse, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKeyFilter, ClientIndexerSearchKeyLike, ClientIndexerSearchKeyTransactionLike, ClientTransactionResponse, TransactionStatus } from "../clientTypes.js";
|
|
5
|
-
import { JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerFindTransactionsGroupedResponse, JsonRpcIndexerFindTransactionsResponse, JsonRpcIndexerSearchKey, JsonRpcIndexerSearchKeyFilter, JsonRpcIndexerSearchKeyTransaction, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types.js";
|
|
4
|
+
import { ClientBlock, ClientBlockHeader, ClientBlockUncle, ClientFindCellsResponse, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKeyFilter, ClientIndexerSearchKeyLike, ClientIndexerSearchKeyTransactionLike, ClientTransactionResponse, TransactionStatus } from "../clientTypes.js";
|
|
5
|
+
import { JsonRpcBlock, JsonRpcBlockHeader, JsonRpcBlockUncle, JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerFindTransactionsGroupedResponse, JsonRpcIndexerFindTransactionsResponse, JsonRpcIndexerSearchKey, JsonRpcIndexerSearchKeyFilter, JsonRpcIndexerSearchKeyTransaction, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types.js";
|
|
6
6
|
export declare class JsonRpcTransformers {
|
|
7
7
|
static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
|
|
8
8
|
static hashTypeTo(hashType: JsonRpcHashType): HashType;
|
|
@@ -25,7 +25,10 @@ export declare class JsonRpcTransformers {
|
|
|
25
25
|
status: TransactionStatus;
|
|
26
26
|
};
|
|
27
27
|
transaction: JsonRpcTransaction | null;
|
|
28
|
-
}): ClientTransactionResponse |
|
|
28
|
+
}): ClientTransactionResponse | undefined;
|
|
29
|
+
static blockHeaderTo(header: JsonRpcBlockHeader): ClientBlockHeader;
|
|
30
|
+
static blockUncleTo(block: JsonRpcBlockUncle): ClientBlockUncle;
|
|
31
|
+
static blockTo(block: JsonRpcBlock): ClientBlock;
|
|
29
32
|
static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex];
|
|
30
33
|
static indexerSearchKeyFilterFrom(filter: ClientIndexerSearchKeyFilter): JsonRpcIndexerSearchKeyFilter;
|
|
31
34
|
static indexerSearchKeyFrom(keyLike: ClientIndexerSearchKeyLike): JsonRpcIndexerSearchKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EACL,uBAAuB,EACvB,qCAAqC,EACrC,8BAA8B,EAE9B,4BAA4B,EAC5B,0BAA0B,EAE1B,qCAAqC,EACrC,yBAAyB,EACzB,iBAAi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AE,EAAE,kBAAkB,GAAG,WAAW;IAWzD,MAAM,CAAC,qBAAqB,CAAC,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,EACrB,WAAW,GACZ,EAAE;QACD,SAAS,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAA;SAAE,CAAC;QACzC,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;KACxC,GAAG,yBAAyB,GAAG,
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,qCAAqC,EACrC,8BAA8B,EAE9B,4BAA4B,EAC5B,0BAA0B,EAE1B,qCAAqC,EACrC,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,6CAA6C,EAC7C,sCAAsC,EACtC,uBAAuB,EACvB,6BAA6B,EAC7B,kCAAkC,EAClC,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe;IAG5D,MAAM,CAAC,UAAU,CAA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AAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,gBAAgB;IAM/D,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW;IAUhD,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAGxD,MAAM,CAAC,0BAA0B,CAC/B,MAAM,EAAE,4BAA4B,GACnC,6BAA6B;IAoBhC,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,0BAA0B,GAClC,uBAAuB;IAU1B,MAAM,CAAC,mBAAmB,CAAC,EACzB,WAAW,EACX,OAAO,GACR,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACP,SAAS,EAAE,eAAe,CAAC;YAC3B,MAAM,EAAE,iBAAiB,CAAC;YAC1B,WAAW,CAAC,EAAE,GAAG,CAAC;SACnB,EAAE,CAAC;KACL,GAAG,uBAAuB;IAY3B,MAAM,CAAC,+BAA+B,CACpC,OAAO,EAAE,qCAAqC,GAC7C,kCAAkC;IAUrC,MAAM,CAAC,0BAA0B,CAAC,EAChC,WAAW,EACX,OAAO,GACR,EACG,sCAAsC,GACtC,6CAA6C,GAC7C,8BAA8B,GAC9B,qCAAqC;CAqC1C"}
|
|
@@ -120,13 +120,43 @@ class JsonRpcTransformers {
|
|
|
120
120
|
}
|
|
121
121
|
static transactionResponseTo({ tx_status: { status }, transaction, }) {
|
|
122
122
|
if (transaction == null) {
|
|
123
|
-
return
|
|
123
|
+
return;
|
|
124
124
|
}
|
|
125
125
|
return {
|
|
126
126
|
transaction: JsonRpcTransformers.transactionTo(transaction),
|
|
127
127
|
status,
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
+
static blockHeaderTo(header) {
|
|
131
|
+
return {
|
|
132
|
+
compactTarget: (0, index_js_2.numFrom)(header.compact_target),
|
|
133
|
+
dao: header.dao,
|
|
134
|
+
epoch: (0, index_js_2.numFrom)(header.epoch),
|
|
135
|
+
extraHash: header.extra_hash,
|
|
136
|
+
hash: header.hash,
|
|
137
|
+
nonce: (0, index_js_2.numFrom)(header.nonce),
|
|
138
|
+
number: (0, index_js_2.numFrom)(header.number),
|
|
139
|
+
parentHash: header.parent_hash,
|
|
140
|
+
proposalsHash: header.proposals_hash,
|
|
141
|
+
timestamp: (0, index_js_2.numFrom)(header.timestamp),
|
|
142
|
+
transactionsRoot: header.transactions_root,
|
|
143
|
+
version: (0, index_js_2.numFrom)(header.version),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
static blockUncleTo(block) {
|
|
147
|
+
return {
|
|
148
|
+
header: JsonRpcTransformers.blockHeaderTo(block.header),
|
|
149
|
+
proposals: block.proposals,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
static blockTo(block) {
|
|
153
|
+
return {
|
|
154
|
+
header: JsonRpcTransformers.blockHeaderTo(block.header),
|
|
155
|
+
proposals: block.proposals,
|
|
156
|
+
transactions: block.transactions.map((t) => JsonRpcTransformers.transactionTo(t)),
|
|
157
|
+
uncles: block.uncles.map((u) => JsonRpcTransformers.blockUncleTo(u)),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
130
160
|
static rangeFrom([a, b]) {
|
|
131
161
|
return [(0, index_js_2.numToHex)(a), (0, index_js_2.numToHex)(b)];
|
|
132
162
|
}
|
|
@@ -38,6 +38,30 @@ export type JsonRpcTransaction = {
|
|
|
38
38
|
outputs_data: Hex[];
|
|
39
39
|
witnesses: Hex[];
|
|
40
40
|
};
|
|
41
|
+
export type JsonRpcBlockHeader = {
|
|
42
|
+
compact_target: Hex;
|
|
43
|
+
dao: Hex;
|
|
44
|
+
epoch: Hex;
|
|
45
|
+
extra_hash: Hex;
|
|
46
|
+
hash: Hex;
|
|
47
|
+
nonce: Hex;
|
|
48
|
+
number: Hex;
|
|
49
|
+
parent_hash: Hex;
|
|
50
|
+
proposals_hash: Hex;
|
|
51
|
+
timestamp: Hex;
|
|
52
|
+
transactions_root: Hex;
|
|
53
|
+
version: Hex;
|
|
54
|
+
};
|
|
55
|
+
export type JsonRpcBlockUncle = {
|
|
56
|
+
header: JsonRpcBlockHeader;
|
|
57
|
+
proposals: Hex[];
|
|
58
|
+
};
|
|
59
|
+
export type JsonRpcBlock = {
|
|
60
|
+
header: JsonRpcBlockHeader;
|
|
61
|
+
proposals: Hex[];
|
|
62
|
+
transactions: JsonRpcTransaction[];
|
|
63
|
+
uncles: JsonRpcBlockUncle[];
|
|
64
|
+
};
|
|
41
65
|
export type JsonRpcIndexerSearchKeyFilter = {
|
|
42
66
|
script?: JsonRpcScript;
|
|
43
67
|
script_len_range?: [Hex, Hex];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,eAAe,CAAC;IAC3B,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,eA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AAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IACpD,MAAM,CAAC,EAAE,6BAA6B,CAAC;IACvC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,GAAG,CAAC;QACb,YAAY,EAAE,GAAG,CAAC;QAClB,QAAQ,EAAE,GAAG,CAAC;QACd,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;QAC5B,QAAQ,EAAE,GAAG,CAAC;KACf,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,6CAA6C,GAAG;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,GAAG,CAAC;QACb,YAAY,EAAE,GAAG,CAAC;QAClB,QAAQ,EAAE,GAAG,CAAC;QACd,KAAK,EAAE,CAAC,OAAO,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;KACpC,EAAE,CAAC;CACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
|
|
@@ -18,3 +18,4 @@ __exportStar(require("./signerCkbPrivateKey.js"), exports);
|
|
|
18
18
|
__exportStar(require("./signerCkbPublicKey.js"), exports);
|
|
19
19
|
__exportStar(require("./signerCkbScriptReadonly.js"), exports);
|
|
20
20
|
__exportStar(require("./verifyCkbSecp256k1.js"), exports);
|
|
21
|
+
__exportStar(require("./verifyJoyId.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyJoyId.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/verifyJoyId.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageJoyId = void 0;
|
|
4
|
+
const ckb_1 = require("@joyid/ckb");
|
|
5
|
+
const index_js_1 = require("../../hex/index.js");
|
|
6
|
+
function verifyMessageJoyId(message, signature, identity) {
|
|
7
|
+
const challenge = typeof message === "string" ? message : (0, index_js_1.hexFrom)(message).slice(2);
|
|
8
|
+
const { publicKey, keyType } = JSON.parse(identity);
|
|
9
|
+
return (0, ckb_1.verifySignature)({
|
|
10
|
+
challenge,
|
|
11
|
+
pubkey: publicKey,
|
|
12
|
+
keyType,
|
|
13
|
+
...JSON.parse(signature),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.verifyMessageJoyId = verifyMessageJoyId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD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AMG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAItD;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;GAEG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SignerInfo = exports.Signer = exports.Signature = exports.SignerType = exports.SignerSignType = void 0;
|
|
4
4
|
const index_js_1 = require("../btc/index.js");
|
|
5
5
|
const verifyCkbSecp256k1_js_1 = require("../ckb/verifyCkbSecp256k1.js");
|
|
6
|
+
const verifyJoyId_js_1 = require("../ckb/verifyJoyId.js");
|
|
6
7
|
const verify_js_1 = require("../evm/verify.js");
|
|
7
8
|
const verify_js_2 = require("../nostr/verify.js");
|
|
8
9
|
var SignerSignType;
|
|
@@ -62,7 +63,7 @@ class Signer {
|
|
|
62
63
|
case SignerSignType.BtcEcdsa:
|
|
63
64
|
return (0, index_js_1.verifyMessageBtcEcdsa)(message, signature.signature, signature.identity);
|
|
64
65
|
case SignerSignType.JoyId:
|
|
65
|
-
|
|
66
|
+
return (0, verifyJoyId_js_1.verifyMessageJoyId)(message, signature.signature, signature.identity);
|
|
66
67
|
case SignerSignType.NostrEvent:
|
|
67
68
|
return (0, verify_js_2.verifyMessageNostrEvent)(message, signature.signature, signature.identity);
|
|
68
69
|
case SignerSignType.CkbSecp256k1:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/core",
|
|
3
|
-
"version": "0.0.11-alpha.
|
|
3
|
+
"version": "0.0.11-alpha.2",
|
|
4
4
|
"description": "Core of CCC - CKBer's Codebase",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@ckb-lumos/helpers": "^0.22.2",
|
|
61
|
+
"@joyid/ckb": "^1.0.1",
|
|
61
62
|
"@noble/ciphers": "^0.5.3",
|
|
62
63
|
"@noble/curves": "^1.4.2",
|
|
63
64
|
"@noble/hashes": "^1.4.0",
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
"cross-fetch": "^4.0.0",
|
|
70
71
|
"ethers": "^6.13.1"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "fd2ee28eac9dc6a3572181b9da05eba204ee13df"
|
|
73
74
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { apply, reduceAsync } from "../utils/index.js";
|
|
|
17
17
|
import { filterCell } from "./client.advanced.js";
|
|
18
18
|
import { ClientCollectableSearchKeyLike } from "./clientTypes.advanced.js";
|
|
19
19
|
import {
|
|
20
|
+
ClientBlock,
|
|
20
21
|
ClientFindCellsResponse,
|
|
21
22
|
ClientFindTransactionsGroupedResponse,
|
|
22
23
|
ClientFindTransactionsResponse,
|
|
@@ -76,6 +77,18 @@ export abstract class Client {
|
|
|
76
77
|
Pick<Script, "codeHash" | "hashType"> & { cellDeps: CellDepInfo[] }
|
|
77
78
|
>;
|
|
78
79
|
|
|
80
|
+
abstract getTip(): Promise<Num>;
|
|
81
|
+
abstract getBlockByNumber(
|
|
82
|
+
blockNumber: NumLike,
|
|
83
|
+
verbosity?: number | null,
|
|
84
|
+
withCycles?: boolean | null,
|
|
85
|
+
): Promise<ClientBlock | undefined>;
|
|
86
|
+
abstract getBlockByHash(
|
|
87
|
+
blockHash: HexLike,
|
|
88
|
+
verbosity?: number | null,
|
|
89
|
+
withCycles?: boolean | null,
|
|
90
|
+
): Promise<ClientBlock | undefined>;
|
|
91
|
+
|
|
79
92
|
async markUsable(cellLike: CellLike): Promise<void> {
|
|
80
93
|
const cell = Cell.from(cellLike).clone();
|
|
81
94
|
this.usableCells.push(cell);
|
|
@@ -103,9 +116,9 @@ export abstract class Client {
|
|
|
103
116
|
): Promise<Hex>;
|
|
104
117
|
abstract getTransactionNoCache(
|
|
105
118
|
txHash: HexLike,
|
|
106
|
-
): Promise<ClientTransactionResponse |
|
|
119
|
+
): Promise<ClientTransactionResponse | undefined>;
|
|
107
120
|
|
|
108
|
-
async getCell(outPointLike: OutPointLike): Promise<Cell |
|
|
121
|
+
async getCell(outPointLike: OutPointLike): Promise<Cell | undefined> {
|
|
109
122
|
const outPoint = OutPoint.from(outPointLike);
|
|
110
123
|
const cached = this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
|
|
111
124
|
|
|
@@ -115,12 +128,12 @@ export abstract class Client {
|
|
|
115
128
|
|
|
116
129
|
const transaction = await this.getTransactionNoCache(outPoint.txHash);
|
|
117
130
|
if (!transaction) {
|
|
118
|
-
return
|
|
131
|
+
return;
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
const index = Number(numFrom(outPoint.index));
|
|
122
135
|
if (index >= transaction.transaction.outputs.length) {
|
|
123
|
-
return
|
|
136
|
+
return;
|
|
124
137
|
}
|
|
125
138
|
|
|
126
139
|
const cell = Cell.from({
|
|
@@ -491,7 +504,7 @@ export abstract class Client {
|
|
|
491
504
|
|
|
492
505
|
async getTransaction(
|
|
493
506
|
txHashLike: HexLike,
|
|
494
|
-
): Promise<ClientTransactionResponse |
|
|
507
|
+
): Promise<ClientTransactionResponse | undefined> {
|
|
495
508
|
const txHash = hexFrom(txHashLike);
|
|
496
509
|
const res = await this.getTransactionNoCache(txHash);
|
|
497
510
|
if (res !== null) {
|
|
@@ -500,7 +513,7 @@ export abstract class Client {
|
|
|
500
513
|
|
|
501
514
|
const tx = this.cachedTransactions.find((t) => t.hash() === txHash);
|
|
502
515
|
if (!tx) {
|
|
503
|
-
return
|
|
516
|
+
return;
|
|
504
517
|
}
|
|
505
518
|
|
|
506
519
|
return {
|
|
@@ -133,3 +133,30 @@ export type ClientFindTransactionsGroupedResponse = {
|
|
|
133
133
|
}[];
|
|
134
134
|
}[];
|
|
135
135
|
};
|
|
136
|
+
|
|
137
|
+
export type ClientBlockHeader = {
|
|
138
|
+
compactTarget: Num;
|
|
139
|
+
dao: Hex;
|
|
140
|
+
epoch: Num;
|
|
141
|
+
extraHash: Hex;
|
|
142
|
+
hash: Hex;
|
|
143
|
+
nonce: Num;
|
|
144
|
+
number: Num;
|
|
145
|
+
parentHash: Hex;
|
|
146
|
+
proposalsHash: Hex;
|
|
147
|
+
timestamp: Num;
|
|
148
|
+
transactionsRoot: Hex;
|
|
149
|
+
version: Num;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type ClientBlockUncle = {
|
|
153
|
+
header: ClientBlockHeader;
|
|
154
|
+
proposals: Hex[];
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type ClientBlock = {
|
|
158
|
+
header: ClientBlockHeader;
|
|
159
|
+
proposals: Hex[];
|
|
160
|
+
transactions: Transaction[];
|
|
161
|
+
uncles: ClientBlockUncle[];
|
|
162
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import fetch from "cross-fetch";
|
|
2
|
+
import { apply } from "../../barrel.js";
|
|
2
3
|
import { TransactionLike } from "../../ckb/index.js";
|
|
3
4
|
import { Hex, HexLike, hexFrom } from "../../hex/index.js";
|
|
4
5
|
import { Num, NumLike, numFrom, numToHex } from "../../num/index.js";
|
|
5
6
|
import { Client } from "../client.js";
|
|
6
7
|
import {
|
|
8
|
+
ClientBlock,
|
|
7
9
|
ClientFindCellsResponse,
|
|
8
10
|
ClientIndexerSearchKeyLike,
|
|
9
11
|
ClientTransactionResponse,
|
|
@@ -65,6 +67,44 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
65
67
|
return this.url_;
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Get tip block number
|
|
72
|
+
*
|
|
73
|
+
* @returns Tip block number
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
getTip = this.buildSender(
|
|
77
|
+
"get_tip_block_number",
|
|
78
|
+
[],
|
|
79
|
+
numFrom,
|
|
80
|
+
) as () => Promise<Num>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get block by block hash
|
|
84
|
+
*
|
|
85
|
+
* @param blockNumber - The block number.
|
|
86
|
+
* @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
|
|
87
|
+
* @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
88
|
+
* @returns Block
|
|
89
|
+
*/
|
|
90
|
+
getBlockByNumber = this.buildSender(
|
|
91
|
+
"get_block_by_number",
|
|
92
|
+
[(v: NumLike) => numToHex(numFrom(v))],
|
|
93
|
+
(b) => apply(JsonRpcTransformers.blockTo, b),
|
|
94
|
+
) as () => Promise<ClientBlock | undefined>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get block by block hash
|
|
98
|
+
*
|
|
99
|
+
* @param blockHash - The block hash.
|
|
100
|
+
* @param verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
|
|
101
|
+
* @param with_cycles - whether the return cycles of block transactions. (Optional, default false.)
|
|
102
|
+
* @returns Block
|
|
103
|
+
*/
|
|
104
|
+
getBlockByHash = this.buildSender("get_block", [hexFrom], (b) =>
|
|
105
|
+
apply(JsonRpcTransformers.blockTo, b),
|
|
106
|
+
) as () => Promise<ClientBlock | undefined>;
|
|
107
|
+
|
|
68
108
|
/**
|
|
69
109
|
* Send a transaction to node.
|
|
70
110
|
*
|
|
@@ -93,7 +133,7 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
93
133
|
"get_transaction",
|
|
94
134
|
[hexFrom],
|
|
95
135
|
JsonRpcTransformers.transactionResponseTo,
|
|
96
|
-
) as (txHash: HexLike) => Promise<ClientTransactionResponse |
|
|
136
|
+
) as (txHash: HexLike) => Promise<ClientTransactionResponse | undefined>;
|
|
97
137
|
|
|
98
138
|
/**
|
|
99
139
|
* find cells from node.
|
|
@@ -23,6 +23,9 @@ import { Hex } from "../../hex/index.js";
|
|
|
23
23
|
import { NumLike, numFrom, numToHex } from "../../num/index.js";
|
|
24
24
|
import { apply } from "../../utils/index.js";
|
|
25
25
|
import {
|
|
26
|
+
ClientBlock,
|
|
27
|
+
ClientBlockHeader,
|
|
28
|
+
ClientBlockUncle,
|
|
26
29
|
ClientFindCellsResponse,
|
|
27
30
|
ClientFindTransactionsGroupedResponse,
|
|
28
31
|
ClientFindTransactionsResponse,
|
|
@@ -35,6 +38,9 @@ import {
|
|
|
35
38
|
TransactionStatus,
|
|
36
39
|
} from "../clientTypes.js";
|
|
37
40
|
import {
|
|
41
|
+
JsonRpcBlock,
|
|
42
|
+
JsonRpcBlockHeader,
|
|
43
|
+
JsonRpcBlockUncle,
|
|
38
44
|
JsonRpcCellDep,
|
|
39
45
|
JsonRpcCellInput,
|
|
40
46
|
JsonRpcCellOutput,
|
|
@@ -171,9 +177,9 @@ export class JsonRpcTransformers {
|
|
|
171
177
|
}: {
|
|
172
178
|
tx_status: { status: TransactionStatus };
|
|
173
179
|
transaction: JsonRpcTransaction | null;
|
|
174
|
-
}): ClientTransactionResponse |
|
|
180
|
+
}): ClientTransactionResponse | undefined {
|
|
175
181
|
if (transaction == null) {
|
|
176
|
-
return
|
|
182
|
+
return;
|
|
177
183
|
}
|
|
178
184
|
|
|
179
185
|
return {
|
|
@@ -181,6 +187,38 @@ export class JsonRpcTransformers {
|
|
|
181
187
|
status,
|
|
182
188
|
};
|
|
183
189
|
}
|
|
190
|
+
static blockHeaderTo(header: JsonRpcBlockHeader): ClientBlockHeader {
|
|
191
|
+
return {
|
|
192
|
+
compactTarget: numFrom(header.compact_target),
|
|
193
|
+
dao: header.dao,
|
|
194
|
+
epoch: numFrom(header.epoch),
|
|
195
|
+
extraHash: header.extra_hash,
|
|
196
|
+
hash: header.hash,
|
|
197
|
+
nonce: numFrom(header.nonce),
|
|
198
|
+
number: numFrom(header.number),
|
|
199
|
+
parentHash: header.parent_hash,
|
|
200
|
+
proposalsHash: header.proposals_hash,
|
|
201
|
+
timestamp: numFrom(header.timestamp),
|
|
202
|
+
transactionsRoot: header.transactions_root,
|
|
203
|
+
version: numFrom(header.version),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
static blockUncleTo(block: JsonRpcBlockUncle): ClientBlockUncle {
|
|
207
|
+
return {
|
|
208
|
+
header: JsonRpcTransformers.blockHeaderTo(block.header),
|
|
209
|
+
proposals: block.proposals,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
static blockTo(block: JsonRpcBlock): ClientBlock {
|
|
213
|
+
return {
|
|
214
|
+
header: JsonRpcTransformers.blockHeaderTo(block.header),
|
|
215
|
+
proposals: block.proposals,
|
|
216
|
+
transactions: block.transactions.map((t) =>
|
|
217
|
+
JsonRpcTransformers.transactionTo(t),
|
|
218
|
+
),
|
|
219
|
+
uncles: block.uncles.map((u) => JsonRpcTransformers.blockUncleTo(u)),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
184
222
|
static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex] {
|
|
185
223
|
return [numToHex(a), numToHex(b)];
|
|
186
224
|
}
|
|
@@ -47,6 +47,33 @@ export type JsonRpcTransaction = {
|
|
|
47
47
|
witnesses: Hex[];
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
export type JsonRpcBlockHeader = {
|
|
51
|
+
compact_target: Hex;
|
|
52
|
+
dao: Hex;
|
|
53
|
+
epoch: Hex;
|
|
54
|
+
extra_hash: Hex;
|
|
55
|
+
hash: Hex;
|
|
56
|
+
nonce: Hex;
|
|
57
|
+
number: Hex;
|
|
58
|
+
parent_hash: Hex;
|
|
59
|
+
proposals_hash: Hex;
|
|
60
|
+
timestamp: Hex;
|
|
61
|
+
transactions_root: Hex;
|
|
62
|
+
version: Hex;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type JsonRpcBlockUncle = {
|
|
66
|
+
header: JsonRpcBlockHeader;
|
|
67
|
+
proposals: Hex[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type JsonRpcBlock = {
|
|
71
|
+
header: JsonRpcBlockHeader;
|
|
72
|
+
proposals: Hex[];
|
|
73
|
+
transactions: JsonRpcTransaction[];
|
|
74
|
+
uncles: JsonRpcBlockUncle[];
|
|
75
|
+
};
|
|
76
|
+
|
|
50
77
|
export type JsonRpcIndexerSearchKeyFilter = {
|
|
51
78
|
script?: JsonRpcScript;
|
|
52
79
|
script_len_range?: [Hex, Hex];
|
package/src/signer/ckb/index.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { verifySignature } from "@joyid/ckb";
|
|
2
|
+
import { BytesLike } from "../../bytes/index.js";
|
|
3
|
+
import { hexFrom } from "../../hex/index.js";
|
|
4
|
+
|
|
5
|
+
export function verifyMessageJoyId(
|
|
6
|
+
message: string | BytesLike,
|
|
7
|
+
signature: string,
|
|
8
|
+
identity: string,
|
|
9
|
+
): Promise<boolean> {
|
|
10
|
+
const challenge =
|
|
11
|
+
typeof message === "string" ? message : hexFrom(message).slice(2);
|
|
12
|
+
const { publicKey, keyType } = JSON.parse(identity);
|
|
13
|
+
|
|
14
|
+
return verifySignature({
|
|
15
|
+
challenge,
|
|
16
|
+
pubkey: publicKey,
|
|
17
|
+
keyType,
|
|
18
|
+
...JSON.parse(signature),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -6,6 +6,7 @@ import { Hex } from "../../hex/index.js";
|
|
|
6
6
|
import { Num } from "../../num/index.js";
|
|
7
7
|
import { verifyMessageBtcEcdsa } from "../btc/index.js";
|
|
8
8
|
import { verifyMessageCkbSecp256k1 } from "../ckb/verifyCkbSecp256k1.js";
|
|
9
|
+
import { verifyMessageJoyId } from "../ckb/verifyJoyId.js";
|
|
9
10
|
import { verifyMessageEvmPersonal } from "../evm/verify.js";
|
|
10
11
|
import { verifyMessageNostrEvent } from "../nostr/verify.js";
|
|
11
12
|
|
|
@@ -106,7 +107,11 @@ export abstract class Signer {
|
|
|
106
107
|
signature.identity,
|
|
107
108
|
);
|
|
108
109
|
case SignerSignType.JoyId:
|
|
109
|
-
|
|
110
|
+
return verifyMessageJoyId(
|
|
111
|
+
message,
|
|
112
|
+
signature.signature,
|
|
113
|
+
signature.identity,
|
|
114
|
+
);
|
|
110
115
|
case SignerSignType.NostrEvent:
|
|
111
116
|
return verifyMessageNostrEvent(
|
|
112
117
|
message,
|