@ercworldio/blockchain-shared 1.0.1-dev.0 → 1.0.1-dev.10

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 (37) hide show
  1. package/build/chains/networks_prod-dz.json +4 -4
  2. package/build/chains/networks_stg-dz.json +80 -0
  3. package/build/entities/DepositAddress.d.ts +1 -0
  4. package/build/entities/DepositAddress.d.ts.map +1 -1
  5. package/build/entities/DepositAddress.js +6 -2
  6. package/build/entities/DepositAddressArchive.d.ts +14 -0
  7. package/build/entities/DepositAddressArchive.d.ts.map +1 -0
  8. package/build/entities/DepositAddressArchive.js +66 -0
  9. package/build/index.d.ts +2 -0
  10. package/build/index.d.ts.map +1 -1
  11. package/build/index.js +5 -2
  12. package/build/interfaces/database.d.ts +2 -0
  13. package/build/interfaces/database.d.ts.map +1 -1
  14. package/build/services/BalanceService.d.ts +9 -0
  15. package/build/services/BalanceService.d.ts.map +1 -1
  16. package/build/services/BalanceService.js +93 -0
  17. package/build/services/DepositAddressArchiveService.d.ts +33 -0
  18. package/build/services/DepositAddressArchiveService.d.ts.map +1 -0
  19. package/build/services/DepositAddressArchiveService.js +140 -0
  20. package/build/services/DepositAddressService.d.ts +3 -1
  21. package/build/services/DepositAddressService.d.ts.map +1 -1
  22. package/build/services/DepositAddressService.js +5 -1
  23. package/build/services/SweepHistoryService.d.ts +2 -2
  24. package/build/services/SweepHistoryService.d.ts.map +1 -1
  25. package/build/services/SweepJobService.d.ts.map +1 -1
  26. package/build/services/SweepJobService.js +2 -1
  27. package/build/services/WalletManager.d.ts +2 -2
  28. package/build/services/WalletManager.d.ts.map +1 -1
  29. package/build/services/WalletManager.js +6 -17
  30. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +4 -1
  31. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  32. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +34 -6
  33. package/build/services/types/sweep_job_service.d.ts +3 -1
  34. package/build/services/types/sweep_job_service.d.ts.map +1 -1
  35. package/build/services/types/wallet_manager.d.ts +1 -0
  36. package/build/services/types/wallet_manager.d.ts.map +1 -1
  37. package/package.json +1 -1
@@ -422,9 +422,9 @@
422
422
  "trc20TransferCost": 4000000
423
423
  },
424
424
  "accounting": {
425
- "funding_wallet": "TTxo5LeNkq5g9sywaGdXjttKRvoum8xSGp",
426
- "treasury_receiver": "TTxo5LeNkq5g9sywaGdXjttKRvoum8xSGp",
427
- "overflow_treasury_receiver": "TTxo5LeNkq5g9sywaGdXjttKRvoum8xSGp",
425
+ "funding_wallet": "TBLeFCWoBrwgbvj33F41t8FErhkgbm3276",
426
+ "treasury_receiver": "TBLeFCWoBrwgbvj33F41t8FErhkgbm3276",
427
+ "overflow_treasury_receiver": "TBLeFCWoBrwgbvj33F41t8FErhkgbm3276",
428
428
  "overflow_threshold_decimal": 100000
429
429
  },
430
430
  "rpcMetadata": {
@@ -452,7 +452,7 @@
452
452
  "startingBlock": 1,
453
453
  "escrowAlchemyWebhooks": [],
454
454
  "addresses": [
455
- "TTxo5LeNkq5g9sywaGdXjttKRvoum8xSGp"
455
+ "TBLeFCWoBrwgbvj33F41t8FErhkgbm3276"
456
456
  ]
457
457
  }
458
458
  ],
@@ -166,6 +166,86 @@
166
166
  }
167
167
  ]
168
168
  },
