@ercworldio/blockchain-shared 1.0.1-dev.9 → 1.0.2-dev.1

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 (48) hide show
  1. package/README.md +26 -0
  2. package/build/chains/networks_dev.json +50 -8
  3. package/build/chains/networks_prod-bu.json +98 -7
  4. package/build/chains/networks_prod-dz.json +194 -12
  5. package/build/chains/networks_stg-bu.json +14 -7
  6. package/build/chains/networks_stg-dz.json +60 -20
  7. package/build/errors/AdminErrors.d.ts +5 -9
  8. package/build/errors/AdminErrors.d.ts.map +1 -1
  9. package/build/errors/AdminErrors.js +49 -24
  10. package/build/errors/AlchemyErrors.d.ts +14 -18
  11. package/build/errors/AlchemyErrors.d.ts.map +1 -1
  12. package/build/errors/AlchemyErrors.js +76 -49
  13. package/build/errors/BalanceErrors.d.ts +3 -7
  14. package/build/errors/BalanceErrors.d.ts.map +1 -1
  15. package/build/errors/BalanceErrors.js +47 -26
  16. package/build/errors/DatabaseErrors.d.ts +5 -9
  17. package/build/errors/DatabaseErrors.d.ts.map +1 -1
  18. package/build/errors/DatabaseErrors.js +49 -28
  19. package/build/errors/TransactionsErrors.d.ts +15 -20
  20. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  21. package/build/errors/TransactionsErrors.js +81 -66
  22. package/build/errors/VoltageErrors.d.ts +8 -13
  23. package/build/errors/VoltageErrors.d.ts.map +1 -1
  24. package/build/errors/VoltageErrors.js +58 -45
  25. package/build/errors/WalletErrors.d.ts +6 -12
  26. package/build/errors/WalletErrors.d.ts.map +1 -1
  27. package/build/errors/WalletErrors.js +48 -37
  28. package/build/errors/errors.d.ts +137 -27
  29. package/build/errors/errors.d.ts.map +1 -1
  30. package/build/errors/errors.js +230 -66
  31. package/build/errors/index.d.ts +37 -36
  32. package/build/errors/index.d.ts.map +1 -1
  33. package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
  34. package/build/services/AlchemyWebhookAddressManager.js +3 -1
  35. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
  36. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  37. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
  38. package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
  39. package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
  40. package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
  41. package/build/services/types/chain_manager.d.ts +6 -0
  42. package/build/services/types/chain_manager.d.ts.map +1 -1
  43. package/build/utils/Logger.d.ts.map +1 -1
  44. package/build/utils/Logger.js +13 -2
  45. package/build/utils/solana.d.ts +2 -1
  46. package/build/utils/solana.d.ts.map +1 -1
  47. package/build/utils/solana.js +28 -3
  48. package/package.json +1 -1
@@ -13,7 +13,8 @@
13
13
  "funding_wallet": "0x93c7Db61068415Bf0af97849F15eec295a1670dd",
14
14
  "treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
15
15
  "overflow_treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
16
- "overflow_threshold_decimal": 100000
16
+ "overflow_threshold_decimal": 100000,
17
+ "min_funding_wallet_balance_usd": 5
17
18
  },
