54 lines
2.0 KiB
JavaScript
54 lines
2.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.DataManager = void 0;
|
|
const tslib_1 = require("tslib");
|
|
const coins_eth_json_1 = tslib_1.__importDefault(require("@trezor/connect-common/files/coins-eth.json"));
|
|
const coins_json_1 = tslib_1.__importDefault(require("@trezor/connect-common/files/coins.json"));
|
|
const messages_json_1 = tslib_1.__importDefault(require("@trezor/protobuf/messages.json"));
|
|
const coinInfo_1 = require("./coinInfo");
|
|
const firmwareInfo_1 = require("./firmwareInfo");
|
|
const types_1 = require("../types");
|
|
const assetUtils_1 = require("../utils/assetUtils");
|
|
class DataManager {
|
|
static assets = {};
|
|
static settings;
|
|
static messages = messages_json_1.default;
|
|
static load(settings, withAssets = true) {
|
|
this.settings = settings;
|
|
if (!withAssets)
|
|
return;
|
|
const assetsMap = {
|
|
coins: coins_json_1.default,
|
|
coinsEth: coins_eth_json_1.default,
|
|
...Object.fromEntries(Object.entries(assetUtils_1.firmwareAssets).map(([key, value]) => [
|
|
`firmware-${key.toLowerCase()}`,
|
|
value,
|
|
])),
|
|
};
|
|
Object.assign(this.assets, assetsMap);
|
|
(0, coinInfo_1.parseCoinsJson)({
|
|
...this.assets.coins,
|
|
...this.assets.coinsEth,
|
|
});
|
|
for (const model in types_1.DeviceModelInternal) {
|
|
const firmwareKey = `firmware-${model.toLowerCase()}`;
|
|
const modelType = types_1.DeviceModelInternal[model];
|
|
if (this.assets[firmwareKey]) {
|
|
(0, firmwareInfo_1.parseFirmware)(this.assets[firmwareKey], modelType);
|
|
}
|
|
}
|
|
}
|
|
static getProtobufMessages() {
|
|
return this.messages;
|
|
}
|
|
static getSettings(key) {
|
|
if (!this.settings)
|
|
return null;
|
|
if (typeof key === 'string') {
|
|
return this.settings[key];
|
|
}
|
|
return this.settings;
|
|
}
|
|
}
|
|
exports.DataManager = DataManager;
|
|
//# sourceMappingURL=DataManager.js.map
|