Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethers v5 beta Update #2

Merged
merged 13 commits into from
Sep 7, 2019
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ shims/*.d.ts
**/*.tmp-browserify-*

lerna-debug.log

packages/*/tsconfig.tsbuildinfo

packages/testcases/input/nameprep/**
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ Changelog

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

ethers/v5.0.0-beta.156 (2019-09-06 17:56)
-----------------------------------------

- Removed export star to fix UMD dist file. ([4c17c4d](https://github.com/ethers-io/ethers.js/commit/4c17c4db0455e1b89fd597c4c929cdc36aa3d90d))
- Updated TypeScript version. ([e8028d0](https://github.com/ethers-io/ethers.js/commit/e8028d0e73368257b76b394bb8e2bf63f8aecd71))
- Fixed test suites and reporter. ([1e0ed4e](https://github.com/ethers-io/ethers.js/commit/1e0ed4e99a22a27fe5057336f8cb320809768f3e))
- Added lock-versions admin tool. ([2187604](https://github.com/ethers-io/ethers.js/commit/21876049137644af2b3afa31120ee95d032843a8))
- Updated packages with version lock and moved types. ([85b4db7](https://github.com/ethers-io/ethers.js/commit/85b4db7d6db37b853f11a90cf4648c34404edcf9))
- Fixed typo in error message. ([#592](https://github.com/ethers-io/ethers.js/issues/592); [019c1fc](https://github.com/ethers-io/ethers.js/commit/019c1fc7089b3da2d7bd41c933b6c6bc35c8dade))
- Fixed build process to re-target browser field to ES version. ([3a91e91](https://github.com/ethers-io/ethers.js/commit/3a91e91df56c1ef6cf096c0322f74fd5060891e0))
- Major overhaul in compilation to enable ES6 module generation. ([73a0077](https://github.com/ethers-io/ethers.js/commit/73a0077fd38c6ae79f33a9d4d3cc128a904b4a6c))
- Updated some of the flatworm docs. ([81fd942](https://github.com/ethers-io/ethers.js/commit/81fd9428cab4be7eee7ddeb564bf91f282cae475))
- Fixed package descriptions. ([#561](https://github.com/ethers-io/ethers.js/issues/561); [ebfca98](https://github.com/ethers-io/ethers.js/commit/ebfca98dc276d6f6ca6961632635e8203bb17645))

ethers/v5.0.0-beta.155 (2019-08-22 17:11)
-----------------------------------------

Expand Down
63 changes: 58 additions & 5 deletions admin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const fs = require("fs");
const resolve = require("path").resolve;
const spawn = require("child_process").spawn;

const local = require("./local");
const { dirnames } = require("./local");
const { loadPackage, savePackage } = require("./local");
const { loadJson, saveJson } = require("./utils");

function run(progname, args, ignoreErrorStream) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -46,16 +48,67 @@ function run(progname, args, ignoreErrorStream) {
});
}

function runBuild() {
return run("npx", [ "tsc", "--build", resolve(__dirname, "../tsconfig.project.json") ]);
function setupConfig(outDir, moduleType, targetType) {
function update(value) {
let comps = value.split("/");
if (comps.length >= 3 && comps[0] === "." && comps[1].match(/^lib(\.esm)?$/)) {
return outDir + comps.slice(2).join("/");
}
return value;
}

// Configure the tsconfit.package.json...
const path = resolve(__dirname, "../tsconfig.package.json");
const content = loadJson(path);
content.compilerOptions.module = moduleType;
content.compilerOptions.target = targetType;
saveJson(path, content);

dirnames.forEach((dirname) => {
let info = loadPackage(dirname);

if (info._ethers_nobuild) { return; }

if (info.browser) {
if (typeof(info.browser) === "string") {
info.browser = update(info.browser);
} else {
for (let key in info.browser) {
info.browser[key] = update(info.browser[key]);
}
}
}
savePackage(dirname, info);

let path = resolve(__dirname, "../packages", dirname, "tsconfig.json");
let content = loadJson(path);
content.compilerOptions.outDir = outDir;
saveJson(path, content);
});
}

function setupBuild(buildModule) {
if (buildModule) {
setupConfig("./lib.esm/", "es2015", "es2015");
} else {
setupConfig("./lib/", "commonjs", "es5");
}
}

function runBuild(buildModule) {
setupBuild(buildModule);

// Compile
return run("npx", [ "tsc", "--build", resolve(__dirname, "../tsconfig.project.json"), "--force" ]);
}

function runDist() {
return run("npx", [ "lerna", "run", "dist" ], true);
return run("npm", [ "run", "_dist_ethers" ], true);
}

module.exports = {
run: run,
runDist: runDist,
runBuild: runBuild
runBuild: runBuild,
setupBuild: setupBuild
};
41 changes: 41 additions & 0 deletions admin/cmds/lock-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";

const { getOrdered, loadPackage } = require("../depgraph");
const { savePackage } = require("../local");
const { log } = require("../log");

(async function() {
let versions = { };

const dirnames = getOrdered();

dirnames.forEach((dirname) => {
let info = loadPackage(dirname);
if (info.name.split("/")[0] === "@ethersproject" || info.name === "ethers") {
versions[info.name] = info.version;
}
});

dirnames.forEach((dirname) => {
const info = loadPackage(dirname);
let shown = false;
["dependencies", "devDependencies"].forEach((key) => {
const deps = info[key];
if (!deps) { return; }
Object.keys(deps).forEach((name) => {
if (versions[name] == null) { return; }
const value = ">=" + versions[name];
if (value !== deps[name])
if (!deps[name]) { return; }
if (!shown) {
log(`<bold:Locking ${ info.name }:>`);
shown = true;
}
log(` <green:${ name }>: ${ deps[name] } => <bold:${ value.substring(2) }>`);
deps[name] = value;
});
});
savePackage(dirname, info);
});

})();
5 changes: 5 additions & 0 deletions admin/cmds/reset-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";

const { setupBuild } = require("../build");

setupBuild(false);
20 changes: 20 additions & 0 deletions admin/cmds/update-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";

const fs = require("fs");
const { resolve } = require("path");

const sourceEthers = fs.readFileSync(resolve(__dirname, "../../packages/ethers/src.ts/ethers.ts")).toString();
const targets = sourceEthers.match(/export\s*{\s*((.|\s)*)}/)[1].trim();

const output = `"use strict";

import * as ethers from "./ethers";

export { ethers };

export {
${ targets }
} from "./ethers";
`;

fs.writeFileSync(resolve(__dirname, "../../packages/ethers/src.ts/index.ts"), output);
21 changes: 7 additions & 14 deletions admin/cmds/update-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { getPackageVersion } = require("../npm");
const { resolve } = require("../utils");
const { colorify, log } = require("../log");

const { getProgressBar } = require("../../packages/cli/prompt");
const { prompt } = require("../../packages/cli");

let dirnames = getOrdered();

Expand All @@ -41,8 +41,7 @@ if (process.argv.length > 2) {
}

(async function() {

let progress = getProgressBar(colorify("Updating versions", "bold"));
let progress = prompt.getProgressBar(colorify("Updating versions", "bold"));

for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
Expand All @@ -52,14 +51,6 @@ if (process.argv.length > 2) {

// Get local package.json (update the tarballHash)
let info = await updatePackage(dirname);
/*
let info = await updatePackage(dirname, {
repository: {
type: "git",
url: "git://github.com/ethers-io/ethers.js.git"
}
});
*/