18
19
  "custodialAlchemyWebhooks": [
19
20
  {
@@ -93,7 +94,8 @@
93
94
  "funding_wallet": "0x93c7Db61068415Bf0af97849F15eec295a1670dd",
94
95
  "treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
95
96
  "overflow_treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
96
- "overflow_threshold_decimal": 100000
97
+ "overflow_threshold_decimal": 100000,
98
+ "min_funding_wallet_balance_usd": 5
97
99
  },
98
100
  "custodialAlchemyWebhooks": [
99
101
  {
@@ -173,7 +175,8 @@
173
175
  "funding_wallet": "79ojMgdb9dLuGnFRjaNzkYmd4NFxV5ukRTpYSrTxmTFN",
174
176
  "treasury_receiver": "Fi2BknBbXXcjHst2PwQQVZwYx8NHx6k8NsU5cLXhTwmT",
175
177
  "overflow_treasury_receiver": "Fi2BknBbXXcjHst2PwQQVZwYx8NHx6k8NsU5cLXhTwmT",
176
- "overflow_threshold_decimal": 100000
178
+ "overflow_threshold_decimal": 100000,
179
+ "min_funding_wallet_balance_usd": 5
177
180
  },
178
181
  "custodialAlchemyWebhooks": [
179
182
  {
@@ -253,7 +256,8 @@
253
256
  "funding_wallet": "0x93c7Db61068415Bf0af97849F15eec295a1670dd",
254
257
  "treasury_receiver": "0x45B284aB71F18866438E33f1f68e7561aa8D5806",
255
258
  "overflow_treasury_receiver": "0x45B284aB71F18866438E33f1f68e7561aa8D5806",
256
- "overflow_threshold_decimal": 100000
259
+ "overflow_threshold_decimal": 100000,
260
+ "min_funding_wallet_balance_usd": 5
257
261
  },
258
262
  "custodialAlchemyWebhooks": [
259
263
  {
@@ -333,7 +337,8 @@
333
337
  "funding_wallet": "0x93c7Db61068415Bf0af97849F15eec295a1670dd",
334
338
  "treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
335
339
  "overflow_treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
336
- "overflow_threshold_decimal": 100000
340
+ "overflow_threshold_decimal": 100000,
341
+ "min_funding_wallet_balance_usd": 5
337
342
  },
338
343
  "custodialAlchemyWebhooks": [
339
344
  {
@@ -402,7 +407,8 @@
402
407
  "funding_wallet": "0x93c7Db61068415Bf0af97849F15eec295a1670dd",
403
408
  "treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
404
409
  "overflow_treasury_receiver": "0x8A729F30A9860ad6148D35A4Df49314f571bE84d",
405
- "overflow_threshold_decimal": 100000
410
+ "overflow_threshold_decimal": 100000,
411
+ "min_funding_wallet_balance_usd": 5
406
412
  },
407
413
  "custodialAlchemyWebhooks": [
408
414
  {
@@ -483,7 +489,8 @@
483
489
  "funding_wallet": "TWA4NYYdVtnb7iZfmyruC5MefsFdw84iZu",
484
490
  "treasury_receiver": "TWA4NYYdVtnb7iZfmyruC5MefsFdw84iZu",
485
491
  "overflow_treasury_receiver": "TWA4NYYdVtnb7iZfmyruC5MefsFdw84iZu",
486
- "overflow_threshold_decimal": 100000
492
+ "overflow_threshold_decimal": 100000,
493
+ "min_funding_wallet_balance_usd": 5
487
494
  },
488
495
  "rpcMetadata": {
489
496
  "rpcBaseUrl": "https://rpc.ankr.com/premium-http/tron",
@@ -13,7 +13,8 @@
13
13
  "funding_wallet": "0x5BCAbaCAC48055E02eDc1A640E9208C867AbC4Fa",
14
14
  "treasury_receiver": "0xD7205fD63Fa5def834DD3556c149FF7911478391",
15
15
  "overflow_treasury_receiver": "0xD7205fD63Fa5def834DD3556c149FF7911478391",
16
- "overflow_threshold_decimal": 100000
16
+ "overflow_threshold_decimal": 100000,
17
+ "min_funding_wallet_balance_usd": 5
17
18
  },
18
19
  "custodialAlchemyWebhooks": [
19
20
  {
@@ -62,6 +63,7 @@
62
63
  "type": "native",
63
64
  "decimals": 18,
64
65
  "address": "0x0000000000000000000000000000000000000000",
66
+ "isStableCoin": false,
65
67
  "sweepThreshold": 0.004,
66
68
  "sweepWalletMinBalance": 0.0002
67
69
  },
@@ -72,8 +74,9 @@
72
74
  "type": "erc20",
73
75
  "decimals": 6,
74
76
  "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
75
- "sweepThreshold": 5,
76
- "sweepWalletMinBalance": 1
77
+ "isStableCoin": true,
78
+ "sweepThreshold": 1,
79
+ "sweepWalletMinBalance": 0
77
80
  },
78
81
  {
79
82
  "name": "Circle Token",
@@ -83,8 +86,19 @@
83
86
  "isStableCoin": true,
84
87
  "decimals": 6,
85
88
  "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
86
- "sweepThreshold": 4,
87
- "sweepWalletMinBalance": 1
89
+ "sweepThreshold": 1,
90
+ "sweepWalletMinBalance": 0.1
91
+ },
92
+ {
93
+ "name": "PalmUSD",
94
+ "symbol": "PUSD",
95
+ "token_standard": "ERC-20",
96
+ "type": "erc20",
97
+ "isStableCoin": true,
98
+ "decimals": 6,
99
+ "address": "0xFAF0cEe6B20e2Aaa4B80748a6AF4CD89609a3d78",
100
+ "sweepThreshold": 1,
101
+ "sweepWalletMinBalance": 0.1
88
102
  }
89
103
  ]
90
104
  },
@@ -102,7 +116,8 @@
102
116
  "funding_wallet": "0x5BCAbaCAC48055E02eDc1A640E9208C867AbC4Fa",
103
117
  "treasury_receiver": "0xedb9e987Da3806205D2f1e246Eb8c538A872783E",
104
118
  "overflow_treasury_receiver": "0xedb9e987Da3806205D2f1e246Eb8c538A872783E",
105
- "overflow_threshold_decimal": 100000
119
+ "overflow_threshold_decimal": 100000,
120
+ "min_funding_wallet_balance_usd": 5
106
121
  },
107
122
  "custodialAlchemyWebhooks": [
108
123
  {
@@ -149,6 +164,7 @@
149
164
  "symbol": "BNB",
150
165
  "token_standard": "BEP-20",
151
166
  "type": "native",
167
+ "isStableCoin": false,
152
168
  "decimals": 18,
153
169
  "address": "0x0000000000000000000000000000000000000000",
154
170
  "sweepThreshold": 0.008,
@@ -160,9 +176,10 @@
160
176
  "token_standard": "BEP-20",
161
177
  "type": "erc20",
162
178
  "decimals": 18,
179
+ "isStableCoin": true,
163
180
  "address": "0x55d398326f99059fF775485246999027B3197955",
164
- "sweepThreshold": 5,
165
- "sweepWalletMinBalance": 1
181
+ "sweepThreshold": 1,
182
+ "sweepWalletMinBalance": 0.1
166
183
  }
167
184
  ]
168
185
  },
@@ -180,7 +197,8 @@
180
197
  "funding_wallet": "sB5d7n9EK7QNmFqB9VmLdi8FMf2yJxbovfuz9mToUqD",
181
198
  "treasury_receiver": "yCwEYHrHy2Ri81vxkYbwmuPcLubCZe82mWRUhDciqx6",
182
199
  "overflow_treasury_receiver": "yCwEYHrHy2Ri81vxkYbwmuPcLubCZe82mWRUhDciqx6",
183
- "overflow_threshold_decimal": 100000
200
+ "overflow_threshold_decimal": 100000,
201
+ "min_funding_wallet_balance_usd": 5
184
202
  },
185
203
  "custodialAlchemyWebhooks": [
186
204
  {
@@ -242,7 +260,18 @@
242
260
  "decimals": 6,
243
261
  "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
244
262
  "sweepThreshold": 1,
245
- "sweepWalletMinBalance": 1
263
+ "sweepWalletMinBalance": 0.1
264
+ },
265
+ {
266
+ "name": "PalmUSD",
267
+ "symbol": "PUSD",
268
+ "token_standard": "SOL",
269
+ "type": "erc20",
270
+ "isStableCoin": true,
271
+ "decimals": 6,
272
+ "address": "CZzgUBvxaMLwMhVSLgqJn3npmxoTo6nzMNQPAnwtHF3s",
273
+ "sweepThreshold": 1,
274
+ "sweepWalletMinBalance": 0.1
246
275
  }
247
276
  ]
248
277
  },
