@ckb-ccc/core 0.0.4-alpha.8 → 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 (209) 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/btc/signerBtcPublicKeyReadonly.d.ts +12 -0
  31. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  32. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +16 -0
  33. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +12 -0
  34. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  35. package/dist/signer/ckb/signerCkbScriptReadonly.js +16 -0
  36. package/dist/signer/evm/signerEvm.d.ts +5 -1
  37. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  38. package/dist/signer/evm/signerEvm.js +21 -8
  39. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +13 -1
  40. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  41. package/dist/signer/evm/signerEvmAddressReadonly.js +16 -0
  42. package/dist/signer/index.d.ts +0 -1
  43. package/dist/signer/index.d.ts.map +1 -1
  44. package/dist/signer/index.js +0 -1
  45. package/dist/signer/signer.d.ts +26 -6
  46. package/dist/signer/signer.d.ts.map +1 -1
  47. package/dist/signer/signer.js +14 -3
  48. package/dist.commonjs/address/address.advanced.d.ts +65 -0
  49. package/dist.commonjs/address/address.advanced.d.ts.map +1 -0
  50. package/dist.commonjs/address/address.advanced.js +149 -0
  51. package/dist.commonjs/address/advanced.d.ts +2 -0
  52. package/dist.commonjs/address/advanced.d.ts.map +1 -0
  53. package/dist.commonjs/address/advanced.js +17 -0
  54. package/dist.commonjs/address/index.d.ts +54 -0
  55. package/dist.commonjs/address/index.d.ts.map +1 -0
  56. package/dist.commonjs/address/index.js +84 -0
  57. package/dist.commonjs/advanced.d.ts +3 -0
  58. package/dist.commonjs/advanced.d.ts.map +1 -0
  59. package/dist.commonjs/advanced.js +31 -0
  60. package/dist.commonjs/advancedBarrel.d.ts +5 -0
  61. package/dist.commonjs/advancedBarrel.d.ts.map +1 -0
  62. package/dist.commonjs/advancedBarrel.js +20 -0
  63. package/dist.commonjs/barrel.d.ts +11 -0
  64. package/dist.commonjs/barrel.d.ts.map +1 -0
  65. package/dist.commonjs/barrel.js +26 -0
  66. package/dist.commonjs/bytes/advanced.d.ts +5 -0
  67. package/dist.commonjs/bytes/advanced.d.ts.map +1 -0
  68. package/dist.commonjs/bytes/advanced.js +2 -0
  69. package/dist.commonjs/bytes/index.d.ts +64 -0
  70. package/dist.commonjs/bytes/index.d.ts.map +1 -0
  71. package/dist.commonjs/bytes/index.js +97 -0
  72. package/dist.commonjs/ckb/advanced.d.ts +4 -0
  73. package/dist.commonjs/ckb/advanced.d.ts.map +1 -0
  74. package/dist.commonjs/ckb/advanced.js +32 -0
  75. package/dist.commonjs/ckb/index.d.ts +3 -0
  76. package/dist.commonjs/ckb/index.d.ts.map +1 -0
  77. package/dist.commonjs/ckb/index.js +18 -0
  78. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +355 -0
  79. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts.map +1 -0
  80. package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -0
  81. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +6 -0
  82. package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +1 -0
  83. package/dist.commonjs/ckb/molecule.advanced/index.js +25 -0
  84. package/dist.commonjs/ckb/script.advanced.d.ts +5 -0
  85. package/dist.commonjs/ckb/script.advanced.d.ts.map +1 -0
  86. package/dist.commonjs/ckb/script.advanced.js +16 -0
  87. package/dist.commonjs/ckb/script.d.ts +126 -0
  88. package/dist.commonjs/ckb/script.d.ts.map +1 -0
  89. package/dist.commonjs/ckb/script.js +188 -0
  90. package/dist.commonjs/ckb/transaction.advanced.d.ts +5 -0
  91. package/dist.commonjs/ckb/transaction.advanced.d.ts.map +1 -0
  92. package/dist.commonjs/ckb/transaction.advanced.js +12 -0
  93. package/dist.commonjs/ckb/transaction.d.ts +616 -0
  94. package/dist.commonjs/ckb/transaction.d.ts.map +1 -0
  95. package/dist.commonjs/ckb/transaction.js +810 -0
  96. package/dist.commonjs/client/advanced.d.ts +4 -0
  97. package/dist.commonjs/client/advanced.d.ts.map +1 -0
  98. package/dist.commonjs/client/advanced.js +19 -0
  99. package/dist.commonjs/client/client.d.ts +24 -0
  100. package/dist.commonjs/client/client.d.ts.map +1 -0
  101. package/dist.commonjs/client/client.js +57 -0
  102. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -0
  103. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -0
  104. package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -0
  105. package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -0
  106. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -0
  107. package/dist.commonjs/client/clientPublicMainnet.js +17 -0
  108. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +4 -0
  109. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -0
  110. package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -0
  111. package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -0
  112. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -0
  113. package/dist.commonjs/client/clientPublicTestnet.js +17 -0
  114. package/dist.commonjs/client/clientTypes.d.ts +55 -0
  115. package/dist.commonjs/client/clientTypes.d.ts.map +1 -0
  116. package/dist.commonjs/client/clientTypes.js +31 -0
  117. package/dist.commonjs/client/index.d.ts +6 -0
  118. package/dist.commonjs/client/index.d.ts.map +1 -0
  119. package/dist.commonjs/client/index.js +21 -0
  120. package/dist.commonjs/client/jsonRpc/advanced.d.ts +3 -0
  121. package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +1 -0
  122. package/dist.commonjs/client/jsonRpc/advanced.js +18 -0
  123. package/dist.commonjs/client/jsonRpc/index.d.ts +76 -0
  124. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -0
  125. package/dist.commonjs/client/jsonRpc/index.js +142 -0
  126. package/dist.commonjs/client/jsonRpc/transformers.d.ts +42 -0
  127. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -0
  128. package/dist.commonjs/client/jsonRpc/transformers.js +160 -0
  129. package/dist.commonjs/client/jsonRpc/types.d.ts +56 -0
  130. package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -0
  131. package/dist.commonjs/client/jsonRpc/types.js +2 -0
  132. package/dist.commonjs/fixedPoint/index.d.ts +49 -0
  133. package/dist.commonjs/fixedPoint/index.d.ts.map +1 -0
  134. package/dist.commonjs/fixedPoint/index.js +68 -0
  135. package/dist.commonjs/fixedPoint/index.test.d.ts +2 -0
  136. package/dist.commonjs/fixedPoint/index.test.d.ts.map +1 -0
  137. package/dist.commonjs/fixedPoint/index.test.js +45 -0
  138. package/dist.commonjs/hasher/advanced.d.ts +2 -0
  139. package/dist.commonjs/hasher/advanced.d.ts.map +1 -0
  140. package/dist.commonjs/hasher/advanced.js +4 -0
  141. package/dist.commonjs/hasher/index.d.ts +52 -0
  142. package/dist.commonjs/hasher/index.d.ts.map +1 -0
  143. package/dist.commonjs/hasher/index.js +68 -0
  144. package/dist.commonjs/hex/index.d.ts +24 -0
  145. package/dist.commonjs/hex/index.d.ts.map +1 -0
  146. package/dist.commonjs/hex/index.js +20 -0
  147. package/dist.commonjs/index.d.ts +3 -0
  148. package/dist.commonjs/index.d.ts.map +1 -0
  149. package/dist.commonjs/index.js +31 -0
  150. package/dist.commonjs/num/index.d.ts +112 -0
  151. package/dist.commonjs/num/index.d.ts.map +1 -0
  152. package/dist.commonjs/num/index.js +139 -0
  153. package/dist.commonjs/signer/btc/index.d.ts +3 -0
  154. package/dist.commonjs/signer/btc/index.d.ts.map +1 -0
  155. package/dist.commonjs/signer/btc/index.js +18 -0
  156. package/dist.commonjs/signer/btc/signerBtc.d.ts +50 -0
  157. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -0
  158. package/dist.commonjs/signer/btc/signerBtc.js +70 -0
  159. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +60 -0
  160. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -0
  161. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +72 -0
  162. package/dist.commonjs/signer/ckb/index.d.ts +2 -0
  163. package/dist.commonjs/signer/ckb/index.d.ts.map +1 -0
  164. package/dist.commonjs/signer/ckb/index.js +17 -0
  165. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +59 -0
  166. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -0
  167. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +71 -0
  168. package/dist.commonjs/signer/evm/index.d.ts +3 -0
  169. package/dist.commonjs/signer/evm/index.d.ts.map +1 -0
  170. package/dist.commonjs/signer/evm/index.js +18 -0
  171. package/dist.commonjs/signer/evm/signerEvm.d.ts +46 -0
  172. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -0
  173. package/dist.commonjs/signer/evm/signerEvm.js +82 -0
  174. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +52 -0
  175. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -0
  176. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +62 -0
  177. package/dist.commonjs/signer/index.d.ts +5 -0
  178. package/dist.commonjs/signer/index.d.ts.map +1 -0
  179. package/dist.commonjs/signer/index.js +20 -0
  180. package/dist.commonjs/signer/signer.d.ts +133 -0
  181. package/dist.commonjs/signer/signer.d.ts.map +1 -0
  182. package/dist.commonjs/signer/signer.js +117 -0
  183. package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +1 -0
  184. package/dist.commonjs/utils/index.d.ts +7 -0
  185. package/dist.commonjs/utils/index.d.ts.map +1 -0
  186. package/dist.commonjs/utils/index.js +10 -0
  187. package/jest.config.js +5 -0
  188. package/package.json +24 -7
  189. package/src/ckb/transaction.ts +198 -3
  190. package/src/client/client.ts +64 -3
  191. package/src/client/clientPublicMainnet.advanced.ts +5 -0
  192. package/src/client/clientPublicTestnet.advanced.ts +5 -0
  193. package/src/client/clientTypes.ts +70 -1
  194. package/src/client/jsonRpc/index.ts +38 -2
  195. package/src/client/jsonRpc/transformers.ts +73 -4
  196. package/src/client/jsonRpc/types.ts +16 -0
  197. package/src/fixedPoint/index.test.ts +55 -0
  198. package/src/fixedPoint/index.ts +7 -1
  199. package/src/signer/btc/signerBtc.ts +6 -3
  200. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +18 -0
  201. package/src/signer/ckb/signerCkbScriptReadonly.ts +18 -0
  202. package/src/signer/evm/signerEvm.ts +56 -14
  203. package/src/signer/evm/signerEvmAddressReadonly.ts +19 -1
  204. package/src/signer/index.ts +0 -1
  205. package/src/signer/signer.ts +29 -3
  206. package/dist/signer/helpers.d.ts +0 -40
  207. package/dist/signer/helpers.d.ts.map +0 -1
  208. package/dist/signer/helpers.js +0 -90
  209. package/src/signer/helpers.ts +0 -122
