@ckb-ccc/core 0.0.4 → 0.0.5-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.
Files changed (99) hide show
  1. package/README.md +6 -0
  2. package/dist/ckb/transaction.d.ts +85 -2
  3. package/dist/ckb/transaction.d.ts.map +1 -1
  4. package/dist/ckb/transaction.js +152 -7
  5. package/dist/client/client.d.ts +8 -3
  6. package/dist/client/client.d.ts.map +1 -1
  7. package/dist/client/client.js +29 -2
  8. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  9. package/dist/client/clientPublicMainnet.advanced.js +4 -0
  10. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  11. package/dist/client/clientPublicTestnet.advanced.js +4 -0
  12. package/dist/client/clientTypes.d.ts +48 -1
  13. package/dist/client/clientTypes.d.ts.map +1 -1
  14. package/dist/client/clientTypes.js +27 -1
  15. package/dist/client/jsonRpc/index.d.ts +9 -1
  16. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  17. package/dist/client/jsonRpc/index.js +15 -1
  18. package/dist/client/jsonRpc/transformers.d.ts +17 -3
  19. package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
  20. package/dist/client/jsonRpc/transformers.js +37 -3
  21. package/dist/client/jsonRpc/types.d.ts +15 -0
  22. package/dist/client/jsonRpc/types.d.ts.map +1 -1
  23. package/dist/fixedPoint/index.d.ts.map +1 -1
  24. package/dist/fixedPoint/index.js +4 -1
  25. package/dist/fixedPoint/index.test.d.ts +2 -0
  26. package/dist/fixedPoint/index.test.d.ts.map +1 -0
  27. package/dist/fixedPoint/index.test.js +43 -0
  28. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  29. package/dist/signer/btc/signerBtc.js +2 -3
  30. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  31. package/dist/signer/evm/signerEvm.js +2 -3
  32. package/dist/signer/index.d.ts +0 -1
  33. package/dist/signer/index.d.ts.map +1 -1
  34. package/dist/signer/index.js +0 -1
  35. package/dist/signer/signer.d.ts +10 -2
  36. package/dist/signer/signer.d.ts.map +1 -1
  37. package/dist/signer/signer.js +9 -1
  38. package/dist.commonjs/ckb/transaction.d.ts +85 -2
  39. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  40. package/dist.commonjs/ckb/transaction.js +150 -5
  41. package/dist.commonjs/client/client.d.ts +8 -3
  42. package/dist.commonjs/client/client.d.ts.map +1 -1
  43. package/dist.commonjs/client/client.js +28 -1
  44. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  45. package/dist.commonjs/client/clientPublicMainnet.advanced.js +4 -0
  46. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  47. package/dist.commonjs/client/clientPublicTestnet.advanced.js +4 -0
  48. package/dist.commonjs/client/clientTypes.d.ts +48 -1
  49. package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
  50. package/dist.commonjs/client/clientTypes.js +29 -0
  51. package/dist.commonjs/client/jsonRpc/index.d.ts +9 -1
  52. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  53. package/dist.commonjs/client/jsonRpc/index.js +15 -1
  54. package/dist.commonjs/client/jsonRpc/transformers.d.ts +17 -3
  55. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
  56. package/dist.commonjs/client/jsonRpc/transformers.js +35 -1
  57. package/dist.commonjs/client/jsonRpc/types.d.ts +15 -0
  58. package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -1
  59. package/dist.commonjs/fixedPoint/index.d.ts.map +1 -1
  60. package/dist.commonjs/fixedPoint/index.js +4 -1
  61. package/dist.commonjs/fixedPoint/index.test.d.ts +2 -0
  62. package/dist.commonjs/fixedPoint/index.test.d.ts.map +1 -0
  63. package/dist.commonjs/fixedPoint/index.test.js +45 -0
  64. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  65. package/dist.commonjs/signer/btc/signerBtc.js +2 -3
  66. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  67. package/dist.commonjs/signer/evm/signerEvm.js +2 -3
  68. package/dist.commonjs/signer/index.d.ts +0 -1
  69. package/dist.commonjs/signer/index.d.ts.map +1 -1
  70. package/dist.commonjs/signer/index.js +0 -1
  71. package/dist.commonjs/signer/signer.d.ts +10 -2
  72. package/dist.commonjs/signer/signer.d.ts.map +1 -1
  73. package/dist.commonjs/signer/signer.js +9 -1
  74. package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +1 -1
  75. package/jest.config.js +5 -0
  76. package/package.json +6 -2
  77. package/src/ckb/transaction.ts +198 -3
  78. package/src/client/client.ts +64 -3
  79. package/src/client/clientPublicMainnet.advanced.ts +5 -0
  80. package/src/client/clientPublicTestnet.advanced.ts +5 -0
  81. package/src/client/clientTypes.ts +70 -1
  82. package/src/client/jsonRpc/index.ts +38 -2
  83. package/src/client/jsonRpc/transformers.ts +73 -4
  84. package/src/client/jsonRpc/types.ts +16 -0
  85. package/src/fixedPoint/index.test.ts +55 -0
  86. package/src/fixedPoint/index.ts +7 -1
  87. package/src/signer/btc/signerBtc.ts +6 -3
  88. package/src/signer/evm/signerEvm.ts +2 -3
  89. package/src/signer/index.ts +0 -1
  90. package/src/signer/signer.ts +9 -0
  91. package/dist/signer/helpers.d.ts +0 -40
  92. package/dist/signer/helpers.d.ts.map +0 -1
  93. package/dist/signer/helpers.js +0 -91
  94. package/dist.commonjs/signer/helpers.d.ts +0 -40
  95. package/dist.commonjs/signer/helpers.d.ts.map +0 -1
  96. package/dist.commonjs/signer/helpers.js +0 -96
  97. package/src/signer/helpers.ts +0 -124
  98. package/tsconfig.base.json +0 -21
  99. package/tsconfig.commonjs.json +0 -8