@@ -260,7 +289,8 @@
260
289
  "funding_wallet": "0x5BCAbaCAC48055E02eDc1A640E9208C867AbC4Fa",
261
290
  "treasury_receiver": "0xc4b25365d597EB6B7Db78429f70b8E325C2456BD",
262
291
  "overflow_treasury_receiver": "0xc4b25365d597EB6B7Db78429f70b8E325C2456BD",
263
- "overflow_threshold_decimal": 100000
292
+ "overflow_threshold_decimal": 100000,
293
+ "min_funding_wallet_balance_usd": 5
264
294
  },
265
295
  "custodialAlchemyWebhooks": [
266
296
  {
@@ -307,6 +337,7 @@
307
337
  "symbol": "POL",
308
338
  "token_standard": "POL",
309
339
  "type": "native",
340
+ "isStableCoin": false,
310
341
  "decimals": 18,
311
342
  "address": "0x0000000000000000000000000000000000000000",
312
343
  "sweepThreshold": 10,
@@ -317,10 +348,11 @@
317
348
  "symbol": "USDT",
318
349
  "token_standard": "POL",
319
350
  "type": "erc20",
351
+ "isStableCoin": true,
320
352
  "decimals": 6,
321
353
  "address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
322
- "sweepThreshold": 0,
323
- "sweepWalletMinBalance": 1
354
+ "sweepThreshold": 1,
355
+ "sweepWalletMinBalance": 0.1
324
356
  }
325
357
  ]