169
+ "101": {
170
+ "status": true,
171
+ "isTestnet": false,
172
+ "name": "Solana",
173
+ "blockchainType": "solana",
174
+ "chainId": 101,
175
+ "blockexplorerUrl": "https://solscan.io",
176
+ "rpcBaseUrl": "https://rpc.ankr.com/solana",
177
+ "rpcBaseUrlWss": "wss://rpc.ankr.com/solana/ws",
178
+ "targetConfirmations": 2,
179
+ "accounting": {
180
+ "funding_wallet": "sB5d7n9EK7QNmFqB9VmLdi8FMf2yJxbovfuz9mToUqD",
181
+ "treasury_receiver": "yCwEYHrHy2Ri81vxkYbwmuPcLubCZe82mWRUhDciqx6",
182
+ "overflow_treasury_receiver": "yCwEYHrHy2Ri81vxkYbwmuPcLubCZe82mWRUhDciqx6",
183
+ "overflow_threshold_decimal": 100000
184
+ },
185
+ "custodialAlchemyWebhooks": [
186
+ {
187
+ "chainId": "101",
188
+ "network_symbol": "sol",
189
+ "network": "SOLANA_MAINNET",
190
+ "total_wallet_count": 10,
191
+ "endpoint": "webhook/alchemy/address-activity-sol",
192
+ "source": "wallet"
193
+ }
194
+ ],
195
+ "contracts": [
196
+ {
197
+ "type": "Escrow",
198
+ "version": "1",
199
+ "startingBlock": 416497745,
200
+ "escrowAlchemyWebhooks": [
201
+ {
202
+ "chainId": "101",
203
+ "network_symbol": "sol",
204
+ "network": "SOLANA_MAINNET",
205
+ "type": "ADDRESS_ACTIVITY",
206
+ "endpoint": "webhook/alchemy/solana/escrow-events",
207
+ "source": "contract"
208
+ }
209
+ ],
210
+ "addresses": [
211
+ "yCwEYHrHy2Ri81vxkYbwmuPcLubCZe82mWRUhDciqx6"
212
+ ]
213
+ },
214
+ {
215
+ "type": "FundingWallet",
216
+ "version": "1",
217
+ "startingBlock": 45852351,
218
+ "escrowAlchemyWebhooks": [],
219
+ "addresses": [
220
+ "sB5d7n9EK7QNmFqB9VmLdi8FMf2yJxbovfuz9mToUqD"
221
+ ]
222
+ }
223
+ ],
224
+ "paymentTokens": [
225
+ {
226
+ "name": "Solana",
227
+ "symbol": "SOL",
228
+ "token_standard": "SOL",
229
+ "type": "native",
230
+ "isStableCoin": false,
231
+ "decimals": 9,
232
+ "address": "11111111111111111111111111111111",
233
+ "sweepThreshold": 0.05,
234
+ "sweepWalletMinBalance": 0.01
235
+ },
236
+ {
237
+ "name": "Circle Token",
238
+ "symbol": "USDC",
239
+ "token_standard": "SOL",
240
+ "type": "erc20",
241
+ "isStableCoin": true,
242
+ "decimals": 6,
243
+ "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
244
+ "sweepThreshold": 1,
245
+ "sweepWalletMinBalance": 1
246
+ }
247
+ ]
248
+ },
169
249
  "137": {
170
250
  "status": true,
171
251
  "isTestnet": false,
@@ -6,6 +6,7 @@ export declare class DepositAddress {
6
6
  child_index: number;
7
7
  address: string;
8
8
  transaction_count: number;
9
+ expires_at: Date;
9
10
  created_at: Date;
10
11
  updated_at: Date;
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DepositAddress.d.ts","sourceRoot":"","sources":["../../src/entities/DepositAddress.ts"],"names":[],"mappings":"AAEA,qBAEa,cAAc;IAEvB,EAAE,EAAG,MAAM,CAAC;IAGZ,OAAO,EAAG,MAAM,CAAC;IAGjB,UAAU,EAAG,MAAM,CAAC;IAGpB,YAAY,EAAG,MAAM,CAAC;IAGtB,WAAW,EAAG,MAAM,CAAC;IAGrB,OAAO,EAAG,MAAM,CAAC;IAGjB,iBAAiB,EAAG,MAAM,CAAC;IAG3B,UAAU,EAAG,IAAI,CAAC;IAGlB,UAAU,EAAG,IAAI,CAAC;CACrB"}
1
+ {"version":3,"file":"DepositAddress.d.ts","sourceRoot":"","sources":["../../src/entities/DepositAddress.ts"],"names":[],"mappings":"AAEA,qBAEa,cAAc;IAEvB,EAAE,EAAG,MAAM,CAAC;IAGZ,OAAO,EAAG,MAAM,CAAC;IAGjB,UAAU,EAAG,MAAM,CAAC;IAGpB,YAAY,EAAG,MAAM,CAAC;IAGtB,WAAW,EAAG,MAAM,CAAC;IAGrB,OAAO,EAAG,MAAM,CAAC;IAGjB,iBAAiB,EAAG,MAAM,CAAC;IAG3B,UAAU,EAAG,IAAI,CAAC;IAGlB,UAAU,EAAG,IAAI,CAAC;IAGlB,UAAU,EAAG,IAAI,CAAC;CACrB"}
@@ -43,11 +43,15 @@ __decorate([
43
43
  __metadata("design:type", Number)
44
44
  ], DepositAddress.prototype, "transaction_count", void 0);
45
45
  __decorate([
46
- (0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
46
+ (0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
47
+ __metadata("design:type", Date)
48
+ ], DepositAddress.prototype, "expires_at", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
47
51
  __metadata("design:type", Date)
48
52
  ], DepositAddress.prototype, "created_at", void 0);
49
53
  __decorate([
50
- (0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
54
+ (0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
51
55
  __metadata("design:type", Date)
52
56
  ], DepositAddress.prototype, "updated_at", void 0);
53
57
  exports.DepositAddress = DepositAddress = __decorate([
@@ -0,0 +1,14 @@
1
+ export declare class DepositAddressArchive {
2
+ id: number;
3
+ original_id: number;
4
+ user_id: number;
5
+ blockchain: string;
6
+ parent_index: number;
7
+ child_index: number;
8
+ address: string;
9
+ transaction_count: number;
10
+ expires_at: Date;
11
+ archived_at: Date;
12
+ archived_reason: 'expired' | 'revoked' | 'renewed';
13
+ }
14
+ //# sourceMappingURL=DepositAddressArchive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepositAddressArchive.d.ts","sourceRoot":"","sources":["../../src/entities/DepositAddressArchive.ts"],"names":[],"mappings":"AAEA,qBAEa,qBAAqB;IAE9B,EAAE,EAAG,MAAM,CAAC;IAGZ,WAAW,EAAG,MAAM,CAAC;IAIrB,OAAO,EAAG,MAAM,CAAC;IAGjB,UAAU,EAAG,MAAM,CAAC;IAGpB,YAAY,EAAG,MAAM,CAAC;IAGtB,WAAW,EAAG,MAAM,CAAC;IAIrB,OAAO,EAAG,MAAM,CAAC;IAGjB,iBAAiB,EAAG,MAAM,CAAC;IAG3B,UAAU,EAAG,IAAI,CAAC;IAGlB,WAAW,EAAG,IAAI,CAAC;IAGnB,eAAe,EAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CACvD"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DepositAddressArchive = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ let DepositAddressArchive = class DepositAddressArchive {
15
+ };
16
+ exports.DepositAddressArchive = DepositAddressArchive;
17
+ __decorate([
18
+ (0, typeorm_1.PrimaryGeneratedColumn)({ type: 'bigint' }),
19
+ __metadata("design:type", Number)
20
+ ], DepositAddressArchive.prototype, "id", void 0);
21
+ __decorate([
22
+ (0, typeorm_1.Column)({ type: 'bigint', name: 'original_id' }),
23
+ __metadata("design:type", Number)
24
+ ], DepositAddressArchive.prototype, "original_id", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.Column)({ type: 'bigint', name: 'user_id' }),
27
+ (0, typeorm_1.Index)(),
28
+ __metadata("design:type", Number)
29
+ ], DepositAddressArchive.prototype, "user_id", void 0);
30
+ __decorate([
31
+ (0, typeorm_1.Column)(),
32
+ __metadata("design:type", String)
33
+ ], DepositAddressArchive.prototype, "blockchain", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)({ type: 'int', name: 'parent_index' }),
36
+ __metadata("design:type", Number)
37
+ ], DepositAddressArchive.prototype, "parent_index", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.Column)({ type: 'int', name: 'child_index' }),
40
+ __metadata("design:type", Number)
41
+ ], DepositAddressArchive.prototype, "child_index", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)(),
44
+ (0, typeorm_1.Index)(),
45
+ __metadata("design:type", String)
46
+ ], DepositAddressArchive.prototype, "address", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ type: 'int', name: 'transaction_count' }),
49
+ __metadata("design:type", Number)
50
+ ], DepositAddressArchive.prototype, "transaction_count", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ type: 'timestamptz', name: 'expires_at' }),
53
+ __metadata("design:type", Date)
54
+ ], DepositAddressArchive.prototype, "expires_at", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz', name: 'archived_at' }),
57
+ __metadata("design:type", Date)
58
+ ], DepositAddressArchive.prototype, "archived_at", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'archived_reason', default: 'expired' }),
61
+ __metadata("design:type", String)
62
+ ], DepositAddressArchive.prototype, "archived_reason", void 0);
63
+ exports.DepositAddressArchive = DepositAddressArchive = __decorate([
64
+ (0, typeorm_1.Entity)({ name: "deposit_addresses_archive", schema: "usersmanagement" }),
65
+ (0, typeorm_1.Unique)(['blockchain', 'address'])
66
+ ], DepositAddressArchive);
package/build/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { default as ChainManager } from './services/ChainManager';
11
11
  export { default as ClaimHistoryService } from './services/ClaimHistoryService';
12
12
  export { default as ClaimJobService } from './services/ClaimJobService';
13
13
  export { default as DepositAddressService } from './services/DepositAddressService';
14
+ export { default as DepositAddressArchiveService } from './services/DepositAddressArchiveService';
14
15
  export { default as ElasticSearch } from './services/ElasticSearch';
15
16
  export { default as EventsHandler } from './services/EventsHandler';
16
17
  export { default as EventsService } from './services/EventsService';
@@ -61,6 +62,7 @@ export * from './entities/Checkpoint';
61
62
  export * from './entities/ClaimHistory';
62
63
  export * from './entities/ClaimJob';
63
64
  export * from './entities/DepositAddress';
65
+ export * from './entities/DepositAddressArchive';
64
66
  export * from './entities/DepositWalletBalance';
65
67
  export * from './entities/SweepHistory';
66
68
  export * from './entities/SweepJob';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAClG,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAM,aAAa,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI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ACjG,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAEnF,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAChF,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AAIxC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAG/I,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGtD,cAAc,cAAc,CAAC;AAG7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
