@ckb-ccc/core 0.0.2-alpha.2 → 0.0.2

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 (185) hide show
  1. package/.prettierignore +12 -0
  2. package/dist/address/address.advanced.d.ts +29 -3
  3. package/dist/address/address.advanced.d.ts.map +1 -1
  4. package/dist/address/address.advanced.js +70 -28
  5. package/dist/address/advanced.d.ts +1 -28
  6. package/dist/address/advanced.d.ts.map +1 -1
  7. package/dist/address/advanced.js +1 -75
  8. package/dist/address/index.d.ts +10 -13
  9. package/dist/address/index.d.ts.map +1 -1
  10. package/dist/address/index.js +21 -25
  11. package/dist/advanced.js +2 -31
  12. package/dist/advancedBarrel.d.ts +1 -0
  13. package/dist/advancedBarrel.d.ts.map +1 -1
  14. package/dist/advancedBarrel.js +4 -19
  15. package/dist/barrel.d.ts +4 -2
  16. package/dist/barrel.d.ts.map +1 -1
  17. package/dist/barrel.js +10 -24
  18. package/dist/bytes/index.d.ts +7 -0
  19. package/dist/bytes/index.d.ts.map +1 -0
  20. package/dist/bytes/index.js +34 -0
  21. package/dist/ckb/advanced.d.ts +3 -2
  22. package/dist/ckb/advanced.d.ts.map +1 -1
  23. package/dist/ckb/advanced.js +3 -18
  24. package/dist/ckb/index.d.ts +2 -3
  25. package/dist/ckb/index.d.ts.map +1 -1
  26. package/dist/ckb/index.js +2 -19
  27. package/dist/ckb/molecule.advanced/generated.d.ts.map +1 -0
  28. package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +444 -231
  29. package/dist/ckb/molecule.advanced/index.d.ts +6 -0
  30. package/dist/ckb/molecule.advanced/index.d.ts.map +1 -0
  31. package/dist/ckb/molecule.advanced/index.js +7 -0
  32. package/dist/ckb/{types/script.advanced.d.ts → script.advanced.d.ts} +1 -0
  33. package/dist/ckb/script.advanced.d.ts.map +1 -0
  34. package/dist/ckb/script.advanced.js +13 -0
  35. package/dist/ckb/script.d.ts +29 -0
  36. package/dist/ckb/script.d.ts.map +1 -0
  37. package/dist/ckb/script.js +61 -0
  38. package/dist/ckb/{types/transaction.advanced.d.ts → transaction.advanced.d.ts} +1 -0
  39. package/dist/ckb/transaction.advanced.d.ts.map +1 -0
  40. package/dist/ckb/transaction.advanced.js +9 -0
  41. package/dist/ckb/transaction.d.ts +142 -0
  42. package/dist/ckb/transaction.d.ts.map +1 -0
  43. package/dist/ckb/transaction.js +227 -0
  44. package/dist/client/advanced.js +2 -18
  45. package/dist/client/client.d.ts +5 -4
  46. package/dist/client/client.d.ts.map +1 -1
  47. package/dist/client/client.js +2 -5
  48. package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
  49. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  50. package/dist/client/clientPublicMainnet.advanced.js +7 -10
  51. package/dist/client/clientPublicMainnet.d.ts +2 -2
  52. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  53. package/dist/client/clientPublicMainnet.js +4 -8
  54. package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
  55. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  56. package/dist/client/clientPublicTestnet.advanced.js +7 -10
  57. package/dist/client/clientPublicTestnet.d.ts +2 -2
  58. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  59. package/dist/client/clientPublicTestnet.js +4 -8
  60. package/dist/client/clientTypes.js +1 -2
  61. package/dist/client/index.js +4 -20
  62. package/dist/client/jsonRpc/advanced.d.ts +36 -36
  63. package/dist/client/jsonRpc/advanced.d.ts.map +1 -1
  64. package/dist/client/jsonRpc/advanced.js +13 -17
  65. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  66. package/dist/client/jsonRpc/index.js +5 -13
  67. package/dist/fixedPoint/index.d.ts +7 -0
  68. package/dist/fixedPoint/index.d.ts.map +1 -0
  69. package/dist/fixedPoint/index.js +22 -0
  70. package/dist/{ckb/hasher.advanced.d.ts → hasher/advanced.d.ts} +1 -1
  71. package/dist/hasher/advanced.d.ts.map +1 -0
  72. package/dist/{ckb/hasher.d.ts → hasher/index.d.ts} +3 -2
  73. package/dist/hasher/index.d.ts.map +1 -0
  74. package/dist/hasher/index.js +18 -0
  75. package/dist/hex/index.d.ts +5 -0
  76. package/dist/hex/index.d.ts.map +1 -0
  77. package/dist/hex/index.js +5 -0
  78. package/dist/index.js +2 -31
  79. package/dist/num/index.d.ts +13 -0
  80. package/dist/num/index.d.ts.map +1 -0
  81. package/dist/num/index.js +36 -0
  82. package/dist/signer/helpers.d.ts +3 -3
  83. package/dist/signer/helpers.d.ts.map +1 -1
  84. package/dist/signer/helpers.js +9 -10
  85. package/dist/signer/index.d.ts +2 -0
  86. package/dist/signer/index.d.ts.map +1 -1
  87. package/dist/signer/index.js +4 -18
  88. package/dist/signer/signer.d.ts +12 -3
  89. package/dist/signer/signer.d.ts.map +1 -1
  90. package/dist/signer/signer.js +13 -6
  91. package/dist/signer/signerReadonly.d.ts +8 -0
  92. package/dist/signer/signerReadonly.d.ts.map +1 -0
  93. package/dist/signer/signerReadonly.js +9 -0
  94. package/dist/{ckb/viewerCkbScript.d.ts → signer/signerReadonlyCkbScript.d.ts} +6 -5
  95. package/dist/signer/signerReadonlyCkbScript.d.ts.map +1 -0
  96. package/dist/signer/signerReadonlyCkbScript.js +17 -0
  97. package/dist/utils/index.d.ts +7 -0
  98. package/dist/utils/index.d.ts.map +1 -0
  99. package/dist/utils/index.js +6 -0
  100. package/package.json +5 -3
  101. package/src/address/address.advanced.ts +76 -19
  102. package/src/address/advanced.ts +1 -59
  103. package/src/address/index.ts +46 -28
  104. package/src/advancedBarrel.ts +1 -0
  105. package/src/barrel.ts +4 -2
  106. package/src/bytes/index.ts +46 -0
  107. package/src/ckb/advanced.ts +3 -2
  108. package/src/ckb/index.ts +2 -3
  109. package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +18 -7
  110. package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +551 -123
  111. package/src/ckb/molecule.advanced/index.ts +11 -0
  112. package/src/ckb/{types/script.advanced.ts → script.advanced.ts} +1 -0
  113. package/src/ckb/script.ts +94 -0
  114. package/src/ckb/{types/transaction.advanced.ts → transaction.advanced.ts} +1 -0
  115. package/src/ckb/transaction.ts +357 -0
  116. package/src/client/client.ts +6 -4
  117. package/src/client/clientPublicMainnet.advanced.ts +2 -2
  118. package/src/client/clientPublicMainnet.ts +2 -2
  119. package/src/client/clientPublicTestnet.advanced.ts +2 -2
  120. package/src/client/clientPublicTestnet.ts +2 -2
  121. package/src/client/clientTypes.ts +1 -1
  122. package/src/client/jsonRpc/advanced.ts +25 -25
  123. package/src/client/jsonRpc/index.ts +1 -3
  124. package/src/fixedPoint/index.ts +30 -0
  125. package/src/hasher/advanced.ts +1 -0
  126. package/src/{ckb/hasher.ts → hasher/index.ts} +5 -5
  127. package/src/hex/index.ts +9 -0
  128. package/src/index.ts +1 -1
  129. package/src/num/index.ts +53 -0
  130. package/src/signer/helpers.ts +9 -6
  131. package/src/signer/index.ts +3 -1
  132. package/src/signer/signer.ts +23 -3
  133. package/src/signer/signerReadonly.ts +13 -0
  134. package/src/{ckb/viewerCkbScript.ts → signer/signerReadonlyCkbScript.ts} +8 -4
  135. package/src/utils/index.ts +28 -0
  136. package/dist/bytes.d.ts +0 -15
  137. package/dist/bytes.d.ts.map +0 -1
  138. package/dist/bytes.js +0 -114
  139. package/dist/ckb/hasher.advanced.d.ts.map +0 -1
  140. package/dist/ckb/hasher.advanced.js +0 -4
  141. package/dist/ckb/hasher.d.ts.map +0 -1
  142. package/dist/ckb/hasher.js +0 -26
  143. package/dist/ckb/types/advanced.d.ts +0 -4
  144. package/dist/ckb/types/advanced.d.ts.map +0 -1
  145. package/dist/ckb/types/advanced.js +0 -32
  146. package/dist/ckb/types/index.d.ts +0 -3
  147. package/dist/ckb/types/index.d.ts.map +0 -1
  148. package/dist/ckb/types/index.js +0 -18
  149. package/dist/ckb/types/molecule.advanced/generated.d.ts.map +0 -1
  150. package/dist/ckb/types/molecule.advanced/index.d.ts +0 -2
  151. package/dist/ckb/types/molecule.advanced/index.d.ts.map +0 -1
  152. package/dist/ckb/types/molecule.advanced/index.js +0 -17
  153. package/dist/ckb/types/script.advanced.d.ts.map +0 -1
  154. package/dist/ckb/types/script.advanced.js +0 -15
  155. package/dist/ckb/types/script.d.ts +0 -26
  156. package/dist/ckb/types/script.d.ts.map +0 -1
  157. package/dist/ckb/types/script.js +0 -75
  158. package/dist/ckb/types/transaction.advanced.d.ts.map +0 -1
  159. package/dist/ckb/types/transaction.advanced.js +0 -11
  160. package/dist/ckb/types/transaction.d.ts +0 -127
  161. package/dist/ckb/types/transaction.d.ts.map +0 -1
  162. package/dist/ckb/types/transaction.js +0 -266
  163. package/dist/ckb/viewerCkbScript.d.ts.map +0 -1
  164. package/dist/ckb/viewerCkbScript.js +0 -18
  165. package/dist/fixedPoint.d.ts +0 -9
  166. package/dist/fixedPoint.d.ts.map +0 -1
  167. package/dist/fixedPoint.js +0 -30
  168. package/dist/primitive.d.ts +0 -5
  169. package/dist/primitive.d.ts.map +0 -1
  170. package/dist/primitive.js +0 -2
  171. package/dist/viewer.d.ts +0 -12
  172. package/dist/viewer.d.ts.map +0 -1
  173. package/dist/viewer.js +0 -19
  174. package/src/bytes.ts +0 -127
  175. package/src/ckb/types/advanced.ts +0 -3
  176. package/src/ckb/types/index.ts +0 -2
  177. package/src/ckb/types/molecule.advanced/index.ts +0 -1
  178. package/src/ckb/types/script.ts +0 -70
  179. package/src/ckb/types/transaction.ts +0 -366
  180. package/src/fixedPoint.ts +0 -53
  181. package/src/primitive.ts +0 -8
  182. package/src/viewer.ts +0 -22
  183. /package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +0 -0
  184. /package/{src/ckb/hasher.advanced.ts → dist/hasher/advanced.js} +0 -0
  185. /package/src/ckb/{types/molecule.advanced → molecule.advanced}/blockchain.mol +0 -0
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Script = exports.decodeHashType = exports.encodeHashType = void 0;
27
- const bytes_1 = require("../../bytes");
28
- const script_advanced_1 = require("./script.advanced");
29
- const mol = __importStar(require("./molecule.advanced"));
30
- function encodeHashType(hashType) {
31
- return (0, bytes_1.toBytes)([script_advanced_1.HASH_TYPE_TO_NUM[hashType]]);
32
- }
33
- exports.encodeHashType = encodeHashType;
34
- function decodeHashType(bytes) {
35
- return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.toBytes)(bytes)[0]];
36
- }
37
- exports.decodeHashType = decodeHashType;
38
- class Script {
39
- constructor(codeHash, hashType, args) {
40
- this.codeHash = codeHash;
41
- this.hashType = hashType;
42
- this.args = args;
43
- }
44
- static from({ codeHash, hashType, args, }) {
45
- return {
46
- codeHash: (0, bytes_1.toHex)(codeHash),
47
- hashType: hashType,
48
- args: (0, bytes_1.toHex)(args),
49
- };
50
- }
51
- static _toMolData(script) {
52
- return {
53
- codeHash: (0, bytes_1.toBytes)(script.codeHash),
54
- hashType: encodeHashType(script.hashType),
55
- args: (0, bytes_1.toBytes)(script.args),
56
- };
57
- }
58
- static encode(script) {
59
- return (0, bytes_1.toBytes)(mol.SerializeScript(Script._toMolData(script)));
60
- }
61
- static decode(bytes) {
62
- const view = bytes instanceof mol.Script ? bytes : new mol.Script((0, bytes_1.toBytes)(bytes));
63
- return {
64
- codeHash: (0, bytes_1.toHex)(view.getCodeHash().raw()),
65
- hashType: decodeHashType([view.getHashType()]),
66
- args: (0, bytes_1.toHex)(view.getArgs().raw()),
67
- };
68
- }
69
- static eq(a, b) {
70
- return (a.codeHash === b.codeHash &&
71
- a.args === b.args &&
72
- a.hashType === b.hashType);
73
- }
74
- }
75
- exports.Script = Script;
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.advanced.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/transaction.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAGnD,CAAC;AACF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAGnD,CAAC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NUM_TO_DEP_TYPE = exports.DEP_TYPE_TO_NUM = void 0;
4
- exports.DEP_TYPE_TO_NUM = {
5
- code: 0x00,
6
- depGroup: 0x01,
7
- };
8
- exports.NUM_TO_DEP_TYPE = {
9
- 0x00: "code",
10
- 0x01: "depGroup",
11
- };
@@ -1,127 +0,0 @@
1
- import { Script } from "./script";
2
- import { BytesLike, Hex, NumberLike } from "../../primitive";
3
- import type { TransactionSkeletonType } from "@ckb-lumos/helpers";
4
- import { DeepReadonly } from "ts-essentials";
5
- import * as mol from "./molecule.advanced";
6
- import { Hasher } from "../hasher";
7
- export type DepType = "depGroup" | "code";
8
- export declare function encodeDepType(depType: DepType): Uint8Array;
9
- export declare function decodeDepType(bytes: BytesLike): DepType;
10
- export declare class OutPoint {
11
- txHash: Hex;
12
- index: string;
13
- constructor(txHash: Hex, index: string);
14
- static from({ txHash, index, }: {
15
- txHash: BytesLike;
16
- index: NumberLike;
17
- }): OutPoint;
18
- static _toMolData(outPoint: DeepReadonly<OutPoint>): {
19
- txHash: Uint8Array;
20
- index: Uint8Array;
21
- };
22
- static encode(outPoint: DeepReadonly<OutPoint>): Uint8Array;
23
- static decode(bytes: BytesLike | mol.OutPoint): OutPoint;
24
- }
25
- export declare class CellOutput {
26
- capacity: string;
27
- lock: Script;
28
- type?: Script | undefined;
29
- constructor(capacity: string, lock: Script, type?: Script | undefined);
30
- static from({ capacity, lock, type, }: {
31
- capacity: NumberLike;
32
- lock: Parameters<typeof Script.from>[0];
33
- type?: Parameters<typeof Script.from>[0];
34
- }): CellOutput;
35
- static _toMolData(cellOutput: DeepReadonly<CellOutput>): {
36
- capacity: Uint8Array;
37
- lock: {
38
- codeHash: Uint8Array;
39
- hashType: Uint8Array;
40
- args: Uint8Array;
41
- };
42
- type: {
43
- codeHash: Uint8Array;
44
- hashType: Uint8Array;
45
- args: Uint8Array;
46
- } | undefined;
47
- };
48
- static encode(cellOutput: DeepReadonly<CellOutput>): Uint8Array;
49
- static decode(bytes: BytesLike | mol.CellOutput): CellOutput;
50
- }
51
- export declare class CellInput {
52
- previousOutput: OutPoint;
53
- since: string;
54
- cellOutput?: CellOutput | undefined;
55
- outputData?: `0x${string}` | undefined;
56
- constructor(previousOutput: OutPoint, since: string, cellOutput?: CellOutput | undefined, outputData?: `0x${string}` | undefined);
57
- static from({ previousOutput, since, cellOutput, outputData, }: {
58
- previousOutput: Parameters<typeof OutPoint.from>[0];
59
- since: NumberLike;
60
- cellOutput?: Parameters<typeof CellOutput.from>[0];
61
- outputData?: BytesLike;
62
- }): CellInput;
63
- static _toMolData(cellInput: DeepReadonly<CellInput>): {
64
- previousOutput: {
65
- txHash: Uint8Array;
66
- index: Uint8Array;
67
- };
68
- since: Uint8Array;
69
- };
70
- static encode(cellInput: DeepReadonly<CellInput>): Uint8Array;
71
- static decode(bytes: BytesLike | mol.CellInput): CellInput;
72
- }
73
- export declare class CellDep {
74
- outPoint: OutPoint;
75
- depType: DepType;
76
- constructor(outPoint: OutPoint, depType: DepType);
77
- static from({ outPoint, depType, }: {
78
- outPoint: Parameters<typeof OutPoint.from>[0];
79
- depType: DepType;
80
- }): CellDep;
81
- static _toMolData(cellDep: DeepReadonly<CellDep>): {
82
- outPoint: {
83
- txHash: Uint8Array;
84
- index: Uint8Array;
85
- };
86
- depType: Uint8Array;
87
- };
88
- static encode(cellDep: DeepReadonly<CellDep>): Uint8Array;
89
- static decode(bytes: BytesLike | mol.CellDep): CellDep;
90
- }
91
- export declare class WitnessArgs {
92
- lock?: `0x${string}` | undefined;
93
- inputType?: `0x${string}` | undefined;
94
- outputType?: `0x${string}` | undefined;
95
- constructor(lock?: `0x${string}` | undefined, inputType?: `0x${string}` | undefined, outputType?: `0x${string}` | undefined);
96
- static from({ lock, inputType, outputType, }: {
97
- lock?: BytesLike;
98
- inputType?: BytesLike;
99
- outputType?: BytesLike;
100
- }): WitnessArgs;
101
- static _toMolData(witnessArgs: DeepReadonly<WitnessArgs>): {
102
- lock: Uint8Array | undefined;
103
- inputType: Uint8Array | undefined;
104
- outputType: Uint8Array | undefined;
105
- };
106
- static encode(witnessArgs: DeepReadonly<WitnessArgs>): Uint8Array;
107
- static decode(bytes: BytesLike | mol.WitnessArgs): WitnessArgs;
108
- }
109
- export declare class Transaction {
110
- version: string;
111
- cellDeps: CellDep[];
112
- headerDeps: Hex[];
113
- inputs: CellInput[];
114
- outputs: CellOutput[];
115
- outputsData: Hex[];
116
- witnesses: Hex[];
117
- constructor(version: string, cellDeps: CellDep[], headerDeps: Hex[], inputs: CellInput[], outputs: CellOutput[], outputsData: Hex[], witnesses: Hex[]);
118
- static default(): Transaction;
119
- private static fromLumosOutPoint;
120
- private static fromLumosScript;
121
- private static fromLumosOutput;
122
- static fromLumosSkeleton(skeleton: TransactionSkeletonType): Transaction;
123
- static encodeRaw(transaction: Readonly<Omit<Transaction, "witnesses">>): Uint8Array;
124
- static hashRaw(transaction: Omit<Transaction, "witnesses">): `0x${string}`;
125
- static hashWitnessToHasher(witness: Hex, hasher: Hasher): void;
126
- }
127
- //# sourceMappingURL=transaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAS5C,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;AAE5C,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAE1C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAE1D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEvD;AAED,qBAAa,QAAQ;IAEV,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,MAAM;gBADb,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,MAAM;IAGtB,MAAM,CAAC,IAAI,CAAC,EACV,MAAM,EACN,KAAK,GACN,EAAE;QACD,MAAM,EAAE,SAAS,CAAC;QAClB,KAAK,EAAE,UAAU,CAAC;KACnB,GAAG,QAAQ;IAIZ,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;;;;IAOlD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CA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1,266 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Transaction = exports.WitnessArgs = exports.CellDep = exports.CellInput = exports.CellOutput = exports.OutPoint = exports.decodeDepType = exports.encodeDepType = void 0;
27
- const script_1 = require("./script");
28
- const bytes_1 = require("../../bytes");
29
- const mol = __importStar(require("./molecule.advanced"));
30
- const transaction_advanced_1 = require("./transaction.advanced");
31
- const hasher_1 = require("../hasher");
32
- function encodeDepType(depType) {
33
- return (0, bytes_1.toBytes)([transaction_advanced_1.DEP_TYPE_TO_NUM[depType]]);
34
- }
35
- exports.encodeDepType = encodeDepType;
36
- function decodeDepType(bytes) {
37
- return transaction_advanced_1.NUM_TO_DEP_TYPE[(0, bytes_1.toBytes)(bytes)[0]];
38
- }
39
- exports.decodeDepType = decodeDepType;
40
- class OutPoint {
41
- constructor(txHash, index) {
42
- this.txHash = txHash;
43
- this.index = index;
44
- }
45
- static from({ txHash, index, }) {
46
- return new OutPoint((0, bytes_1.toHex)(txHash), (0, bytes_1.toNumber)(index));
47
- }
48
- static _toMolData(outPoint) {
49
- return {
50
- txHash: (0, bytes_1.toBytes)(outPoint.txHash),
51
- index: (0, bytes_1.toBytesFromNumber)(outPoint.index, 4),
52
- };
53
- }
54
- static encode(outPoint) {
55
- return (0, bytes_1.toBytes)(mol.SerializeOutPoint(OutPoint._toMolData(outPoint)));
56
- }
57
- static decode(bytes) {
58
- const view = bytes instanceof mol.OutPoint ? bytes : new mol.OutPoint((0, bytes_1.toBytes)(bytes));
59
- return {
60
- txHash: (0, bytes_1.toHex)(view.getTxHash().raw()),
61
- index: (0, bytes_1.toNumberFromBytes)(view.getIndex().raw()),
62
- };
63
- }
64
- }
65
- exports.OutPoint = OutPoint;
66
- class CellOutput {
67
- constructor(capacity, lock, type) {
68
- this.capacity = capacity;
69
- this.lock = lock;
70
- this.type = type;
71
- }
72
- static from({ capacity, lock, type, }) {
73
- return new CellOutput((0, bytes_1.toNumber)(capacity), script_1.Script.from(lock), type ? script_1.Script.from(type) : undefined);
74
- }
75
- static _toMolData(cellOutput) {
76
- return {
77
- capacity: (0, bytes_1.toBytesFromNumber)(cellOutput.capacity, 8),
78
- lock: script_1.Script._toMolData(cellOutput.lock),
79
- type: cellOutput.type ? script_1.Script._toMolData(cellOutput.type) : undefined,
80
- };
81
- }
82
- static encode(cellOutput) {
83
- return (0, bytes_1.toBytes)(mol.SerializeCellOutput(CellOutput._toMolData(cellOutput)));
84
- }
85
- static decode(bytes) {
86
- const view = bytes instanceof mol.CellOutput
87
- ? bytes
88
- : new mol.CellOutput((0, bytes_1.toBytes)(bytes));
89
- const type = view.getType();
90
- return {
91
- capacity: (0, bytes_1.toNumberFromBytes)(view.getCapacity().raw()),
92
- lock: script_1.Script.decode(view.getLock()),
93
- type: type.hasValue() ? script_1.Script.decode(type.value()) : undefined,
94
- };
95
- }
96
- }
97
- exports.CellOutput = CellOutput;
98
- class CellInput {
99
- constructor(previousOutput, since, cellOutput, outputData) {
100
- this.previousOutput = previousOutput;
101
- this.since = since;
102
- this.cellOutput = cellOutput;
103
- this.outputData = outputData;
104
- }
105
- static from({ previousOutput, since, cellOutput, outputData, }) {
106
- return new CellInput(OutPoint.from(previousOutput), (0, bytes_1.toNumber)(since), cellOutput ? CellOutput.from(cellOutput) : undefined, outputData ? (0, bytes_1.toHex)(outputData) : undefined);
107
- }
108
- static _toMolData(cellInput) {
109
- return {
110
- previousOutput: OutPoint._toMolData(cellInput.previousOutput),
111
- since: (0, bytes_1.toBytesFromNumber)(cellInput.since, 8),
112
- };
113
- }
114
- static encode(cellInput) {
115
- return (0, bytes_1.toBytes)(mol.SerializeCellInput(CellInput._toMolData(cellInput)));
116
- }
117
- static decode(bytes) {
118
- const view = bytes instanceof mol.CellInput
119
- ? bytes
120
- : new mol.CellInput((0, bytes_1.toBytes)(bytes));
121
- return {
122
- previousOutput: OutPoint.decode(view.getPreviousOutput()),
123
- since: (0, bytes_1.toNumberFromBytes)(view.getSince().raw()),
124
- };
125
- }
126
- }
127
- exports.CellInput = CellInput;
128
- class CellDep {
129
- constructor(outPoint, depType) {
130
- this.outPoint = outPoint;
131
- this.depType = depType;
132
- }
133
- static from({ outPoint, depType, }) {
134
- return new CellDep(OutPoint.from(outPoint), depType);
135
- }
136
- static _toMolData(cellDep) {
137
- return {
138
- outPoint: OutPoint._toMolData(cellDep.outPoint),
139
- depType: encodeDepType(cellDep.depType),
140
- };
141
- }
142
- static encode(cellDep) {
143
- return (0, bytes_1.toBytes)(mol.SerializeCellDep(CellDep._toMolData(cellDep)));
144
- }
145
- static decode(bytes) {
146
- const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep((0, bytes_1.toBytes)(bytes));
147
- return {
148
- outPoint: OutPoint.decode(view.getOutPoint()),
149
- depType: decodeDepType([view.getDepType()]),
150
- };
151
- }
152
- }
153
- exports.CellDep = CellDep;
154
- class WitnessArgs {
155
- constructor(lock, inputType, outputType) {
156
- this.lock = lock;
157
- this.inputType = inputType;
158
- this.outputType = outputType;
159
- }
160
- static from({ lock, inputType, outputType, }) {
161
- return new WitnessArgs(lock ? (0, bytes_1.toHex)(lock) : undefined, inputType ? (0, bytes_1.toHex)(inputType) : undefined, outputType ? (0, bytes_1.toHex)(outputType) : undefined);
162
- }
163
- static _toMolData(witnessArgs) {
164
- return {
165
- lock: witnessArgs.lock ? (0, bytes_1.toBytes)(witnessArgs.lock) : undefined,
166
- inputType: witnessArgs.inputType
167
- ? (0, bytes_1.toBytes)(witnessArgs.inputType)
168
- : undefined,
169
- outputType: witnessArgs.outputType
170
- ? (0, bytes_1.toBytes)(witnessArgs.outputType)
171
- : undefined,
172
- };
173
- }
174
- static encode(witnessArgs) {
175
- return (0, bytes_1.toBytes)(mol.SerializeWitnessArgs(WitnessArgs._toMolData(witnessArgs)));
176
- }
177
- static decode(bytes) {
178
- const view = bytes instanceof mol.WitnessArgs
179
- ? bytes
180
- : new mol.WitnessArgs((0, bytes_1.toBytes)(bytes));
181
- const lock = view.getLock();
182
- const inputType = view.getInputType();
183
- const outputType = view.getOutputType();
184
- return {
185
- lock: lock.hasValue() ? (0, bytes_1.toHex)(lock.value().raw()) : undefined,
186
- inputType: inputType.hasValue()
187
- ? (0, bytes_1.toHex)(inputType.value().raw())
188
- : undefined,
189
- outputType: outputType.hasValue()
190
- ? (0, bytes_1.toHex)(outputType.value().raw())
191
- : undefined,
192
- };
193
- }
194
- }
195
- exports.WitnessArgs = WitnessArgs;
196
- class Transaction {
197
- constructor(version, cellDeps, headerDeps, inputs, outputs, outputsData, witnesses) {
198
- this.version = version;
199
- this.cellDeps = cellDeps;
200
- this.headerDeps = headerDeps;
201
- this.inputs = inputs;
202
- this.outputs = outputs;
203
- this.outputsData = outputsData;
204
- this.witnesses = witnesses;
205
- }
206
- static default() {
207
- return new Transaction("0", [], [], [], [], [], []);
208
- }
209
- static fromLumosOutPoint(outPoint) {
210
- return {
211
- ...outPoint,
212
- txHash: (0, bytes_1.toHexFromHex)(outPoint.txHash),
213
- };
214
- }
215
- static fromLumosScript(script) {
216
- return {
217
- codeHash: (0, bytes_1.toHexFromHex)(script.codeHash),
218
- args: (0, bytes_1.toHexFromHex)(script.args),
219
- hashType: script.hashType,
220
- };
221
- }
222
- static fromLumosOutput(output) {
223
- return {
224
- lock: Transaction.fromLumosScript(output.lock),
225
- type: output.type ? Transaction.fromLumosScript(output.type) : undefined,
226
- capacity: (0, bytes_1.toNumber)(output.capacity),
227
- };
228
- }
229
- static fromLumosSkeleton(skeleton) {
230
- return new Transaction("0", skeleton.cellDeps.toArray().map((cellDep) => CellDep.from({
231
- ...cellDep,
232
- outPoint: Transaction.fromLumosOutPoint(cellDep.outPoint),
233
- })), skeleton.headerDeps.toArray().map(bytes_1.toHex), skeleton.inputs.toArray().map((input, i) => {
234
- if (!input.outPoint) {
235
- throw new Error("outPoint is required in input");
236
- }
237
- return CellInput.from({
238
- previousOutput: Transaction.fromLumosOutPoint(input.outPoint),
239
- since: skeleton.inputSinces.get(i, "0x00"),
240
- cellOutput: Transaction.fromLumosOutput(input.cellOutput),
241
- outputData: (0, bytes_1.toHexFromHex)(input.data),
242
- });
243
- }), skeleton.outputs
244
- .toArray()
245
- .map((output) => CellOutput.from(Transaction.fromLumosOutput(output.cellOutput))), skeleton.outputs.toArray().map((output) => (0, bytes_1.toHex)(output.data)), skeleton.witnesses.toArray().map(bytes_1.toHex));
246
- }
247
- static encodeRaw(transaction) {
248
- return (0, bytes_1.toBytes)(mol.SerializeRawTransaction({
249
- version: (0, bytes_1.toBytesFromNumber)(transaction.version, 4),
250
- cellDeps: transaction.cellDeps.map(CellDep._toMolData),
251
- headerDeps: transaction.headerDeps.map(bytes_1.toBytes),
252
- inputs: transaction.inputs.map(CellInput._toMolData),
253
- outputs: transaction.outputs.map(CellOutput._toMolData),
254
- outputsData: transaction.outputsData.map(bytes_1.toBytes),
255
- }));
256
- }
257
- static hashRaw(transaction) {
258
- return (0, hasher_1.ckbHash)(Transaction.encodeRaw(transaction));
259
- }
260
- static hashWitnessToHasher(witness, hasher) {
261
- const raw = (0, bytes_1.toBytes)(witness);
262
- hasher.update((0, bytes_1.toBytesFromNumber)(raw.length, 8));
263
- hasher.update(raw);
264
- }
265
- }
266
- exports.Transaction = Transaction;
@@ -1 +0,0 @@
1
- {"version":3,"file":"viewerCkbScript.d.ts","sourceRoot":"","sources":["../../src/ckb/viewerCkbScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,qBAAa,eAAgB,SAAQ,MAAM;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM,EAC/B,MAAM,EAAE,MAAM;IAKV,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewerCkbScript = void 0;
4
- const viewer_1 = require("../viewer");
5
- const address_1 = require("../address");
6
- class ViewerCkbScript extends viewer_1.Viewer {
7
- constructor(script, client) {
8
- super(client);
9
- this.script = script;
10
- }
11
- async getInternalAddress() {
12
- return this.getRecommendedAddress();
13
- }
14
- async getAddressObjs() {
15
- return [await address_1.Address.fromScript(this.script, this.client)];
16
- }
17
- }
18
- exports.ViewerCkbScript = ViewerCkbScript;
@@ -1,9 +0,0 @@
1
- export declare function composeFixedPoint(val: undefined | null, decimals?: number): null;
2
- export declare function composeFixedPoint(val: bigint, decimals?: number): string;
3
- export declare function composeFixedPoint(val: bigint | undefined | null, decimals?: number): string | null;
4
- export declare function parseFixedPoint(ori: undefined | null, decimals?: number): null;
5
- export declare function parseFixedPoint(ori: string | number, decimals?: number): bigint;
6
- export declare function parseFixedPoint(ori: string | number | undefined | null, decimals?: number): bigint | null;
7
- export declare const Zero = 0n;
8
- export declare const One: bigint;
9
- //# sourceMappingURL=fixedPoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixedPoint.d.ts","sourceRoot":"","sources":["../src/fixedPoint.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,SAAS,GAAG,IAAI,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC;AACR,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAC1E,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAAC;AAkBjB,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;AAChF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAAC;AACV,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,EACvC,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAAC;AAiBjB,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,GAAG,QAAuB,CAAC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.One = exports.Zero = exports.parseFixedPoint = exports.composeFixedPoint = void 0;
4
- function composeFixedPoint(val, decimals = 8) {
5
- if (val == null) {
6
- return null;
7
- }
8
- const str = val.toString();
9
- const l = str.length <= decimals ? "0" : str.slice(0, -decimals);
10
- const r = str.slice(-decimals).padStart(decimals, "0").replace(/0*$/, "");
11
- if (r === "") {
12
- return l;
13
- }
14
- return `${l}.${r}`;
15
- }
16
- exports.composeFixedPoint = composeFixedPoint;
17
- function parseFixedPoint(ori, decimals = 8) {
18
- if (ori == null) {
19
- return null;
20
- }
21
- const [l, r] = ori.toString().split(".");
22
- const lVal = BigInt(l.padEnd(l.length + decimals, "0"));
23
- if (r === undefined) {
24
- return lVal;
25
- }
26
- return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, "0"));
27
- }
28
- exports.parseFixedPoint = parseFixedPoint;
29
- exports.Zero = 0n;
30
- exports.One = parseFixedPoint("1");
@@ -1,5 +0,0 @@
1
- export type Hex = `0x${string}`;
2
- export type BytesLike = Hex | Uint8Array | ArrayBuffer | number[];
3
- export type HexLike = BytesLike | number | string;
4
- export type NumberLike = string | Hex | number | bigint;
5
- //# sourceMappingURL=primitive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../src/primitive.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,SAAS,GACjB,GAAG,GACH,UAAU,GACV,WAAW,GACX,MAAM,EAAE,CAAC;AACb,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC"}
package/dist/primitive.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/viewer.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { Address } from "./address";
2
- import { Client } from "./client";
3
- export declare abstract class Viewer {
4
- readonly client: Client;
5
- constructor(client: Client);
6
- abstract getInternalAddress(): Promise<string>;
7
- abstract getAddressObjs(): Promise<Address[]>;
8
- getRecommendedAddressObj(_preference?: unknown): Promise<Address>;
9
- getRecommendedAddress(preference?: unknown): Promise<string>;
10
- getAddresses(): Promise<string[]>;
11
- }
12
- //# sourceMappingURL=viewer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,8BAAsB,MAAM;aACE,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;IAE1C,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAE9C,QAAQ,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IACvC,wBAAwB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjE,qBAAqB,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAG5D,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKxC"}
package/dist/viewer.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Viewer = void 0;
4
- const address_1 = require("./address");
5
- class Viewer {
6
- constructor(client) {
7
- this.client = client;
8
- }
9
- async getRecommendedAddressObj(_preference) {
10
- return (await this.getAddressObjs())[0];
11
- }
12
- async getRecommendedAddress(preference) {
13
- return address_1.Address.toString(await this.getRecommendedAddressObj(preference));
14
- }
15
- async getAddresses() {
16
- return this.getAddressObjs().then((addresses) => addresses.map((address) => address_1.Address.toString(address)));
17
- }
18
- }
19
- exports.Viewer = Viewer;