@ckb-ccc/core 0.0.4-alpha.1 → 0.0.4-alpha.12

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 (114) hide show
  1. package/README.md +12 -7
  2. package/dist/address/address.advanced.d.ts +34 -0
  3. package/dist/address/address.advanced.d.ts.map +1 -1
  4. package/dist/address/address.advanced.js +41 -7
  5. package/dist/address/index.d.ts +36 -0
  6. package/dist/address/index.d.ts.map +1 -1
  7. package/dist/address/index.js +44 -5
  8. package/dist/bytes/advanced.d.ts +3 -0
  9. package/dist/bytes/advanced.d.ts.map +1 -1
  10. package/dist/bytes/index.d.ts +57 -0
  11. package/dist/bytes/index.d.ts.map +1 -1
  12. package/dist/bytes/index.js +57 -0
  13. package/dist/ckb/script.d.ts +98 -1
  14. package/dist/ckb/script.d.ts.map +1 -1
  15. package/dist/ckb/script.js +98 -1
  16. package/dist/ckb/transaction.d.ts +392 -1
  17. package/dist/ckb/transaction.d.ts.map +1 -1
  18. package/dist/ckb/transaction.js +403 -1
  19. package/dist/client/advanced.d.ts +1 -0
  20. package/dist/client/advanced.d.ts.map +1 -1
  21. package/dist/client/advanced.js +1 -0
  22. package/dist/client/client.d.ts +10 -8
  23. package/dist/client/client.d.ts.map +1 -1
  24. package/dist/client/client.js +18 -0
  25. package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
  26. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  27. package/dist/client/clientPublicMainnet.d.ts +3 -3
  28. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  29. package/dist/client/clientPublicMainnet.js +2 -2
  30. package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
  31. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  32. package/dist/client/clientPublicTestnet.d.ts +3 -3
  33. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  34. package/dist/client/clientPublicTestnet.js +2 -2
  35. package/dist/client/clientTypes.d.ts +6 -0
  36. package/dist/client/clientTypes.d.ts.map +1 -1
  37. package/dist/client/index.d.ts +1 -0
  38. package/dist/client/index.d.ts.map +1 -1
  39. package/dist/client/index.js +1 -0
  40. package/dist/client/jsonRpc/advanced.d.ts +2 -87
  41. package/dist/client/jsonRpc/advanced.d.ts.map +1 -1
  42. package/dist/client/jsonRpc/advanced.js +2 -65
  43. package/dist/client/jsonRpc/index.d.ts +60 -6
  44. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  45. package/dist/client/jsonRpc/index.js +72 -7
  46. package/dist/client/jsonRpc/transformers.d.ts +28 -0
  47. package/dist/client/jsonRpc/transformers.d.ts.map +1 -0
  48. package/dist/client/jsonRpc/transformers.js +122 -0
  49. package/dist/client/jsonRpc/types.d.ts +41 -0
  50. package/dist/client/jsonRpc/types.d.ts.map +1 -0
  51. package/dist/client/jsonRpc/types.js +1 -0
  52. package/dist/fixedPoint/index.d.ts +43 -1
  53. package/dist/fixedPoint/index.d.ts.map +1 -1
  54. package/dist/fixedPoint/index.js +39 -1
  55. package/dist/hasher/index.d.ts +43 -2
  56. package/dist/hasher/index.d.ts.map +1 -1
  57. package/dist/hasher/index.js +42 -0
  58. package/dist/hex/index.d.ts +19 -0
  59. package/dist/hex/index.d.ts.map +1 -1
  60. package/dist/hex/index.js +12 -0
  61. package/dist/num/index.d.ts +99 -0
  62. package/dist/num/index.d.ts.map +1 -1
  63. package/dist/num/index.js +92 -0
  64. package/dist/signer/btc/signerBtc.d.ts +40 -2
  65. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  66. package/dist/signer/btc/signerBtc.js +36 -4
  67. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +48 -0
  68. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  69. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +52 -0
  70. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +47 -0
  71. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  72. package/dist/signer/ckb/signerCkbScriptReadonly.js +51 -0
  73. package/dist/signer/evm/signerEvm.d.ts +34 -2
  74. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  75. package/dist/signer/evm/signerEvm.js +35 -4
  76. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +43 -1
  77. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  78. package/dist/signer/evm/signerEvmAddressReadonly.js +46 -0
  79. package/dist/signer/helpers.d.ts +35 -2
  80. package/dist/signer/helpers.d.ts.map +1 -1
  81. package/dist/signer/helpers.js +68 -11
  82. package/dist/signer/signer.d.ts +98 -7
  83. package/dist/signer/signer.d.ts.map +1 -1
  84. package/dist/signer/signer.js +70 -3
  85. package/package.json +3 -3
  86. package/src/address/address.advanced.ts +54 -18
  87. package/src/address/index.ts +51 -7
  88. package/src/bytes/advanced.ts +12 -9
  89. package/src/bytes/index.ts +60 -0
  90. package/src/ckb/script.ts +111 -2
  91. package/src/ckb/transaction.ts +455 -2
  92. package/src/client/advanced.ts +1 -0
  93. package/src/client/client.ts +31 -8
  94. package/src/client/clientPublicMainnet.advanced.ts +5 -2
  95. package/src/client/clientPublicMainnet.ts +6 -4
  96. package/src/client/clientPublicTestnet.advanced.ts +5 -2
  97. package/src/client/clientPublicTestnet.ts +6 -4
  98. package/src/client/clientTypes.ts +13 -0
  99. package/src/client/index.ts +1 -0
  100. package/src/client/jsonRpc/advanced.ts +2 -93
  101. package/src/client/jsonRpc/index.ts +99 -11
  102. package/src/client/jsonRpc/transformers.ts +161 -0
  103. package/src/client/jsonRpc/types.ts +48 -0
  104. package/src/fixedPoint/index.ts +52 -2
  105. package/src/hasher/index.ts +47 -1
  106. package/src/hex/index.ts +19 -0
  107. package/src/num/index.ts +101 -0
  108. package/src/signer/btc/signerBtc.ts +47 -4
  109. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +54 -0
  110. package/src/signer/ckb/signerCkbScriptReadonly.ts +54 -0
  111. package/src/signer/evm/signerEvm.ts +42 -4
  112. package/src/signer/evm/signerEvmAddressReadonly.ts +50 -1
  113. package/src/signer/helpers.ts +89 -11
  114. package/src/signer/signer.ts +109 -7