326
358
  },
@@ -338,7 +370,8 @@
338
370
  "funding_wallet": "0x5BCAbaCAC48055E02eDc1A640E9208C867AbC4Fa",
339
371
  "treasury_receiver": "0xA228E95a253B42fFAc8C26Df2ca1EdD0C2D4A191",
340
372
  "overflow_treasury_receiver": "0xA228E95a253B42fFAc8C26Df2ca1EdD0C2D4A191",
341
- "overflow_threshold_decimal": 100000
373
+ "overflow_threshold_decimal": 100000,
374
+ "min_funding_wallet_balance_usd": 5
342
375
  },
343
376
  "custodialAlchemyWebhooks": [
344
377
  {
@@ -386,6 +419,7 @@
386
419
  "token_standard": "ERC-20",
387
420
  "type": "native",
388
421
  "decimals": 18,
422
+ "isStableCoin": false,
389
423
  "address": "0x0000000000000000000000000000000000000000",
390
424
  "sweepThreshold": 10,
391
425
  "sweepWalletMinBalance": 0.1
@@ -406,7 +440,8 @@
406
440
  "funding_wallet": "0x5BCAbaCAC48055E02eDc1A640E9208C867AbC4Fa",
407
441
  "treasury_receiver": "0xD7205fD63Fa5def834DD3556c149FF7911478391",
408
442
  "overflow_treasury_receiver": "0xD7205fD63Fa5def834DD3556c149FF7911478391",
409
- "overflow_threshold_decimal": 100000
443
+ "overflow_threshold_decimal": 100000,
444
+ "min_funding_wallet_balance_usd": 5
410
445
  },
411
446
  "custodialAlchemyWebhooks": [
412
447
  {
@@ -453,6 +488,7 @@
453
488
  "symbol": "AVAX",
454
489
  "token_standard": "AVAXC",
455
490
  "type": "native",
491
+ "isStableCoin": false,
456
492
  "decimals": 18,
457
493
  "address": "0x0000000000000000000000000000000000000000",
458
494
  "sweepThreshold": 0.05,
@@ -463,10 +499,11 @@
463
499
  "symbol": "USDT",
464
500
  "token_standard": "AVAXC",
465
501
  "type": "erc20",
502
+ "isStableCoin": true,
466
503
  "decimals": 6,
467
504
  "address": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
468
- "sweepThreshold": 5,
469
- "sweepWalletMinBalance": 1
505
+ "sweepThreshold": 1,
506
+ "sweepWalletMinBalance": 0.1
470
507
  }
471
508
  ]
472
509
  },
@@ -485,7 +522,8 @@
485
522
  "funding_wallet": "TUWoLoAJKqWome13wtHZ7m62Apa2rT87Ky",
