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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/build/chains/networks_dev.json +28 -7
  2. package/build/chains/networks_prod-bu.json +98 -7
  3. package/build/chains/networks_prod-dz.json +46 -12
  4. package/build/chains/networks_stg-bu.json +14 -7
  5. package/build/chains/networks_stg-dz.json +38 -20
  6. package/build/errors/AdminErrors.d.ts +5 -9
  7. package/build/errors/AdminErrors.d.ts.map +1 -1
  8. package/build/errors/AdminErrors.js +49 -24
  9. package/build/errors/AlchemyErrors.d.ts +14 -18
  10. package/build/errors/AlchemyErrors.d.ts.map +1 -1
  11. package/build/errors/AlchemyErrors.js +76 -49
  12. package/build/errors/BalanceErrors.d.ts +3 -7
  13. package/build/errors/BalanceErrors.d.ts.map +1 -1
  14. package/build/errors/BalanceErrors.js +47 -26
  15. package/build/errors/DatabaseErrors.d.ts +5 -9
  16. package/build/errors/DatabaseErrors.d.ts.map +1 -1
  17. package/build/errors/DatabaseErrors.js +49 -28
  18. package/build/errors/TransactionsErrors.d.ts +15 -20
  19. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  20. package/build/errors/TransactionsErrors.js +81 -66
  21. package/build/errors/VoltageErrors.d.ts +8 -13
  22. package/build/errors/VoltageErrors.d.ts.map +1 -1
  23. package/build/errors/VoltageErrors.js +58 -45
  24. package/build/errors/WalletErrors.d.ts +6 -12
  25. package/build/errors/WalletErrors.d.ts.map +1 -1
  26. package/build/errors/WalletErrors.js +48 -37
  27. package/build/errors/errors.d.ts +137 -27
  28. package/build/errors/errors.d.ts.map +1 -1
  29. package/build/errors/errors.js +230 -66
  30. package/build/errors/index.d.ts +37 -36
  31. package/build/errors/index.d.ts.map +1 -1
  32. package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
  33. package/build/services/AlchemyWebhookAddressManager.js +3 -1
  34. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
  35. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  36. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
  37. package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
  38. package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
  39. package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
  40. package/build/services/types/chain_manager.d.ts +5 -0
  41. package/build/services/types/chain_manager.d.ts.map +1 -1
  42. package/build/utils/Logger.d.ts.map +1 -1
  43. package/build/utils/Logger.js +13 -2
  44. package/build/utils/solana.d.ts +2 -1
  45. package/build/utils/solana.d.ts.map +1 -1
  46. package/build/utils/solana.js +28 -3
  47. package/package.json +1 -1
@@ -5,7 +5,7 @@ import WalletErrors from "./WalletErrors";
5
5
  import BalanceErrors from "./BalanceErrors";
6
6
  import DatabaseErrors from "./DatabaseErrors";
7
7
  import VoltageErrors from "./VoltageErrors";
8
- import BaseErrors from "./errors";
8
+ import BaseErrors, { ErrorCode } from "./errors";
9
9
  import { RequestStatus } from "../services/types/claim";
