@ercworldio/blockchain-shared 1.0.0-dev.20 → 1.0.0-dev.22
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.
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/services/AlchemyWebhookAddressManager.d.ts +38 -0
- package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -0
- package/build/services/AlchemyWebhookAddressManager.js +123 -0
- package/build/services/WalletManager.d.ts +3 -1
- package/build/services/WalletManager.d.ts.map +1 -1
- package/build/services/WalletManager.js +9 -13
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +29 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.js +133 -5
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as AsyncTTLCache } from "./utils/AsyncTTLCache";
|
|
|
3
3
|
export { default as AzureEventHubHandler } from './services/AzureEventHubHandler';
|
|
4
4
|
export { default as AccountingService } from './services/AccountingService';
|
|
5
5
|
export { default as AlchemyService } from './services/AlchemyService';
|
|
6
|
+
export { default as AlchemyWebhookAddressManager } from './services/AlchemyWebhookAddressManager';
|
|
6
7
|
export { default as AlchemyWebhooks } from './services/AlchemyWebhooks';
|
|
7
8
|
export { default as AlchemyWebhookSignature } from './services/AlchemyWebhookSignature';
|
|
8
9
|
export { default as BalanceService } from './services/BalanceService';
|
package/build/index.d.ts.map
CHANGED
|
@@ -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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;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.
|
|
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 = void 0;
|
|
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;
|
|
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; } });
|
|
@@ -53,6 +53,8 @@ var AccountingService_1 = require("./services/AccountingService");
|
|
|
53
53
|
Object.defineProperty(exports, "AccountingService", { enumerable: true, get: function () { return __importDefault(AccountingService_1).default; } });
|
|
54
54
|
var AlchemyService_1 = require("./services/AlchemyService");
|
|
55
55
|
Object.defineProperty(exports, "AlchemyService", { enumerable: true, get: function () { return __importDefault(AlchemyService_1).default; } });
|
|
56
|
+
var AlchemyWebhookAddressManager_1 = require("./services/AlchemyWebhookAddressManager");
|
|
57
|
+
Object.defineProperty(exports, "AlchemyWebhookAddressManager", { enumerable: true, get: function () { return __importDefault(AlchemyWebhookAddressManager_1).default; } });
|
|
56
58
|
var AlchemyWebhooks_1 = require("./services/AlchemyWebhooks");
|
|
57
59
|
Object.defineProperty(exports, "AlchemyWebhooks", { enumerable: true, get: function () { return __importDefault(AlchemyWebhooks_1).default; } });
|
|
58
60
|
var AlchemyWebhookSignature_1 = require("./services/AlchemyWebhookSignature");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BlockchainType, ChainId } from "../interfaces";
|
|
2
|
+
import { IConfig } from "../interfaces/config";
|
|
3
|
+
import { AlchemyWebhookEnvironment } from "./types/alchemy";
|
|
4
|
+
declare class AlchemyWebhookAddressManager {
|
|
5
|
+
private static instance;
|
|
6
|
+
private alchemy;
|
|
7
|
+
private config;
|
|
8
|
+
private cache;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(config: IConfig): AlchemyWebhookAddressManager;
|
|
11
|
+
private is_stale;
|
|
12
|
+
private load;
|
|
13
|
+
private get_webhooks;
|
|
14
|
+
private get_webhooks_for_chain;
|
|
15
|
+
private get_chain_ids_for_blockchain;
|
|
16
|
+
/**
|
|
17
|
+
* Add an address to the webhook(s) for a single chain only.
|
|
18
|
+
* Use this for the immediate await before responding to the caller.
|
|
19
|
+
*/
|
|
20
|
+
add_address_to_chain(env: AlchemyWebhookEnvironment, chain_id: ChainId, address: string): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Remove an address from the webhook(s) for a single chain only.
|
|
23
|
+
* Use this for the immediate await before responding to the caller.
|
|
24
|
+
*/
|
|
25
|
+
remove_address_from_chain(env: AlchemyWebhookEnvironment, chain_id: ChainId, address: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Add an address to all webhooks for a blockchain except the already-updated chain.
|
|
28
|
+
* Call this fire-and-forget after responding to the caller.
|
|
29
|
+
*/
|
|
30
|
+
sync_add_to_remaining(env: AlchemyWebhookEnvironment, blockchain: BlockchainType, address: string, exclude_chain_id: ChainId): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Remove an address from all webhooks for a blockchain except the already-updated chain.
|
|
33
|
+
* Call this fire-and-forget after responding to the caller.
|
|
34
|
+
*/
|
|
35
|
+
sync_remove_from_remaining(env: AlchemyWebhookEnvironment, blockchain: BlockchainType, address: string, exclude_chain_id: ChainId): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export default AlchemyWebhookAddressManager;
|
|
38
|
+
//# sourceMappingURL=AlchemyWebhookAddressManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlchemyWebhookAddressManager.d.ts","sourceRoot":"","sources":["../../src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iter = (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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ChainManager_1 = __importDefault(require("./ChainManager"));
|
|
16
|
+
const AlchemyService_1 = __importDefault(require("./AlchemyService"));
|
|
17
|
+
const alchemy_1 = require("./utils/alchemy");
|
|
18
|
+
const CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
19
|
+
class AlchemyWebhookAddressManager {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.cache = new Map();
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.alchemy = AlchemyService_1.default.getInstance(config);
|
|
24
|
+
}
|
|
25
|
+
static getInstance(config) {
|
|
26
|
+
if (!this.instance) {
|
|
27
|
+
this.instance = new AlchemyWebhookAddressManager(config);
|
|
28
|
+
}
|
|
29
|
+
return this.instance;
|
|
30
|
+
}
|
|
31
|
+
is_stale(env) {
|
|
32
|
+
const cached = this.cache.get(env);
|
|
33
|
+
if (!cached)
|
|
34
|
+
return true;
|
|
35
|
+
return Date.now() - cached.loaded_at > CACHE_TTL_MS;
|
|
36
|
+
}
|
|
37
|
+
load(env) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
const webhooks = yield this.alchemy.get_all_webhooks(env);
|
|
41
|
+
this.cache.set(env, { webhooks, loaded_at: Date.now() });
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error(`AlchemyWebhookAddressManager: Failed to fetch webhooks for env=${env}`, error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
get_webhooks(env) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a;
|
|
51
|
+
if (this.is_stale(env))
|
|
52
|
+
yield this.load(env);
|
|
53
|
+
return ((_a = this.cache.get(env)) === null || _a === void 0 ? void 0 : _a.webhooks) || [];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
get_webhooks_for_chain(all, env, chain_id) {
|
|
57
|
+
let network;
|
|
58
|
+
try {
|
|
59
|
+
network = (0, alchemy_1.get_alchemy_chain_name)(chain_id);
|
|
60
|
+
}
|
|
61
|
+
catch (_a) {
|
|
62
|
+
console.warn(`AlchemyWebhookAddressManager: No Alchemy network mapping for chain_id=${chain_id}`);
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return all.filter(w => w.network === network &&
|
|
66
|
+
w.webhook_type === "ADDRESS_ACTIVITY" &&
|
|
67
|
+
w.webhook_url.includes(env));
|
|
68
|
+
}
|
|
69
|
+
get_chain_ids_for_blockchain(blockchain) {
|
|
70
|
+
return ChainManager_1.default.getInstance(this.config).blockchain_chainid_map.get(blockchain) || [];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Add an address to the webhook(s) for a single chain only.
|
|
74
|
+
* Use this for the immediate await before responding to the caller.
|
|
75
|
+
*/
|
|
76
|
+
add_address_to_chain(env, chain_id, address) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const all = yield this.get_webhooks(env);
|
|
79
|
+
const webhooks = this.get_webhooks_for_chain(all, env, chain_id);
|
|
80
|
+
yield Promise.all(webhooks.map(w => this.alchemy.add_remove_addresses(env, { webhook_id: w.id, addresses_to_add: [address], addresses_to_remove: [] })));
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Remove an address from the webhook(s) for a single chain only.
|
|
86
|
+
* Use this for the immediate await before responding to the caller.
|
|
87
|
+
*/
|
|
88
|
+
remove_address_from_chain(env, chain_id, address) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const all = yield this.get_webhooks(env);
|
|
91
|
+
const webhooks = this.get_webhooks_for_chain(all, env, chain_id);
|
|
92
|
+
yield Promise.all(webhooks.map(w => this.alchemy.add_remove_addresses(env, { webhook_id: w.id, addresses_to_add: [], addresses_to_remove: [address] })));
|
|
93
|
+
return true;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Add an address to all webhooks for a blockchain except the already-updated chain.
|
|
98
|
+
* Call this fire-and-forget after responding to the caller.
|
|
99
|
+
*/
|
|
100
|
+
sync_add_to_remaining(env, blockchain, address, exclude_chain_id) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const all = yield this.get_webhooks(env);
|
|
103
|
+
const remaining_chain_ids = this.get_chain_ids_for_blockchain(blockchain)
|
|
104
|
+
.filter(cid => cid !== exclude_chain_id);
|
|
105
|
+
const webhooks = remaining_chain_ids.flatMap(cid => this.get_webhooks_for_chain(all, env, cid));
|
|
106
|
+
yield Promise.allSettled(webhooks.map(w => this.alchemy.add_remove_addresses(env, { webhook_id: w.id, addresses_to_add: [address], addresses_to_remove: [] })));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Remove an address from all webhooks for a blockchain except the already-updated chain.
|
|
111
|
+
* Call this fire-and-forget after responding to the caller.
|
|
112
|
+
*/
|
|
113
|
+
sync_remove_from_remaining(env, blockchain, address, exclude_chain_id) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const all = yield this.get_webhooks(env);
|
|
116
|
+
const remaining_chain_ids = this.get_chain_ids_for_blockchain(blockchain)
|
|
117
|
+
.filter(cid => cid !== exclude_chain_id);
|
|
118
|
+
const webhooks = remaining_chain_ids.flatMap(cid => this.get_webhooks_for_chain(all, env, cid));
|
|
119
|
+
yield Promise.allSettled(webhooks.map(w => this.alchemy.add_remove_addresses(env, { webhook_id: w.id, addresses_to_add: [], addresses_to_remove: [address] })));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.default = AlchemyWebhookAddressManager;
|
|
@@ -7,6 +7,7 @@ import { IDatabasePool } from "../interfaces/database";
|
|
|
7
7
|
import { BtcWallet, IWallet, TronNodeWallet } from "./types/wallet_manager";
|
|
8
8
|
import { AlchemyWebhookEnvironment } from "./types/alchemy";
|
|
9
9
|
import BaseErrors from "../errors/errors";
|
|
10
|
+
import AsyncRateLimiter from "../utils/AsyncRateLimiter";
|
|
10
11
|
declare class WalletManager extends BaseErrors {
|
|
11
12
|
static instance: WalletManager;
|
|
12
13
|
private config;
|
|
@@ -35,7 +36,8 @@ declare class WalletManager extends BaseErrors {
|
|
|
35
36
|
address: string;
|
|
36
37
|
}>;
|
|
37
38
|
renewWallet: (subscription: AlchemyWebhookEnvironment, userId: number, blockchain: BlockchainType, expired_address: string) => Promise<IWallet>;
|
|
38
|
-
|
|
39
|
+
updateWebhookAddress: (subscription: AlchemyWebhookEnvironment, blockchain: BlockchainType, old_wallet: IWallet, new_wallet: IWallet, limiter: AsyncRateLimiter) => Promise<boolean>;
|
|
40
|
+
handleRenewWallet: (old_wallet: IWallet, new_wallet: IWallet) => Promise<IWallet>;
|
|
39
41
|
deriveWallet: (parentIndex: number, childIndex: number, blockchain: BlockchainType, _mnemonic?: string) => BtcWallet;
|
|
40
42
|
}
|
|
41
43
|
export default WalletManager;
|
|
@@ -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;
|
|
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,OAA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,aAAa,CAAC"}
|
|
@@ -65,6 +65,7 @@ const tronweb_1 = require("tronweb");
|
|
|
65
65
|
const errors_1 = __importDefault(require("../errors/errors"));
|
|
66
66
|
const Logger_1 = require("../utils/Logger");
|
|
67
67
|
const QnWebhookAddressManager_1 = __importDefault(require("./quicknode-notifications/QnWebhookAddressManager"));
|
|
68
|
+
const AsyncRateLimiter_1 = require("../utils/AsyncRateLimiter");
|
|
68
69
|
class WalletManager extends errors_1.default {
|
|
69
70
|
constructor(config, dbPool) {
|
|
70
71
|
super();
|
|
@@ -207,25 +208,20 @@ class WalletManager extends errors_1.default {
|
|
|
207
208
|
yield timerManager.delete_timer(userId, blockchain);
|
|
208
209
|
return updatedWallet;
|
|
209
210
|
});
|
|
210
|
-
this.
|
|
211
|
+
this.updateWebhookAddress = (subscription, blockchain, old_wallet, new_wallet, limiter) => __awaiter(this, void 0, void 0, function* () {
|
|
211
212
|
const alchemy_service = AlchemyService_1.default.getInstance(this.config);
|
|
212
213
|
const qn_service = QnWebhookAddressManager_1.default.getInstance(this.config);
|
|
214
|
+
// Add new address and remove expired address (quicknode and alchemy webhooks)
|
|
215
|
+
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
|
+
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));
|
|
217
|
+
const quicknode_res_remove = yield limiter.execute(() => (0, AsyncRateLimiter_1.withRetry)(() => __awaiter(this, void 0, void 0, function* () { return yield qn_service.remove_address(blockchain, old_wallet.address); }), 3, 500));
|
|
218
|
+
return true;
|
|
219
|
+
});
|
|
220
|
+
this.handleRenewWallet = (old_wallet, new_wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
213
221
|
// Dispatch insert sweep job handler
|
|
214
222
|
const sweep_job_service = new SweepJobService_1.default(this.dbPool, this.config);
|
|
215
223
|
yield sweep_job_service.dispatchAddSweepJobWithBalanceCheck(old_wallet.id, old_wallet.blockchain, old_wallet.userId, old_wallet.address, old_wallet.parentIndex, old_wallet.childIndex, true // full sweep for expired wallet
|
|
216
224
|
);
|
|
217
|
-
// Add new address and remove expired address (quicknode and alchemy webhooks)
|
|
218
|
-
const promises = yield Promise.allSettled([
|
|
219
|
-
alchemy_service.add_remove_addresses_all_webhooks(subscription, blockchain, [new_wallet.address], [old_wallet.address]),
|
|
220
|
-
qn_service.add_address(blockchain, new_wallet.address),
|
|
221
|
-
qn_service.remove_address(blockchain, old_wallet.address),
|
|
222
|
-
]);
|
|
223
|
-
const failed = promises
|
|
224
|
-
.filter(r => r.status === 'rejected')
|
|
225
|
-
.map(r => r.status);
|
|
226
|
-
if (failed.length > 0) {
|
|
227
|
-
throw new Error(`Error renewing wallet. ${failed.length} failed`);
|
|
228
|
-
}
|
|
229
225
|
return new_wallet;
|
|
230
226
|
});
|
|
231
227
|
// TODO: revisit solana and btc wallet creation and return
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockchainType } from "../../interfaces";
|
|
1
|
+
import { BlockchainType, ChainId } from "../../interfaces";
|
|
2
2
|
import { IConfig } from "../../interfaces/config";
|
|
3
3
|
declare class QnWebhookAddressManager {
|
|
4
4
|
private static instance;
|
|
@@ -7,12 +7,40 @@ declare class QnWebhookAddressManager {
|
|
|
7
7
|
private cache;
|
|
8
8
|
private constructor();
|
|
9
9
|
static getInstance(config: IConfig): QnWebhookAddressManager;
|
|
10
|
+
private get_blockchain_for_chain;
|
|
11
|
+
/** Returns the { name, network } pairs for the notification configs of a given chain. */
|
|
12
|
+
private get_webhook_keys_for_chain;
|
|
10
13
|
private get_notif_configs;
|
|
11
14
|
private is_stale;
|
|
12
15
|
private load;
|
|
13
16
|
private ensure_loaded;
|
|
17
|
+
private matches_key;
|
|
14
18
|
add_address(blockchain: BlockchainType, address: string): Promise<boolean>;
|
|
15
19
|
remove_address(blockchain: BlockchainType, address: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Add an address to the webhook(s) for a single chain only.
|
|
22
|
+
* Matches by both name and network to avoid cross-service contamination.
|
|
23
|
+
* Use this for the immediate await before responding to the caller.
|
|
24
|
+
*/
|
|
25
|
+
add_address_to_chain(chain_id: ChainId, address: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Remove an address from the webhook(s) for a single chain only.
|
|
28
|
+
* Matches by both name and network to avoid cross-service contamination.
|
|
29
|
+
* Use this for the immediate await before responding to the caller.
|
|
30
|
+
*/
|
|
31
|
+
remove_address_from_chain(chain_id: ChainId, address: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Add an address to all webhooks for a blockchain except the already-updated chain.
|
|
34
|
+
* Excludes by both name and network so only the exact webhooks for that chain are skipped.
|
|
35
|
+
* Call this fire-and-forget after responding to the caller.
|
|
36
|
+
*/
|
|
37
|
+
sync_add_to_remaining(blockchain: BlockchainType, address: string, exclude_chain_id: ChainId): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Remove an address from all webhooks for a blockchain except the already-updated chain.
|
|
40
|
+
* Excludes by both name and network so only the exact webhooks for that chain are skipped.
|
|
41
|
+
* Call this fire-and-forget after responding to the caller.
|
|
42
|
+
*/
|
|
43
|
+
sync_remove_from_remaining(blockchain: BlockchainType, address: string, exclude_chain_id: ChainId): Promise<void>;
|
|
16
44
|
}
|
|
17
45
|
export default QnWebhookAddressManager;
|
|
18
46
|
//# 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,EAAiB,MAAM,kBAAkB,CAAC;
|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c,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjI;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -27,6 +27,20 @@ class QnWebhookAddressManager {
|
|
|
27
27
|
}
|
|
28
28
|
return this.instance;
|
|
29
29
|
}
|
|
30
|
+
get_blockchain_for_chain(chain_id) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const cfg = (_a = ChainManager_1.default.getInstance(this.config).contractsMap) === null || _a === void 0 ? void 0 : _a[chain_id.toString()];
|
|
33
|
+
return (_b = cfg === null || cfg === void 0 ? void 0 : cfg.blockchainType) !== null && _b !== void 0 ? _b : null;
|
|
34
|
+
}
|
|
35
|
+
/** Returns the { name, network } pairs for the notification configs of a given chain. */
|
|
36
|
+
get_webhook_keys_for_chain(chain_id) {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
const cfg = (_a = ChainManager_1.default.getInstance(this.config).contractsMap) === null || _a === void 0 ? void 0 : _a[chain_id.toString()];
|
|
39
|
+
return (_c = (_b = cfg === null || cfg === void 0 ? void 0 : cfg.quicknodeNotificationConfig) === null || _b === void 0 ? void 0 : _b.map(n => ({
|
|
40
|
+
name: n.name.toLowerCase(),
|
|
41
|
+
network: n.network.toLowerCase(),
|
|
42
|
+
}))) !== null && _c !== void 0 ? _c : [];
|
|
43
|
+
}
|
|
30
44
|
get_notif_configs(blockchain) {
|
|
31
45
|
const chain_manager = ChainManager_1.default.getInstance(this.config);
|
|
32
46
|
if (!chain_manager.contractsMap)
|
|
@@ -76,8 +90,9 @@ class QnWebhookAddressManager {
|
|
|
76
90
|
const addresses = ((_a = existing.templateArgs) === null || _a === void 0 ? void 0 : _a[arg_key]) || [];
|
|
77
91
|
entries.push({
|
|
78
92
|
webhook_id: existing.id,
|
|
93
|
+
name: notif_config.name.toLowerCase(),
|
|
79
94
|
template: notif_config.template,
|
|
80
|
-
network: notif_config.network,
|
|
95
|
+
network: notif_config.network.toLowerCase(),
|
|
81
96
|
address_set: new Set(addresses),
|
|
82
97
|
});
|
|
83
98
|
}
|
|
@@ -93,6 +108,9 @@ class QnWebhookAddressManager {
|
|
|
93
108
|
return ((_a = this.cache.get(blockchain)) === null || _a === void 0 ? void 0 : _a.entries) || [];
|
|
94
109
|
});
|
|
95
110
|
}
|
|
111
|
+
matches_key(entry, key) {
|
|
112
|
+
return entry.name === key.name && entry.network === key.network;
|
|
113
|
+
}
|
|
96
114
|
add_address(blockchain, address) {
|
|
97
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
116
|
const entries = yield this.ensure_loaded(blockchain);
|
|
@@ -102,11 +120,11 @@ class QnWebhookAddressManager {
|
|
|
102
120
|
entry.address_set.add(address);
|
|
103
121
|
try {
|
|
104
122
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
105
|
-
console.log(`QnWebhookAddressManager: Added ${address} to ${entry.
|
|
123
|
+
console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook`);
|
|
106
124
|
}
|
|
107
125
|
catch (error) {
|
|
108
126
|
entry.address_set.delete(address);
|
|
109
|
-
console.error(`QnWebhookAddressManager: Failed to add ${address} to ${entry.
|
|
127
|
+
console.error(`QnWebhookAddressManager: Failed to add ${address} to ${entry.name}`, error);
|
|
110
128
|
throw error;
|
|
111
129
|
}
|
|
112
130
|
}
|
|
@@ -122,16 +140,126 @@ class QnWebhookAddressManager {
|
|
|
122
140
|
entry.address_set.delete(address);
|
|
123
141
|
try {
|
|
124
142
|
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
125
|
-
console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.
|
|
143
|
+
console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook`);
|
|
126
144
|
}
|
|
127
145
|
catch (error) {
|
|
128
146
|
entry.address_set.add(address);
|
|
129
|
-
console.error(`QnWebhookAddressManager: Failed to remove ${address} from ${entry.
|
|
147
|
+
console.error(`QnWebhookAddressManager: Failed to remove ${address} from ${entry.name}`, error);
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Add an address to the webhook(s) for a single chain only.
|
|
156
|
+
* Matches by both name and network to avoid cross-service contamination.
|
|
157
|
+
* Use this for the immediate await before responding to the caller.
|
|
158
|
+
*/
|
|
159
|
+
add_address_to_chain(chain_id, address) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const blockchain = this.get_blockchain_for_chain(chain_id);
|
|
162
|
+
if (!blockchain)
|
|
163
|
+
return false;
|
|
164
|
+
const keys = this.get_webhook_keys_for_chain(chain_id);
|
|
165
|
+
const entries = (yield this.ensure_loaded(blockchain))
|
|
166
|
+
.filter(e => keys.some(k => this.matches_key(e, k)));
|
|
167
|
+
for (const entry of entries) {
|
|
168
|
+
if (entry.address_set.has(address))
|
|
169
|
+
continue;
|
|
170
|
+
entry.address_set.add(address);
|
|
171
|
+
try {
|
|
172
|
+
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
173
|
+
console.log(`QnWebhookAddressManager: Added ${address} to ${entry.name} webhook (chain ${chain_id})`);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
entry.address_set.delete(address);
|
|
177
|
+
console.error(`QnWebhookAddressManager: Failed to add ${address} to ${entry.name}`, error);
|
|
130
178
|
throw error;
|
|
131
179
|
}
|
|
132
180
|
}
|
|
133
181
|
return true;
|
|
134
182
|
});
|
|
135
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Remove an address from the webhook(s) for a single chain only.
|
|
186
|
+
* Matches by both name and network to avoid cross-service contamination.
|
|
187
|
+
* Use this for the immediate await before responding to the caller.
|
|
188
|
+
*/
|
|
189
|
+
remove_address_from_chain(chain_id, address) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const blockchain = this.get_blockchain_for_chain(chain_id);
|
|
192
|
+
if (!blockchain)
|
|
193
|
+
return false;
|
|
194
|
+
const keys = this.get_webhook_keys_for_chain(chain_id);
|
|
195
|
+
const entries = (yield this.ensure_loaded(blockchain))
|
|
196
|
+
.filter(e => keys.some(k => this.matches_key(e, k)));
|
|
197
|
+
for (const entry of entries) {
|
|
198
|
+
if (!entry.address_set.has(address))
|
|
199
|
+
continue;
|
|
200
|
+
entry.address_set.delete(address);
|
|
201
|
+
try {
|
|
202
|
+
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
203
|
+
console.log(`QnWebhookAddressManager: Removed ${address} from ${entry.name} webhook (chain ${chain_id})`);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
entry.address_set.add(address);
|
|
207
|
+
console.error(`QnWebhookAddressManager: Failed to remove ${address} from ${entry.name}`, error);
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return true;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Add an address to all webhooks for a blockchain except the already-updated chain.
|
|
216
|
+
* Excludes by both name and network so only the exact webhooks for that chain are skipped.
|
|
217
|
+
* Call this fire-and-forget after responding to the caller.
|
|
218
|
+
*/
|
|
219
|
+
sync_add_to_remaining(blockchain, address, exclude_chain_id) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const exclude_keys = this.get_webhook_keys_for_chain(exclude_chain_id);
|
|
222
|
+
const entries = (yield this.ensure_loaded(blockchain))
|
|
223
|
+
.filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
if (entry.address_set.has(address))
|
|
226
|
+
continue;
|
|
227
|
+
entry.address_set.add(address);
|
|
228
|
+
try {
|
|
229
|
+
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
230
|
+
console.log(`QnWebhookAddressManager: Synced add ${address} to ${entry.name} webhook`);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
entry.address_set.delete(address);
|
|
234
|
+
console.error(`QnWebhookAddressManager: Sync add failed for ${entry.name}`, error);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Remove an address from all webhooks for a blockchain except the already-updated chain.
|
|
241
|
+
* Excludes by both name and network so only the exact webhooks for that chain are skipped.
|
|
242
|
+
* Call this fire-and-forget after responding to the caller.
|
|
243
|
+
*/
|
|
244
|
+
sync_remove_from_remaining(blockchain, address, exclude_chain_id) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
const exclude_keys = this.get_webhook_keys_for_chain(exclude_chain_id);
|
|
247
|
+
const entries = (yield this.ensure_loaded(blockchain))
|
|
248
|
+
.filter(e => !exclude_keys.some(k => this.matches_key(e, k)));
|
|
249
|
+
for (const entry of entries) {
|
|
250
|
+
if (!entry.address_set.has(address))
|
|
251
|
+
continue;
|
|
252
|
+
entry.address_set.delete(address);
|
|
253
|
+
try {
|
|
254
|
+
yield this.api.update_webhook_addresses(entry.webhook_id, entry.template, Array.from(entry.address_set));
|
|
255
|
+
console.log(`QnWebhookAddressManager: Synced remove ${address} from ${entry.name} webhook`);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
entry.address_set.add(address);
|
|
259
|
+
console.error(`QnWebhookAddressManager: Sync remove failed for ${entry.name}`, error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
136
264
|
}
|
|
137
265
|
exports.default = QnWebhookAddressManager;
|