test-ic-wallet-middleware-icrc
Version:
Ic middleware wallet ICRC protocol
61 lines (60 loc) • 3.37 kB
JavaScript
;
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.IcrcRefreshService = void 0;
const common_1 = require("@ic-wallet-middleware/common");
const handlers_1 = require("../handlers");
const replications_1 = require("../replications");
const typedi_1 = require("typedi");
let IcrcRefreshService = class IcrcRefreshService extends common_1.RefreshServiceBase {
getListAssetHandler;
getListAllowanceHandler;
getListContactHandler;
getListServiceHandler;
configuration;
constructor(getListAssetHandler, getListAllowanceHandler, getListContactHandler, getListServiceHandler, configuration, rxSyncStateService) {
super(configuration, rxSyncStateService);
this.getListAssetHandler = getListAssetHandler;
this.getListAllowanceHandler = getListAllowanceHandler;
this.getListContactHandler = getListContactHandler;
this.getListServiceHandler = getListServiceHandler;
this.configuration = configuration;
}
async runSync() {
let assetListResult = await this.getListAssetHandler.handle({ loadType: common_1.LoadType.Full });
let isSuccess = assetListResult.isSuccess;
if (assetListResult.isSuccess && assetListResult.data) {
for (const asset of assetListResult.data.assets) {
const getAllowanceListResult = await this.getListAllowanceHandler.handle({
loadType: common_1.LoadType.Full, ledgerAddress: asset.ledgerAddress
});
isSuccess = getAllowanceListResult.isSuccess && isSuccess;
}
}
const contactListResult = await this.getListContactHandler.handle({ loadType: common_1.LoadType.Full });
isSuccess = contactListResult.isSuccess && isSuccess;
const serviceListResult = await this.getListServiceHandler.handle({ loadType: common_1.LoadType.Full });
isSuccess = serviceListResult.isSuccess && isSuccess;
return isSuccess;
}
};
exports.IcrcRefreshService = IcrcRefreshService;
exports.IcrcRefreshService = IcrcRefreshService = __decorate([
(0, typedi_1.Service)(),
__param(4, (0, typedi_1.Inject)("RefreshServiceConfiguration")),
__metadata("design:paramtypes", [handlers_1.GetListAssetHandler,
handlers_1.GetListAllowanceHandler,
handlers_1.GetListContactHandler,
handlers_1.GetListServiceHandler, Object, replications_1.IcrcRxSyncStateService])
], IcrcRefreshService);