@@ -1,5 +1,6 @@
1
1
  import fetch from "cross-fetch";
2
2
  import { hexFrom } from "../../hex";
3
+ import { numToHex } from "../../num";
3
4
  import { Client } from "../client";
4
5
  import { JsonRpcTransformers } from "./advanced";
5
6
  /**
@@ -51,6 +52,17 @@ export class ClientJsonRpc extends Client {
51
52
  * @returns The transaction with status.
52
53
  */
53
54
  this.getTransaction = this.buildSender("get_transaction", [hexFrom], JsonRpcTransformers.transactionResponseTo);
55
+ /**
56
+ * find cells from node.
57
+ *
58
+ * @param txHash - The hash of the transaction.
59
+ * @returns The found cells.
60
+ */
61
+ this.findCellsPaged = this.buildSender("get_cells", [
62
+ JsonRpcTransformers.indexerSearchKeyFrom,
63
+ (order) => order ?? "asc",
64
+ (limit) => numToHex(limit ?? 10),
65
+ ], JsonRpcTransformers.findCellsResponseTo);
54
66
  }
55
67
  /**
56
68
  * Returns the URL of the JSON-RPC server.
@@ -70,7 +82,9 @@ export class ClientJsonRpc extends Client {
70
82
  */
71
83
  buildSender(rpcMethod, inTransformers, outTransformer) {
72
84
  return async (...req) => {
73
- const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req.map((v, i) => transform(v, inTransformers[i]))));
85
+ const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req
86
+ .concat(Array.from(new Array(Math.max(inTransformers.length - req.length, 0))))
87
+ .map((v, i) => transform(v, inTransformers[i]))));
74
88
  return transform(await this.send(payload), outTransformer);
