Compare commits
34 Commits
v5.0.0-bet
...
v5.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f308ba3540 | ||
|
|
2f0e679f0b | ||
|
|
abab9f6aa2 | ||
|
|
c11c2e2e33 | ||
|
|
3d75c52dac | ||
|
|
29f0e9dd62 | ||
|
|
79ef1e975d | ||
|
|
3ab373334c | ||
|
|
b72ef27b2a | ||
|
|
e518151509 | ||
|
|
19aaade9c6 | ||
|
|
c35ddaf646 | ||
|
|
8316406977 | ||
|
|
01ca35036c | ||
|
|
da8ca2e8bc | ||
|
|
1ec5804bd4 | ||
|
|
75895fa149 | ||
|
|
51e4ef2b45 | ||
|
|
e1509a6326 | ||
|
|
394c36cad4 | ||
|
|
1d4f90a958 | ||
|
|
494381a628 | ||
|
|
d9d438a119 | ||
|
|
3d514c8dbb | ||
|
|
28339a9c85 | ||
|
|
fea867a206 | ||
|
|
5b0c15930f | ||
|
|
12cfc59965 | ||
|
|
3c864de612 | ||
|
|
778eb3b425 | ||
|
|
3d25882d6b | ||
|
|
a12030ad29 | ||
|
|
828c8cfd41 | ||
|
|
238fcba83b |
45
CHANGELOG.md
45
CHANGELOG.md
@@ -3,6 +3,51 @@ Changelog
|
||||
|
||||
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.0.0-beta.160 (2019-11-20 18:36)
|
||||
-----------------------------------------
|
||||
|
||||
- Updated API in testcases. ([3ab3733](https://github.com/ethers-io/ethers.js/commit/3ab373334c75800f2b20b6639ed8eb1b11e453ef))
|
||||
- Fixed scrypt import in ESM build. ([b72ef27](https://github.com/ethers-io/ethers.js/commit/b72ef27b2a8f9941fb9d79122ec449fed9d2464d))
|
||||
- Fixed null apiKey problem for InfuraProvider. ([e518151](https://github.com/ethers-io/ethers.js/commit/e51815150912d10e2734707986b10b37c87d6d12))
|
||||
- Added support for sighash-style tuple parsing. ([19aaade](https://github.com/ethers-io/ethers.js/commit/19aaade9c62510012cfd50ae487ebd1705a28678))
|
||||
- Fixed solc imports for cli. ([c35ddaf](https://github.com/ethers-io/ethers.js/commit/c35ddaf646efa25e738fee604585a0a7af45b206))
|
||||
- Added nonce manager to experimental index. ([8316406](https://github.com/ethers-io/ethers.js/commit/8316406977ea26ca2044d16f7b3bb6ba21ef5b43))
|
||||
- Removing NodesmithProvider from default provider as it is being discontinued. ([01ca350](https://github.com/ethers-io/ethers.js/commit/01ca35036ca11a47f60890e5cae62e46a00f3da8))
|
||||
- Moved bare ABI named functions and events from Interface into Contracts to simplify other consumers of Interface. ([da8ca2e](https://github.com/ethers-io/ethers.js/commit/da8ca2e8bc982fc3ea0343bb3c593a485ca1fef0))
|
||||
- Added support for complex API keys including support for INFURA project secrets. ([#464](https://github.com/ethers-io/ethers.js/issues/464), [#651](https://github.com/ethers-io/ethers.js/issues/651), [#652](https://github.com/ethers-io/ethers.js/issues/652); [1ec5804](https://github.com/ethers-io/ethers.js/commit/1ec5804bd460f6948d4813469fdc7bf739baa6a6))
|
||||
- Migrated to scrypt-js v3. ([75895fa](https://github.com/ethers-io/ethers.js/commit/75895fa1491e7542c755a102f4e4c190685fd2b6))
|
||||
- Moved getDefaultProvider to providers package. ([51e4ef2](https://github.com/ethers-io/ethers.js/commit/51e4ef2b45b83a8d82923600a2fac544d70b0807))
|
||||
- Migrating providers to modern syntax and scoping. ([#634](https://github.com/ethers-io/ethers.js/issues/634); [e1509a6](https://github.com/ethers-io/ethers.js/commit/e1509a6326dd2cb8bf7ed64b82dd3947b768a314))
|
||||
- Migrating to modern syntax and scoping. ([#634](https://github.com/ethers-io/ethers.js/issues/634); [394c36c](https://github.com/ethers-io/ethers.js/commit/394c36cad43f229a94c72d21f94d1c7982a887a1))
|
||||
- Added provider property to Web3Provider. ([#641](https://github.com/ethers-io/ethers.js/issues/641); [1d4f90a](https://github.com/ethers-io/ethers.js/commit/1d4f90a958da6364117353850d62535c9702abd2))
|
||||
- Updated GitHub issue cache. ([494381a](https://github.com/ethers-io/ethers.js/commit/494381a6284cc8ed90bd8002d42a6b6d94dc1200))
|
||||
- Force deploy receipt to address to be null. ([#573](https://github.com/ethers-io/ethers.js/issues/573); [d9d438a](https://github.com/ethers-io/ethers.js/commit/d9d438a119bb11f8516fc9cf02c534ab3816fcb3))
|
||||
- Updated experimental NonceManager. ([3d514c8](https://github.com/ethers-io/ethers.js/commit/3d514c8dbb94e1c4ce5754463e683dd9dbe7c0aa))
|
||||
- Fixed typo in error message. ([28339a9](https://github.com/ethers-io/ethers.js/commit/28339a9c8585392086da159a46df4afb8958915c))
|
||||
- Added GitHub issue caching. ([fea867a](https://github.com/ethers-io/ethers.js/commit/fea867a206f007a17718396e486883a5e718aa29))
|
||||
|
||||
ethers/v5.0.0-beta.159 (2019-10-17 01:08)
|
||||
-----------------------------------------
|
||||
|
||||
- Removing TypeScript build files from npm to fix excessive package diffs.
|
||||
- Fixed getBlock for blockhashes with a leading 0. ([#629](https://github.com/ethers-io/ethers.js/issues/629); [12cfc59](https://github.com/ethers-io/ethers.js/commit/12cfc599656d7e3a6d3d9aa4e468592865a711cc))
|
||||
|
||||
ethers/v5.0.0-beta.158 (2019-09-28 01:56)
|
||||
-----------------------------------------
|
||||
|
||||
- Added less-common, but useful, coding functions to Interface. ([778eb3b](https://github.com/ethers-io/ethers.js/commit/778eb3b425b5ab5b23d28e75be92feccd0fc56bc))
|
||||
- Add response handling and 304 support to fetchJson. ([3d25882](https://github.com/ethers-io/ethers.js/commit/3d25882d6bf689740506b9c569f6e0d30da6f6a5))
|
||||
- Allow numeric values in a transaction to be odd-lengthed hexstrings. ([#614](https://github.com/ethers-io/ethers.js/issues/614); [a12030a](https://github.com/ethers-io/ethers.js/commit/a12030ad29aa13c02aa75d9e0860f4986a0043b4))
|
||||
- Simpler crypt for admin tools. ([828c8cf](https://github.com/ethers-io/ethers.js/commit/828c8cfd419ac4f8d11d978c2e2ff83eba5ae909))
|
||||
|
||||
ethers/v5.0.0-beta.157 (2019-09-08 02:43)
|
||||
-----------------------------------------
|
||||
|
||||
- Fixed getContractAddress for odd-length hex values. ([#572](https://github.com/ethers-io/ethers.js/issues/572); [751793e](https://github.com/ethers-io/ethers.js/commit/751793ea25183d54d7fc4c610a789608f91c062e))
|
||||
- Fixed typo in error message. ([#592](https://github.com/ethers-io/ethers.js/issues/592); [6f4291f](https://github.com/ethers-io/ethers.js/commit/6f4291f65f0ea20c65fef7fd7b09b4d5bf5f0dcd))
|
||||
- Fixed typo in error message. ([#580](https://github.com/ethers-io/ethers.js/issues/580); [9c63b4a](https://github.com/ethers-io/ethers.js/commit/9c63b4a7535f423a802bb1c17c325ce968987349))
|
||||
- Fixed typo in error message. ([#574](https://github.com/ethers-io/ethers.js/issues/574); [22a2673](https://github.com/ethers-io/ethers.js/commit/22a26736cc332fe6e896c9d2707cc99ceee2fb10))
|
||||
|
||||
ethers/v5.0.0-beta.156 (2019-09-06 17:56)
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -69,15 +69,17 @@ function setupConfig(outDir, moduleType, targetType) {
|
||||
|
||||
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]);
|
||||
[ "browser", "_browser" ].forEach((key) => {
|
||||
if (info[key]) {
|
||||
if (typeof(info[key]) === "string") {
|
||||
info[key] = update(info[key]);
|
||||
} else {
|
||||
for (let k in info[key]) {
|
||||
info[key][k] = update(info[key][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
savePackage(dirname, info);
|
||||
|
||||
let path = resolve(__dirname, "../packages", dirname, "tsconfig.json");
|
||||
|
||||
10
admin/cmds/cache-github.js
Normal file
10
admin/cmds/cache-github.js
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const config = require("../config");
|
||||
const { syncIssues } = require("../github");
|
||||
|
||||
(async function() {
|
||||
const user = await config.get("github-user");
|
||||
const password = await config.get("github-readonly");
|
||||
await syncIssues(user, password);
|
||||
})();
|
||||
142
admin/cmds/grep-github.js
Normal file
142
admin/cmds/grep-github.js
Normal file
@@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
|
||||
const { colorify } = require("../log");
|
||||
const { getIssues } = require("../github");
|
||||
const { repeat } = require("../utils");
|
||||
|
||||
const Options = {
|
||||
"body": 1,
|
||||
"end": 1,
|
||||
"issue": 1,
|
||||
"start": 1,
|
||||
"title": 1,
|
||||
"user": 1,
|
||||
};
|
||||
|
||||
const Flags = {
|
||||
"open": 1,
|
||||
"match-case": 1,
|
||||
};
|
||||
|
||||
(async function() {
|
||||
const options = { };
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
const option = process.argv[i];
|
||||
if (option.substring(0, 2) === "--") {
|
||||
const comps = option.substring(2).split(/=/);
|
||||
if (Flags[comps[0]]) {
|
||||
if (comps[1] != null) { throw new Error("Invalid flag: " + option); }
|
||||
options[comps[0]] = true;
|
||||
} else if (Options[comps[0]]) {
|
||||
if (comps[1] == null) {
|
||||
options[comps[0]] = process.argv[++i];
|
||||
if (options[comps[0]] == null) {
|
||||
throw new Error("Missing option value: " + option);
|
||||
}
|
||||
} else {
|
||||
options[comps[0]] = comps[1];
|
||||
}
|
||||
} else {
|
||||
throw new Error("Unexpected option: " + option);
|
||||
}
|
||||
} else {
|
||||
throw new Error("Unexpected argument: " + option);
|
||||
}
|
||||
}
|
||||
|
||||
if (options["title"]) { options.title = new RegExp(options.title, (options["match-case"] ? "": "i")); }
|
||||
if (options["body"]) { options.body = new RegExp(options.title, (options["match-case"] ? "": "i")); }
|
||||
if (options["start"]) {
|
||||
if (options["start"].match(/^[0-9]{4}-[0-9]{2}-[0-9{2}]$/)) {
|
||||
throw new Error("Expected YYYY-MM-DD");
|
||||
}
|
||||
}
|
||||
if (options["end"]) {
|
||||
if (options["end"].match(/^[0-9]{4}-[0-9]{2}-[0-9{2}]$/)) {
|
||||
throw new Error("Expected YYYY-MM-DD");
|
||||
}
|
||||
}
|
||||
|
||||
const count = { issues: 0, comments: 0, code: 0, responses: 0 };
|
||||
|
||||
const issues = await getIssues();
|
||||
issues.forEach((issue) => {
|
||||
const info = issue.issue;
|
||||
const comments = issue.comments;
|
||||
|
||||
if (options.issue && parseInt(options.issue) != info.number) { return; }
|
||||
if (options.open && info.state !== "open") { return; }
|
||||
if (options.title && !info.title.match(options.title)) { return; }
|
||||
if (options.body) {
|
||||
const body = info.body + "\n" + comments.map((c) => (c.body)).join("\n");
|
||||
if (!body.match(options.body)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (options.user) {
|
||||
const users = comments.map((c) => (c.user.login));
|
||||
users.push(info.user.login);
|
||||
if (users.indexOf(options.user) === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const dates = comments.map((c) => (c.created_at.split("T")[0]));
|
||||
dates.push(info.created_at.split("T")[0]);
|
||||
|
||||
if (options.start) {
|
||||
if (dates.filter((d) => (d >= options.start)).length === 0) { return; }
|
||||
}
|
||||
if (options.end) {
|
||||
if (dates.filter((d) => (d <= options.start)).length === 0) { return; }
|
||||
}
|
||||
|
||||
count.issues++;
|
||||
|
||||
console.log(colorify(repeat("=", 70), "bold"))
|
||||
console.log(colorify("Issue:", "bold"), info.title, ` (#${ info.number })`);
|
||||
console.log(colorify("User:","bold"), colorify(info.user.login, "blue"));
|
||||
console.log(colorify("State:", "bold"), info.state);
|
||||
if (info.created_at === info.updated_at) {
|
||||
console.log(colorify("Created:", "bold"), info.created_at);
|
||||
} else {
|
||||
console.log(colorify("Created:", "bold"), info.created_at, ` (updated: ${ info.updated_at })`);
|
||||
}
|
||||
info.body.trim().split("\n").forEach((line) => {
|
||||
console.log(" " + line);
|
||||
});
|
||||
|
||||
if (comments.length) {
|
||||
comments.forEach((info) => {
|
||||
if (options.start && info.created_at < options.start) { return ; }
|
||||
if (options.end && info.created_at > options.end) { return; }
|
||||
count.comments++;
|
||||
if (options.user && info.user.login !== options.user) { return; }
|
||||
count.responses++;
|
||||
if (info.body.indexOf("`") >= 0) { count.code++; }
|
||||
console.log(colorify(repeat("-", 70), "bold"));
|
||||
console.log(colorify("User:", "bold"), colorify(info.user.login, "green"));
|
||||
if (info.created_at === info.updated_at) {
|
||||
console.log(colorify("Created:", "bold"), info.created_at);
|
||||
} else {
|
||||
console.log(colorify("Created:", "bold"), info.created_at, ` (updated: ${ info.updated_at })`);
|
||||
}
|
||||
info.body.trim().split("\n").forEach((line) => {
|
||||
console.log(" " + line);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.log(colorify(repeat("=", 70), "bold"))
|
||||
|
||||
// @TODO: Add stats on new/closed issues
|
||||
//if (options.user) {
|
||||
// console.log(`${ count.responses } responses (${ count.code } w/ code) on ${ count.comments } comments across ${ count.issues } issues.`);
|
||||
//} else {
|
||||
console.log(`${ count.comments } comment${ (count.comments !== 1) ? "s": "" } across ${ count.issues } issue${ (count.issues !== 1) ? "s": ""}.`);
|
||||
//}
|
||||
|
||||
})().catch((error) => {
|
||||
console.log("Error: " + error.message);
|
||||
});
|
||||
@@ -36,7 +36,7 @@ if (process.argv.length > 2) {
|
||||
|
||||
// Load the token from the encrypted store
|
||||
try {
|
||||
token = await config.get("token");
|
||||
token = await config.get("npm-token");
|
||||
} catch (error) {
|
||||
switch (error.message) {
|
||||
case "wrong password":
|
||||
|
||||
16
admin/cmds/set-config.js
Normal file
16
admin/cmds/set-config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const { prompt } = require("../../packages/cli");
|
||||
const config = require("../config");
|
||||
|
||||
if (process.argv.length !== 3) {
|
||||
console.log("Usage: set-config KEY");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const key = process.argv[2];
|
||||
|
||||
(async function() {
|
||||
const value = await prompt.getPassword("Value: ");
|
||||
await config.set(key, value);
|
||||
})();
|
||||
44
admin/cmds/set-option.js
Executable file
44
admin/cmds/set-option.js
Executable file
@@ -0,0 +1,44 @@
|
||||
const { setupBuild } = require("../build");
|
||||
const { loadPackage, savePackage } = require("../local");
|
||||
|
||||
const arg = process.argv[2];
|
||||
|
||||
(async function() {
|
||||
switch(arg) {
|
||||
case "esm":
|
||||
setupBuild(true);
|
||||
break;
|
||||
|
||||
case "cjs":
|
||||
setupBuild(false);
|
||||
break;
|
||||
|
||||
case "browser-lang-en": {
|
||||
const info = loadPackage("wordlists");
|
||||
if (info._browser) {
|
||||
info.browser = info._browser;
|
||||
delete info._browser;
|
||||
savePackage("wordlists", info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "browser-lang-all": {
|
||||
const info = loadPackage("wordlists");
|
||||
if (info.browser) {
|
||||
info._browser = info.browser;
|
||||
delete info.browser;
|
||||
savePackage("wordlists", info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
console.log("unknown option");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
})().then((result) => {
|
||||
process.exit(result);
|
||||
});
|
||||
@@ -8,8 +8,14 @@ const targets = sourceEthers.match(/export\s*{\s*((.|\s)*)}/)[1].trim();
|
||||
|
||||
const output = `"use strict";
|
||||
|
||||
// To modify this file, you must update ./admin/cmds/update-exports.js
|
||||
|
||||
import * as ethers from "./ethers";
|
||||
|
||||
if ((<any>global)._ethers == null) {
|
||||
(<any>global)._ethers = ethers;
|
||||
}
|
||||
|
||||
export { ethers };
|
||||
|
||||
export {
|
||||
|
||||
121
admin/config.js
121
admin/config.js
@@ -13,75 +13,96 @@ const computeHmac = require("../packages/sha2").computeHmac;
|
||||
|
||||
const colorify = require("./log").colorify;
|
||||
|
||||
function getConfigFilename() {
|
||||
return resolve(os.homedir(), ".ethers-dist");
|
||||
}
|
||||
|
||||
function getScrypt(message, password, salt) {
|
||||
let progressBar = prompt.getProgressBar(message);
|
||||
return new Promise((resolve, reject) => {
|
||||
scrypt(Buffer.from(password), Buffer.from(salt), (1 << 17), 8, 1, 64, (error, progress, key) => {
|
||||
if (error) { return reject(error); }
|
||||
progressBar(progress);
|
||||
if (key) { resolve(key); }
|
||||
});
|
||||
});
|
||||
return scrypt.scrypt(Buffer.from(password), Buffer.from(salt), (1 << 17), 8, 1, 64, progressBar);
|
||||
}
|
||||
|
||||
async function loadConfig(dkey) {
|
||||
let config = { };
|
||||
function Config(filename) {
|
||||
this.salt = null;
|
||||
this.dkey = null;
|
||||
this.values = { };
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
let filename = getConfigFilename();
|
||||
if (fs.existsSync(filename)) {
|
||||
let data = JSON.parse(fs.readFileSync(filename));
|
||||
let ciphertext = Buffer.from(data.ciphertext, "base64");
|
||||
let iv = Buffer.from(data.iv, "base64");
|
||||
let aes = new AES.ModeOfOperation.ctr(dkey.slice(0, 32), new AES.Counter(iv));
|
||||
let plaintext = aes.decrypt(ciphertext);
|
||||
let hmac = computeHmac("sha512", dkey.slice(32, 64), plaintext);
|
||||
Config.prototype.load = async function() {
|
||||
if (this.dkey) { return; }
|
||||
|
||||
let data = null;
|
||||
if (fs.existsSync(this.filename)) {
|
||||
data = JSON.parse(fs.readFileSync(this.filename));
|
||||
} else {
|
||||
data = {
|
||||
salt: Buffer.from(randomBytes(32)).toString("hex")
|
||||
};
|
||||
}
|
||||
|
||||
this.salt = data.salt;
|
||||
|
||||
const password = await prompt.getPassword(colorify("Password (config-store): ", "bold"));
|
||||
|
||||
this.dkey = await getScrypt(colorify("Unlocking config", "bold"), password, this.salt);
|
||||
|
||||
if (data.ciphertext) {
|
||||
const ciphertext = Buffer.from(data.ciphertext, "base64");
|
||||
const iv = Buffer.from(data.iv, "base64");
|
||||
const aes = new AES.ModeOfOperation.ctr(this.dkey.slice(0, 32), new AES.Counter(iv));
|
||||
const plaintext = aes.decrypt(ciphertext);
|
||||
const hmac = computeHmac("sha512", this.dkey.slice(32, 64), plaintext);
|
||||
if (hmac !== data.hmac) {
|
||||
throw new Error("wrong password");
|
||||
}
|
||||
config = JSON.parse(Buffer.from(plaintext).toString());
|
||||
|
||||
this.values = JSON.parse(Buffer.from(plaintext).toString());
|
||||
}
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
Config.prototype.save = function() {
|
||||
this.values._junk = Buffer.from(randomBytes(16 + parseInt(Math.random() * 48))).toString("base64")
|
||||
|
||||
async function getConfig(key) {
|
||||
let password = await prompt.getPassword(colorify("Password (seesion-store): ", "bold"));
|
||||
let dkey = await getScrypt(colorify("Decrypting", "bold"), password, key);
|
||||
const plaintext = Buffer.from(JSON.stringify(this.values));
|
||||
|
||||
let config = await loadConfig(dkey);
|
||||
return config[key];
|
||||
}
|
||||
const iv = Buffer.from(randomBytes(16));
|
||||
const hmac = computeHmac("sha512", this.dkey.slice(32, 64), plaintext);
|
||||
|
||||
async function setConfig(key, value) {
|
||||
let password = await prompt.getPassword(colorify("Password (seesion-store): ", "bold"));
|
||||
let dkey = await getScrypt("Encrypting", password, key);
|
||||
const aes = new AES.ModeOfOperation.ctr(this.dkey.slice(0, 32), new AES.Counter(iv));
|
||||
const ciphertext = Buffer.from(aes.encrypt(plaintext));
|
||||
|
||||
let config = await loadConfig(dkey);
|
||||
config[key] = value;
|
||||
config._junk = Buffer.from(randomBytes(16 + parseInt(Math.random() * 48))).toString("base64")
|
||||
|
||||
let plaintext = Buffer.from(JSON.stringify(config));
|
||||
|
||||
let iv = Buffer.from(randomBytes(16));
|
||||
let hmac = computeHmac("sha512", dkey.slice(32, 64), plaintext);
|
||||
|
||||
let aes = new AES.ModeOfOperation.ctr(dkey.slice(0, 32), new AES.Counter(iv));
|
||||
let ciphertext = Buffer.from(aes.encrypt(plaintext));
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
ciphertext: ciphertext.toString("base64"),
|
||||
iv: iv.toString("base64"),
|
||||
salt: this.salt,
|
||||
hmac: hmac
|
||||
};
|
||||
|
||||
fs.writeFileSync(getConfigFilename(), JSON.stringify(data, null, 2));
|
||||
fs.writeFileSync(this.filename, JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get: getConfig,
|
||||
set: setConfig
|
||||
Config.prototype.get = async function(key) {
|
||||
await this.load();
|
||||
return this.values[key];
|
||||
};
|
||||
|
||||
Config.prototype.set = async function(key, value) {
|
||||
await this.load();
|
||||
this.values[key] = value;
|
||||
this.save();
|
||||
};
|
||||
|
||||
Config.prototype.lock = function() {
|
||||
this.salt = this.dkey = null;
|
||||
}
|
||||
|
||||
const config = new Config(resolve(os.homedir(), ".ethers-dist"));
|
||||
|
||||
module.exports = {
|
||||
get: function(key) {
|
||||
return config.get(key);
|
||||
},
|
||||
set: function(key, value) {
|
||||
config.set(key, value);
|
||||
},
|
||||
lock: function() {
|
||||
config.lock();
|
||||
}
|
||||
}
|
||||
|
||||
134
admin/github.js
Normal file
134
admin/github.js
Normal file
@@ -0,0 +1,134 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const { resolve } = require("path");
|
||||
const zlib = require("zlib");
|
||||
|
||||
const { id } = require("../packages/hash");
|
||||
const { fetchJson } = require("../packages/web");
|
||||
|
||||
const CacheDir = resolve(__dirname, "../github-cache/");
|
||||
|
||||
function addResponse(result, response) {
|
||||
return { result, response };
|
||||
}
|
||||
|
||||
function loadFile(filename) {
|
||||
return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString());
|
||||
//return JSON.parse(fs.readFileSync(filename).toString());
|
||||
}
|
||||
|
||||
// @TODO: atomic
|
||||
function saveFile(filename, content) {
|
||||
fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(content)));
|
||||
//fs.writeFileSync(filename, JSON.stringify(content));
|
||||
}
|
||||
|
||||
function mockFetchJson(url, body, headers) {
|
||||
return {
|
||||
result: null,
|
||||
response: {
|
||||
statusCode: 304
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function _fetchGitHub(user, password, fetchJson, url) {
|
||||
const result = [ ];
|
||||
while (true) {
|
||||
|
||||
const filename = resolve(CacheDir, id(url).substring(2, 14));
|
||||
|
||||
const headers = {
|
||||
"User-Agent": "ethers-io",
|
||||
};
|
||||
|
||||
let items = null;
|
||||
let link = null;
|
||||
try {
|
||||
const data = loadFile(filename);
|
||||
headers["if-none-match"] = data.etag;
|
||||
items = data.items;
|
||||
link = data.link;
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") { throw error; }
|
||||
}
|
||||
|
||||
const fetch = await fetchJson({
|
||||
url: url,
|
||||
user: user,
|
||||
password: password,
|
||||
headers: headers
|
||||
}, null, addResponse);
|
||||
|
||||
// Cached response is good; use it!
|
||||
if (fetch.response.statusCode !== 304) {
|
||||
items = fetch.result;
|
||||
if (fetch.response.headers) {
|
||||
link = (fetch.response.headers.link || null);
|
||||
}
|
||||
if (fetch.response.headers.etag){
|
||||
saveFile(filename, {
|
||||
timestamp: (new Date()).getTime(),
|
||||
url: url,
|
||||
link: link,
|
||||
etag: fetch.response.headers.etag,
|
||||
items: items,
|
||||
version: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
items.forEach((item) => { result.push(item)});
|
||||
|
||||
url = null;
|
||||
(link || "").split(",").forEach((item) => {
|
||||
if (item.indexOf('rel="next"') >= 0) {
|
||||
const match = item.match(/<([^>]*)>/);
|
||||
if (match) { url = match[1]; }
|
||||
}
|
||||
});
|
||||
|
||||
if (!url) { break; }
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function fetchGitHub(user, password, url, cacheOnly) {
|
||||
if (cacheOnly) {
|
||||
return await _fetchGitHub("none", "none", mockFetchJson, url);
|
||||
}
|
||||
|
||||
const results = await _fetchGitHub(user, password, fetchJson, url);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
async function _getIssues(user, password) {
|
||||
const cacheOnly = (user == null);
|
||||
|
||||
let issues = await fetchGitHub(user, password, "https://api.github.com/repos/ethers-io/ethers.js/issues?state=all&per_page=100", cacheOnly)
|
||||
if (!cacheOnly) { console.log(`Found ${ issues.length } issues`); }
|
||||
const result = [ ];
|
||||
for (let i = 0; i < issues.length; i++) {
|
||||
const issue = issues[i];
|
||||
let comments = await fetchGitHub(user, password, issue.comments_url, cacheOnly);
|
||||
result.push({ issue, comments});
|
||||
if (!cacheOnly) { console.log(` Issue ${ issue.number }: ${ comments.length } comments`); }
|
||||
}
|
||||
result.sort((a, b) => (a.issue.number - b.issue.number));
|
||||
return result;
|
||||
}
|
||||
|
||||
function getIssues() {
|
||||
return _getIssues();
|
||||
}
|
||||
|
||||
function syncIssues(user, password) {
|
||||
return _getIssues(user, password);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getIssues,
|
||||
syncIssues,
|
||||
}
|
||||
@@ -15,8 +15,20 @@ const keccak256 = (function() {
|
||||
const { dirnames, loadPackage, ROOT } = require("./depgraph");
|
||||
const { resolve, saveJson } = require("./utils");
|
||||
|
||||
function sorted(obj) {
|
||||
if (Array.isArray(obj)) { return obj.map(sorted); }
|
||||
if (obj == null || typeof(obj) !== "object") { return obj; }
|
||||
|
||||
const keys = Object.keys(obj);
|
||||
keys.sort();
|
||||
|
||||
const result = { };
|
||||
keys.forEach((key) => { result[key] = sorted(obj[key]); });
|
||||
return result;
|
||||
}
|
||||
|
||||
function savePackage(dirname, info) {
|
||||
return saveJson(resolve(ROOT, dirname, "package.json"), info);
|
||||
return saveJson(resolve(ROOT, dirname, "package.json"), sorted(info));
|
||||
}
|
||||
|
||||
async function createTarball(dirname) {
|
||||
|
||||
BIN
github-cache/0021245234e1
Normal file
BIN
github-cache/0021245234e1
Normal file
Binary file not shown.
BIN
github-cache/00b424c41eb4
Normal file
BIN
github-cache/00b424c41eb4
Normal file
Binary file not shown.
BIN
github-cache/0187d6d5fa5a
Normal file
BIN
github-cache/0187d6d5fa5a
Normal file
Binary file not shown.
BIN
github-cache/01b9c61ed32d
Normal file
BIN
github-cache/01b9c61ed32d
Normal file
Binary file not shown.
BIN
github-cache/01fc95de636a
Normal file
BIN
github-cache/01fc95de636a
Normal file
Binary file not shown.
BIN
github-cache/020b2817f386
Normal file
BIN
github-cache/020b2817f386
Normal file
Binary file not shown.
BIN
github-cache/025023c5f720
Normal file
BIN
github-cache/025023c5f720
Normal file
Binary file not shown.
BIN
github-cache/025f73edd66b
Normal file
BIN
github-cache/025f73edd66b
Normal file
Binary file not shown.
BIN
github-cache/02cad84efaa5
Normal file
BIN
github-cache/02cad84efaa5
Normal file
Binary file not shown.
BIN
github-cache/02e68d9902c5
Normal file
BIN
github-cache/02e68d9902c5
Normal file
Binary file not shown.
BIN
github-cache/030b26dabc1c
Normal file
BIN
github-cache/030b26dabc1c
Normal file
Binary file not shown.
BIN
github-cache/0347eac16a9e
Normal file
BIN
github-cache/0347eac16a9e
Normal file
Binary file not shown.
BIN
github-cache/03904c300f1d
Normal file
BIN
github-cache/03904c300f1d
Normal file
Binary file not shown.
BIN
github-cache/0487a716ddcb
Normal file
BIN
github-cache/0487a716ddcb
Normal file
Binary file not shown.
BIN
github-cache/049e20fa6d90
Normal file
BIN
github-cache/049e20fa6d90
Normal file
Binary file not shown.
BIN
github-cache/05949c9a864a
Normal file
BIN
github-cache/05949c9a864a
Normal file
Binary file not shown.
BIN
github-cache/05e27216a6d3
Normal file
BIN
github-cache/05e27216a6d3
Normal file
Binary file not shown.
BIN
github-cache/05e49cf709b1
Normal file
BIN
github-cache/05e49cf709b1
Normal file
Binary file not shown.
BIN
github-cache/0632d7b3a88d
Normal file
BIN
github-cache/0632d7b3a88d
Normal file
Binary file not shown.
BIN
github-cache/06951e334666
Normal file
BIN
github-cache/06951e334666
Normal file
Binary file not shown.
BIN
github-cache/06b567286f9a
Normal file
BIN
github-cache/06b567286f9a
Normal file
Binary file not shown.
BIN
github-cache/06f65f522822
Normal file
BIN
github-cache/06f65f522822
Normal file
Binary file not shown.
BIN
github-cache/07f317c59e81
Normal file
BIN
github-cache/07f317c59e81
Normal file
Binary file not shown.
BIN
github-cache/07fa40c22821
Normal file
BIN
github-cache/07fa40c22821
Normal file
Binary file not shown.
BIN
github-cache/080588b1c830
Normal file
BIN
github-cache/080588b1c830
Normal file
Binary file not shown.
BIN
github-cache/082ca0a35555
Normal file
BIN
github-cache/082ca0a35555
Normal file
Binary file not shown.
BIN
github-cache/0876f22405d4
Normal file
BIN
github-cache/0876f22405d4
Normal file
Binary file not shown.
BIN
github-cache/09b2ad5631e5
Normal file
BIN
github-cache/09b2ad5631e5
Normal file
Binary file not shown.
BIN
github-cache/0a13ed0eb79b
Normal file
BIN
github-cache/0a13ed0eb79b
Normal file
Binary file not shown.
BIN
github-cache/0a2aea48f219
Normal file
BIN
github-cache/0a2aea48f219
Normal file
Binary file not shown.
BIN
github-cache/0a83d5ad54fc
Normal file
BIN
github-cache/0a83d5ad54fc
Normal file
Binary file not shown.
BIN
github-cache/0aa644d9792f
Normal file
BIN
github-cache/0aa644d9792f
Normal file
Binary file not shown.
BIN
github-cache/0ac28a370896
Normal file
BIN
github-cache/0ac28a370896
Normal file
Binary file not shown.
BIN
github-cache/0b89f4fa0714
Normal file
BIN
github-cache/0b89f4fa0714
Normal file
Binary file not shown.
BIN
github-cache/0c483ebe1d6b
Normal file
BIN
github-cache/0c483ebe1d6b
Normal file
Binary file not shown.
BIN
github-cache/0e4b18422ecd
Normal file
BIN
github-cache/0e4b18422ecd
Normal file
Binary file not shown.
BIN
github-cache/0f1424a34b60
Normal file
BIN
github-cache/0f1424a34b60
Normal file
Binary file not shown.
BIN
github-cache/0f858aa8afa6
Normal file
BIN
github-cache/0f858aa8afa6
Normal file
Binary file not shown.
BIN
github-cache/0f973d35737c
Normal file
BIN
github-cache/0f973d35737c
Normal file
Binary file not shown.
BIN
github-cache/0fbc7d5474d6
Normal file
BIN
github-cache/0fbc7d5474d6
Normal file
Binary file not shown.
BIN
github-cache/119007dca37b
Normal file
BIN
github-cache/119007dca37b
Normal file
Binary file not shown.
BIN
github-cache/12456630ab47
Normal file
BIN
github-cache/12456630ab47
Normal file
Binary file not shown.
BIN
github-cache/124e66c7944c
Normal file
BIN
github-cache/124e66c7944c
Normal file
Binary file not shown.
BIN
github-cache/1278908a05f7
Normal file
BIN
github-cache/1278908a05f7
Normal file
Binary file not shown.
BIN
github-cache/12a9abfcdb9a
Normal file
BIN
github-cache/12a9abfcdb9a
Normal file
Binary file not shown.
BIN
github-cache/135ad2423b99
Normal file
BIN
github-cache/135ad2423b99
Normal file
Binary file not shown.
BIN
github-cache/136bf94f1461
Normal file
BIN
github-cache/136bf94f1461
Normal file
Binary file not shown.
BIN
github-cache/13d47f6aaaba
Normal file
BIN
github-cache/13d47f6aaaba
Normal file
Binary file not shown.
BIN
github-cache/14129ba72bcb
Normal file
BIN
github-cache/14129ba72bcb
Normal file
Binary file not shown.
BIN
github-cache/14ab7a534202
Normal file
BIN
github-cache/14ab7a534202
Normal file
Binary file not shown.
BIN
github-cache/15157e6fd83d
Normal file
BIN
github-cache/15157e6fd83d
Normal file
Binary file not shown.
BIN
github-cache/1571c1bb5230
Normal file
BIN
github-cache/1571c1bb5230
Normal file
Binary file not shown.
BIN
github-cache/157bd237a5ae
Normal file
BIN
github-cache/157bd237a5ae
Normal file
Binary file not shown.
BIN
github-cache/15b077194937
Normal file
BIN
github-cache/15b077194937
Normal file
Binary file not shown.
BIN
github-cache/16859ac8de8a
Normal file
BIN
github-cache/16859ac8de8a
Normal file
Binary file not shown.
BIN
github-cache/16e9d885479d
Normal file
BIN
github-cache/16e9d885479d
Normal file
Binary file not shown.
BIN
github-cache/17585707a650
Normal file
BIN
github-cache/17585707a650
Normal file
Binary file not shown.
BIN
github-cache/1762c9fc5767
Normal file
BIN
github-cache/1762c9fc5767
Normal file
Binary file not shown.
BIN
github-cache/188b1fcaaf70
Normal file
BIN
github-cache/188b1fcaaf70
Normal file
Binary file not shown.
BIN
github-cache/195b35167e9c
Normal file
BIN
github-cache/195b35167e9c
Normal file
Binary file not shown.
BIN
github-cache/197016a56cd6
Normal file
BIN
github-cache/197016a56cd6
Normal file
Binary file not shown.
BIN
github-cache/19b1177c1ca7
Normal file
BIN
github-cache/19b1177c1ca7
Normal file
Binary file not shown.
BIN
github-cache/19b5acffe158
Normal file
BIN
github-cache/19b5acffe158
Normal file
Binary file not shown.
BIN
github-cache/19c0f292e1f7
Normal file
BIN
github-cache/19c0f292e1f7
Normal file
Binary file not shown.
BIN
github-cache/1a6b400340e1
Normal file
BIN
github-cache/1a6b400340e1
Normal file
Binary file not shown.
BIN
github-cache/1aeed0f4cc1c
Normal file
BIN
github-cache/1aeed0f4cc1c
Normal file
Binary file not shown.
BIN
github-cache/1afe8f3a86cd
Normal file
BIN
github-cache/1afe8f3a86cd
Normal file
Binary file not shown.
BIN
github-cache/1b853cfd5991
Normal file
BIN
github-cache/1b853cfd5991
Normal file
Binary file not shown.
BIN
github-cache/1c9c9056e6f9
Normal file
BIN
github-cache/1c9c9056e6f9
Normal file
Binary file not shown.
BIN
github-cache/1d21aab07fe5
Normal file
BIN
github-cache/1d21aab07fe5
Normal file
Binary file not shown.
BIN
github-cache/1d2b41b904f2
Normal file
BIN
github-cache/1d2b41b904f2
Normal file
Binary file not shown.
BIN
github-cache/1d53a568ff5e
Normal file
BIN
github-cache/1d53a568ff5e
Normal file
Binary file not shown.
BIN
github-cache/1d9f66b8c13b
Normal file
BIN
github-cache/1d9f66b8c13b
Normal file
Binary file not shown.
BIN
github-cache/1da6a3185d6e
Normal file
BIN
github-cache/1da6a3185d6e
Normal file
Binary file not shown.
BIN
github-cache/1e0112a68ff0
Normal file
BIN
github-cache/1e0112a68ff0
Normal file
Binary file not shown.
BIN
github-cache/1ea8dd444e36
Normal file
BIN
github-cache/1ea8dd444e36
Normal file
Binary file not shown.
BIN
github-cache/1eedc6cbd80c
Normal file
BIN
github-cache/1eedc6cbd80c
Normal file
Binary file not shown.
BIN
github-cache/1f46c02e47b5
Normal file
BIN
github-cache/1f46c02e47b5
Normal file
Binary file not shown.
BIN
github-cache/1f9e4918a78c
Normal file
BIN
github-cache/1f9e4918a78c
Normal file
Binary file not shown.
BIN
github-cache/1f9fd828db24
Normal file
BIN
github-cache/1f9fd828db24
Normal file
Binary file not shown.
BIN
github-cache/2006cc34ad59
Normal file
BIN
github-cache/2006cc34ad59
Normal file
Binary file not shown.
BIN
github-cache/2075f385da58
Normal file
BIN
github-cache/2075f385da58
Normal file
Binary file not shown.
BIN
github-cache/20a7ff89ae2c
Normal file
BIN
github-cache/20a7ff89ae2c
Normal file
Binary file not shown.
BIN
github-cache/21d5bd593128
Normal file
BIN
github-cache/21d5bd593128
Normal file
Binary file not shown.
BIN
github-cache/228e5896f98a
Normal file
BIN
github-cache/228e5896f98a
Normal file
Binary file not shown.
BIN
github-cache/22d091c58f33
Normal file
BIN
github-cache/22d091c58f33
Normal file
Binary file not shown.
BIN
github-cache/239205bd2aa4
Normal file
BIN
github-cache/239205bd2aa4
Normal file
Binary file not shown.
BIN
github-cache/23a0d05256dc
Normal file
BIN
github-cache/23a0d05256dc
Normal file
Binary file not shown.
BIN
github-cache/242e47b2ef84
Normal file
BIN
github-cache/242e47b2ef84
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user