@@ -247,12 +247,16 @@ class Cell {
247
247
  /**
248
248
  * Creates an instance of Cell.
249
249
  *
250
+ * @param outPoint - The output point of the cell.
250
251
  * @param cellOutput - The cell output of the cell.
251
252
  * @param outputData - The output data of the cell.
253
+ * @param blockNumber - The block number of the cell.
252
254
  */
253
- constructor(cellOutput, outputData) {
255
+ constructor(outPoint, cellOutput, outputData, blockNumber) {
256
+ this.outPoint = outPoint;
254
257
  this.cellOutput = cellOutput;
255
258
  this.outputData = outputData;
259
+ this.blockNumber = blockNumber;
256
260
  }
257
261
  /**
258
262
  * Creates a Cell instance from a CellLike object.
@@ -264,7 +268,7 @@ class Cell {
264
268
  if (cell instanceof Cell) {
265
269
  return cell;
266
270
  }
267
- return new Cell(CellOutput.from(cell.cellOutput), (0, hex_1.hexFrom)(cell.outputData));
271
+ return new Cell(OutPoint.from(cell.outPoint), CellOutput.from(cell.cellOutput), (0, hex_1.hexFrom)(cell.outputData), (0, num_1.numFrom)(cell.blockNumber));
268
272
  }
269
273
  }
270
274
  exports.Cell = Cell;
@@ -276,12 +280,14 @@ class CellInput {
276
280
  * @param since - The since value of the cell input.
277
281
  * @param cellOutput - The optional cell output associated with the cell input.
278
282
  * @param outputData - The optional output data associated with the cell input.
283
+ * @param blockNumber - The optional block number associated with the cell input.
279
284
  */
280
- constructor(previousOutput, since, cellOutput, outputData) {
285
+ constructor(previousOutput, since, cellOutput, outputData, blockNumber) {
281
286
  this.previousOutput = previousOutput;
282
287
  this.since = since;
283
288
  this.cellOutput = cellOutput;
284
289
  this.outputData = outputData;
290
+ this.blockNumber = blockNumber;
285
291
  }
286
292
  /**
287
293
  * Creates a CellInput instance from a CellInputLike object.
@@ -301,7 +307,7 @@ class CellInput {
301
307
  if (cellInput instanceof CellInput) {
302
308
  return cellInput;
303
309
  }
304
- return new CellInput(OutPoint.from(cellInput.previousOutput), (0, num_1.numFrom)(cellInput.since), (0, utils_1.apply)(CellOutput.from, cellInput.cellOutput), (0, utils_1.apply)(hex_1.hexFrom, cellInput.outputData));
310
+ return new CellInput(OutPoint.from(cellInput.previousOutput), (0, num_1.numFrom)(cellInput.since), (0, utils_1.apply)(CellOutput.from, cellInput.cellOutput), (0, utils_1.apply)(hex_1.hexFrom, cellInput.outputData), (0, utils_1.apply)(num_1.numFrom, cellInput.blockNumber));
305
311
  }
306
312
  /**
307
313
  * Complete extra infos in the input. Like the output of the out point.
@@ -316,13 +322,14 @@ class CellInput {
316
322
  * ```
317
323
  */
318
324
  async completeExtraInfos(client) {
319
- if (this.cellOutput && this.outputData) {
325
+ if (this.cellOutput && this.outputData && this.blockNumber) {
320
326
  return this;
321
327
  }
322
328
  const cell = await client.getCell(this.previousOutput);
323
329
  if (cell) {
324
330
  this.cellOutput = cell.cellOutput;
325
331
  this.outputData = cell.outputData;
332
+ this.blockNumber = cell.blockNumber;
326
333
  }
327
334
  return this;
328
335
  }
@@ -612,6 +619,14 @@ class Transaction {
612
619
  witnesses: skeleton.witnesses.toArray(),
613
620
  });
614
621
  }
622
+ stringify() {
623
+ return JSON.stringify(this, (_, value) => {
624
+ if (typeof value === "bigint") {
625
+ return (0, num_1.numToHex)(value);
626
+ }
627
+ return value;
628
+ });
629
+ }
615
630
  /**
616
631
  * Converts the raw transaction data to bytes.
617
632
  *
@@ -661,5 +676,135 @@ class Transaction {
661
676
  hasher.update((0, num_1.numToBytes)(raw.length, 8));
662
677
  hasher.update(raw);
663
678
  }
679
+ /**
680
+ * Computes the signing hash information for a given script.
681
+ *
682
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
683
+ * @param client - The client for complete extra infos in the transaction.
684
+ * @returns A promise that resolves to an object containing the signing message and the witness position,
685
+ * or undefined if no matching input is found.
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
690
+ * if (signHashInfo) {
691
+ * console.log(signHashInfo.message); // Outputs the signing message
692
+ * console.log(signHashInfo.position); // Outputs the witness position
693
+ * }
694
+ * ```
695
+ */
696
+ async getSignHashInfo(scriptLike, client) {
697
+ const script = script_1.Script.from(scriptLike);
698
+ let position = -1;
699
+ const hasher = new hasher_1.Hasher();
700
+ hasher.update(this.hash());
701
+ for (let i = 0; i < this.witnesses.length; i += 1) {
702
+ if (this.inputs[i]) {
703
+ const input = await this.inputs[i].completeExtraInfos(client);
704
+ if (!input.cellOutput) {
705
+ throw Error("Unable to resolve inputs info");
706
+ }
707
+ if (!script.eq(input.cellOutput.lock)) {
708
+ continue;
709
+ }
710
+ if (position === -1) {
711
+ position = i;
712
+ }
713
+ }
714
+ if (position === -1) {
715
+ return undefined;
716
+ }
717
+ Transaction.hashWitnessToHasher(this.witnesses[i], hasher);
718
+ }
719
+ if (position === -1) {
720
+ return undefined;
721
+ }
722
+ return {
723
+ message: hasher.digest(),
724
+ position,
725
+ };
726
+ }
727
+ /**
728
+ * Find the first occurrence of a input with the specified lock
729
+ *
730
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
731
+ * @param client - The client for complete extra infos in the transaction.
732
+ * @returns A promise that resolves to the prepared transaction
733
+ *
734
+ * @example
735
+ * ```typescript
736
+ * const index = await tx.findInputIndexByLock(scriptLike, client);
737
+ * ```
738
+ */
739
+ async findInputIndexByLock(scriptLike, client) {
740
+ const script = script_1.Script.from(scriptLike);
741
+ for (let i = 0; i < this.inputs.length; i += 1) {
742
+ const input = await this.inputs[i].completeExtraInfos(client);
743
+ if (!input.cellOutput) {
744
+ throw Error("Unable to resolve inputs info");
745
+ }
746
+ if (script.eq(input.cellOutput.lock)) {
747
+ return i;
748
+ }
749
+ }
750
+ }
751
+ /**
752
+ * Get witness at index as WitnessArgs
753
+ *
754
+ * @param index - The index of the witness.
755
+ * @returns The witness parsed as WitnessArgs.
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * const witnessArgs = await tx.getWitnessArgsAt(0);
760
+ * ```
761
+ */
762
+ getWitnessArgsAt(index) {
763
+ const rawWitness = this.witnesses[index];
764
+ return (rawWitness ?? "0x") !== "0x"
765
+ ? WitnessArgs.fromBytes(rawWitness)
766
+ : undefined;
767
+ }
768
+ /**
769
+ * Set witness at index by WitnessArgs
770
+ *
771
+ * @param index - The index of the witness.
772
+ * @param witness - The WitnessArgs to set.
773
+ * @returns The transaction itself.
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * await tx.setWitnessArgsAt(0, witnessArgs);
778
+ * ```
779
+ */
780
+ setWitnessArgsAt(index, witness) {
781
+ if (this.witnesses.length < index) {
782
+ this.witnesses.push(...Array.from(new Array(index - this.witnesses.length), () => "0x"));
783
+ }
784
+ this.witnesses[index] = (0, hex_1.hexFrom)(witness.toBytes());
785
+ return this;
786
+ }
787
+ /**
788
+ * Prepare dummy witness for sighash all method
789
+ *
790
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
791
+ * @param lockLen - The length of dummy lock bytes.
792
+ * @param client - The client for complete extra infos in the transaction.
793
+ * @returns A promise that resolves to the prepared transaction
794
+ *
795
+ * @example
796
+ * ```typescript
797
+ * await tx.prepareSighashAllWitness(scriptLike, 85, client);
798
+ * ```
799
+ */
800
+ async prepareSighashAllWitness(scriptLike, lockLen, client) {
801
+ const position = await this.findInputIndexByLock(scriptLike, client);
802
+ if (position === undefined) {
803
+ return this;
804
+ }
805
+ const witness = this.getWitnessArgsAt(position) ?? WitnessArgs.from({});
806
+ witness.lock = (0, hex_1.hexFrom)(Array.from(new Array(lockLen), () => 0));
807
+ return this.setWitnessArgsAt(position, witness);
808
+ }
664
809
  }
665
810
  exports.Transaction = Transaction;
@@ -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 { ClientTransactionResponse, OutputsValidator } from "./clientTypes";
3
+ import { 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
- OmniLock = 4
10
+ COTA = 4,
11
+ OmniLock = 5
10
12
  }
11
13
  export declare abstract class Client {
12
14
  abstract getUrl(): string;
@@ -15,5 +17,8 @@ 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>;
18
23
  }
19
24
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE5E,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,CAAC,MAAM,IAAI,MAAM;IAEzB,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAC5C,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GA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D,QAAQ,CAAC,cAAc,CACrB,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,CAAC,EAAE,OAAO,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC;IAE5B,SAAS,CACd,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,SAAK,GACT,cAAc,CAAC,IAAI,CAAC;IAoBvB,sBAAsB,CACpB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,QAAQ,UAAO,GACd,cAAc,CAAC,IAAI,CAAC;CAWxB"}
@@ -9,7 +9,8 @@ var KnownScript;
9
9
  KnownScript[KnownScript["Secp256k1Multisig"] = 1] = "Secp256k1Multisig";
10
10
  KnownScript[KnownScript["AnyoneCanPay"] = 2] = "AnyoneCanPay";
11
11
  KnownScript[KnownScript["JoyId"] = 3] = "JoyId";
12
- KnownScript[KnownScript["OmniLock"] = 4] = "OmniLock";
12
+ KnownScript[KnownScript["COTA"] = 4] = "COTA";
13
+ KnownScript[KnownScript["OmniLock"] = 5] = "OmniLock";
13
14
  })(KnownScript || (exports.KnownScript = KnownScript = {}));
