Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Contract(addressOrName, contractInterface, signerOrProvider) {
var _newTarget = this.constructor;
var _this = this;
logger.checkNew(_newTarget, Contract);
// @TODO: Maybe still check the addressOrName looks like a valid address or name?
//address = getAddress(address);
properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface));
if (abstract_signer_1.Signer.isSigner(signerOrProvider)) {
properties_1.defineReadOnly(this, "provider", signerOrProvider.provider || null);
properties_1.defineReadOnly(this, "signer", signerOrProvider);
}
else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) {
properties_1.defineReadOnly(this, "provider", signerOrProvider);
properties_1.defineReadOnly(this, "signer", null);
}
else {
logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider);
}
properties_1.defineReadOnly(this, "callStatic", {});
properties_1.defineReadOnly(this, "estimate", {});
properties_1.defineReadOnly(this, "functions", {});
properties_1.defineReadOnly(this, "populateTransaction", {});
properties_1.defineReadOnly(this, "filters", {});
{
var uniqueFilters_1 = {};
Object.keys(this.interface.events).forEach(function (eventSignature) {
var event = _this.interface.events[eventSignature];
properties_1.defineReadOnly(_this.filters, eventSignature, function () {
}
else {
var eventTag_1 = getEventTag(eventName);
this._events = this._events.filter(function (event) {
return (event.tag !== eventTag_1);
});
if (eventName === "pending") {
this._stopPending();
}
}
// Do we still have any events that require polling?
this._checkPolling();
return this;
};
return BaseProvider;
}(abstract_provider_1.Provider));
exports.BaseProvider = BaseProvider;
function BaseProvider(network) {
var _newTarget = this.constructor;
var _this = this;
logger.checkNew(_newTarget, abstract_provider_1.Provider);
_this = _super.call(this) || this;
_this.formatter = _newTarget.getFormatter();
if (network instanceof Promise) {
properties_1.defineReadOnly(_this, "ready", network.then(function (network) {
properties_1.defineReadOnly(_this, "_network", network);
return network;
}));
// Squash any "unhandled promise" errors; that do not need to be handled
_this.ready.catch(function (error) { });
}
else {
var knownNetwork = properties_1.getStatic((_newTarget), "getNetwork")(network);
if (knownNetwork) {
properties_1.defineReadOnly(_this, "_network", knownNetwork);
properties_1.defineReadOnly(_this, "ready", Promise.resolve(_this._network));
}
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", {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var abstract_provider_1 = require("@ethersproject/abstract-provider");
exports.Provider = abstract_provider_1.Provider;
var networks_1 = require("@ethersproject/networks");
exports.getNetwork = networks_1.getNetwork;
var base_provider_1 = require("./base-provider");
exports.BaseProvider = base_provider_1.BaseProvider;
var alchemy_provider_1 = require("./alchemy-provider");
exports.AlchemyProvider = alchemy_provider_1.AlchemyProvider;
var cloudflare_provider_1 = require("./cloudflare-provider");
exports.CloudflareProvider = cloudflare_provider_1.CloudflareProvider;
var etherscan_provider_1 = require("./etherscan-provider");
exports.EtherscanProvider = etherscan_provider_1.EtherscanProvider;
var fallback_provider_1 = require("./fallback-provider");
exports.FallbackProvider = fallback_provider_1.FallbackProvider;
var ipc_provider_1 = require("./ipc-provider");
exports.IpcProvider = ipc_provider_1.IpcProvider;
var infura_provider_1 = require("./infura-provider");
exports.InfuraProvider = infura_provider_1.InfuraProvider;