package/build/index.js CHANGED
@@ -40,8 +40,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  return (mod && mod.__esModule) ? mod : { "default": mod };
41
41
  };
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.BalanceErrors = exports.AdminErrors = exports.TransactionsErrors = exports.EscrowInteraction = exports.QnWebhookAddressManager = exports.SetupNotifications = exports.QnNotificationsApi = exports.QuicknodeWebhookSignature = exports.Worker = exports.WithdrawalManager = exports.WalletManagerHelper = exports.WalletManager = exports.WalletIndexService = exports.SweepHistoryService = exports.SweepJobService = exports.StorageService = exports.ProviderManager = exports.Provider = exports.TronFundingWallet = exports.TronCustodialWallet = exports.TronHotWallet = exports.TronHelper = exports.TronTransaction = exports.TronSigner = exports.TimerManager = exports.RedisPubSub = exports.RedisListQueue = exports.RedisQueue = exports.Redis = exports.MemoryMonitor = exports.Logger = exports.KeyVaultHandler = exports.InvoiceQueue = exports.EscrowService = exports.EventsService = exports.EventsHandler = exports.ElasticSearch = exports.DepositAddressService = exports.ClaimJobService = exports.ClaimHistoryService = exports.ChainManager = exports.BalanceService = exports.AlchemyWebhookSignature = exports.AlchemyWebhooks = exports.AlchemyWebhookAddressManager = exports.AlchemyService = exports.AccountingService = exports.AzureEventHubHandler = exports.AsyncTTLCache = exports.AsyncRateLimiter = void 0;
44
- exports.AppErrors = exports.EscrowIdl = exports.CoverageInfo = exports.EscrowEvents = exports.Erc20Events = exports.AccessControlEvents = exports.ERC20Abi = exports.ErrorAbi = exports.EscrowAbi = exports.ERC20MockAbi = exports.BaseErrors = exports.VoltageErrors = exports.AlchemyErrors = exports.WalletErrors = exports.DatabaseErrors = void 0;
43
+ exports.AdminErrors = exports.TransactionsErrors = exports.EscrowInteraction = exports.QnWebhookAddressManager = exports.SetupNotifications = exports.QnNotificationsApi = exports.QuicknodeWebhookSignature = exports.Worker = exports.WithdrawalManager = exports.WalletManagerHelper = exports.WalletManager = exports.WalletIndexService = exports.SweepHistoryService = exports.SweepJobService = exports.StorageService = exports.ProviderManager = exports.Provider = exports.TronFundingWallet = exports.TronCustodialWallet = exports.TronHotWallet = exports.TronHelper = exports.TronTransaction = exports.TronSigner = exports.TimerManager = exports.RedisPubSub = exports.RedisListQueue = exports.RedisQueue = exports.Redis = exports.MemoryMonitor = exports.Logger = exports.KeyVaultHandler = exports.InvoiceQueue = exports.EscrowService = exports.EventsService = exports.EventsHandler = exports.ElasticSearch = exports.DepositAddressArchiveService = exports.DepositAddressService = exports.ClaimJobService = exports.ClaimHistoryService = exports.ChainManager = exports.BalanceService = exports.AlchemyWebhookSignature = exports.AlchemyWebhooks = exports.AlchemyWebhookAddressManager = exports.AlchemyService = exports.AccountingService = exports.AzureEventHubHandler = exports.AsyncTTLCache = exports.AsyncRateLimiter = void 0;
44
+ exports.AppErrors = exports.EscrowIdl = exports.CoverageInfo = exports.EscrowEvents = exports.Erc20Events = exports.AccessControlEvents = exports.ERC20Abi = exports.ErrorAbi = exports.EscrowAbi = exports.ERC20MockAbi = exports.BaseErrors = exports.VoltageErrors = exports.AlchemyErrors = exports.WalletErrors = exports.DatabaseErrors = exports.BalanceErrors = void 0;
45
45
  // Services
46
46
  var AsyncRateLimiter_1 = require("./utils/AsyncRateLimiter");
47
47
  Object.defineProperty(exports, "AsyncRateLimiter", { enumerable: true, get: function () { return __importDefault(AsyncRateLimiter_1).default; } });
@@ -69,6 +69,8 @@ var ClaimJobService_1 = require("./services/ClaimJobService");
69
69
  Object.defineProperty(exports, "ClaimJobService", { enumerable: true, get: function () { return __importDefault(ClaimJobService_1).default; } });
70
70
  var DepositAddressService_1 = require("./services/DepositAddressService");
71
71
  Object.defineProperty(exports, "DepositAddressService", { enumerable: true, get: function () { return __importDefault(DepositAddressService_1).default; } });
72
+ var DepositAddressArchiveService_1 = require("./services/DepositAddressArchiveService");
73
+ Object.defineProperty(exports, "DepositAddressArchiveService", { enumerable: true, get: function () { return __importDefault(DepositAddressArchiveService_1).default; } });
72
74
  var ElasticSearch_1 = require("./services/ElasticSearch");
73
75
  Object.defineProperty(exports, "ElasticSearch", { enumerable: true, get: function () { return __importDefault(ElasticSearch_1).default; } });
74
76
  var EventsHandler_1 = require("./services/EventsHandler");
@@ -156,6 +158,7 @@ __exportStar(require("./entities/Checkpoint"), exports);
156
158
  __exportStar(require("./entities/ClaimHistory"), exports);
157
159
  __exportStar(require("./entities/ClaimJob"), exports);
158
160
  __exportStar(require("./entities/DepositAddress"), exports);
161
+ __exportStar(require("./entities/DepositAddressArchive"), exports);
159
162
  __exportStar(require("./entities/DepositWalletBalance"), exports);
160
163
  __exportStar(require("./entities/SweepHistory"), exports);
161
164
  __exportStar(require("./entities/SweepJob"), exports);
@@ -1,6 +1,7 @@
1
1
  import { DataSource, Repository } from "typeorm";
2
2
  import { DepositWalletBalance } from "../entities/DepositWalletBalance";
3
3
  import { DepositAddress } from "../entities/DepositAddress";
4
+ import { DepositAddressArchive } from "../entities/DepositAddressArchive";
4
5
  import { WalletIndex } from "../entities/WalletIndex";
5
6
  import { SweepJob } from "../entities/SweepJob";
6
7
  import { SweepHistory } from "../entities/SweepHistory";
@@ -13,6 +14,7 @@ export interface IDatabasePool {
13
14
  appDataSource: DataSource | null;
14
15
  balancesRepo: Repository<DepositWalletBalance> | null;
15
16
  accountsRepo: Repository<DepositAddress> | null;
17
+ depositAddressArchiveRepo: Repository<DepositAddressArchive> | null;
16
18
  walletIndexRepo: Repository<WalletIndex> | null;
17
19
  sweepJobRepo: Repository<SweepJob> | null;
18
20
  sweepHistoryRepo: Repository<SweepHistory> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/interfaces/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC1B,qBAAqB,EAAE,UAAU,GAAG,IAAI,CAAC;IACzC,aAAa,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,UAAU,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC;IACtD,YAAY,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AAE,MAAM,qCAAqC,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC1B,qBAAqB,EAAE,UAAU,GAAG,IAAI,CAAC;IACzC,aAAa,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,UAAU,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC;IACtD,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IAChD,yBAAyB,EAAE,UAAU,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;IACpE,eAAe,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAChD,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC1C,gBAAgB,EAAE,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAClD,gBAAgB,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC/C,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;IACtD,2BAA2B,CAAC,EAAE,UAAU,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,UAAU,CAAC;IAChC,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB;AAGD,MAAM,WAAW,qBAAqB;IAClC,WAAW,IAAI,aAAa,CAAC;CAChC"}
@@ -1,5 +1,6 @@
1
1
  import { DepositWalletBalance } from "../entities/DepositWalletBalance";
2
2
  import { BlockchainType, ChainId, SweepResult, TransferResult } from "../interfaces";
3
+ import { IWallet } from "./types/wallet_manager";
3
4
  import { IDatabasePool } from "../interfaces/database";
4
5
  import { IConfig } from "../interfaces/config";
5
6
  import { DepositEvent } from "./types";
@@ -25,6 +26,14 @@ declare class BalanceService extends BaseErrors {
25
26
  removeWalletBalances(walletId: number, blockchain: string): Promise<boolean>;
26
27
  initializeWalletBalances(walletId: number, blockchain: string): Promise<boolean>;
27
28
  createBalanceBatch(walletId: number, blockchain: string): Promise<boolean>;
29
+ /**
30
+ * Atomically in a single DB round-trip:
31
+ * 1. Archive the old deposit address (ON CONFLICT DO NOTHING — idempotent)
32
+ * 2. Update deposit_addresses with new child index, address, expiry
33
+ * 3. Delete old balance rows
34
+ * 4. Insert fresh balance rows for all payment tokens on the blockchain
35
+ */
36
+ renewWalletTransaction(userId: number, blockchain: string, newChildIndex: number, newAddress: string, newExpiresAt: Date): Promise<IWallet>;
28
37
  private createBalance;
29
38
  batchUpdateBalances(events: DepositEvent[]): Promise<void>;
30
39
  updateBalance(userId: number, blockchain: BlockchainType, address: string, chainId: ChainId, paymentToken: string, amountInWei: bigint, operationType: OperationType): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"BalanceService.d.ts","sourceRoot":"","sources":["../../src/services/BalanceService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAgB,OAAO,EAAgB,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAOjH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAI1C,KAAK,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEtC,UAAU,sBAAsB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,cAAM,cAAe,SAAQ,UAAU;IACnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAS;gBACX,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO;IASlD;;;OAGG;YACW,iB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AAI,GACnB,OAAO,CAAC,OAAO,CAAC;YAwFL,aAAa;IAwBd,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE;IA0EjD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa;;;;IA2FpK,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe;IAmE3H,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc;IAUlD,uBAAuB;IAuBvB,kBAAkB,CAAC,KAAK,GAAE,MAAY;YAOrC,gBAAgB;IAoBxB,yBAAyB,CAAC,mBAAmB,EAAE,WAAW,EAAE;IAY5D,6BAA6B,CAAC,mBAAmB,EAAE,cAAc,EAAE;CA8D5E;AAED,eAAe,cAAc,CAAC"}
@@ -185,6 +185,99 @@ class BalanceService extends errors_1.default {
185
185
  return true;
186
186
  });
187
187
  }