10
10
  interface ErrorHandlerResponse {
11
11
  status_code: number;
@@ -17,6 +17,7 @@ interface ResponseObject {
17
17
  message: string;
18
18
  data: any;
19
19
  error: string;
20
+ error_code: ErrorCode | null;
20
21
  }
21
22
  declare class AppErrors extends BaseErrors {
22
23
  admin: AdminErrors;
@@ -27,53 +28,53 @@ declare class AppErrors extends BaseErrors {
27
28
  database: DatabaseErrors;
28
29
  voltage: VoltageErrors;
29
30
  /** Delegated AdminErrors */
30
- adminUnsupportedAlchemyNetwork(chainId: string): string;
31
- adminFailedInitializeWebhooks(subscription: string): string;
31
+ adminUnsupportedAlchemyNetwork(chainId: string): "The blockchain network is not supported by Alchemy";
32
+ adminFailedInitializeWebhooks(subscription: string): "Failed to initialize webhooks. Please try again later";
32
33
  handle_admin_error(error: any, source_method: string): ErrorHandlerResponse;
33
34
  /** Delegated AlchemyErrors */
34
- alchemyInvoiceSubscriberError(r_hash: string): string;
35
- alchemyRequireMinAmount(min_amount: number): string;
36
- alchemyPaymentIdNotFound(paymentId: string): string;
37
- alchemyAlreadyPaidInvoice(): string;
38
- alchemyPaymentFailed(reason: string): string;
39
- alchemyFailedWebhookAction(action_type: string, success_count: number, expected_success_count: number): string;
40
- alchemyNotInitializedOrmRepo(repo_name: string): string;
41
- alchemyNoWebhooks(subscription: string): string;
42
- alchemyFailedGetWebhookAddresses(subscription: string, webhook_id: string): string;
43
- alchemyUnsupportedAlchemyNetwork(chainId: string): string;
44
- alchemyFailedInitializeWebhooks(subscription: string): string;
35
+ alchemyInvoiceSubscriberError(r_hash: string): "Failed to subscribe to the invoice. Please try again";
36
+ alchemyRequireMinAmount(min_amount: number): "The amount is below the minimum required";
37
+ alchemyPaymentIdNotFound(paymentId: string): "Invoice not found or expired. Please request a new one";
38
+ alchemyAlreadyPaidInvoice(): "This invoice has already been paid";
39
+ alchemyPaymentFailed(reason: string): "Payment could not be processed. Please try again";
40
+ alchemyFailedWebhookAction(action_type: string, success_count: number, expected_success_count: number): "A webhook operation failed. Please try again later";
41
+ alchemyNotInitializedOrmRepo(repo_name: string): "A required database repository is not initialized";
42
+ alchemyNoWebhooks(subscription: string): "No webhooks found for this subscription";
43
+ alchemyFailedGetWebhookAddresses(subscription: string, webhook_id: string): "Failed to retrieve webhook addresses. Please try again later";
44
+ alchemyUnsupportedAlchemyNetwork(chainId: string): "The blockchain network is not supported by Alchemy";
45
+ alchemyFailedInitializeWebhooks(subscription: string): "Failed to initialize webhooks. Please try again later";
45
46
  handle_alchemy_error(error: any, source_method: string): ErrorHandlerResponse;
46
47
  /** Delegated TransactionsErrors */
47
- RequestNotApproved(status: RequestStatus): string;
48
- ReceiverRequired(): string;
49
- UnexpectedReceiver(): string;
50
- DuplicateClaimJob(request_id: number): string;
51
- InvalidAddress(): string;
52
- RequestFulfilled(): string;
53
- NotExistWithdrawRequest(): string;
54
- UnsupportedNetwork(suggested_networks: string): string;
55
- UnsupportedAddress(network: string): string;
56
- UnexpectedAddressFormat(current_network: string, expected_network: string): string;
57
- EmptyPayload(action: string): string;
58
- OnlyStablecoinWithdrawal(): string;
48
+ RequestNotApproved(status: RequestStatus): "Withdrawal request has not been approved";
49
+ ReceiverRequired(): "Receiver address is missing. Please contact support";
50
+ UnexpectedReceiver(): "Please use the wallet address associated with your deposit";
51
+ DuplicateClaimJob(request_id: number): "A claim for this request is already in progress. Please check back in a few minutes";
52
+ InvalidAddress(): "The wallet address provided is invalid";
53
+ RequestFulfilled(): "This request has already been fulfilled";
54
+ NotExistWithdrawRequest(): "Withdrawal request not found";
55
+ UnsupportedNetwork(suggested_networks: string): "The selected network is not supported";
56
+ UnsupportedAddress(network: string): "The address format is not compatible with the selected network";
57
+ UnexpectedAddressFormat(current_network: string, expected_network: string): "The address does not match the expected format for the selected network";
58
+ EmptyPayload(action: string): "Request payload cannot be empty";
59
+ OnlyStablecoinWithdrawal(): "This network only supports stablecoin withdrawals";
59
60
  handle_transactions_error(error: any, source_method: string): ErrorHandlerResponse;
60
61
  /** Delegated WalletErrors */
61
- RenewNotAllowed(remaining_duration_s: number, remaining_threshold_s: number): string;
62
- NotAvailableParentIndex(index: number): string;
62
+ RenewNotAllowed(remaining_duration_s: number, remaining_threshold_s: number): "Your deposit address is not yet eligible for renewal";
63
+ NotAvailableParentIndex(index: number): "The selected wallet index is already in use";
63
64
  handle_wallet_error(error: any, source_method: string): ErrorHandlerResponse;
64
65
  /** Delegated BalanceErrors */
65
66
  handle_balance_error(error: any, source_method: string): ErrorHandlerResponse;
66
67
  /** Delegated DatabaseErrors */
67
- ServerUnavailable(): string;
68
- FailedGetTransactions(chainId: string, address: string): string;
68
+ ServerUnavailable(): "Service is temporarily unavailable. Please try again later";
69
+ FailedGetTransactions(chainId: string, address: string): "Failed to retrieve transaction count. Please try again later";
69
70
  handle_database_error(error: any, source_method: string): ErrorHandlerResponse;
70
71
  /** Delegated VoltageErrors */
71
- NotApprovedPaymentRequest(): string;
72
- InvoiceSubscriberError(r_hash: string): string;
73
- RequireMinAmount(min_amount: number): string;
74
- PaymentIdNotFound(paymentId: string): string;
75
- AlreadyPaidInvoice(): string;
76
- PaymentFailed(reason: string): string;
72
+ NotApprovedPaymentRequest(): "Payment request has not been approved";
73
+ InvoiceSubscriberError(r_hash: string): "Failed to subscribe to the invoice. Please try again";
74
+ RequireMinAmount(min_amount: number): "The amount is below the minimum required";
75
+ PaymentIdNotFound(paymentId: string): "Invoice not found or expired. Please request a new one";
76
+ AlreadyPaidInvoice(): "This invoice has already been paid";
77
+ PaymentFailed(reason: string): "Payment could not be processed. Please try again";
77
78
  handle_voltage_error(error: any, source_method: string): ErrorHandlerResponse;
78
79
  handle_error: (error: any, source_method: string) => ErrorHandlerResponse;
79
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,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;AAED,cAAM,SAAU,SAAQ,UAAU;I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;;;OAGG;IACU,qBAAqB,CAAC,GAAG,EAAE,yBAAyB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzJ;;;OAGG;IACU,0BAA0B,CAAC,GAAG,EAAE,yBAAyB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAWjK;AAED,eAAe,4BAA4B,CAAC"}
@@ -64,7 +64,9 @@ class AlchemyWebhookAddressManager {
64
64
  }
65
65
  return all.filter(w => w.network === network &&
66
66
  w.webhook_type === "ADDRESS_ACTIVITY" &&
67
- w.webhook_url.includes(env));
67
+ w.webhook_url.includes(env) &&
68
+ !w.webhook_url.includes("escrow-events") /// @DEV notice this is hardcoded to exclude escrow webhooks from adding custodial addresses to them
69
+ );
68
70
  }
69
71
  get_chain_ids_for_blockchain(blockchain) {
70
72
  return ChainManager_1.default.getInstance(this.config).blockchain_chainid_map.get(blockchain) || [];
@@ -14,8 +14,7 @@ declare class QnWebhookAddressManager {
14
14
  /** Returns the { name, network } pairs for the notification configs of a given chain. */
15
15
  private get_webhook_keys_for_chain;
16
16
  private get_notif_configs;
17
- private is_stale;
18
- private load;
17
+ private load_entries;
19
18
  private ensure_loaded;
20
19
  private matches_key;
21
20
  add_address(blockchain: BlockchainType, address: string): Promise<boolean>;
@@ -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,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,M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;;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"}
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const AsyncTTLCache_1 = __importDefault(require("../../utils/AsyncTTLCache"));
15
16
  const ChainManager_1 = __importDefault(require("../ChainManager"));
16
17
  const DepositAddressService_1 = __importDefault(require("../DepositAddressService"));
17
18
  const QnNotificationsApi_1 = __importDefault(require("./QnNotificationsApi"));
@@ -20,7 +21,7 @@ const ADDRESS_SYNC_BATCH_SIZE = 500;
20
21
  const ADDRESS_LOG_THRESHOLD = 1000;
21
22
  class QnWebhookAddressManager {
22
23
  constructor(config, db, rlc) {
23
- this.cache = new Map();
24
+ this.cache = AsyncTTLCache_1.default.create(CACHE_TTL_MS);
24
25
  this.config = config;
25
26
  this.api = QnNotificationsApi_1.default.getInstance(config, rlc);
26
27
  this.db = db;
@@ -58,34 +59,22 @@ class QnWebhookAddressManager {
58
59
  .flatMap(([_, cfg]) => cfg.quicknodeNotificationConfig.map(n => (Object.assign(Object.assign({}, n), { blockchain: cfg.blockchainType }))))
59
60
  .filter((n, i, arr) => arr.findIndex(x => x.name === n.name) === i);
60
61
  }
61
- is_stale(blockchain) {
62
- const cached = this.cache.get(blockchain);
63
- if (!cached)
64
- return true;
65
- return Date.now() - cached.loaded_at > CACHE_TTL_MS;
66
- }
67
- load(blockchain) {
62
+ load_entries(blockchain) {
68
63
  return __awaiter(this, void 0, void 0, function* () {
69
64
  const notif_configs = this.get_notif_configs(blockchain);
70
65
  if (notif_configs.length === 0)
71
- return;
72
- let all_webhooks = [];
73
- try {
74
- const res = yield this.api.get_all_webhooks();
75
- all_webhooks = res.data || [];
76
- }
77
- catch (error) {
78
- console.error(`QnWebhookAddressManager: Failed to fetch webhooks for blockchain=${blockchain}`, error);
79
- return;
80
- }
81
- // Get all addresses to add to webhook
66
+ return [];
67
+ const res = yield this.api.get_all_webhooks();
68
+ const all_webhooks = res.data || [];
82
69
  const addresses = yield this.fetch_all_db_addresses(blockchain);
70
+ console.log(`Loaded ${addresses.length} addresses from db`);
83
71
  const entries = [];
84
72
  for (const notif_config of notif_configs) {
85
73
  const existing = all_webhooks.find(w => {
86
- var _a, _b;
74
+ var _a, _b, _c;
87
75
  return ((_a = w.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === notif_config.name.toLowerCase() &&
88
- ((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase();
76
+ ((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase() &&
77
+ !((_c = w.name) === null || _c === void 0 ? void 0 : _c.includes('escrow'));
89
78
  });
90
79
  if (!existing) {
91
80
  console.warn(`QnWebhookAddressManager: No webhook found for config=${notif_config.name} network=${notif_config.network}`);
@@ -99,16 +88,12 @@ class QnWebhookAddressManager {
99
88
  address_set: new Set(addresses),
100
89
  });
101
90
  }
102
- this.cache.set(blockchain, { entries, loaded_at: Date.now() });
91
+ return entries;
103
92
  });
104
93
  }
105
94
  ensure_loaded(blockchain) {
106
95
  return __awaiter(this, void 0, void 0, function* () {
107
- var _a;
108
- if (this.is_stale(blockchain)) {
109
- yield this.load(blockchain);
110
- }
111
- return ((_a = this.cache.get(blockchain)) === null || _a === void 0 ? void 0 : _a.entries) || [];
96
+ return this.cache.get_value(blockchain, blockchain, (bc) => this.load_entries(bc));
112
97
  });
113
98
  }
114
99
  matches_key(entry, key) {
@@ -117,12 +102,12 @@ class QnWebhookAddressManager {
117
102
  add_address(blockchain, address) {
118
103
  return __awaiter(this, void 0, void 0, function* () {
119
104
  const entries = yield this.ensure_loaded(blockchain);
105
+ console.log(`Pushing ${entries.length} addresses: `, entries);
106
+ console.log(`Pushed ${entries.length} addresses `);
120
107
  for (const entry of entries) {
121
- if (entry.address_set.has(address))
122
- continue;
123
108
  entry.address_set.add(address);
124
109
  try {
125
- console.log(`Adding addresses: `, entry.address_set);
110
+ console.log(`add_address : Adding addresses: `, entry.address_set);
126
111
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
127
112
  console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook`);
128
113
  }
@@ -137,12 +122,12 @@ class QnWebhookAddressManager {
137
122
  }
138
123
  remove_address(blockchain, address) {
139
124
  return __awaiter(this, void 0, void 0, function* () {
125
+ console.log(`Ensuring loaded...`);
140
126
  const entries = yield this.ensure_loaded(blockchain);
141
127
  for (const entry of entries) {
142
- if (!entry.address_set.has(address))
143
- continue;
144
128
  entry.address_set.delete(address);
145
129
  try {
130
+ console.log(`remove_address: Updating webhook addresses to :`, Array.from(entry.address_set));
146
131
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
147
132
  console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook`);
148
133
  }
@@ -169,10 +154,10 @@ class QnWebhookAddressManager {
169
154
  const entries = (yield this.ensure_loaded(blockchain))
170
155
  .filter(e => keys.some(k => this.matches_key(e, k)));
171
156
  for (const entry of entries) {
172
- if (entry.address_set.has(address))
173
- continue;
174
- entry.address_set.add(address);
157
+ if (!entry.address_set.has(address) && !entry.address_set.has(address.toLowerCase()))
158
+ entry.address_set.add(address);
175
159
  try {
160
+ console.log(`add_address_to_chain: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
176
161
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
177
162
  console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook (chain ${chain_id})`);
178
163
  }
@@ -199,10 +184,10 @@ class QnWebhookAddressManager {
199
184
  const entries = (yield this.ensure_loaded(blockchain))
200
185
  .filter(e => keys.some(k => this.matches_key(e, k)));
201
186
  for (const entry of entries) {
202
- if (!entry.address_set.has(address))
203
- continue;
204
- entry.address_set.delete(address);
187
+ if (entry.address_set.has(address) || entry.address_set.has(address.toLowerCase()))
188
+ entry.address_set.delete(address);
205
189
  try {
190
+ console.log(`remove_address_from_chain: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
206
191
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
207
192
  console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook (chain ${chain_id})`);
208
193
  }
@@ -226,10 +211,9 @@ class QnWebhookAddressManager {
226
211
  const entries = (yield this.ensure_loaded(blockchain))
227
212
  .filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
228
213
  for (const entry of entries) {
229
- if (entry.address_set.has(address))
230
- continue;
231
214
  entry.address_set.add(address);
232
215
  try {
216
+ console.log(`sync_add_to_remaining: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
233
217
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
234
218
  console.log(`QnWebhookAddressManager: Synced add ${address} to ${entry.name} webhook`);
235
219
  }
@@ -251,10 +235,9 @@ class QnWebhookAddressManager {
251
235
  const entries = (yield this.ensure_loaded(blockchain))
252
236
  .filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
253
237
  for (const entry of entries) {
254
- if (!entry.address_set.has(address))
255
- continue;
256
238
  entry.address_set.delete(address);
257
239
  try {
240
+ console.log(`sync_remove_from_remaining: Updating webhook addresses. new set ${entry.address_set.size} addresses`);
258
241
  yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
259
242
  console.log(`QnWebhookAddressManager: Synced remove ${address} from ${entry.name} webhook`);
260
243
  }
@@ -27,6 +27,7 @@ declare class SetupNotifications extends BaseErrors {
27
27
  * The `blockchain` filter value in DepositAddressService is the string stored
28
28
  * in the DB — e.g. "solana", "evm", "ethereum", etc.
29
29
  */
30
+ private fetch_contract_addresses;
30
31
  private fetch_all_db_addresses;
31
32
  /**
32
33
  * Register a newly-created webhook entry in the internal maps.
@@ -1 +1 @@
1
- {"version":3,"file":"SetupNotifications.d.ts","sourceRoot":"","sources":["../../../src/services/quicknode-notifications/SetupNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAQlE,MAAM,WAAW,wBAAwB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,cAAc,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAWD,cAAM,kBAAmB,SAAQ,UAAU;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAC5C,OAAO,CAAC,GAAG,CAAqB;IAEhC,OAAO,CAAC,WAAW,CAAoD;IAEvE,OAAO,CAAC,aAAa,CAA8D;IAEnF,OAAO,CAAC,eAAe,CAAqD;IAC5E,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO;IAOP,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,GAAG,kBAAkB;IAO5F,mBAAmB,IAAI,MAAM,EAAE;IAI/B,u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CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,GAAG,kBAAkB;IAO5F,mBAAmB,IAAI,MAAM,EAAE;IAI/B,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAOhF;;;;OAIG;YACW,wBAAwB;YAoBxB,sBAAsB;IAuBpC;;OAEG;IACH,OAAO,CAAC,cAAc;IAOT,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA0H3B,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyDvE,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAe1F;AAED,eAAe,kBAAkB,CAAC"}
@@ -12,11 +12,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const web3_js_1 = require("@solana/web3.js");
16
+ const constants_1 = require("../../constants");
15
17
  const errors_1 = __importDefault(require("../../errors/errors"));
16
18
  const ChainManager_1 = __importDefault(require("../ChainManager"));
17
19
  const DepositAddressService_1 = __importDefault(require("../DepositAddressService"));
18
20
  const QuicknodeWebhookSignature_1 = __importDefault(require("../QuicknodeWebhookSignature"));
19
21
  const QnNotificationsApi_1 = __importDefault(require("./QnNotificationsApi"));
22
+ const Wallets_1 = require("../../utils/Wallets");
23
+ const __1 = require("../..");
20
24
  const ADDRESS_SYNC_BATCH_SIZE = 500;
21
25
  const ADDRESS_LOG_THRESHOLD = 1000;
22
26
  class SetupNotifications extends errors_1.default {
@@ -53,6 +57,27 @@ class SetupNotifications extends errors_1.default {
53
57
  * The `blockchain` filter value in DepositAddressService is the string stored
54
58
  * in the DB — e.g. "solana", "evm", "ethereum", etc.
55
59
  */
60
+ fetch_contract_addresses(notif_config) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ var _a;
63
+ if (!notif_config.chain_id) {
64
+ console.warn(`SetupNotifications: source='contract' but no chain_id set for ${notif_config.name} — skipping`);
65
+ return [];
66
+ }
67
+ const chain_manager = ChainManager_1.default.getInstance(this.config);
68
+ const escrow_config = chain_manager.getEscrowContractForChain(notif_config.chain_id);
69
+ // Derive vault authority for solana escrow program
70
+ if (notif_config.chain_id !== undefined && notif_config.blockchain === constants_1.BLOCKCHAINS.SOLANA) {
71
+ const chain_manager = ChainManager_1.default.getInstance(this.config);
72
+ const escrow_config = chain_manager.getEscrowContractForChain(parseInt(notif_config.chain_id.toString()));
73
+ // TODO handle multiple escrow contracts on solana
74
+ const escrow_program_pubkey = new web3_js_1.PublicKey((0, Wallets_1.normalizeAddress)(escrow_config.addresses[0], "solana"));
75
+ const vault_authority = __1.EscrowService.findVaultAuthorityPda(escrow_program_pubkey);
76
+ return [vault_authority.toString()];
77
+ }
78
+ return (_a = escrow_config === null || escrow_config === void 0 ? void 0 : escrow_config.addresses) !== null && _a !== void 0 ? _a : [];
79
+ });
80
+ }
56
81
  fetch_all_db_addresses(blockchain) {
57
82
  return __awaiter(this, void 0, void 0, function* () {
58
83
  const service = new DepositAddressService_1.default(this.db);
@@ -117,8 +142,10 @@ class SetupNotifications extends errors_1.default {
117
142
  return ((_a = w.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === notif_config.name.toLowerCase() &&
118
143
  ((_b = w.network) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === notif_config.network.toLowerCase();
119
144
  });
120
- // Fetch current addresses from the DB for this blockchain
121
- const db_addresses = yield this.fetch_all_db_addresses(notif_config.blockchain);
145
+ // Fetch addresses — contract source uses escrow addresses, wallet source uses DB deposit addresses
146
+ const db_addresses = notif_config.source === 'contract'
147
+ ? yield this.fetch_contract_addresses(notif_config)
148
+ : yield this.fetch_all_db_addresses(notif_config.blockchain);
122
149
  console.log(`SetupNotifications: ${db_addresses.length} DB addresses for blockchain=${notif_config.blockchain}`);
123
150
  let webhook_id;
124
151
  if (existing) {
@@ -12,6 +12,10 @@ export type QuicknodeNotificationConfig = {
12
12
  name: string;
13
13
  network: string;
14
14
  template: 'solanaWalletFilter' | 'evmWalletFilter';
15
+ /** 'wallet' (default) = custodial deposit addresses; 'contract' = escrow contract addresses */
16
+ source?: 'wallet' | 'contract';
17
+ /** Required when source === 'contract' — the chain ID to look up the escrow contract */
18
+ chain_id?: number;
15
19
  };
16
20
  export type QuicknodeStreamConfig = {
17
21
  network: string;
@@ -46,6 +50,7 @@ export interface ChainAccountingDetails {
46
50
  treasury_receiver: string;
47
51
  overflow_treasury_receiver: string;
48
52
  overflow_threshold_decimal: number;
53
+ min_funding_wallet_balance_usd: number;
49
54
  }
50
55
  export interface TronConfig {
51
56
  trxTransferCost: number;
@@ -1 +1 @@
1
- {"version":3,"file":"chain_manager.d.ts","sourceRoot":"","sources":["../../../src/services/types/chain_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,6BAA6B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;CACjC,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,oBAAoB,GAAG,iBAAiB,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,GAAG,qBAAq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AE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM;IAcxE;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAI/C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAI9C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAM9C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAO/C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAM/C;;OAEG;IACH,OAAO,CAAC,aAAa;IAuCrB;;OAEG;IACH,OAAO,CAAC,cAAc;CAezB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,aAAa,MAAM,EAAE,UAAU,UAAU,KAAG,MAExF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -84,8 +84,9 @@ class Logger {
84
84
  * Warn level - sent to ElasticSearch
85
85
  */
86
86
  warn(message, data) {
87
- this.pino.warn(Object.assign({ source: this.source }, data), message);
88
- this.indexToElastic('Warning', message, data);
87
+ const logData = this.normalizeData(data);
88
+ this.pino.warn(Object.assign({ source: this.source }, logData), message);
89
+ this.indexToElastic('Warning', message, logData);
89
90
  }
90
91
  /**
91
92
  * Error level - sent to ElasticSearch
@@ -129,6 +130,16 @@ class Logger {
129
130
  stack: value.stack,
130
131
  };
131
132
  }
133
+ else if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
134
+ // Recurse one level to catch nested Error objects (e.g. { data: { err: Error } })
135
+ const nested = {};
136
+ for (const [nk, nv] of Object.entries(value)) {
137
+ nested[nk] = nv instanceof Error
138
+ ? { name: nv.name, message: nv.message, stack: nv.stack }
139
+ : nv;
140
+ }
141
+ normalized[key] = nested;
142
+ }
132
143
  else {
133
144
  normalized[key] = value;
134
145
  }
@@ -70,7 +70,8 @@ export declare const handle_transfer_batch: (payloads: SolanaTransactionRequest[
70
70
  success: SolanaTransactionSuccessRequest[];
71
71
  failed: SolanaTransactionRequest[];
72
72
  }>;
73
- export declare const find_transfer_instruction: (tx: SolanaTransactionLog) => TransferInstructionRecord;
73
+ export declare const find_transfer_instruction: (tx: SolanaTransactionLog, receiver?: string) => TransferInstructionRecord;
74
+ export declare const find_transfer_instruction_depr: (tx: SolanaTransactionLog) => TransferInstructionRecord;
74
75
  export declare const getSolanaConnection: (chainId: string, config: IConfig) => web3.Connection;
75
76
  export declare const getSolanaArchivalConnection: (chainId: string, config: IConfig) => web3.Connection;
76
77
  export declare const getSolanaConnectionPublic: (chainId: string) => web3.Connection;
@@ -1 +1 @@
1
- {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/utils/solana.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,OAAO,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,IAAI,EAAE,EAA6B,OAAO,EAAuC,SAAS,EAAgE,MAAM,iBAAiB,CAAA;AAGxL,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAGnF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAG/C,eAAO,MAAM,2BAA2B,QAA2B,CAAC;AACpE,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,MAAM,EAAE,0BAA0B,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,cAAc,MAAM,EAAE,eAAe,MAAM,EAAE,QAAQ,OAAO;;;;;EAmBzH,CAAA;AAoBD,eAAO,MAAM,mCAAmC,GAAU,UAAU,wBAAwB,EAAE,EAAE,YAAY,IAAI,CAAC,UAAU,EAAE,YAAY,OAAO,YAAQ,EAAE,UAAU,OAAO,YAAQ,EAAE,QAAQ,aAAa,EAAE,QAAQ,OAAO;;;EAmJ1N,CAAA;AAsCD,eAAO,MAAM,0BAA0B,GAAU,UAAU,OAAO,EAAE,mBAAmB,wBAAwB,EAAE,EAAE,OAAO,OAAO,EAAE,QAAQ,aAAa,EAAE,QAAQ,OAAO,oBA2BxK,CAAA;AAED,MAAM,WAAW,yBAAyB;IACtC,UAAU,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB;AA2CD,eAAO,MAAM,uCAAuC,GAAU,mBAAmB,wBAAwB,EAAE,EAAE,YAAY,IAAI,CAAC,UAAU,EAAE,OAAO,OAAO,EAAE,YAAY,OAAO,EAAE,QAAQ,aAAa,EAAE,QAAQ,OAAO;;;;;;;EAoDpN,CAAA;AAuFD,eAAO,MAAM,sBAAsB,GAAU,UAAU,OAAO,EAAE,cAAc,MAAM,EAAE,cAAc,MAAM,EAAE,aAAa,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,aAAa,EAAE,QAAQ,OAAO,qBA6CrL,CAAA;AA0ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG"}
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.check_approve_delegate = exports.handle_create_versioned_transaction_spl = exports.estimate_withdraw_gas_cost = exports.create_versioned_transaction_solana = exports.get_token_account_info = exports.getSolanaConnectionPublic = exports.getSolanaArchivalConnection = exports.getSolanaConnection = exports.find_transfer_instruction = exports.handle_transfer_batch = exports.handle_sweep = exports.SplTransferCheckedLayout = exports.SolTransferInstructionLayout = exports.usdc_program_address = exports.solana_program_address = exports.min_solana_funding_lamports = void 0;
48
+ exports.check_approve_delegate = exports.handle_create_versioned_transaction_spl = exports.estimate_withdraw_gas_cost = exports.create_versioned_transaction_solana = exports.get_token_account_info = exports.getSolanaConnectionPublic = exports.getSolanaArchivalConnection = exports.getSolanaConnection = exports.find_transfer_instruction_depr = exports.find_transfer_instruction = exports.handle_transfer_batch = exports.handle_sweep = exports.SplTransferCheckedLayout = exports.SolTransferInstructionLayout = exports.usdc_program_address = exports.solana_program_address = exports.min_solana_funding_lamports = void 0;
49
49
  const buffer_layout_utils_1 = require("@solana/buffer-layout-utils");
50
50
  const buffer_layout_1 = require("@solana/buffer-layout");
51
51
  const web3_js_1 = __importStar(require("@solana/web3.js"));
@@ -182,7 +182,32 @@ const handle_transfer_batch = (payloads_1, chain_id_1, token_type_1, connection_
182
182
  return { status: true, signatures, success, failed };
183
183
  });
184
184
  exports.handle_transfer_batch = handle_transfer_batch;
185
- const find_transfer_instruction = (tx) => {
185
+ const find_transfer_instruction = (tx, receiver) => {
186
+ const message = tx.transaction[0].message[0];
187
+ const target_instruction = message.instructions.find(i => {
188
+ const program = message.account_keys[parseInt(i.program_id_index)];
189
+ if (!token_program_addresses.some(a => a === program))
190
+ return false;
191
+ // If a receiver is specified and this is a native SOL transfer, match by
192
+ // the destination account (accounts[1]) to find the exact instruction for
193
+ // that recipient. Needed for batch sends where one tx has many transfers.
194
+ if (receiver && program === exports.solana_program_address) {
195
+ if (!i.accounts || i.accounts.length < 2)
196
+ return false;
197
+ return message.account_keys[i.accounts[1]] === receiver;
198
+ }
199
+ return true; // original behaviour: first matching program
200
+ });
201
+ if (!target_instruction)
202
+ throw new Error(`Cannot find program index for accepted payment tokens: ${token_program_addresses}`);
203
+ const program_index = target_instruction.program_id_index;
204
+ return {
205
+ instruction: target_instruction,
206
+ is_native: message.account_keys[parseInt(program_index)] === exports.solana_program_address
207
+ };
208
+ };
209
+ exports.find_transfer_instruction = find_transfer_instruction;
210
+ const find_transfer_instruction_depr = (tx) => {
186
211
  const message = tx.transaction[0].message[0];
187
212
  const target_instruction = message.instructions.find(i => token_program_addresses.some(a => a === message.account_keys[parseInt(i.program_id_index)]));
188
213
  if (!target_instruction)
@@ -190,7 +215,7 @@ const find_transfer_instruction = (tx) => {
190
215
  const program_index = target_instruction === null || target_instruction === void 0 ? void 0 : target_instruction.program_id_index;
191
216
  return { instruction: target_instruction, is_native: tx.transaction[0].message[0].account_keys[parseInt(program_index)] === exports.solana_program_address };
192
217
  };
193
- exports.find_transfer_instruction = find_transfer_instruction;
218
+ exports.find_transfer_instruction_depr = find_transfer_instruction_depr;
194
219
  const getSolanaConnection = (chainId, config) => {
195
220
  const network = ChainManager_1.default.getInstance(config).getChainConfigForChainIdSync(parseInt(chainId));
196
221
  if (!network)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ercworldio/blockchain-shared",
3
- "version": "1.0.1-dev.9",
3
+ "version": "1.0.2-dev.0",
4
4
  "description": "Shared library for blockchain projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",