@ckb-ccc/core 1.5.3 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +61 -7
  2. package/dist/ckb/script.d.ts +2 -1
  3. package/dist/ckb/script.d.ts.map +1 -1
  4. package/dist/ckb/transaction.d.ts +125 -7
  5. package/dist/ckb/transaction.d.ts.map +1 -1
  6. package/dist/ckb/transaction.js +263 -73
  7. package/dist/client/cache/cache.d.ts +67 -11
  8. package/dist/client/cache/cache.d.ts.map +1 -1
  9. package/dist/client/cache/cache.js +94 -9
  10. package/dist/client/cache/memory.advanced.d.ts +2 -2
  11. package/dist/client/cache/memory.advanced.d.ts.map +1 -1
  12. package/dist/client/cache/memory.advanced.js +19 -7
  13. package/dist/client/cache/memory.d.ts +24 -7
  14. package/dist/client/cache/memory.d.ts.map +1 -1
  15. package/dist/client/cache/memory.js +76 -18
  16. package/dist/client/client.d.ts +30 -7
  17. package/dist/client/client.d.ts.map +1 -1
  18. package/dist/client/client.js +114 -22
  19. package/dist/client/clientPublicMainnet.advanced.d.ts +2 -1
  20. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  21. package/dist/client/clientPublicMainnet.advanced.js +1 -1
  22. package/dist/client/clientPublicMainnet.d.ts +2 -1
  23. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  24. package/dist/client/clientPublicMainnet.js +1 -6
  25. package/dist/client/clientPublicTestnet.advanced.d.ts +2 -1
  26. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  27. package/dist/client/clientPublicTestnet.advanced.js +1 -1
  28. package/dist/client/clientPublicTestnet.d.ts +2 -1
  29. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  30. package/dist/client/clientTypes.advanced.d.ts +3 -0
  31. package/dist/client/clientTypes.advanced.d.ts.map +1 -1
  32. package/dist/client/clientTypes.advanced.js +3 -0
  33. package/dist/client/clientTypes.d.ts +110 -38
  34. package/dist/client/clientTypes.d.ts.map +1 -1
  35. package/dist/client/clientTypes.js +118 -31
  36. package/dist/client/index.d.ts +1 -0
  37. package/dist/client/index.d.ts.map +1 -1
  38. package/dist/client/index.js +1 -0
  39. package/dist/client/jsonRpc/client.d.ts +4 -4
  40. package/dist/client/jsonRpc/client.d.ts.map +1 -1
  41. package/dist/client/jsonRpc/client.js +4 -4
  42. package/dist/client/jsonRpc/transformers.js +3 -3
  43. package/dist/client/knownScript.d.ts +26 -0
  44. package/dist/client/knownScript.d.ts.map +1 -0
  45. package/dist/client/knownScript.js +27 -0
  46. package/dist/jsonRpc/transports/webSocket.d.ts.map +1 -1
  47. package/dist/jsonRpc/transports/webSocket.js +7 -3
  48. package/dist/molecule/predefined.d.ts +10 -10
  49. package/dist/molecule/predefined.d.ts.map +1 -1
  50. package/dist/num/index.d.ts.map +1 -1
  51. package/dist/num/index.js +17 -1
  52. package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
  53. package/dist/signer/ckb/signerCkbPublicKey.js +1 -5
  54. package/dist/signer/nostr/index.d.ts +1 -0
  55. package/dist/signer/nostr/index.d.ts.map +1 -1
  56. package/dist/signer/nostr/index.js +1 -0
  57. package/dist/signer/nostr/signerNostr.d.ts +1 -1
  58. package/dist/signer/nostr/signerNostr.d.ts.map +1 -1
  59. package/dist/signer/nostr/signerNostr.js +8 -0
  60. package/dist/signer/nostr/signerNostrPrivateKey.d.ts +5 -7
  61. package/dist/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -1
  62. package/dist/signer/nostr/signerNostrPrivateKey.js +6 -12
  63. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts +11 -0
  64. package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +1 -0
  65. package/dist/signer/nostr/signerNostrPublicKeyReadonly.js +22 -0
  66. package/dist/utils/index.d.ts +4 -0
  67. package/dist/utils/index.d.ts.map +1 -1
  68. package/dist/utils/index.js +13 -1
  69. package/dist.commonjs/advanced.js +17 -7
  70. package/dist.commonjs/ckb/script.d.ts +2 -1
  71. package/dist.commonjs/ckb/script.d.ts.map +1 -1
  72. package/dist.commonjs/ckb/transaction.d.ts +125 -7
  73. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  74. package/dist.commonjs/ckb/transaction.js +352 -160
  75. package/dist.commonjs/client/cache/cache.d.ts +67 -11
  76. package/dist.commonjs/client/cache/cache.d.ts.map +1 -1
  77. package/dist.commonjs/client/cache/cache.js +94 -9
  78. package/dist.commonjs/client/cache/memory.advanced.d.ts +2 -2
  79. package/dist.commonjs/client/cache/memory.advanced.d.ts.map +1 -1
  80. package/dist.commonjs/client/cache/memory.advanced.js +19 -7
  81. package/dist.commonjs/client/cache/memory.d.ts +24 -7
  82. package/dist.commonjs/client/cache/memory.d.ts.map +1 -1
  83. package/dist.commonjs/client/cache/memory.js +75 -17
  84. package/dist.commonjs/client/client.d.ts +30 -7
  85. package/dist.commonjs/client/client.d.ts.map +1 -1
  86. package/dist.commonjs/client/client.js +112 -20
  87. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +2 -1
  88. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  89. package/dist.commonjs/client/clientPublicMainnet.advanced.js +21 -21
  90. package/dist.commonjs/client/clientPublicMainnet.d.ts +2 -1
  91. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  92. package/dist.commonjs/client/clientPublicMainnet.js +1 -6
  93. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +2 -1
  94. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  95. package/dist.commonjs/client/clientPublicTestnet.advanced.js +21 -21
  96. package/dist.commonjs/client/clientPublicTestnet.d.ts +2 -1
  97. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  98. package/dist.commonjs/client/clientTypes.advanced.d.ts +3 -0
  99. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -1
  100. package/dist.commonjs/client/clientTypes.advanced.js +4 -0
  101. package/dist.commonjs/client/clientTypes.d.ts +110 -38
  102. package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
  103. package/dist.commonjs/client/clientTypes.js +123 -31
  104. package/dist.commonjs/client/index.d.ts +1 -0
  105. package/dist.commonjs/client/index.d.ts.map +1 -1
  106. package/dist.commonjs/client/index.js +1 -0
  107. package/dist.commonjs/client/jsonRpc/client.d.ts +4 -4
  108. package/dist.commonjs/client/jsonRpc/client.d.ts.map +1 -1
  109. package/dist.commonjs/client/jsonRpc/client.js +4 -4
  110. package/dist.commonjs/client/jsonRpc/transformers.js +2 -2
  111. package/dist.commonjs/client/knownScript.d.ts +26 -0
  112. package/dist.commonjs/client/knownScript.d.ts.map +1 -0
  113. package/dist.commonjs/client/knownScript.js +30 -0
  114. package/dist.commonjs/index.js +17 -7
  115. package/dist.commonjs/jsonRpc/transports/webSocket.d.ts.map +1 -1
  116. package/dist.commonjs/jsonRpc/transports/webSocket.js +7 -3
  117. package/dist.commonjs/molecule/index.js +17 -7
  118. package/dist.commonjs/num/index.d.ts.map +1 -1
  119. package/dist.commonjs/num/index.js +17 -1
  120. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
  121. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +1 -5
  122. package/dist.commonjs/signer/nostr/index.d.ts +1 -0
  123. package/dist.commonjs/signer/nostr/index.d.ts.map +1 -1
  124. package/dist.commonjs/signer/nostr/index.js +1 -0
  125. package/dist.commonjs/signer/nostr/signerNostr.d.ts +1 -1
  126. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -1
  127. package/dist.commonjs/signer/nostr/signerNostr.js +8 -0
  128. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts +5 -7
  129. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -1
  130. package/dist.commonjs/signer/nostr/signerNostrPrivateKey.js +6 -12
  131. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts +11 -0
  132. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +1 -0
  133. package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.js +26 -0
  134. package/dist.commonjs/utils/index.d.ts +4 -0
  135. package/dist.commonjs/utils/index.d.ts.map +1 -1
  136. package/dist.commonjs/utils/index.js +13 -0
  137. package/package.json +1 -1
  138. package/src/ckb/script.ts +2 -1
  139. package/src/ckb/transaction.ts +376 -97
  140. package/src/client/cache/cache.ts +126 -13
  141. package/src/client/cache/memory.advanced.ts +24 -7
  142. package/src/client/cache/memory.ts +130 -30
  143. package/src/client/client.ts +172 -28
  144. package/src/client/clientPublicMainnet.advanced.ts +2 -1
  145. package/src/client/clientPublicMainnet.ts +3 -7
  146. package/src/client/clientPublicTestnet.advanced.ts +2 -1
  147. package/src/client/clientPublicTestnet.ts +2 -1
  148. package/src/client/clientTypes.advanced.ts +4 -0
  149. package/src/client/clientTypes.ts +224 -61
  150. package/src/client/index.ts +1 -0
  151. package/src/client/jsonRpc/client.ts +11 -9
  152. package/src/client/jsonRpc/transformers.ts +2 -2
  153. package/src/client/knownScript.ts +27 -0
  154. package/src/jsonRpc/transports/webSocket.ts +17 -13
  155. package/src/num/index.ts +21 -1
  156. package/src/signer/ckb/signerCkbPublicKey.ts +3 -5
  157. package/src/signer/nostr/index.ts +1 -0
  158. package/src/signer/nostr/signerNostr.ts +3 -1
  159. package/src/signer/nostr/signerNostrPrivateKey.ts +7 -14
  160. package/src/signer/nostr/signerNostrPublicKeyReadonly.ts +29 -0
  161. package/src/utils/index.ts +14 -1