188
+ /**
189
+ * Atomically in a single DB round-trip:
190
+ * 1. Archive the old deposit address (ON CONFLICT DO NOTHING — idempotent)
191
+ * 2. Update deposit_addresses with new child index, address, expiry
192
+ * 3. Delete old balance rows
193
+ * 4. Insert fresh balance rows for all payment tokens on the blockchain
194
+ */
195
+ renewWalletTransaction(userId, blockchain, newChildIndex, newAddress, newExpiresAt) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const dataSource = this.dbPool.getDataSource();
198
+ if (!dataSource)
199
+ throw new Error('Database connection is not initialized.');
200
+ const chainManager = ChainManager_1.default.getInstance(this.config);
201
+ if (!chainManager.paymentTokenMap)
202
+ throw new Error('Payment token map not defined in ChainManager.');
203
+ const chainIds = [];
204
+ const tokens = [];
205
+ const decimals = [];
206
+ for (const [_, config] of Object.entries(chainManager.paymentTokenMap)) {
207
+ if (config.blockchainType.toLowerCase() !== blockchain.toLowerCase())
208
+ continue;
209
+ if (config.status === false)
210
+ continue;
211
+ for (const token of config.paymentTokens) {
212
+ chainIds.push(config.chainId.toString());
213
+ tokens.push(token.address);
214
+ decimals.push(token.decimals);
215
+ }
216
+ }
217
+ if (tokens.length === 0)
218
+ throw new Error(`No payment tokens found for blockchain ${blockchain}`);
219
+ const rows = yield dataSource.query(`
220
+ WITH old_address AS (
221
+ SELECT id, user_id, blockchain, parent_index, child_index, address, transaction_count, expires_at
222
+ FROM usersmanagement.deposit_addresses
223
+ WHERE user_id = $1 AND blockchain = $2
224
+ ),
225
+ archive_step AS (
226
+ INSERT INTO usersmanagement.deposit_addresses_archive
227
+ (original_id, user_id, blockchain, parent_index, child_index, address, transaction_count, expires_at, archived_at, archived_reason)
228
+ SELECT id, user_id, blockchain, parent_index, child_index, address, transaction_count, expires_at, now(), 'renewed'
229
+ FROM old_address
230
+ ON CONFLICT (blockchain,address) DO NOTHING
231
+ ),
232
+ updated_address AS (
233
+ UPDATE usersmanagement.deposit_addresses
234
+ SET child_index = $3,
235
+ address = $4,
236
+ expires_at = $5,
237
+ updated_at = now()
238
+ WHERE user_id = $1 AND blockchain = $2
239
+ RETURNING id, user_id, blockchain, parent_index, child_index, address, transaction_count, expires_at, created_at, updated_at
240
+ ),
241
+ upserted_balances AS (
242
+ INSERT INTO usersmanagement.deposit_wallet_balance
243
+ (wallet_id, blockchain, chain_id, token, decimals, balance, transaction_count, created_at, updated_at)
244
+ SELECT
245
+ (SELECT id FROM updated_address),
246
+ $2,
247
+ v.chain_id,
248
+ v.token,
249
+ v.decimals,
250
+ 0, 0, now(), now()
251
+ FROM (
252
+ SELECT unnest($6::text[]) AS chain_id,
253
+ unnest($7::text[]) AS token,
254
+ unnest($8::int[]) AS decimals
255
+ ) AS v
256
+ ON CONFLICT (blockchain, chain_id, wallet_id, token) DO UPDATE SET
257
+ decimals = EXCLUDED.decimals,
258
+ balance = 0,
259
+ transaction_count = 0,
260
+ updated_at = now()
261
+ )
262
+ SELECT * FROM updated_address;
263
+ `, [userId, blockchain, newChildIndex, newAddress, newExpiresAt.toISOString(), chainIds, tokens, decimals]);
264
+ if (!rows[0])
265
+ throw new Error(`Deposit address not found for user ${userId} on ${blockchain}`);
266
+ const r = rows[0];
267
+ return {
268
+ id: Number(r.id),
269
+ userId: Number(r.user_id),
270
+ blockchain: r.blockchain,
271
+ parentIndex: r.parent_index,
272
+ childIndex: r.child_index,
273
+ address: r.address,
274
+ transactionCount: r.transaction_count,
275
+ expiresAt: r.expires_at,
276
+ createdAt: r.created_at,
277
+ updatedAt: r.updated_at,
278
+ };
279
+ });
280
+ }
188
281
  // Create a balance entity for a given wallet on a given chain for a given payment token
189
282
  // Used when creating new deposit wallets for users
