@ercworldio/blockchain-shared 1.0.0-dev.19 → 1.0.0-dev.20
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/services/WalletManager.d.ts.map +1 -1
- package/build/services/WalletManager.js +13 -5
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +2 -2
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.js +2 -0
- package/package.json +1 -1
|
@@ -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;AAK1C,cAAM,aAAc,SAAQ,UAAU;IAClC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC;IAC/B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAgB;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,8BAA8B,EAAE,MAAM,CAAC;IACvC,0BAA0B,EAAE,MAAM,CAAC;IAC1C,OAAO,CAAC,MAAM,CAAS;gBACX,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE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cAAc,EAAE,YAAY,OAAO,EAAE,YAAY,OAAO,sBA+B9I;IAIM,YAAY,GAAI,aAAa,MAAM,EAAE,YAAY,MAAM,EAAE,YAAY,cAAc,EAAE,YAAY,MAAM,eA4E7G;CAIJ;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -64,6 +64,7 @@ const constants_1 = require("../constants");
|
|
|
64
64
|
const tronweb_1 = require("tronweb");
|
|
65
65
|
const errors_1 = __importDefault(require("../errors/errors"));
|
|
66
66
|
const Logger_1 = require("../utils/Logger");
|
|
67
|
+
const QnWebhookAddressManager_1 = __importDefault(require("./quicknode-notifications/QnWebhookAddressManager"));
|
|
67
68
|
class WalletManager extends errors_1.default {
|
|
68
69
|
constructor(config, dbPool) {
|
|
69
70
|
super();
|
|
@@ -207,16 +208,23 @@ class WalletManager extends errors_1.default {
|
|
|
207
208
|
return updatedWallet;
|
|
208
209
|
});
|
|
209
210
|
this.handleRenewWallet = (subscription, blockchain, old_wallet, new_wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
const wallet_manager = WalletManager.getInstance(this.config, this.dbPool);
|
|
211
211
|
const alchemy_service = AlchemyService_1.default.getInstance(this.config);
|
|
212
|
+
const qn_service = QnWebhookAddressManager_1.default.getInstance(this.config);
|
|
212
213
|
// Dispatch insert sweep job handler
|
|
213
214
|
const sweep_job_service = new SweepJobService_1.default(this.dbPool, this.config);
|
|
214
215
|
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
|
|
215
216
|
);
|
|
216
|
-
// Add new address and remove expired address
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
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`);
|
|
220
228
|
}
|
|
221
229
|
return new_wallet;
|
|
222
230
|
});
|
|
@@ -11,8 +11,8 @@ declare class QnWebhookAddressManager {
|
|
|
11
11
|
private is_stale;
|
|
12
12
|
private load;
|
|
13
13
|
private ensure_loaded;
|
|
14
|
-
add_address(blockchain: BlockchainType, address: string): Promise<
|
|
15
|
-
remove_address(blockchain: BlockchainType, address: string): Promise<
|
|
14
|
+
add_address(blockchain: BlockchainType, address: string): Promise<boolean>;
|
|
15
|
+
remove_address(blockchain: BlockchainType, address: string): Promise<boolean>;
|
|
16
16
|
}
|
|
17
17
|
export default QnWebhookAddressManager;
|
|
18
18
|
//# 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;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAoBlD,cAAM,uBAAuB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,KAAK,CAAmD;IAEhE,OAAO;IAKP,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,uBAAuB;IAO5D,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,QAAQ;YAMF,IAAI;YAsCJ,aAAa;IAOd,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,
|
|
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;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAoBlD,cAAM,uBAAuB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,KAAK,CAAmD;IAEhE,OAAO;IAKP,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,uBAAuB;IAO5D,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,QAAQ;YAMF,IAAI;YAsCJ,aAAa;IAOd,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB1E,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAiB7F;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -110,6 +110,7 @@ class QnWebhookAddressManager {
|
|
|
110
110
|
throw error;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
return true;
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
remove_address(blockchain, address) {
|
|
@@ -129,6 +130,7 @@ class QnWebhookAddressManager {
|
|
|
129
130
|
throw error;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
return true;
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
136
|
}
|