@ckb-ccc/core 0.0.4 → 0.0.5-alpha.1
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/README.md +6 -0
- package/dist/ckb/transaction.d.ts +85 -2
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +152 -7
- package/dist/client/client.d.ts +11 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +44 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +4 -0
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +4 -0
- package/dist/client/clientTypes.d.ts +48 -1
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +27 -1
- package/dist/client/jsonRpc/index.d.ts +19 -1
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +25 -1
- package/dist/client/jsonRpc/transformers.d.ts +17 -3
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +37 -3
- package/dist/client/jsonRpc/types.d.ts +15 -0
- package/dist/client/jsonRpc/types.d.ts.map +1 -1
- package/dist/fixedPoint/index.d.ts.map +1 -1
- package/dist/fixedPoint/index.js +4 -1
- package/dist/fixedPoint/index.test.d.ts +2 -0
- package/dist/fixedPoint/index.test.d.ts.map +1 -0
- package/dist/fixedPoint/index.test.js +43 -0
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +2 -3
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +2 -3
- package/dist/signer/index.d.ts +0 -1
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +0 -1
- package/dist/signer/signer.d.ts +17 -2
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +17 -1
- package/dist.commonjs/ckb/transaction.d.ts +85 -2
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +150 -5
- package/dist.commonjs/client/client.d.ts +11 -3
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +43 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +4 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +4 -0
- package/dist.commonjs/client/clientTypes.d.ts +48 -1
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +29 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts +19 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +25 -1
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +17 -3
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +35 -1
- package/dist.commonjs/client/jsonRpc/types.d.ts +15 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -1
- package/dist.commonjs/fixedPoint/index.d.ts.map +1 -1
- package/dist.commonjs/fixedPoint/index.js +4 -1
- package/dist.commonjs/fixedPoint/index.test.d.ts +2 -0
- package/dist.commonjs/fixedPoint/index.test.d.ts.map +1 -0
- package/dist.commonjs/fixedPoint/index.test.js +45 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +2 -3
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +2 -3
- package/dist.commonjs/signer/index.d.ts +0 -1
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +0 -1
- package/dist.commonjs/signer/signer.d.ts +17 -2
- package/dist.commonjs/signer/signer.d.ts.map +1 -1
- package/dist.commonjs/signer/signer.js +17 -1
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +1 -1
- package/jest.config.js +5 -0
- package/package.json +6 -2
- package/src/ckb/transaction.ts +198 -3
- package/src/client/client.ts +87 -3
- package/src/client/clientPublicMainnet.advanced.ts +5 -0
- package/src/client/clientPublicTestnet.advanced.ts +5 -0
- package/src/client/clientTypes.ts +70 -1
- package/src/client/jsonRpc/index.ts +54 -2
- package/src/client/jsonRpc/transformers.ts +73 -4
- package/src/client/jsonRpc/types.ts +16 -0
- package/src/fixedPoint/index.test.ts +55 -0
- package/src/fixedPoint/index.ts +7 -1
- package/src/signer/btc/signerBtc.ts +6 -3
- package/src/signer/evm/signerEvm.ts +2 -3
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +21 -0
- package/dist/signer/helpers.d.ts +0 -40
- package/dist/signer/helpers.d.ts.map +0 -1
- package/dist/signer/helpers.js +0 -91
- package/dist.commonjs/signer/helpers.d.ts +0 -40
- package/dist.commonjs/signer/helpers.d.ts.map +0 -1
- package/dist.commonjs/signer/helpers.js +0 -96
- package/src/signer/helpers.ts +0 -124
- package/tsconfig.base.json +0 -21
- package/tsconfig.commonjs.json +0 -8
package/README.md
CHANGED
|
@@ -184,19 +184,25 @@ export declare class CellOutput {
|
|
|
184
184
|
static fromBytes(bytes: BytesLike | mol.CellOutput): CellOutput;
|
|
185
185
|
}
|
|
186
186
|
export type CellLike = {
|
|
187
|
+
outPoint: OutPointLike;
|
|
187
188
|
cellOutput: CellOutputLike;
|
|
188
189
|
outputData: HexLike;
|
|
190
|
+
blockNumber: NumLike;
|
|
189
191
|
};
|
|
190
192
|
export declare class Cell {
|
|
193
|
+
outPoint: OutPoint;
|
|
191
194
|
cellOutput: CellOutput;
|
|
192
195
|
outputData: Hex;
|
|
196
|
+
blockNumber: Num;
|
|
193
197
|
/**
|
|
194
198
|
* Creates an instance of Cell.
|
|
195
199
|
*
|
|
200
|
+
* @param outPoint - The output point of the cell.
|
|
196
201
|
* @param cellOutput - The cell output of the cell.
|
|
197
202
|
* @param outputData - The output data of the cell.
|
|
203
|
+
* @param blockNumber - The block number of the cell.
|
|
198
204
|
*/
|
|
199
|
-
constructor(cellOutput: CellOutput, outputData: Hex);
|
|
205
|
+
constructor(outPoint: OutPoint, cellOutput: CellOutput, outputData: Hex, blockNumber: Num);
|
|
200
206
|
/**
|
|
201
207
|
* Creates a Cell instance from a CellLike object.
|
|
202
208
|
*
|
|
@@ -210,12 +216,14 @@ export type CellInputLike = {
|
|
|
210
216
|
since: NumLike;
|
|
211
217
|
cellOutput?: CellOutputLike;
|
|
212
218
|
outputData?: HexLike;
|
|
219
|
+
blockNumber?: NumLike;
|
|
213
220
|
};
|
|
214
221
|
export declare class CellInput {
|
|
215
222
|
previousOutput: OutPoint;
|
|
216
223
|
since: Num;
|
|
217
224
|
cellOutput?: CellOutput | undefined;
|
|
218
225
|
outputData?: `0x${string}` | undefined;
|
|
226
|
+
blockNumber?: bigint | undefined;
|
|
219
227
|
/**
|
|
220
228
|
* Creates an instance of CellInput.
|
|
221
229
|
*
|
|
@@ -223,8 +231,9 @@ export declare class CellInput {
|
|
|
223
231
|
* @param since - The since value of the cell input.
|
|
224
232
|
* @param cellOutput - The optional cell output associated with the cell input.
|
|
225
233
|
* @param outputData - The optional output data associated with the cell input.
|
|
234
|
+
* @param blockNumber - The optional block number associated with the cell input.
|
|
226
235
|
*/
|
|
227
|
-
constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: `0x${string}` | undefined);
|
|
236
|
+
constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: `0x${string}` | undefined, blockNumber?: bigint | undefined);
|
|
228
237
|
/**
|
|
229
238
|
* Creates a CellInput instance from a CellInputLike object.
|
|
230
239
|
*
|
|
@@ -495,6 +504,7 @@ export declare class Transaction {
|
|
|
495
504
|
* ```
|
|
496
505
|
*/
|
|
497
506
|
static fromLumosSkeleton(skeleton: TransactionSkeletonType): Transaction;
|
|
507
|
+
stringify(): string;
|
|
498
508
|
/**
|
|
499
509
|
* Converts the raw transaction data to bytes.
|
|
500
510
|
*
|
|
@@ -529,5 +539,78 @@ export declare class Transaction {
|
|
|
529
539
|
* ```
|
|
530
540
|
*/
|
|
531
541
|
static hashWitnessToHasher(witness: HexLike, hasher: Hasher): void;
|
|
542
|
+
/**
|
|
543
|
+
* Computes the signing hash information for a given script.
|
|
544
|
+
*
|
|
545
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
546
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
547
|
+
* @returns A promise that resolves to an object containing the signing message and the witness position,
|
|
548
|
+
* or undefined if no matching input is found.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```typescript
|
|
552
|
+
* const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
|
|
553
|
+
* if (signHashInfo) {
|
|
554
|
+
* console.log(signHashInfo.message); // Outputs the signing message
|
|
555
|
+
* console.log(signHashInfo.position); // Outputs the witness position
|
|
556
|
+
* }
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
getSignHashInfo(scriptLike: ScriptLike, client: Client): Promise<{
|
|
560
|
+
message: Hex;
|
|
561
|
+
position: number;
|
|
562
|
+
} | undefined>;
|
|
563
|
+
/**
|
|
564
|
+
* Find the first occurrence of a input with the specified lock
|
|
565
|
+
*
|
|
566
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
567
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
568
|
+
* @returns A promise that resolves to the prepared transaction
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```typescript
|
|
572
|
+
* const index = await tx.findInputIndexByLock(scriptLike, client);
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
findInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
|
|
576
|
+
/**
|
|
577
|
+
* Get witness at index as WitnessArgs
|
|
578
|
+
*
|
|
579
|
+
* @param index - The index of the witness.
|
|
580
|
+
* @returns The witness parsed as WitnessArgs.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```typescript
|
|
584
|
+
* const witnessArgs = await tx.getWitnessArgsAt(0);
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
getWitnessArgsAt(index: number): WitnessArgs | undefined;
|
|
588
|
+
/**
|
|
589
|
+
* Set witness at index by WitnessArgs
|
|
590
|
+
*
|
|
591
|
+
* @param index - The index of the witness.
|
|
592
|
+
* @param witness - The WitnessArgs to set.
|
|
593
|
+
* @returns The transaction itself.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* await tx.setWitnessArgsAt(0, witnessArgs);
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
setWitnessArgsAt(index: number, witness: WitnessArgs): Transaction;
|
|
601
|
+
/**
|
|
602
|
+
* Prepare dummy witness for sighash all method
|
|
603
|
+
*
|
|
604
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
605
|
+
* @param lockLen - The length of dummy lock bytes.
|
|
606
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
607
|
+
* @returns A promise that resolves to the prepared transaction
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* await tx.prepareSighashAllWitness(scriptLike, 85, client);
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
prepareSighashAllWitness(scriptLike: ScriptLike, lockLen: number, client: Client): Promise<Transaction>;
|
|
532
615
|
}
|
|
533
616
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/ckb/transaction.ts"],"names":[],"mappings":"AAAA,OAA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C1D;;;;;;;;;;;OAWG;IACG,oBAAoB,CACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgB9B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAOxD;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW;IAclE;;;;;;;;;;;;OAYG;IACG,wBAAwB,CAC5B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC;CAUxB"}
|
package/dist/ckb/transaction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bytesFrom } from "../bytes";
|
|
2
|
-
import { ckbHash } from "../hasher";
|
|
2
|
+
import { Hasher, ckbHash } from "../hasher";
|
|
3
3
|
import { hexFrom } from "../hex";
|
|
4
|
-
import { numFrom, numFromBytes, numToBytes } from "../num";
|
|
4
|
+
import { numFrom, numFromBytes, numToBytes, numToHex, } from "../num";
|
|
5
5
|
import { apply } from "../utils";
|
|
6
6
|
import * as mol from "./molecule.advanced";
|
|
7
7
|
import { Script } from "./script";
|
|
@@ -216,12 +216,16 @@ export class Cell {
|
|
|
216
216
|
/**
|
|
217
217
|
* Creates an instance of Cell.
|
|
218
218
|
*
|
|
219
|
+
* @param outPoint - The output point of the cell.
|
|
219
220
|
* @param cellOutput - The cell output of the cell.
|
|
220
221
|
* @param outputData - The output data of the cell.
|
|
222
|
+
* @param blockNumber - The block number of the cell.
|
|
221
223
|
*/
|
|
222
|
-
constructor(cellOutput, outputData) {
|
|
224
|
+
constructor(outPoint, cellOutput, outputData, blockNumber) {
|
|
225
|
+
this.outPoint = outPoint;
|
|
223
226
|
this.cellOutput = cellOutput;
|
|
224
227
|
this.outputData = outputData;
|
|
228
|
+
this.blockNumber = blockNumber;
|
|
225
229
|
}
|
|
226
230
|
/**
|
|
227
231
|
* Creates a Cell instance from a CellLike object.
|
|
@@ -233,7 +237,7 @@ export class Cell {
|
|
|
233
237
|
if (cell instanceof Cell) {
|
|
234
238
|
return cell;
|
|
235
239
|
}
|
|
236
|
-
return new Cell(CellOutput.from(cell.cellOutput), hexFrom(cell.outputData));
|
|
240
|
+
return new Cell(OutPoint.from(cell.outPoint), CellOutput.from(cell.cellOutput), hexFrom(cell.outputData), numFrom(cell.blockNumber));
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
export class CellInput {
|
|
@@ -244,12 +248,14 @@ export class CellInput {
|
|
|
244
248
|
* @param since - The since value of the cell input.
|
|
245
249
|
* @param cellOutput - The optional cell output associated with the cell input.
|
|
246
250
|
* @param outputData - The optional output data associated with the cell input.
|
|
251
|
+
* @param blockNumber - The optional block number associated with the cell input.
|
|
247
252
|
*/
|
|
248
|
-
constructor(previousOutput, since, cellOutput, outputData) {
|
|
253
|
+
constructor(previousOutput, since, cellOutput, outputData, blockNumber) {
|
|
249
254
|
this.previousOutput = previousOutput;
|
|
250
255
|
this.since = since;
|
|
251
256
|
this.cellOutput = cellOutput;
|
|
252
257
|
this.outputData = outputData;
|
|
258
|
+
this.blockNumber = blockNumber;
|
|
253
259
|
}
|
|
254
260
|
/**
|
|
255
261
|
* Creates a CellInput instance from a CellInputLike object.
|
|
@@ -269,7 +275,7 @@ export class CellInput {
|
|
|
269
275
|
if (cellInput instanceof CellInput) {
|
|
270
276
|
return cellInput;
|
|
271
277
|
}
|
|
272
|
-
return new CellInput(OutPoint.from(cellInput.previousOutput), numFrom(cellInput.since), apply(CellOutput.from, cellInput.cellOutput), apply(hexFrom, cellInput.outputData));
|
|
278
|
+
return new CellInput(OutPoint.from(cellInput.previousOutput), numFrom(cellInput.since), apply(CellOutput.from, cellInput.cellOutput), apply(hexFrom, cellInput.outputData), apply(numFrom, cellInput.blockNumber));
|
|
273
279
|
}
|
|
274
280
|
/**
|
|
275
281
|
* Complete extra infos in the input. Like the output of the out point.
|
|
@@ -284,13 +290,14 @@ export class CellInput {
|
|
|
284
290
|
* ```
|
|
285
291
|
*/
|
|
286
292
|
async completeExtraInfos(client) {
|
|
287
|
-
if (this.cellOutput && this.outputData) {
|
|
293
|
+
if (this.cellOutput && this.outputData && this.blockNumber) {
|
|
288
294
|
return this;
|
|
289
295
|
}
|
|
290
296
|
const cell = await client.getCell(this.previousOutput);
|
|
291
297
|
if (cell) {
|
|
292
298
|
this.cellOutput = cell.cellOutput;
|
|
293
299
|
this.outputData = cell.outputData;
|
|
300
|
+
this.blockNumber = cell.blockNumber;
|
|
294
301
|
}
|
|
295
302
|
return this;
|
|
296
303
|
}
|
|
@@ -577,6 +584,14 @@ export class Transaction {
|
|
|
577
584
|
witnesses: skeleton.witnesses.toArray(),
|
|
578
585
|
});
|
|
579
586
|
}
|
|
587
|
+
stringify() {
|
|
588
|
+
return JSON.stringify(this, (_, value) => {
|
|
589
|
+
if (typeof value === "bigint") {
|
|
590
|
+
return numToHex(value);
|
|
591
|
+
}
|
|
592
|
+
return value;
|
|
593
|
+
});
|
|
594
|
+
}
|
|
580
595
|
/**
|
|
581
596
|
* Converts the raw transaction data to bytes.
|
|
582
597
|
*
|
|
@@ -626,4 +641,134 @@ export class Transaction {
|
|
|
626
641
|
hasher.update(numToBytes(raw.length, 8));
|
|
627
642
|
hasher.update(raw);
|
|
628
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Computes the signing hash information for a given script.
|
|
646
|
+
*
|
|
647
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
648
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
649
|
+
* @returns A promise that resolves to an object containing the signing message and the witness position,
|
|
650
|
+
* or undefined if no matching input is found.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```typescript
|
|
654
|
+
* const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
|
|
655
|
+
* if (signHashInfo) {
|
|
656
|
+
* console.log(signHashInfo.message); // Outputs the signing message
|
|
657
|
+
* console.log(signHashInfo.position); // Outputs the witness position
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
async getSignHashInfo(scriptLike, client) {
|
|
662
|
+
const script = Script.from(scriptLike);
|
|
663
|
+
let position = -1;
|
|
664
|
+
const hasher = new Hasher();
|
|
665
|
+
hasher.update(this.hash());
|
|
666
|
+
for (let i = 0; i < this.witnesses.length; i += 1) {
|
|
667
|
+
if (this.inputs[i]) {
|
|
668
|
+
const input = await this.inputs[i].completeExtraInfos(client);
|
|
669
|
+
if (!input.cellOutput) {
|
|
670
|
+
throw Error("Unable to resolve inputs info");
|
|
671
|
+
}
|
|
672
|
+
if (!script.eq(input.cellOutput.lock)) {
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
if (position === -1) {
|
|
676
|
+
position = i;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (position === -1) {
|
|
680
|
+
return undefined;
|
|
681
|
+
}
|
|
682
|
+
Transaction.hashWitnessToHasher(this.witnesses[i], hasher);
|
|
683
|
+
}
|
|
684
|
+
if (position === -1) {
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
687
|
+
return {
|
|
688
|
+
message: hasher.digest(),
|
|
689
|
+
position,
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Find the first occurrence of a input with the specified lock
|
|
694
|
+
*
|
|
695
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
696
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
697
|
+
* @returns A promise that resolves to the prepared transaction
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```typescript
|
|
701
|
+
* const index = await tx.findInputIndexByLock(scriptLike, client);
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
async findInputIndexByLock(scriptLike, client) {
|
|
705
|
+
const script = Script.from(scriptLike);
|
|
706
|
+
for (let i = 0; i < this.inputs.length; i += 1) {
|
|
707
|
+
const input = await this.inputs[i].completeExtraInfos(client);
|
|
708
|
+
if (!input.cellOutput) {
|
|
709
|
+
throw Error("Unable to resolve inputs info");
|
|
710
|
+
}
|
|
711
|
+
if (script.eq(input.cellOutput.lock)) {
|
|
712
|
+
return i;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Get witness at index as WitnessArgs
|
|
718
|
+
*
|
|
719
|
+
* @param index - The index of the witness.
|
|
720
|
+
* @returns The witness parsed as WitnessArgs.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const witnessArgs = await tx.getWitnessArgsAt(0);
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
getWitnessArgsAt(index) {
|
|
728
|
+
const rawWitness = this.witnesses[index];
|
|
729
|
+
return (rawWitness ?? "0x") !== "0x"
|
|
730
|
+
? WitnessArgs.fromBytes(rawWitness)
|
|
731
|
+
: undefined;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Set witness at index by WitnessArgs
|
|
735
|
+
*
|
|
736
|
+
* @param index - The index of the witness.
|
|
737
|
+
* @param witness - The WitnessArgs to set.
|
|
738
|
+
* @returns The transaction itself.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* await tx.setWitnessArgsAt(0, witnessArgs);
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
setWitnessArgsAt(index, witness) {
|
|
746
|
+
if (this.witnesses.length < index) {
|
|
747
|
+
this.witnesses.push(...Array.from(new Array(index - this.witnesses.length), () => "0x"));
|
|
748
|
+
}
|
|
749
|
+
this.witnesses[index] = hexFrom(witness.toBytes());
|
|
750
|
+
return this;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Prepare dummy witness for sighash all method
|
|
754
|
+
*
|
|
755
|
+
* @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
|
|
756
|
+
* @param lockLen - The length of dummy lock bytes.
|
|
757
|
+
* @param client - The client for complete extra infos in the transaction.
|
|
758
|
+
* @returns A promise that resolves to the prepared transaction
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```typescript
|
|
762
|
+
* await tx.prepareSighashAllWitness(scriptLike, 85, client);
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
async prepareSighashAllWitness(scriptLike, lockLen, client) {
|
|
766
|
+
const position = await this.findInputIndexByLock(scriptLike, client);
|
|
767
|
+
if (position === undefined) {
|
|
768
|
+
return this;
|
|
769
|
+
}
|
|
770
|
+
const witness = this.getWitnessArgsAt(position) ?? WitnessArgs.from({});
|
|
771
|
+
witness.lock = hexFrom(Array.from(new Array(lockLen), () => 0));
|
|
772
|
+
return this.setWitnessArgsAt(position, witness);
|
|
773
|
+
}
|
|
629
774
|
}
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Cell, OutPointLike, Script, TransactionLike } from "../ckb";
|
|
1
|
+
import { Cell, OutPointLike, Script, ScriptLike, TransactionLike } from "../ckb";
|
|
2
2
|
import { Hex, HexLike } from "../hex";
|
|
3
|
-
import {
|
|
3
|
+
import { Num, NumLike } from "../num";
|
|
4
|
+
import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, OutputsValidator } from "./clientTypes";
|
|
4
5
|
export declare enum KnownScript {
|
|
5
6
|
Secp256k1Blake160 = 0,
|
|
6
7
|
Secp256k1Multisig = 1,
|
|
7
8
|
AnyoneCanPay = 2,
|
|
8
9
|
JoyId = 3,
|
|
9
|
-
|
|
10
|
+
COTA = 4,
|
|
11
|
+
OmniLock = 5
|
|
10
12
|
}
|
|
11
13
|
export declare abstract class Client {
|
|
12
14
|
abstract getUrl(): string;
|
|
@@ -15,5 +17,11 @@ export declare abstract class Client {
|
|
|
15
17
|
abstract sendTransaction(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
|
|
16
18
|
abstract getTransaction(txHash: HexLike): Promise<ClientTransactionResponse | null>;
|
|
17
19
|
getCell(outPoint: OutPointLike): Promise<Cell | null>;
|
|
20
|
+
abstract findCellsPaged(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
|
|
21
|
+
findCells(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
|
|
22
|
+
findCellsByLockAndType(lock: ScriptLike, type: ScriptLike, withData?: boolean): AsyncGenerator<Cell>;
|
|
23
|
+
abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
|
|
24
|
+
getBalanceSingle(lock: ScriptLike): Promise<Num>;
|
|
25
|
+
getBalance(locks: ScriptLike[]): Promise<Num>;
|
|
18
26
|
}
|
|
19
27
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAA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D"}
|
package/dist/client/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Cell } from "../ckb";
|
|
1
|
+
import { Cell, } from "../ckb";
|
|
2
|
+
import { Zero } from "../fixedPoint";
|
|
2
3
|
import { numFrom } from "../num";
|
|
3
4
|
export var KnownScript;
|
|
4
5
|
(function (KnownScript) {
|
|
@@ -6,7 +7,8 @@ export var KnownScript;
|
|
|
6
7
|
KnownScript[KnownScript["Secp256k1Multisig"] = 1] = "Secp256k1Multisig";
|
|
7
8
|
KnownScript[KnownScript["AnyoneCanPay"] = 2] = "AnyoneCanPay";
|
|
8
9
|
KnownScript[KnownScript["JoyId"] = 3] = "JoyId";
|
|
9
|
-
KnownScript[KnownScript["
|
|
10
|
+
KnownScript[KnownScript["COTA"] = 4] = "COTA";
|
|
11
|
+
KnownScript[KnownScript["OmniLock"] = 5] = "OmniLock";
|
|
10
12
|
})(KnownScript || (KnownScript = {}));
|
|
11
13
|
export class Client {
|
|
12
14
|
async getCell(outPoint) {
|
|
@@ -19,8 +21,48 @@ export class Client {
|
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
21
23
|
return Cell.from({
|
|
24
|
+
outPoint,
|
|
22
25
|
cellOutput: transaction.transaction.outputs[index],
|
|
23
26
|
outputData: transaction.transaction.outputsData[index] ?? "0x",
|
|
27
|
+
blockNumber: transaction.blockNumber,
|
|
24
28
|
});
|
|
25
29
|
}
|
|
30
|
+
async *findCells(key, order, limit = 10) {
|
|
31
|
+
let last = undefined;
|
|
32
|
+
while (true) {
|
|
33
|
+
const { cells, lastCursor } = await this.findCellsPaged(key, order, limit, last);
|
|
34
|
+
for (const cell of cells) {
|
|
35
|
+
yield cell;
|
|
36
|
+
}
|
|
37
|
+
if (cells.length === 0 || cells.length < limit) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
last = lastCursor;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
findCellsByLockAndType(lock, type, withData = true) {
|
|
44
|
+
return this.findCells({
|
|
45
|
+
script: lock,
|
|
46
|
+
scriptType: "lock",
|
|
47
|
+
scriptSearchMode: "exact",
|
|
48
|
+
filter: {
|
|
49
|
+
script: type,
|
|
50
|
+
},
|
|
51
|
+
withData,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async getBalanceSingle(lock) {
|
|
55
|
+
return this.getCellsCapacity({
|
|
56
|
+
script: lock,
|
|
57
|
+
scriptType: "lock",
|
|
58
|
+
scriptSearchMode: "exact",
|
|
59
|
+
filter: {
|
|
60
|
+
scriptLenRange: [0, 1],
|
|
61
|
+
outputDataLenRange: [0, 1],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async getBalance(locks) {
|
|
66
|
+
return locks.reduce((res, lock) => this.getBalanceSingle(lock).then((a) => res.then((b) => a + b)), Promise.resolve(Zero));
|
|
67
|
+
}
|
|
26
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicMainnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAgCtC,CAAC"}
|
|
@@ -16,6 +16,10 @@ export const MAINNET_SCRIPTS = {
|
|
|
16
16
|
codeHash: "0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323",
|
|
17
17
|
hashType: "type",
|
|
18
18
|
},
|
|
19
|
+
[KnownScript.COTA]: {
|
|
20
|
+
codeHash: "0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df",
|
|
21
|
+
hashType: "type",
|
|
22
|
+
},
|
|
19
23
|
[KnownScript.OmniLock]: {
|
|
20
24
|
codeHash: "0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26",
|
|
21
25
|
hashType: "type",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAgCtC,CAAC"}
|
|
@@ -16,6 +16,10 @@ export const TESTNET_SCRIPTS = {
|
|
|
16
16
|
codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
|
|
17
17
|
hashType: "type",
|
|
18
18
|
},
|
|
19
|
+
[KnownScript.COTA]: {
|
|
20
|
+
codeHash: "0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8",
|
|
21
|
+
hashType: "type",
|
|
22
|
+
},
|
|
19
23
|
[KnownScript.OmniLock]: {
|
|
20
24
|
codeHash: "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
|
|
21
25
|
hashType: "type",
|
|
@@ -1,8 +1,55 @@
|
|
|
1
|
-
import { Transaction } from "../ckb";
|
|
1
|
+
import { Cell, Script, ScriptLike, Transaction } from "../ckb";
|
|
2
|
+
import { Hex, HexLike } from "../hex";
|
|
3
|
+
import { Num, NumLike } from "../num";
|
|
2
4
|
export type OutputsValidator = "passthrough" | "well_known_scripts_only";
|
|
3
5
|
export type TransactionStatus = "pending" | "proposed" | "committed" | "unknown" | "rejected";
|
|
4
6
|
export type ClientTransactionResponse = {
|
|
5
7
|
transaction: Transaction;
|
|
6
8
|
status: TransactionStatus;
|
|
9
|
+
blockNumber: Num;
|
|
10
|
+
};
|
|
11
|
+
export type ClientIndexerSearchKeyLike = {
|
|
12
|
+
script: ScriptLike;
|
|
13
|
+
scriptType: "lock" | "type";
|
|
14
|
+
scriptSearchMode?: "prefix" | "exact" | "partial";
|
|
15
|
+
filter?: {
|
|
16
|
+
script?: ScriptLike;
|
|
17
|
+
scriptLenRange?: [NumLike, NumLike];
|
|
18
|
+
outputData?: HexLike;
|
|
19
|
+
outputDataSearchMode?: "prefix" | "exact" | "partial";
|
|
20
|
+
outputDataLenRange?: [NumLike, NumLike];
|
|
21
|
+
outputCapacityRange?: [NumLike, NumLike];
|
|
22
|
+
blockRange?: [NumLike, NumLike];
|
|
23
|
+
};
|
|
24
|
+
withData?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare class ClientIndexerSearchKey {
|
|
27
|
+
script: Script;
|
|
28
|
+
scriptType: "lock" | "type";
|
|
29
|
+
scriptSearchMode: "prefix" | "exact" | "partial" | undefined;
|
|
30
|
+
filter: {
|
|
31
|
+
script?: Script;
|
|
32
|
+
scriptLenRange?: [Num, Num];
|
|
33
|
+
outputData?: Hex;
|
|
34
|
+
outputDataSearchMode?: "prefix" | "exact" | "partial";
|
|
35
|
+
outputDataLenRange?: [Num, Num];
|
|
36
|
+
outputCapacityRange?: [Num, Num];
|
|
37
|
+
blockRange?: [Num, Num];
|
|
38
|
+
} | undefined;
|
|
39
|
+
withData: boolean | undefined;
|
|
40
|
+
constructor(script: Script, scriptType: "lock" | "type", scriptSearchMode: "prefix" | "exact" | "partial" | undefined, filter: {
|
|
41
|
+
script?: Script;
|
|
42
|
+
scriptLenRange?: [Num, Num];
|
|
43
|
+
outputData?: Hex;
|
|
44
|
+
outputDataSearchMode?: "prefix" | "exact" | "partial";
|
|
45
|
+
outputDataLenRange?: [Num, Num];
|
|
46
|
+
outputCapacityRange?: [Num, Num];
|
|
47
|
+
blockRange?: [Num, Num];
|
|
48
|
+
} | undefined, withData: boolean | undefined);
|
|
49
|
+
static from(keyLike: ClientIndexerSearchKeyLike): ClientIndexerSearchKey;
|
|
50
|
+
}
|
|
51
|
+
export type ClientFindCellsResponse = {
|
|
52
|
+
lastCursor: string;
|
|
53
|
+
cells: Cell[];
|
|
7
54
|
};
|
|
8
55
|
//# sourceMappingURL=clientTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientTypes.d.ts","sourceRoot":"","sources":["../../src/client/clientTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"clientTypes.d.ts","sourceRoot":"","sources":["../../src/client/clientTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,OAAO,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
+
function rangeFrom([a, b]) {
|
|
6
|
+
return [numFrom(a), numFrom(b)];
|
|
7
|
+
}
|
|
8
|
+
export class ClientIndexerSearchKey {
|
|
9
|
+
constructor(script, scriptType, scriptSearchMode, filter, withData) {
|
|
10
|
+
this.script = script;
|
|
11
|
+
this.scriptType = scriptType;
|
|
12
|
+
this.scriptSearchMode = scriptSearchMode;
|
|
13
|
+
this.filter = filter;
|
|
14
|
+
this.withData = withData;
|
|
15
|
+
}
|
|
16
|
+
static from(keyLike) {
|
|
17
|
+
return new ClientIndexerSearchKey(Script.from(keyLike.script), keyLike.scriptType, keyLike.scriptSearchMode, apply((filter) => ({
|
|
18
|
+
script: apply(Script.from, filter.script),
|
|
19
|
+
scriptLenRange: apply(rangeFrom, filter.scriptLenRange),
|
|
20
|
+
outputData: apply(hexFrom, filter.outputData),
|
|
21
|
+
outputDataSearchMode: filter.outputDataSearchMode,
|
|
22
|
+
outputDataLenRange: apply(rangeFrom, filter.outputDataLenRange),
|
|
23
|
+
outputCapacityRange: apply(rangeFrom, filter.outputCapacityRange),
|
|
24
|
+
blockRange: apply(rangeFrom, filter.blockRange),
|
|
25
|
+
}), keyLike.filter), keyLike.withData);
|
|
26
|
+
}
|
|
27
|
+
}
|