@ckb-ccc/core 0.0.13-alpha.8 → 0.0.14-alpha.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 +57 -0
- package/dist/client/client.d.ts +3 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +9 -2
- package/dist/client/clientTypes.d.ts +12 -4
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +13 -1
- package/dist/client/jsonRpc/index.d.ts +10 -1
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +48 -14
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbPrivateKey.js +9 -8
- package/dist/signer/ckb/signerCkbPublicKey.d.ts +8 -2
- package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbPublicKey.js +65 -7
- package/dist.commonjs/client/client.d.ts +3 -1
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +9 -2
- package/dist.commonjs/client/clientTypes.d.ts +12 -4
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +16 -2
- package/dist.commonjs/client/jsonRpc/index.d.ts +10 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +46 -12
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +9 -8
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +8 -2
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +64 -6
- package/package.json +1 -1
- package/src/client/client.ts +23 -2
- package/src/client/clientTypes.ts +27 -5
- package/src/client/jsonRpc/index.ts +97 -30
- package/src/signer/ckb/signerCkbPrivateKey.ts +13 -9
- package/src/signer/ckb/signerCkbPublicKey.ts +97 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientTypes.d.ts","sourceRoot":"","sources":["../../src/client/clientTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,iBAAiB,CAAC;AAExD,OAAO,EACL,oCAAoC,EACpC,8BAA8B,EAE/B,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,yBAAyB,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,SAAS,GACT,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AACf;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAC1C,oCAAoC,GAAG;IACrC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AACJ;;GAEG;AACH,qBAAa,4BAA4B;IAE9B,MAAM,EAAE,MAAM,GAAG,SAAS;IAC1B,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,G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CAAC;CACd;AACD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE,mBAAmB;CAKxC;AAED,qBAAa,yBAA0B,SAAQ,eAAe;IAC5D,SAAgB,QAAQ,EAAE,QAAQ,CAAC;gBACvB,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,YAAY;CAIpE;AAED,qBAAa,uBAAwB,SAAQ,eAAe;aAMxC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY;aAE3C,SAAS,EAAE,MAAM;aACjB,cAAc,EAAE,MAAM,GAAG,MAAM;IARjD,SAAgB,WAAW,EAAE,GAAG,CAAC;IACjC,SAAgB,cAAc,EAAE,GAAG,CAAC;gBAGlC,MAAM,EAAE,mBAAmB,EACX,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,EAC3D,WAAW,EAAE,OAAO,EACJ,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GAAG,MAAM,EAC/C,cAAc,EAAE,OAAO;CAM1B;AAED,qBAAa,gCAAiC,SAAQ,eAAe;IACnE,SAAgB,MAAM,EAAE,GAAG,CAAC;gBAEhB,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO;CAIzD;AAED,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAgB,UAAU,EAAE,GAAG,CAAC;IAChC,SAAgB,QAAQ,EAAE,GAAG,CAAC;gBAG5B,MAAM,EAAE,mBAAmB,EAC3B,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,OAAO;CAMpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorClientVerification = exports.ErrorClientResolveUnknown = exports.ErrorClientBase = exports.ClientIndexerSearchKeyTransaction = exports.ClientIndexerSearchKey = exports.ClientIndexerSearchKeyFilter = void 0;
|
|
3
|
+
exports.ErrorClientRBFRejected = exports.ErrorClientDuplicatedTransaction = exports.ErrorClientVerification = exports.ErrorClientResolveUnknown = exports.ErrorClientBase = exports.ClientIndexerSearchKeyTransaction = exports.ClientIndexerSearchKey = exports.ClientIndexerSearchKeyFilter = void 0;
|
|
4
4
|
const index_js_1 = require("../ckb/index.js");
|
|
5
5
|
const index_js_2 = require("../hex/index.js");
|
|
6
6
|
const index_js_3 = require("../num/index.js");
|
|
@@ -59,7 +59,6 @@ exports.ClientIndexerSearchKeyTransaction = ClientIndexerSearchKeyTransaction;
|
|
|
59
59
|
class ErrorClientBase extends Error {
|
|
60
60
|
constructor(origin) {
|
|
61
61
|
super(origin.message);
|
|
62
|
-
this.message = origin.message;
|
|
63
62
|
this.code = origin.code;
|
|
64
63
|
this.data = origin.data;
|
|
65
64
|
}
|
|
@@ -83,3 +82,18 @@ class ErrorClientVerification extends ErrorClientBase {
|
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
exports.ErrorClientVerification = ErrorClientVerification;
|
|
85
|
+
class ErrorClientDuplicatedTransaction extends ErrorClientBase {
|
|
86
|
+
constructor(origin, txHash) {
|
|
87
|
+
super(origin);
|
|
88
|
+
this.txHash = (0, index_js_2.hexFrom)(txHash);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ErrorClientDuplicatedTransaction = ErrorClientDuplicatedTransaction;
|
|
92
|
+
class ErrorClientRBFRejected extends ErrorClientBase {
|
|
93
|
+
constructor(origin, currentFee, leastFee) {
|
|
94
|
+
super(origin);
|
|
95
|
+
this.currentFee = (0, index_js_3.numFrom)(currentFee);
|
|
96
|
+
this.leastFee = (0, index_js_3.numFrom)(leastFee);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ErrorClientRBFRejected = ErrorClientRBFRejected;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransactionLike } from "../../ckb/index.js";
|
|
1
|
+
import { Cell, OutPointLike, TransactionLike } from "../../ckb/index.js";
|
|
2
2
|
import { Hex, HexLike } from "../../hex/index.js";
|
|
3
3
|
import { Num, NumLike } from "../../num/index.js";
|
|
4
4
|
import { ClientCache } from "../cache/index.js";
|
|
@@ -105,6 +105,15 @@ export declare abstract class ClientJsonRpc extends Client {
|
|
|
105
105
|
* @returns The transaction with status.
|
|
106
106
|
*/
|
|
107
107
|
getTransactionNoCache: (txHash: HexLike) => Promise<ClientTransactionResponse | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Get a live cell from node.
|
|
110
|
+
*
|
|
111
|
+
* @param outPoint - The out point of the cell.
|
|
112
|
+
* @param withData - Include data in the response.
|
|
113
|
+
* @param includeTxPool - Include cells in the tx pool.
|
|
114
|
+
* @returns The cell
|
|
115
|
+
*/
|
|
116
|
+
getCellLiveNoCache(outPoint: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
|
|
108
117
|
/**
|
|
109
118
|
* find cells from node.
|
|
110
119
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EAOzB,gBAAgB,EACjB,M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,qBAAqB;;;;;;;;MAQgB;IAErC;;;;;OAKG;IAEH,gBAAgB,QAIL,0BAA0B,KAAK,QAAQ,GAAG,CAAC,CAAC;IAEvD;;;;;;;OAOG;IAEH,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,GACnC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC;IAwC1C;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAerD;;;;;;OAMG;IAEH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
|
|
@@ -28,6 +28,28 @@ async function transform(value, transformer) {
|
|
|
28
28
|
}
|
|
29
29
|
return value;
|
|
30
30
|
}
|
|
31
|
+
const ERROR_PARSERS = [
|
|
32
|
+
[
|
|
33
|
+
"Resolve\\(Unknown\\(OutPoint\\((0x.*)\\)\\)\\)",
|
|
34
|
+
(error, match) => new clientTypes_js_1.ErrorClientResolveUnknown(error, index_js_1.OutPoint.fromBytes(match[1])),
|
|
35
|
+
],
|
|
36
|
+
[
|
|
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",
|
|
38
|
+
(error, match) => new clientTypes_js_1.ErrorClientVerification(error, match[3] === "Lock"
|
|
39
|
+
? "lock"
|
|
40
|
+
: match[1] === "Inputs"
|
|
41
|
+
? "inputType"
|
|
42
|
+
: "outputType", match[2], Number(match[4]), match[5] === "data" ? "data" : "type", match[6]),
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"Duplicated\\(Byte32\\((0x.*)\\)\\)",
|
|
46
|
+
(error, match) => new clientTypes_js_1.ErrorClientDuplicatedTransaction(error, match[1]),
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'RBFRejected\\("Tx\'s current fee is ([0-9]*), expect it to >= ([0-9]*) to replace old txs"\\)',
|
|
50
|
+
(error, match) => new clientTypes_js_1.ErrorClientRBFRejected(error, match[1], match[2]),
|
|
51
|
+
],
|
|
52
|
+
];
|
|
31
53
|
/**
|
|
32
54
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
33
55
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
@@ -164,6 +186,21 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
164
186
|
get url() {
|
|
165
187
|
return this.url_;
|
|
166
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Get a live cell from node.
|
|
191
|
+
*
|
|
192
|
+
* @param outPoint - The out point of the cell.
|
|
193
|
+
* @param withData - Include data in the response.
|
|
194
|
+
* @param includeTxPool - Include cells in the tx pool.
|
|
195
|
+
* @returns The cell
|
|
196
|
+
*/
|
|
197
|
+
getCellLiveNoCache(outPoint, withData, includeTxPool) {
|
|
198
|
+
return this.buildSender("get_live_cell", [advanced_js_2.JsonRpcTransformers.outPointFrom], ({ cell, }) => (0, index_js_4.apply)(({ output, data, }) => index_js_1.Cell.from({
|
|
199
|
+
cellOutput: advanced_js_2.JsonRpcTransformers.cellOutputTo(output),
|
|
200
|
+
outputData: data?.content ?? "0x",
|
|
201
|
+
outPoint,
|
|
202
|
+
}), cell))(outPoint, withData ?? true, includeTxPool);
|
|
203
|
+
}
|
|
167
204
|
/**
|
|
168
205
|
* Builds a sender function for a JSON-RPC method.
|
|
169
206
|
*
|
|
@@ -181,21 +218,18 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
181
218
|
return transform(await this.send(payload), outTransformer);
|
|
182
219
|
}
|
|
183
220
|
catch (errAny) {
|
|
184
|
-
if (typeof errAny !== "object" ||
|
|
221
|
+
if (typeof errAny !== "object" ||
|
|
222
|
+
errAny === null ||
|
|
223
|
+
!("data" in errAny) ||
|
|
224
|
+
typeof errAny.data !== "string") {
|
|
185
225
|
throw errAny;
|
|
186
226
|
}
|
|
187
227
|
const err = errAny;
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (verificationFailedMatch) {
|
|
194
|
-
throw new clientTypes_js_1.ErrorClientVerification(err, verificationFailedMatch[3] === "Lock"
|
|
195
|
-
? "lock"
|
|
196
|
-
: verificationFailedMatch[1] === "Inputs"
|
|
197
|
-
? "inputType"
|
|
198
|
-
: "outputType", verificationFailedMatch[2], Number(verificationFailedMatch[4]), verificationFailedMatch[5] === "data" ? "data" : "type", verificationFailedMatch[6]);
|
|
228
|
+
for (const [regexp, builder] of ERROR_PARSERS) {
|
|
229
|
+
const match = err.data.match(regexp);
|
|
230
|
+
if (match) {
|
|
231
|
+
throw builder(err, match);
|
|
232
|
+
}
|
|
199
233
|
}
|
|
200
234
|
throw new clientTypes_js_1.ErrorClientBase(err);
|
|
201
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbPrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAW,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,SAAgB,UAAU,EAAE,GAAG,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;IAUzC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAgB5C,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzD,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerCkbPrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAW,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,SAAgB,UAAU,EAAE,GAAG,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;IAUzC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAgB5C,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzD,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAmBzE"}
|
|
@@ -30,15 +30,16 @@ class SignerCkbPrivateKey extends signerCkbPublicKey_js_1.SignerCkbPublicKey {
|
|
|
30
30
|
}
|
|
31
31
|
async signOnlyTransaction(txLike) {
|
|
32
32
|
const tx = index_js_2.Transaction.from(txLike);
|
|
33
|
-
const { script }
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
for (const { script } of await this.getRelatedScripts(tx)) {
|
|
34
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
35
|
+
if (!info) {
|
|
36
|
+
return tx;
|
|
37
|
+
}
|
|
38
|
+
const signature = await this._signMessage(info.message);
|
|
39
|
+
const witness = tx.getWitnessArgsAt(info.position) ?? index_js_2.WitnessArgs.from({});
|
|
40
|
+
witness.lock = signature;
|
|
41
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
37
42
|
}
|
|
38
|
-
const signature = await this._signMessage(info.message);
|
|
39
|
-
const witness = tx.getWitnessArgsAt(info.position) ?? index_js_2.WitnessArgs.from({});
|
|
40
|
-
witness.lock = signature;
|
|
41
|
-
tx.setWitnessArgsAt(info.position, witness);
|
|
42
43
|
return tx;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address } from "../../address/index.js";
|
|
2
|
-
import { Transaction, TransactionLike } from "../../ckb/index.js";
|
|
3
|
-
import { Client } from "../../client/index.js";
|
|
2
|
+
import { Script, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
3
|
+
import { CellDepInfo, Client } from "../../client/index.js";
|
|
4
4
|
import { Hex, HexLike } from "../../hex/index.js";
|
|
5
5
|
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
6
6
|
/**
|
|
@@ -15,7 +15,13 @@ export declare class SignerCkbPublicKey extends Signer {
|
|
|
15
15
|
isConnected(): Promise<boolean>;
|
|
16
16
|
getInternalAddress(): Promise<string>;
|
|
17
17
|
getIdentity(): Promise<string>;
|
|
18
|
+
getAddressObjSecp256k1(): Promise<Address>;
|
|
19
|
+
getRecommendedAddressObj(_preference?: unknown): Promise<Address>;
|
|
18
20
|
getAddressObjs(): Promise<Address[]>;
|
|
21
|
+
getRelatedScripts(txLike: TransactionLike): Promise<{
|
|
22
|
+
script: Script;
|
|
23
|
+
cellDeps: CellDepInfo[];
|
|
24
|
+
}[]>;
|
|
19
25
|
prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
20
26
|
}
|
|
21
27
|
//# sourceMappingURL=signerCkbPublicKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbPublicKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"signerCkbPublicKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,EAAe,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,SAAgB,SAAS,EAAE,GAAG,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;IASxC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAExB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ1C,wBAAwB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjE,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAmCpC,iBAAiB,CACrB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,WAAW,EAAE,CAAA;KAAE,EAAE,CAAC;IA6CnD,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAWxE"}
|
|
@@ -35,16 +35,74 @@ class SignerCkbPublicKey extends index_js_7.Signer {
|
|
|
35
35
|
async getIdentity() {
|
|
36
36
|
return this.publicKey;
|
|
37
37
|
}
|
|
38
|
+
async getAddressObjSecp256k1() {
|
|
39
|
+
return index_js_1.Address.fromKnownScript(this.client, index_js_4.KnownScript.Secp256k1Blake160, (0, index_js_2.bytesFrom)((0, index_js_5.hashCkb)(this.publicKey)).slice(0, 20));
|
|
40
|
+
}
|
|
41
|
+
async getRecommendedAddressObj(_preference) {
|
|
42
|
+
return this.getAddressObjSecp256k1();
|
|
43
|
+
}
|
|
38
44
|
async getAddressObjs() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const secp256k1 = await this.getAddressObjSecp256k1();
|
|
46
|
+
const addresses = [];
|
|
47
|
+
let count = 0;
|
|
48
|
+
for await (const cell of this.client.findCells({
|
|
49
|
+
script: await index_js_3.Script.fromKnownScript(this.client, index_js_4.KnownScript.AnyoneCanPay, secp256k1.script.args),
|
|
50
|
+
scriptType: "lock",
|
|
51
|
+
scriptSearchMode: "prefix",
|
|
52
|
+
withData: false,
|
|
53
|
+
})) {
|
|
54
|
+
if (count >= 10) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
count += 1;
|
|
58
|
+
if (addresses.some(({ script }) => script.eq(cell.cellOutput.lock))) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
addresses.push(index_js_1.Address.from({
|
|
62
|
+
prefix: this.client.addressPrefix,
|
|
63
|
+
script: cell.cellOutput.lock,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return [secp256k1, ...addresses];
|
|
67
|
+
}
|
|
68
|
+
async getRelatedScripts(txLike) {
|
|
69
|
+
const tx = index_js_3.Transaction.from(txLike);
|
|
70
|
+
const secp256k1 = await this.getAddressObjSecp256k1();
|
|
71
|
+
const acp = await index_js_3.Script.fromKnownScript(this.client, index_js_4.KnownScript.AnyoneCanPay, secp256k1.script.args);
|
|
72
|
+
const scripts = [];
|
|
73
|
+
for (const input of tx.inputs) {
|
|
74
|
+
await input.completeExtraInfos(this.client);
|
|
75
|
+
if (!input.cellOutput) {
|
|
76
|
+
throw new Error("Unable to complete input");
|
|
77
|
+
}
|
|
78
|
+
const { lock } = input.cellOutput;
|
|
79
|
+
if (scripts.some(({ script }) => script.eq(lock))) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (lock.eq(secp256k1.script)) {
|
|
83
|
+
scripts.push({
|
|
84
|
+
script: lock,
|
|
85
|
+
cellDeps: (await this.client.getKnownScript(index_js_4.KnownScript.Secp256k1Blake160)).cellDeps,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (lock.codeHash === acp.codeHash &&
|
|
89
|
+
lock.hashType === acp.hashType &&
|
|
90
|
+
lock.args.startsWith(acp.args)) {
|
|
91
|
+
scripts.push({
|
|
92
|
+
script: lock,
|
|
93
|
+
cellDeps: (await this.client.getKnownScript(index_js_4.KnownScript.AnyoneCanPay))
|
|
94
|
+
.cellDeps,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return scripts;
|
|
42
99
|
}
|
|
43
100
|
async prepareTransaction(txLike) {
|
|
44
101
|
const tx = index_js_3.Transaction.from(txLike);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
102
|
+
await Promise.all((await this.getRelatedScripts(tx)).map(async ({ script, cellDeps }) => {
|
|
103
|
+
await tx.prepareSighashAllWitness(script, 65, this.client);
|
|
104
|
+
await tx.addCellDepInfos(this.client, cellDeps);
|
|
105
|
+
}));
|
|
48
106
|
return tx;
|
|
49
107
|
}
|
|
50
108
|
}
|
package/package.json
CHANGED
package/src/client/client.ts
CHANGED
|
@@ -155,6 +155,27 @@ export abstract class Client {
|
|
|
155
155
|
return cell;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
abstract getCellLiveNoCache(
|
|
159
|
+
outPointLike: OutPointLike,
|
|
160
|
+
withData?: boolean | null,
|
|
161
|
+
includeTxPool?: boolean | null,
|
|
162
|
+
): Promise<Cell | undefined>;
|
|
163
|
+
async getCellLive(
|
|
164
|
+
outPointLike: OutPointLike,
|
|
165
|
+
withData?: boolean | null,
|
|
166
|
+
includeTxPool?: boolean | null,
|
|
167
|
+
): Promise<Cell | undefined> {
|
|
168
|
+
const cell = await this.getCellLiveNoCache(
|
|
169
|
+
outPointLike,
|
|
170
|
+
withData,
|
|
171
|
+
includeTxPool,
|
|
172
|
+
);
|
|
173
|
+
if (withData && cell) {
|
|
174
|
+
await this.cache.recordCells(cell);
|
|
175
|
+
}
|
|
176
|
+
return cell;
|
|
177
|
+
}
|
|
178
|
+
|
|
158
179
|
abstract findCellsPagedNoCache(
|
|
159
180
|
key: ClientIndexerSearchKeyLike,
|
|
160
181
|
order?: "asc" | "desc",
|
|
@@ -172,7 +193,7 @@ export abstract class Client {
|
|
|
172
193
|
return res;
|
|
173
194
|
}
|
|
174
195
|
|
|
175
|
-
async *
|
|
196
|
+
async *findCellsOnChain(
|
|
176
197
|
key: ClientIndexerSearchKeyLike,
|
|
177
198
|
order?: "asc" | "desc",
|
|
178
199
|
limit = 10,
|
|
@@ -215,7 +236,7 @@ export abstract class Client {
|
|
|
215
236
|
yield cell;
|
|
216
237
|
}
|
|
217
238
|
|
|
218
|
-
for await (const cell of this.
|
|
239
|
+
for await (const cell of this.findCellsOnChain(key, order, limit)) {
|
|
219
240
|
if (
|
|
220
241
|
(await this.cache.isUnusable(cell.outPoint)) ||
|
|
221
242
|
foundedOutPoints.some((founded) => founded.eq(cell.outPoint))
|
|
@@ -240,18 +240,16 @@ export type ClientBlock = {
|
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
export interface ErrorClientBaseLike {
|
|
243
|
-
message
|
|
244
|
-
code
|
|
243
|
+
message?: string;
|
|
244
|
+
code?: number;
|
|
245
245
|
data: string;
|
|
246
246
|
}
|
|
247
247
|
export class ErrorClientBase extends Error {
|
|
248
|
-
public readonly
|
|
249
|
-
public readonly code: number;
|
|
248
|
+
public readonly code?: number;
|
|
250
249
|
public readonly data: string;
|
|
251
250
|
|
|
252
251
|
constructor(origin: ErrorClientBaseLike) {
|
|
253
252
|
super(origin.message);
|
|
254
|
-
this.message = origin.message;
|
|
255
253
|
this.code = origin.code;
|
|
256
254
|
this.data = origin.data;
|
|
257
255
|
}
|
|
@@ -282,3 +280,27 @@ export class ErrorClientVerification extends ErrorClientBase {
|
|
|
282
280
|
this.scriptCodeHash = hexFrom(scriptCodeHash);
|
|
283
281
|
}
|
|
284
282
|
}
|
|
283
|
+
|
|
284
|
+
export class ErrorClientDuplicatedTransaction extends ErrorClientBase {
|
|
285
|
+
public readonly txHash: Hex;
|
|
286
|
+
|
|
287
|
+
constructor(origin: ErrorClientBaseLike, txHash: HexLike) {
|
|
288
|
+
super(origin);
|
|
289
|
+
this.txHash = hexFrom(txHash);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export class ErrorClientRBFRejected extends ErrorClientBase {
|
|
294
|
+
public readonly currentFee: Num;
|
|
295
|
+
public readonly leastFee: Num;
|
|
296
|
+
|
|
297
|
+
constructor(
|
|
298
|
+
origin: ErrorClientBaseLike,
|
|
299
|
+
currentFee: NumLike,
|
|
300
|
+
leastFee: NumLike,
|
|
301
|
+
) {
|
|
302
|
+
super(origin);
|
|
303
|
+
this.currentFee = numFrom(currentFee);
|
|
304
|
+
this.leastFee = numFrom(leastFee);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Cell,
|
|
3
|
+
OutPoint,
|
|
4
|
+
OutPointLike,
|
|
5
|
+
TransactionLike,
|
|
6
|
+
} from "../../ckb/index.js";
|
|
2
7
|
import { Hex, HexLike, hexFrom } from "../../hex/index.js";
|
|
3
8
|
import { Num, NumLike, numFrom, numToHex } from "../../num/index.js";
|
|
4
9
|
import { apply } from "../../utils/index.js";
|
|
@@ -10,6 +15,8 @@ import {
|
|
|
10
15
|
ClientTransactionResponse,
|
|
11
16
|
ErrorClientBase,
|
|
12
17
|
ErrorClientBaseLike,
|
|
18
|
+
ErrorClientDuplicatedTransaction,
|
|
19
|
+
ErrorClientRBFRejected,
|
|
13
20
|
ErrorClientResolveUnknown,
|
|
14
21
|
ErrorClientVerification,
|
|
15
22
|
OutputsValidator,
|
|
@@ -19,7 +26,7 @@ import {
|
|
|
19
26
|
Transport,
|
|
20
27
|
transportFromUri,
|
|
21
28
|
} from "../transports/advanced.js";
|
|
22
|
-
import { JsonRpcTransformers } from "./advanced.js";
|
|
29
|
+
import { JsonRpcCellOutput, JsonRpcTransformers } from "./advanced.js";
|
|
23
30
|
|
|
24
31
|
/**
|
|
25
32
|
* Applies a transformation function to a value if the transformer is provided.
|
|
@@ -45,6 +52,41 @@ async function transform(
|
|
|
45
52
|
return value;
|
|
46
53
|
}
|
|
47
54
|
|
|
55
|
+
const ERROR_PARSERS: [
|
|
56
|
+
string,
|
|
57
|
+
(error: ErrorClientBaseLike, match: RegExpMatchArray) => ErrorClientBase,
|
|
58
|
+
][] = [
|
|
59
|
+
[
|
|
60
|
+
"Resolve\\(Unknown\\(OutPoint\\((0x.*)\\)\\)\\)",
|
|
61
|
+
(error, match) =>
|
|
62
|
+
new ErrorClientResolveUnknown(error, OutPoint.fromBytes(match[1])),
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
"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",
|
|
66
|
+
(error, match) =>
|
|
67
|
+
new ErrorClientVerification(
|
|
68
|
+
error,
|
|
69
|
+
match[3] === "Lock"
|
|
70
|
+
? "lock"
|
|
71
|
+
: match[1] === "Inputs"
|
|
72
|
+
? "inputType"
|
|
73
|
+
: "outputType",
|
|
74
|
+
match[2],
|
|
75
|
+
Number(match[4]),
|
|
76
|
+
match[5] === "data" ? "data" : "type",
|
|
77
|
+
match[6],
|
|
78
|
+
),
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
"Duplicated\\(Byte32\\((0x.*)\\)\\)",
|
|
82
|
+
(error, match) => new ErrorClientDuplicatedTransaction(error, match[1]),
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
'RBFRejected\\("Tx\'s current fee is ([0-9]*), expect it to >= ([0-9]*) to replace old txs"\\)',
|
|
86
|
+
(error, match) => new ErrorClientRBFRejected(error, match[1], match[2]),
|
|
87
|
+
],
|
|
88
|
+
];
|
|
89
|
+
|
|
48
90
|
/**
|
|
49
91
|
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
50
92
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
@@ -207,6 +249,48 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
207
249
|
JsonRpcTransformers.transactionResponseTo,
|
|
208
250
|
) as (txHash: HexLike) => Promise<ClientTransactionResponse | undefined>;
|
|
209
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Get a live cell from node.
|
|
254
|
+
*
|
|
255
|
+
* @param outPoint - The out point of the cell.
|
|
256
|
+
* @param withData - Include data in the response.
|
|
257
|
+
* @param includeTxPool - Include cells in the tx pool.
|
|
258
|
+
* @returns The cell
|
|
259
|
+
*/
|
|
260
|
+
getCellLiveNoCache(
|
|
261
|
+
outPoint: OutPointLike,
|
|
262
|
+
withData?: boolean | null,
|
|
263
|
+
includeTxPool?: boolean | null,
|
|
264
|
+
) {
|
|
265
|
+
return this.buildSender(
|
|
266
|
+
"get_live_cell",
|
|
267
|
+
[JsonRpcTransformers.outPointFrom],
|
|
268
|
+
({
|
|
269
|
+
cell,
|
|
270
|
+
}: {
|
|
271
|
+
cell?: {
|
|
272
|
+
output: JsonRpcCellOutput;
|
|
273
|
+
data?: { content: HexLike; hash: HexLike };
|
|
274
|
+
};
|
|
275
|
+
}) =>
|
|
276
|
+
apply(
|
|
277
|
+
({
|
|
278
|
+
output,
|
|
279
|
+
data,
|
|
280
|
+
}: {
|
|
281
|
+
output: JsonRpcCellOutput;
|
|
282
|
+
data?: { content: HexLike; hash: HexLike };
|
|
283
|
+
}) =>
|
|
284
|
+
Cell.from({
|
|
285
|
+
cellOutput: JsonRpcTransformers.cellOutputTo(output),
|
|
286
|
+
outputData: data?.content ?? "0x",
|
|
287
|
+
outPoint,
|
|
288
|
+
}),
|
|
289
|
+
cell,
|
|
290
|
+
),
|
|
291
|
+
)(outPoint, withData ?? true, includeTxPool) as Promise<Cell | undefined>;
|
|
292
|
+
}
|
|
293
|
+
|
|
210
294
|
/**
|
|
211
295
|
* find cells from node.
|
|
212
296
|
*
|
|
@@ -296,38 +380,21 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
296
380
|
try {
|
|
297
381
|
return transform(await this.send(payload), outTransformer);
|
|
298
382
|
} catch (errAny: unknown) {
|
|
299
|
-
if (
|
|
383
|
+
if (
|
|
384
|
+
typeof errAny !== "object" ||
|
|
385
|
+
errAny === null ||
|
|
386
|
+
!("data" in errAny) ||
|
|
387
|
+
typeof errAny.data !== "string"
|
|
388
|
+
) {
|
|
300
389
|
throw errAny;
|
|
301
390
|
}
|
|
302
391
|
const err = errAny as ErrorClientBaseLike;
|
|
303
392
|
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
err,
|
|
310
|
-
OutPoint.fromBytes(unknownOutPointMatch),
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
const verificationFailedMatch = err.data.match(
|
|
314
|
-
new RegExp(
|
|
315
|
-
"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",
|
|
316
|
-
),
|
|
317
|
-
);
|
|
318
|
-
if (verificationFailedMatch) {
|
|
319
|
-
throw new ErrorClientVerification(
|
|
320
|
-
err,
|
|
321
|
-
verificationFailedMatch[3] === "Lock"
|
|
322
|
-
? "lock"
|
|
323
|
-
: verificationFailedMatch[1] === "Inputs"
|
|
324
|
-
? "inputType"
|
|
325
|
-
: "outputType",
|
|
326
|
-
verificationFailedMatch[2],
|
|
327
|
-
Number(verificationFailedMatch[4]),
|
|
328
|
-
verificationFailedMatch[5] === "data" ? "data" : "type",
|
|
329
|
-
verificationFailedMatch[6],
|
|
330
|
-
);
|
|
393
|
+
for (const [regexp, builder] of ERROR_PARSERS) {
|
|
394
|
+
const match = err.data.match(regexp);
|
|
395
|
+
if (match) {
|
|
396
|
+
throw builder(err, match);
|
|
397
|
+
}
|
|
331
398
|
}
|
|
332
399
|
|
|
333
400
|
throw new ErrorClientBase(err);
|
|
@@ -45,17 +45,21 @@ export class SignerCkbPrivateKey extends SignerCkbPublicKey {
|
|
|
45
45
|
|
|
46
46
|
async signOnlyTransaction(txLike: TransactionLike): Promise<Transaction> {
|
|
47
47
|
const tx = Transaction.from(txLike);
|
|
48
|
-
const { script } = await this.getRecommendedAddressObj();
|
|
49
|
-
const info = await tx.getSignHashInfo(script, this.client);
|
|
50
|
-
if (!info) {
|
|
51
|
-
return tx;
|
|
52
|
-
}
|
|
53
48
|
|
|
54
|
-
const
|
|
49
|
+
for (const { script } of await this.getRelatedScripts(tx)) {
|
|
50
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
51
|
+
if (!info) {
|
|
52
|
+
return tx;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const signature = await this._signMessage(info.message);
|
|
56
|
+
|
|
57
|
+
const witness =
|
|
58
|
+
tx.getWitnessArgsAt(info.position) ?? WitnessArgs.from({});
|
|
59
|
+
witness.lock = signature;
|
|
60
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
61
|
+
}
|
|
55
62
|
|
|
56
|
-
const witness = tx.getWitnessArgsAt(info.position) ?? WitnessArgs.from({});
|
|
57
|
-
witness.lock = signature;
|
|
58
|
-
tx.setWitnessArgsAt(info.position, witness);
|
|
59
63
|
return tx;
|
|
60
64
|
}
|
|
61
65
|
}
|