75
89
  };
76
90
  }
@@ -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,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe;IAG5D,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ;IAGtD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc;IAQxD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAQlD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;IAQxD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAO9C,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,eAAe;IAOhE,MAAM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qBAAqB,CAAC,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EACnC,WAAW,GACZ,EAAE;QACD,SAAS,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAC;YAAC,YAAY,EAAE,GAAG,CAAA;SAAE,CAAC;QAC5D,WAAW,EAAE,kBAAkB,CAAC;KACjC,GAAG,yBAAyB;IAO7B,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAGxD,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,0BAA0B,GAClC,uBAAuB;IA8B1B,MAAM,CAAC,mBAAmB,CAAC,EACzB,WAAW,EACX,OAAO,GACR,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACP,YAAY,EAAE,GAAG,CAAC;YAClB,SAAS,EAAE,eAAe,CAAC;YAC3B,MAAM,EAAE,iBAAiB,CAAC;YAC1B,WAAW,EAAE,GAAG,CAAC;SAClB,EAAE,CAAC;KACL,GAAG,uBAAuB;CAa5B"}
@@ -1,6 +1,7 @@
1
- import { CellDep, CellInput, CellOutput, OutPoint, Script, Transaction, depTypeFrom, hashTypeFrom, } from "../../ckb";
2
- import { numToHex } from "../../num";
1
+ import { Cell, CellDep, CellInput, CellOutput, OutPoint, Script, Transaction, depTypeFrom, hashTypeFrom, } from "../../ckb";
2
+ import { numFrom, numToHex } from "../../num";
3
3
  import { apply } from "../../utils";