14
15
  class Client {
15
16
  async getCell(outPoint) {
@@ -22,8 +23,34 @@ class Client {
22
23
  return null;
23
24
  }
24
25
  return ckb_1.Cell.from({
26
+ outPoint,
25
27
  cellOutput: transaction.transaction.outputs[index],
26
28
  outputData: transaction.transaction.outputsData[index] ?? "0x",
29
+ blockNumber: transaction.blockNumber,
30
+ });
31
+ }
32
+ async *findCells(key, order, limit = 10) {
33
+ let last = undefined;
34
+ while (true) {
35
+ const { cells, lastCursor } = await this.findCellsPaged(key, order, limit, last);
36
+ for (const cell of cells) {
37
+ yield cell;
38
+ }
39
+ if (cells.length === 0 || cells.length < limit) {
40
+ return;
41
+ }
42
+ last = lastCursor;
43
+ }
44
+ }
45
+ findCellsByLockAndType(lock, type, withData = true) {
46
+ return this.findCells({
47
+ script: lock,
48
+ scriptType: "lock",
49
+ scriptSearchMode: "exact",
50
+ filter: {
51
+ script: type,
52
+ },
53
+ withData,
27
54
  });
28
55
  }
29
56
  }
@@ -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,CA2BtC,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"}
@@ -19,6 +19,10 @@ exports.MAINNET_SCRIPTS = {
19
19
  codeHash: "0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323",
20
20
  hashType: "type",
21
21
  },