@@ -9,11 +9,16 @@ import {
9
9
  } from "../ckb/index.js";
10
10
  import { Zero } from "../fixedPoint/index.js";
11
11
  import { Hex, HexLike, hexFrom } from "../hex/index.js";
12
- import { Num, NumLike, numFrom, numMax } from "../num/index.js";
12
+ import { Num, NumLike, numFrom, numMax, numMin } from "../num/index.js";
13
13
  import { reduceAsync, sleep } from "../utils/index.js";
14
14
  import { ClientCache } from "./cache/index.js";
15
15
  import { ClientCacheMemory } from "./cache/memory.js";
16
- import { ClientCollectableSearchKeyLike } from "./clientTypes.advanced.js";
16
+ import {
17
+ CONFIRMED_BLOCK_TIME,
18
+ ClientCollectableSearchKeyLike,
19
+ DEFAULT_MAX_FEE_RATE,
20
+ DEFAULT_MIN_FEE_RATE,
21
+ } from "./clientTypes.advanced.js";
17
22
  import {
18
23
  CellDepInfo,
19
24
  CellDepInfoLike,
@@ -26,11 +31,16 @@ import {
26
31
  ClientIndexerSearchKeyLike,
27
32
  ClientIndexerSearchKeyTransactionLike,
28
33
  ClientTransactionResponse,
34
+ ErrorClientMaxFeeRateExceeded,
29
35
  ErrorClientWaitTransactionTimeout,
30
- KnownScript,
31
36
  OutputsValidator,
32
37
  ScriptInfo,
33
38
  } from "./clientTypes.js";
39
+ import { KnownScript } from "./knownScript.js";
40
+
41
+ function hasHeaderConfirmed(header: ClientBlockHeader): boolean {
42
+ return numFrom(Date.now()) - header.timestamp >= CONFIRMED_BLOCK_TIME;
43
+ }
34
44
 
35
45
  /**
36
46
  * @public
@@ -50,30 +60,113 @@ export abstract class Client {
50
60
  abstract getFeeRateStatistics(
51
61
  blockRange?: NumLike,
52
62
  ): Promise<{ mean: Num; median: Num }>;
53
- async getFeeRate(blockRange?: NumLike): Promise<Num> {
54
- return numMax((await this.getFeeRateStatistics(blockRange)).median, 1000);
63
+ async getFeeRate(
64
+ blockRange?: NumLike,
65
+ options?: { maxFeeRate?: NumLike },
66
+ ): Promise<Num> {
67
+ const feeRate = numMax(
68
+ (await this.getFeeRateStatistics(blockRange)).median,
69
+ DEFAULT_MIN_FEE_RATE,
70
+ );
71
+
72
+ const maxFeeRate = numFrom(options?.maxFeeRate ?? DEFAULT_MAX_FEE_RATE);
73
+ if (maxFeeRate === Zero) {
74
+ return feeRate;
75
+ }
76
+
77
+ return numMin(feeRate, maxFeeRate);
55
78
  }
56
79
 
57
80
  abstract getTip(): Promise<Num>;
58
81
  abstract getTipHeader(verbosity?: number | null): Promise<ClientBlockHeader>;
59
- abstract getBlockByNumber(
82
+ abstract getBlockByNumberNoCache(
60
83
  blockNumber: NumLike,
61
84
  verbosity?: number | null,
62
85
  withCycles?: boolean | null,
63
86
  ): Promise<ClientBlock | undefined>;
64
- abstract getBlockByHash(
87
+ abstract getBlockByHashNoCache(
65
88
  blockHash: HexLike,
66
89
  verbosity?: number | null,
67
90
  withCycles?: boolean | null,
68
91
  ): Promise<ClientBlock | undefined>;
69
- abstract getHeaderByNumber(
92
+ abstract getHeaderByNumberNoCache(
70
93
  blockNumber: NumLike,
71
94
  verbosity?: number | null,
72
95
  ): Promise<ClientBlockHeader | undefined>;
73
- abstract getHeaderByHash(
96
+ abstract getHeaderByHashNoCache(
74
97
  blockHash: HexLike,
75
98
  verbosity?: number | null,
76
99
  ): Promise<ClientBlockHeader | undefined>;
100
+ async getBlockByNumber(
101
+ blockNumber: NumLike,
102
+ verbosity?: number | null,
103
+ withCycles?: boolean | null,
104
+ ): Promise<ClientBlock | undefined> {
105
+ const block = await this.cache.getBlockByNumber(blockNumber);
106
+ if (block) {
107
+ return block;
108
+ }
109
+
110
+ const res = await this.getBlockByNumberNoCache(
111
+ blockNumber,
112
+ verbosity,
113
+ withCycles,
114
+ );
115
+ if (res && hasHeaderConfirmed(res.header)) {
116
+ await this.cache.recordBlocks(res);
117
+ }
118
+ return res;
119
+ }
120
+ async getBlockByHash(
121
+ blockHash: HexLike,
122
+ verbosity?: number | null,
123
+ withCycles?: boolean | null,
124
+ ): Promise<ClientBlock | undefined> {
125
+ const block = await this.cache.getBlockByHash(blockHash);
126
+ if (block) {
127
+ return block;
128
+ }
129
+
130
+ const res = await this.getBlockByHashNoCache(
131
+ blockHash,
132
+ verbosity,
133
+ withCycles,
134
+ );
135
+ if (res && hasHeaderConfirmed(res.header)) {
136
+ await this.cache.recordBlocks(res);
137
+ }
138
+ return res;
139
+ }
140
+ async getHeaderByNumber(
141
+ blockNumber: NumLike,
142
+ verbosity?: number | null,
143
+ ): Promise<ClientBlockHeader | undefined> {
144
+ const header = await this.cache.getHeaderByNumber(blockNumber);
145
+ if (header) {
146
+ return header;
147
+ }
148
+
149
+ const res = await this.getHeaderByNumberNoCache(blockNumber, verbosity);
150
+ if (res && hasHeaderConfirmed(res)) {
151
+ await this.cache.recordHeaders(res);
152
+ }
153
+ return res;
154
+ }
155
+ async getHeaderByHash(
156
+ blockHash: HexLike,
157
+ verbosity?: number | null,
158
+ ): Promise<ClientBlockHeader | undefined> {
159
+ const header = await this.cache.getHeaderByHash(blockHash);
160
+ if (header) {
161
+ return header;
162
+ }
163
+
164
+ const res = await this.getHeaderByHashNoCache(blockHash, verbosity);
165
+ if (res && hasHeaderConfirmed(res)) {
166
+ await this.cache.recordHeaders(res);
167
+ }
168
+ return res;
169
+ }
77
170
 
78
171
  abstract estimateCycles(transaction: TransactionLike): Promise<Num>;
79
172
  abstract sendTransactionDry(
@@ -97,25 +190,47 @@ export abstract class Client {
97
190
  return cached;
98
191
  }
99
192
 
100
- const transaction = await this.getTransactionNoCache(outPoint.txHash);
193
+ const transaction = await this.getTransaction(outPoint.txHash);
101
194
  if (!transaction) {
102
195
  return;
103
196
  }
104
-
105
- const index = Number(numFrom(outPoint.index));
106
- if (index >= transaction.transaction.outputs.length) {
197
+ const output = transaction.transaction.getOutput(outPoint.index);
198
+ if (!output) {
107
199
  return;
108
200
  }
109
201
 
110
202
  const cell = Cell.from({
111
203
  outPoint,
112
- cellOutput: transaction.transaction.outputs[index],
113
- outputData: transaction.transaction.outputsData[index] ?? "0x",
204
+ ...output,
114
205
  });
115
206
  await this.cache.recordCells(cell);
116
207
  return cell;
117
208
  }
118
209
 
210
+ async getCellWithHeader(
211
+ outPointLike: OutPointLike,
212
+ ): Promise<{ cell: Cell; header?: ClientBlockHeader } | undefined> {
213
+ const outPoint = OutPoint.from(outPointLike);
214
+
215
+ const res = await this.getTransactionWithHeader(outPoint.txHash);
216
+ if (!res) {
217
+ return;
218
+ }
219
+ const { transaction, header } = res;
220
+
221
+ const output = transaction.transaction.getOutput(outPoint.index);
222
+ if (!output) {
223
+ return;
224
+ }
225
+
226
+ const cell = Cell.from({
227
+ outPoint,
228
+ ...output,
229
+ });
230
+ await this.cache.recordCells(cell);
231
+ return { cell, header };
232
+ }
233
+
119
234
  abstract getCellLiveNoCache(
120
235
  outPointLike: OutPointLike,
121
236
  withData?: boolean | null,
@@ -180,6 +295,7 @@ export abstract class Client {
180
295
 
181
296
  /**
182
297
  * Find cells by search key designed for collectable cells.
298
+ * The result also includes cached cells, the order param only works for cells fetched from RPC.
183
299
  *
184
300
  * @param keyLike - The search key.
185
301
  * @returns A async generator for yielding cells.
@@ -476,14 +592,19 @@ export abstract class Client {
476
592
  async sendTransaction(
477
593
  transaction: TransactionLike,
478
594
  validator?: OutputsValidator,
595
+ options?: { maxFeeRate?: NumLike },
479
596
  ): Promise<Hex> {
480
597
  const tx = Transaction.from(transaction);
481
598
 
599
+ const maxFeeRate = numFrom(options?.maxFeeRate ?? DEFAULT_MAX_FEE_RATE);
600
+ const feeRate = await tx.getFeeRate(this);
601
+ if (maxFeeRate > Zero && feeRate > maxFeeRate) {
602
+ throw new ErrorClientMaxFeeRateExceeded(maxFeeRate, feeRate);
603
+ }
604
+
482
605
  const txHash = await this.sendTransactionNoCache(tx, validator);
483
606
 
484
- await this.cache.recordTransactions(tx);
485
607
  await this.cache.markTransactions(tx);
486
-
487
608
  return txHash;
488
609
  }
489
610
 
@@ -492,25 +613,48 @@ export abstract class Client {
492
613
  ): Promise<ClientTransactionResponse | undefined> {
493
614
  const txHash = hexFrom(txHashLike);
494
615
  const res = await this.getTransactionNoCache(txHash);
495
- if (res?.transaction) {
616
+ if (res) {
617
+ await this.cache.recordTransactionResponses(res);
496
618
  return res;
497
619
  }
498
620
 
499
- const tx = await this.cache.getTransaction(txHash);
500
- if (!tx) {
501
- return;
621
+ return this.cache.getTransactionResponse(txHash);
622
+ }
623
+
624
+ /**
625
+ * This method gets specified transaction with its block header (if existed).
626
+ * This is mainly for caching because we need the header to test if we can safely trust the cached tx status.
627
+ * @param txHashLike
628
+ */
629
+ async getTransactionWithHeader(
630
+ txHashLike: HexLike,
631
+ ): Promise<
632
+ | { transaction: ClientTransactionResponse; header?: ClientBlockHeader }
633
+ | undefined
634
+ > {
635
+ const txHash = hexFrom(txHashLike);
636
+ const tx = await this.cache.getTransactionResponse(txHash);
637
+ if (tx?.blockHash) {
638
+ const header = await this.getHeaderByHash(tx.blockHash);
639
+ if (header && hasHeaderConfirmed(header)) {
640
+ return {
641
+ transaction: tx,
642
+ header,
643
+ };
644
+ }
502
645
  }
503
646
 
647
+ const res = await this.getTransactionNoCache(txHash);
504
648
  if (!res) {
505
- return {
506
- transaction: tx,
507
- status: "sent",
508
- };
649
+ return;
509
650
  }
510
651
 
652
+ await this.cache.recordTransactionResponses(res);
511
653
  return {
512
- ...res,
513
- transaction: tx,
654
+ transaction: res,
655
+ header: res.blockHash
656
+ ? await this.getHeaderByHash(res.blockHash)
657
+ : undefined,
514
658
  };
515
659
  }
516
660
 
@@ -552,7 +696,7 @@ export abstract class Client {
552
696
  }
553
697
 
554
698
  if (Date.now() - startTime + interval >= timeout) {
555
- throw new ErrorClientWaitTransactionTimeout();
699
+ throw new ErrorClientWaitTransactionTimeout(timeout);
556
700
  }
557
701
  await sleep(interval);
558
702
  }
