Compare commits

..

8 Commits

Author SHA1 Message Date
Richard Moore
3abfdffffa Updated dist files. 2020-11-17 20:36:19 -05:00
Richard Moore
02546b9401 Fix browser ws alias. 2020-11-17 20:07:22 -05:00
Richard Moore
fff72ef369 Use faux-registry to better simulate real world React Native apps. 2020-11-17 18:48:02 -05:00
Richard Moore
f10977ab35 Fixing React Native tests. 2020-11-17 13:41:43 -05:00
Richard Moore
1729f804fb Prevent node 8 from using rollup (contains incompatible syntax). 2020-11-17 02:51:54 -05:00
Richard Moore
8933467c01 Updated dist build. 2020-11-16 23:07:24 -05:00
Richard Moore
22bd0c76dd Use dist files in browser tests. 2020-11-16 21:20:35 -05:00
Richard Moore
4809325bee Refactoring dist build process. 2020-11-14 17:42:36 -05:00
622 changed files with 9267 additions and 25971 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
node_modules/
packages/*/node_modules
packages/*/lib._esm
.package_node_modules/
obsolete/
.DS_Store

View File

@@ -3,6 +3,13 @@ Changelog
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
ethers/v5.0.20 (2020-11-17 20:32)
---------------------------------
- Fix browser ws alias for WebSockets. ([02546b9](https://github.com/ethers-io/ethers.js/commit/02546b9401d8066135b4453da917f7ef49c95ad8))
- Fixing React Native tests. ([f10977a](https://github.com/ethers-io/ethers.js/commit/f10977ab35f953c3148d99b61799788f47d2a5a2), [fff72ef](https://github.com/ethers-io/ethers.js/commit/fff72ef369f5420bf8283b0808e8fec71f26dd2b))
- Refactoring dist build process. ([4809325](https://github.com/ethers-io/ethers.js/commit/4809325bee9cbdd269b099d7b12b218f441ac840), [22bd0c7](https://github.com/ethers-io/ethers.js/commit/22bd0c76dddef7134618ec70ac1b084a054e616e), [8933467](https://github.com/ethers-io/ethers.js/commit/8933467c01b64ead547d7c136f22f3c05c85ca1f))
ethers/v5.0.19 (2020-10-22 21:55)
---------------------------------

View File

@@ -61,6 +61,7 @@ function getMime(filename) {
case 'js': return 'application/javascript';
case 'jpg': return 'image/jpeg';
case 'jpeg': return 'image/jpeg';
case 'json': return 'application/json';
case 'md': return 'text/markdown';
case 'pickle': return 'application/x-pickle';
case 'png': return 'image/png';

View File

@@ -2,10 +2,11 @@
module.exports = function(config) {
config.set({
basePath: "./output/karma",
frameworks: [ 'mocha' ],
files: [
{ pattern: "./packages/ethers/dist/ethers-all.esm.min.js", type: "module" },
{ pattern: "./packages/tests/dist/tests.esm.js", type: "module" }
{ pattern: "./ethers.esm.js", type: "module" },
{ pattern: "./tests.esm.js", type: "module" }
],
reporters: [ 'karma' ],
plugins: [

View File

@@ -2,10 +2,11 @@
module.exports = function(config) {
config.set({
basePath: "./output/karma",
frameworks: [ 'mocha' ],
files: [
"./packages/ethers/dist/ethers-all.umd.min.js",
"./packages/tests/dist/tests.umd.js",
"./ethers.umd.js",
"./tests.umd.js",
],
reporters: [ 'karma' ],
plugins: [
@@ -41,7 +42,7 @@ module.exports = function(config) {
/*
client: {
mocha: {
grep: 'Etherscan',
grep: 'Test WebSocketProvider',
}
}
*/

View File

@@ -59,3 +59,4 @@ buck-out/
/ios/Pods/
webserver.log
faux-registry/*.tgz

View File

@@ -21,15 +21,16 @@ import {
} from 'react-native/Libraries/NewAppScreen';
// Inject the crpyot shims (BEFORE the ethers shims)
import "./crypto-shims.js";
// Inject the crypto shims (BEFORE the ethers shims)
import "react-native-get-random-values";
// Inject the missing features with the ethers shims
import "./libs/shims.js";
import "@ethersproject/shims";
//import "./libs/shims";
// Import ethers
import { ethers } from "./libs/ethers.js";
import { ethers } from "ethers";
//import { ethers } from "./libs/ethers";
// Import the test framework
import "./libs/mocha.js";

View File

@@ -1,3 +0,0 @@
try {
require("get-random-values-polypony").polyfill();
} catch (error) { };

View File

@@ -0,0 +1,131 @@
"use strict";
const { spawnSync } = require("child_process");
const fs = require("fs");
const { createServer } = require("http");
const { URL } = require("url");
const { resolve } = require("path");
const http = require("http");
const https = require("https");
const PORT = 8043;
function getPath(...path) {
return resolve(__dirname, "../../../", ...path);
}
function loadJson(filename) {
return JSON.parse(fs.readFileSync(filename).toString());
}
function getPackageInfo(name) {
const info = loadJson(getPath("packages", name, "package.json"));
// Create the npm packaged tarball
const child = spawnSync("npm", [ "pack", getPath("packages", name), "--json" ], { cwd: resolve(__dirname) });
if (child.status !== 0) { throw new Error("npm pack failed"); }
const filename = JSON.parse(child.stdout.toString())[0].filename;
info.dist = {
tarball: `http:/\/localhost:${ PORT }/__packages__/${ filename }`
};
info.maintainers = [ info.author ];
const versions = { };
versions[info.version] = info;
const time = { };
time[info.version] = "2020-11-17T00:00:00.000Z";
return JSON.stringify({
"dist-tags": { latest: info.version },
name: info.name,
readmeFilename: "README.md",
readme: "README",
author: info.author,
_id: info.name,
bugs: info.bugs,
description: info.description,
homepage: info.homepage,
license: info.license,
repository: info.repository,
maintainers: info.maintainers,
time: time,
versions: versions,
});
}
async function readStream(stream) {
let data = Buffer.alloc(0);
return new Promise((resolve, reject) => {
stream.on("data", (chunk) => {
data = Buffer.concat([ data, chunk ]);
});
stream.on("end", () => {
resolve(data);
});
stream.on("error", (error) => {
reject(error);
});
});
}
async function forwardRequest(req) {
const newReq = new URL(req.url, "https:/\/registry.npmjs.org");
newReq.method = req.method;
let body = null;
if (req.method === "POST") {
body = await readStream(req);
}
return new Promise((resolve, reject) => {
const req = https.request(newReq, (resp) => {
readStream(resp).then(resolve, reject);
});
req.on("error", (error) => {
reject(error);
});
if (body != null) { req.write(body); }
req.end();
});
}
const server = createServer(async (req, resp) => {
const method = req.method;
const url = new URL(req.url, `http:/\/localhost:${ PORT }`);
const packageName = (url.pathname ? url.pathname: "/").substring(1).replace(/%([0-9a-f][0-9a-f])/ig, (all, escape) => {
return String.fromCharCode(parseInt(escape, 16));
});
let result = null;
if (packageName === "ethers") {
result = getPackageInfo("ethers");
console.log(`Using local ${ packageName }...`);
} else if (packageName.split("/")[0] === "@ethersproject") {
result = getPackageInfo(packageName.split("/").pop());
console.log(`Using local ${ packageName }...`);
} else if (packageName.split("/")[0] === "__packages__") {
const filename = packageName.split("/").pop();
result = fs.readFileSync(resolve(__dirname, filename));
console.log(`Using local ${ filename }...`);
} else {
result = await forwardRequest(req);
}
resp.write(result);
resp.end();
});
server.listen(PORT, () => {
console.log(`Started faux-registry on ${ PORT }...`);
});

View File

@@ -66,8 +66,6 @@ PODS:
- boost-for-react-native
- DoubleConversion
- glog
- get-random-values-polypony (1.0.0):
- React
- glog (0.3.5)
- OpenSSL-Universal (1.0.2.19):
- OpenSSL-Universal/Static (= 1.0.2.19)
@@ -238,6 +236,8 @@ PODS:
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- React-jsinspector (0.63.2)
- react-native-get-random-values (1.5.0):
- React
- React-RCTActionSheet (0.63.2):
- React-Core/RCTActionSheetHeaders (= 0.63.2)
- React-RCTAnimation (0.63.2):
@@ -326,7 +326,6 @@ DEPENDENCIES:
- FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.41.1)
- FlipperKit/SKIOSNetworkPlugin (~> 0.41.1)
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- get-random-values-polypony (from `../node_modules/get-random-values-polypony`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
@@ -340,6 +339,7 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
@@ -376,8 +376,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/FBReactNativeSpec"
Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec"
get-random-values-polypony:
:path: "../node_modules/get-random-values-polypony"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
RCTRequired:
@@ -400,6 +398,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-get-random-values:
:path: "../node_modules/react-native-get-random-values"
React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation:
@@ -438,7 +438,6 @@ SPEC CHECKSUMS:
Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7
FlipperKit: bc68102cd4952a258a23c9c1b316c7bec1fecf83
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
get-random-values-polypony: 6caa66e41322297b72477ffe91201a06890fcf8a
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355
RCTRequired: f13f25e7b12f925f1f6a6a8c69d929a03c0129fe
@@ -451,6 +450,7 @@ SPEC CHECKSUMS:
React-jsi: 54245e1d5f4b690dec614a73a3795964eeef13a8
React-jsiexecutor: 8ca588cc921e70590820ce72b8789b02c67cce38
React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606
react-native-get-random-values: 1404bd5cc0ab0e287f75ee1c489555688fc65f89
React-RCTActionSheet: 910163b6b09685a35c4ebbc52b66d1bfbbe39fc5
React-RCTAnimation: 9a883bbe1e9d2e158d4fb53765ed64c8dc2200c6
React-RCTBlob: 39cf0ece1927996c4466510e25d2105f67010e13

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,11 @@
"lint": "eslint ."
},
"dependencies": {
"get-random-values-polypony": "^1.0.0",
"ethers": "^5.0.0",
"@ethersproject/shims": "^5.0.0",
"react": "16.13.1",
"react-native": "0.63.2"
"react-native": "0.63.2",
"react-native-get-random-values": "1.5.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",

View File

@@ -1,12 +1,17 @@
#!/bin/bash
cp ../../packages/ethers/dist/ethers-all.umd.min.js libs/ethers.js
cp ../../node_modules/mocha/mocha.js libs/mocha.js
cp ../../packages/tests/dist/tests.umd.js libs/tests.js
cp ../../packages/shims/dist/index.js libs/shims.js
cp ../../packages/tests/dist/tests.esm.js libs/tests.js
# Start our fake registry
node faux-registry/server.js &
REGISTRY=$!
# Install React (comment this out during debugging)
npm install
npm install --registry http://localhost:8043
# Shutdown our fake registry
kill $REGISTRY
# Link any native modules
npx react-native link
@@ -30,7 +35,7 @@ npx react-native run-ios
wait $WATCHER
RESULT=$?
# Kill the server
# Shutdown the server
kill $SERVER
# Forward the status

View File

@@ -17,20 +17,6 @@ function setupConfig(outDir, moduleType, targetType) {
if (info._ethers_nobuild) {
return;
}
if (targetType === "es2015") {
if (info["browser.esm"]) {
info.browser = info["browser.esm"];
}
}
else if (targetType === "es5") {
if (info["browser.umd"]) {
info.browser = info["browser.umd"];
}
}
else {
throw new Error("unsupported target");
}
utils_1.saveJson(filename, info, true);
let path = path_1.resolve("packages", dirname, "tsconfig.json");
let content = utils_1.loadJson(path);
content.compilerOptions.outDir = outDir;
@@ -39,7 +25,7 @@ function setupConfig(outDir, moduleType, targetType) {
}
function setupBuild(buildModule) {
if (buildModule) {
setupConfig("./lib.esm/", "es2015", "es2015");
setupConfig("./lib._esm/", "es2015", "es2015");
}
else {
setupConfig("./lib/", "commonjs", "es5");

View File

@@ -0,0 +1,66 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/** bundle-testcases
*
* This sript converts all the testase data (including needed
* text files) into a single JSON file.
*
* All gzip files (mostly .json.gz) are decompressed and recompressed
* using deflate, so a much more simple deflate library can be used.
*/
const fs_1 = __importDefault(require("fs"));
const path_1 = require("path");
const zlib_1 = __importDefault(require("zlib"));
const log_1 = require("../log");
const path_2 = require("../path");
const utils_1 = require("../utils");
const config = {
dirs: [
"./input/easyseed-bip39",
"./testcases",
"./input/wordlists"
]
};
(function () {
return __awaiter(this, void 0, void 0, function* () {
console.log(log_1.colorify.bold(`Bundling Testcase Data...`));
const data = { "_": JSON.stringify({ name: "browser-fs", config: config }) };
config.dirs.forEach((dirname) => {
let fulldirname = path_2.resolve("packages/testcases", dirname);
fs_1.default.readdirSync(fulldirname).forEach((filename) => {
const key = path_1.join(dirname, filename);
const content = fs_1.default.readFileSync(path_1.join(fulldirname, filename));
if (filename.split(".").pop() === "gz") {
const contentData = zlib_1.default.gunzipSync(content);
data[key] = String(contentData.length) + "," + zlib_1.default.deflateRawSync(contentData).toString("base64");
}
else {
data[key] = content.toString("base64");
}
console.log(` - Added ${key} (${data[key].length} bytes)`);
});
});
utils_1.mkdir(path_2.resolve("packages/testcases/lib"));
utils_1.mkdir(path_2.resolve("packages/testcases/lib._esm"));
utils_1.mkdir(path_2.resolve("packages/testcases/lib.esm"));
// We write it out to all needed places
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib._esm/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib.esm/browser-data.json"), JSON.stringify(data));
// Write it to the TypeScript source last, in case it is running it will
// be regenerated overwriting the above files, but with identical content
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/src.ts/browser-data.json"), JSON.stringify(data));
});
})();

1
misc/admin/lib/cmds/esm-alias.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,131 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = require("path");
const depgraph_1 = require("../depgraph");
const path_2 = require("../path");
const utils_1 = require("../utils");
const log_1 = require("../log");
function diff(a, b) {
return (Buffer.compare(fs_1.default.readFileSync(a), fs_1.default.readFileSync(b)) !== 0);
}
function alias(name) {
return __awaiter(this, void 0, void 0, function* () {
console.log(` Aliasing: ${name}`);
const baseDir = path_2.resolve("packages", name);
const info = utils_1.loadJson(path_2.resolve(baseDir, "package.json"));
const replacements = info["_ethers.alias"] || {};
const skip = Object.keys(replacements).reduce((accum, key) => {
const replace = replacements[key];
accum[replace] = true;
accum[replace + ".map"] = true;
accum[replace.replace(/\.js$/, ".d.ts")] = true;
return accum;
}, ({}));
const transforms = [];
const recurse = function (input, output) {
fs_1.default.readdirSync(path_1.join(baseDir, input)).forEach((filename) => {
const stat = fs_1.default.statSync(path_1.join(baseDir, input, filename));
if (stat.isDirectory()) {
recurse(path_1.join(input, filename), path_1.join(output, filename));
return;
}
if (skip[filename]) {
return;
}
let inputFilename = filename;
let transform = null;
if (filename.match(/\.js(on)?$/)) {
// JavaScript; swap in any replacement
// e.g. (filename = geturl.js) => (inputFilename = browser-geturl.js)
// + transform (//# sourceMappingURL=browser-geturl.js.map) to
// (//# sourceMappingURL=geturl.js.map)
const replace = replacements[filename];
// Skip!
if (replace === "") {
return;
}
if (replace) {
inputFilename = replace;
transform = function (content) {
content = content.replace(/(\/\/# sourceMappingURL=)(.*)$/g, (all, prefix, mapFilename) => {
return prefix + filename + ".map";
});
return content;
};
}
}
else if (filename.match(/\.d\.ts$/)) {
// TypeScript definietion file
// e.g. (filename = geturl.d.ts) => diff(geturl.d.ts, browser-geturl.d.ts)
// We do not need to swap anything out, but we need to ensure
// the definition of the node and browser are identical
const replace = replacements[filename.replace(/\.d\.ts$/i, ".js")];
// Skip!
if (replace === "") {
return;
}
if (replace) {
inputFilename = replace.replace(/\.js$/i, ".d.ts");
if (diff(path_1.join(baseDir, input, filename), path_1.join(baseDir, input, inputFilename))) {
console.log(`Warning: TypeScript Definition files differ: ${filename} != ${inputFilename}`);
}
}
}
else if (filename.match(/\.map$/)) {
// Map files; swap in the replacement
// e.g. (filename = geturl.js.map) => (inputFilename = browser-geturl.js.map)
// + transform the map JSON to reference "geturl.js"
// We need to swap in the replacement and update its data
const replace = replacements[filename.replace(/\.js.map$/i, ".js")];
// Skip!
if (replace === "") {
return;
}
if (replace) {
inputFilename = replace + ".map";
transform = function (content) {
const data = JSON.parse(content);
data["file"] = filename.replace(/\.js\.map$/, ".js");
return JSON.stringify(data);
};
}
}
transforms.push({ input: path_1.join(input, inputFilename), output: path_1.join(output, filename), transform });
});
};
recurse("lib._esm", "lib.esm");
transforms.forEach(({ input, output, transform }) => {
const sourceFile = path_1.join(baseDir, input);
let content = fs_1.default.readFileSync(sourceFile).toString();
if (transform) {
content = transform(content);
}
const targetFile = path_1.join(baseDir, output);
const targetDir = path_1.dirname(targetFile);
utils_1.mkdir(targetDir);
fs_1.default.writeFileSync(targetFile, content);
});
});
}
(function () {
return __awaiter(this, void 0, void 0, function* () {
console.log(log_1.colorify.bold(`Aliasing Node ESM to Browser ESM...`));
const dirnames = depgraph_1.getOrdered(true);
for (let i = 0; i < dirnames.length; i++) {
yield alias(dirnames[i]);
}
});
})();

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,37 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = require("../path");
const utils_1 = require("../utils");
function copy(src, dst, transform) {
let data = fs_1.default.readFileSync(path_1.resolve(src));
if (transform) {
data = Buffer.from(transform(data.toString()));
}
fs_1.default.writeFileSync(dst, data);
}
(function () {
return __awaiter(this, void 0, void 0, function* () {
yield utils_1.mkdir(path_1.resolve("output/karma"));
copy(path_1.resolve("packages/ethers/dist/ethers.esm.js"), path_1.resolve("output/karma/ethers.esm.js"));
copy(path_1.resolve("packages/tests/dist/tests.esm.js"), path_1.resolve("output/karma/tests.esm.js"), (data) => {
return data.replace(/^(import [^;]* from ')(ethers)(';)/, (all, prefix, id, suffix) => {
return prefix + "./ethers.esm.js" + suffix;
});
});
copy(path_1.resolve("packages/ethers/dist/ethers.umd.js"), path_1.resolve("output/karma/ethers.umd.js"));
copy(path_1.resolve("packages/tests/dist/tests.umd.js"), path_1.resolve("output/karma/tests.umd.js"));
});
})();

View File

@@ -18,19 +18,6 @@ function setupConfig(outDir: string, moduleType: string, targetType: string) {
if (info._ethers_nobuild) { return; }
if (targetType === "es2015") {
if (info["browser.esm"]) {
info.browser = info["browser.esm"];
}
} else if (targetType === "es5") {
if (info["browser.umd"]) {
info.browser = info["browser.umd"];
}
} else {
throw new Error("unsupported target");
}
saveJson(filename, info, true);
let path = resolve("packages", dirname, "tsconfig.json");
let content = loadJson(path);
content.compilerOptions.outDir = outDir;
@@ -40,7 +27,7 @@ function setupConfig(outDir: string, moduleType: string, targetType: string) {
export function setupBuild(buildModule: boolean): void {
if (buildModule) {
setupConfig("./lib.esm/", "es2015", "es2015");
setupConfig("./lib._esm/", "es2015", "es2015");
} else {
setupConfig("./lib/", "commonjs", "es5");
}

View File

@@ -0,0 +1,61 @@
"use strict";
/** bundle-testcases
*
* This sript converts all the testase data (including needed
* text files) into a single JSON file.
*
* All gzip files (mostly .json.gz) are decompressed and recompressed
* using deflate, so a much more simple deflate library can be used.
*/
import fs from "fs";
import { join } from "path";
import zlib from "zlib";
import { colorify } from "../log";
import { resolve } from "../path";
import { mkdir } from "../utils";
const config = {
dirs: [
"./input/easyseed-bip39",
"./testcases",
"./input/wordlists"
]
};
(async function() {
console.log(colorify.bold(`Bundling Testcase Data...`));
const data: Record<string, string> = { "_": JSON.stringify({ name: "browser-fs", config: config }) };
config.dirs.forEach((dirname) => {
let fulldirname = resolve("packages/testcases", dirname);
fs.readdirSync(fulldirname).forEach((filename) => {
const key = join(dirname, filename);
const content = fs.readFileSync(join(fulldirname, filename));
if (filename.split(".").pop() === "gz") {
const contentData = zlib.gunzipSync(content);
data[key] = String(contentData.length) + "," + zlib.deflateRawSync(contentData).toString("base64");
} else {
data[key] = content.toString("base64");
}
console.log(` - Added ${ key } (${ data[key].length } bytes)`);
});
});
mkdir(resolve("packages/testcases/lib"));
mkdir(resolve("packages/testcases/lib._esm"));
mkdir(resolve("packages/testcases/lib.esm"));
// We write it out to all needed places
fs.writeFileSync(resolve("packages/testcases/lib/browser-data.json"), JSON.stringify(data));
fs.writeFileSync(resolve("packages/testcases/lib._esm/browser-data.json"), JSON.stringify(data));
fs.writeFileSync(resolve("packages/testcases/lib.esm/browser-data.json"), JSON.stringify(data));
// Write it to the TypeScript source last, in case it is running it will
// be regenerated overwriting the above files, but with identical content
fs.writeFileSync(resolve("packages/testcases/src.ts/browser-data.json"), JSON.stringify(data));
})();

View File

@@ -0,0 +1,123 @@
import fs from "fs";
import { dirname, join } from "path";
import { getOrdered } from "../depgraph";
import { resolve } from "../path";
import { loadJson, mkdir } from "../utils";
import { colorify } from "../log";
function diff(a: string, b: string): boolean {
return (Buffer.compare(fs.readFileSync(a), fs.readFileSync(b)) !== 0);
}
async function alias(name: string): Promise<void> {
console.log(` Aliasing: ${ name }`);
const baseDir = resolve("packages", name);
const info = loadJson(resolve(baseDir, "package.json"));
const replacements: Record<string, string> = info["_ethers.alias"] || { };
const skip = Object.keys(replacements).reduce((accum, key) => {
const replace = replacements[key];
accum[replace] = true;
accum[replace + ".map"] = true;
accum[replace.replace(/\.js$/, ".d.ts")] = true;
return accum;
}, <Record<string, boolean>>({ }));
const transforms: Array<{ input: string, output: string, transform?: (content: string) => string }> = [ ];
const recurse = function(input: string, output: string) {
fs.readdirSync(join(baseDir, input)).forEach((filename) => {
const stat = fs.statSync(join(baseDir, input, filename));
if (stat.isDirectory()) {
recurse(join(input, filename), join(output, filename));
return;
}
if (skip[filename]) { return; }
let inputFilename = filename;
let transform: (content: string) => string = null;
if (filename.match(/\.js(on)?$/)) {
// JavaScript; swap in any replacement
// e.g. (filename = geturl.js) => (inputFilename = browser-geturl.js)
// + transform (//# sourceMappingURL=browser-geturl.js.map) to
// (//# sourceMappingURL=geturl.js.map)
const replace = replacements[filename];
// Skip!
if (replace === "") { return; }
if (replace) {
inputFilename = replace;
transform = function(content: string) {
content = content.replace(/(\/\/# sourceMappingURL=)(.*)$/g, (all, prefix, mapFilename) => {
return prefix + filename + ".map";
});
return content;
}
}
} else if (filename.match(/\.d\.ts$/)) {
// TypeScript definietion file
// e.g. (filename = geturl.d.ts) => diff(geturl.d.ts, browser-geturl.d.ts)
// We do not need to swap anything out, but we need to ensure
// the definition of the node and browser are identical
const replace = replacements[filename.replace(/\.d\.ts$/i, ".js")];
// Skip!
if (replace === "") { return; }
if (replace) {
inputFilename = replace.replace(/\.js$/i, ".d.ts");
if (diff(join(baseDir, input, filename), join(baseDir, input, inputFilename))) {
console.log(`Warning: TypeScript Definition files differ: ${ filename } != ${ inputFilename }`);
}
}
} else if (filename.match(/\.map$/)) {
// Map files; swap in the replacement
// e.g. (filename = geturl.js.map) => (inputFilename = browser-geturl.js.map)
// + transform the map JSON to reference "geturl.js"
// We need to swap in the replacement and update its data
const replace = replacements[filename.replace(/\.js.map$/i, ".js")];
// Skip!
if (replace === "") { return; }
if (replace) {
inputFilename = replace + ".map";
transform = function(content: string) {
const data = JSON.parse(content);
data["file"] = filename.replace(/\.js\.map$/, ".js");
return JSON.stringify(data);
}
}
}
transforms.push({ input: join(input, inputFilename), output: join(output, filename), transform });
});
};
recurse("lib._esm", "lib.esm");
transforms.forEach(({ input, output, transform }) => {
const sourceFile = join(baseDir, input);
let content = fs.readFileSync(sourceFile).toString();
if (transform) { content = transform(content); }
const targetFile = join(baseDir, output);
const targetDir = dirname(targetFile);
mkdir(targetDir);
fs.writeFileSync(targetFile, content);
});
}
(async function() {
console.log(colorify.bold(`Aliasing Node ESM to Browser ESM...`));
const dirnames = getOrdered(true);
for (let i = 0; i < dirnames.length; i++) {
await alias(dirnames[i]);
}
})();

View File

@@ -0,0 +1,27 @@
import fs from "fs";
import { resolve } from "../path";
import { mkdir } from "../utils";
function copy(src: string, dst: string, transform?: (data: string) => string): void {
let data = fs.readFileSync(resolve(src));
if (transform) {
data = Buffer.from(transform(data.toString()));
}
fs.writeFileSync(dst, data);
}
(async function() {
await mkdir(resolve("output/karma"));
copy(resolve("packages/ethers/dist/ethers.esm.js"), resolve("output/karma/ethers.esm.js"));
copy(resolve("packages/tests/dist/tests.esm.js"), resolve("output/karma/tests.esm.js"), (data) => {
return data.replace(/^(import [^;]* from ')(ethers)(';)/, (all, prefix, id, suffix) => {
return prefix + "./ethers.esm.js" + suffix;
});
});
copy(resolve("packages/ethers/dist/ethers.umd.js"), resolve("output/karma/ethers.umd.js"));
copy(resolve("packages/tests/dist/tests.umd.js"), resolve("output/karma/tests.umd.js"));
})();

2451
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,58 +15,56 @@
"build": "tsc --build ./tsconfig.project.json",
"_build-cjs": "node ./misc/admin/lib/cmds/echo 'Building CommonJS libraries...' && node ./misc/admin/lib/cmds/set-build-option cjs && npm run build",
"_build-esm": "node ./misc/admin/lib/cmds/echo 'Building ES modules libraries...' && node ./misc/admin/lib/cmds/set-build-option esm && npm run build",
"clean": "node ./misc/admin/lib/cmds/echo 'Cleaning all build files...' && rm -rf packages/*/lib packages/*/lib.esm packages/*/node_modules packages/*/dist/*.js packages/*/tsconfig.tsbuildinfo node_modules .package_node_modules package-lock.json",
"_test-esm-dist": "rollup -c rollup-tests.config.js --configModule",
"_test-umd-dist": "rollup -c rollup-tests.config.js",
"clean": "node ./misc/admin/lib/cmds/echo 'Cleaning all build files...' && rm -rf packages/*/lib packages/*/lib._esm packages/*/lib.esm packages/*/node_modules packages/*/dist/*.js packages/*/tsconfig.tsbuildinfo node_modules .package_node_modules package-lock.json",
"_test-dist": "rollup -c rollup-tests.config.js && node ./misc/admin/lib/cmds/setup-karma-tests",
"_test-browser-umd": "karma start --single-run --browsers HeadlessLittleLiar karma-umd.conf.js",
"_test-browser-esm": "karma start --single-run --browsers HeadlessLittleLiar karma-esm.conf.js",
"test-browser-umd": "npm run _test-umd-dist && npm run _test-browser-umd",
"test-browser-esm": "npm run _test-esm-dist && npm run _test-browser-esm",
"test-browser-umd": "npm run _test-dist && npm run _test-browser-umd",
"test-browser-esm": "npm run _test-dist && npm run _test-browser-esm",
"test-coverage": "nyc --report-dir=output --reporter=lcov --reporter=text mocha --reporter ./packages/tests/reporter-keepalive ./packages/tests/lib/test-*.js | tee output/summary.txt",
"test-node": "mocha --no-colors --reporter ./packages/tests/reporter ./packages/tests/lib/test-*.js",
"test-react": "npm run _test-umd-dist && npm run build-dist-shims && pushd misc/ReactNativeTestApp && ./run-tests.sh && popd",
"test-react": "npm run _test-dist && pushd misc/ReactNativeTestApp && ./run-tests.sh && popd",
"test": "npm run build-all && npm run test-node",
"build-docs": "flatworm docs.wrm docs",
"serve-docs": "node ./misc/admin/lib/cmds/serve-docs.js",
"upload-docs": " node ./admin/cmds/upload-docs.js",
"spell-check": "node ./misc/admin/lib/cmds/spell-check.js",
"build-dist-ancillary": "node ./misc/admin/lib/cmds/set-build-option esm && rollup -c rollup-ancillary.config.js",
"build-dist-shims": "browserify ./packages/shims/src/index.js -o ./packages/shims/dist/index.js && uglifyjs --compress --mangle --output ./packages/shims/dist/index.min.js -- ./packages/shims/dist/index.js",
"build-dist-umd": "node ./misc/admin/lib/cmds/set-build-option cjs browser-lang-all && rollup -c && mv ./packages/ethers/dist/ethers.umd.min.js ./packages/ethers/dist/ethers-all.umd.min.js && node ./misc/admin/lib/cmds/set-build-option cjs && rollup -c",
"build-dist-esm": "node ./misc/admin/lib/cmds/set-build-option esm browser-lang-all && rollup -c --configModule && mv ./packages/ethers/dist/ethers.esm.min.js ./packages/ethers/dist/ethers-all.esm.min.js && node ./misc/admin/lib/cmds/set-build-option esm && rollup -c --configModule",
"_build-dist": "node ./misc/admin/lib/cmds/echo 'Building dist files...' && npm run build-dist-shims && npm run build-dist-esm && npm run build-dist-ancillary && npm run build-dist-umd",
"build-dist": "node ./misc/admin/lib/cmds/npm-skip-node8.js || npm run _build-dist",
"build-libs": "node ./misc/admin/lib/cmds/update-exports.js && npm run _build-cjs && npm run _build-esm && node ./misc/admin/lib/cmds/set-build-option cjs && node packages/asm/generate.js && chmod 755 packages/*/lib/bin/*.js",
"_reset-build": "node ./misc/admin/lib/cmds/set-build-option cjs",
"_esm-alias-nodesafe": "node ./misc/admin/lib/cmds/echo 'Bundling ESM elliptic (lib._esm/browser-elliptic.js)...' && rollup -c rollup-pre-alias.config.js && node misc/admin/lib/cmds/esm-alias",
"_esm-alias": "node ./misc/admin/lib/cmds/npm-skip-node8.js || npm run _esm-alias-nodesafe",
"build-libs": "node ./misc/admin/lib/cmds/update-exports.js && node ./misc/admin/lib/cmds/bundle-testcases && npm run _build-cjs && npm run _build-esm && npm run _reset-build && node packages/asm/generate.js && npm run _esm-alias && chmod 755 packages/*/lib/bin/*.js",
"build-dist-shims": "rollup -c rollup-shims.config.js && uglifyjs --compress --mangle --output ./packages/shims/dist/index.min.js -- ./packages/shims/dist/index.js",
"build-dist-libs": "rollup -c rollup-dist.config.js && uglifyjs packages/ethers/dist/ethers.umd.js --output packages/ethers/dist/ethers.umd.min.js --source-map 'content=packages/ethers/dist/ethers.umd.js.map' && uglifyjs packages/ethers/dist/ethers.esm.js --output packages/ethers/dist/ethers.esm.min.js --source-map 'content=packages/ethers/dist/ethers.esm.js.map'",
"_build-dist-nodesafe": "node ./misc/admin/lib/cmds/echo 'Building dist files...' && npm run build-dist-libs && npm run build-dist-shims",
"build-dist": "node ./misc/admin/lib/cmds/npm-skip-node8.js || npm run _build-dist-nodesafe",
"build-all": "npm run build-libs && npm run build-dist",
"update-versions": "npm run clean && npm install && npm run spell-check && npm run build-all && node ./misc/admin/lib/cmds/bump-versions && npm run build-all && node ./misc/admin/lib/cmds/update-hashes && node ./misc/admin/lib/cmds/update-changelog",
"publish-all": "node ./misc/admin/lib/cmds/publish",
"TODO-sync-github": "node ./admin/cmds/cache-github"
},
"devDependencies": {
"@erquhart/rollup-plugin-node-builtins": "2.1.5",
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"@rollup/plugin-replace": "2.3.3",
"@types/assert": "^1.4.1",
"@types/mocha": "^5.2.0",
"@types/node": "^12.7.4",
"@types/semver": "^7.3.4",
"aes-js": "3.0.0",
"aws-sdk": "2.137.0",
"browserify": "16.2.3",
"diff": "4.0.1",
"flatworm": "0.0.2-beta.5",
"jison": "^0.4.18",
"karma": "5.1.0",
"jison": "0.4.18",
"karma": "5.2.3",
"karma-chrome-launcher": "3.1.0",
"karma-mocha": "2.0.1",
"libnpmpublish": "3.0.1",
"mocha": "^7.1.1",
"nyc": "15.1.0",
"rollup": "1.20.1",
"rollup-plugin-commonjs": "10.0.2",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "^7.0.0",
"rollup-pluginutils": "2.8.1",
"rollup": "2.33.2",
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-sourcemaps": "0.6.3",
"scrypt-js": "3.0.1",
"semver": "^5.6.0",
"typescript": "3.8.3",
@@ -75,21 +73,19 @@
"dependencies": {
"@babel/parser": "7.8.4",
"@babel/types": "7.8.3",
"@ledgerhq/hw-app-eth": "5.3.0",
"@ledgerhq/hw-transport": "5.3.0",
"@ledgerhq/hw-transport-u2f": "5.3.0",
"@ledgerhq/hw-app-eth": "5.27.2",
"@ledgerhq/hw-transport": "5.26.0",
"@ledgerhq/hw-transport-u2f": "5.26.0",
"@types/mocha": "^5.2.0",
"aes-js": "3.0.0",
"bech32": "1.1.4",
"bn.js": "^4.4.0",
"browserify-zlib": "^0.2.0",
"elliptic": "6.5.3",
"hash.js": "1.1.3",
"js-sha3": "0.5.7",
"mime-types": "2.1.11",
"scrypt-js": "3.0.1",
"solc": "0.7.1",
"solidity-parser-antlr": "^0.3.2",
"tiny-inflate": "1.0.3",
"ws": "7.2.3"
}
}

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "abi/5.0.7";
export declare const version = "abi/5.0.8";

View File

@@ -1,2 +1,2 @@
export const version = "abi/5.0.7";
export const version = "abi/5.0.8";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
export declare const version = "abi/5.0.7";
export declare const version = "abi/5.0.8";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abi/5.0.7";
exports.version = "abi/5.0.8";
//# sourceMappingURL=_version.js.map

View File

@@ -31,7 +31,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x1cb0dc8fd334cbf9dba1c9746ed316852af2f5dbbd61f07048e737f452568352",
"tarballHash": "0xd0da395b7622fd7dd82ecb018055bab5f061029c1f526b2577457d83da3739e1",
"types": "./lib/index.d.ts",
"version": "5.0.7"
"version": "5.0.8"
}

View File

@@ -1 +1 @@
export const version = "abi/5.0.7";
export const version = "abi/5.0.8";

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "abstract-provider/5.0.5";
export declare const version = "abstract-provider/5.0.6";

View File

@@ -1,2 +1,2 @@
export const version = "abstract-provider/5.0.5";
export const version = "abstract-provider/5.0.6";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
export declare const version = "abstract-provider/5.0.5";
export declare const version = "abstract-provider/5.0.6";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abstract-provider/5.0.5";
exports.version = "abstract-provider/5.0.6";
//# sourceMappingURL=_version.js.map

View File

@@ -29,7 +29,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x87fdc7d7ee69d8c228c0e6946be702acd027a832b5a3deaa5b60e3c9f7110e58",
"sideEffects": false,
"tarballHash": "0x7f7031bb38c6ca4604423fb6ed651450b9992537548ae9b3848f249d107a88a7",
"types": "./lib/index.d.ts",
"version": "5.0.5"
"version": "5.0.6"
}

View File

@@ -1 +1 @@
export const version = "abstract-provider/5.0.5";
export const version = "abstract-provider/5.0.6";

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "abstract-signer/5.0.7";
export declare const version = "abstract-signer/5.0.8";

View File

@@ -1,2 +1,2 @@
export const version = "abstract-signer/5.0.7";
export const version = "abstract-signer/5.0.8";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
export declare const version = "abstract-signer/5.0.7";
export declare const version = "abstract-signer/5.0.8";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abstract-signer/5.0.7";
exports.version = "abstract-signer/5.0.8";
//# sourceMappingURL=_version.js.map

View File

@@ -27,7 +27,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x722fb4b5e18bb70cda3c2fbd250d96bacdbe7d358c4c426a73d262fc1f751845",
"sideEffects": false,
"tarballHash": "0x6d9f5f4b221cb8879f684ac29d0ccebfb6d71a742007e8aa0e902b610e686827",
"types": "./lib/index.d.ts",
"version": "5.0.7"
"version": "5.0.8"
}

View File

@@ -1 +1 @@
export const version = "abstract-signer/5.0.7";
export const version = "abstract-signer/5.0.8";

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "address/5.0.5";
export declare const version = "address/5.0.6";

View File

@@ -1,2 +1,2 @@
export const version = "address/5.0.5";
export const version = "address/5.0.6";
//# sourceMappingURL=_version.js.map

View File

@@ -1,8 +1,6 @@
"use strict";
// We use this for base 36 maths
import { BN } from "bn.js";
import { arrayify, concat, hexDataLength, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes";
import { BigNumber } from "@ethersproject/bignumber";
import { BigNumber, _base16To36, _base36To16 } from "@ethersproject/bignumber";
import { keccak256 } from "@ethersproject/keccak256";
import { encode } from "@ethersproject/rlp";
import { Logger } from "@ethersproject/logger";
@@ -86,7 +84,7 @@ export function getAddress(address) {
if (address.substring(2, 4) !== ibanChecksum(address)) {
logger.throwArgumentError("bad icap checksum", "address", address);
}
result = (new BN(address.substring(4), 36)).toString(16);
result = _base36To16(address.substring(4));
while (result.length < 40) {
result = "0" + result;
}
@@ -106,7 +104,7 @@ export function isAddress(address) {
return false;
}
export function getIcapAddress(address) {
let base36 = (new BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase();
let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();
while (base36.length < 30) {
base36 = "0" + base36;
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
export declare const version = "address/5.0.5";
export declare const version = "address/5.0.6";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "address/5.0.5";
exports.version = "address/5.0.6";
//# sourceMappingURL=_version.js.map

View File

@@ -1,7 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// We use this for base 36 maths
var bn_js_1 = require("bn.js");
var bytes_1 = require("@ethersproject/bytes");
var bignumber_1 = require("@ethersproject/bignumber");
var keccak256_1 = require("@ethersproject/keccak256");
@@ -87,7 +85,7 @@ function getAddress(address) {
if (address.substring(2, 4) !== ibanChecksum(address)) {
logger.throwArgumentError("bad icap checksum", "address", address);
}
result = (new bn_js_1.BN(address.substring(4), 36)).toString(16);
result = bignumber_1._base36To16(address.substring(4));
while (result.length < 40) {
result = "0" + result;
}
@@ -109,7 +107,7 @@ function isAddress(address) {
}
exports.isAddress = isAddress;
function getIcapAddress(address) {
var base36 = (new bn_js_1.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase();
var base36 = bignumber_1._base16To36(getAddress(address).substring(2)).toUpperCase();
while (base36.length < 30) {
base36 = "0" + base36;
}

File diff suppressed because one or more lines are too long

View File

@@ -5,8 +5,7 @@
"@ethersproject/bytes": "^5.0.4",
"@ethersproject/keccak256": "^5.0.3",
"@ethersproject/logger": "^5.0.5",
"@ethersproject/rlp": "^5.0.3",
"bn.js": "^4.4.0"
"@ethersproject/rlp": "^5.0.3"
},
"description": "Utilities for handling Ethereum Addresses for ethers.",
"ethereum": "donations.ethers.eth",
@@ -28,7 +27,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0xd6263c8653bc6784fed703b8a30075630c544e3861f43ed5b49ab56ffb5d4808",
"sideEffects": false,
"tarballHash": "0xed9bb243991ef357503555a8f3dc3081da5c5a64ec148a34791a264d07568f99",
"types": "./lib/index.d.ts",
"version": "5.0.5"
"version": "5.0.6"
}

View File

@@ -1 +1 @@
export const version = "address/5.0.5";
export const version = "address/5.0.6";

View File

@@ -1,10 +1,7 @@
"use strict";
// We use this for base 36 maths
import { BN } from "bn.js";
import { arrayify, BytesLike, concat, hexDataLength, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
import { BigNumber, BigNumberish, _base16To36, _base36To16 } from "@ethersproject/bignumber";
import { keccak256 } from "@ethersproject/keccak256";
import { encode } from "@ethersproject/rlp";
@@ -104,7 +101,7 @@ export function getAddress(address: string): string {
logger.throwArgumentError("bad icap checksum", "address", address);
}
result = (new BN(address.substring(4), 36)).toString(16);
result = _base36To16(address.substring(4));
while (result.length < 40) { result = "0" + result; }
result = getChecksumAddress("0x" + result);
@@ -124,7 +121,7 @@ export function isAddress(address: string): boolean {
}
export function getIcapAddress(address: string): string {
let base36 = (new BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase();
let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();
while (base36.length < 30) { base36 = "0" + base36; }
return "XE" + ibanChecksum("XE00" + base36) + base36;
}

View File

@@ -1,30 +0,0 @@
declare module "bn.js" {
export class BN {
constructor(value: string | number, radix?: number);
add(other: BN): BN;
sub(other: BN): BN;
div(other: BN): BN;
mod(other: BN): BN;
mul(other: BN): BN;
pow(other: BN): BN;
maskn(other: number): BN;
eq(other: BN): boolean;
lt(other: BN): boolean;
lte(other: BN): boolean;
gt(other: BN): boolean;
gte(other: BN): boolean;
isZero(): boolean;
toTwos(other: number): BN;
fromTwos(other: number): BN;
toString(radix: number): string;
toNumber(): number;
toArray(endian: string, width: number): Uint8Array;
encode(encoding: string, compact: boolean): Uint8Array;
}
}

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -11,4 +11,12 @@ const parser = new jison.Parser(grammar);
const parserSource = parser.generate({ moduleName: "parser" });
const esmSuffix = `
// Added By ../generate.js
const parse = exports.parse;
export { parse, parser }
`;
fs.writeFileSync(resolve(__dirname, "./lib/_parser.js"), parserSource);
fs.writeFileSync(resolve(__dirname, "./lib._esm/_parser.js"), parserSource + esmSuffix);

View File

@@ -0,0 +1,786 @@
/* parser generated by jison 0.4.18 */
/*
Returns a Parser object of the following structure:
Parser: {
yy: {}
}
Parser.prototype: {
yy: {},
trace: function(),
symbols_: {associative list: name ==> number},
terminals_: {associative list: number ==> name},
productions_: [...],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
table: [...],
defaultActions: {...},
parseError: function(str, hash),
parse: function(input),
lexer: {
EOF: 1,
parseError: function(str, hash),
setInput: function(input),
input: function(),
unput: function(str),
more: function(),
less: function(n),
pastInput: function(),
upcomingInput: function(),
showPosition: function(),
test_match: function(regex_match_array, rule_index),
next: function(),
lex: function(),
begin: function(condition),
popState: function(),
_currentRules: function(),
topState: function(),
pushState: function(condition),
options: {
ranges: boolean (optional: true ==> token location info will include a .range[] member)
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
},
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
rules: [...],
conditions: {associative list: name ==> set},
}
}
token location info (@$, _$, etc.): {
first_line: n,
last_line: n,
first_column: n,
last_column: n,
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
}
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
text: (matched text)
token: (the produced terminal token, if any)
line: (yylineno)
}
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
loc: (yylloc)
expected: (string describing the set of expected tokens)
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
}
*/
var parser = (function(){
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,23],$V1=[1,7],$V2=[1,8],$V3=[1,9],$V4=[1,10],$V5=[1,11],$V6=[1,12],$V7=[1,13],$V8=[1,14],$V9=[1,15],$Va=[1,5],$Vb=[1,6],$Vc=[5,28],$Vd=[5,11,14,15,16,17,18,19,20,21,25,28,31],$Ve=[2,2],$Vf=[1,22],$Vg=[5,10,11,13,14,15,16,17,18,19,20,21,25,28,31],$Vh=[1,28],$Vi=[1,29],$Vj=[1,30],$Vk=[1,31],$Vl=[2,17],$Vm=[5,10,11,13,14,15,16,17,18,19,20,21,25,28,30,31],$Vn=[16,17,18,21,30];
var parser = {trace: function trace () { },
yy: {},
symbols_: {"error":2,"program":3,"statement_list":4,"EOF":5,"javascript":6,"SCRIPT_TOKEN":7,"opcode_list":8,"opcode":9,"COMMA":10,"ID":11,"OPEN_PAREN":12,"CLOSE_PAREN":13,"HASH_ID":14,"DOLLAR_ID":15,"HEX":16,"DECIMAL":17,"BINARY":18,"DOLLAR_DOLLAR":19,"DOLLAR_INDEX":20,"SCRIPT_EVAL":21,"hex_list":22,"hex":23,"statement":24,"AT_ID":25,"COLON":26,"OPEN_BRACE":27,"CLOSE_BRACE":28,"OPEN_BRACKET":29,"CLOSE_BRACKET":30,"SCRIPT_EXEC":31,"$accept":0,"$end":1},
terminals_: {2:"error",5:"EOF",7:"SCRIPT_TOKEN",10:"COMMA",11:"ID",12:"OPEN_PAREN",13:"CLOSE_PAREN",14:"HASH_ID",15:"DOLLAR_ID",16:"HEX",17:"DECIMAL",18:"BINARY",19:"DOLLAR_DOLLAR",20:"DOLLAR_INDEX",21:"SCRIPT_EVAL",25:"AT_ID",26:"COLON",27:"OPEN_BRACE",28:"CLOSE_BRACE",29:"OPEN_BRACKET",30:"CLOSE_BRACKET",31:"SCRIPT_EXEC"},
productions_: [0,[3,2],[6,0],[6,2],[8,1],[8,3],[9,1],[9,3],[9,4],[9,1],[9,1],[9,1],[9,1],[9,1],[9,1],[9,1],[9,2],[22,0],[22,2],[23,1],[23,1],[23,1],[23,2],[4,0],[4,2],[24,1],[24,2],[24,4],[24,4],[24,2]],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
/* this == yyval */
var $0 = $$.length - 1;
switch (yystate) {
case 1:
return { type: "scope", name: "_", statements: $$[$0-1], loc: getLoc(yy, null) };
break;
case 2:
this.$ = "";
break;
case 3:
this.$ = $$[$0-1] + $$[$0];
break;
case 4:
this.$ = [ $$[$0] ];
break;
case 5:
{
const opcodes = $$[$0].slice();
opcodes.unshift($$[$0-2]);
this.$ = opcodes;
}
break;
case 6:
this.$ = { type: "opcode", bare: true, mnemonic: $$[$0], operands: [ ], loc: getLoc(yy, _$[$0]) };
break;
case 7:
this.$ = { type: "opcode", mnemonic: $$[$0-2], operands: [ ], loc: getLoc(yy, _$[$0-2], _$[$0]) };
break;
case 8:
this.$ = { type: "opcode", mnemonic: $$[$0-3], operands: $$[$0-1], loc: getLoc(yy, _$[$0-3], _$[$0]) };
break;
case 9:
this.$ = { type: "length", label: $$[$0].substring(1), loc: getLoc(yy, _$[$0]) };
break;
case 10:
this.$ = { type: "offset", label: $$[$0].substring(1), loc: getLoc(yy, _$[$0]) };
break;
case 11:
this.$ = { type: "hex", value: $$[$0], loc: getLoc(yy, _$[$0]) };
break;
case 12:
this.$ = { type: "decimal", value: $$[$0], loc: getLoc(yy, _$[$0]) };
break;
case 13:
{
const hex = "0x" + parseInt(("0" + ($$[$0]).substring(2)), 2).toString(16);
this.$ = { type: "hex", value: hex, loc: getLoc(yy, _$[$0]) };
}
break;
case 14:
this.$ = { type: "pop", index: 0, loc: getLoc(yy, _$[$0]) };
break;
case 15:
this.$ = { type: "pop", index: parseInt(($$[$0]).substring(1)), loc: getLoc(yy, _$[$0]) };
break;
case 16:
this.$ = { type: "eval", script: $$[$0], loc: getLoc(yy, _$[$0-1], _$[$0]) };
break;
case 17: case 23:
this.$ = [ ];
break;
case 18:
{
const hexes = $$[$0].slice();;
hexes.unshift($$[$0-1]);
this.$ = hexes;
}
break;
case 19:
this.$ = { type: "hex", verbatim: true, value: $$[$0], loc: getLoc(yy, _$[$0]) };
break;
case 20:
{
const value = parseInt($$[$0]);
if (value >= 256) { throw new Error("decimal data values must be single bytes"); }
let hex = (value).toString(16);
while (hex.length < 2) { hex = "0" + hex; }
this.$ = { type: "hex", verbatim: true, value: ("0x" + hex), loc: getLoc(yy, _$[$0]) };
}
break;
case 21:
{
const value = parseInt(($$[$0]).substring(2), 2);
if (value >= 256) { throw new Error("binary data values must be single bytes"); }
const hex = ("0x" + (value).toString(16));
this.$ = { type: "hex", verbatim: true, value: hex, loc: getLoc(yy, _$[$0]) };
}
break;
case 22:
this.$ = { type: "eval", verbatim: true, script: $$[$0], loc: getLoc(yy, _$[$0-1], _$[$0]) };
break;
case 24:
{
const statements = $$[$0].slice();
statements.unshift($$[$0-1]);
this.$ = statements;
}
break;
case 25:
{
const statement = $$[$0];
statement.loc.statement = true;
this.$ = statement;
}
break;
case 26:
this.$ = { type: "label", name: $$[$0-1].substring(1), loc: getLoc(yy, _$[$0-1], _$[$0], true) };
break;
case 27:
this.$ = { type: "scope", name: $$[$0-3].substring(1), statements: $$[$0-1], loc: getLoc(yy, _$[$0-3], _$[$0], true) };
break;
case 28:
this.$ = { type: "data", name: $$[$0-3].substring(1), data: $$[$0-1], loc: getLoc(yy, _$[$0-3], _$[$0], true) };
break;
case 29:
this.$ = { type: "exec", script: $$[$0], loc: getLoc(yy, _$[$0-1], _$[$0], true) };
break;
}
},
table: [{3:1,4:2,5:$V0,9:4,11:$V1,14:$V2,15:$V3,16:$V4,17:$V5,18:$V6,19:$V7,20:$V8,21:$V9,24:3,25:$Va,31:$Vb},{1:[3]},{5:[1,16]},o($Vc,$V0,{24:3,9:4,4:17,11:$V1,14:$V2,15:$V3,16:$V4,17:$V5,18:$V6,19:$V7,20:$V8,21:$V9,25:$Va,31:$Vb}),o($Vd,[2,25]),{26:[1,18],27:[1,19],29:[1,20]},o($Vd,$Ve,{6:21,7:$Vf}),o($Vg,[2,6],{12:[1,23]}),o($Vg,[2,9]),o($Vg,[2,10]),o($Vg,[2,11]),o($Vg,[2,12]),o($Vg,[2,13]),o($Vg,[2,14]),o($Vg,[2,15]),o($Vg,$Ve,{6:24,7:$Vf}),{1:[2,1]},o($Vc,[2,24]),o($Vd,[2,26]),{4:25,9:4,11:$V1,14:$V2,15:$V3,16:$V4,17:$V5,18:$V6,19:$V7,20:$V8,21:$V9,24:3,25:$Va,28:$V0,31:$Vb},{16:$Vh,17:$Vi,18:$Vj,21:$Vk,22:26,23:27,30:$Vl},o($Vd,[2,29]),o($Vm,$Ve,{6:32,7:$Vf}),{8:34,9:35,11:$V1,13:[1,33],14:$V2,15:$V3,16:$V4,17:$V5,18:$V6,19:$V7,20:$V8,21:$V9},o($Vg,[2,16]),{28:[1,36]},{30:[1,37]},{16:$Vh,17:$Vi,18:$Vj,21:$Vk,22:38,23:27,30:$Vl},o($Vn,[2,19]),o($Vn,[2,20]),o($Vn,[2,21]),o($Vn,$Ve,{6:39,7:$Vf}),o($Vm,[2,3]),o($Vg,[2,7]),{13:[1,40]},{10:[1,41],13:[2,4]},o($Vd,[2,27]),o($Vd,[2,28]),{30:[2,18]},o($Vn,[2,22]),o($Vg,[2,8]),{8:42,9:35,11:$V1,14:$V2,15:$V3,16:$V4,17:$V5,18:$V6,19:$V7,20:$V8,21:$V9},{13:[2,5]}],
defaultActions: {16:[2,1],38:[2,18],42:[2,5]},
parseError: function parseError (str, hash) {
if (hash.recoverable) {
this.trace(str);
} else {
var error = new Error(str);
error.hash = hash;
throw error;
}
},
parse: function parse(input) {
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
var args = lstack.slice.call(arguments, 1);
var lexer = Object.create(this.lexer);
var sharedState = { yy: {} };
for (var k in this.yy) {
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
sharedState.yy[k] = this.yy[k];
}
}
lexer.setInput(input, sharedState.yy);
sharedState.yy.lexer = lexer;
sharedState.yy.parser = this;
if (typeof lexer.yylloc == 'undefined') {
lexer.yylloc = {};
}
var yyloc = lexer.yylloc;
lstack.push(yyloc);
var ranges = lexer.options && lexer.options.ranges;
if (typeof sharedState.yy.parseError === 'function') {
this.parseError = sharedState.yy.parseError;
} else {
this.parseError = Object.getPrototypeOf(this).parseError;
}
function popStack(n) {
stack.length = stack.length - 2 * n;
vstack.length = vstack.length - n;
lstack.length = lstack.length - n;
}
_token_stack:
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];
if (this.defaultActions[state]) {
action = this.defaultActions[state];
} else {
if (symbol === null || typeof symbol == 'undefined') {
symbol = lex();
}
action = table[state] && table[state][symbol];
}
if (typeof action === 'undefined' || !action.length || !action[0]) {
var errStr = '';
expected = [];
for (p in table[state]) {
if (this.terminals_[p] && p > TERROR) {
expected.push('\'' + this.terminals_[p] + '\'');
}
}
if (lexer.showPosition) {
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
} else {
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
}
this.parseError(errStr, {
text: lexer.match,
token: this.terminals_[symbol] || symbol,
line: lexer.yylineno,
loc: yyloc,
expected: expected
});
}
if (action[0] instanceof Array && action.length > 1) {
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
}
switch (action[0]) {
case 1:
stack.push(symbol);
vstack.push(lexer.yytext);
lstack.push(lexer.yylloc);
stack.push(action[1]);
symbol = null;
if (!preErrorSymbol) {
yyleng = lexer.yyleng;
yytext = lexer.yytext;
yylineno = lexer.yylineno;
yyloc = lexer.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
symbol = preErrorSymbol;
preErrorSymbol = null;
}
break;
case 2:
len = this.productions_[action[1]][1];
yyval.$ = vstack[vstack.length - len];
yyval._$ = {
first_line: lstack[lstack.length - (len || 1)].first_line,
last_line: lstack[lstack.length - 1].last_line,
first_column: lstack[lstack.length - (len || 1)].first_column,
last_column: lstack[lstack.length - 1].last_column
};
if (ranges) {
yyval._$.range = [
lstack[lstack.length - (len || 1)].range[0],
lstack[lstack.length - 1].range[1]
];
}
r = this.performAction.apply(yyval, [
yytext,
yyleng,
yylineno,
sharedState.yy,
action[1],
vstack,
lstack
].concat(args));
if (typeof r !== 'undefined') {
return r;
}
if (len) {
stack = stack.slice(0, -1 * len * 2);
vstack = vstack.slice(0, -1 * len);
lstack = lstack.slice(0, -1 * len);
}
stack.push(this.productions_[action[1]][0]);
vstack.push(yyval.$);
lstack.push(yyval._$);
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
stack.push(newState);
break;
case 3:
return true;
}
}
return true;
}};
function getLoc(yy, start, end, statement) {
if (end == null) { end = start; }
let result = null;
if (start) {
result = {
first_line: start.first_line,
first_column: start.first_column,
last_line: end.last_line,
last_column: end.last_column,
statement: !!statement
};
}
if (yy._ethersLocation) {
return yy._ethersLocation(result);
}
return result;
}
/* generated by jison-lex 0.3.4 */
var lexer = (function(){
var lexer = ({
EOF:1,
parseError:function parseError(str, hash) {
if (this.yy.parser) {
this.yy.parser.parseError(str, hash);
} else {
throw new Error(str);
}
},
// resets the lexer, sets new input
setInput:function (input, yy) {
this.yy = yy || this.yy || {};
this._input = input;
this._more = this._backtrack = this.done = false;
this.yylineno = this.yyleng = 0;
this.yytext = this.matched = this.match = '';
this.conditionStack = ['INITIAL'];
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
};
if (this.options.ranges) {
this.yylloc.range = [0,0];
}
this.offset = 0;
return this;
},
// consumes and returns one char from the input
input:function () {
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
var lines = ch.match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
} else {
this.yylloc.last_column++;
}
if (this.options.ranges) {
this.yylloc.range[1]++;
}
this._input = this._input.slice(1);
return ch;
},
// unshifts one char (or a string) into the input
unput:function (ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
//this.yyleng -= len;
this.offset -= len;
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1);
this.matched = this.matched.substr(0, this.matched.length - 1);
if (lines.length - 1) {
this.yylineno -= lines.length - 1;
}
var r = this.yylloc.range;
this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: lines ?
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
this.yylloc.first_column - len
};
if (this.options.ranges) {
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
}
this.yyleng = this.yytext.length;
return this;
},
// When called from action, caches matched text and appends it on next action
more:function () {
this._more = true;
return this;
},
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject:function () {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
return this;
},
// retain first n characters of the match
less:function (n) {
this.unput(this.match.slice(n));
},
// displays already matched input, i.e. for error messages
pastInput:function () {
var past = this.matched.substr(0, this.matched.length - this.match.length);
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
},
// displays upcoming input, i.e. for error messages
upcomingInput:function () {
var next = this.match;
if (next.length < 20) {
next += this._input.substr(0, 20-next.length);
}
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
},
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition:function () {
var pre = this.pastInput();
var c = new Array(pre.length + 1).join("-");
return pre + this.upcomingInput() + "\n" + c + "^";
},
// test the lexed token: return FALSE when not a match, otherwise return token
test_match:function(match, indexed_rule) {
var token,
lines,
backup;
if (this.options.backtrack_lexer) {
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
if (this.options.ranges) {
backup.yylloc.range = this.yylloc.range.slice(0);
}
}
lines = match[0].match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno += lines.length;
}
this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines ?
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
this.yylloc.last_column + match[0].length
};
this.yytext += match[0];
this.match += match[0];
this.matches = match;
this.yyleng = this.yytext.length;
if (this.options.ranges) {
this.yylloc.range = [this.offset, this.offset += this.yyleng];
}
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match[0].length);
this.matched += match[0];
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
// recover context
for (var k in backup) {
this[k] = backup[k];
}
return false; // rule action called reject() implying the next rule should be tested instead.
}
return false;
},
// return next match in input
next:function () {
if (this.done) {
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token,
match,
tempMatch,
index;
if (!this._more) {
this.yytext = '';
this.match = '';
}
var rules = this._currentRules();
for (var i = 0; i < rules.length; i++) {
tempMatch = this._input.match(this.rules[rules[i]]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rules[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = false;
continue; // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rules[index]);
if (token !== false) {
return token;
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
if (this._input === "") {
return this.EOF;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
},
// return next match that has a token
lex:function lex () {
var r = this.next();
if (r) {
return r;
} else {
return this.lex();
}
},
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin:function begin (condition) {
this.conditionStack.push(condition);
},
// pop the previously active lexer condition state off the condition stack
popState:function popState () {
var n = this.conditionStack.length - 1;
if (n > 0) {
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules:function _currentRules () {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
} else {
return this.conditions["INITIAL"].rules;
}
},
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState:function topState (n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return "INITIAL";
}
},
// alias for begin(condition)
pushState:function pushState (condition) {
this.begin(condition);
},
// return the number of states currently on the stack
stateStackSize:function stateStackSize() {
return this.conditionStack.length;
},
options: {},
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
var YYSTATE=YY_START;
switch($avoiding_name_collisions) {
case 0: this.begin("script"); return "SCRIPT_EVAL";
break;
case 1: this.begin("script"); return "SCRIPT_EXEC";
break;
case 2:return "SCRIPT_TOKEN";
break;
case 3:this.popState()
break;
case 4:// Ignore comments
break;
case 5:// Ignore Whitespace
break;
case 6:return "ID"
break;
case 7:return "OPEN_PAREN"
break;
case 8:return "CLOSE_PAREN"
break;
case 9:return "COMMA"
break;
case 10:return "AT_ID"
break;
case 11:return "DOLLAR_ID"
break;
case 12:return "HASH_ID"
break;
case 13:return "OPEN_BRACE"
break;
case 14:return "CLOSE_BRACE"
break;
case 15:return "COLON"
break;
case 16:return "OPEN_BRACKET"
break;
case 17:return "CLOSE_BRACKET"
break;
case 18:return "HEX"
break;
case 19:return "BINARY"
break;
case 20:return "DECIMAL"
break;
case 21:return "DOLLAR_DOLLAR"
break;
case 22:return "DOLLAR_INDEX"
break;
case 23:return "EOF"
break;
case 24:return "INVALID"
break;
}
},
rules: [/^(?:\{\{=)/,/^(?:\{\{!)/,/^(?:([^\}]|\n|\}[^}]))/,/^(?:\}\})/,/^(?:([;][^\n]*\n))/,/^(?:(\s+))/,/^(?:([A-Za-z][A-Za-z0-9]*))/,/^(?:\()/,/^(?:\))/,/^(?:,)/,/^(?:([@][A-Za-z][A-Za-z0-9]*))/,/^(?:([$](_|[A-Za-z][A-Za-z0-9]*)))/,/^(?:([#](_|[A-Za-z][A-Za-z0-9]*)))/,/^(?:\{)/,/^(?:\})/,/^(?::)/,/^(?:\[)/,/^(?:\])/,/^(?:(0x([0-9a-fA-F][0-9a-fA-F])*))/,/^(?:(0b(0|1)+))/,/^(?:([1-9][0-9]*|0))/,/^(?:\$\$)/,/^(?:([$][1-9][0-9]*))/,/^(?:$)/,/^(?:)/],
conditions: {"script":{"rules":[2,3],"inclusive":false},"INITIAL":{"rules":[0,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"inclusive":true}}
});
return lexer;
})();
parser.lexer = lexer;
function Parser () {
this.yy = {};
}
Parser.prototype = parser;parser.Parser = Parser;
return new Parser;
})();
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = parser;
exports.Parser = parser.Parser;
exports.parse = function () { return parser.parse.apply(parser, arguments); };
exports.main = function commonjsMain (args) {
if (!args[1]) {
console.log('Usage: '+args[0]+' FILE');
process.exit(1);
}
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
return exports.parser.parse(source);
};
if (typeof module !== 'undefined' && require.main === module) {
exports.main(process.argv.slice(1));
}
}
// Added By ../generate.js
const parse = exports.parse;
export { parse, parser }

View File

@@ -1 +1 @@
export declare const version = "asm/5.0.6";
export declare const version = "asm/5.0.7";

View File

@@ -1,2 +1,2 @@
export const version = "asm/5.0.6";
export const version = "asm/5.0.7";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
export declare const version = "asm/5.0.6";
export declare const version = "asm/5.0.7";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "asm/5.0.6";
exports.version = "asm/5.0.7";
//# sourceMappingURL=_version.js.map

View File

@@ -25,7 +25,7 @@
"generate": "node ./generate.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x29773f2f77c16dcd4e7f6cb0cc1929a249f165cfc128380558a64cc5dff87cb7",
"tarballHash": "0xa34335f80d32a66c7b35829a2f4c253b231e4b33607c73c1b3df61201fe31068",
"types": "./lib/index.d.ts",
"version": "5.0.6"
"version": "5.0.7"
}

View File

@@ -1 +1 @@
export const version = "asm/5.0.6";
export const version = "asm/5.0.7";

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "base64/5.0.4";
export declare const version = "base64/5.0.5";

View File

@@ -1,2 +1,2 @@
export const version = "base64/5.0.4";
export const version = "base64/5.0.5";
//# sourceMappingURL=_version.js.map

3
packages/base64/lib.esm/base64.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { BytesLike } from "@ethersproject/bytes";
export declare function decode(textData: string): Uint8Array;
export declare function encode(data: BytesLike): string;

View File

@@ -16,4 +16,4 @@ export function encode(data) {
}
return btoa(textData);
}
//# sourceMappingURL=browser.js.map
//# sourceMappingURL=base64.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../src.ts/browser-base64.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;AAE3D,MAAM,UAAU,MAAM,CAAC,QAAgB;IACnC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAe;IAClC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}

View File

@@ -1 +0,0 @@
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src.ts/browser.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;AAE3D,MAAM,UAAU,MAAM,CAAC,QAAgB;IACnC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAe;IAClC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}

View File

@@ -1,3 +1 @@
import { BytesLike } from "@ethersproject/bytes";
export declare function decode(textData: string): Uint8Array;
export declare function encode(data: BytesLike): string;
export { decode, encode } from "./base64";

View File

@@ -1,10 +1,3 @@
"use strict";
import { arrayify } from "@ethersproject/bytes";
export function decode(textData) {
return arrayify(new Uint8Array(Buffer.from(textData, "base64")));
}
;
export function encode(data) {
return Buffer.from(arrayify(data)).toString("base64");
}
export { decode, encode } from "./base64";
//# sourceMappingURL=index.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;AAG3D,MAAM,UAAU,MAAM,CAAC,QAAgB;IACnC,OAAO,QAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,MAAM,CAAC,IAAe;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}

View File

@@ -1 +1 @@
export declare const version = "base64/5.0.4";
export declare const version = "base64/5.0.5";

View File

@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "base64/5.0.4";
exports.version = "base64/5.0.5";
//# sourceMappingURL=_version.js.map

3
packages/base64/lib/base64.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { BytesLike } from "@ethersproject/bytes";
export declare function decode(textData: string): Uint8Array;
export declare function encode(data: BytesLike): string;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
function decode(textData) {
return bytes_1.arrayify(new Uint8Array(Buffer.from(textData, "base64")));
}
exports.decode = decode;
;
function encode(data) {
return Buffer.from(bytes_1.arrayify(data)).toString("base64");
}
exports.encode = encode;
//# sourceMappingURL=base64.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../src.ts/base64.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8CAA2D;AAG3D,SAAgB,MAAM,CAAC,QAAgB;IACnC,OAAO,gBAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC;AAAA,CAAC;AAEF,SAAgB,MAAM,CAAC,IAAe;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,gBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAFD,wBAEC"}

View File

@@ -0,0 +1,3 @@
import { BytesLike } from "@ethersproject/bytes";
export declare function decode(textData: string): Uint8Array;
export declare function encode(data: BytesLike): string;

View File

@@ -19,4 +19,4 @@ function encode(data) {
return btoa(textData);
}
exports.encode = encode;
//# sourceMappingURL=browser.js.map
//# sourceMappingURL=browser-base64.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-base64.js","sourceRoot":"","sources":["../src.ts/browser-base64.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8CAA2D;AAE3D,SAAgB,MAAM,CAAC,QAAgB;IACnC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,IAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;IACD,OAAO,gBAAQ,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAPD,wBAOC;AAED,SAAgB,MAAM,CAAC,IAAe;IAClC,IAAI,GAAG,gBAAQ,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAPD,wBAOC"}

View File

@@ -1 +0,0 @@
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src.ts/browser.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8CAA2D;AAE3D,SAAgB,MAAM,CAAC,QAAgB;IACnC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,IAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;IACD,OAAO,gBAAQ,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAPD,wBAOC;AAED,SAAgB,MAAM,CAAC,IAAe;IAClC,IAAI,GAAG,gBAAQ,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAPD,wBAOC"}

View File

@@ -1,3 +1 @@
import { BytesLike } from "@ethersproject/bytes";
export declare function decode(textData: string): Uint8Array;
export declare function encode(data: BytesLike): string;
export { decode, encode } from "./base64";

View File

@@ -1,13 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("@ethersproject/bytes");
function decode(textData) {
return bytes_1.arrayify(new Uint8Array(Buffer.from(textData, "base64")));
}
exports.decode = decode;
;
function encode(data) {
return Buffer.from(bytes_1.arrayify(data)).toString("base64");
}
exports.encode = encode;
var base64_1 = require("./base64");
exports.decode = base64_1.decode;
exports.encode = base64_1.encode;
//# sourceMappingURL=index.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8CAA2D;AAG3D,SAAgB,MAAM,CAAC,QAAgB;IACnC,OAAO,gBAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC;AAAA,CAAC;AAEF,SAAgB,MAAM,CAAC,IAAe;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,gBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAFD,wBAEC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,mCAA0C;AAAjC,0BAAA,MAAM,CAAA;AAAE,0BAAA,MAAM,CAAA"}

View File

@@ -1,8 +1,11 @@
{
"_ethers.alias": {
"base64.js": "browser-base64.js"
},
"author": "Richard Moore <me@ricmoo.com>",
"browser": "./lib/browser.js",
"browser.esm": "./lib.esm/browser.js",
"browser.umd": "./lib/browser.js",
"browser": {
"./lib/base64": "./lib/browser-base64.js"
},
"dependencies": {
"@ethersproject/bytes": "^5.0.4"
},
@@ -26,7 +29,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0xf9edd66aa5131bf0bca2ea188265e0e333d781e4b0ef5e92090a7cef8556cb30",
"sideEffects": false,
"tarballHash": "0xb364a54a1e2a4180ba3704634382e9280ed96801142e8f51eb956bf2d9853d4d",
"types": "./lib/index.d.ts",
"version": "5.0.4"
"version": "5.0.5"
}

View File

@@ -1 +1 @@
export const version = "base64/5.0.4";
export const version = "base64/5.0.5";

View File

@@ -0,0 +1,12 @@
"use strict";
import { arrayify, BytesLike } from "@ethersproject/bytes";
export function decode(textData: string): Uint8Array {
return arrayify(new Uint8Array(Buffer.from(textData, "base64")));
};
export function encode(data: BytesLike): string {
return Buffer.from(arrayify(data)).toString("base64");
}

View File

@@ -1,12 +1,3 @@
"use strict";
import { arrayify, BytesLike } from "@ethersproject/bytes";
export function decode(textData: string): Uint8Array {
return arrayify(new Uint8Array(Buffer.from(textData, "base64")));
};
export function encode(data: BytesLike): string {
return Buffer.from(arrayify(data)).toString("base64");
}
export { decode, encode } from "./base64";

View File

@@ -1,4 +1,4 @@
.DS_Store
tsconfig.json
src.ts/
lib._esm
tsconfig.tsbuildinfo

View File

@@ -1 +1 @@
export declare const version = "basex/5.0.4";
export declare const version = "basex/5.0.5";

View File

@@ -1,2 +1,2 @@
export const version = "basex/5.0.4";
export const version = "basex/5.0.5";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
export declare const version = "basex/5.0.4";
export declare const version = "basex/5.0.5";

Some files were not shown because too many files have changed in this diff Show More