22
+ [client_1.KnownScript.COTA]: {
23
+ codeHash: "0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df",
24
+ hashType: "type",
25
+ },
22
26
  [client_1.KnownScript.OmniLock]: {
23
27
  codeHash: "0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26",
24
28
  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,CA2BtC,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"}
@@ -19,6 +19,10 @@ exports.TESTNET_SCRIPTS = {
19
19
  codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
20
20
  hashType: "type",
21
21
  },
22
+ [client_1.KnownScript.COTA]: {
23
+ codeHash: "0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8",
24
+ hashType: "type",
25
+ },
22
26
  [client_1.KnownScript.OmniLock]: {
23
27
  codeHash: "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
24
28
  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;AAErC,MAAM,MAAM,gBAAgB,GA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,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzB,GACD,SAAS,EACN,QAAQ,EAAE,OAAO,GAAG,SAAS;IAGtC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,0BAA0B,GAAG,sBAAsB;CAoBzE;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC"}
@@ -1,2 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientIndexerSearchKey = void 0;
4
+ const ckb_1 = require("../ckb");
5
+ const hex_1 = require("../hex");
6
+ const num_1 = require("../num");
7
+ const utils_1 = require("../utils");
8
+ function rangeFrom([a, b]) {
9
+ return [(0, num_1.numFrom)(a), (0, num_1.numFrom)(b)];
10
+ }
11
+ class ClientIndexerSearchKey {
12
+ constructor(script, scriptType, scriptSearchMode, filter, withData) {
13
+ this.script = script;
14
+ this.scriptType = scriptType;
15
+ this.scriptSearchMode = scriptSearchMode;
16
+ this.filter = filter;
17
+ this.withData = withData;
18
+ }
19
+ static from(keyLike) {
20
+ return new ClientIndexerSearchKey(ckb_1.Script.from(keyLike.script), keyLike.scriptType, keyLike.scriptSearchMode, (0, utils_1.apply)((filter) => ({
21
+ script: (0, utils_1.apply)(ckb_1.Script.from, filter.script),
22
+ scriptLenRange: (0, utils_1.apply)(rangeFrom, filter.scriptLenRange),
23
+ outputData: (0, utils_1.apply)(hex_1.hexFrom, filter.outputData),
24
+ outputDataSearchMode: filter.outputDataSearchMode,
25
+ outputDataLenRange: (0, utils_1.apply)(rangeFrom, filter.outputDataLenRange),
26
+ outputCapacityRange: (0, utils_1.apply)(rangeFrom, filter.outputCapacityRange),
27
+ blockRange: (0, utils_1.apply)(rangeFrom, filter.blockRange),
28
+ }), keyLike.filter), keyLike.withData);
29
+ }
30
+ }
31
+ exports.ClientIndexerSearchKey = ClientIndexerSearchKey;
@@ -1,7 +1,8 @@
1
1
  import { TransactionLike } from "../../ckb";
2
2
  import { Hex, HexLike } from "../../hex";
3
+ import { NumLike } from "../../num";
3
4
  import { Client } from "../client";
4
- import { ClientTransactionResponse, OutputsValidator } from "../clientTypes";
5
+ import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, OutputsValidator } from "../clientTypes";
5
6
  import { JsonRpcPayload } from "./advanced";
6
7
  /**
7
8
  * An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
@@ -38,6 +39,13 @@ export declare abstract class ClientJsonRpc extends Client {
38
39
  * @returns The transaction with status.
39
40
  */
40
41
  getTransaction: (txHash: HexLike) => Promise<ClientTransactionResponse>;
42
+ /**
43
+ * find cells from node.
44
+ *
45
+ * @param txHash - The hash of the transaction.
46
+ * @returns The found cells.
47
+ */
48
+ findCellsPaged: (key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string) => Promise<ClientFindCellsResponse>;
41
49
  /**
42
50
  * Builds a sender function for a JSON-RPC method.
43
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AA0BjE;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;IAS9C,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B;;;;;OAKG;gBAGgB,GAAG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AAE,MAAM,EACX,OAAO,SAAQ;IAKlC;;;;OAIG;IAEH,MAAM;IAIN;;;;;;OAMG;IAEH,eAAe,gBAKA,eAAe,cAChB,gBAAgB,GAAG,SAAS,KACrC,QAAQ,GAAG,CAAC,CAAC;IAElB;;;;;OAKG;IAEH,cAAc,WAIA,OAAO,KAAK,QAAQ,yBAAyB,CAAC,CAAC;IAE7D;;;;;OAKG;IAEH,cAAc,QASP,0BAA0B,UACvB,KAAK,GAAG,MAAM,UACd,OAAO,UACP,MAAM,KACX,QAAQ,uBAAuB,CAAC,CAAC;IAEtC;;;;;;;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,YAEd,OAAO,EAAE;IAkBjC;;;;;;;OAOG;IAEG,IAAI,CAAC,OAAO,EAAE,cAAc;IA4BlC;;;;;;OAMG;IAEH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ClientJsonRpc = void 0;
7
7
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
8
8
  const hex_1 = require("../../hex");
9
+ const num_1 = require("../../num");
9
10
  const client_1 = require("../client");
10
11
  const advanced_1 = require("./advanced");
11
12
  /**
@@ -57,6 +58,17 @@ class ClientJsonRpc extends client_1.Client {
57
58
  * @returns The transaction with status.
58
59
  */
59
60
  this.getTransaction = this.buildSender("get_transaction", [hex_1.hexFrom], advanced_1.JsonRpcTransformers.transactionResponseTo);
61
+ /**
62
+ * find cells from node.
63
+ *
64
+ * @param txHash - The hash of the transaction.
65
+ * @returns The found cells.
66
+ */
67
+ this.findCellsPaged = this.buildSender("get_cells", [
68
+ advanced_1.JsonRpcTransformers.indexerSearchKeyFrom,
69
+ (order) => order ?? "asc",
70
+ (limit) => (0, num_1.numToHex)(limit ?? 10),
71
+ ], advanced_1.JsonRpcTransformers.findCellsResponseTo);
60
72
  }