4
+ import { ClientIndexerSearchKey, } from "../clientTypes";
4
5
  export class JsonRpcTransformers {
5
6
  static hashTypeFrom(hashType) {
6
7
  return hashTypeFrom(hashType);
@@ -113,10 +114,43 @@ export class JsonRpcTransformers {
113
114
  witnesses: tx.witnesses,
114
115
  });
115
116
  }
116
- static transactionResponseTo({ tx_status: { status }, transaction, }) {
117
+ static transactionResponseTo({ tx_status: { status, block_number }, transaction, }) {
117
118
  return {
118
119
  transaction: JsonRpcTransformers.transactionTo(transaction),
119
120
  status,
121
+ blockNumber: numFrom(block_number),
122
+ };
123
+ }
124
+ static rangeFrom([a, b]) {
125
+ return [numToHex(a), numToHex(b)];
126
+ }
127
+ static indexerSearchKeyFrom(keyLike) {
128
+ const key = ClientIndexerSearchKey.from(keyLike);
129
+ return {
130
+ script: JsonRpcTransformers.scriptFrom(key.script),
131
+ script_type: key.scriptType,
132
+ script_search_mode: key.scriptSearchMode,
133
+ filter: apply((filter) => ({
134
+ script: apply(JsonRpcTransformers.scriptFrom, filter.script),
135
+ script_len_range: apply(JsonRpcTransformers.rangeFrom, filter.scriptLenRange),
136
+ output_data: filter.outputData,
137
+ output_data_filter_mode: filter.outputDataSearchMode,
138
+ output_data_len_range: apply(JsonRpcTransformers.rangeFrom, filter.outputDataLenRange),
139
+ output_capacity_range: apply(JsonRpcTransformers.rangeFrom, filter.outputCapacityRange),
140
+ block_range: apply(JsonRpcTransformers.rangeFrom, filter.blockRange),
141
+ }), key.filter),
142
+ with_data: key.withData,
143
+ };
144
+ }
145
+ static findCellsResponseTo({ last_cursor, objects, }) {
146
+ return {
147
+ lastCursor: last_cursor,
148
+ cells: objects.map((cell) => Cell.from({
149
+ blockNumber: cell.block_number,
150
+ outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
151
+ cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
152
+ outputData: cell.output_data,
153
+ })),
120
154
  };
121
155
  }
122
156
  }
@@ -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,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;I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G,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"}
@@ -17,6 +17,9 @@
17
17
  */