@@ -1 +1 @@
1
- {"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,CAAC,EAAE,MAAM;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;CAG7E"}
1
+ {"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAI3D,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
@@ -1,8 +1,8 @@
1
1
  import { MAINNET_SCRIPTS } from "./clientPublicMainnet.advanced";
2
2
  import { ClientJsonRpc } from "./jsonRpc";
3
3
  export class ClientPublicMainnet extends ClientJsonRpc {
4
- constructor(timeout) {
5
- super("https://mainnet.ckbapp.dev/", timeout);
4
+ constructor(url = "https://mainnet.ckbapp.dev/", timeout) {
5
+ super(url, timeout);
6
6
  }
7
7
  async getAddressPrefix() {
8
8
  return "ckb";
@@ -1,4 +1,4 @@
1
- import { ScriptLike } from "../ckb";
1
+ import { Script } from "../ckb";
2
2
  import { KnownScript } from "./client";
3
- export declare const TESTNET_SCRIPTS: Record<KnownScript, Omit<ScriptLike, "args">>;
3
+ export declare const TESTNET_SCRIPTS: Record<KnownScript, Pick<Script, "codeHash" | "hashType">>;
4
4
  //# sourceMappingURL=clientPublicTestnet.advanced.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CA0BzE,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,CA2BtC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { ScriptLike } from "../ckb";
1
+ import { Script } from "../ckb";
2
2
  import { KnownScript } from "./client";
3
3
  import { ClientJsonRpc } from "./jsonRpc";
4
4
  export declare class ClientPublicTestnet extends ClientJsonRpc {
5
- constructor(timeout?: number);
5
+ constructor(url?: string, timeout?: number);
6
6
  getAddressPrefix(): Promise<string>;
7
- getKnownScript(script: KnownScript): Promise<Omit<ScriptLike, "args">>;
7
+ getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
8
8
  }
9
9
  //# sourceMappingURL=clientPublicTestnet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,CAAC,EAAE,MAAM;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;CAG7E"}
1
+ {"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAI3D,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
@@ -1,8 +1,8 @@
1
1
  import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced";
2
2
  import { ClientJsonRpc } from "./jsonRpc";
3
3
  export class ClientPublicTestnet extends ClientJsonRpc {
4
- constructor(timeout) {
5
- super("https://testnet.ckbapp.dev/", timeout);
4
+ constructor(url = "https://testnet.ckbapp.dev/", timeout) {
5
+ super(url, timeout);
6
6
  }
7
7
  async getAddressPrefix() {
8
8
  return "ckt";
@@ -1,2 +1,8 @@
1
+ import { Transaction } from "../ckb";
1
2
  export type OutputsValidator = "passthrough" | "well_known_scripts_only";
3
+ export type TransactionStatus = "pending" | "proposed" | "committed" | "unknown" | "rejected";
4
+ export type ClientTransactionResponse = {
5
+ transaction: Transaction;
6
+ status: TransactionStatus;
7
+ };
2
8
  //# sourceMappingURL=clientTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientTypes.d.ts","sourceRoot":"","sources":["../../src/client/clientTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,yBAAyB,CAAC"}
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,GAAG,aAAa,GAAG,yBAAyB,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AACf,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC"}
@@ -2,4 +2,5 @@ export * from "./client";
2
2
  export * from "./clientPublicMainnet";
3
3
  export * from "./clientPublicTestnet";
4
4
  export * from "./clientTypes";
5
+ export * from "./jsonRpc";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
@@ -2,3 +2,4 @@ export * from "./client";
2
2
  export * from "./clientPublicMainnet";
3
3
  export * from "./clientPublicTestnet";
4
4
  export * from "./clientTypes";
5
+ export * from "./jsonRpc";
@@ -1,88 +1,3 @@
1
- import { CellDepLike, CellInputLike, CellOutputLike, DepTypeLike, OutPointLike, ScriptLike, TransactionLike } from "../../ckb";
2
- import type { Client } from "../client";
3
- export type JsonRpcPayload = {
4
- id: number;
5
- jsonrpc: "2.0";
6
- method: string;
7
- params: unknown[] | Record<string, unknown>;
8
- };
9
- export type JsonRpcMethod = {
10
- method: keyof Client;
11
- rpcMethod: string;
12
- inTransformers: (((_: any) => unknown) | undefined)[];
13
- outTransformer?: (_: any) => unknown;
14
- };
15
- export declare class JsonRpcTransformers {
16
- static toDepType(depType: DepTypeLike): "code" | "dep_group";
17
- static toScript(script: ScriptLike): {
18
- code_hash: import("../..").BytesLike;
19
- hash_type: import("../../ckb").HashTypeLike;
20
- args: import("../..").BytesLike;
21
- };
22
- static toOutPoint(outPoint: OutPointLike): {
23
- index: `0x${string}`;
24
- tx_hash: import("../..").BytesLike;
25
- };
26
- static toCellInput(cellInput: CellInputLike): {
27
- previous_output: {
28
- index: `0x${string}`;
29
- tx_hash: import("../..").BytesLike;
30
- };
31
- since: `0x${string}`;
32
- };
33
- static toCellOutput(cellOutput: CellOutputLike): {
34
- capacity: `0x${string}`;
35
- lock: {
36
- code_hash: import("../..").BytesLike;
37
- hash_type: import("../../ckb").HashTypeLike;
38
- args: import("../..").BytesLike;
39
- };
40
- type: {
41
- code_hash: import("../..").BytesLike;
42
- hash_type: import("../../ckb").HashTypeLike;
43
- args: import("../..").BytesLike;
44
- } | undefined;
45
- };
46
- static toCellDep(cellDep: CellDepLike): {
47
- out_point: {
48
- index: `0x${string}`;
49
- tx_hash: import("../..").BytesLike;
50
- };
51
- dep_type: string;
52
- };
53
- static toTransaction(tx: TransactionLike): {
54
- version: `0x${string}`;
55
- cell_deps: {
56
- out_point: {
57
- index: `0x${string}`;
58
- tx_hash: import("../..").BytesLike;
59
- };
60
- dep_type: string;
61
- }[];
62
- header_deps: import("../..").BytesLike[];
63
- inputs: {
64
- previous_output: {
65
- index: `0x${string}`;
66
- tx_hash: import("../..").BytesLike;
67
- };
68
- since: `0x${string}`;
69
- }[];
70
- outputs: {
71
- capacity: `0x${string}`;
72
- lock: {
73
- code_hash: import("../..").BytesLike;
74
- hash_type: import("../../ckb").HashTypeLike;
75
- args: import("../..").BytesLike;
76
- };
77
- type: {
78
- code_hash: import("../..").BytesLike;
79
- hash_type: import("../../ckb").HashTypeLike;
80
- args: import("../..").BytesLike;
81
- } | undefined;
82
- }[];
83
- outputs_data: import("../..").BytesLike[];
84
- witnesses: import("../..").BytesLike[];
85
- };
86
- }
87
- export declare const CkbRpcMethods: JsonRpcMethod[];
1
+ export * from "./transformers";
2
+ export * from "./types";
88
3
  //# sourceMappingURL=advanced.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EAEhB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,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,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IAEtD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;CACtC,CAAC;AAEF,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW;IAQrC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU;;;;;IAOlC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY;;;;IAMxC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,aAAa;;;;;;;IAM3C,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,cAAc;;;;;;;;;;;;;IAO9C,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW;;;;;;;IAMrC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWzC;AAED,eAAO,MAAM,aAAa,EAAE,aAAa,EAOxC,CAAC"}
1
+ {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
@@ -1,65 +1,2 @@
1
- import { depTypeFrom, } from "../../ckb";
2
- import { hexFrom } from "../../hex";
3
- import { numToHex } from "../../num";
4
- import { apply } from "../../utils";
5
- export class JsonRpcTransformers {
6
- static toDepType(depType) {
7
- switch (depTypeFrom(depType)) {
8
- case "code":
9
- return "code";
10
- case "depGroup":
11
- return "dep_group";
12
- }
13
- }
14
- static toScript(script) {
15
- return {
16
- code_hash: script.codeHash,
17
- hash_type: script.hashType,
18
- args: script.args,
19
- };
20
- }
21
- static toOutPoint(outPoint) {
22
- return {
23
- index: numToHex(outPoint.index),
24
- tx_hash: outPoint.txHash,
25
- };
26
- }
27
- static toCellInput(cellInput) {
28
- return {
29
- previous_output: JsonRpcTransformers.toOutPoint(cellInput.previousOutput),
30
- since: numToHex(cellInput.since),
31
- };
32
- }
33
- static toCellOutput(cellOutput) {
34
- return {
35
- capacity: numToHex(cellOutput.capacity),
36
- lock: JsonRpcTransformers.toScript(cellOutput.lock),
37
- type: apply(JsonRpcTransformers.toScript, cellOutput.type),
38
- };
39
- }
40
- static toCellDep(cellDep) {
41
- return {
42
- out_point: JsonRpcTransformers.toOutPoint(cellDep.outPoint),
43
- dep_type: JsonRpcTransformers.toDepType(cellDep.depType),
44
- };
45
- }
46
- static toTransaction(tx) {
47
- return {
48
- version: numToHex(tx.version),
49
- cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.toCellDep(c)),
50
- header_deps: tx.headerDeps,
51
- inputs: tx.inputs.map((i) => JsonRpcTransformers.toCellInput(i)),
52
- outputs: tx.outputs.map((o) => JsonRpcTransformers.toCellOutput(o)),
53
- outputs_data: tx.outputsData,
54
- witnesses: tx.witnesses,
55
- };
56
- }
57
- }
58
- export const CkbRpcMethods = [
59
- {
60
- method: "sendTransaction",
61
- rpcMethod: "send_transaction",
62
- inTransformers: [JsonRpcTransformers.toTransaction],
63
- outTransformer: hexFrom,
64
- },
65
- ];
1
+ export * from "./transformers";
2
+ export * from "./types";
@@ -1,14 +1,68 @@
1
- import type { Client } from "../client";
2
- import { JsonRpcMethod, JsonRpcPayload } from "./advanced";
3
- export interface ClientJsonRpc extends Pick<Client, "sendTransaction"> {
4
- }
5
- export declare abstract class ClientJsonRpc implements Pick<Client, "sendTransaction"> {
1
+ import { TransactionLike } from "../../ckb";
2
+ import { Hex, HexLike } from "../../hex";
3
+ import { Client } from "../client";
4
+ import { ClientTransactionResponse, OutputsValidator } from "../clientTypes";
5
+ import { JsonRpcPayload } from "./advanced";
6
+ /**
7
+ * An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
8
+ * Provides methods for sending transactions and building JSON-RPC payloads.
9
+ */
10
+ export declare abstract class ClientJsonRpc extends Client {
6
11
  private readonly url;
7
12
  private readonly timeout;
13
+ /**
14
+ * Creates an instance of ClientJsonRpc.
15
+ *
16
+ * @param url - The URL of the JSON-RPC server.
17
+ * @param timeout - The timeout for requests in milliseconds, default is 30000.
18
+ */
8
19
  constructor(url: string, timeout?: number);
20
+ /**
21
+ * Returns the URL of the JSON-RPC server.
22
+ *
23
+ * @returns The URL of the JSON-RPC server.
24
+ */
9
25
  getUrl(): string;
10
- buildSender({ rpcMethod, inTransformers, outTransformer }: JsonRpcMethod): (...req: unknown[]) => Promise<unknown>;
26
+ /**
27
+ * Send a transaction to node.
28
+ *
29
+ * @param transaction - The transaction to send.
30
+ * @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
31
+ * @returns Transaction hash.
32
+ */
33
+ sendTransaction: (transaction: TransactionLike, validator?: OutputsValidator | undefined) => Promise<Hex>;
34
+ /**
35
+ * Get a transaction from node.
36
+ *
37
+ * @param txHash - The hash of the transaction.
38
+ * @returns The transaction with status.
39
+ */
40
+ getTransaction: (txHash: HexLike) => Promise<ClientTransactionResponse>;
41
+ /**
42
+ * Builds a sender function for a JSON-RPC method.
43
+ *
44
+ * @param rpcMethod - The JSON-RPC method.
45
+ * @param inTransformers - An array of input transformers.
46
+ * @param outTransformer - An output transformer function.
47
+ * @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
48
+ */
49
+ buildSender(rpcMethod: string, inTransformers: (((_: any) => unknown) | undefined)[], outTransformer?: (_: any) => unknown): (...req: unknown[]) => Promise<unknown>;
50
+ /**
51
+ * Sends a JSON-RPC request to the server.
52
+ *
53
+ * @param payload - The JSON-RPC payload to send.
54
+ * @returns The result of the JSON-RPC request.
55
+ *
56
+ * @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
57
+ */
11
58
  send(payload: JsonRpcPayload): Promise<unknown>;
59
+ /**
60
+ * Builds a JSON-RPC payload for the given method and parameters.
61
+ *
62
+ * @param method - The JSON-RPC method name.
63
+ * @param req - The parameters for the JSON-RPC method.
64
+ * @returns The JSON-RPC payload.
65
+ */
12
66
  static buildPayload(method: string, req: unknown[]): JsonRpcPayload;
13
67
  }
14
68
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAiB,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1E,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC;CAAG;AAYzE,8BAAsB,aAAc,YAAW,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAE1E,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,GAAG,EAAE,MAAM,EACX,OAAO,SAAQ;IAUlC,MAAM;IAIN,WAAW,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,aAAa,YAChD,OAAO,EAAE;IAU3B,IAAI,CAAC,OAAO,EAAE,cAAc;IA4BlC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
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,EAAE,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;;;;;;;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;IAUjC;;;;;;;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"}
@@ -1,29 +1,87 @@
1
1
  import fetch from "cross-fetch";
2
- import { CkbRpcMethods } from "./advanced";
2
+ import { hexFrom } from "../../hex";
3
+ import { Client } from "../client";
4
+ import { JsonRpcTransformers } from "./advanced";
5
+ /**
6
+ * Applies a transformation function to a value if the transformer is provided.
7
+ *
8
+ * @param value - The value to be transformed.
9
+ * @param transformer - An optional transformation function.
10
+ * @returns The transformed value if a transformer is provided, otherwise the original value.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const result = await transform(5, (x) => x * 2); // Outputs 10
15
+ * const resultWithoutTransformer = await transform(5); // Outputs 5
16
+ * ```
17
+ */
3
18
  async function transform(value, transformer) {
4
19
  if (transformer) {
5
20
  return transformer(value);
6
21
  }
7
22
  return value;
8
23
  }
9
- export class ClientJsonRpc {
24
+ /**
25
+ * An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
26
+ * Provides methods for sending transactions and building JSON-RPC payloads.
27
+ */
28
+ export class ClientJsonRpc extends Client {
29
+ /**
30
+ * Creates an instance of ClientJsonRpc.
31
+ *
32
+ * @param url - The URL of the JSON-RPC server.
33
+ * @param timeout - The timeout for requests in milliseconds, default is 30000.
34
+ */
10
35
  constructor(url, timeout = 30000) {
36
+ super();
11
37
  this.url = url;
12
38
  this.timeout = timeout;
13
- CkbRpcMethods.map((method) => Object.defineProperty(this, method.method, {
14
- value: this.buildSender(method),
15
- enumerable: true,
16
- }));
39
+ /**
40
+ * Send a transaction to node.
41
+ *
42
+ * @param transaction - The transaction to send.
43
+ * @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
44
+ * @returns Transaction hash.
45
+ */
46
+ this.sendTransaction = this.buildSender("send_transaction", [JsonRpcTransformers.transactionFrom], hexFrom);
47
+ /**
48
+ * Get a transaction from node.
49
+ *
50
+ * @param txHash - The hash of the transaction.
51
+ * @returns The transaction with status.
52
+ */
53
+ this.getTransaction = this.buildSender("get_transaction", [hexFrom], JsonRpcTransformers.transactionResponseTo);
17
54
  }
55
+ /**
56
+ * Returns the URL of the JSON-RPC server.
57
+ *
58
+ * @returns The URL of the JSON-RPC server.
59
+ */
18
60
  getUrl() {
19
61
  return this.url;
20
62
  }
21
- buildSender({ rpcMethod, inTransformers, outTransformer }) {
63
+ /**
64
+ * Builds a sender function for a JSON-RPC method.
65
+ *
66
+ * @param rpcMethod - The JSON-RPC method.
67
+ * @param inTransformers - An array of input transformers.
68
+ * @param outTransformer - An output transformer function.
69
+ * @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
70
+ */
71
+ buildSender(rpcMethod, inTransformers, outTransformer) {
22
72
  return async (...req) => {
23
73
  const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req.map((v, i) => transform(v, inTransformers[i]))));
24
74
  return transform(await this.send(payload), outTransformer);
25
75
  };
26
76
  }
77
+ /**
78
+ * Sends a JSON-RPC request to the server.
79
+ *
80
+ * @param payload - The JSON-RPC payload to send.
81
+ * @returns The result of the JSON-RPC request.
82
+ *
83
+ * @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
84
+ */
27
85
  async send(payload) {
28
86
  const aborter = new AbortController();
29
87
  const abortTimer = setTimeout(() => aborter.abort(), this.timeout);
@@ -45,6 +103,13 @@ export class ClientJsonRpc {
45
103
  }
46
104
  return res.result;
47
105
  }
106
+ /**
107
+ * Builds a JSON-RPC payload for the given method and parameters.
108
+ *
109
+ * @param method - The JSON-RPC method name.
110
+ * @param req - The parameters for the JSON-RPC method.
111
+ * @returns The JSON-RPC payload.
112
+ */
48
113
  static buildPayload(method, req) {
49
114
  return {
50
115
  id: Math.round(Math.random() * 10000),
@@ -0,0 +1,28 @@
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";
4
+ export declare class JsonRpcTransformers {
5
+ static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
6
+ static hashTypeTo(hashType: JsonRpcHashType): HashType;
7
+ static depTypeFrom(depType: DepTypeLike): JsonRpcDepType;
8
+ static depTypeTo(depType: JsonRpcDepType): DepType;
9
+ static scriptFrom(scriptLike: ScriptLike): JsonRpcScript;
10
+ static scriptTo(script: JsonRpcScript): Script;
11
+ static outPointFrom(outPointLike: OutPointLike): JsonRpcOutPoint;
12
+ static outPointTo(outPoint: JsonRpcOutPoint): OutPoint;
13
+ static cellInputFrom(cellInput: CellInputLike): JsonRpcCellInput;
14
+ static cellInputTo(cellInput: JsonRpcCellInput): CellInput;
15
+ static cellOutputFrom(cellOutput: CellOutputLike): JsonRpcCellOutput;
16
+ static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput;
17
+ static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep;
18
+ static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
19
+ static transactionFrom(txLike: TransactionLike): JsonRpcTransaction;
20
+ static transactionTo(tx: JsonRpcTransaction): Transaction;
21
+ static transactionResponseTo({ tx_status: { status }, transaction, }: {
22
+ tx_status: {
23
+ status: TransactionStatus;
24
+ };
25
+ transaction: JsonRpcTransaction;
26
+ }): ClientTransactionResponse;
27
+ }
28
+ //# sourceMappingURL=transformers.d.ts.map
@@ -0,0 +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,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ;IAMtD,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB;IAQhE,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,gBAAgB,GAAG,SAAS;IAM1D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,GAAG,iBAAiB;IAOpE,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,UAAU;IAO9D,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc;IAMxD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAMlD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB;IAYnE,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,kBAAkB,GAAG,WAAW;IAWzD,MAAM,CAAC,qBAAqB,CAAC,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,EACrB,WAAW,GACZ,EAAE;QACD,SAAS,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAA;SAAE,CAAC;QACzC,WAAW,EAAE,kBAAkB,CAAC;KACjC,GAAG,yBAAyB;CAM9B"}
@@ -0,0 +1,122 @@
1
+ import { CellDep, CellInput, CellOutput, OutPoint, Script, Transaction, depTypeFrom, hashTypeFrom, } from "../../ckb";
2
+ import { numToHex } from "../../num";
3
+ import { apply } from "../../utils";
4
+ export class JsonRpcTransformers {
5
+ static hashTypeFrom(hashType) {
6
+ return hashTypeFrom(hashType);
7
+ }
8
+ static hashTypeTo(hashType) {
9
+ return hashType;
10
+ }
11
+ static depTypeFrom(depType) {
12
+ switch (depTypeFrom(depType)) {
13
+ case "code":
14
+ return "code";
15
+ case "depGroup":
16
+ return "dep_group";
17
+ }
18
+ }
19
+ static depTypeTo(depType) {
20
+ switch (depType) {
21
+ case "code":
22
+ return "code";
23
+ case "dep_group":
24
+ return "depGroup";
25
+ }
26
+ }
27
+ static scriptFrom(scriptLike) {
28
+ const script = Script.from(scriptLike);
29
+ return {
30
+ code_hash: script.codeHash,
31
+ hash_type: JsonRpcTransformers.hashTypeFrom(script.hashType),
32
+ args: script.args,
33
+ };
34
+ }
35
+ static scriptTo(script) {
36
+ return Script.from({
37
+ codeHash: script.code_hash,
38
+ hashType: JsonRpcTransformers.hashTypeTo(script.hash_type),
39
+ args: script.args,
40
+ });
41
+ }
42
+ static outPointFrom(outPointLike) {
43
+ const outPoint = OutPoint.from(outPointLike);
44
+ return {
45
+ index: numToHex(outPoint.index),
46
+ tx_hash: outPoint.txHash,
47
+ };
48
+ }
49
+ static outPointTo(outPoint) {
50
+ return OutPoint.from({
51
+ index: outPoint.index,
52
+ txHash: outPoint.tx_hash,
53
+ });
54
+ }
55
+ static cellInputFrom(cellInput) {
56
+ return {
57
+ previous_output: JsonRpcTransformers.outPointFrom(cellInput.previousOutput),
58
+ since: numToHex(cellInput.since),
59
+ };
60
+ }
61
+ static cellInputTo(cellInput) {
62
+ return CellInput.from({
63
+ previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),
64
+ since: cellInput.since,
65
+ });
66
+ }
67
+ static cellOutputFrom(cellOutput) {
68
+ return {
69
+ capacity: numToHex(cellOutput.capacity),
70
+ lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
71
+ type: apply(JsonRpcTransformers.scriptFrom, cellOutput.type),
72
+ };
73
+ }
74
+ static cellOutputTo(cellOutput) {
75
+ return CellOutput.from({
76
+ capacity: cellOutput.capacity,
77
+ lock: JsonRpcTransformers.scriptTo(cellOutput.lock),
78
+ type: apply(JsonRpcTransformers.scriptTo, cellOutput.type),
79
+ });
80
+ }
81
+ static cellDepFrom(cellDep) {
82
+ return {
83
+ out_point: JsonRpcTransformers.outPointFrom(cellDep.outPoint),
84
+ dep_type: JsonRpcTransformers.depTypeFrom(cellDep.depType),
85
+ };
86
+ }
87
+ static cellDepTo(cellDep) {
88
+ return CellDep.from({
89
+ outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),
90
+ depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),
91
+ });
92
+ }
93
+ static transactionFrom(txLike) {
94
+ const tx = Transaction.from(txLike);
95
+ return {
96
+ version: numToHex(tx.version),
97
+ cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),
98
+ header_deps: tx.headerDeps,
99
+ inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),
100
+ outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputFrom(o)),
101
+ outputs_data: tx.outputsData,
102
+ witnesses: tx.witnesses,
103
+ };
104
+ }
105
+ static transactionTo(tx) {
106
+ return Transaction.from({
107
+ version: tx.version,
108
+ cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),
109
+ headerDeps: tx.header_deps,
110
+ inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputTo(i)),
111
+ outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputTo(o)),
112
+ outputsData: tx.outputs_data,
113
+ witnesses: tx.witnesses,
114
+ });
115
+ }
116
+ static transactionResponseTo({ tx_status: { status }, transaction, }) {
117
+ return {
118
+ transaction: JsonRpcTransformers.transactionTo(transaction),
119
+ status,
120
+ };
121
+ }
122
+ }
@@ -0,0 +1,41 @@
1
+ import { Hex } from "../../hex";
2
+ export type JsonRpcPayload = {
3
+ id: number;
4
+ jsonrpc: "2.0";
5
+ method: string;
6
+ params: unknown[] | Record<string, unknown>;
7
+ };
8
+ export type JsonRpcHashType = "type" | "data" | "data1" | "data2";
9
+ export type JsonRpcDepType = "dep_group" | "code";
10
+ export type JsonRpcScript = {
11
+ code_hash: Hex;
12
+ hash_type: JsonRpcHashType;
13
+ args: Hex;
14
+ };
15
+ export type JsonRpcOutPoint = {
16
+ index: Hex;
17
+ tx_hash: Hex;
18
+ };
19
+ export type JsonRpcCellInput = {
20
+ previous_output: JsonRpcOutPoint;
21
+ since: Hex;
22
+ };
23
+ export type JsonRpcCellOutput = {
24
+ capacity: Hex;
25
+ lock: JsonRpcScript;
26
+ type?: JsonRpcScript;
27
+ };
28
+ export type JsonRpcCellDep = {
29
+ out_point: JsonRpcOutPoint;
30
+ dep_type: JsonRpcDepType;
31
+ };
32
+ export type JsonRpcTransaction = {
33
+ version: Hex;
34
+ cell_deps: JsonRpcCellDep[];
35
+ header_deps: Hex[];
36
+ inputs: JsonRpcCellInput[];
37
+ outputs: JsonRpcCellOutput[];
38
+ outputs_data: Hex[];
39
+ witnesses: Hex[];
40
+ };
41
+ //# sourceMappingURL=types.d.ts.map