61
73
  /**
62
74
  * Returns the URL of the JSON-RPC server.
@@ -76,7 +88,9 @@ class ClientJsonRpc extends client_1.Client {
76
88
  */
77
89
  buildSender(rpcMethod, inTransformers, outTransformer) {
78
90
  return async (...req) => {
79
- const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req.map((v, i) => transform(v, inTransformers[i]))));
91
+ const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req
92
+ .concat(Array.from(new Array(Math.max(inTransformers.length - req.length, 0))))
93
+ .map((v, i) => transform(v, inTransformers[i]))));
80
94
  return transform(await this.send(payload), outTransformer);
81
95
  };
82
96
  }
@@ -1,6 +1,8 @@
1
1
  import { CellDep, CellDepLike, CellInput, CellInputLike, CellOutput, CellOutputLike, DepType, DepTypeLike, HashType, HashTypeLike, OutPoint, OutPointLike, Script, ScriptLike, Transaction, TransactionLike } from "../../ckb";
2
- import { ClientTransactionResponse, TransactionStatus } from "../clientTypes";
3
- import { JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types";
2
+ import { Hex } from "../../hex";
3
+ import { NumLike } from "../../num";
4
+ import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, TransactionStatus } from "../clientTypes";
5
+ import { JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerSearchKey, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types";
4
6
  export declare class JsonRpcTransformers {
5
7
  static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
6
8
  static hashTypeTo(hashType: JsonRpcHashType): HashType;
@@ -18,11 +20,23 @@ export declare class JsonRpcTransformers {
18
20
  static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
19
21
  static transactionFrom(txLike: TransactionLike): JsonRpcTransaction;
20
22
  static transactionTo(tx: JsonRpcTransaction): Transaction;
21
- static transactionResponseTo({ tx_status: { status }, transaction, }: {
23
+ static transactionResponseTo({ tx_status: { status, block_number }, transaction, }: {
22
24
  tx_status: {
23
25
  status: TransactionStatus;
26
+ block_number: Hex;
24
27
  };
25
28
  transaction: JsonRpcTransaction;
26
29
  }): ClientTransactionResponse;
30
+ static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex];
31
+ static indexerSearchKeyFrom(keyLike: ClientIndexerSearchKeyLike): JsonRpcIndexerSearchKey;
32
+ static findCellsResponseTo({ last_cursor, objects, }: {
33
+ last_cursor: string;
34
+ objects: {
35
+ block_number: Hex;
36
+ out_point: JsonRpcOutPoint;
37
+ output: JsonRpcCellOutput;
38
+ output_data: Hex;
39
+ }[];
40
+ }): ClientFindCellsResponse;
27
41
  }
28
42
  //# sourceMappingURL=transformers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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,WAAW,CAAC;AAGnB,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAmB;IAC9B,MAAM,CAAC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require("../../num");
6
6
  const utils_1 = require("../../utils");
7
+ const clientTypes_1 = require("../clientTypes");
7
8
  class JsonRpcTransformers {
8
9
  static hashTypeFrom(hashType) {
9
10
  return (0, ckb_1.hashTypeFrom)(hashType);
@@ -116,10 +117,43 @@ class JsonRpcTransformers {
116
117
  witnesses: tx.witnesses,
117
118
  });
118
119
  }
119
- static transactionResponseTo({ tx_status: { status }, transaction, }) {
120
+ static transactionResponseTo({ tx_status: { status, block_number }, transaction, }) {
120
121
  return {
121
122
  transaction: JsonRpcTransformers.transactionTo(transaction),
122
123
  status,
124
+ blockNumber: (0, num_1.numFrom)(block_number),
125
+ };
126
+ }
127
+ static rangeFrom([a, b]) {
128
+ return [(0, num_1.numToHex)(a), (0, num_1.numToHex)(b)];
129
+ }
130
+ static indexerSearchKeyFrom(keyLike) {
131
+ const key = clientTypes_1.ClientIndexerSearchKey.from(keyLike);
132
+ return {
133
+ script: JsonRpcTransformers.scriptFrom(key.script),
134
+ script_type: key.scriptType,
135
+ script_search_mode: key.scriptSearchMode,
136
+ filter: (0, utils_1.apply)((filter) => ({
137
+ script: (0, utils_1.apply)(JsonRpcTransformers.scriptFrom, filter.script),
138
+ script_len_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.scriptLenRange),
139
+ output_data: filter.outputData,
140
+ output_data_filter_mode: filter.outputDataSearchMode,
141
+ output_data_len_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.outputDataLenRange),
142
+ output_capacity_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.outputCapacityRange),
143
+ block_range: (0, utils_1.apply)(JsonRpcTransformers.rangeFrom, filter.blockRange),
144
+ }), key.filter),
145
+ with_data: key.withData,
146
+ };
147
+ }
148
+ static findCellsResponseTo({ last_cursor, objects, }) {
149
+ return {
150
+ lastCursor: last_cursor,
151
+ cells: objects.map((cell) => ckb_1.Cell.from({
152
+ blockNumber: cell.block_number,
153
+ outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
154
+ cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
155
+ outputData: cell.output_data,
156
+ })),
123
157
  };
124
158
  }
125
159
  }
