2019-08-25 09:39:20 +03:00
|
|
|
"use strict";
|
|
|
|
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
|
|
|
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
2020-02-27 22:58:05 +03:00
|
|
|
import { decrypt as decryptKeystore, decryptSync as decryptKeystoreSync, encrypt as encryptKeystore } from "./keystore";
|
2019-08-25 09:39:20 +03:00
|
|
|
function decryptJsonWallet(json, password, progressCallback) {
|
|
|
|
if (isCrowdsaleWallet(json)) {
|
|
|
|
if (progressCallback) {
|
|
|
|
progressCallback(0);
|
|
|
|
}
|
2019-11-20 12:57:38 +03:00
|
|
|
const account = decryptCrowdsale(json, password);
|
2019-08-25 09:39:20 +03:00
|
|
|
if (progressCallback) {
|
|
|
|
progressCallback(1);
|
|
|
|
}
|
|
|
|
return Promise.resolve(account);
|
|
|
|
}
|
|
|
|
if (isKeystoreWallet(json)) {
|
|
|
|
return decryptKeystore(json, password, progressCallback);
|
|
|
|
}
|
|
|
|
return Promise.reject(new Error("invalid JSON wallet"));
|
|
|
|
}
|
2020-02-27 22:58:05 +03:00
|
|
|
function decryptJsonWalletSync(json, password) {
|
|
|
|
if (isCrowdsaleWallet(json)) {
|
|
|
|
return decryptCrowdsale(json, password);
|
|
|
|
}
|
|
|
|
if (isKeystoreWallet(json)) {
|
|
|
|
return decryptKeystoreSync(json, password);
|
|
|
|
}
|
|
|
|
throw new Error("invalid JSON wallet");
|
|
|
|
}
|
|
|
|
export { decryptCrowdsale, decryptKeystore, decryptKeystoreSync, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, decryptJsonWalletSync, };
|
2020-07-13 15:03:56 +03:00
|
|
|
//# sourceMappingURL=index.js.map
|