UNPKG

test-ic-wallet-middleware-icrc

Version:
88 lines (87 loc) 4.76 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IcrcReplicationManager = void 0; const common_1 = require("@ic-wallet-middleware/common"); const storage_1 = require("../storage"); const typedi_1 = require("typedi"); const IcrcRxSyncStateService_1 = require("./IcrcRxSyncStateService"); let IcrcReplicationManager = class IcrcReplicationManager { allowanceDataStorage; assetDataStorage; contactDataStorage; serviceDataStorage; replicationProcessor; constructor(logger, replicationConfiguration, identifierService, icrcRxSyncStateService, icrcDbContext, createCanisterFunc, allowanceDataStorage, assetDataStorage, contactDataStorage, serviceDataStorage) { this.allowanceDataStorage = allowanceDataStorage; this.assetDataStorage = assetDataStorage; this.contactDataStorage = contactDataStorage; this.serviceDataStorage = serviceDataStorage; this.replicationProcessor = new common_1.ReplicationProcessor(logger, replicationConfiguration, identifierService, icrcRxSyncStateService, icrcDbContext, createCanisterFunc); } async init() { const replicationCollectionList = []; replicationCollectionList.push({ collectionName: this.allowanceDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullAllowances(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushAllowances(items); } }); replicationCollectionList.push({ collectionName: this.assetDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullAssets(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushAssets(items); } }); replicationCollectionList.push({ collectionName: this.contactDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullContacts(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushContacts(items); } }); replicationCollectionList.push({ collectionName: this.serviceDataStorage.collectionName, async replicationPull(replicaCanister, updatedAt, id, batchSize) { return await replicaCanister.pullServices(updatedAt, id, batchSize); }, async replicationPush(replicaCanister, items) { return await replicaCanister.pushServices(items); } }); await this.replicationProcessor.initReplication(replicationCollectionList); } }; exports.IcrcReplicationManager = IcrcReplicationManager; exports.IcrcReplicationManager = IcrcReplicationManager = __decorate([ (0, typedi_1.Service)(), __param(0, (0, typedi_1.Inject)("ILogger")), __param(1, (0, typedi_1.Inject)("IcrcReplicationConfiguration")), __param(5, (0, typedi_1.Inject)("createIcrcCanisterFunc")), __param(6, (0, typedi_1.Inject)("IAllowanceDataStorage")), __param(7, (0, typedi_1.Inject)("IAssetDataStorage")), __param(8, (0, typedi_1.Inject)("IContactDataStorage")), __param(9, (0, typedi_1.Inject)("IServiceDataStorage")), __metadata("design:paramtypes", [Object, Object, common_1.IdentifierService, IcrcRxSyncStateService_1.IcrcRxSyncStateService, storage_1.IcrcDbContext, Function, Object, Object, Object, Object]) ], IcrcReplicationManager);