Merge branch 'yuetloo-ethers-v5-beta' into ethers-v5-beta

This commit is contained in:
Richard Moore 2019-12-13 14:55:29 -05:00
commit 06cafe3437
14 changed files with 10540 additions and 14 deletions

148
.circleci/config.yml Normal file

@ -0,0 +1,148 @@
version: 2.1
executors:
machine_executor:
machine: true
working_directory: ~/repo
commands:
build-and-test:
parameters:
node-version:
type: string
default: "10.16.3"
test-script:
type: string
default: "test-node"
upgrade-chrome:
type: string
default: ""
steps:
- checkout
- when:
condition: << parameters.upgrade-chrome >>
steps:
- run:
name: Upgrade chrome
command: |
sudo apt-get purge chromium-browser
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
google-chrome --version
- run:
name: Update gcc version
command: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-6
sudo apt install g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6
- run:
name: Prepare to run parity
command: |
mkdir -p /tmp/parity/keys
cp -r admin/test-parity/parity-keys /tmp/parity/keys/DevelopmentChain
cp admin/test-parity/parity-dev.* /tmp/parity
chmod -R 777 /tmp/parity
ls -la /tmp/parity
- run:
name: Starting Parity
command: |
docker run -d \
-p 8545:8545 \
-p 8546:8546 \
-p 30303:30303 \
-p 30303:30303/udp \
--name parity \
-v /tmp/parity:/home/parity/.local/share/io.parity.ethereum parity/parity:v2.4.8-stable \
--chain /home/parity/.local/share/io.parity.ethereum/parity-dev.json \
--unlock=0x7454a8F5a7c7555d79B172C89D20E1f4e4CC226C \
--password /home/parity/.local/share/io.parity.ethereum/parity-dev.pwds \
--min-gas-price 1000000000 \
--jsonrpc-interface all
- run:
name: Waiting for Parity to be ready
command: |
for i in `seq 1 20`;
do
nc -z localhost 8545 && echo Success && exit 0
echo -n .
sleep 2
done
docker ps -a
docker logs parity
echo Failed waiting for Parity && exit 1
- run:
name: Run << parameters.test-script >> with node version << parameters.node-version >>
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install << parameters.node-version >>
node -v
npm -v
gcc --version
npm ci
npm run bootstrap
npm run << parameters.test-script >>
jobs:
node-v8:
description: "test with node version 8"
executor: machine_executor
steps:
- build-and-test:
node-version: "8.16.1"
test-script: "test-node"
node-v10:
description: "test with node version 10"
executor: machine_executor
steps:
- build-and-test:
node-version: "10.16.3"
test-script: "test-node"
node-v12:
description: "test with node version 12"
executor: machine_executor
steps:
- build-and-test:
node-version: "12.13.1"
test-script: "test-node"
browser-esm:
description: "test browser with es6 module"
executor: machine_executor
steps:
- build-and-test:
node-version: "12.13.1"
test-script: "test-browser-esm"
upgrade-chrome: "true"
browser-umd:
description: "test browser with es3 module"
executor: machine_executor
steps:
- build-and-test:
node-version: "12.13.1"
test-script: "test-browser-umd"
workflows:
version: 2
all:
jobs:
- node-v8
- node-v10
- node-v12
- browser-esm
- browser-umd

@ -0,0 +1,50 @@
{
"name": "DevelopmentChain",
"engine": {
"instantSeal": null
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x11",
"registrar" : "0x0000000000000000000000000000000000001337",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip98Transition": "0x7fffffffffffff",
"eip140Transition": "0x0",
"eip145Transition": "0x0",
"eip150Transition": "0x0",
"eip155Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip658Transition": "0x0",
"wasmActivationTransition": "0x0"
},
"genesis": {
"seal": {
"generic": "0x0"
},
"difficulty": "0x20000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x7A1200"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } },
"0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } },
"0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } },
"0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } },
"0x7454a8f5a7c7555d79b172c89d20e1f4e4cc226c": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
}
}

@ -0,0 +1 @@

@ -0,0 +1 @@
{"id":"24d70b97-fff9-d322-e760-4b8cc2e21751","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"45d392cd16dbbd5c0f5b2d145c112da9"},"ciphertext":"b001ccd09fc5431dc055975b58ee61f86e85529245506c04182c902716e750e5","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"028594da27a0e864105f33b912e5dc6ce7c75ecd13c81bfc158fe963d30c93bb"},"mac":"374bf2e9144b74b889708abc19e9ebc164f90bc27e83fd9f01da4571a9f81a70"},"address":"7454a8f5a7c7555d79b172c89d20e1f4e4cc226c","name":"","meta":"{}"}

