@bsv/wallet-toolbox 1.6.2 → 1.6.3

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 (59) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/docs/client.md +315 -2500
  3. package/docs/services.md +15 -4
  4. package/docs/wallet.md +315 -2500
  5. package/mobile/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
  6. package/mobile/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +1 -2
  7. package/mobile/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
  8. package/mobile/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
  9. package/mobile/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +2 -3
  10. package/mobile/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
  11. package/mobile/package-lock.json +2 -2
  12. package/mobile/package.json +1 -1
  13. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
  14. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +1 -2
  15. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
  16. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
  17. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +2 -3
  18. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
  19. package/out/src/storage/__test/getBeefForTransaction.test.js.map +1 -1
  20. package/out/test/storage/idb/update.test.js +1 -1
  21. package/out/test/storage/idb/update.test.js.map +1 -1
  22. package/out/tsconfig.all.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.ts +1 -2
  25. package/src/services/chaintracker/chaintracks/util/BulkFileDataManager.ts +2 -3
  26. package/src/storage/__test/getBeefForTransaction.test.ts +2 -5
  27. package/test/storage/idb/update.test.ts +1 -1
  28. package/mobile/out/src/Setup.d.ts +0 -267
  29. package/mobile/out/src/Setup.d.ts.map +0 -1
  30. package/mobile/out/src/Setup.js +0 -408
  31. package/mobile/out/src/Setup.js.map +0 -1
  32. package/mobile/out/src/storage/StorageKnex.d.ts +0 -179
  33. package/mobile/out/src/storage/StorageKnex.d.ts.map +0 -1
  34. package/mobile/out/src/storage/StorageKnex.js +0 -1215
  35. package/mobile/out/src/storage/StorageKnex.js.map +0 -1
  36. package/mobile/out/src/storage/methods/listActionsKnex.d.ts +0 -6
  37. package/mobile/out/src/storage/methods/listActionsKnex.d.ts.map +0 -1
  38. package/mobile/out/src/storage/methods/listActionsKnex.js +0 -198
  39. package/mobile/out/src/storage/methods/listActionsKnex.js.map +0 -1
  40. package/mobile/out/src/storage/methods/listOutputsKnex.d.ts +0 -6
  41. package/mobile/out/src/storage/methods/listOutputsKnex.d.ts.map +0 -1
  42. package/mobile/out/src/storage/methods/listOutputsKnex.js +0 -241
  43. package/mobile/out/src/storage/methods/listOutputsKnex.js.map +0 -1
  44. package/mobile/out/src/storage/methods/purgeData.d.ts +0 -4
  45. package/mobile/out/src/storage/methods/purgeData.d.ts.map +0 -1
  46. package/mobile/out/src/storage/methods/purgeData.js +0 -207
  47. package/mobile/out/src/storage/methods/purgeData.js.map +0 -1
  48. package/mobile/out/src/storage/methods/reviewStatus.d.ts +0 -20
  49. package/mobile/out/src/storage/methods/reviewStatus.d.ts.map +0 -1
  50. package/mobile/out/src/storage/methods/reviewStatus.js +0 -84
  51. package/mobile/out/src/storage/methods/reviewStatus.js.map +0 -1
  52. package/mobile/out/src/storage/schema/KnexMigrations.d.ts +0 -39
  53. package/mobile/out/src/storage/schema/KnexMigrations.d.ts.map +0 -1
  54. package/mobile/out/src/storage/schema/KnexMigrations.js +0 -410
  55. package/mobile/out/src/storage/schema/KnexMigrations.js.map +0 -1
  56. package/mobile/out/test/utils/TestUtilsWalletStorage.d.ts +0 -522
  57. package/mobile/out/test/utils/TestUtilsWalletStorage.d.ts.map +0 -1
  58. package/mobile/out/test/utils/TestUtilsWalletStorage.js +0 -1956
  59. package/mobile/out/test/utils/TestUtilsWalletStorage.js.map +0 -1