486
523
  "treasury_receiver": "TUWoLoAJKqWome13wtHZ7m62Apa2rT87Ky",
487
524
  "overflow_treasury_receiver": "TUWoLoAJKqWome13wtHZ7m62Apa2rT87Ky",
488
- "overflow_threshold_decimal": 100000
525
+ "overflow_threshold_decimal": 100000,
526
+ "min_funding_wallet_balance_usd": 5
489
527
  },
490
528
  "rpcMetadata": {
491
529
  "rpcBaseUrl": "https://rpc.ankr.com/premium-http/tron",
@@ -522,6 +560,7 @@
522
560
  "symbol": "TRX",
523
561
  "token_standard": "TRX",
524
562
  "type": "native",
563
+ "isStableCoin": false,
525
564
  "decimals": 6,
526
565
  "address": "0000000000000000000000000000000000000000",
527
566
  "sweepThreshold": 10,
@@ -532,10 +571,11 @@
532
571
  "symbol": "USDT",
533
572
  "token_standard": "TRC-20",
534
573
  "type": "trc20",
574
+ "isStableCoin": true,
535
575
  "decimals": 6,
536
576
  "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
537
- "sweepThreshold": 5,
538
- "sweepWalletMinBalance": 1
577
+ "sweepThreshold": 1,
578
+ "sweepWalletMinBalance": 0.1
539
579
  }
540
580
  ]
541
581
  }
@@ -1,4 +1,4 @@
1
- import BaseErrors from "./errors";
1
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
2
2
  interface ErrorHandlerResponse {
3
3
  status_code: number;
4
4
  response: ResponseObject;
@@ -7,19 +7,15 @@ interface ErrorHandlerResponse {
7
7
  interface ResponseObject {
8
8
  status: boolean;
9
9
  message: string;
10
+ error_code: ErrorCode | null;
10
11
  data: any;
11
12
  error: string;
12
13
  }
13
14
  declare class AdminErrors extends BaseErrors {
14
- /** Error Definition */
15
- UnsupportedAlchemyNetwork(chainId: string): string;
16
- FailedInitializeWebhooks(subscription: string): string;
17
- /** Handler methods */
15
+ UnsupportedAlchemyNetwork(_?: any): "The blockchain network is not supported by Alchemy";
16
+ FailedInitializeWebhooks(_?: any): "Failed to initialize webhooks. Please try again later";
18
17
  handle_admin_error: (error: any, source_method: string) => ErrorHandlerResponse;
19
- get_error_code: (message: string) => {
20
- code: number;
21
- error: string;
22
- };
18
+ get_error_code: (message: string) => ErrorCodeEntry;
23
19
  }
24
20
  export default AdminErrors;
25
21
  //# sourceMappingURL=AdminErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminErrors.d.ts","sourceRoot":"","sources":["../../src/errors/AdminErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,WAAY,SAAQ,UAAU;IAChC,uBAAuB;IAEhB,yBAAyB,CAAC,OAAO,EAAE,MAAM;IACzC,wBAAwB,CAAC,YAAY,EAAE,MAAM;IACpD,sBAAsB;IAEf,kBAAkB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAapF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAWvC;CACJ;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"AdminErrors.d.ts","sourceRoot":"","sources":["../../src/errors/AdminErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,WAAY,SAAQ,UAAU;IACzB,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG;IACjC,wBAAwB,CAAC,CAAC,CAAC,EAAE,GAAG;IAEhC,kBAAkB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAapF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAQxD;CACJ;AAED,eAAe,WAAW,CAAC"}
@@ -1,45 +1,70 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = __importDefault(require("./errors"));
36
+ const errors_1 = __importStar(require("./errors"));
7
37
  class AdminErrors extends errors_1.default {
8
38
  constructor() {
9
- /** Error Definition */
10
39
  super(...arguments);
11
- /** Handler methods */
12
40
  this.handle_admin_error = (error, source_method) => {
13
- let status = this.get_error_code(error.message);
14
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
15
43
  status_code: status.code,
44
+ source_method,
16
45
  response: {
17
46
  status: false,
18
- message: status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message,
47
+ message: status.code === 500 && !error.message ? "An unexpected error occurred. Please try again later." : error.message,
48
+ error_code: status.error_code,
19
49
  data: {},
20
50
  error: status.error
21
51
  }
22
52
  };
23
- return Object.assign(Object.assign({}, result), { source_method });
24
53
  };
25
- // Get the status code and error message
26
54
  this.get_error_code = (message) => {
27
- // Try base codes
28
- let response = this.get_error_code_base(message);
29
- if (response) {
30
- return response;
31
- }
32
- // Try custom class error codes
33
- // if (message.includes("")) return this.codes[500];
34
- return {
35
- code: 500,
36
- error: "Internal Server Error"
37
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("not supported by Alchemy"))
59
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_ALCHEMY_NETWORK });
60
+ if (message.includes("Failed to initialize webhooks"))
61
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_INITIALIZE_WEBHOOKS });
62
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
38
63
  };
