Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bytecodeHex = bytecode.object;
}
else {
// Crash in the next verification step
bytecodeHex = "!";
}
// Make sure it is 0x prefixed
if (bytecodeHex.substring(0, 2) !== "0x") {
bytecodeHex = "0x" + bytecodeHex;
}
// Make sure the final result is valid bytecode
if (!bytes_1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) {
logger.throwArgumentError("invalid bytecode", "bytecode", bytecode);
}
// If we have a signer, make sure it is valid
if (signer && !abstract_signer_1.Signer.isSigner(signer)) {
logger.throwArgumentError("invalid signer", "signer", signer);
}
properties_1.defineReadOnly(this, "bytecode", bytecodeHex);
properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface));
properties_1.defineReadOnly(this, "signer", signer || null);
}
ContractFactory.prototype.getDeployTransaction = function () {
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", {});
{
JsonRpcSigner.prototype.signMessage = function (message) {
var _this = this;
var data = ((typeof (message) === "string") ? strings_1.toUtf8Bytes(message) : message);
return this.getAddress().then(function (address) {
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
return _this.provider.send("eth_sign", [address.toLowerCase(), bytes_1.hexlify(data)]);
});
};
JsonRpcSigner.prototype.unlock = function (password) {
var provider = this.provider;
return this.getAddress().then(function (address) {
return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]);
});
};
return JsonRpcSigner;
}(abstract_signer_1.Signer));
exports.JsonRpcSigner = JsonRpcSigner;
var UncheckedJsonRpcSigner = /** @class */ (function (_super) {
__extends(UncheckedJsonRpcSigner, _super);
function UncheckedJsonRpcSigner() {
return _super !== null && _super.apply(this, arguments) || this;
}
UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) {
var _this = this;
return this.sendUncheckedTransaction(transaction).then(function (hash) {
return {
hash: hash,
nonce: null,
gasLimit: null,
gasPrice: null,
data: null,
value: null,
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var contracts_1 = require("@ethersproject/contracts");
exports.Contract = contracts_1.Contract;
exports.ContractFactory = contracts_1.ContractFactory;
var bignumber_1 = require("@ethersproject/bignumber");
exports.BigNumber = bignumber_1.BigNumber;
exports.FixedNumber = bignumber_1.FixedNumber;
var abstract_signer_1 = require("@ethersproject/abstract-signer");
exports.Signer = abstract_signer_1.Signer;
exports.VoidSigner = abstract_signer_1.VoidSigner;
var wallet_1 = require("@ethersproject/wallet");
exports.Wallet = wallet_1.Wallet;
var constants = __importStar(require("@ethersproject/constants"));
exports.constants = constants;
var providers = __importStar(require("@ethersproject/providers"));
exports.providers = providers;
var providers_1 = require("@ethersproject/providers");
exports.getDefaultProvider = providers_1.getDefaultProvider;
var wordlists_1 = require("@ethersproject/wordlists");
exports.Wordlist = wordlists_1.Wordlist;
exports.wordlists = wordlists_1.wordlists;
var utils = __importStar(require("./utils"));
exports.utils = utils;
var logger_1 = require("@ethersproject/logger");
var errors = logger_1.Logger.errors;
var mnemonic = hdnode_1.entropyToMnemonic(entropy, options.locale);
return Wallet.fromMnemonic(mnemonic, options.path, options.locale);
};
Wallet.fromEncryptedJson = function (json, password, progressCallback) {
return json_wallets_1.decryptJsonWallet(json, password, progressCallback).then(function (account) {
return new Wallet(account);
});
};
Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
if (!path) {
path = hdnode_1.defaultPath;
}
return new Wallet(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path));
};
return Wallet;
}(abstract_signer_1.Signer));
exports.Wallet = Wallet;
function verifyMessage(message, signature) {
return transactions_1.recoverAddress(hash_1.hashMessage(message), signature);
}
exports.verifyMessage = verifyMessage;