Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(this.interface.functions).forEach(function (name) {
var fragment = _this.interface.functions[name];
// @TODO: This should take in fragment
var run = runMethod(_this, name, {});
if (_this[name] == null) {
properties_1.defineReadOnly(_this, name, run);
}
if (_this.functions[name] == null) {
properties_1.defineReadOnly(_this.functions, name, run);
}
if (_this.callStatic[name] == null) {
properties_1.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true }));
}
if (_this.populateTransaction[name] == null) {
properties_1.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true }));
}
if (_this.estimate[name] == null) {
properties_1.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true }));
}
if (!uniqueFunctions[fragment.name]) {
uniqueFunctions[fragment.name] = [];
}
constructor(locale) {
logger.checkAbstract(new.target, Wordlist);
defineReadOnly(this, "locale", locale);
}
// Subclasses may override this
logger.checkNew(_newTarget, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
var signingKey = new signing_key_1.SigningKey(privateKey);
properties_1.defineReadOnly(this, "privateKey", signingKey.privateKey);
properties_1.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
}
else {
properties_1.defineReadOnly(this, "privateKey", null);
properties_1.defineReadOnly(this, "publicKey", bytes_1.hexlify(publicKey));
}
properties_1.defineReadOnly(this, "parentFingerprint", parentFingerprint);
properties_1.defineReadOnly(this, "fingerprint", bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4));
properties_1.defineReadOnly(this, "address", transactions_1.computeAddress(this.publicKey));
properties_1.defineReadOnly(this, "chainCode", chainCode);
properties_1.defineReadOnly(this, "index", index);
properties_1.defineReadOnly(this, "depth", depth);
properties_1.defineReadOnly(this, "mnemonic", mnemonic);
properties_1.defineReadOnly(this, "path", path);
}
Object.defineProperty(HDNode.prototype, "extendedKey", {
}
} else {
defineReadOnly(this, "_mnemonic", (): string => null);
defineReadOnly(this, "path", null);
}
} else {
if (SigningKey.isSigningKey(privateKey)) {
if (privateKey.curve !== "secp256k1") {
logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
}
defineReadOnly(this, "_signingKey", () => privateKey);
} else {
const signingKey = new SigningKey(privateKey);
defineReadOnly(this, "_signingKey", () => signingKey);
}
defineReadOnly(this, "_mnemonic", (): string => null);
defineReadOnly(this, "path", null);
defineReadOnly(this, "address", computeAddress(this.publicKey));
}
if (provider && !Provider.isProvider(provider)) {
logger.throwArgumentError("invalid provider", "provider", provider);
}
defineReadOnly(this, "provider", provider || null);
}
constructor(tag, filter) {
defineReadOnly(this, "tag", tag);
defineReadOnly(this, "filter", filter);
this._listeners = [];
}
addListener(listener, once) {
properties_1.defineReadOnly(_this, "path", null);
}
}
else {
if (signing_key_1.SigningKey.isSigningKey(privateKey)) {
if (privateKey.curve !== "secp256k1") {
logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
}
properties_1.defineReadOnly(_this, "_signingKey", function () { return privateKey; });
}
else {
var signingKey_2 = new signing_key_1.SigningKey(privateKey);
properties_1.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; });
}
properties_1.defineReadOnly(_this, "_mnemonic", function () { return null; });
properties_1.defineReadOnly(_this, "path", null);
properties_1.defineReadOnly(_this, "address", transactions_1.computeAddress(_this.publicKey));
}
if (provider && !abstract_provider_1.Provider.isProvider(provider)) {
logger.throwArgumentError("invalid provider", "provider", provider);
}
properties_1.defineReadOnly(_this, "provider", provider || null);
return _this;
}
Object.defineProperty(Wallet.prototype, "mnemonic", {
constructor(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) {
logger.checkNew(new.target, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
const signingKey = new SigningKey(privateKey);
defineReadOnly(this, "privateKey", signingKey.privateKey);
defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
}
else {
defineReadOnly(this, "privateKey", null);
defineReadOnly(this, "publicKey", hexlify(publicKey));
}
defineReadOnly(this, "parentFingerprint", parentFingerprint);
defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4));
defineReadOnly(this, "address", computeAddress(this.publicKey));
defineReadOnly(this, "chainCode", chainCode);
defineReadOnly(this, "index", index);
defineReadOnly(this, "depth", depth);
defineReadOnly(this, "mnemonic", mnemonic);
defineReadOnly(this, "path", path);
}
get extendedKey() {
function register(lang, name) {
if (!name) {
name = lang.locale;
}
if (exportWordlist) {
var g = global;
if (!(g.wordlists)) {
properties_1.defineReadOnly(g, "wordlists", {});
}
if (!g.wordlists[name]) {
properties_1.defineReadOnly(g.wordlists, name, lang);
}
if (g.ethers && g.ethers.wordlists) {
if (!g.ethers.wordlists[name]) {
properties_1.defineReadOnly(g.ethers.wordlists, name, lang);
}
}
}
}
exports.register = register;
}
if (privateKey) {
var signingKey = new signing_key_1.SigningKey(privateKey);
properties_1.defineReadOnly(this, "privateKey", signingKey.privateKey);
properties_1.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
}
else {
properties_1.defineReadOnly(this, "privateKey", null);
properties_1.defineReadOnly(this, "publicKey", bytes_1.hexlify(publicKey));
}
properties_1.defineReadOnly(this, "parentFingerprint", parentFingerprint);
properties_1.defineReadOnly(this, "fingerprint", bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4));
properties_1.defineReadOnly(this, "address", transactions_1.computeAddress(this.publicKey));
properties_1.defineReadOnly(this, "chainCode", chainCode);
properties_1.defineReadOnly(this, "index", index);
properties_1.defineReadOnly(this, "depth", depth);
properties_1.defineReadOnly(this, "mnemonic", mnemonic);
properties_1.defineReadOnly(this, "path", path);
}
Object.defineProperty(HDNode.prototype, "extendedKey", {
Object.keys(uniqueFilters_1).forEach(function (name) {
var filters = uniqueFilters_1[name];
if (filters.length === 1) {
properties_1.defineReadOnly(_this.filters, name, _this.filters[filters[0]]);
}
else {
logger.warn("Duplicate definition of " + name + " (" + filters.join(", ") + ")");
}
});
}