39
64
  }
40
- UnsupportedAlchemyNetwork(chainId) { return `Unsupported alchemy network for chain ${chainId}`; }
65
+ UnsupportedAlchemyNetwork(_) { return errors_1.ErrorMessages.UNSUPPORTED_ALCHEMY_NETWORK; }
41
66
  ;
42
- FailedInitializeWebhooks(subscription) { return `Failed to initialize webhooks on subscription ${subscription}`; }
67
+ FailedInitializeWebhooks(_) { return errors_1.ErrorMessages.FAILED_INITIALIZE_WEBHOOKS; }
43
68
  ;
44
69
  }
45
70
  exports.default = AdminErrors;
@@ -1,4 +1,4 @@
1
- import BaseErrors from "./errors";
1
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
2
2
  interface ErrorHandlerResponse {
3
3
  status_code: number;
4
4
  response: ResponseObject;
@@ -7,28 +7,24 @@ interface ErrorHandlerResponse {
7
7
  interface ResponseObject {
8
8
  status: boolean;
9
9
  message: string;
10
+ error_code: ErrorCode | null;
10
11
  data: any;
11
12
  error: string;
12
13
  }
13
14
  declare class AlchemyErrors extends BaseErrors {
14
- /** Error Definition */
15
- InvoiceSubscriberError(r_hash: string): string;
16
- RequireMinAmount(min_amount: number): string;
17
- PaymentIdNotFound(paymentId: string): string;
18
- AlreadyPaidInvoice(): string;
19
- PaymentFailed(reason: string): string;
20
- FailedWebhookAction(action_type: string, success_count: number, expected_success_count: number): string;
21
- NotInitializedOrmRepo(repo_name: string): string;
22
- NoWebhooks(subscription: string): string;
23
- FailedGetWebhookAddresses(subscription: string, webhook_id: string): string;
24
- UnsupportedAlchemyNetwork(chainId: string): string;
25
- FailedInitializeWebhooks(subscription: string): string;
26
- /** Handler methods */
15
+ InvoiceSubscriberError(_?: any): "Failed to subscribe to the invoice. Please try again";
16
+ RequireMinAmount(_?: any): "The amount is below the minimum required";
17
+ PaymentIdNotFound(_?: any): "Invoice not found or expired. Please request a new one";
18
+ AlreadyPaidInvoice(_?: any): "This invoice has already been paid";
19
+ PaymentFailed(_?: any): "Payment could not be processed. Please try again";
20
+ FailedWebhookAction(_?: any, __?: any, ___?: any): "A webhook operation failed. Please try again later";
21
+ NotInitializedOrmRepo(_?: any): "A required database repository is not initialized";
22
+ NoWebhooks(_?: any): "No webhooks found for this subscription";
23
+ FailedGetWebhookAddresses(_?: any, __?: any): "Failed to retrieve webhook addresses. Please try again later";
24
+ UnsupportedAlchemyNetwork(_?: any): "The blockchain network is not supported by Alchemy";
25
+ FailedInitializeWebhooks(_?: any): "Failed to initialize webhooks. Please try again later";
27
26
  handle_alchemy_error: (error: any, source_method: string) => ErrorHandlerResponse;
28
- get_error_code: (message: string) => {
29
- code: number;
30
- error: string;
31
- };
27
+ get_error_code: (message: string) => ErrorCodeEntry;
32
28
  }
33
29
  export default AlchemyErrors;
34
30
  //# sourceMappingURL=AlchemyErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AlchemyErrors.d.ts","sourceRoot":"","sources":["../../src/errors/AlchemyErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,aAAc,SAAQ,UAAU;IAClC,uBAAuB;IAGhB,sBAAsB,CAAC,MAAM,EAAE,MAAM;IACrC,gBAAgB,CAAC,UAAU,EAAE,MAAM;IACnC,iBAAiB,CAAC,SAAS,EAAE,MAAM;IACnC,kBAAkB;IAClB,aAAa,CAAC,MAAM,EAAE,MAAM;IAE5B,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM;IAC9F,qBAAqB,CAAC,SAAS,EAAE,MAAM;IACvC,UAAU,CAAC,YAAY,EAAE,MAAM;IAC/B,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAElE,yBAAyB,CAAC,OAAO,EAAE,MAAM;IACzC,wBAAwB,CAAC,YAAY,EAAE,MAAM;IACpD,sBAAsB;IAGf,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAkBvC;CACJ;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AlchemyErrors.d.ts","sourceRoot":"","sources":["../../src/errors/AlchemyErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,aAAc,SAAQ,UAAU;IAC3B,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG;IAChD,qBAAqB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC7B,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG;IAClB,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IAC3C,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG;IACjC,wBAAwB,CAAC,CAAC,CAAC,EAAE,GAAG;IAEhC,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAiBxD;CACJ;AAED,eAAe,aAAa,CAAC"}
@@ -1,79 +1,106 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = __importDefault(require("./errors"));
36
+ const errors_1 = __importStar(require("./errors"));
7
37
  class AlchemyErrors extends errors_1.default {
8
38
  constructor() {
9
- /** Error Definition */
10
- // public RequirePaymentId() { return "'paymentId' is required" };
11
39
  super(...arguments);
12
- /** Handler methods */
13
- // Return status code, error, and message
14
40
  this.handle_alchemy_error = (error, source_method) => {
15
- let status = this.get_error_code(error.message);
16
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
17
43
  status_code: status.code,
44
+ source_method,
18
45
  response: {
19
46
  status: false,
20
- message: status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message,
47
+ message: status.code === 500 && !error.message ? "An unexpected error occurred. Please try again later." : error.message,
48
+ error_code: status.error_code,
21
49
  data: {},
22
50
  error: status.error
23
51
  }
24
52
  };
25
- return Object.assign(Object.assign({}, result), { source_method });
26
53
  };
27
- // Get the status code and error message
28
54
  this.get_error_code = (message) => {
29
- // Try base codes
30
- let response = this.get_error_code_base(message);
31
- if (response) {
32
- return response;
33
- }
34
- // Try custom class error codes
35
- if (message.includes("User Id associated with payment ID"))
36
- return this.codes[400];
37
- if (message.includes("Failed to delete all webhooks"))
38
- return this.codes[500];
39
- if (message.includes("TypeORM database repository"))
40
- return this.codes[500];
41
- if (message.includes("No webhooks found in"))
42
- return this.codes[500];
43
- if (message.includes("Failed to get addresses for webhook id"))
44
- return this.codes[500];
45
- if (message.includes("AlchemyActionError:"))
46
- return this.codes[500];
47
- if (message.includes("Unsupported alchemy network for chain"))
48
- return this.codes[500];
49
- return {
50
- code: 500,
51
- error: "Internal Server Error"
52
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("Failed to subscribe to the invoice"))
59
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.INVOICE_SUBSCRIBER_ERROR });
60
+ if (message.includes("amount is below the minimum required"))
61
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.REQUIRE_MIN_AMOUNT });
62
+ if (message.includes("Invoice not found or expired"))
63
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.PAYMENT_ID_NOT_FOUND });
64
+ if (message.includes("already been paid"))
65
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.ALREADY_PAID_INVOICE });
66
+ if (message.includes("Payment could not be processed"))
67
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.PAYMENT_FAILED });
68
+ if (message.includes("webhook operation failed"))
69
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_WEBHOOK_ACTION });
70
+ if (message.includes("database repository is not initialized"))
71
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.ORM_REPO_NOT_INITIALIZED });
72
+ if (message.includes("No webhooks found for this subscription"))
73
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.NO_WEBHOOKS });
74
+ if (message.includes("Failed to retrieve webhook addresses"))
75
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_GET_WEBHOOK_ADDRESSES });
76
+ if (message.includes("not supported by Alchemy"))
77
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_ALCHEMY_NETWORK });
78
+ if (message.includes("Failed to initialize webhooks"))
79
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_INITIALIZE_WEBHOOKS });
80
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
53
81
  };
