@ckb-ccc/core 0.0.5-alpha.0 → 0.0.5-alpha.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 (107) hide show
  1. package/dist/address/index.d.ts +1 -1
  2. package/dist/address/index.d.ts.map +1 -1
  3. package/dist/address/index.js +4 -4
  4. package/dist/client/client.d.ts +6 -3
  5. package/dist/client/client.d.ts.map +1 -1
  6. package/dist/client/client.js +15 -0
  7. package/dist/client/clientPublicMainnet.d.ts +1 -1
  8. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  9. package/dist/client/clientPublicMainnet.js +1 -1
  10. package/dist/client/clientPublicTestnet.d.ts +1 -1
  11. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  12. package/dist/client/clientPublicTestnet.js +1 -1
  13. package/dist/client/jsonRpc/index.d.ts +15 -5
  14. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  15. package/dist/client/jsonRpc/index.js +16 -6
  16. package/dist/signer/btc/index.d.ts +1 -0
  17. package/dist/signer/btc/index.d.ts.map +1 -1
  18. package/dist/signer/btc/index.js +1 -0
  19. package/dist/signer/btc/signerBtc.d.ts +9 -1
  20. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  21. package/dist/signer/btc/signerBtc.js +16 -2
  22. package/dist/signer/btc/verify.d.ts +3 -0
  23. package/dist/signer/btc/verify.d.ts.map +1 -0
  24. package/dist/signer/btc/verify.js +6 -0
  25. package/dist/signer/ckb/index.d.ts +1 -0
  26. package/dist/signer/ckb/index.d.ts.map +1 -1
  27. package/dist/signer/ckb/index.js +1 -0
  28. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
  29. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  30. package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -2
  31. package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
  32. package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
  33. package/dist/signer/ckb/verifyJoyId.js +12 -0
  34. package/dist/signer/evm/index.d.ts +1 -0
  35. package/dist/signer/evm/index.d.ts.map +1 -1
  36. package/dist/signer/evm/index.js +1 -0
  37. package/dist/signer/evm/signerEvm.d.ts +3 -1
  38. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  39. package/dist/signer/evm/signerEvm.js +8 -2
  40. package/dist/signer/evm/verify.d.ts +3 -0
  41. package/dist/signer/evm/verify.d.ts.map +1 -0
  42. package/dist/signer/evm/verify.js +6 -0
  43. package/dist/signer/signer.d.ts +67 -14
  44. package/dist/signer/signer.d.ts.map +1 -1
  45. package/dist/signer/signer.js +103 -16
  46. package/dist.commonjs/address/index.d.ts +1 -1
  47. package/dist.commonjs/address/index.d.ts.map +1 -1
  48. package/dist.commonjs/address/index.js +4 -4
  49. package/dist.commonjs/client/client.d.ts +6 -3
  50. package/dist.commonjs/client/client.d.ts.map +1 -1
  51. package/dist.commonjs/client/client.js +15 -0
  52. package/dist.commonjs/client/clientPublicMainnet.d.ts +1 -1
  53. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  54. package/dist.commonjs/client/clientPublicMainnet.js +1 -1
  55. package/dist.commonjs/client/clientPublicTestnet.d.ts +1 -1
  56. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  57. package/dist.commonjs/client/clientPublicTestnet.js +1 -1
  58. package/dist.commonjs/client/jsonRpc/index.d.ts +15 -5
  59. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  60. package/dist.commonjs/client/jsonRpc/index.js +15 -5
  61. package/dist.commonjs/signer/btc/index.d.ts +1 -0
  62. package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
  63. package/dist.commonjs/signer/btc/index.js +1 -0
  64. package/dist.commonjs/signer/btc/signerBtc.d.ts +9 -1
  65. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  66. package/dist.commonjs/signer/btc/signerBtc.js +15 -1
  67. package/dist.commonjs/signer/btc/verify.d.ts +3 -0
  68. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
  69. package/dist.commonjs/signer/btc/verify.js +10 -0
  70. package/dist.commonjs/signer/ckb/index.d.ts +1 -0
  71. package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
  72. package/dist.commonjs/signer/ckb/index.js +1 -0
  73. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
  74. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  75. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +7 -1
  76. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
  77. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
  78. package/dist.commonjs/signer/ckb/verifyJoyId.js +16 -0
  79. package/dist.commonjs/signer/evm/index.d.ts +1 -0
  80. package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
  81. package/dist.commonjs/signer/evm/index.js +1 -0
  82. package/dist.commonjs/signer/evm/signerEvm.d.ts +3 -1
  83. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  84. package/dist.commonjs/signer/evm/signerEvm.js +7 -1
  85. package/dist.commonjs/signer/evm/verify.d.ts +3 -0
  86. package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
  87. package/dist.commonjs/signer/evm/verify.js +10 -0
  88. package/dist.commonjs/signer/signer.d.ts +67 -14
  89. package/dist.commonjs/signer/signer.d.ts.map +1 -1
  90. package/dist.commonjs/signer/signer.js +105 -17
  91. package/package.json +6 -3
  92. package/src/address/index.ts +4 -7
  93. package/src/client/client.ts +26 -3
  94. package/src/client/clientPublicMainnet.ts +1 -1
  95. package/src/client/clientPublicTestnet.ts +1 -1
  96. package/src/client/jsonRpc/index.ts +21 -5
  97. package/src/signer/btc/index.ts +1 -0
  98. package/src/signer/btc/signerBtc.ts +19 -2
  99. package/src/signer/btc/verify.ts +14 -0
  100. package/src/signer/ckb/index.ts +1 -0
  101. package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -2
  102. package/src/signer/ckb/verifyJoyId.ts +20 -0
  103. package/src/signer/evm/index.ts +1 -0
  104. package/src/signer/evm/signerEvm.ts +10 -2
  105. package/src/signer/evm/verify.ts +16 -0
  106. package/src/signer/signer.ts +137 -15
  107. package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