18
18
  export function fixedPointToString(val, decimals = 8) {
19
19
  const str = fixedPointFrom(val).toString();
20
+ if (decimals === 0) {
21
+ return str;
22
+ }
20
23
  const l = str.length <= decimals ? "0" : str.slice(0, -decimals);
21
24
  const r = str.slice(-decimals).padStart(decimals, "0").replace(/0*$/, "");
22
25
  if (r === "") {
@@ -42,7 +45,7 @@ export function fixedPointFrom(val, decimals = 8) {
42
45
  if (typeof val === "bigint") {
43
46
  return val;
44
47
  }
45
- const [l, r] = val.toString().split(".");
48
+ const [l, r] = (typeof val === "number" ? val.toFixed(decimals) : val.toString()).split(".");
46
49
  const lVal = BigInt(l.padEnd(l.length + decimals, "0"));
47
50
  if (r === undefined) {
48
51
  return lVal;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/fixedPoint/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ import { fixedPointFrom, fixedPointToString } from ".";
2
+ describe("fixedPointToString", () => {
3
+ const cases = [
4
+ [0n, "0"],
5
+ [1n, "0.00000001"],
6
+ [100000000n, "1"],
7
+ [1000000000n, "10"],
8
+ [1010100000n, "10.101"],
9
+ [11n, "1.1", 1],
10
+ [0n, "0", 1],
11
+ [1n, "1", 0],
12
+ [0n, "0", 0],
13
+ ];
14
+ cases.forEach(([i, o, decimals]) => test(`${i} with ${decimals ?? "default"} decimals = "${o}"`, () => {
15
+ expect(fixedPointToString(i, decimals)).toBe(o);
16
+ }));
17
+ });
18
+ describe("fixedPointFrom string", () => {
19
+ const cases = [
20
+ ["0", 0n],
21
+ ["0.00000001", 1n],
22
+ ["1", 100000000n],
23
+ ["10", 1000000000n],
24
+ ["10.101", 1010100000n],
25
+ ["1.1", 11n, 1],
26
+ ["0", 0n, 1],
27
+ ["1", 1n, 0],
28
+ ["0", 0n, 0],
29
+ ];
30
+ cases.forEach(([i, o, decimals]) => test(`"${i}" = ${o} with ${decimals ?? "default"} decimals `, () => {
31
+ expect(fixedPointFrom(i, decimals)).toBe(o);
32
+ }));
33
+ });
34
+ describe("fixedPointFrom number", () => {
35
+ const cases = [
36
+ [0.00000001, 1n],
37
+ [10.101, 1010100000n],
38
+ [1.1, 11n, 1],
39
+ ];
40
+ cases.forEach(([i, o, decimals]) => test(`${i} = ${o} with ${decimals ?? "default"} decimals `, () => {
41
+ expect(fixedPointFrom(i, decimals)).toBe(o);
42
+ }));
43
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
1
+ {"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
@@ -6,7 +6,6 @@ import { Transaction, WitnessArgs } from "../../ckb";
6
6
  import { KnownScript } from "../../client";
7
7
  import { hexFrom } from "../../hex";
8
8
  import { numToBytes } from "../../num";
9
- import { getSignHashInfo, prepareSighashAllWitness } from "../helpers";
10
9
  import { Signer } from "../signer";
11
10
  /**
12
11
  * An abstract class extending the Signer class for Bitcoin-like signing operations.
@@ -42,7 +41,7 @@ export class SignerBtc extends Signer {
42
41
  */
43
42
  async prepareTransaction(txLike) {
44
43
  const { script } = await this.getRecommendedAddressObj();
45
- return prepareSighashAllWitness(txLike, script, 85, this.client);
44
+ return Transaction.from(txLike).prepareSighashAllWitness(script, 85, this.client);
46
45
  }
47
46
  /**
48
47
  * Signs a transaction without modifying it.
@@ -53,7 +52,7 @@ export class SignerBtc extends Signer {
53
52
  async signOnlyTransaction(txLike) {
54
53
  const tx = Transaction.from(txLike);
55
54
  const { script } = await this.getRecommendedAddressObj();
56
- const info = await getSignHashInfo(tx, script, this.client);
55
+ const info = await tx.getSignHashInfo(script, this.client);
57
56
  if (!info) {
58
57
  return tx;
59
58
  }
@@ -16,12 +16,24 @@ export declare class SignerBtcPublicKeyReadonly extends SignerBtc {
16
16
  * @param publicKey - The public key associated with the signer.
17
17
  */
18
18
  constructor(client: Client, account: string, publicKey: HexLike);
19
+ /**
20
+ * Construct a new signer with the client replaced.
21
+ *
22
+ * @returns A promise that resolves the new Signer.
23
+ */
24
+ replaceClient(client: Client): Promise<SignerBtcPublicKeyReadonly>;
19
25
  /**
20
26
  * Connects to the client. This implementation does nothing as the class is read-only.
21
27
  *
22
28
  * @returns A promise that resolves when the connection is complete.
23
29
  */
24
30
  connect(): Promise<void>;
31
+ /**
32
+ * Check if the signer is connected.
33
+ *
34
+ * @returns A promise that resolves the connection status.
35
+ */
36
+ isConnected(): Promise<boolean>;
25
37
  /**
26
38
  * Gets the Bitcoin account associated with the signer.
27
39
  *
@@ -1 +1 @@
1
- {"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
1
+ {"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIxE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
@@ -17,12 +17,28 @@ export class SignerBtcPublicKeyReadonly extends SignerBtc {
17
17
  this.account = account;
18
18
  this.publicKey = hexFrom(publicKey);
19
19
  }
20
+ /**
21
+ * Construct a new signer with the client replaced.
22
+ *
23
+ * @returns A promise that resolves the new Signer.
24
+ */
25
+ async replaceClient(client) {
26
+ return new SignerBtcPublicKeyReadonly(client, this.account, this.publicKey);
27
+ }
20
28
  /**
21
29
  * Connects to the client. This implementation does nothing as the class is read-only.
22
30
  *
23
31
  * @returns A promise that resolves when the connection is complete.
24
32
  */
25
33
  async connect() { }
34
+ /**
35
+ * Check if the signer is connected.
36
+ *
37
+ * @returns A promise that resolves the connection status.
38
+ */
39
+ async isConnected() {
40
+ return true;
41
+ }
26
42
  /**
27
43
  * Gets the Bitcoin account associated with the signer.
28
44
  *
@@ -15,12 +15,24 @@ export declare class SignerCkbScriptReadonly extends Signer {
15
15
  * @param script - The script associated with the signer.
16
16
  */
17
17
  constructor(client: Client, script: ScriptLike);
18
+ /**
19
+ * Construct a new signer with the client replaced.
20
+ *
21
+ * @returns A promise that resolves the new Signer.
22
+ */
23
+ replaceClient(client: Client): Promise<SignerCkbScriptReadonly>;
18
24
  /**
19
25
  * Connects to the client. This implementation does nothing as the class is read-only.
20
26
  *
21
27
  * @returns A promise that resolves when the connection is complete.
22
28
  */
23
29
  connect(): Promise<void>;
30
+ /**
31
+ * Check if the signer is connected.
32
+ *
33
+ * @returns A promise that resolves the connection status.
34
+ */
35
+ isConnected(): Promise<boolean>;
24
36
  /**
25
37
  * Gets the internal address for the script.
26
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
1
+ {"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIrE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
@@ -16,12 +16,28 @@ export class SignerCkbScriptReadonly extends Signer {
16
16
  super(client);
17
17
  this.script = Script.from(script);
18
18
  }
19
+ /**
20
+ * Construct a new signer with the client replaced.
21
+ *
22
+ * @returns A promise that resolves the new Signer.
23
+ */
24
+ async replaceClient(client) {
25
+ return new SignerCkbScriptReadonly(client, this.script);
26
+ }
19
27
  /**
20
28
  * Connects to the client. This implementation does nothing as the class is read-only.
21
29
  *
22
30
  * @returns A promise that resolves when the connection is complete.
23
31
  */
24
32
  async connect() { }
33
+ /**
34
+ * Check if the signer is connected.
35
+ *
36
+ * @returns A promise that resolves the connection status.
37
+ */
38
+ async isConnected() {
39
+ return true;
40
+ }
25
41
  /**
26
42
  * Gets the internal address for the script.
27
43
  *
@@ -1,5 +1,6 @@
1
1
  import { Address } from "../../address";
2
- import { Transaction, TransactionLike } from "../../ckb";
2
+ import { BytesLike } from "../../bytes";
3
+ import { Script, Transaction, TransactionLike } from "../../ckb";
3
4
  import { Signer } from "../signer";
4
5
  /**
5
6
  * An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
@@ -24,6 +25,8 @@ export declare abstract class SignerEvm extends Signer {
24
25
  * @returns A promise that resolves to an array of Address objects.
25
26
  */
26
27
  getAddressObjs(): Promise<Address[]>;
28
+ _getOmniLockEvmAddressObj(account: string): Promise<Address>;
29
+ _getOmniLockOldEvmAddressObj(account: string): Promise<Address>;
27
30
  /**
28
31
  * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
29
32
  *
@@ -38,5 +41,6 @@ export declare abstract class SignerEvm extends Signer {
38
41
  * @returns A promise that resolves to a signed Transaction object.
39
42
  */
40
43
  signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
44
+ _signOmniLockScriptForTransaction(tx: Transaction, script: Script, messageTransformer: (hash: string) => BytesLike): Promise<Transaction>;
41
45
  }
42
46
  //# sourceMappingURL=signerEvm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAKtE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAW1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
1
+ {"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAQpC,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5D,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAYvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAsBlE,iCAAiC,CACrC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;CA6BxB"}
@@ -4,7 +4,6 @@ import { Transaction, WitnessArgs } from "../../ckb";
4
4
  import { KnownScript } from "../../client";
5
5
  import { hexFrom } from "../../hex";
6
6
  import { numToBytes } from "../../num";
7
- import { getSignHashInfo, prepareSighashAllWitness } from "../helpers";
8
7
  import { Signer } from "../signer";
9
8
  /**
10
9
  * An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
@@ -27,9 +26,16 @@ export class SignerEvm extends Signer {
27
26
  async getAddressObjs() {
28
27
  const account = await this.getEvmAccount();
29
28
  return [
30
- await Address.fromKnownScript(KnownScript.OmniLock, hexFrom([0x12, ...bytesFrom(account), 0x00]), this.client),
29
+ await this._getOmniLockEvmAddressObj(account),
30
+ await this._getOmniLockOldEvmAddressObj(account),
31
31
  ];
32
32
  }
33
+ async _getOmniLockEvmAddressObj(account) {
34
+ return Address.fromKnownScript(KnownScript.OmniLock, hexFrom([0x12, ...bytesFrom(account), 0x00]), this.client);
35
+ }
36
+ async _getOmniLockOldEvmAddressObj(account) {
37
+ return Address.fromKnownScript(KnownScript.OmniLock, hexFrom([0x1, ...bytesFrom(account), 0x00]), this.client);
38
+ }
33
39
  /**
34
40
  * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
35
41
  *
@@ -37,8 +43,8 @@ export class SignerEvm extends Signer {
37
43
  * @returns A promise that resolves to the prepared Transaction object.
38
44
  */
39
45
  async prepareTransaction(txLike) {
40
- const { script } = await this.getRecommendedAddressObj();
41
- return prepareSighashAllWitness(txLike, script, 85, this.client);
46
+ const addresses = await this.getAddressObjs();
47
+ return addresses.reduce((txPromise, { script }) => txPromise.then((tx) => tx.prepareSighashAllWitness(script, 85, this.client)), Promise.resolve(Transaction.from(txLike)));
42
48
  }
43
49
  /**
44
50
  * Signs a transaction without modifying it.
@@ -47,13 +53,20 @@ export class SignerEvm extends Signer {
47
53
  * @returns A promise that resolves to a signed Transaction object.
48
54
  */
49
55
  async signOnlyTransaction(txLike) {
50
- const tx = Transaction.from(txLike);
51
- const { script } = await this.getRecommendedAddressObj();
52
- const info = await getSignHashInfo(tx, script, this.client);
56
+ let tx = Transaction.from(txLike);
57
+ const account = await this.getEvmAccount();
58
+ const { script: evmScript } = await this._getOmniLockEvmAddressObj(account);
59
+ const { script: oldEvmScript } = await this._getOmniLockOldEvmAddressObj(account);
60
+ tx = await this._signOmniLockScriptForTransaction(tx, evmScript, (hash) => `CKB transaction: ${hash}`);
61
+ tx = await this._signOmniLockScriptForTransaction(tx, oldEvmScript, (hash) => bytesFrom(hash));
62
+ return tx;
63
+ }
64
+ async _signOmniLockScriptForTransaction(tx, script, messageTransformer) {
65
+ const info = await tx.getSignHashInfo(script, this.client);
53
66
  if (!info) {
54
67
  return tx;
55
68
  }
56
- const signature = bytesFrom(await this.signMessage(`CKB transaction: ${info.message}`));
69
+ const signature = bytesFrom(await this.signMessage(messageTransformer(info.message)));
57
70
  if (signature[signature.length - 1] >= 27) {
58
71
  signature[signature.length - 1] -= 27;
59
72
  }
@@ -5,7 +5,7 @@ import { SignerEvm } from "./signerEvm";
5
5
  * A class extending SignerEvm that provides read-only access to an EVM address.
6
6
  * This class does not support signing operations.
7
7
  */
8
- export declare abstract class SignerEvmAddressReadonly extends SignerEvm {
8
+ export declare class SignerEvmAddressReadonly extends SignerEvm {
9
9
  private readonly address;
10
10
  /**
11
11
  * Creates an instance of SignerEvmAddressReadonly.
@@ -14,6 +14,12 @@ export declare abstract class SignerEvmAddressReadonly extends SignerEvm {
14
14
  * @param address - The EVM address associated with the signer.
15
15
  */
16
16
  constructor(client: Client, address: HexLike);
17
+ /**
18
+ * Construct a new signer with the client replaced.
19
+ *
20
+ * @returns A promise that resolves the new Signer.
21
+ */
22
+ replaceClient(client: Client): Promise<SignerEvmAddressReadonly>;
17
23
  /**
18
24
  * Connects to the client. This implementation does nothing as the class is read-only.
19
25
  *
@@ -25,6 +31,12 @@ export declare abstract class SignerEvmAddressReadonly extends SignerEvm {
25
31
  * ```
26
32
  */
27
33
  connect(): Promise<void>;
34
+ /**
35
+ * Check if the signer is connected.
36
+ *
37
+ * @returns A promise that resolves the connection status.
38
+ */
39
+ isConnected(): Promise<boolean>;
28
40
  /**
29
41
  * Gets the EVM account associated with the signer.
30
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"signerEvmAddressReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvmAddressReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAO,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,8BAAsB,wBAAyB,SAAQ,SAAS;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAM;IAE9B;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C;;;;;;;;;OASG;IAEG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
1
+ {"version":3,"file":"signerEvmAddressReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvmAddressReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAO,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAM;IAE9B;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAItE;;;;;;;;;OASG;IAEG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
@@ -15,6 +15,14 @@ export class SignerEvmAddressReadonly extends SignerEvm {
15
15
  super(client);
16
16
  this.address = hexFrom(address);
17
17
  }
18
+ /**
19
+ * Construct a new signer with the client replaced.
20
+ *
21
+ * @returns A promise that resolves the new Signer.
22
+ */
23
+ async replaceClient(client) {
24
+ return new SignerEvmAddressReadonly(client, this.address);
25
+ }
18
26
  /**
19
27
  * Connects to the client. This implementation does nothing as the class is read-only.
20
28
  *
@@ -26,6 +34,14 @@ export class SignerEvmAddressReadonly extends SignerEvm {
26
34
  * ```
27
35
  */
28
36
  async connect() { }
37
+ /**
38
+ * Check if the signer is connected.
39
+ *
40
+ * @returns A promise that resolves the connection status.
41
+ */
42
+ async isConnected() {
43
+ return true;
44
+ }
29
45
  /**
30
46
  * Gets the EVM account associated with the signer.
31
47
  *
@@ -1,6 +1,5 @@
1
1
  export * from "./btc";
2
2
  export * from "./ckb";
3
3
  export * from "./evm";
4
- export * from "./helpers";
5
4
  export * from "./signer";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export * from "./btc";
2
2
  export * from "./ckb";
3
3
  export * from "./evm";
4
- export * from "./helpers";
5
4
  export * from "./signer";