54
82
  }
55
- InvoiceSubscriberError(r_hash) { return `Failed to subscribe to invoice ${r_hash}`; }
83
+ InvoiceSubscriberError(_) { return errors_1.ErrorMessages.INVOICE_SUBSCRIBER_ERROR; }
56
84
  ;
57
- RequireMinAmount(min_amount) { return `Amount must be greater than ${min_amount} satoshis."`; }
85
+ RequireMinAmount(_) { return errors_1.ErrorMessages.REQUIRE_MIN_AMOUNT; }
58
86
  ;
59
- PaymentIdNotFound(paymentId) { return `User Id associated with payment ID ${paymentId} not found. Please request a new invoice.`; }
87
+ PaymentIdNotFound(_) { return errors_1.ErrorMessages.PAYMENT_ID_NOT_FOUND; }
60
88
  ;
61
- AlreadyPaidInvoice() { return "Invoice is already paid"; }
89
+ AlreadyPaidInvoice(_) { return errors_1.ErrorMessages.ALREADY_PAID_INVOICE; }
62
90
  ;
63
- PaymentFailed(reason) { return `Payment failed: ${reason}`; }
91
+ PaymentFailed(_) { return errors_1.ErrorMessages.PAYMENT_FAILED; }
64
92
  ;
65
- // public FailedWebhookDeleteAll(success_count: number, expected_success_count: number) { return `Failed to delete all webhooks. Deleted ${success_count} out of ${expected_success_count}` };
66
- FailedWebhookAction(action_type, success_count, expected_success_count) { return `AlchemyActionError: Failed to ${action_type}. Success count: ${success_count} out of ${expected_success_count}`; }
93
+ FailedWebhookAction(_, __, ___) { return errors_1.ErrorMessages.FAILED_WEBHOOK_ACTION; }
67
94
  ;