@@ -3,6 +3,27 @@ import { BytesLike } from "../bytes";
3
3
  import { Transaction, TransactionLike } from "../ckb";
4
4
  import { Client } from "../client";
5
5
  import { Hex } from "../hex";
6
+ import { Num } from "../num";
7
+ export declare enum SignerSignType {
8
+ Unknown = "Unknown",
9
+ BtcEcdsa = "BtcEcdsa",
10
+ EvmPersonal = "EvmPersonal",
11
+ JoyId = "JoyId"
12
+ }
13
+ /**
14
+ * An enumeration of signer display types in wallet.
15
+ */
16
+ export declare enum SignerType {
17
+ EVM = "EVM",
18
+ BTC = "BTC",
19
+ CKB = "CKB"
20
+ }
21
+ export declare class Signature {
22
+ signature: string;
23
+ identity: string;
24
+ signType: SignerSignType;
25
+ constructor(signature: string, identity: string, signType: SignerSignType);
26
+ }
6
27
  /**
7
28
  * An abstract class representing a generic signer.
8
29
  * This class provides methods to connect, get addresses, and sign transactions.
@@ -10,7 +31,10 @@ import { Hex } from "../hex";
10
31
  export declare abstract class Signer {
11
32
  protected client_: Client;
12
33
  constructor(client_: Client);
34
+ abstract get type(): SignerType;
35
+ abstract get signType(): SignerSignType;
13
36
  get client(): Client;
37
+ static verifyMessage(message: string | BytesLike, signature: Signature): Promise<boolean>;
14
38
  /**
15
39
  * Construct a new signer with the client replaced.
16
40
  *
@@ -41,6 +65,12 @@ export declare abstract class Signer {
41
65
  * @returns A promise that resolves to a string representing the internal address.
42
66
  */
43
67
  abstract getInternalAddress(): Promise<string>;
68
+ /**
69
+ * Gets the identity for verifying signature, usually it's address
70
+ *
71
+ * @returns A promise that resolves to a string representing the identity
72
+ */
73
+ getIdentity(): Promise<string>;
44
74
  /**
45
75
  * Gets an array of Address objects associated with the signer.
46
76
  *
@@ -68,13 +98,45 @@ export declare abstract class Signer {
68
98
  */