@ -7,12 +7,18 @@ module.exports = function(config) {
{ pattern: "./packages/ethers/dist/ethers-all.esm.min.js", type: "module" }, { pattern: "./packages/ethers/dist/ethers-all.esm.min.js", type: "module" },
{ pattern: "./packages/tests/dist/tests.esm.js", type: "module" } { pattern: "./packages/tests/dist/tests.esm.js", type: "module" }
], ],
reporters: [ 'progress' ], reporters: ['karma'],
plugins: [
'karma-mocha',
'karma-chrome-launcher',
require('./packages/tests/karma-reporter')
],
port: 9876, port: 9876,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
browsers: [ 'ChromeHeadless' ], browsers: [ 'ChromeHeadless' ],
autoWatch: false, autoWatch: false,
singleRun: true, singleRun: true,
browserNoActivityTimeout: 60000
/* /*
client: { client: {
mocha: { mocha: {

@ -7,12 +7,18 @@ module.exports = function(config) {
"./packages/ethers/dist/ethers-all.umd.min.js", "./packages/ethers/dist/ethers-all.umd.min.js",
"./packages/tests/dist/tests.umd.js", "./packages/tests/dist/tests.umd.js",
], ],
reporters: [ 'progress' ], reporters: [ 'karma' ],
plugins: [
'karma-mocha',
'karma-chrome-launcher',
require('./packages/tests/karma-reporter')
],
port: 9876, port: 9876,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
browsers: [ 'ChromeHeadless' ], browsers: [ 'ChromeHeadless' ],
autoWatch: false, autoWatch: false,
singleRun: true, singleRun: true,
browserNoActivityTimeout: 180000
/* /*
client: { client: {
mocha: { mocha: {

10216
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

@ -9,7 +9,6 @@
"auto-build": "node ./admin/cmds/reset-build.js && npm run build -- -w", "auto-build": "node ./admin/cmds/reset-build.js && npm run build -- -w",
"bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", "bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist",
"build": "tsc --build ./tsconfig.project.json", "build": "tsc --build ./tsconfig.project.json",
"_build-cjs": "node ./admin/cmds/set-option cjs && npm run build", "_build-cjs": "node ./admin/cmds/set-option cjs && npm run build",
"_build-esm": "node ./admin/cmds/set-option esm && npm run build", "_build-esm": "node ./admin/cmds/set-option esm && npm run build",
"_dist-min-all": "node ./admin/cmds/set-option.js browser-lang-all && rollup -c --configMinify && rollup -c --configMinify --configModule && mv ./packages/ethers/dist/ethers.umd.min.js ./packages/ethers/dist/ethers-all.umd.min.js && mv ./packages/ethers/dist/ethers.esm.min.js ./packages/ethers/dist/ethers-all.esm.min.js", "_dist-min-all": "node ./admin/cmds/set-option.js browser-lang-all && rollup -c --configMinify && rollup -c --configMinify --configModule && mv ./packages/ethers/dist/ethers.umd.min.js ./packages/ethers/dist/ethers-all.umd.min.js && mv ./packages/ethers/dist/ethers.esm.min.js ./packages/ethers/dist/ethers-all.esm.min.js",
@ -17,15 +16,11 @@
"_dist-full": "rollup -c && rollup -c --configModule", "_dist-full": "rollup -c && rollup -c --configModule",
"_dist": "npm run _dist-min-all && npm run _dist-min-en && npm run _dist-full", "_dist": "npm run _dist-min-all && npm run _dist-min-en && npm run _dist-full",
"build-all": "node ./admin/cmds/update-exports.js && npm run _build-esm && npm run _build-cjs && npm run _dist", "build-all": "node ./admin/cmds/update-exports.js && npm run _build-esm && npm run _build-cjs && npm run _dist",
"clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json", "clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json",
"__dist_ethers": "npm run _dist-min-all && npm run _dist-min-en && npm run _dist-full", "__dist_ethers": "npm run _dist-min-all && npm run _dist-min-en && npm run _dist-full",
"__dist_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js", "__dist_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js",
"__dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", "__dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify",
"__test_prepare": "npm run _dist_prepare && npm run _dist_tests", "__test_prepare": "npm run _dist_prepare && npm run _dist_tests",
"__test_node": "cd packages/tests && mocha --no-colors --reporter ./reporter ./lib/test-*.js",
"__test_node": "npm run _test_prepare && npm run _test_node", "__test_node": "npm run _test_prepare && npm run _test_node",
"__dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist", "__dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist",
"__old-test": "npm run _dist_old && npm run test-check", "__old-test": "npm run _dist_old && npm run test-check",
@ -34,7 +29,6 @@
"__old-test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js", "__old-test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js",
"__old-test-aion": "npm run dist && npm run test-aion-node", "__old-test-aion": "npm run dist && npm run test-aion-node",
"__old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", "__old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js",
"_dist-test-esm": "rollup -c rollup-tests.config.js --configModule", "_dist-test-esm": "rollup -c rollup-tests.config.js --configModule",
"_dist-test-umd": "rollup -c rollup-tests.config.js", "_dist-test-umd": "rollup -c rollup-tests.config.js",
"_test-browser-umd": "karma start --single-run --browsers ChromeHeadless karma-umd.conf.js", "_test-browser-umd": "karma start --single-run --browsers ChromeHeadless karma-umd.conf.js",
@ -44,16 +38,11 @@
"test-browser-esm": "npm run build-all && npm run _dist-test-esm && npm run _test-browser-esm", "test-browser-esm": "npm run build-all && npm run _dist-test-esm && npm run _test-browser-esm",
"test-node": "npm run build-all && npm run _test-node", "test-node": "npm run build-all && npm run _test-node",
"test": "if [ \"$TEST\" == \"\" ]; then npm run test-node; else npm run \"test-$TEST\"; fi", "test": "if [ \"$TEST\" == \"\" ]; then npm run test-node; else npm run \"test-$TEST\"; fi",
"lock-versions": "node ./admin/cmds/lock-versions", "lock-versions": "node ./admin/cmds/lock-versions",
"build-docs": "flatworm docs.wrm docs", "build-docs": "flatworm docs.wrm docs",
"_admin_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js", "_admin_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js",
"update-versions": "npm run _admin_prepare && node ./admin/cmds/update-versions", "update-versions": "npm run _admin_prepare && node ./admin/cmds/update-versions",
"publish-all": "node ./admin/cmds/publish", "publish-all": "node ./admin/cmds/publish",
"sync-github": "node ./admin/cmds/cache-github" "sync-github": "node ./admin/cmds/cache-github"
}, },
"devDependencies": { "devDependencies": {

@ -0,0 +1,9 @@
pragma solidity ^0.5.0;
import "./libraries/lib.sol";
contract Consumer {
function f() public {
Lib.f();
}
}

@ -0,0 +1,7 @@
pragma solidity ^0.5.0;
library Lib {
function f() internal returns (uint) {
return 7;
}
}

@ -0,0 +1,70 @@
"use strict";
const Reporter = require('./reporter')
const EventEmitter = require('events');
const KarmaReporter = function () {
const runner = new EventEmitter();
const reporter = new Reporter(runner);
let lastSuite = null;
// capture console logs
this.onBrowserLog = function (browser, log, type) {
console.log('\x1b[36m%s\x1b[0m', log);
}
this.onRunComplete = function (browsers, results) {
if (lastSuite !== null) {
runner.emit('suite end');
lastSuite = null;
}
// end the dummy suite for total test count
runner.emit('suite end');
}
this.onSpecComplete = function (browser, result) {
if (result.suite[0] !== lastSuite) {
if (lastSuite === null) {
// this is the first test, start a dummy suite to track total test count
runner.emit('suite', {});
}
else {
// end previous suite
runner.emit('suite end');
}
runner.emit('suite', { title: result.suite });
lastSuite = result.suite[0];
}
runner.emit('test');
if (result.skipped) {
runner.emit('skipped');
}
else if (result.success) {
runner.emit('pass');
}
else {
const test = {
title: result.description,
};
const error = {
browser: browser.name,
suite: result.suite,
test: result.description,
log: result.log
}
runner.emit('fail', test, error);
}
}
}
module.exports = {
'reporter:karma': ['type', KarmaReporter]
};

@ -5,6 +5,7 @@
}, },
"dependencies": { "dependencies": {
"@ethersproject/testcases": ">=5.0.0-beta.131", "@ethersproject/testcases": ">=5.0.0-beta.131",
"@ethersproject/cli": ">=5.0.0-beta.145",
"@types/mocha": "^5.2.0", "@types/mocha": "^5.2.0",
"ethers": ">=5.0.0-beta.156", "ethers": ">=5.0.0-beta.156",
"mocha-phantomjs-core": "2.1.2" "mocha-phantomjs-core": "2.1.2"

@ -51,7 +51,7 @@ export function Reporter(runner: Runner) {
runner.on('suite', function(suite: Suite) { runner.on('suite', function(suite: Suite) {
if (!suite.title) { if (!suite.title) {
log('Testing: Found ' + suite.suites.length + ' test suites'); log('Testing: ' + (suite.suites ? 'Found ' + suite.suites.length + ' test suites' : ''));
} else { } else {
let filename = (suite.file || '').split('/').pop(); let filename = (suite.file || '').split('/').pop();
if (filename) { filename = ' (' + filename + ')'; } if (filename) { filename = ' (' + filename + ')'; }

@ -0,0 +1,22 @@
'use strict';
import assert from "assert";
import { resolve } from "path";
import fs from "fs";
import { solc } from "@ethersproject/cli";
describe('Test solc', function () {
it('compiles contracts with imported library', function () {
this.timeout(1200000);
const filename = resolve(__dirname, '../contracts/test-solc/consumer.sol');
const source = fs.readFileSync(filename).toString();
const code = solc.compile(source, { filename, optimize: true })
.filter(((contract: any) => contract.name === 'Consumer'))[0];
const { bytecode, interface: iface } = code;
assert(bytecode.length > 2, 'The bytecode should should have a length');
assert(bytecode.startsWith('0x'), 'The bytecode should start with 0x');
assert(iface.functions['f()'], 'The interface should have function f()');
});
});