190
283
  createBalance(walletId, blockchain, config, paymentToken, decimals) {
@@ -0,0 +1,33 @@
1
+ import { DepositAddress } from "../entities/DepositAddress";
2
+ import { DepositAddressArchive } from "../entities/DepositAddressArchive";
3
+ import { IDatabasePool } from "../interfaces/database";
4
+ import { Paginated } from "./types/claim_job_service";
5
+ export interface DepositAddressArchiveFilters {
6
+ userId?: number;
7
+ blockchain?: string;
8
+ address?: string;
9
+ archivedReason?: 'expired' | 'revoked' | 'renewed';
10
+ }
11
+ declare class DepositAddressArchiveService {
12
+ private dbPool;
13
+ constructor(dbPool: IDatabasePool);
14
+ private getRepo;
15
+ /**
16
+ * Archive an expired/revoked/renewed deposit address.
17
+ * Call this before replacing the live deposit_addresses row.
18
+ */
19
+ archive(address: DepositAddress, reason?: 'expired' | 'revoked' | 'renewed'): Promise<DepositAddressArchive>;
20
+ /**
21
+ * Idempotent archive — safe to call from multiple workers concurrently.
22
+ * Uses ON CONFLICT DO NOTHING on original_id so duplicate calls are no-ops.
23
+ * Returns the existing row if already archived, or the newly inserted row.
24
+ */
25
+ archiveIdempotent(address: DepositAddress, reason?: 'expired' | 'revoked' | 'renewed'): Promise<DepositAddressArchive>;
26
+ findById(id: number): Promise<DepositAddressArchive | null>;
27
+ findByOriginalId(originalId: number): Promise<DepositAddressArchive[]>;
28
+ findByUserId(userId: number, blockchain?: string): Promise<DepositAddressArchive[]>;
29
+ findByAddress(address: string): Promise<DepositAddressArchive[]>;
30
+ getPaginated(page: number, page_size?: number, filters?: DepositAddressArchiveFilters): Promise<Paginated<DepositAddressArchive[]>>;
31
+ }
32
+ export default DepositAddressArchiveService;
33
+ //# sourceMappingURL=DepositAddressArchiveService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepositAddressArchiveService.d.ts","sourceRoot":"","sources":["../../src/services/DepositAddressArchiveService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,WAAW,4BAA4B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CACtD;AAED,cAAM,4BAA4B;IAC9B,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAIjC,OAAO,CAAC,OAAO;IAMf;;;OAGG;IACG,OAAO,CACT,OAAO,EAAE,cAAc,EACvB,MAAM,GAAE,SAAS,GAAG,SAAS,GAAG,SAAqB,GACtD,OAAO,CAAC,qBAAqB,CAAC;IAgBjC;;;;OAIG;IACG,iBAAiB,CACnB,OAAO,EAAE,cAAc,EACvB,MAAM,GAAE,SAAS,GAAG,SAAS,GAAG,SAAqB,GACtD,OAAO,CAAC,qBAAqB,CAAC;IA+B3B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAI3D,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAOtE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAMnF,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAOhE,YAAY,CACd,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAW,EACtB,OAAO,GAAE,4BAAiC,GAC3C,OAAO,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC,CAAC;CA4BjD;AAED,eAAe,4BAA4B,CAAC"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ class DepositAddressArchiveService {
13
+ constructor(dbPool) {
14
+ this.dbPool = dbPool;
15
+ }
16
+ getRepo() {
17
+ const repo = this.dbPool.depositAddressArchiveRepo;
18
+ if (!repo)
19
+ throw new Error('depositAddressArchiveRepo is not initialized.');
20
+ return repo;
21
+ }
22
+ /**
23
+ * Archive an expired/revoked/renewed deposit address.
24
+ * Call this before replacing the live deposit_addresses row.
25
+ */
26
+ archive(address_1) {
27
+ return __awaiter(this, arguments, void 0, function* (address, reason = 'expired') {
28
+ const repo = this.getRepo();
29
+ const entry = repo.create({
30
+ original_id: address.id,
31
+ user_id: address.user_id,
32
+ blockchain: address.blockchain,
33
+ parent_index: address.parent_index,
34
+ child_index: address.child_index,
35
+ address: address.address,
36
+ transaction_count: address.transaction_count,
37
+ expires_at: address.expires_at,
38
+ archived_reason: reason,
39
+ });
40
+ return repo.save(entry);
41
+ });
42
+ }
43
+ /**
44
+ * Idempotent archive — safe to call from multiple workers concurrently.
45
+ * Uses ON CONFLICT DO NOTHING on original_id so duplicate calls are no-ops.
46
+ * Returns the existing row if already archived, or the newly inserted row.
47
+ */
48
+ archiveIdempotent(address_1) {
49
+ return __awaiter(this, arguments, void 0, function* (address, reason = 'expired') {
50
+ const repo = this.getRepo();
51
+ const dataSource = this.dbPool.appDataSource;
52
+ if (!dataSource)
53
+ throw new Error('appDataSource is not initialized.');
54
+ const rows = yield dataSource.query(`
55
+ INSERT INTO usersmanagement.deposit_addresses_archive
56
+ (original_id, user_id, blockchain, parent_index, child_index, address, transaction_count, expires_at, archived_at, archived_reason)
57
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, now(), $9)
58
+ ON CONFLICT (blockchain, address) DO NOTHING
59
+ RETURNING *
60
+ `, [
61
+ address.id,
62
+ address.user_id,
63
+ address.blockchain,
64
+ address.parent_index,
65
+ address.child_index,
66
+ address.address,
67
+ address.transaction_count,
68
+ address.expires_at,
69
+ reason,
70
+ ]);
71
+ // If conflict (already archived), return the existing record
72
+ if (rows.length === 0) {
73
+ return repo.findOneOrFail({ where: { blockchain: address.blockchain, address: address.address } });
74
+ }
75
+ return rows[0];
76
+ });
77
+ }
78
+ findById(id) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ return this.getRepo().findOne({ where: { id } });
81
+ });
82
+ }
83
+ findByOriginalId(originalId) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ return this.getRepo().find({
86
+ where: { original_id: originalId },
87
+ order: { archived_at: 'DESC' },
88
+ });
89
+ });
90
+ }
91
+ findByUserId(userId, blockchain) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const where = { userId };
94
+ if (blockchain)
95
+ where.blockchain = blockchain;
96
+ return this.getRepo().find({ where, order: { archived_at: 'DESC' } });
97
+ });
98
+ }
99
+ findByAddress(address) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ return this.getRepo().find({
102
+ where: { address },
103
+ order: { archived_at: 'DESC' },
104
+ });
105
+ });
106
+ }
107
+ getPaginated(page_1) {
108
+ return __awaiter(this, arguments, void 0, function* (page, page_size = 20, filters = {}) {
109
+ const repo = this.getRepo();
110
+ if (page === 0)
111
+ page = 1;
112
+ const where = {};
113
+ if (filters.userId)
114
+ where.userId = filters.userId;
115
+ if (filters.blockchain)
116
+ where.blockchain = filters.blockchain;
117
+ if (filters.address)
118
+ where.address = filters.address;
119
+ if (filters.archivedReason)
120
+ where.archivedReason = filters.archivedReason;
121
+ const [items, totalCount] = yield Promise.all([
122
+ repo.find({
123
+ where,
124
+ order: { archived_at: 'DESC' },
125
+ take: page_size,
126
+ skip: (page - 1) * page_size,
127
+ }),
128
+ repo.count({ where }),
129
+ ]);
130
+ return {
131
+ total_count: totalCount,
132
+ pages_count: Math.ceil(totalCount / page_size),
133
+ has_next: totalCount > page * page_size,
134
+ current_page: page,
135
+ items,
136
+ };
137
+ });
138
+ }
139
+ }
140
+ exports.default = DepositAddressArchiveService;
@@ -15,6 +15,7 @@ interface CreateDepositResult {
15
15
  childIndex: number;
16
16
  transactionCount: number;
17
17
  blockchain: string;
18
+ expiresAt: Date;
18
19
  updatedAt: Date;
19
20
  createdAt: Date;
20
21
  }
@@ -23,6 +24,7 @@ export interface UpdateDepositAddressValues {
23
24
  parentIndex: number;
24
25
  childIndex: number;
25
26
  address: string;
27
+ expiresAt: Date;
26
28
  }
27
29
  interface UpdateDepositResult extends CreateDepositResult {
28
30
  }