69
99
  getAddresses(): Promise<string[]>;
70
100
  /**
71
- * Signs a message. This method is not implemented and should be overridden by subclasses.
101
+ * Gets balance of all addresses
102
+ *
103
+ * @returns A promise that resolves to the balance
104
+ */
105
+ getBalance(): Promise<Num>;
106
+ /**
107
+ * Signs a message.
72
108
  *
73
109
  * @param _ - The message to sign, as a string or BytesLike object.
74
- * @returns A promise that resolves to the signed message as a string.
110
+ * @returns A promise that resolves to the signature info.
75
111
  * @throws Will throw an error if not implemented.
76
112
  */
77
- signMessage(_: string | BytesLike): Promise<string>;
113
+ signMessage(message: string | BytesLike): Promise<Signature>;
114
+ /**
115
+ * Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
116
+ *
117
+ * @param _ - The message to sign, as a string or BytesLike object.
118
+ * @returns A promise that resolves to the signature as a string.
119
+ * @throws Will throw an error if not implemented.
120
+ */
121
+ signMessageRaw(_: string | BytesLike): Promise<string>;
122
+ /**
123
+ * Verify a signature.
124
+ *
125
+ * @param _ - The original message.
126
+ * @param _ - The signature to verify.
127
+ * @returns A promise that resolves to the verification result.
128
+ * @throws Will throw an error if not implemented.
129
+ */
130
+ verifyMessage(message: string | BytesLike, signature: string | Signature): Promise<boolean>;
131
+ /**
132
+ * Verify a string signature. This method is not implemented and should be overridden by subclasses.
133
+ *
134
+ * @param _0 - The original message.
135
+ * @param _1 - The signature to verify.
136
+ * @returns A promise that resolves to the verification result.
137
+ * @throws Will throw an error if not implemented.
138
+ */
139
+ verifyMessageRaw(_0: string | BytesLike, _1: string): Promise<boolean>;
78
140
  /**
79
141
  * Sends a transaction after signing it.
80
142
  *
@@ -98,7 +160,7 @@ export declare abstract class Signer {
98
160
  */
99
161
  prepareTransaction(_: TransactionLike): Promise<Transaction>;
100
162
  /**
101
- * Signs a transaction without sending it. This method is not implemented and should be overridden by subclasses.
163
+ * Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
102
164
  *
103
165
  * @param _ - The transaction to sign, represented as a TransactionLike object.
104
166
  * @returns A promise that resolves to the signed Transaction object.
@@ -106,22 +168,13 @@ export declare abstract class Signer {
106
168
  */
107
169
  signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
108
170
  }
109
- /**
110
- * An enumeration of signer types.
111
- */
112
- export declare enum SignerType {
113
- EVM = "EVM",
114
- BTC = "BTC",
115
- CKB = "CKB"
116
- }
117
171
  /**
118
172
  * A class representing information about a signer, including its type and the signer instance.
119
173
  */
120
174
  export declare class SignerInfo {
121
175
  name: string;
122
- type: SignerType;
123
176
  signer: Signer;
124
- constructor(name: string, type: SignerType, signer: Signer);
177
+ constructor(name: string, signer: Signer);
125
178
  }