68
- NotInitializedOrmRepo(repo_name) { return `TypeORM database repository '${repo_name}' not initialized.`; }
95
+ NotInitializedOrmRepo(_) { return errors_1.ErrorMessages.ORM_REPO_NOT_INITIALIZED; }
69
96
  ;
70
- NoWebhooks(subscription) { return `No webhooks found in ${subscription} subscription.`; }
97
+ NoWebhooks(_) { return errors_1.ErrorMessages.NO_WEBHOOKS; }
71
98
  ;
72
- FailedGetWebhookAddresses(subscription, webhook_id) { return `Failed to get addresses for webhook id ${webhook_id} in ${subscription} subscription`; }
99
+ FailedGetWebhookAddresses(_, __) { return errors_1.ErrorMessages.FAILED_GET_WEBHOOK_ADDRESSES; }
73
100
  ;
74
- UnsupportedAlchemyNetwork(chainId) { return `Unsupported alchemy network for chain ${chainId}`; }
101
+ UnsupportedAlchemyNetwork(_) { return errors_1.ErrorMessages.UNSUPPORTED_ALCHEMY_NETWORK; }
75
102
  ;
76
- FailedInitializeWebhooks(subscription) { return `Failed to initialize webhooks on subscription ${subscription}`; }
103
+ FailedInitializeWebhooks(_) { return errors_1.ErrorMessages.FAILED_INITIALIZE_WEBHOOKS; }
77
104
  ;
78
105
  }
79
106
  exports.default = AlchemyErrors;