@@ -35,7 +37,7 @@ declare class DepositAddressService {
35
37
  findByUserId(userId: number, blockchain: string): Promise<DepositAddress>;
36
38
  findByBlockchainAndParentIndex(blockchain: BlockchainType, parentIndex: number): Promise<null>;
37
39
  private findByBlockchainAndUserId;
38
- createDepositAddress(userId: number, blockchain: string, parentIndex: number, address: string): Promise<CreateDepositResult>;
40
+ createDepositAddress(userId: number, blockchain: string, parentIndex: number, address: string, expiry_duration_s: number): Promise<CreateDepositResult>;
39
41
  updateDepositAddress(userId: number, values: UpdateDepositAddressValues): Promise<UpdateDepositResult>;
40
42
  deleteDepositAddress(userId: number, blockchain: string): Promise<{
41
43
  status: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"DepositAddressService.d.ts","sourceRoot":"","sources":["../../src/services/DepositAddressService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,WAAW,2BAA2B;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAmB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AACD,MAAM,WAAW,0BAA0B;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,mBAAoB,SAAQ,mBAAmB;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1
+ {"version":3,"file":"DepositAddressService.d.ts","sourceRoot":"","sources":["../../src/services/DepositAddressService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,WAAW,2BAA2B;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAmB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AACD,MAAM,WAAW,0BAA0B;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,UAAU,mBAAoB,SAAQ,mBAAmB;CACxD;AAED,cAAM,qBAAqB;IACvB,OAAO,CAAC,MAAM,CAAgB;gBAClB,MAAM,EAAE,aAAa;IAKjC,OAAO,CAAC,gBAAgB;IAiBlB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAqB9E,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAazB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAkBzE,8BAA8B,CAAC,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM;YAyBtE,yBAAyB;IAqBjC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA4DvJ,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAqDtG,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;YA4B/F,QAAQ;IAwBhB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAK,EAAE,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IAI9I,0BAA0B,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAkBvG,6BAA6B,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAanH;AAED,eAAe,qBAAqB,CAAC"}
@@ -121,7 +121,7 @@ class DepositAddressService {
121
121
  }
122
122
  });
123
123
  }
124
- createDepositAddress(userId, blockchain, parentIndex, address) {
124
+ createDepositAddress(userId, blockchain, parentIndex, address, expiry_duration_s) {
125
125
  return __awaiter(this, void 0, void 0, function* () {
126
126
  try {
127
127
  const dbDriver = this.dbPool;
@@ -146,6 +146,7 @@ class DepositAddressService {
146
146
  entity.transaction_count = 0;
147
147
  entity.blockchain = blockchain;
148
148
  entity.parent_index = parentIndex;
149
+ entity.expires_at = new Date(new Date().getTime() + expiry_duration_s * 1000);
149
150
  entity.child_index = 0;
150
151
  entity.address = this.normalizeAddress(address, blockchain);
151
152
  const depositAddress = yield dbDriver.accountsRepo.save(entity);
@@ -160,6 +161,7 @@ class DepositAddressService {
160
161
  childIndex: updatedDepositAddress.child_index,
161
162
  address: this.normalizeAddress(updatedDepositAddress.address, updatedDepositAddress.blockchain),
162
163
  transactionCount: updatedDepositAddress.transaction_count,
164
+ expiresAt: updatedDepositAddress.expires_at,
163
165
  updatedAt: updatedDepositAddress.updated_at,
164
166
  createdAt: updatedDepositAddress.created_at
165
167
  };
@@ -199,6 +201,7 @@ class DepositAddressService {
199
201
  }
200
202
  // Update address renewal date
201
203
  entity.updated_at = new Date();
204
+ entity.expires_at = values.expiresAt;
202
205
  // Insert the entity into the database
203
206
  const insertedDepositAddress = yield dbDriver.accountsRepo.update(entity.id, entity);
204
207
  return {
@@ -209,6 +212,7 @@ class DepositAddressService {
209
212
  childIndex: entity.child_index,
210
213
  transactionCount: entity.transaction_count,
211
214
  blockchain: entity.blockchain,
215
+ expiresAt: entity.expires_at,
212
216
  createdAt: entity.created_at,
213
217
  updatedAt: entity.updated_at
214
218
  };
@@ -2,14 +2,14 @@ import { SweepHistory } from "../entities/SweepHistory";
2
2
  import { IDatabasePool } from "../interfaces/database";
3
3
  import { IConfig } from "../interfaces/config";
4
4
  import { Paginated } from "./types/claim_job_service";
5
- import { SweepSearchFilters } from "./types/sweep_job_service";
5
+ import { SweepHistoryFilters } from "./types/sweep_job_service";
6
6
  declare class SweepHistoryService {
7
7
  private dbPool;
8
8
  private config;
9
9
  constructor(dbPool: IDatabasePool, config: IConfig);
10
10
  private get_repo;
11
11
  private paginate;
12
- get_sweep_jobs_paginated(page: number, page_size: number | undefined, filters: SweepSearchFilters): Promise<Paginated<SweepHistory[]>>;
12
+ get_sweep_jobs_paginated(page: number, page_size: number | undefined, filters: SweepHistoryFilters): Promise<Paginated<SweepHistory[]>>;
13
13
  }
14
14
  export default SweepHistoryService;
15
15
  //# sourceMappingURL=SweepHistoryService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SweepHistoryService.d.ts","sourceRoot":"","sources":["../../src/services/SweepHistoryService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,cAAM,mBAAmB;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAU;gBACZ,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO;IAKlD,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,QAAQ,CAsBf;IAEK,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAK,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC;CAIxI;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"SweepHistoryService.d.ts","sourceRoot":"","sources":["../../src/services/SweepHistoryService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,cAAM,mBAAmB;IAC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Ac,EAC1B,gBAAgB,MAAM,EACtB,YAAY,OAAO,KACpB,OAAO,CAAC,IAAI,CAAC,CAad;IAGK,mCAAmC,GACtC,MAAM,QAAQ,EAAE,EAChB,WAAW,OAAO,KACnB,OAAO,CAAC,IAAI,CAAC,CAqBf;IAEM,uBAAuB,GAAU,MAAM,WAAW,EAAE,EAAE,iBAAiB,cAAc,mBA2B3F;IAEM,iBAAiB,GAAU,SAAS,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAQjE;IAEI,iCAAiC,CACnC,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,MAAU,GACzB,OAAO,CAAC,QAAQ,EAAE,CAAC;CA2BzB;AAED,eAAe,eAAe,CAAC"}
@@ -37,7 +37,7 @@ class SweepJobService {
37
37
  AND s.job_status = $3
38
38
  `, [
39
39
  jobs.map(j => j.id),
40
- jobs.map(j => j.sweep_before),
40
+ jobs.map(j => j.sweep_before ? j.sweep_before.toISOString() : null),
41
41
  expected_status
42
42
  ]);
43
43
  });
@@ -131,6 +131,7 @@ class SweepJobService {
131
131
  AND dup.chain_id = s.chain_id
132
132
  AND dup.token = s.token
133
133
  AND dup.address = s.address
134
+ AND dup.id != s.id
134
135
  AND dup.job_status IN ('pending', 'queued')
135
136
  )
136
137
  ),
@@ -22,7 +22,7 @@ declare class WalletManager extends BaseErrors {
22
22
  getEscrowFundsManagerWallet: (blockchain: BlockchainType) => ethers.Wallet | Keypair | TronNodeWallet;
23
23
  fund_wallets_evm: (chainId: ChainId, wallets: string[], estimation_type: TransactionType) => Promise<string>;
24
24
  private get_wallet_service_mnemonic;
25
- createWallet: (userId: number, blockchain: BlockchainType) => Promise<IWallet>;
25
+ createWallet: (userId: number, blockchain: BlockchainType, expiry_duration_s: number) => Promise<IWallet>;
26
26
  isAddressExpired(blockchain: BlockchainType, address: string): Promise<boolean>;
27
27
  calculate_expiry(wallet: IWallet): {
28
28
  is_expired: boolean;
@@ -35,7 +35,7 @@ declare class WalletManager extends BaseErrors {
35
35
  status: boolean;
36
36
  address: string;
37
37
  }>;
38
- renewWallet: (subscription: AlchemyWebhookEnvironment, userId: number, blockchain: BlockchainType, expired_address: string) => Promise<IWallet>;
38
+ renewWallet: (subscription: AlchemyWebhookEnvironment, userId: number, blockchain: BlockchainType, expired_address: string, expiry_duration_s: number) => Promise<IWallet>;
39
39
  updateWebhookAddress: (subscription: AlchemyWebhookEnvironment, blockchain: BlockchainType, old_wallet: IWallet, new_wallet: IWallet, limiter: AsyncRateLimiter) => Promise<boolean>;
40
40
  handleRenewWallet: (old_wallet: IWallet, new_wallet: IWallet) => Promise<IWallet>;
41
41
  deriveWallet: (parentIndex: number, childIndex: number, blockchain: BlockchainType, _mnemonic?: string) => BtcWallet;
@@ -1 +1 @@
1
- {"version":3,"file":"WalletManager.d.ts","sourceRoot":"","sources":["../../src/services/WalletManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoC,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxD,OAAO,EAAe,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAe,OAAO,EAAgB,cAAc,EAAc,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAO5D,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAG1C,OAAO,gBAA+B,MAAM,2BAA2B,CAAC;AAGxE,cAAM,aAAc,SAAQ,UAAU;IAClC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC;IAC/B,OAAO,CAAC,MAAM,CAAU;I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,2BAA2B;IAa5B,YAAY,GAAU,QAAQ,MAAM,EAAE,YAAY,cAAc,EAAE,mBAAmB,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CA4BpH;IAEY,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;IAsBlE,gBAAgB,CAAC,MAAM,EAAE,OAAO;;;;;;;IAoBhC,YAAY,GAAU,QAAQ,MAAM,EAAE,YAAY,cAAc;;;OAGtE;IAGM,WAAW,GAAU,cAAc,yBAAyB,EAAE,QAAQ,MAAM,EAAE,YAAY,cAAc,EAAE,iBAAiB,MAAM,EAAE,mBAAmB,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CA8BrL;IAEM,oBAAoB,GAAU,cAAc,yBAAyB,EAAE,YAAY,cAAc,EAAE,YAAY,OAAO,EAAE,YAAY,OAAO,EAAE,SAAS,gBAAgB,sBA8B5K;IAGM,iBAAiB,GAAU,YAAY,OAAO,EAAE,YAAY,OAAO,sBAezE;IAIM,YAAY,GAAI,aAAa,MAAM,EAAE,YAAY,MAAM,EAAE,YAAY,cAAc,EAAE,YAAY,MAAM,eA4E7G;CAIJ;AAED,eAAe,aAAa,CAAC"}
@@ -82,6 +82,7 @@ class WalletManager extends errors_1.default {
82
82
  childIndex: existingWallet.child_index,
83
83
  transactionCount: existingWallet.transaction_count,
84
84
  blockchain: existingWallet.blockchain,
85
+ expiresAt: existingWallet.expires_at,
85
86
  updatedAt: existingWallet.updated_at,
86
87
  createdAt: existingWallet.created_at
87
88
  };
@@ -150,7 +151,7 @@ class WalletManager extends errors_1.default {
150
151
  throw new Error("Failed to fund wallets.");
151
152
  return response.transactionHash;
152
153
  });
153
- this.createWallet = (userId, blockchain) => __awaiter(this, void 0, void 0, function* () {
154
+ this.createWallet = (userId, blockchain, expiry_duration_s) => __awaiter(this, void 0, void 0, function* () {
154
155
  try {
155
156
  // User main wallet mnemonic
156
157
  const mnemonic = this.get_wallet_service_mnemonic(blockchain);
@@ -167,7 +168,7 @@ class WalletManager extends errors_1.default {
167
168
  throw new Error(`Failed to derive child wallet.`);
168
169
  }
169
170
  // Create new entity in db
170
- const newEntity = yield depositAddressService.createDepositAddress(userId, blockchain, parentIndex, derivedWallet.address);
171
+ const newEntity = yield depositAddressService.createDepositAddress(userId, blockchain, parentIndex, derivedWallet.address, expiry_duration_s);
171
172
  return newEntity;
172
173
  }
173
174
  catch (error) {
@@ -178,7 +179,7 @@ class WalletManager extends errors_1.default {
178
179
  const depositAddressService = new DepositAddressService_1.default(this.dbPool);
179
180
  return yield depositAddressService.deleteDepositAddress(userId, blockchain);
180
181
  });
181
- this.renewWallet = (subscription, userId, blockchain, expired_address) => __awaiter(this, void 0, void 0, function* () {
182
+ this.renewWallet = (subscription, userId, blockchain, expired_address, expiry_duration_s) => __awaiter(this, void 0, void 0, function* () {
182
183
  const wallet = yield this.getWallet(userId, blockchain);
183
184
  if (!wallet) {
184
185
  throw new Error(`Wallet not found`);
@@ -190,27 +191,15 @@ class WalletManager extends errors_1.default {
190
191
  if (!newWallet) {
191
192
  throw new Error("Failed to derive new wallet.");
192
193
  }
193
- const depositAddressService = new DepositAddressService_1.default(this.dbPool);
194
- const updatedWallet = yield depositAddressService.updateDepositAddress(userId, {
195
- parentIndex: wallet.parentIndex,
196
- childIndex: newChildIndex,
197
- blockchain,
198
- address: newWallet.address,
199
- });
200
194
  const balanceService = new BalanceService_1.default(this.dbPool, this.config);
201
- const deleteBalancesAndDispatchSweep = yield balanceService.removeWalletBalances(updatedWallet.id, blockchain);
202
- if (!deleteBalancesAndDispatchSweep)
203
- throw new Error(`Failed to remove wallet balances for expired address ${wallet.address}`);
204
- const updatedBalance = yield balanceService.initializeWalletBalances(updatedWallet.id, blockchain);
205
- if (!updatedBalance)
206
- throw new Error(`Failed to initialize wallet balances for address ${updatedWallet.address}`);
195
+ const updatedWallet = yield balanceService.renewWalletTransaction(userId, blockchain, newChildIndex, newWallet.address, new Date(Date.now() + expiry_duration_s * 1000));
207
196
  const timerManager = TimerManager_1.default.getInstance(this.config, this.dbPool);
208
197
  yield timerManager.delete_timer(userId, blockchain);
209
198
  return updatedWallet;
210
199
  });
211
200
  this.updateWebhookAddress = (subscription, blockchain, old_wallet, new_wallet, limiter) => __awaiter(this, void 0, void 0, function* () {
212
201
  const alchemy_service = AlchemyService_1.default.getInstance(this.config);
213
- const qn_service = QnWebhookAddressManager_1.default.getInstance(this.config);
202
+ const qn_service = QnWebhookAddressManager_1.default.getInstance(this.config, this.dbPool, { maxConcurrent: 1, minDelayMs: 1000 });
214
203
  // Add new address and remove expired address (quicknode and alchemy webhooks)
215
204
  const alchemy_res = yield limiter.execute(() => (0, AsyncRateLimiter_1.withRetry)(() => __awaiter(this, void 0, void 0, function* () { return yield alchemy_service.add_remove_addresses_all_webhooks(subscription, blockchain, [new_wallet.address], [old_wallet.address]); }), 2, 500));
216
205
  const quicknode_res_add = yield limiter.execute(() => (0, AsyncRateLimiter_1.withRetry)(() => __awaiter(this, void 0, void 0, function* () { return yield qn_service.add_address(blockchain, new_wallet.address); }), 3, 500));
@@ -1,13 +1,15 @@
1
1
  import { BlockchainType, ChainId } from "../../interfaces";
2
2
  import { IConfig } from "../../interfaces/config";
3
+ import { IDatabasePool } from "../../interfaces/database";
3
4
  import { RateLimiterOptions } from "../../utils/AsyncRateLimiter";
4
5
  declare class QnWebhookAddressManager {
5
6
  private static instance;
6
7
  private api;
7
8
  private config;
8
9
  private cache;
10
+ private db;
9
11
  private constructor();
10
- static getInstance(config: IConfig, rlc?: RateLimiterOptions): QnWebhookAddressManager;
12
+ static getInstance(config: IConfig, db: IDatabasePool, rlc?: RateLimiterOptions): QnWebhookAddressManager;
11
13
  private get_blockchain_for_chain;
12
14
  /** Returns the { name, network } pairs for the notification configs of a given chain. */
13
15
  private get_webhook_keys_for_chain;
@@ -42,6 +44,7 @@ declare class QnWebhookAddressManager {
42
44
  * Call this fire-and-forget after responding to the caller.
43
45
  */
44
46
  sync_remove_from_remaining(blockchain: BlockchainType, address: string, exclude_chain_id: ChainId): Promise<void>;
47
+ private fetch_all_db_addresses;
45
48
  }
46
49
  export default QnWebhookAddressManager;
47
50
  //# sourceMappingURL=QnWebhookAddressManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QnWebhookAddressManager.d.ts","sourceRoot":"","sources":["../../../src/services/quicknode-notifications/QnWebhookAddressManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AA0BlE,cAAM,uBAAuB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,KAAK,CAAmD;IAEhE,OAAO;IAKP,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,kBAAkB,GAAG,uBAAuB;IAOtF,OAAO,CAAC,wBAAwB;IAKhC,yFAAyF;IACzF,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,QAAQ;YAMF,IAAI;YAuCJ,aAAa;IAO3B,OAAO,CAAC,WAAW;IAIN,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB1E,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB1F;;;;OAIG;IACU,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBvF;;;;OAIG;IACU,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,G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AO,CAAC,OAAO,CAAC;IAoB1E,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB1F;;;;OAIG;IACU,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBvF;;;;OAIG;IACU,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuB5F;;;;OAIG;IACU,qBAAqB,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBzH;;;;OAIG;IACU,0BAA0B,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YAqBhH,sBAAsB;CAuBvC;AAED,eAAe,uBAAuB,CAAC"}
@@ -13,17 +13,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const ChainManager_1 = __importDefault(require("../ChainManager"));
16
+ const DepositAddressService_1 = __importDefault(require("../DepositAddressService"));
16
17
  const QnNotificationsApi_1 = __importDefault(require("./QnNotificationsApi"));
17
18
  const CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes
19
+ const ADDRESS_SYNC_BATCH_SIZE = 500;
20
+ const ADDRESS_LOG_THRESHOLD = 1000;
18
21
  class QnWebhookAddressManager {
19
- constructor(config, rlc) {
22
+ constructor(config, db, rlc) {
20
23
  this.cache = new Map();
21
24
  this.config = config;
22
25
  this.api = QnNotificationsApi_1.default.getInstance(config, rlc);
26
+ this.db = db;
23
27
  }
24
- static getInstance(config, rlc) {
28
+ static getInstance(config, db, rlc) {
25
29
  if (!this.instance) {
26
- this.instance = new QnWebhookAddressManager(config, rlc);
30
+ this.instance = new QnWebhookAddressManager(config, db, rlc);
27
31
  }
28
32
  return this.instance;
29
33
  }
@@ -62,7 +66,6 @@ class QnWebhookAddressManager {
62
66
  }
63
67
  load(blockchain) {
64
68
  return __awaiter(this, void 0, void 0, function* () {
65
- var _a;
66
69
  const notif_configs = this.get_notif_configs(blockchain);
67
70
  if (notif_configs.length === 0)
68
71
  return;
@@ -75,6 +78,8 @@ class QnWebhookAddressManager {
75
78
  console.error(`QnWebhookAddressManager: Failed to fetch webhooks for blockchain=${blockchain}`, error);
76
79
  return;
77
80
  }
81
+ // Get all addresses to add to webhook
82
+ const addresses = yield this.fetch_all_db_addresses(blockchain);
78
83
  const entries = [];
79
84
  for (const notif_config of notif_configs) {
80
85
  const existing = all_webhooks.find(w => {
@@ -86,8 +91,6 @@ class QnWebhookAddressManager {
86
91
  console.warn(`QnWebhookAddressManager: No webhook found for config=${notif_config.name} network=${notif_config.network}`);
87
92
  continue;
88
93
  }
89
- const arg_key = notif_config.template === 'solanaWalletFilter' ? 'accounts' : 'wallets';
90
- const addresses = ((_a = existing.templateArgs) === null || _a === void 0 ? void 0 : _a[arg_key]) || [];
91
94
  entries.push({
92
95
  webhook_id: existing.id,
93
96
  name: notif_config.name.toLowerCase(),
@@ -114,11 +117,14 @@ class QnWebhookAddressManager {
114
117
  add_address(blockchain, address) {
115
118
  return __awaiter(this, void 0, void 0, function* () {
116
119
  const entries = yield this.ensure_loaded(blockchain);
120
+ console.log(`Pushing ${entries.length} addresses: `, entries);
121
+ console.log(`Pushed ${entries.length} addresses `);
117
122
  for (const entry of entries) {
118
123
  if (entry.address_set.has(address))
119
124
  continue;
120
125
  entry.address_set.add(address);
121
126
  try {
127
+ console.log(`Adding addresses: `, entry.address_set);
122
128
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
123
129
  console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook`);
124
130
  }
@@ -261,5 +267,27 @@ class QnWebhookAddressManager {
261
267
  }
262
268
  });
263
269
  }
270
+ // Get all custodial addresses for monitoring
271
+ fetch_all_db_addresses(blockchain) {
272
+ return __awaiter(this, void 0, void 0, function* () {
273
+ const service = new DepositAddressService_1.default(this.db);
274
+ const addresses = [];
275
+ let page = 1;
276
+ const page_size = ADDRESS_SYNC_BATCH_SIZE;
277
+ while (true) {
278
+ const result = yield service.getDepositAddressesPaginated(page, page_size, { blockchain });
279
+ for (const item of result.items) {
280
+ addresses.push(item.address);
281
+ }
282
+ if (!result.has_next)
283
+ break;
284
+ page++;
285
+ }
286
+ if (addresses.length > ADDRESS_LOG_THRESHOLD) {
287
+ console.warn(`QnWebhookAddressManager: ${addresses.length} addresses fetched for blockchain=${blockchain} — ensure QN webhook limit is sufficient`);
288
+ }
289
+ return addresses;
290
+ });
291
+ }
264
292
  }
265
293
  exports.default = QnWebhookAddressManager;
@@ -1,8 +1,10 @@
1
- export interface SweepSearchFilters {
1
+ export interface SweepHistoryFilters {
2
2
  blockchain?: string;
3
3
  chain_id?: string;
4
4
  token?: string;
5
5
  address?: string;
6
+ }
7
+ export interface SweepSearchFilters extends SweepHistoryFilters {
6
8
  job_status?: SweepJobStatus;
7
9
  }
8
10
  export type SweepJobStatus = 'pending' | 'queued' | 'executing' | 'confirming' | 'transferred' | 'failed_retryable' | 'failed_permanent';
@@ -1 +1 @@
1
- {"version":3,"file":"sweep_job_service.d.ts","sourceRoot":"","sources":["../../../src/services/types/sweep_job_service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,cAAc,CAAC;CAC/B;AAGD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
1
+ {"version":3,"file":"sweep_job_service.d.ts","sourceRoot":"","sources":["../../../src/services/types/sweep_job_service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,EAAE,cAAc,CAAC;CAC/B;AAGD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
@@ -8,6 +8,7 @@ export interface IWallet {
8
8
  childIndex: number;
9
9
  transactionCount: number;
10
10
  blockchain: string;
11
+ expiresAt: Date;
11
12
  updatedAt: Date;
12
13
  createdAt: Date;
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../../src/services/types/wallet_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../../src/services/types/wallet_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ercworldio/blockchain-shared",
3
- "version": "1.0.1-dev.0",
3
+ "version": "1.0.1-dev.10",
4
4
  "description": "Shared library for blockchain projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",