ethers.js/packages/json-wallets/lib/index.js

41 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-05-15 01:48:48 +03:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2021-03-08 02:24:04 +03:00
exports.decryptJsonWalletSync = exports.decryptJsonWallet = exports.getJsonWalletAddress = exports.isKeystoreWallet = exports.isCrowdsaleWallet = exports.encryptKeystore = exports.decryptKeystoreSync = exports.decryptKeystore = exports.decryptCrowdsale = void 0;
2019-05-15 01:48:48 +03:00
var crowdsale_1 = require("./crowdsale");
2021-03-08 02:24:04 +03:00
Object.defineProperty(exports, "decryptCrowdsale", { enumerable: true, get: function () { return crowdsale_1.decrypt; } });
2019-05-15 01:48:48 +03:00
var inspect_1 = require("./inspect");
2021-03-08 02:24:04 +03:00
Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function () { return inspect_1.getJsonWalletAddress; } });
Object.defineProperty(exports, "isCrowdsaleWallet", { enumerable: true, get: function () { return inspect_1.isCrowdsaleWallet; } });
Object.defineProperty(exports, "isKeystoreWallet", { enumerable: true, get: function () { return inspect_1.isKeystoreWallet; } });
2019-05-15 01:48:48 +03:00
var keystore_1 = require("./keystore");
2021-03-08 02:24:04 +03:00
Object.defineProperty(exports, "decryptKeystore", { enumerable: true, get: function () { return keystore_1.decrypt; } });
Object.defineProperty(exports, "decryptKeystoreSync", { enumerable: true, get: function () { return keystore_1.decryptSync; } });
Object.defineProperty(exports, "encryptKeystore", { enumerable: true, get: function () { return keystore_1.encrypt; } });
2019-05-15 01:48:48 +03:00
function decryptJsonWallet(json, password, progressCallback) {
if (inspect_1.isCrowdsaleWallet(json)) {
if (progressCallback) {
progressCallback(0);
}
var account = crowdsale_1.decrypt(json, password);
if (progressCallback) {
progressCallback(1);
}
return Promise.resolve(account);
}
if (inspect_1.isKeystoreWallet(json)) {
return keystore_1.decrypt(json, password, progressCallback);
}
return Promise.reject(new Error("invalid JSON wallet"));
}
exports.decryptJsonWallet = decryptJsonWallet;
2020-02-27 22:58:05 +03:00
function decryptJsonWalletSync(json, password) {
if (inspect_1.isCrowdsaleWallet(json)) {
return crowdsale_1.decrypt(json, password);
}
if (inspect_1.isKeystoreWallet(json)) {
return keystore_1.decryptSync(json, password);
}
throw new Error("invalid JSON wallet");
}
exports.decryptJsonWalletSync = decryptJsonWalletSync;
2020-07-13 15:03:56 +03:00
//# sourceMappingURL=index.js.map