@effect-blockchain/solana 0.0.0-stage → 0.2.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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/SolanaAddress.d.ts +21 -0
  4. package/dist/SolanaAddress.d.ts.map +1 -0
  5. package/dist/SolanaAddress.js +33 -0
  6. package/dist/SolanaAddress.js.map +1 -0
  7. package/dist/SolanaIndexer.d.ts +198 -0
  8. package/dist/SolanaIndexer.d.ts.map +1 -0
  9. package/dist/SolanaIndexer.js +344 -0
  10. package/dist/SolanaIndexer.js.map +1 -0
  11. package/dist/SolanaNetwork.d.ts +64 -0
  12. package/dist/SolanaNetwork.d.ts.map +1 -0
  13. package/dist/SolanaNetwork.js +84 -0
  14. package/dist/SolanaNetwork.js.map +1 -0
  15. package/dist/SolanaRelayer.d.ts +207 -0
  16. package/dist/SolanaRelayer.d.ts.map +1 -0
  17. package/dist/SolanaRelayer.js +377 -0
  18. package/dist/SolanaRelayer.js.map +1 -0
  19. package/dist/SolanaRpc.d.ts +427 -0
  20. package/dist/SolanaRpc.d.ts.map +1 -0
  21. package/dist/SolanaRpc.js +216 -0
  22. package/dist/SolanaRpc.js.map +1 -0
  23. package/dist/SolanaSigner.d.ts +49 -0
  24. package/dist/SolanaSigner.d.ts.map +1 -0
  25. package/dist/SolanaSigner.js +82 -0
  26. package/dist/SolanaSigner.js.map +1 -0
  27. package/dist/SolanaTransactionHash.d.ts +14 -0
  28. package/dist/SolanaTransactionHash.d.ts.map +1 -0
  29. package/dist/SolanaTransactionHash.js +34 -0
  30. package/dist/SolanaTransactionHash.js.map +1 -0
  31. package/dist/index.d.ts +32 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +33 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/internal/bigIntJson.d.ts +2 -0
  36. package/dist/internal/bigIntJson.d.ts.map +1 -0
  37. package/dist/internal/bigIntJson.js +9 -0
  38. package/dist/internal/bigIntJson.js.map +1 -0
  39. package/dist/internal/confirmations.d.ts +2 -0
  40. package/dist/internal/confirmations.d.ts.map +1 -0
  41. package/dist/internal/confirmations.js +15 -0
  42. package/dist/internal/confirmations.js.map +1 -0
  43. package/dist/internal/rpcMethods.d.ts +2 -0
  44. package/dist/internal/rpcMethods.d.ts.map +1 -0
  45. package/dist/internal/rpcMethods.js +223 -0
  46. package/dist/internal/rpcMethods.js.map +1 -0
  47. package/package.json +66 -3
  48. package/src/SolanaAddress.ts +40 -0
  49. package/src/SolanaIndexer.ts +552 -0
  50. package/src/SolanaNetwork.ts +105 -0
  51. package/src/SolanaRelayer.ts +493 -0
  52. package/src/SolanaRpc.ts +595 -0
  53. package/src/SolanaSigner.ts +98 -0
  54. package/src/SolanaTransactionHash.ts +41 -0
  55. package/src/index.ts +40 -0
  56. package/src/internal/bigIntJson.ts +18 -0
  57. package/src/internal/confirmations.ts +17 -0
  58. package/src/internal/rpcMethods.ts +260 -0
