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

41 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

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