// Get the remote package.json (or sub in a placeholder for new pacakges)
let npmInfo = await getPackageVersion(info.name);
Expand All @@ -85,8 +76,10 @@ if (process.argv.length > 2) {
progress(1);

try {
log("<bold:Building TypeScript source...>");
await runBuild();
log("<bold:Building TypeScript source (es6)...>");
await runBuild(true);
log("<bold:Building TypeScript source (commonjs)...>");
await runBuild(false);
log("<bold:Building distribution files...>");
let content = await runDist();
console.log(content);
Expand All @@ -97,7 +90,7 @@ if (process.argv.length > 2) {
}

// Update the tarball hash now that _version and package.json may have changed.
progress = getProgressBar(colorify("Updating tarballHash", "bold"));
progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
await updatePackage(dirnames[i]);
Expand Down
2 changes: 1 addition & 1 deletion admin/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const resolve = require("path").resolve;
const AES = require("aes-js");
const scrypt = require("scrypt-js");

const prompt = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");
const randomBytes = require("../packages/random").randomBytes;
const computeHmac = require("../packages/sha2").computeHmac;

Expand Down
6 changes: 3 additions & 3 deletions admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const resolve = require("path").resolve;
const diff = require("diff");
const semver = require("semver");

const { getProgressBar, prompt } = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");

const build = require("./build");
const changelog = require("./changelog");
Expand Down Expand Up @@ -158,7 +158,7 @@ async function runUpdate(dirnames) {
// @TODO: Root

// Update all the package.json and _version.ts
let progress = getProgressBar(colorify("Updating versions", "bold"));
let progress = prompt.getProgressBar(colorify("Updating versions", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);

Expand Down Expand Up @@ -205,7 +205,7 @@ async function runUpdate(dirnames) {
// @TODO:

// Update the tarball hash now that _version and package.json may have changed.
progress = getProgressBar(colorify("Updating tarballHash", "bold"));
progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
await local.updatePackage(dirnames[i]);
Expand Down
11 changes: 10 additions & 1 deletion admin/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

const packlist = require("npm-packlist");
const tar = require("tar");
const keccak256 = require("../packages/keccak256").keccak256;

const keccak256 = (function() {
try {
return require("../packages/keccak256").keccak256;
} catch (error) {
console.log("Cannot load Keccak256 (maybe not built yet? Not really a problem for most things)");
return null;
}
})();

const { dirnames, loadPackage, ROOT } = require("./depgraph");
const { resolve, saveJson } = require("./utils");

Expand Down
2 changes: 1 addition & 1 deletion admin/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const local = require("./local");

const keccak256 = require("../packages/keccak256").keccak256;
const fetchJson = require("../packages/web").fetchJson;
const prompt = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");

const colorify = require("./log").colorify;
const git = require("./git");
Expand Down
33 changes: 29 additions & 4 deletions docs.wrm/api/providers/api-providers.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,43 @@ resiliance, security and increase the amount of required trust.
To mitigate these issues, it is recommended you use a
[Default Provider](get-default-provider).


_subsection: EtherscanProvider

Tra la la...
The **EtherscanProvider** is backed by a combination of the various
[Etherscan APIs](https://etherscan.io/apis).

_property: provider.getHistory(address) => Array<History>


_subsection: InfuraProvider

Tra la la...
The **InfuraProvider** is backed by the popular [INFURA](https://infura.io)
Ethereum service.

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby,
G&ouml;rli and Kovan).


_subsection: NodesmithProvider

Tra la la...
The **NodesmithProvider** is backed by [Nodesmith](https://nodesmith.io).

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby,
G&ouml;rli and Kovan), as well as the Ethereum-like network [Aion](https://aion.network).


_subsection: AlchemyProvider

Tra la la...
The **AlchemtProvider** is backed by [Alchemy](https://alchemyapi.io).

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby,
G&ouml;rli and Kovan).


_subsection: CloudfrontProvider

The CloudfrontProvider is backed by the
[Cloudflare Ethereum Gateway](https://developers.cloudflare.com/distributed-web/ethereum-gateway/).

It only supports Mainnet (homestead).
11 changes: 6 additions & 5 deletions docs.wrm/api/signer.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ _section: Signers

Tra la la...

_subsection: Signer
_subsection: Signer @<signer>

_property: signer.connect(provider) => Signer
_property: signer.connect(provider) => [[signer]]
TODO

_heading: Blockchain Methods

_property: signer.getBalance([ blockTag = "latest" ]) => Promise(BigNumber)
_property: signer.getBalance([ blockTag = "latest" ]) => Promise<[[bignumber]]>
TODO

_property: signer.getTransactionCount([ blockTag = "latest" ]) => Promise(number)
_property: signer.getTransactionCount([ blockTag = "latest" ]) => Promise<number>
TODO


_subsection: Wallet inherits Signer

Wallet is...
The Wallet class inherits [[signer]] and can sign transactions and messages
using a private key as a standard Externally Owned Account (EOA).

_heading: Creating an Instance

Expand Down
6 changes: 3 additions & 3 deletions docs.wrm/api/utils/bignumber.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ the //bitcount// least significant bits set to zero.
_heading: Two's Compliment

[Two's Complicment](https://en.wikipedia.org/wiki/Two%27s_complement)
is a method used to encode and decode fixed-width values which can be
positive or negative, without requiring a separate sign bit. Most users
will not need to interact with these.
is an elegant method used to encode and decode fixed-width signed values
while efficiently preserving mathematic operations.
Most users will not need to interact with these.

_property: bignumber.fromTwos(bitwidth) => [[bignumber]]
Returns a BigNumber with the value of //bignumber// converted from twos-compliment with //bitwidth//.
Expand Down
Loading