@@ -0,0 +1,377 @@
1
+ /**
2
+ * Solana transaction relaying on top of {@link SolanaRpc.SolanaRpc}: signing a transaction, broadcasting it and
3
+ * following it until it is final.
4
+ *
5
+ * A relayer here sends an account's own transactions and manages their fees, as OpenZeppelin Relayer does. It is not
6
+ * a meta-transaction relayer paying for someone else's transaction. It keeps no state: storing signatures and their
7
+ * `lastValidBlockHeight`, deciding when to resend and holding keys belong to the application. Solana has no nonce:
8
+ * the recent blockhash plays that role, so concurrent senders from one address need no coordination, but two
9
+ * transactions with the same instructions, signers, fees and blockhash are one transaction and land once.
10
+ *
11
+ * Only v0 transactions with a recent blockhash are sent: address lookup tables and durable nonces are not. `sign`
12
+ * returns the transaction's signature before anything is broadcast, so it can be stored first, and `broadcast` can be
13
+ * repeated with the same bytes.
14
+ *
15
+ * Every transaction starts with the two Compute Budget instructions. Unless `sign` receives them, the compute unit
16
+ * limit is what a simulation consumed times the layer's `computeUnitMultiplier`, and the compute unit price comes from
17
+ * `getRecentPrioritizationFees` for the accounts the transaction writes to (see {@link defaultFees}). The price sets
18
+ * the priority fee only: the base fee of 5000 lamports per signature is charged on top.
19
+ *
20
+ * A transaction is in one {@link SolanaTransactionStatus}:
21
+ *
22
+ * | status | meaning | final |
23
+ * |---|---|---|
24
+ * | `Pending` | never reported: a node does not expose the transactions it has not processed | no |
25
+ * | `Included` | in `block`, not finalized or above the last confirmed slot: a fork can still drop it | no |
26
+ * | `Confirmed` | succeeded in `block`, finalized, at or below the last confirmed slot | yes |
27
+ * | `Failed` | failed in `block`, finalized, at or below the last confirmed slot: it paid its fee | yes |
28
+ * | `Expired` | unknown to the node, and its blockhash expired: it can no longer land | yes |
29
+ * | `NotFound` | unknown to the node: not processed yet, dropped, or never sent | no |
30
+ *
31
+ * A node reports a transaction as soon as it has processed its block, then the block reaches the `confirmed`
32
+ * commitment (voted by a supermajority) and the `finalized` one. `processed` and `confirmed` are both `Included`:
33
+ * the `Confirmed` status is not the `confirmed` commitment. A `finalized` transaction is `Confirmed` or `Failed` once
34
+ * its slot is at or below the last confirmed slot, the finalized slot minus `confirmations` (0 by default), as
35
+ * `SolanaIndexer.lastConfirmedBlock`.
36
+ *
37
+ * A transaction can land only while the block height is at most the `lastValidBlockHeight` returned with its recent
38
+ * blockhash. `Expired` is reported when the caller passes that height and the `finalized` block height is above it,
39
+ * so a transaction that can still land is never `Expired`. A durable-nonce transaction does not expire: leave
40
+ * `lastValidBlockHeight` out.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { type SolanaInstruction, SolanaRelayer } from "@effect-blockchain/solana/SolanaRelayer"
45
+ * import type { SolanaSigner } from "@effect-blockchain/solana/SolanaSigner"
46
+ * import type { SolanaTransactionHash } from "@effect-blockchain/solana/SolanaTransactionHash"
47
+ * import * as Effect from "effect/Effect"
48
+ *
49
+ * declare const feePayer: SolanaSigner
50
+ * declare const instructions: ReadonlyArray<SolanaInstruction>
51
+ * declare const store: (hash: SolanaTransactionHash, lastValidBlockHeight: bigint) => Effect.Effect<void>
52
+ *
53
+ * const program = Effect.gen(function*() {
54
+ * const relayer = yield* SolanaRelayer
55
+ * const { hash, lastValidBlockHeight, signed } = yield* relayer.sign({ feePayer, instructions })
56
+ * // stored before the broadcast: a crash in between leaves a signature to look up, never an unknown transaction
57
+ * yield* store(hash, lastValidBlockHeight)
58
+ * yield* relayer.broadcast({ signed })
59
+ * // a lagging endpoint can answer `NotFound` for a while: the timeout bounds the wait
60
+ * const status = yield* relayer.awaitConfirmation({ hash, lastValidBlockHeight }).pipe(Effect.timeout("5 minutes"))
61
+ * if (status._tag === "Failed") {
62
+ * yield* Effect.logError(`failed in slot ${status.block}`, status.reason)
63
+ * }
64
+ * if (status._tag === "Expired") {
65
+ * yield* Effect.logError("never landed: sign it again with a new blockhash")
66
+ * }
67
+ * })
68
+ * ```
69
+ *
70
+ * @since 0.2.0
71
+ */
72
+ import { AccountRole, address, appendTransactionMessageInstructions, assertIsSignatureBytes, blockhash, compileTransaction, createTransactionMessage, getBase64EncodedWireTransaction, getBase64Encoder, getSignatureFromTransaction, getTransactionDecoder, pipe, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE } from "@solana/kit";
73
+ import * as Arr from "effect/Array";
74
+ import * as BigInt_ from "effect/BigInt";
75
+ import * as Context from "effect/Context";
76
+ import * as Effect from "effect/Effect";
77
+ import * as Layer from "effect/Layer";
78
+ import * as Order from "effect/Order";
79
+ import * as Schedule from "effect/Schedule";
80
+ import * as Schema from "effect/Schema";
81
+ import * as Confirmations from "./internal/confirmations.js";
82
+ import * as RpcMethods from "./internal/rpcMethods.js";
83
+ import { SolanaAddress } from "./SolanaAddress.js";
84
+ import { DEFAULT_POLL_INTERVAL } from "./SolanaIndexer.js";
85
+ import * as SolanaRpc from "./SolanaRpc.js";
86
+ import { SolanaSignerError } from "./SolanaSigner.js";
87
+ import { SolanaTransactionHash } from "./SolanaTransactionHash.js";
88
+ /**
89
+ * The node does not know the transaction's blockhash: it has expired, or the node is behind the one that returned
90
+ * it. Past `lastValidBlockHeight`, sign the transaction again.
91
+ *
92
+ * @since 0.2.0
93
+ * @category reasons
94
+ */
95
+ export class BlockhashNotFound extends /*#__PURE__*/Schema.TaggedError()("BlockhashNotFound", {}) {}
96
+ /**
97
+ * The fee payer cannot pay the transaction fee: its balance is too low, or it holds no account.
98
+ *
99
+ * @since 0.2.0
100
+ * @category reasons
101
+ */
102
+ export class InsufficientFundsForFee extends /*#__PURE__*/Schema.TaggedError()("InsufficientFundsForFee", {}) {}
103
+ const TransactionError = /*#__PURE__*/Schema.toType(RpcMethods.TransactionError);
104
+ /**
105
+ * The node simulated the transaction and it failed: `error` is the transaction error and `logs` the program logs up
106
+ * to it. {@link SolanaRelayer.sign} fails with it when it estimates the compute unit limit.
107
+ *
108
+ * @since 0.2.0
109
+ * @category reasons
110
+ */
111
+ export class SimulationFailed extends /*#__PURE__*/Schema.TaggedError()("SimulationFailed", {
112
+ error: TransactionError,
113
+ logs: /*#__PURE__*/Schema.Array(Schema.String)
114
+ }) {}
115
+ /**
116
+ * Why a node refused a transaction, the `reason` of a {@link SolanaBroadcastError}, matched with `Effect.catchReason`.
117
+ *
118
+ * @since 0.2.0
119
+ * @category reasons
120
+ */
121
+ export const SolanaBroadcastReason = /*#__PURE__*/Schema.Union([BlockhashNotFound, InsufficientFundsForFee, SimulationFailed]);
122
+ /**
123
+ * A node refused the transaction at its preflight simulation for a `reason` the sender can act on: `cause` is the
124
+ * {@link SolanaRpc.SolanaRpcError} holding the node's message. Any other refusal stays a `SolanaRpcError`.
125
+ *
126
+ * @since 0.2.0
127
+ * @category errors
128
+ */
129
+ export class SolanaBroadcastError extends /*#__PURE__*/Schema.TaggedError()("SolanaBroadcastError", {
130
+ reason: SolanaBroadcastReason,
131
+ cause: /*#__PURE__*/Schema.Defect()
132
+ }) {}
133
+ /**
134
+ * @since 0.2.0
135
+ * @category services
136
+ */
137
+ export class SolanaRelayer extends /*#__PURE__*/Context.Service()("@effect-blockchain/solana/SolanaRelayer") {}
138
+ // a slot reports the lowest price that landed in it, 0 as soon as one transaction paid none: any price above 0 is
139
+ // ordered before those transactions
140
+ const PRIORITY_FEE_FLOOR = /*#__PURE__*/BigInt(1);
141
+ /**
142
+ * The library's fee strategy: the compute unit price is the 75th percentile of the recent slots' prioritization fees,
143
+ * at least 1 micro-lamport.
144
+ *
145
+ * @since 0.2.0
146
+ * @category fees
147
+ */
148
+ export const defaultFees = fees => {
149
+ const sorted = Arr.sort(fees.map(({
150
+ prioritizationFee
151
+ }) => prioritizationFee), Order.BigInt);
152
+ return BigInt_.max(sorted[Math.floor(sorted.length * 0.75)] ?? PRIORITY_FEE_FLOOR, PRIORITY_FEE_FLOOR);
153
+ };
154
+ const COMPUTE_BUDGET_PROGRAM = /*#__PURE__*/SolanaAddress.make("ComputeBudget111111111111111111111111111111");
155
+ // the most a transaction can ask for, and what the simulation runs with
156
+ const MAX_COMPUTE_UNITS = 1_400_000;
157
+ // `getRecentPrioritizationFees` takes at most 128 addresses
158
+ const MAX_FEE_ADDRESSES = 128;
159
+ // `SetComputeUnitLimit` (discriminator 2, u32) and `SetComputeUnitPrice` (discriminator 3, u64), little-endian
160
+ const computeBudget = (limit, price) => {
161
+ const unitLimit = new DataView(new ArrayBuffer(5));
162
+ unitLimit.setUint8(0, 2);
163
+ unitLimit.setUint32(1, limit, true);
164
+ const unitPrice = new DataView(new ArrayBuffer(9));
165
+ unitPrice.setUint8(0, 3);
166
+ unitPrice.setBigUint64(1, price, true);
167
+ return [{
168
+ programAddress: COMPUTE_BUDGET_PROGRAM,
169
+ data: new Uint8Array(unitLimit.buffer)
170
+ }, {
171
+ programAddress: COMPUTE_BUDGET_PROGRAM,
172
+ data: new Uint8Array(unitPrice.buffer)
173
+ }];
174
+ };
175
+ const roleOf = ({
176
+ signer = false,
177
+ writable = false
178
+ }) => signer ? writable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER : writable ? AccountRole.WRITABLE : AccountRole.READONLY;
179
+ const compile = (feePayer, lifetime, instructions) => Effect.try({
180
+ try: () => compileTransaction(pipe(createTransactionMessage({
181
+ version: 0
182
+ }), message => setTransactionMessageFeePayer(address(feePayer), message), message => setTransactionMessageLifetimeUsingBlockhash({
183
+ blockhash: blockhash(lifetime.blockhash),
184
+ lastValidBlockHeight: lifetime.lastValidBlockHeight
185
+ }, message), message => appendTransactionMessageInstructions(instructions.map(({
186
+ accounts = [],
187
+ data,
188
+ programAddress
189
+ }) => ({
190
+ programAddress: address(programAddress),
191
+ accounts: accounts.map(account => ({
192
+ address: address(account.address),
193
+ role: roleOf(account)
194
+ })),
195
+ ...(data === undefined ? {} : {
196
+ data
197
+ })
198
+ })), message))),
199
+ catch: cause => new SolanaSignerError({
200
+ cause
201
+ })
202
+ });
203
+ /**
204
+ * Builds a {@link SolanaRelayer} over the provided {@link SolanaRpc.SolanaRpc}. `confirmations` overrides the
205
+ * network's default, as in `SolanaIndexer.layer`: both agree on the last confirmed slot. `fees` (default
206
+ * {@link defaultFees}) prices the transactions signed without a compute unit price, and `computeUnitMultiplier`
207
+ * (default 1.2) is the margin applied to a simulated compute unit limit.
208
+ *
209
+ * @since 0.2.0
210
+ * @category layers
211
+ */
212
+ export const layer = (options = {}) => Layer.effect(SolanaRelayer, Effect.gen(function* () {
213
+ const rpc = yield* SolanaRpc.SolanaRpc;
214
+ const sign = Effect.fn("SolanaRelayer.sign")(function* ({
215
+ feePayer,
216
+ instructions,
217
+ signers = [],
218
+ ...given
219
+ }) {
220
+ const writable = Arr.dedupe([feePayer.address, ...instructions.flatMap(({
221
+ accounts = []
222
+ }) => accounts.filter(account => account.writable === true).map(account => account.address))]);
223
+ const {
224
+ lifetime,
225
+ price
226
+ } = yield* Effect.all({
227
+ lifetime: given.blockhash === undefined ? rpc.getLatestBlockhash({
228
+ commitment: "confirmed"
229
+ }) : Effect.succeed(given.blockhash),
230
+ price: given.computeUnitPrice === undefined ? Effect.map(rpc.getRecentPrioritizationFees({
231
+ addresses: writable.slice(0, MAX_FEE_ADDRESSES)
232
+ }), options.fees ?? defaultFees) : Effect.succeed(given.computeUnitPrice)
233
+ }, {
234
+ concurrency: "unbounded"
235
+ });
236
+ const build = limit => compile(feePayer.address, lifetime, [...computeBudget(limit, price), ...instructions]);
237
+ const estimate = Effect.gen(function* () {
238
+ const simulation = yield* rpc.simulateTransaction({
239
+ transaction: getBase64EncodedWireTransaction(yield* build(MAX_COMPUTE_UNITS)),
240
+ commitment: "confirmed",
241
+ sigVerify: false,
242
+ replaceRecentBlockhash: true
243
+ });
244
+ if (simulation.err !== null) {
245
+ return yield* new SimulationFailed({
246
+ error: simulation.err,
247
+ logs: simulation.logs ?? []
248
+ });
249
+ }
250
+ const units = Number(simulation.unitsConsumed ?? MAX_COMPUTE_UNITS);
251
+ return Math.min(MAX_COMPUTE_UNITS, Math.ceil(units * (options.computeUnitMultiplier ?? 1.2)));
252
+ });
253
+ const compiled = yield* build(given.computeUnitLimit ?? (yield* estimate));
254
+ const message = Uint8Array.from(compiled.messageBytes);
255
+ const required = Object.keys(compiled.signatures);
256
+ const signatures = yield* Effect.forEach(required, account => {
257
+ const signer = [feePayer, ...signers].find(signer => signer.address === account);
258
+ return signer === undefined ? Effect.fail(new SolanaSignerError({
259
+ cause: new Error(`no signer for ${account}`)
260
+ })) : Effect.flatMap(signer.signTransactionMessage(message), signature => Effect.try({
261
+ try: () => {
262
+ assertIsSignatureBytes(signature);
263
+ return signature;
264
+ },
265
+ catch: cause => new SolanaSignerError({
266
+ cause
267
+ })
268
+ }));
269
+ }, {
270
+ concurrency: "unbounded"
271
+ });
272
+ const transaction = {
273
+ ...compiled,
274
+ signatures: Object.fromEntries(Arr.zip(required, signatures))
275
+ };
276
+ return {
277
+ hash: SolanaTransactionHash.make(getSignatureFromTransaction(transaction)),
278
+ signed: getBase64EncodedWireTransaction(transaction),
279
+ lastValidBlockHeight: lifetime.lastValidBlockHeight
280
+ };
281
+ });
282
+ const broadcast = Effect.fn("SolanaRelayer.broadcast")(function* ({
283
+ signed
284
+ }) {
285
+ // the blockhash is read at `confirmed`: a preflight at the default `finalized` would not know it yet
286
+ const sent = yield* Effect.result(rpc.sendTransaction({
287
+ transaction: signed,
288
+ preflightCommitment: "confirmed"
289
+ }));
290
+ if (sent._tag === "Success") return sent.success;
291
+ const cause = sent.failure;
292
+ if (cause.code !== SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE) {
293
+ return yield* cause;
294
+ }
295
+ // the JSON-RPC error only carries a message: the simulation run again returns the transaction error
296
+ const {
297
+ err,
298
+ logs
299
+ } = yield* rpc.simulateTransaction({
300
+ transaction: signed,
301
+ commitment: "confirmed",
302
+ sigVerify: true
303
+ });
304
+ if (err === null) return yield* cause;
305
+ if (err === "AlreadyProcessed") {
306
+ return SolanaTransactionHash.make(getSignatureFromTransaction(getTransactionDecoder().decode(getBase64Encoder().encode(signed))));
307
+ }
308
+ const reason = err === "BlockhashNotFound" ? new BlockhashNotFound()
309
+ // `AccountNotFound` is the fee payer's: the only account a transaction needs to exist
310
+ : err === "InsufficientFundsForFee" || err === "AccountNotFound" ? new InsufficientFundsForFee() : new SimulationFailed({
311
+ error: err,
312
+ logs: logs ?? []
313
+ });
314
+ return yield* new SolanaBroadcastError({
315
+ reason,
316
+ cause
317
+ });
318
+ });
319
+ const fetchTransactionStatus = Effect.fn("SolanaRelayer.fetchTransactionStatus")(function* ({
320
+ hash,
321
+ lastValidBlockHeight
322
+ }) {
323
+ // read before the status: once the finalized height has passed `lastValidBlockHeight`, a block holding the
324
+ // transaction is finalized too, and the status read that follows finds it
325
+ const expired = lastValidBlockHeight !== undefined && (yield* rpc.getBlockHeight({
326
+ commitment: "finalized"
327
+ })) > lastValidBlockHeight;
328
+ // the node's status cache only covers recent slots: without the history, an old transaction would be unknown
329
+ const {
330
+ value
331
+ } = yield* rpc.getSignatureStatuses({
332
+ signatures: [hash],
333
+ searchTransactionHistory: true
334
+ });
335
+ const status = value[0] ?? null;
336
+ if (status === null) return expired ? {
337
+ _tag: "Expired"
338
+ } : {
339
+ _tag: "NotFound"
340
+ };
341
+ const block = status.slot;
342
+ if (status.confirmationStatus !== "finalized") return {
343
+ _tag: "Included",
344
+ block
345
+ };
346
+ // read after the status: a finalized slot older than the transaction's could only delay `Confirmed`
347
+ if (block > (yield* Confirmations.lastConfirmedBlock(rpc, options.confirmations))) {
348
+ return {
349
+ _tag: "Included",
350
+ block
351
+ };
352
+ }
353
+ return status.err === null ? {
354
+ _tag: "Confirmed",
355
+ block
356
+ } : {
357
+ _tag: "Failed",
358
+ block,
359
+ reason: status.err
360
+ };
361
+ });
362
+ return SolanaRelayer.of({
363
+ sign,
364
+ broadcast,
365
+ fetchTransactionStatus,
366
+ awaitConfirmation: ({
367
+ poll = Schedule.spaced(DEFAULT_POLL_INTERVAL),
368
+ ...transaction
369
+ }) => fetchTransactionStatus(transaction).pipe(Effect.repeat({
370
+ schedule: poll,
371
+ until: ({
372
+ _tag
373
+ }) => _tag === "Confirmed" || _tag === "Failed" || _tag === "Expired"
374
+ }), Effect.withSpan("SolanaRelayer.awaitConfirmation"))
375
+ });
376
+ }));
377
+ //# sourceMappingURL=SolanaRelayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolanaRelayer.js","names":[],"sources":["../src/SolanaRelayer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SACE,WAAW,EACX,OAAO,EACP,oCAAoC,EACpC,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EAClB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,IAAI,EACJ,6BAA6B,EAC7B,2CAA2C,EAC3C,uEAAuE,QAClE,aAAa;AACpB,OAAO,KAAK,G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