126
179
  /**
127
180
  * Represents a wallet with a name, icon, and an array of signer information.
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B;;;GAGG;AACH,8BAAsB,MAAM;IACd,SAAS,CAAC,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAErC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEvD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC;;;;OAIG;IACH,QAAQ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IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;GAEG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -1,3 +1,29 @@
1
+ import { verifyMessageBtcEcdsa } from "./btc";
2
+ import { verifyMessageJoyId } from "./ckb/verifyJoyId";
3
+ import { verifyMessageEvmPersonal } from "./evm/verify";
4
+ export var SignerSignType;
5
+ (function (SignerSignType) {
6
+ SignerSignType["Unknown"] = "Unknown";
7
+ SignerSignType["BtcEcdsa"] = "BtcEcdsa";
8
+ SignerSignType["EvmPersonal"] = "EvmPersonal";
9
+ SignerSignType["JoyId"] = "JoyId";
10
+ })(SignerSignType || (SignerSignType = {}));
11
+ /**
12
+ * An enumeration of signer display types in wallet.
13
+ */
14
+ export var SignerType;
15
+ (function (SignerType) {
16
+ SignerType["EVM"] = "EVM";
17
+ SignerType["BTC"] = "BTC";
18
+ SignerType["CKB"] = "CKB";
19
+ })(SignerType || (SignerType = {}));
20
+ export class Signature {
21
+ constructor(signature, identity, signType) {
22
+ this.signature = signature;
23
+ this.identity = identity;
24
+ this.signType = signType;
25
+ }
26
+ }
1
27
  /**
2
28
  * An abstract class representing a generic signer.
3
29
  * This class provides methods to connect, get addresses, and sign transactions.
@@ -9,12 +35,32 @@ export class Signer {
9
35
  get client() {
10
36
  return this.client_;
11
37
  }
38
+ static async verifyMessage(message, signature) {
39
+ switch (signature.signType) {
40
+ case SignerSignType.EvmPersonal:
41
+ return verifyMessageEvmPersonal(message, signature.signature, signature.identity);
42
+ case SignerSignType.BtcEcdsa:
43
+ return verifyMessageBtcEcdsa(message, signature.signature, signature.identity);
44
+ case SignerSignType.JoyId:
45
+ return verifyMessageJoyId(message, signature.signature, signature.identity);
46
+ case SignerSignType.Unknown:
47
+ throw new Error("Unknown signer sign type");
48
+ }
49
+ }
12
50
  /**
13
51
  * Disconnects to the signer.
14
52
  *
15
53
  * @returns A promise that resolves when disconnected.
16
54
  */
17
55
  async disconnect() { }
56
+ /**
57
+ * Gets the identity for verifying signature, usually it's address
58
+ *
59
+ * @returns A promise that resolves to a string representing the identity
60
+ */
61
+ async getIdentity() {
62
+ return this.getInternalAddress();
63
+ }
18
64
  /**
19
65
  * Gets the recommended Address object for the signer.
20
66
  *
@@ -42,14 +88,65 @@ export class Signer {
42
88
  return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
43
89
  }
44
90
  /**
45
- * Signs a message. This method is not implemented and should be overridden by subclasses.
91
+ * Gets balance of all addresses
92
+ *
93
+ * @returns A promise that resolves to the balance
94
+ */
95
+ async getBalance() {
96
+ return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
97
+ }
98
+ /**
99
+ * Signs a message.
46
100
  *
47
101
  * @param _ - The message to sign, as a string or BytesLike object.
48
- * @returns A promise that resolves to the signed message as a string.
102
+ * @returns A promise that resolves to the signature info.
49
103
  * @throws Will throw an error if not implemented.
50
104
  */