@@ -38,4 +38,19 @@ export type JsonRpcTransaction = {
38
38
  outputs_data: Hex[];
39
39
  witnesses: Hex[];
40
40
  };
41
+ export type JsonRpcIndexerSearchKey = {
42
+ script: JsonRpcScript;
43
+ script_type: "lock" | "type";
44
+ script_search_mode?: "prefix" | "exact" | "partial";
45
+ filter?: {
46
+ script?: JsonRpcScript;
47
+ script_len_range?: [Hex, Hex];
48
+ output_data?: Hex;
49
+ output_data_filter_mode?: "prefix" | "exact" | "partial";
50
+ output_data_len_range?: [Hex, Hex];
51
+ output_capacity_range?: [Hex, Hex];
52
+ block_range?: [Hex, Hex];
53
+ };
54
+ with_data?: boolean;
55
+ };
41
56
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,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,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AG,EAAE,GAAG,CAAC,CAAC;QACnC,qBAAqB,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixedPoint/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,SAAI,GAAG,MAAM,CAS5E;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,SAAI,GAAG,UAAU,CAY5E;AAED;;GAEG;AAEH,eAAO,MAAM,IAAI,KAAK,CAAC;AAEvB;;;GAGG;AAEH,eAAO,MAAM,GAAG,QAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixedPoint/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,SAAI,GAAG,MAAM,CAa5E;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,SAAI,GAAG,UAAU,CAc5E;AAED;;GAEG;AAEH,eAAO,MAAM,IAAI,KAAK,CAAC;AAEvB;;;GAGG;AAEH,eAAO,MAAM,GAAG,QAAsB,CAAC"}