@@ -1,4 +1,5 @@
1
- import { KnownScript, ScriptInfoLike } from "./clientTypes.js";
1
+ import { ScriptInfoLike } from "./clientTypes.js";
2
+ import { KnownScript } from "./knownScript.js";
2
3
 
3
4
  export const MAINNET_SCRIPTS: Record<KnownScript, ScriptInfoLike | undefined> =
4
5
  Object.freeze({
@@ -1,7 +1,8 @@
1
1
  import WebSocket from "isomorphic-ws";
2
2
  import { MAINNET_SCRIPTS } from "./clientPublicMainnet.advanced.js";
3
- import { KnownScript, ScriptInfo, ScriptInfoLike } from "./clientTypes.js";
3
+ import { ScriptInfo, ScriptInfoLike } from "./clientTypes.js";
4
4
  import { ClientJsonRpc, ClientJsonRpcConfig } from "./jsonRpc/index.js";
5
+ import { KnownScript } from "./knownScript.js";
5
6
 
6
7
  /**
7
8
  * @public
@@ -28,13 +29,8 @@ export class ClientPublicMainnet extends ClientJsonRpc {
28
29
  "wss://mainnet.ckb.dev/ws",
29
30
  "https://mainnet.ckb.dev/",
30
31
  "https://mainnet.ckbapp.dev/",
31
- "https://rpc.ankr.com/nervos_ckb",
32
32
  ]
33
- : [
34
- "https://mainnet.ckb.dev/",
35
- "https://mainnet.ckbapp.dev/",
36
- "https://rpc.ankr.com/nervos_ckb",
37
- ]),
33
+ : ["https://mainnet.ckb.dev/", "https://mainnet.ckbapp.dev/"]),
38
34
  },
39
35
  );
40
36
  }
@@ -1,4 +1,5 @@
1
- import { KnownScript, ScriptInfoLike } from "./clientTypes.js";
1
+ import { ScriptInfoLike } from "./clientTypes.js";
2
+ import { KnownScript } from "./knownScript.js";
2
3
 
3
4
  export const TESTNET_SCRIPTS: Record<KnownScript, ScriptInfoLike> =
4
5
  Object.freeze({
@@ -1,7 +1,8 @@
1
1
  import WebSocket from "isomorphic-ws";
2
2
  import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced.js";
3
- import { KnownScript, ScriptInfo, ScriptInfoLike } from "./clientTypes.js";
3
+ import { ScriptInfo, ScriptInfoLike } from "./clientTypes.js";
4
4
  import { ClientJsonRpc, ClientJsonRpcConfig } from "./jsonRpc/index.js";
5
+ import { KnownScript } from "./knownScript.js";
5
6
 
6
7
  /**
7
8
  * @public
@@ -2,6 +2,10 @@ import { ScriptLike } from "../ckb/index.js";
2
2
  import { HexLike } from "../hex/index.js";
3
3
  import { Num, numFrom, NumLike } from "../num/index.js";
4
4
 
5
+ export const CONFIRMED_BLOCK_TIME = numFrom(1000 * 10 * 50); // 50 blocks * 10s
6
+ export const DEFAULT_MAX_FEE_RATE = numFrom(10000000);
7
+ export const DEFAULT_MIN_FEE_RATE = numFrom(1000);
8
+
5
9
  export function clientSearchKeyRangeFrom([a, b]: [NumLike, NumLike]): [
6
10
  Num,
7
11
  Num,