51
- signMessage(_) {
52
- throw Error("Signer.signMessage not implemented");
105
+ async signMessage(message) {
106
+ return {
107
+ signature: await this.signMessageRaw(message),
108
+ identity: await this.getIdentity(),
109
+ signType: this.signType,
110
+ };
111
+ }
112
+ /**
113
+ * Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
114
+ *
115
+ * @param _ - The message to sign, as a string or BytesLike object.
116
+ * @returns A promise that resolves to the signature as a string.
117
+ * @throws Will throw an error if not implemented.
118
+ */
119
+ signMessageRaw(_) {
120
+ throw Error("Signer.signMessageRaw not implemented");
121
+ }
122
+ /**
123
+ * Verify a signature.
124
+ *
125
+ * @param _ - The original message.
126
+ * @param _ - The signature to verify.
127
+ * @returns A promise that resolves to the verification result.
128
+ * @throws Will throw an error if not implemented.
129
+ */
130
+ async verifyMessage(message, signature) {
131
+ if (typeof signature === "string") {
132
+ return this.verifyMessageRaw(message, signature);
133
+ }
134
+ if (signature.identity !== (await this.getIdentity()) ||
135
+ ![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
136
+ return false;
137
+ }
138
+ return this.verifyMessageRaw(message, signature.signature);
139
+ }
140
+ /**
141
+ * Verify a string signature. This method is not implemented and should be overridden by subclasses.
142
+ *
143
+ * @param _0 - The original message.
144
+ * @param _1 - The signature to verify.
145
+ * @returns A promise that resolves to the verification result.
146
+ * @throws Will throw an error if not implemented.
147
+ */
148
+ verifyMessageRaw(_0, _1) {
149
+ throw Error("Signer.verifyMessageRaw not implemented");
53
150
  }
54
151
  /**
55
152
  * Sends a transaction after signing it.
@@ -81,7 +178,7 @@ export class Signer {
81
178
  throw Error("Signer.prepareTransaction not implemented");
82
179
  }
83
180
  /**
84
- * Signs a transaction without sending it. This method is not implemented and should be overridden by subclasses.
181
+ * Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
85
182
  *
86
183
  * @param _ - The transaction to sign, represented as a TransactionLike object.
87
184
  * @returns A promise that resolves to the signed Transaction object.
@@ -91,22 +188,12 @@ export class Signer {
91
188
  throw Error("Signer.signOnlyTransaction not implemented");
92
189
  }
93
190
  }
94
- /**
95
- * An enumeration of signer types.
96
- */
97
- export var SignerType;
98
- (function (SignerType) {
99
- SignerType["EVM"] = "EVM";
100
- SignerType["BTC"] = "BTC";
101
- SignerType["CKB"] = "CKB";
102
- })(SignerType || (SignerType = {}));
103
191
  /**
104
192
  * A class representing information about a signer, including its type and the signer instance.
105
193
  */
106
194
  export class SignerInfo {
107
- constructor(name, type, signer) {
195
+ constructor(name, signer) {
108
196
  this.name = name;
109
- this.type = type;
110
197
  this.signer = signer;
111
198
  }
112
199
  }
@@ -42,7 +42,7 @@ export declare class Address {
42
42
  * @param client - The client instance used to fetch the address prefix.
43
43
  * @returns A promise that resolves to an Address instance.
44
44
  */
45
- static fromScript(script: ScriptLike, client: Client): Promise<Address>;
45
+ static fromScript(script: ScriptLike, client: Client): Address;
46
46
  static fromKnownScript(script: KnownScript, args: HexLike, client: Client): Promise<Address>;
47
47
  /**
48
48
  * Converts the Address instance to a string.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAQjC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,qBAAa,OAAO;IAQT,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IARvB;;;;;OAKG;gBAEM,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGvB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAQ1C;;;;;;;;OAQG;WAEU,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;;OAMG;WAEU,UAAU,CACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;WAIN,eAAe,CAC1B,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM;IAWhB;;;;OAIG;IAEH,QAAQ,IAAI,MAAM;CAcnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAQjC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,qBAAa,OAAO;IAQT,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IARvB;;;;;OAKG;gBAEM,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGvB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAQ1C;;;;;;;;OAQG;WAEU,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;;OAMG;IAEH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;WAIjD,eAAe,CAC1B,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM;IAWhB;;;;OAIG;IAEH,QAAQ,IAAI,MAAM;CAcnB"}
@@ -46,7 +46,7 @@ class Address {
46
46
  if (!client) {
47
47
  throw new Error(`Unknown address prefix ${prefix}`);
48
48
  }
49
- const expectedPrefix = await client.getAddressPrefix();
49
+ const expectedPrefix = client.addressPrefix;
50
50
  if (expectedPrefix !== prefix) {
51
51
  throw new Error(`Unknown address prefix ${prefix}, expected ${expectedPrefix}`);
52
52
  }
@@ -59,8 +59,8 @@ class Address {
59
59
  * @param client - The client instance used to fetch the address prefix.
60
60
  * @returns A promise that resolves to an Address instance.
61
61
  */
62
- static async fromScript(script, client) {
63
- return Address.from({ script, prefix: await client.getAddressPrefix() });
62
+ static fromScript(script, client) {
63
+ return Address.from({ script, prefix: client.addressPrefix });
64
64
  }
65
65
  static async fromKnownScript(script, args, client) {
66
66
  return Address.from({
@@ -68,7 +68,7 @@ class Address {
68
68
  ...(await client.getKnownScript(script)),
69
69
  args,
70
70
  },
71
- prefix: await client.getAddressPrefix(),
71
+ prefix: client.addressPrefix,
72
72
  });
73
73
  }
74
74
  /**
@@ -1,6 +1,6 @@
1
1
  import { Cell, OutPointLike, Script, ScriptLike, TransactionLike } from "../ckb";
2
2
  import { Hex, HexLike } from "../hex";
3
- import { NumLike } from "../num";
3
+ import { Num, NumLike } from "../num";
4
4
  import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, OutputsValidator } from "./clientTypes";
5
5
  export declare enum KnownScript {
6
6
  Secp256k1Blake160 = 0,
@@ -11,8 +11,8 @@ export declare enum KnownScript {
11
11
  OmniLock = 5
12
12
  }
13
13
  export declare abstract class Client {
14
- abstract getUrl(): string;
15
- abstract getAddressPrefix(): Promise<string>;
14
+ abstract get url(): string;
15
+ abstract get addressPrefix(): string;
16
16
  abstract getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
17
17
  abstract sendTransaction(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
18
18
  abstract getTransaction(txHash: HexLike): Promise<ClientTransactionResponse | null>;
@@ -20,5 +20,8 @@ export declare abstract class Client {
20
20
  abstract findCellsPaged(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
21
21
  findCells(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
22
22
  findCellsByLockAndType(lock: ScriptLike, type: ScriptLike, withData?: boolean): AsyncGenerator<Cell>;
23
+ abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
24
+ getBalanceSingle(lock: ScriptLike): Promise<Num>;
25
+ getBalance(locks: ScriptLike[]): Promise<Num>;
23
26
  }
24
27
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,CAAC,MAAM,IAAI,MAAM;IAEzB,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAC5C,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAEtC,OAAO,CA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AG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAEtC,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB3D,QAAQ,CAAC,cAAc,CACrB,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,CAAC,EAAE,OAAO,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC;IAE5B,SAAS,CACd,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,SAAK,GACT,cAAc,CAAC,IAAI,CAAC;IAoBvB,sBAAsB,CACpB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,QAAQ,UAAO,GACd,cAAc,CAAC,IAAI,CAAC;IAYvB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,EAAE,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAElE,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAYhD,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAOpD"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = exports.KnownScript = void 0;
4
4
  const ckb_1 = require("../ckb");
5
+ const fixedPoint_1 = require("../fixedPoint");
5
6
  const num_1 = require("../num");
6
7
  var KnownScript;
7
8
  (function (KnownScript) {
@@ -53,5 +54,19 @@ class Client {
53
54
  withData,
54
55
  });
55
56
  }
57
+ async getBalanceSingle(lock) {
58
+ return this.getCellsCapacity({
59
+ script: lock,
60
+ scriptType: "lock",
61
+ scriptSearchMode: "exact",
62
+ filter: {
63
+ scriptLenRange: [0, 1],
64
+ outputDataLenRange: [0, 1],
65
+ },
66
+ });
67
+ }
68
+ async getBalance(locks) {
69
+ return locks.reduce((res, lock) => this.getBalanceSingle(lock).then((a) => res.then((b) => a + b)), Promise.resolve(fixedPoint_1.Zero));
70
+ }
56
71
  }
57
72
  exports.Client = Client;
@@ -3,7 +3,7 @@ import { KnownScript } from "./client";
3
3
  import { ClientJsonRpc } from "./jsonRpc";
4
4
  export declare class ClientPublicMainnet extends ClientJsonRpc {
5
5
  constructor(url?: string, timeout?: number);
6
- getAddressPrefix(): Promise<string>;
6
+ get addressPrefix(): string;
7
7
  getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
8
8
  }
9
9
  //# sourceMappingURL=clientPublicMainnet.d.ts.map
@@ -1 +1 @@
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
+ {"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;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
@@ -7,7 +7,7 @@ class ClientPublicMainnet extends jsonRpc_1.ClientJsonRpc {
7
7
  constructor(url = "https://mainnet.ckbapp.dev/", timeout) {
8
8
  super(url, timeout);
9
9
  }
10
- async getAddressPrefix() {
10
+ get addressPrefix() {
11
11
  return "ckb";
12
12
  }
13
13
  async getKnownScript(script) {
@@ -3,7 +3,7 @@ import { KnownScript } from "./client";
3
3
  import { ClientJsonRpc } from "./jsonRpc";
4
4
  export declare class ClientPublicTestnet extends ClientJsonRpc {
5
5
  constructor(url?: string, timeout?: number);
6
- getAddressPrefix(): Promise<string>;
6
+ get addressPrefix(): string;
7
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,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
+ {"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;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
@@ -7,7 +7,7 @@ class ClientPublicTestnet extends jsonRpc_1.ClientJsonRpc {
7
7
  constructor(url = "https://testnet.ckbapp.dev/", timeout) {
8
8
  super(url, timeout);
9
9
  }
10
- async getAddressPrefix() {
10
+ get addressPrefix() {
11
11
  return "ckt";
12
12
  }
13
13
  async getKnownScript(script) {
@@ -1,6 +1,6 @@
1
1
  import { TransactionLike } from "../../ckb";
2
2
  import { Hex, HexLike } from "../../hex";
3
- import { NumLike } from "../../num";
3
+ import { Num, NumLike } from "../../num";
4
4
  import { Client } from "../client";
5
5
  import { ClientFindCellsResponse, ClientIndexerSearchKeyLike, ClientTransactionResponse, OutputsValidator } from "../clientTypes";
6
6
  import { JsonRpcPayload } from "./advanced";
@@ -9,7 +9,7 @@ import { JsonRpcPayload } from "./advanced";
9
9
  * Provides methods for sending transactions and building JSON-RPC payloads.
10
10
  */
11
11
  export declare abstract class ClientJsonRpc extends Client {
12
- private readonly url;
12
+ private readonly url_;
13
13
  private readonly timeout;
14
14
  /**
15
15
  * Creates an instance of ClientJsonRpc.
@@ -17,13 +17,13 @@ export declare abstract class ClientJsonRpc extends Client {
17
17
  * @param url - The URL of the JSON-RPC server.
18
18
  * @param timeout - The timeout for requests in milliseconds, default is 30000.
19
19
  */
20
- constructor(url: string, timeout?: number);
20
+ constructor(url_: string, timeout?: number);
21
21
  /**
22
22
  * Returns the URL of the JSON-RPC server.
23
23
  *
24
24
  * @returns The URL of the JSON-RPC server.
25
25
  */
26
- getUrl(): string;
26
+ get url(): string;
27
27
  /**
28
28
  * Send a transaction to node.
29
29
  *
@@ -42,10 +42,20 @@ export declare abstract class ClientJsonRpc extends Client {
42
42
  /**
43
43
  * find cells from node.
44
44
  *
45
- * @param txHash - The hash of the transaction.
45
+ * @param key - The search key of cells.
46
+ * @param order - The order of cells.
47
+ * @param limit - The max return size of cells.
48
+ * @param after - Pagination parameter.
46
49
  * @returns The found cells.
47
50
  */
48
51
  findCellsPaged: (key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string) => Promise<ClientFindCellsResponse>;
52
+ /**
53
+ * get cells capacity from node.
54
+ *
55
+ * @param key - The search key of cells.
56
+ * @returns The sum of cells capacity.
57
+ */
58
+ getCellsCapacity: (key: ClientIndexerSearchKeyLike) => Promise<Num>;
49
59
  /**
50
60
  * Builds a sender function for a JSON-RPC method.
51
61
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,OAAO,EAAY,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,C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
  * @param timeout - The timeout for requests in milliseconds, default is 30000.
41
41
  */
42
- constructor(url, timeout = 30000) {
42
+ constructor(url_, timeout = 30000) {
43
43
  super();
44
- this.url = url;
44
+ this.url_ = url_;
45
45
  this.timeout = timeout;
46
46
  /**
47
47
  * Send a transaction to node.
@@ -61,7 +61,10 @@ class ClientJsonRpc extends client_1.Client {
61
61
  /**
62
62
  * find cells from node.
63
63
  *
64
- * @param txHash - The hash of the transaction.
64
+ * @param key - The search key of cells.
65
+ * @param order - The order of cells.
66
+ * @param limit - The max return size of cells.
67
+ * @param after - Pagination parameter.
65
68
  * @returns The found cells.
66
69
  */
67
70
  this.findCellsPaged = this.buildSender("get_cells", [
@@ -69,14 +72,21 @@ class ClientJsonRpc extends client_1.Client {
69
72
  (order) => order ?? "asc",
70
73
  (limit) => (0, num_1.numToHex)(limit ?? 10),
71
74
  ], advanced_1.JsonRpcTransformers.findCellsResponseTo);
75
+ /**
76
+ * get cells capacity from node.
77
+ *
78
+ * @param key - The search key of cells.
79
+ * @returns The sum of cells capacity.
80
+ */
81
+ this.getCellsCapacity = this.buildSender("get_cells_capacity", [advanced_1.JsonRpcTransformers.indexerSearchKeyFrom], ({ capacity }) => (0, num_1.numFrom)(capacity));
72
82
  }
73
83
  /**
74
84
  * Returns the URL of the JSON-RPC server.
75
85
  *
76
86
  * @returns The URL of the JSON-RPC server.
77
87
  */
78
- getUrl() {
79
- return this.url;
88
+ get url() {
89
+ return this.url_;
80
90
  }
81
91
  /**
82
92
  * Builds a sender function for a JSON-RPC method.
@@ -1,3 +1,4 @@
1
1
  export * from "./signerBtc";
2
2
  export * from "./signerBtcPublicKeyReadonly";
3
+ export * from "./verify";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC"}
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./signerBtc"), exports);
18
18
  __exportStar(require("./signerBtcPublicKeyReadonly"), exports);
19
+ __exportStar(require("./verify"), exports);
@@ -1,13 +1,15 @@
1
1
  import { Address } from "../../address";
2
2
  import { Transaction, TransactionLike } from "../../ckb";
3
3
  import { HexLike } from "../../hex";
4
- import { Signer } from "../signer";
4
+ import { Signer, SignerSignType, SignerType } from "../signer";
5
5
  /**
6
6
  * An abstract class extending the Signer class for Bitcoin-like signing operations.
7
7
  * This class provides methods to get Bitcoin account, public key, and internal address,
8
8
  * as well as signing transactions.
9
9
  */
10
10
  export declare abstract class SignerBtc extends Signer {
11
+ get type(): SignerType;
12
+ get signType(): SignerSignType;
11
13
  /**
12
14
  * Gets the Bitcoin account associated with the signer.
13
15
  *
@@ -26,6 +28,12 @@ export declare abstract class SignerBtc extends Signer {
26
28
  * @returns A promise that resolves to a string representing the internal address.
27
29
  */
28
30
  getInternalAddress(): Promise<string>;
31
+ /**
32
+ * Gets the identity, which is the Bitcoin public key in this case.
33
+ *
34
+ * @returns A promise that resolves to a string representing the identity
35
+ */
36
+ getIdentity(): Promise<string>;
29
37
  /**
30
38
  * Gets an array of Address objects representing the known script addresses for the signer.
31
39
  *
@@ -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;AAE7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