@@ -1,207 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.purgeData = purgeData;
4
- const sdk_1 = require("@bsv/sdk");
5
- const WalletError_1 = require("../../sdk/WalletError");
6
- async function purgeData(storage, params, trx) {
7
- const r = { count: 0, log: '' };
8
- const defaultAge = 1000 * 60 * 60 * 24 * 14;
9
- const runPurgeQuery = async (pq) => {
10
- try {
11
- pq.sql = pq.q.toString();
12
- const count = await pq.q;
13
- if (count > 0) {
14
- r.count += count;
15
- r.log += `${count} ${pq.log}\n`;
16
- }
17
- }
18
- catch (eu) {
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- const e = WalletError_1.WalletError.fromUnknown(eu);
21
- throw eu;
22
- }
23
- };
24
- if (params.purgeCompleted) {
25
- const age = params.purgeCompletedAge || defaultAge;
26
- const before = toSqlWhereDate(new Date(Date.now() - age));
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- const qs = [];
29
- // select * from transactions where updated_at < '2024-08-20' and status = 'completed' and not provenTxId is null and (not truncatedExternalInputs is null or not beef is null or not rawTx is null)
30
- qs.push({
31
- log: 'conpleted transactions purged of transient data',
32
- q: storage
33
- .toDb(trx)('transactions')
34
- .update({
35
- inputBEEF: null,
36
- rawTx: null
37
- })
38
- .where('updated_at', '<', before)
39
- .where('status', 'completed')
40
- .whereNotNull('provenTxId')
41
- .where(function () {
42
- this.orWhereNotNull('inputBEEF');
43
- this.orWhereNotNull('rawTx');
44
- })
45
- });
46
- const completedReqs = await storage
47
- .toDb(trx)('proven_tx_reqs')
48
- .select('provenTxReqId')
49
- .where('updated_at', '<', before)
50
- .where('status', 'completed')
51
- .whereNotNull('provenTxId')
52
- .where('notified', 1);
53
- const completedReqIds = completedReqs.map(o => o.provenTxReqId);
54
- if (completedReqIds.length > 0) {
55
- qs.push({
56
- log: 'completed proven_tx_reqs deleted',
57
- q: storage.toDb(trx)('proven_tx_reqs').whereIn('provenTxReqId', completedReqIds).delete()
58
- });
59
- }
60
- for (const q of qs)
61
- await runPurgeQuery(q);
62
- }
63
- if (params.purgeFailed) {
64
- const age = params.purgeFailedAge || defaultAge;
65
- const before = toSqlWhereDate(new Date(Date.now() - age));
66
- const qs = [];
67
- const failedTxsQ = storage
68
- .toDb(trx)('transactions')
69
- .select('transactionId')
70
- .where('updated_at', '<', before)
71
- .where('status', 'failed');
72
- const txs = await failedTxsQ;
73
- const failedTxIds = txs.map(tx => tx.transactionId);
74
- await deleteTransactions(failedTxIds, qs, 'failed', true);
75
- const invalidReqs = await storage
76
- .toDb(trx)('proven_tx_reqs')
77
- .select('provenTxReqId')
78
- .where('updated_at', '<', before)
79
- .where('status', 'invalid');
80
- const invalidReqIds = invalidReqs.map(o => o.provenTxReqId);
81
- if (invalidReqIds.length > 0)
82
- qs.push({
83
- log: 'invalid proven_tx_reqs deleted',
84
- q: storage.toDb(trx)('proven_tx_reqs').whereIn('provenTxReqId', invalidReqIds).delete()
85
- });
86
- const doubleSpendReqs = await storage
87
- .toDb(trx)('proven_tx_reqs')
88
- .select('provenTxReqId')
89
- .where('updated_at', '<', before)
90
- .where('status', 'doubleSpend');
91
- const doubleSpendReqIds = doubleSpendReqs.map(o => o.provenTxReqId);
92
- if (doubleSpendReqIds.length > 0)
93
- qs.push({
94
- log: 'doubleSpend proven_tx_reqs deleted',
95
- q: storage.toDb(trx)('proven_tx_reqs').whereIn('provenTxReqId', doubleSpendReqIds).delete()
96
- });
97
- for (const q of qs)
98
- await runPurgeQuery(q);
99
- }
100
- if (params.purgeSpent) {
101
- const age = params.purgeSpentAge || defaultAge;
102
- const before = toSqlWhereDate(new Date(Date.now() - age));
103
- const beef = new sdk_1.Beef();
104
- const utxos = await storage.findOutputs({
105
- partial: { spendable: true },
106
- txStatus: ['sending', 'unproven', 'completed', 'nosend']
107
- });
108
- for (const utxo of utxos) {
109
- // Figure out all the txids required to prove the validity of this utxo and merge proofs into beef.
110
- const options = {
111
- mergeToBeef: beef,
112
- ignoreServices: true
113
- };
114
- if (utxo.txid)
115
- await storage.getBeefForTransaction(utxo.txid, options);
116
- }
117
- const proofTxids = {};
118
- for (const btx of beef.txs)
119
- proofTxids[btx.txid] = true;
120
- let qs = [];
121
- const spentTxsQ = storage
122
- .toDb(trx)('transactions')
123
- .where('updated_at', '<', before)
124
- .where('status', 'completed')
125
- .whereRaw(`not exists(select outputId from outputs as o where o.transactionId = transactions.transactionId and o.spendable = 1)`);
126
- const txs = await spentTxsQ;
127
- // Save any spent txid still needed to prove a utxo:
128
- const nptxs = txs.filter(t => !proofTxids[t.txid || '']);
129
- let spentTxIds = nptxs.map(tx => tx.transactionId);
130
- if (spentTxIds.length > 0) {
131
- const update = {
132
- spentBy: null
133
- };
134
- qs.push({
135
- log: 'spent outputs no longer tracked by spentBy',
136
- q: storage
137
- .toDb(trx)('outputs')
138
- .update(storage.validatePartialForUpdate(update, undefined, ['spendable']))
139
- .where('spendable', false)
140
- .whereIn('spentBy', spentTxIds)
141
- });
142
- await deleteTransactions(spentTxIds, qs, 'spent', false);
143
- for (const q of qs)
144
- await runPurgeQuery(q);
145
- }
146
- }
147
- // Delete proven_txs no longer referenced by remaining transactions.
148
- const qs = [];
149
- qs.push({
150
- log: 'orphan proven_txs deleted',
151
- q: storage
152
- .toDb(trx)('proven_txs')
153
- .whereRaw(`not exists(select * from transactions as t where t.txid = proven_txs.txid or t.provenTxId = proven_txs.provenTxId)`)
154
- .whereRaw(`not exists(select * from proven_tx_reqs as r where r.txid = proven_txs.txid or r.provenTxId = proven_txs.provenTxId)`)
155
- .delete()
156
- });
157
- for (const q of qs)
158
- await runPurgeQuery(q);
159
- return r;
160
- async function deleteTransactions(transactionIds, qs, reason, markNotSpentBy) {
161
- if (transactionIds.length > 0) {
162
- const outputs = await storage
163
- .toDb(trx)('outputs')
164
- .select('outputId')
165
- .whereIn('transactionId', transactionIds);
166
- const outputIds = outputs.map(o => o.outputId);
167
- if (outputIds.length > 0) {
168
- qs.push({
169
- log: `${reason} output_tags_map deleted`,
170
- q: storage.toDb(trx)('output_tags_map').whereIn('outputId', outputIds).delete()
171
- });
172
- qs.push({
173
- log: `${reason} outputs deleted`,
174
- q: storage.toDb(trx)('outputs').whereIn('outputId', outputIds).delete()
175
- });
176
- }
177
- qs.push({
178
- log: `${reason} tx_labels_map deleted`,
179
- q: storage.toDb(trx)('tx_labels_map').whereIn('transactionId', transactionIds).delete()
180
- });
181
- qs.push({
182
- log: `${reason} commissions deleted`,
183
- q: storage.toDb(trx)('commissions').whereIn('transactionId', transactionIds).delete()
184
- });
185
- if (markNotSpentBy) {
186
- qs.push({
187
- log: 'unspent outputs updated to spendable',
188
- q: storage
189
- .toDb(trx)('outputs')
190
- .update({ spendable: true, spentBy: null })
191
- .whereIn('spentBy', transactionIds)
192
- });
193
- }
194
- qs.push({
195
- log: `${reason} transactions deleted`,
196
- q: storage.toDb(trx)('transactions').whereIn('transactionId', transactionIds).delete()
197
- });
198
- }
199
- }
200
- }
201
- function toSqlWhereDate(d) {
202
- let s = d.toISOString();
203
- s = s.replace('T', ' ');
204
- s = s.replace('Z', '');
205
- return s;
206
- }
207
- //# sourceMappingURL=purgeData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"purgeData.js","sourceRoot":"","sources":["../../../../../src/storage/methods/purgeData.ts"],"names":[],"mappings":";;AAWA,8BAkOC;AA7OD,kCAA+B;AAI/B,uDAAmD;AAO5C,KAAK,UAAU,SAAS,CAAC,OAAoB,EAAE,MAAmB,EAAE,GAAc;IACvF,MAAM,CAAC,GAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAA;IAC7C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,E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AAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACtB,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -1,20 +0,0 @@
1
- import { StorageKnex } from '../StorageKnex';
2
- import { TrxToken } from '../../sdk/WalletStorage.interfaces';
3
- /**
4
- * Looks for unpropagated state:
5
- *
6
- * 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
7
- * 2. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
8
- * 3. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
9
- *
10
- * @param storage
11
- * @param args
12
- * @returns
13
- */
14
- export declare function reviewStatus(storage: StorageKnex, args: {
15
- agedLimit: Date;
16
- trx?: TrxToken;
17
- }): Promise<{
18
- log: string;
19
- }>;
20
- //# sourceMappingURL=reviewStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reviewStatus.d.ts","sourceRoot":"","sources":["../../../../../src/storage/methods/reviewStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAK7D;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,QAAQ,CAAA;CAAE,GACxC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAyE1B"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reviewStatus = reviewStatus;
4
- const WalletError_1 = require("../../sdk/WalletError");
5
- /**
6
- * Looks for unpropagated state:
7
- *
8
- * 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
9
- * 2. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
10
- * 3. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
11
- *
12
- * @param storage
13
- * @param args
14
- * @returns
15
- */
16
- async function reviewStatus(storage, args) {
17
- const r = { log: '' };
18
- const runReviewStatusQuery = async (pq) => {
19
- try {
20
- pq.sql = pq.q.toString();
21
- const count = await pq.q;
22
- if (count > 0) {
23
- r.log += `${count} ${pq.log}\n`;
24
- }
25
- }
26
- catch (eu) {
27
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
- const e = WalletError_1.WalletError.fromUnknown(eu);
29
- throw eu;
30
- }
31
- };
32
- const k = storage.toDb(args.trx);
33
- const qs = [];
34
- qs.push({
35
- log: `transactions updated to status of 'failed' where provenTxReq with matching txid is 'invalid'`,
36
- /*
37
- UPDATE transactions SET status = 'failed'
38
- WHERE exists(select 1 from proven_tx_reqs as r where transactions.txid = r.txid and r.status = 'invalid')
39
- */
40
- q: k('transactions')
41
- .update({ status: 'failed' })
42
- .whereNot({ status: 'failed' })
43
- .whereExists(function () {
44
- this.select(k.raw(1))
45
- .from('proven_tx_reqs as r')
46
- .whereRaw(`transactions.txid = r.txid and r.status = 'invalid'`);
47
- })
48
- });
49
- qs.push({
50
- log: `outputs updated to spendable where spentBy is a transaction with status 'failed'`,
51
- /*
52
- UPDATE outputs SET spentBy = null, spendable = 1
53
- where exists(select 1 from transactions as t where outputs.spentBy = t.transactionId and t.status = 'failed')
54
- */
55
- q: k('outputs')
56
- .update({ spentBy: null, spendable: true })
57
- .whereExists(function () {
58
- this.select(k.raw(1))
59
- .from('transactions as t')
60
- .whereRaw(`outputs.spentBy = t.transactionId and t.status = 'failed'`);
61
- })
62
- });
63
- qs.push({
64
- log: `transactions updated with provenTxId and status of 'completed' where provenTx with matching txid exists`,
65
- /*
66
- UPDATE transactions SET status = 'completed', provenTxId = p.provenTxId
67
- FROM proven_txs p
68
- WHERE transactions.txid = p.txid AND transactions.provenTxId IS NULL
69
- */
70
- q: k('transactions')
71
- .update({
72
- status: 'completed',
73
- provenTxId: k.raw('(SELECT provenTxId FROM proven_txs AS p WHERE transactions.txid = p.txid)')
74
- })
75
- .whereNull('provenTxId')
76
- .whereExists(function () {
77
- this.select(k.raw(1)).from('proven_txs as p').whereRaw('transactions.txid = p.txid');
78
- })
79
- });
80
- for (const q of qs)
81
- await runReviewStatusQuery(q);
82
- return r;
83
- }
84
- //# sourceMappingURL=reviewStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reviewStatus.js","sourceRoot":"","sources":["../../../../../src/storage/methods/reviewStatus.ts"],"names":[],"mappings":";;AAkBA,oCA4EC;AA3FD,uDAAmD;AAInD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAChC,OAAoB,EACpB,IAAyC;IAEzC,MAAM,CAAC,GAAoB,EAAE,GAAG,EAAE,EAAE,EAAE,CAAA;IAEtC,MAAM,oBAAoB,GAAG,KAAK,EAAoB,EAAqB,EAAiB,EAAE;QAC5F,IAAI,CAAC;YACH,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;YACxB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC,CAAA;YACxB,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;YACjC,CAAC;QACH,CAAC;QAAC,OAAO,EAAW,EAAE,CAAC;YACrB,6DAA6D;YAC7D,MAAM,CAAC,GAAG,yBAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YACrC,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC,CAAA;IAED,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEhC,MAAM,EAAE,GAAwB,EAAE,CAAA;IAElC,EAAE,CAAC,IAAI,CAAC;QACN,GAAG,EAAE,8FAA8F;QACnG;;;cAGM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;QAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAEjD,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -1,39 +0,0 @@
1
- import { Knex } from 'knex';
2
- import { DBType } from '../StorageReader';
3
- import { Chain } from '../../sdk/types';
4
- interface Migration {
5
- up: (knex: Knex) => Promise<void>;
6
- down?: (knex: Knex) => Promise<void>;
7
- config?: object;
8
- }
9
- interface MigrationSource<TMigrationSpec> {
10
- getMigrations(loadExtensions: readonly string[]): Promise<TMigrationSpec[]>;
11
- getMigrationName(migration: TMigrationSpec): string;
12
- getMigration(migration: TMigrationSpec): Promise<Migration>;
13
- }
14
- export declare class KnexMigrations implements MigrationSource<string> {
15
- chain: Chain;
16
- storageName: string;
17
- storageIdentityKey: string;
18
- maxOutputScriptLength: number;
19
- migrations: Record<string, Migration>;
20
- /**
21
- * @param chain
22
- * @param storageName human readable name for this storage instance
23
- * @param maxOutputScriptLength limit for scripts kept in outputs table, longer scripts will be pulled from rawTx
24
- */
25
- constructor(chain: Chain, storageName: string, storageIdentityKey: string, maxOutputScriptLength: number);
26
- getMigrations(): Promise<string[]>;
27
- getMigrationName(migration: string): string;
28
- getMigration(migration: string): Promise<Migration>;
29
- getLatestMigration(): Promise<string>;
30
- static latestMigration(): Promise<string>;
31
- setupMigrations(chain: string, storageName: string, storageIdentityKey: string, maxOutputScriptLength: number): Record<string, Migration>;
32
- }
33
- /**
34
- * @param knex
35
- * @returns {DBType} connected database engine variant
36
- */
37
- export declare function determineDBType(knex: Knex<any, any[]>): Promise<DBType>;
38
- export {};
39
- //# sourceMappingURL=KnexMigrations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KnexMigrations.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/KnexMigrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,KA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