Skip to content

Commit

Permalink
Updated dist files.
Browse files Browse the repository at this point in the history
ricmoo committed Jan 30, 2020
1 parent 7428776 commit bee5944
Showing 45 changed files with 446 additions and 205 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,11 +3,17 @@ Changelog

This change log is managed by `scripts/cmds/update-versions` but may be manually updated.

ethers/v5.0.0-beta.171 (2020-01-29 21:41)
-----------------------------------------

- Better solc support in CLI; it will search the local pacakge for an existing solc version. ([7428776](https://github.com/ethers-io/ethers.js/commit/7428776f75222d5c07282bc29c3dd8ed99f5d2cc))
- Update ENS registry address and lower default quorum for testnets. ([edb49da](https://github.com/ethers-io/ethers.js/commit/edb49da15518f25b3d60813ebb84f54171e308f3))
- Exposed isBytes and isBytesLike in ethers.utils. ([99329b0](https://github.com/ethers-io/ethers.js/commit/99329b013ce7f3af301d40c41f7eb35bff288910))

ethers/v5.0.0-beta.170 (2020-01-21 20:37)
-----------------------------------------

- Better, easier and more provider testing. ([e0d1d38](https://github.com/ethers-io/ethers.js/commit/e0d1d3866d2559f39627254873a0a1d4c0fcaf3d))
- Updated dist files. ([f92d156](https://github.com/ethers-io/ethers.js/commit/f92d156f1784bbb299d99fe6a0ddb53c0e2d0d09))
- Fixed out-of-bounds difficulty in getBlock, which can affect PoA networks. ([#711](https://github.com/ethers-io/ethers.js/issues/711); [251882c](https://github.com/ethers-io/ethers.js/commit/251882ced4379931ec82ba28a4db10bc7dbf3580))

ethers/v5.0.0-beta.169 (2020-01-20 19:42)
2 changes: 1 addition & 1 deletion packages/cli/lib.esm/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "cli/5.0.0-beta.148";
export declare const version = "cli/5.0.0-beta.149";
2 changes: 1 addition & 1 deletion packages/cli/lib.esm/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "cli/5.0.0-beta.148";
export const version = "cli/5.0.0-beta.149";
85 changes: 62 additions & 23 deletions packages/cli/lib.esm/bin/ethers.js
Original file line number Diff line number Diff line change
@@ -10,15 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
import fs from "fs";
import _module from "module";
import { dirname, resolve } from "path";
import REPL from "repl";
import util from "util";
import vm from "vm";
import { ethers } from "ethers";
import { CLI, dump, Plugin } from "../cli";
import { getPassword, getProgressBar } from "../prompt";
import { compile } from "../solc";
import { compile, customRequire } from "../solc";
function setupContext(path, context, plugin) {
context.provider = plugin.provider;
context.accounts = plugin.accounts;
@@ -32,7 +31,8 @@ function setupContext(path, context, plugin) {
context.console = console;
}
if (!context.require) {
context.require = _module.createRequireFromPath(path);
//context.require = _module.createRequireFromPath(path);
context.require = customRequire(path);
}
if (!context.process) {
context.process = process;
@@ -225,10 +225,15 @@ class FundPlugin extends Plugin {
if (this.network.name !== "ropsten") {
this.throwError("Funding requires --network ropsten");
}
if (args.length !== 1) {
if (args.length === 1) {
this.toAddress = yield this.getAddress(args[0], "Cannot fund ZERO address", false);
}
else if (args.length === 0 && this.accounts.length === 1) {
this.toAddress = yield this.accounts[0].getAddress();
}
else {
this.throwUsageError("fund requires ADDRESS");
}
this.toAddress = yield this.getAddress(args[0], "Cannot fund ZERO address", false);
});
}
run() {
@@ -757,22 +762,37 @@ class CompilePlugin extends Plugin {
if (args.length !== 1) {
this.throwError("compile requires exactly FILENAME");
}
this.filename = args[0];
this.filename = resolve(args[0]);
});
}
run() {
return __awaiter(this, void 0, void 0, function* () {
let source = fs.readFileSync(this.filename).toString();
let result = compile(source, {
filename: this.filename,
optimize: (!this.noOptimize)
});
const source = fs.readFileSync(this.filename).toString();
let result = null;
try {
result = compile(source, {
filename: this.filename,
optimize: (!this.noOptimize)
});
}
catch (error) {
if (error.errors) {
error.errors.forEach((error) => {
console.log(error);
});
}
else {
throw error;
}
throw new Error("Failed to compile contract.");
}
let output = {};
result.forEach((contract, index) => {
output[contract.name] = {
bytecode: contract.bytecode,
runtime: contract.runtime,
interface: contract.interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full))
interface: contract.interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full)),
compiler: contract.compiler
};
});
console.log(JSON.stringify(output, null, 4));
@@ -821,30 +841,49 @@ class DeployPlugin extends Plugin {
if (args.length !== 1) {
this.throwError("deploy requires exactly FILENAME");
}
this.filename = args[0];
this.filename = resolve(args[0]);
});
}
run() {
return __awaiter(this, void 0, void 0, function* () {
let source = fs.readFileSync(this.filename).toString();
let result = compile(source, {
filename: this.filename,
optimize: (!this.noOptimize)
});
let codes = result.filter((c) => (c.bytecode !== "0x" && (this.contractName == null || this.contractName == c.name)));
let result = null;
try {
result = compile(source, {
filename: this.filename,
optimize: (!this.noOptimize)
});
}
catch (error) {
if (error.errors) {
error.errors.forEach((error) => {
console.log(error);
});
}
else {
throw error;
}
throw new Error("Failed to compile contract.");
}
const codes = result.filter((c) => (this.contractName == null || this.contractName == c.name));
if (codes.length > 1) {
this.throwError("Please specify a contract with --contract NAME");
this.throwError("Multiple contracts found; please specify a contract with --contract NAME");
}
if (codes.length === 0) {
this.throwError("No contract found");
}
let factory = new ethers.ContractFactory(codes[0].interface, codes[0].bytecode, this.accounts[0]);
let contract = yield factory.deploy();
const factory = new ethers.ContractFactory(codes[0].interface, codes[0].bytecode, this.accounts[0]);
dump("Deploying:", {
Contract: codes[0].name,
Bytecode: codes[0].bytecode,
Interface: codes[0].interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full)),
Compiler: codes[0].compiler,
Optimizer: (this.noOptimize ? "No" : "Yes")
});
const contract = yield factory.deploy();
dump("Deployed:", {
Contract: codes[0].name,
Address: contract.address,
Bytecode: codes[0].bytecode,
Interface: codes[0].interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full))
});
});
}
9 changes: 6 additions & 3 deletions packages/cli/lib.esm/solc.d.ts
Original file line number Diff line number Diff line change
@@ -2,13 +2,16 @@ import { ethers } from "ethers";
export interface ContractCode {
interface: ethers.utils.Interface;
name: string;
bytecode?: string;
runtime?: string;
compiler: string;
bytecode: string;
runtime: string;
}
export declare type CompilerOptions = {
filename?: string;
basedir?: string;
optimize?: boolean;
throwWarnings?: boolean;
};
export declare function compile(source: string, options?: CompilerOptions): Array<ContractCode>;
export declare function customRequire(path: string): (name: string) => any;
export declare function wrapSolc(_solc: any): (source: string, options?: CompilerOptions) => Array<ContractCode>;
export declare const compile: (source: string, options?: CompilerOptions) => ContractCode[];
77 changes: 62 additions & 15 deletions packages/cli/lib.esm/solc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
'use strict';
import fs from "fs";
import _module from "module";
import { dirname, resolve } from "path";
import { ethers } from "ethers";
let _solc = null;
function getSolc() {
if (!_solc) {
_solc = require("solc");
}
return _solc;
}
;
export function compile(source, options) {
function populateOptions(options) {
options = ethers.utils.shallowCopy(options || {});
if (options.filename && !options.basedir) {
options.basedir = dirname(options.filename);
@@ -21,9 +15,12 @@ export function compile(source, options) {
if (!options.basedir) {
options.basedir = ".";
}
let sources = {};
return options;
}
function getInput(source, options) {
const sources = {};
sources[options.filename] = { content: source };
let input = {
const input = {
language: "Solidity",
sources: sources,
settings: {
@@ -40,6 +37,21 @@ export function compile(source, options) {
runs: 200
};
}
return input;
}
function _compile(_solc, source, options) {
const compilerVersion = _solc.version();
const ver = compilerVersion.match(/(\d+)\.(\d+)\.(\d+)/);
if (!ver || ver[1] !== "0") {
throw new Error("unknown version");
}
const version = parseFloat(ver[2] + "." + ver[3]);
//if (version < 4.11 || version >= 7) {
if (version < 5.0 || version >= 7.0) {
throw new Error(`unsupported version: ${ver[1]}.${ver[2]}.${ver[3]}`);
}
options = populateOptions(options);
const input = getInput(source, options);
let findImport = (filename) => {
try {
return {
@@ -50,24 +62,59 @@ export function compile(source, options) {
return { error: error.message };
}
};
let output = JSON.parse(getSolc().compile(JSON.stringify(input), findImport));
let errors = (output.errors || []).filter((x) => (x.severity === "error" || options.throwWarnings)).map((x) => x.formattedMessage);
if (version >= 6) {
findImport = { import: findImport };
}
const outputJson = _solc.compile(JSON.stringify(input), findImport);
const output = JSON.parse(outputJson);
const errors = (output.errors || []).filter((x) => (x.severity === "error" || options.throwWarnings)).map((x) => x.formattedMessage);
if (errors.length) {
let error = new Error("compilation error");
const error = new Error("compilation error");
error.errors = errors;
throw error;
}
let result = [];
const result = [];
for (let filename in output.contracts) {
for (let name in output.contracts[filename]) {
let contract = output.contracts[filename][name];
// Skip empty contracts
if (!contract.evm.bytecode.object) {
continue;
}
result.push({
name: name,
interface: new ethers.utils.Interface(contract.abi),
bytecode: "0x" + contract.evm.bytecode.object,
runtime: "0x" + contract.evm.deployedBytecode.object
runtime: "0x" + contract.evm.deployedBytecode.object,
compiler: compilerVersion
});
}
}
return result;
}
// Creates a require which will first search from the current location,
// and for solc will fallback onto the version included in @ethersproject/cli
export function customRequire(path) {
const pathRequire = _module.createRequireFromPath(resolve(path, "./sandbox.js"));
const libRequire = _module.createRequireFromPath(resolve(__filename));
return function (name) {
try {
return pathRequire(name);
}
catch (error) {
if (name === "solc") {
try {
return libRequire(name);
}
catch (error) { }
}
throw error;
}
};
}
export function wrapSolc(_solc) {
return function (source, options) {
return _compile(_solc, source, options || {});
};
}
export const compile = wrapSolc(customRequire(".")("solc"));
2 changes: 1 addition & 1 deletion packages/cli/lib/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "cli/5.0.0-beta.148";
export declare const version = "cli/5.0.0-beta.149";
2 changes: 1 addition & 1 deletion packages/cli/lib/_version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "cli/5.0.0-beta.148";
exports.version = "cli/5.0.0-beta.149";
Loading

0 comments on commit bee5944

Please sign in to comment.