diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6442effca --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +node_modules/ +obsolete/ +.DS_Store +.tmp/ +dist/types/shims/ +shims/*.d.ts +**/*.swp + +# Weird intermediate files tsc generates for references +**/src.ts/*.js + +# Weird file Browserify sometimes leaves lying around. +**/*.tmp-browserify-* + +lerna-debug.log diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..f1103395a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +Changelog +========= + +This change log is managed by scripts/index.js but may +be manually updated. + +Coming Soon... diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 684e27f7d..d0ef66b5f 100644 --- a/README.md +++ b/README.md @@ -1 +1,85 @@ -Coming soon... +The Ethers Project +================== + +**EXPERIMENTAL!!!** + +This is just a development version to experiment with lerna. + +**Do NOT use** + + +Installing +---------- + +**node.js** + +``` +/home/ricmoo/some_project> npm install --save ethers +``` + +**browser** + +``` + +``` + + +Ancillary Packages +------------------ + +These are a number of packages not included in the umbrella `ethers ` npm package, and +additional packages are always being added. Often these packages are for specific +use-cases, so rather than adding them to the umbrella package, they are added as +ancillary packaged, which can be included by those who need them, while not bloating +everyone else with packages they do not need. + +We will keep a list of useful pacakges here. + +- `@ethersproject/experimental` +- `@ethersproject/cli` +- `@ethersproject/ens` +- `@ethersproject/ledger` +- `@ethersproject/trezor` + + +Hacking +------- + +This project uses a combination of Lerna and the ./admin scripts to manage +itself as a package of packages. + +The umbrella package can be found in `packages/ethers`, and all packages in general +can be found in the `packages/` folder. + +If you add new dependencies to any package (incuding internal dependencies), you will +need to re-create the internal links and re-build teh dependency graph:: + +``` +/home/ethers> npm run bootstrap +``` + +To run a continuous build (with incremental TypeScript compilation): + +``` +/home/ethers> npm run auto-build +``` + +Finally, once you have made all your changes, you will need to bump the version +of packages that changed their NPM tarballs, as well as update the _version.* +and distribution builds (which is what we host on the CDN for browser-based +apps). To do this, run: + + +``` +/home/ethers> npm run update-version +``` + +Which will also list all packages that have changed along with the specifc files. + + +License +------- + +MIT License (including **all** dependencies). + diff --git a/admin/README.md b/admin/README.md new file mode 100644 index 000000000..3e24c14fd --- /dev/null +++ b/admin/README.md @@ -0,0 +1,80 @@ +Admin Tool +========== + +This tool is meant for admin taks related to ethers.js. + + +Workflow +-------- + +After a new change is made and `npm run build` has been used to compile the +TypeScript, the following steps should be completed to publish it. + +1. Run `admin status` or `admin diff` to update the package.json (tarballHash and version) and audit changes +2. Run `admin add-source` to stage changed source files +3. Run `git commit -S -m "message..."` +4. Run `npm dist` to create the changelog and all dist files +5. Update the changelog as needed +6. Run `admin add-dist` to stage the dist files +7. Run test cases +8. Run `git commit -S -m "Updated dist files."` +9. Run `git push` +10. Wait for TravisCI to complete running test cases +11. Run `admin publish` to publish changed packages to NPM and tag GitHub + + +Status: admin status +-------------------- + +- Updates all package.json `tarballHash` +- List all files that are different from the most recent published files. + +Diff: admin diff +---------------- + +- Updates all package.json `tarballHash` +- List all diffs between the local files and the most recent published files. + +Add Source: admin add-source +---------------------------- + +- Stages all changed files which are library source files + +Add Dist: admin add-dist +------------------------ + +- Stages all changed files which are dist files + + +Update Dependency Graph: admin/cmds/update-depgraph +--------------------------------------------------- + +This is run as part of `npm run bootstrap` before running lerna bootstrap. +It recomputes the dependency graph and writes out the ordered +**tsconfig.project.json** + + +Update Versions: admin/cmds/update-versions +------------------------------------------- + +Run using the `npm run update-versions`, which also cleans, bootstraps and +rebuilds the project. + +For each package that has changed from the version in NPM (the published +tarballs are compared): + +- Update the `version` in the **package.json** +- Update the **src.ts/_version.js** (matches the **package.json**) +- Updates the `tarballHash` in the **package.json** +- Compiles the TypeScript (which updates the **_version.js** and **_version.d.js**) +- Lists all changed files + + +Publish: admin/cmds/publish +---------------------------- + +Run using `node admin/cmds/publish`. + +- Publish (in dependency order) changed files to NPM +- The `gitHead` is updated in **only** the NPM **package.json** + diff --git a/admin/build.js b/admin/build.js new file mode 100644 index 000000000..9e912a0fa --- /dev/null +++ b/admin/build.js @@ -0,0 +1,61 @@ +"use strict"; + +const fs = require("fs"); +const resolve = require("path").resolve; +const spawn = require("child_process").spawn; + +const local = require("./local"); + +function run(progname, args, ignoreErrorStream) { + return new Promise((resolve, reject) => { + const proc = spawn(progname, args); + + let stdout = Buffer.from([]); + let stderr = Buffer.from([]); + + proc.stdout.on("data", (data) => { + stdout = Buffer.concat([ stdout, data ]); + }); + + proc.stderr.on("data", (data) => { + stderr = Buffer.concat([ stdout, data ]); + }); + + proc.on("error", (error) => { + console.log("ERROR"); + console.log(stderr.toString()); + error.stderr = stderr.toString(); + error.stdout = stdout.toString(); + reject(error); + }); + + proc.on("close", (code) => { + if ((stderr.length && !ignoreErrorStream) || code !== 0) { + console.log("ERROR"); + console.log(stderr.toString()); + + let error = new Error("stderr not empty"); + error.stderr = stderr.toString(); + error.stdout = stdout.toString(); + error.statusCode = code; + reject(error); + } else { + resolve(stdout.toString()); + } + }); + }); +} + +function runBuild() { + return run("npx", [ "tsc", "--build", resolve(__dirname, "../tsconfig.project.json") ]); +} + +function runDist() { + return run("npx", [ "lerna", "run", "dist" ], true); +} + +module.exports = { + run: run, + runDist: runDist, + runBuild: runBuild +}; diff --git a/admin/changelog.js b/admin/changelog.js new file mode 100644 index 000000000..ec6d7bd68 --- /dev/null +++ b/admin/changelog.js @@ -0,0 +1,101 @@ +"use strict"; + +const fs = require("fs"); +const resolve = require("path").resolve; + +const git = require("./git"); +const local = require("./local"); +const utils = require("./utils"); + +async function generate() { + + let version = local.loadPackage("ethers").version; + let latest = await git.getLatestTag(); + let date = utils.today(); + let ethersVersion = "ethers/" + version; + let log = await git.run([ "log", "--format=%B", (latest + "..") ]) + + let existing = fs.readFileSync(resolve(__dirname, "../CHANGELOG.md")).toString().split("\n"); + + let sections = [ [ ] ]; + + for (let i = 0; i < existing.length; i++) { + let line = existing[i]; + let lastSection = sections[sections.length - 1]; + if (line.substring(0, 3) === "---" || line.substring(0, 3) === "===") { + sections.push([ lastSection.pop(), line ]) + } else { + lastSection.push(line); + } + } + + // Snip off the dummy first section + sections.shift(); + + let output = [ ]; + + let addSection = (section) => { + + // Add the header with the same underline style + let header = section[0]; + output.push(header); + output.push(utils.repeat(section[1], header.length)); + + // Add gap before body + output.push(""); + + // For each line, properly indent it (the root body does not get indented) + section.slice(2).forEach((line) => { + line = line.trim(); + if (line === "") { return; } + if (header.trim().toLowerCase() !== "changelog") { + if (line.substring(0, 1) !== "*") { + line = " " + line; + } + line = " " + line; + } + output.push(line); + }); + + // Add gap after body + output.push(""); + } + + let newSection = []; + { + let header = "ethers/" + version + " (" + date + ")"; + newSection.push(header); + newSection.push(utils.repeat("-", header.length)); + log.split("\n").forEach((line) => { + line = line.trim(); + if (line === "") { return; } + newSection.push(" * " + line); + }); + } + + sections.forEach((section) => { + let header = section[0].split(" "); + + // Check if this is the current version, we may need to update + if (header.length === 2) { + // This new section obsoletes the old new section... + if (header[0] === ethersVersion) { + addSection(newSection); + newSection = null; + return; + + // Put the new section before any old sections + } else if (newSection) { + addSection(newSection); + } + } + + addSection(section); + }); + + return output.join("\n") + "\n"; +} + +module.exports = { + generate: generate +} diff --git a/admin/cmds/publish.js b/admin/cmds/publish.js new file mode 100644 index 000000000..8589c2568 --- /dev/null +++ b/admin/cmds/publish.js @@ -0,0 +1,92 @@ +"use strict"; + +const config = require("../config"); + +const { getOrdered, loadPackage } = require("../depgraph"); +const { getPackageVersion, publish } = require("../npm"); +const { log } = require("../log"); + +const USER_AGENT = "ethers-dist@0.0.0"; +const TAG = "next"; + +let dirnames = getOrdered(); + +// Only publish specific packages +if (process.argv.length > 2) { + let filter = process.argv.slice(2); + + // Verify all named packages exist + filter.forEach((dirname) => { + try { + loadPackage(dirname); + } catch (error) { + console.log("Package not found: " + dirname); + process.exit(1); + } + }); + + // Filter out pacakges we don't care about + dirnames = dirnames.filter((dirname) => (filter.indexOf(dirname) >= 0)); +} + +(async function() { + let token = null; + + // @TODO: Fail if there are any untracked files or unchecked in files + + // Load the token from the encrypted store + try { + token = await config.get("token"); + } catch (error) { + switch (error.message) { + case "wrong password": + log(""); + break; + case "cancelled": + break; + default: + console.log(error); + } + + log(""); + + return; + } + + token = token.trim().split("="); + + let options = { + npmVersion: USER_AGENT, + tag: TAG + }; + + // Set the authentication token + options[token[0]] = token[1]; + + for (let i = 0; i < dirnames.length; i++) { + let dirname = dirnames[i]; + + if (dirname === "ethers") { + options.tag = "next"; + } else { + options.tag = "latest"; + } + + let info = loadPackage(dirname); + let npmInfo = await getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { version: "NEW" }; } + + if (info.tarballHash === npmInfo.tarballHash) { continue; } + + log(` ${info.name}...`); + log(` ${npmInfo.version} > ${info.version}`); + + let success = await publish(dirname, options); + if (!success) { + log(" "); + return; + } + log(" "); + } + +})(); diff --git a/admin/cmds/update-depgraph.js b/admin/cmds/update-depgraph.js new file mode 100644 index 000000000..618fbe38f --- /dev/null +++ b/admin/cmds/update-depgraph.js @@ -0,0 +1,16 @@ +"use stricT"; + +const depgraph = require("../depgraph"); +const { log } = require("../log"); +const { loadJson, resolve, saveJson } = require("../utils"); + +(async function() { + log(``); + let ordered = depgraph.getOrdered(true); + + let path = resolve("tsconfig.project.json") + + let projectConfig = loadJson(path); + projectConfig.references = ordered.map((name) => ({ path: ("./packages/" + name) })); + saveJson(path, projectConfig); +})(); diff --git a/admin/cmds/update-versions.js b/admin/cmds/update-versions.js new file mode 100644 index 000000000..6b3c935fa --- /dev/null +++ b/admin/cmds/update-versions.js @@ -0,0 +1,131 @@ +"use strict"; + +// Expected this to be run after +// - npm run clean +// - npm run bootstrap +// - npm run build + +const fs = require("fs"); + +const semver = require("semver"); + +const { runBuild, runDist } = require("../build"); +const { getOrdered, loadPackage } = require("../depgraph"); +const { getDiff, getGitTag } = require("../git"); +const { updatePackage } = require("../local"); +const { getPackageVersion } = require("../npm"); +const { resolve } = require("../utils"); +const { colorify, log } = require("../log"); + +const { getProgressBar } = require("../../packages/cli/prompt"); + +let dirnames = getOrdered(); + +// Only publish specific packages +if (process.argv.length > 2) { + let filter = process.argv.slice(2); + + // Verify all named packages exist + filter.forEach((dirname) => { + try { + loadPackage(dirname); + } catch (error) { + console.log("Package not found: " + dirname); + process.exit(1); + } + }); + + // Filter out pacakges we don't care about + dirnames = dirnames.filter((dirname) => (filter.indexOf(dirname) >= 0)); +} + +(async function() { + let progress = getProgressBar(colorify("Updating versions", "bold")); + + for (let i = 0; i < dirnames.length; i++) { + progress(i / dirnames.length); + + let dirname = dirnames[i]; + let path = resolve("packages", dirname); + + // Get local package.json (update the tarballHash) + let info = await updatePackage(dirname); + + // Get the remote package.json (or sub in a placeholder for new pacakges) + let npmInfo = await getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { version: "NEW" }; } + + if (info.tarballHash === npmInfo.tarballHash) { continue; } + + // Bump the version if necessary + if (info.version === npmInfo.version) { + let newVersion = semver.inc(info.version, "prerelease", "beta"); + + // Write out the _version.ts + if (!info._ethers_nobuild) { + let code = "export const version = " + JSON.stringify(newVersion) + ";\n"; + fs.writeFileSync(resolve(path, "src.ts/_version.ts"), code); + } + + // Update the package.json (we do this after _version, so if we fail, + // this remains old; which is what triggers the version bump) + info = await updatePackage(dirname, { version: newVersion }); + } + } + progress(1); + + try { + log(""); + await runBuild(); + log(""); + let content = await runDist(); + console.log(content); + } catch (error) { + console.log(error); + log(""); + return; + } + + // Update the tarball hash now that _version and package.json may have changed. + progress = getProgressBar(colorify("Updating tarballHash", "bold")); + for (let i = 0; i < dirnames.length; i++) { + progress(i / dirnames.length); + await updatePackage(dirnames[i]); + } + progress(1); + + // Show the changed files (compared to npm) + for (let i = 0; i < dirnames.length; i++) { + let dirname = dirnames[i]; + + // Get local package.json + let info = await loadPackage(dirname); + let path = resolve("packages/", dirname); + + // Get the remote package.json (or sub in a placeholder for new pacakges) + let npmInfo = await getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { version: "NEW" }; } + + // No change + if (info.tarballHash === npmInfo.tarballHash) { continue; } + + let gitHead = await getGitTag(path); + + log(`: ${info.name}`); + log(` (bumping version)`); + log(` ${npmInfo.version} => ${info.version}`) + log(` `); + let filenames = await getDiff(path, npmInfo.gitHead, true); + filenames.forEach((filename) => { + let short = filename.split("/").slice(1).join("/"); + if (short.indexOf("/src.ts/") >= 0 || short.indexOf("/dist/") >= 0) { + log(` `); + } else { + log(` ${short}`); + } + }); + log(""); + } + + +})(); diff --git a/admin/config.js b/admin/config.js new file mode 100644 index 000000000..5d894c76c --- /dev/null +++ b/admin/config.js @@ -0,0 +1,87 @@ +"use strict"; + +const fs = require("fs"); +const os = require("os"); +const resolve = require("path").resolve; + +const AES = require("aes-js"); +const scrypt = require("scrypt-js"); + +const prompt = require("../packages/cli/prompt"); +const randomBytes = require("../packages/random").randomBytes; +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); } + }); + }); +} + +async function loadConfig(dkey) { + let config = { }; + + 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); + if (hmac !== data.hmac) { + throw new Error("wrong password"); + } + config = JSON.parse(Buffer.from(plaintext).toString()); + } + + return config; +} + +async function getConfig(key) { + let password = await prompt.getPassword(colorify("Password (seesion-store): ", "bold")); + let dkey = await getScrypt(colorify("Decrypting", "bold"), password, key); + + let config = await loadConfig(dkey); + return config[key]; +} + +async function setConfig(key, value) { + let password = await prompt.getPassword(colorify("Password (seesion-store): ", "bold")); + let dkey = await getScrypt("Encrypting", password, key); + + 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 = { + ciphertext: ciphertext.toString("base64"), + iv: iv.toString("base64"), + hmac: hmac + }; + + fs.writeFileSync(getConfigFilename(), JSON.stringify(data, null, 2)); +} + +module.exports = { + get: getConfig, + set: setConfig +} diff --git a/admin/depgraph.js b/admin/depgraph.js new file mode 100644 index 000000000..42b887f60 --- /dev/null +++ b/admin/depgraph.js @@ -0,0 +1,94 @@ +"use strict"; + +const fs = require("fs"); + +const { loadJson, resolve } = require("./utils"); + +const ROOT = resolve("packages"); + +const dirnames = fs.readdirSync(ROOT); + +function loadPackage(dirname) { + return loadJson(resolve("packages", dirname, "package.json")); +} + +function getOrdered(skipNobuild) { + let packages = { }; + let filenames = { }; + + let addDeps = (name, depends) => { + Object.keys(depends).forEach((dep) => { + // Not a package we manage + if (packages[dep] == null) { return; } + deps[name][dep] = true; + }); + } + + for (let i = 0; i < dirnames.length; i++) { + let dirname = dirnames[i]; + let info = loadPackage(dirname); + if (skipNobuild && info._ethers_nobuild) { continue; } + packages[info.name] = info; + filenames[info.name] = dirname; + } + + // Maps names to list of dependencies; { [ name:string]: Array } + let deps = { }; + let depGraph = { }; + + Object.keys(packages).forEach((name) => { + let info = packages[name]; + deps[info.name] = { }; + addDeps(info.name, info.dependencies || { }); + addDeps(info.name, info.devDependencies || { }); + deps[info.name] = Object.keys(deps[info.name]); + deps[info.name].sort(); + }); + + let ordered = [ ]; + let remaining = Object.keys(deps); + + let isSatisfied = (name) => { + for (let i = 0; i < deps[name].length; i++) { + if (ordered.indexOf(deps[name][i]) === -1) { return false; } + } + return true; + } + + while (remaining.length) { + let bail = true; + for (let i = 0; i < remaining.length; i++) { + if (!isSatisfied(remaining[i])) { continue; } + bail = false; + ordered.push(remaining[i]); + remaining.splice(i, 1); + break; + } + + if (bail) { + throw new Error("Nothing processed; circular dependencies..."); + } + } + + return ordered.map((name) => filenames[name]); +} + +function sort(dirnames) { + let ordered = getOrdered(); + dirnames.sort((a, b) => { + let ai = ordered.indexOf(local.loadPackage(a).name); + let bi = ordered.indexOf(local.loadPackage(b).name); + if (ai === -1 || bi === -1) { + throw new Error("unknown dirname - " + [a, b].join(", ")); + } + return ai - bi; + }); +} + +module.exports = { + dirnames: dirnames, + getOrdered: getOrdered, + loadPackage: loadPackage, + ROOT: ROOT, + sort: sort +} diff --git a/admin/git.js b/admin/git.js new file mode 100644 index 000000000..0582ad16b --- /dev/null +++ b/admin/git.js @@ -0,0 +1,173 @@ +"use strict"; + +const resolve = require("path").resolve; +const spawn = require("child_process").spawn; + +const semver = require("semver"); + +const { run } = require("./build"); +const { loadPackage } = require("./local"); + +function git(args) { + return run("git", args); +} + +function getStatus(filename) { + return git([ "status", "-s", resolve(__dirname, "..", filename) ]).then((result) => { + result = result.trim(); + if (result === "") { return "unmodified"; } + switch (result.substring(0, 2)) { + case 'M ': return "modified"; + case 'A ': return "added"; + case 'D ': return "deleted"; + case 'R ': return "renamed"; + case 'C ': return "copied"; + case 'U ': return "updated"; + case '??': return "untracked"; + } + console.log(result); + return "unknown"; + }); +} + +async function getChanges(latest) { + let diff = await git(["diff", "--name-only", latest ]); + + // Map dirname => { dist: [ ], src: [ ] } + let changes = { "_": { filename: "_", dist: [], src: [] } }; + + diff.split("\n").forEach((line) => { + // e.g. packages/constants/index.d.ts + let comps = line.trim().split("/"); + + // Track non-packages as dist + if (comps.length < 2 || comps[0] !== "packages") { + let filename = comps.join("/").trim(); + if (filename === "") { return; } + changes._.dist.push(filename); + return; + } + + let name = loadPackage(comps[1]).name; + + let change = changes[name]; + if (!change) { + change = { filename: comps[1], dist: [ ], src: [ ] } + changes[name] = change; + } + + // Split changes into source changes (src.ts/) or dist changes (output of TypeScript) + if (comps[2] === "src.ts") { + change.src.push(comps.join("/")); + } else { + change.dist.push(comps.join("/")); + } + }); + + return changes; +} + +function getLatestTag() { + let seq = Promise.resolve(); + + // @TODO: Pull + if (false) { + seq = seq.then(() => { + console.log("Pulling remote changes..."); + return git([ "pull" ]); + }); + } + + seq = seq.then(() => { + return git([ "tag" ]).then((tags) => { + tags = tags.split("\n").filter(tag => (tag.match(/^v[0-9]+\.[0-9]+\.[0-9]+\-/))); + tags.sort(semver.compare) + return tags.pop(); + }); + }); + + return seq; +} + +function findChanges(latest) { + let seq = Promise.resolve(); + + seq = seq.then(() => { + return git(["diff", "--name-only", latest, "HEAD" ]).then((result) => { + let filenames = { }; + result.split("\n").forEach((line) => { + // e.g. packages/constants/index.d.ts + let comps = line.trim().split("/"); + if (comps.length < 2) { return; } + filenames[comps[1]] = true; + }); + return Object.keys(filenames); + }); + }); + + seq = seq.then((filenames) => { + return filenames.map((filename) => { + let name = packages[filename].name; + return { + filename: filename, + name: name, + localVersion: getLocalVersion(name), + } + }); + }); + + seq = seq.then((packages) => { + let seq = Promise.resolve(); + packages.forEach((p) => { + seq = seq.then(() => { + return getNpmVersion(p.name).then((version) => { + p.npmVersion = version; + }); + }); + }); + return seq.then(() => packages); + }); + return seq; +} + +async function getGitTag(filename) { + let result = await git([ "log", "-n", "1", "--", filename ]); + result = result.trim(); + if (!result) { return null; } + result = result.match(/^commit\s+([0-9a-f]{40})\n/i); + if (!result) { return null; } + return result[1]; +} + +async function getDiff(filename, tag, nameOnly) { + if (tag == null) { tag = "HEAD"; } + let cmd = [ "diff", "--name-only", tag, "--", filename ] + if (!nameOnly) { cmd.splice(1, 1); } + let result = await git(cmd); + result = result.trim(); + if (result === "") { return [ ]; } + return result.split("\n"); +} + +async function getUntracked(filename) { + let cmd = [ "ls-files", "-o", "--exclude-standard"]; + if (filename) { + cmd.push("--"); + cmd.push(filename); + } + let result = await git(cmd); + result = result.trim(); + if (result === "") { return [ ]; } + return result.split("\n"); +} + +module.exports = { + findChanges: findChanges, + getChanges: getChanges, + getDiff: getDiff, + getGitTag: getGitTag, + getLatestTag: getLatestTag, + getStatus: getStatus, + getUntracked: getUntracked, + run: git, +} diff --git a/admin/index.js b/admin/index.js new file mode 100644 index 000000000..3da0db121 --- /dev/null +++ b/admin/index.js @@ -0,0 +1,401 @@ +"use strict"; + +const fs = require("fs"); +const resolve = require("path").resolve; + +const diff = require("diff"); +const semver = require("semver"); + +const { getProgressBar, prompt } = require("../packages/cli/prompt"); + +const build = require("./build"); +const changelog = require("./changelog"); +const depgraph = require("./depgraph"); +const { colorify, colorifyStatus, log } = require("./log"); +const config = require("./config") +const git = require("./git"); +const local = require("./local"); +const npm = require("./npm"); +const utils = require("./utils"); + +/* +async function runChanged(dirnames, callback) { + try { + await callback(dirname, info, npmInfo); + } catch (error) { + console.log(error); + console.log(colorify("Aborting! " + error.message)); + return; + } + } + } +} +*/ +/* + if (diff) { + } else { +*/ + +async function runDiff(dirnames) { + // Default to all packages + if (dirnames == null || dirnames.length === 0) { dirnames = local.dirnames; } + + for (let i = 0; i < dirnames.length; i++) { + let dirname = dirnames[i]; + + // Get local (update the tarballHash) and remote package.json + let info = await local.loadPackage(dirname); + let npmInfo = await npm.getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { gitHead: "HEAD", version: "NEW" }; } + + let delta = await git.getDiff(resolve(__dirname, "../packages", dirname), npmInfo.gitHead); + + if (delta.length === 0) { continue; } + + // Bump the version if necessary + if (info.version === npmInfo.version) { + info.version = semver.inc(info.version, "prerelease", "beta"); + } + + console.log(colorify(": ") + info.name); + console.log(colorify(" (run update to bump version)")); + console.log(" " + npmInfo.gitHead) + console.log(" " + npmInfo.version + colorify(" => ", "bold") + info.version) + + console.log(colorify(" Diff", "bold")); + delta.forEach((line) => { + let color = "blue"; + switch (line.substring(0, 1)) { + case '+': + color = "green"; + break; + case '-': + color = "red"; + break; + case ' ': + color = "normal"; + break; + } + console.log(" " + colorify(line, color)); + }); + + console.log(""); + } + + console.log(""); +} + +async function updateChangelog() { + let filename = resolve(local.ROOT, "../CHANGELOG.md"); + + let lastVersion = await git.getLatestTag(); + let newVersion = "v" + local.getVersion("ethers"); + + let current = fs.readFileSync(filename).toString(); + let log = await changelog.generate(); + if (log === current) { return; } + + let changes = diff.createTwoFilesPatch("CHANGELOG-old.md", "CHANGELOG.md", current, log, lastVersion, newVersion); + console.log(changes); + + try { + let response = await prompt.getChoice(colorify("Accept changes?", "bold"), "yn", "n"); + if (response === "n") { throw new Error("Not changing."); } + } catch (error) { + console.log("Abort: " + error.message); + return; + } + + fs.writeFileSync(filename, log); +} + +// Updates the dependency-graph (tsconfig.project.json) so the build order is correct +async function runUpdateDepgraph() { + log(``); + let ordered = depgraph.getOrdered(); + + let path = resolve(local.ROOT, "../tsconfig.project.json") + + let projectConfig = local.loadJson(path); + projectConfig.references = ordered.map((name) => ({ path: ("./packages/" + name) })); + local.saveJson(path, projectConfig); +} + +async function runUpdate(dirnames) { + + // Check for untracked files... + let untracked = [ ]; + if (dirnames == null || dirnames.length === 0) { + dirnames = local.dirnames; + let filenames = await git.getUntracked(resolve(__dirname, "..")); + for (let i = 0; i < filenames.length; i++) { + untracked.push(filenames[i]); + } + } else { + for (let i = 0; i < dirnames.length; i++) { + let filenames = await git.getUntracked(resolve(local.ROOT, dirnames[i])); + for (let j = 0; j < filenames.length; j++) { + untracked.push(filenames[j]); + } + } + } + + // Untracked files! Abort. + if (untracked.length) { + log(""); + untracked.forEach((filename) => { + console.log(" " + filename); + }); + log(""); + return; + } + + log(``); + await build.runBuild() + + log(""); + + // @TODO: Root + + // Update all the package.json and _version.ts + let progress = getProgressBar(colorify("Updating versions", "bold")); + for (let i = 0; i < dirnames.length; i++) { + progress(i / dirnames.length); + + let dirname = dirnames[i]; + let path = resolve(__dirname, "../packages/", dirname); + + // Get local package.json (update the tarballHash) + let info = await local.updatePackage(dirname); + + // Get the remote package.json (or sub in a placeholder for new pacakges) + let npmInfo = await npm.getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { version: "NEW" }; } + + if (info.tarballHash === npmInfo.tarballHash) { continue; } + + // Bump the version if necessary + if (info.version === npmInfo.version) { + let newVersion = semver.inc(info.version, "prerelease", "beta"); + + // Write out the _version.ts + if (!info._ethers_skipPrepare) { + let code = "export const version = " + JSON.stringify(newVersion) + ";\n"; + fs.writeFileSync(resolve(path, "src.ts/_version.ts"), code); + } + + // Update the package.json (we do this after _version, so if we fail, + // this remains old; which is what triggers the version bump) + info = await local.updatePackage(dirname, { version: newVersion }); + } + } + progress(1); + + // Build the TypeScript sources + log(""); + try { + await build.runTsc(); + } catch (error) { + console.log(error); + log(""); + return; + } + + // Run the dist + // @TODO: + + // Update the tarball hash now that _version and package.json may have changed. + progress = getProgressBar(colorify("Updating tarballHash", "bold")); + for (let i = 0; i < dirnames.length; i++) { + progress(i / dirnames.length); + await local.updatePackage(dirnames[i]); + } + progress(1); + + // Show the changed files (compared to npm) + for (let i = 0; i < dirnames.length; i++) { + let dirname = dirnames[i]; + + // Get local package.json + let info = await local.loadPackage(dirname); + let path = resolve(__dirname, "../packages/", dirname); + + // Get the remote package.json (or sub in a placeholder for new pacakges) + let npmInfo = await npm.getPackageVersion(info.name); + if (!npmInfo) { npmInfo = { version: "NEW" }; } + + // No change + if (info.tarballHash === npmInfo.tarballHash) { continue; } + + let gitHead = await git.getGitTag(path); + + log(`: ${info.name}`); + log(` (bumping version)`); + log(` ${npmInfo.version} => ${info.version}`) + log(` `); + let filenames = await git.getDiff(resolve(__dirname, "../packages", dirname), npmInfo.gitHead, true); + filenames.forEach((filename) => { + let short = filename.split("/").slice(1).join("/"); + if (short.indexOf("/src.ts/") >= 0) { + log(` `); + } else { + log(` ${short}`); + } + }); + log(""); + } + + // @TODO: Changelog + await updateChangelog(); +} + +async function runAdd(type, names) { + let latest = await git.getLatestTag(); + console.log(""); + console.log(colorify(": ") + latest); + console.log(""); + + let changes = await git.getChanges("HEAD"); + + if (!names || names.length === 0) { + names = Object.keys(changes); + } + + let filenames = [ ]; + for (let i = 0; i < names.length; i++) { + let name = names[i]; + let change = changes[name] || changes[(packages[name] || {}).name]; + if (!change) { return; } + change[type].forEach((filename) => { + filenames.push(filename); + }); + } + + if (filenames.length === 0) { + console.log(colorify("")); + console.log(""); + return; + } + + for (let i = 0; i < filenames.length; i++) { + let filename = filenames[i]; + let status = await git.getStatus(filename); + console.log(" " + colorifyStatus(status) + ": " + utils.repeat(" ", 10 - status.length) + filename); + } + + console.log(""); + + try { + let response = await prompt.getChoice(colorify("Add these files?", "bold"), "yn", "n"); + if (response === "n") { throw new Error("Not adding."); } + } catch (error) { + console.log("Abort: " + error.message); + return; + } + + let params = filenames.map((f) => f); //resolve(ROOT, f)); + params.unshift("--"); + params.unshift("add"); + + console.log("git " + params.join(" ")); + + try { + await git.run(params); + } catch (error) { + console.log("Error: (status: " + error.code + ")"); + console.log(" " + error.stderr); + return; + } + + console.log("Added."); +} + +function runDist() { + // Run npm dist + // Generate changelog + // run status to update all the package + // add dist files? +} + +async function runPublish(dirnames) { + + // @TODO: Make sure there are no staged files + + // @TODO: Make sure the repo has been pushed + + // @TODO: Run the publish in the correct order + + // Get the authentication token from our encrypted store + let token = await config.get("token"); + token = token.trim().split("="); + + let options = { + npmVersion: "ethers-dist@0.0.0", + tag: "next" + }; + + // Set the authentication token + options[token[0]] = token[1]; + + if (dirnames == null || dirnames.length === 0) { dirnames = local.dirnames; } + depgraph.sort(dirnames); + + await runChanged(dirnames, async (dirname, info, npmInfo) => { + console.log(colorify(" ") + info.name + "...") + console.log(colorify(" Version: ", "blue") + npmInfo.version + colorify(" => ", "bold") + info.version); + + let success = await npm.publish(dirname, options); + if (!success) { + console.log(colorify(" ")); + throw new Error(""); + } + console.log(colorify(" ")); + }); +} + +async function runTest() { + let r = await git([ "tag", "--porcelain", "-a", "-m", "Title of Release\n\nHello\n-----\n\nTesting 4 **bold** #1\nHello World", "test6", "HEAD" ]); + console.log(r); + try { + r = await git([ "push", "--tags" ]) + } catch(e) { console.log(e); } + console.log(r); +} + +(function() { + let args = process.argv.slice(2); + switch (args[0]) { + + // Compare published to current stage + case "diff": + return runDiff(args.slice(1)); + + // Add unchecked-in source files + case "add-source": + return runAdd("src", args.slice(1)); + + // Update all package.json. the changelog and dist files + case "update": + return runUpdate(args.slice(1)); + + // Update dependency graph (./tsconfig-project.json) + case "update-depgraph": + return runUpdateDepgraph(); + + // Add unchecked-in dist files + case "add-dist": + return runAdd("dist", args.slice(1)); + + + // Add unchecked-in source files + case "changelog": + return updateChangelog(); + + // Add unchecked-in source files + case "publish": + return runPublish(args.slice(1)); + + case "test": + return runTest(); + } +})(); diff --git a/admin/local.js b/admin/local.js new file mode 100644 index 000000000..415951cf2 --- /dev/null +++ b/admin/local.js @@ -0,0 +1,80 @@ +"use strict"; + +const packlist = require("npm-packlist"); +const tar = require("tar"); +const keccak256 = require("../packages/keccak256").keccak256; +const { dirnames, loadPackage, ROOT } = require("./depgraph"); +const { resolve, saveJson } = require("./utils"); + +function savePackage(dirname, info) { + return saveJson(resolve(ROOT, dirname, "package.json"), info); +} + +async function createTarball(dirname) { + let base = resolve(ROOT, dirname); + + // From NPM publish, create the packed version + let files = await packlist({ path: base }); + files = files.map((f) => ("./" + f)); + + let options = { + cwd: base, + prefix: 'package/', + portable: true, + sync: true, + // Provide a specific date in the 1980s for the benefit of zip, + // which is confounded by files dated at the Unix epoch 0. + mtime: new Date('1985-10-26T08:15:00.000Z'), + gzip: true + }; + + // Take the hash of the package sans + return tar.create(options, files).read(); +} + +async function updatePackage(dirname, values) { + let info = loadPackage(dirname); + + if (values) { + for (let key in values) { + info[key] = values[key]; + } + } + /* + ["dependencies", "devDependencies"].forEach((key) => { + let deps = info[key] || []; + for (let name in deps) { + if (name.substring(0, "@ethersproject".length) === "@ethersproject" || name === "ethers") { + deps[name] = ">5.0.0-beta.0"; + } + } + }); + */ + + //if (dirname !== "ethers") { + // delete info.publishConfig.tag; + //} + + // Create a normalized version sans tarballHash to compute the tarballHash + delete info.tarballHash; + savePackage(dirname, info); + + // Compute the tarballHash + let tarball = await createTarball(dirname); + info.tarballHash = keccak256(tarball); + + // Save the updated package.json to disk + savePackage(dirname, info); + + return info; +} + +module.exports = { + ROOT: ROOT, + createTarball: createTarball, + dirnames: dirnames, + getVersion: function(dirname) { return ((loadPackage(dirname) || {}).version || null); }, + loadPackage: loadPackage, + savePackage: savePackage, + updatePackage: updatePackage, +} diff --git a/admin/log.js b/admin/log.js new file mode 100644 index 000000000..c740f26ff --- /dev/null +++ b/admin/log.js @@ -0,0 +1,53 @@ +"use strict"; + +function getColor(color) { + if (!color || color === "normal") { return "\x1b[0m"; } + return "\x1b[1m" + ({ + blue: "\x1b[34m", + cyan: "\x1b[36m", + green: "\x1b[32m", + magenta: "\x1b[35m", + red: "\x1b[31m", + yellow: "\x1b[33m", + bold: "" + })[color]; +} + +// See: https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color +let disableColor = !(process.stdout.isTTY); +function colorify(message, color) { + if (color) { + if (disableColor) { return message; } + return getColor(color) + message + getColor(); + } + + return message.replace(/<([^:]*):((?:[^<>\\]|\\.)*)>/g, (all, color, message) => { + message = message.replace("\\>", ">"); + if (disableColor) { return message; } + return getColor(color) + message + getColor(); + }); +} + +function colorifyStatus(status) { + switch (status) { + case "modified": return colorify(""); + case "added": return colorify(""); + case "deleted": return colorify(""); + case "unmodified": return colorify(""); + } + return status; +} + +function log(message, color) { + if (color) { + console.log(colorify(message, color)); + } else { + console.log(colorify(message)); + } +} + +module.exports = { + colorify: colorify, + colorifyStatus: colorifyStatus, + log: log +} diff --git a/admin/npm.js b/admin/npm.js new file mode 100644 index 000000000..06824ddb4 --- /dev/null +++ b/admin/npm.js @@ -0,0 +1,104 @@ +"use strict"; + +const resolve = require("path").resolve; + +const npm = require("libnpm"); +const semver = require("semver"); + +const local = require("./local"); + +const keccak256 = require("../packages/keccak256").keccak256; +const fetchJson = require("../packages/web").fetchJson; +const prompt = require("../packages/cli/prompt"); + +const colorify = require("./log").colorify; +const git = require("./git"); + + +let cache = { }; + +async function getPackage(name) { + if (cache[name]) { return cache[name]; } + + return fetchJson("http:/" + "/registry.npmjs.org/" + name).then((result) => { + cache[name] = result; + return result; + }, (error) => { + if (error.statusCode === 404) { + return null; + } + throw error; + }); +} + +async function getVersion(name) { + return getPackage(name).then((result) => { + if (!result) { return null; } + let versions = Object.keys(result.versions); + versions.sort(semver.compare) + return versions.pop(); + }); +} + +async function getPackageVersion(name, version) { + let info = await getPackage(name) + if (!info) { return null; } + + if (version == null) { + let versions = Object.keys(info.versions); + versions.sort(semver.compare); + version = versions.pop(); + } + + return info.versions[version] || null; +} + +async function getTarballHash(name, version) { + let info = await getPackageVersion(name, version); + return (info || {}).tarballHash; +} + +async function _publish(info, tarball, options) { + try { + let result = await npm.publish(info, tarball, options); + return result; + } catch (error) { + + // We need an OTP + if (error.code === "EOTP") { + try { + let otp = await prompt.getMessage(colorify("Enter OTP: ", "bold")); + options.otp = otp.replace(" ", ""); + } catch (error) { + + // CTRL-C + if (error.message === "cancelled") { + return false; + } + + // Something unexpected... + throw error; + } + + // Retry with the new OTP + return _publish(info, tarball, options); + } + throw error; + } +} + +async function publish(dirname, options) { + let info = local.loadPackage(dirname); + info.gitHead = await git.getGitTag(resolve(__dirname, "../packages/", dirname)); + if (info.gitHead == null) { throw new Error("no git tag found - " + dirname); } + let tarball = await local.createTarball(dirname); + return _publish(info, tarball, options); +} + +module.exports = { + getPackage: getPackage, + getPackageVersion: getPackageVersion, + getTarballHash: getTarballHash, + getVersion: getVersion, + publish: publish, +}; diff --git a/admin/utils.js b/admin/utils.js new file mode 100644 index 000000000..9979cfcca --- /dev/null +++ b/admin/utils.js @@ -0,0 +1,47 @@ +"use strict"; + +const fs = require("fs"); +const _resolve = require("path").resolve; + +function repeat(chr, length) { + let result = chr; + while (result.length < length) { result += chr; } + return result; +} + +function zpad(value) { + value = String(value); + while (value.length < 2) { value = "0" + value; } + return value; +} + +function today() { + let now = new Date(); + return [ now.getFullYear(), zpad(now.getMonth() + 1), zpad(now.getDate()) ].join("-"); +} + +function loadJson(filename) { + return JSON.parse(fs.readFileSync(filename).toString()); +} + +// @TODO: atomic write +function saveJson(filename, json) { + fs.writeFileSync(filename, JSON.stringify(json, null, 2) + "\n"); +} + +function resolve(...args) { + args = args.slice(); + args.unshift(".."); + args.unshift(__dirname); + return _resolve.apply(null, args); +} + +module.exports = { + resolve: resolve, + + loadJson: loadJson, + saveJson: saveJson, + + repeat: repeat, + today: today +} diff --git a/lerna.json b/lerna.json new file mode 100644 index 000000000..a2bb50ba7 --- /dev/null +++ b/lerna.json @@ -0,0 +1,6 @@ +{ + "packages": [ + "packages/*" + ], + "version": "independent" +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..c4b533ac7 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "root", + "private": true, + "scripts": { + "auto-build": "npm run build -- -w", + "bootstrap": "node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", + "build": "tsc --build ./tsconfig.project.json", + "clean": "tsc --build --clean ./tsconfig.project.json", + "_dist": "npm run clean && npm run bootstrap && npm run build && lerna run dist", + "test": "npm run _dist && npm run test-check", + "test-check": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", + "test-node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", + "test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js", + "test-aion": "npm run dist && npm run test-aion-node", + "test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", + "update-versions": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-versions", + "publish-all": "node ./admin/cmds/publish" + }, + "devDependencies": { + "@types/assert": "^1.4.1", + "@types/mocha": "^5.2.0", + "aes-js": "3.0.0", + "browserify": "16.2.3", + "diff": "4.0.1", + "npm-packlist": "1.4.1", + "lerna": "^3.13.0", + "libnpm": "2.0.1", + "mocha": "^5.2.0", + "mocha-phantomjs-core": "2.1.2", + "scrypt-js": "2.0.4", + "semver": "^5.6.0", + "tar": "4.4.8", + "typescript": "^3.3.3" + } +} diff --git a/packages/abi/.npmignore b/packages/abi/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/abi/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/abi/LICENSE.md b/packages/abi/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/abi/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/abi/README.md b/packages/abi/README.md new file mode 100644 index 000000000..c3c158183 --- /dev/null +++ b/packages/abi/README.md @@ -0,0 +1,17 @@ +Ethereum ABI Coder +================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/abi/package.json b/packages/abi/package.json new file mode 100644 index 000000000..9a874dfcc --- /dev/null +++ b/packages/abi/package.json @@ -0,0 +1,30 @@ +{ + "name": "@ethersproject/abi", + "version": "5.0.0-beta.128", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/hash": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xd6298eed7cb50f08154591d43a324a68220ce97b92ab6f44d2015437688def09" +} diff --git a/packages/abi/src.ts/_version.ts b/packages/abi/src.ts/_version.ts new file mode 100644 index 000000000..d25e399bf --- /dev/null +++ b/packages/abi/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.128"; diff --git a/packages/abi/src.ts/abi-coder.ts b/packages/abi/src.ts/abi-coder.ts new file mode 100644 index 000000000..24d9d99a9 --- /dev/null +++ b/packages/abi/src.ts/abi-coder.ts @@ -0,0 +1,124 @@ +"use strict"; + +// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI + +import { arrayify, BytesLike } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly } from "@ethersproject/properties"; + +import { Coder, Reader, Writer } from "./coders/abstract-coder"; +import { AddressCoder } from "./coders/address"; +import { ArrayCoder } from "./coders/array"; +import { BooleanCoder } from "./coders/boolean"; +import { BytesCoder } from "./coders/bytes"; +import { FixedBytesCoder } from "./coders/fixed-bytes"; +import { NullCoder } from "./coders/null"; +import { NumberCoder } from "./coders/number"; +import { StringCoder } from "./coders/string"; +import { TupleCoder } from "./coders/tuple"; + +import { ParamType } from "./fragments"; + + +const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); +const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); + + +export type CoerceFunc = (type: string, value: any) => any; + +export class AbiCoder { + readonly coerceFunc: CoerceFunc; + + constructor(coerceFunc?: CoerceFunc) { + errors.checkNew(new.target, AbiCoder); + defineReadOnly(this, "coerceFunc", coerceFunc || null); + } + + _getCoder(param: ParamType): Coder { + + switch (param.baseType) { + case "address": + return new AddressCoder(param.name); + case "bool": + return new BooleanCoder(param.name); + case "string": + return new StringCoder(param.name); + case "bytes": + return new BytesCoder(param.name); + case "array": + return new ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new TupleCoder((param.components || []).map((component) => { + return this._getCoder(component); + }), param.name); + case "": + return new NullCoder(param.name); + } + + // u?int[0-9]* + let match = param.type.match(paramTypeNumber); + if (match) { + let size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || (size % 8) !== 0) { + errors.throwError("invalid " + match[1] + " bit length", errors.INVALID_ARGUMENT, { + arg: "param", + value: param + }); + } + return new NumberCoder(size / 8, (match[1] === "int"), param.name); + } + + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + let size = parseInt(match[1]); + if (size === 0 || size > 32) { + errors.throwError("invalid bytes length", errors.INVALID_ARGUMENT, { + arg: "param", + value: param + }); + } + return new FixedBytesCoder(size, param.name); + } + + return errors.throwError("invalid type", errors.INVALID_ARGUMENT, { + arg: "type", + value: param.type + }); + } + + _getWordSize(): number { return 32; } + + _getReader(data: Uint8Array): Reader { + return new Reader(data, this._getWordSize(), this.coerceFunc); + } + + _getWriter(): Writer { + return new Writer(this._getWordSize()); + } + + encode(types: Array, values: Array): string { + if (types.length !== values.length) { + errors.throwError("types/values length mismatch", errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types: types, values: values } + }); + } + + let coders = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = (new TupleCoder(coders, "_")); + + let writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + } + + decode(types: Array, data: BytesLike): any { + let coders: Array = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = new TupleCoder(coders, "_"); + return coder.decode(this._getReader(arrayify(data))); + } +} + +export const defaultAbiCoder: AbiCoder = new AbiCoder(); + diff --git a/packages/abi/src.ts/coders/abstract-coder.ts b/packages/abi/src.ts/coders/abstract-coder.ts new file mode 100644 index 000000000..00e5a332c --- /dev/null +++ b/packages/abi/src.ts/coders/abstract-coder.ts @@ -0,0 +1,161 @@ +"use trict"; + +import { arrayify, BytesLike, concat, hexlify } from "@ethersproject/bytes"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly } from "@ethersproject/properties"; + +export type CoerceFunc = (type: string, value: any) => any; + +export abstract class Coder { + + // The coder name: + // - address, uint256, tuple, array, etc. + readonly name: string; + + // The fully expanded type, including composite types: + // - address, uint256, tuple(address,bytes), uint256[3][4][], etc. + readonly type: string; + + // The localName bound in the signature, in this example it is "baz": + // - tuple(address foo, uint bar) baz + readonly localName: string; + + // Whether this type is dynamic: + // - Dynamic: bytes, string, address[], tuple(boolean[]), etc. + // - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8) + readonly dynamic: boolean; + + constructor(name: string, type: string, localName: string, dynamic: boolean) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + + _throwError(message: string, value: any): void { + errors.throwError(message, errors.INVALID_ARGUMENT, { + argument: this.localName, + coder: this, + value: value + }); + } + + abstract encode(writer: Writer, value: any): number; + abstract decode(reader: Reader): any; +} + +export class Writer { + readonly wordSize: number; + + _data: Uint8Array; + _padding: Uint8Array; + + constructor(wordSize?: number) { + defineReadOnly(this, "wordSize", wordSize || 32); + this._data = arrayify([ ]); + this._padding = new Uint8Array(wordSize); + } + + get data(): string { return hexlify(this._data); } + get length(): number { return this._data.length; } + + _writeData(data: Uint8Array): number { + this._data = concat([ this._data, data ]); + return data.length; + } + + // Arrayish items; padded on the right to wordSize + writeBytes(value: BytesLike): number { + let bytes = arrayify(value); + if (bytes.length % this.wordSize) { + bytes = concat([ bytes, this._padding.slice(bytes.length % this.wordSize) ]) + } + return this._writeData(bytes); + } + + _getValue(value: BigNumberish): Uint8Array { + let bytes = arrayify(BigNumber.from(value)); + if (bytes.length > this.wordSize) { + errors.throwError("value out-of-bounds", errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = concat([ this._padding.slice(bytes.length % this.wordSize), bytes ]); + } + return bytes; + } + + // BigNumberish items; padded on the left to wordSize + writeValue(value: BigNumberish): number { + return this._writeData(this._getValue(value)); + } + + writeUpdatableValue(): (value: BigNumberish) => void { + let offset = this.length; + this.writeValue(0); + return (value: BigNumberish) => { + this._data.set(this._getValue(value), offset); + }; + } +} + +export class Reader { + readonly wordSize: number; + + readonly _data: Uint8Array; + readonly _coerceFunc: CoerceFunc; + + _offset: number; + + constructor(data: BytesLike, wordSize?: number, coerceFunc?: CoerceFunc) { + defineReadOnly(this, "_data", arrayify(data)); + defineReadOnly(this, "wordSize", wordSize || 32); + defineReadOnly(this, "_coerceFunc", coerceFunc); + + this._offset = 0; + } + + get data(): string { return hexlify(this._data); } + get consumed(): number { return this._offset; } + + // The default Coerce function + static coerce(name: string, value: any): any { + let match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { value = value.toNumber(); } + return value; + } + + coerce(name: string, value: any): any { + if (this._coerceFunc) { return this._coerceFunc(name, value); } + return Reader.coerce(name, value); + } + + _peekBytes(offset: number, length: number): Uint8Array { + let alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + errors.throwError("data out-of-bounds", errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength) + } + + subReader(offset: number): Reader { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + } + + readBytes(length: number): Uint8Array { + let bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + } + + readValue(): BigNumber { + return BigNumber.from(this.readBytes(this.wordSize)); + } +} diff --git a/packages/abi/src.ts/coders/address.ts b/packages/abi/src.ts/coders/address.ts new file mode 100644 index 000000000..efaf93a54 --- /dev/null +++ b/packages/abi/src.ts/coders/address.ts @@ -0,0 +1,27 @@ +"use strict"; + +import { getAddress } from "@ethersproject/address"; +import { hexZeroPad } from "@ethersproject/bytes"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +export class AddressCoder extends Coder { + + constructor(localName: string) { + super("address", "address", localName, false); + } + + encode(writer: Writer, value: string): number { + try { + getAddress(value); + } catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + } + + decode(reader: Reader): any { + return getAddress(hexZeroPad(reader.readValue().toHexString(), 20)); + } +} + diff --git a/packages/abi/src.ts/coders/anonymous.ts b/packages/abi/src.ts/coders/anonymous.ts new file mode 100644 index 000000000..59c99f6a9 --- /dev/null +++ b/packages/abi/src.ts/coders/anonymous.ts @@ -0,0 +1,21 @@ +"use strict"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +// Clones the functionality of an existing Coder, but without a localName +export class AnonymousCoder extends Coder { + private coder: Coder; + + constructor(coder: Coder) { + super(coder.name, coder.type, undefined, coder.dynamic); + this.coder = coder; + } + + encode(writer: Writer, value: any): number { + return this.coder.encode(writer, value); + } + + decode(reader: Reader): any { + return this.coder.decode(reader); + } +} diff --git a/packages/abi/src.ts/coders/array.ts b/packages/abi/src.ts/coders/array.ts new file mode 100644 index 000000000..6b066a222 --- /dev/null +++ b/packages/abi/src.ts/coders/array.ts @@ -0,0 +1,159 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; + +import { Coder, Reader, Writer } from "./abstract-coder"; +import { AnonymousCoder } from "./anonymous"; + +export function pack(writer: Writer, coders: Array, values: Array): number { + + if (Array.isArray(values)) { + // do nothing + + } else if (values && typeof(values) === "object") { + let arrayValues: Array = []; + coders.forEach(function(coder) { + arrayValues.push((values)[coder.localName]); + }); + values = arrayValues; + + } else { + errors.throwError("invalid tuple value", errors.INVALID_ARGUMENT, { + coderType: "tuple", + value: values + }); + } + + if (coders.length !== values.length) { + errors.throwError("types/value length mismatch", errors.INVALID_ARGUMENT, { + coderType: "tuple", + value: values + }); + } + + let staticWriter = new Writer(writer.wordSize); + let dynamicWriter = new Writer(writer.wordSize); + + let updateFuncs: Array<(baseOffset: number) => void> = []; + coders.forEach((coder, index) => { + let value = values[index]; + + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + let dynamicOffset = dynamicWriter.length; + + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + + // Prepare to populate the correct offset once we are done + let updateFunc = staticWriter.writeUpdatableValue(); + updateFuncs.push((baseOffset: number) => { + updateFunc(baseOffset + dynamicOffset); + }); + + } else { + coder.encode(staticWriter, value); + } + }); + + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach((func) => { func(staticWriter.length); }); + + let length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; +} + +export function unpack(reader: Reader, coders: Array): Array { + let values: any = []; + + // A reader anchored to this base + let baseReader = reader.subReader(0); + + // The amount of dynamic data read; to consume later to synchronize + let dynamicLength = 0; + + coders.forEach((coder) => { + let value: any = null; + + if (coder.dynamic) { + let offset = reader.readValue(); + let offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } else { + value = coder.decode(reader); + } + + if (value != undefined) { + values.push(value); + } + }); + +// @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + + // Add any named parameters (i.e. tuples) + coders.forEach((coder: Coder, index: number) => { + let name: string = coder.localName; + if (!name) { return; } + + if (name === "length") { name = "_length"; } + + if (values[name] != null) { return; } + + values[name] = values[index]; + }); + + return values; +} + + +export class ArrayCoder extends Coder { + readonly coder: Coder; + readonly length: number; + + constructor(coder: Coder, length: number, localName: string) { + const type = (coder.type + "[" + (length >= 0 ? length: "") + "]"); + const dynamic = (length === -1 || coder.dynamic); + super("array", type, localName, dynamic); + + this.coder = coder; + this.length = length; + } + + encode(writer: Writer, value: Array): number { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + + let count = this.length; + + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + + errors.checkArgumentCount(count, value.length, " in coder array" + (this.localName? (" "+ this.localName): "")); + + let coders = []; + for (let i = 0; i < value.length; i++) { coders.push(this.coder); } + + return pack(writer, coders, value); + } + + decode(reader: Reader): any { + let count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + + let coders = []; + for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); } + + return reader.coerce(this.name, unpack(reader, coders)); + } +} + diff --git a/packages/abi/src.ts/coders/boolean.ts b/packages/abi/src.ts/coders/boolean.ts new file mode 100644 index 000000000..ebd7384ab --- /dev/null +++ b/packages/abi/src.ts/coders/boolean.ts @@ -0,0 +1,19 @@ +"use strict"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +export class BooleanCoder extends Coder { + + constructor(localName: string) { + super("bool", "bool", localName, false); + } + + encode(writer: Writer, value: boolean): number { + return writer.writeValue(value ? 1: 0); + } + + decode(reader: Reader): any { + return reader.coerce(this.type, !reader.readValue().isZero()); + } +} + diff --git a/packages/abi/src.ts/coders/bytes.ts b/packages/abi/src.ts/coders/bytes.ts new file mode 100644 index 000000000..a2d8ce43c --- /dev/null +++ b/packages/abi/src.ts/coders/bytes.ts @@ -0,0 +1,34 @@ +"use strict"; + +import { arrayify, hexlify } from "@ethersproject/bytes"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +export class DynamicBytesCoder extends Coder { + constructor(type: string, localName: string) { + super(type, type, localName, true); + } + + encode(writer: Writer, value: any): number { + value = arrayify(value); + let length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + } + + decode(reader: Reader): any { + return reader.readBytes(reader.readValue().toNumber()); + } +} + +export class BytesCoder extends DynamicBytesCoder { + constructor(localName: string) { + super("bytes", localName); + } + + decode(reader: Reader): any { + return reader.coerce(this.name, hexlify(super.decode(reader))); + } +} + + diff --git a/packages/abi/src.ts/coders/fixed-bytes.ts b/packages/abi/src.ts/coders/fixed-bytes.ts new file mode 100644 index 000000000..45cadeedf --- /dev/null +++ b/packages/abi/src.ts/coders/fixed-bytes.ts @@ -0,0 +1,26 @@ +"use strict"; + +import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +// @TODO: Merge this with bytes +export class FixedBytesCoder extends Coder { + readonly size: number; + + constructor(size: number, localName: string) { + let name = "bytes" + String(size); + super(name, name, localName, false); + this.size = size; + } + + encode(writer: Writer, value: BytesLike): number { + let data = arrayify(value); + if (data.length !== this.size) { this._throwError("incorrect data length", value); } + return writer.writeBytes(data); + } + + decode(reader: Reader): any { + return reader.coerce(this.name, hexlify(reader.readBytes(this.size))); + } +} diff --git a/packages/abi/src.ts/coders/null.ts b/packages/abi/src.ts/coders/null.ts new file mode 100644 index 000000000..e0ad58870 --- /dev/null +++ b/packages/abi/src.ts/coders/null.ts @@ -0,0 +1,20 @@ +"use strict"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +export class NullCoder extends Coder { + + constructor(localName: string) { + super("null", "", localName, false); + } + + encode(writer: Writer, value: any): number { + if (value != null) { this._throwError("not null", value); } + return writer.writeBytes([ ]); + } + + decode(reader: Reader): any { + reader.readBytes(0); + return reader.coerce(this.name, null); + } +} diff --git a/packages/abi/src.ts/coders/number.ts b/packages/abi/src.ts/coders/number.ts new file mode 100644 index 000000000..19f237d19 --- /dev/null +++ b/packages/abi/src.ts/coders/number.ts @@ -0,0 +1,53 @@ +"use strict"; + +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { MaxUint256, NegativeOne, One, Zero } from "@ethersproject/constants"; + +import { Coder, Reader, Writer } from "./abstract-coder"; + +export class NumberCoder extends Coder { + readonly size: number; + readonly signed: boolean; + + constructor(size: number, signed: boolean, localName: string) { + const name = ((signed ? "int": "uint") + (size * 8)); + super(name, name, localName, false); + + this.size = size; + this.signed = signed; + } + + encode(writer: Writer, value: BigNumberish): number { + let v = BigNumber.from(value); + + // Check bounds are safe for encoding + let maxUintValue = MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + let bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(One).mul(NegativeOne))) { + this._throwError("value out-of-bounds", value); + } + } else if (v.lt(Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + + v = v.toTwos(this.size * 8).maskn(this.size * 8); + + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + + return writer.writeValue(v); + } + + decode(reader: Reader): any { + let value = reader.readValue().maskn(this.size * 8); + + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + + return reader.coerce(this.name, value); + } +} + diff --git a/packages/abi/src.ts/coders/string.ts b/packages/abi/src.ts/coders/string.ts new file mode 100644 index 000000000..14f13b1a6 --- /dev/null +++ b/packages/abi/src.ts/coders/string.ts @@ -0,0 +1,21 @@ +"use strict"; + +import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; + +import { Reader, Writer } from "./abstract-coder"; +import { DynamicBytesCoder } from "./bytes"; + +export class StringCoder extends DynamicBytesCoder { + + constructor(localName: string) { + super("string", localName); + } + + encode(writer: Writer, value: any): number { + return super.encode(writer, toUtf8Bytes(value)); + } + + decode(reader: Reader): any { + return toUtf8String(super.decode(reader)); + } +} diff --git a/packages/abi/src.ts/coders/tuple.ts b/packages/abi/src.ts/coders/tuple.ts new file mode 100644 index 000000000..257fec7f7 --- /dev/null +++ b/packages/abi/src.ts/coders/tuple.ts @@ -0,0 +1,30 @@ +"use strict"; + +import { Coder, Reader, Writer } from "./abstract-coder"; +import { pack, unpack } from "./array"; + +export class TupleCoder extends Coder { + readonly coders: Array; + + constructor(coders: Array, localName: string) { + let dynamic = false; + let types: Array = []; + coders.forEach((coder) => { + if (coder.dynamic) { dynamic = true; } + types.push(coder.type); + }); + let type = ("tuple(" + types.join(",") + ")"); + + super("tuple", type, localName, dynamic); + this.coders = coders; + } + + encode(writer: Writer, value: Array): number { + return pack(writer, this.coders, value); + } + + decode(reader: Reader): any { + return reader.coerce(this.name, unpack(reader, this.coders)); + } +} + diff --git a/packages/abi/src.ts/fragments.ts b/packages/abi/src.ts/fragments.ts new file mode 100644 index 000000000..4602e363d --- /dev/null +++ b/packages/abi/src.ts/fragments.ts @@ -0,0 +1,676 @@ +"use strict"; + +import { BigNumber } from "@ethersproject/bignumber"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly, isNamedInstance } from "@ethersproject/properties"; + + +export interface JsonFragmentType { + name?: string; + indexed?: boolean; + type?: string; + components?: Array; +} + +export interface JsonFragment { + name?: string; + type?: string; + + anonymous?: boolean; + + payable?: boolean; + constant?: boolean; + stateMutability?: string; + + inputs?: Array; + outputs?: Array; + + gas?: string; +}; + + +const _constructorGuard = { }; + +// AST Node parser state +type ParseState = { + allowArray?: boolean, + allowName?: boolean, + allowParams?: boolean, + allowType?: boolean, + readArray?: boolean, +}; + +// AST Node +type ParseNode = { + parent?: any, + type?: string, + name?: string, + state?: ParseState, + indexed?: boolean, + components?: Array +}; + + +// @TODO: Make sure that children of an indexed tuple are marked with a null indexed +function parseParamType(param: string, allowIndexed: boolean): ParseNode { + + let originalParam = param; + function throwError(i: number) { + throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); + } + param = param.replace(/\s/g, " "); + + function newNode(parent: ParseNode): ParseNode { + let node: ParseNode = { type: "", name: "", parent: parent, state: { allowType: true } }; + if (allowIndexed) { node.indexed = false; } + return node + } + + let parent: ParseNode = { type: "", name: "", state: { allowType: true } }; + let node = parent; + + for (let i = 0; i < param.length; i++) { + let c = param[i]; + switch (c) { + case "(": + if (!node.state.allowParams) { throwError(i); } + node.state.allowType = false; + node.type = verifyType(node.type); + node.components = [ newNode(node) ]; + node = node.components[0]; + break; + + case ")": + delete node.state; + if (allowIndexed) { + if (node.name === "indexed") { + node.indexed = true; + node.name = ""; + } + } + node.type = verifyType(node.type); + + let child = node; + node = node.parent; + if (!node) { throwError(i); } + delete child.parent; + node.state.allowParams = false; + node.state.allowName = true; + node.state.allowArray = true; + break; + + case ",": + delete node.state; + if (allowIndexed) { + if (node.name === "indexed") { + node.indexed = true; + node.name = ""; + } + } + node.type = verifyType(node.type); + + let sibling: ParseNode = newNode(node.parent); + //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; + node.parent.components.push(sibling); + delete node.parent; + node = sibling; + break; + + // Hit a space... + case " ": + + // If reading type, the type is done and may read a param or name + if (node.state.allowType) { + if (node.type !== "") { + node.type = verifyType(node.type); + delete node.state.allowType; + node.state.allowName = true; + node.state.allowParams = true; + } + } + + // If reading name, the name is done + if (node.state.allowName) { + if (node.name !== "") { + if (allowIndexed) { + if (node.name === "indexed") { + if (node.indexed) { throwError(i); } + node.indexed = true; + node.name = ""; + } + } else { + node.state.allowName = false; + } + } + } + + break; + + case "[": + if (!node.state.allowArray) { throwError(i); } + + node.type += c; + + node.state.allowArray = false; + node.state.allowName = false; + node.state.readArray = true; + break; + + case "]": + if (!node.state.readArray) { throwError(i); } + + node.type += c; + + node.state.readArray = false; + node.state.allowArray = true; + node.state.allowName = true; + break; + + default: + if (node.state.allowType) { + node.type += c; + node.state.allowParams = true; + node.state.allowArray = true; + } else if (node.state.allowName) { + node.name += c; + delete node.state.allowArray; + } else if (node.state.readArray) { + node.type += c; + } else { + throwError(i); + } + } + } + + if (node.parent) { throw new Error("unexpected eof"); } + + delete parent.state; + + if (allowIndexed) { + if (node.name === "indexed") { + if (node.indexed) { throwError(originalParam.length - 7); } + node.indexed = true; + node.name = ""; + } + } + parent.type = verifyType(parent.type); + + return parent; +} + +function populate(object: any, params: any) { + for (let key in params) { defineReadOnly(object, key, params[key]); } +} + +const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); + +export class ParamType { + + // The local name of the parameter (of null if unbound) + readonly name: string; + + // The fully qualified type (e.g. "address", "tuple(address)", "uint256[3][]" + readonly type: string; + + // The base type (e.g. "address", "tuple", "array") + readonly baseType: string; + + // Indexable Paramters ONLY (otherwise null) + readonly indexed: boolean; + + // Tuples ONLY: (otherwise null) + // - sub-components + readonly components: Array; + + // Arrays ONLY: (otherwise null) + // - length of the array (-1 for dynamic length) + // - child type + readonly arrayLength: number; + readonly arrayChildren: ParamType; + + constructor(constructorGuard: any, params: any) { + if (constructorGuard !== _constructorGuard) { throw new Error("use fromString"); } + populate(this, params); + + let match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: ((this.components != null) ? "tuple": this.type) + }); + } + } + + // Format the parameter fragment + // - non-expanded: "(uint256,address)" + // - expanded: "tuple(uint256 foo, addres bar) indexed baz" + format(expanded?: boolean): string { + let result = ""; + + // Array + if (this.baseType === "array") { + result += this.arrayChildren.format(expanded); + result += "[" + (this.arrayLength < 0 ? "": String(this.arrayLength)) + "]"; + } else { + if (this.baseType === "tuple") { + if (expanded) { + result += this.type; + } + result += "(" + this.components.map((c) => c.format(expanded)).join(expanded ? ", ": ",") + ")"; + } else { + result += this.type; + } + } + + if (expanded) { + if (this.indexed === true) { result += " indexed"; } + if (this.name) { result += " " + this.name; } + } + + return result; + } + + static from(value: string | JsonFragmentType | ParamType, allowIndexed?: boolean): ParamType { + if (typeof(value) === "string") { + return ParamType.fromString(value, allowIndexed); + } + return ParamType.fromObject(value); + } + + static fromObject(value: JsonFragmentType | ParamType): ParamType { + if (isNamedInstance(ParamType, value)) { return value; } + + return new ParamType(_constructorGuard, { + name: (value.name || null), + type: verifyType(value.type), + indexed: ((value.indexed == null) ? null: !!value.indexed), + components: (value.components ? value.components.map(ParamType.fromObject): null) + }); + } + + static fromString(value: string, allowIndexed?: boolean): ParamType { + function ParamTypify(node: ParseNode): ParamType { + return ParamType.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components + }); + } + + return ParamTypify(parseParamType(value, !!allowIndexed)); + } +}; + +function parseParams(value: string, allowIndex: boolean): Array { + return splitNesting(value).map((param) => ParamType.fromString(param, allowIndex)); +} + +export abstract class Fragment { + + readonly type: string; + readonly name: string; + readonly inputs: Array; + + constructor(constructorGuard: any, params: any) { + if (constructorGuard !== _constructorGuard) { throw new Error("use a static from method"); } + populate(this, params); + } + + // @TOOD: move logic to sub-classes; make this abstract + format(expanded?: boolean): string { + let result = ""; + + if (this.type === "constructor") { + result += "constructor"; + } else { + if (expanded) { + result += this.type + " "; + } + result += this.name; + } + + result += "(" + this.inputs.map((i) => i.format(expanded)).join(expanded ? ", ": ",") + ") "; + + // @TODO: Handle returns, modifiers, etc. + if (expanded) { + result += "public "; + if ((this).mutabilityState) { + result += (this).mutabilityState + " "; + } else if ((this).constant) { + result += "view "; + } + + if ((this).outputs && (this).outputs.length) { + result += "(" + (this).outputs.map((i: ParamType) => i.format(expanded)).join(", ") + ") "; + } + } + + return result.trim(); + } + + static from(value: Fragment | JsonFragment | string): Fragment { + if (typeof(value) === "string") { + return Fragment.fromString(value); + } + return Fragment.fromObject(value); + } + + static fromObject(value: Fragment | JsonFragment): Fragment { + if (isNamedInstance(Fragment, value)) { return value; } + + if (value.type === "function") { + return FunctionFragment.fromObject(value); + } else if (value.type === "event") { + return EventFragment.fromObject(value); + } else if (value.type === "constructor") { + return ConstructorFragment.fromObject(value); + } else if (value.type === "fallback") { + // @TODO: + return null; + } + + return errors.throwError("invalid fragment object", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + } + + static fromString(value: string): Fragment { + // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } + + throw new Error("unknown fragment"); + } +} + +export class EventFragment extends Fragment { + readonly anonymous: boolean; + + static from(value: EventFragment | JsonFragment | string): EventFragment { + if (typeof(value) === "string") { + return EventFragment.fromString(value); + } + return EventFragment.fromObject(value); + } + + static fromObject(value: JsonFragment | EventFragment): EventFragment { + if (isNamedInstance(EventFragment, value)) { return value; } + + if (value.type !== "event") { throw new Error("invalid event object - " + value.type); } + + return new EventFragment(_constructorGuard, { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + type: "event" + }); + } + + static fromString(value: string): EventFragment { + + let match = value.match(regexParen); + if (!match) { throw new Error("invalid event: " + value); } + + let anonymous = false; + match[3].split(" ").forEach((modifier) => { + switch(modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + errors.warn("unknown modifier: " + modifier); + } + }); + + return EventFragment.fromObject({ + name: match[1].trim(), + anonymous: anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + } +} + +function parseGas(value: string, params: any): string { + params.gas = null; + + let comps = value.split("@"); + if (comps.length !== 1) { + if (comps.length > 2) { + throw new Error("invalid signature"); + } + if (!comps[1].match(/^[0-9]+$/)) { + throw new Error("invalid signature gas"); + } + params.gas = BigNumber.from(comps[1]); + return comps[0]; + } + + return value; +} + +function parseModifiers(value: string, params: any): void { + params.constant = false; + params.payable = false; + // @TODO: Should this be initialized to "nonpayable"? + params.stateMutability = null; + + value.split(" ").forEach((modifier) => { + switch (modifier.trim()) { + case "constant": + params.constant = true; + break; + case "payable": + params.payable = true; + params.stateMutability = "payable"; + break; + case "pure": + params.constant = true; + params.stateMutability = "pure"; + break; + case "view": + params.constant = true; + params.stateMutability = "view"; + break; + case "external": + case "public": + case "": + break; + default: + console.log("unknown modifier: " + modifier); + } + }); +} + +export class ConstructorFragment extends Fragment { + stateMutability: string; + payable: boolean; + gas?: BigNumber; + + static from(value: ConstructorFragment | JsonFragment | string): ConstructorFragment { + if (typeof(value) === "string") { + return ConstructorFragment.fromString(value); + } + return ConstructorFragment.fromObject(value); + } + + static fromObject(value: ConstructorFragment | JsonFragment): ConstructorFragment { + if (isNamedInstance(ConstructorFragment, value)) { return value; } + + if (value.type !== "constructor") { throw new Error("invalid constructor object - " + value.type); } + + return new ConstructorFragment(_constructorGuard, { + type: value.type, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject): []), + payable: ((value.payable == null) ? true: !!value.payable), + gas: (value.gas ? BigNumber.from(value.gas): null) + }); + } + + static fromString(value: string): ConstructorFragment { + let params: any = { type: "constructor" }; + + value = parseGas(value, params); + + let parens = value.match(regexParen); + if (!parens) { throw new Error("invalid constructor: " + value); } + + if (parens[1].trim() !== "constructor") { throw new Error("invalid constructor"); } + + params.inputs = parseParams(parens[2].trim(), false); + + parseModifiers(parens[3].trim(), params); + + return ConstructorFragment.fromObject(params); + } + +} + +export class FunctionFragment extends ConstructorFragment { + constant: boolean; + outputs?: Array; + + static from(value: FunctionFragment | JsonFragment | string): FunctionFragment { + if (typeof(value) === "string") { + return FunctionFragment.fromString(value); + } + return FunctionFragment.fromObject(value); + } + + static fromObject(value: FunctionFragment | JsonFragment): FunctionFragment { + if (isNamedInstance(FunctionFragment, value)) { return value; } + + if (value.type !== "function") { throw new Error("invalid function object - " + value.type); } + + return new FunctionFragment(_constructorGuard, { + type: value.type, + name: verifyIdentifier(value.name), + constant: !!value.constant, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject): []), + outputs: (value.outputs ? value.outputs.map(ParamType.fromObject): [ ]), + payable: ((value.payable == null) ? true: !!value.payable), + stateMutability: ((value.stateMutability != null) ?verifyString(value.stateMutability): null), + gas: (value.gas ? BigNumber.from(value.gas): null) + }); + } + + static fromString(value: string): FunctionFragment { + let params: any = { type: "function" }; + value = parseGas(value, params); + + let comps = value.split(" returns "); + if (comps.length > 2) { throw new Error("invalid function"); } + + let parens = comps[0].match(regexParen); + if (!parens) { throw new Error("invalid signature"); } + + params.name = parens[1].trim(); + if (!params.name.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + params.name + "'"); + } + + params.inputs = parseParams(parens[2], false); + + parseModifiers(parens[3].trim(), params); + + // We have outputs + if (comps.length > 1) { + let returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + throw new Error("unexpected tokens"); + } + params.outputs = parseParams(returns[2], false); + } else { + params.outputs = [ ]; + } + + return FunctionFragment.fromObject(params); + } +} + +//export class ErrorFragment extends Fragment { +//} + +//export class StructFragment extends Fragment { +//} + +function verifyString(value: string): string { + if (typeof(value) !== "string") { throw new Error("requires a string"); } + return value; +} + +function verifyType(type: string): string { + + // These need to be transformed to their full description + if (type.match(/^uint($|[^1-9])/)) { + type = "uint256" + type.substring(4); + } else if (type.match(/^int($|[^1-9])/)) { + type = "int256" + type.substring(3); + } + + // @TODO: more verification + + return type; +} + +const regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); +function verifyIdentifier(value: string): string { + if (!value || !value.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + value + "'"); + } + return value; +} + +const regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); + +function splitNesting(value: string): Array { + value = value.trim(); + + let result = []; + let accum = ""; + let depth = 0; + for (let offset = 0; offset < value.length; offset++) { + let c = value[offset]; + if (c === "," && depth === 0) { + result.push(accum); + accum = ""; + } else { + accum += c; + if (c === "(") { + depth++; + } else if (c === ")") { + depth--; + if (depth === -1) { + throw new Error("unbalanced parenthsis"); + } + } + } + } + if (accum) { result.push(accum); } + + return result; +} + diff --git a/packages/abi/src.ts/index.ts b/packages/abi/src.ts/index.ts new file mode 100644 index 000000000..33ce6c1d4 --- /dev/null +++ b/packages/abi/src.ts/index.ts @@ -0,0 +1,26 @@ +"use strict"; + +import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments"; +import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder"; +import { Indexed, Interface } from "./interface"; + +export { + ConstructorFragment, + EventFragment, + Fragment, + FunctionFragment, + ParamType, + + AbiCoder, + defaultAbiCoder, + + Interface, + Indexed, + + ///////////////////////// + // Types + + CoerceFunc, + JsonFragment, + JsonFragmentType +}; diff --git a/packages/abi/src.ts/interface.ts b/packages/abi/src.ts/interface.ts new file mode 100644 index 000000000..80b7f3251 --- /dev/null +++ b/packages/abi/src.ts/interface.ts @@ -0,0 +1,406 @@ +"use strict"; + +import { getAddress } from "@ethersproject/address"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { arrayify, BytesLike, concat, hexDataSlice, hexlify, hexZeroPad, isHexString } from "@ethersproject/bytes"; +import { id } from "@ethersproject/hash"; +import { keccak256 } from "@ethersproject/keccak256" +import * as errors from "@ethersproject/errors"; +import { defineReadOnly, Description, isNamedInstance } from "@ethersproject/properties"; + +import { AbiCoder, defaultAbiCoder } from "./abi-coder"; +import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments"; + + +export class LogDescription extends Description { + readonly eventFragment: EventFragment; + readonly name: string; + readonly signature: string; + readonly topic: string; + readonly values: any +} + +export class TransactionDescription extends Description { + readonly functionFragment: FunctionFragment; + readonly name: string; + readonly args: Array; + readonly signature: string; + readonly sighash: string; + readonly value: BigNumber; +} + +export class Indexed extends Description { + readonly hash: string; +} + +export class Result { + [key: string]: any; + [key: number]: any; +} + + +export class Interface { + readonly fragments: Array; + + readonly errors: { [ name: string ]: any }; + readonly events: { [ name: string ]: EventFragment }; + readonly functions: { [ name: string ]: FunctionFragment }; + readonly structs: { [ name: string ]: any }; + + readonly deploy: ConstructorFragment; + + readonly _abiCoder: AbiCoder; + + constructor(fragments: string | Array) { + errors.checkNew(new.target, Interface); + + let abi: Array = [ ]; + if (typeof(fragments) === "string") { + abi = JSON.parse(fragments); + } else { + abi = fragments; + } + + defineReadOnly(this, "fragments", abi.map((fragment) => { + if (isNamedInstance(Fragment, fragment)) { + return fragment + } + return Fragment.from(fragment); + }).filter((fragment) => (fragment != null))); + + defineReadOnly(this, "_abiCoder", new.target.getAbiCoder()); + + defineReadOnly(this, "functions", { }); + defineReadOnly(this, "errors", { }); + defineReadOnly(this, "events", { }); + defineReadOnly(this, "structs", { }); + + // Add all fragments by their signature + this.fragments.forEach((fragment) => { + let bucket: { [ name: string ]: Fragment } = null; + switch (fragment.type) { + case "constructor": + if (this.deploy) { + errors.warn("duplicate definition - constructor"); + return; + } + defineReadOnly(this, "deploy", fragment); + return; + case "function": + bucket = this.functions; + break; + case "event": + bucket = this.events; + break; + default: + return; + } + + let signature = fragment.format(); + if (bucket[signature]) { + errors.warn("duplicate definition - " + signature); + return; + } + + bucket[signature] = fragment; + }); + + // Add any fragments with a unique name by its name (sans signature parameters) + [this.events, this.functions].forEach((bucket) => { + let count = getNameCount(bucket); + Object.keys(bucket).forEach((signature) => { + let fragment = bucket[signature]; + if (count[fragment.name] !== 1) { + errors.warn("duplicate definition - " + fragment.name); + return; + } + bucket[fragment.name] = fragment; + }); + }); + + // If we do not have a constructor use the default "constructor() payable" + if (!this.deploy) { + defineReadOnly(this, "deploy", ConstructorFragment.from( { type: "constructor" } )); + } + } + + static getAbiCoder(): AbiCoder { + return defaultAbiCoder; + } + + static getAddress(address: string): string { + return getAddress(address); + } + + _sighashify(functionFragment: FunctionFragment): string { + return hexDataSlice(id(functionFragment.format()), 0, 4); + } + + _topicify(eventFragment: EventFragment): string { + return id(eventFragment.format()); + } + + getFunction(nameOrSignatureOrSighash: string): FunctionFragment { + if (isHexString(nameOrSignatureOrSighash)) { + return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); + } + + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + return (this.functions[nameOrSignatureOrSighash.trim()] || null); + } + + // Normlize the signature and lookup the function + return this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + } + + getEvent(nameOrSignatureOrTopic: string): EventFragment { + if (isHexString(nameOrSignatureOrTopic)) { + return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); + } + + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + return this.events[nameOrSignatureOrTopic]; + } + + return this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()]; + } + + + getSighash(functionFragment: FunctionFragment | string): string { + if (typeof(functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + + return this._sighashify(functionFragment); + } + + getEventTopic(eventFragment: EventFragment | string): string { + if (typeof(eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + + return this._topicify(eventFragment); + } + + + _encodeParams(params: Array, values: Array): string { + return this._abiCoder.encode(params, values) + } + + encodeDeploy(values?: Array): string { + return this._encodeParams(this.deploy.inputs, values || [ ]); + } + + encodeFunctionData(functionFragment: FunctionFragment | string, values?: Array): string { + if (typeof(functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + + return hexlify(concat([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || [ ]) + ])); + } + + decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Array { + if (typeof(functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + + let bytes = arrayify(data); + + let reason: string = null; + let errorSignature: string = null; + switch (bytes.length % this._abiCoder._getWordSize()) { + case 0: + try { + return this._abiCoder.decode(functionFragment.outputs, bytes); + } catch (error) { } + break; + + case 4: + if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") { + errorSignature = "Error(string)"; + reason = this._abiCoder.decode([ "string" ], bytes.slice(4)); + } + break; + } + + return errors.throwError("call revert exception", errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorSignature: errorSignature, + errorArgs: [ reason ], + reason: reason + }); + } + + encodeFilterTopics(eventFragment: EventFragment, values: Array): Array> { + if (typeof(eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + + if (values.length > eventFragment.inputs.length) { + errors.throwError("too many arguments for " + eventFragment.format(), errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values + }) + } + + let topics: Array = []; + if (!eventFragment.anonymous) { topics.push(this.getEventTopic(eventFragment)); } + + values.forEach((value, index) => { + + let param = eventFragment.inputs[index]; + + if (!param.indexed) { + if (value != null) { + errors.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + } + return; + } + + if (value == null) { + topics.push(null); + } else if (param.type === "string") { + topics.push(id(value)); + } else if (param.type === "bytes") { + topics.push(keccak256(hexlify(value))); + } else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { + errors.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } else { + // Check addresses are valid + if (param.type === "address") { this._abiCoder.encode( [ "address" ], [ value ]); } + topics.push(hexZeroPad(hexlify(value), 32)); + } + }); + + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + + return topics; + } + + decodeEventLog(eventFragment: EventFragment | string, data: BytesLike, topics?: Array): Array { + if (typeof(eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + + if (topics != null && !eventFragment.anonymous) { topics = topics.slice(1); } + + let indexed: Array = []; + let nonIndexed: Array = []; + let dynamic: Array = []; + + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); + } else { + indexed.push(param); + dynamic.push(false); + } + } else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + + let resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, concat(topics)): null; + let resultNonIndexed = this._abiCoder.decode(nonIndexed, data); + + let result: Array = [ ]; + let nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ hash: null }); + + } else if (dynamic[index]) { + result[index] = new Indexed({ hash: resultIndexed[indexedIndex++] }); + + } else { + result[index] = resultIndexed[indexedIndex++]; + } + } else { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } + //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } + }); + + return result; + } + + + parseTransaction(tx: { data: string, value?: BigNumberish }): TransactionDescription { + let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()) + + if (!fragment) { return null; } + + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: BigNumber.from(tx.value || "0"), + }); + } + + parseLog(log: { topics: Array, data: string}): LogDescription { + let fragment = this.getEvent(log.topics[0]); + + if (!fragment || fragment.anonymous) { return null; } + + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + + + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + values: this.decodeEventLog(fragment, log.data, log.topics) + }); + } + + + /* + static from(value: Array | string | Interface) { + if (Interface.isInterface(value)) { + return value; + } + if (typeof(value) === "string") { + return new Interface(JSON.parse(value)); + } + return new Interface(value); + } + */ +} + +function getFragment(hash: string, calcFunc: (f: Fragment) => string, items: { [ sig: string ]: Fragment } ) { + for (let signature in items) { + if (signature.indexOf("(") === -1) { continue; } + let fragment = items[signature]; + if (calcFunc(fragment) === hash) { return fragment; } + } + return null; +} + +function getNameCount(fragments: { [ signature: string ]: Fragment }): { [ name: string ]: number } { + let unique: { [ name: string ]: number } = { }; + + // Count each name + for (let signature in fragments) { + let name = fragments[signature].name; + if (!unique[name]) { unique[name] = 0; } + unique[name]++; + } + + return unique; +} diff --git a/packages/abi/test-coder.js b/packages/abi/test-coder.js new file mode 100644 index 000000000..6969951d2 --- /dev/null +++ b/packages/abi/test-coder.js @@ -0,0 +1,4 @@ +let { defaultAbiCoder } = require("."); + +console.log(defaultAbiCoder); +console.log(defaultAbiCoder.encode([ "uint256", "bytes" ], [ 42, "0x1234" ])); diff --git a/packages/abi/tsconfig.json b/packages/abi/tsconfig.json new file mode 100644 index 000000000..bbf8508be --- /dev/null +++ b/packages/abi/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts", + "./src.ts/coders/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/abstract-provider/.npmignore b/packages/abstract-provider/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/abstract-provider/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/abstract-provider/LICENSE.md b/packages/abstract-provider/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/abstract-provider/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/abstract-provider/README.md b/packages/abstract-provider/README.md new file mode 100644 index 000000000..8010615a2 --- /dev/null +++ b/packages/abstract-provider/README.md @@ -0,0 +1,17 @@ +Abstract Provider +================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json new file mode 100644 index 000000000..81a7f51b3 --- /dev/null +++ b/packages/abstract-provider/package.json @@ -0,0 +1,32 @@ +{ + "name": "@ethersproject/abstract-provider", + "version": "5.0.0-beta.126", + "description": "Error utility functions for ethers.", + "main": "index.js", + "browser": { + "net": "./browser-net.js", + "./ipc-provider": "./browser-ipc-provider" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/networks": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/web": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x4424dfecaacd3e4d135d01136d92bcee22bb7a5d0ce5d2c5272bd02422135db7" +} diff --git a/packages/abstract-provider/src.ts/_version.ts b/packages/abstract-provider/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/abstract-provider/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/abstract-provider/src.ts/index.ts b/packages/abstract-provider/src.ts/index.ts new file mode 100644 index 000000000..a17efc4ea --- /dev/null +++ b/packages/abstract-provider/src.ts/index.ts @@ -0,0 +1,283 @@ +"use strict"; + +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike, isHexString } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { checkAbstract } from "@ethersproject/errors"; +import { Network } from "@ethersproject/networks"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Transaction } from "@ethersproject/transactions"; +import { OnceBlockable } from "@ethersproject/web"; + + +/////////////////////////////// +// Exported Types + + +export type TransactionRequest = { + to?: string | Promise, + from?: string | Promise, + nonce?: BigNumberish | Promise, + + gasLimit?: BigNumberish | Promise, + gasPrice?: BigNumberish | Promise, + + data?: BytesLike | Promise, + value?: BigNumberish | Promise, + chainId?: number | Promise, +} + +export interface TransactionResponse extends Transaction { + // Only if a transaction has been mined + blockNumber?: number, + blockHash?: string, + timestamp?: number, + + confirmations: number, + + // Not optional (as it is in Transaction) + from: string; + + // The raw transaction + raw?: string, + + // This function waits until the transaction has been mined + wait: (confirmations?: number) => Promise +}; + +export type BlockTag = string | number; + +interface _Block { + hash: string; + parentHash: string; + number: number; + + timestamp: number; + nonce: string; + difficulty: number; + + gasLimit: BigNumber; + gasUsed: BigNumber; + + miner: string; + extraData: string; +} + +export interface Block extends _Block { + transactions: Array; +} + +export interface BlockWithTransactions extends _Block { + transactions: Array; +} + + +export interface Log { + blockNumber?: number; + blockHash?: string; + transactionIndex?: number; + + removed?: boolean; + + transactionLogIndex?: number, + + address: string; + data: string; + + topics: Array; + + transactionHash?: string; + logIndex?: number; +} + +export interface TransactionReceipt { + to?: string; + from?: string; + contractAddress?: string, + transactionIndex?: number, + root?: string, + gasUsed?: BigNumber, + logsBloom?: string, + blockHash?: string, + transactionHash?: string, + logs?: Array, + blockNumber?: number, + confirmations?: number, + cumulativeGasUsed?: BigNumber, + byzantium: boolean, + status?: number +}; + +export interface EventFilter { + address?: string; + topics?: Array>; +} + +export interface Filter extends EventFilter { + fromBlock?: BlockTag, + toBlock?: BlockTag, +} + +export interface FilterByBlockHash extends EventFilter { + blockhash?: string; +} + +//export type CallTransactionable = { +// call(transaction: TransactionRequest): Promise; +//}; + +export class ForkEvent { + readonly expiry: number; + + constructor(expiry?: number) { + defineReadOnly(this, "expiry", expiry || 0); + } +} + +export class BlockForkEvent extends ForkEvent { + readonly blockhash: string; + + constructor(blockhash: string, expiry?: number) { + if (!isHexString(blockhash, 32)) { + errors.throwArgumentError("invalid blockhash", "blockhash", blockhash); + } + super(expiry); + defineReadOnly(this, "blockhash", blockhash); + } +} + +export class TransactionForkEvent extends ForkEvent { + readonly hash: string; + + constructor(hash: string, expiry?: number) { + if (!isHexString(hash, 32)) { + errors.throwArgumentError("invalid transaction hash", "hash", hash); + } + super(expiry); + defineReadOnly(this, "hash", hash); + } +} + +export class TransactionOrderForkEvent extends ForkEvent { + readonly beforeHash: string; + readonly afterHash: string; + + constructor(beforeHash: string, afterHash: string, expiry?: number) { + if (!isHexString(beforeHash, 32)) { + errors.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!isHexString(afterHash, 32)) { + errors.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + super(expiry); + defineReadOnly(this, "beforeHash", beforeHash); + defineReadOnly(this, "afterHash", afterHash); + } +} + +export type EventType = string | Array> | EventFilter | ForkEvent; + +export type Listener = (...args: Array) => void; + +/////////////////////////////// +// Exported Abstracts + +export abstract class Provider implements OnceBlockable { + + // Network + abstract getNetwork(): Promise; + + // Latest State + abstract getBlockNumber(): Promise; + abstract getGasPrice(): Promise; + + // Account + abstract getBalance(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + abstract getTransactionCount(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + abstract getCode(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise ; + abstract getStorageAt(addressOrName: string | Promise, position: BigNumberish | Promise, blockTag?: BlockTag | Promise): Promise; + + // Execution + abstract sendTransaction(signedTransaction: string | Promise): Promise; + abstract call(transaction: TransactionRequest, blockTag?: BlockTag | Promise): Promise; + abstract estimateGas(transaction: TransactionRequest): Promise; + + // Queries + abstract getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + abstract getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + abstract getTransaction(transactionHash: string): Promise; + abstract getTransactionReceipt(transactionHash: string): Promise; + + // Bloom-filter Queries + abstract getLogs(filter: Filter): Promise>; + + // ENS + abstract resolveName(name: string | Promise): Promise; + abstract lookupAddress(address: string | Promise): Promise; + + // Event Emitter (ish) + abstract on(eventName: EventType, listener: Listener): Provider; + abstract once(eventName: EventType, listener: Listener): Provider; + abstract emit(eventName: EventType, ...args: Array): boolean + abstract listenerCount(eventName?: EventType): number; + abstract listeners(eventName?: EventType): Array; + abstract off(eventName: EventType, listener?: Listener): Provider; + abstract removeAllListeners(eventName?: EventType): Provider; + + // Alias for "on" + addListener(eventName: EventType, listener: Listener): Provider { + return this.on(eventName, listener); + } + + // Alias for "off" + removeListener(eventName: EventType, listener: Listener): Provider { + return this.off(eventName, listener); + } + + // @TODO: This *could* be implemented here, but would pull in events... + abstract waitForTransaction(transactionHash: string, timeout?: number): Promise; + + constructor() { + checkAbstract(new.target, Provider); + } + +/* + static getResolver(network: Network, callable: CallTransactionable, namehash: string): string { + // No ENS... + if (!network.ensAddress) { + errors.throwError( + "network does support ENS", + errors.UNSUPPORTED_OPERATION, + { operation: "ENS", network: network.name } + ); + } + + // Not a namehash + if (!isHexString(namehash, 32)) { + errors.throwArgumentError("invalid name hash", "namehash", namehash); + } + + // keccak256("resolver(bytes32)") + let data = "0x0178b8bf" + namehash.substring(2); + let transaction = { to: network.ensAddress, data: data }; + + return provider.call(transaction).then((data) => { + return provider.formatter.callAddress(data); + }); + } + + static resolveNamehash(network: Network, callable: CallTransactionable, namehash: string): string { + return this.getResolver(network, callable, namehash).then((resolverAddress) => { + if (!resolverAddress) { return null; } + + // keccak256("addr(bytes32)") + let data = "0x3b3b57de" + namehash(name).substring(2); + let transaction = { to: resolverAddress, data: data }; + return callable.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + + }) + } +*/ +} diff --git a/packages/abstract-provider/tsconfig.json b/packages/abstract-provider/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/abstract-provider/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/abstract-signer/.npmignore b/packages/abstract-signer/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/abstract-signer/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/abstract-signer/LICENSE.md b/packages/abstract-signer/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/abstract-signer/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/abstract-signer/README.md b/packages/abstract-signer/README.md new file mode 100644 index 000000000..bf4277022 --- /dev/null +++ b/packages/abstract-signer/README.md @@ -0,0 +1,17 @@ +Abstract Signer +=============== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/abstract-signer/package.json b/packages/abstract-signer/package.json new file mode 100644 index 000000000..c036fd260 --- /dev/null +++ b/packages/abstract-signer/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/abstract-signer", + "version": "5.0.0-beta.126", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abstract-provider": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x3bc5ce92bedb99f4c15e3c399e4367eaa001bb72bf25a82f52e09c74f09f492f" +} diff --git a/packages/abstract-signer/src.ts/_version.ts b/packages/abstract-signer/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/abstract-signer/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/abstract-signer/src.ts/index.ts b/packages/abstract-signer/src.ts/index.ts new file mode 100644 index 000000000..1af05aaee --- /dev/null +++ b/packages/abstract-signer/src.ts/index.ts @@ -0,0 +1,216 @@ +"use strict"; + +import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { BigNumber } from "@ethersproject/bignumber"; +import { Bytes } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties"; + +const allowedTransactionKeys: Array = [ + "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" +]; + +// Sub-classes of Signer may optionally extend this interface to indicate +// they have a private key available synchronously +export interface ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; +} + +// Sub-Class Notes: +// - A Signer MUST always make sure, that if present, the "from" field +// matches the Signer, before sending or signing a transaction +// - A Signer SHOULD always wrap private information (such as a private +// key or mnemonic) in a function, so that console.log does not leak +// the data + +export abstract class Signer { + readonly provider?: Provider; + + /////////////////// + // Sub-classes MUST implement these + + // Returns the checksum address + abstract getAddress(): Promise + + // Returns the signed prefixed-message. This MUST treat: + // - Bytes as a binary message + // - string as a UTF8-message + // i.e. "0x1234" is a SIX (6) byte string, NOT 2 bytes of data + abstract signMessage(message: Bytes | string): Promise; + + // Signs a transaxction and returns the fully serialized, signed transaction. + // The EXACT transaction MUST be signed, and NO additional properties to be added. + // - This MAY throw if signing transactions is not supports, but if + // it does, sentTransaction MUST be overridden. + abstract signTransaction(transaction: TransactionRequest): Promise; + + // Returns a new instance of the Signer, connected to provider. + // This MAY throw if changing providers is not supported. + abstract connect(provider: Provider): Signer; + + + /////////////////// + // Sub-classes MUST call super + constructor() { + errors.checkAbstract(new.target, Signer); + } + + + /////////////////// + // Sub-classes MAY override these + + getBalance(blockTag?: BlockTag): Promise { + this._checkProvider("getBalance"); + return this.provider.getBalance(this.getAddress(), blockTag); + } + + getTransactionCount(blockTag?: BlockTag): Promise { + this._checkProvider("getTransactionCount"); + return this.provider.getTransactionCount(this.getAddress(), blockTag); + } + + // Populates "from" if unspecified, and estimates the gas for the transation + estimateGas(transaction: TransactionRequest): Promise { + this._checkProvider("estimateGas"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.estimateGas(tx); + }); + } + + // Populates "from" if unspecified, and calls with the transation + call(transaction: TransactionRequest, blockTag?: BlockTag): Promise { + this._checkProvider("call"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.call(tx); + }); + } + + // Populates all fields in a transaction, signs it and sends it to the network + sendTransaction(transaction: TransactionRequest): Promise { + this._checkProvider("sendTransaction"); + return this.populateTransaction(transaction).then((tx) => { + return this.signTransaction(tx).then((signedTx) => { + return this.provider.sendTransaction(signedTx); + }); + }); + } + + getChainId(): Promise { + this._checkProvider("getChainId"); + return this.provider.getNetwork().then((network) => network.chainId); + } + + getGasPrice(): Promise { + this._checkProvider("getGasPrice"); + return this.provider.getGasPrice(); + } + + resolveName(name: string): Promise { + this._checkProvider("resolveName"); + return this.provider.resolveName(name); + } + + + + + // Checks a transaction does not contain invalid keys and if + // no "from" is provided, populates it. + // - does NOT require a provider + // - adds "from" is not present + // - returns a COPY (safe to mutate the result) + // By default called from: (overriding these prevents it) + // - call + // - estimateGas + // - populateTransaction (and therefor sendTransaction) + checkTransaction(transaction: TransactionRequest): TransactionRequest { + for (let key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + errors.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + } + } + + let tx = shallowCopy(transaction); + if (tx.from == null) { tx.from = this.getAddress(); } + return tx; + } + + // Populates ALL keys for a transaction and checks that "from" matches + // this Signer. Should be used by sendTransaction but NOT by signTransaction. + // By default called from: (overriding these prevents it) + // - sendTransaction + populateTransaction(transaction: TransactionRequest): Promise { + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + + if (tx.to != null) { tx.to = Promise.resolve(tx.to).then((to) => this.resolveName(to)); } + if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); } + if (tx.nonce == null) { tx.nonce = this.getTransactionCount("pending"); } + + // Make sure any provided address matches this signer + if (tx.from == null) { + tx.from = this.getAddress(); + } else { + tx.from = Promise.all([ + this.getAddress(), + this.provider.resolveName(tx.from) + ]).then((results) => { + if (results[0] !== results[1]) { + errors.throwArgumentError("from address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + + if (tx.gasLimit == null) { tx.gasLimit = this.estimateGas(tx); } + if (tx.chainId == null) { tx.chainId = this.getChainId(); } + + return resolveProperties(tx); + }); + } + + + /////////////////// + // Sub-classes SHOULD leave these alone + + _checkProvider(operation?: string): void { + if (!this.provider) { errors.throwError("missing provider", errors.UNSUPPORTED_OPERATION, { + operation: (operation || "_checkProvider") }); + } + } +} + +export class VoidSigner extends Signer { + readonly address: string; + + constructor(address: string, provider?: Provider) { + errors.checkNew(new.target, VoidSigner); + super(); + defineReadOnly(this, "address", address); + defineReadOnly(this, "provider", provider || null); + } + + getAddress(): Promise { + return Promise.resolve(this.address); + } + + _fail(message: string, operation: string): Promise { + return Promise.resolve().then(() => { + errors.throwError(message, errors.UNSUPPORTED_OPERATION, { operation: operation }); + }); + } + + signMessage(message: Bytes | string): Promise { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + } + + signTransaction(transaction: TransactionRequest): Promise { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + } + + connect(provider: Provider): VoidSigner { + return new VoidSigner(this.address, provider); + } +} + diff --git a/packages/abstract-signer/tsconfig.json b/packages/abstract-signer/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/abstract-signer/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/address/.npmignore b/packages/address/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/address/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/address/LICENSE.md b/packages/address/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/address/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/address/README.md b/packages/address/README.md new file mode 100644 index 000000000..dbea4f2da --- /dev/null +++ b/packages/address/README.md @@ -0,0 +1,17 @@ +Ethereum Address Utilities +========================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/address/package.json b/packages/address/package.json new file mode 100644 index 000000000..3b88052ee --- /dev/null +++ b/packages/address/package.json @@ -0,0 +1,27 @@ +{ + "name": "@ethersproject/address", + "version": "5.0.0-beta.125", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/rlp": ">5.0.0-beta.0", + "bn.js": "^4.4.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x962ac58ce384cd1b220fd2d7fbd66e914f4c55f38440d75afd12ba560cffc7f1" +} diff --git a/packages/address/src.ts/_version.ts b/packages/address/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/address/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/address/src.ts/index.ts b/packages/address/src.ts/index.ts new file mode 100644 index 000000000..40acf766f --- /dev/null +++ b/packages/address/src.ts/index.ts @@ -0,0 +1,146 @@ +"use strict"; + +// We use this for base 36 maths +import * as BN from "bn.js"; + +import * as errors from "@ethersproject/errors"; + +import { arrayify, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes"; +import { BigNumberish } from "@ethersproject/bignumber"; +import { keccak256 } from "@ethersproject/keccak256"; +import { encode } from "@ethersproject/rlp"; + + +function getChecksumAddress(address: string): string { + if (!isHexString(address, 20)) { + errors.throwError("invalid address", errors.INVALID_ARGUMENT, { arg: "address", value: address }); + } + + address = address.toLowerCase(); + + let chars = address.substring(2).split(""); + + let hashed = new Uint8Array(40); + for (let i = 0; i < 40; i++) { + hashed[i] = chars[i].charCodeAt(0); + } + hashed = arrayify(keccak256(hashed)); + + for (let i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + + return "0x" + chars.join(""); +} + +// Shims for environments that are missing some required constants and functions +const MAX_SAFE_INTEGER: number = 0x1fffffffffffff; + +function log10(x: number): number { + if (Math.log10) { return Math.log10(x); } + return Math.log(x) / Math.LN10; +} + + +// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number + +// Create lookup table +let ibanLookup: { [character: string]: string } = {}; +for (let i = 0; i < 10; i++) { ibanLookup[String(i)] = String(i); } +for (let i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); } + +// How many decimal digits can we process? (for 64-bit float, this is 15) +let safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); + +function ibanChecksum(address: string): string { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + + let expanded = ""; + address.split("").forEach(function(c) { + expanded += ibanLookup[c]; + }); + + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits){ + let block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + + let checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { checksum = "0" + checksum; } + + return checksum; +}; + +export function getAddress(address: string): string { + let result = null; + + if (typeof(address) !== "string") { + errors.throwArgumentError("invalid address", "address", address); + } + + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + + // Missing the 0x prefix + if (address.substring(0, 2) !== "0x") { address = "0x" + address; } + + result = getChecksumAddress(address); + + // It is a checksummed address with a bad checksum + if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { + errors.throwArgumentError("bad address checksum", "address", address); + } + + // Maybe ICAP? (we only support direct mode) + } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + + // It is an ICAP address with a bad checksum + if (address.substring(2, 4) !== ibanChecksum(address)) { + errors.throwArgumentError("bad icap checksum", "address", address); + } + + result = (new BN.BN(address.substring(4), 36)).toString(16); + while (result.length < 40) { result = "0" + result; } + result = getChecksumAddress("0x" + result); + + } else { + errors.throwArgumentError("invalid address", "address", address); + } + + return result; +} + +export function isAddress(address: string): boolean { + try { + getAddress(address); + return true; + } catch (error) { } + return false; +} + +export function getIcapAddress(address: string): string { + let base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + while (base36.length < 30) { base36 = "0" + base36; } + return "XE" + ibanChecksum("XE00" + base36) + base36; +} + +// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed +export function getContractAddress(transaction: { from: string, nonce: BigNumberish }) { + let from: string = null; + try { + from = getAddress(transaction.from); + } catch (error) { + errors.throwArgumentError("missing from address", "transaction", transaction); + } + + let nonce = stripZeros(arrayify(transaction.nonce)); + + return getAddress(hexDataSlice(keccak256(encode([ from, nonce ])), 12)); +} + diff --git a/packages/address/thirdparty.d.ts b/packages/address/thirdparty.d.ts new file mode 100644 index 000000000..8c07d6bfb --- /dev/null +++ b/packages/address/thirdparty.d.ts @@ -0,0 +1,30 @@ +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; + } +} diff --git a/packages/address/tsconfig.json b/packages/address/tsconfig.json new file mode 100644 index 000000000..f7c84c603 --- /dev/null +++ b/packages/address/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/base64/.gitignore b/packages/base64/.gitignore new file mode 100644 index 000000000..aa5c62527 --- /dev/null +++ b/packages/base64/.gitignore @@ -0,0 +1 @@ +browser.d.ts diff --git a/packages/base64/.npmignore b/packages/base64/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/base64/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/base64/LICENSE.md b/packages/base64/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/base64/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/base64/README.md b/packages/base64/README.md new file mode 100644 index 000000000..7e4a07fdd --- /dev/null +++ b/packages/base64/README.md @@ -0,0 +1,36 @@ +Base64 Coder +============ + +function decode(textData: string): Uint8Array +--------------------------------------------- + +Decodes a base64 encoded string into the binary data. + +```javascript +import * as base64 from "@ethersproject/base64"; + +let encodedData = "..."; +let data = base64.decode(encodedData); +console.log(data); +// { Uint8Array: [] } +``` + +function encode(data: Arrayish): string +--------------------------------------- + +Decodes a base64 encoded string into the binary data. + +```javascript +import * as base64 from "@ethersproject/base64"; + +let data = [ ]; +let encodedData = base64.encode(data); +console.log(encodedData); +// "..." +``` + + +License +======= + +MIT License diff --git a/packages/base64/package.json b/packages/base64/package.json new file mode 100644 index 000000000..2d36b08ce --- /dev/null +++ b/packages/base64/package.json @@ -0,0 +1,23 @@ +{ + "name": "@ethersproject/base64", + "version": "5.0.0-beta.124", + "description": "Base64 coder.", + "main": "index.js", + "browser": "browser.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xe5da4b9df9188216fed902efb45ee9af1cdb9a47c1212d9a674a93c5adb716bd" +} diff --git a/packages/base64/src.ts/_version.ts b/packages/base64/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/base64/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/base64/src.ts/browser.ts b/packages/base64/src.ts/browser.ts new file mode 100644 index 000000000..a252395a6 --- /dev/null +++ b/packages/base64/src.ts/browser.ts @@ -0,0 +1,23 @@ +"use strict"; + +import { arrayify, BytesLike } from "@ethersproject/bytes"; + +export function decode(textData: string): Uint8Array { + textData = atob(textData); + let data = []; + for (let i = 0; i < textData.length; i++) { + data.push(textData.charCodeAt(i)); + } + return arrayify(data); +} + +export function encode(data: BytesLike): string { + data = arrayify(data); + let textData = ""; + for (let i = 0; i < data.length; i++) { + textData += String.fromCharCode(data[i]); + } + return btoa(textData); +} + + diff --git a/packages/base64/src.ts/index.ts b/packages/base64/src.ts/index.ts new file mode 100644 index 000000000..c6f84a0cc --- /dev/null +++ b/packages/base64/src.ts/index.ts @@ -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"); +} diff --git a/packages/base64/tsconfig.json b/packages/base64/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/base64/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/basex/.npmignore b/packages/basex/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/basex/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/basex/LICENSE.md b/packages/basex/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/basex/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/basex/README.md b/packages/basex/README.md new file mode 100644 index 000000000..db64b85c6 --- /dev/null +++ b/packages/basex/README.md @@ -0,0 +1,5 @@ +Base X +====== + +**EXPERIMENTAL** + diff --git a/packages/basex/package.json b/packages/basex/package.json new file mode 100644 index 000000000..abc2f2b3f --- /dev/null +++ b/packages/basex/package.json @@ -0,0 +1,23 @@ +{ + "name": "@ethersproject/basex", + "version": "5.0.0-beta.124", + "description": "Base-X without Buffer.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x8243e502fd9c51780351423f21ff95978c66005a9a9691cabd98e805ca69fe40" +} diff --git a/packages/basex/src.ts/_version.ts b/packages/basex/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/basex/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/basex/src.ts/index.ts b/packages/basex/src.ts/index.ts new file mode 100644 index 000000000..a99e9905b --- /dev/null +++ b/packages/basex/src.ts/index.ts @@ -0,0 +1,143 @@ +/** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +import { arrayify, BytesLike } from "@ethersproject/bytes"; +import { defineReadOnly } from "@ethersproject/properties"; + +export class BaseX { + readonly alphabet: string; + readonly base: number; + + private _alphabetMap: { [ character: string ]: number }; + private _leader: string; + + constructor(alphabet: string) { + defineReadOnly(this, "alphabet", alphabet); + defineReadOnly(this, "base", alphabet.length); + + defineReadOnly(this, "_alphabetMap", { }); + defineReadOnly(this, "_leader", alphabet.charAt(0)); + + // pre-compute lookup table + for (let i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + + encode(value: BytesLike): string { + let source = arrayify(value); + + if (source.length === 0) { return ""; } + + let digits = [ 0 ] + for (let i = 0; i < source.length; ++i) { + let carry = source[i]; + for (let j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = (carry / this.base) | 0; + } + + while (carry > 0) { + digits.push(carry % this.base); + carry = (carry / this.base) | 0; + } + } + + let string = "" + + // deal with leading zeros + for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + + // convert digits to a string + for (let q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + + return string; + } + + decode(value: string): Uint8Array { + if (typeof(value) !== "string") { + throw new TypeError("Expected String"); + } + + let bytes: Array = []; + if (value.length === 0) { return new Uint8Array(bytes); } + + bytes.push(0); + for (let i = 0; i < value.length; i++) { + let byte = this._alphabetMap[value[i]]; + + if (byte === undefined) { + throw new Error("Non-base" + this.base + " character"); + } + + let carry = byte; + for (let j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 0xff; + carry >>= 8; + } + + while (carry > 0) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + + // deal with leading zeros + for (let k = 0; value[k] === this._leader && k < value.length - 1; ++k) { + bytes.push(0) + } + + return arrayify(new Uint8Array(bytes.reverse())) + } +} + +const Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); +const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + +export { Base32, Base58 }; + +//console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) +//console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) diff --git a/packages/basex/tsconfig.json b/packages/basex/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/basex/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/bignumber/.npmignore b/packages/bignumber/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/bignumber/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/bignumber/LICENSE.md b/packages/bignumber/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/bignumber/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/bignumber/README.md b/packages/bignumber/README.md new file mode 100644 index 000000000..1d1b8bb2d --- /dev/null +++ b/packages/bignumber/README.md @@ -0,0 +1,17 @@ +Big Numbers +=========== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/bignumber/package.json b/packages/bignumber/package.json new file mode 100644 index 000000000..9de8fa8d9 --- /dev/null +++ b/packages/bignumber/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/bignumber", + "version": "5.0.0-beta.126", + "description": "BigNumber library used in ethers.js.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "bn.js": "^4.4.0" + }, + "keywords": [ + "Ethereum", + "bignumber", + "bn" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xbb5426f664ba919d5668ddde9f13255ef77278a2e556f4d64f9be1089f5947c0" +} diff --git a/packages/bignumber/src.ts/_version.ts b/packages/bignumber/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/bignumber/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/bignumber/src.ts/bignumber.ts b/packages/bignumber/src.ts/bignumber.ts new file mode 100644 index 000000000..990e8e606 --- /dev/null +++ b/packages/bignumber/src.ts/bignumber.ts @@ -0,0 +1,350 @@ +"use strict"; + +/** + * BigNumber + * + * A wrapper around the BN.js object. We use the BN.js library + * because it is used by elliptic, so it is required regardles. + * + */ + +import * as BN from "bn.js"; + +import { Bytes, Hexable, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; +import { defineReadOnly, isNamedInstance } from "@ethersproject/properties"; + +import * as errors from "@ethersproject/errors"; + +const _constructorGuard = { }; + +const MAX_SAFE = 0x1fffffffffffff; + + +export type BigNumberish = BigNumber | Bytes | string | number; + +/* +export function isBigNumberLike(value: any): value is BigNumberish { + return (BigNumber.isBigNumber(value) || + (!!((value).toHexString)) || + isBytes(value) || + value.match(/^-?([0-9]+|0x[0-9a-f]+)$/i) || + typeof(value) === "number"); +} +*/ + +export class BigNumber implements Hexable { + readonly _hex: string; + + constructor(constructorGuard: any, hex: string) { + errors.checkNew(new.target, BigNumber); + + if (constructorGuard !== _constructorGuard) { + errors.throwError("cannot call consturtor directly; use BigNumber.from", errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + + defineReadOnly(this, "_hex", hex); + } + + fromTwos(value: number): BigNumber { + return toBigNumber(toBN(this).fromTwos(value)); + } + + toTwos(value: number): BigNumber { + return toBigNumber(toBN(this).toTwos(value)); + } + + abs(): BigNumber { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + } + + add(other: BigNumberish): BigNumber { + return toBigNumber(toBN(this).add(toBN(other))); + } + + sub(other: BigNumberish): BigNumber { + return toBigNumber(toBN(this).sub(toBN(other))); + } + + div(other: BigNumberish): BigNumber { + let o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + } + + mul(other: BigNumberish): BigNumber { + return toBigNumber(toBN(this).mul(toBN(other))); + } + + mod(other: BigNumberish): BigNumber { + return toBigNumber(toBN(this).mod(toBN(other))); + } + + pow(other: BigNumberish): BigNumber { + return toBigNumber(toBN(this).pow(toBN(other))); + } + + maskn(value: number): BigNumber { + return toBigNumber(toBN(this).maskn(value)); + } + + eq(other: BigNumberish): boolean { + return toBN(this).eq(toBN(other)); + } + + lt(other: BigNumberish): boolean { + return toBN(this).lt(toBN(other)); + } + + lte(other: BigNumberish): boolean { + return toBN(this).lte(toBN(other)); + } + + gt(other: BigNumberish): boolean { + return toBN(this).gt(toBN(other)); + } + + gte(other: BigNumberish): boolean { + return toBN(this).gte(toBN(other)); + } + + isZero(): boolean { + return toBN(this).isZero(); + } + + toNumber(): number { + try { + return toBN(this).toNumber(); + } catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + } + + toString(): string { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + errors.throwError("bigNumber.toString does not accept parameters", errors.UNEXPECTED_ARGUMENT, { }); + } + return toBN(this).toString(10); + } + + toHexString(): string { + return this._hex; + } + + static from(value: any): BigNumber { + if (value instanceof BigNumber) { return value; } + + if (typeof(value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + } + + return errors.throwArgumentError("invalid BigNumber string", "value", value); + } + + if (typeof(value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + + return BigNumber.from(String(value)); + } + + if (typeof(value) === "bigint") { + return BigNumber.from((value).toString()); + } + + if (isBytes(value)) { + return BigNumber.from(hexlify(value)); + } + + if ((value)._hex && isHexString((value)._hex)) { + return BigNumber.from((value)._hex); + } + + if ((value).toHexString) { + value = (value).toHexString(); + if (typeof(value) === "string") { + return BigNumber.from(value); + } + } + + return errors.throwArgumentError("invalid BigNumber value", "value", value); + } + + static isBigNumber(value: any): value is BigNumber { + return isNamedInstance(this, value); + } +} + +/* +export function bigNumberify(value: BigNumberish): BigNumber { + if (BigNumber.isBigNumber(value)) { return value; } + return new BigNumber(value); +} +*/ + +/* +function zeros(length) { + let result = ""; + while (result.length < length) { tens += "0"; } + return result; +} +export class FixedNumber { + readonly value: BigNumber; + readonly decimalPlaces: number; + + constructor(value: BigNumberish, decimalPlaces: number) { + defineReadOnly(this, "value", bigNumberify(value)); + defineReadOnly(this, "decimalPlaces", decimalPlaces); + } + + toString(): string { + return formatUnits(this.value, this.decimalPlaces); + } + + static fromString(value: string): FixedNumber { + let comps = value.split("."); + let decimalPlaces = 0; + if (comps.length === 2) { decimalPlaces = comps[1].length; } + return new FixedNumber(parseUnits(value, decimalPlaces), decimalPlaces); + } +*/ +/* + + readonly negative: boolean; + readonly whole: BigNumber; + readonly fraction: BigNumber; + constructor(whole: BigNumberish, fraction: BigNumberish, negative?: boolean) { + if (whole.lt(constants.Zero)) { + errors.throwError("whole component must be positive", errors.INVALID_ARGUMENT, { + argument: whole, + value: whole + }); + } + defineReadOnly(this, "whole", bigNumberify(whole)); + defineReadOnly(this, "fraction", bigNumberify(fraction)); + defineReadOnly(this, "negative", !!boolean); + } +*/ +/* + toHexString(bitWidth?: number, decimalPlaces?: number, signed?: boolean): string { + if (bitWidth == null) { bitWidth = 128; } + if (decimalPlaces == null) { decimalPlaces = 18; } + if (signed == null) { signed = true; } + return null; + } + static fromValue(value: BigNumberish, decimalPlaces: number): FixedNumber { + let negative = false; + if (value.lt(constants.Zero)) { + negative = true; + value = value.abs(); + } + let tens = bigNumberify("1" + zeros(decimalPlaces)); + return new FixedNumber(value.divide(tens), value.mod(tens), negative); + } + let negative = false; + if (value.substring(0, 1) === "-") { + negative = true; + value = value.substring(1); + } + + if (value !== "." && value !== "") { + let comps = value.split("."); + if (comps.length === 1) { + return new FixedNumber(comps[0], 0, negative); + } else if (comps.length === 2) { + if (comps[0] === "") { comps[0] = "0"; } + if (comps[1] === "") { comps[1] = "0"; } + return new FixedNumber(comps[0], comps[1], negative); + } + } + + errors.throwError("invalid fixed-point value", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + + return null; +*/ + +//} + + +// Normalize the hex string +function toHex(value: string | BN.BN): string { + + // For BN, call on the hex string + if (typeof(value) !== "string") { + return toHex(value.toString(16)); + } + + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { errors.throwArgumentError("invalid hex", "value", value); } + + // Call toHex on the positive component + value = toHex(value); + + // Do not allow "-0x00" + if (value === "0x00") { return value; } + + // Negate the value + return "-" + value; + } + + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { value = "0x" + value; } + + // Normalize zero + if (value === "0x") { return "0x00"; } + + // Make the string even length + if (value.length % 2) { value = "0x0" + value.substring(2); } + + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + + return value; +} + +function toBigNumber(value: BN.BN): BigNumber { + return BigNumber.from(toHex(value)); +} + +function toBN(value: BigNumberish): BN.BN { + let hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN.BN("-" + hex.substring(3), 16)); + } + return new BN.BN(hex.substring(2), 16); +} + +function throwFault(fault: string, operation: string, value?: any): never { + let params: any = { fault: fault, operation: operation }; + if (value != null) { params.value = value; } + + return errors.throwError(fault, errors.NUMERIC_FAULT, params); +} diff --git a/packages/bignumber/src.ts/fixednumber.ts b/packages/bignumber/src.ts/fixednumber.ts new file mode 100644 index 000000000..482f1ab7a --- /dev/null +++ b/packages/bignumber/src.ts/fixednumber.ts @@ -0,0 +1,343 @@ +"use strict"; + +import { arrayify, BytesLike, hexZeroPad, isBytes } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly, isNamedInstance } from "@ethersproject/properties"; + +import { BigNumber, BigNumberish } from "./bignumber"; + +const _constructorGuard = { }; + +const Zero = BigNumber.from(0); +const NegativeOne = BigNumber.from(-1); + +function throwFault(message: string, fault: string, operation: string, value?: any): never { + let params: any = { fault: fault, operation: operation }; + if (value !== undefined) { params.value = value; } + return errors.throwError(message, errors.NUMERIC_FAULT, params); +} + +// Constant to pull zeros from for multipliers +let zeros = "0"; +while (zeros.length < 256) { zeros += zeros; } + +// Returns a string "1" followed by decimal "0"s +function getMultiplier(decimals: BigNumberish): string { + + if (typeof(decimals) !== "number") { + try { + decimals = BigNumber.from(decimals).toNumber(); + } catch (e) { } + } + + if (typeof(decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + + return errors.throwArgumentError("invalid decimal size", "decimals", decimals); +} + +export function formatFixed(value: BigNumberish, decimals?: string | BigNumberish): string { + if (decimals == null) { decimals = 0; } + let multiplier = getMultiplier(decimals); + + // Make sure wei is a big number (convert as necessary) + value = BigNumber.from(value); + + let negative = value.lt(Zero); + if (negative) { value = value.mul(NegativeOne); } + + let fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { fraction = "0" + fraction; } + + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + + let whole = value.div(multiplier).toString(); + + value = whole + "." + fraction; + + if (negative) { value = "-" + value; } + + return value; +} + +export function parseFixed(value: string, decimals?: BigNumberish): BigNumber { + if (decimals == null) { decimals = 0; } + let multiplier = getMultiplier(decimals); + + if (typeof(value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + errors.throwArgumentError("invalid decimal value", "value", value); + } + + if (multiplier.length - 1 === 0) { + return BigNumber.from(value); + } + + // Is it negative? + let negative = (value.substring(0, 1) === "-"); + if (negative) { value = value.substring(1); } + + if (value === ".") { + errors.throwArgumentError("missing value", "value", value); + } + + // Split it into a whole and fractional part + let comps = value.split("."); + if (comps.length > 2) { + errors.throwArgumentError("too many decimal points", "value", value); + } + + let whole = comps[0], fraction = comps[1]; + if (!whole) { whole = "0"; } + if (!fraction) { fraction = "0"; } + + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { fraction += "0"; } + + let wholeValue = BigNumber.from(whole); + let fractionValue = BigNumber.from(fraction); + + let wei = (wholeValue.mul(multiplier)).add(fractionValue); + + if (negative) { wei = wei.mul(NegativeOne); } + + return wei; +} + +export class FixedFormat { + readonly signed: boolean; + readonly width: number; + readonly decimals: number; + readonly name: string; + readonly _multiplier: BigNumber; + + constructor(constructorGuard: any, signed: boolean, width: number, decimals: number) { + defineReadOnly(this, "signed", signed); + defineReadOnly(this, "width", width); + defineReadOnly(this, "decimals", decimals); + + let name = (signed ? "": "u") + "fixed" + String(width) + "x" + String(decimals); + defineReadOnly(this, "name", name); + + defineReadOnly(this, "_multiplier", getMultiplier(decimals)); + } + + static from(value: any): FixedFormat { + if (value instanceof FixedFormat) { return value; } + + let signed = true; + let width = 128; + let decimals = 18; + + if (typeof(value) === "string") { + if (value === "fixed") { + // defaults... + } else if (value === "ufixed") { + signed = false; + } else if (value != null) { + let match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { errors.throwArgumentError("invalid fixed format", "format", value); } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } else if (value) { + let check = (key: string, type: string, defaultValue: any): any => { + if (value[key] == null) { return defaultValue; } + if (typeof(value[key]) !== type) { + errors.throwArgumentError("invalid fixed format (" + key + " not " + type +")", "format." + key, value[key]); + } + return value[key]; + } + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + + if (width % 8) { + errors.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + + if (decimals > 80) { + errors.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + + return new FixedFormat(_constructorGuard, signed, width, decimals); + } + + static isInstance(value: any): value is FixedFormat { + return isNamedInstance(this, value); + } +} + +export class FixedNumber { + readonly format: FixedFormat; + readonly _hex: string; + readonly _value: string; + + constructor(constructorGuard: any, hex: string, value: string, format?: FixedFormat) { + errors.checkNew(new.target, FixedNumber); + defineReadOnly(this, 'format', format); + defineReadOnly(this, '_hex', hex); + defineReadOnly(this, '_value', value); + } + + + _checkFormat(other: FixedNumber): void { + if (this.format.name !== other.format.name) { + errors.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + } + + addUnsafe(other: FixedNumber): FixedNumber { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + } + + subUnsafe(other: FixedNumber): FixedNumber { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + } + + mulUnsafe(other: FixedNumber): FixedNumber { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + } + + divUnsafe(other: FixedNumber): FixedNumber { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + } + + // @TODO: Support other rounding algorithms + round(decimals?: number): FixedNumber { + if (decimals == null) { decimals = 0; } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + errors.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + + // If we are already in range, we're done + let comps = this.toString().split("."); + if (comps[1].length <= decimals) { return this; } + + // Bump the value up by the 0.00...0005 + let bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + } + + + toString(): string { return this._value; } + + toHexString(width?: number): string { + if (width == null) { return this._hex; } + if (width % 8) { errors.throwArgumentError("invalid byte width", "width", width); } + let hex = BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return hexZeroPad(hex, width / 8); + } + + toUnsafeFloat(): number { return parseFloat(this.toString()); } + + toFormat(format: FixedFormat | string): FixedNumber { + return FixedNumber.fromString(this._value, format); + } + + + static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && (FixedFormat.isInstance(decimals) || typeof(decimals) === "string")) { + format = decimals; + decimals = null; + } + + if (decimals == null) { decimals = 0; } + if (format == null) { format = "fixed"; } + + let fixedFormat = (FixedFormat.isInstance(format) ? format: FixedFormat.from(format)); + return FixedNumber.fromString(formatFixed(value, decimals), fixedFormat); + } + + + static fromString(value: string, format?: FixedFormat | string): FixedNumber { + if (format == null) { format = "fixed"; } + + let fixedFormat = (FixedFormat.isInstance(format) ? format: FixedFormat.from(format)); + + let numeric = parseFixed(value, fixedFormat.decimals); + + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + + let hex: string = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } else { + hex = numeric.toHexString(); + hex = hexZeroPad(hex, fixedFormat.width / 8); + } + + let decimal = formatFixed(numeric, fixedFormat.decimals); + + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + } + + static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber { + if (format == null) { format = "fixed"; } + + let fixedFormat = (FixedFormat.isInstance(format) ? format: FixedFormat.from(format)); + + if (arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + + let numeric = BigNumber.from(value); + if (fixedFormat.signed) { numeric = numeric.fromTwos(fixedFormat.width); } + + let hex = numeric.toTwos((fixedFormat.signed ? 0: 1) + fixedFormat.width).toHexString(); + let decimal = formatFixed(numeric, fixedFormat.decimals); + + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + } + + static from(value: any, format?: FixedFormat | string) { + if (typeof(value) === "string") { + return FixedNumber.fromString(value, format); + } + + if (isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + + try { + return FixedNumber.fromValue(value, 0, format); + } catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== errors.INVALID_ARGUMENT) { + throw error; + } + } + + return errors.throwArgumentError("invalid FixedNumber value", "value", value); + } + + static isFixedNumber(value: any): value is FixedNumber { + return isNamedInstance(this, value); + } +} diff --git a/packages/bignumber/src.ts/index.ts b/packages/bignumber/src.ts/index.ts new file mode 100644 index 000000000..a80c3ba53 --- /dev/null +++ b/packages/bignumber/src.ts/index.ts @@ -0,0 +1,2 @@ +export { BigNumber, BigNumberish } from "./bignumber"; +export { FixedNumber } from "./fixednumber"; diff --git a/packages/bignumber/thirdparty.d.ts b/packages/bignumber/thirdparty.d.ts new file mode 100644 index 000000000..8c07d6bfb --- /dev/null +++ b/packages/bignumber/thirdparty.d.ts @@ -0,0 +1,30 @@ +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; + } +} diff --git a/packages/bignumber/tsconfig.json b/packages/bignumber/tsconfig.json new file mode 100644 index 000000000..f09aa6ba8 --- /dev/null +++ b/packages/bignumber/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts", + "./thirdparty.d.ts" + ], + "exclude": [ ] +} + diff --git a/packages/bytes/.npmignore b/packages/bytes/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/bytes/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/bytes/LICENSE.md b/packages/bytes/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/bytes/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/bytes/README.md b/packages/bytes/README.md new file mode 100644 index 000000000..0616e29a6 --- /dev/null +++ b/packages/bytes/README.md @@ -0,0 +1,17 @@ +Byte Manipulation Libraries +=========================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/bytes/package.json b/packages/bytes/package.json new file mode 100644 index 000000000..f0b473aa7 --- /dev/null +++ b/packages/bytes/package.json @@ -0,0 +1,24 @@ +{ + "name": "@ethersproject/bytes", + "version": "5.0.0-beta.126", + "description": "Bytes utility functions for ethers.", + "main": "index.js", + "scripts": { + "build": "tsc -p ./tsconfig.json", + "auto-build": "npm run build -- -w", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/errors": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xb1a6e6e8b38d5c28de285c858a6a7fe0a505a0de9cb2baa0d07a7c0e3af167d1" +} diff --git a/packages/bytes/src.ts/_version.ts b/packages/bytes/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/bytes/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/bytes/src.ts/index.ts b/packages/bytes/src.ts/index.ts new file mode 100644 index 000000000..8cf1e1d4f --- /dev/null +++ b/packages/bytes/src.ts/index.ts @@ -0,0 +1,445 @@ +"use strict"; + + +import * as errors from "@ethersproject/errors"; + + +/////////////////////////////// +// Exported Types + +export type Bytes = ArrayLike; + +export type BytesLike = Bytes | string; + +export type DataOptions = { + allowMissingPrefix?: boolean; + allowOddLength?: boolean; +}; + +export interface Hexable { + toHexString(): string; +} + + +/* +export interface HexString { + length: number; + substring: (start: number, end?: number) => string; + + [index: number]: string; +} +*/ + +export type SignatureLike = { + r: string; + s?: string; + _vs?: string, + recoveryParam?: number; + v?: number; +} | BytesLike; + +export interface Signature { + r: string; + + s: string; + _vs: string, + + recoveryParam: number; + v: number; +} + +/////////////////////////////// + + +function isHexable(value: any): value is Hexable { + return !!(value.toHexString); +} + +function addSlice(array: Uint8Array): Uint8Array { + if (array.slice) { return array; } + + array.slice = function() { + let args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + } + + return array; +} + +export function isBytesLike(value: any): value is BytesLike { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); +} + +export function isBytes(value: any): value is Bytes { + if (value == null) { return false; } + + if (value.constructor === Uint8Array) { return true; } + if (typeof(value) === "string") { return false; } + if (value.length == null) { return false; } + + for (let i = 0; i < value.length; i++) { + let v = value[i]; + if (v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + + return true; +} + + +export function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array { + if (!options) { options = { }; } + + if (typeof(value) === "number") { + errors.checkSafeUint53(value, "invalid arrayify value"); + + let result = []; + while (value) { + result.unshift(value & 0xff); + value /= 256; + } + if (result.length === 0) { result.push(0); } + + return addSlice(new Uint8Array(result)); + } + + if (options.allowMissingPrefix && typeof(value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + + if (isHexable(value)) { value = value.toHexString(); } + + if (isHexString(value)) { + let hex = (value).substring(2); + if (!options.allowOddLength && hex.length % 2) { + errors.throwArgumentError("hex data is odd-length", "value", value); + } + + let result = []; + for (let i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + + return addSlice(new Uint8Array(result)); + } + + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + + return errors.throwArgumentError("invalid arrayify value", "value", value); +} + +export function concat(items: Array): Uint8Array { + let objects = items.map(item => arrayify(item)); + let length = objects.reduce((accum, item) => (accum + item.length), 0); + + let result = new Uint8Array(length); + + objects.reduce((offset, object) => { + result.set(object, offset); + return offset + object.length; + }, 0); + + return addSlice(result); +} + +export function stripZeros(value: BytesLike): Uint8Array { + let result: Uint8Array = arrayify(value); + + if (result.length === 0) { return result; } + + // Find the first non-zero entry + let start = 0; + while (start < result.length && result[start] === 0) { start++ } + + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + + return result; +} + +export function zeroPad(value: BytesLike, length: number): Uint8Array { + value = arrayify(value); + + if (value.length > length) { + errors.throwArgumentError("value out of range", "value", arguments[0]); + } + + let result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); +} + + +export function isHexString(value: any, length?: number): boolean { + if (typeof(value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false + } + if (length && value.length !== 2 + 2 * length) { return false; } + return true; +} + +const HexCharacters: string = "0123456789abcdef"; + +export function hexlify(value: BytesLike | Hexable | number, options?: DataOptions): string { + if (!options) { options = { }; } + + if (typeof(value) === "number") { + errors.checkSafeUint53(value, "invalid hexlify value"); + + let hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + + if (hex.length) { + if (hex.length % 2) { hex = "0" + hex; } + return "0x" + hex; + } + + return "0x00"; + } + + if (options.allowMissingPrefix && typeof(value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + + if (isHexable(value)) { return value.toHexString(); } + + if (isHexString(value)) { + if (!options.allowOddLength && (value).length % 2) { + errors.throwArgumentError("hex data is odd-length", "value", value); + } + return (value).toLowerCase(); + } + + if (isBytes(value)) { + let result = "0x"; + for (let i = 0; i < value.length; i++) { + let v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + + return errors.throwArgumentError("invalid hexlify value", "value", value); +} + +/* +function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; +} +*/ +export function hexDataLength(data: BytesLike) { + if (typeof(data) !== "string") { + data = hexlify(data); + } else if (!isHexString(data) || (data.length % 2)) { + return null; + } + + return (data.length - 2) / 2; +} + +export function hexDataSlice(data: BytesLike, offset: number, endOffset?: number): string { + if (typeof(data) !== "string") { + data = hexlify(data); + } else if (!isHexString(data) || (data.length % 2)) { + errors.throwArgumentError("invalid hexData", "value", data ); + } + + offset = 2 + 2 * offset; + + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + + return "0x" + data.substring(offset); +} + +export function hexConcat(items: Array): string { + let result = "0x"; + items.forEach((item) => { + result += hexlify(item).substring(2); + }); + return result; +} + +export function hexValue(value: BytesLike | Hexable | number): string { + let trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); + if (trimmed === "0x") { return "0x0"; } + return trimmed; +} + +export function hexStripZeros(value: BytesLike): string { + if (typeof(value) !== "string") { value = hexlify(value); } + + if (!isHexString(value)) { + errors.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + let offset = 0; + while (offset < value.length && value[offset] === "0") { offset++; } + return "0x" + value.substring(offset); +} + +export function hexZeroPad(value: BytesLike, length: number): string { + if (typeof(value) !== "string") { + value = hexlify(value); + } else if (!isHexString(value)) { + errors.throwArgumentError("invalid hex string", "value", value); + } + + if (value.length > 2 * length + 2) { + errors.throwArgumentError("value out of range", "value", arguments[1]); + } + + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + + return value; +} + +export function splitSignature(signature: SignatureLike): Signature { + let result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + + if (isBytesLike(signature)) { + let bytes: Uint8Array = arrayify(signature); + if (bytes.length !== 65) { + errors.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + + // Get the r and s + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + + // Reduce v to the canonical 27 or 28 + result.v = bytes[64]; + if (result.v !== 27 && result.v !== 28) { + result.v = 27 + (result.v % 2); + } + + // Compute recoveryParam from v + result.recoveryParam = (result.v - 27); + + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { bytes[32] |= 0x80; } + result._vs = hexlify(bytes.slice(32, 64)) + + } else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + + // Normalize v into a canonical 27 or 28 + if (result.v != null && !(result.v == 27 || result.v == 28)) { + result.v = 27 + (result.v % 2); + } + + // Populate a missing v or recoveryParam if possible + if (result.recoveryParam == null && result.v != null) { + result.recoveryParam = 1 - (result.v % 2); + } else if (result.recoveryParam != null && result.v == null) { + result.v = 27 + result.recoveryParam; + } else if (result.recoveryParam != null && result.v != null) { + if (result.v !== 27 + result.recoveryParam) { + errors.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + } + } + + // Make sure r and s are padded properly + if (result.r != null) { result.r = hexZeroPad(result.r, 32); } + if (result.s != null) { result.s = hexZeroPad(result.s, 32); } + + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + result._vs = hexZeroPad(result._vs, 32); + if (result._vs.length > 66) { + errors.throwArgumentError("signature _vs overflow", "signature", signature); + } + + let vs = arrayify(result._vs); + + let recoveryParam = ((vs[0] >= 128) ? 1: 0); + let v = 27 + result.recoveryParam; + + // Use _vs to compute s + vs[0] &= 0x7f; + let s = hexlify(vs); + + // Check _vs aggress with other parameters + + if (result.s == null) { + result.s = s; + } else if (result.s !== s) { + errors.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + + if (result.v == null) { + result.v = v; + } else if (result.v !== v) { + errors.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + + if (recoveryParam == null) { + result.recoveryParam = recoveryParam; + } else if (result.recoveryParam !== recoveryParam) { + errors.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + } + + // After all populating, both v and recoveryParam are still missing... + if (result.v == null && result.recoveryParam == null) { + errors.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + } + + // Check for canonical v + if (result.v !== 27 && result.v !== 28) { + errors.throwArgumentError("signature v not canonical", "signature", signature); + } + + // Check that r and s are in range + if (result.r.length > 66 || result.s.length > 66) { + errors.throwArgumentError("signature overflow r or s", "signature", signature); + } + + if (result._vs == null) { + let vs = arrayify(result.s); + if (vs[0] >= 128) { + errors.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { vs[0] |= 0x80; } + result._vs = hexlify(vs); + } + } + + return result; +} + +export function joinSignature(signature: Signature): string { + signature = splitSignature(signature); + + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c": "0x1b") + ])); +} + diff --git a/packages/bytes/tsconfig.json b/packages/bytes/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/bytes/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/cli/.gitignore b/packages/cli/.gitignore new file mode 100644 index 000000000..13cc592f7 --- /dev/null +++ b/packages/cli/.gitignore @@ -0,0 +1 @@ +bin/*.ts diff --git a/packages/cli/package.json b/packages/cli/package.json new file mode 100644 index 000000000..1afee4cba --- /dev/null +++ b/packages/cli/package.json @@ -0,0 +1,31 @@ +{ + "name": "@ethersproject/cli", + "version": "5.0.0-beta.129", + "description": "Command-Line Interface scripts and releated utilities.", + "main": "index.js", + "scripts": { + "test": "exit 1" + }, + "bin": { + "ethers": "./bin/ethers.js", + "ethers-ts": "./bin/ethers-ts.js" + }, + "dependencies": { + "@types/node": "^10.3.2", + "ethers": ">5.0.0-beta.0", + "mime-types": "2.1.11", + "solc": "^0.5.5", + "solidity-parser-antlr": "^0.3.2" + }, + "keywords": [ + "Ethereum", + "ethers", + "cli" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xf1056c4f8e2c3d6896510821ac3042b3e73bee3312c9c046518115c9fe9df45b" +} diff --git a/packages/cli/src.ts/_version.ts b/packages/cli/src.ts/_version.ts new file mode 100644 index 000000000..cc0f13f68 --- /dev/null +++ b/packages/cli/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.129"; diff --git a/packages/cli/src.ts/bin/ethers-ts.ts b/packages/cli/src.ts/bin/ethers-ts.ts new file mode 100644 index 000000000..e36b256cd --- /dev/null +++ b/packages/cli/src.ts/bin/ethers-ts.ts @@ -0,0 +1,126 @@ +#!/usr/bin/env node + +'use strict'; + +import fs from 'fs'; +import { join as pathJoin } from "path"; + +import { ethers } from 'ethers'; + +import { ArgParser, CLI, Plugin } from '../cli'; +import { header as Header, generate as generateTypeScript } from "../typescript"; +import { compile, ContractCode } from "../solc"; + +function computeHash(content: string): string { + let bareContent = content.replace(/\/\*\* Content Hash: 0x[0-9A-F]{64} \*\//i, '/** Content Hash: */'); + return ethers.utils.id(bareContent); +} + +function checkHash(content: string): boolean { + let match = content.match(/\/\*\* Content Hash: (0x[0-9A-F]{64}) \*\//i); + return (match && match[1] === computeHash(content)); +} + +function addContentHash(content: string): string { + let contentHash = computeHash("/** Content Hash: */\n" + content); + return "/** Content Hash: " + contentHash + " */\n" + content; +} + +function save(path: string, content: string, force?: boolean): boolean { + if (fs.existsSync(path) && !force) { + let oldContent = fs.readFileSync(path).toString(); + if (!checkHash(oldContent)) { return false; } + } + fs.writeFileSync(path, content); + return true; +} + +function walkFilenames(filenames: Array): Array { + let result: Array = []; + filenames.forEach((filename) => { + let stat = fs.statSync(filename); + if (stat.isDirectory()) { + walkFilenames(fs.readdirSync(filename).map((x: string) => pathJoin(filename, x))).forEach((filename) => { + result.push(filename); + }); + } else if (stat.isFile()) { + result.push(filename); + } + }); + return result; +} + +let cli = new CLI("generate"); + +class GeneratePlugin extends Plugin { + + filenames: Array; + output: string; + force: boolean; + optimize: boolean; + noBytecode: boolean; + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + this.output = argParser.consumeOption("output"); + this.force = argParser.consumeFlag("force"); + this.optimize = argParser.consumeFlag("no-optimize"); + this.noBytecode = argParser.consumeFlag("no-bytecode"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length === 0) { + this.throwError("generate requires at least one FILENAME"); + } + + this.filenames = args; + } + + + async run(): Promise { + let output = Header; + + walkFilenames(this.filenames).forEach((filename) => { + if (!filename.match(/\.sol$/)) { return; } + let contracts: Array = null; + let content = fs.readFileSync(filename).toString(); + + try { + contracts = compile(content, { filename: filename, optimize: this.optimize }); + } catch (error) { + console.log(error); + if ((error).errors) { + (error).errors.forEach((error: string) => { + console.log(error); + }); + } + + throw new Error("errors during compilation"); + } + + contracts.forEach((contract) => { + output += generateTypeScript(contract, (this.noBytecode ? null: contract.bytecode)); + output += "\n"; + }); + }); + + output = addContentHash(output.trim()); + + if (this.output) { + let success = save(this.output, output, this.force); + if (!success) { + return Promise.reject(new Error("File has been modified; use --force")); + } + } else { + console.log(output); + } + + return Promise.resolve(null); + } +} +cli.addPlugin("generate", GeneratePlugin); + +cli.run(process.argv.slice(2)) diff --git a/packages/cli/src.ts/bin/ethers.ts b/packages/cli/src.ts/bin/ethers.ts new file mode 100644 index 000000000..9364d531a --- /dev/null +++ b/packages/cli/src.ts/bin/ethers.ts @@ -0,0 +1,718 @@ +#!/usr/bin/env node + +"use strict"; + +import fs from "fs"; +import REPL from "repl"; +import util from "util"; +import vm from "vm"; + +import { ethers } from "ethers"; + +import { ArgParser, CLI, dump, Help, Plugin } from "../cli"; +import { getPassword, getProgressBar } from "../prompt"; +import { compile } from "../solc"; + +function setupContext(context: any, plugin: Plugin) { + + context.provider = plugin.provider; + context.accounts = plugin.accounts; + + if (!context.console) { context.console = console; } + if (!context.require) { context.require = require; } + if (!context.process) { context.process = process; } + + context.ethers = ethers; + context.version = ethers.version; + + context.Contract = ethers.Contract; + context.ContractFactory = ethers.ContractFactory; + context.Wallet = ethers.Wallet; + + context.providers = ethers.providers; + context.utils = ethers.utils; + + context.abiCoder = ethers.utils.defaultAbiCoder; + + context.BN = ethers.BigNumber; + context.BigNumber = ethers.BigNumber; + context.FixedNumber = ethers.FixedNumber; + + context.getAddress = ethers.utils.getAddress; + context.getContractAddress = ethers.utils.getContractAddress; + context.getIcapAddress = ethers.utils.getIcapAddress; + + context.arrayify = ethers.utils.arrayify; + context.hexlify = ethers.utils.hexlify; + + context.joinSignature = ethers.utils.joinSignature; + context.splitSignature = ethers.utils.splitSignature; + + context.id = ethers.utils.id; + context.keccak256 = ethers.utils.keccak256; + context.namehash = ethers.utils.namehash; + context.sha256 = ethers.utils.sha256; + + context.parseEther = ethers.utils.parseEther; + context.parseUnits = ethers.utils.parseUnits; + context.formatEther = ethers.utils.formatEther; + context.formatUnits = ethers.utils.formatUnits; + + context.randomBytes = ethers.utils.randomBytes; + context.constants = ethers.constants; + + context.parseTransaction = ethers.utils.parseTransaction; + context.serializeTransaction = ethers.utils.serializeTransaction; + + context.toUtf8Bytes = ethers.utils.toUtf8Bytes; + context.toUtf8String = ethers.utils.toUtf8String; +} + + +const cli = new CLI("sandbox"); + +class SandboxPlugin extends Plugin { + static getHelp(): Help { + return { + name: "sandbox", + help: "Run a REPL VM environment with ethers" + } + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 0) { + this.throwUsageError("Unexpected argument - " + JSON.stringify(args[0])); + } + + for (let i = 0; i < this.accounts.length; i++) { + await this.accounts[i].unlock(); + } + } + + run(): Promise { + console.log("network: " + this.network.name + " (chainId: " + this.network.chainId + ")"); + + let nextPromiseId = 0; + function promiseWriter(output: any): string { + if (output instanceof Promise) { + repl.context._p = output; + let promiseId = nextPromiseId++; + output.then((result) => { + console.log(`\n`); + console.log(util.inspect(result)); + repl.context._r = result; + repl.displayPrompt(true) + }, (error) => { + console.log(`\n`); + console.log(util.inspect(error)); + repl.displayPrompt(true) + }); + return ``; + } + return util.inspect(output); + } + + let repl = REPL.start({ + input: process.stdin, + output: process.stdout, + prompt: (this.provider ? this.network.name: "no-network") + "> ", + writer: promiseWriter + }); + setupContext(repl.context, this); + + return new Promise((resolve) => { + repl.on("exit", function() { + console.log(""); + resolve(null); + }); + }); + } +} +cli.addPlugin("sandbox", SandboxPlugin); + + +class InitPlugin extends Plugin { + filename: string; + force: boolean; + + static getHelp(): Help { + return { + name: "init FILENAME", + help: "Create a new JSON wallet" + } + } + + static getOptionHelp(): Array { + return [ + { + name: "[ --force ]", + help: "Overwrite any existing files" + } + ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + this.force = argParser.consumeFlag("force"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args) + + if (args.length !== 1) { + this.throwUsageError("init requires FILENAME"); + } + + this.filename = args[0]; + } + + async run(): Promise { + if (!this.force && fs.existsSync(this.filename)) { + this.throwError('File already exists (use --force to overwrite)'); + } + + console.log("Creating a new JSON Wallet - " + this.filename); + console.log('Keep this password and file SAFE!! If lost or forgotten'); + console.log('it CANNOT be recovered, by ANYone, EVER.'); + + let password = await getPassword("Choose a password: "); + let confirm = await getPassword("Confirm password: "); + if (password !== confirm) { + this.throwError("Passwords do not match"); + } + + let wallet = ethers.Wallet.createRandom(); + + let progressBar = await getProgressBar("Encrypting"); + let json = await wallet.encrypt(password, { }, progressBar); + + try { + if (this.force) { + fs.writeFileSync(this.filename, json); + } else { + fs.writeFileSync(this.filename, json, { flag: 'wx' }); + } + console.log('New account address: ' + wallet.address); + console.log('Saved: ' + this.filename); + } catch (error) { + if (error.code === 'EEXIST') { + this.throwError('File already exists (use --force to overwrite)'); + } + this.throwError('Unknown Error: ' + error.message); + } + } +} +cli.addPlugin("init", InitPlugin); + + +class FundPlugin extends Plugin { + toAddress: string; + + static getHelp(): Help { + return { + name: "fund TARGET", + help: "Fund TARGET with testnet ether" + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (this.network.name !== "ropsten") { + this.throwError("Funding requires --network ropsten"); + } + + if (args.length !== 1) { + this.throwUsageError("fund requires ADDRESS"); + } + + this.toAddress = await this.getAddress(args[0], "Cannot fund ZERO address", false); + } + + async run(): Promise { + let url = "https:/" + "/api.ethers.io/api/v1/?action=fundAccount&address=" + this.toAddress.toLowerCase(); + return ethers.utils.fetchJson(url).then((data) => { + console.log("Transaction Hash: " + data.hash); + }); + } +} +cli.addPlugin("fund", FundPlugin); + + +class InfoPlugin extends Plugin { + queries: Array; + addresses: Array; + + static getHelp(): Help { + return { + name: "info [ TARGET ... ]", + help: "Dump info for accounts, addresses and ENS names" + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + this.queries = [ ]; + let runners: Array> = []; + + this.accounts.forEach((account, index) => { + this.queries.push(`Account #${index}`); + runners.push(account.getAddress()); + }); + + args.forEach((arg) => { + if (ethers.utils.isAddress(arg)) { + this.queries.push(`Address: ${arg}`); + } else { + this.queries.push(`ENS Name: ${arg}`); + } + runners.push(this.provider.resolveName(arg)); + }) + + this.addresses = await Promise.all(runners); + } + + async run(): Promise { + for (let i = 0; i < this.addresses.length; i++) { + let address = this.addresses[i]; + let { balance, nonce, code, reverse } = await ethers.utils.resolveProperties({ + balance: this.provider.getBalance(address), + nonce: this.provider.getTransactionCount(address), + code: this.provider.getCode(address), + reverse: this.provider.lookupAddress(address) + }); + + let info: any = { + "Address": address, + "Balance": (ethers.utils.formatEther(balance) + " ether"), + "Transaction Count": nonce + } + + if (code != "0x") { + info["Code"] = code; + } + + if (reverse) { + info["Reverse Lookup"] = reverse; + } + + dump(this.queries[i], info); + } + } +} +cli.addPlugin("info", InfoPlugin); + + +class SendPlugin extends Plugin { + toAddress: string; + value: ethers.BigNumber; + allowZero: boolean; + + static getHelp(): Help { + return { + name: "send TARGET ETHER", + help: "Send ETHER ether to TARGET form accounts[0]" + } + } + + static getOptionHelp(): Array { + return [ + { + name: "[ --allow-zero ]", + help: "Allow sending to the address zero" + } + ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + if (this.accounts.length !== 1) { + this.throwUsageError("send requires exacly one account"); + } + + this.allowZero = argParser.consumeFlag("allow-zero"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 2) { + this.throwUsageError("send requires exactly ADDRESS and AMOUNT"); + } + + this.toAddress = await this.getAddress(args[0], "Cannot send to the zero address (use --allow-zero to override)", this.allowZero); + this.value = ethers.utils.parseEther(args[1]); + } + + async run(): Promise { + await this.accounts[0].sendTransaction({ + to: this.toAddress, + value: this.value + });; + } +} +cli.addPlugin("send", SendPlugin); + + +class SweepPlugin extends Plugin { + toAddress: string; + + static getHelp(): Help { + return { + name: "sweep TARGET", + help: "Send all ether from accounts[0] to TARGET" + } + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + if (this.accounts.length !== 1) { + this.throwUsageError("sweep requires exacly one account"); + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwUsageError("sweep requires exactly ADDRESS"); + } + + this.toAddress = await this.getAddress(args[0]);; + } + + async run(): Promise { + + let { balance, gasPrice, code } = await ethers.utils.resolveProperties({ + balance: this.provider.getBalance(this.accounts[0].getAddress()), + gasPrice: (this.gasPrice || this.provider.getGasPrice()), + code: this.provider.getCode(this.toAddress) + }); + + if (code !== "0x") { + this.throwError("Cannot sweep to a contract address"); + } + + let maxSpendable = balance.sub(gasPrice.mul(21000)); + if (maxSpendable.lte(0)) { + this.throwError("Insufficient funds to sweep"); + } + + await this.accounts[0].sendTransaction({ + to: this.toAddress, + gasLimit: 21000, + gasPrice: gasPrice, + value: maxSpendable + }); + } +} +cli.addPlugin("sweep", SweepPlugin); + + +class SignMessagePlugin extends Plugin { + message: string; + hex: boolean; + + static getHelp(): Help { + return { + name: "sign-message MESSAGE", + help: "Sign a MESSAGE with accounts[0]" + } + } + + static getOptionHelp(): Array { + return [ + { + name: "[ --hex ]", + help: "The message content is hex encoded" + } + ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + if (this.accounts.length !== 1) { + this.throwError("sign-message requires exacly one account"); + } + this.hex = argParser.consumeFlag("hex"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("send requires exactly MESSAGE"); + } + + this.message = args[0]; + } + + async run(): Promise { + await this.accounts[0].signMessage(this.message); + } +} +cli.addPlugin("sign-message", SignMessagePlugin); + + +class EvalPlugin extends Plugin { + code: string; + + static getHelp(): Help { + return { + name: "eval CODE", + help: "Run CODE in a VM with ethers" + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("eval requires exactly CODE"); + } + + this.code = args[0]; + } + + async run(): Promise { + let contextObject = { }; + setupContext(contextObject, this); + + let context = vm.createContext(contextObject); + let script = new vm.Script(this.code, { filename: "-" }); + + let result = script.runInContext(context); + if (result instanceof Promise) { + result = await result; + } + + console.log(result); + } +} +cli.addPlugin("eval", EvalPlugin); + + +class RunPlugin extends Plugin { + filename: string; + + static getHelp(): Help { + return { + name: "run FILENAME", + help: "Run FILENAME in a VM with ethers" + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("run requires exactly FILENAME"); + } + + this.filename = args[0]; + } + + async run(): Promise { + let contextObject = { }; + setupContext(contextObject, this); + + let context = vm.createContext(contextObject); + let script = new vm.Script(fs.readFileSync(this.filename).toString(), { filename: this.filename }); + + let result = script.runInContext(context); + if (result instanceof Promise) { + result = await result; + } + + console.log(result); + } +} +cli.addPlugin("run", RunPlugin); + + +class WaitPlugin extends Plugin { + hash: string; + + static getHelp(): Help { + return { + name: "wait HASH", + help: "Wait for a transaction HASH to be mined" + } + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("wait requires exactly HASH"); + } + + this.hash = args[0]; + } + + async run(): Promise { + console.log("Waiting for Transaction:", this.hash); + + let receipt = await this.provider.waitForTransaction(this.hash); + dump("Response:", { + "Block": receipt.blockNumber, + "Block Hash": receipt.blockHash, + "Status": (receipt.status ? "ok": "failed") + }); + } +} +cli.addPlugin("wait", WaitPlugin); + + +class CompilePlugin extends Plugin { + filename: string; + noOptimize: boolean; + warnings: boolean; + + static getHelp(): Help { + return { + name: "compile FILENAME", + help: "Compiles a Solidity contract" + } + } + + static getOptionHelp(): Array { + return [ + { + name: "[ --no-optimize ]", + help: "Do not optimize the compiled output" + }, + { + name: "[ --warnings ]", + help: "Error on any warning" + } + ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + this.noOptimize = argParser.consumeFlag("no-optimize"); + this.warnings = argParser.consumeFlag("warnings"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("compile requires exactly FILENAME"); + } + + this.filename = args[0]; + } + + async run(): Promise { + let source = fs.readFileSync(this.filename).toString(); + let result = compile(source, { + filename: this.filename, + optimize: (!this.noOptimize) + }); + + let output: any = { }; + result.forEach((contract, index) => { + output[contract.name] = { + bytecode: contract.bytecode, + runtime: contract.runtime, + interface: contract.interface.fragments.map((f) => f.format(true)) + }; + }); + + console.log(JSON.stringify(output, null, 4)); + } +} +cli.addPlugin("compile", CompilePlugin); + + +class DeployPlugin extends Plugin { + filename: string; + contractName: string; + noOptimize: boolean; + + static getHelp(): Help { + return { + name: "deploy FILENAME", + help: "Compile and deploy a Solidity contract" + } + } + + static getOptionHelp(): Array { + return [ + { + name: "[ --no-optimize ]", + help: "Do not optimize the compiled output" + }, + { + name: "[ --contract NAME ]", + help: "Specify the contract to deploy" + } + ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + if (this.accounts.length !== 1) { + this.throwError("deploy requires exactly one account"); + } + + this.noOptimize = argParser.consumeFlag("no-optimize"); + this.contractName = argParser.consumeOption("contract"); + } + + async prepareArgs(args: Array): Promise { + await super.prepareArgs(args); + + if (args.length !== 1) { + this.throwError("deploy requires exactly FILENAME"); + } + + this.filename = args[0]; + } + + async run(): Promise { + let source = fs.readFileSync(this.filename).toString(); + let result = compile(source, { + filename: this.filename, + optimize: (!this.noOptimize) + }); + + let codes = result.filter((c) => (c.bytecode !== "0x" && (this.contractName == null || this.contractName == c.name))); + + if (codes.length > 1) { + this.throwError("Please specify a contract with --contract NAME"); + } + + if (codes.length === 0) { + this.throwError("No contract found"); + } + + let factory = new ethers.ContractFactory(codes[0].interface, codes[0].bytecode, this.accounts[0]); + + let contract = await factory.deploy(); + + dump("Deployed:", { + Contract: codes[0].name, + Address: contract.address, + Bytecode: codes[0].bytecode, + Interface: codes[0].interface.fragments.map((f) => f.format(true)) + }); + } +} +cli.addPlugin("deploy", DeployPlugin); + + +cli.run(process.argv.slice(2)); diff --git a/packages/cli/src.ts/cli.ts b/packages/cli/src.ts/cli.ts new file mode 100644 index 000000000..46a78e4e4 --- /dev/null +++ b/packages/cli/src.ts/cli.ts @@ -0,0 +1,754 @@ +"use strict"; + +import fs from "fs"; + +import { ethers } from "ethers"; + +import { getChoice, getPassword, getProgressBar } from "./prompt"; + +class UsageError extends Error { } + + +///////////////////////////// +// Signer + +const signerFuncs = new WeakMap(); +const signers = new WeakMap(); +const alwaysAllow = new WeakMap(); + +// Gets a signer or lazily request it if needed, possibly asking for a password +// to decrypt a JSON wallet +async function getSigner(wrapper: WrappedSigner): Promise { + if (!signers.has(wrapper)) { + let signerFunc: () => Promise = signerFuncs.get(wrapper); + let signer = await signerFunc(); + signers.set(wrapper, signer); + } + return signers.get(wrapper); +} + +// Throws an error if the user does not allow the operation. If "y" is +// selected, all future operations of that type are automatically accepted +async function isAllowed(wrapper: WrappedSigner, message: string): Promise { + if (wrapper.plugin.yes) { + console.log(message + " (--yes => \"y\")"); + return true; + } + + let allowed = alwaysAllow.get(wrapper) || { }; + if (allowed[message]) { + console.log(message + " (previous (a)ll => \"y\")"); + return true; + } + + try { + let allow = await getChoice(message, "yna", "n"); + if (allow === "a") { + allowed[message] = true; + alwaysAllow.set(wrapper, allowed); + } else if (allow === "n") { + throw new Error("Cancelled."); + } + } catch (error) { + throw new Error("Cancelled."); + } + + return true; +} + +function repeat(chr: string, length: number): string { + let result = chr; + while (result.length < length) { result += result; } + return result.substring(0, length); +} + +// @TODO: Make dump recurable for objects + +// Dumps key/value pairs in a nice format +export function dump(header: string, info: any): void { + console.log(header); + let maxLength = Object.keys(info).reduce((maxLength, i) => Math.max(maxLength, i.length), 0); + for (let key in info) { + let value = info[key]; + if (Array.isArray(value)) { + console.log(" " + key + ":"); + value.forEach((value) => { + console.log(" " + value); + }); + } else { + console.log(" " + key + ":" + repeat(" ", maxLength - key.length) + " " + info[key]); + } + } +} + +// This wraps our signers to prevent the private keys and mnemonics from being exposed. +// It is also in charge of user-interaction, requesting permission before signing or +// sending. +class WrappedSigner extends ethers.Signer { + readonly addressPromise: Promise; + readonly provider: ethers.providers.Provider; + readonly plugin: Plugin; + + constructor(addressPromise: Promise, signerFunc: () => Promise, plugin: Plugin) { + super(); + signerFuncs.set(this, signerFunc); + ethers.utils.defineReadOnly(this, "addressPromise", addressPromise); + ethers.utils.defineReadOnly(this, "provider", plugin.provider); + ethers.utils.defineReadOnly(this, "plugin", plugin); + } + + connect(provider?: ethers.providers.Provider): ethers.Signer { + throw new Error("unsupported for now..."); + //return new WrappedSigner(this.addressPromise, () => getSigner(this).then((s) => s.connect(provider)), provider); + } + + async getAddress(): Promise { + return this.addressPromise; + } + + async signMessage(message: string | ethers.utils.Bytes): Promise { + let signer = await getSigner(this); + + let info: any = { }; + if (typeof(message) === "string") { + info["Message"] = JSON.stringify(message); + info["Message (hex)"] = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)); + } else { + let bytes = ethers.utils.arrayify(message); + for (let i = 0; i < bytes.length; i++) { + let c = bytes[i]; + if (c < 32 || c > 126) { + bytes = null; + break; + } + } + if (bytes) { + info["Message"] = ethers.utils.toUtf8String(bytes); + } + info["Message (hex)"] = ethers.utils.hexlify(message); + } + + dump("Message:", info); + + await isAllowed(this, "Sign Message?"); + + let result = await signer.signMessage(message) + + let signature = ethers.utils.splitSignature(result); + dump("Signature", { + Flat: result, + r: signature.r, + s: signature.s, + vs: signature._vs, + v: signature.v, + recid: signature.recoveryParam, + }); + + return result; + } + + async signTransaction(transactionRequest: ethers.providers.TransactionRequest): Promise { + let signer = await getSigner(this); + + let network = await this.provider.getNetwork(); + + let tx = await ethers.utils.resolveProperties(transactionRequest); + + let info: any = { }; + if (tx.to != null) { info["To"] = tx.to; } + if (tx.from != null) { info["From"] = tx.from; } + info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); + if (tx.nonce != null) { info["None"] = tx.nonce; } + info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); + info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), + info["Chain ID"] = (tx.chainId || 0); + info["Data"] = ethers.utils.hexlify(tx.data || "0x"); + info["Network"] = network.name; + + dump("Transaction:", info); + + await isAllowed(this, "Sign Transaction?"); + + let result = await signer.signTransaction(transactionRequest); + + let signature = ethers.utils.splitSignature(result); + dump("Signature:", { + Signature: result, + r: signature.r, + s: signature.s, + vs: signature._vs, + v: signature.v, + recid: signature.recoveryParam, + }); + + return result; + } + + async sendTransaction(transactionRequest: ethers.providers.TransactionRequest): Promise { + let signer = await getSigner(this); + + let network = await this.provider.getNetwork(); + + let tx: any = await signer.populateTransaction(transactionRequest); + tx = await ethers.utils.resolveProperties(tx); + + let info: any = { }; + if (tx.to != null) { info["To"] = tx.to; } + if (tx.from != null) { info["From"] = tx.from; } + info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); + if (tx.nonce != null) { info["None"] = tx.nonce; } + info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); + info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), + info["Chain ID"] = (tx.chainId || 0); + info["Data"] = ethers.utils.hexlify(tx.data || "0x"); + info["Network"] = network.name; + + dump("Transaction:", info); + + await isAllowed(this, "Send Transaction?"); + + let response = await signer.sendTransaction(tx); + + dump("Response:", { + "Hash": response.hash + }); + + return response; + } + + async unlock(): Promise { + await getSigner(this); + } +} + + +///////////////////////////// +// Argument Parser + +export class ArgParser { + readonly _args: Array + readonly _consumed: Array + + constructor(args: Array) { + ethers.utils.defineReadOnly(this, "_args", args); + ethers.utils.defineReadOnly(this, "_consumed", args.map((a) => false)); + } + + _finalizeArgs(): Array { + let args = [ ]; + for (let i = 0; i < this._args.length; i++) { + if (this._consumed[i]) { continue; } + + let arg = this._args[i]; + + // Escaped args, add the rest as args + if (arg === "--") { + for (let j = i + 1; j < this._args.length; j++) { + args.push(this._args[j]); + } + break; + } + + if (arg.substring(0, 2) === "--") { + throw new UsageError(`unexpected option ${arg}`); + } + + args.push(arg); + } + return args; + } + + _checkCommandIndex() { + for (let i = 0; i < this._args.length; i++) { + if (this._consumed[i]) { continue; } + return i; + } + return -1; + } + + consumeFlag(name: string): boolean { + let count = 0; + for (let i = 0; i < this._args.length; i++) { + let arg = this._args[i]; + if (arg === "--") { break; } + if (arg === ("--" + name)) { + count++; + this._consumed[i] = true; + } + } + + if (count > 1) { + throw new UsageError("expected at most one --${name}"); + } + + return (count === 1); + } + + consumeMultiOptions(names: Array): Array<{ name: string, value: string }> { + let result: Array<{ name: string, value: string }> = [ ]; + + if (typeof(names) === "string") { names = [ names ]; } + + for (let i = 0; i < this._args.length; i++) { + let arg = this._args[i]; + if (arg === "--") { break; } + if (arg.substring(0, 2) === "--") { + let name = arg.substring(2); + let index = names.indexOf(name); + if (index < 0) { continue; } + + if (this._args.length === i) { + throw new UsageError("missing argument for --${name}"); + } + this._consumed[i] = true; + result.push({ name: name, value: this._args[++i] }); + this._consumed[i] = true; + } + } + + return result; + } + + consumeOptions(name: string): Array { + return this.consumeMultiOptions([ name ]).map((o) => o.value); + } + + consumeOption(name: string): string { + let options = this.consumeOptions(name); + if (options.length > 1) { + throw new UsageError(`expected at most one --${name}`); + } + return (options.length ? options[0]: null); + } +} + +// Accepts: +// - "-" which indicates to read from the terminal using prompt (which can then be any of the below) +// - JSON Wallet filename (which will require a password to unlock) +// - raw private key +// - mnemonic +async function loadAccount(arg: string, plugin: Plugin): Promise { + + // Secure entry; use prompt with mask + if (arg === "-") { + let content = await getPassword("Private Key / Mnemonic:"); + return loadAccount(content, plugin); + } + + // Raw private key + if (ethers.utils.isHexString(arg, 32)) { + let signer = new ethers.Wallet(arg, plugin.provider) + return Promise.resolve(new WrappedSigner(signer.getAddress(), () => Promise.resolve(signer), plugin)); + } + + // Mnemonic + if (ethers.utils.isValidMnemonic(arg)) { + let signer = ethers.Wallet.fromMnemonic(arg).connect(plugin.provider); + return Promise.resolve(new WrappedSigner(signer.getAddress(), () => Promise.resolve(signer), plugin)); + } + + // Check for a JSON wallet + try { + let content = fs.readFileSync(arg).toString(); + let address = ethers.utils.getJsonWalletAddress(content); + if (address) { + return Promise.resolve(new WrappedSigner( + Promise.resolve(address), + async (): Promise => { + let password = await getPassword(`Password (${arg}): `); + + let progressBar = getProgressBar("Decrypting"); + return ethers.Wallet.fromEncryptedJson(content, password, progressBar).then((wallet) => { + return wallet.connect(plugin.provider); + }); + }, + plugin)); + } + } catch (error) { + if (error.message === "cancelled") { + throw new Error("Cancelled."); + } else if (error.message === "wrong password") { + throw new Error("Incorrect password."); + } + } + + throw new UsageError("unknown account option - [REDACTED]"); + return null; +} + + +///////////////////////////// +// Plugin Class + +export interface Help { + name: string; + help: string; +} + +export interface PluginType { + new(...args: any[]): Plugin; + getHelp?: () => Help; + getOptionHelp?: () => Array; +} + +export class Plugin { + network: ethers.providers.Network; + provider: ethers.providers.Provider; + + accounts: Array; + + gasLimit: ethers.BigNumber; + gasPrice: ethers.BigNumber; + nonce: number; + data: string; + value: ethers.BigNumber; + yes: boolean; + + constructor() { + } + + static getHelp(): Help { + return null; + } + + static getOptionHelp(): Array { + return [ ]; + } + + async prepareOptions(argParser: ArgParser): Promise { + let runners: Array> = [ ]; + + this.yes = argParser.consumeFlag("yes"); + + ///////////////////// + // Provider + + let network = (argParser.consumeOption("network") || "homestead"); + let providers: Array = [ ]; + + let rpc: Array = [ ]; + argParser.consumeOptions("rpc").forEach((url) => { + let provider = new ethers.providers.JsonRpcProvider(url) + providers.push(provider); + rpc.push(provider); + }); + + if (argParser.consumeFlag("alchemy")) { + providers.push(new ethers.providers.AlchemyProvider(network)); + } + + if (argParser.consumeFlag("etherscan")) { + providers.push(new ethers.providers.EtherscanProvider(network)); + } + + if (argParser.consumeFlag("infura")) { + providers.push(new ethers.providers.InfuraProvider(network)); + } + + if (argParser.consumeFlag("nodesmith")) { + providers.push(new ethers.providers.NodesmithProvider(network)); + } + + if (providers.length === 1) { + this.provider = providers[0]; + } else if (providers.length) { + this.provider = new ethers.providers.FallbackProvider(providers); + } else { + this.provider = ethers.getDefaultProvider(network); + } + + + ///////////////////// + // Accounts + + let accounts: Array = [ ]; + + let accountOptions = argParser.consumeMultiOptions([ "account", "account-rpc", "account-void" ]); + for (let i = 0; i < accountOptions.length; i++) { + let account = accountOptions[i]; + switch (account.name) { + case "account": + let wrappedSigner = await loadAccount(account.value, this); + accounts.push(wrappedSigner); + break; + + case "account-rpc": + if (rpc.length !== 1) { + this.throwUsageError("--account-rpc requires exactly one JSON-RPC provider"); + } + + try { + let signer: ethers.providers.JsonRpcSigner = null; + if (account.value.match(/^[0-9]+$/)) { + signer = rpc[0].getSigner(parseInt(account.value)); + } else { + signer = rpc[0].getSigner(ethers.utils.getAddress(account.value)); + } + accounts.push(new WrappedSigner(signer.getAddress(), () => Promise.resolve(signer), this)); + } catch (error) { + this.throwUsageError("invalid --account-rpc - " + account.value); + } + break; + + case "account-void": { + let addressPromise = this.provider.resolveName(account.value); + let signerPromise = addressPromise.then((addr) => { + return new ethers.VoidSigner(addr, this.provider); + }); + accounts.push(new WrappedSigner(addressPromise, () => signerPromise, this)); + break; + } + } + } + + this.accounts = accounts; + + + ///////////////////// + // Transaction Options + + let gasPrice = argParser.consumeOption("gas-price"); + if (gasPrice) { + this.gasPrice = ethers.utils.parseUnits(gasPrice, "gwei"); + } + + let gasLimit = argParser.consumeOption("gas-limit"); + if (gasLimit) { + this.gasLimit = ethers.BigNumber.from(gasLimit); + } + + let nonce = argParser.consumeOption("nonce"); + if (nonce) { + this.nonce = ethers.BigNumber.from(nonce).toNumber(); + } + + let value = argParser.consumeOption("value"); + if (value) { + this.value = ethers.utils.parseEther(value); + } + + let data = argParser.consumeOption("data"); + if (data) { + this.data = ethers.utils.hexlify(data); + } + + + // Now wait for all asynchronous options to load + + runners.push(this.provider.getNetwork().then((network) => { + this.network = network; + }, (error) => { + this.network = { + chainId: 0, + name: "no-network" + } + })); + + try { + await Promise.all(runners) + } catch (error) { + this.throwError(error); + } + } + + prepareArgs(args: Array): Promise { + return Promise.resolve(null); + } + + run(): Promise { + return null; + } + + getAddress(addressOrName: string, message?: string, allowZero?: boolean): Promise { + try { + return Promise.resolve(ethers.utils.getAddress(addressOrName)); + } catch (error) { } + + return this.provider.resolveName(addressOrName).then((address) => { + if (address == null) { + this.throwError("ENS name not configured - " + addressOrName); + } + + if (address === ethers.constants.AddressZero && !allowZero) { + this.throwError(message); + } + + return address; + }); + } + + throwUsageError(message?: string): never { + throw new UsageError(message); + } + + throwError(message: string): never { + throw new Error(message); + } +} + + +///////////////////////////// +// Command Line Runner + +export class CLI { + readonly defaultCommand: string; + //readonly plugins: { [ command: string ]: { new(...args: any[]): Plugin; getHelp(): Help; } }; + readonly plugins: { [ command: string ]: PluginType }; + + constructor(defaultCommand: string) { + ethers.utils.defineReadOnly(this, "defaultCommand", defaultCommand || null); + ethers.utils.defineReadOnly(this, "plugins", { }); + } + + addPlugin(command: string, plugin: PluginType) { + this.plugins[command] = plugin; + } + + showUsage(message?: string, status?: number): never { + // Limit: | | + console.log("Usage:"); + + let lines: Array = []; + for (let cmd in this.plugins) { + let plugin = this.plugins[cmd]; + let help = (plugin.getHelp ? plugin.getHelp(): null); + if (help == null) { continue; } + let helpLine = " " + help.name; + if (helpLine.length > 28) { + lines.push(helpLine); + lines.push(repeat(" ", 30) + help.help); + } else { + helpLine += repeat(" ", 30 - helpLine.length); + lines.push(helpLine + help.help); + } + + let optionHelp = (plugin.getOptionHelp ? plugin.getOptionHelp(): [ ]); + optionHelp.forEach((help) => { + lines.push(" " + help.name + repeat(" ", 27 - help.name.length) + help.help); + }); + } + + if (lines.length) { + if (this.defaultCommand) { + console.log(" ethers [ COMMAND ] [ ARGS ] [ OPTIONS ]"); + console.log(""); + console.log(`COMMANDS (default: ${this.defaultCommand})`); + } else { + console.log(" ethers COMMAND [ ARGS ] [ OPTIONS ]"); + console.log(""); + console.log("COMMANDS"); + } + + lines.forEach((line) => { + console.log(line); + }); + console.log(""); + } + + console.log("ACCOUNT OPTIONS"); + console.log(" --account FILENAME Load a JSON Wallet (crowdsale or keystore)"); + console.log(" --account RAW_KEY Use a private key (insecure *)"); + console.log(" --account 'MNEMONIC' Use a mnemonic (insecure *)"); + console.log(" --account - Use secure entry for a raw key or mnemonic"); + console.log(" --account-void ADDRESS Udd an address as a void signer"); + console.log(" --account-void ENS_NAME Add the resolved address as a void signer"); + console.log(" --account-rpc ADDRESS Add the address from a JSON-RPC provider"); + console.log(" --account-rpc INDEX Add the index from a JSON-RPC provider"); + console.log(""); + console.log("PROVIDER OPTIONS (default: getDefaultProvider)"); + console.log(" --alchemy Include Alchemy"); + console.log(" --etherscan Include Etherscan"); + console.log(" --infura Include INFURA"); + console.log(" --nodesmith Include nodesmith"); + console.log(" --rpc URL Include a custom JSON-RPC"); + console.log(" --network NETWORK Network to connect to (default: homestead)"); + console.log(""); + console.log("TRANSACTION OPTIONS (default: query the network)"); + console.log(" --gasPrice GWEI Default gas price for transactions(in wei)"); + console.log(" --gasLimit GAS Default gas limit for transactions"); + console.log(" --nonce NONCE Initial nonce for the first transaction"); + console.log(" --value VALUE Default value (in ether) for transactions"); + console.log(" --yes Always accept Siging and Sending"); + console.log(""); + console.log("OTHER OPTIONS"); + console.log(" --help Show this usage and quit"); + console.log(""); + console.log("(*) By including mnemonics or private keys on the command line they are"); + console.log(" possibly readable by other users on your system and may get stored in"); + console.log(" your bash history file."); + console.log(""); + + if (message) { + console.log(message); + console.log(""); + } + + process.exit(status || 0); + throw new Error("never reached"); + } + + async run(args: Array): Promise { + args = args.slice(); + + let command: string = null; + + // We run a temporary argument parser to check for a command by processing standard options + { + let argParser = new ArgParser(args); + + [ "debug", "help", "yes"].forEach((key) => { + argParser.consumeFlag(key); + }); + + [ "alchemy", "etherscan", "infura", "nodesmith" ].forEach((flag) => { + argParser.consumeFlag(flag); + }); + [ "network", "rpc", "account", "account-rpc", "account-void", "gas-price", "gas-limit", "nonce", "data" ].forEach((option) => { + argParser.consumeOption(option); + }); + + let commandIndex = argParser._checkCommandIndex(); + if (commandIndex === -1) { + command = this.defaultCommand; + } else { + command = args[commandIndex]; + args.splice(commandIndex, 1); + } + } + + // Reset the argument parser + let argParser = new ArgParser(args); + if (argParser.consumeFlag("help")) { + return this.showUsage(); + } + + let debug = argParser.consumeFlag("debug"); + + // Create PLug-in instance + let plugin: Plugin = null; + try { + plugin = new this.plugins[command](); + } catch (error) { + if (command) { this.showUsage("unknown command - " + command); } + return this.showUsage("no command provided", 1); + } + + try { + await plugin.prepareOptions(argParser); + await plugin.prepareArgs(argParser._finalizeArgs()); + await plugin.run(); + + } catch (error) { + if (debug) { + console.log("----- ------") + console.log(error); + console.log("----- -----") + } + if (error instanceof UsageError) { + return this.showUsage(error.message, 1); + } + console.log("Error: " + error.message); + process.exit(2); + } + } +} diff --git a/packages/cli/src.ts/prompt.ts b/packages/cli/src.ts/prompt.ts new file mode 100644 index 000000000..b830fb2d1 --- /dev/null +++ b/packages/cli/src.ts/prompt.ts @@ -0,0 +1,143 @@ +"use strict"; + +export type PromptOptions = { + choice?: Array; + defaultChoice?: string; + mask?: string; +}; + +function repeat(chr: string, count: number): string { + let result = ""; + while (result.length < count) { result += chr; } + return result; +} + +function _getPrompt(prompt: string, options: PromptOptions, callback: (ctrlC: boolean, message: string) => void) { + process.stdout.write(prompt); + + let stdin = process.stdin; + stdin.resume(); + stdin.setRawMode(true); + stdin.resume(); + stdin.setEncoding('utf8'); + + let message = ''; + + let respond = (ctrlC: boolean, message: string) => { + process.stdout.write('\n'); + stdin.setRawMode(false); + stdin.pause(); + stdin.removeListener('data', handler); + callback(ctrlC, message); + } + + function handler(chr: string): void { + chr = String(chr); + + switch (chr) { + // Enter (ish) + case "\n": + case "\r": + case "\u0004": + if (options.choice) { + if (options.defaultChoice) { + respond(null, options.defaultChoice); + } + } else { + respond(null, message); + } + break; + + // Backspace + case "\u007f": + if (message.length > 0 && options.choice == null) { + message = message.substring(0, message.length - 1); + ((process.stdout)).clearLine(); + ((process.stdout)).cursorTo(0); + if (options.mask) { + process.stdout.write(prompt + repeat(options.mask, message.length)); + } else { + process.stdout.write(prompt + message); + } + } + break; + + // Ctrl-C + case "\u0003": + process.stdout.write('\n[ CTRL-C ]'); + respond(true, null); + break; + + // Any other character + default: + if (options.choice) { + if (options.choice.indexOf(chr) >= 0) { + process.stdout.write(chr); + respond(null, chr); + } + } else { + // More passsword characters + if (options.mask) { + process.stdout.write('*'); + } else { + process.stdout.write(chr); + } + message += chr; + } + break; + } + } + stdin.on('data', handler); +} + +function getPrompt(prompt: string, options: PromptOptions): Promise { + return new Promise((resolve, reject) => { + _getPrompt(prompt, options, (ctrlC, password) => { + if (ctrlC) { + return reject(new Error("cancelled")); + } + resolve(password); + }); + }); +} + + +export function getProgressBar(action: string): (percent: number) => void { + let lastProgress = -1; + return function(percent: number): void { + let progress = Math.trunc(percent * 100); + if (progress == lastProgress) { return; } + lastProgress = progress; + + process.stdin.setRawMode(false); + process.stdin.pause(); + + ((process.stdout)).clearLine(); + ((process.stdout)).cursorTo(0); + process.stdout.write(action + "... " + progress + "%"); + + if (percent === 1) { + process.stdout.write('\n'); + } + } +} + +export function getPassword(prompt: string): Promise { + return getPrompt(prompt, { mask: "*" }); +} + +export function getMessage(prompt: string): Promise { + return getPrompt(prompt, { }); +} + + +// @TODO: Allow choices to be an array, [ "Yes", "No", "All" ] => "(y)es/ (N)o/ (a)ll" +export function getChoice(prompt: string, choices: string, defaultChoice?: string): Promise { + let choice = choices.toLowerCase().split(""); + if (defaultChoice) { + defaultChoice = defaultChoice.toLowerCase(); + } + let options = { choice: choice, defaultChoice: defaultChoice } + let hint = choice.map((c) => ((c === defaultChoice) ? c.toUpperCase(): c)).join("/"); + return getPrompt((prompt + " (" + hint + ") "), options); +} diff --git a/packages/cli/src.ts/solc.ts b/packages/cli/src.ts/solc.ts new file mode 100644 index 000000000..80ddd67e8 --- /dev/null +++ b/packages/cli/src.ts/solc.ts @@ -0,0 +1,96 @@ +'use strict'; + +import fs from "fs"; +import { dirname, resolve } from "path"; + +import { ethers } from "ethers"; + +let _solc: any = null; +function getSolc(): any { + if (!_solc) { + _solc = require("solc"); + } + return _solc; +} + +export interface ContractCode { + interface: ethers.utils.Interface; + name: string; + bytecode?: string; + runtime?: string +}; + +export type CompilerOptions = { + filename?: string; + basedir?: string; + optimize?: boolean; + throwWarnings?: boolean; +}; + +export function compile(source: string, options?: CompilerOptions): Array { + options = ethers.utils.shallowCopy(options || { }); + + if (options.filename && !options.basedir) { + options.basedir = dirname(options.filename); + } + if (!options.filename) { options.filename = "_contract.sol"; } + if (!options.basedir) { options.basedir = "."; } + + let sources: { [ filename: string]: { content: string } } = { }; + sources[options.filename] = { content: source }; + + let input: any = { + language: "Solidity", + sources: sources, + settings: { + outputSelection: { + "*": { + "*": [ "*" ] + } + } + } + }; + + if (options.optimize) { + input.settings.optimizer = { + enabled: true, + runs: 200 + }; + } + + let findImport = (filename: string): { contents?: string, error?: string } => { + try { + return { + contents: fs.readFileSync(resolve(options.basedir, options.filename)).toString() + }; + } catch (error) { + return { error: error.message } + } + }; + + let output = JSON.parse(getSolc().compile(JSON.stringify(input), findImport)); + + let errors = (output.errors || []).filter((x: any) => (x.severity === "error" || options.throwWarnings)).map((x: any) => x.formattedMessage); + if (errors.length) { + let error = new Error("compilation error"); + (error).errors = errors; + throw error; + } + + let result: Array = []; + for (let filename in output.contracts) { + for (let name in output.contracts[filename]) { + let contract = output.contracts[filename][name]; + + result.push({ + name: name, + interface: new ethers.utils.Interface(contract.abi), + bytecode: "0x" + contract.evm.bytecode.object, + runtime: "0x" + contract.evm.deployedBytecode.object + }); + } + } + + return result; +} + diff --git a/packages/cli/src.ts/typescript.ts b/packages/cli/src.ts/typescript.ts new file mode 100644 index 000000000..5a923b154 --- /dev/null +++ b/packages/cli/src.ts/typescript.ts @@ -0,0 +1,127 @@ +"use strict"; + +import { ethers } from "ethers"; + +import { ContractCode } from "./solc"; + + +function getType(param: ethers.utils.ParamType, flexible?: boolean): string { + + if (param.type === "address" || param.type === "string") { return "string"; } + + if (param.type.substring(0, 5) === "bytes") { + if (flexible) { + return "string | ethers.utils.BytesLike"; + } + return "string" + } + + let match = param.type.match(/^(u?int)([0-9]+)$/) + if (match) { + if (flexible) { + return "ethers.BigNumberish"; + } + if (parseInt(match[2]) < 53) { return 'number'; } + return 'ethers.BigNumber'; + } + + if (param.type === "array") { + return "Array<" + getType(param.arrayChildren) + ">"; + } + + if (param.type === "tuple") { + let struct = param.components.map((p, i) => `${p.name || "p_" + i}: ${getType(p, flexible)}`); + return "{ " + struct.join(", ") + " }"; + } + + throw new Error("unknown type"); + return null; +} + +export const header = "import { ethers } from \"ethers\";\n\n" + +export function generate(contract: ContractCode, bytecode?: string): string { + + let lines = [ ]; + + lines.push("export class " + contract.name + " extends ethers.Contract {"); + lines.push(""); + lines.push(" constructor(addressOrName: string, providerOrSigner: ethers.Signer | ethers.providers.Provider) {"); + lines.push(" super(addressOrName, new.target.ABI(), providerOrSigner)"); + lines.push(" }"); + lines.push(""); + lines.push(` connect(providerOrSigner: ethers.Signer | ethers.providers.Provider): ${contract.name} {`); + lines.push(` return new (<{ new(...args: any[]): ${contract.name} }>(this.constructor))(this.address, providerOrSigner)`); + lines.push(" }"); + lines.push(""); + lines.push(` attach(addressOrName: string): ${contract.name} {`); + lines.push(` return new (<{ new(...args: any[]): ${contract.name} }>(this.constructor))(addressOrName, this.signer || this.provider)`); + lines.push(" }"); + + for (let signature in contract.interface.functions) { + if (signature.indexOf('(') === -1) { continue; } + let fragment = contract.interface.functions[signature]; + console.log(fragment); + + let output = "Promise"; + + let overrides = "ethers.CallOverrides"; + if (fragment.constant == false) { + if (fragment.payable) { + overrides = "ethers.PayableOverrides"; + } else { + overrides = "ethers.Overrides"; + } + } else if (fragment.outputs.length > 0) { + if (fragment.outputs.length === 1) { + output = "Promise<" + getType(fragment.outputs[0]) + ">"; + } else { + throw new Error('not implemented yet'); + } + } + + let inputs: Array = []; + let passed: Array = []; + fragment.inputs.forEach((input, index) => { + let name = (input.name || ("p_" + index)); + let type = getType(input, true); + inputs.push(name + ": " + type); + passed.push(name); + }); + inputs.push("_overrides?: " + overrides); + passed.push("_overrides"); + + lines.push(""); + lines.push(` ${fragment.name}(${inputs.join(', ')}): ${output} {`); + lines.push(` return this.functions["${signature}"](${passed.join(", ")});`); + lines.push(" }"); + } + + lines.push(""); + lines.push(" static factory(signer?: ethers.Signer): ethers.ContractFactory {"); + lines.push(" return new ethers.ContractFactory(" + contract.name + ".ABI(), " + contract.name + ".bytecode(), signer);"); + lines.push(" }"); + + lines.push(""); + lines.push(" static bytecode(): string {"); + if (bytecode == null) { + lines.push(' return ethers.errors.throwError("no bytecode provided during generation", ethers.errors.UNSUPPORTED_OPERATION, { operation: "contract.bytecode" });'); + } else { + lines.push(' return "' + bytecode + '";'); + } + lines.push(" }"); + + lines.push(""); + lines.push(" static ABI(): Array {"); + lines.push(" return ["); + contract.interface.fragments.forEach((fragment) => { + lines.push(` "${fragment.format(true)}",`); + }); + lines.push(" ];"); + lines.push(" }"); + lines.push("}"); + let output = lines.join("\n") + "\n" + + return output; +} + diff --git a/packages/cli/thirdparty.d.ts b/packages/cli/thirdparty.d.ts new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/packages/cli/thirdparty.d.ts @@ -0,0 +1 @@ + diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json new file mode 100644 index 000000000..f551276d9 --- /dev/null +++ b/packages/cli/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*", + "./src.ts/bin/*" + ], + "exclude": [ ] +} + diff --git a/packages/constants/.npmignore b/packages/constants/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/constants/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/constants/LICENSE.md b/packages/constants/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/constants/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/constants/README.md b/packages/constants/README.md new file mode 100644 index 000000000..327559c8d --- /dev/null +++ b/packages/constants/README.md @@ -0,0 +1,17 @@ +Etehreum Constants +================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/constants/package.json b/packages/constants/package.json new file mode 100644 index 000000000..280ed2b42 --- /dev/null +++ b/packages/constants/package.json @@ -0,0 +1,22 @@ +{ + "name": "@ethersproject/constants", + "version": "5.0.0-beta.126", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xf33835528c26572d9703ffa048dedf600435f5e4061867a22c5f0a80a8b2da7d" +} diff --git a/packages/constants/src.ts/_version.ts b/packages/constants/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/constants/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/constants/src.ts/index.ts b/packages/constants/src.ts/index.ts new file mode 100644 index 000000000..754744e61 --- /dev/null +++ b/packages/constants/src.ts/index.ts @@ -0,0 +1,33 @@ +"use strict"; + +import { BigNumber } from "@ethersproject/bignumber"; + +const AddressZero = "0x0000000000000000000000000000000000000000"; +const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; + +// NFKD (decomposed) +//const EtherSymbol = "\uD835\uDF63"; + +// NFKC (composed) +const EtherSymbol = "\u039e"; + +const NegativeOne: BigNumber = BigNumber.from(-1); +const Zero: BigNumber = BigNumber.from(0); +const One: BigNumber = BigNumber.from(1); +const Two: BigNumber = BigNumber.from(2); +const WeiPerEther: BigNumber = BigNumber.from("1000000000000000000"); +const MaxUint256: BigNumber = BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + +export { + AddressZero, + HashZero, + + EtherSymbol, + + NegativeOne, + Zero, + One, + Two, + WeiPerEther, + MaxUint256 +}; diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/constants/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/contracts/.npmignore b/packages/contracts/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/contracts/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/contracts/LICENSE.md b/packages/contracts/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/contracts/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/contracts/README.md b/packages/contracts/README.md new file mode 100644 index 000000000..f8d0aaf91 --- /dev/null +++ b/packages/contracts/README.md @@ -0,0 +1,17 @@ +Ethereum Contract Meta-Class +============================ + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/contracts/package.json b/packages/contracts/package.json new file mode 100644 index 000000000..b82a084e1 --- /dev/null +++ b/packages/contracts/package.json @@ -0,0 +1,31 @@ +{ + "name": "@ethersproject/contracts", + "version": "5.0.0-beta.127", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abi": ">5.0.0-beta.0", + "@ethersproject/abstract-provider": ">5.0.0-beta.0", + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x3c18af73c012369861311cba72ffc90bb5d93c59c325df3d1d1f22b742f01171" +} diff --git a/packages/contracts/src.ts/_version.ts b/packages/contracts/src.ts/_version.ts new file mode 100644 index 000000000..6508cc3a6 --- /dev/null +++ b/packages/contracts/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.127"; diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts new file mode 100644 index 000000000..82dffe47f --- /dev/null +++ b/packages/contracts/src.ts/index.ts @@ -0,0 +1,864 @@ +"use strict"; + +import { EventFragment, Fragment, Indexed, Interface, JsonFragment, ParamType } from "@ethersproject/abi"; +import { Block, BlockTag, Listener, Log, Provider, TransactionReceipt, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { Signer, VoidSigner } from "@ethersproject/abstract-signer"; +import { getContractAddress } from "@ethersproject/address"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike, concat, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; +import { Zero } from "@ethersproject/constants"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly, deepCopy, isNamedInstance, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { UnsignedTransaction } from "@ethersproject/transactions"; + + +export interface Overrides { + gasLimit?: BigNumberish | Promise; + gasPrice?: BigNumberish | Promise; + nonce?: BigNumberish | Promise; +} + +export interface PayableOverrides extends Overrides { + value?: BigNumberish | Promise; +} + +export interface CallOverrides extends PayableOverrides { + blockTag?: BlockTag | Promise; + from?: string | Promise +} + +export type ContractFunction = (...params: Array) => Promise; + +export type EventFilter = { + address?: string; + topics?: Array; + // @TODO: Support OR-style topcis; backwards compatible to make this change + //topics?: Array> +}; + +// The (n + 1)th parameter passed to contract event callbacks +export interface Event extends Log { + + // The event name + event?: string; + + // The event signature + eventSignature?: string; + + // The parsed arguments to the event + values?: Array; + + // A function that can be used to decode event data and topics + decode?: (data: string, topics?: Array) => any; + + // A function that will remove the listener responsible for this event (if any) + removeListener: () => void; + + // Get blockchain details about this event's block and transaction + getBlock: () => Promise; + getTransaction: () => Promise; + getTransactionReceipt: () => Promise; +} + +export interface ContractReceipt extends TransactionReceipt { + events?: Array; +} + +export interface ContractTransaction extends TransactionResponse { + wait(confirmations?: number): Promise; +} + +/////////////////////////////// + +const allowedTransactionKeys: { [ key: string ]: boolean } = { + chainId: true, data: true, from: true, gasLimit: true, gasPrice:true, nonce: true, to: true, value: true +} + +// Recursively replaces ENS names with promises to resolve the name and +// stalls until all promises have returned +// @TODO: Expand this to resolve any promises too +function resolveAddresses(signerOrProvider: Signer | Provider, value: any, paramType: ParamType | Array): Promise { + if (Array.isArray(paramType)) { + return Promise.all(paramType.map((paramType, index) => { + return resolveAddresses( + signerOrProvider, + ((Array.isArray(value)) ? value[index]: value[paramType.name]), + paramType + ); + })); + } + + if (paramType.type === "address") { + return signerOrProvider.resolveName(value); + } + + if (paramType.type === "tuple") { + return resolveAddresses(signerOrProvider, value, paramType.components); + } + + // Strips one level of array indexing off the end to recuse into + //let isArrayMatch = paramType.type.match(/(.*)(\[[0-9]*\]$)/); + if (paramType.baseType === "array") { + if (!Array.isArray(value)) { throw new Error("invalid value for array"); } + return Promise.all(value.map((v) => resolveAddresses(signerOrProvider, v, paramType.arrayChildren))); + } + + return Promise.resolve(value); +} + +type RunFunction = (...params: Array) => Promise; + +type RunOptions = { + estimate?: boolean; + callStatic?: boolean; + payable?: boolean; + transaction?: boolean; +}; + +function runMethod(contract: Contract, functionName: string, options: RunOptions): RunFunction { + let method = contract.interface.functions[functionName]; + return function(...params): Promise { + let tx: any = {} + + let blockTag: BlockTag = null; + + // If 1 extra parameter was passed in, it contains overrides + if (params.length === method.inputs.length + 1 && typeof(params[params.length - 1]) === "object") { + tx = shallowCopy(params.pop()); + + if (tx.blockTag != null) { + blockTag = tx.blockTag; + } + + delete tx.blockTag; + + // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") + for (let key in tx) { + if (!allowedTransactionKeys[key]) { + errors.throwError(("unknown transaxction override - " + key), "overrides", tx); + } + } + } + + errors.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + + // Check overrides make sense + ["data", "to"].forEach(function(key) { + if (tx[key] != null) { + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }); + } + }); + + // If the contract was just deployed, wait until it is minded + if (contract.deployTransaction != null) { + tx.to = contract._deployed(blockTag).then(() => { + return contract.addressPromise; + }); + } else { + tx.to = contract.addressPromise; + } + + return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then((params) => { + tx.data = contract.interface.encodeFunctionData(method, params); + if (method.constant || options.callStatic) { + + // Call (constant functions) always cost 0 ether + if (options.estimate) { + return Promise.resolve(Zero); + } + + if (!contract.provider && !contract.signer) { + errors.throwError("call (constant functions) require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "call" }) + } + + // Check overrides make sense + ["gasLimit", "gasPrice", "value"].forEach(function(key) { + if (tx[key] != null) { + throw new Error("call cannot override " + key) ; + } + }); + + if (options.transaction) { return resolveProperties(tx); } + + return (contract.signer || contract.provider).call(tx, blockTag).then((value) => { + + try { + let result = contract.interface.decodeFunctionResult(method, value); + if (method.outputs.length === 1) { + result = result[0]; + } + return result; + + } catch (error) { + if (error.code === errors.CALL_EXCEPTION) { + error.address = contract.address; + error.args = params; + error.transaction = tx; + } + throw error; + } + }); + + } + + // Only computing the transaction estimate + if (options.estimate) { + if (!contract.provider && !contract.signer) { + errors.throwError("estimate require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }) + } + + return (contract.signer || contract.provider).estimateGas(tx); + } + + if (tx.gasLimit == null && method.gas != null) { + tx.gasLimit = BigNumber.from(method.gas).add(21000); + } + + if (tx.value != null && !method.payable) { + errors.throwError("contract method is not payable", errors.INVALID_ARGUMENT, { + argument: "sendTransaction", + value: tx, + method: method.format() + }) + } + + if (!contract.signer) { + errors.throwError("sending a transaction require a signer", errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }) + } + + if (options.transaction) { return tx; } + + return contract.signer.sendTransaction(tx).then((tx) => { + let wait = tx.wait.bind(tx); + + tx.wait = (confirmations?: number) => { + return wait(confirmations).then((receipt: ContractReceipt) => { + receipt.events = receipt.logs.map((log) => { + let event: Event = (deepCopy(log)); + + let parsed = contract.interface.parseLog(log); + if (parsed) { + event.values = parsed.values; + event.decode = (data: BytesLike, topics?: Array) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.event = parsed.name; + event.eventSignature = parsed.signature; + } + + event.removeListener = () => { return contract.provider; } + event.getBlock = () => { + return contract.provider.getBlock(receipt.blockHash); + } + event.getTransaction = () => { + return contract.provider.getTransaction(receipt.transactionHash); + } + event.getTransactionReceipt = () => { + return Promise.resolve(receipt); + } + + return event; + }); + + return receipt; + }); + }; + + return tx; + }); + }); + } +} + +function getEventTag(filter: EventFilter): string { + if (filter.address && (filter.topics == null || filter.topics.length === 0)) { + return "*"; + } + return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":"): ""); +} + +interface Bucket { + [name: string]: T; +} + +type _EventFilter = { + prepareEvent: (event: Event) => void; + fragment?: EventFragment; + eventTag: string; + filter: EventFilter; +}; + +type _Event = { + eventFilter: _EventFilter; + listener: Listener; + once: boolean; + wrappedListener: Listener; +}; + +export type ContractInterface = string | Array | Interface; + +export class Contract { + readonly address: string; + readonly interface: Interface; + + readonly signer: Signer; + readonly provider: Provider; + + readonly functions: Bucket; + + readonly callStatic: Bucket; + readonly estimate: Bucket<(...params: Array) => Promise>; + readonly populateTransaction: Bucket<(...params: Array) => Promise>; + + readonly filters: Bucket<(...params: Array) => EventFilter>; + + readonly [ name: string ]: ContractFunction | any; + + readonly addressPromise: Promise; + + // This is only set if the contract was created with a call to deploy + readonly deployTransaction: TransactionResponse; + + _deployedPromise: Promise; + + // https://github.com/Microsoft/TypeScript/issues/5453 + // Once this issue is resolved (there are open PR) we can do this nicer + // by making addressOrName default to null for 2 operand calls. :) + + constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider: Signer | Provider) { + errors.checkNew(new.target, Contract); + + // @TODO: Maybe still check the addressOrName looks like a valid address or name? + //address = getAddress(address); + + defineReadOnly(this, "interface", new.target.getInterface(contractInterface)); + + if (isNamedInstance(Signer, signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider.provider); + defineReadOnly(this, "signer", signerOrProvider); + } else if (isNamedInstance(Provider, signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider); + defineReadOnly(this, "signer", null); + } else { + errors.throwError("invalid signer or provider", errors.INVALID_ARGUMENT, { arg: "signerOrProvider", value: signerOrProvider }); + } + + defineReadOnly(this, "callStatic", { }); + defineReadOnly(this, "estimate", { }); + defineReadOnly(this, "functions", { }); + defineReadOnly(this, "populateTransaction", { }); + + defineReadOnly(this, "filters", { }); + + Object.keys(this.interface.events).forEach((eventName) => { + let event = this.interface.events[eventName]; + defineReadOnly(this.filters, eventName, (...args: Array) => { + return { + address: this.address, + topics: this.interface.encodeFilterTopics(event, args) + } + }); + }); + + this._events = []; + + defineReadOnly(this, "address", addressOrName); + if (this.provider) { + defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then((address) => { + if (address == null) { throw new Error("name not found"); } + return address; + }).catch((error: Error) => { + console.log("ERROR: Cannot find Contract - " + addressOrName); + throw error; + })); + } else { + try { + defineReadOnly(this, "addressPromise", Promise.resolve(((this.interface.constructor)).getAddress(addressOrName))); + } catch (error) { + // Without a provider, we cannot use ENS names + errors.throwError("provider is required to use non-address contract address", errors.INVALID_ARGUMENT, { argument: "addressOrName", value: addressOrName }); + } + } + + Object.keys(this.interface.functions).forEach((name) => { + let run = runMethod(this, name, { }); + + if (this[name] == null) { + defineReadOnly(this, name, run); + } + + if (this.functions[name] == null) { + defineReadOnly(this.functions, name, run); + } + + if (this.callStatic[name] == null) { + defineReadOnly(this.callStatic, name, runMethod(this, name, { callStatic: true })); + } + + if (this.populateTransaction[name] == null) { + defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true })); + } + + if (this.estimate[name] == null) { + defineReadOnly(this.estimate, name, runMethod(this, name, { estimate: true })); + } + }); + } + + static getContractAddress(transaction: { from: string, nonce: BigNumberish }): string { + return getContractAddress(transaction); + } + + static getInterface(contractInterface: ContractInterface): Interface { + if (isNamedInstance(Interface, contractInterface)) { + return contractInterface; + } + return new Interface(contractInterface); + } + + // @TODO: Allow timeout? + deployed(): Promise { + return this._deployed(); + } + + _deployed(blockTag?: BlockTag): Promise { + if (!this._deployedPromise) { + + // If we were just deployed, we know the transaction we should occur in + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(() => { + return this; + }); + + } else { + // @TODO: Once we allow a timeout to be passed in, we will wait + // up to that many blocks for getCode + + // Otherwise, poll for our code to be deployed + this._deployedPromise = this.provider.getCode(this.address, blockTag).then((code) => { + if (code === "0x") { + errors.throwError("contract not deployed", errors.UNSUPPORTED_OPERATION, { + contractAddress: this.address, + operation: "getDeployed" + }); + } + return this; + }); + } + } + + return this._deployedPromise; + } + + // @TODO: + // estimateFallback(overrides?: TransactionRequest): Promise + + // @TODO: + // estimateDeploy(bytecode: string, ...args): Promise + + fallback(overrides?: TransactionRequest): Promise { + if (!this.signer) { + errors.throwError("sending a transaction require a signer", errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }) + } + + let tx: TransactionRequest = shallowCopy(overrides || {}); + + ["from", "to"].forEach(function(key) { + if ((tx)[key] == null) { return; } + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }) + }); + + tx.to = this.addressPromise; + return this.deployed().then(() => { + return this.signer.sendTransaction(tx); + }); + } + + // Reconnect to a different signer or provider + connect(signerOrProvider: Signer | Provider | string): Contract { + if (typeof(signerOrProvider) === "string") { + signerOrProvider = new VoidSigner(signerOrProvider, this.provider); + } + + let contract = new (<{ new(...args: any[]): Contract }>(this.constructor))(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + defineReadOnly(contract, "deployTransaction", this.deployTransaction); + } + return contract; + } + + // Re-attach to a different on-chain instance of this contract + attach(addressOrName: string): Contract { + return new (<{ new(...args: any[]): Contract }>(this.constructor))(addressOrName, this.interface, this.signer || this.provider); + } + + static isIndexed(value: any): value is Indexed { + return isNamedInstance(Indexed, value); + } + + private _events: Array<_Event>; + + private _getEventFilter(eventName: EventFilter | string): _EventFilter { + if (typeof(eventName) === "string") { + + // Listen for any event + if (eventName === "*") { + return { + prepareEvent: (e: Event) => { + let parsed = this.interface.parseLog(e); + if (parsed) { + e.values = parsed.values; + e.decode = (data: BytesLike, topics?: Array) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }, + e.event = parsed.name; + e.eventSignature = parsed.signature; + } + }, + eventTag: "*", + filter: { address: this.address }, + }; + } + + let fragment = this.interface.getEvent(eventName) + if (!fragment) { + errors.throwError("unknown event - " + eventName, errors.INVALID_ARGUMENT, { argumnet: "eventName", value: eventName }); + } + + let filter = { + address: this.address, + topics: [ this.interface.getEventTopic(fragment) ] + } + + return { + prepareEvent: (e: Event) => { + e.values = this.interface.decodeEventLog(fragment, e.data, e.topics); + }, + fragment: fragment, + eventTag: getEventTag(filter), + filter: filter + }; + } + + let filter: EventFilter = { + address: this.address + } + + // Find the matching event in the ABI; if none, we still allow filtering + // since it may be a filter for an otherwise unknown event + let fragment: EventFragment = null; + if (eventName.topics && eventName.topics[0]) { + filter.topics = eventName.topics; + fragment = this.interface.getEvent(eventName.topics[0]); + } + + return { + prepareEvent: (e: Event) => { + if (!fragment) { return; } + e.values = this.interface.decodeEventLog(fragment, e.data, e.topics); + }, + fragment: fragment, + eventTag: getEventTag(filter), + filter: filter + } + } + + // @TODO: move this to _EventFilter.wrapLog. Maybe into prepareEvent? + _wrapEvent(eventFilter: _EventFilter, log: Log, listener: Listener): Event { + let event = deepCopy(log); + + // @TODO: Move all the below stuff into prepare + eventFilter.prepareEvent(event); + + if (eventFilter.fragment) { + event.decode = (data: BytesLike, topics?: Array) => { + return this.interface.decodeEventLog(eventFilter.fragment, data, topics); + }, + event.event = eventFilter.fragment.name; + event.eventSignature = eventFilter.fragment.format(); + } + + event.removeListener = () => { + if (!listener) { return; } + this.removeListener(eventFilter.filter, listener); + }; + + event.getBlock = () => { return this.provider.getBlock(log.blockHash); } + event.getTransaction = () => { return this.provider.getTransaction(log.transactionHash); } + event.getTransactionReceipt = () => { return this.provider.getTransactionReceipt(log.transactionHash); } + + return event; + } + + private _addEventListener(eventFilter: _EventFilter, listener: Listener, once: boolean): void { + if (!this.provider) { + errors.throwError("events require a provider or a signer with a provider", errors.UNSUPPORTED_OPERATION, { operation: "once" }) + } + + let wrappedListener = (log: Log) => { + let event = this._wrapEvent(eventFilter, log, listener); + let values = (event.values || []); + values.push(event); + this.emit(eventFilter.filter, ...values); + }; + + this.provider.on(eventFilter.filter, wrappedListener); + this._events.push({ eventFilter: eventFilter, listener: listener, wrappedListener: wrappedListener, once: once }); + } + + queryFilter(event: EventFilter, fromBlockOrBlockhash?: BlockTag | string, toBlock?: BlockTag): Promise> { + let eventFilter = this._getEventFilter(event); + let filter = shallowCopy(eventFilter.filter); + + if (typeof(fromBlockOrBlockhash) === "string" && isHexString(fromBlockOrBlockhash, 32)) { + filter.blockhash = fromBlockOrBlockhash; + if (toBlock != null) { + errors.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + } + } else { + filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash: 0); + filter.toBlock = ((toBlock != null) ? toBlock: "latest"); + } + + return this.provider.getLogs(filter).then((logs) => { + return logs.map((log) => this._wrapEvent(eventFilter, log, null)); + }); + } + + on(event: EventFilter | string, listener: Listener): Contract { + this._addEventListener(this._getEventFilter(event), listener, false); + return this; + } + + once(event: EventFilter | string, listener: Listener): Contract { + this._addEventListener(this._getEventFilter(event), listener, true); + return this; + } + + addListener(eventName: EventFilter | string, listener: Listener): Contract { + return this.on(eventName, listener); + } + + emit(eventName: EventFilter | string, ...args: Array): boolean { + if (!this.provider) { return false; } + + let result = false; + + let eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter((event) => { + + // Not this event (keep it for later) + if (event.eventFilter.eventTag !== eventFilter.eventTag) { return true; } + + // Call the callback in the next event loop + setTimeout(() => { + event.listener.apply(this, args); + }, 0); + result = true; + + // Reschedule it if it not "once" + return !(event.once); + }); + + return result; + } + + listenerCount(eventName?: EventFilter | string): number { + if (!this.provider) { return 0; } + + let eventFilter = this._getEventFilter(eventName); + return this._events.filter((event) => { + return event.eventFilter.eventTag === eventFilter.eventTag + }).length; + } + + listeners(eventName?: EventFilter | string): Array { + if (!this.provider) { return []; } + + if (eventName == null) { + return this._events.map((event) => event.listener); + } + + let eventFilter = this._getEventFilter(eventName); + return this._events + .filter((event) => (event.eventFilter.eventTag === eventFilter.eventTag)) + .map((event) => event.listener); + } + + removeAllListeners(eventName: EventFilter | string): Contract { + if (!this.provider) { return this; } + + let eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter((event) => { + // Keep non-matching events + if (event.eventFilter.eventTag !== eventFilter.eventTag) { + return true; + } + + // De-register this event from the provider and filter it out + this.provider.removeListener(event.eventFilter.filter, event.wrappedListener); + return false; + }); + + return this; + } + + off(eventName: any, listener: Listener): Contract { + if (!this.provider) { return this; } + + let found = false; + + let eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter((event) => { + + // Make sure this event and listener match + if (event.eventFilter.eventTag !== eventFilter.eventTag) { return true; } + if (event.listener !== listener) { return true; } + this.provider.removeListener(event.eventFilter.filter, event.wrappedListener); + + // Already found a matching event in a previous loop + if (found) { return true; } + + // Remove this event (returning false filters us out) + found = true; + return false; + }); + + return this; + } + + removeListener(eventName: any, listener: Listener): Contract { + return this.off(eventName, listener); + } + +} + +export class ContractFactory { + + readonly interface: Interface; + readonly bytecode: string; + readonly signer: Signer; + + constructor(contractInterface: ContractInterface, bytecode: BytesLike | { object: string }, signer?: Signer) { + + let bytecodeHex: string = null; + + if (typeof(bytecode) === "string") { + bytecodeHex = bytecode; + } else if (isBytes(bytecode)) { + bytecodeHex = hexlify(bytecode); + } else if (bytecode && typeof(bytecode.object) === "string") { + // Allow the bytecode object from the Solidity compiler + bytecodeHex = (bytecode).object; + } else { + // Crash in the next verification step + bytecodeHex = "!"; + } + + // Make sure it is 0x prefixed + if (bytecodeHex.substring(0, 2) !== "0x") { bytecodeHex = "0x" + bytecodeHex; } + + // Make sure the final result is valid bytecode + if (!isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + errors.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + + // If we have a signer, make sure it is valid + if (signer && !isNamedInstance(Signer, signer)) { + errors.throwArgumentError("invalid signer", "signer", signer); + } + + defineReadOnly(this, "bytecode", bytecodeHex); + defineReadOnly(this, "interface", new.target.getInterface(contractInterface)); + defineReadOnly(this, "signer", signer || null); + } + + getDeployTransaction(...args: Array): UnsignedTransaction { + + let tx: UnsignedTransaction = { }; + + // If we have 1 additional argument, we allow transaction overrides + if (args.length === this.interface.deploy.inputs.length + 1) { + tx = shallowCopy(args.pop()); + for (let key in tx) { + if (!allowedTransactionKeys[key]) { + throw new Error("unknown transaction override " + key); + } + } + } + + // Do not allow these to be overridden in a deployment transaction + ["data", "from", "to"].forEach((key) => { + if ((tx)[key] == null) { return; } + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }) + }); + + // Make sure the call matches the constructor signature + errors.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + + // Set the data to the bytecode + the encoded constructor arguments + tx.data = hexlify(concat([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + + return tx + } + + deploy(...args: Array): Promise { + + // Get the deployment transaction (with optional overrides) + let tx = this.getDeployTransaction(...args); + + // Send the deployment transaction + return this.signer.sendTransaction(tx).then((tx) => { + let address = ((this.constructor)).getContractAddress(tx); + let contract = ((this.constructor)).getContract(address, this.interface, this.signer); + defineReadOnly(contract, "deployTransaction", tx); + return contract; + }); + } + + attach(address: string): Contract { + return ((this.constructor)).getContract(address, this.interface, this.signer); + } + + connect(signer: Signer) { + return new (<{ new(...args: any[]): ContractFactory }>(this.constructor))(this.interface, this.bytecode, signer); + } + + static fromSolidity(compilerOutput: any, signer?: Signer): ContractFactory { + if (compilerOutput == null) { + errors.throwError("missing compiler output", errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + + if (typeof(compilerOutput) === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + + let abi = compilerOutput.abi; + + let bytecode: any = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + + return new this(abi, bytecode, signer); + } + + static getInterface(contractInterface: ContractInterface) { + return Contract.getInterface(contractInterface); + } + + static getContractAddress(tx: { from: string, nonce: BytesLike | BigNumber | number }): string { + return getContractAddress(tx); + } + + static getContract(address: string, contractInterface: ContractInterface, signer?: Signer): Contract { + return new Contract(address, contractInterface, signer); + } +} + + diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json new file mode 100644 index 000000000..969328db8 --- /dev/null +++ b/packages/contracts/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/errors/.npmignore b/packages/errors/.npmignore new file mode 100644 index 000000000..a17b47758 --- /dev/null +++ b/packages/errors/.npmignore @@ -0,0 +1,6 @@ +# We do not need the TypeScipt source in deployments +tsconfig.json +src.ts/ + +# To run tests, checkout GitHub +tests/ diff --git a/packages/errors/LICENSE.md b/packages/errors/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/errors/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/errors/README.md b/packages/errors/README.md new file mode 100644 index 000000000..40b419026 --- /dev/null +++ b/packages/errors/README.md @@ -0,0 +1,17 @@ +Error Generalizations and Utilities +=================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/errors/package.json b/packages/errors/package.json new file mode 100644 index 000000000..27cb23ff5 --- /dev/null +++ b/packages/errors/package.json @@ -0,0 +1,19 @@ +{ + "name": "@ethersproject/errors", + "version": "5.0.0-beta.125", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xdaa9e78cc9425c9c650900552749b0fd0889e1d325b3f80261433811811e70e4" +} diff --git a/packages/errors/src.ts/_version.ts b/packages/errors/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/errors/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/errors/src.ts/index.ts b/packages/errors/src.ts/index.ts new file mode 100644 index 000000000..bb3392e0f --- /dev/null +++ b/packages/errors/src.ts/index.ts @@ -0,0 +1,339 @@ +"use strict"; + +//import { version } from "./_version"; +const version = "@TODO"; + + +/////////////////// +// Generic Errors + +// Unknown Error +export const UNKNOWN_ERROR = "UNKNOWN_ERROR"; + +// Not Implemented +export const NOT_IMPLEMENTED = "NOT_IMPLEMENTED"; + +// Unsupported Operation +// - operation +export const UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION"; + +// Network Error +export const NETWORK_ERROR = "NETWORK_ERROR"; + + +/////////////////// +// Operational Errors + +// Buffer Overrun +export const BUFFER_OVERRUN = "BUFFER_OVERRUN"; + +// Numeric Fault +// - operation: the operation being executed +// - fault: the reason this faulted +export const NUMERIC_FAULT = "NUMERIC_FAULT"; + + +/////////////////// +// Argument Errors + +// Missing new operator to an object +// - name: The name of the class +export const MISSING_NEW = "MISSING_NEW"; + +// Invalid argument (e.g. value is incompatible with type) to a function: +// - argument: The argument name that was invalid +// - value: The value of the argument +export const INVALID_ARGUMENT = "INVALID_ARGUMENT"; + +// Missing argument to a function: +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +export const MISSING_ARGUMENT = "MISSING_ARGUMENT"; + +// Too many arguments +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +export const UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT"; + + +/////////////////// +// Blockchain Errors + +// Call exception +// - transaction: the transaction +// - address?: the contract address +// - args?: The arguments passed into the function +// - method?: The Solidity method signature +// - errorSignature?: The EIP848 error signature +// - errorArgs?: The EIP848 error parameters +// - reason: The reason (only for EIP848 "Error(string)") +export const CALL_EXCEPTION = "CALL_EXCEPTION"; + +// Insufficien funds (< value + gasLimit * gasPrice) +// - transaction: the transaction attempted +export const INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"; + +// Nonce has already been used +// - transaction: the transaction attempted +export const NONCE_EXPIRED = "NONCE_EXPIRED"; + +// The replacement fee for the transaction is too low +// - transaction: the transaction attempted +export const REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED"; + +// The gas limit could not be estimated +// - transaction: the transaction passed to estimateGas +export const UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; + +//export const errors: { [ code: string ]: string } = { +//}; + +/////////////////// +// Censorship + +let _permanentCensorErrors = false; +let _censorErrors = false; + +export function setCensorship(censorship: boolean, permanent?: boolean): void { + if (_permanentCensorErrors) { + throwError("error censorship permanent", UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; +} + + +/////////////////// +// Errors + +export function makeError(message: string, code: string, params: any): Error { + if (_censorErrors) { + return new Error("unknown error"); + } + + if (!code) { code = UNKNOWN_ERROR; } + if (!params) { params = {}; } + + let messageDetails: Array = []; + Object.keys(params).forEach((key) => { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + version); + + let reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + + // @TODO: Any?? + let error: any = new Error(message); + error.reason = reason; + error.code = code + + Object.keys(params).forEach(function(key) { + error[key] = params[key]; + }); + + return error; +} + +// @TODO: Enum +export function throwError(message: string, code: string, params: any): never { + throw makeError(message, code, params); +} + + +export function throwArgumentError(message: string, name: string, value: any): never { + return throwError(message, INVALID_ARGUMENT, { + argument: name, + value: value + }); +} + + +/////////////////// +// Checking + +export function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void { + if (suffix) { + suffix = " " + suffix; + } else { + suffix = ""; + } + + if (count < expectedCount) { + throwError("missing argument" + suffix, MISSING_ARGUMENT, { count: count, expectedCount: expectedCount }); + } + + if (count > expectedCount) { + throwError("too many arguments" + suffix, UNEXPECTED_ARGUMENT, { count: count, expectedCount: expectedCount }); + } +} + +export function checkNew(target: any, kind: any): void { + if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} + +/* +export function check(target: any: void { + if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ + +export function checkAbstract(target: any, kind: any): void { + if (target === kind) { + throwError( + "cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", + UNSUPPORTED_OPERATION, + { name: target.name, operation: "new" } + ); + } else if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} + +/* +export function checkTarget(target: any, kind: any): void { + if (target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ +function _checkNormalize(): string { + try { + let missing: Array = [ ]; + + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + "test".normalize(form); + } catch(error) { + missing.push(form); + } + }); + + if (missing.length) { + throw new Error("missing " + missing.join(", ")); + } + + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation") + } + } catch (error) { + return error.message; + } + + return null; +} + +let _normalizeError = _checkNormalize(); +export function checkNormalize(): void { + if (_normalizeError) { + throwError("platform missing String.prototype.normalize", UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } +} + +export function checkSafeUint53(value: number, message?: string): void { + if (typeof(value) !== "number") { return; } + + if (message == null) { message = "value not safe"; } + + if (value < 0 || value >= 0x1fffffffffffff) { + throwError(message, NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + + if (value % 1) { + throwError(message, NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } +} + + +/////////////////// +// Logging + +const LogLevels: { [ name: string ]: number } = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; +let LogLevel = LogLevels["default"]; + +export function setLogLevel(logLevel: string): void { + let level = LogLevels[logLevel]; + if (level == null) { + warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; +} + +function log(logLevel: string, args: Array): void { + if (LogLevel > LogLevels[logLevel]) { return; } + console.log.apply(console, args); +} + +export function warn(...args: Array): void { + log("warn", args); +} + +export function info(...args: Array): void { + log("info", args); +} +/* +export class Logger { + readonly version: string; + _logLevel: number; + + constructor(version?: string) { + Object.defineProperty(this, "version", { + enumerable: true, + value: (version || "unknown"), + writable: false + }); + this._logLevel = LogLevels["default"];; + } + + _log(logLevel: string, args: Array): void { + if (this._logLevel > LogLevels[logLevel]) { return; } + console.log.apply(console, args); + } + + get logLevel(): number { + return this._logLevel; + } + + set logLevel(value: string | number) { + if (typeof(value) === "string") { + value = LogLevels[value]; + if (logLevel == null) { + this.warn("invliad log level - " + value); + return; + } + } + this._logLevel = value; + } + + warn(...args: Array): void { + this._log("warn", args); + } + + log(...args: Array): void { + this._log("info", args); + } +} +*/ diff --git a/packages/errors/tsconfig.json b/packages/errors/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/errors/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/ethers/.npmignore b/packages/ethers/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/ethers/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/ethers/LICENSE.md b/packages/ethers/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/ethers/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/ethers/README.md b/packages/ethers/README.md new file mode 100644 index 000000000..bfae05c5d --- /dev/null +++ b/packages/ethers/README.md @@ -0,0 +1,17 @@ +Ethers +====== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/ethers/dist/ethers.js b/packages/ethers/dist/ethers.js new file mode 100644 index 000000000..f87d3cb36 --- /dev/null +++ b/packages/ethers/dist/ethers.js @@ -0,0 +1,18829 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethers = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 255) { + return false; + } + } + + return true; + } + + function coerceArray(arg, copy) { + + // ArrayBuffer view + if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') { + + if (copy) { + if (arg.slice) { + arg = arg.slice(); + } else { + arg = Array.prototype.slice.call(arg); + } + } + + return arg; + } + + // It's an array; check it is a valid representation of a byte + if (Array.isArray(arg)) { + if (!checkInts(arg)) { + throw new Error('Array contains invalid value: ' + arg); + } + + return new Uint8Array(arg); + } + + // Something else, but behaves like an array (maybe a Buffer? Arguments?) + if (checkInt(arg.length) && checkInts(arg)) { + return new Uint8Array(arg); + } + + throw new Error('unsupported array-like object'); + } + + function createArray(length) { + return new Uint8Array(length); + } + + function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { + if (sourceStart != null || sourceEnd != null) { + if (sourceArray.slice) { + sourceArray = sourceArray.slice(sourceStart, sourceEnd); + } else { + sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); + } + } + targetArray.set(sourceArray, targetStart); + } + + + + var convertUtf8 = (function() { + function toBytes(text) { + var result = [], i = 0; + text = encodeURI(text); + while (i < text.length) { + var c = text.charCodeAt(i++); + + // if it is a % sign, encode the following 2 bytes as a hex value + if (c === 37) { + result.push(parseInt(text.substr(i, 2), 16)) + i += 2; + + // otherwise, just the actual byte + } else { + result.push(c) + } + } + + return coerceArray(result); + } + + function fromBytes(bytes) { + var result = [], i = 0; + + while (i < bytes.length) { + var c = bytes[i]; + + if (c < 128) { + result.push(String.fromCharCode(c)); + i++; + } else if (c > 191 && c < 224) { + result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f))); + i += 2; + } else { + result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f))); + i += 3; + } + } + + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + var convertHex = (function() { + function toBytes(text) { + var result = []; + for (var i = 0; i < text.length; i += 2) { + result.push(parseInt(text.substr(i, 2), 16)); + } + + return result; + } + + // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html + var Hex = '0123456789abcdef'; + + function fromBytes(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i++) { + var v = bytes[i]; + result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]); + } + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + + // Number of rounds by keysize + var numberOfRounds = {16: 10, 24: 12, 32: 14} + + // Round constant words + var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91]; + + // S-box and Inverse S-box (S is for Substitution) + var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]; + + // Transformations for encryption + var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a]; + var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616]; + var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16]; + var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c]; + + // Transformations for decryption + var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742]; + var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857]; + var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8]; + var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0]; + + // Transformations for decryption key expansion + var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]; + var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697]; + var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46]; + var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d]; + + function convertToInt32(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i += 4) { + result.push( + (bytes[i ] << 24) | + (bytes[i + 1] << 16) | + (bytes[i + 2] << 8) | + bytes[i + 3] + ); + } + return result; + } + + var AES = function(key) { + if (!(this instanceof AES)) { + throw Error('AES must be instanitated with `new`'); + } + + Object.defineProperty(this, 'key', { + value: coerceArray(key, true) + }); + + this._prepare(); + } + + + AES.prototype._prepare = function() { + + var rounds = numberOfRounds[this.key.length]; + if (rounds == null) { + throw new Error('invalid key size (must be 16, 24 or 32 bytes)'); + } + + // encryption round keys + this._Ke = []; + + // decryption round keys + this._Kd = []; + + for (var i = 0; i <= rounds; i++) { + this._Ke.push([0, 0, 0, 0]); + this._Kd.push([0, 0, 0, 0]); + } + + var roundKeyCount = (rounds + 1) * 4; + var KC = this.key.length / 4; + + // convert the key into ints + var tk = convertToInt32(this.key); + + // copy values into round key arrays + var index; + for (var i = 0; i < KC; i++) { + index = i >> 2; + this._Ke[index][i % 4] = tk[i]; + this._Kd[rounds - index][i % 4] = tk[i]; + } + + // key expansion (fips-197 section 5.2) + var rconpointer = 0; + var t = KC, tt; + while (t < roundKeyCount) { + tt = tk[KC - 1]; + tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^ + (S[(tt >> 8) & 0xFF] << 16) ^ + (S[ tt & 0xFF] << 8) ^ + S[(tt >> 24) & 0xFF] ^ + (rcon[rconpointer] << 24)); + rconpointer += 1; + + // key expansion (for non-256 bit) + if (KC != 8) { + for (var i = 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + + // key expansion for 256-bit keys is "slightly different" (fips-197) + } else { + for (var i = 1; i < (KC / 2); i++) { + tk[i] ^= tk[i - 1]; + } + tt = tk[(KC / 2) - 1]; + + tk[KC / 2] ^= (S[ tt & 0xFF] ^ + (S[(tt >> 8) & 0xFF] << 8) ^ + (S[(tt >> 16) & 0xFF] << 16) ^ + (S[(tt >> 24) & 0xFF] << 24)); + + for (var i = (KC / 2) + 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + } + + // copy values into round key arrays + var i = 0, r, c; + while (i < KC && t < roundKeyCount) { + r = t >> 2; + c = t % 4; + this._Ke[r][c] = tk[i]; + this._Kd[rounds - r][c] = tk[i++]; + t++; + } + } + + // inverse-cipher-ify the decryption round key (fips-197 section 5.3) + for (var r = 1; r < rounds; r++) { + for (var c = 0; c < 4; c++) { + tt = this._Kd[r][c]; + this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^ + U2[(tt >> 16) & 0xFF] ^ + U3[(tt >> 8) & 0xFF] ^ + U4[ tt & 0xFF]); + } + } + } + + AES.prototype.encrypt = function(plaintext) { + if (plaintext.length != 16) { + throw new Error('invalid plaintext size (must be 16 bytes)'); + } + + var rounds = this._Ke.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(plaintext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Ke[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T1[(t[ i ] >> 24) & 0xff] ^ + T2[(t[(i + 1) % 4] >> 16) & 0xff] ^ + T3[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T4[ t[(i + 3) % 4] & 0xff] ^ + this._Ke[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Ke[rounds][i]; + result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + } + + AES.prototype.decrypt = function(ciphertext) { + if (ciphertext.length != 16) { + throw new Error('invalid ciphertext size (must be 16 bytes)'); + } + + var rounds = this._Kd.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(ciphertext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Kd[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T5[(t[ i ] >> 24) & 0xff] ^ + T6[(t[(i + 3) % 4] >> 16) & 0xff] ^ + T7[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T8[ t[(i + 1) % 4] & 0xff] ^ + this._Kd[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Kd[rounds][i]; + result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + } + + + /** + * Mode Of Operation - Electonic Codebook (ECB) + */ + var ModeOfOperationECB = function(key) { + if (!(this instanceof ModeOfOperationECB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Electronic Code Block"; + this.name = "ecb"; + + this._aes = new AES(key); + } + + ModeOfOperationECB.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + block = this._aes.encrypt(block); + copyArray(block, ciphertext, i); + } + + return ciphertext; + } + + ModeOfOperationECB.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + copyArray(block, plaintext, i); + } + + return plaintext; + } + + + /** + * Mode Of Operation - Cipher Block Chaining (CBC) + */ + var ModeOfOperationCBC = function(key, iv) { + if (!(this instanceof ModeOfOperationCBC)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Block Chaining"; + this.name = "cbc"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastCipherblock = coerceArray(iv, true); + + this._aes = new AES(key); + } + + ModeOfOperationCBC.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + + for (var j = 0; j < 16; j++) { + block[j] ^= this._lastCipherblock[j]; + } + + this._lastCipherblock = this._aes.encrypt(block); + copyArray(this._lastCipherblock, ciphertext, i); + } + + return ciphertext; + } + + ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + + for (var j = 0; j < 16; j++) { + plaintext[i + j] = block[j] ^ this._lastCipherblock[j]; + } + + copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16); + } + + return plaintext; + } + + + /** + * Mode Of Operation - Cipher Feedback (CFB) + */ + var ModeOfOperationCFB = function(key, iv, segmentSize) { + if (!(this instanceof ModeOfOperationCFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Feedback"; + this.name = "cfb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 size)'); + } + + if (!segmentSize) { segmentSize = 1; } + + this.segmentSize = segmentSize; + + this._shiftRegister = coerceArray(iv, true); + + this._aes = new AES(key); + } + + ModeOfOperationCFB.prototype.encrypt = function(plaintext) { + if ((plaintext.length % this.segmentSize) != 0) { + throw new Error('invalid plaintext size (must be segmentSize bytes)'); + } + + var encrypted = coerceArray(plaintext, true); + + var xorSegment; + for (var i = 0; i < encrypted.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + for (var j = 0; j < this.segmentSize; j++) { + encrypted[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return encrypted; + } + + ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { + if ((ciphertext.length % this.segmentSize) != 0) { + throw new Error('invalid ciphertext size (must be segmentSize bytes)'); + } + + var plaintext = coerceArray(ciphertext, true); + + var xorSegment; + for (var i = 0; i < plaintext.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + + for (var j = 0; j < this.segmentSize; j++) { + plaintext[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return plaintext; + } + + /** + * Mode Of Operation - Output Feedback (OFB) + */ + var ModeOfOperationOFB = function(key, iv) { + if (!(this instanceof ModeOfOperationOFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Output Feedback"; + this.name = "ofb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastPrecipher = coerceArray(iv, true); + this._lastPrecipherIndex = 16; + + this._aes = new AES(key); + } + + ModeOfOperationOFB.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._lastPrecipherIndex === 16) { + this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); + this._lastPrecipherIndex = 0; + } + encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++]; + } + + return encrypted; + } + + // Decryption is symetric + ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; + + + /** + * Counter object for CTR common mode of operation + */ + var Counter = function(initialValue) { + if (!(this instanceof Counter)) { + throw Error('Counter must be instanitated with `new`'); + } + + // We allow 0, but anything false-ish uses the default 1 + if (initialValue !== 0 && !initialValue) { initialValue = 1; } + + if (typeof(initialValue) === 'number') { + this._counter = createArray(16); + this.setValue(initialValue); + + } else { + this.setBytes(initialValue); + } + } + + Counter.prototype.setValue = function(value) { + if (typeof(value) !== 'number' || parseInt(value) != value) { + throw new Error('invalid counter value (must be an integer)'); + } + + for (var index = 15; index >= 0; --index) { + this._counter[index] = value % 256; + value = value >> 8; + } + } + + Counter.prototype.setBytes = function(bytes) { + bytes = coerceArray(bytes, true); + + if (bytes.length != 16) { + throw new Error('invalid counter bytes size (must be 16 bytes)'); + } + + this._counter = bytes; + }; + + Counter.prototype.increment = function() { + for (var i = 15; i >= 0; i--) { + if (this._counter[i] === 255) { + this._counter[i] = 0; + } else { + this._counter[i]++; + break; + } + } + } + + + /** + * Mode Of Operation - Counter (CTR) + */ + var ModeOfOperationCTR = function(key, counter) { + if (!(this instanceof ModeOfOperationCTR)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Counter"; + this.name = "ctr"; + + if (!(counter instanceof Counter)) { + counter = new Counter(counter) + } + + this._counter = counter; + + this._remainingCounter = null; + this._remainingCounterIndex = 16; + + this._aes = new AES(key); + } + + ModeOfOperationCTR.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._remainingCounterIndex === 16) { + this._remainingCounter = this._aes.encrypt(this._counter._counter); + this._remainingCounterIndex = 0; + this._counter.increment(); + } + encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++]; + } + + return encrypted; + } + + // Decryption is symetric + ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; + + + /////////////////////// + // Padding + + // See:https://tools.ietf.org/html/rfc2315 + function pkcs7pad(data) { + data = coerceArray(data, true); + var padder = 16 - (data.length % 16); + var result = createArray(data.length + padder); + copyArray(data, result); + for (var i = data.length; i < result.length; i++) { + result[i] = padder; + } + return result; + } + + function pkcs7strip(data) { + data = coerceArray(data, true); + if (data.length < 16) { throw new Error('PKCS#7 invalid length'); } + + var padder = data[data.length - 1]; + if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); } + + var length = data.length - padder; + for (var i = 0; i < padder; i++) { + if (data[length + i] !== padder) { + throw new Error('PKCS#7 invalid padding byte'); + } + } + + var result = createArray(length); + copyArray(data, result, 0, 0, length); + return result; + } + + /////////////////////// + // Exporting + + + // The block cipher + var aesjs = { + AES: AES, + Counter: Counter, + + ModeOfOperation: { + ecb: ModeOfOperationECB, + cbc: ModeOfOperationCBC, + cfb: ModeOfOperationCFB, + ofb: ModeOfOperationOFB, + ctr: ModeOfOperationCTR + }, + + utils: { + hex: convertHex, + utf8: convertUtf8 + }, + + padding: { + pkcs7: { + pad: pkcs7pad, + strip: pkcs7strip + } + }, + + _arrayTest: { + coerceArray: coerceArray, + createArray: createArray, + copyArray: copyArray, + } + }; + + + // node.js + if (typeof exports !== 'undefined') { + module.exports = aesjs + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(define) === 'function' && define.amd) { + define(aesjs); + + // Web Browsers + } else { + + // If there was an existing library at "aesjs" make sure it's still available + if (root.aesjs) { + aesjs._aesjs = root.aesjs; + } + + root.aesjs = aesjs; + } + + +})(this); + +},{}],2:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + Buffer = require('buffer').Buffer; + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + } + + if (base === 16) { + this._parseHex(number, start); + } else { + this._parseBase(number, base, start); + } + + if (number[0] === '-') { + this.negative = 1; + } + + this.strip(); + + if (endian !== 'le') return; + + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex (str, start, end) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r <<= 4; + + // 'a' - 'f' + if (c >= 49 && c <= 54) { + r |= c - 49 + 0xa; + + // 'A' - 'F' + } else if (c >= 17 && c <= 22) { + r |= c - 17 + 0xa; + + // '0' - '9' + } else { + r |= c & 0xf; + } + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + // Scan 24-bit chunks and add them to the number + var off = 0; + for (i = number.length - 6, j = 0; i >= start; i -= 6) { + w = parseHex(number, i, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + if (i + 6 !== start) { + w = parseHex(number, start, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + r.strip(); + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":4}],3:[function(require,module,exports){ +(function (global){ +module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; } +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],4:[function(require,module,exports){ + +},{}],5:[function(require,module,exports){ +'use strict'; + +var elliptic = exports; + +elliptic.version = require('../package.json').version; +elliptic.utils = require('./elliptic/utils'); +elliptic.rand = require('brorand'); +elliptic.hmacDRBG = require('./elliptic/hmac-drbg'); +elliptic.curve = require('./elliptic/curve'); +elliptic.curves = require('./elliptic/curves'); + +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); + +},{"../package.json":19,"./elliptic/curve":8,"./elliptic/curves":11,"./elliptic/ec":12,"./elliptic/eddsa":15,"./elliptic/hmac-drbg":16,"./elliptic/utils":18,"brorand":3}],6:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var elliptic = require('../../elliptic'); +var utils = elliptic.utils; +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; + +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } +} +module.exports = BaseCurve; + +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + for (var j = 0; j < naf.length; j += doubles.step) { + var nafW = 0; + for (var k = j + doubles.step - 1; k >= j; k--) + nafW = (nafW << 1) + naf[k]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (var j = 0; j < repr.length; j++) { + var nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); +}; + +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var k = 0; i >= 0 && naf[i] === 0; i--) + k++; + if (i >= 0) + k++; + acc = acc.dblp(k); + + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; +}; + +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + for (var i = 0; i < len; i++) { + var p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (var i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a]); + naf[b] = getNAF(coeffs[b], wndWidth[b]); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b] /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3 /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (var j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (var i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (var j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (var j = 0; j < len; j++) { + var z = tmp[j]; + var p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (var i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); +}; + +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; + +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; +}; + +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); +}; + +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; +}; + +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); +}; + +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles + }; +}; + +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +},{"../../elliptic":5,"bn.js":2}],7:[function(require,module,exports){ +module.exports = {}; +},{}],8:[function(require,module,exports){ +'use strict'; + +var curve = exports; + +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); + +},{"./base":6,"./edwards":7,"./mont":9,"./short":10}],9:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],10:[function(require,module,exports){ +'use strict'; + +var curve = require('../curve'); +var elliptic = require('../../elliptic'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = curve.base; + +var assert = elliptic.utils.assert; + +function ShortCurve(conf) { + Base.call(this, 'short', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits(ShortCurve, Base); +module.exports = ShortCurve; + +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16) + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis + }; +}; + +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; + +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 } + ]; +}; + +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; + +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; + +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; +}; + +function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } +} +inherits(Point, Base.BasePoint); + +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; + +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; + +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul) + } + }; + } + return beta; +}; + +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + } ]; +}; + +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)) + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)) + } + }; + return res; +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; + +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); +}; + +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); +}; + +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate) + } + }; + } + return res; +}; + +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; + +function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); + +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; + +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); +}; + +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; + +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (var i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (var i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; + +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); +}; + +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); + + return this.curve._wnafMul(this, k); +}; + +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; +}; + +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } + return false; +}; + +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +},{"../../elliptic":5,"../curve":8,"bn.js":2,"inherits":32}],11:[function(require,module,exports){ +'use strict'; + +var curves = exports; + +var hash = require('hash.js'); +var elliptic = require('../elliptic'); + +var assert = elliptic.utils.assert; + +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new elliptic.curve.short(options); + else if (options.type === 'edwards') + this.curve = new elliptic.curve.edwards(options); + else + this.curve = new elliptic.curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; + +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve + }); + return curve; + } + }); +} + +defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' + ] +}); + +defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' + ] +}); + +defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' + ] +}); + +defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' + ] +}); + +defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650' + ] +}); + +defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '9' + ] +}); + +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', + + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658' + ] +}); + +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} + +defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash.sha256, + + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3' + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15' + } + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre + ] +}); + +},{"../elliptic":5,"./precomputed/secp256k1":17,"hash.js":20}],12:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var elliptic = require('../../elliptic'); +var utils = elliptic.utils; +var assert = utils.assert; + +var KeyPair = require('./key'); +var Signature = require('./signature'); + +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); + + options = elliptic.curves[options]; + } + + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof elliptic.curves.PresetCurve) + options = { curve: options }; + + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; + +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); +}; + +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); +}; + +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); +}; + +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + + // Instantiate Hmac_DRBG + var drbg = new elliptic.hmacDRBG({ + hash: this.hash, + pers: options.pers, + entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), + nonce: this.n.toArray() + }); + + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + do { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; + + priv.iaddn(1); + return this.keyFromPrivate(priv); + } while (true); +}; + +EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; +}; + +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; + + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); + + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); + + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); + + // Instantiate Hmac_DRBG + var drbg = new elliptic.hmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc + }); + + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); + + for (var iter = 0; true; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; + + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; + + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; + + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; + + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } + + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + } +}; + +EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); + + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; + + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + + if (!this.curve._maxwellTrick) { + var p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + return p.getX().umod(this.n).cmp(r) === 0; + } + + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K + + var p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); +}; + +EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); + + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; + + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); + + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); + + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); + + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; + +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; + + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; + } + + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; + +},{"../../elliptic":5,"./key":13,"./signature":14,"bn.js":2}],13:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var elliptic = require('../../elliptic'); +var utils = elliptic.utils; +var assert = utils.assert; + +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +module.exports = KeyPair; + +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + + return new KeyPair(ec, { + pub: pub, + pubEnc: enc + }); +}; + +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + + return new KeyPair(ec, { + priv: priv, + privEnc: enc + }); +}; + +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); + + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; + + return { result: true, reason: null }; +}; + +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); +}; + +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; + +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); + + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; + +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; + +// ECDH +KeyPair.prototype.derive = function derive(pub) { + return pub.mul(this.priv).getX(); +}; + +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; + +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; + +KeyPair.prototype.inspect = function inspect() { + return ''; +}; + +},{"../../elliptic":5,"bn.js":2}],14:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); + +var elliptic = require('../../elliptic'); +var utils = elliptic.utils; +var assert = utils.assert; + +function Signature(options, enc) { + if (options instanceof Signature) + return options; + + if (this._importDER(options, enc)) + return; + + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +module.exports = Signature; + +function Position() { + this.place = 0; +} + +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + } + p.place = off; + return val; +} + +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; + } + if (i === 0) { + return buf; + } + return buf.slice(i); +} + +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0 && (r[1] & 0x80)) { + r = r.slice(1); + } + if (s[0] === 0 && (s[1] & 0x80)) { + s = s.slice(1); + } + + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; +}; + +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); +} + +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); +}; + +},{"../../elliptic":5,"bn.js":2}],15:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],16:[function(require,module,exports){ +'use strict'; + +var hash = require('hash.js'); +var elliptic = require('../elliptic'); +var utils = elliptic.utils; +var assert = utils.assert; + +function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + + this.reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + + var entropy = utils.toArray(options.entropy, options.entropyEnc); + var nonce = utils.toArray(options.nonce, options.nonceEnc); + var pers = utils.toArray(options.pers, options.persEnc); + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + this._init(entropy, nonce, pers); +} +module.exports = HmacDRBG; + +HmacDRBG.prototype._init = function init(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i = 0; i < this.V.length; i++) { + this.K[i] = 0x00; + this.V[i] = 0x01; + } + + this._update(seed); + this.reseed = 1; + this.reseedInterval = 0x1000000000000; // 2^48 +}; + +HmacDRBG.prototype._hmac = function hmac() { + return new hash.hmac(this.hash, this.K); +}; + +HmacDRBG.prototype._update = function update(seed) { + var kmac = this._hmac() + .update(this.V) + .update([ 0x00 ]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + + this.K = this._hmac() + .update(this.V) + .update([ 0x01 ]) + .update(seed) + .digest(); + this.V = this._hmac().update(this.V).digest(); +}; + +HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { + // Optional entropy enc + if (typeof entropyEnc !== 'string') { + addEnc = add; + add = entropyEnc; + entropyEnc = null; + } + + entropy = utils.toBuffer(entropy, entropyEnc); + add = utils.toBuffer(add, addEnc); + + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + + this._update(entropy.concat(add || [])); + this.reseed = 1; +}; + +HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { + if (this.reseed > this.reseedInterval) + throw new Error('Reseed is required'); + + // Optional encoding + if (typeof enc !== 'string') { + addEnc = add; + add = enc; + enc = null; + } + + // Optional additional data + if (add) { + add = utils.toArray(add, addEnc); + this._update(add); + } + + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + + var res = temp.slice(0, len); + this._update(add); + this.reseed++; + return utils.encode(res, enc); +}; + +},{"../elliptic":5,"hash.js":20}],17:[function(require,module,exports){ +module.exports = undefined; +},{}],18:[function(require,module,exports){ +'use strict'; + +var utils = exports; +var BN = require('bn.js'); + +utils.assert = function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); +}; + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== 'string') { + for (var i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + return res; + } + if (!enc) { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } else if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (var i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } + return res; +} +utils.toArray = toArray; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +utils.zero2 = zero2; + +function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +utils.toHex = toHex; + +utils.encode = function encode(arr, enc) { + if (enc === 'hex') + return toHex(arr); + else + return arr; +}; + +// Represent num in a w-NAF form +function getNAF(num, w) { + var naf = []; + var ws = 1 << (w + 1); + var k = num.clone(); + while (k.cmpn(1) >= 0) { + var z; + if (k.isOdd()) { + var mod = k.andln(ws - 1); + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } + naf.push(z); + + // Optimization, shift by word if possible + var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; + for (var i = 1; i < shift; i++) + naf.push(0); + k.iushrn(shift); + } + + return naf; +} +utils.getNAF = getNAF; + +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [] + ]; + + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + var m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + var m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); + + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } + + return jsf; +} +utils.getJSF = getJSF; + +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; +} +utils.cachedProperty = cachedProperty; + +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; + +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; + + +},{"bn.js":2}],19:[function(require,module,exports){ +module.exports={"version":"6.3.3"} +},{}],20:[function(require,module,exports){ +var hash = exports; + +hash.utils = require('./hash/utils'); +hash.common = require('./hash/common'); +hash.sha = require('./hash/sha'); +hash.ripemd = require('./hash/ripemd'); +hash.hmac = require('./hash/hmac'); + +// Proxy hash functions to the main object +hash.sha1 = hash.sha.sha1; +hash.sha256 = hash.sha.sha256; +hash.sha224 = hash.sha.sha224; +hash.sha384 = hash.sha.sha384; +hash.sha512 = hash.sha.sha512; +hash.ripemd160 = hash.ripemd.ripemd160; + +},{"./hash/common":21,"./hash/hmac":22,"./hash/ripemd":23,"./hash/sha":24,"./hash/utils":31}],21:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var assert = require('minimalistic-assert'); + +function BlockHash() { + this.pending = null; + this.pendingTotal = 0; + this.blockSize = this.constructor.blockSize; + this.outSize = this.constructor.outSize; + this.hmacStrength = this.constructor.hmacStrength; + this.padLength = this.constructor.padLength / 8; + this.endian = 'big'; + + this._delta8 = this.blockSize / 8; + this._delta32 = this.blockSize / 32; +} +exports.BlockHash = BlockHash; + +BlockHash.prototype.update = function update(msg, enc) { + // Convert message to array, pad it, and join into 32bit blocks + msg = utils.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + + // Enough data, try updating + if (this.pending.length >= this._delta8) { + msg = this.pending; + + // Process pending data in blocks + var r = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r, msg.length); + if (this.pending.length === 0) + this.pending = null; + + msg = utils.join32(msg, 0, msg.length - r, this.endian); + for (var i = 0; i < msg.length; i += this._delta32) + this._update(msg, i, i + this._delta32); + } + + return this; +}; + +BlockHash.prototype.digest = function digest(enc) { + this.update(this._pad()); + assert(this.pending === null); + + return this._digest(enc); +}; + +BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes = this._delta8; + var k = bytes - ((len + this.padLength) % bytes); + var res = new Array(k + this.padLength); + res[0] = 0x80; + for (var i = 1; i < k; i++) + res[i] = 0; + + // Append length + len <<= 3; + if (this.endian === 'big') { + for (var t = 8; t < this.padLength; t++) + res[i++] = 0; + + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = (len >>> 24) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = len & 0xff; + } else { + res[i++] = len & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 24) & 0xff; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + + for (t = 8; t < this.padLength; t++) + res[i++] = 0; + } + + return res; +}; + +},{"./utils":31,"minimalistic-assert":34}],22:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var assert = require('minimalistic-assert'); + +function Hmac(hash, key, enc) { + if (!(this instanceof Hmac)) + return new Hmac(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + + this._init(utils.toArray(key, enc)); +} +module.exports = Hmac; + +Hmac.prototype._init = function init(key) { + // Shorten key, if needed + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + assert(key.length <= this.blockSize); + + // Add padding to key + for (var i = key.length; i < this.blockSize; i++) + key.push(0); + + for (i = 0; i < key.length; i++) + key[i] ^= 0x36; + this.inner = new this.Hash().update(key); + + // 0x36 ^ 0x5c = 0x6a + for (i = 0; i < key.length; i++) + key[i] ^= 0x6a; + this.outer = new this.Hash().update(key); +}; + +Hmac.prototype.update = function update(msg, enc) { + this.inner.update(msg, enc); + return this; +}; + +Hmac.prototype.digest = function digest(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); +}; + +},{"./utils":31,"minimalistic-assert":34}],23:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var common = require('./common'); + +var rotl32 = utils.rotl32; +var sum32 = utils.sum32; +var sum32_3 = utils.sum32_3; +var sum32_4 = utils.sum32_4; +var BlockHash = common.BlockHash; + +function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + + BlockHash.call(this); + + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; + this.endian = 'little'; +} +utils.inherits(RIPEMD160, BlockHash); +exports.ripemd160 = RIPEMD160; + +RIPEMD160.blockSize = 512; +RIPEMD160.outSize = 160; +RIPEMD160.hmacStrength = 192; +RIPEMD160.padLength = 64; + +RIPEMD160.prototype._update = function update(msg, start) { + var A = this.h[0]; + var B = this.h[1]; + var C = this.h[2]; + var D = this.h[3]; + var E = this.h[4]; + var Ah = A; + var Bh = B; + var Ch = C; + var Dh = D; + var Eh = E; + for (var j = 0; j < 80; j++) { + var T = sum32( + rotl32( + sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), + s[j]), + E); + A = E; + E = D; + D = rotl32(C, 10); + C = B; + B = T; + T = sum32( + rotl32( + sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), + sh[j]), + Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32(Ch, 10); + Ch = Bh; + Bh = T; + } + T = sum32_3(this.h[1], C, Dh); + this.h[1] = sum32_3(this.h[2], D, Eh); + this.h[2] = sum32_3(this.h[3], E, Ah); + this.h[3] = sum32_3(this.h[4], A, Bh); + this.h[4] = sum32_3(this.h[0], B, Ch); + this.h[0] = T; +}; + +RIPEMD160.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'little'); + else + return utils.split32(this.h, 'little'); +}; + +function f(j, x, y, z) { + if (j <= 15) + return x ^ y ^ z; + else if (j <= 31) + return (x & y) | ((~x) & z); + else if (j <= 47) + return (x | (~y)) ^ z; + else if (j <= 63) + return (x & z) | (y & (~z)); + else + return x ^ (y | (~z)); +} + +function K(j) { + if (j <= 15) + return 0x00000000; + else if (j <= 31) + return 0x5a827999; + else if (j <= 47) + return 0x6ed9eba1; + else if (j <= 63) + return 0x8f1bbcdc; + else + return 0xa953fd4e; +} + +function Kh(j) { + if (j <= 15) + return 0x50a28be6; + else if (j <= 31) + return 0x5c4dd124; + else if (j <= 47) + return 0x6d703ef3; + else if (j <= 63) + return 0x7a6d76e9; + else + return 0x00000000; +} + +var r = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 +]; + +var rh = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 +]; + +var s = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 +]; + +var sh = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 +]; + +},{"./common":21,"./utils":31}],24:[function(require,module,exports){ +'use strict'; + +exports.sha1 = require('./sha/1'); +exports.sha224 = require('./sha/224'); +exports.sha256 = require('./sha/256'); +exports.sha384 = require('./sha/384'); +exports.sha512 = require('./sha/512'); + +},{"./sha/1":25,"./sha/224":26,"./sha/256":27,"./sha/384":28,"./sha/512":29}],25:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],26:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],27:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var common = require('../common'); +var shaCommon = require('./common'); +var assert = require('minimalistic-assert'); + +var sum32 = utils.sum32; +var sum32_4 = utils.sum32_4; +var sum32_5 = utils.sum32_5; +var ch32 = shaCommon.ch32; +var maj32 = shaCommon.maj32; +var s0_256 = shaCommon.s0_256; +var s1_256 = shaCommon.s1_256; +var g0_256 = shaCommon.g0_256; +var g1_256 = shaCommon.g1_256; + +var BlockHash = common.BlockHash; + +var sha256_K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]; + +function SHA256() { + if (!(this instanceof SHA256)) + return new SHA256(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + this.k = sha256_K; + this.W = new Array(64); +} +utils.inherits(SHA256, BlockHash); +module.exports = SHA256; + +SHA256.blockSize = 512; +SHA256.outSize = 256; +SHA256.hmacStrength = 192; +SHA256.padLength = 64; + +SHA256.prototype._update = function _update(msg, start) { + var W = this.W; + + for (var i = 0; i < 16; i++) + W[i] = msg[start + i]; + for (; i < W.length; i++) + W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); + + var a = this.h[0]; + var b = this.h[1]; + var c = this.h[2]; + var d = this.h[3]; + var e = this.h[4]; + var f = this.h[5]; + var g = this.h[6]; + var h = this.h[7]; + + assert(this.k.length === W.length); + for (i = 0; i < W.length; i++) { + var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); + var T2 = sum32(s0_256(a), maj32(a, b, c)); + h = g; + g = f; + f = e; + e = sum32(d, T1); + d = c; + c = b; + b = a; + a = sum32(T1, T2); + } + + this.h[0] = sum32(this.h[0], a); + this.h[1] = sum32(this.h[1], b); + this.h[2] = sum32(this.h[2], c); + this.h[3] = sum32(this.h[3], d); + this.h[4] = sum32(this.h[4], e); + this.h[5] = sum32(this.h[5], f); + this.h[6] = sum32(this.h[6], g); + this.h[7] = sum32(this.h[7], h); +}; + +SHA256.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +},{"../common":21,"../utils":31,"./common":30,"minimalistic-assert":34}],28:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],29:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var common = require('../common'); +var assert = require('minimalistic-assert'); + +var rotr64_hi = utils.rotr64_hi; +var rotr64_lo = utils.rotr64_lo; +var shr64_hi = utils.shr64_hi; +var shr64_lo = utils.shr64_lo; +var sum64 = utils.sum64; +var sum64_hi = utils.sum64_hi; +var sum64_lo = utils.sum64_lo; +var sum64_4_hi = utils.sum64_4_hi; +var sum64_4_lo = utils.sum64_4_lo; +var sum64_5_hi = utils.sum64_5_hi; +var sum64_5_lo = utils.sum64_5_lo; + +var BlockHash = common.BlockHash; + +var sha512_K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 +]; + +function SHA512() { + if (!(this instanceof SHA512)) + return new SHA512(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xf3bcc908, + 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, + 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, + 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, + 0x5be0cd19, 0x137e2179 ]; + this.k = sha512_K; + this.W = new Array(160); +} +utils.inherits(SHA512, BlockHash); +module.exports = SHA512; + +SHA512.blockSize = 1024; +SHA512.outSize = 512; +SHA512.hmacStrength = 192; +SHA512.padLength = 128; + +SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { + var W = this.W; + + // 32 x 32bit words + for (var i = 0; i < 32; i++) + W[i] = msg[start + i]; + for (; i < W.length; i += 2) { + var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 + var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); + var c1_hi = W[i - 14]; // i - 7 + var c1_lo = W[i - 13]; + var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 + var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); + var c3_hi = W[i - 32]; // i - 16 + var c3_lo = W[i - 31]; + + W[i] = sum64_4_hi( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + W[i + 1] = sum64_4_lo( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + } +}; + +SHA512.prototype._update = function _update(msg, start) { + this._prepareBlock(msg, start); + + var W = this.W; + + var ah = this.h[0]; + var al = this.h[1]; + var bh = this.h[2]; + var bl = this.h[3]; + var ch = this.h[4]; + var cl = this.h[5]; + var dh = this.h[6]; + var dl = this.h[7]; + var eh = this.h[8]; + var el = this.h[9]; + var fh = this.h[10]; + var fl = this.h[11]; + var gh = this.h[12]; + var gl = this.h[13]; + var hh = this.h[14]; + var hl = this.h[15]; + + assert(this.k.length === W.length); + for (var i = 0; i < W.length; i += 2) { + var c0_hi = hh; + var c0_lo = hl; + var c1_hi = s1_512_hi(eh, el); + var c1_lo = s1_512_lo(eh, el); + var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); + var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); + var c3_hi = this.k[i]; + var c3_lo = this.k[i + 1]; + var c4_hi = W[i]; + var c4_lo = W[i + 1]; + + var T1_hi = sum64_5_hi( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + var T1_lo = sum64_5_lo( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + + c0_hi = s0_512_hi(ah, al); + c0_lo = s0_512_lo(ah, al); + c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); + c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); + + var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); + var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); + + hh = gh; + hl = gl; + + gh = fh; + gl = fl; + + fh = eh; + fl = el; + + eh = sum64_hi(dh, dl, T1_hi, T1_lo); + el = sum64_lo(dl, dl, T1_hi, T1_lo); + + dh = ch; + dl = cl; + + ch = bh; + cl = bl; + + bh = ah; + bl = al; + + ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); + al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); + } + + sum64(this.h, 0, ah, al); + sum64(this.h, 2, bh, bl); + sum64(this.h, 4, ch, cl); + sum64(this.h, 6, dh, dl); + sum64(this.h, 8, eh, el); + sum64(this.h, 10, fh, fl); + sum64(this.h, 12, gh, gl); + sum64(this.h, 14, hh, hl); +}; + +SHA512.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +function ch64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ ((~xh) & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function ch64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ ((~xl) & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 28); + var c1_hi = rotr64_hi(xl, xh, 2); // 34 + var c2_hi = rotr64_hi(xl, xh, 7); // 39 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 28); + var c1_lo = rotr64_lo(xl, xh, 2); // 34 + var c2_lo = rotr64_lo(xl, xh, 7); // 39 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 14); + var c1_hi = rotr64_hi(xh, xl, 18); + var c2_hi = rotr64_hi(xl, xh, 9); // 41 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 14); + var c1_lo = rotr64_lo(xh, xl, 18); + var c2_lo = rotr64_lo(xl, xh, 9); // 41 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 1); + var c1_hi = rotr64_hi(xh, xl, 8); + var c2_hi = shr64_hi(xh, xl, 7); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 1); + var c1_lo = rotr64_lo(xh, xl, 8); + var c2_lo = shr64_lo(xh, xl, 7); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 19); + var c1_hi = rotr64_hi(xl, xh, 29); // 61 + var c2_hi = shr64_hi(xh, xl, 6); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 19); + var c1_lo = rotr64_lo(xl, xh, 29); // 61 + var c2_lo = shr64_lo(xh, xl, 6); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +},{"../common":21,"../utils":31,"minimalistic-assert":34}],30:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var rotr32 = utils.rotr32; + +function ft_1(s, x, y, z) { + if (s === 0) + return ch32(x, y, z); + if (s === 1 || s === 3) + return p32(x, y, z); + if (s === 2) + return maj32(x, y, z); +} +exports.ft_1 = ft_1; + +function ch32(x, y, z) { + return (x & y) ^ ((~x) & z); +} +exports.ch32 = ch32; + +function maj32(x, y, z) { + return (x & y) ^ (x & z) ^ (y & z); +} +exports.maj32 = maj32; + +function p32(x, y, z) { + return x ^ y ^ z; +} +exports.p32 = p32; + +function s0_256(x) { + return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); +} +exports.s0_256 = s0_256; + +function s1_256(x) { + return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); +} +exports.s1_256 = s1_256; + +function g0_256(x) { + return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); +} +exports.g0_256 = g0_256; + +function g1_256(x) { + return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); +} +exports.g1_256 = g1_256; + +},{"../utils":31}],31:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +exports.inherits = inherits; + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === 'string') { + if (!enc) { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } else if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } + } else { + for (i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + } + return res; +} +exports.toArray = toArray; + +function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +exports.toHex = toHex; + +function htonl(w) { + var res = (w >>> 24) | + ((w >>> 8) & 0xff00) | + ((w << 8) & 0xff0000) | + ((w & 0xff) << 24); + return res >>> 0; +} +exports.htonl = htonl; + +function toHex32(msg, endian) { + var res = ''; + for (var i = 0; i < msg.length; i++) { + var w = msg[i]; + if (endian === 'little') + w = htonl(w); + res += zero8(w.toString(16)); + } + return res; +} +exports.toHex32 = toHex32; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +exports.zero2 = zero2; + +function zero8(word) { + if (word.length === 7) + return '0' + word; + else if (word.length === 6) + return '00' + word; + else if (word.length === 5) + return '000' + word; + else if (word.length === 4) + return '0000' + word; + else if (word.length === 3) + return '00000' + word; + else if (word.length === 2) + return '000000' + word; + else if (word.length === 1) + return '0000000' + word; + else + return word; +} +exports.zero8 = zero8; + +function join32(msg, start, end, endian) { + var len = end - start; + assert(len % 4 === 0); + var res = new Array(len / 4); + for (var i = 0, k = start; i < res.length; i++, k += 4) { + var w; + if (endian === 'big') + w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; + else + w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; + res[i] = w >>> 0; + } + return res; +} +exports.join32 = join32; + +function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i = 0, k = 0; i < msg.length; i++, k += 4) { + var m = msg[i]; + if (endian === 'big') { + res[k] = m >>> 24; + res[k + 1] = (m >>> 16) & 0xff; + res[k + 2] = (m >>> 8) & 0xff; + res[k + 3] = m & 0xff; + } else { + res[k + 3] = m >>> 24; + res[k + 2] = (m >>> 16) & 0xff; + res[k + 1] = (m >>> 8) & 0xff; + res[k] = m & 0xff; + } + } + return res; +} +exports.split32 = split32; + +function rotr32(w, b) { + return (w >>> b) | (w << (32 - b)); +} +exports.rotr32 = rotr32; + +function rotl32(w, b) { + return (w << b) | (w >>> (32 - b)); +} +exports.rotl32 = rotl32; + +function sum32(a, b) { + return (a + b) >>> 0; +} +exports.sum32 = sum32; + +function sum32_3(a, b, c) { + return (a + b + c) >>> 0; +} +exports.sum32_3 = sum32_3; + +function sum32_4(a, b, c, d) { + return (a + b + c + d) >>> 0; +} +exports.sum32_4 = sum32_4; + +function sum32_5(a, b, c, d, e) { + return (a + b + c + d + e) >>> 0; +} +exports.sum32_5 = sum32_5; + +function sum64(buf, pos, ah, al) { + var bh = buf[pos]; + var bl = buf[pos + 1]; + + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf[pos] = hi >>> 0; + buf[pos + 1] = lo; +} +exports.sum64 = sum64; + +function sum64_hi(ah, al, bh, bl) { + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; +} +exports.sum64_hi = sum64_hi; + +function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; +} +exports.sum64_lo = sum64_lo; + +function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; +} +exports.sum64_4_hi = sum64_4_hi; + +function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; +} +exports.sum64_4_lo = sum64_4_lo; + +function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + lo = (lo + el) >>> 0; + carry += lo < el ? 1 : 0; + + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; +} +exports.sum64_5_hi = sum64_5_hi; + +function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + + return lo >>> 0; +} +exports.sum64_5_lo = sum64_5_lo; + +function rotr64_hi(ah, al, num) { + var r = (al << (32 - num)) | (ah >>> num); + return r >>> 0; +} +exports.rotr64_hi = rotr64_hi; + +function rotr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +exports.rotr64_lo = rotr64_lo; + +function shr64_hi(ah, al, num) { + return ah >>> num; +} +exports.shr64_hi = shr64_hi; + +function shr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +exports.shr64_lo = shr64_lo; + +},{"inherits":32,"minimalistic-assert":34}],32:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + +},{}],33:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.5.7 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2016 + * @license MIT + */ +/*jslint bitwise: true */ +(function () { + 'use strict'; + + var root = typeof window === 'object' ? window : {}; + var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = global; + } + var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports; + var HEX_CHARS = '0123456789abcdef'.split(''); + var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; + var KECCAK_PADDING = [1, 256, 65536, 16777216]; + var PADDING = [6, 1536, 393216, 100663296]; + var SHIFT = [0, 8, 16, 24]; + var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; + var BITS = [224, 256, 384, 512]; + var SHAKE_BITS = [128, 256]; + var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; + + var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; + }; + + var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; + }; + + var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(bits, padding, type); + } + return method; + }; + + var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createShakeOutputMethod(bits, padding, type); + } + return method; + }; + + var algorithms = [ + {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod}, + {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod}, + {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod} + ]; + + var methods = {}, methodNames = []; + + for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name +'_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + } + } + + function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } + } + + Keccak.prototype.update = function (message) { + var notString = typeof message !== 'string'; + if (notString && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } + var length = message.length, blocks = this.blocks, byteCount = this.byteCount, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; + }; + + Keccak.prototype.finalize = function () { + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + }; + + Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + if (extraBytes > 0) { + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + } + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; + }; + + Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; + }; + + Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + + Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + if (extraBytes > 0) { + array[offset] = block & 0xFF; + } + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; + }; + + var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } + }; + + if (COMMON_JS) { + module.exports = methods; + } else { + for (var i = 0; i < methodNames.length; ++i) { + root[methodNames[i]] = methods[methodNames[i]]; + } + } +})(); + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":35}],34:[function(require,module,exports){ +module.exports = assert; + +function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); +} + +assert.equal = function assertEqual(l, r, msg) { + if (l != r) + throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); +}; + +},{}],35:[function(require,module,exports){ +module.exports = { browser: true }; +},{}],36:[function(require,module,exports){ +(function (setImmediate){ +"use strict"; + +(function(root) { + var MAX_VALUE = 0x7fffffff; + + // The SHA256 and PBKDF2 implementation are from scrypt-async-js: + // See: https://github.com/dchest/scrypt-async-js + function SHA256(m) { + var K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, + 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, + 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, + 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, + 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, + 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, + 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, + 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, + 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + + var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a; + var h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; + var w = new Array(64); + + function blocks(p) { + var off = 0, len = p.length; + while (len >= 64) { + var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2; + + for (i = 0; i < 16; i++) { + j = off + i*4; + w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) | + ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff); + } + + for (i = 16; i < 64; i++) { + u = w[i-2]; + t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10); + + u = w[i-15]; + t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3); + + w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0; + } + + for (i = 0; i < 64; i++) { + t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^ + ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) + + ((h + ((K[i] + w[i]) | 0)) | 0)) | 0; + + t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^ + ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + h0 = (h0 + a) | 0; + h1 = (h1 + b) | 0; + h2 = (h2 + c) | 0; + h3 = (h3 + d) | 0; + h4 = (h4 + e) | 0; + h5 = (h5 + f) | 0; + h6 = (h6 + g) | 0; + h7 = (h7 + h) | 0; + + off += 64; + len -= 64; + } + } + + blocks(m); + + var i, bytesLeft = m.length % 64, + bitLenHi = (m.length / 0x20000000) | 0, + bitLenLo = m.length << 3, + numZeros = (bytesLeft < 56) ? 56 : 120, + p = m.slice(m.length - bytesLeft, m.length); + + p.push(0x80); + for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); } + p.push((bitLenHi>>>24) & 0xff); + p.push((bitLenHi>>>16) & 0xff); + p.push((bitLenHi>>>8) & 0xff); + p.push((bitLenHi>>>0) & 0xff); + p.push((bitLenLo>>>24) & 0xff); + p.push((bitLenLo>>>16) & 0xff); + p.push((bitLenLo>>>8) & 0xff); + p.push((bitLenLo>>>0) & 0xff); + + blocks(p); + + return [ + (h0>>>24) & 0xff, (h0>>>16) & 0xff, (h0>>>8) & 0xff, (h0>>>0) & 0xff, + (h1>>>24) & 0xff, (h1>>>16) & 0xff, (h1>>>8) & 0xff, (h1>>>0) & 0xff, + (h2>>>24) & 0xff, (h2>>>16) & 0xff, (h2>>>8) & 0xff, (h2>>>0) & 0xff, + (h3>>>24) & 0xff, (h3>>>16) & 0xff, (h3>>>8) & 0xff, (h3>>>0) & 0xff, + (h4>>>24) & 0xff, (h4>>>16) & 0xff, (h4>>>8) & 0xff, (h4>>>0) & 0xff, + (h5>>>24) & 0xff, (h5>>>16) & 0xff, (h5>>>8) & 0xff, (h5>>>0) & 0xff, + (h6>>>24) & 0xff, (h6>>>16) & 0xff, (h6>>>8) & 0xff, (h6>>>0) & 0xff, + (h7>>>24) & 0xff, (h7>>>16) & 0xff, (h7>>>8) & 0xff, (h7>>>0) & 0xff + ]; + } + + function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) { + // compress password if it's longer than hash block length + password = password.length <= 64 ? password : SHA256(password); + + var i; + var innerLen = 64 + salt.length + 4; + var inner = new Array(innerLen); + var outerKey = new Array(64); + var dk = []; + + // inner = (password ^ ipad) || salt || counter + for (i = 0; i < 64; i++) inner[i] = 0x36; + for (i = 0; i < password.length; i++) inner[i] ^= password[i]; + for (i = 0; i < salt.length; i++) inner[64+i] = salt[i]; + for (i = innerLen - 4; i < innerLen; i++) inner[i] = 0; + + // outerKey = password ^ opad + for (i = 0; i < 64; i++) outerKey[i] = 0x5c; + for (i = 0; i < password.length; i++) outerKey[i] ^= password[i]; + + // increments counter inside inner + function incrementCounter() { + for (var i = innerLen-1; i >= innerLen-4; i--) { + inner[i]++; + if (inner[i] <= 0xff) return; + inner[i] = 0; + } + } + + // output blocks = SHA256(outerKey || SHA256(inner)) ... + while (dkLen >= 32) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner)))); + dkLen -= 32; + } + if (dkLen > 0) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen)); + } + + return dk; + } + + // The following is an adaptation of scryptsy + // See: https://www.npmjs.com/package/scryptsy + function blockmix_salsa8(BY, Yi, r, x, _X) { + var i; + + arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16); + for (i = 0; i < 2 * r; i++) { + blockxor(BY, i * 16, _X, 16); + salsa20_8(_X, x); + arraycopy(_X, 0, BY, Yi + (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16); + } + } + + function R(a, b) { + return (a << b) | (a >>> (32 - b)); + } + + function salsa20_8(B, x) { + arraycopy(B, 0, x, 0, 16); + + for (var i = 8; i > 0; i -= 2) { + x[ 4] ^= R(x[ 0] + x[12], 7); + x[ 8] ^= R(x[ 4] + x[ 0], 9); + x[12] ^= R(x[ 8] + x[ 4], 13); + x[ 0] ^= R(x[12] + x[ 8], 18); + x[ 9] ^= R(x[ 5] + x[ 1], 7); + x[13] ^= R(x[ 9] + x[ 5], 9); + x[ 1] ^= R(x[13] + x[ 9], 13); + x[ 5] ^= R(x[ 1] + x[13], 18); + x[14] ^= R(x[10] + x[ 6], 7); + x[ 2] ^= R(x[14] + x[10], 9); + x[ 6] ^= R(x[ 2] + x[14], 13); + x[10] ^= R(x[ 6] + x[ 2], 18); + x[ 3] ^= R(x[15] + x[11], 7); + x[ 7] ^= R(x[ 3] + x[15], 9); + x[11] ^= R(x[ 7] + x[ 3], 13); + x[15] ^= R(x[11] + x[ 7], 18); + x[ 1] ^= R(x[ 0] + x[ 3], 7); + x[ 2] ^= R(x[ 1] + x[ 0], 9); + x[ 3] ^= R(x[ 2] + x[ 1], 13); + x[ 0] ^= R(x[ 3] + x[ 2], 18); + x[ 6] ^= R(x[ 5] + x[ 4], 7); + x[ 7] ^= R(x[ 6] + x[ 5], 9); + x[ 4] ^= R(x[ 7] + x[ 6], 13); + x[ 5] ^= R(x[ 4] + x[ 7], 18); + x[11] ^= R(x[10] + x[ 9], 7); + x[ 8] ^= R(x[11] + x[10], 9); + x[ 9] ^= R(x[ 8] + x[11], 13); + x[10] ^= R(x[ 9] + x[ 8], 18); + x[12] ^= R(x[15] + x[14], 7); + x[13] ^= R(x[12] + x[15], 9); + x[14] ^= R(x[13] + x[12], 13); + x[15] ^= R(x[14] + x[13], 18); + } + + for (i = 0; i < 16; ++i) { + B[i] += x[i]; + } + } + + // naive approach... going back to loop unrolling may yield additional performance + function blockxor(S, Si, D, len) { + for (var i = 0; i < len; i++) { + D[i] ^= S[Si + i] + } + } + + function arraycopy(src, srcPos, dest, destPos, length) { + while (length--) { + dest[destPos++] = src[srcPos++]; + } + } + + function checkBufferish(o) { + if (!o || typeof(o.length) !== 'number') { + return false; + } + for (var i = 0; i < o.length; i++) { + if (typeof(o[i]) !== 'number') { return false; } + + var v = parseInt(o[i]); + if (v != o[i] || v < 0 || v >= 256) { + return false; + } + } + return true; + } + + function ensureInteger(value, name) { + var intValue = parseInt(value); + if (value != intValue) { throw new Error('invalid ' + name); } + return intValue; + } + + // N = Cpu cost, r = Memory cost, p = parallelization cost + // callback(error, progress, key) + function scrypt(password, salt, N, r, p, dkLen, callback) { + + if (!callback) { throw new Error('missing callback'); } + + N = ensureInteger(N, 'N'); + r = ensureInteger(r, 'r'); + p = ensureInteger(p, 'p'); + + dkLen = ensureInteger(dkLen, 'dkLen'); + + if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); } + + if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); } + if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); } + + if (!checkBufferish(password)) { + throw new Error('password must be an array or buffer'); + } + password = Array.prototype.slice.call(password); + + if (!checkBufferish(salt)) { + throw new Error('salt must be an array or buffer'); + } + salt = Array.prototype.slice.call(salt); + + var b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r); + var B = new Uint32Array(p * 32 * r) + for (var i = 0; i < B.length; i++) { + var j = i * 4; + B[i] = ((b[j + 3] & 0xff) << 24) | + ((b[j + 2] & 0xff) << 16) | + ((b[j + 1] & 0xff) << 8) | + ((b[j + 0] & 0xff) << 0); + } + + var XY = new Uint32Array(64 * r); + var V = new Uint32Array(32 * r * N); + + var Yi = 32 * r; + + // scratch space + var x = new Uint32Array(16); // salsa20_8 + var _X = new Uint32Array(16); // blockmix_salsa8 + + var totalOps = p * N * 2; + var currentOp = 0; + var lastPercent10 = null; + + // Set this to true to abandon the scrypt on the next step + var stop = false; + + // State information + var state = 0; + var i0 = 0, i1; + var Bi; + + // How many blockmix_salsa8 can we do per step? + var limit = parseInt(1000 / r); + + // Trick from scrypt-async; if there is a setImmediate shim in place, use it + var nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout; + + // This is really all I changed; making scryptsy a state machine so we occasionally + // stop and give other evnts on the evnt loop a chance to run. ~RicMoo + var incrementalSMix = function() { + if (stop) { + return callback(new Error('cancelled'), currentOp / totalOps); + } + + switch (state) { + case 0: + // for (var i = 0; i < p; i++)... + Bi = i0 * 32 * r; + + arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1 + + state = 1; // Move to ROMix 2 + i1 = 0; + + // Fall through + + case 1: + + // Run up to 1000 steps of the first inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 2 + arraycopy(XY, 0, V, (i1 + i) * Yi, Yi) // ROMix - 3 + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4 + } + + // for (var i = 0; i < N; i++) + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + i1 = 0; // Move to ROMix 6 + state = 2; + + // Fall through + + case 2: + + // Run up to 1000 steps of the second inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 6 + var offset = (2 * r - 1) * 16; // ROMix - 7 + var j = XY[offset] & (N - 1); + blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner) + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer) + } + + // for (var i = 0; i < N; i++)... + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10 + + // for (var i = 0; i < p; i++)... + i0++; + if (i0 < p) { + state = 0; + break; + } + + b = []; + for (var i = 0; i < B.length; i++) { + b.push((B[i] >> 0) & 0xff); + b.push((B[i] >> 8) & 0xff); + b.push((B[i] >> 16) & 0xff); + b.push((B[i] >> 24) & 0xff); + } + + var derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen); + + // Done; don't break (which would reschedule) + return callback(null, 1.0, derivedKey); + } + + // Schedule the next steps + nextTick(incrementalSMix); + } + + // Bootstrap the incremental smix + incrementalSMix(); + } + + // node.js + if (typeof(exports) !== 'undefined') { + module.exports = scrypt; + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(define) === 'function' && define.amd) { + define(scrypt); + + // Web Browsers + } else if (root) { + + // If there was an existing library "scrypt", make sure it is still available + if (root.scrypt) { + root._scrypt = root.scrypt; + } + + root.scrypt = scrypt; + } + +})(this); + +}).call(this,require("timers").setImmediate) +},{"timers":37}],37:[function(require,module,exports){ +(function (global){ +module.exports = { setImmediate: global.setImmediate }; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],38:[function(require,module,exports){ +(function (global){ + +var rng; + +if (global.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; +} + +if (!rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; +} + +module.exports = rng; + + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],39:[function(require,module,exports){ +// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php + +// Unique ID creation requires a high quality random # generator. We feature +// detect to determine the best RNG source, normalizing to a function that +// returns 128-bits of randomness, since that's what's usually required +var _rng = require('./rng'); + +// Maps for number <-> hex string conversion +var _byteToHex = []; +var _hexToByte = {}; +for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; +} + +// **`parse()` - Parse a UUID into it's component bytes** +function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; +} + +// **`unparse()` - Convert UUID byte array (ala parse()) into a string** +function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; +} + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html + +// random #'s we need to init node and clockseq +var _seedBytes = _rng(); + +// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) +var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] +]; + +// Per 4.2.2, randomize (14 bit) clockseq +var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + +// Previous uuid creation time +var _lastMSecs = 0, _lastNSecs = 0; + +// See https://github.com/broofa/node-uuid for API details +function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); +} + +// **`v4()` - Generate random UUID** + +// See https://github.com/broofa/node-uuid for API details +function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new Array(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); +} + +// Export public API +var uuid = v4; +uuid.v1 = v1; +uuid.v4 = v4; +uuid.parse = parse; +uuid.unparse = unparse; + +module.exports = uuid; + +},{"./rng":38}],40:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var abstract_coder_1 = require("./coders/abstract-coder"); +var address_1 = require("./coders/address"); +var array_1 = require("./coders/array"); +var boolean_1 = require("./coders/boolean"); +var bytes_2 = require("./coders/bytes"); +var fixed_bytes_1 = require("./coders/fixed-bytes"); +var null_1 = require("./coders/null"); +var number_1 = require("./coders/number"); +var string_1 = require("./coders/string"); +var tuple_1 = require("./coders/tuple"); +var fragments_1 = require("./fragments"); +var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); +var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); +var AbiCoder = /** @class */ (function () { + function AbiCoder(coerceFunc) { + var _newTarget = this.constructor; + errors.checkNew(_newTarget, AbiCoder); + properties_1.defineReadOnly(this, "coerceFunc", coerceFunc || null); + } + AbiCoder.prototype._getCoder = function (param) { + var _this = this; + switch (param.baseType) { + case "address": + return new address_1.AddressCoder(param.name); + case "bool": + return new boolean_1.BooleanCoder(param.name); + case "string": + return new string_1.StringCoder(param.name); + case "bytes": + return new bytes_2.BytesCoder(param.name); + case "array": + return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new tuple_1.TupleCoder((param.components || []).map(function (component) { + return _this._getCoder(component); + }), param.name); + case "": + return new null_1.NullCoder(param.name); + } + // u?int[0-9]* + var match = param.type.match(paramTypeNumber); + if (match) { + var size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || (size % 8) !== 0) { + errors.throwError("invalid " + match[1] + " bit length", errors.INVALID_ARGUMENT, { + arg: "param", + value: param + }); + } + return new number_1.NumberCoder(size / 8, (match[1] === "int"), param.name); + } + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + var size = parseInt(match[1]); + if (size === 0 || size > 32) { + errors.throwError("invalid bytes length", errors.INVALID_ARGUMENT, { + arg: "param", + value: param + }); + } + return new fixed_bytes_1.FixedBytesCoder(size, param.name); + } + return errors.throwError("invalid type", errors.INVALID_ARGUMENT, { + arg: "type", + value: param.type + }); + }; + AbiCoder.prototype._getWordSize = function () { return 32; }; + AbiCoder.prototype._getReader = function (data) { + return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc); + }; + AbiCoder.prototype._getWriter = function () { + return new abstract_coder_1.Writer(this._getWordSize()); + }; + AbiCoder.prototype.encode = function (types, values) { + var _this = this; + if (types.length !== values.length) { + errors.throwError("types/values length mismatch", errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types: types, values: values } + }); + } + var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); }); + var coder = (new tuple_1.TupleCoder(coders, "_")); + var writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + }; + AbiCoder.prototype.decode = function (types, data) { + var _this = this; + var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); }); + var coder = new tuple_1.TupleCoder(coders, "_"); + return coder.decode(this._getReader(bytes_1.arrayify(data))); + }; + return AbiCoder; +}()); +exports.AbiCoder = AbiCoder; +exports.defaultAbiCoder = new AbiCoder(); + +},{"./coders/abstract-coder":41,"./coders/address":42,"./coders/array":44,"./coders/boolean":45,"./coders/bytes":46,"./coders/fixed-bytes":47,"./coders/null":48,"./coders/number":49,"./coders/string":50,"./coders/tuple":51,"./fragments":52,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],41:[function(require,module,exports){ +"use trict"; +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var bignumber_1 = require("@ethersproject/bignumber"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var Coder = /** @class */ (function () { + function Coder(name, type, localName, dynamic) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + Coder.prototype._throwError = function (message, value) { + errors.throwError(message, errors.INVALID_ARGUMENT, { + argument: this.localName, + coder: this, + value: value + }); + }; + return Coder; +}()); +exports.Coder = Coder; +var Writer = /** @class */ (function () { + function Writer(wordSize) { + properties_1.defineReadOnly(this, "wordSize", wordSize || 32); + this._data = bytes_1.arrayify([]); + this._padding = new Uint8Array(wordSize); + } + Object.defineProperty(Writer.prototype, "data", { + get: function () { return bytes_1.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Writer.prototype, "length", { + get: function () { return this._data.length; }, + enumerable: true, + configurable: true + }); + Writer.prototype._writeData = function (data) { + this._data = bytes_1.concat([this._data, data]); + return data.length; + }; + // Arrayish items; padded on the right to wordSize + Writer.prototype.writeBytes = function (value) { + var bytes = bytes_1.arrayify(value); + if (bytes.length % this.wordSize) { + bytes = bytes_1.concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); + } + return this._writeData(bytes); + }; + Writer.prototype._getValue = function (value) { + var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value)); + if (bytes.length > this.wordSize) { + errors.throwError("value out-of-bounds", errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]); + } + return bytes; + }; + // BigNumberish items; padded on the left to wordSize + Writer.prototype.writeValue = function (value) { + return this._writeData(this._getValue(value)); + }; + Writer.prototype.writeUpdatableValue = function () { + var _this = this; + var offset = this.length; + this.writeValue(0); + return function (value) { + _this._data.set(_this._getValue(value), offset); + }; + }; + return Writer; +}()); +exports.Writer = Writer; +var Reader = /** @class */ (function () { + function Reader(data, wordSize, coerceFunc) { + properties_1.defineReadOnly(this, "_data", bytes_1.arrayify(data)); + properties_1.defineReadOnly(this, "wordSize", wordSize || 32); + properties_1.defineReadOnly(this, "_coerceFunc", coerceFunc); + this._offset = 0; + } + Object.defineProperty(Reader.prototype, "data", { + get: function () { return bytes_1.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Reader.prototype, "consumed", { + get: function () { return this._offset; }, + enumerable: true, + configurable: true + }); + // The default Coerce function + Reader.coerce = function (name, value) { + var match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + }; + Reader.prototype.coerce = function (name, value) { + if (this._coerceFunc) { + return this._coerceFunc(name, value); + } + return Reader.coerce(name, value); + }; + Reader.prototype._peekBytes = function (offset, length) { + var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + errors.throwError("data out-of-bounds", errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength); + }; + Reader.prototype.subReader = function (offset) { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + }; + Reader.prototype.readBytes = function (length) { + var bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + }; + Reader.prototype.readValue = function () { + return bignumber_1.BigNumber.from(this.readBytes(this.wordSize)); + }; + return Reader; +}()); +exports.Reader = Reader; + +},{"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],42:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +var AddressCoder = /** @class */ (function (_super) { + __extends(AddressCoder, _super); + function AddressCoder(localName) { + return _super.call(this, "address", "address", localName, false) || this; + } + AddressCoder.prototype.encode = function (writer, value) { + try { + address_1.getAddress(value); + } + catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + }; + AddressCoder.prototype.decode = function (reader) { + return address_1.getAddress(bytes_1.hexZeroPad(reader.readValue().toHexString(), 20)); + }; + return AddressCoder; +}(abstract_coder_1.Coder)); +exports.AddressCoder = AddressCoder; + +},{"./abstract-coder":41,"@ethersproject/address":57,"@ethersproject/bytes":63}],43:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +// Clones the functionality of an existing Coder, but without a localName +var AnonymousCoder = /** @class */ (function (_super) { + __extends(AnonymousCoder, _super); + function AnonymousCoder(coder) { + var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this; + _this.coder = coder; + return _this; + } + AnonymousCoder.prototype.encode = function (writer, value) { + return this.coder.encode(writer, value); + }; + AnonymousCoder.prototype.decode = function (reader) { + return this.coder.decode(reader); + }; + return AnonymousCoder; +}(abstract_coder_1.Coder)); +exports.AnonymousCoder = AnonymousCoder; + +},{"./abstract-coder":41}],44:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var abstract_coder_1 = require("./abstract-coder"); +var anonymous_1 = require("./anonymous"); +function pack(writer, coders, values) { + if (Array.isArray(values)) { + // do nothing + } + else if (values && typeof (values) === "object") { + var arrayValues_1 = []; + coders.forEach(function (coder) { + arrayValues_1.push(values[coder.localName]); + }); + values = arrayValues_1; + } + else { + errors.throwError("invalid tuple value", errors.INVALID_ARGUMENT, { + coderType: "tuple", + value: values + }); + } + if (coders.length !== values.length) { + errors.throwError("types/value length mismatch", errors.INVALID_ARGUMENT, { + coderType: "tuple", + value: values + }); + } + var staticWriter = new abstract_coder_1.Writer(writer.wordSize); + var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize); + var updateFuncs = []; + coders.forEach(function (coder, index) { + var value = values[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + var dynamicOffset_1 = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + var updateFunc_1 = staticWriter.writeUpdatableValue(); + updateFuncs.push(function (baseOffset) { + updateFunc_1(baseOffset + dynamicOffset_1); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach(function (func) { func(staticWriter.length); }); + var length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; +} +exports.pack = pack; +function unpack(reader, coders) { + var values = []; + // A reader anchored to this base + var baseReader = reader.subReader(0); + // The amount of dynamic data read; to consume later to synchronize + var dynamicLength = 0; + coders.forEach(function (coder) { + var value = null; + if (coder.dynamic) { + var offset = reader.readValue(); + var offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } + else { + value = coder.decode(reader); + } + if (value != undefined) { + values.push(value); + } + }); + // @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + // Add any named parameters (i.e. tuples) + coders.forEach(function (coder, index) { + var name = coder.localName; + if (!name) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return values; +} +exports.unpack = unpack; +var ArrayCoder = /** @class */ (function (_super) { + __extends(ArrayCoder, _super); + function ArrayCoder(coder, length, localName) { + var _this = this; + var type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + var dynamic = (length === -1 || coder.dynamic); + _this = _super.call(this, "array", type, localName, dynamic) || this; + _this.coder = coder; + _this.length = length; + return _this; + } + ArrayCoder.prototype.encode = function (writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + var count = this.length; + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + errors.checkArgumentCount(count, value.length, " in coder array" + (this.localName ? (" " + this.localName) : "")); + var coders = []; + for (var i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + }; + ArrayCoder.prototype.decode = function (reader) { + var count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + var coders = []; + for (var i = 0; i < count; i++) { + coders.push(new anonymous_1.AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + }; + return ArrayCoder; +}(abstract_coder_1.Coder)); +exports.ArrayCoder = ArrayCoder; + +},{"./abstract-coder":41,"./anonymous":43,"@ethersproject/errors":66}],45:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var BooleanCoder = /** @class */ (function (_super) { + __extends(BooleanCoder, _super); + function BooleanCoder(localName) { + return _super.call(this, "bool", "bool", localName, false) || this; + } + BooleanCoder.prototype.encode = function (writer, value) { + return writer.writeValue(value ? 1 : 0); + }; + BooleanCoder.prototype.decode = function (reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + }; + return BooleanCoder; +}(abstract_coder_1.Coder)); +exports.BooleanCoder = BooleanCoder; + +},{"./abstract-coder":41}],46:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +var DynamicBytesCoder = /** @class */ (function (_super) { + __extends(DynamicBytesCoder, _super); + function DynamicBytesCoder(type, localName) { + return _super.call(this, type, type, localName, true) || this; + } + DynamicBytesCoder.prototype.encode = function (writer, value) { + value = bytes_1.arrayify(value); + var length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + }; + DynamicBytesCoder.prototype.decode = function (reader) { + return reader.readBytes(reader.readValue().toNumber()); + }; + return DynamicBytesCoder; +}(abstract_coder_1.Coder)); +exports.DynamicBytesCoder = DynamicBytesCoder; +var BytesCoder = /** @class */ (function (_super) { + __extends(BytesCoder, _super); + function BytesCoder(localName) { + return _super.call(this, "bytes", localName) || this; + } + BytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes_1.hexlify(_super.prototype.decode.call(this, reader))); + }; + return BytesCoder; +}(DynamicBytesCoder)); +exports.BytesCoder = BytesCoder; + +},{"./abstract-coder":41,"@ethersproject/bytes":63}],47:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +// @TODO: Merge this with bytes +var FixedBytesCoder = /** @class */ (function (_super) { + __extends(FixedBytesCoder, _super); + function FixedBytesCoder(size, localName) { + var _this = this; + var name = "bytes" + String(size); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + return _this; + } + FixedBytesCoder.prototype.encode = function (writer, value) { + var data = bytes_1.arrayify(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); + } + return writer.writeBytes(data); + }; + FixedBytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes_1.hexlify(reader.readBytes(this.size))); + }; + return FixedBytesCoder; +}(abstract_coder_1.Coder)); +exports.FixedBytesCoder = FixedBytesCoder; + +},{"./abstract-coder":41,"@ethersproject/bytes":63}],48:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var NullCoder = /** @class */ (function (_super) { + __extends(NullCoder, _super); + function NullCoder(localName) { + return _super.call(this, "null", "", localName, false) || this; + } + NullCoder.prototype.encode = function (writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + }; + NullCoder.prototype.decode = function (reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + }; + return NullCoder; +}(abstract_coder_1.Coder)); +exports.NullCoder = NullCoder; + +},{"./abstract-coder":41}],49:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("@ethersproject/bignumber"); +var constants_1 = require("@ethersproject/constants"); +var abstract_coder_1 = require("./abstract-coder"); +var NumberCoder = /** @class */ (function (_super) { + __extends(NumberCoder, _super); + function NumberCoder(size, signed, localName) { + var _this = this; + var name = ((signed ? "int" : "uint") + (size * 8)); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + _this.signed = signed; + return _this; + } + NumberCoder.prototype.encode = function (writer, value) { + var v = bignumber_1.BigNumber.from(value); + // Check bounds are safe for encoding + var maxUintValue = constants_1.MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + var bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { + this._throwError("value out-of-bounds", value); + } + } + else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).maskn(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + }; + NumberCoder.prototype.decode = function (reader) { + var value = reader.readValue().maskn(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + }; + return NumberCoder; +}(abstract_coder_1.Coder)); +exports.NumberCoder = NumberCoder; + +},{"./abstract-coder":41,"@ethersproject/bignumber":62,"@ethersproject/constants":64}],50:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var strings_1 = require("@ethersproject/strings"); +var bytes_1 = require("./bytes"); +var StringCoder = /** @class */ (function (_super) { + __extends(StringCoder, _super); + function StringCoder(localName) { + return _super.call(this, "string", localName) || this; + } + StringCoder.prototype.encode = function (writer, value) { + return _super.prototype.encode.call(this, writer, strings_1.toUtf8Bytes(value)); + }; + StringCoder.prototype.decode = function (reader) { + return strings_1.toUtf8String(_super.prototype.decode.call(this, reader)); + }; + return StringCoder; +}(bytes_1.DynamicBytesCoder)); +exports.StringCoder = StringCoder; + +},{"./bytes":46,"@ethersproject/strings":101}],51:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var array_1 = require("./array"); +var TupleCoder = /** @class */ (function (_super) { + __extends(TupleCoder, _super); + function TupleCoder(coders, localName) { + var _this = this; + var dynamic = false; + var types = []; + coders.forEach(function (coder) { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + var type = ("tuple(" + types.join(",") + ")"); + _this = _super.call(this, "tuple", type, localName, dynamic) || this; + _this.coders = coders; + return _this; + } + TupleCoder.prototype.encode = function (writer, value) { + return array_1.pack(writer, this.coders, value); + }; + TupleCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, array_1.unpack(reader, this.coders)); + }; + return TupleCoder; +}(abstract_coder_1.Coder)); +exports.TupleCoder = TupleCoder; + +},{"./abstract-coder":41,"./array":44}],52:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("@ethersproject/bignumber"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +; +var _constructorGuard = {}; +// @TODO: Make sure that children of an indexed tuple are marked with a null indexed +function parseParamType(param, allowIndexed) { + var originalParam = param; + function throwError(i) { + throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); + } + param = param.replace(/\s/g, " "); + function newNode(parent) { + var node = { type: "", name: "", parent: parent, state: { allowType: true } }; + if (allowIndexed) { + node.indexed = false; + } + return node; + } + var parent = { type: "", name: "", state: { allowType: true } }; + var node = parent; + for (var i = 0; i < param.length; i++) { + var c = param[i]; + switch (c) { + case "(": + if (!node.state.allowParams) { + throwError(i); + } + node.state.allowType = false; + node.type = verifyType(node.type); + node.components = [newNode(node)]; + node = node.components[0]; + break; + case ")": + delete node.state; + if (allowIndexed) { + if (node.name === "indexed") { + node.indexed = true; + node.name = ""; + } + } + node.type = verifyType(node.type); + var child = node; + node = node.parent; + if (!node) { + throwError(i); + } + delete child.parent; + node.state.allowParams = false; + node.state.allowName = true; + node.state.allowArray = true; + break; + case ",": + delete node.state; + if (allowIndexed) { + if (node.name === "indexed") { + node.indexed = true; + node.name = ""; + } + } + node.type = verifyType(node.type); + var sibling = newNode(node.parent); + //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; + node.parent.components.push(sibling); + delete node.parent; + node = sibling; + break; + // Hit a space... + case " ": + // If reading type, the type is done and may read a param or name + if (node.state.allowType) { + if (node.type !== "") { + node.type = verifyType(node.type); + delete node.state.allowType; + node.state.allowName = true; + node.state.allowParams = true; + } + } + // If reading name, the name is done + if (node.state.allowName) { + if (node.name !== "") { + if (allowIndexed) { + if (node.name === "indexed") { + if (node.indexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + } + else { + node.state.allowName = false; + } + } + } + break; + case "[": + if (!node.state.allowArray) { + throwError(i); + } + node.type += c; + node.state.allowArray = false; + node.state.allowName = false; + node.state.readArray = true; + break; + case "]": + if (!node.state.readArray) { + throwError(i); + } + node.type += c; + node.state.readArray = false; + node.state.allowArray = true; + node.state.allowName = true; + break; + default: + if (node.state.allowType) { + node.type += c; + node.state.allowParams = true; + node.state.allowArray = true; + } + else if (node.state.allowName) { + node.name += c; + delete node.state.allowArray; + } + else if (node.state.readArray) { + node.type += c; + } + else { + throwError(i); + } + } + } + if (node.parent) { + throw new Error("unexpected eof"); + } + delete parent.state; + if (allowIndexed) { + if (node.name === "indexed") { + if (node.indexed) { + throwError(originalParam.length - 7); + } + node.indexed = true; + node.name = ""; + } + } + parent.type = verifyType(parent.type); + return parent; +} +function populate(object, params) { + for (var key in params) { + properties_1.defineReadOnly(object, key, params[key]); + } +} +var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); +var ParamType = /** @class */ (function () { + function ParamType(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use fromString"); + } + populate(this, params); + var match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } + else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: ((this.components != null) ? "tuple" : this.type) + }); + } + } + // Format the parameter fragment + // - non-expanded: "(uint256,address)" + // - expanded: "tuple(uint256 foo, addres bar) indexed baz" + ParamType.prototype.format = function (expanded) { + var result = ""; + // Array + if (this.baseType === "array") { + result += this.arrayChildren.format(expanded); + result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; + } + else { + if (this.baseType === "tuple") { + if (expanded) { + result += this.type; + } + result += "(" + this.components.map(function (c) { return c.format(expanded); }).join(expanded ? ", " : ",") + ")"; + } + else { + result += this.type; + } + } + if (expanded) { + if (this.indexed === true) { + result += " indexed"; + } + if (this.name) { + result += " " + this.name; + } + } + return result; + }; + ParamType.from = function (value, allowIndexed) { + if (typeof (value) === "string") { + return ParamType.fromString(value, allowIndexed); + } + return ParamType.fromObject(value); + }; + ParamType.fromObject = function (value) { + if (properties_1.isNamedInstance(ParamType, value)) { + return value; + } + return new ParamType(_constructorGuard, { + name: (value.name || null), + type: verifyType(value.type), + indexed: ((value.indexed == null) ? null : !!value.indexed), + components: (value.components ? value.components.map(ParamType.fromObject) : null) + }); + }; + ParamType.fromString = function (value, allowIndexed) { + function ParamTypify(node) { + return ParamType.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components + }); + } + return ParamTypify(parseParamType(value, !!allowIndexed)); + }; + return ParamType; +}()); +exports.ParamType = ParamType; +; +function parseParams(value, allowIndex) { + return splitNesting(value).map(function (param) { return ParamType.fromString(param, allowIndex); }); +} +var Fragment = /** @class */ (function () { + function Fragment(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use a static from method"); + } + populate(this, params); + } + // @TOOD: move logic to sub-classes; make this abstract + Fragment.prototype.format = function (expanded) { + var result = ""; + if (this.type === "constructor") { + result += "constructor"; + } + else { + if (expanded) { + result += this.type + " "; + } + result += this.name; + } + result += "(" + this.inputs.map(function (i) { return i.format(expanded); }).join(expanded ? ", " : ",") + ") "; + // @TODO: Handle returns, modifiers, etc. + if (expanded) { + result += "public "; + if (this.mutabilityState) { + result += this.mutabilityState + " "; + } + else if (this.constant) { + result += "view "; + } + if (this.outputs && this.outputs.length) { + result += "(" + this.outputs.map(function (i) { return i.format(expanded); }).join(", ") + ") "; + } + } + return result.trim(); + }; + Fragment.from = function (value) { + if (typeof (value) === "string") { + return Fragment.fromString(value); + } + return Fragment.fromObject(value); + }; + Fragment.fromObject = function (value) { + if (properties_1.isNamedInstance(Fragment, value)) { + return value; + } + if (value.type === "function") { + return FunctionFragment.fromObject(value); + } + else if (value.type === "event") { + return EventFragment.fromObject(value); + } + else if (value.type === "constructor") { + return ConstructorFragment.fromObject(value); + } + else if (value.type === "fallback") { + // @TODO: + return null; + } + return errors.throwError("invalid fragment object", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + }; + Fragment.fromString = function (value) { + // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } + else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } + else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } + throw new Error("unknown fragment"); + }; + return Fragment; +}()); +exports.Fragment = Fragment; +var EventFragment = /** @class */ (function (_super) { + __extends(EventFragment, _super); + function EventFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + EventFragment.from = function (value) { + if (typeof (value) === "string") { + return EventFragment.fromString(value); + } + return EventFragment.fromObject(value); + }; + EventFragment.fromObject = function (value) { + if (properties_1.isNamedInstance(EventFragment, value)) { + return value; + } + if (value.type !== "event") { + throw new Error("invalid event object - " + value.type); + } + return new EventFragment(_constructorGuard, { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + type: "event" + }); + }; + EventFragment.fromString = function (value) { + var match = value.match(regexParen); + if (!match) { + throw new Error("invalid event: " + value); + } + var anonymous = false; + match[3].split(" ").forEach(function (modifier) { + switch (modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + errors.warn("unknown modifier: " + modifier); + } + }); + return EventFragment.fromObject({ + name: match[1].trim(), + anonymous: anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + }; + return EventFragment; +}(Fragment)); +exports.EventFragment = EventFragment; +function parseGas(value, params) { + params.gas = null; + var comps = value.split("@"); + if (comps.length !== 1) { + if (comps.length > 2) { + throw new Error("invalid signature"); + } + if (!comps[1].match(/^[0-9]+$/)) { + throw new Error("invalid signature gas"); + } + params.gas = bignumber_1.BigNumber.from(comps[1]); + return comps[0]; + } + return value; +} +function parseModifiers(value, params) { + params.constant = false; + params.payable = false; + // @TODO: Should this be initialized to "nonpayable"? + params.stateMutability = null; + value.split(" ").forEach(function (modifier) { + switch (modifier.trim()) { + case "constant": + params.constant = true; + break; + case "payable": + params.payable = true; + params.stateMutability = "payable"; + break; + case "pure": + params.constant = true; + params.stateMutability = "pure"; + break; + case "view": + params.constant = true; + params.stateMutability = "view"; + break; + case "external": + case "public": + case "": + break; + default: + console.log("unknown modifier: " + modifier); + } + }); +} +var ConstructorFragment = /** @class */ (function (_super) { + __extends(ConstructorFragment, _super); + function ConstructorFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstructorFragment.from = function (value) { + if (typeof (value) === "string") { + return ConstructorFragment.fromString(value); + } + return ConstructorFragment.fromObject(value); + }; + ConstructorFragment.fromObject = function (value) { + if (properties_1.isNamedInstance(ConstructorFragment, value)) { + return value; + } + if (value.type !== "constructor") { + throw new Error("invalid constructor object - " + value.type); + } + return new ConstructorFragment(_constructorGuard, { + type: value.type, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + payable: ((value.payable == null) ? true : !!value.payable), + gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null) + }); + }; + ConstructorFragment.fromString = function (value) { + var params = { type: "constructor" }; + value = parseGas(value, params); + var parens = value.match(regexParen); + if (!parens) { + throw new Error("invalid constructor: " + value); + } + if (parens[1].trim() !== "constructor") { + throw new Error("invalid constructor"); + } + params.inputs = parseParams(parens[2].trim(), false); + parseModifiers(parens[3].trim(), params); + return ConstructorFragment.fromObject(params); + }; + return ConstructorFragment; +}(Fragment)); +exports.ConstructorFragment = ConstructorFragment; +var FunctionFragment = /** @class */ (function (_super) { + __extends(FunctionFragment, _super); + function FunctionFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + FunctionFragment.from = function (value) { + if (typeof (value) === "string") { + return FunctionFragment.fromString(value); + } + return FunctionFragment.fromObject(value); + }; + FunctionFragment.fromObject = function (value) { + if (properties_1.isNamedInstance(FunctionFragment, value)) { + return value; + } + if (value.type !== "function") { + throw new Error("invalid function object - " + value.type); + } + return new FunctionFragment(_constructorGuard, { + type: value.type, + name: verifyIdentifier(value.name), + constant: !!value.constant, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), + payable: ((value.payable == null) ? true : !!value.payable), + stateMutability: ((value.stateMutability != null) ? verifyString(value.stateMutability) : null), + gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null) + }); + }; + FunctionFragment.fromString = function (value) { + var params = { type: "function" }; + value = parseGas(value, params); + var comps = value.split(" returns "); + if (comps.length > 2) { + throw new Error("invalid function"); + } + var parens = comps[0].match(regexParen); + if (!parens) { + throw new Error("invalid signature"); + } + params.name = parens[1].trim(); + if (!params.name.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + params.name + "'"); + } + params.inputs = parseParams(parens[2], false); + parseModifiers(parens[3].trim(), params); + // We have outputs + if (comps.length > 1) { + var returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + throw new Error("unexpected tokens"); + } + params.outputs = parseParams(returns[2], false); + } + else { + params.outputs = []; + } + return FunctionFragment.fromObject(params); + }; + return FunctionFragment; +}(ConstructorFragment)); +exports.FunctionFragment = FunctionFragment; +//export class ErrorFragment extends Fragment { +//} +//export class StructFragment extends Fragment { +//} +function verifyString(value) { + if (typeof (value) !== "string") { + throw new Error("requires a string"); + } + return value; +} +function verifyType(type) { + // These need to be transformed to their full description + if (type.match(/^uint($|[^1-9])/)) { + type = "uint256" + type.substring(4); + } + else if (type.match(/^int($|[^1-9])/)) { + type = "int256" + type.substring(3); + } + // @TODO: more verification + return type; +} +var regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); +function verifyIdentifier(value) { + if (!value || !value.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + value + "'"); + } + return value; +} +var regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); +function splitNesting(value) { + value = value.trim(); + var result = []; + var accum = ""; + var depth = 0; + for (var offset = 0; offset < value.length; offset++) { + var c = value[offset]; + if (c === "," && depth === 0) { + result.push(accum); + accum = ""; + } + else { + accum += c; + if (c === "(") { + depth++; + } + else if (c === ")") { + depth--; + if (depth === -1) { + throw new Error("unbalanced parenthsis"); + } + } + } + } + if (accum) { + result.push(accum); + } + return result; +} + +},{"@ethersproject/bignumber":62,"@ethersproject/errors":66,"@ethersproject/properties":82}],53:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var fragments_1 = require("./fragments"); +exports.ConstructorFragment = fragments_1.ConstructorFragment; +exports.EventFragment = fragments_1.EventFragment; +exports.Fragment = fragments_1.Fragment; +exports.FunctionFragment = fragments_1.FunctionFragment; +exports.ParamType = fragments_1.ParamType; +var abi_coder_1 = require("./abi-coder"); +exports.AbiCoder = abi_coder_1.AbiCoder; +exports.defaultAbiCoder = abi_coder_1.defaultAbiCoder; +var interface_1 = require("./interface"); +exports.Indexed = interface_1.Indexed; +exports.Interface = interface_1.Interface; + +},{"./abi-coder":40,"./fragments":52,"./interface":54}],54:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var hash_1 = require("@ethersproject/hash"); +var keccak256_1 = require("@ethersproject/keccak256"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var abi_coder_1 = require("./abi-coder"); +var fragments_1 = require("./fragments"); +var LogDescription = /** @class */ (function (_super) { + __extends(LogDescription, _super); + function LogDescription() { + return _super !== null && _super.apply(this, arguments) || this; + } + return LogDescription; +}(properties_1.Description)); +exports.LogDescription = LogDescription; +var TransactionDescription = /** @class */ (function (_super) { + __extends(TransactionDescription, _super); + function TransactionDescription() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TransactionDescription; +}(properties_1.Description)); +exports.TransactionDescription = TransactionDescription; +var Indexed = /** @class */ (function (_super) { + __extends(Indexed, _super); + function Indexed() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Indexed; +}(properties_1.Description)); +exports.Indexed = Indexed; +var Result = /** @class */ (function () { + function Result() { + } + return Result; +}()); +exports.Result = Result; +var Interface = /** @class */ (function () { + function Interface(fragments) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, Interface); + var abi = []; + if (typeof (fragments) === "string") { + abi = JSON.parse(fragments); + } + else { + abi = fragments; + } + properties_1.defineReadOnly(this, "fragments", abi.map(function (fragment) { + if (properties_1.isNamedInstance(fragments_1.Fragment, fragment)) { + return fragment; + } + return fragments_1.Fragment.from(fragment); + }).filter(function (fragment) { return (fragment != null); })); + properties_1.defineReadOnly(this, "_abiCoder", _newTarget.getAbiCoder()); + properties_1.defineReadOnly(this, "functions", {}); + properties_1.defineReadOnly(this, "errors", {}); + properties_1.defineReadOnly(this, "events", {}); + properties_1.defineReadOnly(this, "structs", {}); + // Add all fragments by their signature + this.fragments.forEach(function (fragment) { + var bucket = null; + switch (fragment.type) { + case "constructor": + if (_this.deploy) { + errors.warn("duplicate definition - constructor"); + return; + } + properties_1.defineReadOnly(_this, "deploy", fragment); + return; + case "function": + bucket = _this.functions; + break; + case "event": + bucket = _this.events; + break; + default: + return; + } + var signature = fragment.format(); + if (bucket[signature]) { + errors.warn("duplicate definition - " + signature); + return; + } + bucket[signature] = fragment; + }); + // Add any fragments with a unique name by its name (sans signature parameters) + [this.events, this.functions].forEach(function (bucket) { + var count = getNameCount(bucket); + Object.keys(bucket).forEach(function (signature) { + var fragment = bucket[signature]; + if (count[fragment.name] !== 1) { + errors.warn("duplicate definition - " + fragment.name); + return; + } + bucket[fragment.name] = fragment; + }); + }); + // If we do not have a constructor use the default "constructor() payable" + if (!this.deploy) { + properties_1.defineReadOnly(this, "deploy", fragments_1.ConstructorFragment.from({ type: "constructor" })); + } + } + Interface.getAbiCoder = function () { + return abi_coder_1.defaultAbiCoder; + }; + Interface.getAddress = function (address) { + return address_1.getAddress(address); + }; + Interface.prototype._sighashify = function (functionFragment) { + return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4); + }; + Interface.prototype._topicify = function (eventFragment) { + return hash_1.id(eventFragment.format()); + }; + Interface.prototype.getFunction = function (nameOrSignatureOrSighash) { + if (bytes_1.isHexString(nameOrSignatureOrSighash)) { + return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + return (this.functions[nameOrSignatureOrSighash.trim()] || null); + } + // Normlize the signature and lookup the function + return this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + }; + Interface.prototype.getEvent = function (nameOrSignatureOrTopic) { + if (bytes_1.isHexString(nameOrSignatureOrTopic)) { + return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + return this.events[nameOrSignatureOrTopic]; + } + return this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()]; + }; + Interface.prototype.getSighash = function (functionFragment) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return this._sighashify(functionFragment); + }; + Interface.prototype.getEventTopic = function (eventFragment) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + return this._topicify(eventFragment); + }; + Interface.prototype._encodeParams = function (params, values) { + return this._abiCoder.encode(params, values); + }; + Interface.prototype.encodeDeploy = function (values) { + return this._encodeParams(this.deploy.inputs, values || []); + }; + Interface.prototype.encodeFunctionData = function (functionFragment, values) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return bytes_1.hexlify(bytes_1.concat([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || []) + ])); + }; + Interface.prototype.decodeFunctionResult = function (functionFragment, data) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + var bytes = bytes_1.arrayify(data); + var reason = null; + var errorSignature = null; + switch (bytes.length % this._abiCoder._getWordSize()) { + case 0: + try { + return this._abiCoder.decode(functionFragment.outputs, bytes); + } + catch (error) { } + break; + case 4: + if (bytes_1.hexlify(bytes.slice(0, 4)) === "0x08c379a0") { + errorSignature = "Error(string)"; + reason = this._abiCoder.decode(["string"], bytes.slice(4)); + } + break; + } + return errors.throwError("call revert exception", errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorSignature: errorSignature, + errorArgs: [reason], + reason: reason + }); + }; + Interface.prototype.encodeFilterTopics = function (eventFragment, values) { + var _this = this; + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (values.length > eventFragment.inputs.length) { + errors.throwError("too many arguments for " + eventFragment.format(), errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values + }); + } + var topics = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + values.forEach(function (value, index) { + var param = eventFragment.inputs[index]; + if (!param.indexed) { + if (value != null) { + errors.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + } + return; + } + if (value == null) { + topics.push(null); + } + else if (param.type === "string") { + topics.push(hash_1.id(value)); + } + else if (param.type === "bytes") { + topics.push(keccak256_1.keccak256(bytes_1.hexlify(value))); + } + else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { + errors.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } + else { + // Check addresses are valid + if (param.type === "address") { + _this._abiCoder.encode(["address"], [value]); + } + topics.push(bytes_1.hexZeroPad(bytes_1.hexlify(value), 32)); + } + }); + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + }; + Interface.prototype.decodeEventLog = function (eventFragment, data, topics) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (topics != null && !eventFragment.anonymous) { + topics = topics.slice(1); + } + var indexed = []; + var nonIndexed = []; + var dynamic = []; + eventFragment.inputs.forEach(function (param, index) { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); + } + else { + indexed.push(param); + dynamic.push(false); + } + } + else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, bytes_1.concat(topics)) : null; + var resultNonIndexed = this._abiCoder.decode(nonIndexed, data); + var result = []; + var nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach(function (param, index) { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ hash: null }); + } + else if (dynamic[index]) { + result[index] = new Indexed({ hash: resultIndexed[indexedIndex++] }); + } + else { + result[index] = resultIndexed[indexedIndex++]; + } + } + else { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } + //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } + }); + return result; + }; + Interface.prototype.parseTransaction = function (tx) { + var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: bignumber_1.BigNumber.from(tx.value || "0"), + }); + }; + Interface.prototype.parseLog = function (log) { + var fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + values: this.decodeEventLog(fragment, log.data, log.topics) + }); + }; + return Interface; +}()); +exports.Interface = Interface; +function getFragment(hash, calcFunc, items) { + for (var signature in items) { + if (signature.indexOf("(") === -1) { + continue; + } + var fragment = items[signature]; + if (calcFunc(fragment) === hash) { + return fragment; + } + } + return null; +} +function getNameCount(fragments) { + var unique = {}; + // Count each name + for (var signature in fragments) { + var name_1 = fragments[signature].name; + if (!unique[name_1]) { + unique[name_1] = 0; + } + unique[name_1]++; + } + return unique; +} + +},{"./abi-coder":40,"./fragments":52,"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/keccak256":79,"@ethersproject/properties":82}],55:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var errors_1 = require("@ethersproject/errors"); +var properties_1 = require("@ethersproject/properties"); +; +; +//export type CallTransactionable = { +// call(transaction: TransactionRequest): Promise; +//}; +var ForkEvent = /** @class */ (function () { + function ForkEvent(expiry) { + properties_1.defineReadOnly(this, "expiry", expiry || 0); + } + return ForkEvent; +}()); +exports.ForkEvent = ForkEvent; +var BlockForkEvent = /** @class */ (function (_super) { + __extends(BlockForkEvent, _super); + function BlockForkEvent(blockhash, expiry) { + var _this = this; + if (!bytes_1.isHexString(blockhash, 32)) { + errors.throwArgumentError("invalid blockhash", "blockhash", blockhash); + } + _this = _super.call(this, expiry) || this; + properties_1.defineReadOnly(_this, "blockhash", blockhash); + return _this; + } + return BlockForkEvent; +}(ForkEvent)); +exports.BlockForkEvent = BlockForkEvent; +var TransactionForkEvent = /** @class */ (function (_super) { + __extends(TransactionForkEvent, _super); + function TransactionForkEvent(hash, expiry) { + var _this = this; + if (!bytes_1.isHexString(hash, 32)) { + errors.throwArgumentError("invalid transaction hash", "hash", hash); + } + _this = _super.call(this, expiry) || this; + properties_1.defineReadOnly(_this, "hash", hash); + return _this; + } + return TransactionForkEvent; +}(ForkEvent)); +exports.TransactionForkEvent = TransactionForkEvent; +var TransactionOrderForkEvent = /** @class */ (function (_super) { + __extends(TransactionOrderForkEvent, _super); + function TransactionOrderForkEvent(beforeHash, afterHash, expiry) { + var _this = this; + if (!bytes_1.isHexString(beforeHash, 32)) { + errors.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!bytes_1.isHexString(afterHash, 32)) { + errors.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + _this = _super.call(this, expiry) || this; + properties_1.defineReadOnly(_this, "beforeHash", beforeHash); + properties_1.defineReadOnly(_this, "afterHash", afterHash); + return _this; + } + return TransactionOrderForkEvent; +}(ForkEvent)); +exports.TransactionOrderForkEvent = TransactionOrderForkEvent; +/////////////////////////////// +// Exported Abstracts +var Provider = /** @class */ (function () { + function Provider() { + var _newTarget = this.constructor; + errors_1.checkAbstract(_newTarget, Provider); + } + // Alias for "on" + Provider.prototype.addListener = function (eventName, listener) { + return this.on(eventName, listener); + }; + // Alias for "off" + Provider.prototype.removeListener = function (eventName, listener) { + return this.off(eventName, listener); + }; + return Provider; +}()); +exports.Provider = Provider; + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],56:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var allowedTransactionKeys = [ + "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" +]; +// Sub-Class Notes: +// - A Signer MUST always make sure, that if present, the "from" field +// matches the Signer, before sending or signing a transaction +// - A Signer SHOULD always wrap private information (such as a private +// key or mnemonic) in a function, so that console.log does not leak +// the data +var Signer = /** @class */ (function () { + /////////////////// + // Sub-classes MUST call super + function Signer() { + var _newTarget = this.constructor; + errors.checkAbstract(_newTarget, Signer); + } + /////////////////// + // Sub-classes MAY override these + Signer.prototype.getBalance = function (blockTag) { + this._checkProvider("getBalance"); + return this.provider.getBalance(this.getAddress(), blockTag); + }; + Signer.prototype.getTransactionCount = function (blockTag) { + this._checkProvider("getTransactionCount"); + return this.provider.getTransactionCount(this.getAddress(), blockTag); + }; + // Populates "from" if unspecified, and estimates the gas for the transation + Signer.prototype.estimateGas = function (transaction) { + var _this = this; + this._checkProvider("estimateGas"); + return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return _this.provider.estimateGas(tx); + }); + }; + // Populates "from" if unspecified, and calls with the transation + Signer.prototype.call = function (transaction, blockTag) { + var _this = this; + this._checkProvider("call"); + return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return _this.provider.call(tx); + }); + }; + // Populates all fields in a transaction, signs it and sends it to the network + Signer.prototype.sendTransaction = function (transaction) { + var _this = this; + this._checkProvider("sendTransaction"); + return this.populateTransaction(transaction).then(function (tx) { + return _this.signTransaction(tx).then(function (signedTx) { + return _this.provider.sendTransaction(signedTx); + }); + }); + }; + Signer.prototype.getChainId = function () { + this._checkProvider("getChainId"); + return this.provider.getNetwork().then(function (network) { return network.chainId; }); + }; + Signer.prototype.getGasPrice = function () { + this._checkProvider("getGasPrice"); + return this.provider.getGasPrice(); + }; + Signer.prototype.resolveName = function (name) { + this._checkProvider("resolveName"); + return this.provider.resolveName(name); + }; + // Checks a transaction does not contain invalid keys and if + // no "from" is provided, populates it. + // - does NOT require a provider + // - adds "from" is not present + // - returns a COPY (safe to mutate the result) + // By default called from: (overriding these prevents it) + // - call + // - estimateGas + // - populateTransaction (and therefor sendTransaction) + Signer.prototype.checkTransaction = function (transaction) { + for (var key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + errors.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + } + } + var tx = properties_1.shallowCopy(transaction); + if (tx.from == null) { + tx.from = this.getAddress(); + } + return tx; + }; + // Populates ALL keys for a transaction and checks that "from" matches + // this Signer. Should be used by sendTransaction but NOT by signTransaction. + // By default called from: (overriding these prevents it) + // - sendTransaction + Signer.prototype.populateTransaction = function (transaction) { + var _this = this; + return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + if (tx.to != null) { + tx.to = Promise.resolve(tx.to).then(function (to) { return _this.resolveName(to); }); + } + if (tx.gasPrice == null) { + tx.gasPrice = _this.getGasPrice(); + } + if (tx.nonce == null) { + tx.nonce = _this.getTransactionCount("pending"); + } + // Make sure any provided address matches this signer + if (tx.from == null) { + tx.from = _this.getAddress(); + } + else { + tx.from = Promise.all([ + _this.getAddress(), + _this.provider.resolveName(tx.from) + ]).then(function (results) { + if (results[0] !== results[1]) { + errors.throwArgumentError("from address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + if (tx.gasLimit == null) { + tx.gasLimit = _this.estimateGas(tx); + } + if (tx.chainId == null) { + tx.chainId = _this.getChainId(); + } + return properties_1.resolveProperties(tx); + }); + }; + /////////////////// + // Sub-classes SHOULD leave these alone + Signer.prototype._checkProvider = function (operation) { + if (!this.provider) { + errors.throwError("missing provider", errors.UNSUPPORTED_OPERATION, { + operation: (operation || "_checkProvider") + }); + } + }; + return Signer; +}()); +exports.Signer = Signer; +var VoidSigner = /** @class */ (function (_super) { + __extends(VoidSigner, _super); + function VoidSigner(address, provider) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, VoidSigner); + _this = _super.call(this) || this; + properties_1.defineReadOnly(_this, "address", address); + properties_1.defineReadOnly(_this, "provider", provider || null); + return _this; + } + VoidSigner.prototype.getAddress = function () { + return Promise.resolve(this.address); + }; + VoidSigner.prototype._fail = function (message, operation) { + return Promise.resolve().then(function () { + errors.throwError(message, errors.UNSUPPORTED_OPERATION, { operation: operation }); + }); + }; + VoidSigner.prototype.signMessage = function (message) { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + }; + VoidSigner.prototype.signTransaction = function (transaction) { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + }; + VoidSigner.prototype.connect = function (provider) { + return new VoidSigner(this.address, provider); + }; + return VoidSigner; +}(Signer)); +exports.VoidSigner = VoidSigner; + +},{"@ethersproject/errors":66,"@ethersproject/properties":82}],57:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// We use this for base 36 maths +var BN = __importStar(require("bn.js")); +var errors = __importStar(require("@ethersproject/errors")); +var bytes_1 = require("@ethersproject/bytes"); +var keccak256_1 = require("@ethersproject/keccak256"); +var rlp_1 = require("@ethersproject/rlp"); +function getChecksumAddress(address) { + if (!bytes_1.isHexString(address, 20)) { + errors.throwError("invalid address", errors.INVALID_ARGUMENT, { arg: "address", value: address }); + } + address = address.toLowerCase(); + var chars = address.substring(2).split(""); + var hashed = new Uint8Array(40); + for (var i = 0; i < 40; i++) { + hashed[i] = chars[i].charCodeAt(0); + } + hashed = bytes_1.arrayify(keccak256_1.keccak256(hashed)); + for (var i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + return "0x" + chars.join(""); +} +// Shims for environments that are missing some required constants and functions +var MAX_SAFE_INTEGER = 0x1fffffffffffff; +function log10(x) { + if (Math.log10) { + return Math.log10(x); + } + return Math.log(x) / Math.LN10; +} +// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number +// Create lookup table +var ibanLookup = {}; +for (var i = 0; i < 10; i++) { + ibanLookup[String(i)] = String(i); +} +for (var i = 0; i < 26; i++) { + ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); +} +// How many decimal digits can we process? (for 64-bit float, this is 15) +var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); +function ibanChecksum(address) { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + var expanded = ""; + address.split("").forEach(function (c) { + expanded += ibanLookup[c]; + }); + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits) { + var block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + var checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { + checksum = "0" + checksum; + } + return checksum; +} +; +function getAddress(address) { + var result = null; + if (typeof (address) !== "string") { + errors.throwArgumentError("invalid address", "address", address); + } + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + // Missing the 0x prefix + if (address.substring(0, 2) !== "0x") { + address = "0x" + address; + } + result = getChecksumAddress(address); + // It is a checksummed address with a bad checksum + if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { + errors.throwArgumentError("bad address checksum", "address", address); + } + // Maybe ICAP? (we only support direct mode) + } + else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + // It is an ICAP address with a bad checksum + if (address.substring(2, 4) !== ibanChecksum(address)) { + errors.throwArgumentError("bad icap checksum", "address", address); + } + result = (new BN.BN(address.substring(4), 36)).toString(16); + while (result.length < 40) { + result = "0" + result; + } + result = getChecksumAddress("0x" + result); + } + else { + errors.throwArgumentError("invalid address", "address", address); + } + return result; +} +exports.getAddress = getAddress; +function isAddress(address) { + try { + getAddress(address); + return true; + } + catch (error) { } + return false; +} +exports.isAddress = isAddress; +function getIcapAddress(address) { + var base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + while (base36.length < 30) { + base36 = "0" + base36; + } + return "XE" + ibanChecksum("XE00" + base36) + base36; +} +exports.getIcapAddress = getIcapAddress; +// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed +function getContractAddress(transaction) { + var from = null; + try { + from = getAddress(transaction.from); + } + catch (error) { + errors.throwArgumentError("missing from address", "transaction", transaction); + } + var nonce = bytes_1.stripZeros(bytes_1.arrayify(transaction.nonce)); + return getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(rlp_1.encode([from, nonce])), 12)); +} +exports.getContractAddress = getContractAddress; + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/rlp":97,"bn.js":2}],58:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +function decode(textData) { + textData = atob(textData); + var data = []; + for (var i = 0; i < textData.length; i++) { + data.push(textData.charCodeAt(i)); + } + return bytes_1.arrayify(data); +} +exports.decode = decode; +function encode(data) { + data = bytes_1.arrayify(data); + var textData = ""; + for (var i = 0; i < data.length; i++) { + textData += String.fromCharCode(data[i]); + } + return btoa(textData); +} +exports.encode = encode; + +},{"@ethersproject/bytes":63}],59:[function(require,module,exports){ +"use strict"; +/** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var properties_1 = require("@ethersproject/properties"); +var BaseX = /** @class */ (function () { + function BaseX(alphabet) { + properties_1.defineReadOnly(this, "alphabet", alphabet); + properties_1.defineReadOnly(this, "base", alphabet.length); + properties_1.defineReadOnly(this, "_alphabetMap", {}); + properties_1.defineReadOnly(this, "_leader", alphabet.charAt(0)); + // pre-compute lookup table + for (var i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + BaseX.prototype.encode = function (value) { + var source = bytes_1.arrayify(value); + if (source.length === 0) { + return ""; + } + var digits = [0]; + for (var i = 0; i < source.length; ++i) { + var carry = source[i]; + for (var j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = (carry / this.base) | 0; + } + while (carry > 0) { + digits.push(carry % this.base); + carry = (carry / this.base) | 0; + } + } + var string = ""; + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + return string; + }; + BaseX.prototype.decode = function (value) { + if (typeof (value) !== "string") { + throw new TypeError("Expected String"); + } + var bytes = []; + if (value.length === 0) { + return new Uint8Array(bytes); + } + bytes.push(0); + for (var i = 0; i < value.length; i++) { + var byte = this._alphabetMap[value[i]]; + if (byte === undefined) { + throw new Error("Non-base" + this.base + " character"); + } + var carry = byte; + for (var j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 0xff; + carry >>= 8; + } + while (carry > 0) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { + bytes.push(0); + } + return bytes_1.arrayify(new Uint8Array(bytes.reverse())); + }; + return BaseX; +}()); +exports.BaseX = BaseX; +var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); +exports.Base32 = Base32; +var Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); +exports.Base58 = Base58; +//console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) +//console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) + +},{"@ethersproject/bytes":63,"@ethersproject/properties":82}],60:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * BigNumber + * + * A wrapper around the BN.js object. We use the BN.js library + * because it is used by elliptic, so it is required regardles. + * + */ +var BN = __importStar(require("bn.js")); +var bytes_1 = require("@ethersproject/bytes"); +var properties_1 = require("@ethersproject/properties"); +var errors = __importStar(require("@ethersproject/errors")); +var _constructorGuard = {}; +var MAX_SAFE = 0x1fffffffffffff; +/* +export function isBigNumberLike(value: any): value is BigNumberish { + return (BigNumber.isBigNumber(value) || + (!!((value).toHexString)) || + isBytes(value) || + value.match(/^-?([0-9]+|0x[0-9a-f]+)$/i) || + typeof(value) === "number"); +} +*/ +var BigNumber = /** @class */ (function () { + function BigNumber(constructorGuard, hex) { + var _newTarget = this.constructor; + errors.checkNew(_newTarget, BigNumber); + if (constructorGuard !== _constructorGuard) { + errors.throwError("cannot call consturtor directly; use BigNumber.from", errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + properties_1.defineReadOnly(this, "_hex", hex); + } + BigNumber.prototype.fromTwos = function (value) { + return toBigNumber(toBN(this).fromTwos(value)); + }; + BigNumber.prototype.toTwos = function (value) { + return toBigNumber(toBN(this).toTwos(value)); + }; + BigNumber.prototype.abs = function () { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + }; + BigNumber.prototype.add = function (other) { + return toBigNumber(toBN(this).add(toBN(other))); + }; + BigNumber.prototype.sub = function (other) { + return toBigNumber(toBN(this).sub(toBN(other))); + }; + BigNumber.prototype.div = function (other) { + var o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + }; + BigNumber.prototype.mul = function (other) { + return toBigNumber(toBN(this).mul(toBN(other))); + }; + BigNumber.prototype.mod = function (other) { + return toBigNumber(toBN(this).mod(toBN(other))); + }; + BigNumber.prototype.pow = function (other) { + return toBigNumber(toBN(this).pow(toBN(other))); + }; + BigNumber.prototype.maskn = function (value) { + return toBigNumber(toBN(this).maskn(value)); + }; + BigNumber.prototype.eq = function (other) { + return toBN(this).eq(toBN(other)); + }; + BigNumber.prototype.lt = function (other) { + return toBN(this).lt(toBN(other)); + }; + BigNumber.prototype.lte = function (other) { + return toBN(this).lte(toBN(other)); + }; + BigNumber.prototype.gt = function (other) { + return toBN(this).gt(toBN(other)); + }; + BigNumber.prototype.gte = function (other) { + return toBN(this).gte(toBN(other)); + }; + BigNumber.prototype.isZero = function () { + return toBN(this).isZero(); + }; + BigNumber.prototype.toNumber = function () { + try { + return toBN(this).toNumber(); + } + catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + }; + BigNumber.prototype.toString = function () { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + errors.throwError("bigNumber.toString does not accept parameters", errors.UNEXPECTED_ARGUMENT, {}); + } + return toBN(this).toString(10); + }; + BigNumber.prototype.toHexString = function () { + return this._hex; + }; + BigNumber.from = function (value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + } + return errors.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + if (typeof (value) === "bigint") { + return BigNumber.from(value.toString()); + } + if (bytes_1.isBytes(value)) { + return BigNumber.from(bytes_1.hexlify(value)); + } + if (value._hex && bytes_1.isHexString(value._hex)) { + return BigNumber.from(value._hex); + } + if (value.toHexString) { + value = value.toHexString(); + if (typeof (value) === "string") { + return BigNumber.from(value); + } + } + return errors.throwArgumentError("invalid BigNumber value", "value", value); + }; + BigNumber.isBigNumber = function (value) { + return properties_1.isNamedInstance(this, value); + }; + return BigNumber; +}()); +exports.BigNumber = BigNumber; +/* +export function bigNumberify(value: BigNumberish): BigNumber { + if (BigNumber.isBigNumber(value)) { return value; } + return new BigNumber(value); +} +*/ +/* +function zeros(length) { + let result = ""; + while (result.length < length) { tens += "0"; } + return result; +} +export class FixedNumber { + readonly value: BigNumber; + readonly decimalPlaces: number; + + constructor(value: BigNumberish, decimalPlaces: number) { + defineReadOnly(this, "value", bigNumberify(value)); + defineReadOnly(this, "decimalPlaces", decimalPlaces); + } + + toString(): string { + return formatUnits(this.value, this.decimalPlaces); + } + + static fromString(value: string): FixedNumber { + let comps = value.split("."); + let decimalPlaces = 0; + if (comps.length === 2) { decimalPlaces = comps[1].length; } + return new FixedNumber(parseUnits(value, decimalPlaces), decimalPlaces); + } +*/ +/* + + readonly negative: boolean; + readonly whole: BigNumber; + readonly fraction: BigNumber; + constructor(whole: BigNumberish, fraction: BigNumberish, negative?: boolean) { + if (whole.lt(constants.Zero)) { + errors.throwError("whole component must be positive", errors.INVALID_ARGUMENT, { + argument: whole, + value: whole + }); + } + defineReadOnly(this, "whole", bigNumberify(whole)); + defineReadOnly(this, "fraction", bigNumberify(fraction)); + defineReadOnly(this, "negative", !!boolean); + } +*/ +/* + toHexString(bitWidth?: number, decimalPlaces?: number, signed?: boolean): string { + if (bitWidth == null) { bitWidth = 128; } + if (decimalPlaces == null) { decimalPlaces = 18; } + if (signed == null) { signed = true; } + return null; + } + static fromValue(value: BigNumberish, decimalPlaces: number): FixedNumber { + let negative = false; + if (value.lt(constants.Zero)) { + negative = true; + value = value.abs(); + } + let tens = bigNumberify("1" + zeros(decimalPlaces)); + return new FixedNumber(value.divide(tens), value.mod(tens), negative); + } + let negative = false; + if (value.substring(0, 1) === "-") { + negative = true; + value = value.substring(1); + } + + if (value !== "." && value !== "") { + let comps = value.split("."); + if (comps.length === 1) { + return new FixedNumber(comps[0], 0, negative); + } else if (comps.length === 2) { + if (comps[0] === "") { comps[0] = "0"; } + if (comps[1] === "") { comps[1] = "0"; } + return new FixedNumber(comps[0], comps[1], negative); + } + } + + errors.throwError("invalid fixed-point value", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + + return null; +*/ +//} +// Normalize the hex string +function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + errors.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; +} +function toBigNumber(value) { + return BigNumber.from(toHex(value)); +} +function toBN(value) { + var hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN.BN("-" + hex.substring(3), 16)); + } + return new BN.BN(hex.substring(2), 16); +} +function throwFault(fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return errors.throwError(fault, errors.NUMERIC_FAULT, params); +} + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,"bn.js":2}],61:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var bignumber_1 = require("./bignumber"); +var _constructorGuard = {}; +var Zero = bignumber_1.BigNumber.from(0); +var NegativeOne = bignumber_1.BigNumber.from(-1); +function throwFault(message, fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return errors.throwError(message, errors.NUMERIC_FAULT, params); +} +// Constant to pull zeros from for multipliers +var zeros = "0"; +while (zeros.length < 256) { + zeros += zeros; +} +// Returns a string "1" followed by decimal "0"s +function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = bignumber_1.BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return errors.throwArgumentError("invalid decimal size", "decimals", decimals); +} +function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = bignumber_1.BigNumber.from(value); + var negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + var fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + var whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; +} +exports.formatFixed = formatFixed; +function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + errors.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return bignumber_1.BigNumber.from(value); + } + // Is it negative? + var negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + errors.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + var comps = value.split("."); + if (comps.length > 2) { + errors.throwArgumentError("too many decimal points", "value", value); + } + var whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + var wholeValue = bignumber_1.BigNumber.from(whole); + var fractionValue = bignumber_1.BigNumber.from(fraction); + var wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; +} +exports.parseFixed = parseFixed; +var FixedFormat = /** @class */ (function () { + function FixedFormat(constructorGuard, signed, width, decimals) { + properties_1.defineReadOnly(this, "signed", signed); + properties_1.defineReadOnly(this, "width", width); + properties_1.defineReadOnly(this, "decimals", decimals); + var name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + properties_1.defineReadOnly(this, "name", name); + properties_1.defineReadOnly(this, "_multiplier", getMultiplier(decimals)); + } + FixedFormat.from = function (value) { + if (value instanceof FixedFormat) { + return value; + } + var signed = true; + var width = 128; + var decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + errors.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + var check = function (key, type, defaultValue) { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + errors.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + errors.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + errors.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard, signed, width, decimals); + }; + FixedFormat.isInstance = function (value) { + return properties_1.isNamedInstance(this, value); + }; + return FixedFormat; +}()); +exports.FixedFormat = FixedFormat; +var FixedNumber = /** @class */ (function () { + function FixedNumber(constructorGuard, hex, value, format) { + var _newTarget = this.constructor; + errors.checkNew(_newTarget, FixedNumber); + properties_1.defineReadOnly(this, 'format', format); + properties_1.defineReadOnly(this, '_hex', hex); + properties_1.defineReadOnly(this, '_value', value); + } + FixedNumber.prototype._checkFormat = function (other) { + if (this.format.name !== other.format.name) { + errors.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + }; + FixedNumber.prototype.addUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.subUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.mulUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + }; + FixedNumber.prototype.divUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + }; + // @TODO: Support other rounding algorithms + FixedNumber.prototype.round = function (decimals) { + if (decimals == null) { + decimals = 0; + } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + errors.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + // If we are already in range, we're done + var comps = this.toString().split("."); + if (comps[1].length <= decimals) { + return this; + } + // Bump the value up by the 0.00...0005 + var bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + }; + FixedNumber.prototype.toString = function () { return this._value; }; + FixedNumber.prototype.toHexString = function (width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + errors.throwArgumentError("invalid byte width", "width", width); + } + var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return bytes_1.hexZeroPad(hex, width / 8); + }; + FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; + FixedNumber.prototype.toFormat = function (format) { + return FixedNumber.fromString(this._value, format); + }; + FixedNumber.fromValue = function (value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && (FixedFormat.isInstance(decimals) || typeof (decimals) === "string")) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + var fixedFormat = (FixedFormat.isInstance(format) ? format : FixedFormat.from(format)); + return FixedNumber.fromString(formatFixed(value, decimals), fixedFormat); + }; + FixedNumber.fromString = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = (FixedFormat.isInstance(format) ? format : FixedFormat.from(format)); + var numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + var hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = bytes_1.hexZeroPad(hex, fixedFormat.width / 8); + } + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.fromBytes = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = (FixedFormat.isInstance(format) ? format : FixedFormat.from(format)); + if (bytes_1.arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + var numeric = bignumber_1.BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.from = function (value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (bytes_1.isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== errors.INVALID_ARGUMENT) { + throw error; + } + } + return errors.throwArgumentError("invalid FixedNumber value", "value", value); + }; + FixedNumber.isFixedNumber = function (value) { + return properties_1.isNamedInstance(this, value); + }; + return FixedNumber; +}()); +exports.FixedNumber = FixedNumber; + +},{"./bignumber":60,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],62:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("./bignumber"); +exports.BigNumber = bignumber_1.BigNumber; +var fixednumber_1 = require("./fixednumber"); +exports.FixedNumber = fixednumber_1.FixedNumber; + +},{"./bignumber":60,"./fixednumber":61}],63:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +/////////////////////////////// +function isHexable(value) { + return !!(value.toHexString); +} +function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + var args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; +} +function isBytesLike(value) { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); +} +exports.isBytesLike = isBytesLike; +function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (value.length == null) { + return false; + } + for (var i = 0; i < value.length; i++) { + var v = value[i]; + if (v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + return true; +} +exports.isBytes = isBytes; +function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + errors.checkSafeUint53(value, "invalid arrayify value"); + var result = []; + while (value) { + result.unshift(value & 0xff); + value /= 256; + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + var hex = value.substring(2); + if (!options.allowOddLength && hex.length % 2) { + errors.throwArgumentError("hex data is odd-length", "value", value); + } + var result = []; + for (var i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return errors.throwArgumentError("invalid arrayify value", "value", value); +} +exports.arrayify = arrayify; +function concat(items) { + var objects = items.map(function (item) { return arrayify(item); }); + var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0); + var result = new Uint8Array(length); + objects.reduce(function (offset, object) { + result.set(object, offset); + return offset + object.length; + }, 0); + return addSlice(result); +} +exports.concat = concat; +function stripZeros(value) { + var result = arrayify(value); + if (result.length === 0) { + return result; + } + // Find the first non-zero entry + var start = 0; + while (start < result.length && result[start] === 0) { + start++; + } + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + return result; +} +exports.stripZeros = stripZeros; +function zeroPad(value, length) { + value = arrayify(value); + if (value.length > length) { + errors.throwArgumentError("value out of range", "value", arguments[0]); + } + var result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); +} +exports.zeroPad = zeroPad; +function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; +} +exports.isHexString = isHexString; +var HexCharacters = "0123456789abcdef"; +function hexlify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + errors.checkSafeUint53(value, "invalid hexlify value"); + var hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + if (hex.length) { + if (hex.length % 2) { + hex = "0" + hex; + } + return "0x" + hex; + } + return "0x00"; + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + return value.toHexString(); + } + if (isHexString(value)) { + if (!options.allowOddLength && value.length % 2) { + errors.throwArgumentError("hex data is odd-length", "value", value); + } + return value.toLowerCase(); + } + if (isBytes(value)) { + var result = "0x"; + for (var i = 0; i < value.length; i++) { + var v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + return errors.throwArgumentError("invalid hexlify value", "value", value); +} +exports.hexlify = hexlify; +/* +function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; +} +*/ +function hexDataLength(data) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + return null; + } + return (data.length - 2) / 2; +} +exports.hexDataLength = hexDataLength; +function hexDataSlice(data, offset, endOffset) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + errors.throwArgumentError("invalid hexData", "value", data); + } + offset = 2 + 2 * offset; + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + return "0x" + data.substring(offset); +} +exports.hexDataSlice = hexDataSlice; +function hexConcat(items) { + var result = "0x"; + items.forEach(function (item) { + result += hexlify(item).substring(2); + }); + return result; +} +exports.hexConcat = hexConcat; +function hexValue(value) { + var trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); + if (trimmed === "0x") { + return "0x0"; + } + return trimmed; +} +exports.hexValue = hexValue; +function hexStripZeros(value) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + if (!isHexString(value)) { + errors.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + var offset = 0; + while (offset < value.length && value[offset] === "0") { + offset++; + } + return "0x" + value.substring(offset); +} +exports.hexStripZeros = hexStripZeros; +function hexZeroPad(value, length) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + else if (!isHexString(value)) { + errors.throwArgumentError("invalid hex string", "value", value); + } + if (value.length > 2 * length + 2) { + errors.throwArgumentError("value out of range", "value", arguments[1]); + } + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + return value; +} +exports.hexZeroPad = hexZeroPad; +function splitSignature(signature) { + var result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + if (isBytesLike(signature)) { + var bytes = arrayify(signature); + if (bytes.length !== 65) { + errors.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + // Get the r and s + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + // Reduce v to the canonical 27 or 28 + result.v = bytes[64]; + if (result.v !== 27 && result.v !== 28) { + result.v = 27 + (result.v % 2); + } + // Compute recoveryParam from v + result.recoveryParam = (result.v - 27); + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { + bytes[32] |= 0x80; + } + result._vs = hexlify(bytes.slice(32, 64)); + } + else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + // Normalize v into a canonical 27 or 28 + if (result.v != null && !(result.v == 27 || result.v == 28)) { + result.v = 27 + (result.v % 2); + } + // Populate a missing v or recoveryParam if possible + if (result.recoveryParam == null && result.v != null) { + result.recoveryParam = 1 - (result.v % 2); + } + else if (result.recoveryParam != null && result.v == null) { + result.v = 27 + result.recoveryParam; + } + else if (result.recoveryParam != null && result.v != null) { + if (result.v !== 27 + result.recoveryParam) { + errors.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + } + } + // Make sure r and s are padded properly + if (result.r != null) { + result.r = hexZeroPad(result.r, 32); + } + if (result.s != null) { + result.s = hexZeroPad(result.s, 32); + } + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + result._vs = hexZeroPad(result._vs, 32); + if (result._vs.length > 66) { + errors.throwArgumentError("signature _vs overflow", "signature", signature); + } + var vs = arrayify(result._vs); + var recoveryParam = ((vs[0] >= 128) ? 1 : 0); + var v = 27 + result.recoveryParam; + // Use _vs to compute s + vs[0] &= 0x7f; + var s = hexlify(vs); + // Check _vs aggress with other parameters + if (result.s == null) { + result.s = s; + } + else if (result.s !== s) { + errors.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (result.v == null) { + result.v = v; + } + else if (result.v !== v) { + errors.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (recoveryParam == null) { + result.recoveryParam = recoveryParam; + } + else if (result.recoveryParam !== recoveryParam) { + errors.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + } + // After all populating, both v and recoveryParam are still missing... + if (result.v == null && result.recoveryParam == null) { + errors.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + } + // Check for canonical v + if (result.v !== 27 && result.v !== 28) { + errors.throwArgumentError("signature v not canonical", "signature", signature); + } + // Check that r and s are in range + if (result.r.length > 66 || result.s.length > 66) { + errors.throwArgumentError("signature overflow r or s", "signature", signature); + } + if (result._vs == null) { + var vs = arrayify(result.s); + if (vs[0] >= 128) { + errors.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { + vs[0] |= 0x80; + } + result._vs = hexlify(vs); + } + } + return result; +} +exports.splitSignature = splitSignature; +function joinSignature(signature) { + signature = splitSignature(signature); + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c" : "0x1b") + ])); +} +exports.joinSignature = joinSignature; + +},{"@ethersproject/errors":66}],64:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("@ethersproject/bignumber"); +var AddressZero = "0x0000000000000000000000000000000000000000"; +exports.AddressZero = AddressZero; +var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; +exports.HashZero = HashZero; +// NFKD (decomposed) +//const EtherSymbol = "\uD835\uDF63"; +// NFKC (composed) +var EtherSymbol = "\u039e"; +exports.EtherSymbol = EtherSymbol; +var NegativeOne = bignumber_1.BigNumber.from(-1); +exports.NegativeOne = NegativeOne; +var Zero = bignumber_1.BigNumber.from(0); +exports.Zero = Zero; +var One = bignumber_1.BigNumber.from(1); +exports.One = One; +var Two = bignumber_1.BigNumber.from(2); +exports.Two = Two; +var WeiPerEther = bignumber_1.BigNumber.from("1000000000000000000"); +exports.WeiPerEther = WeiPerEther; +var MaxUint256 = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +exports.MaxUint256 = MaxUint256; + +},{"@ethersproject/bignumber":62}],65:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var abi_1 = require("@ethersproject/abi"); +var abstract_provider_1 = require("@ethersproject/abstract-provider"); +var abstract_signer_1 = require("@ethersproject/abstract-signer"); +var address_1 = require("@ethersproject/address"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var constants_1 = require("@ethersproject/constants"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +/////////////////////////////// +var allowedTransactionKeys = { + chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +// Recursively replaces ENS names with promises to resolve the name and +// stalls until all promises have returned +// @TODO: Expand this to resolve any promises too +function resolveAddresses(signerOrProvider, value, paramType) { + if (Array.isArray(paramType)) { + return Promise.all(paramType.map(function (paramType, index) { + return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); + })); + } + if (paramType.type === "address") { + return signerOrProvider.resolveName(value); + } + if (paramType.type === "tuple") { + return resolveAddresses(signerOrProvider, value, paramType.components); + } + // Strips one level of array indexing off the end to recuse into + //let isArrayMatch = paramType.type.match(/(.*)(\[[0-9]*\]$)/); + if (paramType.baseType === "array") { + if (!Array.isArray(value)) { + throw new Error("invalid value for array"); + } + return Promise.all(value.map(function (v) { return resolveAddresses(signerOrProvider, v, paramType.arrayChildren); })); + } + return Promise.resolve(value); +} +function runMethod(contract, functionName, options) { + var method = contract.interface.functions[functionName]; + return function () { + var _this = this; + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + var tx = {}; + var blockTag = null; + // If 1 extra parameter was passed in, it contains overrides + if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { + tx = properties_1.shallowCopy(params.pop()); + if (tx.blockTag != null) { + blockTag = tx.blockTag; + } + delete tx.blockTag; + // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") + for (var key in tx) { + if (!allowedTransactionKeys[key]) { + errors.throwError(("unknown transaxction override - " + key), "overrides", tx); + } + } + } + errors.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + // Check overrides make sense + ["data", "to"].forEach(function (key) { + if (tx[key] != null) { + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }); + } + }); + // If the contract was just deployed, wait until it is minded + if (contract.deployTransaction != null) { + tx.to = contract._deployed(blockTag).then(function () { + return contract.addressPromise; + }); + } + else { + tx.to = contract.addressPromise; + } + return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then(function (params) { + tx.data = contract.interface.encodeFunctionData(method, params); + if (method.constant || options.callStatic) { + // Call (constant functions) always cost 0 ether + if (options.estimate) { + return Promise.resolve(constants_1.Zero); + } + if (!contract.provider && !contract.signer) { + errors.throwError("call (constant functions) require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "call" }); + } + // Check overrides make sense + ["gasLimit", "gasPrice", "value"].forEach(function (key) { + if (tx[key] != null) { + throw new Error("call cannot override " + key); + } + }); + if (options.transaction) { + return properties_1.resolveProperties(tx); + } + return (contract.signer || contract.provider).call(tx, blockTag).then(function (value) { + try { + var result = contract.interface.decodeFunctionResult(method, value); + if (method.outputs.length === 1) { + result = result[0]; + } + return result; + } + catch (error) { + if (error.code === errors.CALL_EXCEPTION) { + error.address = contract.address; + error.args = params; + error.transaction = tx; + } + throw error; + } + }); + } + // Only computing the transaction estimate + if (options.estimate) { + if (!contract.provider && !contract.signer) { + errors.throwError("estimate require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); + } + return (contract.signer || contract.provider).estimateGas(tx); + } + if (tx.gasLimit == null && method.gas != null) { + tx.gasLimit = bignumber_1.BigNumber.from(method.gas).add(21000); + } + if (tx.value != null && !method.payable) { + errors.throwError("contract method is not payable", errors.INVALID_ARGUMENT, { + argument: "sendTransaction", + value: tx, + method: method.format() + }); + } + if (!contract.signer) { + errors.throwError("sending a transaction require a signer", errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); + } + if (options.transaction) { + return tx; + } + return contract.signer.sendTransaction(tx).then(function (tx) { + var wait = tx.wait.bind(tx); + tx.wait = function (confirmations) { + return wait(confirmations).then(function (receipt) { + receipt.events = receipt.logs.map(function (log) { + var event = properties_1.deepCopy(log); + var parsed = contract.interface.parseLog(log); + if (parsed) { + event.values = parsed.values; + event.decode = function (data, topics) { + return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.event = parsed.name; + event.eventSignature = parsed.signature; + } + event.removeListener = function () { return contract.provider; }; + event.getBlock = function () { + return contract.provider.getBlock(receipt.blockHash); + }; + event.getTransaction = function () { + return contract.provider.getTransaction(receipt.transactionHash); + }; + event.getTransactionReceipt = function () { + return Promise.resolve(receipt); + }; + return event; + }); + return receipt; + }); + }; + return tx; + }); + }); + }; +} +function getEventTag(filter) { + if (filter.address && (filter.topics == null || filter.topics.length === 0)) { + return "*"; + } + return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":") : ""); +} +var Contract = /** @class */ (function () { + // https://github.com/Microsoft/TypeScript/issues/5453 + // Once this issue is resolved (there are open PR) we can do this nicer + // by making addressOrName default to null for 2 operand calls. :) + function Contract(addressOrName, contractInterface, signerOrProvider) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, Contract); + // @TODO: Maybe still check the addressOrName looks like a valid address or name? + //address = getAddress(address); + properties_1.defineReadOnly(this, "interface", _newTarget.getInterface(contractInterface)); + if (properties_1.isNamedInstance(abstract_signer_1.Signer, signerOrProvider)) { + properties_1.defineReadOnly(this, "provider", signerOrProvider.provider); + properties_1.defineReadOnly(this, "signer", signerOrProvider); + } + else if (properties_1.isNamedInstance(abstract_provider_1.Provider, signerOrProvider)) { + properties_1.defineReadOnly(this, "provider", signerOrProvider); + properties_1.defineReadOnly(this, "signer", null); + } + else { + errors.throwError("invalid signer or provider", errors.INVALID_ARGUMENT, { arg: "signerOrProvider", value: signerOrProvider }); + } + properties_1.defineReadOnly(this, "callStatic", {}); + properties_1.defineReadOnly(this, "estimate", {}); + properties_1.defineReadOnly(this, "functions", {}); + properties_1.defineReadOnly(this, "populateTransaction", {}); + properties_1.defineReadOnly(this, "filters", {}); + Object.keys(this.interface.events).forEach(function (eventName) { + var event = _this.interface.events[eventName]; + properties_1.defineReadOnly(_this.filters, eventName, function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { + address: _this.address, + topics: _this.interface.encodeFilterTopics(event, args) + }; + }); + }); + this._events = []; + properties_1.defineReadOnly(this, "address", addressOrName); + if (this.provider) { + properties_1.defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then(function (address) { + if (address == null) { + throw new Error("name not found"); + } + return address; + }).catch(function (error) { + console.log("ERROR: Cannot find Contract - " + addressOrName); + throw error; + })); + } + else { + try { + properties_1.defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); + } + catch (error) { + // Without a provider, we cannot use ENS names + errors.throwError("provider is required to use non-address contract address", errors.INVALID_ARGUMENT, { argument: "addressOrName", value: addressOrName }); + } + } + Object.keys(this.interface.functions).forEach(function (name) { + var run = runMethod(_this, name, {}); + if (_this[name] == null) { + properties_1.defineReadOnly(_this, name, run); + } + if (_this.functions[name] == null) { + properties_1.defineReadOnly(_this.functions, name, run); + } + if (_this.callStatic[name] == null) { + properties_1.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true })); + } + if (_this.populateTransaction[name] == null) { + properties_1.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true })); + } + if (_this.estimate[name] == null) { + properties_1.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true })); + } + }); + } + Contract.getContractAddress = function (transaction) { + return address_1.getContractAddress(transaction); + }; + Contract.getInterface = function (contractInterface) { + if (properties_1.isNamedInstance(abi_1.Interface, contractInterface)) { + return contractInterface; + } + return new abi_1.Interface(contractInterface); + }; + // @TODO: Allow timeout? + Contract.prototype.deployed = function () { + return this._deployed(); + }; + Contract.prototype._deployed = function (blockTag) { + var _this = this; + if (!this._deployedPromise) { + // If we were just deployed, we know the transaction we should occur in + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(function () { + return _this; + }); + } + else { + // @TODO: Once we allow a timeout to be passed in, we will wait + // up to that many blocks for getCode + // Otherwise, poll for our code to be deployed + this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) { + if (code === "0x") { + errors.throwError("contract not deployed", errors.UNSUPPORTED_OPERATION, { + contractAddress: _this.address, + operation: "getDeployed" + }); + } + return _this; + }); + } + } + return this._deployedPromise; + }; + // @TODO: + // estimateFallback(overrides?: TransactionRequest): Promise + // @TODO: + // estimateDeploy(bytecode: string, ...args): Promise + Contract.prototype.fallback = function (overrides) { + var _this = this; + if (!this.signer) { + errors.throwError("sending a transaction require a signer", errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + } + var tx = properties_1.shallowCopy(overrides || {}); + ["from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + tx.to = this.addressPromise; + return this.deployed().then(function () { + return _this.signer.sendTransaction(tx); + }); + }; + // Reconnect to a different signer or provider + Contract.prototype.connect = function (signerOrProvider) { + if (typeof (signerOrProvider) === "string") { + signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider); + } + var contract = new (this.constructor)(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + properties_1.defineReadOnly(contract, "deployTransaction", this.deployTransaction); + } + return contract; + }; + // Re-attach to a different on-chain instance of this contract + Contract.prototype.attach = function (addressOrName) { + return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); + }; + Contract.isIndexed = function (value) { + return properties_1.isNamedInstance(abi_1.Indexed, value); + }; + Contract.prototype._getEventFilter = function (eventName) { + var _this = this; + if (typeof (eventName) === "string") { + // Listen for any event + if (eventName === "*") { + return { + prepareEvent: function (e) { + var parsed = _this.interface.parseLog(e); + if (parsed) { + e.values = parsed.values; + e.decode = function (data, topics) { + return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }, + e.event = parsed.name; + e.eventSignature = parsed.signature; + } + }, + eventTag: "*", + filter: { address: this.address }, + }; + } + var fragment_1 = this.interface.getEvent(eventName); + if (!fragment_1) { + errors.throwError("unknown event - " + eventName, errors.INVALID_ARGUMENT, { argumnet: "eventName", value: eventName }); + } + var filter_1 = { + address: this.address, + topics: [this.interface.getEventTopic(fragment_1)] + }; + return { + prepareEvent: function (e) { + e.values = _this.interface.decodeEventLog(fragment_1, e.data, e.topics); + }, + fragment: fragment_1, + eventTag: getEventTag(filter_1), + filter: filter_1 + }; + } + var filter = { + address: this.address + }; + // Find the matching event in the ABI; if none, we still allow filtering + // since it may be a filter for an otherwise unknown event + var fragment = null; + if (eventName.topics && eventName.topics[0]) { + filter.topics = eventName.topics; + fragment = this.interface.getEvent(eventName.topics[0]); + } + return { + prepareEvent: function (e) { + if (!fragment) { + return; + } + e.values = _this.interface.decodeEventLog(fragment, e.data, e.topics); + }, + fragment: fragment, + eventTag: getEventTag(filter), + filter: filter + }; + }; + // @TODO: move this to _EventFilter.wrapLog. Maybe into prepareEvent? + Contract.prototype._wrapEvent = function (eventFilter, log, listener) { + var _this = this; + var event = properties_1.deepCopy(log); + // @TODO: Move all the below stuff into prepare + eventFilter.prepareEvent(event); + if (eventFilter.fragment) { + event.decode = function (data, topics) { + return _this.interface.decodeEventLog(eventFilter.fragment, data, topics); + }, + event.event = eventFilter.fragment.name; + event.eventSignature = eventFilter.fragment.format(); + } + event.removeListener = function () { + if (!listener) { + return; + } + _this.removeListener(eventFilter.filter, listener); + }; + event.getBlock = function () { return _this.provider.getBlock(log.blockHash); }; + event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); }; + event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); }; + return event; + }; + Contract.prototype._addEventListener = function (eventFilter, listener, once) { + var _this = this; + if (!this.provider) { + errors.throwError("events require a provider or a signer with a provider", errors.UNSUPPORTED_OPERATION, { operation: "once" }); + } + var wrappedListener = function (log) { + var event = _this._wrapEvent(eventFilter, log, listener); + var values = (event.values || []); + values.push(event); + _this.emit.apply(_this, [eventFilter.filter].concat(values)); + }; + this.provider.on(eventFilter.filter, wrappedListener); + this._events.push({ eventFilter: eventFilter, listener: listener, wrappedListener: wrappedListener, once: once }); + }; + Contract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) { + var _this = this; + var eventFilter = this._getEventFilter(event); + var filter = properties_1.shallowCopy(eventFilter.filter); + if (typeof (fromBlockOrBlockhash) === "string" && bytes_1.isHexString(fromBlockOrBlockhash, 32)) { + filter.blockhash = fromBlockOrBlockhash; + if (toBlock != null) { + errors.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + } + } + else { + filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0); + filter.toBlock = ((toBlock != null) ? toBlock : "latest"); + } + return this.provider.getLogs(filter).then(function (logs) { + return logs.map(function (log) { return _this._wrapEvent(eventFilter, log, null); }); + }); + }; + Contract.prototype.on = function (event, listener) { + this._addEventListener(this._getEventFilter(event), listener, false); + return this; + }; + Contract.prototype.once = function (event, listener) { + this._addEventListener(this._getEventFilter(event), listener, true); + return this; + }; + Contract.prototype.addListener = function (eventName, listener) { + return this.on(eventName, listener); + }; + Contract.prototype.emit = function (eventName) { + var _this = this; + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + if (!this.provider) { + return false; + } + var result = false; + var eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter(function (event) { + // Not this event (keep it for later) + if (event.eventFilter.eventTag !== eventFilter.eventTag) { + return true; + } + // Call the callback in the next event loop + setTimeout(function () { + event.listener.apply(_this, args); + }, 0); + result = true; + // Reschedule it if it not "once" + return !(event.once); + }); + return result; + }; + Contract.prototype.listenerCount = function (eventName) { + if (!this.provider) { + return 0; + } + var eventFilter = this._getEventFilter(eventName); + return this._events.filter(function (event) { + return event.eventFilter.eventTag === eventFilter.eventTag; + }).length; + }; + Contract.prototype.listeners = function (eventName) { + if (!this.provider) { + return []; + } + if (eventName == null) { + return this._events.map(function (event) { return event.listener; }); + } + var eventFilter = this._getEventFilter(eventName); + return this._events + .filter(function (event) { return (event.eventFilter.eventTag === eventFilter.eventTag); }) + .map(function (event) { return event.listener; }); + }; + Contract.prototype.removeAllListeners = function (eventName) { + var _this = this; + if (!this.provider) { + return this; + } + var eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter(function (event) { + // Keep non-matching events + if (event.eventFilter.eventTag !== eventFilter.eventTag) { + return true; + } + // De-register this event from the provider and filter it out + _this.provider.removeListener(event.eventFilter.filter, event.wrappedListener); + return false; + }); + return this; + }; + Contract.prototype.off = function (eventName, listener) { + var _this = this; + if (!this.provider) { + return this; + } + var found = false; + var eventFilter = this._getEventFilter(eventName); + this._events = this._events.filter(function (event) { + // Make sure this event and listener match + if (event.eventFilter.eventTag !== eventFilter.eventTag) { + return true; + } + if (event.listener !== listener) { + return true; + } + _this.provider.removeListener(event.eventFilter.filter, event.wrappedListener); + // Already found a matching event in a previous loop + if (found) { + return true; + } + // Remove this event (returning false filters us out) + found = true; + return false; + }); + return this; + }; + Contract.prototype.removeListener = function (eventName, listener) { + return this.off(eventName, listener); + }; + return Contract; +}()); +exports.Contract = Contract; +var ContractFactory = /** @class */ (function () { + function ContractFactory(contractInterface, bytecode, signer) { + var _newTarget = this.constructor; + var bytecodeHex = null; + if (typeof (bytecode) === "string") { + bytecodeHex = bytecode; + } + else if (bytes_1.isBytes(bytecode)) { + bytecodeHex = bytes_1.hexlify(bytecode); + } + else if (bytecode && typeof (bytecode.object) === "string") { + // Allow the bytecode object from the Solidity compiler + bytecodeHex = bytecode.object; + } + else { + // Crash in the next verification step + bytecodeHex = "!"; + } + // Make sure it is 0x prefixed + if (bytecodeHex.substring(0, 2) !== "0x") { + bytecodeHex = "0x" + bytecodeHex; + } + // Make sure the final result is valid bytecode + if (!bytes_1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + errors.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + // If we have a signer, make sure it is valid + if (signer && !properties_1.isNamedInstance(abstract_signer_1.Signer, signer)) { + errors.throwArgumentError("invalid signer", "signer", signer); + } + properties_1.defineReadOnly(this, "bytecode", bytecodeHex); + properties_1.defineReadOnly(this, "interface", _newTarget.getInterface(contractInterface)); + properties_1.defineReadOnly(this, "signer", signer || null); + } + ContractFactory.prototype.getDeployTransaction = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var tx = {}; + // If we have 1 additional argument, we allow transaction overrides + if (args.length === this.interface.deploy.inputs.length + 1) { + tx = properties_1.shallowCopy(args.pop()); + for (var key in tx) { + if (!allowedTransactionKeys[key]) { + throw new Error("unknown transaction override " + key); + } + } + } + // Do not allow these to be overridden in a deployment transaction + ["data", "from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + errors.throwError("cannot override " + key, errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + // Make sure the call matches the constructor signature + errors.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + // Set the data to the bytecode + the encoded constructor arguments + tx.data = bytes_1.hexlify(bytes_1.concat([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + return tx; + }; + ContractFactory.prototype.deploy = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + // Get the deployment transaction (with optional overrides) + var tx = this.getDeployTransaction.apply(this, args); + // Send the deployment transaction + return this.signer.sendTransaction(tx).then(function (tx) { + var address = (_this.constructor).getContractAddress(tx); + var contract = (_this.constructor).getContract(address, _this.interface, _this.signer); + properties_1.defineReadOnly(contract, "deployTransaction", tx); + return contract; + }); + }; + ContractFactory.prototype.attach = function (address) { + return (this.constructor).getContract(address, this.interface, this.signer); + }; + ContractFactory.prototype.connect = function (signer) { + return new (this.constructor)(this.interface, this.bytecode, signer); + }; + ContractFactory.fromSolidity = function (compilerOutput, signer) { + if (compilerOutput == null) { + errors.throwError("missing compiler output", errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + if (typeof (compilerOutput) === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + var abi = compilerOutput.abi; + var bytecode = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } + else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + return new this(abi, bytecode, signer); + }; + ContractFactory.getInterface = function (contractInterface) { + return Contract.getInterface(contractInterface); + }; + ContractFactory.getContractAddress = function (tx) { + return address_1.getContractAddress(tx); + }; + ContractFactory.getContract = function (address, contractInterface, signer) { + return new Contract(address, contractInterface, signer); + }; + return ContractFactory; +}()); +exports.ContractFactory = ContractFactory; + +},{"@ethersproject/abi":53,"@ethersproject/abstract-provider":55,"@ethersproject/abstract-signer":56,"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66,"@ethersproject/properties":82}],66:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//import { version } from "./_version"; +var version = "@TODO"; +/////////////////// +// Generic Errors +// Unknown Error +exports.UNKNOWN_ERROR = "UNKNOWN_ERROR"; +// Not Implemented +exports.NOT_IMPLEMENTED = "NOT_IMPLEMENTED"; +// Unsupported Operation +// - operation +exports.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION"; +// Network Error +exports.NETWORK_ERROR = "NETWORK_ERROR"; +/////////////////// +// Operational Errors +// Buffer Overrun +exports.BUFFER_OVERRUN = "BUFFER_OVERRUN"; +// Numeric Fault +// - operation: the operation being executed +// - fault: the reason this faulted +exports.NUMERIC_FAULT = "NUMERIC_FAULT"; +/////////////////// +// Argument Errors +// Missing new operator to an object +// - name: The name of the class +exports.MISSING_NEW = "MISSING_NEW"; +// Invalid argument (e.g. value is incompatible with type) to a function: +// - argument: The argument name that was invalid +// - value: The value of the argument +exports.INVALID_ARGUMENT = "INVALID_ARGUMENT"; +// Missing argument to a function: +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +exports.MISSING_ARGUMENT = "MISSING_ARGUMENT"; +// Too many arguments +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +exports.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT"; +/////////////////// +// Blockchain Errors +// Call exception +// - transaction: the transaction +// - address?: the contract address +// - args?: The arguments passed into the function +// - method?: The Solidity method signature +// - errorSignature?: The EIP848 error signature +// - errorArgs?: The EIP848 error parameters +// - reason: The reason (only for EIP848 "Error(string)") +exports.CALL_EXCEPTION = "CALL_EXCEPTION"; +// Insufficien funds (< value + gasLimit * gasPrice) +// - transaction: the transaction attempted +exports.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"; +// Nonce has already been used +// - transaction: the transaction attempted +exports.NONCE_EXPIRED = "NONCE_EXPIRED"; +// The replacement fee for the transaction is too low +// - transaction: the transaction attempted +exports.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED"; +// The gas limit could not be estimated +// - transaction: the transaction passed to estimateGas +exports.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; +//export const errors: { [ code: string ]: string } = { +//}; +/////////////////// +// Censorship +var _permanentCensorErrors = false; +var _censorErrors = false; +function setCensorship(censorship, permanent) { + if (_permanentCensorErrors) { + throwError("error censorship permanent", exports.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; +} +exports.setCensorship = setCensorship; +/////////////////// +// Errors +function makeError(message, code, params) { + if (_censorErrors) { + return new Error("unknown error"); + } + if (!code) { + code = exports.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + var messageDetails = []; + Object.keys(params).forEach(function (key) { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + version); + var reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + var error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; +} +exports.makeError = makeError; +// @TODO: Enum +function throwError(message, code, params) { + throw makeError(message, code, params); +} +exports.throwError = throwError; +function throwArgumentError(message, name, value) { + return throwError(message, exports.INVALID_ARGUMENT, { + argument: name, + value: value + }); +} +exports.throwArgumentError = throwArgumentError; +/////////////////// +// Checking +function checkArgumentCount(count, expectedCount, suffix) { + if (suffix) { + suffix = " " + suffix; + } + else { + suffix = ""; + } + if (count < expectedCount) { + throwError("missing argument" + suffix, exports.MISSING_ARGUMENT, { count: count, expectedCount: expectedCount }); + } + if (count > expectedCount) { + throwError("too many arguments" + suffix, exports.UNEXPECTED_ARGUMENT, { count: count, expectedCount: expectedCount }); + } +} +exports.checkArgumentCount = checkArgumentCount; +function checkNew(target, kind) { + if (target === Object || target == null) { + throwError("missing new", exports.MISSING_NEW, { name: kind.name }); + } +} +exports.checkNew = checkNew; +/* +export function check(target: any: void { + if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ +function checkAbstract(target, kind) { + if (target === kind) { + throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", exports.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + throwError("missing new", exports.MISSING_NEW, { name: kind.name }); + } +} +exports.checkAbstract = checkAbstract; +/* +export function checkTarget(target: any, kind: any): void { + if (target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ +function _checkNormalize() { + try { + var missing_1 = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) { + try { + "test".normalize(form); + } + catch (error) { + missing_1.push(form); + } + }); + if (missing_1.length) { + throw new Error("missing " + missing_1.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; +} +var _normalizeError = _checkNormalize(); +function checkNormalize() { + if (_normalizeError) { + throwError("platform missing String.prototype.normalize", exports.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } +} +exports.checkNormalize = checkNormalize; +function checkSafeUint53(value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + throwError(message, exports.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + throwError(message, exports.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } +} +exports.checkSafeUint53 = checkSafeUint53; +/////////////////// +// Logging +var LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; +var LogLevel = LogLevels["default"]; +function setLogLevel(logLevel) { + var level = LogLevels[logLevel]; + if (level == null) { + warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; +} +exports.setLogLevel = setLogLevel; +function log(logLevel, args) { + if (LogLevel > LogLevels[logLevel]) { + return; + } + console.log.apply(console, args); +} +function warn() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + log("warn", args); +} +exports.warn = warn; +function info() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + log("info", args); +} +exports.info = info; + +},{}],67:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.version = "5.0.0-beta.134"; + +},{}],68:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var contracts_1 = require("@ethersproject/contracts"); +exports.Contract = contracts_1.Contract; +exports.ContractFactory = contracts_1.ContractFactory; +var bignumber_1 = require("@ethersproject/bignumber"); +exports.BigNumber = bignumber_1.BigNumber; +exports.FixedNumber = bignumber_1.FixedNumber; +var abstract_signer_1 = require("@ethersproject/abstract-signer"); +exports.Signer = abstract_signer_1.Signer; +exports.VoidSigner = abstract_signer_1.VoidSigner; +var wallet_1 = require("@ethersproject/wallet"); +exports.Wallet = wallet_1.Wallet; +var constants = __importStar(require("@ethersproject/constants")); +exports.constants = constants; +var errors = __importStar(require("@ethersproject/errors")); +exports.errors = errors; +var providers = __importStar(require("@ethersproject/providers")); +exports.providers = providers; +var wordlists = __importStar(require("@ethersproject/wordlists")); +exports.wordlists = wordlists; +var utils = __importStar(require("./utils")); +exports.utils = utils; +var _version_1 = require("./_version"); +exports.version = _version_1.version; +var wordlist_1 = require("@ethersproject/wordlists/wordlist"); +exports.Wordlist = wordlist_1.Wordlist; +//////////////////////// +// Compile-Time Constants +// This is empty in node, and used by browserify to inject extra goodies +var platform_1 = require("./platform"); +exports.platform = platform_1.platform; +//////////////////////// +// Helper Functions +function getDefaultProvider(network, options) { + if (network == null) { + network = "homestead"; + } + var n = providers.getNetwork(network); + if (!n || !n._defaultProvider) { + errors.throwError("unsupported getDefaultProvider network", errors.NETWORK_ERROR, { + operation: "getDefaultProvider", + network: network + }); + } + return n._defaultProvider(providers, options); +} +exports.getDefaultProvider = getDefaultProvider; + +},{"./_version":67,"./platform":70,"./utils":71,"@ethersproject/abstract-signer":56,"@ethersproject/bignumber":62,"@ethersproject/constants":64,"@ethersproject/contracts":65,"@ethersproject/errors":66,"@ethersproject/providers":89,"@ethersproject/wallet":104,"@ethersproject/wordlists":107,"@ethersproject/wordlists/wordlist":109}],69:[function(require,module,exports){ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ethers = __importStar(require("./ethers")); +exports.ethers = ethers; +__export(require("./ethers")); + +},{"./ethers":68}],70:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.platform = "node"; + +},{}],71:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var abi_1 = require("@ethersproject/abi"); +exports.AbiCoder = abi_1.AbiCoder; +exports.defaultAbiCoder = abi_1.defaultAbiCoder; +exports.EventFragment = abi_1.EventFragment; +exports.Fragment = abi_1.Fragment; +exports.FunctionFragment = abi_1.FunctionFragment; +exports.Indexed = abi_1.Indexed; +exports.Interface = abi_1.Interface; +exports.ParamType = abi_1.ParamType; +var address_1 = require("@ethersproject/address"); +exports.getAddress = address_1.getAddress; +exports.getContractAddress = address_1.getContractAddress; +exports.getIcapAddress = address_1.getIcapAddress; +exports.isAddress = address_1.isAddress; +var base64 = __importStar(require("@ethersproject/base64")); +exports.base64 = base64; +var bytes_1 = require("@ethersproject/bytes"); +exports.arrayify = bytes_1.arrayify; +exports.concat = bytes_1.concat; +exports.hexDataSlice = bytes_1.hexDataSlice; +exports.hexDataLength = bytes_1.hexDataLength; +exports.hexlify = bytes_1.hexlify; +exports.hexStripZeros = bytes_1.hexStripZeros; +exports.hexValue = bytes_1.hexValue; +exports.hexZeroPad = bytes_1.hexZeroPad; +exports.isHexString = bytes_1.isHexString; +exports.joinSignature = bytes_1.joinSignature; +exports.zeroPad = bytes_1.zeroPad; +exports.splitSignature = bytes_1.splitSignature; +exports.stripZeros = bytes_1.stripZeros; +var hash_1 = require("@ethersproject/hash"); +exports.hashMessage = hash_1.hashMessage; +exports.id = hash_1.id; +exports.namehash = hash_1.namehash; +var hdnode_1 = require("@ethersproject/hdnode"); +exports.entropyToMnemonic = hdnode_1.entropyToMnemonic; +exports.HDNode = hdnode_1.HDNode; +exports.isValidMnemonic = hdnode_1.isValidMnemonic; +exports.mnemonicToEntropy = hdnode_1.mnemonicToEntropy; +exports.mnemonicToSeed = hdnode_1.mnemonicToSeed; +var json_wallets_1 = require("@ethersproject/json-wallets"); +exports.getJsonWalletAddress = json_wallets_1.getJsonWalletAddress; +var keccak256_1 = require("@ethersproject/keccak256"); +exports.keccak256 = keccak256_1.keccak256; +var sha2_1 = require("@ethersproject/sha2"); +exports.sha256 = sha2_1.sha256; +var solidity_1 = require("@ethersproject/solidity"); +exports.solidityKeccak256 = solidity_1.keccak256; +exports.solidityPack = solidity_1.pack; +exports.soliditySha256 = solidity_1.sha256; +var random_1 = require("@ethersproject/random"); +exports.randomBytes = random_1.randomBytes; +var properties_1 = require("@ethersproject/properties"); +exports.checkProperties = properties_1.checkProperties; +exports.deepCopy = properties_1.deepCopy; +exports.defineReadOnly = properties_1.defineReadOnly; +exports.resolveProperties = properties_1.resolveProperties; +exports.shallowCopy = properties_1.shallowCopy; +var RLP = __importStar(require("@ethersproject/rlp")); +exports.RLP = RLP; +var signing_key_1 = require("@ethersproject/signing-key"); +exports.computePublicKey = signing_key_1.computePublicKey; +exports.recoverPublicKey = signing_key_1.recoverPublicKey; +exports.SigningKey = signing_key_1.SigningKey; +var strings_1 = require("@ethersproject/strings"); +exports.formatBytes32String = strings_1.formatBytes32String; +exports.parseBytes32String = strings_1.parseBytes32String; +exports.toUtf8Bytes = strings_1.toUtf8Bytes; +exports.toUtf8String = strings_1.toUtf8String; +var transactions_1 = require("@ethersproject/transactions"); +exports.computeAddress = transactions_1.computeAddress; +exports.parseTransaction = transactions_1.parse; +exports.recoverAddress = transactions_1.recoverAddress; +exports.serializeTransaction = transactions_1.serialize; +var units_1 = require("@ethersproject/units"); +exports.commify = units_1.commify; +exports.formatEther = units_1.formatEther; +exports.parseEther = units_1.parseEther; +exports.formatUnits = units_1.formatUnits; +exports.parseUnits = units_1.parseUnits; +var wallet_1 = require("@ethersproject/wallet"); +exports.verifyMessage = wallet_1.verifyMessage; +var web_1 = require("@ethersproject/web"); +exports.fetchJson = web_1.fetchJson; +//////////////////////// +// Enums +var sha2_2 = require("@ethersproject/sha2"); +exports.SupportedAlgorithms = sha2_2.SupportedAlgorithms; +var strings_2 = require("@ethersproject/strings"); +exports.UnicodeNormalizationForm = strings_2.UnicodeNormalizationForm; + +},{"@ethersproject/abi":53,"@ethersproject/address":57,"@ethersproject/base64":58,"@ethersproject/bytes":63,"@ethersproject/hash":72,"@ethersproject/hdnode":73,"@ethersproject/json-wallets":75,"@ethersproject/keccak256":79,"@ethersproject/properties":82,"@ethersproject/random":95,"@ethersproject/rlp":97,"@ethersproject/sha2":98,"@ethersproject/signing-key":99,"@ethersproject/solidity":100,"@ethersproject/strings":101,"@ethersproject/transactions":102,"@ethersproject/units":103,"@ethersproject/wallet":104,"@ethersproject/web":106}],72:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// @TODO: Migrate this to a better named package... +var errors = __importStar(require("@ethersproject/errors")); +var bytes_1 = require("@ethersproject/bytes"); +var strings_1 = require("@ethersproject/strings"); +var keccak256_1 = require("@ethersproject/keccak256"); +/////////////////////////////// +var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); +var Partition = new RegExp("^((.*)\\.)?([^.]+)$"); +var UseSTD3ASCIIRules = new RegExp("^[a-z0-9.-]*$"); +function namehash(name) { + if (typeof (name) !== "string") { + errors.throwError("invalid address - " + String(name), errors.INVALID_ARGUMENT, { + argument: "name", + value: name + }); + } + name = name.toLowerCase(); + // Supporting the full UTF-8 space requires additional (and large) + // libraries, so for now we simply do not support them. + // It should be fairly easy in the future to support systems with + // String.normalize, but that is future work. + if (!name.match(UseSTD3ASCIIRules)) { + errors.throwError("contains invalid UseSTD3ASCIIRules characters", errors.INVALID_ARGUMENT, { + argument: "name", + value: name + }); + } + var result = Zeros; + while (name.length) { + var partition = name.match(Partition); + var label = strings_1.toUtf8Bytes(partition[3]); + result = keccak256_1.keccak256(bytes_1.concat([result, keccak256_1.keccak256(label)])); + name = partition[2] || ""; + } + return bytes_1.hexlify(result); +} +exports.namehash = namehash; +function id(text) { + return keccak256_1.keccak256(strings_1.toUtf8Bytes(text)); +} +exports.id = id; +exports.messagePrefix = "\x19Ethereum Signed Message:\n"; +function hashMessage(message) { + if (typeof (message) === "string") { + message = strings_1.toUtf8Bytes(message); + } + return keccak256_1.keccak256(bytes_1.concat([ + strings_1.toUtf8Bytes(exports.messagePrefix), + strings_1.toUtf8Bytes(String(message.length)), + message + ])); +} +exports.hashMessage = hashMessage; + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/strings":101}],73:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// See: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki +// See: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki +// The English language word list. +// For additional word lists, please see @ethersproject//wordlists +var lang_en_1 = require("@ethersproject/wordlists/lang-en"); +var basex_1 = require("@ethersproject/basex"); +var errors = __importStar(require("@ethersproject/errors")); +var bytes_1 = require("@ethersproject/bytes"); +var bignumber_1 = require("@ethersproject/bignumber"); +var strings_1 = require("@ethersproject/strings"); +var pbkdf2_1 = require("@ethersproject/pbkdf2"); +var properties_1 = require("@ethersproject/properties"); +var signing_key_1 = require("@ethersproject/signing-key"); +var sha2_1 = require("@ethersproject/sha2"); +var transactions_1 = require("@ethersproject/transactions"); +var N = bignumber_1.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); +// "Bitcoin seed" +var MasterSecret = strings_1.toUtf8Bytes("Bitcoin seed"); +var HardenedBit = 0x80000000; +// Returns a byte with the MSB bits set +function getUpperMask(bits) { + return ((1 << bits) - 1) << (8 - bits); +} +// Returns a byte with the LSB bits set +function getLowerMask(bits) { + return (1 << bits) - 1; +} +function bytes32(value) { + return bytes_1.hexZeroPad(bytes_1.hexlify(value), 32); +} +function base58check(data) { + var checksum = bytes_1.hexDataSlice(sha2_1.sha256(sha2_1.sha256(data)), 0, 4); + return basex_1.Base58.encode(bytes_1.concat([data, checksum])); +} +var _constructorGuard = {}; +exports.defaultPath = "m/44'/60'/0'/0/0"; +var HDNode = /** @class */ (function () { + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { + var _newTarget = this.constructor; + errors.checkNew(_newTarget, HDNode); + if (constructorGuard !== _constructorGuard) { + throw new Error("HDNode constructor cannot be called directly"); + } + if (privateKey) { + var signingKey = new signing_key_1.SigningKey(privateKey); + properties_1.defineReadOnly(this, "privateKey", signingKey.privateKey); + properties_1.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); + } + else { + properties_1.defineReadOnly(this, "privateKey", null); + properties_1.defineReadOnly(this, "publicKey", bytes_1.hexlify(publicKey)); + } + properties_1.defineReadOnly(this, "parentFingerprint", parentFingerprint); + properties_1.defineReadOnly(this, "fingerprint", bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4)); + properties_1.defineReadOnly(this, "address", transactions_1.computeAddress(this.publicKey)); + properties_1.defineReadOnly(this, "chainCode", chainCode); + properties_1.defineReadOnly(this, "index", index); + properties_1.defineReadOnly(this, "depth", depth); + properties_1.defineReadOnly(this, "mnemonic", mnemonic); + properties_1.defineReadOnly(this, "path", path); + } + Object.defineProperty(HDNode.prototype, "extendedKey", { + get: function () { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current senitment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + if (this.depth >= 256) { + throw new Error("Depth too large!"); + } + return base58check(bytes_1.concat([ + ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), + bytes_1.hexlify(this.depth), + this.parentFingerprint, + bytes_1.hexZeroPad(bytes_1.hexlify(this.index), 4), + this.chainCode, + ((this.privateKey != null) ? bytes_1.concat(["0x00", this.privateKey]) : this.publicKey), + ])); + }, + enumerable: true, + configurable: true + }); + HDNode.prototype.neuter = function () { + return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); + }; + HDNode.prototype._derive = function (index) { + if (index > 0xffffffff) { + throw new Error("invalid index - " + String(index)); + } + // Base path + var path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + } + var data = new Uint8Array(37); + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); + } + // Data = 0x00 || ser_256(k_par) + data.set(bytes_1.arrayify(this.privateKey), 1); + // Hardened path + if (path) { + path += "'"; + } + } + else { + // Data = ser_p(point(k_par)) + data.set(bytes_1.arrayify(this.publicKey)); + } + // Data += ser_32(i) + for (var i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); + } + var I = bytes_1.arrayify(sha2_1.computeHmac(sha2_1.SupportedAlgorithms.sha512, this.chainCode, data)); + var IL = I.slice(0, 32); + var IR = I.slice(32); + // The private key + var ki = null; + // The public key + var Ki = null; + if (this.privateKey) { + ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N)); + } + else { + var ek = new signing_key_1.SigningKey(bytes_1.hexlify(IL)); + Ki = ek._addPoint(this.publicKey); + } + return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); + }; + HDNode.prototype.derivePath = function (path) { + var components = path.split("/"); + if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { + throw new Error("invalid path - " + path); + } + if (components[0] === "m") { + components.shift(); + } + var result = this; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + if (component.match(/^[0-9]+'$/)) { + var index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(HardenedBit + index); + } + else if (component.match(/^[0-9]+$/)) { + var index = parseInt(component); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(index); + } + else { + throw new Error("invlaid path component - " + component); + } + } + return result; + }; + HDNode._fromSeed = function (seed, mnemonic) { + var seedArray = bytes_1.arrayify(seed); + if (seedArray.length < 16 || seedArray.length > 64) { + throw new Error("invalid seed"); + } + var I = bytes_1.arrayify(sha2_1.computeHmac(sha2_1.SupportedAlgorithms.sha512, MasterSecret, seedArray)); + return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); + }; + HDNode.fromMnemonic = function (mnemonic, password, wordlist) { + // Check that the checksum s valid (will throw an error) + mnemonicToEntropy(mnemonic, wordlist); + return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); + }; + HDNode.fromSeed = function (seed) { + return HDNode._fromSeed(seed, null); + }; + HDNode.fromExtendedKey = function (extendedKey) { + var bytes = basex_1.Base58.decode(extendedKey); + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + errors.throwError("invalid extended key", errors.INVALID_ARGUMENT, { + argument: "extendedKey", + value: "[REDACTED]" + }); + } + var depth = bytes[4]; + var parentFingerprint = bytes_1.hexlify(bytes.slice(5, 9)); + var index = parseInt(bytes_1.hexlify(bytes.slice(9, 13)).substring(2), 16); + var chainCode = bytes_1.hexlify(bytes.slice(13, 45)); + var key = bytes.slice(45, 78); + switch (bytes_1.hexlify(bytes.slice(0, 4))) { + // Public Key + case "0x0488b21e": + case "0x043587cf": + return new HDNode(_constructorGuard, null, bytes_1.hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + // Private Key + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; + } + return new HDNode(_constructorGuard, bytes_1.hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + } + return errors.throwError("invalid extended key", errors.INVALID_ARGUMENT, { + argument: "extendedKey", + value: "[REDACTED]" + }); + }; + return HDNode; +}()); +exports.HDNode = HDNode; +function mnemonicToSeed(mnemonic, password) { + if (!password) { + password = ""; + } + var salt = strings_1.toUtf8Bytes("mnemonic" + password, strings_1.UnicodeNormalizationForm.NFKD); + return pbkdf2_1.pbkdf2(strings_1.toUtf8Bytes(mnemonic, strings_1.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); +} +exports.mnemonicToSeed = mnemonicToSeed; +function mnemonicToEntropy(mnemonic, wordlist) { + if (!wordlist) { + wordlist = lang_en_1.langEn; + } + errors.checkNormalize(); + var words = wordlist.split(mnemonic); + if ((words.length % 3) !== 0) { + throw new Error("invalid mnemonic"); + } + var entropy = bytes_1.arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + var offset = 0; + for (var i = 0; i < words.length; i++) { + var index = wordlist.getWordIndex(words[i].normalize("NFKD")); + if (index === -1) { + throw new Error("invalid mnemonic"); + } + for (var bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + var entropyBits = 32 * words.length / 3; + var checksumBits = words.length / 3; + var checksumMask = getUpperMask(checksumBits); + var checksum = bytes_1.arrayify(sha2_1.sha256(entropy.slice(0, entropyBits / 8)))[0]; + checksum &= checksumMask; + if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { + throw new Error("invalid checksum"); + } + return bytes_1.hexlify(entropy.slice(0, entropyBits / 8)); +} +exports.mnemonicToEntropy = mnemonicToEntropy; +function entropyToMnemonic(entropy, wordlist) { + entropy = bytes_1.arrayify(entropy); + if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { + throw new Error("invalid entropy"); + } + var indices = [0]; + var remainingBits = 11; + for (var i = 0; i < entropy.length; i++) { + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + remainingBits -= 8; + // This byte will complete an 11-bit index + } + else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + remainingBits += 3; + } + } + // Compute the checksum bits + var checksum = bytes_1.arrayify(sha2_1.sha256(entropy))[0]; + var checksumBits = entropy.length / 4; + checksum &= getUpperMask(checksumBits); + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + if (!wordlist) { + wordlist = lang_en_1.langEn; + } + return wordlist.join(indices.map(function (index) { return wordlist.getWord(index); })); +} +exports.entropyToMnemonic = entropyToMnemonic; +function isValidMnemonic(mnemonic, wordlist) { + try { + mnemonicToEntropy(mnemonic, wordlist); + return true; + } + catch (error) { } + return false; +} +exports.isValidMnemonic = isValidMnemonic; + +},{"@ethersproject/basex":59,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/pbkdf2":81,"@ethersproject/properties":82,"@ethersproject/sha2":98,"@ethersproject/signing-key":99,"@ethersproject/strings":101,"@ethersproject/transactions":102,"@ethersproject/wordlists/lang-en":108}],74:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aes_js_1 = __importDefault(require("aes-js")); +var address_1 = require("@ethersproject/address"); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var keccak256_1 = require("@ethersproject/keccak256"); +var pbkdf2_1 = require("@ethersproject/pbkdf2"); +var strings_1 = require("@ethersproject/strings"); +var properties_1 = require("@ethersproject/properties"); +var utils_1 = require("./utils"); +var CrowdsaleAccount = /** @class */ (function (_super) { + __extends(CrowdsaleAccount, _super); + function CrowdsaleAccount() { + return _super !== null && _super.apply(this, arguments) || this; + } + CrowdsaleAccount.prototype.isType = function (value) { + return properties_1.Description.isType(value); + }; + return CrowdsaleAccount; +}(properties_1.Description)); +exports.CrowdsaleAccount = CrowdsaleAccount; +// See: https://github.com/ethereum/pyethsaletool +function decrypt(json, password) { + var data = JSON.parse(json); + password = utils_1.getPassword(password); + // Ethereum Address + var ethaddr = address_1.getAddress(utils_1.searchPath(data, "ethaddr")); + // Encrypted Seed + var encseed = utils_1.looseArrayify(utils_1.searchPath(data, "encseed")); + if (!encseed || (encseed.length % 16) !== 0) { + errors.throwError("invalid encseed", errors.INVALID_ARGUMENT, { + argument: "json", + value: json + }); + } + var key = bytes_1.arrayify(pbkdf2_1.pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); + var iv = encseed.slice(0, 16); + var encryptedSeed = encseed.slice(16); + // Decrypt the seed + var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv); + var seed = bytes_1.arrayify(aesCbc.decrypt(encryptedSeed)); + seed = aes_js_1.default.padding.pkcs7.strip(seed); + // This wallet format is weird... Convert the binary encoded hex to a string. + var seedHex = ""; + for (var i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + var seedHexBytes = strings_1.toUtf8Bytes(seedHex); + var privateKey = keccak256_1.keccak256(seedHexBytes); + return new CrowdsaleAccount({ + address: ethaddr, + privateKey: privateKey + }); +} +exports.decrypt = decrypt; + +},{"./utils":78,"@ethersproject/address":57,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/pbkdf2":81,"@ethersproject/properties":82,"@ethersproject/strings":101,"aes-js":1}],75:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var crowdsale_1 = require("./crowdsale"); +exports.decryptCrowdsale = crowdsale_1.decrypt; +var inspect_1 = require("./inspect"); +exports.getJsonWalletAddress = inspect_1.getJsonWalletAddress; +exports.isCrowdsaleWallet = inspect_1.isCrowdsaleWallet; +exports.isKeystoreWallet = inspect_1.isKeystoreWallet; +var keystore_1 = require("./keystore"); +exports.decryptKeystore = keystore_1.decrypt; +exports.encryptKeystore = keystore_1.encrypt; +function decryptJsonWallet(json, password, progressCallback) { + if (inspect_1.isCrowdsaleWallet(json)) { + if (progressCallback) { + progressCallback(0); + } + var account = crowdsale_1.decrypt(json, password); + if (progressCallback) { + progressCallback(1); + } + return Promise.resolve(account); + } + if (inspect_1.isKeystoreWallet(json)) { + return keystore_1.decrypt(json, password, progressCallback); + } + return Promise.reject(new Error("invalid JSON wallet")); +} +exports.decryptJsonWallet = decryptJsonWallet; + +},{"./crowdsale":74,"./inspect":76,"./keystore":77}],76:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +function isCrowdsaleWallet(json) { + var data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + return (data.encseed && data.ethaddr); +} +exports.isCrowdsaleWallet = isCrowdsaleWallet; +function isKeystoreWallet(json) { + var data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { + return false; + } + // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff + return true; +} +exports.isKeystoreWallet = isKeystoreWallet; +//export function isJsonWallet(json: string): boolean { +// return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); +//} +function getJsonWalletAddress(json) { + if (isCrowdsaleWallet(json)) { + try { + return address_1.getAddress(JSON.parse(json).ethaddr); + } + catch (error) { + return null; + } + } + if (isKeystoreWallet(json)) { + try { + return address_1.getAddress(JSON.parse(json).address); + } + catch (error) { + return null; + } + } + return null; +} +exports.getJsonWalletAddress = getJsonWalletAddress; + +},{"@ethersproject/address":57}],77:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aes_js_1 = __importDefault(require("aes-js")); +var scrypt_js_1 = __importDefault(require("scrypt-js")); +var uuid_1 = __importDefault(require("uuid")); +var address_1 = require("@ethersproject/address"); +var bytes_1 = require("@ethersproject/bytes"); +var hdnode_1 = require("@ethersproject/hdnode"); +var keccak256_1 = require("@ethersproject/keccak256"); +var pbkdf2_1 = require("@ethersproject/pbkdf2"); +var random_1 = require("@ethersproject/random"); +var properties_1 = require("@ethersproject/properties"); +var transactions_1 = require("@ethersproject/transactions"); +var utils_1 = require("./utils"); +// Exported Types +var KeystoreAccount = /** @class */ (function (_super) { + __extends(KeystoreAccount, _super); + function KeystoreAccount() { + return _super !== null && _super.apply(this, arguments) || this; + } + KeystoreAccount.prototype.isType = function (value) { + return properties_1.Description.isType(value); + }; + return KeystoreAccount; +}(properties_1.Description)); +exports.KeystoreAccount = KeystoreAccount; +function decrypt(json, password, progressCallback) { + var data = JSON.parse(json); + var passwordBytes = utils_1.getPassword(password); + var decrypt = function (key, ciphertext) { + var cipher = utils_1.searchPath(data, "crypto/cipher"); + if (cipher === "aes-128-ctr") { + var iv = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/cipherparams/iv")); + var counter = new aes_js_1.default.Counter(iv); + var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter); + return bytes_1.arrayify(aesCtr.decrypt(ciphertext)); + } + return null; + }; + var computeMAC = function (derivedHalf, ciphertext) { + return keccak256_1.keccak256(bytes_1.concat([derivedHalf, ciphertext])); + }; + var getAccount = function (key, reject) { + var ciphertext = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/ciphertext")); + var computedMAC = bytes_1.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + if (computedMAC !== utils_1.searchPath(data, "crypto/mac").toLowerCase()) { + reject(new Error("invalid password")); + return null; + } + var privateKey = decrypt(key.slice(0, 16), ciphertext); + var mnemonicKey = key.slice(32, 64); + if (!privateKey) { + reject(new Error("unsupported cipher")); + return null; + } + var address = data.address.toLowerCase(); + if (address.substring(0, 2) !== "0x") { + address = "0x" + address; + } + try { + if (address_1.getAddress(address) !== transactions_1.computeAddress(privateKey)) { + reject(new Error("address mismatch")); + return null; + } + } + catch (e) { } + var account = { + address: address, + privateKey: bytes_1.hexlify(privateKey) + }; + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + if (utils_1.searchPath(data, "x-ethers/version") === "0.1") { + var mnemonicCiphertext = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCiphertext")); + var mnemonicIv = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCounter")); + var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); + var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + var path = utils_1.searchPath(data, "x-ethers/path") || hdnode_1.defaultPath; + var entropy = bytes_1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + var mnemonic = hdnode_1.entropyToMnemonic(entropy); + var node = hdnode_1.HDNode.fromMnemonic(mnemonic).derivePath(path); + if (node.privateKey != account.privateKey) { + reject(new Error("mnemonic mismatch")); + return null; + } + account.mnemonic = node.mnemonic; + account.path = node.path; + } + return new KeystoreAccount(account); + }; + return new Promise(function (resolve, reject) { + var kdf = utils_1.searchPath(data, "crypto/kdf"); + if (kdf && typeof (kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt")); + var N = parseInt(utils_1.searchPath(data, "crypto/kdfparams/n")); + var r = parseInt(utils_1.searchPath(data, "crypto/kdfparams/r")); + var p = parseInt(utils_1.searchPath(data, "crypto/kdfparams/p")); + if (!N || !r || !p) { + reject(new Error("unsupported key-derivation function parameters")); + return; + } + // Make sure N is a power of 2 + if ((N & (N - 1)) !== 0) { + reject(new Error("unsupported key-derivation function parameter value for N")); + return; + } + var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + if (progressCallback) { + progressCallback(0); + } + scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = bytes_1.arrayify(key); + var account = getAccount(key, reject); + if (!account) { + return; + } + if (progressCallback) { + progressCallback(1); + } + resolve(account); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + } + else if (kdf.toLowerCase() === "pbkdf2") { + var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt")); + var prfFunc = null; + var prf = utils_1.searchPath(data, "crypto/kdfparams/prf"); + if (prf === "hmac-sha256") { + prfFunc = "sha256"; + } + else if (prf === "hmac-sha512") { + prfFunc = "sha512"; + } + else { + reject(new Error("unsupported prf")); + return; + } + var c = parseInt(utils_1.searchPath(data, "crypto/kdfparams/c")); + var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + var key = bytes_1.arrayify(pbkdf2_1.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); + var account = getAccount(key, reject); + if (!account) { + return; + } + resolve(account); + } + else { + reject(new Error("unsupported key-derivation function")); + } + } + else { + reject(new Error("unsupported key-derivation function")); + } + }); +} +exports.decrypt = decrypt; +function encrypt(account, password, options, progressCallback) { + try { + if (address_1.getAddress(account.address) !== transactions_1.computeAddress(account.privateKey)) { + throw new Error("address/privateKey mismatch"); + } + if (account.mnemonic != null) { + var node = hdnode_1.HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || hdnode_1.defaultPath); + if (node.privateKey != account.privateKey) { + throw new Error("mnemonic mismatch"); + } + } + else if (account.path != null) { + throw new Error("cannot specify path without mnemonic"); + } + } + catch (e) { + return Promise.reject(e); + } + // the options are optional, so adjust the call as needed + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (!options) { + options = {}; + } + var privateKey = bytes_1.arrayify(account.privateKey); + var passwordBytes = utils_1.getPassword(password); + var entropy = null; + var path = account.path; + if (account.mnemonic) { + entropy = bytes_1.arrayify(hdnode_1.mnemonicToEntropy(account.mnemonic)); + if (!path) { + path = hdnode_1.defaultPath; + } + } + var client = options.client; + if (!client) { + client = "ethers.js"; + } + // Check/generate the salt + var salt = null; + if (options.salt) { + salt = bytes_1.arrayify(options.salt); + } + else { + salt = random_1.randomBytes(32); + ; + } + // Override initialization vector + var iv = null; + if (options.iv) { + iv = bytes_1.arrayify(options.iv); + if (iv.length !== 16) { + throw new Error("invalid iv"); + } + } + else { + iv = random_1.randomBytes(16); + } + // Override the uuid + var uuidRandom = null; + if (options.uuid) { + uuidRandom = bytes_1.arrayify(options.uuid); + if (uuidRandom.length !== 16) { + throw new Error("invalid uuid"); + } + } + else { + uuidRandom = random_1.randomBytes(16); + } + // Override the scrypt password-based key derivation function parameters + var N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { + N = options.scrypt.N; + } + if (options.scrypt.r) { + r = options.scrypt.r; + } + if (options.scrypt.p) { + p = options.scrypt.p; + } + } + return new Promise(function (resolve, reject) { + if (progressCallback) { + progressCallback(0); + } + // We take 64 bytes: + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = bytes_1.arrayify(key); + // This will be used to encrypt the wallet (as per Web3 secret storage) + var derivedKey = key.slice(0, 16); + var macPrefix = key.slice(16, 32); + // This will be used to encrypt the mnemonic phrase (if any) + var mnemonicKey = key.slice(32, 64); + // Encrypt the private key + var counter = new aes_js_1.default.Counter(iv); + var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter); + var ciphertext = bytes_1.arrayify(aesCtr.encrypt(privateKey)); + // Compute the message authentication code, used to check the password + var mac = keccak256_1.keccak256(bytes_1.concat([macPrefix, ciphertext])); + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + var data = { + address: account.address.substring(2).toLowerCase(), + id: uuid_1.default.v4({ random: uuidRandom }), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: bytes_1.hexlify(iv).substring(2), + }, + ciphertext: bytes_1.hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: bytes_1.hexlify(salt).substring(2), + n: N, + dklen: 32, + p: p, + r: r + }, + mac: mac.substring(2) + } + }; + // If we have a mnemonic, encrypt it into the JSON wallet + if (entropy) { + var mnemonicIv = random_1.randomBytes(16); + var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); + var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + var mnemonicCiphertext = bytes_1.arrayify(mnemonicAesCtr.encrypt(entropy)); + var now = new Date(); + var timestamp = (now.getUTCFullYear() + "-" + + utils_1.zpad(now.getUTCMonth() + 1, 2) + "-" + + utils_1.zpad(now.getUTCDate(), 2) + "T" + + utils_1.zpad(now.getUTCHours(), 2) + "-" + + utils_1.zpad(now.getUTCMinutes(), 2) + "-" + + utils_1.zpad(now.getUTCSeconds(), 2) + ".0Z"); + data["x-ethers"] = { + client: client, + gethFilename: ("UTC--" + timestamp + "--" + data.address), + mnemonicCounter: bytes_1.hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: bytes_1.hexlify(mnemonicCiphertext).substring(2), + path: path, + version: "0.1" + }; + } + if (progressCallback) { + progressCallback(1); + } + resolve(JSON.stringify(data)); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + }); +} +exports.encrypt = encrypt; + +},{"./utils":78,"@ethersproject/address":57,"@ethersproject/bytes":63,"@ethersproject/hdnode":73,"@ethersproject/keccak256":79,"@ethersproject/pbkdf2":81,"@ethersproject/properties":82,"@ethersproject/random":95,"@ethersproject/transactions":102,"aes-js":1,"scrypt-js":36,"uuid":39}],78:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +//import { Description } from "@ethersproject/properties"; +var strings_1 = require("@ethersproject/strings"); +/* +export class Account extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + +// static isAccount(value: any): value is Account { +// return Description._isType(value); +// } +} +//defineReadOnly(Account, "name", "Account"); +*/ +function looseArrayify(hexString) { + if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { + hexString = '0x' + hexString; + } + return bytes_1.arrayify(hexString); +} +exports.looseArrayify = looseArrayify; +function zpad(value, length) { + value = String(value); + while (value.length < length) { + value = '0' + value; + } + return value; +} +exports.zpad = zpad; +function getPassword(password) { + if (typeof (password) === 'string') { + return strings_1.toUtf8Bytes(password, strings_1.UnicodeNormalizationForm.NFKC); + } + return bytes_1.arrayify(password); +} +exports.getPassword = getPassword; +function searchPath(object, path) { + var currentChild = object; + var comps = path.toLowerCase().split('/'); + for (var i = 0; i < comps.length; i++) { + // Search for a child object with a case-insensitive matching key + var matchingChild = null; + for (var key in currentChild) { + if (key.toLowerCase() === comps[i]) { + matchingChild = currentChild[key]; + break; + } + } + // Didn't find one. :'( + if (matchingChild === null) { + return null; + } + // Now check this child... + currentChild = matchingChild; + } + return currentChild; +} +exports.searchPath = searchPath; + +},{"@ethersproject/bytes":63,"@ethersproject/strings":101}],79:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var sha3 = require("js-sha3"); +var bytes_1 = require("@ethersproject/bytes"); +function keccak256(data) { + return '0x' + sha3.keccak_256(bytes_1.arrayify(data)); +} +exports.keccak256 = keccak256; + +},{"@ethersproject/bytes":63,"js-sha3":33}],80:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +function ethDefaultProvider(network) { + return function (providers, options) { + if (options == null) { + options = {}; + } + var providerList = []; + if (providers.InfuraProvider) { + try { + providerList.push(new providers.InfuraProvider(network, options.infura)); + } + catch (error) { } + } + if (providers.EtherscanProvider) { + try { + providerList.push(new providers.EtherscanProvider(network, options.etherscan)); + } + catch (error) { } + } + if (providers.NodesmithProvider) { + try { + providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); + } + catch (error) { } + } + if (providers.AlchemyProvider) { + try { + providerList.push(new providers.AlchemyProvider(network, options.alchemy)); + } + catch (error) { } + } + if (providerList.length === 0) { + return null; + } + if (providers.FallbackProvider) { + return new providers.FallbackProvider(providerList); + ; + } + return providerList[0]; + }; +} +function etcDefaultProvider(url, network) { + return function (providers, options) { + if (providers.JsonRpcProvider) { + return new providers.JsonRpcProvider(url, network); + } + return null; + }; +} +var homestead = { + chainId: 1, + ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", + name: "homestead", + _defaultProvider: ethDefaultProvider("homestead") +}; +var ropsten = { + chainId: 3, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "ropsten", + _defaultProvider: ethDefaultProvider("ropsten") +}; +var networks = { + unspecified: { + chainId: 0, + name: "unspecified" + }, + homestead: homestead, + mainnet: homestead, + morden: { + chainId: 2, + name: "morden" + }, + ropsten: ropsten, + testnet: ropsten, + rinkeby: { + chainId: 4, + ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", + name: "rinkeby", + _defaultProvider: ethDefaultProvider("rinkeby") + }, + kovan: { + chainId: 42, + name: "kovan", + _defaultProvider: ethDefaultProvider("kovan") + }, + goerli: { + chainId: 5, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "goerli", + _defaultProvider: ethDefaultProvider("goerli") + }, + classic: { + chainId: 61, + name: "classic", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") + }, + classicTestnet: { + chainId: 62, + name: "classicTestnet", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") + } +}; +/** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ +function getNetwork(network) { + // No network (null) + if (network == null) { + return null; + } + if (typeof (network) === "number") { + for (var name_1 in networks) { + var standard_1 = networks[name_1]; + if (standard_1.chainId === network) { + return { + name: standard_1.name, + chainId: standard_1.chainId, + ensAddress: (standard_1.ensAddress || null), + _defaultProvider: (standard_1._defaultProvider || null) + }; + } + } + return { + chainId: network, + name: "unknown" + }; + } + if (typeof (network) === "string") { + var standard_2 = networks[network]; + if (standard_2 == null) { + return null; + } + return { + name: standard_2.name, + chainId: standard_2.chainId, + ensAddress: standard_2.ensAddress, + _defaultProvider: (standard_2._defaultProvider || null) + }; + } + var standard = networks[network.name]; + // Not a standard network; check that it is a valid network in general + if (!standard) { + if (typeof (network.chainId) !== "number") { + errors.throwError("invalid network chainId", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + return network; + } + // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) + if (network.chainId !== 0 && network.chainId !== standard.chainId) { + errors.throwError("network chainId mismatch", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + // Standard Network (allow overriding the ENS address) + return { + name: network.name, + chainId: standard.chainId, + ensAddress: (network.ensAddress || standard.ensAddress || null), + _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) + }; +} +exports.getNetwork = getNetwork; + +},{"@ethersproject/errors":66}],81:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var sha2_1 = require("@ethersproject/sha2"); +function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { + password = bytes_1.arrayify(password); + salt = bytes_1.arrayify(salt); + var hLen; + var l = 1; + var DK = new Uint8Array(keylen); + var block1 = new Uint8Array(salt.length + 4); + block1.set(salt); + //salt.copy(block1, 0, 0, salt.length) + var r; + var T; + for (var i = 1; i <= l; i++) { + //block1.writeUInt32BE(i, salt.length) + block1[salt.length] = (i >> 24) & 0xff; + block1[salt.length + 1] = (i >> 16) & 0xff; + block1[salt.length + 2] = (i >> 8) & 0xff; + block1[salt.length + 3] = i & 0xff; + //let U = createHmac(password).update(block1).digest(); + var U = bytes_1.arrayify(sha2_1.computeHmac(hashAlgorithm, password, block1)); + if (!hLen) { + hLen = U.length; + T = new Uint8Array(hLen); + l = Math.ceil(keylen / hLen); + r = keylen - (l - 1) * hLen; + } + //U.copy(T, 0, 0, hLen) + T.set(U); + for (var j = 1; j < iterations; j++) { + //U = createHmac(password).update(U).digest(); + U = bytes_1.arrayify(sha2_1.computeHmac(hashAlgorithm, password, U)); + for (var k = 0; k < hLen; k++) + T[k] ^= U[k]; + } + var destPos = (i - 1) * hLen; + var len = (i === l ? r : hLen); + //T.copy(DK, destPos, 0, len) + DK.set(bytes_1.arrayify(T).slice(0, len), destPos); + } + return bytes_1.hexlify(DK); +} +exports.pbkdf2 = pbkdf2; + +},{"@ethersproject/bytes":63,"@ethersproject/sha2":98}],82:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +function defineReadOnly(object, name, value) { + Object.defineProperty(object, name, { + enumerable: true, + value: value, + writable: false, + }); +} +exports.defineReadOnly = defineReadOnly; +// There are some issues with instanceof with npm link, so we use this +// to ensure types are what we expect. We use this for a little extra +// protection to make sure the correct types are being passed around. +function getType(object) { + var type = typeof (object); + if (type !== "function") { + return null; + } + var types = []; + var obj = object; + while (true) { + var type_1 = obj.name; + if (!type_1) { + break; + } + types.push(type_1); + obj = Object.getPrototypeOf(obj); + } + return types.join(" "); +} +function hasSuffix(text, suffix) { + return text.substring(text.length - suffix.length) === suffix; +} +function isNamedInstance(type, value) { + var name = getType(type); + if (!name) { + return false; + } + // Not a string... + if (typeof (value) !== "string") { + // Not an instance... + if (typeof (value) !== "object") { + return false; + } + // Get the instance type + value = getType(value.constructor); + } + return (name === value || hasSuffix(value, " " + name)); +} +exports.isNamedInstance = isNamedInstance; +function resolveProperties(object) { + var result = {}; + var promises = []; + Object.keys(object).forEach(function (key) { + var value = object[key]; + if (value instanceof Promise) { + promises.push(value.then(function (value) { + result[key] = value; + return null; + })); + } + else { + result[key] = value; + } + }); + return Promise.all(promises).then(function () { + return result; + }); +} +exports.resolveProperties = resolveProperties; +function checkProperties(object, properties) { + if (!object || typeof (object) !== "object") { + errors.throwError("invalid object", errors.INVALID_ARGUMENT, { + argument: "object", + value: object + }); + } + Object.keys(object).forEach(function (key) { + if (!properties[key]) { + errors.throwError("invalid object key - " + key, errors.INVALID_ARGUMENT, { + argument: "transaction", + value: object, + key: key + }); + } + }); +} +exports.checkProperties = checkProperties; +function shallowCopy(object) { + var result = {}; + for (var key in object) { + result[key] = object[key]; + } + return result; +} +exports.shallowCopy = shallowCopy; +var opaque = { boolean: true, number: true, string: true }; +function deepCopy(object, frozen) { + // Opaque objects are not mutable, so safe to copy by assignment + if (object === undefined || object === null || opaque[typeof (object)]) { + return object; + } + // Arrays are mutable, so we need to create a copy + if (Array.isArray(object)) { + var result = object.map(function (item) { return deepCopy(item, frozen); }); + if (frozen) { + Object.freeze(result); + } + return result; + } + if (typeof (object) === "object") { + // Some internal objects, which are already immutable + if (isNamedInstance("BigNumber", object)) { + return object; + } + if (isNamedInstance("Description", object)) { + return object; + } + if (isNamedInstance("Indexed", object)) { + return object; + } + var result = {}; + for (var key in object) { + var value = object[key]; + if (value === undefined) { + continue; + } + defineReadOnly(result, key, deepCopy(value, frozen)); + } + if (frozen) { + Object.freeze(result); + } + return result; + } + // The function type is also immutable, so safe to copy by assignment + if (typeof (object) === "function") { + return object; + } + throw new Error("Cannot deepCopy " + typeof (object)); +} +exports.deepCopy = deepCopy; +var Description = /** @class */ (function () { + function Description(info) { + for (var key in info) { + defineReadOnly(this, key, deepCopy(info[key], true)); + } + Object.freeze(this); + } + Description.isType = function (value) { + return isNamedInstance(this, value); + }; + return Description; +}()); +exports.Description = Description; + +},{"@ethersproject/errors":66}],83:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); +// This key was provided to ethers.js by Alchemy to be used by the +// default provider, but it is recommended that for your own +// production environments, that you acquire your own API key at: +// https://dashboard.alchemyapi.io +var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; +var AlchemyProvider = /** @class */ (function (_super) { + __extends(AlchemyProvider, _super); + function AlchemyProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlchemyProvider.getApiKey = function (apiKey) { + if (apiKey == null) { + return defaultApiKey; + } + return apiKey; + }; + AlchemyProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/jsonrpc/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/jsonrpc/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/jsonrpc/"; + break; + default: + errors.throwArgumentError("unsupported network", "network", arguments[0]); + } + return ("https:/" + "/" + host + apiKey); + }; + return AlchemyProvider; +}(url_json_rpc_provider_1.UrlJsonRpcProvider)); +exports.AlchemyProvider = AlchemyProvider; + +},{"./url-json-rpc-provider":93,"@ethersproject/errors":66}],84:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_provider_1 = require("@ethersproject/abstract-provider"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var hash_1 = require("@ethersproject/hash"); +var networks_1 = require("@ethersproject/networks"); +var properties_1 = require("@ethersproject/properties"); +var strings_1 = require("@ethersproject/strings"); +var web_1 = require("@ethersproject/web"); +var formatter_1 = require("./formatter"); +////////////////////////////// +// Event Serializeing +function checkTopic(topic) { + if (topic == null) { + return "null"; + } + if (bytes_1.hexDataLength(topic) !== 32) { + errors.throwArgumentError("invalid topic", "topic", topic); + } + return topic.toLowerCase(); +} +function serializeTopics(topics) { + // Remove trailing null AND-topics; they are redundant + topics = topics.slice(); + while (topics[topics.length - 1] == null) { + topics.pop(); + } + return topics.map(function (topic) { + if (Array.isArray(topic)) { + // Only track unique OR-topics + var unique_1 = {}; + topic.forEach(function (topic) { + unique_1[checkTopic(topic)] = true; + }); + // The order of OR-topics does not matter + var sorted = Object.keys(unique_1); + sorted.sort(); + return sorted.join("|"); + } + else { + return checkTopic(topic); + } + }).join("&"); +} +function deserializeTopics(data) { + return data.split(/&/g).map(function (topic) { + return topic.split("|").map(function (topic) { + return ((topic === "null") ? null : topic); + }); + }); +} +function getEventTag(eventName) { + if (typeof (eventName) === "string") { + eventName = eventName.toLowerCase(); + if (bytes_1.hexDataLength(eventName) === 32) { + return "tx:" + eventName; + } + if (eventName.indexOf(":") === -1) { + return eventName; + } + } + else if (Array.isArray(eventName)) { + return "filter:*:" + serializeTopics(eventName); + } + else if (properties_1.isNamedInstance(abstract_provider_1.ForkEvent, eventName)) { + errors.warn("not implemented"); + throw new Error("not implemented"); + } + else if (eventName && typeof (eventName) === "object") { + return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); + } + throw new Error("invalid event - " + eventName); +} +////////////////////////////// +// Helper Object +function getTime() { + return (new Date()).getTime(); +} +////////////////////////////// +// Provider Object +/** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ +var Event = /** @class */ (function () { + function Event(tag, listener, once) { + properties_1.defineReadOnly(this, "tag", tag); + properties_1.defineReadOnly(this, "listener", listener); + properties_1.defineReadOnly(this, "once", once); + } + Event.prototype.pollable = function () { + return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); + }; + return Event; +}()); +var defaultFormatter = null; +var nextPollId = 1; +var BaseProvider = /** @class */ (function (_super) { + __extends(BaseProvider, _super); + function BaseProvider(network) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, abstract_provider_1.Provider); + _this = _super.call(this) || this; + _this.formatter = _newTarget.getFormatter(); + if (network instanceof Promise) { + properties_1.defineReadOnly(_this, "ready", network.then(function (network) { + properties_1.defineReadOnly(_this, "_network", network); + return network; + })); + // Squash any "unhandled promise" errors; that do not need to be handled + _this.ready.catch(function (error) { }); + } + else { + var knownNetwork = networks_1.getNetwork((network == null) ? "homestead" : network); + if (knownNetwork) { + properties_1.defineReadOnly(_this, "_network", knownNetwork); + properties_1.defineReadOnly(_this, "ready", Promise.resolve(_this._network)); + } + else { + errors.throwError("invalid network", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + } + _this._lastBlockNumber = -2; + // Events being listened to + _this._events = []; + _this._pollingInterval = 4000; + _this._emitted = { block: -2 }; + _this._fastQueryDate = 0; + return _this; + } + BaseProvider.getFormatter = function () { + if (defaultFormatter == null) { + defaultFormatter = new formatter_1.Formatter(); + } + return defaultFormatter; + }; + BaseProvider.prototype.poll = function () { + var _this = this; + var pollId = nextPollId++; + this.emit("willPoll", pollId); + // Track all running promises, so we can trigger a post-poll once they are complete + var runners = []; + this.getBlockNumber().then(function (blockNumber) { + _this._setFastBlockNumber(blockNumber); + // If the block has not changed, meh. + if (blockNumber === _this._lastBlockNumber) { + return; + } + // First polling cycle, trigger a "block" events + if (_this._emitted.block === -2) { + _this._emitted.block = blockNumber - 1; + } + // Notify all listener for each block that has passed + for (var i = _this._emitted.block + 1; i <= blockNumber; i++) { + _this.emit("block", i); + } + // The emitted block was updated, check for obsolete events + if (_this._emitted.block !== blockNumber) { + _this._emitted.block = blockNumber; + Object.keys(_this._emitted).forEach(function (key) { + // The block event does not expire + if (key === "block") { + return; + } + // The block we were at when we emitted this event + var eventBlockNumber = _this._emitted[key]; + // We cannot garbage collect pending transactions or blocks here + // They should be garbage collected by the Provider when setting + // "pending" events + if (eventBlockNumber === "pending") { + return; + } + // Evict any transaction hashes or block hashes over 12 blocks + // old, since they should not return null anyways + if (blockNumber - eventBlockNumber > 12) { + delete _this._emitted[key]; + } + }); + } + // First polling cycle + if (_this._lastBlockNumber === -2) { + _this._lastBlockNumber = blockNumber - 1; + } + // Find all transaction hashes we are waiting on + _this._events.forEach(function (event) { + var comps = event.tag.split(":"); + switch (comps[0]) { + case "tx": { + var hash_2 = comps[1]; + var runner = _this.getTransactionReceipt(hash_2).then(function (receipt) { + if (!receipt || receipt.blockNumber == null) { + return null; + } + _this._emitted["t:" + hash_2] = receipt.blockNumber; + _this.emit(hash_2, receipt); + return null; + }).catch(function (error) { _this.emit("error", error); }); + runners.push(runner); + break; + } + case "filter": { + var topics = deserializeTopics(comps[2]); + var filter_1 = { + address: comps[1], + fromBlock: _this._lastBlockNumber + 1, + toBlock: blockNumber, + topics: topics + }; + if (!filter_1.address) { + delete filter_1.address; + } + var runner = _this.getLogs(filter_1).then(function (logs) { + if (logs.length === 0) { + return; + } + logs.forEach(function (log) { + _this._emitted["b:" + log.blockHash] = log.blockNumber; + _this._emitted["t:" + log.transactionHash] = log.blockNumber; + _this.emit(filter_1, log); + }); + return null; + }).catch(function (error) { _this.emit("error", error); }); + runners.push(runner); + break; + } + } + }); + _this._lastBlockNumber = blockNumber; + return null; + }).catch(function (error) { }); + Promise.all(runners).then(function () { + _this.emit("didPoll", pollId); + }); + }; + BaseProvider.prototype.resetEventsBlock = function (blockNumber) { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { + this.poll(); + } + }; + Object.defineProperty(BaseProvider.prototype, "network", { + get: function () { + return this._network; + }, + enumerable: true, + configurable: true + }); + BaseProvider.prototype.getNetwork = function () { + return this.ready; + }; + Object.defineProperty(BaseProvider.prototype, "blockNumber", { + get: function () { + return this._fastBlockNumber; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseProvider.prototype, "polling", { + get: function () { + return (this._poller != null); + }, + set: function (value) { + var _this = this; + setTimeout(function () { + if (value && !_this._poller) { + _this._poller = setInterval(_this.poll.bind(_this), _this.pollingInterval); + } + else if (!value && _this._poller) { + clearInterval(_this._poller); + _this._poller = null; + } + }, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseProvider.prototype, "pollingInterval", { + get: function () { + return this._pollingInterval; + }, + set: function (value) { + var _this = this; + if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); + } + this._pollingInterval = value; + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(function () { _this.poll(); }, this._pollingInterval); + } + }, + enumerable: true, + configurable: true + }); + BaseProvider.prototype._getFastBlockNumber = function () { + var _this = this; + var now = getTime(); + // Stale block number, request a newer value + if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then(function (blockNumber) { + if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) { + _this._fastBlockNumber = blockNumber; + } + return _this._fastBlockNumber; + }); + } + return this._fastBlockNumberPromise; + }; + BaseProvider.prototype._setFastBlockNumber = function (blockNumber) { + // Older block, maybe a stale request + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { + return; + } + // Update the time we updated the blocknumber + this._fastQueryDate = getTime(); + // Newer block number, use it + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + }; + // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; + // this will be used once we move to the WebSocket or other alternatives to polling + BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations) { + var _this = this; + if (confirmations == null) { + confirmations = 1; + } + if (confirmations === 0) { + return this.getTransactionReceipt(transactionHash); + } + return new Promise(function (resolve) { + var handler = function (receipt) { + if (receipt.confirmations < confirmations) { + return; + } + _this.removeListener(transactionHash, handler); + resolve(receipt); + }; + _this.on(transactionHash, handler); + }); + }; + BaseProvider.prototype._runPerform = function (method, params) { + var _this = this; + return this.ready.then(function () { + // Execute all the functions now that we are "ready" + Object.keys(params).forEach(function (key) { + params[key] = params[key](); + }); + return properties_1.resolveProperties(params).then(function (params) { + return _this.perform(method, params); + }); + }); + }; + BaseProvider.prototype.getBlockNumber = function () { + var _this = this; + return this._runPerform("getBlockNumber", {}).then(function (result) { + var value = parseInt(result); + if (value != result) { + throw new Error("invalid response - getBlockNumber"); + } + _this._setFastBlockNumber(value); + return value; + }); + }; + BaseProvider.prototype.getGasPrice = function () { + return this._runPerform("getGasPrice", {}).then(function (result) { + return bignumber_1.BigNumber.from(result); + }); + }; + BaseProvider.prototype.getBalance = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getBalance", { + address: function () { return _this.resolveName(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bignumber_1.BigNumber.from(result); + }); + }; + BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getTransactionCount", { + address: function () { return _this.resolveName(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bignumber_1.BigNumber.from(result).toNumber(); + }); + }; + BaseProvider.prototype.getCode = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getCode", { + address: function () { return _this.resolveName(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bytes_1.hexlify(result); + }); + }; + BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) { + var _this = this; + return this._runPerform("getStorageAt", { + address: function () { return _this.resolveName(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); }, + position: function () { return Promise.resolve(position).then(function (p) { return bytes_1.hexValue(p); }); } + }).then(function (result) { + return bytes_1.hexlify(result); + }); + }; + // This should be called by any subclass wrapping a TransactionResponse + BaseProvider.prototype._wrapTransaction = function (tx, hash) { + var _this = this; + if (hash != null && bytes_1.hexDataLength(hash) !== 32) { + throw new Error("invalid response - sendTransaction"); + } + var result = tx; + // Check the hash we expect is the same as the hash the server reported + if (hash != null && tx.hash !== hash) { + errors.throwError("Transaction hash mismatch from Provider.sendTransaction.", errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + // @TODO: (confirmations? number, timeout? number) + result.wait = function (confirmations) { + // We know this transaction *must* exist (whether it gets mined is + // another story), so setting an emitted value forces us to + // wait even if the node returns null for the receipt + if (confirmations !== 0) { + _this._emitted["t:" + tx.hash] = "pending"; + } + return _this.waitForTransaction(tx.hash, confirmations).then(function (receipt) { + if (receipt == null && confirmations === 0) { + return null; + } + // No longer pending, allow the polling loop to garbage collect this + _this._emitted["t:" + tx.hash] = receipt.blockNumber; + if (receipt.status === 0) { + errors.throwError("transaction failed", errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx + }); + } + return receipt; + }); + }; + return result; + }; + BaseProvider.prototype.sendTransaction = function (signedTransaction) { + var _this = this; + return this._runPerform("sendTransaction", { + signedTransaction: function () { return Promise.resolve(signedTransaction).then(function (t) { return bytes_1.hexlify(t); }); } + }).then(function (result) { + return _this._wrapTransaction(_this.formatter.transaction(signedTransaction), result); + }, function (error) { + error.transaction = _this.formatter.transaction(signedTransaction); + if (error.transaction.hash) { + error.transactionHash = error.transaction.hash; + } + throw error; + }); + }; + BaseProvider.prototype._getTransactionRequest = function (transaction) { + var _this = this; + return Promise.resolve(transaction).then(function (t) { + var tx = {}; + ["from", "to"].forEach(function (key) { + if (t[key] == null) { + return; + } + tx[key] = Promise.resolve(t[key]).then(function (a) { return (a ? _this.resolveName(a) : null); }); + }); + ["data", "gasLimit", "gasPrice", "value"].forEach(function (key) { + if (t[key] == null) { + return; + } + tx[key] = t[key]; + }); + return properties_1.resolveProperties(tx).then(function (t) { return _this.formatter.transactionRequest(t); }); + }); + }; + BaseProvider.prototype._getFilter = function (filter) { + var _this = this; + return Promise.resolve(filter).then(function (f) { + var filter = {}; + if (f.address != null) { + filter.address = _this.resolveName(f.address); + } + if (f.blockHash != null) { + filter.blockHash = f.blockHash; + } + ["fromBlock", "toBlock"].forEach(function (key) { + if (f[key] == null) { + return; + } + filter[key] = _this._getBlockTag(f[key]); + }); + return properties_1.resolveProperties(filter).then(function (f) { return _this.formatter.filter(f); }); + }); + }; + BaseProvider.prototype.call = function (transaction, blockTag) { + var _this = this; + return this._runPerform("call", { + transaction: function () { return _this._getTransactionRequest(transaction); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bytes_1.hexlify(result); + }); + }; + BaseProvider.prototype.estimateGas = function (transaction) { + var _this = this; + return this._runPerform("estimateGas", { + transaction: function () { return _this._getTransactionRequest(transaction); } + }).then(function (result) { + return bignumber_1.BigNumber.from(result); + }); + }; + BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) { + var _this = this; + return this.ready.then(function () { + return _this._getBlockTag(blockHashOrBlockTag).then(function (blockHashOrBlockTag) { + var params = { + includeTransactions: !!includeTransactions + }; + // Exactly one of blockHash or blockTag will be set + var blockHash = null; + var blockTag = null; + // If blockTag is a number (not "latest", etc), this is the block number + var blockNumber = -128; + if (bytes_1.isHexString(blockHashOrBlockTag, 32)) { + params.blockHash = blockHashOrBlockTag; + } + else { + try { + params.blockTag = _this.formatter.blockTag(blockHashOrBlockTag); + if (bytes_1.isHexString(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + } + catch (error) { + errors.throwError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + } + } + return web_1.poll(function () { + return _this.perform("getBlock", params).then(function (block) { + // Block was not found + if (block == null) { + // For blockhashes, if we didn't say it existed, that blockhash may + // not exist. If we did see it though, perhaps from a log, we know + // it exists, and this node is just not caught up yet. + if (blockHash) { + if (_this._emitted["b:" + blockHash] == null) { + return null; + } + } + // For block tags, if we are asking for a future block, we return null + if (blockTag) { + if (blockNumber > _this._emitted.block) { + return null; + } + } + // Retry on the next block + return undefined; + } + // Add transactions + if (includeTransactions) { + return _this.formatter.blockWithTransactions(block); + } + return _this.formatter.block(block); + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getBlock = function (blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, false)); + }; + BaseProvider.prototype.getBlockWithTransactions = function (blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, true)); + }; + BaseProvider.prototype.getTransaction = function (transactionHash) { + var _this = this; + return this.ready.then(function () { + return properties_1.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + var transactionHash = _a.transactionHash; + var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; + return web_1.poll(function () { + return _this.perform("getTransaction", params).then(function (result) { + if (result == null) { + if (_this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + var tx = _this.formatter.transactionResponse(result); + if (tx.blockNumber == null) { + tx.confirmations = 0; + } + else if (tx.confirmations == null) { + return _this._getFastBlockNumber().then(function (blockNumber) { + // Add the confirmations using the fast block number (pessimistic) + var confirmations = (blockNumber - tx.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + return _this._wrapTransaction(tx); + }); + } + return _this._wrapTransaction(tx); + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getTransactionReceipt = function (transactionHash) { + var _this = this; + return this.ready.then(function () { + return properties_1.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + var transactionHash = _a.transactionHash; + var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; + return web_1.poll(function () { + return _this.perform("getTransactionReceipt", params).then(function (result) { + if (result == null) { + if (_this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + // "geth-etc" returns receipts before they are ready + if (result.blockHash == null) { + return undefined; + } + var receipt = _this.formatter.receipt(result); + if (receipt.blockNumber == null) { + receipt.confirmations = 0; + } + else if (receipt.confirmations == null) { + return _this._getFastBlockNumber().then(function (blockNumber) { + // Add the confirmations using the fast block number (pessimistic) + var confirmations = (blockNumber - receipt.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + receipt.confirmations = confirmations; + return receipt; + }); + } + return receipt; + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getLogs = function (filter) { + var _this = this; + return this._runPerform("getLogs", { + filter: function () { return _this._getFilter(filter); } + }).then(function (result) { + return formatter_1.Formatter.arrayOf(_this.formatter.filterLog.bind(_this.formatter))(result); + }); + }; + BaseProvider.prototype.getEtherPrice = function () { + return this._runPerform("getEtherPrice", {}).then(function (result) { + return result; + }); + }; + BaseProvider.prototype._getBlockTag = function (blockTag) { + var _this = this; + if (blockTag instanceof Promise) { + return blockTag.then(function (b) { return _this._getBlockTag(b); }); + } + if (typeof (blockTag) === "number" && blockTag < 0) { + if (blockTag % 1) { + errors.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + return this._getFastBlockNumber().then(function (bn) { + bn += blockTag; + if (bn < 0) { + bn = 0; + } + return _this.formatter.blockTag(bn); + }); + } + return Promise.resolve(this.formatter.blockTag(blockTag)); + }; + BaseProvider.prototype._getResolver = function (name) { + var _this = this; + // Get the resolver from the blockchain + return this.getNetwork().then(function (network) { + // No ENS... + if (!network.ensAddress) { + errors.throwError("network does support ENS", errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + } + // keccak256("resolver(bytes32)") + var data = "0x0178b8bf" + hash_1.namehash(name).substring(2); + var transaction = { to: network.ensAddress, data: data }; + return _this.call(transaction).then(function (data) { + return _this.formatter.callAddress(data); + }); + }); + }; + BaseProvider.prototype.resolveName = function (name) { + var _this = this; + // If it is a promise, resolve it then recurse + if (name instanceof Promise) { + return name.then(function (addressOrName) { return _this.resolveName(addressOrName); }); + } + // If it is already an address, nothing to resolve + try { + return Promise.resolve(this.formatter.address(name)); + } + catch (error) { } + // Get the addr from the resovler + return this._getResolver(name).then(function (resolverAddress) { + if (!resolverAddress) { + return null; + } + // keccak256("addr(bytes32)") + var data = "0x3b3b57de" + hash_1.namehash(name).substring(2); + var transaction = { to: resolverAddress, data: data }; + return _this.call(transaction).then(function (data) { + return _this.formatter.callAddress(data); + }); + }); + }; + BaseProvider.prototype.lookupAddress = function (address) { + var _this = this; + if (address instanceof Promise) { + return address.then(function (address) { return _this.lookupAddress(address); }); + } + address = this.formatter.address(address); + var name = address.substring(2) + ".addr.reverse"; + return this._getResolver(name).then(function (resolverAddress) { + if (!resolverAddress) { + return null; + } + // keccak("name(bytes32)") + var data = "0x691f3431" + hash_1.namehash(name).substring(2); + return _this.call({ to: resolverAddress, data: data }).then(function (data) { + var bytes = bytes_1.arrayify(data); + // Strip off the dynamic string pointer (0x20) + if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) { + return null; + } + bytes = bytes.slice(32); + if (bytes.length < 32) { + return null; + } + var length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + if (length > bytes.length) { + return null; + } + var name = strings_1.toUtf8String(bytes.slice(0, length)); + // Make sure the reverse record matches the foward record + return _this.resolveName(name).then(function (addr) { + if (addr != address) { + return null; + } + return name; + }); + }); + }); + }; + BaseProvider.prototype.perform = function (method, params) { + return errors.throwError(method + " not implemented", errors.NOT_IMPLEMENTED, { operation: method }); + }; + BaseProvider.prototype._startPending = function () { + console.log("WARNING: this provider does not support pending events"); + }; + BaseProvider.prototype._stopPending = function () { + }; + // Returns true if there are events that still require polling + BaseProvider.prototype._checkPolling = function () { + this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0); + }; + BaseProvider.prototype._addEventListener = function (eventName, listener, once) { + this._events.push(new Event(getEventTag(eventName), listener, once)); + if (eventName === "pending") { + this._startPending(); + } + // Do we still now have any events that require polling? + this._checkPolling(); + return this; + }; + BaseProvider.prototype.on = function (eventName, listener) { + return this._addEventListener(eventName, listener, false); + }; + BaseProvider.prototype.once = function (eventName, listener) { + return this._addEventListener(eventName, listener, true); + }; + BaseProvider.prototype.emit = function (eventName) { + var _this = this; + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var result = false; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function (event) { + if (event.tag !== eventTag) { + return true; + } + setTimeout(function () { + event.listener.apply(_this, args); + }, 0); + result = true; + return !(event.once); + }); + // Do we still have any events that require polling? ("once" events remove themselves) + this._checkPolling(); + return result; + }; + BaseProvider.prototype.listenerCount = function (eventName) { + if (!eventName) { + return this._events.length; + } + var eventTag = getEventTag(eventName); + return this._events.filter(function (event) { + return (event.tag === eventTag); + }).length; + }; + BaseProvider.prototype.listeners = function (eventName) { + if (eventName == null) { + return this._events.map(function (event) { return event.listener; }); + } + var eventTag = getEventTag(eventName); + return this._events + .filter(function (event) { return (event.tag === eventTag); }) + .map(function (event) { return event.listener; }); + }; + BaseProvider.prototype.off = function (eventName, listener) { + if (listener == null) { + return this.removeAllListeners(eventName); + } + var found = false; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function (event) { + if (event.tag !== eventTag || event.listener != listener) { + return true; + } + if (found) { + return true; + } + found = true; + return false; + }); + if (eventName === "pending" && this.listenerCount("pending") === 0) { + this._stopPending(); + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + }; + BaseProvider.prototype.removeAllListeners = function (eventName) { + if (eventName == null) { + this._events = []; + this._stopPending(); + } + else { + var eventTag_1 = getEventTag(eventName); + this._events = this._events.filter(function (event) { + return (event.tag !== eventTag_1); + }); + if (eventName === "pending") { + this._stopPending(); + } + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + }; + return BaseProvider; +}(abstract_provider_1.Provider)); +exports.BaseProvider = BaseProvider; + +},{"./formatter":88,"@ethersproject/abstract-provider":55,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/networks":80,"@ethersproject/properties":82,"@ethersproject/strings":101,"@ethersproject/web":106}],85:[function(require,module,exports){ +"use strict"; +module.exports.IpcProvider = null; + +},{}],86:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var web_1 = require("@ethersproject/web"); +var base_provider_1 = require("./base-provider"); +// The transaction has already been sanitized by the calls in Provider +function getTransactionString(transaction) { + var result = []; + for (var key in transaction) { + if (transaction[key] == null) { + continue; + } + var value = bytes_1.hexlify(transaction[key]); + if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { + value = bytes_1.hexValue(value); + } + result.push(key + "=" + value); + } + return result.join("&"); +} +function getResult(result) { + // getLogs, getHistory have weird success responses + if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { + return result.result; + } + if (result.status != 1 || result.message != "OK") { + // @TODO: not any + var error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + return result.result; +} +function getJsonResult(result) { + if (result.jsonrpc != "2.0") { + // @TODO: not any + var error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + if (result.error) { + // @TODO: not any + var error = new Error(result.error.message || "unknown error"); + if (result.error.code) { + error.code = result.error.code; + } + if (result.error.data) { + error.data = result.error.data; + } + throw error; + } + return result.result; +} +// The blockTag was normalized as a string by the Provider pre-perform operations +function checkLogTag(blockTag) { + if (blockTag === "pending") { + throw new Error("pending not supported"); + } + if (blockTag === "latest") { + return blockTag; + } + return parseInt(blockTag.substring(2), 16); +} +var EtherscanProvider = /** @class */ (function (_super) { + __extends(EtherscanProvider, _super); + function EtherscanProvider(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, EtherscanProvider); + _this = _super.call(this, network) || this; + var name = "invalid"; + if (_this.network) { + name = _this.network.name; + } + var baseUrl = null; + switch (name) { + case "homestead": + baseUrl = "https://api.etherscan.io"; + break; + case "ropsten": + baseUrl = "https://api-ropsten.etherscan.io"; + break; + case "rinkeby": + baseUrl = "https://api-rinkeby.etherscan.io"; + break; + case "kovan": + baseUrl = "https://api-kovan.etherscan.io"; + break; + case "goerli": + baseUrl = "https://api-goerli.etherscan.io"; + break; + default: + throw new Error("unsupported network"); + } + properties_1.defineReadOnly(_this, "baseUrl", baseUrl); + properties_1.defineReadOnly(_this, "apiKey", apiKey); + return _this; + } + EtherscanProvider.prototype.perform = function (method, params) { + var _this = this; + var url = this.baseUrl; + var apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + var get = function (url, procFunc) { + return web_1.fetchJson(url, null, procFunc || getJsonResult).then(function (result) { + _this.emit("debug", { + action: "perform", + request: url, + response: result, + provider: _this + }); + return result; + }); + }; + switch (method) { + case "getBlockNumber": + url += "/api?module=proxy&action=eth_blockNumber" + apiKey; + return get(url); + case "getGasPrice": + url += "/api?module=proxy&action=eth_gasPrice" + apiKey; + return get(url); + case "getBalance": + // Returns base-10 result + url += "/api?module=account&action=balance&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getResult); + case "getTransactionCount": + url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url); + case "getCode": + url += "/api?module=proxy&action=eth_getCode&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "getStorageAt": + url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; + url += "&position=" + params.position; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "sendTransaction": + url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; + url += apiKey; + return get(url).catch(function (error) { + if (error.responseText) { + // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" + if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, {}); + } + // "Transaction with the same hash was already imported." + if (error.responseText.indexOf("same hash was already imported") >= 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, {}); + } + // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." + if (error.responseText.indexOf("another transaction with same nonce") >= 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; + if (params.includeTransactions) { + url += "&boolean=true"; + } + else { + url += "&boolean=false"; + } + url += apiKey; + return get(url); + } + throw new Error("getBlock by blockHash not implmeneted"); + case "getTransaction": + url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "getTransactionReceipt": + url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "call": { + var transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_call" + transaction; + //url += "&tag=" + params.blockTag + apiKey; + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + url += apiKey; + return get(url); + } + case "estimateGas": { + var transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_estimateGas&" + transaction; + url += apiKey; + return get(url); + } + case "getLogs": + url += "/api?module=logs&action=getLogs"; + try { + if (params.filter.fromBlock) { + url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); + } + if (params.filter.toBlock) { + url += "&toBlock=" + checkLogTag(params.filter.toBlock); + } + if (params.filter.address) { + url += "&address=" + params.filter.address; + } + // @TODO: We can handle slightly more complicated logs using the logs API + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + throw new Error("unsupported topic format"); + } + var topic0 = params.filter.topics[0]; + if (typeof (topic0) !== "string" || topic0.length !== 66) { + throw new Error("unsupported topic0 format"); + } + url += "&topic0=" + topic0; + } + } + catch (error) { + return Promise.reject(error); + } + url += apiKey; + var self_1 = this; + return get(url, getResult).then(function (logs) { + var txs = {}; + var seq = Promise.resolve(); + logs.forEach(function (log) { + seq = seq.then(function () { + if (log.blockHash != null) { + return null; + } + log.blockHash = txs[log.transactionHash]; + if (log.blockHash == null) { + return self_1.getTransaction(log.transactionHash).then(function (tx) { + txs[log.transactionHash] = tx.blockHash; + log.blockHash = tx.blockHash; + return null; + }); + } + return null; + }); + }); + return seq.then(function () { + return logs; + }); + }); + case "getEtherPrice": + if (this.network.name !== "homestead") { + return Promise.resolve(0.0); + } + url += "/api?module=stats&action=ethprice"; + url += apiKey; + return get(url, getResult).then(function (result) { + return parseFloat(result.ethusd); + }); + default: + break; + } + return _super.prototype.perform.call(this, method, params); + }; + // @TODO: Allow startBlock and endBlock to be Promises + EtherscanProvider.prototype.getHistory = function (addressOrName, startBlock, endBlock) { + var _this = this; + var url = this.baseUrl; + var apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + if (startBlock == null) { + startBlock = 0; + } + if (endBlock == null) { + endBlock = 99999999; + } + return this.resolveName(addressOrName).then(function (address) { + url += "/api?module=account&action=txlist&address=" + address; + url += "&startblock=" + startBlock; + url += "&endblock=" + endBlock; + url += "&sort=asc" + apiKey; + return web_1.fetchJson(url, null, getResult).then(function (result) { + _this.emit("debug", { + action: "getHistory", + request: url, + response: result, + provider: _this + }); + var output = []; + result.forEach(function (tx) { + ["contractAddress", "to"].forEach(function (key) { + if (tx[key] == "") { + delete tx[key]; + } + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + var item = _this.formatter.transactionResponse(tx); + if (tx.timeStamp) { + item.timestamp = parseInt(tx.timeStamp); + } + output.push(item); + }); + return output; + }); + }); + }; + return EtherscanProvider; +}(base_provider_1.BaseProvider)); +exports.EtherscanProvider = EtherscanProvider; + +},{"./base-provider":84,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/web":106}],87:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var random_1 = require("@ethersproject/random"); +var properties_1 = require("@ethersproject/properties"); +var base_provider_1 = require("./base-provider"); +function now() { return (new Date()).getTime(); } +// Returns: +// - true is all networks match +// - false if any network is null +// - throws if any 2 networks do not match +function checkNetworks(networks) { + var result = true; + var check = null; + networks.forEach(function (network) { + // Null + if (network == null) { + result = false; + return; + } + // Have nothing to compre to yet + if (check == null) { + check = network; + return; + } + // Matches! + if (check.name === network.name && + check.chainId === network.chainId && + ((check.ensAddress === network.ensAddress) || + (check.ensAddress == null && network.ensAddress == null))) { + return; + } + errors.throwError("provider mismatch", errors.INVALID_ARGUMENT, { arg: "networks", value: networks }); + }); + return result; +} +function serialize(result) { + if (Array.isArray(result)) { + return JSON.stringify(result.map(function (r) { return serialize(r); })); + } + else if (result === null) { + return "null"; + } + else if (typeof (result) === "object") { + var bare_1 = {}; + var keys = Object.keys(result); + keys.sort(); + keys.forEach(function (key) { + var value = result[key]; + if (typeof (value) === "function") { + return; + } + bare_1[key] = serialize(value); + }); + return JSON.stringify(bare_1); + } + return JSON.stringify(result); +} +var nextRid = 1; +var FallbackProvider = /** @class */ (function (_super) { + __extends(FallbackProvider, _super); + function FallbackProvider(providers, quorum, weights) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, FallbackProvider); + if (providers.length === 0) { + errors.throwArgumentError("missing providers", "providers", providers); + } + if (weights != null && weights.length !== providers.length) { + errors.throwArgumentError("too many weights", "weights", weights); + } + else if (!weights) { + weights = providers.map(function (p) { return 1; }); + } + else { + weights.forEach(function (w) { + if (w % 1 || w > 512 || w < 1) { + errors.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + } + }); + } + var total = weights.reduce(function (accum, w) { return (accum + w); }); + if (quorum == null) { + quorum = total / 2; + } + else { + if (quorum > total) { + errors.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + } + } + // All networks are ready, we can know the network for certain + var ready = checkNetworks(providers.map(function (p) { return p.network; })); + if (ready) { + _this = _super.call(this, providers[0].network) || this; + } + else { + // The network won't be known until all child providers know + var ready_1 = Promise.all(providers.map(function (p) { return p.getNetwork(); })).then(function (networks) { + if (!checkNetworks(networks)) { + errors.throwError("getNetwork returned null", errors.UNKNOWN_ERROR, {}); + } + return networks[0]; + }); + _this = _super.call(this, ready_1) || this; + } + // Preserve a copy, so we do not get mutated + properties_1.defineReadOnly(_this, "providers", Object.freeze(providers.slice())); + properties_1.defineReadOnly(_this, "quorum", quorum); + properties_1.defineReadOnly(_this, "weights", Object.freeze(weights.slice())); + return _this; + } + FallbackProvider.prototype.perform = function (method, params) { + var _this = this; + var T0 = now(); + var runners = (random_1.shuffled(this.providers)).map(function (provider, i) { + var weight = _this.weights[i]; + var rid = nextRid++; + return { + run: function () { + var t0 = now(); + var start = t0 - T0; + _this.emit("debug", "perform", rid, { weight: weight, start: start, provider: provider, method: method, params: params }); + return provider.perform(method, params).then(function (result) { + var duration = now() - t0; + _this.emit("debug", "result", rid, { duration: duration, result: result }); + return { weight: weight, result: result }; + }, function (error) { + var duration = now() - t0; + _this.emit("debug", "error", rid, { duration: duration, error: error }); + return { weight: weight, error: error }; + }); + }, + weight: weight + }; + }); + // Broadcast transactions to all backends, any that succeed is good enough + if (method === "sendTransaction") { + return Promise.all(runners.map(function (r) { return r.run(); })).then(function (results) { + for (var i = 0; i < results.length; i++) { + var result = results[i]; + if (result.result) { + return result.result; + } + } + return Promise.reject(results[0].error); + }); + } + // Otherwise query backends (randomly) until we have a quorum agreement + // on the correct result + return new Promise(function (resolve, reject) { + var firstError = null; + // How much weight is inflight + var inflightWeight = 0; + // All results, indexed by the serialized response. + var results = {}; + var next = function () { + if (runners.length === 0) { + return; + } + var runner = runners.shift(); + inflightWeight += runner.weight; + runner.run().then(function (result) { + if (results === null) { + return; + } + inflightWeight -= runner.weight; + if (result.error) { + if (firstError == null) { + firstError = result.error; + } + } + else { + var unique = serialize(result.result); + if (results[unique] == null) { + results[unique] = []; + } + results[unique].push(result); + // Do any results meet our quroum? + for (var u in results) { + var weight = results[u].reduce(function (accum, r) { return (accum + r.weight); }, 0); + if (weight >= _this.quorum) { + var result_1 = results[u][0].result; + _this.emit("debug", "quorum", -1, { weight: weight, result: result_1 }); + resolve(result_1); + results = null; + return; + } + } + } + // Out of options; give up + if (runners.length === 0 && inflightWeight === 0) { + reject(firstError); + return; + } + // Queue up the next round + setTimeout(next, 0); + }); + // Fire off requests until we could possibly meet quorum + if (inflightWeight < _this.quorum) { + setTimeout(next, 0); + return; + } + }; + // bootstrap firing requests + next(); + }); + }; + return FallbackProvider; +}(base_provider_1.BaseProvider)); +exports.FallbackProvider = FallbackProvider; + +},{"./base-provider":84,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/random":95}],88:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var constants_1 = require("@ethersproject/constants"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var transactions_1 = require("@ethersproject/transactions"); +var Formatter = /** @class */ (function () { + function Formatter() { + var _newTarget = this.constructor; + errors.checkNew(_newTarget, Formatter); + this.formats = this.getDefaultFormats(); + } + Formatter.prototype.getDefaultFormats = function () { + var _this = this; + var formats = ({}); + var address = this.address.bind(this); + var bigNumber = this.bigNumber.bind(this); + var blockTag = this.blockTag.bind(this); + var data = this.data.bind(this); + var hash = this.hash.bind(this); + var hex = this.hex.bind(this); + var number = this.number.bind(this); + var strictData = function (v) { return _this.data(v, true); }; + formats.transaction = { + hash: hash, + blockHash: Formatter.allowNull(hash, null), + blockNumber: Formatter.allowNull(number, null), + transactionIndex: Formatter.allowNull(number, null), + confirmations: Formatter.allowNull(number, null), + from: address, + gasPrice: bigNumber, + gasLimit: bigNumber, + to: Formatter.allowNull(address, null), + value: bigNumber, + nonce: number, + data: data, + r: Formatter.allowNull(this.uint256), + s: Formatter.allowNull(this.uint256), + v: Formatter.allowNull(number), + creates: Formatter.allowNull(address, null), + raw: Formatter.allowNull(data), + }; + formats.transactionRequest = { + from: Formatter.allowNull(address), + nonce: Formatter.allowNull(number), + gasLimit: Formatter.allowNull(bigNumber), + gasPrice: Formatter.allowNull(bigNumber), + to: Formatter.allowNull(address), + value: Formatter.allowNull(bigNumber), + data: Formatter.allowNull(strictData), + }; + formats.receiptLog = { + transactionLogIndex: Formatter.allowNull(number), + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address: address, + topics: Formatter.arrayOf(hash), + data: data, + logIndex: number, + blockHash: hash, + }; + formats.receipt = { + to: Formatter.allowNull(this.address), + from: Formatter.allowNull(this.address), + contractAddress: Formatter.allowNull(address, null), + transactionIndex: number, + root: Formatter.allowNull(hash), + gasUsed: bigNumber, + logsBloom: Formatter.allowNull(data), + blockHash: hash, + transactionHash: hash, + logs: Formatter.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter.allowNull(number, null), + cumulativeGasUsed: bigNumber, + status: Formatter.allowNull(number) + }; + formats.block = { + hash: hash, + parentHash: hash, + number: number, + timestamp: number, + nonce: Formatter.allowNull(hex), + difficulty: this.difficulty.bind(this), + gasLimit: bigNumber, + gasUsed: bigNumber, + miner: address, + extraData: data, + transactions: Formatter.allowNull(Formatter.arrayOf(hash)), + }; + formats.blockWithTransactions = properties_1.shallowCopy(formats.block); + formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); + formats.filter = { + fromBlock: Formatter.allowNull(blockTag, undefined), + toBlock: Formatter.allowNull(blockTag, undefined), + blockHash: Formatter.allowNull(hash, undefined), + address: Formatter.allowNull(address, undefined), + topics: Formatter.allowNull(this.topics.bind(this), undefined), + }; + formats.filterLog = { + blockNumber: Formatter.allowNull(number), + blockHash: Formatter.allowNull(hash), + transactionIndex: number, + removed: Formatter.allowNull(this.boolean.bind(this)), + address: address, + data: Formatter.allowFalsish(data, "0x"), + topics: Formatter.arrayOf(hash), + transactionHash: hash, + logIndex: number, + }; + return formats; + }; + // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number + // Strict! Used on input. + Formatter.prototype.number = function (number) { + return bignumber_1.BigNumber.from(number).toNumber(); + }; + // Strict! Used on input. + Formatter.prototype.bigNumber = function (value) { + return bignumber_1.BigNumber.from(value); + }; + // Requires a boolean, "true" or "false"; returns a boolean + Formatter.prototype.boolean = function (value) { + if (typeof (value) === "boolean") { + return value; + } + if (typeof (value) === "string") { + value = value.toLowerCase(); + if (value === "true") { + return true; + } + if (value === "false") { + return false; + } + } + throw new Error("invaid boolean - " + value); + }; + Formatter.prototype.hex = function (value, strict) { + if (typeof (value) === "string") { + if (!strict && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (bytes_1.isHexString(value)) { + return value.toLowerCase(); + } + } + return errors.throwError("invalid hash", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + }; + Formatter.prototype.data = function (value, strict) { + var result = this.hex(value, strict); + if ((result.length % 2) !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + }; + // Requires an address + // Strict! Used on input. + Formatter.prototype.address = function (value) { + return address_1.getAddress(value); + }; + Formatter.prototype.callAddress = function (value) { + if (!bytes_1.isHexString(value, 32)) { + return null; + } + var address = address_1.getAddress(bytes_1.hexDataSlice(value, 12)); + return (address === constants_1.AddressZero) ? null : address; + }; + Formatter.prototype.contractAddress = function (value) { + return address_1.getContractAddress(value); + }; + // Strict! Used on input. + Formatter.prototype.blockTag = function (blockTag) { + if (blockTag == null) { + return "latest"; + } + if (blockTag === "earliest") { + return "0x0"; + } + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + if (typeof (blockTag) === "number" || bytes_1.isHexString(blockTag)) { + return bytes_1.hexValue(blockTag); + } + throw new Error("invalid blockTag"); + }; + // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. + Formatter.prototype.hash = function (value, strict) { + var result = this.hex(value, strict); + if (bytes_1.hexDataLength(result) !== 32) { + return errors.throwError("invalid hash", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + } + return result; + }; + // Returns the difficulty as a number, or if too large (i.e. PoA network) null + Formatter.prototype.difficulty = function (value) { + var v = bignumber_1.BigNumber.from(value); + try { + return v.toNumber(); + } + catch (error) { } + return null; + }; + Formatter.prototype.uint256 = function (value) { + if (!bytes_1.isHexString(value)) { + throw new Error("invalid uint256"); + } + return bytes_1.hexZeroPad(value, 32); + }; + Formatter.prototype._block = function (value, format) { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + return Formatter.check(format, value); + }; + Formatter.prototype.block = function (value) { + return this._block(value, this.formats.block); + }; + Formatter.prototype.blockWithTransactions = function (value) { + return this._block(value, this.formats.blockWithTransactions); + }; + // Strict! Used on input. + Formatter.prototype.transactionRequest = function (value) { + return Formatter.check(this.formats.transactionRequest, value); + }; + Formatter.prototype.transactionResponse = function (transaction) { + // Rename gas to gasLimit + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + // Rename input to data + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + // If to and creates are empty, populate the creates from the transaction + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + // @TODO: use transaction.serialize? Have to add support for including v, r, and s... + /* + if (!transaction.raw) { + + // Very loose providers (e.g. TestRPC) do not provide a signature or raw + if (transaction.v && transaction.r && transaction.s) { + let raw = [ + stripZeros(hexlify(transaction.nonce)), + stripZeros(hexlify(transaction.gasPrice)), + stripZeros(hexlify(transaction.gasLimit)), + (transaction.to || "0x"), + stripZeros(hexlify(transaction.value || "0x")), + hexlify(transaction.data || "0x"), + stripZeros(hexlify(transaction.v || "0x")), + stripZeros(hexlify(transaction.r)), + stripZeros(hexlify(transaction.s)), + ]; + + transaction.raw = rlpEncode(raw); + } + } + */ + var result = Formatter.check(this.formats.transaction, transaction); + var networkId = transaction.networkId; + // geth-etc returns chainId + if (transaction.chainId != null && networkId == null && result.v == null) { + networkId = transaction.chainId; + } + if (bytes_1.isHexString(networkId)) { + networkId = bignumber_1.BigNumber.from(networkId).toNumber(); + } + if (typeof (networkId) !== "number" && result.v != null) { + networkId = (result.v - 35) / 2; + if (networkId < 0) { + networkId = 0; + } + networkId = parseInt(networkId); + } + if (typeof (networkId) !== "number") { + networkId = 0; + } + result.networkId = networkId; + // 0x0000... should actually be null + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + return result; + }; + Formatter.prototype.transaction = function (value) { + return transactions_1.parse(value); + }; + Formatter.prototype.receiptLog = function (value) { + return Formatter.check(this.formats.receiptLog, value); + }; + Formatter.prototype.receipt = function (value) { + //let status = transactionReceipt.status; + //let root = transactionReceipt.root; + var result = Formatter.check(this.formats.receipt, value); + result.logs.forEach(function (entry, index) { + if (entry.transactionLogIndex == null) { + entry.transactionLogIndex = index; + } + }); + if (value.status != null) { + result.byzantium = true; + } + return result; + }; + Formatter.prototype.topics = function (value) { + var _this = this; + if (Array.isArray(value)) { + return value.map(function (v) { return _this.topics(v); }); + } + else if (value != null) { + return this.hash(value, true); + } + return null; + }; + Formatter.prototype.filter = function (value) { + return Formatter.check(this.formats.filter, value); + }; + Formatter.prototype.filterLog = function (value) { + return Formatter.check(this.formats.filterLog, value); + }; + Formatter.check = function (format, object) { + var result = {}; + for (var key in format) { + try { + var value = format[key](object[key]); + if (value !== undefined) { + result[key] = value; + } + } + catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; + } + } + return result; + }; + // if value is null-ish, nullValue is returned + Formatter.allowNull = function (format, nullValue) { + return (function (value) { + if (value == null) { + return nullValue; + } + return format(value); + }); + }; + // If value is false-ish, replaceValue is returned + Formatter.allowFalsish = function (format, replaceValue) { + return (function (value) { + if (!value) { + return replaceValue; + } + return format(value); + }); + }; + // Requires an Array satisfying check + Formatter.arrayOf = function (format) { + return (function (array) { + if (!Array.isArray(array)) { + throw new Error("not an array"); + } + var result = []; + array.forEach(function (value) { + result.push(format(value)); + }); + return result; + }); + }; + return Formatter; +}()); +exports.Formatter = Formatter; + +},{"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/transactions":102}],89:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_provider_1 = require("@ethersproject/abstract-provider"); +exports.Provider = abstract_provider_1.Provider; +var networks_1 = require("@ethersproject/networks"); +exports.getNetwork = networks_1.getNetwork; +var base_provider_1 = require("./base-provider"); +exports.BaseProvider = base_provider_1.BaseProvider; +var alchemy_provider_1 = require("./alchemy-provider"); +exports.AlchemyProvider = alchemy_provider_1.AlchemyProvider; +var etherscan_provider_1 = require("./etherscan-provider"); +exports.EtherscanProvider = etherscan_provider_1.EtherscanProvider; +var fallback_provider_1 = require("./fallback-provider"); +exports.FallbackProvider = fallback_provider_1.FallbackProvider; +var ipc_provider_1 = require("./ipc-provider"); +exports.IpcProvider = ipc_provider_1.IpcProvider; +var infura_provider_1 = require("./infura-provider"); +exports.InfuraProvider = infura_provider_1.InfuraProvider; +var json_rpc_provider_1 = require("./json-rpc-provider"); +exports.JsonRpcProvider = json_rpc_provider_1.JsonRpcProvider; +exports.JsonRpcSigner = json_rpc_provider_1.JsonRpcSigner; +var nodesmith_provider_1 = require("./nodesmith-provider"); +exports.NodesmithProvider = nodesmith_provider_1.NodesmithProvider; +var web3_provider_1 = require("./web3-provider"); +exports.Web3Provider = web3_provider_1.Web3Provider; + +},{"./alchemy-provider":83,"./base-provider":84,"./etherscan-provider":86,"./fallback-provider":87,"./infura-provider":90,"./ipc-provider":85,"./json-rpc-provider":91,"./nodesmith-provider":92,"./web3-provider":94,"@ethersproject/abstract-provider":55,"@ethersproject/networks":80}],90:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); +var defaultProjectId = "84842078b09946638c03157f83405213"; +var InfuraProvider = /** @class */ (function (_super) { + __extends(InfuraProvider, _super); + function InfuraProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(InfuraProvider.prototype, "projectId", { + get: function () { return this.apiKey; }, + enumerable: true, + configurable: true + }); + InfuraProvider.getApiKey = function (apiKey) { + if (apiKey == null) { + return defaultProjectId; + } + if (!bytes_1.isHexString(apiKey, 16)) { + errors.throwArgumentError("invalid projectId", "projectId", apiKey); + } + return apiKey; + }; + InfuraProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + default: + errors.throwError("unsupported network", errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + return "https://" + host + "/v3/" + apiKey; + }; + return InfuraProvider; +}(url_json_rpc_provider_1.UrlJsonRpcProvider)); +exports.InfuraProvider = InfuraProvider; + +},{"./url-json-rpc-provider":93,"@ethersproject/bytes":63,"@ethersproject/errors":66}],91:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_signer_1 = require("@ethersproject/abstract-signer"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var networks_1 = require("@ethersproject/networks"); +var properties_1 = require("@ethersproject/properties"); +var strings_1 = require("@ethersproject/strings"); +var web_1 = require("@ethersproject/web"); +var base_provider_1 = require("./base-provider"); +function timer(timeout) { + return new Promise(function (resolve) { + setTimeout(function () { + resolve(); + }, timeout); + }); +} +function getResult(payload) { + if (payload.error) { + // @TODO: not any + var error = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; + throw error; + } + return payload.result; +} +function getLowerCase(value) { + if (value) { + return value.toLowerCase(); + } + return value; +} +var _constructorGuard = {}; +var JsonRpcSigner = /** @class */ (function (_super) { + __extends(JsonRpcSigner, _super); + function JsonRpcSigner(constructorGuard, provider, addressOrIndex) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, JsonRpcSigner); + _this = _super.call(this) || this; + if (constructorGuard !== _constructorGuard) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + properties_1.defineReadOnly(_this, "provider", provider); + // Statically attach to a given address + if (addressOrIndex == null) { + addressOrIndex = 0; + } + if (addressOrIndex) { + if (typeof (addressOrIndex) === "string") { + properties_1.defineReadOnly(_this, "_address", _this.provider.formatter.address(addressOrIndex)); + properties_1.defineReadOnly(_this, "_index", null); + } + else if (typeof (addressOrIndex) === "number") { + properties_1.defineReadOnly(_this, "_index", addressOrIndex); + properties_1.defineReadOnly(_this, "_address", null); + } + else { + errors.throwError("invalid address or index", errors.INVALID_ARGUMENT, { argument: "addressOrIndex", value: addressOrIndex }); + } + } + return _this; + } + JsonRpcSigner.prototype.connect = function (provider) { + return errors.throwError("cannot alter JSON-RPC Signer connection", errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + }; + JsonRpcSigner.prototype.connectUnchecked = function () { + return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); + }; + JsonRpcSigner.prototype.getAddress = function () { + var _this = this; + if (this._address) { + return Promise.resolve(this._address); + } + return this.provider.send("eth_accounts", []).then(function (accounts) { + if (accounts.length <= _this._index) { + errors.throwError("unknown account #" + _this._index, errors.UNSUPPORTED_OPERATION, { operation: "getAddress" }); + } + return _this.provider.formatter.address(accounts[_this._index]); + }); + }; + JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) { + var _this = this; + transaction = properties_1.shallowCopy(transaction); + var fromAddress = this.getAddress().then(function (address) { + if (address) { + address = address.toLowerCase(); + } + return address; + }); + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (transaction.gasLimit == null) { + var estimate = properties_1.shallowCopy(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + return Promise.all([ + properties_1.resolveProperties(transaction), + fromAddress + ]).then(function (results) { + var tx = results[0]; + var hexTx = _this.constructor.hexlifyTransaction(tx); + hexTx.from = results[1]; + return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) { + return hash; + }, function (error) { + if (error.responseText) { + // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) + if (error.responseText.indexOf("insufficient funds") >= 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, { + transaction: tx + }); + } + if (error.responseText.indexOf("nonce too low") >= 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, { + transaction: tx + }); + } + if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, { + transaction: tx + }); + } + } + throw error; + }); + }); + }; + JsonRpcSigner.prototype.signTransaction = function (transaction) { + return errors.throwError("signing transactions is unsupported", errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + }; + JsonRpcSigner.prototype.sendTransaction = function (transaction) { + var _this = this; + return this.sendUncheckedTransaction(transaction).then(function (hash) { + return web_1.poll(function () { + return _this.provider.getTransaction(hash).then(function (tx) { + if (tx === null) { + return undefined; + } + return _this.provider._wrapTransaction(tx, hash); + }); + }, { onceBlock: _this.provider }).catch(function (error) { + error.transactionHash = hash; + throw error; + }); + }); + }; + JsonRpcSigner.prototype.signMessage = function (message) { + var _this = this; + var data = ((typeof (message) === "string") ? strings_1.toUtf8Bytes(message) : message); + return this.getAddress().then(function (address) { + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + return _this.provider.send("eth_sign", [address.toLowerCase(), bytes_1.hexlify(data)]); + }); + }; + JsonRpcSigner.prototype.unlock = function (password) { + var provider = this.provider; + return this.getAddress().then(function (address) { + return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); + }); + }; + return JsonRpcSigner; +}(abstract_signer_1.Signer)); +exports.JsonRpcSigner = JsonRpcSigner; +var UncheckedJsonRpcSigner = /** @class */ (function (_super) { + __extends(UncheckedJsonRpcSigner, _super); + function UncheckedJsonRpcSigner() { + return _super !== null && _super.apply(this, arguments) || this; + } + UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) { + var _this = this; + return this.sendUncheckedTransaction(transaction).then(function (hash) { + return { + hash: hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: function (confirmations) { return _this.provider.waitForTransaction(hash, confirmations); } + }; + }); + }; + return UncheckedJsonRpcSigner; +}(JsonRpcSigner)); +var allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +var JsonRpcProvider = /** @class */ (function (_super) { + __extends(JsonRpcProvider, _super); + function JsonRpcProvider(url, network) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, JsonRpcProvider); + // One parameter, but it is a network name, so swap it with the URL + if (typeof (url) === "string") { + if (network === null && networks_1.getNetwork(url)) { + network = url; + url = null; + } + } + if (network) { + // The network has been specified explicitly, we can use it + _this = _super.call(this, network) || this; + } + else { + // The network is unknown, query the JSON-RPC for it + var ready = new Promise(function (resolve, reject) { + setTimeout(function () { + _this.send("eth_chainId", []).then(function (result) { + resolve(networks_1.getNetwork(bignumber_1.BigNumber.from(result).toNumber())); + }).catch(function (error) { + _this.send("net_version", []).then(function (result) { + resolve(networks_1.getNetwork(bignumber_1.BigNumber.from(result).toNumber())); + }).catch(function (error) { + reject(errors.makeError("could not detect network", errors.NETWORK_ERROR, {})); + }); + }); + }); + }); + _this = _super.call(this, ready) || this; + } + // Default URL + if (!url) { + url = "http:/" + "/localhost:8545"; + } + if (typeof (url) === "string") { + _this.connection = { + url: url + }; + } + else { + _this.connection = url; + } + return _this; + } + JsonRpcProvider.prototype.getSigner = function (addressOrIndex) { + return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); + }; + JsonRpcProvider.prototype.getUncheckedSigner = function (addressOrIndex) { + return this.getSigner(addressOrIndex).connectUnchecked(); + }; + JsonRpcProvider.prototype.listAccounts = function () { + var _this = this; + return this.send("eth_accounts", []).then(function (accounts) { + return accounts.map(function (a) { return _this.formatter.address(a); }); + }); + }; + JsonRpcProvider.prototype.send = function (method, params) { + var _this = this; + var request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + return web_1.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) { + _this.emit("debug", { + action: "send", + request: request, + response: result, + provider: _this + }); + return result; + }); + }; + JsonRpcProvider.prototype.perform = function (method, params) { + switch (method) { + case "getBlockNumber": + return this.send("eth_blockNumber", []); + case "getGasPrice": + return this.send("eth_gasPrice", []); + case "getBalance": + return this.send("eth_getBalance", [getLowerCase(params.address), params.blockTag]); + case "getTransactionCount": + return this.send("eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]); + case "getCode": + return this.send("eth_getCode", [getLowerCase(params.address), params.blockTag]); + case "getStorageAt": + return this.send("eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]); + case "sendTransaction": + return this.send("eth_sendRawTransaction", [params.signedTransaction]).catch(function (error) { + if (error.responseText) { + // "insufficient funds for gas * price + value" + if (error.responseText.indexOf("insufficient funds") > 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, {}); + } + // "nonce too low" + if (error.responseText.indexOf("nonce too low") > 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, {}); + } + // "replacement transaction underpriced" + if (error.responseText.indexOf("replacement transaction underpriced") > 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + return this.send("eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]); + } + else if (params.blockHash) { + return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); + } + return Promise.reject(new Error("invalid block tag or block hash")); + case "getTransaction": + return this.send("eth_getTransactionByHash", [params.transactionHash]); + case "getTransactionReceipt": + return this.send("eth_getTransactionReceipt", [params.transactionHash]); + case "call": + return this.send("eth_call", [this.constructor.hexlifyTransaction(params.transaction, { from: true }), params.blockTag]); + case "estimateGas": + return this.send("eth_estimateGas", [this.constructor.hexlifyTransaction(params.transaction, { from: true })]); + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return this.send("eth_getLogs", [params.filter]); + default: + break; + } + return errors.throwError(method + " not implemented", errors.NOT_IMPLEMENTED, { operation: method }); + }; + JsonRpcProvider.prototype._startPending = function () { + if (this._pendingFilter != null) { + return; + } + var self = this; + var pendingFilter = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + pendingFilter.then(function (filterId) { + function poll() { + self.send("eth_getFilterChanges", [filterId]).then(function (hashes) { + if (self._pendingFilter != pendingFilter) { + return null; + } + var seq = Promise.resolve(); + hashes.forEach(function (hash) { + // @TODO: This should be garbage collected at some point... How? When? + self._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function () { + return self.getTransaction(hash).then(function (tx) { + self.emit("pending", tx); + return null; + }); + }); + }); + return seq.then(function () { + return timer(1000); + }); + }).then(function () { + if (self._pendingFilter != pendingFilter) { + self.send("eth_uninstallFilter", [filterId]); + return; + } + setTimeout(function () { poll(); }, 0); + return null; + }).catch(function (error) { }); + } + poll(); + return filterId; + }).catch(function (error) { }); + }; + JsonRpcProvider.prototype._stopPending = function () { + this._pendingFilter = null; + }; + // Convert an ethers.js transaction into a JSON-RPC transaction + // - gasLimit => gas + // - All values hexlified + // - All numeric values zero-striped + // NOTE: This allows a TransactionRequest, but all values should be resolved + // before this is called + JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) { + // Check only allowed properties are given + var allowed = properties_1.shallowCopy(allowedTransactionKeys); + if (allowExtra) { + for (var key in allowExtra) { + if (allowExtra[key]) { + allowed[key] = true; + } + } + } + properties_1.checkProperties(transaction, allowed); + var result = {}; + // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. + ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + var value = bytes_1.hexValue(transaction[key]); + if (key === "gasLimit") { + key = "gas"; + } + result[key] = value; + }); + ["from", "to", "data"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + result[key] = bytes_1.hexlify(transaction[key]); + }); + return result; + }; + return JsonRpcProvider; +}(base_provider_1.BaseProvider)); +exports.JsonRpcProvider = JsonRpcProvider; + +},{"./base-provider":84,"@ethersproject/abstract-signer":56,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/networks":80,"@ethersproject/properties":82,"@ethersproject/strings":101,"@ethersproject/web":106}],92:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); +// Special API key provided by Nodesmith for ethers.js +var defaultApiKey = "ETHERS_JS_SHARED"; +var NodesmithProvider = /** @class */ (function (_super) { + __extends(NodesmithProvider, _super); + function NodesmithProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + NodesmithProvider.getApiKey = function (apiKey) { + return apiKey || defaultApiKey; + }; + NodesmithProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + errors.throwArgumentError("unsupported network", "network", arguments[0]); + } + return (host + "?apiKey=" + apiKey); + }; + return NodesmithProvider; +}(url_json_rpc_provider_1.UrlJsonRpcProvider)); +exports.NodesmithProvider = NodesmithProvider; + +},{"./url-json-rpc-provider":93,"@ethersproject/errors":66}],93:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var networks_1 = require("@ethersproject/networks"); +var properties_1 = require("@ethersproject/properties"); +var json_rpc_provider_1 = require("./json-rpc-provider"); +var UrlJsonRpcProvider = /** @class */ (function (_super) { + __extends(UrlJsonRpcProvider, _super); + function UrlJsonRpcProvider(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + errors.checkAbstract(_newTarget, UrlJsonRpcProvider); + network = networks_1.getNetwork((network == null) ? "homestead" : network); + apiKey = _newTarget.getApiKey(apiKey); + var url = _newTarget.getUrl(network, apiKey); + _this = _super.call(this, url, network) || this; + properties_1.defineReadOnly(_this, "apiKey", apiKey); + return _this; + } + UrlJsonRpcProvider.prototype._startPending = function () { + errors.warn("WARNING: API provider does not support pending filters"); + }; + UrlJsonRpcProvider.prototype.getSigner = function (address) { + errors.throwError("API provider does not support signing", errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + return null; + }; + UrlJsonRpcProvider.prototype.listAccounts = function () { + return Promise.resolve([]); + }; + // Return a defaultApiKey if null, otherwise validate the API key + UrlJsonRpcProvider.getApiKey = function (apiKey) { + return apiKey; + }; + // Returns the url for the given network and API key + UrlJsonRpcProvider.getUrl = function (network, apiKey) { + return errors.throwError("not implemented; sub-classes must override getUrl", errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + }; + return UrlJsonRpcProvider; +}(json_rpc_provider_1.JsonRpcProvider)); +exports.UrlJsonRpcProvider = UrlJsonRpcProvider; + +},{"./json-rpc-provider":91,"@ethersproject/errors":66,"@ethersproject/networks":80,"@ethersproject/properties":82}],94:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var json_rpc_provider_1 = require("./json-rpc-provider"); +/* +@TODO +utils.defineProperty(Web3Signer, "onchange", { + +}); + +*/ +var Web3Provider = /** @class */ (function (_super) { + __extends(Web3Provider, _super); + function Web3Provider(web3Provider, network) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, Web3Provider); + // HTTP has a host; IPC has a path. + _this = _super.call(this, web3Provider.host || web3Provider.path || "", network) || this; + if (web3Provider) { + if (web3Provider.sendAsync) { + _this._sendAsync = web3Provider.sendAsync.bind(web3Provider); + } + else if (web3Provider.send) { + _this._sendAsync = web3Provider.send.bind(web3Provider); + } + } + if (!web3Provider || !_this._sendAsync) { + errors.throwError("invalid web3Provider", errors.INVALID_ARGUMENT, { arg: "web3Provider", value: web3Provider }); + } + properties_1.defineReadOnly(_this, "_web3Provider", web3Provider); + return _this; + } + Web3Provider.prototype.send = function (method, params) { + var _this = this; + // Metamask complains about eth_sign (and on some versions hangs) + if (method == "eth_sign" && this._web3Provider.isMetaMask) { + // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + method = "personal_sign"; + params = [params[1], params[0]]; + } + return new Promise(function (resolve, reject) { + var request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + _this._sendAsync(request, function (error, result) { + if (error) { + reject(error); + return; + } + if (result.error) { + // @TODO: not any + var error_1 = new Error(result.error.message); + error_1.code = result.error.code; + error_1.data = result.error.data; + reject(error_1); + return; + } + resolve(result.result); + }); + }); + }; + return Web3Provider; +}(json_rpc_provider_1.JsonRpcProvider)); +exports.Web3Provider = Web3Provider; + +},{"./json-rpc-provider":91,"@ethersproject/errors":66,"@ethersproject/properties":82}],95:[function(require,module,exports){ +(function (global){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var shuffle_1 = require("./shuffle"); +exports.shuffled = shuffle_1.shuffled; +var crypto = global.crypto || global.msCrypto; +if (!crypto || !crypto.getRandomValues) { + errors.warn("WARNING: Missing strong random number source"); + crypto = { + getRandomValues: function (buffer) { + return errors.throwError("no secure random source avaialble", errors.UNSUPPORTED_OPERATION, { + operation: "crypto.getRandomValues" + }); + } + }; +} +function randomBytes(length) { + if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { + errors.throwError("invalid length", errors.INVALID_ARGUMENT, { + argument: "length", + value: length + }); + } + var result = new Uint8Array(length); + crypto.getRandomValues(result); + return bytes_1.arrayify(result); +} +exports.randomBytes = randomBytes; +; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./shuffle":96,"@ethersproject/bytes":63,"@ethersproject/errors":66}],96:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function shuffled(array) { + array = array.slice(); + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + return array; +} +exports.shuffled = shuffled; + +},{}],97:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//See: https://github.com/ethereum/wiki/wiki/RLP +var bytes_1 = require("@ethersproject/bytes"); +function arrayifyInteger(value) { + var result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; +} +function unarrayifyInteger(data, offset, length) { + var result = 0; + for (var i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; +} +function _encode(object) { + if (Array.isArray(object)) { + var payload_1 = []; + object.forEach(function (child) { + payload_1 = payload_1.concat(_encode(child)); + }); + if (payload_1.length <= 55) { + payload_1.unshift(0xc0 + payload_1.length); + return payload_1; + } + var length_1 = arrayifyInteger(payload_1.length); + length_1.unshift(0xf7 + length_1.length); + return length_1.concat(payload_1); + } + var data = Array.prototype.slice.call(bytes_1.arrayify(object)); + if (data.length === 1 && data[0] <= 0x7f) { + return data; + } + else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + var length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + return length.concat(data); +} +function encode(object) { + return bytes_1.hexlify(_encode(object)); +} +exports.encode = encode; +function _decodeChildren(data, offset, childOffset, length) { + var result = []; + while (childOffset < offset + 1 + length) { + var decoded = _decode(data, childOffset); + result.push(decoded.result); + childOffset += decoded.consumed; + if (childOffset > offset + 1 + length) { + throw new Error("invalid rlp"); + } + } + return { consumed: (1 + length), result: result }; +} +// returns { consumed: number, result: Object } +function _decode(data, offset) { + if (data.length === 0) { + throw new Error("invalid rlp data"); + } + // Array with extra length prefix + if (data[offset] >= 0xf8) { + var lengthLength = data[offset] - 0xf7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("too short"); + } + var length_2 = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length_2 > data.length) { + throw new Error("to short"); + } + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length_2); + } + else if (data[offset] >= 0xc0) { + var length_3 = data[offset] - 0xc0; + if (offset + 1 + length_3 > data.length) { + throw new Error("invalid rlp data"); + } + return _decodeChildren(data, offset, offset + 1, length_3); + } + else if (data[offset] >= 0xb8) { + var lengthLength = data[offset] - 0xb7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("invalid rlp data"); + } + var length_4 = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length_4 > data.length) { + throw new Error("invalid rlp data"); + } + var result = bytes_1.hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4)); + return { consumed: (1 + lengthLength + length_4), result: result }; + } + else if (data[offset] >= 0x80) { + var length_5 = data[offset] - 0x80; + if (offset + 1 + length_5 > data.length) { + throw new Error("invlaid rlp data"); + } + var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length_5)); + return { consumed: (1 + length_5), result: result }; + } + return { consumed: 1, result: bytes_1.hexlify(data[offset]) }; +} +function decode(data) { + var bytes = bytes_1.arrayify(data); + var decoded = _decode(bytes, 0); + if (decoded.consumed !== bytes.length) { + throw new Error("invalid rlp data"); + } + return decoded.result; +} +exports.decode = decode; + +},{"@ethersproject/bytes":63}],98:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hash = __importStar(require("hash.js")); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var SupportedAlgorithms; +(function (SupportedAlgorithms) { + SupportedAlgorithms["sha256"] = "sha256"; + SupportedAlgorithms["sha512"] = "sha512"; +})(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); +; +function ripemd160(data) { + return "0x" + (hash.ripemd160().update(bytes_1.arrayify(data)).digest("hex")); +} +exports.ripemd160 = ripemd160; +function sha256(data) { + return "0x" + (hash.sha256().update(bytes_1.arrayify(data)).digest("hex")); +} +exports.sha256 = sha256; +function sha512(data) { + return "0x" + (hash.sha512().update(bytes_1.arrayify(data)).digest("hex")); +} +exports.sha512 = sha512; +function computeHmac(algorithm, key, data) { + if (!SupportedAlgorithms[algorithm]) { + errors.throwError("unsupported algorithm " + algorithm, errors.UNSUPPORTED_OPERATION, { + operation: "hmac", + algorithm: algorithm + }); + } + return "0x" + hash.hmac(hash[algorithm], bytes_1.arrayify(key)).update(bytes_1.arrayify(data)).digest(); +} +exports.computeHmac = computeHmac; + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"hash.js":20}],99:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var elliptic_1 = require("elliptic"); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var _curve = null; +function getCurve() { + if (!_curve) { + _curve = new elliptic_1.ec("secp256k1"); + } + return _curve; +} +var SigningKey = /** @class */ (function () { + function SigningKey(privateKey) { + properties_1.defineReadOnly(this, "curve", "secp256k1"); + properties_1.defineReadOnly(this, "privateKey", bytes_1.hexlify(privateKey)); + var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); + properties_1.defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + properties_1.defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + } + SigningKey.prototype._addPoint = function (other) { + var p0 = getCurve().keyFromPublic(bytes_1.arrayify(this.publicKey)); + var p1 = getCurve().keyFromPublic(bytes_1.arrayify(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + }; + SigningKey.prototype.signDigest = function (digest) { + var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); + var signature = keyPair.sign(bytes_1.arrayify(digest), { canonical: true }); + return bytes_1.splitSignature({ + recoveryParam: signature.recoveryParam, + r: bytes_1.hexZeroPad("0x" + signature.r.toString(16), 32), + s: bytes_1.hexZeroPad("0x" + signature.s.toString(16), 32), + }); + }; + SigningKey.prototype.computeSharedSecret = function (otherKey) { + var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); + var otherKeyPair = getCurve().keyFromPublic(bytes_1.arrayify(computePublicKey(otherKey))); + return bytes_1.hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + }; + return SigningKey; +}()); +exports.SigningKey = SigningKey; +function recoverPublicKey(digest, signature) { + var sig = bytes_1.splitSignature(signature); + var rs = { r: bytes_1.arrayify(sig.r), s: bytes_1.arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(bytes_1.arrayify(digest), rs, sig.recoveryParam).encode("hex", false); +} +exports.recoverPublicKey = recoverPublicKey; +function computePublicKey(key, compressed) { + var bytes = bytes_1.arrayify(key); + if (bytes.length === 32) { + var signingKey = new SigningKey(bytes); + if (compressed) { + return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); + } + return signingKey.publicKey; + } + else if (bytes.length === 33) { + if (compressed) { + return bytes_1.hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); + } + else if (bytes.length === 65) { + if (!compressed) { + return bytes_1.hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); + } + return errors.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +exports.computePublicKey = computePublicKey; + +},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,"elliptic":5}],100:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var keccak256_1 = require("@ethersproject/keccak256"); +var sha2_1 = require("@ethersproject/sha2"); +var strings_1 = require("@ethersproject/strings"); +var regexBytes = new RegExp("^bytes([0-9]+)$"); +var regexNumber = new RegExp("^(u?int)([0-9]*)$"); +var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); +var Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; +function _pack(type, value, isArray) { + switch (type) { + case "address": + if (isArray) { + return bytes_1.zeroPad(value, 32); + } + return bytes_1.arrayify(value); + case "string": + return strings_1.toUtf8Bytes(value); + case "bytes": + return bytes_1.arrayify(value); + case "bool": + value = (value ? "0x01" : "0x00"); + if (isArray) { + return bytes_1.zeroPad(value, 32); + } + return bytes_1.arrayify(value); + } + var match = type.match(regexNumber); + if (match) { + //let signed = (match[1] === "int") + var size = parseInt(match[2] || "256"); + if ((size % 8 != 0) || size === 0 || size > 256) { + throw new Error("invalid number type - " + type); + } + if (isArray) { + size = 256; + } + value = bignumber_1.BigNumber.from(value).toTwos(size); + return bytes_1.zeroPad(value, size / 8); + } + match = type.match(regexBytes); + if (match) { + var size = parseInt(match[1]); + if (String(size) != match[1] || size === 0 || size > 32) { + throw new Error("invalid number type - " + type); + } + if (bytes_1.arrayify(value).byteLength !== size) { + throw new Error("invalid value for " + type); + } + if (isArray) { + return bytes_1.arrayify((value + Zeros).substring(0, 66)); + } + return value; + } + match = type.match(regexArray); + if (match && Array.isArray(value)) { + var baseType_1 = match[1]; + var count = parseInt(match[2] || String(value.length)); + if (count != value.length) { + throw new Error("invalid value for " + type); + } + var result_1 = []; + value.forEach(function (value) { + result_1.push(_pack(baseType_1, value, true)); + }); + return bytes_1.concat(result_1); + } + throw new Error("unknown type - " + type); +} +// @TODO: Array Enum +function pack(types, values) { + if (types.length != values.length) { + throw new Error("type/value count mismatch"); + } + var tight = []; + types.forEach(function (type, index) { + tight.push(_pack(type, values[index])); + }); + return bytes_1.hexlify(bytes_1.concat(tight)); +} +exports.pack = pack; +function keccak256(types, values) { + return keccak256_1.keccak256(pack(types, values)); +} +exports.keccak256 = keccak256; +function sha256(types, values) { + return sha2_1.sha256(pack(types, values)); +} +exports.sha256 = sha256; + +},{"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/keccak256":79,"@ethersproject/sha2":98,"@ethersproject/strings":101}],101:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var constants_1 = require("@ethersproject/constants"); +var errors_1 = require("@ethersproject/errors"); +var bytes_1 = require("@ethersproject/bytes"); +/////////////////////////////// +var UnicodeNormalizationForm; +(function (UnicodeNormalizationForm) { + UnicodeNormalizationForm["current"] = ""; + UnicodeNormalizationForm["NFC"] = "NFC"; + UnicodeNormalizationForm["NFD"] = "NFD"; + UnicodeNormalizationForm["NFKC"] = "NFKC"; + UnicodeNormalizationForm["NFKD"] = "NFKD"; +})(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {})); +; +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +function toUtf8Bytes(str, form) { + if (form === void 0) { form = UnicodeNormalizationForm.current; } + if (form != UnicodeNormalizationForm.current) { + errors_1.checkNormalize(); + str = str.normalize(form); + } + var result = []; + for (var i = 0; i < str.length; i++) { + var c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + var c2 = str.charCodeAt(i); + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + // Surrogate Pair + c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((c >> 18) | 0xf0); + result.push(((c >> 12) & 0x3f) | 0x80); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return bytes_1.arrayify(result); +} +exports.toUtf8Bytes = toUtf8Bytes; +; +// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 +function toUtf8String(bytes, ignoreErrors) { + bytes = bytes_1.arrayify(bytes); + var result = ""; + var i = 0; + // Invalid bytes are ignored + while (i < bytes.length) { + var c = bytes[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result += String.fromCharCode(c); + continue; + } + // Multibyte; how many bytes left for this character? + var extraLength = null; + var overlongMask = null; + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + // 1110 xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + } + else { + if (!ignoreErrors) { + if ((c & 0xc0) === 0x80) { + throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); + } + throw new Error("invalid utf8 byte sequence; invalid prefix"); + } + continue; + } + // Do we have enough bytes in our data? + if (i + extraLength > bytes.length) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; too short"); + } + // If there is an invalid unprocessed byte, skip continuation bytes + for (; i < bytes.length; i++) { + if (bytes[i] >> 6 !== 0x02) { + break; + } + } + continue; + } + // Remove the length prefix from the char + var res = c & ((1 << (8 - extraLength - 1)) - 1); + for (var j = 0; j < extraLength; j++) { + var nextChar = bytes[i]; + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + res = null; + break; + } + ; + res = (res << 6) | (nextChar & 0x3f); + i++; + } + if (res === null) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; invalid continuation byte"); + } + continue; + } + // Check for overlong seuences (more bytes than needed) + if (res <= overlongMask) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; overlong"); + } + continue; + } + // Maximum code point + if (res > 0x10ffff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; out-of-range"); + } + continue; + } + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); + } + continue; + } + if (res <= 0xffff) { + result += String.fromCharCode(res); + continue; + } + res -= 0x10000; + result += String.fromCharCode(((res >> 10) & 0x3ff) + 0xd800, (res & 0x3ff) + 0xdc00); + } + return result; +} +exports.toUtf8String = toUtf8String; +function formatBytes32String(text) { + // Get the bytes + var bytes = toUtf8Bytes(text); + // Check we have room for null-termination + if (bytes.length > 31) { + throw new Error("bytes32 string must be less than 32 bytes"); + } + // Zero-pad (implicitly null-terminates) + return bytes_1.hexlify(bytes_1.concat([bytes, constants_1.HashZero]).slice(0, 32)); +} +exports.formatBytes32String = formatBytes32String; +function parseBytes32String(bytes) { + var data = bytes_1.arrayify(bytes); + // Must be 32 bytes with a null-termination + if (data.length !== 32) { + throw new Error("invalid bytes32 - not 32 bytes long"); + } + if (data[31] !== 0) { + throw new Error("invalid bytes32 sdtring - no null terminator"); + } + // Find the null termination + var length = 31; + while (data[length - 1] === 0) { + length--; + } + // Determine the string value + return toUtf8String(data.slice(0, length)); +} +exports.parseBytes32String = parseBytes32String; + +},{"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66}],102:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var bignumber_1 = require("@ethersproject/bignumber"); +var bytes_1 = require("@ethersproject/bytes"); +var constants_1 = require("@ethersproject/constants"); +var errors = __importStar(require("@ethersproject/errors")); +var keccak256_1 = require("@ethersproject/keccak256"); +var properties_1 = require("@ethersproject/properties"); +var RLP = __importStar(require("@ethersproject/rlp")); +var signing_key_1 = require("@ethersproject/signing-key"); +/////////////////////////////// +function handleAddress(value) { + if (value === "0x") { + return null; + } + return address_1.getAddress(value); +} +function handleNumber(value) { + if (value === "0x") { + return constants_1.Zero; + } + return bignumber_1.BigNumber.from(value); +} +var transactionFields = [ + { name: "nonce", maxLength: 32 }, + { name: "gasPrice", maxLength: 32 }, + { name: "gasLimit", maxLength: 32 }, + { name: "to", length: 20 }, + { name: "value", maxLength: 32 }, + { name: "data" }, +]; +var allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +function computeAddress(key) { + var publicKey = signing_key_1.computePublicKey(key); + return address_1.getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.hexDataSlice(publicKey, 1)), 12)); +} +exports.computeAddress = computeAddress; +function recoverAddress(digest, signature) { + return computeAddress(signing_key_1.recoverPublicKey(bytes_1.arrayify(digest), signature)); +} +exports.recoverAddress = recoverAddress; +function serialize(transaction, signature) { + properties_1.checkProperties(transaction, allowedTransactionKeys); + var raw = []; + transactionFields.forEach(function (fieldInfo) { + var value = transaction[fieldInfo.name] || ([]); + value = bytes_1.arrayify(bytes_1.hexlify(value)); + // Fixed-width field + if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { + errors.throwError("invalid length for " + fieldInfo.name, errors.INVALID_ARGUMENT, { arg: ("transaction" + fieldInfo.name), value: value }); + } + // Variable-width (with a maximum) + if (fieldInfo.maxLength) { + value = bytes_1.stripZeros(value); + if (value.length > fieldInfo.maxLength) { + errors.throwError("invalid length for " + fieldInfo.name, errors.INVALID_ARGUMENT, { arg: ("transaction" + fieldInfo.name), value: value }); + } + } + raw.push(bytes_1.hexlify(value)); + }); + if (transaction.chainId != null && transaction.chainId !== 0) { + raw.push(bytes_1.hexlify(transaction.chainId)); + raw.push("0x"); + raw.push("0x"); + } + var unsignedTransaction = RLP.encode(raw); + // Requesting an unsigned transation + if (!signature) { + return unsignedTransaction; + } + // The splitSignature will ensure the transaction has a recoveryParam in the + // case that the signTransaction function only adds a v. + var sig = bytes_1.splitSignature(signature); + // We pushed a chainId and null r, s on for hashing only; remove those + var v = 27 + sig.recoveryParam; + if (raw.length === 9) { + raw.pop(); + raw.pop(); + raw.pop(); + v += transaction.chainId * 2 + 8; + } + raw.push(bytes_1.hexlify(v)); + raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.r))); + raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.s))); + return RLP.encode(raw); +} +exports.serialize = serialize; +function parse(rawTransaction) { + var transaction = RLP.decode(rawTransaction); + if (transaction.length !== 9 && transaction.length !== 6) { + errors.throwError("invalid raw transaction", errors.INVALID_ARGUMENT, { arg: "rawTransactin", value: rawTransaction }); + } + var tx = { + nonce: handleNumber(transaction[0]).toNumber(), + gasPrice: handleNumber(transaction[1]), + gasLimit: handleNumber(transaction[2]), + to: handleAddress(transaction[3]), + value: handleNumber(transaction[4]), + data: transaction[5], + chainId: 0 + }; + // Legacy unsigned transaction + if (transaction.length === 6) { + return tx; + } + try { + tx.v = bignumber_1.BigNumber.from(transaction[6]).toNumber(); + } + catch (error) { + console.log(error); + return tx; + } + tx.r = bytes_1.hexZeroPad(transaction[7], 32); + tx.s = bytes_1.hexZeroPad(transaction[8], 32); + if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) { + // EIP-155 unsigned transaction + tx.chainId = tx.v; + tx.v = 0; + } + else { + // Signed Tranasaction + tx.chainId = Math.floor((tx.v - 35) / 2); + if (tx.chainId < 0) { + tx.chainId = 0; + } + var recoveryParam = tx.v - 27; + var raw = transaction.slice(0, 6); + if (tx.chainId !== 0) { + raw.push(bytes_1.hexlify(tx.chainId)); + raw.push("0x"); + raw.push("0x"); + recoveryParam -= tx.chainId * 2 + 8; + } + var digest = keccak256_1.keccak256(RLP.encode(raw)); + try { + tx.from = recoverAddress(digest, { r: bytes_1.hexlify(tx.r), s: bytes_1.hexlify(tx.s), recoveryParam: recoveryParam }); + } + catch (error) { + console.log(error); + } + tx.hash = keccak256_1.keccak256(rawTransaction); + } + return tx; +} +exports.parse = parse; + +},{"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/properties":82,"@ethersproject/rlp":97,"@ethersproject/signing-key":99}],103:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var fixednumber_1 = require("@ethersproject/bignumber/fixednumber"); +var errors = __importStar(require("@ethersproject/errors")); +var names = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", +]; +// Some environments have issues with RegEx that contain back-tracking, so we cannot +// use them. +function commify(value) { + var comps = String(value).split("."); + if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { + errors.throwError("invalid value", errors.INVALID_ARGUMENT, { argument: "value", value: value }); + } + // Make sure we have at least one whole digit (0 if none) + var whole = comps[0]; + var negative = ""; + if (whole.substring(0, 1) === "-") { + negative = "-"; + whole = whole.substring(1); + } + // Make sure we have at least 1 whole digit with no leading zeros + while (whole.substring(0, 1) === "0") { + whole = whole.substring(1); + } + if (whole === "") { + whole = "0"; + } + var suffix = ""; + if (comps.length === 2) { + suffix = "." + (comps[1] || "0"); + } + var formatted = []; + while (whole.length) { + if (whole.length <= 3) { + formatted.unshift(whole); + break; + } + else { + var index = whole.length - 3; + formatted.unshift(whole.substring(index)); + whole = whole.substring(0, index); + } + } + return negative + formatted.join(",") + suffix; +} +exports.commify = commify; +function formatUnits(value, unitName) { + if (typeof (unitName) === "string") { + var index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber_1.formatFixed(value, (unitName != null) ? unitName : 18); +} +exports.formatUnits = formatUnits; +function parseUnits(value, unitName) { + if (typeof (unitName) === "string") { + var index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber_1.parseFixed(value, (unitName != null) ? unitName : 18); +} +exports.parseUnits = parseUnits; +function formatEther(wei) { + return formatUnits(wei, 18); +} +exports.formatEther = formatEther; +function parseEther(ether) { + return parseUnits(ether, 18); +} +exports.parseEther = parseEther; + +},{"@ethersproject/bignumber/fixednumber":61,"@ethersproject/errors":66}],104:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var abstract_provider_1 = require("@ethersproject/abstract-provider"); +var abstract_signer_1 = require("@ethersproject/abstract-signer"); +var bytes_1 = require("@ethersproject/bytes"); +var errors = __importStar(require("@ethersproject/errors")); +var hash_1 = require("@ethersproject/hash"); +var hdnode_1 = require("@ethersproject/hdnode"); +var keccak256_1 = require("@ethersproject/keccak256"); +var properties_1 = require("@ethersproject/properties"); +var random_1 = require("@ethersproject/random"); +var signing_key_1 = require("@ethersproject/signing-key"); +var json_wallets_1 = require("@ethersproject/json-wallets"); +var transactions_1 = require("@ethersproject/transactions"); +function isAccount(value) { + return (value != null && bytes_1.isHexString(value.privateKey, 32) && value.address != null); +} +var Wallet = /** @class */ (function (_super) { + __extends(Wallet, _super); + function Wallet(privateKey, provider) { + var _newTarget = this.constructor; + var _this = this; + errors.checkNew(_newTarget, Wallet); + _this = _super.call(this) || this; + if (isAccount(privateKey)) { + var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey); + properties_1.defineReadOnly(_this, "_signingKey", function () { return signingKey_1; }); + properties_1.defineReadOnly(_this, "address", transactions_1.computeAddress(_this.publicKey)); + if (_this.address !== address_1.getAddress(privateKey.address)) { + errors.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + } + if (privateKey.mnemonic != null) { + var mnemonic_1 = privateKey.mnemonic; + var path = privateKey.path || hdnode_1.defaultPath; + properties_1.defineReadOnly(_this, "_mnemonic", function () { return mnemonic_1; }); + properties_1.defineReadOnly(_this, "path", privateKey.path); + var node = hdnode_1.HDNode.fromMnemonic(mnemonic_1).derivePath(path); + if (transactions_1.computeAddress(node.privateKey) !== _this.address) { + errors.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + } + } + else { + properties_1.defineReadOnly(_this, "_mnemonic", function () { return null; }); + properties_1.defineReadOnly(_this, "path", null); + } + } + else { + if (properties_1.isNamedInstance(signing_key_1.SigningKey, privateKey)) { + properties_1.defineReadOnly(_this, "_signingKey", function () { return privateKey; }); + } + else { + var signingKey_2 = new signing_key_1.SigningKey(privateKey); + properties_1.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; }); + } + properties_1.defineReadOnly(_this, "_mnemonic", function () { return null; }); + properties_1.defineReadOnly(_this, "path", null); + properties_1.defineReadOnly(_this, "address", transactions_1.computeAddress(_this.publicKey)); + } + if (provider && !properties_1.isNamedInstance(abstract_provider_1.Provider, provider)) { + errors.throwError("invalid provider", errors.INVALID_ARGUMENT, { + argument: "provider", + value: provider + }); + } + properties_1.defineReadOnly(_this, "provider", provider || null); + return _this; + } + Object.defineProperty(Wallet.prototype, "mnemonic", { + get: function () { return this._mnemonic(); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Wallet.prototype, "privateKey", { + get: function () { return this._signingKey().privateKey; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Wallet.prototype, "publicKey", { + get: function () { return this._signingKey().publicKey; }, + enumerable: true, + configurable: true + }); + Wallet.prototype.getAddress = function () { + return Promise.resolve(this.address); + }; + Wallet.prototype.connect = function (provider) { + return new Wallet(this, provider); + }; + Wallet.prototype.signTransaction = function (transaction) { + var _this = this; + return properties_1.resolveProperties(transaction).then(function (tx) { + if (tx.from != null) { + if (address_1.getAddress(tx.from) !== _this.address) { + throw new Error("transaction from address mismatch"); + } + delete tx.from; + } + var signature = _this._signingKey().signDigest(keccak256_1.keccak256(transactions_1.serialize(tx))); + return transactions_1.serialize(tx, signature); + }); + }; + Wallet.prototype.signMessage = function (message) { + return Promise.resolve(bytes_1.joinSignature(this._signingKey().signDigest(hash_1.hashMessage(message)))); + }; + Wallet.prototype.encrypt = function (password, options, progressCallback) { + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (progressCallback && typeof (progressCallback) !== "function") { + throw new Error("invalid callback"); + } + if (!options) { + options = {}; + } + return json_wallets_1.encryptKeystore(this, password, options, progressCallback); + }; + /** + * Static methods to create Wallet instances. + */ + Wallet.createRandom = function (options) { + var entropy = random_1.randomBytes(16); + if (!options) { + options = {}; + } + if (options.extraEntropy) { + entropy = bytes_1.arrayify(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.concat([entropy, options.extraEntropy])), 0, 16)); + } + var mnemonic = hdnode_1.entropyToMnemonic(entropy, options.locale); + return Wallet.fromMnemonic(mnemonic, options.path, options.locale); + }; + Wallet.fromEncryptedJson = function (json, password, progressCallback) { + return json_wallets_1.decryptJsonWallet(json, password, progressCallback).then(function (account) { + return new Wallet(account); + }); + }; + Wallet.fromMnemonic = function (mnemonic, path, wordlist) { + if (!path) { + path = hdnode_1.defaultPath; + } + return new Wallet(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + }; + return Wallet; +}(abstract_signer_1.Signer)); +exports.Wallet = Wallet; +function verifyMessage(message, signature) { + return transactions_1.recoverAddress(hash_1.hashMessage(message), signature); +} +exports.verifyMessage = verifyMessage; + +},{"@ethersproject/abstract-provider":55,"@ethersproject/abstract-signer":56,"@ethersproject/address":57,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/hdnode":73,"@ethersproject/json-wallets":75,"@ethersproject/keccak256":79,"@ethersproject/properties":82,"@ethersproject/random":95,"@ethersproject/signing-key":99,"@ethersproject/transactions":102}],105:[function(require,module,exports){ +"use strict"; +try { + module.exports.XMLHttpRequest = XMLHttpRequest; +} +catch (error) { + console.log("Warning: XMLHttpRequest is not defined"); + module.exports.XMLHttpRequest = null; +} + +},{}],106:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var xmlhttprequest_1 = require("xmlhttprequest"); +var base64_1 = require("@ethersproject/base64"); +var errors = __importStar(require("@ethersproject/errors")); +var properties_1 = require("@ethersproject/properties"); +var strings_1 = require("@ethersproject/strings"); +function fetchJson(connection, json, processFunc) { + var headers = {}; + var url = null; + var timeout = 2 * 60 * 1000; + if (typeof (connection) === "string") { + url = connection; + } + else if (typeof (connection) === "object") { + if (connection.url == null) { + errors.throwError("missing URL", errors.MISSING_ARGUMENT, { arg: "url" }); + } + url = connection.url; + if (typeof (connection.timeout) === "number" && connection.timeout > 0) { + timeout = connection.timeout; + } + if (connection.headers) { + for (var key in connection.headers) { + headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; + } + } + if (connection.user != null && connection.password != null) { + if (url.substring(0, 6) !== "https:" && connection.allowInsecure !== true) { + errors.throwError("basic authentication requires a secure https url", errors.INVALID_ARGUMENT, { arg: "url", url: url, user: connection.user, password: "[REDACTED]" }); + } + var authorization = connection.user + ":" + connection.password; + headers["authorization"] = { + key: "Authorization", + value: "Basic " + base64_1.encode(strings_1.toUtf8Bytes(authorization)) + }; + } + } + return new Promise(function (resolve, reject) { + var request = new xmlhttprequest_1.XMLHttpRequest(); + var timer = null; + timer = setTimeout(function () { + if (timer == null) { + return; + } + timer = null; + reject(new Error("timeout")); + setTimeout(function () { + request.abort(); + }, 0); + }, timeout); + var cancelTimeout = function () { + if (timer == null) { + return; + } + clearTimeout(timer); + timer = null; + }; + if (json) { + request.open("POST", url, true); + headers["content-type"] = { key: "Content-Type", value: "application/json" }; + } + else { + request.open("GET", url, true); + } + Object.keys(headers).forEach(function (key) { + var header = headers[key]; + request.setRequestHeader(header.key, header.value); + }); + request.onreadystatechange = function () { + if (request.readyState !== 4) { + return; + } + if (request.status != 200) { + cancelTimeout(); + // @TODO: not any! + var error = new Error("invalid response - " + request.status); + error.statusCode = request.status; + if (request.responseText) { + error.responseText = request.responseText; + } + reject(error); + return; + } + var result = null; + try { + result = JSON.parse(request.responseText); + } + catch (error) { + cancelTimeout(); + // @TODO: not any! + var jsonError = new Error("invalid json response"); + jsonError.orginialError = error; + jsonError.responseText = request.responseText; + if (json != null) { + jsonError.requestBody = json; + } + jsonError.url = url; + reject(jsonError); + return; + } + if (processFunc) { + try { + result = processFunc(result); + } + catch (error) { + cancelTimeout(); + error.url = url; + error.body = json; + error.responseText = request.responseText; + reject(error); + return; + } + } + cancelTimeout(); + resolve(result); + }; + request.onerror = function (error) { + cancelTimeout(); + reject(error); + }; + try { + if (json != null) { + request.send(json); + } + else { + request.send(); + } + } + catch (error) { + cancelTimeout(); + // @TODO: not any! + var connectionError = new Error("connection error"); + connectionError.error = error; + reject(connectionError); + } + }); +} +exports.fetchJson = fetchJson; +function poll(func, options) { + if (!options) { + options = {}; + } + options = properties_1.shallowCopy(options); + if (options.floor == null) { + options.floor = 0; + } + if (options.ceiling == null) { + options.ceiling = 10000; + } + if (options.interval == null) { + options.interval = 250; + } + return new Promise(function (resolve, reject) { + var timer = null; + var done = false; + // Returns true if cancel was successful. Unsuccessful cancel means we're already done. + var cancel = function () { + if (done) { + return false; + } + done = true; + if (timer) { + clearTimeout(timer); + } + return true; + }; + if (options.timeout) { + timer = setTimeout(function () { + if (cancel()) { + reject(new Error("timeout")); + } + }, options.timeout); + } + var retryLimit = options.retryLimit; + var attempt = 0; + function check() { + return func().then(function (result) { + // If we have a result, or are allowed null then we're done + if (result !== undefined) { + if (cancel()) { + resolve(result); + } + } + else if (options.onceBlock) { + options.onceBlock.once("block", check); + // Otherwise, exponential back-off (up to 10s) our next request + } + else if (!done) { + attempt++; + if (attempt > retryLimit) { + if (cancel()) { + reject(new Error("retry limit reached")); + } + return; + } + var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); + if (timeout < options.floor) { + timeout = options.floor; + } + if (timeout > options.ceiling) { + timeout = options.ceiling; + } + setTimeout(check, timeout); + } + return null; + }, function (error) { + if (cancel()) { + reject(error); + } + }); + } + check(); + }); +} +exports.poll = poll; + +},{"@ethersproject/base64":58,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/strings":101,"xmlhttprequest":105}],107:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var lang_en_1 = require("./lang-en"); +var en = lang_en_1.langEn; +exports.en = en; + +},{"./lang-en":108}],108:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var wordlist_1 = require("./wordlist"); +var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; +var wordlist = null; +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); + if (wordlist_1.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { + wordlist = null; + throw new Error("BIP39 Wordlist for en (English) FAILED"); + } +} +var LangEn = /** @class */ (function (_super) { + __extends(LangEn, _super); + function LangEn() { + return _super.call(this, "en") || this; + } + LangEn.prototype.getWord = function (index) { + loadWords(this); + return wordlist[index]; + }; + LangEn.prototype.getWordIndex = function (word) { + loadWords(this); + return wordlist.indexOf(word); + }; + return LangEn; +}(wordlist_1.Wordlist)); +var langEn = new LangEn(); +exports.langEn = langEn; +wordlist_1.register(langEn); + +},{"./wordlist":109}],109:[function(require,module,exports){ +(function (global){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// This gets overriddenby gulp during bip39-XX +var exportWordlist = false; +var errors_1 = require("@ethersproject/errors"); +var hash_1 = require("@ethersproject/hash"); +var properties_1 = require("@ethersproject/properties"); +function check(wordlist) { + var words = []; + for (var i = 0; i < 2048; i++) { + var word = wordlist.getWord(i); + if (i !== wordlist.getWordIndex(word)) { + return "0x"; + } + words.push(word); + } + return hash_1.id(words.join("\n") + "\n"); +} +exports.check = check; +var Wordlist = /** @class */ (function () { + function Wordlist(locale) { + var _newTarget = this.constructor; + errors_1.checkAbstract(_newTarget, Wordlist); + properties_1.defineReadOnly(this, "locale", locale); + } + // Subclasses may override this + Wordlist.prototype.split = function (mnemonic) { + return mnemonic.toLowerCase().split(/ +/g); + }; + // Subclasses may override this + Wordlist.prototype.join = function (words) { + return words.join(" "); + }; + return Wordlist; +}()); +exports.Wordlist = Wordlist; +function register(lang, name) { + if (!name) { + name = lang.locale; + } + if (exportWordlist) { + var g = global; + if (!(g.wordlists)) { + properties_1.defineReadOnly(g, "wordlists", {}); + } + if (!g.wordlists[name]) { + properties_1.defineReadOnly(g.wordlists, name, lang); + } + if (g.ethers && g.ethers.wordlists) { + if (!g.ethers.wordlists[name]) { + properties_1.defineReadOnly(g.ethers.wordlists, name, lang); + } + } + } +} +exports.register = register; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/properties":82}]},{},[69])(69) +}); diff --git a/packages/ethers/dist/ethers.min.js b/packages/ethers/dist/ethers.min.js new file mode 100644 index 000000000..abadc178a --- /dev/null +++ b/packages/ethers/dist/ethers.min.js @@ -0,0 +1 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ethers=e()}}(function(){return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){return i(t[s][1][e]||e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s255)return!1;return!0}function o(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!i(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(n(e.length)&&i(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function s(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var u=function(){return{toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}}}(),c=function(){var e="0123456789abcdef";return{toBytes:function(e){for(var t=[],r=0;r>4]+e[15&i])}return r.join("")}}}(),h={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],l=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],v=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],g=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],M=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],k=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],E=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function S(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var s,a=0,u=i;u>16&255]<<24^l[s>>8&255]<<16^l[255&s]<<8^l[s>>24&255]^f[a]<<24,a+=1,8!=i)for(t=1;t>8&255]<<8^l[s>>16&255]<<16^l[s>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[c][d]=o[t],this._Kd[e-c][d]=o[t++],u++}for(var c=1;c>24&255]^k[s>>16&255]^E[s>>8&255]^A[255&s]},P.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=S(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var o=1;o>24&255]^m[n[(i+1)%4]>>16&255]^v[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[o][i];n=r.slice()}var a,u=s(16);for(i=0;i<4;i++)a=this._Ke[t][i],u[4*i]=255&(l[n[i]>>24&255]^a>>24),u[4*i+1]=255&(l[n[(i+1)%4]>>16&255]^a>>16),u[4*i+2]=255&(l[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(l[255&n[(i+3)%4]]^a);return u},P.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=S(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var o=1;o>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[o][i];n=r.slice()}var a,u=s(16);for(i=0;i<4;i++)a=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^a>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return u};var j=function(e){if(!(this instanceof j))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(e)};j.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=s(e.length),r=s(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},T.prototype.setBytes=function(e){if(16!=(e=o(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},T.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var I=function(e,t){if(!(this instanceof I))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof T||(t=new T(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(e)};I.prototype.encrypt=function(e){for(var t=o(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,f=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;h+=(s=(i=0|e.words[p])*(o=0|t.words[d])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=h[e],d=f[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?m+r:c[l-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===t,c=new e(o),h=this.clone();if(u){for(a=0;!h.isZero();a++)s=h.andln(255),h.iushrn(8),c[a]=s;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,v=0|s[2],y=8191&v,g=v>>>13,b=0|s[3],w=8191&b,_=b>>>13,M=0|s[4],k=8191&M,E=M>>>13,A=0|s[5],S=8191&A,P=A>>>13,j=0|s[6],x=8191&j,O=j>>>13,N=0|s[7],T=8191&N,I=N>>>13,R=0|s[8],C=8191&R,B=R>>>13,F=0|s[9],D=8191&F,L=F>>>13,U=0|a[0],z=8191&U,H=U>>>13,K=0|a[1],G=8191&K,q=K>>>13,V=0|a[2],W=8191&V,J=V>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,he=0|a[8],fe=8191&he,le=he>>>13,de=0|a[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ve=(c+(n=Math.imul(f,z))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(l,z)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(c+(n=n+Math.imul(f,G)|0)|0)+((8191&(i=(i=i+Math.imul(f,q)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(g,z)|0,o=Math.imul(g,H),n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(m,G)|0,o=o+Math.imul(m,q)|0;var ge=(c+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,G)|0,i=(i=i+Math.imul(y,q)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,q)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,W)|0,o=o+Math.imul(m,J)|0;var be=(c+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(l,X)|0))<<13)|0;c=((o=o+Math.imul(l,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(k,z),i=(i=Math.imul(k,H))+Math.imul(E,z)|0,o=Math.imul(E,H),n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,q)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(g,W)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(l,Y)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,z),i=(i=Math.imul(S,H))+Math.imul(P,z)|0,o=Math.imul(P,H),n=n+Math.imul(k,G)|0,i=(i=i+Math.imul(k,q)|0)+Math.imul(E,G)|0,o=o+Math.imul(E,q)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(g,X)|0,o=o+Math.imul(g,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(x,z),i=(i=Math.imul(x,H))+Math.imul(O,z)|0,o=Math.imul(O,H),n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,q)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,q)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Me=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,se)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(T,z),i=(i=Math.imul(T,H))+Math.imul(I,z)|0,o=Math.imul(I,H),n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,q)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,q)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0;var ke=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,H))+Math.imul(B,z)|0,o=Math.imul(B,H),n=n+Math.imul(T,G)|0,i=(i=i+Math.imul(T,q)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,q)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(O,W)|0,o=o+Math.imul(O,J)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,ce)|0;var Ee=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,le)|0)+Math.imul(l,fe)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(D,z),i=(i=Math.imul(D,H))+Math.imul(L,z)|0,o=Math.imul(L,H),n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,q)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,q)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(x,X)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,le)|0;var Ae=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,me)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,q))+Math.imul(L,G)|0,o=Math.imul(L,q),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(B,W)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,$)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,le)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;c=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(D,W),i=(i=Math.imul(D,J))+Math.imul(L,W)|0,o=Math.imul(L,J),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,ce)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,fe)|0,o=o+Math.imul(_,le)|0;var Pe=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,$))+Math.imul(L,X)|0,o=Math.imul(L,$),n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,se)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(k,fe)|0,i=(i=i+Math.imul(k,le)|0)+Math.imul(E,fe)|0,o=o+Math.imul(E,le)|0;var je=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,ee))+Math.imul(L,Y)|0,o=Math.imul(L,ee),n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(P,fe)|0,o=o+Math.imul(P,le)|0;var xe=(c+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,me)|0)+Math.imul(E,pe)|0))<<13)|0;c=((o=o+Math.imul(E,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(x,fe)|0,i=(i=i+Math.imul(x,le)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,le)|0;var Oe=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,me)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,se))+Math.imul(L,oe)|0,o=Math.imul(L,se),n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,ce)|0)+Math.imul(B,ue)|0,o=o+Math.imul(B,ce)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(I,fe)|0,o=o+Math.imul(I,le)|0;var Ne=(c+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,me)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(D,ue),i=(i=Math.imul(D,ce))+Math.imul(L,ue)|0,o=Math.imul(L,ce),n=n+Math.imul(C,fe)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(B,fe)|0,o=o+Math.imul(B,le)|0;var Te=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,me)|0)+Math.imul(I,pe)|0))<<13)|0;c=((o=o+Math.imul(I,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,fe),i=(i=Math.imul(D,le))+Math.imul(L,fe)|0,o=Math.imul(L,le);var Ie=(c+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(B,pe)|0))<<13)|0;c=((o=o+Math.imul(B,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Re=(c+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,me))+Math.imul(L,pe)|0))<<13)|0;return c=((o=Math.imul(L,me))+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,u[0]=ve,u[1]=ye,u[2]=ge,u[3]=be,u[4]=we,u[5]=_e,u[6]=Me,u[7]=ke,u[8]=Ee,u[9]=Ae,u[10]=Se,u[11]=Pe,u[12]=je,u[13]=xe,u[14]=Oe,u[15]=Ne,u[16]=Te,u[17]=Ie,u[18]=Re,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==h||c>=i);c--){var f=0|this.words[c];this.words[c]=h<<26-o|f>>>o,h=f&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,u=n.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;f--){var l=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,f);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),f=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(h),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(f)),a.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(t.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,l=1;0==(r.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new M(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var v={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function k(e){M.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},i(g,y),g.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},g.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(v[e])return v[e];var t;if("k256"===e)t=new g;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return v[e]=t,t},M.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},M.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},M.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},M.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},M.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},M.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},M.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},M.prototype.isqr=function(e){return this.imul(e,e.clone())},M.prototype.sqr=function(e){return this.mul(e,e)},M.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var m=d,v=0;0!==m.cmp(a);v++)m=m.redSqr();n(v=0;n--){for(var c=t.words[n],h=u-1;h>=0;h--){var f=c>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===h)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},M.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},M.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new k(e)},i(k,M),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:4}],3:[function(e,t,r){(function(e){t.exports=function(t){var r=new Uint8Array(t);return(e.crypto||e.msCrypto).getRandomValues(r),r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.hmacDRBG=e("./elliptic/hmac-drbg"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":19,"./elliptic/curve":8,"./elliptic/curves":11,"./elliptic/ec":12,"./elliptic/eddsa":15,"./elliptic/hmac-drbg":16,"./elliptic/utils":18,brorand:3}],6:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,s=i.getJSF,a=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];s.push(c)}for(var h=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var h=s[c];a(0!==h),u="affine"===e.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,u=this._wnafT2,c=this._wnafT3,h=0,f=0;f=1;f-=2){var d=f-1,p=f;if(1===a[d]&&1===a[p]){var m=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(m[1]=t[d].add(t[p]),m[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(m[1]=t[d].toJ().mixedAdd(t[p]),m[2]=t[d].add(t[p].neg())):(m[1]=t[d].toJ().mixedAdd(t[p]),m[2]=t[d].toJ().mixedAdd(t[p].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],y=s(r[d],r[p]);h=Math.max(y[0].length,h),c[d]=new Array(h),c[p]=new Array(h);for(var g=0;g=0;f--){for(var k=0;f>=0;){var E=!0;for(g=0;g=0&&k++,_=_.dblp(k),f<0)break;for(g=0;g0?A=u[g][S-1>>1]:S<0&&(A=u[g][-S-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},h.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},h.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},h.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},h.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},h.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),h=c.redMul(a),f=n.redMul(c),l=u.redSqr().redIAdd(h).redISub(f).redISub(f),d=u.redMul(f.redISub(l)).redISub(o.redMul(h)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),h=r.redMul(u),f=a.redSqr().redIAdd(c).redISub(h).redISub(h),l=a.redMul(h.redISub(f)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(f,l,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":5,"../curve":8,"bn.js":2,inherits:32}],11:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),s=e("../elliptic"),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":5,"./precomputed/secp256k1":17,"hash.js":20}],12:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic"),o=i.utils.assert,s=e("./key"),a=e("./signature");function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(o(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=u,u.prototype.keyPair=function(e){return new s(this,e)},u.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new i.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),u=t.getPrivate().toArray("be",s),c=e.toArray("be",s),h=new i.hmacDRBG({hash:this.hash,entropy:u,nonce:c,pers:o.pers,persEnc:o.persEnc}),f=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(h.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(f)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var m=p.getX(),v=m.umod(this.n);if(0!==v.cmpn(0)){var y=d.invm(this.n).mul(v.mul(t.getPrivate()).iadd(e));if(0!==(y=y.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==m.cmp(v)?2:0);return o.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),g^=1),new a({r:v,s:y,recoveryParam:g})}}}}}},u.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new a(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var u,c=s.invm(this.n),h=c.mul(e).umod(this.n),f=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(u=this.g.jmulAdd(h,r.getPublic(),f)).isInfinity()&&u.eqXToP(o):!(u=this.g.mulAdd(h,r.getPublic(),f)).isInfinity()&&0===u.getX().umod(this.n).cmp(o)},u.prototype.recoverPubKey=function(e,t,r,i){o((3&r)===r,"The recovery param is more than two bits"),t=new a(t,i);var s=this.n,u=new n(e),c=t.r,h=t.s,f=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),f):this.curve.pointFromX(c,f);var d=t.r.invm(s),p=s.sub(u).mul(d).umod(s),m=h.mul(d).umod(s);return this.g.mulAdd(p,c,m)},u.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new a(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":5,"./key":13,"./signature":14,"bn.js":2}],13:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":5,"bn.js":2}],14:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=a(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(s),this.s=new n(c),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,e)}},{"../../elliptic":5,"bn.js":2}],15:[function(e,t,r){arguments[4][7][0].apply(r,arguments)},{dup:7}],16:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../elliptic").utils,o=i.assert;function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc),r=i.toArray(e.nonce,e.nonceEnc),n=i.toArray(e.pers,e.persEnc);o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this.reseed=1},s.prototype.generate=function(e,t,r,n){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n),this._update(r));for(var o=[];o.length>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=o,n.toHex=s,n.encode=function(e,t){return"hex"===t?s(e):e},n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":2}],19:[function(e,t,r){t.exports={version:"6.3.3"}},{}],20:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":21,"./hash/hmac":22,"./hash/ripemd":23,"./hash/sha":24,"./hash/utils":31}],21:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":31}],31:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,s,a){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,s,a,u,c){var h=0,f=t;return h+=(f=f+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:32,"minimalistic-assert":34}],32:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],33:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),s=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],h=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},f=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=h(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,a=this.byteCount,u=this.blockCount,c=0,h=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];a%t==0&&(M(r),s=0)}return i&&(e=r[s],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(e);s>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&M(n)}return o&&(e=a<<2,t=n[s],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var M=function(e){var t,r,n,i,o,s,u,c,h,f,l,d,p,m,v,y,g,b,w,_,M,k,E,A,S,P,j,x,O,N,T,I,R,C,B,F,D,L,U,z,H,K,G,q,V,W,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,se,ae,ue,ce,he;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],h=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|h>>>31),r=o^(h<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|l>>>31),r=u^(l<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=h^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],v=e[1],W=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,x=e[20]<<3|e[21]>>>29,O=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,G=e[41]<<18|e[40]>>>14,C=e[2]<<1|e[3]>>>31,B=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,g=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,T=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,he=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,F=e[14]<<6|e[15]>>>26,D=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,I=e[45]<<29|e[44]>>>3,R=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,L=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,M=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,q=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,P=e[18]<<20|e[19]>>>12,j=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,k=e[48]<<14|e[49]>>>18,E=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=v^~g&w,e[10]=A^~P&x,e[11]=S^~j&O,e[20]=C^~F&L,e[21]=B^~D&U,e[30]=q^~W&Z,e[31]=V^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=y^~b&_,e[3]=g^~w&M,e[12]=P^~x&N,e[13]=j^~O&T,e[22]=F^~L&z,e[23]=D^~U&H,e[32]=W^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=b^~_&k,e[5]=w^~M&E,e[14]=x^~N&I,e[15]=O^~T&R,e[24]=L^~z&K,e[25]=U^~H&G,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&he,e[6]=_^~k&m,e[7]=M^~E&v,e[16]=N^~I&A,e[17]=T^~R&S,e[26]=z^~K&C,e[27]=H^~G&B,e[36]=$^~Y&q,e[37]=Q^~ee&V,e[46]=ae^~ce&te,e[47]=ue^~he&re,e[8]=k^~m&y,e[9]=E^~v&g,e[18]=I^~A&P,e[19]=R^~S&j,e[28]=K^~C&F,e[29]=G^~B&D,e[38]=Y^~q&W,e[39]=ee^~V&J,e[48]=ce^~te&ne,e[49]=he^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(i)t.exports=p;else for(v=0;v=64;){var d,p,m,v,y,g=r,b=n,w=i,_=o,M=s,k=a,E=u,A=c;for(p=0;p<16;p++)m=f+4*p,h[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)v=((d=h[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=h[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,h[p]=(v+h[p-7]|0)+(y+h[p-16]|0)|0;for(p=0;p<64;p++)v=(((M>>>6|M<<26)^(M>>>11|M<<21)^(M>>>25|M<<7))+(M&k^~M&E)|0)+(A+(t[p]+h[p]|0)|0)|0,y=((g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10))+(g&b^g&w^b&w)|0,A=E,E=k,k=M,M=_+v|0,_=w,w=b,b=g,g=v+y|0;r=r+g|0,n=n+b|0,i=i+w|0,o=o+_|0,s=s+M|0,a=a+k|0,u=u+E|0,c=c+A|0,f+=64,l-=64}}f(e);var l,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,v=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),l=d+1;l>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255]}function s(e,t,r){var n;e=e.length<=64?e:o(e);var i=64+t.length+4,s=new Array(i),a=new Array(64),u=[];for(n=0;n<64;n++)s[n]=54;for(n=0;n=i-4;e--){if(s[e]++,s[e]<=255)return;s[e]=0}}for(;r>=32;)c(),u=u.concat(o(a.concat(o(s)))),r-=32;return r>0&&(c(),u=u.concat(o(a.concat(o(s))).slice(0,r))),u}function a(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)h(e,16*o,i,16),c(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function c(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=u(t[0]+t[12],7),t[8]^=u(t[4]+t[0],9),t[12]^=u(t[8]+t[4],13),t[0]^=u(t[12]+t[8],18),t[9]^=u(t[5]+t[1],7),t[13]^=u(t[9]+t[5],9),t[1]^=u(t[13]+t[9],13),t[5]^=u(t[1]+t[13],18),t[14]^=u(t[10]+t[6],7),t[2]^=u(t[14]+t[10],9),t[6]^=u(t[2]+t[14],13),t[10]^=u(t[6]+t[2],18),t[3]^=u(t[15]+t[11],7),t[7]^=u(t[3]+t[15],9),t[11]^=u(t[7]+t[3],13),t[15]^=u(t[11]+t[7],18),t[1]^=u(t[0]+t[3],7),t[2]^=u(t[1]+t[0],9),t[3]^=u(t[2]+t[1],13),t[0]^=u(t[3]+t[2],18),t[6]^=u(t[5]+t[4],7),t[7]^=u(t[6]+t[5],9),t[4]^=u(t[7]+t[6],13),t[5]^=u(t[4]+t[7],18),t[11]^=u(t[10]+t[9],7),t[8]^=u(t[11]+t[10],9),t[9]^=u(t[8]+t[11],13),t[10]^=u(t[9]+t[8],18),t[12]^=u(t[15]+t[14],7),t[13]^=u(t[12]+t[15],9),t[14]^=u(t[13]+t[12],13),t[15]^=u(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function h(e,t,r,n){for(var i=0;i=256)return!1}return!0}function d(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function p(t,r,n,o,u,c,p){if(!p)throw new Error("missing callback");if(n=d(n,"N"),o=d(o,"r"),u=d(u,"p"),c=d(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>i/128/o)throw new Error("N too large");if(o>i/128/u)throw new Error("r too large");if(!l(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!l(r))throw new Error("salt must be an array or buffer");r=Array.prototype.slice.call(r);for(var m=s(t,r,128*u*o),v=new Uint32Array(32*u*o),y=0;yT&&(r=T);for(var e=0;eT&&(r=T);for(e=0;e>0&255),m.push(v[e]>>8&255),m.push(v[e]>>16&255),m.push(v[e]>>24&255);var d=s(t,m,c);return p(null,1,d)}I(R)};R()}void 0!==r?t.exports=p:n&&(n.scrypt&&(n._scrypt=n.scrypt),n.scrypt=p)}(this)}).call(this,e("timers").setImmediate)},{timers:37}],37:[function(e,t,r){(function(e){t.exports={setImmediate:e.setImmediate}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],38:[function(e,t,r){(function(e){var r;if(e.crypto&&crypto.getRandomValues){var n=new Uint8Array(16);r=function(){return crypto.getRandomValues(n),n}}if(!r){var i=new Array(16);r=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],39:[function(e,t,r){for(var n=e("./rng"),i=[],o={},s=0;s<256;s++)i[s]=(s+256).toString(16).substr(1),o[i[s]]=s;function a(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],h=16383&(u[6]<<8|u[7]),f=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var s=0;s<16;s++)t[i+s]=o[s];return t||a(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:h,s=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=s-f+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||s>f)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=s,l=u,h=o;var p=(1e4*(268435455&(s+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var m=s/4294967296*1e4&268435455;i[n++]=m>>>8&255,i[n++]=255&m,i[n++]=m>>>24&15|16,i[n++]=m>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var v=e.node||c,y=0;y<6;y++)i[n+y]=v[y];return t||a(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=a,t.exports=p},{"./rng":38}],40:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/bytes"),o=n(e("@ethersproject/errors")),s=e("@ethersproject/properties"),a=e("./coders/abstract-coder"),u=e("./coders/address"),c=e("./coders/array"),h=e("./coders/boolean"),f=e("./coders/bytes"),l=e("./coders/fixed-bytes"),d=e("./coders/null"),p=e("./coders/number"),m=e("./coders/string"),v=e("./coders/tuple"),y=e("./fragments"),g=new RegExp(/^bytes([0-9]*)$/),b=new RegExp(/^(u?int)([0-9]*)$/),w=function(){function e(t){var r=this.constructor;o.checkNew(r,e),s.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new u.AddressCoder(e.name);case"bool":return new h.BooleanCoder(e.name);case"string":return new m.StringCoder(e.name);case"bytes":return new f.BytesCoder(e.name);case"array":return new c.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new v.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new d.NullCoder(e.name)}var r,n=e.type.match(b);return n?((0===(r=parseInt(n[2]||"256"))||r>256||r%8!=0)&&o.throwError("invalid "+n[1]+" bit length",o.INVALID_ARGUMENT,{arg:"param",value:e}),new p.NumberCoder(r/8,"int"===n[1],e.name)):(n=e.type.match(g))?((0===(r=parseInt(n[1]))||r>32)&&o.throwError("invalid bytes length",o.INVALID_ARGUMENT,{arg:"param",value:e}),new l.FixedBytesCoder(r,e.name)):o.throwError("invalid type",o.INVALID_ARGUMENT,{arg:"type",value:e.type})},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new a.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new a.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var r=this;e.length!==t.length&&o.throwError("types/values length mismatch",o.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var n=e.map(function(e){return r._getCoder(y.ParamType.from(e))}),i=new v.TupleCoder(n,"_"),s=this._getWriter();return i.encode(s,t),s.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(y.ParamType.from(e))});return new v.TupleCoder(n,"_").decode(this._getReader(i.arrayify(t)))},e}();r.AbiCoder=w,r.defaultAbiCoder=new w},{"./coders/abstract-coder":41,"./coders/address":42,"./coders/array":44,"./coders/boolean":45,"./coders/bytes":46,"./coders/fixed-bytes":47,"./coders/null":48,"./coders/number":49,"./coders/string":50,"./coders/tuple":51,"./fragments":52,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],41:[function(e,t,r){"use trict";"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/bytes"),o=e("@ethersproject/bignumber"),s=n(e("@ethersproject/errors")),a=e("@ethersproject/properties"),u=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){s.throwError(e,s.INVALID_ARGUMENT,{argument:this.localName,coder:this,value:t})},e}();r.Coder=u;var c=function(){function e(e){a.defineReadOnly(this,"wordSize",e||32),this._data=i.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return i.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=i.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=i.arrayify(e);return t.length%this.wordSize&&(t=i.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=i.arrayify(o.BigNumber.from(e));return t.length>this.wordSize&&s.throwError("value out-of-bounds",s.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=i.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();r.Writer=c;var h=function(){function e(e,t,r){a.defineReadOnly(this,"_data",i.arrayify(e)),a.defineReadOnly(this,"wordSize",t||32),a.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return i.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var r=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&s.throwError("data out-of-bounds",s.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return o.BigNumber.from(this.readBytes(this.wordSize))},e}();r.Reader=h},{"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],42:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/address"),s=e("@ethersproject/bytes"),a=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{o.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return o.getAddress(s.hexZeroPad(e.readValue().toHexString(),20))},t}(e("./abstract-coder").Coder);r.AddressCoder=a},{"./abstract-coder":41,"@ethersproject/address":57,"@ethersproject/bytes":63}],43:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(e("./abstract-coder").Coder);r.AnonymousCoder=o},{"./abstract-coder":41}],44:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=e("./abstract-coder"),u=e("./anonymous");function c(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else s.throwError("invalid tuple value",s.INVALID_ARGUMENT,{coderType:"tuple",value:r});t.length!==r.length&&s.throwError("types/value length mismatch",s.INVALID_ARGUMENT,{coderType:"tuple",value:r});var i=new a.Writer(e.wordSize),o=new a.Writer(e.wordSize),u=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var s=o.length;e.encode(o,n);var a=i.writeUpdatableValue();u.push(function(e){a(e+s)})}else e.encode(i,n)}),u.forEach(function(e){e(i.length)});var c=e.writeBytes(i.data);return c+=e.writeBytes(o.data)}function h(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var s=e.readValue(),a=n.subReader(s.toNumber());o=t.decode(a),i+=a.consumed}else o=t.decode(e);void 0!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=c,r.unpack=h;var f=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",s=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,s)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),s.checkArgumentCount(r,t.length," in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=s.BigNumber.from(r[1]),r[0]}return e}function y(e,t){t.constant=!1,t.payable=!1,t.stateMutability=null,e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}r.EventFragment=m;var g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(u.isNamedInstance(t,e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);return new t(c,{type:e.type,inputs:e.inputs?e.inputs.map(l.fromObject):[],payable:null==e.payable||!!e.payable,gas:e.gas?s.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=v(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),y(n[3].trim(),r),t.fromObject(r)},t}(p);r.ConstructorFragment=g;var b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(u.isNamedInstance(t,e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);return new t(c,{type:e.type,name:M(e.name),constant:!!e.constant,inputs:e.inputs?e.inputs.map(l.fromObject):[],outputs:e.outputs?e.outputs.map(l.fromObject):[],payable:null==e.payable||!!e.payable,stateMutability:null!=e.stateMutability?function(e){if("string"!=typeof e)throw new Error("requires a string");return e}(e.stateMutability):null,gas:e.gas?s.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=v(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(_))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),y(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t}(g);function w(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=b;var _=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(_))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")},{"@ethersproject/bignumber":62,"@ethersproject/errors":66,"@ethersproject/properties":82}],53:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./fragments");r.ConstructorFragment=n.ConstructorFragment,r.EventFragment=n.EventFragment,r.Fragment=n.Fragment,r.FunctionFragment=n.FunctionFragment,r.ParamType=n.ParamType;var i=e("./abi-coder");r.AbiCoder=i.AbiCoder,r.defaultAbiCoder=i.defaultAbiCoder;var o=e("./interface");r.Indexed=o.Indexed,r.Interface=o.Interface},{"./abi-coder":40,"./fragments":52,"./interface":54}],54:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=e("@ethersproject/address"),a=e("@ethersproject/bignumber"),u=e("@ethersproject/bytes"),c=e("@ethersproject/hash"),h=e("@ethersproject/keccak256"),f=o(e("@ethersproject/errors")),l=e("@ethersproject/properties"),d=e("./abi-coder"),p=e("./fragments"),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(l.Description);r.LogDescription=m;var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(l.Description);r.TransactionDescription=v;var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(l.Description);r.Indexed=y;var g=function(){return function(){}}();r.Result=g;var b=function(){function e(t){var r=this.constructor,n=this;f.checkNew(r,e);var i=[];i="string"==typeof t?JSON.parse(t):t,l.defineReadOnly(this,"fragments",i.map(function(e){return l.isNamedInstance(p.Fragment,e)?e:p.Fragment.from(e)}).filter(function(e){return null!=e})),l.defineReadOnly(this,"_abiCoder",r.getAbiCoder()),l.defineReadOnly(this,"functions",{}),l.defineReadOnly(this,"errors",{}),l.defineReadOnly(this,"events",{}),l.defineReadOnly(this,"structs",{}),this.fragments.forEach(function(e){var t=null;switch(e.type){case"constructor":return n.deploy?void f.warn("duplicate definition - constructor"):void l.defineReadOnly(n,"deploy",e);case"function":t=n.functions;break;case"event":t=n.events;break;default:return}var r=e.format();t[r]?f.warn("duplicate definition - "+r):t[r]=e}),[this.events,this.functions].forEach(function(e){var t=function(e){var t={};for(var r in e){var n=e[r].name;t[n]||(t[n]=0),t[n]++}return t}(e);Object.keys(e).forEach(function(r){var n=e[r];1===t[n.name]?e[n.name]=n:f.warn("duplicate definition - "+n.name)})}),this.deploy||l.defineReadOnly(this,"deploy",p.ConstructorFragment.from({type:"constructor"}))}return e.getAbiCoder=function(){return d.defaultAbiCoder},e.getAddress=function(e){return s.getAddress(e)},e.prototype._sighashify=function(e){return u.hexDataSlice(c.id(e.format()),0,4)},e.prototype._topicify=function(e){return c.id(e.format())},e.prototype.getFunction=function(e){return u.isHexString(e)?w(e,this.getSighash.bind(this),this.functions):-1===e.indexOf("(")?this.functions[e.trim()]||null:this.functions[p.FunctionFragment.fromString(e).format()]},e.prototype.getEvent=function(e){return u.isHexString(e)?w(e,this.getEventTopic.bind(this),this.events):-1===e.indexOf("(")?this.events[e]:this.events[p.EventFragment.fromString(e).format()]},e.prototype.getSighash=function(e){return"string"==typeof e&&(e=this.getFunction(e)),this._sighashify(e)},e.prototype.getEventTopic=function(e){return"string"==typeof e&&(e=this.getEvent(e)),this._topicify(e)},e.prototype._encodeParams=function(e,t){return this._abiCoder.encode(e,t)},e.prototype.encodeDeploy=function(e){return this._encodeParams(this.deploy.inputs,e||[])},e.prototype.encodeFunctionData=function(e,t){return"string"==typeof e&&(e=this.getFunction(e)),u.hexlify(u.concat([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))},e.prototype.decodeFunctionResult=function(e,t){"string"==typeof e&&(e=this.getFunction(e));var r=u.arrayify(t),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,r)}catch(e){}break;case 4:"0x08c379a0"===u.hexlify(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return f.throwError("call revert exception",f.CALL_EXCEPTION,{method:e.format(),errorSignature:i,errorArgs:[n],reason:n})},e.prototype.encodeFilterTopics=function(e,t){var r=this;"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&f.throwError("too many arguments for "+e.format(),f.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var o=e.inputs[i];o.indexed?null==t?n.push(null):"string"===o.type?n.push(c.id(t)):"bytes"===o.type?n.push(h.keccak256(u.hexlify(t))):-1!==o.type.indexOf("[")||"tuple"===o.type.substring(0,5)?f.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,t):("address"===o.type&&r._abiCoder.encode(["address"],[t]),n.push(u.hexZeroPad(u.hexlify(t),32))):null!=t&&f.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){"string"==typeof e&&(e=this.getEvent(e)),null==r||e.anonymous||(r=r.slice(1));var n=[],i=[],o=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(p.ParamType.fromObject({type:"bytes32",name:e.name})),o.push(!0)):(n.push(e),o.push(!1)):(i.push(e),o.push(!1))});var s=null!=r?this._abiCoder.decode(n,u.concat(r)):null,a=this._abiCoder.decode(i,t),c=[],h=0,f=0;return e.inputs.forEach(function(e,t){e.indexed?null==s?c[t]=new y({hash:null}):o[t]?c[t]=new y({hash:s[f++]}):c[t]=s[f++]:c[t]=a[h++]}),c},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new v({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:a.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new m({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e}();function w(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=b},{"./abi-coder":40,"./fragments":52,"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/keccak256":79,"@ethersproject/properties":82}],55:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=e("@ethersproject/bytes"),a=o(e("@ethersproject/errors")),u=e("@ethersproject/errors"),c=e("@ethersproject/properties"),h=function(){return function(e){c.defineReadOnly(this,"expiry",e||0)}}();r.ForkEvent=h;var f=function(e){function t(t,r){var n;return s.isHexString(t,32)||a.throwArgumentError("invalid blockhash","blockhash",t),n=e.call(this,r)||this,c.defineReadOnly(n,"blockhash",t),n}return i(t,e),t}(h);r.BlockForkEvent=f;var l=function(e){function t(t,r){var n;return s.isHexString(t,32)||a.throwArgumentError("invalid transaction hash","hash",t),n=e.call(this,r)||this,c.defineReadOnly(n,"hash",t),n}return i(t,e),t}(h);r.TransactionForkEvent=l;var d=function(e){function t(t,r,n){var i;return s.isHexString(t,32)||a.throwArgumentError("invalid transaction hash","beforeHash",t),s.isHexString(r,32)||a.throwArgumentError("invalid transaction hash","afterHash",r),i=e.call(this,n)||this,c.defineReadOnly(i,"beforeHash",t),c.defineReadOnly(i,"afterHash",r),i}return i(t,e),t}(h);r.TransactionOrderForkEvent=d;var p=function(){function e(){var t=this.constructor;u.checkAbstract(t,e)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Provider=p},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],56:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=e("@ethersproject/properties"),u=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],c=function(){function e(){var t=this.constructor;s.checkAbstract(t,e)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),a.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),a.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===u.indexOf(t)&&s.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=a.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return a.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&s.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r)),null==r.chainId&&(r.chainId=t.getChainId()),a.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||s.throwError("missing provider",s.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e}();r.Signer=c;var h=function(e){function t(r,n){var i,o=this.constructor;return s.checkNew(o,t),i=e.call(this)||this,a.defineReadOnly(i,"address",r),a.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){s.throwError(e,s.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(c);r.VoidSigner=h},{"@ethersproject/errors":66,"@ethersproject/properties":82}],57:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=n(e("@ethersproject/errors")),s=e("@ethersproject/bytes"),a=e("@ethersproject/keccak256"),u=e("@ethersproject/rlp");function c(e){s.isHexString(e,20)||o.throwError("invalid address",o.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=s.arrayify(a.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var h={},f=0;f<10;f++)h[String(f)]=String(f);for(f=0;f<26;f++)h[String.fromCharCode(65+f)]=String(10+f);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){var t="";for((e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").forEach(function(e){t+=h[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=s.stripZeros(s.arrayify(e.nonce));return m(s.hexDataSlice(a.keccak256(u.encode([t,r])),12))}},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/rlp":97,"bn.js":2}],58:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes");r.decode=function(e){e=atob(e);for(var t=[],r=0;r0;)r.push(o%this.base),o=o/this.base|0}for(var a="",u=0;0===t[u]&&u=0;--c)a+=this.alphabet[r[c]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;o>0;)t.push(255&o),o>>=8}for(var a=0;e[a]===this._leader&&a=9007199254740991||t<=-9007199254740991)&&d("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):o.isBytes(t)?e.from(o.hexlify(t)):t._hex&&o.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):a.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return s.isNamedInstance(this,e)},e}();function h(e){if("string"!=typeof e)return h(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&a.throwArgumentError("invalid hex","value",e),"0x00"===(e=h(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function f(e){return c.from(h(e))}function l(e){var t=c.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function d(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),a.throwError(e,a.NUMERIC_FAULT,n)}r.BigNumber=c},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,"bn.js":2}],61:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/bytes"),o=n(e("@ethersproject/errors")),s=e("@ethersproject/properties"),a=e("./bignumber"),u={},c=a.BigNumber.from(0),h=a.BigNumber.from(-1);function f(e,t,r,n){var i={fault:t,operation:r};return void 0!==n&&(i.value=n),o.throwError(e,o.NUMERIC_FAULT,i)}for(var l="0";l.length<256;)l+=l;function d(e){if("number"!=typeof e)try{e=a.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+l.substring(0,e):o.throwArgumentError("invalid decimal size","decimals",e)}function p(e,t){null==t&&(t=0);var r=d(t),n=(e=a.BigNumber.from(e)).lt(c);n&&(e=e.mul(h));for(var i=e.mod(r).toString();i.length2&&o.throwArgumentError("too many decimal points","value",e);var s=i[0],u=i[1];for(s||(s="0"),u||(u="0"),u.length>r.length-1&&f("fractional component exceeds decimals","underflow","parseFixed");u.length80&&o.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new e(u,r,n,i)},e.isInstance=function(e){return s.isNamedInstance(this,e)},e}();r.FixedFormat=v;var y=function(){function e(t,r,n,i){var a=this.constructor;o.checkNew(a,e),s.defineReadOnly(this,"format",i),s.defineReadOnly(this,"_hex",r),s.defineReadOnly(this,"_value",n)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&o.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=m(this._value,this.format.decimals),n=m(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=m(this._value,this.format.decimals),n=m(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=m(this._value,this.format.decimals),n=m(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=m(this._value,this.format.decimals),n=m(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&o.throwArgumentError("invalid decimal cound","decimals",t);var r=this.toString().split(".");if(r[1].length<=t)return this;var n="0."+l.substring(0,t)+"5";return r=this.addUnsafe(e.fromString(n,this.format))._value.split("."),e.fromString(r[0]+"."+r[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&o.throwArgumentError("invalid byte width","width",e);var t=a.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return i.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){null!=n||null==r||!v.isInstance(r)&&"string"!=typeof r||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed");var i=v.isInstance(n)?n:v.from(n);return e.fromString(p(t,r),i)},e.fromString=function(t,r){null==r&&(r="fixed");var n=v.isInstance(r)?r:v.from(r),o=m(t,n.decimals);!n.signed&&o.lt(c)&&f("unsigned value cannot be negative","overflow","value",t);var s=null;n.signed?s=o.toTwos(n.width).toHexString():(s=o.toHexString(),s=i.hexZeroPad(s,n.width/8));var a=p(o,n.decimals);return new e(u,s,a,n)},e.fromBytes=function(t,r){null==r&&(r="fixed");var n=v.isInstance(r)?r:v.from(r);if(i.arrayify(t).length>n.width/8)throw new Error("overflow");var o=a.BigNumber.from(t);n.signed&&(o=o.fromTwos(n.width));var s=o.toTwos((n.signed?0:1)+n.width).toHexString(),c=p(o,n.decimals);return new e(u,s,c,n)},e.from=function(t,r){if("string"==typeof t)return e.fromString(t,r);if(i.isBytes(t))return e.fromBytes(t,r);try{return e.fromValue(t,0,r)}catch(e){if(e.code!==o.INVALID_ARGUMENT)throw e}return o.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return s.isNamedInstance(this,e)},e}();r.FixedNumber=y},{"./bignumber":60,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82}],62:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bignumber");r.BigNumber=n.BigNumber;var i=e("./fixednumber");r.FixedNumber=i.FixedNumber},{"./bignumber":60,"./fixednumber":61}],63:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("@ethersproject/errors"));function o(e){return!!e.toHexString}function s(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return s(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function a(e){return f(e)&&!(e.length%2)||u(e)}function u(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function c(e,t){if(t||(t={}),"number"==typeof e){i.checkSafeUint53(e,"invalid arrayify value");for(var r=[];e;)r.unshift(255&e),e/=256;return 0===r.length&&r.push(0),s(new Uint8Array(r))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),o(e)&&(e=e.toHexString()),f(e)){var n=e.substring(2);!t.allowOddLength&&n.length%2&&i.throwArgumentError("hex data is odd-length","value",e);r=[];for(var a=0;at&&i.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(t);return r.set(e,t-e.length),s(r)},r.isHexString=f;var l="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){i.checkSafeUint53(e,"invalid hexlify value");for(var r="";e;)r=l[15&e]+r,e=Math.floor(e/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),o(e))return e.toHexString();if(f(e))return!t.allowOddLength&&e.length%2&&i.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(u(e)){for(var n="0x",s=0;s>4]+l[15&a]}return n}return i.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),f(e)||i.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&i.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function v(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(a(e)){var r=c(e);65!==r.length&&i.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(r.slice(0,32)),t.s=d(r.slice(32,64)),t.v=r[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(r[32]|=128),t._vs=d(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&i.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&i.throwArgumentError("signature _vs overflow","signature",e);var n=(u=c(t._vs))[0]>=128?1:0,o=27+t.recoveryParam;u[0]&=127;var s=d(u);null==t.s?t.s=s:t.s!==s&&i.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=o:t.v!==o&&i.throwArgumentError("signature v mismatch _vs","signature",e),null==n?t.recoveryParam=n:t.recoveryParam!==n&&i.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var u;if(null==t.v&&null==t.recoveryParam&&i.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&i.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&i.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(u=c(t.s))[0]>=128&&i.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(u[0]|=128),t._vs=d(u)}return t}r.hexlify=d,r.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!f(e)||e.length%2)return null;return(e.length-2)/2},r.hexDataSlice=function(e,t,r){return"string"!=typeof e?e=d(e):(!f(e)||e.length%2)&&i.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)},r.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},r.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},r.hexStripZeros=p,r.hexZeroPad=m,r.splitSignature=v,r.joinSignature=function(e){return d(h([(e=v(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"@ethersproject/errors":66}],64:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bignumber");r.AddressZero="0x0000000000000000000000000000000000000000";r.HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";r.EtherSymbol="Ξ";var i=n.BigNumber.from(-1);r.NegativeOne=i;var o=n.BigNumber.from(0);r.Zero=o;var s=n.BigNumber.from(1);r.One=s;var a=n.BigNumber.from(2);r.Two=a;var u=n.BigNumber.from("1000000000000000000");r.WeiPerEther=u;var c=n.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");r.MaxUint256=c},{"@ethersproject/bignumber":62}],65:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/abi"),o=e("@ethersproject/abstract-provider"),s=e("@ethersproject/abstract-signer"),a=e("@ethersproject/address"),u=e("@ethersproject/bignumber"),c=e("@ethersproject/bytes"),h=e("@ethersproject/constants"),f=n(e("@ethersproject/errors")),l=e("@ethersproject/properties"),d={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function p(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],o=0;ot&&a("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.checkNew=function(e,t){e!==Object&&null!=e||a("missing new",r.MISSING_NEW,{name:t.name})},r.checkAbstract=function(e,t){e===t?a("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||a("missing new",r.MISSING_NEW,{name:t.name})};var u=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{"test".normalize(t)}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();r.checkNormalize=function(){u&&a("platform missing String.prototype.normalize",r.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:u})},r.checkSafeUint53=function(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&a(t,r.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&a(t,r.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))};var c={debug:1,default:2,info:2,warn:3,error:4,off:5},h=c.default;function f(e,t){h>c[e]||console.log.apply(console,t)}function l(){for(var e=[],t=0;t=256)throw new Error("Depth too large!");return b(a.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",a.hexlify(this.depth),this.parentFingerprint,a.hexZeroPad(a.hexlify(this.index),4),this.chainCode,null!=this.privateKey?a.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(w,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var n=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");n.set(a.arrayify(this.privateKey),1),r&&(r+="'")}else n.set(a.arrayify(this.publicKey));for(var i=24;i>=0;i-=8)n[33+(i>>3)]=t>>24-i&255;var o=a.arrayify(d.computeHmac(d.SupportedAlgorithms.sha512,this.chainCode,n)),s=o.slice(0,32),c=o.slice(32),h=null,f=null;this.privateKey?h=g(u.BigNumber.from(s).add(this.privateKey).mod(m)):f=new l.SigningKey(a.hexlify(s))._addPoint(this.publicKey);return new e(w,h,f,this.fingerprint,g(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=a.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var i=a.arrayify(d.computeHmac(d.SupportedAlgorithms.sha512,v,n));return new e(w,g(i.slice(0,32)),null,"0x00000000",g(i.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return k(t,n),e._fromSeed(M(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var r=o.Base58.decode(t);82===r.length&&b(r.slice(0,78))===t||s.throwError("invalid extended key",s.INVALID_ARGUMENT,{argument:"extendedKey",value:"[REDACTED]"});var n=r[4],i=a.hexlify(r.slice(5,9)),u=parseInt(a.hexlify(r.slice(9,13)).substring(2),16),c=a.hexlify(r.slice(13,45)),h=r.slice(45,78);switch(a.hexlify(r.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(w,null,a.hexlify(h),i,c,u,n,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==h[0])break;return new e(w,a.hexlify(h.slice(1)),null,i,c,u,n,null,null)}return s.throwError("invalid extended key",s.INVALID_ARGUMENT,{argument:"extendedKey",value:"[REDACTED]"})},e}();function M(e,t){t||(t="");var r=c.toUtf8Bytes("mnemonic"+t,c.UnicodeNormalizationForm.NFKD);return h.pbkdf2(c.toUtf8Bytes(e,c.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function k(e,t){t||(t=i.langEn),s.checkNormalize();var r=t.split(e);if(r.length%3!=0)throw new Error("invalid mnemonic");for(var n=a.arrayify(new Uint8Array(Math.ceil(11*r.length/8))),o=0,u=0;u>3]|=1<<7-o%8),o++}var f=32*r.length/3,l=y(r.length/3),p=a.arrayify(d.sha256(n.slice(0,f/8)))[0];if((p&=l)!==(n[n.length-1]&l))throw new Error("invalid checksum");return a.hexlify(n.slice(0,f/8))}r.HDNode=_,r.mnemonicToSeed=M,r.mnemonicToEntropy=k,r.entropyToMnemonic=function(e,t){if((e=a.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,o=0;o8?(r[r.length-1]<<=8,r[r.length-1]|=e[o],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[o]>>8-n,r.push(e[o]&(1<<8-n)-1),n+=3);var s=a.arrayify(d.sha256(e))[0],u=e.length/4;return s&=y(u),r[r.length-1]<<=u,r[r.length-1]|=s>>8-u,t||(t=i.langEn),t.join(r.map(function(e){return t.getWord(e)}))},r.isValidMnemonic=function(e,t){try{return k(e,t),!0}catch(e){}return!1}},{"@ethersproject/basex":59,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/pbkdf2":81,"@ethersproject/properties":82,"@ethersproject/sha2":98,"@ethersproject/signing-key":99,"@ethersproject/strings":101,"@ethersproject/transactions":102,"@ethersproject/wordlists/lang-en":108}],74:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=o(e("aes-js")),u=e("@ethersproject/address"),c=e("@ethersproject/bytes"),h=s(e("@ethersproject/errors")),f=e("@ethersproject/keccak256"),l=e("@ethersproject/pbkdf2"),d=e("@ethersproject/strings"),p=e("@ethersproject/properties"),m=e("./utils"),v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isType=function(e){return p.Description.isType(e)},t}(p.Description);r.CrowdsaleAccount=v,r.decrypt=function(e,t){var r=JSON.parse(e);t=m.getPassword(t);var n=u.getAddress(m.searchPath(r,"ethaddr")),i=m.looseArrayify(m.searchPath(r,"encseed"));i&&i.length%16==0||h.throwError("invalid encseed",h.INVALID_ARGUMENT,{argument:"json",value:e});var o=c.arrayify(l.pbkdf2(t,t,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),p=i.slice(16),y=new a.default.ModeOfOperation.cbc(o,s),g=c.arrayify(y.decrypt(p));g=a.default.padding.pkcs7.strip(g);for(var b="",w=0;w>24&255,l[t.length+1]=d>>16&255,l[t.length+2]=d>>8&255,l[t.length+3]=255&d;var p=n.arrayify(i.computeHmac(s,e,l));a||(a=p.length,c=new Uint8Array(a),u=o-((h=Math.ceil(o/a))-1)*a),c.set(p);for(var m=1;m=0||"block"===this.tag||"pending"===this.tag},e}(),_=null,M=1,k=function(e){function t(t){var r=this.constructor,n=this;if(c.checkNew(r,s.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)l.defineReadOnly(n,"ready",t.then(function(e){return l.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=f.getNetwork(null==t?"homestead":t);i?(l.defineReadOnly(n,"_network",i),l.defineReadOnly(n,"ready",Promise.resolve(n._network))):c.throwError("invalid network",c.INVALID_ARGUMENT,{arg:"network",value:t})}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==_&&(_=new m.Formatter),_},t.prototype.poll=function(){var e=this,t=M++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],s=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(s);break;case"filter":var a=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:a};u.address||delete u.address;s=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(s)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=b();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=d.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return c.throwError(e+" not implemented",c.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new w(g(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&a.throwError("insufficient funds",a.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&a.throwError("nonce has already been used",a.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&a.throwError("replacement fee too low",a.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",s(i+=o);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,s(i+=o);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,s(i+=o);case"call":if((u=h(r.transaction))&&(u="&"+u),i+="/api?module=proxy&action=eth_call"+u,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return s(i+=o);case"estimateGas":var u;return(u=h(r.transaction))&&(u="&"+u),i+="/api?module=proxy&action=eth_estimateGas&"+u,s(i+=o);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+d(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+d(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return s(i+=o,f).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",s(i+=o,f).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,c.fetchJson(i,null,f).then(function(e){n.emit("debug",{action:"getHistory",request:i,response:e,provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(e("./base-provider").BaseProvider);r.EtherscanProvider=p},{"./base-provider":84,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/web":106}],87:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=e("@ethersproject/random"),u=e("@ethersproject/properties");function c(){return(new Date).getTime()}function h(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||s.throwError("provider mismatch",s.INVALID_ARGUMENT,{arg:"networks",value:e}):r=n:t=!1}),t}var f=1,l=function(e){function t(r,n,i){var o=this.constructor,a=this;s.checkNew(o,t),0===r.length&&s.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?s.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&s.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&s.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),h(r.map(function(e){return e.network})))a=e.call(this,r[0].network)||this;else{var f=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return h(e)||s.throwError("getNetwork returned null",s.UNKNOWN_ERROR,{}),e[0]});a=e.call(this,f)||this}return u.defineReadOnly(a,"providers",Object.freeze(r.slice())),u.defineReadOnly(a,"quorum",n),u.defineReadOnly(a,"weights",Object.freeze(i.slice())),a}return i(t,e),t.prototype.perform=function(e,t){var r=this,n=c(),i=a.shuffled(this.providers).map(function(i,o){var s=r.weights[o],a=f++;return{run:function(){var o=c(),u=o-n;return r.emit("debug","perform",a,{weight:s,start:u,provider:i,method:e,params:t}),i.perform(e,t).then(function(e){var t=c()-o;return r.emit("debug","result",a,{duration:t,result:e}),{weight:s,result:e}},function(e){var t=c()-o;return r.emit("debug","error",a,{duration:t,error:e}),{weight:s,error:e}})},weight:s}});return"sendTransaction"===e?Promise.all(i.map(function(e){return e.run()})).then(function(e){for(var t=0;t=r.quorum){var d=s[f][0].result;return r.emit("debug","quorum",-1,{weight:l,result:d}),e(d),void(s=null)}}}0!==i.length||0!==o?setTimeout(a,0):t(n)}}),o=0&&c.throwError("insufficient funds",c.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&c.throwError("nonce has already been used",c.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&c.throwError("replacement fee too low",c.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return c.throwError("signing transactions is unsupported",c.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return d.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?l.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),u.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(s.Signer);r.JsonRpcSigner=g;var b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(g),w={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},_=function(e){function t(r,n){var i=this.constructor,o=this;if(c.checkNew(i,t),"string"==typeof r&&null===n&&h.getNetwork(r)&&(n=r,r=null),n)o=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){o.send("eth_chainId",[]).then(function(t){e(h.getNetwork(a.BigNumber.from(t).toNumber()))}).catch(function(r){o.send("net_version",[]).then(function(t){e(h.getNetwork(a.BigNumber.from(t).toNumber()))}).catch(function(e){t(c.makeError("could not detect network",c.NETWORK_ERROR,{}))})})})});o=e.call(this,s)||this}return r||(r="http://localhost:8545"),o.connection="string"==typeof r?{url:r}:r,o}return i(t,e),t.prototype.getSigner=function(e){return new g(y,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:42,jsonrpc:"2.0"};return d.fetchJson(this.connection,JSON.stringify(n),m).then(function(e){return r.emit("debug",{action:"send",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[v(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[v(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[v(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[v(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&c.throwError("insufficient funds",c.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&c.throwError("nonce has already been used",c.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&c.throwError("replacement fee too low",c.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):Promise.reject(new Error("invalid block tag or block hash"));case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=v(t.filter.address)),this.send("eth_getLogs",[t.filter])}return c.throwError(e+" not implemented",c.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=f.shallowCopy(w);if(t)for(var n in t)t[n]&&(r[n]=!0);f.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=u.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=u.hexlify(e[t]))}),i},t}(p.BaseProvider);r.JsonRpcProvider=_},{"./base-provider":84,"@ethersproject/abstract-signer":56,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/networks":80,"@ethersproject/properties":82,"@ethersproject/strings":101,"@ethersproject/web":106}],92:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return e||"ETHERS_JS_SHARED"},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:s.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t},t}(e("./url-json-rpc-provider").UrlJsonRpcProvider);r.NodesmithProvider=a},{"./url-json-rpc-provider":93,"@ethersproject/errors":66}],93:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=e("@ethersproject/networks"),u=e("@ethersproject/properties"),c=function(e){function t(r,n){var i,o=this.constructor;s.checkAbstract(o,t),r=a.getNetwork(null==r?"homestead":r),n=o.getApiKey(n);var c=o.getUrl(r,n);return i=e.call(this,c,r)||this,u.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){s.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return s.throwError("API provider does not support signing",s.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return s.throwError("not implemented; sub-classes must override getUrl",s.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(e("./json-rpc-provider").JsonRpcProvider);r.UrlJsonRpcProvider=c},{"./json-rpc-provider":91,"@ethersproject/errors":66,"@ethersproject/networks":80,"@ethersproject/properties":82}],94:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("@ethersproject/errors")),a=e("@ethersproject/properties"),u=function(e){function t(r,n){var i=this.constructor,o=this;return s.checkNew(i,t),o=e.call(this,r.host||r.path||"",n)||this,r&&(r.sendAsync?o._sendAsync=r.sendAsync.bind(r):r.send&&(o._sendAsync=r.send.bind(r))),r&&o._sendAsync||s.throwError("invalid web3Provider",s.INVALID_ARGUMENT,{arg:"web3Provider",value:r}),a.defineReadOnly(o,"_web3Provider",r),o}return i(t,e),t.prototype.send=function(e,t){var r=this;return"eth_sign"==e&&this._web3Provider.isMetaMask&&(e="personal_sign",t=[t[1],t[0]]),new Promise(function(n,i){var o={method:e,params:t,id:42,jsonrpc:"2.0"};r._sendAsync(o,function(e,t){if(e)i(e);else{if(t.error){var r=new Error(t.error.message);return r.code=t.error.code,r.data=t.error.data,void i(r)}n(t.result)}})})},t}(e("./json-rpc-provider").JsonRpcProvider);r.Web3Provider=u},{"./json-rpc-provider":91,"@ethersproject/errors":66,"@ethersproject/properties":82}],95:[function(e,t,r){(function(t){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/bytes"),o=n(e("@ethersproject/errors")),s=e("./shuffle");r.shuffled=s.shuffled;var a=t.crypto||t.msCrypto;a&&a.getRandomValues||(o.warn("WARNING: Missing strong random number source"),a={getRandomValues:function(e){return o.throwError("no secure random source avaialble",o.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&o.throwError("invalid length",o.INVALID_ARGUMENT,{argument:"length",value:e});var t=new Uint8Array(e);return a.getRandomValues(t),i.arrayify(t)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./shuffle":96,"@ethersproject/bytes":63,"@ethersproject/errors":66}],96:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}},{}],97:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function a(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=o(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return s(e,t,t+1+a,a+r)}if(e[t]>=192){var i=e[t]-192;if(t+1+i>e.length)throw new Error("invalid rlp data");return s(e,t,t+1,i)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var u=o(e,t+1,a);if(t+1+a+u>e.length)throw new Error("invalid rlp data");return{consumed:1+a+u,result:n.hexlify(e.slice(t+1+a,t+1+a+u))}}if(e[t]>=128){var c=e[t]-128;if(t+1+c>e.length)throw new Error("invlaid rlp data");return{consumed:1+c,result:n.hexlify(e.slice(t+1,t+1+c))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];if(t.forEach(function(t){r=r.concat(e(t))}),r.length<=55)return r.unshift(192+r.length),r;var o=i(r.length);return o.unshift(247+o.length),o.concat(r)}var s=Array.prototype.slice.call(n.arrayify(t));if(1===s.length&&s[0]<=127)return s;if(s.length<=55)return s.unshift(128+s.length),s;var a=i(s.length);return a.unshift(183+a.length),a.concat(s)}(e))},r.decode=function(e){var t=n.arrayify(e),r=a(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"@ethersproject/bytes":63}],98:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i,o=n(e("hash.js")),s=e("@ethersproject/bytes"),a=n(e("@ethersproject/errors"));!function(e){e.sha256="sha256",e.sha512="sha512"}(i=r.SupportedAlgorithms||(r.SupportedAlgorithms={})),r.ripemd160=function(e){return"0x"+o.ripemd160().update(s.arrayify(e)).digest("hex")},r.sha256=function(e){return"0x"+o.sha256().update(s.arrayify(e)).digest("hex")},r.sha512=function(e){return"0x"+o.sha512().update(s.arrayify(e)).digest("hex")},r.computeHmac=function(e,t,r){return i[e]||a.throwError("unsupported algorithm "+e,a.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:e}),"0x"+o.hmac(o[e],s.arrayify(t)).update(s.arrayify(r)).digest()}},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"hash.js":20}],99:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("elliptic"),o=e("@ethersproject/bytes"),s=n(e("@ethersproject/errors")),a=e("@ethersproject/properties"),u=null;function c(){return u||(u=new i.ec("secp256k1")),u}var h=function(){function e(e){a.defineReadOnly(this,"curve","secp256k1"),a.defineReadOnly(this,"privateKey",o.hexlify(e));var t=c().keyFromPrivate(o.arrayify(this.privateKey));a.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),a.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex"))}return e.prototype._addPoint=function(e){var t=c().keyFromPublic(o.arrayify(this.publicKey)),r=c().keyFromPublic(o.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=c().keyFromPrivate(o.arrayify(this.privateKey)).sign(o.arrayify(e),{canonical:!0});return o.splitSignature({recoveryParam:t.recoveryParam,r:o.hexZeroPad("0x"+t.r.toString(16),32),s:o.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=c().keyFromPrivate(o.arrayify(this.privateKey)),r=c().keyFromPublic(o.arrayify(f(e)));return o.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e}();function f(e,t){var r=o.arrayify(e);if(32===r.length){var n=new h(r);return t?"0x"+c().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}return 33===r.length?t?o.hexlify(r):"0x"+c().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?t?"0x"+c().keyFromPublic(r).getPublic(!0,"hex"):o.hexlify(r):s.throwArgumentError("invalid public or private key","key","[REDACTED]")}r.SigningKey=h,r.recoverPublicKey=function(e,t){var r=o.splitSignature(t),n={r:o.arrayify(r.r),s:o.arrayify(r.s)};return"0x"+c().recoverPubKey(o.arrayify(e),n,r.recoveryParam).encode("hex",!1)},r.computePublicKey=f},{"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/properties":82,elliptic:5}],100:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bignumber"),i=e("@ethersproject/bytes"),o=e("@ethersproject/keccak256"),s=e("@ethersproject/sha2"),a=e("@ethersproject/strings"),u=new RegExp("^bytes([0-9]+)$"),c=new RegExp("^(u?int)([0-9]*)$"),h=new RegExp("^(.*)\\[([0-9]*)\\]$"),f="0000000000000000000000000000000000000000000000000000000000000000";function l(e,t){if(e.length!=t.length)throw new Error("type/value count mismatch");var r=[];return e.forEach(function(e,o){r.push(function e(t,r,o){switch(t){case"address":return o?i.zeroPad(r,32):i.arrayify(r);case"string":return a.toUtf8Bytes(r);case"bytes":return i.arrayify(r);case"bool":return r=r?"0x01":"0x00",o?i.zeroPad(r,32):i.arrayify(r)}var s=t.match(c);if(s){if((l=parseInt(s[2]||"256"))%8!=0||0===l||l>256)throw new Error("invalid number type - "+t);return o&&(l=256),r=n.BigNumber.from(r).toTwos(l),i.zeroPad(r,l/8)}if(s=t.match(u)){var l=parseInt(s[1]);if(String(l)!=s[1]||0===l||l>32)throw new Error("invalid number type - "+t);if(i.arrayify(r).byteLength!==l)throw new Error("invalid value for "+t);return o?i.arrayify((r+f).substring(0,66)):r}if((s=t.match(h))&&Array.isArray(r)){var d=s[1];if(parseInt(s[2]||String(r.length))!=r.length)throw new Error("invalid value for "+t);var p=[];return r.forEach(function(t){p.push(e(d,t,!0))}),i.concat(p)}throw new Error("unknown type - "+t)}(e,t[o]))}),i.hexlify(i.concat(r))}r.pack=l,r.keccak256=function(e,t){return o.keccak256(l(e,t))},r.sha256=function(e,t){return s.sha256(l(e,t))}},{"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/keccak256":79,"@ethersproject/sha2":98,"@ethersproject/strings":101}],101:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("@ethersproject/constants"),o=e("@ethersproject/errors"),s=e("@ethersproject/bytes");function a(e,t){void 0===t&&(t=n.current),t!=n.current&&(o.checkNormalize(),e=e.normalize(t));for(var r=[],i=0;i>6|192),r.push(63&a|128);else if(55296==(64512&a)){i++;var u=e.charCodeAt(i);if(i>=e.length||56320!=(64512&u))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&u),r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(63&a|128)}else r.push(a>>12|224),r.push(a>>6&63|128),r.push(63&a|128)}return s.arrayify(r)}function u(e,t){e=s.arrayify(e);for(var r="",n=0;n>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var u=i&(1<<8-o-1)-1,c=0;c1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(u>=55296&&u<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else u<=65535?r+=String.fromCharCode(u):(u-=65536,r+=String.fromCharCode(55296+(u>>10&1023),56320+(1023&u)));else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r+=String.fromCharCode(i)}return r}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=a,r.toUtf8String=u,r.formatBytes32String=function(e){var t=a(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return s.hexlify(s.concat([t,i.HashZero]).slice(0,32))},r.parseBytes32String=function(e){var t=s.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 sdtring - no null terminator");for(var r=31;0===t[r-1];)r--;return u(t.slice(0,r))}},{"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66}],102:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/address"),o=e("@ethersproject/bignumber"),s=e("@ethersproject/bytes"),a=e("@ethersproject/constants"),u=n(e("@ethersproject/errors")),c=e("@ethersproject/keccak256"),h=e("@ethersproject/properties"),f=n(e("@ethersproject/rlp")),l=e("@ethersproject/signing-key");function d(e){return"0x"===e?a.Zero:o.BigNumber.from(e)}var p=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],m={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function v(e){var t=l.computePublicKey(e);return i.getAddress(s.hexDataSlice(c.keccak256(s.hexDataSlice(t,1)),12))}function y(e,t){return v(l.recoverPublicKey(s.arrayify(e),t))}r.computeAddress=v,r.recoverAddress=y,r.serialize=function(e,t){h.checkProperties(e,m);var r=[];p.forEach(function(t){var n=e[t.name]||[];n=s.arrayify(s.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&u.throwError("invalid length for "+t.name,u.INVALID_ARGUMENT,{arg:"transaction"+t.name,value:n}),t.maxLength&&(n=s.stripZeros(n)).length>t.maxLength&&u.throwError("invalid length for "+t.name,u.INVALID_ARGUMENT,{arg:"transaction"+t.name,value:n}),r.push(s.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(s.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=f.encode(r);if(!t)return n;var i=s.splitSignature(t),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*e.chainId+8),r.push(s.hexlify(o)),r.push(s.stripZeros(s.arrayify(i.r))),r.push(s.stripZeros(s.arrayify(i.s))),f.encode(r)},r.parse=function(e){var t=f.decode(e);9!==t.length&&6!==t.length&&u.throwError("invalid raw transaction",u.INVALID_ARGUMENT,{arg:"rawTransactin",value:e});var r,n={nonce:d(t[0]).toNumber(),gasPrice:d(t[1]),gasLimit:d(t[2]),to:(r=t[3],"0x"===r?null:i.getAddress(r)),value:d(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=o.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=s.hexZeroPad(t[7],32),n.s=s.hexZeroPad(t[8],32),o.BigNumber.from(n.r).isZero()&&o.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var a=n.v-27,h=t.slice(0,6);0!==n.chainId&&(h.push(s.hexlify(n.chainId)),h.push("0x"),h.push("0x"),a-=2*n.chainId+8);var l=c.keccak256(f.encode(h));try{n.from=y(l,{r:s.hexlify(n.r),s:s.hexlify(n.s),recoveryParam:a})}catch(e){console.log(e)}n.hash=c.keccak256(e)}return n}},{"@ethersproject/address":57,"@ethersproject/bignumber":62,"@ethersproject/bytes":63,"@ethersproject/constants":64,"@ethersproject/errors":66,"@ethersproject/keccak256":79,"@ethersproject/properties":82,"@ethersproject/rlp":97,"@ethersproject/signing-key":99}],103:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/bignumber/fixednumber"),o=n(e("@ethersproject/errors")),s=["wei","kwei","mwei","gwei","szabo","finney","ether"];function a(e,t){if("string"==typeof t){var r=s.indexOf(t);-1!==r&&(t=3*r)}return i.formatFixed(e,null!=t?t:18)}function u(e,t){if("string"==typeof t){var r=s.indexOf(t);-1!==r&&(t=3*r)}return i.parseFixed(e,null!=t?t:18)}r.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&o.throwError("invalid value",o.INVALID_ARGUMENT,{argument:"value",value:e});var r=t[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");var i="";2===t.length&&(i="."+(t[1]||"0"));for(var s=[];r.length;){if(r.length<=3){s.unshift(r);break}var a=r.length-3;s.unshift(r.substring(a)),r=r.substring(0,a)}return n+s.join(",")+i},r.formatUnits=a,r.parseUnits=u,r.formatEther=function(e){return a(e,18)},r.parseEther=function(e){return u(e,18)}},{"@ethersproject/bignumber/fixednumber":61,"@ethersproject/errors":66}],104:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=e("@ethersproject/address"),a=e("@ethersproject/abstract-provider"),u=e("@ethersproject/abstract-signer"),c=e("@ethersproject/bytes"),h=o(e("@ethersproject/errors")),f=e("@ethersproject/hash"),l=e("@ethersproject/hdnode"),d=e("@ethersproject/keccak256"),p=e("@ethersproject/properties"),m=e("@ethersproject/random"),v=e("@ethersproject/signing-key"),y=e("@ethersproject/json-wallets"),g=e("@ethersproject/transactions");var b=function(e){function t(r,n){var i,o,u=this.constructor;if(h.checkNew(u,t),i=e.call(this)||this,null!=(o=r)&&c.isHexString(o.privateKey,32)&&null!=o.address){var f=new v.SigningKey(r.privateKey);if(p.defineReadOnly(i,"_signingKey",function(){return f}),p.defineReadOnly(i,"address",g.computeAddress(i.publicKey)),i.address!==s.getAddress(r.address)&&h.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var d=r.mnemonic,m=r.path||l.defaultPath;p.defineReadOnly(i,"_mnemonic",function(){return d}),p.defineReadOnly(i,"path",r.path);var y=l.HDNode.fromMnemonic(d).derivePath(m);g.computeAddress(y.privateKey)!==i.address&&h.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else p.defineReadOnly(i,"_mnemonic",function(){return null}),p.defineReadOnly(i,"path",null)}else{if(p.isNamedInstance(v.SigningKey,r))p.defineReadOnly(i,"_signingKey",function(){return r});else{var b=new v.SigningKey(r);p.defineReadOnly(i,"_signingKey",function(){return b})}p.defineReadOnly(i,"_mnemonic",function(){return null}),p.defineReadOnly(i,"path",null),p.defineReadOnly(i,"address",g.computeAddress(i.publicKey))}return n&&!p.isNamedInstance(a.Provider,n)&&h.throwError("invalid provider",h.INVALID_ARGUMENT,{argument:"provider",value:n}),p.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return p.resolveProperties(e).then(function(e){if(null!=e.from){if(s.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(d.keccak256(g.serialize(e)));return g.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(c.joinSignature(this._signingKey().signDigest(f.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),y.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=m.randomBytes(16);e||(e={}),e.extraEntropy&&(r=c.arrayify(c.hexDataSlice(d.keccak256(c.concat([r,e.extraEntropy])),0,16)));var n=l.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return y.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=l.defaultPath),new t(l.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(u.Signer);r.Wallet=b,r.verifyMessage=function(e,t){return g.recoverAddress(f.hashMessage(e),t)}},{"@ethersproject/abstract-provider":55,"@ethersproject/abstract-signer":56,"@ethersproject/address":57,"@ethersproject/bytes":63,"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/hdnode":73,"@ethersproject/json-wallets":75,"@ethersproject/keccak256":79,"@ethersproject/properties":82,"@ethersproject/random":95,"@ethersproject/signing-key":99,"@ethersproject/transactions":102}],105:[function(e,t,r){"use strict";try{t.exports.XMLHttpRequest=XMLHttpRequest}catch(e){console.log("Warning: XMLHttpRequest is not defined"),t.exports.XMLHttpRequest=null}},{}],106:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("xmlhttprequest"),o=e("@ethersproject/base64"),s=n(e("@ethersproject/errors")),a=e("@ethersproject/properties"),u=e("@ethersproject/strings");r.fetchJson=function(e,t,r){var n={},a=null,c=12e4;if("string"==typeof e)a=e;else if("object"==typeof e){if(null==e.url&&s.throwError("missing URL",s.MISSING_ARGUMENT,{arg:"url"}),a=e.url,"number"==typeof e.timeout&&e.timeout>0&&(c=e.timeout),e.headers)for(var h in e.headers)n[h.toLowerCase()]={key:h,value:String(e.headers[h])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecure&&s.throwError("basic authentication requires a secure https url",s.INVALID_ARGUMENT,{arg:"url",url:a,user:e.user,password:"[REDACTED]"});var f=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+o.encode(u.toUtf8Bytes(f))}}}return new Promise(function(e,o){var s=new i.XMLHttpRequest,u=null;u=setTimeout(function(){null!=u&&(u=null,o(new Error("timeout")),setTimeout(function(){s.abort()},0))},c);var h=function(){null!=u&&(clearTimeout(u),u=null)};t?(s.open("POST",a,!0),n["content-type"]={key:"Content-Type",value:"application/json"}):s.open("GET",a,!0),Object.keys(n).forEach(function(e){var t=n[e];s.setRequestHeader(t.key,t.value)}),s.onreadystatechange=function(){if(4===s.readyState){if(200!=s.status){h();var n=new Error("invalid response - "+s.status);return n.statusCode=s.status,s.responseText&&(n.responseText=s.responseText),void o(n)}var i=null;try{i=JSON.parse(s.responseText)}catch(n){h();var u=new Error("invalid json response");return u.orginialError=n,u.responseText=s.responseText,null!=t&&(u.requestBody=t),u.url=a,void o(u)}if(r)try{i=r(i)}catch(n){return h(),n.url=a,n.body=t,n.responseText=s.responseText,void o(n)}h(),e(i)}},s.onerror=function(e){h(),o(e)};try{null!=t?s.send(t):s.send()}catch(e){h();var f=new Error("connection error");f.error=e,o(f)}})},r.poll=function(e,t){return t||(t={}),null==(t=a.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,s=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){s()&&n(new Error("timeout"))},t.timeout));var a=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)s()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>a)return void(s()&&n(new Error("retry limit reached")));var c=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ct.ceiling&&(c=t.ceiling),setTimeout(i,c)}return null},function(e){s()&&n(e)})}()})}},{"@ethersproject/base64":58,"@ethersproject/errors":66,"@ethersproject/properties":82,"@ethersproject/strings":101,xmlhttprequest:105}],107:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./lang-en").langEn;r.en=n},{"./lang-en":108}],108:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("./wordlist"),s="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function u(e){if(null==a&&(a=s.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==o.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var c=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return u(this),a[e]},t.prototype.getWordIndex=function(e){return u(this),a.indexOf(e)},t}(o.Wordlist));r.langEn=c,o.register(c)},{"./wordlist":109}],109:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=e("@ethersproject/errors"),o=e("@ethersproject/hash"),s=e("@ethersproject/properties");r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return o.id(t.join("\n")+"\n")};var a=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),s.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=a,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||s.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||s.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||s.defineReadOnly(i.ethers.wordlists,r,e))}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@ethersproject/errors":66,"@ethersproject/hash":72,"@ethersproject/properties":82}]},{},[69])(69)}); \ No newline at end of file diff --git a/packages/ethers/package.json b/packages/ethers/package.json new file mode 100644 index 000000000..44ec6061c --- /dev/null +++ b/packages/ethers/package.json @@ -0,0 +1,60 @@ +{ + "name": "ethers", + "version": "5.0.0-beta.134", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "dist": "npm run dist-browser && npm run dist-minified", + "dist-browser": "browserify -s ethers -g ./scripts/transform index.js -o ./dist/ethers.js", + "dist-minified": "uglifyjs --compress --mangle --output ./dist/ethers.min.js -- ./dist/ethers.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abi": ">5.0.0-beta.0", + "@ethersproject/abstract-provider": ">5.0.0-beta.0", + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/base64": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/contracts": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/hash": ">5.0.0-beta.0", + "@ethersproject/hdnode": ">5.0.0-beta.0", + "@ethersproject/json-wallets": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/networks": ">5.0.0-beta.0", + "@ethersproject/pbkdf2": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/providers": ">5.0.0-beta.0", + "@ethersproject/random": ">5.0.0-beta.0", + "@ethersproject/rlp": ">5.0.0-beta.0", + "@ethersproject/sha2": ">5.0.0-beta.0", + "@ethersproject/signing-key": ">5.0.0-beta.0", + "@ethersproject/solidity": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/units": ">5.0.0-beta.0", + "@ethersproject/wallet": ">5.0.0-beta.0", + "@ethersproject/web": ">5.0.0-beta.0", + "@ethersproject/wordlists": ">5.0.0-beta.0" + }, + "devDependencies": { + "browserify": "16.2.3", + "uglify-es": "3.3.9" + }, + "browser": { + "platform.js": "browser-platform.js" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "tag": "next" + }, + "tarballHash": "0x9fcccdd98830d1bd0cc18d45a2ec5592170c442fd3346109c427689ed2aa43a1" +} diff --git a/packages/ethers/scripts/transform.js b/packages/ethers/scripts/transform.js new file mode 100644 index 000000000..d28b7cd1a --- /dev/null +++ b/packages/ethers/scripts/transform.js @@ -0,0 +1,120 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const through = require('through'); + +let show = { transformed: true, preserved: true }; + + // The elliptic package.json is only used for its version + var ellipticPackage = require('elliptic/package.json'); + ellipticPackage = JSON.stringify({ version: ellipticPackage.version }); + + var version = require('../package.json').version; + + var undef = "module.exports = undefined;"; + var empty = "module.exports = {};"; + + // This is only used in getKeyPair, which we do not use; but we'll + // leave it in tact using the browser crypto functions + var brorand = "module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; }"; + + // setImmediate is installed globally by our src.browser/shims.ts, loaded from src.ts/index.ts + var process = "module.exports = { browser: true };"; + var timers = "module.exports = { setImmediate: global.setImmediate }; "; + + function readShim(filename) { + return fs.readFileSync('./shims/' + filename + '.js').toString(); + } + + var transforms = { + + // Remove the precomputed secp256k1 points + "elliptic/lib/elliptic/precomputed/secp256k1.js": undef, + + // Remove curves we don't care about + "elliptic/curve/edwards.js": empty, + "elliptic/curve/mont.js": empty, + "elliptic/lib/elliptic/eddsa/.*": empty, + + // We only use the version from this JSON package + "elliptic/package.json" : ellipticPackage, + + // Remove RIPEMD160 and unneeded hashing algorithms + //"hash.js/lib/hash/ripemd.js": "module.exports = {ripemd160: null}", + "hash.js/lib/hash/sha/1.js": empty, + "hash.js/lib/hash/sha/224.js": empty, + "hash.js/lib/hash/sha/384.js": empty, + + // Swap out borland for the random bytes we already have + "brorand/index.js": brorand, + +// "xmlhttprequest/lib/XMLHttpRequest.js": readShim("xmlhttprequest"), + // Used by sha3 if it exists; (so make it no exist) + "process/browser.js": process, + "timers-browserify/main.js": timers, + +// "ethers.js/utils/base64.js": readShim("base64"), +// "ethers.js/providers/ipc-provider.js": readShim("empty"), +// "ethers.js/utils/hmac.js": readShim("hmac"), +// "ethers.js/utils/pbkdf2.js": readShim("pbkdf2"), +// "ethers.js/utils/random-bytes.js": readShim("random-bytes"), +// "ethers.js/utils/shims.js": readShim("shims"), +// "ethers.js/wordlists/index.js": readShim("wordlists"), + + }; + + function padding(length) { + let pad = ''; + while (pad.length < length) { pad += ' '; } + return pad; + } + + function transformFile(path) { + for (var pattern in transforms) { + if (path.match(new RegExp('/' + pattern + '$'))) { + return transforms[pattern]; + } + } + return null; + } + +const dirname = path.resolve(__dirname, '../../..'); +module.exports = function(pathname, options) { + let data = ''; + return through(function(chunk) { + data += chunk; + }, function () { + var contents = fs.readFileSync(pathname).toString(); + /* + [ 'Buffer' ].forEach((word) => { + if (contents.indexOf(word) !== -1) { + console.log("Found Bad Word:", word, "in", pathname) + } + }); + */ + var transformed = transformFile(pathname); + var shortPath = pathname; + if (shortPath.substring(0, dirname.length) == dirname) { + shortPath = shortPath.substring(dirname.length); + } + var size = fs.readFileSync(pathname).length; + if (transformed != null) { + if (show.transformed) { + console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', transformed.length); + } + data = transformed; + } else if (shortPath === '/src.ts/utils/wordlist.ts') { + data += '\n\nexportWordlist = true;' + if (show.transformed) { + console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', data.length); + } + } else { + if (show.preserved) { + console.log('Preserved: ', shortPath, padding(70 - shortPath.length), size); + } + } this.queue(data); + + this.queue(null); + }); +} diff --git a/packages/ethers/src.ts/_version.ts b/packages/ethers/src.ts/_version.ts new file mode 100644 index 000000000..911a626de --- /dev/null +++ b/packages/ethers/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.134"; diff --git a/packages/ethers/src.ts/browser-platform.ts b/packages/ethers/src.ts/browser-platform.ts new file mode 100644 index 000000000..ada08efbd --- /dev/null +++ b/packages/ethers/src.ts/browser-platform.ts @@ -0,0 +1,4 @@ +"use strict"; + +export const platform = "browser"; + diff --git a/packages/ethers/src.ts/ethers.ts b/packages/ethers/src.ts/ethers.ts new file mode 100644 index 000000000..68a448538 --- /dev/null +++ b/packages/ethers/src.ts/ethers.ts @@ -0,0 +1,135 @@ +"use strict"; + +import { Contract, ContractFactory } from "@ethersproject/contracts"; + +import { BigNumber, FixedNumber } from "@ethersproject/bignumber"; + +import { Signer, VoidSigner } from "@ethersproject/abstract-signer"; +import { Wallet } from "@ethersproject/wallet"; + +import * as constants from "@ethersproject/constants"; +import * as errors from "@ethersproject/errors"; + +import * as providers from "@ethersproject/providers"; +import * as wordlists from "@ethersproject/wordlists"; + +import * as utils from "./utils"; + +import { version } from "./_version"; + +//////////////////////// +// Types + +import { BigNumberish } from "@ethersproject/bignumber"; +import { Bytes, BytesLike, Signature } from "@ethersproject/bytes"; +import { Transaction, UnsignedTransaction } from "@ethersproject/transactions"; +import { Wordlist } from "@ethersproject/wordlists/wordlist"; + + +//////////////////////// +// Compile-Time Constants + +// This is empty in node, and used by browserify to inject extra goodies +import { platform } from "./platform"; + +// This is generated by "npm run dist" +//import { version } from "./_version"; + + +//////////////////////// +// Types + +import { + ContractFunction, + ContractReceipt, + ContractTransaction, + + Event, + EventFilter, + + Overrides, + PayableOverrides, + CallOverrides, + + ContractInterface +} from "@ethersproject/contracts"; + + +//////////////////////// +// Helper Functions + +function getDefaultProvider(network?: providers.Network | string, options?: any): providers.BaseProvider { + if (network == null) { network = "homestead"; } + let n = providers.getNetwork(network); + if (!n || !n._defaultProvider) { + errors.throwError("unsupported getDefaultProvider network", errors.NETWORK_ERROR, { + operation: "getDefaultProvider", + network: network + }); + } + return n._defaultProvider(providers, options); +} + +//////////////////////// +// Exports + +export { + version, + + Signer, + + Wallet, + VoidSigner, + + getDefaultProvider, + providers, + + Contract, + ContractFactory, + + BigNumber, + FixedNumber, + + constants, + errors, + + utils, + + wordlists, + + + //////////////////////// + // Compile-Time Constants + + platform, +// version, + + + //////////////////////// + // Types + + ContractFunction, + ContractReceipt, + ContractTransaction, + Event, + EventFilter, + + Overrides, + PayableOverrides, + CallOverrides, + + ContractInterface, + + BigNumberish, + + Bytes, + BytesLike, + + Signature, + + Transaction, + UnsignedTransaction, + + Wordlist +}; + diff --git a/packages/ethers/src.ts/index.ts b/packages/ethers/src.ts/index.ts new file mode 100644 index 000000000..b7fc3fe0e --- /dev/null +++ b/packages/ethers/src.ts/index.ts @@ -0,0 +1,7 @@ +"use strict"; + +import * as ethers from "./ethers"; + +export { ethers }; + +export * from "./ethers"; diff --git a/packages/ethers/src.ts/platform.ts b/packages/ethers/src.ts/platform.ts new file mode 100644 index 000000000..54b1039c1 --- /dev/null +++ b/packages/ethers/src.ts/platform.ts @@ -0,0 +1,3 @@ +"use strict"; + +export const platform = "node"; diff --git a/packages/ethers/src.ts/utils.ts b/packages/ethers/src.ts/utils.ts new file mode 100644 index 000000000..b6429269f --- /dev/null +++ b/packages/ethers/src.ts/utils.ts @@ -0,0 +1,160 @@ +"use strict"; + +import { AbiCoder, defaultAbiCoder, EventFragment, Fragment, FunctionFragment, Indexed, Interface, ParamType } from "@ethersproject/abi"; +import { getAddress, getContractAddress, getIcapAddress, isAddress } from "@ethersproject/address"; +import * as base64 from "@ethersproject/base64"; +import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexValue, hexZeroPad, isHexString, joinSignature, zeroPad, splitSignature, stripZeros } from "@ethersproject/bytes"; +import { hashMessage, id, namehash } from "@ethersproject/hash"; +import { entropyToMnemonic, HDNode, isValidMnemonic, mnemonicToEntropy, mnemonicToSeed } from "@ethersproject/hdnode"; +import { getJsonWalletAddress } from "@ethersproject/json-wallets"; +import { keccak256 } from "@ethersproject/keccak256"; +import { sha256 } from "@ethersproject/sha2"; +import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from "@ethersproject/solidity"; +import { randomBytes } from "@ethersproject/random"; +import { checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import * as RLP from "@ethersproject/rlp"; +import { computePublicKey, recoverPublicKey, SigningKey } from "@ethersproject/signing-key"; +import { formatBytes32String, parseBytes32String, toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; +import { computeAddress, parse as parseTransaction, recoverAddress, serialize as serializeTransaction } from "@ethersproject/transactions"; +import { commify, formatEther, parseEther, formatUnits, parseUnits } from "@ethersproject/units"; +import { verifyMessage } from "@ethersproject/wallet"; +import { fetchJson } from "@ethersproject/web"; + +//////////////////////// +// Enums + +import { SupportedAlgorithms } from "@ethersproject/sha2"; +import { UnicodeNormalizationForm } from "@ethersproject/strings"; + + +//////////////////////// +// Types and Interfaces + +import { CoerceFunc } from "@ethersproject/abi"; +import { Bytes, BytesLike, Hexable } from "@ethersproject/bytes" +import { ConnectionInfo, OnceBlockable, PollOptions } from "@ethersproject/web"; +import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets"; + +//////////////////////// +// Exports + +export { + AbiCoder, + defaultAbiCoder, + + Fragment, + EventFragment, + FunctionFragment, + ParamType, + + RLP, + + fetchJson, + + checkProperties, + deepCopy, + defineReadOnly, + resolveProperties, + shallowCopy, + + arrayify, + + concat, + stripZeros, + zeroPad, + + HDNode, + SigningKey, + + Interface, + + base64, + + hexlify, + isHexString, + hexStripZeros, + hexValue, + hexZeroPad, + hexDataLength, + hexDataSlice, + + toUtf8Bytes, + toUtf8String, + + formatBytes32String, + parseBytes32String, + + hashMessage, + namehash, + id, + + getAddress, + getIcapAddress, + getContractAddress, + isAddress, + + formatEther, + parseEther, + + formatUnits, + parseUnits, + + commify, + + keccak256, + sha256, + + randomBytes, + + solidityPack, + solidityKeccak256, + soliditySha256, + + splitSignature, + joinSignature, + + parseTransaction, + serializeTransaction, + + getJsonWalletAddress, + + computeAddress, + recoverAddress, + + computePublicKey, + recoverPublicKey, + + verifyMessage, + + mnemonicToEntropy, + entropyToMnemonic, + isValidMnemonic, + mnemonicToSeed, + + + //////////////////////// + // Enums + + SupportedAlgorithms, + UnicodeNormalizationForm, + + + //////////////////////// + // Types + + Bytes, + BytesLike, + Hexable, + + CoerceFunc, + + Indexed, + + ConnectionInfo, + OnceBlockable, + PollOptions, + + EncryptOptions, + ProgressCallback +} + diff --git a/packages/ethers/tsconfig.json b/packages/ethers/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/ethers/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/experimental/.npmignore b/packages/experimental/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/experimental/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/experimental/LICENSE.md b/packages/experimental/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/experimental/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/experimental/README.md b/packages/experimental/README.md new file mode 100644 index 000000000..34da0e869 --- /dev/null +++ b/packages/experimental/README.md @@ -0,0 +1,82 @@ +Experimental Playground +======================= + +This package is a collection of quick little ideas, which may be half-baked. + +If you find a particular feature piques your interest, please feel free to open +an issue on GitHub to discuss it. + +Also, if you have any system that requires an object from this package, make sure +you specify the **exact npm version** in your package.json, as backwards compatibility +is **NOT** guaranteed for this pacakge; APIs may change and classes may disappear. + + +Items +----- + +**BrainWallet** + +In general, a Brain Wallet is not recommended, but it is a fature we offered in v3 +and below. It allows a wallet to be described and recovered using a username and a +password. However, anyone who can guess a username and password can steal the funds, +and the password cannot be changed. But for backwards compatibility and for simple +testing, we provide it here. + +```javascript +import { BrainWallet } from "@ethersproject/experimenatl/brain-wallet"; + +// This is optional, but since a Brain Wallet can take 5-10s to generate, +// helps keep your users informed +function showProgress(percent) { + if (percent === 1) { + console.log("Done."); + } else { + console.log("Completed: " + Math.trunc(100 * percent) + "%"); + } +} + +// Generate a legacy-compatible Brain Wallet +BrainWallet.generateLegacy(username, password, showProgress).then((wallet) => { + console.log(wallet); +}); + +// Generate a new-style Brain Wallet, which contains a Mnemonic Phrase too +BrainWallet.generate(username, password, showProgess).then((wallet) => { + console.log(wallet); +}); +``` + +**NonceManager** + +```javascript +import { NonceManager } from "@ethersproject/experimenatl/nonce-manager"; + +let signer = "... any way you get a signer ..."; + +// The NonceManager Signer will automatically manage the nonce for you +// so you may blast the network with as many transactions as you would +// like. Transactions which have not been mined within XXX timeout and +// will be rebroadcast; keep in mind that unmined transactions remain +// in memory. +let managedSigner = new NonceManager(signer); +``` + +**RetryProvider** + +```javascript +import { RetryProvider } from "@ethersproject/experimenatl/retry-provider"; + +let provider = "... any way you get a signer..."; + +// All options are optional +let options = { +} + +let retryProivder = new RetryProvider(provider, options); +``` + + +License +------- + +MIT License. diff --git a/packages/experimental/package.json b/packages/experimental/package.json new file mode 100644 index 000000000..a62f397d4 --- /dev/null +++ b/packages/experimental/package.json @@ -0,0 +1,24 @@ +{ + "name": "@ethersproject/experimental", + "version": "5.0.0-beta.126", + "description": "Experimental libraries for ethers. These should not be considered stable.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/web": ">5.0.0-beta.0", + "ethers": ">5.0.0-beta.0", + "scrypt-js": "2.0.4" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x03208a62350c0f5fb087f77c922c55eecb3dba2d86e2a445bf30d5993b19fa09" +} diff --git a/packages/experimental/src.ts/_version.ts b/packages/experimental/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/experimental/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/experimental/src.ts/brain-wallet.ts b/packages/experimental/src.ts/brain-wallet.ts new file mode 100644 index 000000000..4a52391c3 --- /dev/null +++ b/packages/experimental/src.ts/brain-wallet.ts @@ -0,0 +1,76 @@ +"use strict"; + +import { ethers } from "ethers"; + +import scrypt from "scrypt-js"; + +let warned = false; + +export class BrainWallet extends ethers.Wallet { + + static _generate(username: ethers.Bytes | string, password: ethers.Bytes | string, legacy: boolean, progressCallback?: ethers.utils.ProgressCallback): Promise { + if (!warned) { + ethers.errors.warn("Warning: using Brain Wallets should be considered insecure (this warning will not be repeated)"); + warned = true; + } + let usernameBytes: Uint8Array = null; + let passwordBytes: Uint8Array = null; + + if (typeof(username) === 'string') { + ethers.errors.checkNormalize(); + usernameBytes = ethers.utils.toUtf8Bytes(username.normalize('NFKC')); + } else { + usernameBytes = ethers.utils.arrayify(username); + } + + if (typeof(password) === 'string') { + ethers.errors.checkNormalize(); + passwordBytes = ethers.utils.toUtf8Bytes(password.normalize('NFKC')); + } else { + passwordBytes = ethers.utils.arrayify(password); + } + + return new Promise((resolve, reject) => { + scrypt(passwordBytes, usernameBytes, (1 << 18), 8, 1, 32, (error: Error, progress: number, key: Uint8Array) => { + if (error) { + reject(error); + + } else if (key) { + if (legacy) { + resolve(new BrainWallet(key)); + + } else { + let mnemonic = ethers.utils.entropyToMnemonic(ethers.utils.arrayify(key).slice(0, 16)); + resolve(new BrainWallet(ethers.Wallet.fromMnemonic(mnemonic))); + } + + } else if (progressCallback) { + return progressCallback(progress); + } + }); + }); + } + + static generate(username: ethers.Bytes | string, password: ethers.Bytes | string, progressCallback?: ethers.utils.ProgressCallback): Promise { + return BrainWallet._generate(username, password, false, progressCallback); + } + + static generateLegacy(username: ethers.Bytes | string, password: ethers.Bytes | string, progressCallback?: ethers.utils.ProgressCallback): Promise { + return BrainWallet._generate(username, password, true, progressCallback); + } +} + +/* +// Test Legacy correctly matches our old test-vector: +// See: https://github.com/ethers-io/ethers.js/blob/3bf39b3bee0834566243211783ed8ec052c2f950/tests/test-wallet.js#L13 +BrainWallet.generateLegacy("ricmoo", "password").then((wallet) => { + console.log("Expected:", "0xbed9d2E41BdD066f702C4bDB86eB3A3740101acC"); + console.log(wallet); +}); + + +BrainWallet.generate("ricmoo", "password").then((wallet) => { + console.log("Expected:", "0xbed9d2E41BdD066f702C4bDB86eB3A3740101acC"); + console.log(wallet); +}); +*/ diff --git a/packages/experimental/src.ts/index.ts b/packages/experimental/src.ts/index.ts new file mode 100644 index 000000000..23e72fdc5 --- /dev/null +++ b/packages/experimental/src.ts/index.ts @@ -0,0 +1,2 @@ +"use strict"; + diff --git a/packages/experimental/src.ts/metamask-provider.ts b/packages/experimental/src.ts/metamask-provider.ts new file mode 100644 index 000000000..75eb282bb --- /dev/null +++ b/packages/experimental/src.ts/metamask-provider.ts @@ -0,0 +1,73 @@ +"use strict"; + +import { ethers } from "ethers"; + + +export class MetamaskProvider extends ethers.providers.Web3Provider { + + _pollingAccount: any; + _pollAccountFunc: () => void; + + constructor(ethereum?: ethers.providers.AsyncSendable) { + if (!ethereum) { + ethereum = (global).ethereum; + if (!ethereum) { + ethers.errors.throwError("could not auto-detect global.ethereum", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "window.ethereum" + }); + } + } + + super(ethereum); + + let _account: string = null; + ethers.utils.defineReadOnly(this, "_pollAccountFunc", () => { + let account: string = null; + if (account === _account) { return; } + console.log("poll"); + this.emit("account", account, _account); + _account = account; + }); + + super(ethereum); + } + + getSigner(addressOrIndex?: string | number): ethers.providers.JsonRpcSigner { + if (!this.enabled) { return null } + return super.getSigner(addressOrIndex); + } + + get enabled(): boolean { + return false; + } + + _startPollingAccount(): void { + if (this._pollingAccount) { return; } + console.log("start polling for account changes including to/from null"); + this._pollingAccount = setInterval(this._pollAccountFunc, 1000); + } + + _stopPollingAccount(): void { + if (!this._pollingAccount) { return; } + console.log("stop polling for account changes including to/from null"); + clearInterval(this._pollingAccount); + this._pollingAccount = null; + } + + on(eventName: ethers.providers.EventType, listener: ethers.providers.Listener): this { + super.on(eventName, listener); + if (this.listenerCount("account") > 0) { + this._startPollingAccount(); + } + return this; + } + + off(eventName: ethers.providers.EventType, listener?: ethers.providers.Listener): this { + super.off(eventName, listener); + if (this.listenerCount("account") === 0) { + this._stopPollingAccount(); + } + return this; + } + +} diff --git a/packages/experimental/src.ts/nonce-manager.ts b/packages/experimental/src.ts/nonce-manager.ts new file mode 100644 index 000000000..fad231900 --- /dev/null +++ b/packages/experimental/src.ts/nonce-manager.ts @@ -0,0 +1,68 @@ +"use strict" + +import { ethers } from "ethers"; + +export class NonceManager extends ethers.Signer { + readonly signer: ethers.Signer; + readonly provider: ethers.providers.Provider; + + _transactionCount: Promise; + + constructor(signer: ethers.Signer) { + ethers.errors.checkNew(new.target, NonceManager); + super(); + ethers.utils.defineReadOnly(this, "signer", signer); + } + + connect(provider: ethers.providers.Provider): NonceManager { + return new NonceManager(this.signer.connect(provider)); + } + + getAddress(): Promise { + return this.signer.getAddress(); + } + + getTransactionCount(blockTag?: ethers.providers.BlockTag): Promise { + if (blockTag === "pending") { + if (!this._transactionCount) { + this._transactionCount = this.signer.getTransactionCount("pending"); + } + return this._transactionCount; + } + + return this.signer.getTransactionCount(blockTag); + } + + setTransactionCount(transactionCount: ethers.BigNumberish | Promise): void { + this._transactionCount = Promise.resolve(transactionCount).then((nonce) => { + return ethers.BigNumber.from(nonce).toNumber(); + }); + } + + incrementTransactionCount(count?: number): void { + if (!count) { count = 1; } + this._transactionCount = this.getTransactionCount("pending").then((nonce) => { + return nonce + count; + }); + } + + signMessage(message: ethers.Bytes | string): Promise { + return this.signer.signMessage(message);; + } + + signTransaction(transaction: ethers.providers.TransactionRequest): Promise { + return this.signer.signTransaction(transaction); + } + + sendTransaction(transaction: ethers.providers.TransactionRequest): Promise { + if (transaction.nonce == null) { + transaction = ethers.utils.shallowCopy(transaction); + transaction.nonce = this.getTransactionCount(); + } + + this.setTransactionCount(transaction.nonce); + + return this.signer.sendTransaction(transaction); + } + +} diff --git a/packages/experimental/src.ts/retry-provider.ts b/packages/experimental/src.ts/retry-provider.ts new file mode 100644 index 000000000..ec6a0e32b --- /dev/null +++ b/packages/experimental/src.ts/retry-provider.ts @@ -0,0 +1,51 @@ +"use strict"; + +// RetryProvider +// +// Wraps an existing Provider to provide retry logic. +// +// See: https://github.com/ethers-io/ethers.js/issues/427 + + +import { ethers } from "ethers"; +import { poll } from "@ethersproject/web"; + + +export type RetryOptions = { + // Maximum time in total to retry + timeout?: number, + + // Minimum Duration to wait between retries + floor?: number, + + // Maximum Duration to wait between retries + ceiling?: number, + + // The slot interval for exponential back-off + interval?: number, + + // Maximum number of times to rety + retryLimit?: number +}; + +export class RetryProvider extends ethers.providers.BaseProvider { + readonly provider: ethers.providers.BaseProvider; + readonly options: RetryOptions; + + constructor(provider: ethers.providers.BaseProvider, options?: RetryOptions) { + ethers.errors.checkNew(new.target, RetryProvider); + super(provider.getNetwork()); + ethers.utils.defineReadOnly(this, "provider", provider); + ethers.utils.defineReadOnly(this, "options", options || { }); + } + + perform(method: string, params: any): Promise { + return poll(() => { + return this.provider.perform(method, params).then((result) => { + return result + }, (error) => { + return undefined + }); + }, this.options); + } +} diff --git a/packages/experimental/thirdparty.d.ts b/packages/experimental/thirdparty.d.ts new file mode 100644 index 000000000..a49e518b2 --- /dev/null +++ b/packages/experimental/thirdparty.d.ts @@ -0,0 +1,7 @@ +declare module "scrypt-js" { + export class ScryptError extends Error { + progress: number; + } + export type ScryptCallback = (error: ScryptError, progress: number, key: Uint8Array) => void; + export default function(password: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, callback: ScryptCallback): void; +} diff --git a/packages/experimental/tsconfig.json b/packages/experimental/tsconfig.json new file mode 100644 index 000000000..f09aa6ba8 --- /dev/null +++ b/packages/experimental/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts", + "./thirdparty.d.ts" + ], + "exclude": [ ] +} + diff --git a/packages/hash/.npmignore b/packages/hash/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/hash/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/hash/LICENSE.md b/packages/hash/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/hash/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/hash/README.md b/packages/hash/README.md new file mode 100644 index 000000000..c2a48b211 --- /dev/null +++ b/packages/hash/README.md @@ -0,0 +1,17 @@ +Etheruem Hash Utilities +======================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/hash/package.json b/packages/hash/package.json new file mode 100644 index 000000000..0e0f16203 --- /dev/null +++ b/packages/hash/package.json @@ -0,0 +1,25 @@ +{ + "name": "@ethersproject/hash", + "version": "5.0.0-beta.124", + "description": "Hash utility functions for Ethereum.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xb57fea0e087099e9814038a44a3462bedfeea17aa424e24d7a05e4e23212b298" +} diff --git a/packages/hash/src.ts/_version.ts b/packages/hash/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/hash/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/hash/src.ts/index.ts b/packages/hash/src.ts/index.ts new file mode 100644 index 000000000..cd61a0a8d --- /dev/null +++ b/packages/hash/src.ts/index.ts @@ -0,0 +1,64 @@ +"use strict"; + +// @TODO: Migrate this to a better named package... + +import * as errors from "@ethersproject/errors"; + +import { Bytes, concat, hexlify } from "@ethersproject/bytes"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { keccak256 } from "@ethersproject/keccak256"; + +/////////////////////////////// + +const Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); +const Partition = new RegExp("^((.*)\\.)?([^.]+)$"); +const UseSTD3ASCIIRules = new RegExp("^[a-z0-9.-]*$"); + +export function namehash(name: string): string { + if (typeof(name) !== "string") { + errors.throwError("invalid address - " + String(name), errors.INVALID_ARGUMENT, { + argument: "name", + value: name + }); + } + + name = name.toLowerCase(); + + // Supporting the full UTF-8 space requires additional (and large) + // libraries, so for now we simply do not support them. + // It should be fairly easy in the future to support systems with + // String.normalize, but that is future work. + if (!name.match(UseSTD3ASCIIRules)) { + errors.throwError("contains invalid UseSTD3ASCIIRules characters", errors.INVALID_ARGUMENT, { + argument: "name", + value: name + }); + } + + let result: string | Uint8Array = Zeros; + while (name.length) { + let partition = name.match(Partition); + let label = toUtf8Bytes(partition[3]); + result = keccak256(concat([result, keccak256(label)])); + + name = partition[2] || ""; + } + + return hexlify(result); +} + + +export function id(text: string): string { + return keccak256(toUtf8Bytes(text)); +} + +export const messagePrefix = "\x19Ethereum Signed Message:\n"; + +export function hashMessage(message: Bytes | string): string { + if (typeof(message) === "string") { message = toUtf8Bytes(message); } + return keccak256(concat([ + toUtf8Bytes(messagePrefix), + toUtf8Bytes(String(message.length)), + message + ])); +} diff --git a/packages/hash/tsconfig.json b/packages/hash/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/hash/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/hdnode/.npmignore b/packages/hdnode/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/hdnode/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/hdnode/LICENSE.md b/packages/hdnode/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/hdnode/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/hdnode/README.md b/packages/hdnode/README.md new file mode 100644 index 000000000..eb8597b9f --- /dev/null +++ b/packages/hdnode/README.md @@ -0,0 +1,17 @@ +Hierarchal Deterministic Utilities (BIP32) +========================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/hdnode/package.json b/packages/hdnode/package.json new file mode 100644 index 000000000..4875555ee --- /dev/null +++ b/packages/hdnode/package.json @@ -0,0 +1,33 @@ +{ + "name": "@ethersproject/hdnode", + "version": "5.0.0-beta.125", + "description": "BIP32 Hierarchal Deterministic Node operations.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/basex": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/pbkdf2": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/sha2": ">5.0.0-beta.0", + "@ethersproject/signing-key": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/wordlists": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xa4ea4ba02e4291ed5731089d4cfddf37e6567ea5195342fc884a5cb39083e1b7" +} diff --git a/packages/hdnode/src.ts/_version.ts b/packages/hdnode/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/hdnode/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/hdnode/src.ts/index.ts b/packages/hdnode/src.ts/index.ts new file mode 100644 index 000000000..1c71fc184 --- /dev/null +++ b/packages/hdnode/src.ts/index.ts @@ -0,0 +1,362 @@ +"use strict"; + +// See: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki +// See: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki + + +// The English language word list. +// For additional word lists, please see @ethersproject//wordlists +import { langEn } from "@ethersproject/wordlists/lang-en"; + +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { Base58 } from "@ethersproject/basex"; +import * as errors from "@ethersproject/errors"; +import { arrayify, BytesLike, concat, hexDataSlice, hexZeroPad, hexlify } from "@ethersproject/bytes"; +import { BigNumber } from "@ethersproject/bignumber"; +import { toUtf8Bytes, UnicodeNormalizationForm } from "@ethersproject/strings"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { defineReadOnly } from "@ethersproject/properties"; +import { SigningKey } from "@ethersproject/signing-key"; +import { computeHmac, ripemd160, sha256, SupportedAlgorithms } from "@ethersproject/sha2"; +import { computeAddress } from "@ethersproject/transactions"; + +const N = BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + +import { Wordlist } from "@ethersproject/wordlists/wordlist"; + + +// "Bitcoin seed" +const MasterSecret = toUtf8Bytes("Bitcoin seed"); + +const HardenedBit = 0x80000000; + +// Returns a byte with the MSB bits set +function getUpperMask(bits: number): number { + return ((1 << bits) - 1) << (8 - bits); +} + +// Returns a byte with the LSB bits set +function getLowerMask(bits: number): number { + return (1 << bits) - 1; +} + +function bytes32(value: BigNumber | Uint8Array): string { + return hexZeroPad(hexlify(value), 32); +} + +function base58check(data: Uint8Array): string { + let checksum = hexDataSlice(sha256(sha256(data)), 0, 4); + return Base58.encode(concat([ data, checksum ])); +} + +const _constructorGuard: any = {}; + +export const defaultPath = "m/44'/60'/0'/0/0"; + +export class HDNode implements ExternallyOwnedAccount { + readonly privateKey: string; + readonly publicKey: string; + + readonly fingerprint: string; + readonly parentFingerprint: string; + + readonly address: string; + + readonly mnemonic: string; + readonly path: string; + + readonly chainCode: string; + + readonly index: number; + readonly depth: number; + + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + constructor(constructorGuard: any, privateKey: string, publicKey: string, parentFingerprint: string, chainCode: string, index: number, depth: number, mnemonic: string, path: string) { + errors.checkNew(new.target, HDNode); + + if (constructorGuard !== _constructorGuard) { + throw new Error("HDNode constructor cannot be called directly"); + } + + if (privateKey) { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "privateKey", signingKey.privateKey); + defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); + } else { + defineReadOnly(this, "privateKey", null); + defineReadOnly(this, "publicKey", hexlify(publicKey)); + } + + defineReadOnly(this, "parentFingerprint", parentFingerprint); + defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4)); + + defineReadOnly(this, "address", computeAddress(this.publicKey)); + + defineReadOnly(this, "chainCode", chainCode); + + defineReadOnly(this, "index", index); + defineReadOnly(this, "depth", depth); + + defineReadOnly(this, "mnemonic", mnemonic); + defineReadOnly(this, "path", path); + } + + get extendedKey(): string { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current senitment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + + if (this.depth >= 256) { throw new Error("Depth too large!"); } + + return base58check(concat([ + ((this.privateKey != null) ? "0x0488ADE4": "0x0488B21E"), + hexlify(this.depth), + this.parentFingerprint, + hexZeroPad(hexlify(this.index), 4), + this.chainCode, + ((this.privateKey != null) ? concat([ "0x00", this.privateKey ]): this.publicKey), + ])); + } + + neuter(): HDNode { + return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); + } + + private _derive(index: number): HDNode { + if (index > 0xffffffff) { throw new Error("invalid index - " + String(index)); } + + // Base path + let path = this.path; + if (path) { path += "/" + (index & ~HardenedBit); } + + let data = new Uint8Array(37); + + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); + } + + // Data = 0x00 || ser_256(k_par) + data.set(arrayify(this.privateKey), 1); + + // Hardened path + if (path) { path += "'"; } + + } else { + // Data = ser_p(point(k_par)) + data.set(arrayify(this.publicKey)); + } + + // Data += ser_32(i) + for (let i = 24; i >= 0; i -= 8) { data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); } + + let I = arrayify(computeHmac(SupportedAlgorithms.sha512, this.chainCode, data)); + let IL = I.slice(0, 32); + let IR = I.slice(32); + + // The private key + + let ki: string = null + // The public key + let Ki: string = null; + + if (this.privateKey) { + ki = bytes32(BigNumber.from(IL).add(this.privateKey).mod(N)); + } else { + let ek = new SigningKey(hexlify(IL)); + Ki = ek._addPoint(this.publicKey); + } + + return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); + } + + derivePath(path: string): HDNode { + let components = path.split("/"); + + if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { + throw new Error("invalid path - " + path); + } + + if (components[0] === "m") { components.shift(); } + + let result: HDNode = this; + for (let i = 0; i < components.length; i++) { + let component = components[i]; + if (component.match(/^[0-9]+'$/)) { + let index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { throw new Error("invalid path index - " + component); } + result = result._derive(HardenedBit + index); + } else if (component.match(/^[0-9]+$/)) { + let index = parseInt(component); + if (index >= HardenedBit) { throw new Error("invalid path index - " + component); } + result = result._derive(index); + } else { + throw new Error("invlaid path component - " + component); + } + } + + return result; + } + + + static _fromSeed(seed: BytesLike, mnemonic: string): HDNode { + let seedArray: Uint8Array = arrayify(seed); + if (seedArray.length < 16 || seedArray.length > 64) { throw new Error("invalid seed"); } + + let I: Uint8Array = arrayify(computeHmac(SupportedAlgorithms.sha512, MasterSecret, seedArray)); + + return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); + } + + static fromMnemonic(mnemonic: string, password?: string, wordlist?: Wordlist): HDNode { + // Check that the checksum s valid (will throw an error) + mnemonicToEntropy(mnemonic, wordlist); + + return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); + } + + static fromSeed(seed: BytesLike): HDNode { + return HDNode._fromSeed(seed, null); + } + + static fromExtendedKey(extendedKey: string): HDNode { + let bytes = Base58.decode(extendedKey); + + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + errors.throwError("invalid extended key", errors.INVALID_ARGUMENT, { + argument: "extendedKey", + value: "[REDACTED]" + }); + } + + let depth = bytes[4]; + let parentFingerprint = hexlify(bytes.slice(5, 9)); + let index = parseInt(hexlify(bytes.slice(9, 13)).substring(2), 16); + let chainCode = hexlify(bytes.slice(13, 45)); + let key = bytes.slice(45, 78); + + switch (hexlify(bytes.slice(0, 4))) { + // Public Key + case "0x0488b21e": case "0x043587cf": + return new HDNode(_constructorGuard, null, hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + + // Private Key + case "0x0488ade4": case "0x04358394 ": + if (key[0] !== 0) { break; } + return new HDNode(_constructorGuard, hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + } + + return errors.throwError("invalid extended key", errors.INVALID_ARGUMENT, { + argument: "extendedKey", + value: "[REDACTED]" + }); + + } +} + +export function mnemonicToSeed(mnemonic: string, password?: string): string { + if (!password) { password = ""; } + + let salt = toUtf8Bytes("mnemonic" + password, UnicodeNormalizationForm.NFKD); + + return pbkdf2(toUtf8Bytes(mnemonic, UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); +} + +export function mnemonicToEntropy(mnemonic: string, wordlist?: Wordlist): string { + if (!wordlist) { wordlist = langEn; } + + errors.checkNormalize(); + + let words = wordlist.split(mnemonic); + if ((words.length % 3) !== 0) { throw new Error("invalid mnemonic"); } + + let entropy = arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + + let offset = 0; + for (let i = 0; i < words.length; i++) { + let index = wordlist.getWordIndex(words[i].normalize("NFKD")); + if (index === -1) { throw new Error("invalid mnemonic"); } + + for (let bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + + let entropyBits = 32 * words.length / 3; + + let checksumBits = words.length / 3; + let checksumMask = getUpperMask(checksumBits); + + let checksum = arrayify(sha256(entropy.slice(0, entropyBits / 8)))[0]; + checksum &= checksumMask; + + if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { + throw new Error("invalid checksum"); + } + + return hexlify(entropy.slice(0, entropyBits / 8)); +} + +export function entropyToMnemonic(entropy: BytesLike, wordlist?: Wordlist): string { + entropy = arrayify(entropy); + + if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { + throw new Error("invalid entropy"); + } + + let indices: Array = [ 0 ]; + + let remainingBits = 11; + for (let i = 0; i < entropy.length; i++) { + + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + + remainingBits -= 8; + + // This byte will complete an 11-bit index + } else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + + remainingBits += 3; + } + } + + // Compute the checksum bits + let checksum = arrayify(sha256(entropy))[0]; + let checksumBits = entropy.length / 4; + checksum &= getUpperMask(checksumBits); + + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + + if (!wordlist) { wordlist = langEn; } + + return wordlist.join(indices.map((index) => wordlist.getWord(index))); +} + +export function isValidMnemonic(mnemonic: string, wordlist?: Wordlist): boolean { + try { + mnemonicToEntropy(mnemonic, wordlist); + return true; + } catch (error) { } + return false; +} diff --git a/packages/hdnode/tsconfig.json b/packages/hdnode/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/hdnode/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/json-wallets/.npmignore b/packages/json-wallets/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/json-wallets/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/json-wallets/LICENSE.md b/packages/json-wallets/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/json-wallets/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/json-wallets/README.md b/packages/json-wallets/README.md new file mode 100644 index 000000000..9531cc324 --- /dev/null +++ b/packages/json-wallets/README.md @@ -0,0 +1,17 @@ +Secret Storage JSON Wallet Utilities +==================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/json-wallets/package.json b/packages/json-wallets/package.json new file mode 100644 index 000000000..b685f452d --- /dev/null +++ b/packages/json-wallets/package.json @@ -0,0 +1,35 @@ +{ + "name": "@ethersproject/json-wallets", + "version": "5.0.0-beta.124", + "description": "Wallet management utilities for KeyStore and Crowdsale JSON wallets.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/hdnode": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/pbkdf2": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/random": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "aes-js": "3.0.0", + "scrypt-js": "2.0.4", + "uuid": "2.0.1" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x4d9580ee8583276571285078677d76242e93047965013975d7c335e5aa97a3ac" +} diff --git a/packages/json-wallets/src.ts/_version.ts b/packages/json-wallets/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/json-wallets/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/json-wallets/src.ts/crowdsale.ts b/packages/json-wallets/src.ts/crowdsale.ts new file mode 100644 index 000000000..98f2bf86e --- /dev/null +++ b/packages/json-wallets/src.ts/crowdsale.ts @@ -0,0 +1,70 @@ +"use strict"; + +import aes from "aes-js"; + +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { getAddress } from "@ethersproject/address"; +import { arrayify, Bytes } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { keccak256 } from "@ethersproject/keccak256"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { Description } from "@ethersproject/properties"; + +import { getPassword, looseArrayify, searchPath } from "./utils"; + +export class CrowdsaleAccount extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + + isType(value: any): value is CrowdsaleAccount { + return Description.isType(value); + } +} + +// See: https://github.com/ethereum/pyethsaletool +export function decrypt(json: string, password: Bytes | string): ExternallyOwnedAccount { + let data = JSON.parse(json); + + password = getPassword(password); + + // Ethereum Address + let ethaddr = getAddress(searchPath(data, "ethaddr")); + + // Encrypted Seed + let encseed = looseArrayify(searchPath(data, "encseed")); + if (!encseed || (encseed.length % 16) !== 0) { + errors.throwError("invalid encseed", errors.INVALID_ARGUMENT, { + argument: "json", + value: json + }); + } + + let key = arrayify(pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); + + let iv = encseed.slice(0, 16); + let encryptedSeed = encseed.slice(16); + + // Decrypt the seed + let aesCbc = new aes.ModeOfOperation.cbc(key, iv); + let seed = arrayify(aesCbc.decrypt(encryptedSeed)); + seed = aes.padding.pkcs7.strip(seed); + + // This wallet format is weird... Convert the binary encoded hex to a string. + let seedHex = ""; + for (let i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + + let seedHexBytes = toUtf8Bytes(seedHex); + + let privateKey = keccak256(seedHexBytes); + + return new CrowdsaleAccount ({ + address: ethaddr, + privateKey: privateKey + }); +} + diff --git a/packages/json-wallets/src.ts/index.ts b/packages/json-wallets/src.ts/index.ts new file mode 100644 index 000000000..a56d7b9fb --- /dev/null +++ b/packages/json-wallets/src.ts/index.ts @@ -0,0 +1,39 @@ +"use strict"; + +import { Bytes } from "@ethersproject/bytes"; +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; + +import { decrypt as decryptCrowdsale } from "./crowdsale"; +import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect"; +import { decrypt as decryptKeystore, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore"; + +function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise { + if (isCrowdsaleWallet(json)) { + if (progressCallback) { progressCallback(0); } + let account = decryptCrowdsale(json, password) + if (progressCallback) { progressCallback(1); } + return Promise.resolve(account); + } + + if (isKeystoreWallet(json)) { + return decryptKeystore(json, password, progressCallback); + } + + return Promise.reject(new Error("invalid JSON wallet")); +} + +export { + decryptCrowdsale, + + decryptKeystore, + encryptKeystore, + + isCrowdsaleWallet, + isKeystoreWallet, + getJsonWalletAddress, + + decryptJsonWallet, + + ProgressCallback, + EncryptOptions, +}; diff --git a/packages/json-wallets/src.ts/inspect.ts b/packages/json-wallets/src.ts/inspect.ts new file mode 100644 index 000000000..eac413a73 --- /dev/null +++ b/packages/json-wallets/src.ts/inspect.ts @@ -0,0 +1,48 @@ +"use strict"; + +import { getAddress } from "@ethersproject/address"; + + +export function isCrowdsaleWallet(json: string): boolean { + let data: any = null; + try { + data = JSON.parse(json); + } catch (error) { return false; } + + return (data.encseed && data.ethaddr); +} + +export function isKeystoreWallet(json: string): boolean { + let data: any = null; + try { + data = JSON.parse(json); + } catch (error) { return false; } + + if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { + return false; + } + + // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff + return true; +} + +//export function isJsonWallet(json: string): boolean { +// return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); +//} + +export function getJsonWalletAddress(json: string): string { + if (isCrowdsaleWallet(json)) { + try { + return getAddress(JSON.parse(json).ethaddr); + } catch (error) { return null; } + } + + if (isKeystoreWallet(json)) { + try { + return getAddress(JSON.parse(json).address); + } catch (error) { return null; } + } + + return null; +} + diff --git a/packages/json-wallets/src.ts/keystore.ts b/packages/json-wallets/src.ts/keystore.ts new file mode 100644 index 000000000..8d7e8fea5 --- /dev/null +++ b/packages/json-wallets/src.ts/keystore.ts @@ -0,0 +1,374 @@ +"use strict"; + +import aes from "aes-js"; +import scrypt from "scrypt-js"; +import uuid from "uuid"; + +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { getAddress } from "@ethersproject/address"; +import { arrayify, Bytes, BytesLike, concat, hexlify } from "@ethersproject/bytes"; +import { defaultPath, entropyToMnemonic, HDNode, mnemonicToEntropy } from "@ethersproject/hdnode"; +import { keccak256 } from "@ethersproject/keccak256"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { randomBytes } from "@ethersproject/random"; +import { Description } from "@ethersproject/properties"; +import { computeAddress } from "@ethersproject/transactions"; + +import { getPassword, looseArrayify, searchPath, zpad } from "./utils"; + +// Exported Types + +export class KeystoreAccount extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + + isType(value: any): value is KeystoreAccount { + return Description.isType(value); + } +} + +export type ProgressCallback = (percent: number) => void; + +export type EncryptOptions = { + iv?: BytesLike; + entropy?: BytesLike; + client?: string; + salt?: BytesLike; + uuid?: string; + scrypt?: { + N?: number; + r?: number; + p?: number; + } +} + +export function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise { + let data = JSON.parse(json); + + let passwordBytes = getPassword(password); + + let decrypt = function(key: Uint8Array, ciphertext: Uint8Array): Uint8Array { + let cipher = searchPath(data, "crypto/cipher"); + if (cipher === "aes-128-ctr") { + let iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv")) + let counter = new aes.Counter(iv); + + let aesCtr = new aes.ModeOfOperation.ctr(key, counter); + + return arrayify(aesCtr.decrypt(ciphertext)); + } + + return null; + }; + + let computeMAC = function(derivedHalf: Uint8Array, ciphertext: Uint8Array) { + return keccak256(concat([ derivedHalf, ciphertext ])); + } + + let getAccount = function(key: Uint8Array, reject: (error?: Error) => void) { + let ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext")); + + let computedMAC = hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) { + reject(new Error("invalid password")); + return null; + } + + let privateKey = decrypt(key.slice(0, 16), ciphertext); + let mnemonicKey = key.slice(32, 64); + + if (!privateKey) { + reject(new Error("unsupported cipher")); + return null; + } + + let address = data.address.toLowerCase(); + if (address.substring(0, 2) !== "0x") { address = "0x" + address; } + + try { + if (getAddress(address) !== computeAddress(privateKey)) { + reject(new Error("address mismatch")); + return null; + } + } catch (e) { } + + let account: any = { + address: address, + privateKey: hexlify(privateKey) + }; + + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + if (searchPath(data, "x-ethers/version") === "0.1") { + let mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext")); + let mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter")); + + let mnemonicCounter = new aes.Counter(mnemonicIv); + let mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + + let path = searchPath(data, "x-ethers/path") || defaultPath; + + let entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + let mnemonic = entropyToMnemonic(entropy); + + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + + if (node.privateKey != account.privateKey) { + reject(new Error("mnemonic mismatch")); + return null; + } + + account.mnemonic = node.mnemonic; + account.path = node.path; + } + + return new KeystoreAccount(account); + } + + + return new Promise(function(resolve, reject) { + let kdf = searchPath(data, "crypto/kdf"); + if (kdf && typeof(kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + let N = parseInt(searchPath(data, "crypto/kdfparams/n")); + let r = parseInt(searchPath(data, "crypto/kdfparams/r")); + let p = parseInt(searchPath(data, "crypto/kdfparams/p")); + if (!N || !r || !p) { + reject(new Error("unsupported key-derivation function parameters")); + return; + } + + // Make sure N is a power of 2 + if ((N & (N - 1)) !== 0) { + reject(new Error("unsupported key-derivation function parameter value for N")); + return; + } + + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject( new Error("unsupported key-derivation derived-key length")); + return; + } + + if (progressCallback) { progressCallback(0); } + scrypt(passwordBytes, salt, N, r, p, 64, function(error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + + } else if (key) { + key = arrayify(key); + + let account = getAccount(key, reject); + if (!account) { return; } + + if (progressCallback) { progressCallback(1); } + resolve(account); + + } else if (progressCallback) { + return progressCallback(progress); + } + }); + + } else if (kdf.toLowerCase() === "pbkdf2") { + + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + + let prfFunc = null; + let prf = searchPath(data, "crypto/kdfparams/prf"); + if (prf === "hmac-sha256") { + prfFunc = "sha256"; + } else if (prf === "hmac-sha512") { + prfFunc = "sha512"; + } else { + reject(new Error("unsupported prf")); + return; + } + + let c = parseInt(searchPath(data, "crypto/kdfparams/c")); + + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject( new Error("unsupported key-derivation derived-key length")); + return; + } + + let key = arrayify(pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); + + let account = getAccount(key, reject); + if (!account) { return; } + + resolve(account); + + } else { + reject(new Error("unsupported key-derivation function")); + } + + } else { + reject(new Error("unsupported key-derivation function")); + } + }); +} + +export function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise { + + try { + if (getAddress(account.address) !== computeAddress(account.privateKey)) { + throw new Error("address/privateKey mismatch"); + } + + if (account.mnemonic != null){ + let node = HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || defaultPath); + + if (node.privateKey != account.privateKey) { + throw new Error("mnemonic mismatch"); + } + } else if (account.path != null) { + throw new Error("cannot specify path without mnemonic"); + } + + } catch (e) { + return Promise.reject(e); + } + + // the options are optional, so adjust the call as needed + if (typeof(options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (!options) { options = {}; } + + let privateKey: Uint8Array = arrayify(account.privateKey); + let passwordBytes = getPassword(password); + + let entropy: Uint8Array = null + let path: string = account.path; + if (account.mnemonic) { + entropy = arrayify(mnemonicToEntropy(account.mnemonic)); + if (!path) { path = defaultPath; } + } + + let client = options.client; + if (!client) { client = "ethers.js"; } + + // Check/generate the salt + let salt: Uint8Array = null; + if (options.salt) { + salt = arrayify(options.salt); + } else { + salt = randomBytes(32);; + } + + // Override initialization vector + let iv: Uint8Array = null; + if (options.iv) { + iv = arrayify(options.iv); + if (iv.length !== 16) { throw new Error("invalid iv"); } + } else { + iv = randomBytes(16); + } + + // Override the uuid + let uuidRandom: Uint8Array = null; + if (options.uuid) { + uuidRandom = arrayify(options.uuid); + if (uuidRandom.length !== 16) { throw new Error("invalid uuid"); } + } else { + uuidRandom = randomBytes(16); + } + + // Override the scrypt password-based key derivation function parameters + let N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { N = options.scrypt.N; } + if (options.scrypt.r) { r = options.scrypt.r; } + if (options.scrypt.p) { p = options.scrypt.p; } + } + + return new Promise(function(resolve, reject) { + if (progressCallback) { progressCallback(0); } + + // We take 64 bytes: + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + scrypt(passwordBytes, salt, N, r, p, 64, function(error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + + } else if (key) { + key = arrayify(key); + + // This will be used to encrypt the wallet (as per Web3 secret storage) + let derivedKey = key.slice(0, 16); + let macPrefix = key.slice(16, 32); + + // This will be used to encrypt the mnemonic phrase (if any) + let mnemonicKey = key.slice(32, 64); + + // Encrypt the private key + let counter = new aes.Counter(iv); + let aesCtr = new aes.ModeOfOperation.ctr(derivedKey, counter); + let ciphertext = arrayify(aesCtr.encrypt(privateKey)); + + // Compute the message authentication code, used to check the password + let mac = keccak256(concat([macPrefix, ciphertext])) + + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + let data: { [key: string]: any } = { + address: account.address.substring(2).toLowerCase(), + id: uuid.v4({ random: uuidRandom }), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: hexlify(iv).substring(2), + }, + ciphertext: hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: hexlify(salt).substring(2), + n: N, + dklen: 32, + p: p, + r: r + }, + mac: mac.substring(2) + } + }; + + // If we have a mnemonic, encrypt it into the JSON wallet + if (entropy) { + let mnemonicIv = randomBytes(16); + let mnemonicCounter = new aes.Counter(mnemonicIv); + let mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + let mnemonicCiphertext = arrayify(mnemonicAesCtr.encrypt(entropy)); + let now = new Date(); + let timestamp = (now.getUTCFullYear() + "-" + + zpad(now.getUTCMonth() + 1, 2) + "-" + + zpad(now.getUTCDate(), 2) + "T" + + zpad(now.getUTCHours(), 2) + "-" + + zpad(now.getUTCMinutes(), 2) + "-" + + zpad(now.getUTCSeconds(), 2) + ".0Z" + ); + data["x-ethers"] = { + client: client, + gethFilename: ("UTC--" + timestamp + "--" + data.address), + mnemonicCounter: hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2), + path: path, + version: "0.1" + }; + } + + if (progressCallback) { progressCallback(1); } + resolve(JSON.stringify(data)); + + } else if (progressCallback) { + return progressCallback(progress); + } + }); + }); +} diff --git a/packages/json-wallets/src.ts/utils.ts b/packages/json-wallets/src.ts/utils.ts new file mode 100644 index 000000000..dd52c9945 --- /dev/null +++ b/packages/json-wallets/src.ts/utils.ts @@ -0,0 +1,66 @@ +"use strict"; + +import { arrayify, Bytes } from "@ethersproject/bytes"; +//import { Description } from "@ethersproject/properties"; +import { toUtf8Bytes, UnicodeNormalizationForm } from '@ethersproject/strings'; + +/* +export class Account extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + +// static isAccount(value: any): value is Account { +// return Description._isType(value); +// } +} +//defineReadOnly(Account, "name", "Account"); +*/ + +export function looseArrayify(hexString: string): Uint8Array { + if (typeof(hexString) === 'string' && hexString.substring(0, 2) !== '0x') { + hexString = '0x' + hexString; + } + return arrayify(hexString); +} + +export function zpad(value: String | number, length: number): String { + value = String(value); + while (value.length < length) { value = '0' + value; } + return value; +} + +export function getPassword(password: Bytes | string): Uint8Array { + if (typeof(password) === 'string') { + return toUtf8Bytes(password, UnicodeNormalizationForm.NFKC); + } + return arrayify(password); +} + +export function searchPath(object: any, path: string): string { + let currentChild = object; + + let comps = path.toLowerCase().split('/'); + for (let i = 0; i < comps.length; i++) { + + // Search for a child object with a case-insensitive matching key + let matchingChild = null; + for (let key in currentChild) { + if (key.toLowerCase() === comps[i]) { + matchingChild = currentChild[key]; + break; + } + } + + // Didn't find one. :'( + if (matchingChild === null) { + return null; + } + + // Now check this child... + currentChild = matchingChild; + } + + return currentChild; +} diff --git a/packages/json-wallets/thirdparty.d.ts b/packages/json-wallets/thirdparty.d.ts new file mode 100644 index 000000000..80d666d48 --- /dev/null +++ b/packages/json-wallets/thirdparty.d.ts @@ -0,0 +1,37 @@ +declare module "aes-js" { + export class Counter { + constructor(iv: Uint8Array); + } + export namespace ModeOfOperation { + class cbc{ + constructor(key: Uint8Array, iv: Uint8Array); + decrypt(data: Uint8Array): Uint8Array; + encrypt(data: Uint8Array): Uint8Array; + } + class ctr{ + constructor(key: Uint8Array, counter: Counter); + decrypt(data: Uint8Array): Uint8Array; + encrypt(data: Uint8Array): Uint8Array; + } + } + export namespace padding { + export namespace pkcs7 { + export function strip(data: Uint8Array): Uint8Array; + } + } +} + +declare module "scrypt-js" { + export class ScryptError extends Error { + progress: number; + } + export type ScryptCallback = (error: ScryptError, progress: number, key: Uint8Array) => void; + export default function(password: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, callback: ScryptCallback): void; +} + +declare module "uuid" { + export type Options = { + random: Uint8Array; + }; + export function v4(options?: Options): string; +} diff --git a/packages/json-wallets/tsconfig.json b/packages/json-wallets/tsconfig.json new file mode 100644 index 000000000..026fe496a --- /dev/null +++ b/packages/json-wallets/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/keccak256/.npmignore b/packages/keccak256/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/keccak256/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/keccak256/LICENSE.md b/packages/keccak256/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/keccak256/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/keccak256/README.md b/packages/keccak256/README.md new file mode 100644 index 000000000..d2021a496 --- /dev/null +++ b/packages/keccak256/README.md @@ -0,0 +1,17 @@ +KECCAK256 Hash Function +======================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/keccak256/package.json b/packages/keccak256/package.json new file mode 100644 index 000000000..5e056ee45 --- /dev/null +++ b/packages/keccak256/package.json @@ -0,0 +1,23 @@ +{ + "name": "@ethersproject/keccak256", + "version": "5.0.0-beta.124", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "js-sha3": "0.5.7" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xa98932040e5874dff6fe54c61917a7ae1fd4cc40cbcba3c684c67e416c49b574" +} diff --git a/packages/keccak256/src.ts/_version.ts b/packages/keccak256/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/keccak256/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/keccak256/src.ts/index.ts b/packages/keccak256/src.ts/index.ts new file mode 100644 index 000000000..868d26d1f --- /dev/null +++ b/packages/keccak256/src.ts/index.ts @@ -0,0 +1,9 @@ +"use strict"; + +import sha3 = require("js-sha3"); + +import { arrayify, BytesLike } from "@ethersproject/bytes"; + +export function keccak256(data: BytesLike): string { + return '0x' + sha3.keccak_256(arrayify(data)); +} diff --git a/packages/keccak256/tsconfig.json b/packages/keccak256/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/keccak256/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/networks/.npmignore b/packages/networks/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/networks/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/networks/LICENSE.md b/packages/networks/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/networks/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/networks/README.md b/packages/networks/README.md new file mode 100644 index 000000000..92e05b02d --- /dev/null +++ b/packages/networks/README.md @@ -0,0 +1,17 @@ +Ethereum (and ilk) Network Definitions +====================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/networks/package.json b/packages/networks/package.json new file mode 100644 index 000000000..737e01001 --- /dev/null +++ b/packages/networks/package.json @@ -0,0 +1,22 @@ +{ + "name": "@ethersproject/networks", + "version": "5.0.0-beta.125", + "description": "Network definitions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/errors": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x00ddc55c9d4a55e9bdb76344f8fed34b0733a4e132666e505f227c40a91748f3" +} diff --git a/packages/networks/src.ts/_version.ts b/packages/networks/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/networks/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/networks/src.ts/index.ts b/packages/networks/src.ts/index.ts new file mode 100644 index 000000000..92e079617 --- /dev/null +++ b/packages/networks/src.ts/index.ts @@ -0,0 +1,187 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; + +import { Network, Networkish } from "./types"; + +export { + Network, + Networkish +}; + +function ethDefaultProvider(network: string): (providers: any) => any { + return function(providers: any, options?: any): any { + if (options == null) { options = { }; } + let providerList: Array = []; + + if (providers.InfuraProvider) { + try { + providerList.push(new providers.InfuraProvider(network, options.infura)); + } catch(error) { } + } + + if (providers.EtherscanProvider) { + try { + providerList.push(new providers.EtherscanProvider(network, options.etherscan)); + } catch(error) { } + } + + if (providers.NodesmithProvider) { + try { + providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); + } catch(error) { } + } + + if (providers.AlchemyProvider) { + try { + providerList.push(new providers.AlchemyProvider(network, options.alchemy)); + } catch(error) { } + } + + if (providerList.length === 0) { return null; } + + if (providers.FallbackProvider) { + return new providers.FallbackProvider(providerList);; + } + + return providerList[0]; + } +} + +function etcDefaultProvider(url: string, network: string): (providers: any) => any { + return function(providers: any, options?: any): any { + if (providers.JsonRpcProvider) { + return new providers.JsonRpcProvider(url, network); + } + + return null; + } +} + +const homestead: Network = { + chainId: 1, + ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", + name: "homestead", + _defaultProvider: ethDefaultProvider("homestead") +}; + +const ropsten: Network = { + chainId: 3, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "ropsten", + _defaultProvider: ethDefaultProvider("ropsten") +}; + +const networks: { [name: string]: Network } = { + unspecified: { + chainId: 0, + name: "unspecified" + }, + + homestead: homestead, + mainnet: homestead, + + morden: { + chainId: 2, + name: "morden" + }, + + ropsten: ropsten, + testnet: ropsten, + + rinkeby: { + chainId: 4, + ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", + name: "rinkeby", + _defaultProvider: ethDefaultProvider("rinkeby") + }, + + kovan: { + chainId: 42, + name: "kovan", + _defaultProvider: ethDefaultProvider("kovan") + }, + + goerli: { + chainId: 5, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "goerli", + _defaultProvider: ethDefaultProvider("goerli") + }, + + classic: { + chainId: 61, + name: "classic", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") + }, + + classicTestnet: { + chainId: 62, + name: "classicTestnet", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") + } +} + +/** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ +export function getNetwork(network: Networkish): Network { + // No network (null) + if (network == null) { return null; } + + if (typeof(network) === "number") { + for (let name in networks) { + let standard = networks[name]; + if (standard.chainId === network) { + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: (standard.ensAddress || null), + _defaultProvider: (standard._defaultProvider || null) + }; + } + } + + return { + chainId: network, + name: "unknown" + }; + } + + if (typeof(network) === "string") { + let standard = networks[network]; + if (standard == null) { return null; } + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: standard.ensAddress, + _defaultProvider: (standard._defaultProvider || null) + }; + } + + let standard = networks[network.name]; + + // Not a standard network; check that it is a valid network in general + if (!standard) { + if (typeof(network.chainId) !== "number") { + errors.throwError("invalid network chainId", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + return network; + } + + // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) + if (network.chainId !== 0 && network.chainId !== standard.chainId) { + errors.throwError("network chainId mismatch", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + + // Standard Network (allow overriding the ENS address) + return { + name: network.name, + chainId: standard.chainId, + ensAddress: (network.ensAddress || standard.ensAddress || null), + _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) + }; +} diff --git a/packages/networks/src.ts/types.ts b/packages/networks/src.ts/types.ts new file mode 100644 index 000000000..4e048d0d0 --- /dev/null +++ b/packages/networks/src.ts/types.ts @@ -0,0 +1,10 @@ +"use strict"; + +export type Network = { + name: string, + chainId: number, + ensAddress?: string, + _defaultProvider?: (providers: any, options?: any) => any +} + +export type Networkish = Network | string | number; diff --git a/packages/networks/tsconfig.json b/packages/networks/tsconfig.json new file mode 100644 index 000000000..969328db8 --- /dev/null +++ b/packages/networks/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/pbkdf2/.gitignore b/packages/pbkdf2/.gitignore new file mode 100644 index 000000000..aa5c62527 --- /dev/null +++ b/packages/pbkdf2/.gitignore @@ -0,0 +1 @@ +browser.d.ts diff --git a/packages/pbkdf2/.npmignore b/packages/pbkdf2/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/pbkdf2/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/pbkdf2/LICENSE.md b/packages/pbkdf2/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/pbkdf2/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/pbkdf2/README.md b/packages/pbkdf2/README.md new file mode 100644 index 000000000..cd2c61e0a --- /dev/null +++ b/packages/pbkdf2/README.md @@ -0,0 +1,17 @@ +Password-Based Key Derivation Function 2 (pbkdf2) +================================================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/pbkdf2/package.json b/packages/pbkdf2/package.json new file mode 100644 index 000000000..2a15c2c4e --- /dev/null +++ b/packages/pbkdf2/package.json @@ -0,0 +1,25 @@ +{ + "name": "@ethersproject/pbkdf2", + "version": "5.0.0-beta.124", + "description": "Error utility functions for ethers.", + "main": "index.js", + "browser": "browser.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/sha2": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers", + "pbkdf2" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xa09dfd11dd48c714f383bb8543ed26b1258dcdcb9b9b84b8b9e86ef0d5e6348b" +} diff --git a/packages/pbkdf2/src.ts/_version.ts b/packages/pbkdf2/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/pbkdf2/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/pbkdf2/src.ts/browser.ts b/packages/pbkdf2/src.ts/browser.ts new file mode 100644 index 000000000..1dd428901 --- /dev/null +++ b/packages/pbkdf2/src.ts/browser.ts @@ -0,0 +1,55 @@ +"use strict"; + +import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes"; +import { computeHmac, SupportedAlgorithms } from "@ethersproject/sha2"; + +export function pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, hashAlgorithm: SupportedAlgorithms): string { + password = arrayify(password); + salt = arrayify(salt); + let hLen + let l = 1 + let DK = new Uint8Array(keylen) + let block1 = new Uint8Array(salt.length + 4) + block1.set(salt); + //salt.copy(block1, 0, 0, salt.length) + + let r: number; + let T: Uint8Array; + + for (let i = 1; i <= l; i++) { + //block1.writeUInt32BE(i, salt.length) + block1[salt.length] = (i >> 24) & 0xff; + block1[salt.length + 1] = (i >> 16) & 0xff; + block1[salt.length + 2] = (i >> 8) & 0xff; + block1[salt.length + 3] = i & 0xff; + + //let U = createHmac(password).update(block1).digest(); + let U = arrayify(computeHmac(hashAlgorithm, password, block1)); + + if (!hLen) { + hLen = U.length + T = new Uint8Array(hLen) + l = Math.ceil(keylen / hLen) + r = keylen - (l - 1) * hLen + } + + //U.copy(T, 0, 0, hLen) + T.set(U); + + + for (let j = 1; j < iterations; j++) { + //U = createHmac(password).update(U).digest(); + U = arrayify(computeHmac(hashAlgorithm, password, U)); + for (let k = 0; k < hLen; k++) T[k] ^= U[k] + } + + + let destPos = (i - 1) * hLen + let len = (i === l ? r : hLen) + //T.copy(DK, destPos, 0, len) + DK.set(arrayify(T).slice(0, len), destPos); + } + + return hexlify(DK) +} + diff --git a/packages/pbkdf2/src.ts/index.ts b/packages/pbkdf2/src.ts/index.ts new file mode 100644 index 000000000..b67190e35 --- /dev/null +++ b/packages/pbkdf2/src.ts/index.ts @@ -0,0 +1,14 @@ +"use strict"; + +import { pbkdf2Sync as _pbkdf2 } from "crypto"; + +import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes"; + + +function bufferify(value: BytesLike): Buffer { + return Buffer.from(arrayify(value)); +} + +export function pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, hashAlgorithm: string): string { + return hexlify(_pbkdf2(bufferify(password), bufferify(salt), iterations, keylen, hashAlgorithm)); +} diff --git a/packages/pbkdf2/tsconfig.json b/packages/pbkdf2/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/pbkdf2/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/properties/.npmignore b/packages/properties/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/properties/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/properties/LICENSE.md b/packages/properties/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/properties/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/properties/README.md b/packages/properties/README.md new file mode 100644 index 000000000..1f82cfe60 --- /dev/null +++ b/packages/properties/README.md @@ -0,0 +1,17 @@ +Property Utilities +================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/properties/package.json b/packages/properties/package.json new file mode 100644 index 000000000..235c53447 --- /dev/null +++ b/packages/properties/package.json @@ -0,0 +1,24 @@ +{ + "name": "@ethersproject/properties", + "version": "5.0.0-beta.125", + "description": "Properties utility functions for ethers.", + "main": "index.js", + "scripts": { + "build": "tsc -p ./tsconfig.json", + "auto-build": "npm run build -- -w", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/errors": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xb8bb631ef71d25129b1ab6627a77368e262b366499c8088478bcd97eef8adca8" +} diff --git a/packages/properties/src.ts/_version.ts b/packages/properties/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/properties/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/properties/src.ts/index.ts b/packages/properties/src.ts/index.ts new file mode 100644 index 000000000..d7c3f558a --- /dev/null +++ b/packages/properties/src.ts/index.ts @@ -0,0 +1,154 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; + +export function defineReadOnly(object: any, name: string, value: any): void { + Object.defineProperty(object, name, { + enumerable: true, + value: value, + writable: false, + }); +} + +// There are some issues with instanceof with npm link, so we use this +// to ensure types are what we expect. We use this for a little extra +// protection to make sure the correct types are being passed around. + +function getType(object: any) { + + let type = typeof(object); + if (type !== "function") { return null; } + + let types = [ ]; + let obj = object; + while (true) { + let type = obj.name; + if (!type) { break; } + types.push(type); + obj = Object.getPrototypeOf(obj); + } + return types.join(" "); +} + +function hasSuffix(text: string, suffix: string) { + return text.substring(text.length - suffix.length) === suffix; +} + +export function isNamedInstance(type: Function | string, value: any): value is T { + let name = getType(type); + if (!name) { return false; } + + // Not a string... + if (typeof(value) !== "string") { + + // Not an instance... + if (typeof(value) !== "object") { return false; } + + // Get the instance type + value = getType(value.constructor); + } + + return (name === value || hasSuffix(value, " " + name)); +} + +export function resolveProperties(object: any): Promise { + let result: any = {}; + + let promises: Array> = []; + Object.keys(object).forEach((key) => { + let value = object[key]; + if (value instanceof Promise) { + promises.push( + value.then((value) => { + result[key] = value; + return null; + }) + ); + } else { + result[key] = value; + } + }); + + return Promise.all(promises).then(() => { + return result; + }); +} + +export function checkProperties(object: any, properties: { [ name: string ]: boolean }): void { + if (!object || typeof(object) !== "object") { + errors.throwError("invalid object", errors.INVALID_ARGUMENT, { + argument: "object", + value: object + }); + } + + Object.keys(object).forEach((key) => { + if (!properties[key]) { + errors.throwError("invalid object key - " + key, errors.INVALID_ARGUMENT, { + argument: "transaction", + value: object, + key: key + }); + } + }); +} + +export function shallowCopy(object: any): any { + let result: any = {}; + for (let key in object) { result[key] = object[key]; } + return result; +} + +let opaque: { [key: string]: boolean } = { boolean: true, number: true, string: true }; + +export function deepCopy(object: any, frozen?: boolean): any { + + // Opaque objects are not mutable, so safe to copy by assignment + if (object === undefined || object === null || opaque[typeof(object)]) { return object; } + + // Arrays are mutable, so we need to create a copy + if (Array.isArray(object)) { + let result = object.map((item) => deepCopy(item, frozen)); + if (frozen) { Object.freeze(result); } + return result + } + + if (typeof(object) === "object") { + + // Some internal objects, which are already immutable + if (isNamedInstance("BigNumber", object)) { return object; } + if (isNamedInstance("Description", object)) { return object; } + if (isNamedInstance("Indexed", object)) { return object; } + + let result: { [ key: string ]: any } = {}; + for (let key in object) { + let value = object[key]; + if (value === undefined) { continue; } + defineReadOnly(result, key, deepCopy(value, frozen)); + } + + if (frozen) { Object.freeze(result); } + + return result; + } + + // The function type is also immutable, so safe to copy by assignment + if (typeof(object) === "function") { + return object; + } + + throw new Error("Cannot deepCopy " + typeof(object)); +} + +export class Description { + constructor(info: any) { + for (let key in info) { + defineReadOnly(this, key, deepCopy(info[key], true)); + } + Object.freeze(this); + } + + static isType(value: any): boolean { + return isNamedInstance(this, value); + } +} diff --git a/packages/properties/tsconfig.json b/packages/properties/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/properties/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/providers/.npmignore b/packages/providers/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/providers/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/providers/LICENSE.md b/packages/providers/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/providers/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/providers/README.md b/packages/providers/README.md new file mode 100644 index 000000000..8b28057b4 --- /dev/null +++ b/packages/providers/README.md @@ -0,0 +1,17 @@ +Ethereum Providers +================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/providers/package.json b/packages/providers/package.json new file mode 100644 index 000000000..4b0590f8e --- /dev/null +++ b/packages/providers/package.json @@ -0,0 +1,40 @@ +{ + "name": "@ethersproject/providers", + "version": "5.0.0-beta.129", + "description": "Error utility functions for ethers.", + "main": "index.js", + "browser": { + "net": "./browser-net.js", + "./ipc-provider": "./browser-ipc-provider.js" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abstract-provider": ">5.0.0-beta.0", + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/hash": ">5.0.0-beta.0", + "@ethersproject/networks": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/random": ">5.0.0-beta.0", + "@ethersproject/rlp": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/web": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x2c10c49a8773e705470f3ba599a4e63652460cd12023aa1bb6f7c87779f90cd1" +} diff --git a/packages/providers/src.ts/_version.ts b/packages/providers/src.ts/_version.ts new file mode 100644 index 000000000..cc0f13f68 --- /dev/null +++ b/packages/providers/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.129"; diff --git a/packages/providers/src.ts/alchemy-provider.ts b/packages/providers/src.ts/alchemy-provider.ts new file mode 100644 index 000000000..d7fd4faca --- /dev/null +++ b/packages/providers/src.ts/alchemy-provider.ts @@ -0,0 +1,44 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; +import { Network } from "@ethersproject/networks"; + +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; + +// This key was provided to ethers.js by Alchemy to be used by the +// default provider, but it is recommended that for your own +// production environments, that you acquire your own API key at: +// https://dashboard.alchemyapi.io + +const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC" + +export class AlchemyProvider extends UrlJsonRpcProvider { + readonly apiKey: string; + + static getApiKey(apiKey: string): string { + if (apiKey == null) { return defaultApiKey; } + return apiKey; + } + + static getUrl(network: Network, apiKey: string): string { + let host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/jsonrpc/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/jsonrpc/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/jsonrpc/"; + break; + default: + errors.throwArgumentError("unsupported network", "network", arguments[0]); + } + + return ("https:/" + "/" + host + apiKey); + } +} diff --git a/packages/providers/src.ts/base-provider.ts b/packages/providers/src.ts/base-provider.ts new file mode 100644 index 000000000..b25fe0d49 --- /dev/null +++ b/packages/providers/src.ts/base-provider.ts @@ -0,0 +1,982 @@ +"use strict"; + +import { + Block, BlockTag, BlockWithTransactions, EventType, Filter, FilterByBlockHash, ForkEvent, + Listener, Log, Provider, TransactionReceipt, TransactionRequest, TransactionResponse +} from "@ethersproject/abstract-provider"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { arrayify, hexDataLength, hexlify, hexValue, isHexString } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { namehash } from "@ethersproject/hash"; +import { getNetwork, Network, Networkish } from "@ethersproject/networks"; +import { defineReadOnly, isNamedInstance, resolveProperties } from "@ethersproject/properties"; +import { Transaction } from "@ethersproject/transactions"; +import { toUtf8String } from "@ethersproject/strings"; +import { poll } from "@ethersproject/web"; + +import { Formatter } from "./formatter"; + + +////////////////////////////// +// Event Serializeing + +function checkTopic(topic: string): string { + if (topic == null) { return "null"; } + if (hexDataLength(topic) !== 32) { + errors.throwArgumentError("invalid topic", "topic", topic); + } + return topic.toLowerCase(); +} + +function serializeTopics(topics: Array>): string { + + // Remove trailing null AND-topics; they are redundant + topics = topics.slice(); + while (topics[topics.length - 1] == null) { topics.pop(); } + + return topics.map((topic) => { + if (Array.isArray(topic)) { + + // Only track unique OR-topics + let unique: { [ topic: string ]: boolean } = { } + topic.forEach((topic) => { + unique[checkTopic(topic)] = true; + }); + + // The order of OR-topics does not matter + let sorted = Object.keys(unique); + sorted.sort(); + + return sorted.join("|"); + } else { + return checkTopic(topic); + } + }).join("&"); +} + +function deserializeTopics(data: string): Array> { + return data.split(/&/g).map((topic) => { + return topic.split("|").map((topic) => { + return ((topic === "null") ? null: topic); + }); + }); +} + +function getEventTag(eventName: EventType): string { + if (typeof(eventName) === "string") { + eventName = eventName.toLowerCase(); + + if (hexDataLength(eventName) === 32) { + return "tx:" + eventName; + } + + if (eventName.indexOf(":") === -1) { + return eventName; + } + + } else if (Array.isArray(eventName)) { + return "filter:*:" + serializeTopics(eventName); + + } else if (isNamedInstance(ForkEvent, eventName)) { + errors.warn("not implemented"); + throw new Error("not implemented"); + + } else if (eventName && typeof(eventName) === "object") { + return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); + } + + throw new Error("invalid event - " + eventName); +} + +////////////////////////////// +// Helper Object + +function getTime() { + return (new Date()).getTime(); +} + +////////////////////////////// +// Provider Object + + +/** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ + +class Event { + readonly listener: Listener; + readonly once: boolean; + readonly tag: string; + + constructor(tag: string, listener: Listener, once: boolean) { + defineReadOnly(this, "tag", tag); + defineReadOnly(this, "listener", listener); + defineReadOnly(this, "once", once); + } + + pollable(): boolean { + return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); + } +} + + +let defaultFormatter: Formatter = null; + +let nextPollId = 1; + +export class BaseProvider extends Provider { + _network: Network; + + _events: Array; + + formatter: Formatter; + + // To help mitigate the eventually conssitent nature of the blockchain + // we keep a mapping of events we emit. If we emit an event X, we expect + // that a user should be able to query for that event in the callback, + // if the node returns null, we stall the response until we get back a + // meaningful value, since we may be hitting a re-org, or a node that + // has not indexed the event yet. + // Events: + // - t:{hash} - Transaction hash + // - b:{hash} - BlockHash + // - block - The most recent emitted block + _emitted: { [ eventName: string ]: number | "pending" }; + + _pollingInterval: number; + _poller: any; // @TODO: what does TypeScript think setInterval returns? + + _lastBlockNumber: number; + + _fastBlockNumber: number; + _fastBlockNumberPromise: Promise; + _fastQueryDate: number; + + + /** + * ready + * + * A Promise that resolves only once the provider is ready. + * + * Sub-classes that call the super with a network without a chainId + * MUST set this. Standard named networks have a known chainId. + * + */ + ready: Promise; + + constructor(network: Networkish | Promise) { + errors.checkNew(new.target, Provider); + + super(); + + this.formatter = new.target.getFormatter(); + + if (network instanceof Promise) { + defineReadOnly(this, "ready", network.then((network) => { + defineReadOnly(this, "_network", network); + return network; + })); + + // Squash any "unhandled promise" errors; that do not need to be handled + this.ready.catch((error) => { }); + + } else { + let knownNetwork = getNetwork((network == null) ? "homestead": network); + if (knownNetwork) { + defineReadOnly(this, "_network", knownNetwork); + defineReadOnly(this, "ready", Promise.resolve(this._network)); + + } else { + errors.throwError("invalid network", errors.INVALID_ARGUMENT, { arg: "network", value: network }); + } + } + + this._lastBlockNumber = -2; + + // Events being listened to + this._events = []; + + this._pollingInterval = 4000; + + this._emitted = { block: -2 }; + + this._fastQueryDate = 0; + } + + static getFormatter(): Formatter { + if (defaultFormatter == null) { + defaultFormatter = new Formatter(); + } + return defaultFormatter; + } + + poll(): void { + let pollId = nextPollId++; + this.emit("willPoll", pollId); + + // Track all running promises, so we can trigger a post-poll once they are complete + let runners: Array> = []; + + this.getBlockNumber().then((blockNumber) => { + this._setFastBlockNumber(blockNumber); + + // If the block has not changed, meh. + if (blockNumber === this._lastBlockNumber) { return; } + + // First polling cycle, trigger a "block" events + if (this._emitted.block === -2) { + this._emitted.block = blockNumber - 1; + } + + // Notify all listener for each block that has passed + for (let i = (this._emitted.block) + 1; i <= blockNumber; i++) { + this.emit("block", i); + } + + // The emitted block was updated, check for obsolete events + if ((this._emitted.block) !== blockNumber) { + this._emitted.block = blockNumber; + + Object.keys(this._emitted).forEach((key) => { + // The block event does not expire + if (key === "block") { return; } + + // The block we were at when we emitted this event + let eventBlockNumber = this._emitted[key]; + + // We cannot garbage collect pending transactions or blocks here + // They should be garbage collected by the Provider when setting + // "pending" events + if (eventBlockNumber === "pending") { return; } + + // Evict any transaction hashes or block hashes over 12 blocks + // old, since they should not return null anyways + if (blockNumber - eventBlockNumber > 12) { + delete this._emitted[key]; + } + }); + } + + // First polling cycle + if (this._lastBlockNumber === -2) { + this._lastBlockNumber = blockNumber - 1; + } + + // Find all transaction hashes we are waiting on + this._events.forEach((event) => { + let comps = event.tag.split(":"); + switch (comps[0]) { + case "tx": { + let hash = comps[1]; + let runner = this.getTransactionReceipt(hash).then((receipt) => { + if (!receipt || receipt.blockNumber == null) { return null; } + this._emitted["t:" + hash] = receipt.blockNumber; + this.emit(hash, receipt); + return null; + }).catch((error: Error) => { this.emit("error", error); }); + + runners.push(runner); + + break; + } + + case "filter": { + let topics = deserializeTopics(comps[2]); + let filter = { + address: comps[1], + fromBlock: this._lastBlockNumber + 1, + toBlock: blockNumber, + topics: topics + } + if (!filter.address) { delete filter.address; } + let runner = this.getLogs(filter).then((logs) => { + if (logs.length === 0) { return; } + logs.forEach((log: Log) => { + this._emitted["b:" + log.blockHash] = log.blockNumber; + this._emitted["t:" + log.transactionHash] = log.blockNumber; + this.emit(filter, log); + }); + return null; + }).catch((error: Error) => { this.emit("error", error); }); + + runners.push(runner); + + break; + } + } + }); + + this._lastBlockNumber = blockNumber; + + return null; + }).catch((error: Error) => { }); + + Promise.all(runners).then(() => { + this.emit("didPoll", pollId); + }); + } + + resetEventsBlock(blockNumber: number): void { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { this.poll(); } + } + + get network(): Network { + return this._network; + } + + getNetwork(): Promise { + return this.ready; + } + + get blockNumber(): number { + return this._fastBlockNumber; + } + + get polling(): boolean { + return (this._poller != null); + } + + set polling(value: boolean) { + setTimeout(() => { + if (value && !this._poller) { + this._poller = setInterval(this.poll.bind(this), this.pollingInterval); + + } else if (!value && this._poller) { + clearInterval(this._poller); + this._poller = null; + } + }, 0); + } + + get pollingInterval(): number { + return this._pollingInterval; + } + + set pollingInterval(value: number) { + if (typeof(value) !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); + } + + this._pollingInterval = value; + + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(() => { this.poll() }, this._pollingInterval); + } + } + + _getFastBlockNumber(): Promise { + let now = getTime(); + + // Stale block number, request a newer value + if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then((blockNumber) => { + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + } + return this._fastBlockNumber; + }); + } + + return this._fastBlockNumberPromise; + } + + _setFastBlockNumber(blockNumber: number): void { + // Older block, maybe a stale request + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { return; } + + // Update the time we updated the blocknumber + this._fastQueryDate = getTime(); + + // Newer block number, use it + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + } + + // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; + // this will be used once we move to the WebSocket or other alternatives to polling + + waitForTransaction(transactionHash: string, confirmations?: number): Promise { + if (confirmations == null) { confirmations = 1; } + + if (confirmations === 0) { + return this.getTransactionReceipt(transactionHash); + } + + return new Promise((resolve) => { + let handler = (receipt: TransactionReceipt) => { + if (receipt.confirmations < confirmations) { return; } + this.removeListener(transactionHash, handler); + resolve(receipt); + } + this.on(transactionHash, handler); + }); + } + + _runPerform(method: string, params: { [ key: string ]: () => any }): Promise { + return this.ready.then(() => { + // Execute all the functions now that we are "ready" + Object.keys(params).forEach((key) => { + params[key] = params[key](); + }); + return resolveProperties(params).then((params) => { + return this.perform(method, params); + }); + }); + } + + getBlockNumber(): Promise { + return this._runPerform("getBlockNumber", { }).then((result) => { + let value = parseInt(result); + if (value != result) { throw new Error("invalid response - getBlockNumber"); } + this._setFastBlockNumber(value); + return value; + }); + } + + getGasPrice(): Promise { + return this._runPerform("getGasPrice", { }).then((result) => { + return BigNumber.from(result); + }); + } + + getBalance(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise { + return this._runPerform("getBalance", { + address: () => this.resolveName(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result); + }); + } + + getTransactionCount(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise { + return this._runPerform("getTransactionCount", { + address: () => this.resolveName(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result).toNumber(); + }); + } + + getCode(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise { + return this._runPerform("getCode", { + address: () => this.resolveName(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + + getStorageAt(addressOrName: string | Promise, position: BigNumberish | Promise, blockTag?: BlockTag | Promise): Promise { + return this._runPerform("getStorageAt", { + address: () => this.resolveName(addressOrName), + blockTag: () => this._getBlockTag(blockTag), + position: () => Promise.resolve(position).then((p) => hexValue(p)) + }).then((result) => { + return hexlify(result); + }); + } + + // This should be called by any subclass wrapping a TransactionResponse + _wrapTransaction(tx: Transaction, hash?: string): TransactionResponse { + if (hash != null && hexDataLength(hash) !== 32) { throw new Error("invalid response - sendTransaction"); } + + let result = tx; + + // Check the hash we expect is the same as the hash the server reported + if (hash != null && tx.hash !== hash) { + errors.throwError("Transaction hash mismatch from Provider.sendTransaction.", errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + + // @TODO: (confirmations? number, timeout? number) + result.wait = (confirmations?: number) => { + + // We know this transaction *must* exist (whether it gets mined is + // another story), so setting an emitted value forces us to + // wait even if the node returns null for the receipt + if (confirmations !== 0) { + this._emitted["t:" + tx.hash] = "pending"; + } + + return this.waitForTransaction(tx.hash, confirmations).then((receipt) => { + if (receipt == null && confirmations === 0) { return null; } + + // No longer pending, allow the polling loop to garbage collect this + this._emitted["t:" + tx.hash] = receipt.blockNumber; + + if (receipt.status === 0) { + errors.throwError("transaction failed", errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx + }); + } + return receipt; + }); + }; + + return result; + } + + sendTransaction(signedTransaction: string | Promise): Promise { + return this._runPerform("sendTransaction", { + signedTransaction: () => Promise.resolve(signedTransaction).then(t => hexlify(t)) + }).then((result) => { + return this._wrapTransaction(this.formatter.transaction(signedTransaction), result); + }, (error) => { + error.transaction = this.formatter.transaction(signedTransaction); + if (error.transaction.hash) { + (error).transactionHash = error.transaction.hash; + } + throw error; + }); + } + + _getTransactionRequest(transaction: TransactionRequest | Promise): Promise { + return Promise.resolve(transaction).then((t: any) => { + let tx: any = { }; + ["from", "to"].forEach((key) => { + if (t[key] == null) { return; } + tx[key] = Promise.resolve(t[key]).then(a => (a ? this.resolveName(a): null)) + }); + ["data", "gasLimit", "gasPrice", "value"].forEach((key) => { + if (t[key] == null) { return; } + tx[key] = t[key]; + }); + return resolveProperties(tx).then((t) => this.formatter.transactionRequest(t)); + }); + } + + _getFilter(filter: Filter | FilterByBlockHash | Promise): Promise { + return Promise.resolve(filter).then((f: any) => { + let filter: any = { }; + + if (f.address != null) { + filter.address = this.resolveName(f.address); + } + + if (f.blockHash != null) { + filter.blockHash = f.blockHash; + } + + ["fromBlock", "toBlock"].forEach((key) => { + if (f[key] == null) { return; } + filter[key] = this._getBlockTag(f[key]); + }); + + return resolveProperties(filter).then((f) => this.formatter.filter(f)); + }); + } + + + call(transaction: TransactionRequest | Promise, blockTag?: BlockTag | Promise): Promise { + return this._runPerform("call", { + transaction: () => this._getTransactionRequest(transaction), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + + estimateGas(transaction: TransactionRequest | Promise) { + return this._runPerform("estimateGas", { + transaction: () => this._getTransactionRequest(transaction) + }).then((result) => { + return BigNumber.from(result); + }); + } + + _getBlock(blockHashOrBlockTag: BlockTag | string | Promise, includeTransactions?: boolean): Promise { + return this.ready.then(() => { + return this._getBlockTag(blockHashOrBlockTag).then((blockHashOrBlockTag) => { + let params: { [key: string]: any } = { + includeTransactions: !!includeTransactions + }; + + // Exactly one of blockHash or blockTag will be set + let blockHash: string = null; + let blockTag: string = null; + + // If blockTag is a number (not "latest", etc), this is the block number + let blockNumber = -128; + + if (isHexString(blockHashOrBlockTag, 32)) { + params.blockHash = blockHashOrBlockTag; + } else { + try { + params.blockTag = this.formatter.blockTag(blockHashOrBlockTag); + if (isHexString(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + } catch (error) { + errors.throwError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + } + } + + return poll(() => { + return this.perform("getBlock", params).then((block) => { + + // Block was not found + if (block == null) { + + // For blockhashes, if we didn't say it existed, that blockhash may + // not exist. If we did see it though, perhaps from a log, we know + // it exists, and this node is just not caught up yet. + if (blockHash) { + if (this._emitted["b:" + blockHash] == null) { return null; } + } + + // For block tags, if we are asking for a future block, we return null + if (blockTag) { + if (blockNumber > this._emitted.block) { return null; } + } + + // Retry on the next block + return undefined; + } + + // Add transactions + if (includeTransactions) { + return this.formatter.blockWithTransactions(block); + } + + return this.formatter.block(block); + }); + }, { onceBlock: this }); + }); + }); + } + + getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise { + return >(this._getBlock(blockHashOrBlockTag, false)); + } + + getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise): Promise { + return >(this._getBlock(blockHashOrBlockTag, true)); + } + + getTransaction(transactionHash: string): Promise { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransaction", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + + let tx = this.formatter.transactionResponse(result); + + if (tx.blockNumber == null) { + tx.confirmations = 0; + + } else if (tx.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - tx.blockNumber) + 1; + if (confirmations <= 0) { confirmations = 1; } + tx.confirmations = confirmations; + + return this._wrapTransaction(tx); + }); + } + + return this._wrapTransaction(tx); + }); + }, { onceBlock: this }); + }); + }); + } + + getTransactionReceipt(transactionHash: string): Promise { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransactionReceipt", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + + // "geth-etc" returns receipts before they are ready + if (result.blockHash == null) { return undefined; } + + let receipt = this.formatter.receipt(result); + + if (receipt.blockNumber == null) { + receipt.confirmations = 0; + + } else if (receipt.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - receipt.blockNumber) + 1; + if (confirmations <= 0) { confirmations = 1; } + receipt.confirmations = confirmations; + + return receipt; + }); + } + + return receipt; + }); + }, { onceBlock: this }); + }); + }); + } + + + getLogs(filter: Filter | FilterByBlockHash | Promise): Promise> { + return this._runPerform("getLogs", { + filter: () => this._getFilter(filter) + }).then((result) => { + return Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(result); + }); + } + + getEtherPrice(): Promise { + return this._runPerform("getEtherPrice", { }).then((result) => { + return result; + }); + } + + _getBlockTag(blockTag: BlockTag | Promise): Promise { + if (blockTag instanceof Promise) { + return blockTag.then((b) => this._getBlockTag(b)); + } + + if (typeof(blockTag) === "number" && blockTag < 0) { + if (blockTag % 1) { + errors.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + + return this._getFastBlockNumber().then((bn) => { + bn += blockTag; + if (bn < 0) { bn = 0; } + return this.formatter.blockTag(bn) + }); + } + + return Promise.resolve(this.formatter.blockTag(blockTag)); + } + + + _getResolver(name: string): Promise { + // Get the resolver from the blockchain + return this.getNetwork().then((network) => { + + // No ENS... + if (!network.ensAddress) { + errors.throwError( + "network does support ENS", + errors.UNSUPPORTED_OPERATION, + { operation: "ENS", network: network.name } + ); + } + + // keccak256("resolver(bytes32)") + let data = "0x0178b8bf" + namehash(name).substring(2); + let transaction = { to: network.ensAddress, data: data }; + + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + + resolveName(name: string | Promise): Promise { + + // If it is a promise, resolve it then recurse + if (name instanceof Promise) { + return name.then((addressOrName) => this.resolveName(addressOrName)); + } + + // If it is already an address, nothing to resolve + try { + return Promise.resolve(this.formatter.address(name)); + } catch (error) { } + + // Get the addr from the resovler + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { return null; } + + // keccak256("addr(bytes32)") + let data = "0x3b3b57de" + namehash(name).substring(2); + let transaction = { to: resolverAddress, data: data }; + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + + lookupAddress(address: string | Promise): Promise { + if (address instanceof Promise) { + return address.then((address) => this.lookupAddress(address)); + } + + address = this.formatter.address(address); + + let name = address.substring(2) + ".addr.reverse" + + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { return null; } + + // keccak("name(bytes32)") + let data = "0x691f3431" + namehash(name).substring(2); + return this.call({ to: resolverAddress, data: data }).then((data) => { + let bytes = arrayify(data); + + // Strip off the dynamic string pointer (0x20) + if (bytes.length < 32 || !BigNumber.from(bytes.slice(0, 32)).eq(32)) { return null; } + bytes = bytes.slice(32); + + if (bytes.length < 32) { return null; } + let length = BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + + if (length > bytes.length) { return null; } + + let name = toUtf8String(bytes.slice(0, length)); + + // Make sure the reverse record matches the foward record + return this.resolveName(name).then((addr) => { + if (addr != address) { return null; } + return name; + }); + }); + }); + } + + perform(method: string, params: any): Promise { + return errors.throwError(method + " not implemented", errors.NOT_IMPLEMENTED, { operation: method }); + } + + _startPending(): void { + console.log("WARNING: this provider does not support pending events"); + } + + _stopPending(): void { + } + + // Returns true if there are events that still require polling + _checkPolling(): void { + this.polling = (this._events.filter((e) => e.pollable()).length > 0); + } + + _addEventListener(eventName: EventType, listener: Listener, once: boolean): this { + this._events.push(new Event(getEventTag(eventName), listener, once)); + + if (eventName === "pending") { this._startPending(); } + + // Do we still now have any events that require polling? + this._checkPolling(); + + return this; + } + + on(eventName: EventType, listener: Listener): this { + return this._addEventListener(eventName, listener, false); + } + + once(eventName: EventType, listener: Listener): this { + return this._addEventListener(eventName, listener, true); + } + + + emit(eventName: EventType, ...args: Array): boolean { + let result = false; + + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag) { return true; } + setTimeout(() => { + event.listener.apply(this, args); + }, 0); + result = true; + return !(event.once); + }); + + // Do we still have any events that require polling? ("once" events remove themselves) + this._checkPolling(); + + return result; + } + + listenerCount(eventName?: EventType): number { + if (!eventName) { return this._events.length; } + + let eventTag = getEventTag(eventName); + return this._events.filter((event) => { + return (event.tag === eventTag); + }).length; + } + + listeners(eventName?: EventType): Array { + if (eventName == null) { + return this._events.map((event) => event.listener); + } + + let eventTag = getEventTag(eventName); + return this._events + .filter((event) => (event.tag === eventTag)) + .map((event) => event.listener); + } + + off(eventName: EventType, listener?: Listener): this { + if (listener == null) { + return this.removeAllListeners(eventName); + } + + let found = false; + + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag || event.listener != listener) { return true; } + if (found) { return true; } + found = true; + return false; + }); + + if (eventName === "pending" && this.listenerCount("pending") === 0) { this._stopPending(); } + + // Do we still have any events that require polling? + this._checkPolling(); + + return this; + } + + removeAllListeners(eventName?: EventType): this { + if (eventName == null) { + this._events = [ ]; + this._stopPending(); + } else { + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + return (event.tag !== eventTag); + }); + if (eventName === "pending") { this._stopPending(); } + } + + // Do we still have any events that require polling? + this._checkPolling(); + + return this; + } + +} diff --git a/packages/providers/src.ts/browser-ipc-provider.ts b/packages/providers/src.ts/browser-ipc-provider.ts new file mode 100644 index 000000000..1cb691a64 --- /dev/null +++ b/packages/providers/src.ts/browser-ipc-provider.ts @@ -0,0 +1,3 @@ +"use strict"; + +module.exports.IpcProvider = null; diff --git a/packages/providers/src.ts/browser-net.ts b/packages/providers/src.ts/browser-net.ts new file mode 100644 index 000000000..bd540cc7d --- /dev/null +++ b/packages/providers/src.ts/browser-net.ts @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = { } diff --git a/packages/providers/src.ts/etherscan-provider.ts b/packages/providers/src.ts/etherscan-provider.ts new file mode 100644 index 000000000..f84922397 --- /dev/null +++ b/packages/providers/src.ts/etherscan-provider.ts @@ -0,0 +1,336 @@ +"use strict"; + +import { BlockTag, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { hexlify, hexValue } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { Networkish } from "@ethersproject/networks"; +import { defineReadOnly } from "@ethersproject/properties"; +import { fetchJson } from "@ethersproject/web"; + +import { BaseProvider } from "./base-provider"; + + +// The transaction has already been sanitized by the calls in Provider +function getTransactionString(transaction: TransactionRequest): string { + let result = []; + for (let key in transaction) { + if ((transaction)[key] == null) { continue; } + let value = hexlify((transaction)[key]); + if (({ gasLimit: true, gasPrice: true, nonce: true, value: true })[key]) { + value = hexValue(value); + } + result.push(key + "=" + value); + } + return result.join("&"); +} + +function getResult(result: { status?: number, message?: string, result?: any }): any { + // getLogs, getHistory have weird success responses + if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { + return result.result; + } + + if (result.status != 1 || result.message != "OK") { + // @TODO: not any + let error: any = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + + return result.result; +} + +function getJsonResult(result: { jsonrpc: string, result?: any, error?: { code?: number, data?: any, message?: string} } ): any { + if (result.jsonrpc != "2.0") { + // @TODO: not any + let error: any = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + + if (result.error) { + // @TODO: not any + let error: any = new Error(result.error.message || "unknown error"); + if (result.error.code) { error.code = result.error.code; } + if (result.error.data) { error.data = result.error.data; } + throw error; + } + + return result.result; +} + +// The blockTag was normalized as a string by the Provider pre-perform operations +function checkLogTag(blockTag: string): number | "latest" { + if (blockTag === "pending") { throw new Error("pending not supported"); } + if (blockTag === "latest") { return blockTag; } + + return parseInt(blockTag.substring(2), 16); +} + + +export class EtherscanProvider extends BaseProvider{ + readonly baseUrl: string; + readonly apiKey: string; + constructor(network?: Networkish, apiKey?: string) { + errors.checkNew(new.target, EtherscanProvider); + + super(network); + + let name = "invalid"; + if (this.network) { name = this.network.name; } + + let baseUrl = null; + switch(name) { + case "homestead": + baseUrl = "https://api.etherscan.io"; + break; + case "ropsten": + baseUrl = "https://api-ropsten.etherscan.io"; + break; + case "rinkeby": + baseUrl = "https://api-rinkeby.etherscan.io"; + break; + case "kovan": + baseUrl = "https://api-kovan.etherscan.io"; + break; + case "goerli": + baseUrl = "https://api-goerli.etherscan.io"; + break; + default: + throw new Error("unsupported network"); + } + + defineReadOnly(this, "baseUrl", baseUrl); + defineReadOnly(this, "apiKey", apiKey); + } + + + perform(method: string, params: any) { + let url = this.baseUrl; + + let apiKey = ""; + if (this.apiKey) { apiKey += "&apikey=" + this.apiKey; } + + let get = (url: string, procFunc?: (value: any) => any) => { + return fetchJson(url, null, procFunc || getJsonResult).then((result) => { + this.emit("debug", { + action: "perform", + request: url, + response: result, + provider: this + }); + return result; + }); + }; + + switch (method) { + case "getBlockNumber": + url += "/api?module=proxy&action=eth_blockNumber" + apiKey; + return get(url); + + case "getGasPrice": + url += "/api?module=proxy&action=eth_gasPrice" + apiKey; + return get(url); + + case "getBalance": + // Returns base-10 result + url += "/api?module=account&action=balance&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getResult); + + case "getTransactionCount": + url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url); + + + case "getCode": + url += "/api?module=proxy&action=eth_getCode&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + + case "getStorageAt": + url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; + url += "&position=" + params.position; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + + + case "sendTransaction": + url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; + url += apiKey; + return get(url).catch((error) => { + if (error.responseText) { + // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" + if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, { }); + } + // "Transaction with the same hash was already imported." + if (error.responseText.indexOf("same hash was already imported") >= 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, { }); + } + // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." + if (error.responseText.indexOf("another transaction with same nonce") >= 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, { }); + } + } + throw error; + }); + + case "getBlock": + if (params.blockTag) { + url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; + if (params.includeTransactions) { + url += "&boolean=true"; + } else { + url += "&boolean=false"; + } + url += apiKey; + return get(url); + } + throw new Error("getBlock by blockHash not implmeneted"); + + case "getTransaction": + url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + + case "getTransactionReceipt": + url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + + + case "call": { + let transaction = getTransactionString(params.transaction); + if (transaction) { transaction = "&" + transaction; } + url += "/api?module=proxy&action=eth_call" + transaction; + //url += "&tag=" + params.blockTag + apiKey; + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + url += apiKey; + return get(url); + } + + case "estimateGas": { + let transaction = getTransactionString(params.transaction); + if (transaction) { transaction = "&" + transaction; } + url += "/api?module=proxy&action=eth_estimateGas&" + transaction; + url += apiKey; + return get(url); + } + + case "getLogs": + url += "/api?module=logs&action=getLogs"; + try { + if (params.filter.fromBlock) { + url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); + } + + if (params.filter.toBlock) { + url += "&toBlock=" + checkLogTag(params.filter.toBlock); + } + + if (params.filter.address) { + url += "&address=" + params.filter.address; + } + + // @TODO: We can handle slightly more complicated logs using the logs API + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + throw new Error("unsupported topic format"); + } + let topic0 = params.filter.topics[0]; + if (typeof(topic0) !== "string" || topic0.length !== 66) { + throw new Error("unsupported topic0 format"); + } + url += "&topic0=" + topic0; + } + } catch (error) { + return Promise.reject(error); + } + + url += apiKey; + + let self = this; + return get(url, getResult).then(function(logs: Array) { + let txs: { [hash: string]: string } = {}; + + let seq = Promise.resolve(); + logs.forEach(function(log) { + seq = seq.then(function() { + if (log.blockHash != null) { return null; } + log.blockHash = txs[log.transactionHash]; + if (log.blockHash == null) { + return self.getTransaction(log.transactionHash).then(function(tx) { + txs[log.transactionHash] = tx.blockHash; + log.blockHash = tx.blockHash; + return null; + }); + } + return null; + }); + }); + + return seq.then(function() { + return logs; + }); + }); + + case "getEtherPrice": + if (this.network.name !== "homestead") { return Promise.resolve(0.0); } + url += "/api?module=stats&action=ethprice"; + url += apiKey; + return get(url, getResult).then(function(result) { + return parseFloat(result.ethusd); + }); + + default: + break; + } + + return super.perform(method, params); + } + + // @TODO: Allow startBlock and endBlock to be Promises + getHistory(addressOrName: string | Promise, startBlock?: BlockTag, endBlock?: BlockTag): Promise> { + + let url = this.baseUrl; + + let apiKey = ""; + if (this.apiKey) { apiKey += "&apikey=" + this.apiKey; } + + if (startBlock == null) { startBlock = 0; } + if (endBlock == null) { endBlock = 99999999; } + + return this.resolveName(addressOrName).then((address) => { + url += "/api?module=account&action=txlist&address=" + address; + url += "&startblock=" + startBlock; + url += "&endblock=" + endBlock; + url += "&sort=asc" + apiKey; + + return fetchJson(url, null, getResult).then((result: Array) => { + this.emit("debug", { + action: "getHistory", + request: url, + response: result, + provider: this + }); + let output: Array = []; + result.forEach((tx) => { + ["contractAddress", "to"].forEach(function(key) { + if (tx[key] == "") { delete tx[key]; } + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + let item = this.formatter.transactionResponse(tx); + if (tx.timeStamp) { item.timestamp = parseInt(tx.timeStamp); } + output.push(item); + }); + return output; + }); + }); + } +} diff --git a/packages/providers/src.ts/fallback-provider.ts b/packages/providers/src.ts/fallback-provider.ts new file mode 100644 index 000000000..cebb33120 --- /dev/null +++ b/packages/providers/src.ts/fallback-provider.ts @@ -0,0 +1,240 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; +import { Network } from "@ethersproject/networks"; +import { shuffled } from "@ethersproject/random"; +import { defineReadOnly } from "@ethersproject/properties"; + +import { BaseProvider } from "./base-provider"; + +function now() { return (new Date()).getTime(); } + +// Returns: +// - true is all networks match +// - false if any network is null +// - throws if any 2 networks do not match +function checkNetworks(networks: Array): boolean { + let result = true; + + let check: Network = null; + networks.forEach((network) => { + + // Null + if (network == null) { + result = false; + return; + } + + // Have nothing to compre to yet + if (check == null) { + check = network; + return; + } + + // Matches! + if (check.name === network.name && + check.chainId === network.chainId && + ((check.ensAddress === network.ensAddress) || + (check.ensAddress == null && network.ensAddress == null))) { return; } + + errors.throwError( + "provider mismatch", + errors.INVALID_ARGUMENT, + { arg: "networks", value: networks } + ); + }); + + return result; +} + +type Result = { + result?: any; + error?: Error; + weight: number; +}; + +type Runner = { + run: () => Promise; + weight: number; +}; + + +function serialize(result: any): string { + if (Array.isArray(result)) { + return JSON.stringify(result.map((r) => serialize(r))); + } else if (result === null) { + return "null"; + } else if (typeof(result) === "object") { + let bare: any = {}; + let keys = Object.keys(result); + keys.sort(); + keys.forEach((key) => { + let value = result[key]; + if (typeof(value) === "function") { return; } + bare[key] = serialize(value); + }); + return JSON.stringify(bare); + } + + return JSON.stringify(result); +} + +let nextRid = 1; + +export class FallbackProvider extends BaseProvider { + readonly providers: Array; + readonly weights: Array; + readonly quorum: number; + + constructor(providers: Array, quorum?: number, weights?: Array) { + errors.checkNew(new.target, FallbackProvider); + + if (providers.length === 0) { + errors.throwArgumentError("missing providers", "providers", providers); + } + + if (weights != null && weights.length !== providers.length) { + errors.throwArgumentError("too many weights", "weights", weights); + } else if (!weights) { + weights = providers.map((p) => 1); + } else { + weights.forEach((w) => { + if (w % 1 || w > 512 || w < 1) { + errors.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + } + }); + } + + let total = weights.reduce((accum, w) => (accum + w)); + + if (quorum == null) { + quorum = total / 2; + } else { + if (quorum > total) { + errors.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + } + } + + + // All networks are ready, we can know the network for certain + let ready = checkNetworks(providers.map((p) => p.network)); + if (ready) { + super(providers[0].network); + + } else { + // The network won't be known until all child providers know + let ready = Promise.all(providers.map((p) => p.getNetwork())).then((networks) => { + if (!checkNetworks(networks)) { + errors.throwError("getNetwork returned null", errors.UNKNOWN_ERROR, { }) + } + return networks[0]; + }); + + super(ready); + } + + // Preserve a copy, so we do not get mutated + defineReadOnly(this, "providers", Object.freeze(providers.slice())); + defineReadOnly(this, "quorum", quorum); + defineReadOnly(this, "weights", Object.freeze(weights.slice())); + } + + perform(method: string, params: { [name: string]: any }): any { + let T0 = now(); + let runners: Array = (>(shuffled(this.providers))).map((provider, i) => { + let weight = this.weights[i]; + let rid = nextRid++; + return { + run: () => { + let t0 = now(); + let start = t0 - T0; + this.emit("debug", "perform", rid, { weight, start, provider, method, params }); + return provider.perform(method, params).then((result) => { + let duration = now() - t0; + this.emit("debug", "result", rid, { duration, result }); + return { weight: weight, result: result }; + }, (error) => { + let duration = now() - t0; + this.emit("debug", "error", rid, { duration, error }); + return { weight: weight, error: error }; + }); + }, + weight: weight + } + }); + + // Broadcast transactions to all backends, any that succeed is good enough + if (method === "sendTransaction") { + return Promise.all(runners.map((r) => r.run())).then((results) => { + for (let i = 0; i < results.length; i++) { + let result = results[i]; + if (result.result) { return result.result; } + } + return Promise.reject(results[0].error); + }); + } + + // Otherwise query backends (randomly) until we have a quorum agreement + // on the correct result + return new Promise((resolve, reject) => { + let firstError: Error = null; + + // How much weight is inflight + let inflightWeight = 0; + + // All results, indexed by the serialized response. + let results: { [ unique: string ]: Array } = { }; + + let next = () => { + if (runners.length === 0) { return; } + + let runner = runners.shift(); + inflightWeight += runner.weight; + + runner.run().then((result) => { + if (results === null) { return; } + inflightWeight -= runner.weight; + + if (result.error) { + if (firstError == null) { firstError = result.error; } + + } else { + let unique = serialize(result.result); + if (results[unique] == null) { results[unique] = []; } + results[unique].push(result); + + // Do any results meet our quroum? + for (let u in results) { + let weight = results[u].reduce((accum, r) => (accum + r.weight), 0); + if (weight >= this.quorum) { + let result = results[u][0].result; + this.emit("debug", "quorum", -1, { weight, result }) + resolve(result); + results = null; + return; + } + } + } + + // Out of options; give up + if (runners.length === 0 && inflightWeight === 0) { + reject(firstError); + return; + } + + // Queue up the next round + setTimeout(next, 0); + }); + + // Fire off requests until we could possibly meet quorum + if (inflightWeight < this.quorum) { + setTimeout(next, 0); + return; + } + } + + // bootstrap firing requests + next(); + }); + } +} diff --git a/packages/providers/src.ts/formatter.ts b/packages/providers/src.ts/formatter.ts new file mode 100644 index 000000000..6e378b43c --- /dev/null +++ b/packages/providers/src.ts/formatter.ts @@ -0,0 +1,454 @@ +"use strict"; + +import { Block, TransactionReceipt, TransactionResponse } from "@ethersproject/abstract-provider"; +import { getAddress, getContractAddress } from "@ethersproject/address"; +import { BigNumber } from "@ethersproject/bignumber"; +import { hexDataLength, hexDataSlice, hexValue, hexZeroPad, isHexString } from "@ethersproject/bytes"; +import { AddressZero } from "@ethersproject/constants"; +import * as errors from "@ethersproject/errors"; +import { shallowCopy } from "@ethersproject/properties"; +import { parse as parseTransaction } from "@ethersproject/transactions"; + +export type FormatFunc = (value: any) => any; + +export type FormatFuncs = { [ key: string ]: FormatFunc }; + +export type Formats = { + transaction: FormatFuncs, + transactionRequest: FormatFuncs, + receipt: FormatFuncs, + receiptLog: FormatFuncs, + block: FormatFuncs, + blockWithTransactions: FormatFuncs, + filter: FormatFuncs, + filterLog: FormatFuncs, +}; + +export class Formatter { + readonly formats: Formats; + + constructor() { + errors.checkNew(new.target, Formatter); + this.formats = this.getDefaultFormats(); + } + + getDefaultFormats(): Formats { + let formats: Formats = ({ }); + + let address = this.address.bind(this); + let bigNumber = this.bigNumber.bind(this); + let blockTag = this.blockTag.bind(this); + let data = this.data.bind(this); + let hash = this.hash.bind(this); + let hex = this.hex.bind(this); + let number = this.number.bind(this); + + let strictData = (v: any) => { return this.data(v, true); }; + + formats.transaction = { + hash: hash, + + blockHash: Formatter.allowNull(hash, null), + blockNumber: Formatter.allowNull(number, null), + transactionIndex: Formatter.allowNull(number, null), + + confirmations: Formatter.allowNull(number, null), + + from: address, + + gasPrice: bigNumber, + gasLimit: bigNumber, + to: Formatter.allowNull(address, null), + value: bigNumber, + nonce: number, + data: data, + + r: Formatter.allowNull(this.uint256), + s: Formatter.allowNull(this.uint256), + v: Formatter.allowNull(number), + + creates: Formatter.allowNull(address, null), + + raw: Formatter.allowNull(data), + }; + + formats.transactionRequest = { + from: Formatter.allowNull(address), + nonce: Formatter.allowNull(number), + gasLimit: Formatter.allowNull(bigNumber), + gasPrice: Formatter.allowNull(bigNumber), + to: Formatter.allowNull(address), + value: Formatter.allowNull(bigNumber), + data: Formatter.allowNull(strictData), + }; + + formats.receiptLog = { + transactionLogIndex: Formatter.allowNull(number), + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address: address, + topics: Formatter.arrayOf(hash), + data: data, + logIndex: number, + blockHash: hash, + }; + + formats.receipt = { + to: Formatter.allowNull(this.address), + from: Formatter.allowNull(this.address), + contractAddress: Formatter.allowNull(address, null), + transactionIndex: number, + root: Formatter.allowNull(hash), + gasUsed: bigNumber, + logsBloom: Formatter.allowNull(data),// @TODO: should this be data? + blockHash: hash, + transactionHash: hash, + logs: Formatter.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter.allowNull(number, null), + cumulativeGasUsed: bigNumber, + status: Formatter.allowNull(number) + }; + + formats.block = { + hash: hash, + parentHash: hash, + number: number, + + timestamp: number, + nonce: Formatter.allowNull(hex), + difficulty: this.difficulty.bind(this), + + gasLimit: bigNumber, + gasUsed: bigNumber, + + miner: address, + extraData: data, + + transactions: Formatter.allowNull(Formatter.arrayOf(hash)), + }; + + formats.blockWithTransactions = shallowCopy(formats.block); + formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); + + formats.filter = { + fromBlock: Formatter.allowNull(blockTag, undefined), + toBlock: Formatter.allowNull(blockTag, undefined), + blockHash: Formatter.allowNull(hash, undefined), + address: Formatter.allowNull(address, undefined), + topics: Formatter.allowNull(this.topics.bind(this), undefined), + }; + + formats.filterLog = { + blockNumber: Formatter.allowNull(number), + blockHash: Formatter.allowNull(hash), + transactionIndex: number, + + removed: Formatter.allowNull(this.boolean.bind(this)), + + address: address, + data: Formatter.allowFalsish(data, "0x"), + + topics: Formatter.arrayOf(hash), + + transactionHash: hash, + logIndex: number, + }; + + return formats; + } + + // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number + // Strict! Used on input. + number(number: any): number { + return BigNumber.from(number).toNumber(); + } + + // Strict! Used on input. + bigNumber(value: any): BigNumber { + return BigNumber.from(value); + } + + // Requires a boolean, "true" or "false"; returns a boolean + boolean(value: any): boolean { + if (typeof(value) === "boolean") { return value; } + if (typeof(value) === "string") { + value = value.toLowerCase(); + if (value === "true") { return true; } + if (value === "false") { return false; } + } + throw new Error("invaid boolean - " + value); + } + + hex(value: any, strict?: boolean): string { + if (typeof(value) === "string") { + if (!strict && value.substring(0, 2) !== "0x") { value = "0x" + value; } + if (isHexString(value)) { + return value.toLowerCase(); + } + } + return errors.throwError("invalid hash", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + } + + data(value: any, strict?: boolean): string { + let result = this.hex(value, strict); + if ((result.length % 2) !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + } + + // Requires an address + // Strict! Used on input. + address(value: any): string { + return getAddress(value); + } + + callAddress(value: any): string { + if (!isHexString(value, 32)) { return null; } + let address = getAddress(hexDataSlice(value, 12)); + return (address === AddressZero) ? null: address; + } + + contractAddress(value: any): string { + return getContractAddress(value); + } + + // Strict! Used on input. + blockTag(blockTag: any): string { + if (blockTag == null) { return "latest"; } + + if (blockTag === "earliest") { return "0x0"; } + + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + + if (typeof(blockTag) === "number" || isHexString(blockTag)) { + return hexValue(blockTag); + } + + throw new Error("invalid blockTag"); + } + + // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. + hash(value: any, strict?: boolean): string { + let result = this.hex(value, strict); + if (hexDataLength(result) !== 32) { + return errors.throwError("invalid hash", errors.INVALID_ARGUMENT, { + argument: "value", + value: value + }); + } + return result; + } + + // Returns the difficulty as a number, or if too large (i.e. PoA network) null + difficulty(value: any): number { + let v = BigNumber.from(value); + + try { + return v.toNumber(); + } catch (error) { } + + return null; + } + + uint256(value: any): string { + if (!isHexString(value)) { + throw new Error("invalid uint256"); + } + return hexZeroPad(value, 32); + } + + _block(value: any, format: any): Block { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + return Formatter.check(format, value); + } + + block(value: any): Block { + return this._block(value, this.formats.block); + } + + blockWithTransactions(value: any): Block { + return this._block(value, this.formats.blockWithTransactions); + } + + // Strict! Used on input. + transactionRequest(value: any): any { + return Formatter.check(this.formats.transactionRequest, value); + } + + transactionResponse(transaction: any): TransactionResponse { + + // Rename gas to gasLimit + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (transaction.to && BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + + // Rename input to data + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + + // If to and creates are empty, populate the creates from the transaction + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + + // @TODO: use transaction.serialize? Have to add support for including v, r, and s... + /* + if (!transaction.raw) { + + // Very loose providers (e.g. TestRPC) do not provide a signature or raw + if (transaction.v && transaction.r && transaction.s) { + let raw = [ + stripZeros(hexlify(transaction.nonce)), + stripZeros(hexlify(transaction.gasPrice)), + stripZeros(hexlify(transaction.gasLimit)), + (transaction.to || "0x"), + stripZeros(hexlify(transaction.value || "0x")), + hexlify(transaction.data || "0x"), + stripZeros(hexlify(transaction.v || "0x")), + stripZeros(hexlify(transaction.r)), + stripZeros(hexlify(transaction.s)), + ]; + + transaction.raw = rlpEncode(raw); + } + } + */ + + let result = Formatter.check(this.formats.transaction, transaction); + + let networkId = transaction.networkId; + + // geth-etc returns chainId + if (transaction.chainId != null && networkId == null && result.v == null) { + networkId = transaction.chainId; + } + + if (isHexString(networkId)) { + networkId = BigNumber.from(networkId).toNumber(); + } + + if (typeof(networkId) !== "number" && result.v != null) { + networkId = (result.v - 35) / 2; + if (networkId < 0) { networkId = 0; } + networkId = parseInt(networkId); + } + + if (typeof(networkId) !== "number") { networkId = 0; } + + result.networkId = networkId; + + // 0x0000... should actually be null + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + + return result; + } + + transaction(value: any): any { + return parseTransaction(value); + } + + receiptLog(value: any): any { + return Formatter.check(this.formats.receiptLog, value); + } + + receipt(value: any): TransactionReceipt { + //let status = transactionReceipt.status; + //let root = transactionReceipt.root; + + let result: TransactionReceipt = Formatter.check(this.formats.receipt, value); + result.logs.forEach((entry, index) => { + if (entry.transactionLogIndex == null) { + entry.transactionLogIndex = index; + } + }); + if (value.status != null) { + result.byzantium = true; + } + return result; + } + + topics(value: any): any { + if (Array.isArray(value)) { + return value.map((v) => this.topics(v)); + + } else if (value != null) { + return this.hash(value, true); + } + + return null; + } + + filter(value: any): any { + return Formatter.check(this.formats.filter, value); + } + + filterLog(value: any): any { + return Formatter.check(this.formats.filterLog, value); + } + + static check(format: { [ name: string ]: FormatFunc }, object: any): any { + let result: any = {}; + for (let key in format) { + try { + let value = format[key](object[key]); + if (value !== undefined) { result[key] = value; } + } catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; + } + } + return result; + } + + // if value is null-ish, nullValue is returned + static allowNull(format: FormatFunc, nullValue?: any): FormatFunc { + return (function(value: any) { + if (value == null) { return nullValue; } + return format(value); + }); + } + + // If value is false-ish, replaceValue is returned + static allowFalsish(format: FormatFunc, replaceValue: any): FormatFunc { + return (function(value: any) { + if (!value) { return replaceValue; } + return format(value); + }); + } + + // Requires an Array satisfying check + static arrayOf(format: FormatFunc): FormatFunc { + return (function(array: any): Array { + if (!Array.isArray(array)) { throw new Error("not an array"); } + + let result: any = []; + + array.forEach(function(value) { + result.push(format(value)); + }); + + return result; + }); + } +} + diff --git a/packages/providers/src.ts/index.ts b/packages/providers/src.ts/index.ts new file mode 100644 index 000000000..1828644dd --- /dev/null +++ b/packages/providers/src.ts/index.ts @@ -0,0 +1,88 @@ +"use strict"; + +import { + Block, + BlockTag, + EventType, + Filter, + Log, + Listener, + Provider, + TransactionReceipt, + TransactionRequest, + TransactionResponse +} from "@ethersproject/abstract-provider"; + +import { getNetwork } from "@ethersproject/networks"; +import { Network, Networkish } from "@ethersproject/networks"; + +import { BaseProvider } from "./base-provider"; + +import { AlchemyProvider } from "./alchemy-provider"; +import { EtherscanProvider } from "./etherscan-provider"; +import { FallbackProvider } from "./fallback-provider"; +import { IpcProvider } from "./ipc-provider"; +import { InfuraProvider } from "./infura-provider"; +import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider"; +import { NodesmithProvider } from "./nodesmith-provider"; +import { Web3Provider } from "./web3-provider"; + +import { AsyncSendable } from "./web3-provider"; + + +//////////////////////// +// Exports + +export { + + // Abstract Providers (or Abstract-ish) + Provider, + BaseProvider, + + + /////////////////////// + // Concreate Providers + + FallbackProvider, + + AlchemyProvider, + EtherscanProvider, + InfuraProvider, + JsonRpcProvider, + NodesmithProvider, + Web3Provider, + + IpcProvider, + + + /////////////////////// + // Signer + + JsonRpcSigner, + + + /////////////////////// + // Functions + + getNetwork, + + + /////////////////////// + // Types + + Block, + BlockTag, + EventType, + Filter, + Log, + Listener, + TransactionReceipt, + TransactionRequest, + TransactionResponse, + + AsyncSendable, + + Network, + Networkish +}; + diff --git a/packages/providers/src.ts/infura-provider.ts b/packages/providers/src.ts/infura-provider.ts new file mode 100644 index 000000000..24a38debb --- /dev/null +++ b/packages/providers/src.ts/infura-provider.ts @@ -0,0 +1,50 @@ +"use strict"; + +import { isHexString } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { Network } from "@ethersproject/networks"; + +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; + + +const defaultProjectId = "84842078b09946638c03157f83405213" + +export class InfuraProvider extends UrlJsonRpcProvider { + get projectId(): string { return this.apiKey; } + + static getApiKey(apiKey: string): string { + if (apiKey == null) { return defaultProjectId; } + if (!isHexString(apiKey, 16)) { + errors.throwArgumentError("invalid projectId", "projectId", apiKey); + } + return apiKey; + } + + static getUrl(network: Network, apiKey: string): string { + let host = null; + switch(network.name) { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + default: + errors.throwError("unsupported network", errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + + return "https://" + host + "/v3/" + apiKey; + } +} diff --git a/packages/providers/src.ts/ipc-provider.ts b/packages/providers/src.ts/ipc-provider.ts new file mode 100644 index 000000000..a0b44d38c --- /dev/null +++ b/packages/providers/src.ts/ipc-provider.ts @@ -0,0 +1,71 @@ +"use strict"; + +import net from "net"; + +import * as errors from "@ethersproject/errors"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Networkish } from "@ethersproject/networks"; + +import { JsonRpcProvider } from "./json-rpc-provider"; + + +export class IpcProvider extends JsonRpcProvider { + readonly path: string; + + constructor(path: string, network?: Networkish) { + errors.checkNew(new.target, IpcProvider); + + if (path == null) { + errors.throwError("missing path", errors.MISSING_ARGUMENT, { arg: "path" }); + } + + super("ipc://" + path, network); + + defineReadOnly(this, "path", path); + } + + // @TODO: Create a connection to the IPC path and use filters instead of polling for block + + send(method: string, params: any): Promise { + // This method is very simple right now. We create a new socket + // connection each time, which may be slower, but the main + // advantage we are aiming for now is security. This simplifies + // multiplexing requests (since we do not need to multiplex). + + let payload = JSON.stringify({ + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }); + + return new Promise((resolve, reject) => { + let response = Buffer.alloc(0); + + let stream = net.connect(this.path); + + stream.on("data", (data) => { + response = Buffer.concat([ response, data ]); + }); + + stream.on("end", () => { + try { + resolve(JSON.parse(response.toString()).result); + // @TODO: Better pull apart the error + stream.destroy(); + } catch (error) { + reject(error); + stream.destroy(); + } + }); + + stream.on("error", (error) => { + reject(error); + stream.destroy(); + }); + + stream.write(payload); + stream.end(); + }); + } +} diff --git a/packages/providers/src.ts/json-rpc-provider.ts b/packages/providers/src.ts/json-rpc-provider.ts new file mode 100644 index 000000000..5b75a5dc8 --- /dev/null +++ b/packages/providers/src.ts/json-rpc-provider.ts @@ -0,0 +1,447 @@ +"use strict"; + +// See: https://github.com/ethereum/wiki/wiki/JSON-RPC + +import { Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { BigNumber } from "@ethersproject/bignumber"; +import { Bytes, hexlify, hexValue } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { getNetwork, Network, Networkish } from "@ethersproject/networks"; +import { checkProperties, defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { ConnectionInfo, fetchJson, poll } from "@ethersproject/web"; + +import { BaseProvider } from "./base-provider"; + + +function timer(timeout: number): Promise { + return new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, timeout); + }); +} + +function getResult(payload: { error?: { code?: number, data?: any, message?: string }, result?: any }): any { + if (payload.error) { + // @TODO: not any + let error: any = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; + throw error; + } + + return payload.result; +} + +function getLowerCase(value: string): string { + if (value) { return value.toLowerCase(); } + return value; +} + +const _constructorGuard = {}; + +export class JsonRpcSigner extends Signer { + readonly provider: JsonRpcProvider; + _index: number; + _address: string; + + constructor(constructorGuard: any, provider: JsonRpcProvider, addressOrIndex?: string | number) { + errors.checkNew(new.target, JsonRpcSigner); + + super(); + + if (constructorGuard !== _constructorGuard) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + + defineReadOnly(this, "provider", provider); + + // Statically attach to a given address + if (addressOrIndex == null) { addressOrIndex = 0; } + if (addressOrIndex) { + if (typeof(addressOrIndex) === "string") { + defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex)); + defineReadOnly(this, "_index", null); + } else if (typeof(addressOrIndex) === "number") { + defineReadOnly(this, "_index", addressOrIndex); + defineReadOnly(this, "_address", null); + } else { + errors.throwError("invalid address or index", errors.INVALID_ARGUMENT, { argument: "addressOrIndex", value: addressOrIndex }); + } + } + } + + connect(provider: Provider): JsonRpcSigner { + return errors.throwError("cannot alter JSON-RPC Signer connection", errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + } + + connectUnchecked(): JsonRpcSigner { + return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); + } + + getAddress(): Promise { + if (this._address) { + return Promise.resolve(this._address); + } + + return this.provider.send("eth_accounts", []).then((accounts) => { + if (accounts.length <= this._index) { + errors.throwError("unknown account #" + this._index, errors.UNSUPPORTED_OPERATION, { operation: "getAddress" }); + } + return this.provider.formatter.address(accounts[this._index]) + }); + } + + sendUncheckedTransaction(transaction: TransactionRequest): Promise { + transaction = shallowCopy(transaction); + + let fromAddress = this.getAddress().then((address) => { + if (address) { address = address.toLowerCase(); } + return address; + }); + + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (transaction.gasLimit == null) { + let estimate = shallowCopy(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + + return Promise.all([ + resolveProperties(transaction), + fromAddress + ]).then((results) => { + let tx = results[0]; + let hexTx = (this.constructor).hexlifyTransaction(tx); + hexTx.from = results[1]; + return this.provider.send("eth_sendTransaction", [ hexTx ]).then((hash) => { + return hash; + }, (error) => { + if (error.responseText) { + // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) + if (error.responseText.indexOf("insufficient funds") >= 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, { + transaction: tx + }); + } + if (error.responseText.indexOf("nonce too low") >= 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, { + transaction: tx + }); + } + if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, { + transaction: tx + }); + } + } + throw error; + }); + }); + } + + signTransaction(transaction: TransactionRequest): Promise { + return errors.throwError("signing transactions is unsupported", errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + } + + sendTransaction(transaction: TransactionRequest): Promise { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return poll(() => { + return this.provider.getTransaction(hash).then((tx: TransactionResponse) => { + if (tx === null) { return undefined; } + return this.provider._wrapTransaction(tx, hash); + }); + }, { onceBlock: this.provider }).catch((error: Error) => { + (error).transactionHash = hash; + throw error; + }); + }); + } + + signMessage(message: Bytes | string): Promise { + let data = ((typeof(message) === "string") ? toUtf8Bytes(message): message); + return this.getAddress().then((address) => { + + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + return this.provider.send("eth_sign", [ address.toLowerCase(), hexlify(data) ]); + }); + } + + unlock(password: string): Promise { + let provider = this.provider; + + return this.getAddress().then(function(address) { + return provider.send("personal_unlockAccount", [ address.toLowerCase(), password, null ]); + }); + } +} + +class UncheckedJsonRpcSigner extends JsonRpcSigner { + sendTransaction(transaction: TransactionRequest): Promise { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return { + hash: hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: (confirmations?: number) => { return this.provider.waitForTransaction(hash, confirmations); } + }; + }); + } +} + +const allowedTransactionKeys: { [ key: string ]: boolean } = { + chainId: true, data: true, gasLimit: true, gasPrice:true, nonce: true, to: true, value: true +} + +export class JsonRpcProvider extends BaseProvider { + readonly connection: ConnectionInfo; + + _pendingFilter: Promise; + + constructor(url?: ConnectionInfo | string, network?: Networkish) { + errors.checkNew(new.target, JsonRpcProvider); + + // One parameter, but it is a network name, so swap it with the URL + if (typeof(url) === "string") { + if (network === null && getNetwork(url)) { + network = url; + url = null; + } + } + + if (network) { + // The network has been specified explicitly, we can use it + super(network); + + } else { + + // The network is unknown, query the JSON-RPC for it + let ready: Promise = new Promise((resolve, reject) => { + setTimeout(() => { + this.send("eth_chainId", [ ]).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + this.send("net_version", [ ]).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + reject(errors.makeError("could not detect network", errors.NETWORK_ERROR, { })); + }); + }); + }); + }); + super(ready); + } + + // Default URL + if (!url) { url = "http:/" + "/localhost:8545"; } + + if (typeof(url) === "string") { + this.connection = { + url: url + }; + } else { + this.connection = url; + } + + } + + getSigner(addressOrIndex?: string | number): JsonRpcSigner { + return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); + } + + getUncheckedSigner(addressOrIndex?: string | number): UncheckedJsonRpcSigner { + return this.getSigner(addressOrIndex).connectUnchecked(); + } + + listAccounts(): Promise> { + return this.send("eth_accounts", []).then((accounts: Array) => { + return accounts.map((a) => this.formatter.address(a)); + }); + } + + send(method: string, params: any): Promise { + let request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + + return fetchJson(this.connection, JSON.stringify(request), getResult).then((result) => { + this.emit("debug", { + action: "send", + request: request, + response: result, + provider: this + }); + return result; + }); + } + + perform(method: string, params: any): Promise { + switch (method) { + case "getBlockNumber": + return this.send("eth_blockNumber", []); + + case "getGasPrice": + return this.send("eth_gasPrice", []); + + case "getBalance": + return this.send("eth_getBalance", [ getLowerCase(params.address), params.blockTag ]); + + case "getTransactionCount": + return this.send("eth_getTransactionCount", [ getLowerCase(params.address), params.blockTag ]); + + case "getCode": + return this.send("eth_getCode", [ getLowerCase(params.address), params.blockTag ]); + + case "getStorageAt": + return this.send("eth_getStorageAt", [ getLowerCase(params.address), params.position, params.blockTag ]); + + case "sendTransaction": + return this.send("eth_sendRawTransaction", [ params.signedTransaction ]).catch((error) => { + if (error.responseText) { + // "insufficient funds for gas * price + value" + if (error.responseText.indexOf("insufficient funds") > 0) { + errors.throwError("insufficient funds", errors.INSUFFICIENT_FUNDS, { }); + } + // "nonce too low" + if (error.responseText.indexOf("nonce too low") > 0) { + errors.throwError("nonce has already been used", errors.NONCE_EXPIRED, { }); + } + // "replacement transaction underpriced" + if (error.responseText.indexOf("replacement transaction underpriced") > 0) { + errors.throwError("replacement fee too low", errors.REPLACEMENT_UNDERPRICED, { }); + } + } + throw error; + }); + + case "getBlock": + if (params.blockTag) { + return this.send("eth_getBlockByNumber", [ params.blockTag, !!params.includeTransactions ]); + } else if (params.blockHash) { + return this.send("eth_getBlockByHash", [ params.blockHash, !!params.includeTransactions ]); + } + return Promise.reject(new Error("invalid block tag or block hash")); + + case "getTransaction": + return this.send("eth_getTransactionByHash", [ params.transactionHash ]); + + case "getTransactionReceipt": + return this.send("eth_getTransactionReceipt", [ params.transactionHash ]); + + case "call": + return this.send("eth_call", [ (this.constructor).hexlifyTransaction(params.transaction, { from: true }), params.blockTag ]); + + case "estimateGas": + return this.send("eth_estimateGas", [ (this.constructor).hexlifyTransaction(params.transaction, { from: true }) ]); + + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return this.send("eth_getLogs", [ params.filter ]); + + default: + break; + } + + return errors.throwError(method + " not implemented", errors.NOT_IMPLEMENTED, { operation: method }); + } + + _startPending(): void { + if (this._pendingFilter != null) { return; } + let self = this; + + let pendingFilter: Promise = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + + pendingFilter.then(function(filterId) { + function poll() { + self.send("eth_getFilterChanges", [ filterId ]).then(function(hashes: Array) { + if (self._pendingFilter != pendingFilter) { return null; } + + let seq = Promise.resolve(); + hashes.forEach(function(hash) { + // @TODO: This should be garbage collected at some point... How? When? + self._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function() { + return self.getTransaction(hash).then(function(tx) { + self.emit("pending", tx); + return null; + }); + }); + }); + + return seq.then(function() { + return timer(1000); + }); + }).then(function() { + if (self._pendingFilter != pendingFilter) { + self.send("eth_uninstallFilter", [ filterId ]); + return; + } + setTimeout(function() { poll(); }, 0); + + return null; + }).catch((error: Error) => { }); + } + poll(); + + return filterId; + }).catch((error: Error) => { }); + } + + _stopPending(): void { + this._pendingFilter = null; + } + + // Convert an ethers.js transaction into a JSON-RPC transaction + // - gasLimit => gas + // - All values hexlified + // - All numeric values zero-striped + // NOTE: This allows a TransactionRequest, but all values should be resolved + // before this is called + static hexlifyTransaction(transaction: TransactionRequest, allowExtra?: { [key: string]: boolean }): { [key: string]: string } { + // Check only allowed properties are given + let allowed = shallowCopy(allowedTransactionKeys); + if (allowExtra) { + for (let key in allowExtra) { + if (allowExtra[key]) { allowed[key] = true; } + } + } + checkProperties(transaction, allowed); + + let result: { [key: string]: string } = {}; + + // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. + ["gasLimit", "gasPrice", "nonce", "value"].forEach(function(key) { + if ((transaction)[key] == null) { return; } + let value = hexValue((transaction)[key]); + if (key === "gasLimit") { key = "gas"; } + result[key] = value; + }); + + ["from", "to", "data"].forEach(function(key) { + if ((transaction)[key] == null) { return; } + result[key] = hexlify((transaction)[key]); + }); + + return result; + } +} diff --git a/packages/providers/src.ts/nodesmith-provider.ts b/packages/providers/src.ts/nodesmith-provider.ts new file mode 100644 index 000000000..55c2fc132 --- /dev/null +++ b/packages/providers/src.ts/nodesmith-provider.ts @@ -0,0 +1,42 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; + +import { Network } from "@ethersproject/networks"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; + + +// Special API key provided by Nodesmith for ethers.js +const defaultApiKey = "ETHERS_JS_SHARED"; + +export class NodesmithProvider extends UrlJsonRpcProvider { + + static getApiKey(apiKey: string): string { + return apiKey || defaultApiKey; + } + + static getUrl(network: Network, apiKey?: string): string { + let host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + errors.throwArgumentError("unsupported network", "network", arguments[0]); + } + + return (host + "?apiKey=" + apiKey); + } +} diff --git a/packages/providers/src.ts/url-json-rpc-provider.ts b/packages/providers/src.ts/url-json-rpc-provider.ts new file mode 100644 index 000000000..eef17dd2a --- /dev/null +++ b/packages/providers/src.ts/url-json-rpc-provider.ts @@ -0,0 +1,54 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; +import { getNetwork, Network, Networkish } from "@ethersproject/networks"; +import { defineReadOnly } from "@ethersproject/properties"; + +import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider"; + +export class UrlJsonRpcProvider extends JsonRpcProvider { + readonly apiKey: string; + + constructor(network?: Networkish, apiKey?: string) { + errors.checkAbstract(new.target, UrlJsonRpcProvider); + + network = getNetwork((network == null) ? "homestead": network); + apiKey = new.target.getApiKey(apiKey); + + let url = new.target.getUrl(network, apiKey); + + super(url, network); + + defineReadOnly(this, "apiKey", apiKey); + } + + _startPending(): void { + errors.warn("WARNING: API provider does not support pending filters"); + } + + getSigner(address?: string): JsonRpcSigner { + errors.throwError( + "API provider does not support signing", + errors.UNSUPPORTED_OPERATION, + { operation: "getSigner" } + ); + return null; + } + + listAccounts(): Promise> { + return Promise.resolve([]); + } + + // Return a defaultApiKey if null, otherwise validate the API key + static getApiKey(apiKey: string): string { + return apiKey; + } + + // Returns the url for the given network and API key + static getUrl(network: Network, apiKey: string): string { + return errors.throwError("not implemented; sub-classes must override getUrl", errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + } + +} diff --git a/packages/providers/src.ts/web3-provider.ts b/packages/providers/src.ts/web3-provider.ts new file mode 100644 index 000000000..4082de958 --- /dev/null +++ b/packages/providers/src.ts/web3-provider.ts @@ -0,0 +1,92 @@ +"use strict"; + +import * as errors from "@ethersproject/errors"; +import { Networkish } from "@ethersproject/networks"; +import { defineReadOnly } from "@ethersproject/properties"; + +import { JsonRpcProvider } from "./json-rpc-provider"; + + +// Exported Types +export type AsyncSendable = { + isMetaMask?: boolean; + host?: string; + path?: string; + sendAsync?: (request: any, callback: (error: any, response: any) => void) => void + send?: (request: any, callback: (error: any, response: any) => void) => void +} + +/* +@TODO +utils.defineProperty(Web3Signer, "onchange", { + +}); + +*/ + +export class Web3Provider extends JsonRpcProvider { + readonly _web3Provider: AsyncSendable; + private _sendAsync: (request: any, callback: (error: any, response: any) => void) => void; + + constructor(web3Provider: AsyncSendable, network?: Networkish) { + errors.checkNew(new.target, Web3Provider); + + // HTTP has a host; IPC has a path. + super(web3Provider.host || web3Provider.path || "", network); + + if (web3Provider) { + if (web3Provider.sendAsync) { + this._sendAsync = web3Provider.sendAsync.bind(web3Provider); + } else if (web3Provider.send) { + this._sendAsync = web3Provider.send.bind(web3Provider); + } + } + + if (!web3Provider || !this._sendAsync) { + errors.throwError( + "invalid web3Provider", + errors.INVALID_ARGUMENT, + { arg: "web3Provider", value: web3Provider } + ); + } + + defineReadOnly(this, "_web3Provider", web3Provider); + } + + send(method: string, params: any): Promise { + + // Metamask complains about eth_sign (and on some versions hangs) + if (method == "eth_sign" && this._web3Provider.isMetaMask) { + // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + method = "personal_sign"; + params = [ params[1], params[0] ]; + } + + return new Promise((resolve, reject) => { + let request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + + this._sendAsync(request, function(error, result) { + if (error) { + reject(error); + return; + } + + if (result.error) { + // @TODO: not any + let error: any = new Error(result.error.message); + error.code = result.error.code; + error.data = result.error.data; + reject(error); + return; + } + + resolve(result.result); + }); + }); + } +} diff --git a/packages/providers/tsconfig.json b/packages/providers/tsconfig.json new file mode 100644 index 000000000..969328db8 --- /dev/null +++ b/packages/providers/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/random/.gitignore b/packages/random/.gitignore new file mode 100644 index 000000000..aa5c62527 --- /dev/null +++ b/packages/random/.gitignore @@ -0,0 +1 @@ +browser.d.ts diff --git a/packages/random/.npmignore b/packages/random/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/random/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/random/LICENSE.md b/packages/random/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/random/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/random/README.md b/packages/random/README.md new file mode 100644 index 000000000..f04a4efbd --- /dev/null +++ b/packages/random/README.md @@ -0,0 +1,17 @@ +Random Value Utilities +====================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/random/package.json b/packages/random/package.json new file mode 100644 index 000000000..9ec5f7f5b --- /dev/null +++ b/packages/random/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/random", + "version": "5.0.0-beta.124", + "description": "Random utility functions for ethers.", + "main": "index.js", + "browser": "browser.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@types/node": "^10.3.2" + }, + "keywords": [ + "Ethereum", + "ethers", + "random" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x8c5e3559cbbd8dd93f0badc75c974ef48a349354acf66eba819475d676c076b7" +} diff --git a/packages/random/src.ts/_version.ts b/packages/random/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/random/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/random/src.ts/browser.ts b/packages/random/src.ts/browser.ts new file mode 100644 index 000000000..86eff57ef --- /dev/null +++ b/packages/random/src.ts/browser.ts @@ -0,0 +1,33 @@ +"use strict"; + +import { arrayify } from "@ethersproject/bytes"; +import * as errors from"@ethersproject/errors"; + +export { shuffled } from "./shuffle"; + +let crypto: any = (global).crypto || (global).msCrypto; +if (!crypto || !crypto.getRandomValues) { + + errors.warn("WARNING: Missing strong random number source"); + + crypto = { + getRandomValues: function(buffer: Uint8Array): Uint8Array { + return errors.throwError("no secure random source avaialble", errors.UNSUPPORTED_OPERATION, { + operation: "crypto.getRandomValues" + }); + } + }; +} + +export function randomBytes(length: number): Uint8Array { + if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { + errors.throwError("invalid length", errors.INVALID_ARGUMENT, { + argument: "length", + value: length + }); + } + + let result = new Uint8Array(length); + crypto.getRandomValues(result); + return arrayify(result); +}; diff --git a/packages/random/src.ts/index.ts b/packages/random/src.ts/index.ts new file mode 100644 index 000000000..1f3b84a1e --- /dev/null +++ b/packages/random/src.ts/index.ts @@ -0,0 +1,12 @@ +"use strict"; + +import { randomBytes as _randomBytes } from "crypto"; + +import { arrayify } from "@ethersproject/bytes"; + +export { shuffled } from "./shuffle"; + +export function randomBytes(length: number): Uint8Array { + return arrayify(_randomBytes(length)); +} + diff --git a/packages/random/src.ts/shuffle.ts b/packages/random/src.ts/shuffle.ts new file mode 100644 index 000000000..c3cb176e4 --- /dev/null +++ b/packages/random/src.ts/shuffle.ts @@ -0,0 +1,14 @@ +"use strict"; + +export function shuffled(array: Array): Array { + array = array.slice(); + + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)); + let tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + + return array; +} diff --git a/packages/random/tsconfig.json b/packages/random/tsconfig.json new file mode 100644 index 000000000..969328db8 --- /dev/null +++ b/packages/random/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/rlp/.npmignore b/packages/rlp/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/rlp/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/rlp/LICENSE.md b/packages/rlp/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/rlp/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/rlp/README.md b/packages/rlp/README.md new file mode 100644 index 000000000..1693604f1 --- /dev/null +++ b/packages/rlp/README.md @@ -0,0 +1,17 @@ +Recursive-Length Prefix Coder +============================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/rlp/package.json b/packages/rlp/package.json new file mode 100644 index 000000000..eae51640e --- /dev/null +++ b/packages/rlp/package.json @@ -0,0 +1,23 @@ +{ + "name": "@ethersproject/rlp", + "version": "5.0.0-beta.124", + "description": "Recursive-Length Prefix (RLP) coder.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers", + "rlp" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xd016b9a8cbeacb891eb40af683ace142e4618568cfa00234e2d5d82efbc26bc8" +} diff --git a/packages/rlp/src.ts/_version.ts b/packages/rlp/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/rlp/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/rlp/src.ts/index.ts b/packages/rlp/src.ts/index.ts new file mode 100644 index 000000000..8fd3aa853 --- /dev/null +++ b/packages/rlp/src.ts/index.ts @@ -0,0 +1,146 @@ +"use strict"; + +//See: https://github.com/ethereum/wiki/wiki/RLP + + +import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes"; + +function arrayifyInteger(value: number): Array { + let result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; +} + +function unarrayifyInteger(data: Uint8Array, offset: number, length: number): number { + let result = 0; + for (let i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; +} + +function _encode(object: Array | string): Array { + if (Array.isArray(object)) { + let payload: Array = []; + object.forEach(function(child) { + payload = payload.concat(_encode(child)); + }); + + if (payload.length <= 55) { + payload.unshift(0xc0 + payload.length) + return payload; + } + + let length = arrayifyInteger(payload.length); + length.unshift(0xf7 + length.length); + + return length.concat(payload); + + } + + let data: Array = Array.prototype.slice.call(arrayify(object)); + + if (data.length === 1 && data[0] <= 0x7f) { + return data; + + } else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + + let length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + + return length.concat(data); +} + +export function encode(object: any): string { + return hexlify(_encode(object)); +} + +type Decoded = { + result: any; + consumed: number; +}; + +function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded { + let result = []; + + while (childOffset < offset + 1 + length) { + let decoded = _decode(data, childOffset); + + result.push(decoded.result); + + childOffset += decoded.consumed; + if (childOffset > offset + 1 + length) { + throw new Error("invalid rlp"); + } + } + + return {consumed: (1 + length), result: result}; +} + +// returns { consumed: number, result: Object } +function _decode(data: Uint8Array, offset: number): { consumed: number, result: any } { + if (data.length === 0) { throw new Error("invalid rlp data"); } + + // Array with extra length prefix + if (data[offset] >= 0xf8) { + let lengthLength = data[offset] - 0xf7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("too short"); + } + + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("to short"); + } + + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length); + + } else if (data[offset] >= 0xc0) { + let length = data[offset] - 0xc0; + if (offset + 1 + length > data.length) { + throw new Error("invalid rlp data"); + } + + return _decodeChildren(data, offset, offset + 1, length); + + } else if (data[offset] >= 0xb8) { + let lengthLength = data[offset] - 0xb7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("invalid rlp data"); + } + + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("invalid rlp data"); + } + + let result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length)); + return { consumed: (1 + lengthLength + length), result: result } + + } else if (data[offset] >= 0x80) { + let length = data[offset] - 0x80; + if (offset + 1 + length > data.length) { + throw new Error("invlaid rlp data"); + } + + let result = hexlify(data.slice(offset + 1, offset + 1 + length)); + return { consumed: (1 + length), result: result } + } + return { consumed: 1, result: hexlify(data[offset]) }; +} + +export function decode(data: BytesLike): any { + let bytes = arrayify(data); + let decoded = _decode(bytes, 0); + if (decoded.consumed !== bytes.length) { + throw new Error("invalid rlp data"); + } + return decoded.result; +} + diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/rlp/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/sha2/.gitignore b/packages/sha2/.gitignore new file mode 100644 index 000000000..aa5c62527 --- /dev/null +++ b/packages/sha2/.gitignore @@ -0,0 +1 @@ +browser.d.ts diff --git a/packages/sha2/.npmignore b/packages/sha2/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/sha2/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/sha2/LICENSE.md b/packages/sha2/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/sha2/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sha2/README.md b/packages/sha2/README.md new file mode 100644 index 000000000..fce94ac48 --- /dev/null +++ b/packages/sha2/README.md @@ -0,0 +1,17 @@ +SHA2 Hash Functions +=================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/sha2/package.json b/packages/sha2/package.json new file mode 100644 index 000000000..f9315e9cf --- /dev/null +++ b/packages/sha2/package.json @@ -0,0 +1,25 @@ +{ + "name": "@ethersproject/sha2", + "version": "5.0.0-beta.124", + "description": "Error utility functions for ethers.", + "main": "index.js", + "browser": "browser.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "hash.js": "1.1.3" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x5deeeeba2b49c9f7dcaf8ccc7ff399a5af73dadd64ebbb400e65f85f99ef3e21" +} diff --git a/packages/sha2/src.ts/_version.ts b/packages/sha2/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/sha2/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/sha2/src.ts/browser.ts b/packages/sha2/src.ts/browser.ts new file mode 100644 index 000000000..7fd56a392 --- /dev/null +++ b/packages/sha2/src.ts/browser.ts @@ -0,0 +1,34 @@ +"use strict"; + +import * as hash from "hash.js"; + +import { arrayify, BytesLike } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; + + +export enum SupportedAlgorithms { sha256 = "sha256", sha512 = "sha512" }; + +export function ripemd160(data: BytesLike): string { + return "0x" + (hash.ripemd160().update(arrayify(data)).digest("hex")); +} + +export function sha256(data: BytesLike): string { + return "0x" + (hash.sha256().update(arrayify(data)).digest("hex")); +} + +export function sha512(data: BytesLike): string { + return "0x" + (hash.sha512().update(arrayify(data)).digest("hex")); +} + + +export function computeHmac(algorithm: SupportedAlgorithms, key: BytesLike, data: BytesLike): string { + if (!SupportedAlgorithms[algorithm]) { + errors.throwError("unsupported algorithm " + algorithm, errors.UNSUPPORTED_OPERATION, { + operation: "hmac", + algorithm: algorithm + }); + } + + return "0x" + hash.hmac((hash)[algorithm], arrayify(key)).update(arrayify(data)).digest(); +} + diff --git a/packages/sha2/src.ts/index.ts b/packages/sha2/src.ts/index.ts new file mode 100644 index 000000000..676176ef2 --- /dev/null +++ b/packages/sha2/src.ts/index.ts @@ -0,0 +1,35 @@ +"use strict"; + +import { createHash, createHmac } from 'crypto'; + +import { arrayify, BytesLike } from '@ethersproject/bytes'; +import * as errors from '@ethersproject/errors'; + + +export enum SupportedAlgorithms { sha256 = "sha256", sha512 = "sha512" }; + + +export function ripemd160(data: BytesLike): string { + return "0x" + createHash("ripemd160").update(Buffer.from(arrayify(data))).digest("hex") +} + +export function sha256(data: BytesLike): string { + return "0x" + createHash("sha256").update(Buffer.from(arrayify(data))).digest("hex") +} + +export function sha512(data: BytesLike): string { + return "0x" + createHash("sha512").update(Buffer.from(arrayify(data))).digest("hex") +} + + +export function computeHmac(algorithm: SupportedAlgorithms, key: BytesLike, data: BytesLike): string { + if (!SupportedAlgorithms[algorithm]) { + errors.throwError("unsupported algorithm - " + algorithm, errors.UNSUPPORTED_OPERATION, { + operation: "computeHmac", + algorithm: algorithm + }); + } + + return "0x" + createHmac(algorithm, Buffer.from(arrayify(key))).update(Buffer.from(arrayify(data))).digest("hex"); +} + diff --git a/packages/sha2/thirdparty.d.ts b/packages/sha2/thirdparty.d.ts new file mode 100644 index 000000000..a0f86e85d --- /dev/null +++ b/packages/sha2/thirdparty.d.ts @@ -0,0 +1,14 @@ +declare module "hash.js" { + export interface HashFunc { + update(chunk: Uint8Array): HashFunc; + digest(encoding: string): string; + digest(): Uint8Array; + } + + export type CreateHashFunc = () => HashFunc; + + export function sha256(): HashFunc; + export function sha512(): HashFunc; + export function ripemd160(): HashFunc; + export function hmac(createHashFunc: CreateHashFunc, key: Uint8Array): HashFunc; +} diff --git a/packages/sha2/tsconfig.json b/packages/sha2/tsconfig.json new file mode 100644 index 000000000..d0d26fd98 --- /dev/null +++ b/packages/sha2/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*.ts" + ], + "exclude": [ ] +} + diff --git a/packages/shims/.npmignore b/packages/shims/.npmignore new file mode 100644 index 000000000..15231cfea --- /dev/null +++ b/packages/shims/.npmignore @@ -0,0 +1 @@ +tsconfig.json diff --git a/packages/shims/LICENSE.md b/packages/shims/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/shims/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/shims/README.md b/packages/shims/README.md new file mode 100644 index 000000000..e341bd270 --- /dev/null +++ b/packages/shims/README.md @@ -0,0 +1,17 @@ +Compatibility Shims (for constrained environments) +================================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/shims/dist/index.js b/packages/shims/dist/index.js new file mode 100644 index 000000000..6f4a6ebc8 --- /dev/null +++ b/packages/shims/dist/index.js @@ -0,0 +1,1979 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],2:[function(require,module,exports){ +/** + * See: https://github.com/MaxArt2501/base64-js + * The MIT License (MIT) + * + * Copyright (c) 2014 MaxArt2501 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], function() {factory(root);}); + } else factory(root); +// node.js has always supported base64 conversions, while browsers that support +// web workers support base64 too, but you may never know. +})(typeof exports !== "undefined" ? exports : this, function(root) { + if (root.atob) { + // Some browsers' implementation of atob doesn't support whitespaces + // in the encoded string (notably, IE). This wraps the native atob + // in a function that strips the whitespaces. + // The original function can be retrieved in atob.original + try { + root.atob(" "); + } catch(e) { + root.atob = (function(atob) { + var func = function(string) { + return atob(String(string).replace(/[\t\n\f\r ]+/g, "")); + }; + func.original = atob; + return func; + })(root.atob); + } + return; + } + + // base64 character set, plus padding character (=) + var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + // Regular expression to check formal correctness of base64 encoded strings + b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; + + root.btoa = function(string) { + string = String(string); + var bitmap, a, b, c, + result = "", i = 0, + rest = string.length % 3; // To determine the final padding + + for (; i < string.length;) { + if ((a = string.charCodeAt(i++)) > 255 + || (b = string.charCodeAt(i++)) > 255 + || (c = string.charCodeAt(i++)) > 255) + throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."); + + bitmap = (a << 16) | (b << 8) | c; + result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63); + } + + // If there's need of padding, replace the last 'A's with equal signs + return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result; + }; + + root.atob = function(string) { + // atob can work with strings with whitespaces, even inside the encoded part, + // but only \t, \n, \f, \r and ' ', which can be stripped. + string = String(string).replace(/[\t\n\f\r ]+/g, ""); + if (!b64re.test(string)) + throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); + + // Adding the padding if missing, for semplicity + string += "==".slice(2 - (string.length & 3)); + var bitmap, result = "", r1, r2, i = 0; + for (; i < string.length;) { + bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 + | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++))); + + result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) + : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) + : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255); + } + return result; + }; +}); + +},{}],3:[function(require,module,exports){ +(function (process,global){ +/*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE + * @version 4.1.0+f046478d + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.ES6Promise = factory()); +}(this, (function () { 'use strict'; + +function objectOrFunction(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +function isFunction(x) { + return typeof x === 'function'; +} + +var _isArray = undefined; +if (Array.isArray) { + _isArray = Array.isArray; +} else { + _isArray = function (x) { + return Object.prototype.toString.call(x) === '[object Array]'; + }; +} + +var isArray = _isArray; + +var len = 0; +var vertxNext = undefined; +var customSchedulerFn = undefined; + +var asap = function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 2, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + if (customSchedulerFn) { + customSchedulerFn(flush); + } else { + scheduleFlush(); + } + } +}; + +function setScheduler(scheduleFn) { + customSchedulerFn = scheduleFn; +} + +function setAsap(asapFn) { + asap = asapFn; +} + +var browserWindow = typeof window !== 'undefined' ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // see https://github.com/cujojs/when/issues/410 for details + return function () { + return process.nextTick(flush); + }; +} + +// vertx +function useVertxTimer() { + if (typeof vertxNext !== 'undefined') { + return function () { + vertxNext(flush); + }; + } + + return useSetTimeout(); +} + +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function () { + node.data = iterations = ++iterations % 2; + }; +} + +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + return channel.port2.postMessage(0); + }; +} + +function useSetTimeout() { + // Store setTimeout reference so es6-promise will be unaffected by + // other code modifying setTimeout (like sinon.useFakeTimers()) + var globalSetTimeout = setTimeout; + return function () { + return globalSetTimeout(flush, 1); + }; +} + +var queue = new Array(1000); +function flush() { + for (var i = 0; i < len; i += 2) { + var callback = queue[i]; + var arg = queue[i + 1]; + + callback(arg); + + queue[i] = undefined; + queue[i + 1] = undefined; + } + + len = 0; +} + +function attemptVertx() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch (e) { + return useSetTimeout(); + } +} + +var scheduleFlush = undefined; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); +} else if (isWorker) { + scheduleFlush = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush = attemptVertx(); +} else { + scheduleFlush = useSetTimeout(); +} + +function then(onFulfillment, onRejection) { + var _arguments = arguments; + + var parent = this; + + var child = new this.constructor(noop); + + if (child[PROMISE_ID] === undefined) { + makePromise(child); + } + + var _state = parent._state; + + if (_state) { + (function () { + var callback = _arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); + })(); + } else { + subscribe(parent, child, onFulfillment, onRejection); + } + + return child; +} + +/** + `Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {Any} value value that the returned promise will be resolved with + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } + + var promise = new Constructor(noop); + resolve(promise, object); + return promise; +} + +var PROMISE_ID = Math.random().toString(36).substring(16); + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function selfFulfillment() { + return new TypeError("You cannot resolve a promise with itself"); +} + +function cannotReturnOwn() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function getThen(promise) { + try { + return promise.then; + } catch (error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} + +function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { + try { + then$$1.call(value, fulfillmentHandler, rejectionHandler); + } catch (e) { + return e; + } +} + +function handleForeignThenable(promise, thenable, then$$1) { + asap(function (promise) { + var sealed = false; + var error = tryThen(then$$1, thenable, function (value) { + if (sealed) { + return; + } + sealed = true; + if (thenable !== value) { + resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function (reason) { + if (sealed) { + return; + } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); + } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function (value) { + return resolve(promise, value); + }, function (reason) { + return reject(promise, reason); + }); + } +} + +function handleMaybeThenable(promise, maybeThenable, then$$1) { + if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$1 === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + GET_THEN_ERROR.error = null; + } else if (then$$1 === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$1)) { + handleForeignThenable(promise, maybeThenable, then$$1); + } else { + fulfill(promise, maybeThenable); + } + } +} + +function resolve(promise, value) { + if (promise === value) { + reject(promise, selfFulfillment()); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} + +function publishRejection(promise) { + if (promise._onerror) { + promise._onerror(promise._result); + } + + publish(promise); +} + +function fulfill(promise, value) { + if (promise._state !== PENDING) { + return; + } + + promise._result = value; + promise._state = FULFILLED; + + if (promise._subscribers.length !== 0) { + asap(publish, promise); + } +} + +function reject(promise, reason) { + if (promise._state !== PENDING) { + return; + } + promise._state = REJECTED; + promise._result = reason; + + asap(publishRejection, promise); +} + +function subscribe(parent, child, onFulfillment, onRejection) { + var _subscribers = parent._subscribers; + var length = _subscribers.length; + + parent._onerror = null; + + _subscribers[length] = child; + _subscribers[length + FULFILLED] = onFulfillment; + _subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + asap(publish, parent); + } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; + + if (subscribers.length === 0) { + return; + } + + var child = undefined, + callback = undefined, + detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); + } + } + + promise._subscribers.length = 0; +} + +function ErrorObject() { + this.error = null; +} + +var TRY_CATCH_ERROR = new ErrorObject(); + +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch (e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value = undefined, + error = undefined, + succeeded = undefined, + failed = undefined; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value.error = null; + } else { + succeeded = true; + } + + if (promise === value) { + reject(promise, cannotReturnOwn()); + return; + } + } else { + value = detail; + succeeded = true; + } + + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} + +function initializePromise(promise, resolver) { + try { + resolver(function resolvePromise(value) { + resolve(promise, value); + }, function rejectPromise(reason) { + reject(promise, reason); + }); + } catch (e) { + reject(promise, e); + } +} + +var id = 0; +function nextId() { + return id++; +} + +function makePromise(promise) { + promise[PROMISE_ID] = id++; + promise._state = undefined; + promise._result = undefined; + promise._subscribers = []; +} + +function Enumerator$1(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); + + if (!this.promise[PROMISE_ID]) { + makePromise(this.promise); + } + + if (isArray(input)) { + this.length = input.length; + this._remaining = input.length; + + this._result = new Array(this.length); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(input); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + reject(this.promise, validationError()); + } +} + +function validationError() { + return new Error('Array Methods must be provided an Array'); +} + +Enumerator$1.prototype._enumerate = function (input) { + for (var i = 0; this._state === PENDING && i < input.length; i++) { + this._eachEntry(input[i], i); + } +}; + +Enumerator$1.prototype._eachEntry = function (entry, i) { + var c = this._instanceConstructor; + var resolve$$1 = c.resolve; + + if (resolve$$1 === resolve$1) { + var _then = getThen(entry); + + if (_then === then && entry._state !== PENDING) { + this._settledAt(entry._state, i, entry._result); + } else if (typeof _then !== 'function') { + this._remaining--; + this._result[i] = entry; + } else if (c === Promise$3) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, _then); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function (resolve$$1) { + return resolve$$1(entry); + }), i); + } + } else { + this._willSettleAt(resolve$$1(entry), i); + } +}; + +Enumerator$1.prototype._settledAt = function (state, i, value) { + var promise = this.promise; + + if (promise._state === PENDING) { + this._remaining--; + + if (state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = value; + } + } + + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; + +Enumerator$1.prototype._willSettleAt = function (promise, i) { + var enumerator = this; + + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); +}; + +/** + `Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = resolve(2); + let promise3 = resolve(3); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = reject(new Error("2")); + let promise3 = reject(new Error("3")); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all$1(entries) { + return new Enumerator$1(this, entries).promise; +} + +/** + `Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} promises array of promises to observe + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race$1(entries) { + /*jshint validthis:true */ + var Constructor = this; + + if (!isArray(entries)) { + return new Constructor(function (_, reject) { + return reject(new TypeError('You must pass an array to race.')); + }); + } else { + return new Constructor(function (resolve, reject) { + var length = entries.length; + for (var i = 0; i < length; i++) { + Constructor.resolve(entries[i]).then(resolve, reject); + } + }); + } +} + +/** + `Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {Any} reason value that the returned promise will be rejected with. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop); + reject(promise, reason); + return promise; +} + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise's eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + let promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + let xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } + }; + }); + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class Promise + @param {function} resolver + Useful for tooling. + @constructor +*/ +function Promise$3(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise$3 ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise$3.all = all$1; +Promise$3.race = race$1; +Promise$3.resolve = resolve$1; +Promise$3.reject = reject$1; +Promise$3._setScheduler = setScheduler; +Promise$3._setAsap = setAsap; +Promise$3._asap = asap; + +Promise$3.prototype = { + constructor: Promise$3, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + let result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + let author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. + @return {Promise} + */ + then: then, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function _catch(onRejection) { + return this.then(null, onRejection); + } +}; + +/*global self*/ +function polyfill$1() { + var local = undefined; + + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + + var P = local.Promise; + + if (P) { + var promiseToString = null; + try { + promiseToString = Object.prototype.toString.call(P.resolve()); + } catch (e) { + // silently ignored + } + + if (promiseToString === '[object Promise]' && !P.cast) { + return; + } + } + + local.Promise = Promise$3; +} + +// Strange compat.. +Promise$3.polyfill = polyfill$1; +Promise$3.Promise = Promise$3; + +Promise$3.polyfill(); + +return Promise$3; + +}))); + + + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":1}],4:[function(require,module,exports){ +(function (global){ +'use strict'; + +var shims = []; + +// Shim String.prototype.normalize +try { + var missing = []; + + // Some platforms are missing certain normalization forms + var forms = ["NFD", "NFC", "NFKD", "NFKC"]; + for (var i = 0; i < forms.length; i++) { + try { + if ("test".normalize(forms[i]) !== "test") { + throw new Error("failed to normalize"); + } + } catch(error) { + missing.push(forms[i]); + } + } + + if (missing.length) { + shims.push("String.prototype.normalize (missing: " + missing.join(", ") + ")"); + throw new Error('bad normalize'); + } + + // Some platforms have a native normalize, but it is broken; so we force our shim + if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) { + shims.push("String.prototype.normalize (broken)"); + throw new Error('bad normalize'); + } +} catch (error) { + var unorm = require('./unorm.js'); + String.prototype.normalize = function(form) { + var func = unorm[(form || 'NFC').toLowerCase()]; + if (!func) { throw new RangeError('invalid form - ' + form); } + return func(this); + } +} + +// Shim atob and btoa +var base64 = require('./base64.js'); +if (!global.atob) { + shims.push("atob"); + global.atob = base64.atob; +} +if (!global.btoa) { + shims.push("btoa"); + global.btoa = base64.btoa; +} + +// Shim Promise +// @TODO: Check first? +if (window.Promise == null) { + var promise = require('./es6-promise.auto.js'); +} + +// Shim ArrayBuffer.isView +if (!ArrayBuffer.isView) { + shims.push("ArrayBuffer.isView"); + ArrayBuffer.isView = function(obj) { + // @TODO: This should probably check various instanceof aswell + return !!(obj.buffer); + } +} + +// Shim nextTick +if (!global.nextTick) { + shims.push("nextTick"); + global.nextTick = function (callback) { setTimeout(callback, 0); } +} + +if (shims.length) { + console.log("Shims Injected:"); + for (var i = 0; i < shims.length; i++) { + console.log(' - ' + shims[i]); + } +} + +// @TOOD: Add crypto.rand? +// - https://github.com/brix/crypto-js/issues/7 + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./base64.js":2,"./es6-promise.auto.js":3,"./unorm.js":5}],5:[function(require,module,exports){ +(function (root) { + "use strict"; + +/***** unorm.js *****/ + +/* + * UnicodeNormalizer 1.0.0 + * Copyright (c) 2008 Matsuza + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * $Date: 2008-06-05 16:44:17 +0200 (Thu, 05 Jun 2008) $ + * $Rev: 13309 $ + */ + + var DEFAULT_FEATURE = [null, 0, {}]; + var CACHE_THRESHOLD = 10; + var SBase = 0xAC00, LBase = 0x1100, VBase = 0x1161, TBase = 0x11A7, LCount = 19, VCount = 21, TCount = 28; + var NCount = VCount * TCount; // 588 + var SCount = LCount * NCount; // 11172 + + var UChar = function(cp, feature){ + this.codepoint = cp; + this.feature = feature; + }; + + // Strategies + var cache = {}; + var cacheCounter = []; + for (var i = 0; i <= 0xFF; ++i){ + cacheCounter[i] = 0; + } + + function fromCache(next, cp, needFeature){ + var ret = cache[cp]; + if(!ret){ + ret = next(cp, needFeature); + if(!!ret.feature && ++cacheCounter[(cp >> 8) & 0xFF] > CACHE_THRESHOLD){ + cache[cp] = ret; + } + } + return ret; + } + + function fromData(next, cp, needFeature){ + var hash = cp & 0xFF00; + var dunit = UChar.udata[hash] || {}; + var f = dunit[cp]; + return f ? new UChar(cp, f) : new UChar(cp, DEFAULT_FEATURE); + } + function fromCpOnly(next, cp, needFeature){ + return !!needFeature ? next(cp, needFeature) : new UChar(cp, null); + } + function fromRuleBasedJamo(next, cp, needFeature){ + var j; + if(cp < LBase || (LBase + LCount <= cp && cp < SBase) || (SBase + SCount < cp)){ + return next(cp, needFeature); + } + if(LBase <= cp && cp < LBase + LCount){ + var c = {}; + var base = (cp - LBase) * VCount; + for (j = 0; j < VCount; ++j){ + c[VBase + j] = SBase + TCount * (j + base); + } + return new UChar(cp, [,,c]); + } + + var SIndex = cp - SBase; + var TIndex = SIndex % TCount; + var feature = []; + if(TIndex !== 0){ + feature[0] = [SBase + SIndex - TIndex, TBase + TIndex]; + } else { + feature[0] = [LBase + Math.floor(SIndex / NCount), VBase + Math.floor((SIndex % NCount) / TCount)]; + feature[2] = {}; + for (j = 1; j < TCount; ++j){ + feature[2][TBase + j] = cp + j; + } + } + return new UChar(cp, feature); + } + function fromCpFilter(next, cp, needFeature){ + return cp < 60 || 13311 < cp && cp < 42607 ? new UChar(cp, DEFAULT_FEATURE) : next(cp, needFeature); + } + + var strategies = [fromCpFilter, fromCache, fromCpOnly, fromRuleBasedJamo, fromData]; + + UChar.fromCharCode = strategies.reduceRight(function (next, strategy) { + return function (cp, needFeature) { + return strategy(next, cp, needFeature); + }; + }, null); + + UChar.isHighSurrogate = function(cp){ + return cp >= 0xD800 && cp <= 0xDBFF; + }; + UChar.isLowSurrogate = function(cp){ + return cp >= 0xDC00 && cp <= 0xDFFF; + }; + + UChar.prototype.prepFeature = function(){ + if(!this.feature){ + this.feature = UChar.fromCharCode(this.codepoint, true).feature; + } + }; + + UChar.prototype.toString = function(){ + if(this.codepoint < 0x10000){ + return String.fromCharCode(this.codepoint); + } else { + var x = this.codepoint - 0x10000; + return String.fromCharCode(Math.floor(x / 0x400) + 0xD800, x % 0x400 + 0xDC00); + } + }; + + UChar.prototype.getDecomp = function(){ + this.prepFeature(); + return this.feature[0] || null; + }; + + UChar.prototype.isCompatibility = function(){ + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 8)); + }; + UChar.prototype.isExclude = function(){ + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 9)); + }; + UChar.prototype.getCanonicalClass = function(){ + this.prepFeature(); + return !!this.feature[1] ? (this.feature[1] & 0xff) : 0; + }; + UChar.prototype.getComposite = function(following){ + this.prepFeature(); + if(!this.feature[2]){ + return null; + } + var cp = this.feature[2][following.codepoint]; + return cp ? UChar.fromCharCode(cp) : null; + }; + + var UCharIterator = function(str){ + this.str = str; + this.cursor = 0; + }; + UCharIterator.prototype.next = function(){ + if(!!this.str && this.cursor < this.str.length){ + var cp = this.str.charCodeAt(this.cursor++); + var d; + if(UChar.isHighSurrogate(cp) && this.cursor < this.str.length && UChar.isLowSurrogate((d = this.str.charCodeAt(this.cursor)))){ + cp = (cp - 0xD800) * 0x400 + (d -0xDC00) + 0x10000; + ++this.cursor; + } + return UChar.fromCharCode(cp); + } else { + this.str = null; + return null; + } + }; + + var RecursDecompIterator = function(it, cano){ + this.it = it; + this.canonical = cano; + this.resBuf = []; + }; + + RecursDecompIterator.prototype.next = function(){ + function recursiveDecomp(cano, uchar){ + var decomp = uchar.getDecomp(); + if(!!decomp && !(cano && uchar.isCompatibility())){ + var ret = []; + for(var i = 0; i < decomp.length; ++i){ + var a = recursiveDecomp(cano, UChar.fromCharCode(decomp[i])); + ret = ret.concat(a); + } + return ret; + } else { + return [uchar]; + } + } + if(this.resBuf.length === 0){ + var uchar = this.it.next(); + if(!uchar){ + return null; + } + this.resBuf = recursiveDecomp(this.canonical, uchar); + } + return this.resBuf.shift(); + }; + + var DecompIterator = function(it){ + this.it = it; + this.resBuf = []; + }; + + DecompIterator.prototype.next = function(){ + var cc; + if(this.resBuf.length === 0){ + do{ + var uchar = this.it.next(); + if(!uchar){ + break; + } + cc = uchar.getCanonicalClass(); + var inspt = this.resBuf.length; + if(cc !== 0){ + for(; inspt > 0; --inspt){ + var uchar2 = this.resBuf[inspt - 1]; + var cc2 = uchar2.getCanonicalClass(); + if(cc2 <= cc){ + break; + } + } + } + this.resBuf.splice(inspt, 0, uchar); + } while(cc !== 0); + } + return this.resBuf.shift(); + }; + + var CompIterator = function(it){ + this.it = it; + this.procBuf = []; + this.resBuf = []; + this.lastClass = null; + }; + + CompIterator.prototype.next = function(){ + while(this.resBuf.length === 0){ + var uchar = this.it.next(); + if(!uchar){ + this.resBuf = this.procBuf; + this.procBuf = []; + break; + } + if(this.procBuf.length === 0){ + this.lastClass = uchar.getCanonicalClass(); + this.procBuf.push(uchar); + } else { + var starter = this.procBuf[0]; + var composite = starter.getComposite(uchar); + var cc = uchar.getCanonicalClass(); + if(!!composite && (this.lastClass < cc || this.lastClass === 0)){ + this.procBuf[0] = composite; + } else { + if(cc === 0){ + this.resBuf = this.procBuf; + this.procBuf = []; + } + this.lastClass = cc; + this.procBuf.push(uchar); + } + } + } + return this.resBuf.shift(); + }; + + var createIterator = function(mode, str){ + switch(mode){ + case "NFD": + return new DecompIterator(new RecursDecompIterator(new UCharIterator(str), true)); + case "NFKD": + return new DecompIterator(new RecursDecompIterator(new UCharIterator(str), false)); + case "NFC": + return new CompIterator(new DecompIterator(new RecursDecompIterator(new UCharIterator(str), true))); + case "NFKC": + return new CompIterator(new DecompIterator(new RecursDecompIterator(new UCharIterator(str), false))); + } + throw mode + " is invalid"; + }; + var normalize = function(mode, str){ + var it = createIterator(mode, str); + var ret = ""; + var uchar; + while(!!(uchar = it.next())){ + ret += uchar.toString(); + } + return ret; + }; + + /* API functions */ + function nfd(str){ + return normalize("NFD", str); + } + + function nfkd(str){ + return normalize("NFKD", str); + } + + function nfc(str){ + return normalize("NFC", str); + } + + function nfkc(str){ + return normalize("NFKC", str); + } + +/* Unicode data */ +UChar.udata={ +0:{60:[,,{824:8814}],61:[,,{824:8800}],62:[,,{824:8815}],65:[,,{768:192,769:193,770:194,771:195,772:256,774:258,775:550,776:196,777:7842,778:197,780:461,783:512,785:514,803:7840,805:7680,808:260}],66:[,,{775:7682,803:7684,817:7686}],67:[,,{769:262,770:264,775:266,780:268,807:199}],68:[,,{775:7690,780:270,803:7692,807:7696,813:7698,817:7694}],69:[,,{768:200,769:201,770:202,771:7868,772:274,774:276,775:278,776:203,777:7866,780:282,783:516,785:518,803:7864,807:552,808:280,813:7704,816:7706}],70:[,,{775:7710}],71:[,,{769:500,770:284,772:7712,774:286,775:288,780:486,807:290}],72:[,,{770:292,775:7714,776:7718,780:542,803:7716,807:7720,814:7722}],73:[,,{768:204,769:205,770:206,771:296,772:298,774:300,775:304,776:207,777:7880,780:463,783:520,785:522,803:7882,808:302,816:7724}],74:[,,{770:308}],75:[,,{769:7728,780:488,803:7730,807:310,817:7732}],76:[,,{769:313,780:317,803:7734,807:315,813:7740,817:7738}],77:[,,{769:7742,775:7744,803:7746}],78:[,,{768:504,769:323,771:209,775:7748,780:327,803:7750,807:325,813:7754,817:7752}],79:[,,{768:210,769:211,770:212,771:213,772:332,774:334,775:558,776:214,777:7886,779:336,780:465,783:524,785:526,795:416,803:7884,808:490}],80:[,,{769:7764,775:7766}],82:[,,{769:340,775:7768,780:344,783:528,785:530,803:7770,807:342,817:7774}],83:[,,{769:346,770:348,775:7776,780:352,803:7778,806:536,807:350}],84:[,,{775:7786,780:356,803:7788,806:538,807:354,813:7792,817:7790}],85:[,,{768:217,769:218,770:219,771:360,772:362,774:364,776:220,777:7910,778:366,779:368,780:467,783:532,785:534,795:431,803:7908,804:7794,808:370,813:7798,816:7796}],86:[,,{771:7804,803:7806}],87:[,,{768:7808,769:7810,770:372,775:7814,776:7812,803:7816}],88:[,,{775:7818,776:7820}],89:[,,{768:7922,769:221,770:374,771:7928,772:562,775:7822,776:376,777:7926,803:7924}],90:[,,{769:377,770:7824,775:379,780:381,803:7826,817:7828}],97:[,,{768:224,769:225,770:226,771:227,772:257,774:259,775:551,776:228,777:7843,778:229,780:462,783:513,785:515,803:7841,805:7681,808:261}],98:[,,{775:7683,803:7685,817:7687}],99:[,,{769:263,770:265,775:267,780:269,807:231}],100:[,,{775:7691,780:271,803:7693,807:7697,813:7699,817:7695}],101:[,,{768:232,769:233,770:234,771:7869,772:275,774:277,775:279,776:235,777:7867,780:283,783:517,785:519,803:7865,807:553,808:281,813:7705,816:7707}],102:[,,{775:7711}],103:[,,{769:501,770:285,772:7713,774:287,775:289,780:487,807:291}],104:[,,{770:293,775:7715,776:7719,780:543,803:7717,807:7721,814:7723,817:7830}],105:[,,{768:236,769:237,770:238,771:297,772:299,774:301,776:239,777:7881,780:464,783:521,785:523,803:7883,808:303,816:7725}],106:[,,{770:309,780:496}],107:[,,{769:7729,780:489,803:7731,807:311,817:7733}],108:[,,{769:314,780:318,803:7735,807:316,813:7741,817:7739}],109:[,,{769:7743,775:7745,803:7747}],110:[,,{768:505,769:324,771:241,775:7749,780:328,803:7751,807:326,813:7755,817:7753}],111:[,,{768:242,769:243,770:244,771:245,772:333,774:335,775:559,776:246,777:7887,779:337,780:466,783:525,785:527,795:417,803:7885,808:491}],112:[,,{769:7765,775:7767}],114:[,,{769:341,775:7769,780:345,783:529,785:531,803:7771,807:343,817:7775}],115:[,,{769:347,770:349,775:7777,780:353,803:7779,806:537,807:351}],116:[,,{775:7787,776:7831,780:357,803:7789,806:539,807:355,813:7793,817:7791}],117:[,,{768:249,769:250,770:251,771:361,772:363,774:365,776:252,777:7911,778:367,779:369,780:468,783:533,785:535,795:432,803:7909,804:7795,808:371,813:7799,816:7797}],118:[,,{771:7805,803:7807}],119:[,,{768:7809,769:7811,770:373,775:7815,776:7813,778:7832,803:7817}],120:[,,{775:7819,776:7821}],121:[,,{768:7923,769:253,770:375,771:7929,772:563,775:7823,776:255,777:7927,778:7833,803:7925}],122:[,,{769:378,770:7825,775:380,780:382,803:7827,817:7829}],160:[[32],256],168:[[32,776],256,{768:8173,769:901,834:8129}],170:[[97],256],175:[[32,772],256],178:[[50],256],179:[[51],256],180:[[32,769],256],181:[[956],256],184:[[32,807],256],185:[[49],256],186:[[111],256],188:[[49,8260,52],256],189:[[49,8260,50],256],190:[[51,8260,52],256],192:[[65,768]],193:[[65,769]],194:[[65,770],,{768:7846,769:7844,771:7850,777:7848}],195:[[65,771]],196:[[65,776],,{772:478}],197:[[65,778],,{769:506}],198:[,,{769:508,772:482}],199:[[67,807],,{769:7688}],200:[[69,768]],201:[[69,769]],202:[[69,770],,{768:7872,769:7870,771:7876,777:7874}],203:[[69,776]],204:[[73,768]],205:[[73,769]],206:[[73,770]],207:[[73,776],,{769:7726}],209:[[78,771]],210:[[79,768]],211:[[79,769]],212:[[79,770],,{768:7890,769:7888,771:7894,777:7892}],213:[[79,771],,{769:7756,772:556,776:7758}],214:[[79,776],,{772:554}],216:[,,{769:510}],217:[[85,768]],218:[[85,769]],219:[[85,770]],220:[[85,776],,{768:475,769:471,772:469,780:473}],221:[[89,769]],224:[[97,768]],225:[[97,769]],226:[[97,770],,{768:7847,769:7845,771:7851,777:7849}],227:[[97,771]],228:[[97,776],,{772:479}],229:[[97,778],,{769:507}],230:[,,{769:509,772:483}],231:[[99,807],,{769:7689}],232:[[101,768]],233:[[101,769]],234:[[101,770],,{768:7873,769:7871,771:7877,777:7875}],235:[[101,776]],236:[[105,768]],237:[[105,769]],238:[[105,770]],239:[[105,776],,{769:7727}],241:[[110,771]],242:[[111,768]],243:[[111,769]],244:[[111,770],,{768:7891,769:7889,771:7895,777:7893}],245:[[111,771],,{769:7757,772:557,776:7759}],246:[[111,776],,{772:555}],248:[,,{769:511}],249:[[117,768]],250:[[117,769]],251:[[117,770]],252:[[117,776],,{768:476,769:472,772:470,780:474}],253:[[121,769]],255:[[121,776]]}, +256:{256:[[65,772]],257:[[97,772]],258:[[65,774],,{768:7856,769:7854,771:7860,777:7858}],259:[[97,774],,{768:7857,769:7855,771:7861,777:7859}],260:[[65,808]],261:[[97,808]],262:[[67,769]],263:[[99,769]],264:[[67,770]],265:[[99,770]],266:[[67,775]],267:[[99,775]],268:[[67,780]],269:[[99,780]],270:[[68,780]],271:[[100,780]],274:[[69,772],,{768:7700,769:7702}],275:[[101,772],,{768:7701,769:7703}],276:[[69,774]],277:[[101,774]],278:[[69,775]],279:[[101,775]],280:[[69,808]],281:[[101,808]],282:[[69,780]],283:[[101,780]],284:[[71,770]],285:[[103,770]],286:[[71,774]],287:[[103,774]],288:[[71,775]],289:[[103,775]],290:[[71,807]],291:[[103,807]],292:[[72,770]],293:[[104,770]],296:[[73,771]],297:[[105,771]],298:[[73,772]],299:[[105,772]],300:[[73,774]],301:[[105,774]],302:[[73,808]],303:[[105,808]],304:[[73,775]],306:[[73,74],256],307:[[105,106],256],308:[[74,770]],309:[[106,770]],310:[[75,807]],311:[[107,807]],313:[[76,769]],314:[[108,769]],315:[[76,807]],316:[[108,807]],317:[[76,780]],318:[[108,780]],319:[[76,183],256],320:[[108,183],256],323:[[78,769]],324:[[110,769]],325:[[78,807]],326:[[110,807]],327:[[78,780]],328:[[110,780]],329:[[700,110],256],332:[[79,772],,{768:7760,769:7762}],333:[[111,772],,{768:7761,769:7763}],334:[[79,774]],335:[[111,774]],336:[[79,779]],337:[[111,779]],340:[[82,769]],341:[[114,769]],342:[[82,807]],343:[[114,807]],344:[[82,780]],345:[[114,780]],346:[[83,769],,{775:7780}],347:[[115,769],,{775:7781}],348:[[83,770]],349:[[115,770]],350:[[83,807]],351:[[115,807]],352:[[83,780],,{775:7782}],353:[[115,780],,{775:7783}],354:[[84,807]],355:[[116,807]],356:[[84,780]],357:[[116,780]],360:[[85,771],,{769:7800}],361:[[117,771],,{769:7801}],362:[[85,772],,{776:7802}],363:[[117,772],,{776:7803}],364:[[85,774]],365:[[117,774]],366:[[85,778]],367:[[117,778]],368:[[85,779]],369:[[117,779]],370:[[85,808]],371:[[117,808]],372:[[87,770]],373:[[119,770]],374:[[89,770]],375:[[121,770]],376:[[89,776]],377:[[90,769]],378:[[122,769]],379:[[90,775]],380:[[122,775]],381:[[90,780]],382:[[122,780]],383:[[115],256,{775:7835}],416:[[79,795],,{768:7900,769:7898,771:7904,777:7902,803:7906}],417:[[111,795],,{768:7901,769:7899,771:7905,777:7903,803:7907}],431:[[85,795],,{768:7914,769:7912,771:7918,777:7916,803:7920}],432:[[117,795],,{768:7915,769:7913,771:7919,777:7917,803:7921}],439:[,,{780:494}],452:[[68,381],256],453:[[68,382],256],454:[[100,382],256],455:[[76,74],256],456:[[76,106],256],457:[[108,106],256],458:[[78,74],256],459:[[78,106],256],460:[[110,106],256],461:[[65,780]],462:[[97,780]],463:[[73,780]],464:[[105,780]],465:[[79,780]],466:[[111,780]],467:[[85,780]],468:[[117,780]],469:[[220,772]],470:[[252,772]],471:[[220,769]],472:[[252,769]],473:[[220,780]],474:[[252,780]],475:[[220,768]],476:[[252,768]],478:[[196,772]],479:[[228,772]],480:[[550,772]],481:[[551,772]],482:[[198,772]],483:[[230,772]],486:[[71,780]],487:[[103,780]],488:[[75,780]],489:[[107,780]],490:[[79,808],,{772:492}],491:[[111,808],,{772:493}],492:[[490,772]],493:[[491,772]],494:[[439,780]],495:[[658,780]],496:[[106,780]],497:[[68,90],256],498:[[68,122],256],499:[[100,122],256],500:[[71,769]],501:[[103,769]],504:[[78,768]],505:[[110,768]],506:[[197,769]],507:[[229,769]],508:[[198,769]],509:[[230,769]],510:[[216,769]],511:[[248,769]],66045:[,220]}, +512:{512:[[65,783]],513:[[97,783]],514:[[65,785]],515:[[97,785]],516:[[69,783]],517:[[101,783]],518:[[69,785]],519:[[101,785]],520:[[73,783]],521:[[105,783]],522:[[73,785]],523:[[105,785]],524:[[79,783]],525:[[111,783]],526:[[79,785]],527:[[111,785]],528:[[82,783]],529:[[114,783]],530:[[82,785]],531:[[114,785]],532:[[85,783]],533:[[117,783]],534:[[85,785]],535:[[117,785]],536:[[83,806]],537:[[115,806]],538:[[84,806]],539:[[116,806]],542:[[72,780]],543:[[104,780]],550:[[65,775],,{772:480}],551:[[97,775],,{772:481}],552:[[69,807],,{774:7708}],553:[[101,807],,{774:7709}],554:[[214,772]],555:[[246,772]],556:[[213,772]],557:[[245,772]],558:[[79,775],,{772:560}],559:[[111,775],,{772:561}],560:[[558,772]],561:[[559,772]],562:[[89,772]],563:[[121,772]],658:[,,{780:495}],688:[[104],256],689:[[614],256],690:[[106],256],691:[[114],256],692:[[633],256],693:[[635],256],694:[[641],256],695:[[119],256],696:[[121],256],728:[[32,774],256],729:[[32,775],256],730:[[32,778],256],731:[[32,808],256],732:[[32,771],256],733:[[32,779],256],736:[[611],256],737:[[108],256],738:[[115],256],739:[[120],256],740:[[661],256],66272:[,220]}, +768:{768:[,230],769:[,230],770:[,230],771:[,230],772:[,230],773:[,230],774:[,230],775:[,230],776:[,230,{769:836}],777:[,230],778:[,230],779:[,230],780:[,230],781:[,230],782:[,230],783:[,230],784:[,230],785:[,230],786:[,230],787:[,230],788:[,230],789:[,232],790:[,220],791:[,220],792:[,220],793:[,220],794:[,232],795:[,216],796:[,220],797:[,220],798:[,220],799:[,220],800:[,220],801:[,202],802:[,202],803:[,220],804:[,220],805:[,220],806:[,220],807:[,202],808:[,202],809:[,220],810:[,220],811:[,220],812:[,220],813:[,220],814:[,220],815:[,220],816:[,220],817:[,220],818:[,220],819:[,220],820:[,1],821:[,1],822:[,1],823:[,1],824:[,1],825:[,220],826:[,220],827:[,220],828:[,220],829:[,230],830:[,230],831:[,230],832:[[768],230],833:[[769],230],834:[,230],835:[[787],230],836:[[776,769],230],837:[,240],838:[,230],839:[,220],840:[,220],841:[,220],842:[,230],843:[,230],844:[,230],845:[,220],846:[,220],848:[,230],849:[,230],850:[,230],851:[,220],852:[,220],853:[,220],854:[,220],855:[,230],856:[,232],857:[,220],858:[,220],859:[,230],860:[,233],861:[,234],862:[,234],863:[,233],864:[,234],865:[,234],866:[,233],867:[,230],868:[,230],869:[,230],870:[,230],871:[,230],872:[,230],873:[,230],874:[,230],875:[,230],876:[,230],877:[,230],878:[,230],879:[,230],884:[[697]],890:[[32,837],256],894:[[59]],900:[[32,769],256],901:[[168,769]],902:[[913,769]],903:[[183]],904:[[917,769]],905:[[919,769]],906:[[921,769]],908:[[927,769]],910:[[933,769]],911:[[937,769]],912:[[970,769]],913:[,,{768:8122,769:902,772:8121,774:8120,787:7944,788:7945,837:8124}],917:[,,{768:8136,769:904,787:7960,788:7961}],919:[,,{768:8138,769:905,787:7976,788:7977,837:8140}],921:[,,{768:8154,769:906,772:8153,774:8152,776:938,787:7992,788:7993}],927:[,,{768:8184,769:908,787:8008,788:8009}],929:[,,{788:8172}],933:[,,{768:8170,769:910,772:8169,774:8168,776:939,788:8025}],937:[,,{768:8186,769:911,787:8040,788:8041,837:8188}],938:[[921,776]],939:[[933,776]],940:[[945,769],,{837:8116}],941:[[949,769]],942:[[951,769],,{837:8132}],943:[[953,769]],944:[[971,769]],945:[,,{768:8048,769:940,772:8113,774:8112,787:7936,788:7937,834:8118,837:8115}],949:[,,{768:8050,769:941,787:7952,788:7953}],951:[,,{768:8052,769:942,787:7968,788:7969,834:8134,837:8131}],953:[,,{768:8054,769:943,772:8145,774:8144,776:970,787:7984,788:7985,834:8150}],959:[,,{768:8056,769:972,787:8000,788:8001}],961:[,,{787:8164,788:8165}],965:[,,{768:8058,769:973,772:8161,774:8160,776:971,787:8016,788:8017,834:8166}],969:[,,{768:8060,769:974,787:8032,788:8033,834:8182,837:8179}],970:[[953,776],,{768:8146,769:912,834:8151}],971:[[965,776],,{768:8162,769:944,834:8167}],972:[[959,769]],973:[[965,769]],974:[[969,769],,{837:8180}],976:[[946],256],977:[[952],256],978:[[933],256,{769:979,776:980}],979:[[978,769]],980:[[978,776]],981:[[966],256],982:[[960],256],1008:[[954],256],1009:[[961],256],1010:[[962],256],1012:[[920],256],1013:[[949],256],1017:[[931],256],66422:[,230],66423:[,230],66424:[,230],66425:[,230],66426:[,230]}, +1024:{1024:[[1045,768]],1025:[[1045,776]],1027:[[1043,769]],1030:[,,{776:1031}],1031:[[1030,776]],1036:[[1050,769]],1037:[[1048,768]],1038:[[1059,774]],1040:[,,{774:1232,776:1234}],1043:[,,{769:1027}],1045:[,,{768:1024,774:1238,776:1025}],1046:[,,{774:1217,776:1244}],1047:[,,{776:1246}],1048:[,,{768:1037,772:1250,774:1049,776:1252}],1049:[[1048,774]],1050:[,,{769:1036}],1054:[,,{776:1254}],1059:[,,{772:1262,774:1038,776:1264,779:1266}],1063:[,,{776:1268}],1067:[,,{776:1272}],1069:[,,{776:1260}],1072:[,,{774:1233,776:1235}],1075:[,,{769:1107}],1077:[,,{768:1104,774:1239,776:1105}],1078:[,,{774:1218,776:1245}],1079:[,,{776:1247}],1080:[,,{768:1117,772:1251,774:1081,776:1253}],1081:[[1080,774]],1082:[,,{769:1116}],1086:[,,{776:1255}],1091:[,,{772:1263,774:1118,776:1265,779:1267}],1095:[,,{776:1269}],1099:[,,{776:1273}],1101:[,,{776:1261}],1104:[[1077,768]],1105:[[1077,776]],1107:[[1075,769]],1110:[,,{776:1111}],1111:[[1110,776]],1116:[[1082,769]],1117:[[1080,768]],1118:[[1091,774]],1140:[,,{783:1142}],1141:[,,{783:1143}],1142:[[1140,783]],1143:[[1141,783]],1155:[,230],1156:[,230],1157:[,230],1158:[,230],1159:[,230],1217:[[1046,774]],1218:[[1078,774]],1232:[[1040,774]],1233:[[1072,774]],1234:[[1040,776]],1235:[[1072,776]],1238:[[1045,774]],1239:[[1077,774]],1240:[,,{776:1242}],1241:[,,{776:1243}],1242:[[1240,776]],1243:[[1241,776]],1244:[[1046,776]],1245:[[1078,776]],1246:[[1047,776]],1247:[[1079,776]],1250:[[1048,772]],1251:[[1080,772]],1252:[[1048,776]],1253:[[1080,776]],1254:[[1054,776]],1255:[[1086,776]],1256:[,,{776:1258}],1257:[,,{776:1259}],1258:[[1256,776]],1259:[[1257,776]],1260:[[1069,776]],1261:[[1101,776]],1262:[[1059,772]],1263:[[1091,772]],1264:[[1059,776]],1265:[[1091,776]],1266:[[1059,779]],1267:[[1091,779]],1268:[[1063,776]],1269:[[1095,776]],1272:[[1067,776]],1273:[[1099,776]]}, +1280:{1415:[[1381,1410],256],1425:[,220],1426:[,230],1427:[,230],1428:[,230],1429:[,230],1430:[,220],1431:[,230],1432:[,230],1433:[,230],1434:[,222],1435:[,220],1436:[,230],1437:[,230],1438:[,230],1439:[,230],1440:[,230],1441:[,230],1442:[,220],1443:[,220],1444:[,220],1445:[,220],1446:[,220],1447:[,220],1448:[,230],1449:[,230],1450:[,220],1451:[,230],1452:[,230],1453:[,222],1454:[,228],1455:[,230],1456:[,10],1457:[,11],1458:[,12],1459:[,13],1460:[,14],1461:[,15],1462:[,16],1463:[,17],1464:[,18],1465:[,19],1466:[,19],1467:[,20],1468:[,21],1469:[,22],1471:[,23],1473:[,24],1474:[,25],1476:[,230],1477:[,220],1479:[,18]}, +1536:{1552:[,230],1553:[,230],1554:[,230],1555:[,230],1556:[,230],1557:[,230],1558:[,230],1559:[,230],1560:[,30],1561:[,31],1562:[,32],1570:[[1575,1619]],1571:[[1575,1620]],1572:[[1608,1620]],1573:[[1575,1621]],1574:[[1610,1620]],1575:[,,{1619:1570,1620:1571,1621:1573}],1608:[,,{1620:1572}],1610:[,,{1620:1574}],1611:[,27],1612:[,28],1613:[,29],1614:[,30],1615:[,31],1616:[,32],1617:[,33],1618:[,34],1619:[,230],1620:[,230],1621:[,220],1622:[,220],1623:[,230],1624:[,230],1625:[,230],1626:[,230],1627:[,230],1628:[,220],1629:[,230],1630:[,230],1631:[,220],1648:[,35],1653:[[1575,1652],256],1654:[[1608,1652],256],1655:[[1735,1652],256],1656:[[1610,1652],256],1728:[[1749,1620]],1729:[,,{1620:1730}],1730:[[1729,1620]],1746:[,,{1620:1747}],1747:[[1746,1620]],1749:[,,{1620:1728}],1750:[,230],1751:[,230],1752:[,230],1753:[,230],1754:[,230],1755:[,230],1756:[,230],1759:[,230],1760:[,230],1761:[,230],1762:[,230],1763:[,220],1764:[,230],1767:[,230],1768:[,230],1770:[,220],1771:[,230],1772:[,230],1773:[,220]}, +1792:{1809:[,36],1840:[,230],1841:[,220],1842:[,230],1843:[,230],1844:[,220],1845:[,230],1846:[,230],1847:[,220],1848:[,220],1849:[,220],1850:[,230],1851:[,220],1852:[,220],1853:[,230],1854:[,220],1855:[,230],1856:[,230],1857:[,230],1858:[,220],1859:[,230],1860:[,220],1861:[,230],1862:[,220],1863:[,230],1864:[,220],1865:[,230],1866:[,230],2027:[,230],2028:[,230],2029:[,230],2030:[,230],2031:[,230],2032:[,230],2033:[,230],2034:[,220],2035:[,230]}, +2048:{2070:[,230],2071:[,230],2072:[,230],2073:[,230],2075:[,230],2076:[,230],2077:[,230],2078:[,230],2079:[,230],2080:[,230],2081:[,230],2082:[,230],2083:[,230],2085:[,230],2086:[,230],2087:[,230],2089:[,230],2090:[,230],2091:[,230],2092:[,230],2093:[,230],2137:[,220],2138:[,220],2139:[,220],2276:[,230],2277:[,230],2278:[,220],2279:[,230],2280:[,230],2281:[,220],2282:[,230],2283:[,230],2284:[,230],2285:[,220],2286:[,220],2287:[,220],2288:[,27],2289:[,28],2290:[,29],2291:[,230],2292:[,230],2293:[,230],2294:[,220],2295:[,230],2296:[,230],2297:[,220],2298:[,220],2299:[,230],2300:[,230],2301:[,230],2302:[,230],2303:[,230]}, +2304:{2344:[,,{2364:2345}],2345:[[2344,2364]],2352:[,,{2364:2353}],2353:[[2352,2364]],2355:[,,{2364:2356}],2356:[[2355,2364]],2364:[,7],2381:[,9],2385:[,230],2386:[,220],2387:[,230],2388:[,230],2392:[[2325,2364],512],2393:[[2326,2364],512],2394:[[2327,2364],512],2395:[[2332,2364],512],2396:[[2337,2364],512],2397:[[2338,2364],512],2398:[[2347,2364],512],2399:[[2351,2364],512],2492:[,7],2503:[,,{2494:2507,2519:2508}],2507:[[2503,2494]],2508:[[2503,2519]],2509:[,9],2524:[[2465,2492],512],2525:[[2466,2492],512],2527:[[2479,2492],512]}, +2560:{2611:[[2610,2620],512],2614:[[2616,2620],512],2620:[,7],2637:[,9],2649:[[2582,2620],512],2650:[[2583,2620],512],2651:[[2588,2620],512],2654:[[2603,2620],512],2748:[,7],2765:[,9],68109:[,220],68111:[,230],68152:[,230],68153:[,1],68154:[,220],68159:[,9],68325:[,230],68326:[,220]}, +2816:{2876:[,7],2887:[,,{2878:2891,2902:2888,2903:2892}],2888:[[2887,2902]],2891:[[2887,2878]],2892:[[2887,2903]],2893:[,9],2908:[[2849,2876],512],2909:[[2850,2876],512],2962:[,,{3031:2964}],2964:[[2962,3031]],3014:[,,{3006:3018,3031:3020}],3015:[,,{3006:3019}],3018:[[3014,3006]],3019:[[3015,3006]],3020:[[3014,3031]],3021:[,9]}, +3072:{3142:[,,{3158:3144}],3144:[[3142,3158]],3149:[,9],3157:[,84],3158:[,91],3260:[,7],3263:[,,{3285:3264}],3264:[[3263,3285]],3270:[,,{3266:3274,3285:3271,3286:3272}],3271:[[3270,3285]],3272:[[3270,3286]],3274:[[3270,3266],,{3285:3275}],3275:[[3274,3285]],3277:[,9]}, +3328:{3398:[,,{3390:3402,3415:3404}],3399:[,,{3390:3403}],3402:[[3398,3390]],3403:[[3399,3390]],3404:[[3398,3415]],3405:[,9],3530:[,9],3545:[,,{3530:3546,3535:3548,3551:3550}],3546:[[3545,3530]],3548:[[3545,3535],,{3530:3549}],3549:[[3548,3530]],3550:[[3545,3551]]}, +3584:{3635:[[3661,3634],256],3640:[,103],3641:[,103],3642:[,9],3656:[,107],3657:[,107],3658:[,107],3659:[,107],3763:[[3789,3762],256],3768:[,118],3769:[,118],3784:[,122],3785:[,122],3786:[,122],3787:[,122],3804:[[3755,3737],256],3805:[[3755,3745],256]}, +3840:{3852:[[3851],256],3864:[,220],3865:[,220],3893:[,220],3895:[,220],3897:[,216],3907:[[3906,4023],512],3917:[[3916,4023],512],3922:[[3921,4023],512],3927:[[3926,4023],512],3932:[[3931,4023],512],3945:[[3904,4021],512],3953:[,129],3954:[,130],3955:[[3953,3954],512],3956:[,132],3957:[[3953,3956],512],3958:[[4018,3968],512],3959:[[4018,3969],256],3960:[[4019,3968],512],3961:[[4019,3969],256],3962:[,130],3963:[,130],3964:[,130],3965:[,130],3968:[,130],3969:[[3953,3968],512],3970:[,230],3971:[,230],3972:[,9],3974:[,230],3975:[,230],3987:[[3986,4023],512],3997:[[3996,4023],512],4002:[[4001,4023],512],4007:[[4006,4023],512],4012:[[4011,4023],512],4025:[[3984,4021],512],4038:[,220]}, +4096:{4133:[,,{4142:4134}],4134:[[4133,4142]],4151:[,7],4153:[,9],4154:[,9],4237:[,220],4348:[[4316],256],69702:[,9],69759:[,9],69785:[,,{69818:69786}],69786:[[69785,69818]],69787:[,,{69818:69788}],69788:[[69787,69818]],69797:[,,{69818:69803}],69803:[[69797,69818]],69817:[,9],69818:[,7]}, +4352:{69888:[,230],69889:[,230],69890:[,230],69934:[[69937,69927]],69935:[[69938,69927]],69937:[,,{69927:69934}],69938:[,,{69927:69935}],69939:[,9],69940:[,9],70003:[,7],70080:[,9]}, +4608:{70197:[,9],70198:[,7],70377:[,7],70378:[,9]}, +4864:{4957:[,230],4958:[,230],4959:[,230],70460:[,7],70471:[,,{70462:70475,70487:70476}],70475:[[70471,70462]],70476:[[70471,70487]],70477:[,9],70502:[,230],70503:[,230],70504:[,230],70505:[,230],70506:[,230],70507:[,230],70508:[,230],70512:[,230],70513:[,230],70514:[,230],70515:[,230],70516:[,230]}, +5120:{70841:[,,{70832:70844,70842:70843,70845:70846}],70843:[[70841,70842]],70844:[[70841,70832]],70846:[[70841,70845]],70850:[,9],70851:[,7]}, +5376:{71096:[,,{71087:71098}],71097:[,,{71087:71099}],71098:[[71096,71087]],71099:[[71097,71087]],71103:[,9],71104:[,7]}, +5632:{71231:[,9],71350:[,9],71351:[,7]}, +5888:{5908:[,9],5940:[,9],6098:[,9],6109:[,230]}, +6144:{6313:[,228]}, +6400:{6457:[,222],6458:[,230],6459:[,220]}, +6656:{6679:[,230],6680:[,220],6752:[,9],6773:[,230],6774:[,230],6775:[,230],6776:[,230],6777:[,230],6778:[,230],6779:[,230],6780:[,230],6783:[,220],6832:[,230],6833:[,230],6834:[,230],6835:[,230],6836:[,230],6837:[,220],6838:[,220],6839:[,220],6840:[,220],6841:[,220],6842:[,220],6843:[,230],6844:[,230],6845:[,220]}, +6912:{6917:[,,{6965:6918}],6918:[[6917,6965]],6919:[,,{6965:6920}],6920:[[6919,6965]],6921:[,,{6965:6922}],6922:[[6921,6965]],6923:[,,{6965:6924}],6924:[[6923,6965]],6925:[,,{6965:6926}],6926:[[6925,6965]],6929:[,,{6965:6930}],6930:[[6929,6965]],6964:[,7],6970:[,,{6965:6971}],6971:[[6970,6965]],6972:[,,{6965:6973}],6973:[[6972,6965]],6974:[,,{6965:6976}],6975:[,,{6965:6977}],6976:[[6974,6965]],6977:[[6975,6965]],6978:[,,{6965:6979}],6979:[[6978,6965]],6980:[,9],7019:[,230],7020:[,220],7021:[,230],7022:[,230],7023:[,230],7024:[,230],7025:[,230],7026:[,230],7027:[,230],7082:[,9],7083:[,9],7142:[,7],7154:[,9],7155:[,9]}, +7168:{7223:[,7],7376:[,230],7377:[,230],7378:[,230],7380:[,1],7381:[,220],7382:[,220],7383:[,220],7384:[,220],7385:[,220],7386:[,230],7387:[,230],7388:[,220],7389:[,220],7390:[,220],7391:[,220],7392:[,230],7394:[,1],7395:[,1],7396:[,1],7397:[,1],7398:[,1],7399:[,1],7400:[,1],7405:[,220],7412:[,230],7416:[,230],7417:[,230]}, +7424:{7468:[[65],256],7469:[[198],256],7470:[[66],256],7472:[[68],256],7473:[[69],256],7474:[[398],256],7475:[[71],256],7476:[[72],256],7477:[[73],256],7478:[[74],256],7479:[[75],256],7480:[[76],256],7481:[[77],256],7482:[[78],256],7484:[[79],256],7485:[[546],256],7486:[[80],256],7487:[[82],256],7488:[[84],256],7489:[[85],256],7490:[[87],256],7491:[[97],256],7492:[[592],256],7493:[[593],256],7494:[[7426],256],7495:[[98],256],7496:[[100],256],7497:[[101],256],7498:[[601],256],7499:[[603],256],7500:[[604],256],7501:[[103],256],7503:[[107],256],7504:[[109],256],7505:[[331],256],7506:[[111],256],7507:[[596],256],7508:[[7446],256],7509:[[7447],256],7510:[[112],256],7511:[[116],256],7512:[[117],256],7513:[[7453],256],7514:[[623],256],7515:[[118],256],7516:[[7461],256],7517:[[946],256],7518:[[947],256],7519:[[948],256],7520:[[966],256],7521:[[967],256],7522:[[105],256],7523:[[114],256],7524:[[117],256],7525:[[118],256],7526:[[946],256],7527:[[947],256],7528:[[961],256],7529:[[966],256],7530:[[967],256],7544:[[1085],256],7579:[[594],256],7580:[[99],256],7581:[[597],256],7582:[[240],256],7583:[[604],256],7584:[[102],256],7585:[[607],256],7586:[[609],256],7587:[[613],256],7588:[[616],256],7589:[[617],256],7590:[[618],256],7591:[[7547],256],7592:[[669],256],7593:[[621],256],7594:[[7557],256],7595:[[671],256],7596:[[625],256],7597:[[624],256],7598:[[626],256],7599:[[627],256],7600:[[628],256],7601:[[629],256],7602:[[632],256],7603:[[642],256],7604:[[643],256],7605:[[427],256],7606:[[649],256],7607:[[650],256],7608:[[7452],256],7609:[[651],256],7610:[[652],256],7611:[[122],256],7612:[[656],256],7613:[[657],256],7614:[[658],256],7615:[[952],256],7616:[,230],7617:[,230],7618:[,220],7619:[,230],7620:[,230],7621:[,230],7622:[,230],7623:[,230],7624:[,230],7625:[,230],7626:[,220],7627:[,230],7628:[,230],7629:[,234],7630:[,214],7631:[,220],7632:[,202],7633:[,230],7634:[,230],7635:[,230],7636:[,230],7637:[,230],7638:[,230],7639:[,230],7640:[,230],7641:[,230],7642:[,230],7643:[,230],7644:[,230],7645:[,230],7646:[,230],7647:[,230],7648:[,230],7649:[,230],7650:[,230],7651:[,230],7652:[,230],7653:[,230],7654:[,230],7655:[,230],7656:[,230],7657:[,230],7658:[,230],7659:[,230],7660:[,230],7661:[,230],7662:[,230],7663:[,230],7664:[,230],7665:[,230],7666:[,230],7667:[,230],7668:[,230],7669:[,230],7676:[,233],7677:[,220],7678:[,230],7679:[,220]}, +7680:{7680:[[65,805]],7681:[[97,805]],7682:[[66,775]],7683:[[98,775]],7684:[[66,803]],7685:[[98,803]],7686:[[66,817]],7687:[[98,817]],7688:[[199,769]],7689:[[231,769]],7690:[[68,775]],7691:[[100,775]],7692:[[68,803]],7693:[[100,803]],7694:[[68,817]],7695:[[100,817]],7696:[[68,807]],7697:[[100,807]],7698:[[68,813]],7699:[[100,813]],7700:[[274,768]],7701:[[275,768]],7702:[[274,769]],7703:[[275,769]],7704:[[69,813]],7705:[[101,813]],7706:[[69,816]],7707:[[101,816]],7708:[[552,774]],7709:[[553,774]],7710:[[70,775]],7711:[[102,775]],7712:[[71,772]],7713:[[103,772]],7714:[[72,775]],7715:[[104,775]],7716:[[72,803]],7717:[[104,803]],7718:[[72,776]],7719:[[104,776]],7720:[[72,807]],7721:[[104,807]],7722:[[72,814]],7723:[[104,814]],7724:[[73,816]],7725:[[105,816]],7726:[[207,769]],7727:[[239,769]],7728:[[75,769]],7729:[[107,769]],7730:[[75,803]],7731:[[107,803]],7732:[[75,817]],7733:[[107,817]],7734:[[76,803],,{772:7736}],7735:[[108,803],,{772:7737}],7736:[[7734,772]],7737:[[7735,772]],7738:[[76,817]],7739:[[108,817]],7740:[[76,813]],7741:[[108,813]],7742:[[77,769]],7743:[[109,769]],7744:[[77,775]],7745:[[109,775]],7746:[[77,803]],7747:[[109,803]],7748:[[78,775]],7749:[[110,775]],7750:[[78,803]],7751:[[110,803]],7752:[[78,817]],7753:[[110,817]],7754:[[78,813]],7755:[[110,813]],7756:[[213,769]],7757:[[245,769]],7758:[[213,776]],7759:[[245,776]],7760:[[332,768]],7761:[[333,768]],7762:[[332,769]],7763:[[333,769]],7764:[[80,769]],7765:[[112,769]],7766:[[80,775]],7767:[[112,775]],7768:[[82,775]],7769:[[114,775]],7770:[[82,803],,{772:7772}],7771:[[114,803],,{772:7773}],7772:[[7770,772]],7773:[[7771,772]],7774:[[82,817]],7775:[[114,817]],7776:[[83,775]],7777:[[115,775]],7778:[[83,803],,{775:7784}],7779:[[115,803],,{775:7785}],7780:[[346,775]],7781:[[347,775]],7782:[[352,775]],7783:[[353,775]],7784:[[7778,775]],7785:[[7779,775]],7786:[[84,775]],7787:[[116,775]],7788:[[84,803]],7789:[[116,803]],7790:[[84,817]],7791:[[116,817]],7792:[[84,813]],7793:[[116,813]],7794:[[85,804]],7795:[[117,804]],7796:[[85,816]],7797:[[117,816]],7798:[[85,813]],7799:[[117,813]],7800:[[360,769]],7801:[[361,769]],7802:[[362,776]],7803:[[363,776]],7804:[[86,771]],7805:[[118,771]],7806:[[86,803]],7807:[[118,803]],7808:[[87,768]],7809:[[119,768]],7810:[[87,769]],7811:[[119,769]],7812:[[87,776]],7813:[[119,776]],7814:[[87,775]],7815:[[119,775]],7816:[[87,803]],7817:[[119,803]],7818:[[88,775]],7819:[[120,775]],7820:[[88,776]],7821:[[120,776]],7822:[[89,775]],7823:[[121,775]],7824:[[90,770]],7825:[[122,770]],7826:[[90,803]],7827:[[122,803]],7828:[[90,817]],7829:[[122,817]],7830:[[104,817]],7831:[[116,776]],7832:[[119,778]],7833:[[121,778]],7834:[[97,702],256],7835:[[383,775]],7840:[[65,803],,{770:7852,774:7862}],7841:[[97,803],,{770:7853,774:7863}],7842:[[65,777]],7843:[[97,777]],7844:[[194,769]],7845:[[226,769]],7846:[[194,768]],7847:[[226,768]],7848:[[194,777]],7849:[[226,777]],7850:[[194,771]],7851:[[226,771]],7852:[[7840,770]],7853:[[7841,770]],7854:[[258,769]],7855:[[259,769]],7856:[[258,768]],7857:[[259,768]],7858:[[258,777]],7859:[[259,777]],7860:[[258,771]],7861:[[259,771]],7862:[[7840,774]],7863:[[7841,774]],7864:[[69,803],,{770:7878}],7865:[[101,803],,{770:7879}],7866:[[69,777]],7867:[[101,777]],7868:[[69,771]],7869:[[101,771]],7870:[[202,769]],7871:[[234,769]],7872:[[202,768]],7873:[[234,768]],7874:[[202,777]],7875:[[234,777]],7876:[[202,771]],7877:[[234,771]],7878:[[7864,770]],7879:[[7865,770]],7880:[[73,777]],7881:[[105,777]],7882:[[73,803]],7883:[[105,803]],7884:[[79,803],,{770:7896}],7885:[[111,803],,{770:7897}],7886:[[79,777]],7887:[[111,777]],7888:[[212,769]],7889:[[244,769]],7890:[[212,768]],7891:[[244,768]],7892:[[212,777]],7893:[[244,777]],7894:[[212,771]],7895:[[244,771]],7896:[[7884,770]],7897:[[7885,770]],7898:[[416,769]],7899:[[417,769]],7900:[[416,768]],7901:[[417,768]],7902:[[416,777]],7903:[[417,777]],7904:[[416,771]],7905:[[417,771]],7906:[[416,803]],7907:[[417,803]],7908:[[85,803]],7909:[[117,803]],7910:[[85,777]],7911:[[117,777]],7912:[[431,769]],7913:[[432,769]],7914:[[431,768]],7915:[[432,768]],7916:[[431,777]],7917:[[432,777]],7918:[[431,771]],7919:[[432,771]],7920:[[431,803]],7921:[[432,803]],7922:[[89,768]],7923:[[121,768]],7924:[[89,803]],7925:[[121,803]],7926:[[89,777]],7927:[[121,777]],7928:[[89,771]],7929:[[121,771]]}, +7936:{7936:[[945,787],,{768:7938,769:7940,834:7942,837:8064}],7937:[[945,788],,{768:7939,769:7941,834:7943,837:8065}],7938:[[7936,768],,{837:8066}],7939:[[7937,768],,{837:8067}],7940:[[7936,769],,{837:8068}],7941:[[7937,769],,{837:8069}],7942:[[7936,834],,{837:8070}],7943:[[7937,834],,{837:8071}],7944:[[913,787],,{768:7946,769:7948,834:7950,837:8072}],7945:[[913,788],,{768:7947,769:7949,834:7951,837:8073}],7946:[[7944,768],,{837:8074}],7947:[[7945,768],,{837:8075}],7948:[[7944,769],,{837:8076}],7949:[[7945,769],,{837:8077}],7950:[[7944,834],,{837:8078}],7951:[[7945,834],,{837:8079}],7952:[[949,787],,{768:7954,769:7956}],7953:[[949,788],,{768:7955,769:7957}],7954:[[7952,768]],7955:[[7953,768]],7956:[[7952,769]],7957:[[7953,769]],7960:[[917,787],,{768:7962,769:7964}],7961:[[917,788],,{768:7963,769:7965}],7962:[[7960,768]],7963:[[7961,768]],7964:[[7960,769]],7965:[[7961,769]],7968:[[951,787],,{768:7970,769:7972,834:7974,837:8080}],7969:[[951,788],,{768:7971,769:7973,834:7975,837:8081}],7970:[[7968,768],,{837:8082}],7971:[[7969,768],,{837:8083}],7972:[[7968,769],,{837:8084}],7973:[[7969,769],,{837:8085}],7974:[[7968,834],,{837:8086}],7975:[[7969,834],,{837:8087}],7976:[[919,787],,{768:7978,769:7980,834:7982,837:8088}],7977:[[919,788],,{768:7979,769:7981,834:7983,837:8089}],7978:[[7976,768],,{837:8090}],7979:[[7977,768],,{837:8091}],7980:[[7976,769],,{837:8092}],7981:[[7977,769],,{837:8093}],7982:[[7976,834],,{837:8094}],7983:[[7977,834],,{837:8095}],7984:[[953,787],,{768:7986,769:7988,834:7990}],7985:[[953,788],,{768:7987,769:7989,834:7991}],7986:[[7984,768]],7987:[[7985,768]],7988:[[7984,769]],7989:[[7985,769]],7990:[[7984,834]],7991:[[7985,834]],7992:[[921,787],,{768:7994,769:7996,834:7998}],7993:[[921,788],,{768:7995,769:7997,834:7999}],7994:[[7992,768]],7995:[[7993,768]],7996:[[7992,769]],7997:[[7993,769]],7998:[[7992,834]],7999:[[7993,834]],8000:[[959,787],,{768:8002,769:8004}],8001:[[959,788],,{768:8003,769:8005}],8002:[[8000,768]],8003:[[8001,768]],8004:[[8000,769]],8005:[[8001,769]],8008:[[927,787],,{768:8010,769:8012}],8009:[[927,788],,{768:8011,769:8013}],8010:[[8008,768]],8011:[[8009,768]],8012:[[8008,769]],8013:[[8009,769]],8016:[[965,787],,{768:8018,769:8020,834:8022}],8017:[[965,788],,{768:8019,769:8021,834:8023}],8018:[[8016,768]],8019:[[8017,768]],8020:[[8016,769]],8021:[[8017,769]],8022:[[8016,834]],8023:[[8017,834]],8025:[[933,788],,{768:8027,769:8029,834:8031}],8027:[[8025,768]],8029:[[8025,769]],8031:[[8025,834]],8032:[[969,787],,{768:8034,769:8036,834:8038,837:8096}],8033:[[969,788],,{768:8035,769:8037,834:8039,837:8097}],8034:[[8032,768],,{837:8098}],8035:[[8033,768],,{837:8099}],8036:[[8032,769],,{837:8100}],8037:[[8033,769],,{837:8101}],8038:[[8032,834],,{837:8102}],8039:[[8033,834],,{837:8103}],8040:[[937,787],,{768:8042,769:8044,834:8046,837:8104}],8041:[[937,788],,{768:8043,769:8045,834:8047,837:8105}],8042:[[8040,768],,{837:8106}],8043:[[8041,768],,{837:8107}],8044:[[8040,769],,{837:8108}],8045:[[8041,769],,{837:8109}],8046:[[8040,834],,{837:8110}],8047:[[8041,834],,{837:8111}],8048:[[945,768],,{837:8114}],8049:[[940]],8050:[[949,768]],8051:[[941]],8052:[[951,768],,{837:8130}],8053:[[942]],8054:[[953,768]],8055:[[943]],8056:[[959,768]],8057:[[972]],8058:[[965,768]],8059:[[973]],8060:[[969,768],,{837:8178}],8061:[[974]],8064:[[7936,837]],8065:[[7937,837]],8066:[[7938,837]],8067:[[7939,837]],8068:[[7940,837]],8069:[[7941,837]],8070:[[7942,837]],8071:[[7943,837]],8072:[[7944,837]],8073:[[7945,837]],8074:[[7946,837]],8075:[[7947,837]],8076:[[7948,837]],8077:[[7949,837]],8078:[[7950,837]],8079:[[7951,837]],8080:[[7968,837]],8081:[[7969,837]],8082:[[7970,837]],8083:[[7971,837]],8084:[[7972,837]],8085:[[7973,837]],8086:[[7974,837]],8087:[[7975,837]],8088:[[7976,837]],8089:[[7977,837]],8090:[[7978,837]],8091:[[7979,837]],8092:[[7980,837]],8093:[[7981,837]],8094:[[7982,837]],8095:[[7983,837]],8096:[[8032,837]],8097:[[8033,837]],8098:[[8034,837]],8099:[[8035,837]],8100:[[8036,837]],8101:[[8037,837]],8102:[[8038,837]],8103:[[8039,837]],8104:[[8040,837]],8105:[[8041,837]],8106:[[8042,837]],8107:[[8043,837]],8108:[[8044,837]],8109:[[8045,837]],8110:[[8046,837]],8111:[[8047,837]],8112:[[945,774]],8113:[[945,772]],8114:[[8048,837]],8115:[[945,837]],8116:[[940,837]],8118:[[945,834],,{837:8119}],8119:[[8118,837]],8120:[[913,774]],8121:[[913,772]],8122:[[913,768]],8123:[[902]],8124:[[913,837]],8125:[[32,787],256],8126:[[953]],8127:[[32,787],256,{768:8141,769:8142,834:8143}],8128:[[32,834],256],8129:[[168,834]],8130:[[8052,837]],8131:[[951,837]],8132:[[942,837]],8134:[[951,834],,{837:8135}],8135:[[8134,837]],8136:[[917,768]],8137:[[904]],8138:[[919,768]],8139:[[905]],8140:[[919,837]],8141:[[8127,768]],8142:[[8127,769]],8143:[[8127,834]],8144:[[953,774]],8145:[[953,772]],8146:[[970,768]],8147:[[912]],8150:[[953,834]],8151:[[970,834]],8152:[[921,774]],8153:[[921,772]],8154:[[921,768]],8155:[[906]],8157:[[8190,768]],8158:[[8190,769]],8159:[[8190,834]],8160:[[965,774]],8161:[[965,772]],8162:[[971,768]],8163:[[944]],8164:[[961,787]],8165:[[961,788]],8166:[[965,834]],8167:[[971,834]],8168:[[933,774]],8169:[[933,772]],8170:[[933,768]],8171:[[910]],8172:[[929,788]],8173:[[168,768]],8174:[[901]],8175:[[96]],8178:[[8060,837]],8179:[[969,837]],8180:[[974,837]],8182:[[969,834],,{837:8183}],8183:[[8182,837]],8184:[[927,768]],8185:[[908]],8186:[[937,768]],8187:[[911]],8188:[[937,837]],8189:[[180]],8190:[[32,788],256,{768:8157,769:8158,834:8159}]}, +8192:{8192:[[8194]],8193:[[8195]],8194:[[32],256],8195:[[32],256],8196:[[32],256],8197:[[32],256],8198:[[32],256],8199:[[32],256],8200:[[32],256],8201:[[32],256],8202:[[32],256],8209:[[8208],256],8215:[[32,819],256],8228:[[46],256],8229:[[46,46],256],8230:[[46,46,46],256],8239:[[32],256],8243:[[8242,8242],256],8244:[[8242,8242,8242],256],8246:[[8245,8245],256],8247:[[8245,8245,8245],256],8252:[[33,33],256],8254:[[32,773],256],8263:[[63,63],256],8264:[[63,33],256],8265:[[33,63],256],8279:[[8242,8242,8242,8242],256],8287:[[32],256],8304:[[48],256],8305:[[105],256],8308:[[52],256],8309:[[53],256],8310:[[54],256],8311:[[55],256],8312:[[56],256],8313:[[57],256],8314:[[43],256],8315:[[8722],256],8316:[[61],256],8317:[[40],256],8318:[[41],256],8319:[[110],256],8320:[[48],256],8321:[[49],256],8322:[[50],256],8323:[[51],256],8324:[[52],256],8325:[[53],256],8326:[[54],256],8327:[[55],256],8328:[[56],256],8329:[[57],256],8330:[[43],256],8331:[[8722],256],8332:[[61],256],8333:[[40],256],8334:[[41],256],8336:[[97],256],8337:[[101],256],8338:[[111],256],8339:[[120],256],8340:[[601],256],8341:[[104],256],8342:[[107],256],8343:[[108],256],8344:[[109],256],8345:[[110],256],8346:[[112],256],8347:[[115],256],8348:[[116],256],8360:[[82,115],256],8400:[,230],8401:[,230],8402:[,1],8403:[,1],8404:[,230],8405:[,230],8406:[,230],8407:[,230],8408:[,1],8409:[,1],8410:[,1],8411:[,230],8412:[,230],8417:[,230],8421:[,1],8422:[,1],8423:[,230],8424:[,220],8425:[,230],8426:[,1],8427:[,1],8428:[,220],8429:[,220],8430:[,220],8431:[,220],8432:[,230]}, +8448:{8448:[[97,47,99],256],8449:[[97,47,115],256],8450:[[67],256],8451:[[176,67],256],8453:[[99,47,111],256],8454:[[99,47,117],256],8455:[[400],256],8457:[[176,70],256],8458:[[103],256],8459:[[72],256],8460:[[72],256],8461:[[72],256],8462:[[104],256],8463:[[295],256],8464:[[73],256],8465:[[73],256],8466:[[76],256],8467:[[108],256],8469:[[78],256],8470:[[78,111],256],8473:[[80],256],8474:[[81],256],8475:[[82],256],8476:[[82],256],8477:[[82],256],8480:[[83,77],256],8481:[[84,69,76],256],8482:[[84,77],256],8484:[[90],256],8486:[[937]],8488:[[90],256],8490:[[75]],8491:[[197]],8492:[[66],256],8493:[[67],256],8495:[[101],256],8496:[[69],256],8497:[[70],256],8499:[[77],256],8500:[[111],256],8501:[[1488],256],8502:[[1489],256],8503:[[1490],256],8504:[[1491],256],8505:[[105],256],8507:[[70,65,88],256],8508:[[960],256],8509:[[947],256],8510:[[915],256],8511:[[928],256],8512:[[8721],256],8517:[[68],256],8518:[[100],256],8519:[[101],256],8520:[[105],256],8521:[[106],256],8528:[[49,8260,55],256],8529:[[49,8260,57],256],8530:[[49,8260,49,48],256],8531:[[49,8260,51],256],8532:[[50,8260,51],256],8533:[[49,8260,53],256],8534:[[50,8260,53],256],8535:[[51,8260,53],256],8536:[[52,8260,53],256],8537:[[49,8260,54],256],8538:[[53,8260,54],256],8539:[[49,8260,56],256],8540:[[51,8260,56],256],8541:[[53,8260,56],256],8542:[[55,8260,56],256],8543:[[49,8260],256],8544:[[73],256],8545:[[73,73],256],8546:[[73,73,73],256],8547:[[73,86],256],8548:[[86],256],8549:[[86,73],256],8550:[[86,73,73],256],8551:[[86,73,73,73],256],8552:[[73,88],256],8553:[[88],256],8554:[[88,73],256],8555:[[88,73,73],256],8556:[[76],256],8557:[[67],256],8558:[[68],256],8559:[[77],256],8560:[[105],256],8561:[[105,105],256],8562:[[105,105,105],256],8563:[[105,118],256],8564:[[118],256],8565:[[118,105],256],8566:[[118,105,105],256],8567:[[118,105,105,105],256],8568:[[105,120],256],8569:[[120],256],8570:[[120,105],256],8571:[[120,105,105],256],8572:[[108],256],8573:[[99],256],8574:[[100],256],8575:[[109],256],8585:[[48,8260,51],256],8592:[,,{824:8602}],8594:[,,{824:8603}],8596:[,,{824:8622}],8602:[[8592,824]],8603:[[8594,824]],8622:[[8596,824]],8653:[[8656,824]],8654:[[8660,824]],8655:[[8658,824]],8656:[,,{824:8653}],8658:[,,{824:8655}],8660:[,,{824:8654}]}, +8704:{8707:[,,{824:8708}],8708:[[8707,824]],8712:[,,{824:8713}],8713:[[8712,824]],8715:[,,{824:8716}],8716:[[8715,824]],8739:[,,{824:8740}],8740:[[8739,824]],8741:[,,{824:8742}],8742:[[8741,824]],8748:[[8747,8747],256],8749:[[8747,8747,8747],256],8751:[[8750,8750],256],8752:[[8750,8750,8750],256],8764:[,,{824:8769}],8769:[[8764,824]],8771:[,,{824:8772}],8772:[[8771,824]],8773:[,,{824:8775}],8775:[[8773,824]],8776:[,,{824:8777}],8777:[[8776,824]],8781:[,,{824:8813}],8800:[[61,824]],8801:[,,{824:8802}],8802:[[8801,824]],8804:[,,{824:8816}],8805:[,,{824:8817}],8813:[[8781,824]],8814:[[60,824]],8815:[[62,824]],8816:[[8804,824]],8817:[[8805,824]],8818:[,,{824:8820}],8819:[,,{824:8821}],8820:[[8818,824]],8821:[[8819,824]],8822:[,,{824:8824}],8823:[,,{824:8825}],8824:[[8822,824]],8825:[[8823,824]],8826:[,,{824:8832}],8827:[,,{824:8833}],8828:[,,{824:8928}],8829:[,,{824:8929}],8832:[[8826,824]],8833:[[8827,824]],8834:[,,{824:8836}],8835:[,,{824:8837}],8836:[[8834,824]],8837:[[8835,824]],8838:[,,{824:8840}],8839:[,,{824:8841}],8840:[[8838,824]],8841:[[8839,824]],8849:[,,{824:8930}],8850:[,,{824:8931}],8866:[,,{824:8876}],8872:[,,{824:8877}],8873:[,,{824:8878}],8875:[,,{824:8879}],8876:[[8866,824]],8877:[[8872,824]],8878:[[8873,824]],8879:[[8875,824]],8882:[,,{824:8938}],8883:[,,{824:8939}],8884:[,,{824:8940}],8885:[,,{824:8941}],8928:[[8828,824]],8929:[[8829,824]],8930:[[8849,824]],8931:[[8850,824]],8938:[[8882,824]],8939:[[8883,824]],8940:[[8884,824]],8941:[[8885,824]]}, +8960:{9001:[[12296]],9002:[[12297]]}, +9216:{9312:[[49],256],9313:[[50],256],9314:[[51],256],9315:[[52],256],9316:[[53],256],9317:[[54],256],9318:[[55],256],9319:[[56],256],9320:[[57],256],9321:[[49,48],256],9322:[[49,49],256],9323:[[49,50],256],9324:[[49,51],256],9325:[[49,52],256],9326:[[49,53],256],9327:[[49,54],256],9328:[[49,55],256],9329:[[49,56],256],9330:[[49,57],256],9331:[[50,48],256],9332:[[40,49,41],256],9333:[[40,50,41],256],9334:[[40,51,41],256],9335:[[40,52,41],256],9336:[[40,53,41],256],9337:[[40,54,41],256],9338:[[40,55,41],256],9339:[[40,56,41],256],9340:[[40,57,41],256],9341:[[40,49,48,41],256],9342:[[40,49,49,41],256],9343:[[40,49,50,41],256],9344:[[40,49,51,41],256],9345:[[40,49,52,41],256],9346:[[40,49,53,41],256],9347:[[40,49,54,41],256],9348:[[40,49,55,41],256],9349:[[40,49,56,41],256],9350:[[40,49,57,41],256],9351:[[40,50,48,41],256],9352:[[49,46],256],9353:[[50,46],256],9354:[[51,46],256],9355:[[52,46],256],9356:[[53,46],256],9357:[[54,46],256],9358:[[55,46],256],9359:[[56,46],256],9360:[[57,46],256],9361:[[49,48,46],256],9362:[[49,49,46],256],9363:[[49,50,46],256],9364:[[49,51,46],256],9365:[[49,52,46],256],9366:[[49,53,46],256],9367:[[49,54,46],256],9368:[[49,55,46],256],9369:[[49,56,46],256],9370:[[49,57,46],256],9371:[[50,48,46],256],9372:[[40,97,41],256],9373:[[40,98,41],256],9374:[[40,99,41],256],9375:[[40,100,41],256],9376:[[40,101,41],256],9377:[[40,102,41],256],9378:[[40,103,41],256],9379:[[40,104,41],256],9380:[[40,105,41],256],9381:[[40,106,41],256],9382:[[40,107,41],256],9383:[[40,108,41],256],9384:[[40,109,41],256],9385:[[40,110,41],256],9386:[[40,111,41],256],9387:[[40,112,41],256],9388:[[40,113,41],256],9389:[[40,114,41],256],9390:[[40,115,41],256],9391:[[40,116,41],256],9392:[[40,117,41],256],9393:[[40,118,41],256],9394:[[40,119,41],256],9395:[[40,120,41],256],9396:[[40,121,41],256],9397:[[40,122,41],256],9398:[[65],256],9399:[[66],256],9400:[[67],256],9401:[[68],256],9402:[[69],256],9403:[[70],256],9404:[[71],256],9405:[[72],256],9406:[[73],256],9407:[[74],256],9408:[[75],256],9409:[[76],256],9410:[[77],256],9411:[[78],256],9412:[[79],256],9413:[[80],256],9414:[[81],256],9415:[[82],256],9416:[[83],256],9417:[[84],256],9418:[[85],256],9419:[[86],256],9420:[[87],256],9421:[[88],256],9422:[[89],256],9423:[[90],256],9424:[[97],256],9425:[[98],256],9426:[[99],256],9427:[[100],256],9428:[[101],256],9429:[[102],256],9430:[[103],256],9431:[[104],256],9432:[[105],256],9433:[[106],256],9434:[[107],256],9435:[[108],256],9436:[[109],256],9437:[[110],256],9438:[[111],256],9439:[[112],256],9440:[[113],256],9441:[[114],256],9442:[[115],256],9443:[[116],256],9444:[[117],256],9445:[[118],256],9446:[[119],256],9447:[[120],256],9448:[[121],256],9449:[[122],256],9450:[[48],256]}, +10752:{10764:[[8747,8747,8747,8747],256],10868:[[58,58,61],256],10869:[[61,61],256],10870:[[61,61,61],256],10972:[[10973,824],512]}, +11264:{11388:[[106],256],11389:[[86],256],11503:[,230],11504:[,230],11505:[,230]}, +11520:{11631:[[11617],256],11647:[,9],11744:[,230],11745:[,230],11746:[,230],11747:[,230],11748:[,230],11749:[,230],11750:[,230],11751:[,230],11752:[,230],11753:[,230],11754:[,230],11755:[,230],11756:[,230],11757:[,230],11758:[,230],11759:[,230],11760:[,230],11761:[,230],11762:[,230],11763:[,230],11764:[,230],11765:[,230],11766:[,230],11767:[,230],11768:[,230],11769:[,230],11770:[,230],11771:[,230],11772:[,230],11773:[,230],11774:[,230],11775:[,230]}, +11776:{11935:[[27597],256],12019:[[40863],256]}, +12032:{12032:[[19968],256],12033:[[20008],256],12034:[[20022],256],12035:[[20031],256],12036:[[20057],256],12037:[[20101],256],12038:[[20108],256],12039:[[20128],256],12040:[[20154],256],12041:[[20799],256],12042:[[20837],256],12043:[[20843],256],12044:[[20866],256],12045:[[20886],256],12046:[[20907],256],12047:[[20960],256],12048:[[20981],256],12049:[[20992],256],12050:[[21147],256],12051:[[21241],256],12052:[[21269],256],12053:[[21274],256],12054:[[21304],256],12055:[[21313],256],12056:[[21340],256],12057:[[21353],256],12058:[[21378],256],12059:[[21430],256],12060:[[21448],256],12061:[[21475],256],12062:[[22231],256],12063:[[22303],256],12064:[[22763],256],12065:[[22786],256],12066:[[22794],256],12067:[[22805],256],12068:[[22823],256],12069:[[22899],256],12070:[[23376],256],12071:[[23424],256],12072:[[23544],256],12073:[[23567],256],12074:[[23586],256],12075:[[23608],256],12076:[[23662],256],12077:[[23665],256],12078:[[24027],256],12079:[[24037],256],12080:[[24049],256],12081:[[24062],256],12082:[[24178],256],12083:[[24186],256],12084:[[24191],256],12085:[[24308],256],12086:[[24318],256],12087:[[24331],256],12088:[[24339],256],12089:[[24400],256],12090:[[24417],256],12091:[[24435],256],12092:[[24515],256],12093:[[25096],256],12094:[[25142],256],12095:[[25163],256],12096:[[25903],256],12097:[[25908],256],12098:[[25991],256],12099:[[26007],256],12100:[[26020],256],12101:[[26041],256],12102:[[26080],256],12103:[[26085],256],12104:[[26352],256],12105:[[26376],256],12106:[[26408],256],12107:[[27424],256],12108:[[27490],256],12109:[[27513],256],12110:[[27571],256],12111:[[27595],256],12112:[[27604],256],12113:[[27611],256],12114:[[27663],256],12115:[[27668],256],12116:[[27700],256],12117:[[28779],256],12118:[[29226],256],12119:[[29238],256],12120:[[29243],256],12121:[[29247],256],12122:[[29255],256],12123:[[29273],256],12124:[[29275],256],12125:[[29356],256],12126:[[29572],256],12127:[[29577],256],12128:[[29916],256],12129:[[29926],256],12130:[[29976],256],12131:[[29983],256],12132:[[29992],256],12133:[[30000],256],12134:[[30091],256],12135:[[30098],256],12136:[[30326],256],12137:[[30333],256],12138:[[30382],256],12139:[[30399],256],12140:[[30446],256],12141:[[30683],256],12142:[[30690],256],12143:[[30707],256],12144:[[31034],256],12145:[[31160],256],12146:[[31166],256],12147:[[31348],256],12148:[[31435],256],12149:[[31481],256],12150:[[31859],256],12151:[[31992],256],12152:[[32566],256],12153:[[32593],256],12154:[[32650],256],12155:[[32701],256],12156:[[32769],256],12157:[[32780],256],12158:[[32786],256],12159:[[32819],256],12160:[[32895],256],12161:[[32905],256],12162:[[33251],256],12163:[[33258],256],12164:[[33267],256],12165:[[33276],256],12166:[[33292],256],12167:[[33307],256],12168:[[33311],256],12169:[[33390],256],12170:[[33394],256],12171:[[33400],256],12172:[[34381],256],12173:[[34411],256],12174:[[34880],256],12175:[[34892],256],12176:[[34915],256],12177:[[35198],256],12178:[[35211],256],12179:[[35282],256],12180:[[35328],256],12181:[[35895],256],12182:[[35910],256],12183:[[35925],256],12184:[[35960],256],12185:[[35997],256],12186:[[36196],256],12187:[[36208],256],12188:[[36275],256],12189:[[36523],256],12190:[[36554],256],12191:[[36763],256],12192:[[36784],256],12193:[[36789],256],12194:[[37009],256],12195:[[37193],256],12196:[[37318],256],12197:[[37324],256],12198:[[37329],256],12199:[[38263],256],12200:[[38272],256],12201:[[38428],256],12202:[[38582],256],12203:[[38585],256],12204:[[38632],256],12205:[[38737],256],12206:[[38750],256],12207:[[38754],256],12208:[[38761],256],12209:[[38859],256],12210:[[38893],256],12211:[[38899],256],12212:[[38913],256],12213:[[39080],256],12214:[[39131],256],12215:[[39135],256],12216:[[39318],256],12217:[[39321],256],12218:[[39340],256],12219:[[39592],256],12220:[[39640],256],12221:[[39647],256],12222:[[39717],256],12223:[[39727],256],12224:[[39730],256],12225:[[39740],256],12226:[[39770],256],12227:[[40165],256],12228:[[40565],256],12229:[[40575],256],12230:[[40613],256],12231:[[40635],256],12232:[[40643],256],12233:[[40653],256],12234:[[40657],256],12235:[[40697],256],12236:[[40701],256],12237:[[40718],256],12238:[[40723],256],12239:[[40736],256],12240:[[40763],256],12241:[[40778],256],12242:[[40786],256],12243:[[40845],256],12244:[[40860],256],12245:[[40864],256]}, +12288:{12288:[[32],256],12330:[,218],12331:[,228],12332:[,232],12333:[,222],12334:[,224],12335:[,224],12342:[[12306],256],12344:[[21313],256],12345:[[21316],256],12346:[[21317],256],12358:[,,{12441:12436}],12363:[,,{12441:12364}],12364:[[12363,12441]],12365:[,,{12441:12366}],12366:[[12365,12441]],12367:[,,{12441:12368}],12368:[[12367,12441]],12369:[,,{12441:12370}],12370:[[12369,12441]],12371:[,,{12441:12372}],12372:[[12371,12441]],12373:[,,{12441:12374}],12374:[[12373,12441]],12375:[,,{12441:12376}],12376:[[12375,12441]],12377:[,,{12441:12378}],12378:[[12377,12441]],12379:[,,{12441:12380}],12380:[[12379,12441]],12381:[,,{12441:12382}],12382:[[12381,12441]],12383:[,,{12441:12384}],12384:[[12383,12441]],12385:[,,{12441:12386}],12386:[[12385,12441]],12388:[,,{12441:12389}],12389:[[12388,12441]],12390:[,,{12441:12391}],12391:[[12390,12441]],12392:[,,{12441:12393}],12393:[[12392,12441]],12399:[,,{12441:12400,12442:12401}],12400:[[12399,12441]],12401:[[12399,12442]],12402:[,,{12441:12403,12442:12404}],12403:[[12402,12441]],12404:[[12402,12442]],12405:[,,{12441:12406,12442:12407}],12406:[[12405,12441]],12407:[[12405,12442]],12408:[,,{12441:12409,12442:12410}],12409:[[12408,12441]],12410:[[12408,12442]],12411:[,,{12441:12412,12442:12413}],12412:[[12411,12441]],12413:[[12411,12442]],12436:[[12358,12441]],12441:[,8],12442:[,8],12443:[[32,12441],256],12444:[[32,12442],256],12445:[,,{12441:12446}],12446:[[12445,12441]],12447:[[12424,12426],256],12454:[,,{12441:12532}],12459:[,,{12441:12460}],12460:[[12459,12441]],12461:[,,{12441:12462}],12462:[[12461,12441]],12463:[,,{12441:12464}],12464:[[12463,12441]],12465:[,,{12441:12466}],12466:[[12465,12441]],12467:[,,{12441:12468}],12468:[[12467,12441]],12469:[,,{12441:12470}],12470:[[12469,12441]],12471:[,,{12441:12472}],12472:[[12471,12441]],12473:[,,{12441:12474}],12474:[[12473,12441]],12475:[,,{12441:12476}],12476:[[12475,12441]],12477:[,,{12441:12478}],12478:[[12477,12441]],12479:[,,{12441:12480}],12480:[[12479,12441]],12481:[,,{12441:12482}],12482:[[12481,12441]],12484:[,,{12441:12485}],12485:[[12484,12441]],12486:[,,{12441:12487}],12487:[[12486,12441]],12488:[,,{12441:12489}],12489:[[12488,12441]],12495:[,,{12441:12496,12442:12497}],12496:[[12495,12441]],12497:[[12495,12442]],12498:[,,{12441:12499,12442:12500}],12499:[[12498,12441]],12500:[[12498,12442]],12501:[,,{12441:12502,12442:12503}],12502:[[12501,12441]],12503:[[12501,12442]],12504:[,,{12441:12505,12442:12506}],12505:[[12504,12441]],12506:[[12504,12442]],12507:[,,{12441:12508,12442:12509}],12508:[[12507,12441]],12509:[[12507,12442]],12527:[,,{12441:12535}],12528:[,,{12441:12536}],12529:[,,{12441:12537}],12530:[,,{12441:12538}],12532:[[12454,12441]],12535:[[12527,12441]],12536:[[12528,12441]],12537:[[12529,12441]],12538:[[12530,12441]],12541:[,,{12441:12542}],12542:[[12541,12441]],12543:[[12467,12488],256]}, +12544:{12593:[[4352],256],12594:[[4353],256],12595:[[4522],256],12596:[[4354],256],12597:[[4524],256],12598:[[4525],256],12599:[[4355],256],12600:[[4356],256],12601:[[4357],256],12602:[[4528],256],12603:[[4529],256],12604:[[4530],256],12605:[[4531],256],12606:[[4532],256],12607:[[4533],256],12608:[[4378],256],12609:[[4358],256],12610:[[4359],256],12611:[[4360],256],12612:[[4385],256],12613:[[4361],256],12614:[[4362],256],12615:[[4363],256],12616:[[4364],256],12617:[[4365],256],12618:[[4366],256],12619:[[4367],256],12620:[[4368],256],12621:[[4369],256],12622:[[4370],256],12623:[[4449],256],12624:[[4450],256],12625:[[4451],256],12626:[[4452],256],12627:[[4453],256],12628:[[4454],256],12629:[[4455],256],12630:[[4456],256],12631:[[4457],256],12632:[[4458],256],12633:[[4459],256],12634:[[4460],256],12635:[[4461],256],12636:[[4462],256],12637:[[4463],256],12638:[[4464],256],12639:[[4465],256],12640:[[4466],256],12641:[[4467],256],12642:[[4468],256],12643:[[4469],256],12644:[[4448],256],12645:[[4372],256],12646:[[4373],256],12647:[[4551],256],12648:[[4552],256],12649:[[4556],256],12650:[[4558],256],12651:[[4563],256],12652:[[4567],256],12653:[[4569],256],12654:[[4380],256],12655:[[4573],256],12656:[[4575],256],12657:[[4381],256],12658:[[4382],256],12659:[[4384],256],12660:[[4386],256],12661:[[4387],256],12662:[[4391],256],12663:[[4393],256],12664:[[4395],256],12665:[[4396],256],12666:[[4397],256],12667:[[4398],256],12668:[[4399],256],12669:[[4402],256],12670:[[4406],256],12671:[[4416],256],12672:[[4423],256],12673:[[4428],256],12674:[[4593],256],12675:[[4594],256],12676:[[4439],256],12677:[[4440],256],12678:[[4441],256],12679:[[4484],256],12680:[[4485],256],12681:[[4488],256],12682:[[4497],256],12683:[[4498],256],12684:[[4500],256],12685:[[4510],256],12686:[[4513],256],12690:[[19968],256],12691:[[20108],256],12692:[[19977],256],12693:[[22235],256],12694:[[19978],256],12695:[[20013],256],12696:[[19979],256],12697:[[30002],256],12698:[[20057],256],12699:[[19993],256],12700:[[19969],256],12701:[[22825],256],12702:[[22320],256],12703:[[20154],256]}, +12800:{12800:[[40,4352,41],256],12801:[[40,4354,41],256],12802:[[40,4355,41],256],12803:[[40,4357,41],256],12804:[[40,4358,41],256],12805:[[40,4359,41],256],12806:[[40,4361,41],256],12807:[[40,4363,41],256],12808:[[40,4364,41],256],12809:[[40,4366,41],256],12810:[[40,4367,41],256],12811:[[40,4368,41],256],12812:[[40,4369,41],256],12813:[[40,4370,41],256],12814:[[40,4352,4449,41],256],12815:[[40,4354,4449,41],256],12816:[[40,4355,4449,41],256],12817:[[40,4357,4449,41],256],12818:[[40,4358,4449,41],256],12819:[[40,4359,4449,41],256],12820:[[40,4361,4449,41],256],12821:[[40,4363,4449,41],256],12822:[[40,4364,4449,41],256],12823:[[40,4366,4449,41],256],12824:[[40,4367,4449,41],256],12825:[[40,4368,4449,41],256],12826:[[40,4369,4449,41],256],12827:[[40,4370,4449,41],256],12828:[[40,4364,4462,41],256],12829:[[40,4363,4457,4364,4453,4523,41],256],12830:[[40,4363,4457,4370,4462,41],256],12832:[[40,19968,41],256],12833:[[40,20108,41],256],12834:[[40,19977,41],256],12835:[[40,22235,41],256],12836:[[40,20116,41],256],12837:[[40,20845,41],256],12838:[[40,19971,41],256],12839:[[40,20843,41],256],12840:[[40,20061,41],256],12841:[[40,21313,41],256],12842:[[40,26376,41],256],12843:[[40,28779,41],256],12844:[[40,27700,41],256],12845:[[40,26408,41],256],12846:[[40,37329,41],256],12847:[[40,22303,41],256],12848:[[40,26085,41],256],12849:[[40,26666,41],256],12850:[[40,26377,41],256],12851:[[40,31038,41],256],12852:[[40,21517,41],256],12853:[[40,29305,41],256],12854:[[40,36001,41],256],12855:[[40,31069,41],256],12856:[[40,21172,41],256],12857:[[40,20195,41],256],12858:[[40,21628,41],256],12859:[[40,23398,41],256],12860:[[40,30435,41],256],12861:[[40,20225,41],256],12862:[[40,36039,41],256],12863:[[40,21332,41],256],12864:[[40,31085,41],256],12865:[[40,20241,41],256],12866:[[40,33258,41],256],12867:[[40,33267,41],256],12868:[[21839],256],12869:[[24188],256],12870:[[25991],256],12871:[[31631],256],12880:[[80,84,69],256],12881:[[50,49],256],12882:[[50,50],256],12883:[[50,51],256],12884:[[50,52],256],12885:[[50,53],256],12886:[[50,54],256],12887:[[50,55],256],12888:[[50,56],256],12889:[[50,57],256],12890:[[51,48],256],12891:[[51,49],256],12892:[[51,50],256],12893:[[51,51],256],12894:[[51,52],256],12895:[[51,53],256],12896:[[4352],256],12897:[[4354],256],12898:[[4355],256],12899:[[4357],256],12900:[[4358],256],12901:[[4359],256],12902:[[4361],256],12903:[[4363],256],12904:[[4364],256],12905:[[4366],256],12906:[[4367],256],12907:[[4368],256],12908:[[4369],256],12909:[[4370],256],12910:[[4352,4449],256],12911:[[4354,4449],256],12912:[[4355,4449],256],12913:[[4357,4449],256],12914:[[4358,4449],256],12915:[[4359,4449],256],12916:[[4361,4449],256],12917:[[4363,4449],256],12918:[[4364,4449],256],12919:[[4366,4449],256],12920:[[4367,4449],256],12921:[[4368,4449],256],12922:[[4369,4449],256],12923:[[4370,4449],256],12924:[[4366,4449,4535,4352,4457],256],12925:[[4364,4462,4363,4468],256],12926:[[4363,4462],256],12928:[[19968],256],12929:[[20108],256],12930:[[19977],256],12931:[[22235],256],12932:[[20116],256],12933:[[20845],256],12934:[[19971],256],12935:[[20843],256],12936:[[20061],256],12937:[[21313],256],12938:[[26376],256],12939:[[28779],256],12940:[[27700],256],12941:[[26408],256],12942:[[37329],256],12943:[[22303],256],12944:[[26085],256],12945:[[26666],256],12946:[[26377],256],12947:[[31038],256],12948:[[21517],256],12949:[[29305],256],12950:[[36001],256],12951:[[31069],256],12952:[[21172],256],12953:[[31192],256],12954:[[30007],256],12955:[[22899],256],12956:[[36969],256],12957:[[20778],256],12958:[[21360],256],12959:[[27880],256],12960:[[38917],256],12961:[[20241],256],12962:[[20889],256],12963:[[27491],256],12964:[[19978],256],12965:[[20013],256],12966:[[19979],256],12967:[[24038],256],12968:[[21491],256],12969:[[21307],256],12970:[[23447],256],12971:[[23398],256],12972:[[30435],256],12973:[[20225],256],12974:[[36039],256],12975:[[21332],256],12976:[[22812],256],12977:[[51,54],256],12978:[[51,55],256],12979:[[51,56],256],12980:[[51,57],256],12981:[[52,48],256],12982:[[52,49],256],12983:[[52,50],256],12984:[[52,51],256],12985:[[52,52],256],12986:[[52,53],256],12987:[[52,54],256],12988:[[52,55],256],12989:[[52,56],256],12990:[[52,57],256],12991:[[53,48],256],12992:[[49,26376],256],12993:[[50,26376],256],12994:[[51,26376],256],12995:[[52,26376],256],12996:[[53,26376],256],12997:[[54,26376],256],12998:[[55,26376],256],12999:[[56,26376],256],13000:[[57,26376],256],13001:[[49,48,26376],256],13002:[[49,49,26376],256],13003:[[49,50,26376],256],13004:[[72,103],256],13005:[[101,114,103],256],13006:[[101,86],256],13007:[[76,84,68],256],13008:[[12450],256],13009:[[12452],256],13010:[[12454],256],13011:[[12456],256],13012:[[12458],256],13013:[[12459],256],13014:[[12461],256],13015:[[12463],256],13016:[[12465],256],13017:[[12467],256],13018:[[12469],256],13019:[[12471],256],13020:[[12473],256],13021:[[12475],256],13022:[[12477],256],13023:[[12479],256],13024:[[12481],256],13025:[[12484],256],13026:[[12486],256],13027:[[12488],256],13028:[[12490],256],13029:[[12491],256],13030:[[12492],256],13031:[[12493],256],13032:[[12494],256],13033:[[12495],256],13034:[[12498],256],13035:[[12501],256],13036:[[12504],256],13037:[[12507],256],13038:[[12510],256],13039:[[12511],256],13040:[[12512],256],13041:[[12513],256],13042:[[12514],256],13043:[[12516],256],13044:[[12518],256],13045:[[12520],256],13046:[[12521],256],13047:[[12522],256],13048:[[12523],256],13049:[[12524],256],13050:[[12525],256],13051:[[12527],256],13052:[[12528],256],13053:[[12529],256],13054:[[12530],256]}, +13056:{13056:[[12450,12497,12540,12488],256],13057:[[12450,12523,12501,12449],256],13058:[[12450,12531,12506,12450],256],13059:[[12450,12540,12523],256],13060:[[12452,12491,12531,12464],256],13061:[[12452,12531,12481],256],13062:[[12454,12457,12531],256],13063:[[12456,12473,12463,12540,12489],256],13064:[[12456,12540,12459,12540],256],13065:[[12458,12531,12473],256],13066:[[12458,12540,12512],256],13067:[[12459,12452,12522],256],13068:[[12459,12521,12483,12488],256],13069:[[12459,12525,12522,12540],256],13070:[[12460,12525,12531],256],13071:[[12460,12531,12510],256],13072:[[12462,12460],256],13073:[[12462,12491,12540],256],13074:[[12461,12517,12522,12540],256],13075:[[12462,12523,12480,12540],256],13076:[[12461,12525],256],13077:[[12461,12525,12464,12521,12512],256],13078:[[12461,12525,12513,12540,12488,12523],256],13079:[[12461,12525,12527,12483,12488],256],13080:[[12464,12521,12512],256],13081:[[12464,12521,12512,12488,12531],256],13082:[[12463,12523,12476,12452,12525],256],13083:[[12463,12525,12540,12493],256],13084:[[12465,12540,12473],256],13085:[[12467,12523,12490],256],13086:[[12467,12540,12509],256],13087:[[12469,12452,12463,12523],256],13088:[[12469,12531,12481,12540,12512],256],13089:[[12471,12522,12531,12464],256],13090:[[12475,12531,12481],256],13091:[[12475,12531,12488],256],13092:[[12480,12540,12473],256],13093:[[12487,12471],256],13094:[[12489,12523],256],13095:[[12488,12531],256],13096:[[12490,12494],256],13097:[[12494,12483,12488],256],13098:[[12495,12452,12484],256],13099:[[12497,12540,12475,12531,12488],256],13100:[[12497,12540,12484],256],13101:[[12496,12540,12524,12523],256],13102:[[12500,12450,12473,12488,12523],256],13103:[[12500,12463,12523],256],13104:[[12500,12467],256],13105:[[12499,12523],256],13106:[[12501,12449,12521,12483,12489],256],13107:[[12501,12451,12540,12488],256],13108:[[12502,12483,12471,12455,12523],256],13109:[[12501,12521,12531],256],13110:[[12504,12463,12479,12540,12523],256],13111:[[12506,12477],256],13112:[[12506,12491,12498],256],13113:[[12504,12523,12484],256],13114:[[12506,12531,12473],256],13115:[[12506,12540,12472],256],13116:[[12505,12540,12479],256],13117:[[12509,12452,12531,12488],256],13118:[[12508,12523,12488],256],13119:[[12507,12531],256],13120:[[12509,12531,12489],256],13121:[[12507,12540,12523],256],13122:[[12507,12540,12531],256],13123:[[12510,12452,12463,12525],256],13124:[[12510,12452,12523],256],13125:[[12510,12483,12495],256],13126:[[12510,12523,12463],256],13127:[[12510,12531,12471,12519,12531],256],13128:[[12511,12463,12525,12531],256],13129:[[12511,12522],256],13130:[[12511,12522,12496,12540,12523],256],13131:[[12513,12460],256],13132:[[12513,12460,12488,12531],256],13133:[[12513,12540,12488,12523],256],13134:[[12516,12540,12489],256],13135:[[12516,12540,12523],256],13136:[[12518,12450,12531],256],13137:[[12522,12483,12488,12523],256],13138:[[12522,12521],256],13139:[[12523,12500,12540],256],13140:[[12523,12540,12502,12523],256],13141:[[12524,12512],256],13142:[[12524,12531,12488,12466,12531],256],13143:[[12527,12483,12488],256],13144:[[48,28857],256],13145:[[49,28857],256],13146:[[50,28857],256],13147:[[51,28857],256],13148:[[52,28857],256],13149:[[53,28857],256],13150:[[54,28857],256],13151:[[55,28857],256],13152:[[56,28857],256],13153:[[57,28857],256],13154:[[49,48,28857],256],13155:[[49,49,28857],256],13156:[[49,50,28857],256],13157:[[49,51,28857],256],13158:[[49,52,28857],256],13159:[[49,53,28857],256],13160:[[49,54,28857],256],13161:[[49,55,28857],256],13162:[[49,56,28857],256],13163:[[49,57,28857],256],13164:[[50,48,28857],256],13165:[[50,49,28857],256],13166:[[50,50,28857],256],13167:[[50,51,28857],256],13168:[[50,52,28857],256],13169:[[104,80,97],256],13170:[[100,97],256],13171:[[65,85],256],13172:[[98,97,114],256],13173:[[111,86],256],13174:[[112,99],256],13175:[[100,109],256],13176:[[100,109,178],256],13177:[[100,109,179],256],13178:[[73,85],256],13179:[[24179,25104],256],13180:[[26157,21644],256],13181:[[22823,27491],256],13182:[[26126,27835],256],13183:[[26666,24335,20250,31038],256],13184:[[112,65],256],13185:[[110,65],256],13186:[[956,65],256],13187:[[109,65],256],13188:[[107,65],256],13189:[[75,66],256],13190:[[77,66],256],13191:[[71,66],256],13192:[[99,97,108],256],13193:[[107,99,97,108],256],13194:[[112,70],256],13195:[[110,70],256],13196:[[956,70],256],13197:[[956,103],256],13198:[[109,103],256],13199:[[107,103],256],13200:[[72,122],256],13201:[[107,72,122],256],13202:[[77,72,122],256],13203:[[71,72,122],256],13204:[[84,72,122],256],13205:[[956,8467],256],13206:[[109,8467],256],13207:[[100,8467],256],13208:[[107,8467],256],13209:[[102,109],256],13210:[[110,109],256],13211:[[956,109],256],13212:[[109,109],256],13213:[[99,109],256],13214:[[107,109],256],13215:[[109,109,178],256],13216:[[99,109,178],256],13217:[[109,178],256],13218:[[107,109,178],256],13219:[[109,109,179],256],13220:[[99,109,179],256],13221:[[109,179],256],13222:[[107,109,179],256],13223:[[109,8725,115],256],13224:[[109,8725,115,178],256],13225:[[80,97],256],13226:[[107,80,97],256],13227:[[77,80,97],256],13228:[[71,80,97],256],13229:[[114,97,100],256],13230:[[114,97,100,8725,115],256],13231:[[114,97,100,8725,115,178],256],13232:[[112,115],256],13233:[[110,115],256],13234:[[956,115],256],13235:[[109,115],256],13236:[[112,86],256],13237:[[110,86],256],13238:[[956,86],256],13239:[[109,86],256],13240:[[107,86],256],13241:[[77,86],256],13242:[[112,87],256],13243:[[110,87],256],13244:[[956,87],256],13245:[[109,87],256],13246:[[107,87],256],13247:[[77,87],256],13248:[[107,937],256],13249:[[77,937],256],13250:[[97,46,109,46],256],13251:[[66,113],256],13252:[[99,99],256],13253:[[99,100],256],13254:[[67,8725,107,103],256],13255:[[67,111,46],256],13256:[[100,66],256],13257:[[71,121],256],13258:[[104,97],256],13259:[[72,80],256],13260:[[105,110],256],13261:[[75,75],256],13262:[[75,77],256],13263:[[107,116],256],13264:[[108,109],256],13265:[[108,110],256],13266:[[108,111,103],256],13267:[[108,120],256],13268:[[109,98],256],13269:[[109,105,108],256],13270:[[109,111,108],256],13271:[[80,72],256],13272:[[112,46,109,46],256],13273:[[80,80,77],256],13274:[[80,82],256],13275:[[115,114],256],13276:[[83,118],256],13277:[[87,98],256],13278:[[86,8725,109],256],13279:[[65,8725,109],256],13280:[[49,26085],256],13281:[[50,26085],256],13282:[[51,26085],256],13283:[[52,26085],256],13284:[[53,26085],256],13285:[[54,26085],256],13286:[[55,26085],256],13287:[[56,26085],256],13288:[[57,26085],256],13289:[[49,48,26085],256],13290:[[49,49,26085],256],13291:[[49,50,26085],256],13292:[[49,51,26085],256],13293:[[49,52,26085],256],13294:[[49,53,26085],256],13295:[[49,54,26085],256],13296:[[49,55,26085],256],13297:[[49,56,26085],256],13298:[[49,57,26085],256],13299:[[50,48,26085],256],13300:[[50,49,26085],256],13301:[[50,50,26085],256],13302:[[50,51,26085],256],13303:[[50,52,26085],256],13304:[[50,53,26085],256],13305:[[50,54,26085],256],13306:[[50,55,26085],256],13307:[[50,56,26085],256],13308:[[50,57,26085],256],13309:[[51,48,26085],256],13310:[[51,49,26085],256],13311:[[103,97,108],256]}, +27136:{92912:[,1],92913:[,1],92914:[,1],92915:[,1],92916:[,1]}, +27392:{92976:[,230],92977:[,230],92978:[,230],92979:[,230],92980:[,230],92981:[,230],92982:[,230]}, +42496:{42607:[,230],42612:[,230],42613:[,230],42614:[,230],42615:[,230],42616:[,230],42617:[,230],42618:[,230],42619:[,230],42620:[,230],42621:[,230],42652:[[1098],256],42653:[[1100],256],42655:[,230],42736:[,230],42737:[,230]}, +42752:{42864:[[42863],256],43000:[[294],256],43001:[[339],256]}, +43008:{43014:[,9],43204:[,9],43232:[,230],43233:[,230],43234:[,230],43235:[,230],43236:[,230],43237:[,230],43238:[,230],43239:[,230],43240:[,230],43241:[,230],43242:[,230],43243:[,230],43244:[,230],43245:[,230],43246:[,230],43247:[,230],43248:[,230],43249:[,230]}, +43264:{43307:[,220],43308:[,220],43309:[,220],43347:[,9],43443:[,7],43456:[,9]}, +43520:{43696:[,230],43698:[,230],43699:[,230],43700:[,220],43703:[,230],43704:[,230],43710:[,230],43711:[,230],43713:[,230],43766:[,9]}, +43776:{43868:[[42791],256],43869:[[43831],256],43870:[[619],256],43871:[[43858],256],44013:[,9]}, +48128:{113822:[,1]}, +53504:{119134:[[119127,119141],512],119135:[[119128,119141],512],119136:[[119135,119150],512],119137:[[119135,119151],512],119138:[[119135,119152],512],119139:[[119135,119153],512],119140:[[119135,119154],512],119141:[,216],119142:[,216],119143:[,1],119144:[,1],119145:[,1],119149:[,226],119150:[,216],119151:[,216],119152:[,216],119153:[,216],119154:[,216],119163:[,220],119164:[,220],119165:[,220],119166:[,220],119167:[,220],119168:[,220],119169:[,220],119170:[,220],119173:[,230],119174:[,230],119175:[,230],119176:[,230],119177:[,230],119178:[,220],119179:[,220],119210:[,230],119211:[,230],119212:[,230],119213:[,230],119227:[[119225,119141],512],119228:[[119226,119141],512],119229:[[119227,119150],512],119230:[[119228,119150],512],119231:[[119227,119151],512],119232:[[119228,119151],512]}, +53760:{119362:[,230],119363:[,230],119364:[,230]}, +54272:{119808:[[65],256],119809:[[66],256],119810:[[67],256],119811:[[68],256],119812:[[69],256],119813:[[70],256],119814:[[71],256],119815:[[72],256],119816:[[73],256],119817:[[74],256],119818:[[75],256],119819:[[76],256],119820:[[77],256],119821:[[78],256],119822:[[79],256],119823:[[80],256],119824:[[81],256],119825:[[82],256],119826:[[83],256],119827:[[84],256],119828:[[85],256],119829:[[86],256],119830:[[87],256],119831:[[88],256],119832:[[89],256],119833:[[90],256],119834:[[97],256],119835:[[98],256],119836:[[99],256],119837:[[100],256],119838:[[101],256],119839:[[102],256],119840:[[103],256],119841:[[104],256],119842:[[105],256],119843:[[106],256],119844:[[107],256],119845:[[108],256],119846:[[109],256],119847:[[110],256],119848:[[111],256],119849:[[112],256],119850:[[113],256],119851:[[114],256],119852:[[115],256],119853:[[116],256],119854:[[117],256],119855:[[118],256],119856:[[119],256],119857:[[120],256],119858:[[121],256],119859:[[122],256],119860:[[65],256],119861:[[66],256],119862:[[67],256],119863:[[68],256],119864:[[69],256],119865:[[70],256],119866:[[71],256],119867:[[72],256],119868:[[73],256],119869:[[74],256],119870:[[75],256],119871:[[76],256],119872:[[77],256],119873:[[78],256],119874:[[79],256],119875:[[80],256],119876:[[81],256],119877:[[82],256],119878:[[83],256],119879:[[84],256],119880:[[85],256],119881:[[86],256],119882:[[87],256],119883:[[88],256],119884:[[89],256],119885:[[90],256],119886:[[97],256],119887:[[98],256],119888:[[99],256],119889:[[100],256],119890:[[101],256],119891:[[102],256],119892:[[103],256],119894:[[105],256],119895:[[106],256],119896:[[107],256],119897:[[108],256],119898:[[109],256],119899:[[110],256],119900:[[111],256],119901:[[112],256],119902:[[113],256],119903:[[114],256],119904:[[115],256],119905:[[116],256],119906:[[117],256],119907:[[118],256],119908:[[119],256],119909:[[120],256],119910:[[121],256],119911:[[122],256],119912:[[65],256],119913:[[66],256],119914:[[67],256],119915:[[68],256],119916:[[69],256],119917:[[70],256],119918:[[71],256],119919:[[72],256],119920:[[73],256],119921:[[74],256],119922:[[75],256],119923:[[76],256],119924:[[77],256],119925:[[78],256],119926:[[79],256],119927:[[80],256],119928:[[81],256],119929:[[82],256],119930:[[83],256],119931:[[84],256],119932:[[85],256],119933:[[86],256],119934:[[87],256],119935:[[88],256],119936:[[89],256],119937:[[90],256],119938:[[97],256],119939:[[98],256],119940:[[99],256],119941:[[100],256],119942:[[101],256],119943:[[102],256],119944:[[103],256],119945:[[104],256],119946:[[105],256],119947:[[106],256],119948:[[107],256],119949:[[108],256],119950:[[109],256],119951:[[110],256],119952:[[111],256],119953:[[112],256],119954:[[113],256],119955:[[114],256],119956:[[115],256],119957:[[116],256],119958:[[117],256],119959:[[118],256],119960:[[119],256],119961:[[120],256],119962:[[121],256],119963:[[122],256],119964:[[65],256],119966:[[67],256],119967:[[68],256],119970:[[71],256],119973:[[74],256],119974:[[75],256],119977:[[78],256],119978:[[79],256],119979:[[80],256],119980:[[81],256],119982:[[83],256],119983:[[84],256],119984:[[85],256],119985:[[86],256],119986:[[87],256],119987:[[88],256],119988:[[89],256],119989:[[90],256],119990:[[97],256],119991:[[98],256],119992:[[99],256],119993:[[100],256],119995:[[102],256],119997:[[104],256],119998:[[105],256],119999:[[106],256],120000:[[107],256],120001:[[108],256],120002:[[109],256],120003:[[110],256],120005:[[112],256],120006:[[113],256],120007:[[114],256],120008:[[115],256],120009:[[116],256],120010:[[117],256],120011:[[118],256],120012:[[119],256],120013:[[120],256],120014:[[121],256],120015:[[122],256],120016:[[65],256],120017:[[66],256],120018:[[67],256],120019:[[68],256],120020:[[69],256],120021:[[70],256],120022:[[71],256],120023:[[72],256],120024:[[73],256],120025:[[74],256],120026:[[75],256],120027:[[76],256],120028:[[77],256],120029:[[78],256],120030:[[79],256],120031:[[80],256],120032:[[81],256],120033:[[82],256],120034:[[83],256],120035:[[84],256],120036:[[85],256],120037:[[86],256],120038:[[87],256],120039:[[88],256],120040:[[89],256],120041:[[90],256],120042:[[97],256],120043:[[98],256],120044:[[99],256],120045:[[100],256],120046:[[101],256],120047:[[102],256],120048:[[103],256],120049:[[104],256],120050:[[105],256],120051:[[106],256],120052:[[107],256],120053:[[108],256],120054:[[109],256],120055:[[110],256],120056:[[111],256],120057:[[112],256],120058:[[113],256],120059:[[114],256],120060:[[115],256],120061:[[116],256],120062:[[117],256],120063:[[118],256]}, +54528:{120064:[[119],256],120065:[[120],256],120066:[[121],256],120067:[[122],256],120068:[[65],256],120069:[[66],256],120071:[[68],256],120072:[[69],256],120073:[[70],256],120074:[[71],256],120077:[[74],256],120078:[[75],256],120079:[[76],256],120080:[[77],256],120081:[[78],256],120082:[[79],256],120083:[[80],256],120084:[[81],256],120086:[[83],256],120087:[[84],256],120088:[[85],256],120089:[[86],256],120090:[[87],256],120091:[[88],256],120092:[[89],256],120094:[[97],256],120095:[[98],256],120096:[[99],256],120097:[[100],256],120098:[[101],256],120099:[[102],256],120100:[[103],256],120101:[[104],256],120102:[[105],256],120103:[[106],256],120104:[[107],256],120105:[[108],256],120106:[[109],256],120107:[[110],256],120108:[[111],256],120109:[[112],256],120110:[[113],256],120111:[[114],256],120112:[[115],256],120113:[[116],256],120114:[[117],256],120115:[[118],256],120116:[[119],256],120117:[[120],256],120118:[[121],256],120119:[[122],256],120120:[[65],256],120121:[[66],256],120123:[[68],256],120124:[[69],256],120125:[[70],256],120126:[[71],256],120128:[[73],256],120129:[[74],256],120130:[[75],256],120131:[[76],256],120132:[[77],256],120134:[[79],256],120138:[[83],256],120139:[[84],256],120140:[[85],256],120141:[[86],256],120142:[[87],256],120143:[[88],256],120144:[[89],256],120146:[[97],256],120147:[[98],256],120148:[[99],256],120149:[[100],256],120150:[[101],256],120151:[[102],256],120152:[[103],256],120153:[[104],256],120154:[[105],256],120155:[[106],256],120156:[[107],256],120157:[[108],256],120158:[[109],256],120159:[[110],256],120160:[[111],256],120161:[[112],256],120162:[[113],256],120163:[[114],256],120164:[[115],256],120165:[[116],256],120166:[[117],256],120167:[[118],256],120168:[[119],256],120169:[[120],256],120170:[[121],256],120171:[[122],256],120172:[[65],256],120173:[[66],256],120174:[[67],256],120175:[[68],256],120176:[[69],256],120177:[[70],256],120178:[[71],256],120179:[[72],256],120180:[[73],256],120181:[[74],256],120182:[[75],256],120183:[[76],256],120184:[[77],256],120185:[[78],256],120186:[[79],256],120187:[[80],256],120188:[[81],256],120189:[[82],256],120190:[[83],256],120191:[[84],256],120192:[[85],256],120193:[[86],256],120194:[[87],256],120195:[[88],256],120196:[[89],256],120197:[[90],256],120198:[[97],256],120199:[[98],256],120200:[[99],256],120201:[[100],256],120202:[[101],256],120203:[[102],256],120204:[[103],256],120205:[[104],256],120206:[[105],256],120207:[[106],256],120208:[[107],256],120209:[[108],256],120210:[[109],256],120211:[[110],256],120212:[[111],256],120213:[[112],256],120214:[[113],256],120215:[[114],256],120216:[[115],256],120217:[[116],256],120218:[[117],256],120219:[[118],256],120220:[[119],256],120221:[[120],256],120222:[[121],256],120223:[[122],256],120224:[[65],256],120225:[[66],256],120226:[[67],256],120227:[[68],256],120228:[[69],256],120229:[[70],256],120230:[[71],256],120231:[[72],256],120232:[[73],256],120233:[[74],256],120234:[[75],256],120235:[[76],256],120236:[[77],256],120237:[[78],256],120238:[[79],256],120239:[[80],256],120240:[[81],256],120241:[[82],256],120242:[[83],256],120243:[[84],256],120244:[[85],256],120245:[[86],256],120246:[[87],256],120247:[[88],256],120248:[[89],256],120249:[[90],256],120250:[[97],256],120251:[[98],256],120252:[[99],256],120253:[[100],256],120254:[[101],256],120255:[[102],256],120256:[[103],256],120257:[[104],256],120258:[[105],256],120259:[[106],256],120260:[[107],256],120261:[[108],256],120262:[[109],256],120263:[[110],256],120264:[[111],256],120265:[[112],256],120266:[[113],256],120267:[[114],256],120268:[[115],256],120269:[[116],256],120270:[[117],256],120271:[[118],256],120272:[[119],256],120273:[[120],256],120274:[[121],256],120275:[[122],256],120276:[[65],256],120277:[[66],256],120278:[[67],256],120279:[[68],256],120280:[[69],256],120281:[[70],256],120282:[[71],256],120283:[[72],256],120284:[[73],256],120285:[[74],256],120286:[[75],256],120287:[[76],256],120288:[[77],256],120289:[[78],256],120290:[[79],256],120291:[[80],256],120292:[[81],256],120293:[[82],256],120294:[[83],256],120295:[[84],256],120296:[[85],256],120297:[[86],256],120298:[[87],256],120299:[[88],256],120300:[[89],256],120301:[[90],256],120302:[[97],256],120303:[[98],256],120304:[[99],256],120305:[[100],256],120306:[[101],256],120307:[[102],256],120308:[[103],256],120309:[[104],256],120310:[[105],256],120311:[[106],256],120312:[[107],256],120313:[[108],256],120314:[[109],256],120315:[[110],256],120316:[[111],256],120317:[[112],256],120318:[[113],256],120319:[[114],256]}, +54784:{120320:[[115],256],120321:[[116],256],120322:[[117],256],120323:[[118],256],120324:[[119],256],120325:[[120],256],120326:[[121],256],120327:[[122],256],120328:[[65],256],120329:[[66],256],120330:[[67],256],120331:[[68],256],120332:[[69],256],120333:[[70],256],120334:[[71],256],120335:[[72],256],120336:[[73],256],120337:[[74],256],120338:[[75],256],120339:[[76],256],120340:[[77],256],120341:[[78],256],120342:[[79],256],120343:[[80],256],120344:[[81],256],120345:[[82],256],120346:[[83],256],120347:[[84],256],120348:[[85],256],120349:[[86],256],120350:[[87],256],120351:[[88],256],120352:[[89],256],120353:[[90],256],120354:[[97],256],120355:[[98],256],120356:[[99],256],120357:[[100],256],120358:[[101],256],120359:[[102],256],120360:[[103],256],120361:[[104],256],120362:[[105],256],120363:[[106],256],120364:[[107],256],120365:[[108],256],120366:[[109],256],120367:[[110],256],120368:[[111],256],120369:[[112],256],120370:[[113],256],120371:[[114],256],120372:[[115],256],120373:[[116],256],120374:[[117],256],120375:[[118],256],120376:[[119],256],120377:[[120],256],120378:[[121],256],120379:[[122],256],120380:[[65],256],120381:[[66],256],120382:[[67],256],120383:[[68],256],120384:[[69],256],120385:[[70],256],120386:[[71],256],120387:[[72],256],120388:[[73],256],120389:[[74],256],120390:[[75],256],120391:[[76],256],120392:[[77],256],120393:[[78],256],120394:[[79],256],120395:[[80],256],120396:[[81],256],120397:[[82],256],120398:[[83],256],120399:[[84],256],120400:[[85],256],120401:[[86],256],120402:[[87],256],120403:[[88],256],120404:[[89],256],120405:[[90],256],120406:[[97],256],120407:[[98],256],120408:[[99],256],120409:[[100],256],120410:[[101],256],120411:[[102],256],120412:[[103],256],120413:[[104],256],120414:[[105],256],120415:[[106],256],120416:[[107],256],120417:[[108],256],120418:[[109],256],120419:[[110],256],120420:[[111],256],120421:[[112],256],120422:[[113],256],120423:[[114],256],120424:[[115],256],120425:[[116],256],120426:[[117],256],120427:[[118],256],120428:[[119],256],120429:[[120],256],120430:[[121],256],120431:[[122],256],120432:[[65],256],120433:[[66],256],120434:[[67],256],120435:[[68],256],120436:[[69],256],120437:[[70],256],120438:[[71],256],120439:[[72],256],120440:[[73],256],120441:[[74],256],120442:[[75],256],120443:[[76],256],120444:[[77],256],120445:[[78],256],120446:[[79],256],120447:[[80],256],120448:[[81],256],120449:[[82],256],120450:[[83],256],120451:[[84],256],120452:[[85],256],120453:[[86],256],120454:[[87],256],120455:[[88],256],120456:[[89],256],120457:[[90],256],120458:[[97],256],120459:[[98],256],120460:[[99],256],120461:[[100],256],120462:[[101],256],120463:[[102],256],120464:[[103],256],120465:[[104],256],120466:[[105],256],120467:[[106],256],120468:[[107],256],120469:[[108],256],120470:[[109],256],120471:[[110],256],120472:[[111],256],120473:[[112],256],120474:[[113],256],120475:[[114],256],120476:[[115],256],120477:[[116],256],120478:[[117],256],120479:[[118],256],120480:[[119],256],120481:[[120],256],120482:[[121],256],120483:[[122],256],120484:[[305],256],120485:[[567],256],120488:[[913],256],120489:[[914],256],120490:[[915],256],120491:[[916],256],120492:[[917],256],120493:[[918],256],120494:[[919],256],120495:[[920],256],120496:[[921],256],120497:[[922],256],120498:[[923],256],120499:[[924],256],120500:[[925],256],120501:[[926],256],120502:[[927],256],120503:[[928],256],120504:[[929],256],120505:[[1012],256],120506:[[931],256],120507:[[932],256],120508:[[933],256],120509:[[934],256],120510:[[935],256],120511:[[936],256],120512:[[937],256],120513:[[8711],256],120514:[[945],256],120515:[[946],256],120516:[[947],256],120517:[[948],256],120518:[[949],256],120519:[[950],256],120520:[[951],256],120521:[[952],256],120522:[[953],256],120523:[[954],256],120524:[[955],256],120525:[[956],256],120526:[[957],256],120527:[[958],256],120528:[[959],256],120529:[[960],256],120530:[[961],256],120531:[[962],256],120532:[[963],256],120533:[[964],256],120534:[[965],256],120535:[[966],256],120536:[[967],256],120537:[[968],256],120538:[[969],256],120539:[[8706],256],120540:[[1013],256],120541:[[977],256],120542:[[1008],256],120543:[[981],256],120544:[[1009],256],120545:[[982],256],120546:[[913],256],120547:[[914],256],120548:[[915],256],120549:[[916],256],120550:[[917],256],120551:[[918],256],120552:[[919],256],120553:[[920],256],120554:[[921],256],120555:[[922],256],120556:[[923],256],120557:[[924],256],120558:[[925],256],120559:[[926],256],120560:[[927],256],120561:[[928],256],120562:[[929],256],120563:[[1012],256],120564:[[931],256],120565:[[932],256],120566:[[933],256],120567:[[934],256],120568:[[935],256],120569:[[936],256],120570:[[937],256],120571:[[8711],256],120572:[[945],256],120573:[[946],256],120574:[[947],256],120575:[[948],256]}, +55040:{120576:[[949],256],120577:[[950],256],120578:[[951],256],120579:[[952],256],120580:[[953],256],120581:[[954],256],120582:[[955],256],120583:[[956],256],120584:[[957],256],120585:[[958],256],120586:[[959],256],120587:[[960],256],120588:[[961],256],120589:[[962],256],120590:[[963],256],120591:[[964],256],120592:[[965],256],120593:[[966],256],120594:[[967],256],120595:[[968],256],120596:[[969],256],120597:[[8706],256],120598:[[1013],256],120599:[[977],256],120600:[[1008],256],120601:[[981],256],120602:[[1009],256],120603:[[982],256],120604:[[913],256],120605:[[914],256],120606:[[915],256],120607:[[916],256],120608:[[917],256],120609:[[918],256],120610:[[919],256],120611:[[920],256],120612:[[921],256],120613:[[922],256],120614:[[923],256],120615:[[924],256],120616:[[925],256],120617:[[926],256],120618:[[927],256],120619:[[928],256],120620:[[929],256],120621:[[1012],256],120622:[[931],256],120623:[[932],256],120624:[[933],256],120625:[[934],256],120626:[[935],256],120627:[[936],256],120628:[[937],256],120629:[[8711],256],120630:[[945],256],120631:[[946],256],120632:[[947],256],120633:[[948],256],120634:[[949],256],120635:[[950],256],120636:[[951],256],120637:[[952],256],120638:[[953],256],120639:[[954],256],120640:[[955],256],120641:[[956],256],120642:[[957],256],120643:[[958],256],120644:[[959],256],120645:[[960],256],120646:[[961],256],120647:[[962],256],120648:[[963],256],120649:[[964],256],120650:[[965],256],120651:[[966],256],120652:[[967],256],120653:[[968],256],120654:[[969],256],120655:[[8706],256],120656:[[1013],256],120657:[[977],256],120658:[[1008],256],120659:[[981],256],120660:[[1009],256],120661:[[982],256],120662:[[913],256],120663:[[914],256],120664:[[915],256],120665:[[916],256],120666:[[917],256],120667:[[918],256],120668:[[919],256],120669:[[920],256],120670:[[921],256],120671:[[922],256],120672:[[923],256],120673:[[924],256],120674:[[925],256],120675:[[926],256],120676:[[927],256],120677:[[928],256],120678:[[929],256],120679:[[1012],256],120680:[[931],256],120681:[[932],256],120682:[[933],256],120683:[[934],256],120684:[[935],256],120685:[[936],256],120686:[[937],256],120687:[[8711],256],120688:[[945],256],120689:[[946],256],120690:[[947],256],120691:[[948],256],120692:[[949],256],120693:[[950],256],120694:[[951],256],120695:[[952],256],120696:[[953],256],120697:[[954],256],120698:[[955],256],120699:[[956],256],120700:[[957],256],120701:[[958],256],120702:[[959],256],120703:[[960],256],120704:[[961],256],120705:[[962],256],120706:[[963],256],120707:[[964],256],120708:[[965],256],120709:[[966],256],120710:[[967],256],120711:[[968],256],120712:[[969],256],120713:[[8706],256],120714:[[1013],256],120715:[[977],256],120716:[[1008],256],120717:[[981],256],120718:[[1009],256],120719:[[982],256],120720:[[913],256],120721:[[914],256],120722:[[915],256],120723:[[916],256],120724:[[917],256],120725:[[918],256],120726:[[919],256],120727:[[920],256],120728:[[921],256],120729:[[922],256],120730:[[923],256],120731:[[924],256],120732:[[925],256],120733:[[926],256],120734:[[927],256],120735:[[928],256],120736:[[929],256],120737:[[1012],256],120738:[[931],256],120739:[[932],256],120740:[[933],256],120741:[[934],256],120742:[[935],256],120743:[[936],256],120744:[[937],256],120745:[[8711],256],120746:[[945],256],120747:[[946],256],120748:[[947],256],120749:[[948],256],120750:[[949],256],120751:[[950],256],120752:[[951],256],120753:[[952],256],120754:[[953],256],120755:[[954],256],120756:[[955],256],120757:[[956],256],120758:[[957],256],120759:[[958],256],120760:[[959],256],120761:[[960],256],120762:[[961],256],120763:[[962],256],120764:[[963],256],120765:[[964],256],120766:[[965],256],120767:[[966],256],120768:[[967],256],120769:[[968],256],120770:[[969],256],120771:[[8706],256],120772:[[1013],256],120773:[[977],256],120774:[[1008],256],120775:[[981],256],120776:[[1009],256],120777:[[982],256],120778:[[988],256],120779:[[989],256],120782:[[48],256],120783:[[49],256],120784:[[50],256],120785:[[51],256],120786:[[52],256],120787:[[53],256],120788:[[54],256],120789:[[55],256],120790:[[56],256],120791:[[57],256],120792:[[48],256],120793:[[49],256],120794:[[50],256],120795:[[51],256],120796:[[52],256],120797:[[53],256],120798:[[54],256],120799:[[55],256],120800:[[56],256],120801:[[57],256],120802:[[48],256],120803:[[49],256],120804:[[50],256],120805:[[51],256],120806:[[52],256],120807:[[53],256],120808:[[54],256],120809:[[55],256],120810:[[56],256],120811:[[57],256],120812:[[48],256],120813:[[49],256],120814:[[50],256],120815:[[51],256],120816:[[52],256],120817:[[53],256],120818:[[54],256],120819:[[55],256],120820:[[56],256],120821:[[57],256],120822:[[48],256],120823:[[49],256],120824:[[50],256],120825:[[51],256],120826:[[52],256],120827:[[53],256],120828:[[54],256],120829:[[55],256],120830:[[56],256],120831:[[57],256]}, +59392:{125136:[,220],125137:[,220],125138:[,220],125139:[,220],125140:[,220],125141:[,220],125142:[,220]}, +60928:{126464:[[1575],256],126465:[[1576],256],126466:[[1580],256],126467:[[1583],256],126469:[[1608],256],126470:[[1586],256],126471:[[1581],256],126472:[[1591],256],126473:[[1610],256],126474:[[1603],256],126475:[[1604],256],126476:[[1605],256],126477:[[1606],256],126478:[[1587],256],126479:[[1593],256],126480:[[1601],256],126481:[[1589],256],126482:[[1602],256],126483:[[1585],256],126484:[[1588],256],126485:[[1578],256],126486:[[1579],256],126487:[[1582],256],126488:[[1584],256],126489:[[1590],256],126490:[[1592],256],126491:[[1594],256],126492:[[1646],256],126493:[[1722],256],126494:[[1697],256],126495:[[1647],256],126497:[[1576],256],126498:[[1580],256],126500:[[1607],256],126503:[[1581],256],126505:[[1610],256],126506:[[1603],256],126507:[[1604],256],126508:[[1605],256],126509:[[1606],256],126510:[[1587],256],126511:[[1593],256],126512:[[1601],256],126513:[[1589],256],126514:[[1602],256],126516:[[1588],256],126517:[[1578],256],126518:[[1579],256],126519:[[1582],256],126521:[[1590],256],126523:[[1594],256],126530:[[1580],256],126535:[[1581],256],126537:[[1610],256],126539:[[1604],256],126541:[[1606],256],126542:[[1587],256],126543:[[1593],256],126545:[[1589],256],126546:[[1602],256],126548:[[1588],256],126551:[[1582],256],126553:[[1590],256],126555:[[1594],256],126557:[[1722],256],126559:[[1647],256],126561:[[1576],256],126562:[[1580],256],126564:[[1607],256],126567:[[1581],256],126568:[[1591],256],126569:[[1610],256],126570:[[1603],256],126572:[[1605],256],126573:[[1606],256],126574:[[1587],256],126575:[[1593],256],126576:[[1601],256],126577:[[1589],256],126578:[[1602],256],126580:[[1588],256],126581:[[1578],256],126582:[[1579],256],126583:[[1582],256],126585:[[1590],256],126586:[[1592],256],126587:[[1594],256],126588:[[1646],256],126590:[[1697],256],126592:[[1575],256],126593:[[1576],256],126594:[[1580],256],126595:[[1583],256],126596:[[1607],256],126597:[[1608],256],126598:[[1586],256],126599:[[1581],256],126600:[[1591],256],126601:[[1610],256],126603:[[1604],256],126604:[[1605],256],126605:[[1606],256],126606:[[1587],256],126607:[[1593],256],126608:[[1601],256],126609:[[1589],256],126610:[[1602],256],126611:[[1585],256],126612:[[1588],256],126613:[[1578],256],126614:[[1579],256],126615:[[1582],256],126616:[[1584],256],126617:[[1590],256],126618:[[1592],256],126619:[[1594],256],126625:[[1576],256],126626:[[1580],256],126627:[[1583],256],126629:[[1608],256],126630:[[1586],256],126631:[[1581],256],126632:[[1591],256],126633:[[1610],256],126635:[[1604],256],126636:[[1605],256],126637:[[1606],256],126638:[[1587],256],126639:[[1593],256],126640:[[1601],256],126641:[[1589],256],126642:[[1602],256],126643:[[1585],256],126644:[[1588],256],126645:[[1578],256],126646:[[1579],256],126647:[[1582],256],126648:[[1584],256],126649:[[1590],256],126650:[[1592],256],126651:[[1594],256]}, +61696:{127232:[[48,46],256],127233:[[48,44],256],127234:[[49,44],256],127235:[[50,44],256],127236:[[51,44],256],127237:[[52,44],256],127238:[[53,44],256],127239:[[54,44],256],127240:[[55,44],256],127241:[[56,44],256],127242:[[57,44],256],127248:[[40,65,41],256],127249:[[40,66,41],256],127250:[[40,67,41],256],127251:[[40,68,41],256],127252:[[40,69,41],256],127253:[[40,70,41],256],127254:[[40,71,41],256],127255:[[40,72,41],256],127256:[[40,73,41],256],127257:[[40,74,41],256],127258:[[40,75,41],256],127259:[[40,76,41],256],127260:[[40,77,41],256],127261:[[40,78,41],256],127262:[[40,79,41],256],127263:[[40,80,41],256],127264:[[40,81,41],256],127265:[[40,82,41],256],127266:[[40,83,41],256],127267:[[40,84,41],256],127268:[[40,85,41],256],127269:[[40,86,41],256],127270:[[40,87,41],256],127271:[[40,88,41],256],127272:[[40,89,41],256],127273:[[40,90,41],256],127274:[[12308,83,12309],256],127275:[[67],256],127276:[[82],256],127277:[[67,68],256],127278:[[87,90],256],127280:[[65],256],127281:[[66],256],127282:[[67],256],127283:[[68],256],127284:[[69],256],127285:[[70],256],127286:[[71],256],127287:[[72],256],127288:[[73],256],127289:[[74],256],127290:[[75],256],127291:[[76],256],127292:[[77],256],127293:[[78],256],127294:[[79],256],127295:[[80],256],127296:[[81],256],127297:[[82],256],127298:[[83],256],127299:[[84],256],127300:[[85],256],127301:[[86],256],127302:[[87],256],127303:[[88],256],127304:[[89],256],127305:[[90],256],127306:[[72,86],256],127307:[[77,86],256],127308:[[83,68],256],127309:[[83,83],256],127310:[[80,80,86],256],127311:[[87,67],256],127338:[[77,67],256],127339:[[77,68],256],127376:[[68,74],256]}, +61952:{127488:[[12411,12363],256],127489:[[12467,12467],256],127490:[[12469],256],127504:[[25163],256],127505:[[23383],256],127506:[[21452],256],127507:[[12487],256],127508:[[20108],256],127509:[[22810],256],127510:[[35299],256],127511:[[22825],256],127512:[[20132],256],127513:[[26144],256],127514:[[28961],256],127515:[[26009],256],127516:[[21069],256],127517:[[24460],256],127518:[[20877],256],127519:[[26032],256],127520:[[21021],256],127521:[[32066],256],127522:[[29983],256],127523:[[36009],256],127524:[[22768],256],127525:[[21561],256],127526:[[28436],256],127527:[[25237],256],127528:[[25429],256],127529:[[19968],256],127530:[[19977],256],127531:[[36938],256],127532:[[24038],256],127533:[[20013],256],127534:[[21491],256],127535:[[25351],256],127536:[[36208],256],127537:[[25171],256],127538:[[31105],256],127539:[[31354],256],127540:[[21512],256],127541:[[28288],256],127542:[[26377],256],127543:[[26376],256],127544:[[30003],256],127545:[[21106],256],127546:[[21942],256],127552:[[12308,26412,12309],256],127553:[[12308,19977,12309],256],127554:[[12308,20108,12309],256],127555:[[12308,23433,12309],256],127556:[[12308,28857,12309],256],127557:[[12308,25171,12309],256],127558:[[12308,30423,12309],256],127559:[[12308,21213,12309],256],127560:[[12308,25943,12309],256],127568:[[24471],256],127569:[[21487],256]}, +63488:{194560:[[20029]],194561:[[20024]],194562:[[20033]],194563:[[131362]],194564:[[20320]],194565:[[20398]],194566:[[20411]],194567:[[20482]],194568:[[20602]],194569:[[20633]],194570:[[20711]],194571:[[20687]],194572:[[13470]],194573:[[132666]],194574:[[20813]],194575:[[20820]],194576:[[20836]],194577:[[20855]],194578:[[132380]],194579:[[13497]],194580:[[20839]],194581:[[20877]],194582:[[132427]],194583:[[20887]],194584:[[20900]],194585:[[20172]],194586:[[20908]],194587:[[20917]],194588:[[168415]],194589:[[20981]],194590:[[20995]],194591:[[13535]],194592:[[21051]],194593:[[21062]],194594:[[21106]],194595:[[21111]],194596:[[13589]],194597:[[21191]],194598:[[21193]],194599:[[21220]],194600:[[21242]],194601:[[21253]],194602:[[21254]],194603:[[21271]],194604:[[21321]],194605:[[21329]],194606:[[21338]],194607:[[21363]],194608:[[21373]],194609:[[21375]],194610:[[21375]],194611:[[21375]],194612:[[133676]],194613:[[28784]],194614:[[21450]],194615:[[21471]],194616:[[133987]],194617:[[21483]],194618:[[21489]],194619:[[21510]],194620:[[21662]],194621:[[21560]],194622:[[21576]],194623:[[21608]],194624:[[21666]],194625:[[21750]],194626:[[21776]],194627:[[21843]],194628:[[21859]],194629:[[21892]],194630:[[21892]],194631:[[21913]],194632:[[21931]],194633:[[21939]],194634:[[21954]],194635:[[22294]],194636:[[22022]],194637:[[22295]],194638:[[22097]],194639:[[22132]],194640:[[20999]],194641:[[22766]],194642:[[22478]],194643:[[22516]],194644:[[22541]],194645:[[22411]],194646:[[22578]],194647:[[22577]],194648:[[22700]],194649:[[136420]],194650:[[22770]],194651:[[22775]],194652:[[22790]],194653:[[22810]],194654:[[22818]],194655:[[22882]],194656:[[136872]],194657:[[136938]],194658:[[23020]],194659:[[23067]],194660:[[23079]],194661:[[23000]],194662:[[23142]],194663:[[14062]],194664:[[14076]],194665:[[23304]],194666:[[23358]],194667:[[23358]],194668:[[137672]],194669:[[23491]],194670:[[23512]],194671:[[23527]],194672:[[23539]],194673:[[138008]],194674:[[23551]],194675:[[23558]],194676:[[24403]],194677:[[23586]],194678:[[14209]],194679:[[23648]],194680:[[23662]],194681:[[23744]],194682:[[23693]],194683:[[138724]],194684:[[23875]],194685:[[138726]],194686:[[23918]],194687:[[23915]],194688:[[23932]],194689:[[24033]],194690:[[24034]],194691:[[14383]],194692:[[24061]],194693:[[24104]],194694:[[24125]],194695:[[24169]],194696:[[14434]],194697:[[139651]],194698:[[14460]],194699:[[24240]],194700:[[24243]],194701:[[24246]],194702:[[24266]],194703:[[172946]],194704:[[24318]],194705:[[140081]],194706:[[140081]],194707:[[33281]],194708:[[24354]],194709:[[24354]],194710:[[14535]],194711:[[144056]],194712:[[156122]],194713:[[24418]],194714:[[24427]],194715:[[14563]],194716:[[24474]],194717:[[24525]],194718:[[24535]],194719:[[24569]],194720:[[24705]],194721:[[14650]],194722:[[14620]],194723:[[24724]],194724:[[141012]],194725:[[24775]],194726:[[24904]],194727:[[24908]],194728:[[24910]],194729:[[24908]],194730:[[24954]],194731:[[24974]],194732:[[25010]],194733:[[24996]],194734:[[25007]],194735:[[25054]],194736:[[25074]],194737:[[25078]],194738:[[25104]],194739:[[25115]],194740:[[25181]],194741:[[25265]],194742:[[25300]],194743:[[25424]],194744:[[142092]],194745:[[25405]],194746:[[25340]],194747:[[25448]],194748:[[25475]],194749:[[25572]],194750:[[142321]],194751:[[25634]],194752:[[25541]],194753:[[25513]],194754:[[14894]],194755:[[25705]],194756:[[25726]],194757:[[25757]],194758:[[25719]],194759:[[14956]],194760:[[25935]],194761:[[25964]],194762:[[143370]],194763:[[26083]],194764:[[26360]],194765:[[26185]],194766:[[15129]],194767:[[26257]],194768:[[15112]],194769:[[15076]],194770:[[20882]],194771:[[20885]],194772:[[26368]],194773:[[26268]],194774:[[32941]],194775:[[17369]],194776:[[26391]],194777:[[26395]],194778:[[26401]],194779:[[26462]],194780:[[26451]],194781:[[144323]],194782:[[15177]],194783:[[26618]],194784:[[26501]],194785:[[26706]],194786:[[26757]],194787:[[144493]],194788:[[26766]],194789:[[26655]],194790:[[26900]],194791:[[15261]],194792:[[26946]],194793:[[27043]],194794:[[27114]],194795:[[27304]],194796:[[145059]],194797:[[27355]],194798:[[15384]],194799:[[27425]],194800:[[145575]],194801:[[27476]],194802:[[15438]],194803:[[27506]],194804:[[27551]],194805:[[27578]],194806:[[27579]],194807:[[146061]],194808:[[138507]],194809:[[146170]],194810:[[27726]],194811:[[146620]],194812:[[27839]],194813:[[27853]],194814:[[27751]],194815:[[27926]]}, +63744:{63744:[[35912]],63745:[[26356]],63746:[[36554]],63747:[[36040]],63748:[[28369]],63749:[[20018]],63750:[[21477]],63751:[[40860]],63752:[[40860]],63753:[[22865]],63754:[[37329]],63755:[[21895]],63756:[[22856]],63757:[[25078]],63758:[[30313]],63759:[[32645]],63760:[[34367]],63761:[[34746]],63762:[[35064]],63763:[[37007]],63764:[[27138]],63765:[[27931]],63766:[[28889]],63767:[[29662]],63768:[[33853]],63769:[[37226]],63770:[[39409]],63771:[[20098]],63772:[[21365]],63773:[[27396]],63774:[[29211]],63775:[[34349]],63776:[[40478]],63777:[[23888]],63778:[[28651]],63779:[[34253]],63780:[[35172]],63781:[[25289]],63782:[[33240]],63783:[[34847]],63784:[[24266]],63785:[[26391]],63786:[[28010]],63787:[[29436]],63788:[[37070]],63789:[[20358]],63790:[[20919]],63791:[[21214]],63792:[[25796]],63793:[[27347]],63794:[[29200]],63795:[[30439]],63796:[[32769]],63797:[[34310]],63798:[[34396]],63799:[[36335]],63800:[[38706]],63801:[[39791]],63802:[[40442]],63803:[[30860]],63804:[[31103]],63805:[[32160]],63806:[[33737]],63807:[[37636]],63808:[[40575]],63809:[[35542]],63810:[[22751]],63811:[[24324]],63812:[[31840]],63813:[[32894]],63814:[[29282]],63815:[[30922]],63816:[[36034]],63817:[[38647]],63818:[[22744]],63819:[[23650]],63820:[[27155]],63821:[[28122]],63822:[[28431]],63823:[[32047]],63824:[[32311]],63825:[[38475]],63826:[[21202]],63827:[[32907]],63828:[[20956]],63829:[[20940]],63830:[[31260]],63831:[[32190]],63832:[[33777]],63833:[[38517]],63834:[[35712]],63835:[[25295]],63836:[[27138]],63837:[[35582]],63838:[[20025]],63839:[[23527]],63840:[[24594]],63841:[[29575]],63842:[[30064]],63843:[[21271]],63844:[[30971]],63845:[[20415]],63846:[[24489]],63847:[[19981]],63848:[[27852]],63849:[[25976]],63850:[[32034]],63851:[[21443]],63852:[[22622]],63853:[[30465]],63854:[[33865]],63855:[[35498]],63856:[[27578]],63857:[[36784]],63858:[[27784]],63859:[[25342]],63860:[[33509]],63861:[[25504]],63862:[[30053]],63863:[[20142]],63864:[[20841]],63865:[[20937]],63866:[[26753]],63867:[[31975]],63868:[[33391]],63869:[[35538]],63870:[[37327]],63871:[[21237]],63872:[[21570]],63873:[[22899]],63874:[[24300]],63875:[[26053]],63876:[[28670]],63877:[[31018]],63878:[[38317]],63879:[[39530]],63880:[[40599]],63881:[[40654]],63882:[[21147]],63883:[[26310]],63884:[[27511]],63885:[[36706]],63886:[[24180]],63887:[[24976]],63888:[[25088]],63889:[[25754]],63890:[[28451]],63891:[[29001]],63892:[[29833]],63893:[[31178]],63894:[[32244]],63895:[[32879]],63896:[[36646]],63897:[[34030]],63898:[[36899]],63899:[[37706]],63900:[[21015]],63901:[[21155]],63902:[[21693]],63903:[[28872]],63904:[[35010]],63905:[[35498]],63906:[[24265]],63907:[[24565]],63908:[[25467]],63909:[[27566]],63910:[[31806]],63911:[[29557]],63912:[[20196]],63913:[[22265]],63914:[[23527]],63915:[[23994]],63916:[[24604]],63917:[[29618]],63918:[[29801]],63919:[[32666]],63920:[[32838]],63921:[[37428]],63922:[[38646]],63923:[[38728]],63924:[[38936]],63925:[[20363]],63926:[[31150]],63927:[[37300]],63928:[[38584]],63929:[[24801]],63930:[[20102]],63931:[[20698]],63932:[[23534]],63933:[[23615]],63934:[[26009]],63935:[[27138]],63936:[[29134]],63937:[[30274]],63938:[[34044]],63939:[[36988]],63940:[[40845]],63941:[[26248]],63942:[[38446]],63943:[[21129]],63944:[[26491]],63945:[[26611]],63946:[[27969]],63947:[[28316]],63948:[[29705]],63949:[[30041]],63950:[[30827]],63951:[[32016]],63952:[[39006]],63953:[[20845]],63954:[[25134]],63955:[[38520]],63956:[[20523]],63957:[[23833]],63958:[[28138]],63959:[[36650]],63960:[[24459]],63961:[[24900]],63962:[[26647]],63963:[[29575]],63964:[[38534]],63965:[[21033]],63966:[[21519]],63967:[[23653]],63968:[[26131]],63969:[[26446]],63970:[[26792]],63971:[[27877]],63972:[[29702]],63973:[[30178]],63974:[[32633]],63975:[[35023]],63976:[[35041]],63977:[[37324]],63978:[[38626]],63979:[[21311]],63980:[[28346]],63981:[[21533]],63982:[[29136]],63983:[[29848]],63984:[[34298]],63985:[[38563]],63986:[[40023]],63987:[[40607]],63988:[[26519]],63989:[[28107]],63990:[[33256]],63991:[[31435]],63992:[[31520]],63993:[[31890]],63994:[[29376]],63995:[[28825]],63996:[[35672]],63997:[[20160]],63998:[[33590]],63999:[[21050]],194816:[[27966]],194817:[[28023]],194818:[[27969]],194819:[[28009]],194820:[[28024]],194821:[[28037]],194822:[[146718]],194823:[[27956]],194824:[[28207]],194825:[[28270]],194826:[[15667]],194827:[[28363]],194828:[[28359]],194829:[[147153]],194830:[[28153]],194831:[[28526]],194832:[[147294]],194833:[[147342]],194834:[[28614]],194835:[[28729]],194836:[[28702]],194837:[[28699]],194838:[[15766]],194839:[[28746]],194840:[[28797]],194841:[[28791]],194842:[[28845]],194843:[[132389]],194844:[[28997]],194845:[[148067]],194846:[[29084]],194847:[[148395]],194848:[[29224]],194849:[[29237]],194850:[[29264]],194851:[[149000]],194852:[[29312]],194853:[[29333]],194854:[[149301]],194855:[[149524]],194856:[[29562]],194857:[[29579]],194858:[[16044]],194859:[[29605]],194860:[[16056]],194861:[[16056]],194862:[[29767]],194863:[[29788]],194864:[[29809]],194865:[[29829]],194866:[[29898]],194867:[[16155]],194868:[[29988]],194869:[[150582]],194870:[[30014]],194871:[[150674]],194872:[[30064]],194873:[[139679]],194874:[[30224]],194875:[[151457]],194876:[[151480]],194877:[[151620]],194878:[[16380]],194879:[[16392]],194880:[[30452]],194881:[[151795]],194882:[[151794]],194883:[[151833]],194884:[[151859]],194885:[[30494]],194886:[[30495]],194887:[[30495]],194888:[[30538]],194889:[[16441]],194890:[[30603]],194891:[[16454]],194892:[[16534]],194893:[[152605]],194894:[[30798]],194895:[[30860]],194896:[[30924]],194897:[[16611]],194898:[[153126]],194899:[[31062]],194900:[[153242]],194901:[[153285]],194902:[[31119]],194903:[[31211]],194904:[[16687]],194905:[[31296]],194906:[[31306]],194907:[[31311]],194908:[[153980]],194909:[[154279]],194910:[[154279]],194911:[[31470]],194912:[[16898]],194913:[[154539]],194914:[[31686]],194915:[[31689]],194916:[[16935]],194917:[[154752]],194918:[[31954]],194919:[[17056]],194920:[[31976]],194921:[[31971]],194922:[[32000]],194923:[[155526]],194924:[[32099]],194925:[[17153]],194926:[[32199]],194927:[[32258]],194928:[[32325]],194929:[[17204]],194930:[[156200]],194931:[[156231]],194932:[[17241]],194933:[[156377]],194934:[[32634]],194935:[[156478]],194936:[[32661]],194937:[[32762]],194938:[[32773]],194939:[[156890]],194940:[[156963]],194941:[[32864]],194942:[[157096]],194943:[[32880]],194944:[[144223]],194945:[[17365]],194946:[[32946]],194947:[[33027]],194948:[[17419]],194949:[[33086]],194950:[[23221]],194951:[[157607]],194952:[[157621]],194953:[[144275]],194954:[[144284]],194955:[[33281]],194956:[[33284]],194957:[[36766]],194958:[[17515]],194959:[[33425]],194960:[[33419]],194961:[[33437]],194962:[[21171]],194963:[[33457]],194964:[[33459]],194965:[[33469]],194966:[[33510]],194967:[[158524]],194968:[[33509]],194969:[[33565]],194970:[[33635]],194971:[[33709]],194972:[[33571]],194973:[[33725]],194974:[[33767]],194975:[[33879]],194976:[[33619]],194977:[[33738]],194978:[[33740]],194979:[[33756]],194980:[[158774]],194981:[[159083]],194982:[[158933]],194983:[[17707]],194984:[[34033]],194985:[[34035]],194986:[[34070]],194987:[[160714]],194988:[[34148]],194989:[[159532]],194990:[[17757]],194991:[[17761]],194992:[[159665]],194993:[[159954]],194994:[[17771]],194995:[[34384]],194996:[[34396]],194997:[[34407]],194998:[[34409]],194999:[[34473]],195000:[[34440]],195001:[[34574]],195002:[[34530]],195003:[[34681]],195004:[[34600]],195005:[[34667]],195006:[[34694]],195007:[[17879]],195008:[[34785]],195009:[[34817]],195010:[[17913]],195011:[[34912]],195012:[[34915]],195013:[[161383]],195014:[[35031]],195015:[[35038]],195016:[[17973]],195017:[[35066]],195018:[[13499]],195019:[[161966]],195020:[[162150]],195021:[[18110]],195022:[[18119]],195023:[[35488]],195024:[[35565]],195025:[[35722]],195026:[[35925]],195027:[[162984]],195028:[[36011]],195029:[[36033]],195030:[[36123]],195031:[[36215]],195032:[[163631]],195033:[[133124]],195034:[[36299]],195035:[[36284]],195036:[[36336]],195037:[[133342]],195038:[[36564]],195039:[[36664]],195040:[[165330]],195041:[[165357]],195042:[[37012]],195043:[[37105]],195044:[[37137]],195045:[[165678]],195046:[[37147]],195047:[[37432]],195048:[[37591]],195049:[[37592]],195050:[[37500]],195051:[[37881]],195052:[[37909]],195053:[[166906]],195054:[[38283]],195055:[[18837]],195056:[[38327]],195057:[[167287]],195058:[[18918]],195059:[[38595]],195060:[[23986]],195061:[[38691]],195062:[[168261]],195063:[[168474]],195064:[[19054]],195065:[[19062]],195066:[[38880]],195067:[[168970]],195068:[[19122]],195069:[[169110]],195070:[[38923]],195071:[[38923]]}, +64000:{64000:[[20999]],64001:[[24230]],64002:[[25299]],64003:[[31958]],64004:[[23429]],64005:[[27934]],64006:[[26292]],64007:[[36667]],64008:[[34892]],64009:[[38477]],64010:[[35211]],64011:[[24275]],64012:[[20800]],64013:[[21952]],64016:[[22618]],64018:[[26228]],64021:[[20958]],64022:[[29482]],64023:[[30410]],64024:[[31036]],64025:[[31070]],64026:[[31077]],64027:[[31119]],64028:[[38742]],64029:[[31934]],64030:[[32701]],64032:[[34322]],64034:[[35576]],64037:[[36920]],64038:[[37117]],64042:[[39151]],64043:[[39164]],64044:[[39208]],64045:[[40372]],64046:[[37086]],64047:[[38583]],64048:[[20398]],64049:[[20711]],64050:[[20813]],64051:[[21193]],64052:[[21220]],64053:[[21329]],64054:[[21917]],64055:[[22022]],64056:[[22120]],64057:[[22592]],64058:[[22696]],64059:[[23652]],64060:[[23662]],64061:[[24724]],64062:[[24936]],64063:[[24974]],64064:[[25074]],64065:[[25935]],64066:[[26082]],64067:[[26257]],64068:[[26757]],64069:[[28023]],64070:[[28186]],64071:[[28450]],64072:[[29038]],64073:[[29227]],64074:[[29730]],64075:[[30865]],64076:[[31038]],64077:[[31049]],64078:[[31048]],64079:[[31056]],64080:[[31062]],64081:[[31069]],64082:[[31117]],64083:[[31118]],64084:[[31296]],64085:[[31361]],64086:[[31680]],64087:[[32244]],64088:[[32265]],64089:[[32321]],64090:[[32626]],64091:[[32773]],64092:[[33261]],64093:[[33401]],64094:[[33401]],64095:[[33879]],64096:[[35088]],64097:[[35222]],64098:[[35585]],64099:[[35641]],64100:[[36051]],64101:[[36104]],64102:[[36790]],64103:[[36920]],64104:[[38627]],64105:[[38911]],64106:[[38971]],64107:[[24693]],64108:[[148206]],64109:[[33304]],64112:[[20006]],64113:[[20917]],64114:[[20840]],64115:[[20352]],64116:[[20805]],64117:[[20864]],64118:[[21191]],64119:[[21242]],64120:[[21917]],64121:[[21845]],64122:[[21913]],64123:[[21986]],64124:[[22618]],64125:[[22707]],64126:[[22852]],64127:[[22868]],64128:[[23138]],64129:[[23336]],64130:[[24274]],64131:[[24281]],64132:[[24425]],64133:[[24493]],64134:[[24792]],64135:[[24910]],64136:[[24840]],64137:[[24974]],64138:[[24928]],64139:[[25074]],64140:[[25140]],64141:[[25540]],64142:[[25628]],64143:[[25682]],64144:[[25942]],64145:[[26228]],64146:[[26391]],64147:[[26395]],64148:[[26454]],64149:[[27513]],64150:[[27578]],64151:[[27969]],64152:[[28379]],64153:[[28363]],64154:[[28450]],64155:[[28702]],64156:[[29038]],64157:[[30631]],64158:[[29237]],64159:[[29359]],64160:[[29482]],64161:[[29809]],64162:[[29958]],64163:[[30011]],64164:[[30237]],64165:[[30239]],64166:[[30410]],64167:[[30427]],64168:[[30452]],64169:[[30538]],64170:[[30528]],64171:[[30924]],64172:[[31409]],64173:[[31680]],64174:[[31867]],64175:[[32091]],64176:[[32244]],64177:[[32574]],64178:[[32773]],64179:[[33618]],64180:[[33775]],64181:[[34681]],64182:[[35137]],64183:[[35206]],64184:[[35222]],64185:[[35519]],64186:[[35576]],64187:[[35531]],64188:[[35585]],64189:[[35582]],64190:[[35565]],64191:[[35641]],64192:[[35722]],64193:[[36104]],64194:[[36664]],64195:[[36978]],64196:[[37273]],64197:[[37494]],64198:[[38524]],64199:[[38627]],64200:[[38742]],64201:[[38875]],64202:[[38911]],64203:[[38923]],64204:[[38971]],64205:[[39698]],64206:[[40860]],64207:[[141386]],64208:[[141380]],64209:[[144341]],64210:[[15261]],64211:[[16408]],64212:[[16441]],64213:[[152137]],64214:[[154832]],64215:[[163539]],64216:[[40771]],64217:[[40846]],195072:[[38953]],195073:[[169398]],195074:[[39138]],195075:[[19251]],195076:[[39209]],195077:[[39335]],195078:[[39362]],195079:[[39422]],195080:[[19406]],195081:[[170800]],195082:[[39698]],195083:[[40000]],195084:[[40189]],195085:[[19662]],195086:[[19693]],195087:[[40295]],195088:[[172238]],195089:[[19704]],195090:[[172293]],195091:[[172558]],195092:[[172689]],195093:[[40635]],195094:[[19798]],195095:[[40697]],195096:[[40702]],195097:[[40709]],195098:[[40719]],195099:[[40726]],195100:[[40763]],195101:[[173568]]}, +64256:{64256:[[102,102],256],64257:[[102,105],256],64258:[[102,108],256],64259:[[102,102,105],256],64260:[[102,102,108],256],64261:[[383,116],256],64262:[[115,116],256],64275:[[1396,1398],256],64276:[[1396,1381],256],64277:[[1396,1387],256],64278:[[1406,1398],256],64279:[[1396,1389],256],64285:[[1497,1460],512],64286:[,26],64287:[[1522,1463],512],64288:[[1506],256],64289:[[1488],256],64290:[[1491],256],64291:[[1492],256],64292:[[1499],256],64293:[[1500],256],64294:[[1501],256],64295:[[1512],256],64296:[[1514],256],64297:[[43],256],64298:[[1513,1473],512],64299:[[1513,1474],512],64300:[[64329,1473],512],64301:[[64329,1474],512],64302:[[1488,1463],512],64303:[[1488,1464],512],64304:[[1488,1468],512],64305:[[1489,1468],512],64306:[[1490,1468],512],64307:[[1491,1468],512],64308:[[1492,1468],512],64309:[[1493,1468],512],64310:[[1494,1468],512],64312:[[1496,1468],512],64313:[[1497,1468],512],64314:[[1498,1468],512],64315:[[1499,1468],512],64316:[[1500,1468],512],64318:[[1502,1468],512],64320:[[1504,1468],512],64321:[[1505,1468],512],64323:[[1507,1468],512],64324:[[1508,1468],512],64326:[[1510,1468],512],64327:[[1511,1468],512],64328:[[1512,1468],512],64329:[[1513,1468],512],64330:[[1514,1468],512],64331:[[1493,1465],512],64332:[[1489,1471],512],64333:[[1499,1471],512],64334:[[1508,1471],512],64335:[[1488,1500],256],64336:[[1649],256],64337:[[1649],256],64338:[[1659],256],64339:[[1659],256],64340:[[1659],256],64341:[[1659],256],64342:[[1662],256],64343:[[1662],256],64344:[[1662],256],64345:[[1662],256],64346:[[1664],256],64347:[[1664],256],64348:[[1664],256],64349:[[1664],256],64350:[[1658],256],64351:[[1658],256],64352:[[1658],256],64353:[[1658],256],64354:[[1663],256],64355:[[1663],256],64356:[[1663],256],64357:[[1663],256],64358:[[1657],256],64359:[[1657],256],64360:[[1657],256],64361:[[1657],256],64362:[[1700],256],64363:[[1700],256],64364:[[1700],256],64365:[[1700],256],64366:[[1702],256],64367:[[1702],256],64368:[[1702],256],64369:[[1702],256],64370:[[1668],256],64371:[[1668],256],64372:[[1668],256],64373:[[1668],256],64374:[[1667],256],64375:[[1667],256],64376:[[1667],256],64377:[[1667],256],64378:[[1670],256],64379:[[1670],256],64380:[[1670],256],64381:[[1670],256],64382:[[1671],256],64383:[[1671],256],64384:[[1671],256],64385:[[1671],256],64386:[[1677],256],64387:[[1677],256],64388:[[1676],256],64389:[[1676],256],64390:[[1678],256],64391:[[1678],256],64392:[[1672],256],64393:[[1672],256],64394:[[1688],256],64395:[[1688],256],64396:[[1681],256],64397:[[1681],256],64398:[[1705],256],64399:[[1705],256],64400:[[1705],256],64401:[[1705],256],64402:[[1711],256],64403:[[1711],256],64404:[[1711],256],64405:[[1711],256],64406:[[1715],256],64407:[[1715],256],64408:[[1715],256],64409:[[1715],256],64410:[[1713],256],64411:[[1713],256],64412:[[1713],256],64413:[[1713],256],64414:[[1722],256],64415:[[1722],256],64416:[[1723],256],64417:[[1723],256],64418:[[1723],256],64419:[[1723],256],64420:[[1728],256],64421:[[1728],256],64422:[[1729],256],64423:[[1729],256],64424:[[1729],256],64425:[[1729],256],64426:[[1726],256],64427:[[1726],256],64428:[[1726],256],64429:[[1726],256],64430:[[1746],256],64431:[[1746],256],64432:[[1747],256],64433:[[1747],256],64467:[[1709],256],64468:[[1709],256],64469:[[1709],256],64470:[[1709],256],64471:[[1735],256],64472:[[1735],256],64473:[[1734],256],64474:[[1734],256],64475:[[1736],256],64476:[[1736],256],64477:[[1655],256],64478:[[1739],256],64479:[[1739],256],64480:[[1733],256],64481:[[1733],256],64482:[[1737],256],64483:[[1737],256],64484:[[1744],256],64485:[[1744],256],64486:[[1744],256],64487:[[1744],256],64488:[[1609],256],64489:[[1609],256],64490:[[1574,1575],256],64491:[[1574,1575],256],64492:[[1574,1749],256],64493:[[1574,1749],256],64494:[[1574,1608],256],64495:[[1574,1608],256],64496:[[1574,1735],256],64497:[[1574,1735],256],64498:[[1574,1734],256],64499:[[1574,1734],256],64500:[[1574,1736],256],64501:[[1574,1736],256],64502:[[1574,1744],256],64503:[[1574,1744],256],64504:[[1574,1744],256],64505:[[1574,1609],256],64506:[[1574,1609],256],64507:[[1574,1609],256],64508:[[1740],256],64509:[[1740],256],64510:[[1740],256],64511:[[1740],256]}, +64512:{64512:[[1574,1580],256],64513:[[1574,1581],256],64514:[[1574,1605],256],64515:[[1574,1609],256],64516:[[1574,1610],256],64517:[[1576,1580],256],64518:[[1576,1581],256],64519:[[1576,1582],256],64520:[[1576,1605],256],64521:[[1576,1609],256],64522:[[1576,1610],256],64523:[[1578,1580],256],64524:[[1578,1581],256],64525:[[1578,1582],256],64526:[[1578,1605],256],64527:[[1578,1609],256],64528:[[1578,1610],256],64529:[[1579,1580],256],64530:[[1579,1605],256],64531:[[1579,1609],256],64532:[[1579,1610],256],64533:[[1580,1581],256],64534:[[1580,1605],256],64535:[[1581,1580],256],64536:[[1581,1605],256],64537:[[1582,1580],256],64538:[[1582,1581],256],64539:[[1582,1605],256],64540:[[1587,1580],256],64541:[[1587,1581],256],64542:[[1587,1582],256],64543:[[1587,1605],256],64544:[[1589,1581],256],64545:[[1589,1605],256],64546:[[1590,1580],256],64547:[[1590,1581],256],64548:[[1590,1582],256],64549:[[1590,1605],256],64550:[[1591,1581],256],64551:[[1591,1605],256],64552:[[1592,1605],256],64553:[[1593,1580],256],64554:[[1593,1605],256],64555:[[1594,1580],256],64556:[[1594,1605],256],64557:[[1601,1580],256],64558:[[1601,1581],256],64559:[[1601,1582],256],64560:[[1601,1605],256],64561:[[1601,1609],256],64562:[[1601,1610],256],64563:[[1602,1581],256],64564:[[1602,1605],256],64565:[[1602,1609],256],64566:[[1602,1610],256],64567:[[1603,1575],256],64568:[[1603,1580],256],64569:[[1603,1581],256],64570:[[1603,1582],256],64571:[[1603,1604],256],64572:[[1603,1605],256],64573:[[1603,1609],256],64574:[[1603,1610],256],64575:[[1604,1580],256],64576:[[1604,1581],256],64577:[[1604,1582],256],64578:[[1604,1605],256],64579:[[1604,1609],256],64580:[[1604,1610],256],64581:[[1605,1580],256],64582:[[1605,1581],256],64583:[[1605,1582],256],64584:[[1605,1605],256],64585:[[1605,1609],256],64586:[[1605,1610],256],64587:[[1606,1580],256],64588:[[1606,1581],256],64589:[[1606,1582],256],64590:[[1606,1605],256],64591:[[1606,1609],256],64592:[[1606,1610],256],64593:[[1607,1580],256],64594:[[1607,1605],256],64595:[[1607,1609],256],64596:[[1607,1610],256],64597:[[1610,1580],256],64598:[[1610,1581],256],64599:[[1610,1582],256],64600:[[1610,1605],256],64601:[[1610,1609],256],64602:[[1610,1610],256],64603:[[1584,1648],256],64604:[[1585,1648],256],64605:[[1609,1648],256],64606:[[32,1612,1617],256],64607:[[32,1613,1617],256],64608:[[32,1614,1617],256],64609:[[32,1615,1617],256],64610:[[32,1616,1617],256],64611:[[32,1617,1648],256],64612:[[1574,1585],256],64613:[[1574,1586],256],64614:[[1574,1605],256],64615:[[1574,1606],256],64616:[[1574,1609],256],64617:[[1574,1610],256],64618:[[1576,1585],256],64619:[[1576,1586],256],64620:[[1576,1605],256],64621:[[1576,1606],256],64622:[[1576,1609],256],64623:[[1576,1610],256],64624:[[1578,1585],256],64625:[[1578,1586],256],64626:[[1578,1605],256],64627:[[1578,1606],256],64628:[[1578,1609],256],64629:[[1578,1610],256],64630:[[1579,1585],256],64631:[[1579,1586],256],64632:[[1579,1605],256],64633:[[1579,1606],256],64634:[[1579,1609],256],64635:[[1579,1610],256],64636:[[1601,1609],256],64637:[[1601,1610],256],64638:[[1602,1609],256],64639:[[1602,1610],256],64640:[[1603,1575],256],64641:[[1603,1604],256],64642:[[1603,1605],256],64643:[[1603,1609],256],64644:[[1603,1610],256],64645:[[1604,1605],256],64646:[[1604,1609],256],64647:[[1604,1610],256],64648:[[1605,1575],256],64649:[[1605,1605],256],64650:[[1606,1585],256],64651:[[1606,1586],256],64652:[[1606,1605],256],64653:[[1606,1606],256],64654:[[1606,1609],256],64655:[[1606,1610],256],64656:[[1609,1648],256],64657:[[1610,1585],256],64658:[[1610,1586],256],64659:[[1610,1605],256],64660:[[1610,1606],256],64661:[[1610,1609],256],64662:[[1610,1610],256],64663:[[1574,1580],256],64664:[[1574,1581],256],64665:[[1574,1582],256],64666:[[1574,1605],256],64667:[[1574,1607],256],64668:[[1576,1580],256],64669:[[1576,1581],256],64670:[[1576,1582],256],64671:[[1576,1605],256],64672:[[1576,1607],256],64673:[[1578,1580],256],64674:[[1578,1581],256],64675:[[1578,1582],256],64676:[[1578,1605],256],64677:[[1578,1607],256],64678:[[1579,1605],256],64679:[[1580,1581],256],64680:[[1580,1605],256],64681:[[1581,1580],256],64682:[[1581,1605],256],64683:[[1582,1580],256],64684:[[1582,1605],256],64685:[[1587,1580],256],64686:[[1587,1581],256],64687:[[1587,1582],256],64688:[[1587,1605],256],64689:[[1589,1581],256],64690:[[1589,1582],256],64691:[[1589,1605],256],64692:[[1590,1580],256],64693:[[1590,1581],256],64694:[[1590,1582],256],64695:[[1590,1605],256],64696:[[1591,1581],256],64697:[[1592,1605],256],64698:[[1593,1580],256],64699:[[1593,1605],256],64700:[[1594,1580],256],64701:[[1594,1605],256],64702:[[1601,1580],256],64703:[[1601,1581],256],64704:[[1601,1582],256],64705:[[1601,1605],256],64706:[[1602,1581],256],64707:[[1602,1605],256],64708:[[1603,1580],256],64709:[[1603,1581],256],64710:[[1603,1582],256],64711:[[1603,1604],256],64712:[[1603,1605],256],64713:[[1604,1580],256],64714:[[1604,1581],256],64715:[[1604,1582],256],64716:[[1604,1605],256],64717:[[1604,1607],256],64718:[[1605,1580],256],64719:[[1605,1581],256],64720:[[1605,1582],256],64721:[[1605,1605],256],64722:[[1606,1580],256],64723:[[1606,1581],256],64724:[[1606,1582],256],64725:[[1606,1605],256],64726:[[1606,1607],256],64727:[[1607,1580],256],64728:[[1607,1605],256],64729:[[1607,1648],256],64730:[[1610,1580],256],64731:[[1610,1581],256],64732:[[1610,1582],256],64733:[[1610,1605],256],64734:[[1610,1607],256],64735:[[1574,1605],256],64736:[[1574,1607],256],64737:[[1576,1605],256],64738:[[1576,1607],256],64739:[[1578,1605],256],64740:[[1578,1607],256],64741:[[1579,1605],256],64742:[[1579,1607],256],64743:[[1587,1605],256],64744:[[1587,1607],256],64745:[[1588,1605],256],64746:[[1588,1607],256],64747:[[1603,1604],256],64748:[[1603,1605],256],64749:[[1604,1605],256],64750:[[1606,1605],256],64751:[[1606,1607],256],64752:[[1610,1605],256],64753:[[1610,1607],256],64754:[[1600,1614,1617],256],64755:[[1600,1615,1617],256],64756:[[1600,1616,1617],256],64757:[[1591,1609],256],64758:[[1591,1610],256],64759:[[1593,1609],256],64760:[[1593,1610],256],64761:[[1594,1609],256],64762:[[1594,1610],256],64763:[[1587,1609],256],64764:[[1587,1610],256],64765:[[1588,1609],256],64766:[[1588,1610],256],64767:[[1581,1609],256]}, +64768:{64768:[[1581,1610],256],64769:[[1580,1609],256],64770:[[1580,1610],256],64771:[[1582,1609],256],64772:[[1582,1610],256],64773:[[1589,1609],256],64774:[[1589,1610],256],64775:[[1590,1609],256],64776:[[1590,1610],256],64777:[[1588,1580],256],64778:[[1588,1581],256],64779:[[1588,1582],256],64780:[[1588,1605],256],64781:[[1588,1585],256],64782:[[1587,1585],256],64783:[[1589,1585],256],64784:[[1590,1585],256],64785:[[1591,1609],256],64786:[[1591,1610],256],64787:[[1593,1609],256],64788:[[1593,1610],256],64789:[[1594,1609],256],64790:[[1594,1610],256],64791:[[1587,1609],256],64792:[[1587,1610],256],64793:[[1588,1609],256],64794:[[1588,1610],256],64795:[[1581,1609],256],64796:[[1581,1610],256],64797:[[1580,1609],256],64798:[[1580,1610],256],64799:[[1582,1609],256],64800:[[1582,1610],256],64801:[[1589,1609],256],64802:[[1589,1610],256],64803:[[1590,1609],256],64804:[[1590,1610],256],64805:[[1588,1580],256],64806:[[1588,1581],256],64807:[[1588,1582],256],64808:[[1588,1605],256],64809:[[1588,1585],256],64810:[[1587,1585],256],64811:[[1589,1585],256],64812:[[1590,1585],256],64813:[[1588,1580],256],64814:[[1588,1581],256],64815:[[1588,1582],256],64816:[[1588,1605],256],64817:[[1587,1607],256],64818:[[1588,1607],256],64819:[[1591,1605],256],64820:[[1587,1580],256],64821:[[1587,1581],256],64822:[[1587,1582],256],64823:[[1588,1580],256],64824:[[1588,1581],256],64825:[[1588,1582],256],64826:[[1591,1605],256],64827:[[1592,1605],256],64828:[[1575,1611],256],64829:[[1575,1611],256],64848:[[1578,1580,1605],256],64849:[[1578,1581,1580],256],64850:[[1578,1581,1580],256],64851:[[1578,1581,1605],256],64852:[[1578,1582,1605],256],64853:[[1578,1605,1580],256],64854:[[1578,1605,1581],256],64855:[[1578,1605,1582],256],64856:[[1580,1605,1581],256],64857:[[1580,1605,1581],256],64858:[[1581,1605,1610],256],64859:[[1581,1605,1609],256],64860:[[1587,1581,1580],256],64861:[[1587,1580,1581],256],64862:[[1587,1580,1609],256],64863:[[1587,1605,1581],256],64864:[[1587,1605,1581],256],64865:[[1587,1605,1580],256],64866:[[1587,1605,1605],256],64867:[[1587,1605,1605],256],64868:[[1589,1581,1581],256],64869:[[1589,1581,1581],256],64870:[[1589,1605,1605],256],64871:[[1588,1581,1605],256],64872:[[1588,1581,1605],256],64873:[[1588,1580,1610],256],64874:[[1588,1605,1582],256],64875:[[1588,1605,1582],256],64876:[[1588,1605,1605],256],64877:[[1588,1605,1605],256],64878:[[1590,1581,1609],256],64879:[[1590,1582,1605],256],64880:[[1590,1582,1605],256],64881:[[1591,1605,1581],256],64882:[[1591,1605,1581],256],64883:[[1591,1605,1605],256],64884:[[1591,1605,1610],256],64885:[[1593,1580,1605],256],64886:[[1593,1605,1605],256],64887:[[1593,1605,1605],256],64888:[[1593,1605,1609],256],64889:[[1594,1605,1605],256],64890:[[1594,1605,1610],256],64891:[[1594,1605,1609],256],64892:[[1601,1582,1605],256],64893:[[1601,1582,1605],256],64894:[[1602,1605,1581],256],64895:[[1602,1605,1605],256],64896:[[1604,1581,1605],256],64897:[[1604,1581,1610],256],64898:[[1604,1581,1609],256],64899:[[1604,1580,1580],256],64900:[[1604,1580,1580],256],64901:[[1604,1582,1605],256],64902:[[1604,1582,1605],256],64903:[[1604,1605,1581],256],64904:[[1604,1605,1581],256],64905:[[1605,1581,1580],256],64906:[[1605,1581,1605],256],64907:[[1605,1581,1610],256],64908:[[1605,1580,1581],256],64909:[[1605,1580,1605],256],64910:[[1605,1582,1580],256],64911:[[1605,1582,1605],256],64914:[[1605,1580,1582],256],64915:[[1607,1605,1580],256],64916:[[1607,1605,1605],256],64917:[[1606,1581,1605],256],64918:[[1606,1581,1609],256],64919:[[1606,1580,1605],256],64920:[[1606,1580,1605],256],64921:[[1606,1580,1609],256],64922:[[1606,1605,1610],256],64923:[[1606,1605,1609],256],64924:[[1610,1605,1605],256],64925:[[1610,1605,1605],256],64926:[[1576,1582,1610],256],64927:[[1578,1580,1610],256],64928:[[1578,1580,1609],256],64929:[[1578,1582,1610],256],64930:[[1578,1582,1609],256],64931:[[1578,1605,1610],256],64932:[[1578,1605,1609],256],64933:[[1580,1605,1610],256],64934:[[1580,1581,1609],256],64935:[[1580,1605,1609],256],64936:[[1587,1582,1609],256],64937:[[1589,1581,1610],256],64938:[[1588,1581,1610],256],64939:[[1590,1581,1610],256],64940:[[1604,1580,1610],256],64941:[[1604,1605,1610],256],64942:[[1610,1581,1610],256],64943:[[1610,1580,1610],256],64944:[[1610,1605,1610],256],64945:[[1605,1605,1610],256],64946:[[1602,1605,1610],256],64947:[[1606,1581,1610],256],64948:[[1602,1605,1581],256],64949:[[1604,1581,1605],256],64950:[[1593,1605,1610],256],64951:[[1603,1605,1610],256],64952:[[1606,1580,1581],256],64953:[[1605,1582,1610],256],64954:[[1604,1580,1605],256],64955:[[1603,1605,1605],256],64956:[[1604,1580,1605],256],64957:[[1606,1580,1581],256],64958:[[1580,1581,1610],256],64959:[[1581,1580,1610],256],64960:[[1605,1580,1610],256],64961:[[1601,1605,1610],256],64962:[[1576,1581,1610],256],64963:[[1603,1605,1605],256],64964:[[1593,1580,1605],256],64965:[[1589,1605,1605],256],64966:[[1587,1582,1610],256],64967:[[1606,1580,1610],256],65008:[[1589,1604,1746],256],65009:[[1602,1604,1746],256],65010:[[1575,1604,1604,1607],256],65011:[[1575,1603,1576,1585],256],65012:[[1605,1581,1605,1583],256],65013:[[1589,1604,1593,1605],256],65014:[[1585,1587,1608,1604],256],65015:[[1593,1604,1610,1607],256],65016:[[1608,1587,1604,1605],256],65017:[[1589,1604,1609],256],65018:[[1589,1604,1609,32,1575,1604,1604,1607,32,1593,1604,1610,1607,32,1608,1587,1604,1605],256],65019:[[1580,1604,32,1580,1604,1575,1604,1607],256],65020:[[1585,1740,1575,1604],256]}, +65024:{65040:[[44],256],65041:[[12289],256],65042:[[12290],256],65043:[[58],256],65044:[[59],256],65045:[[33],256],65046:[[63],256],65047:[[12310],256],65048:[[12311],256],65049:[[8230],256],65056:[,230],65057:[,230],65058:[,230],65059:[,230],65060:[,230],65061:[,230],65062:[,230],65063:[,220],65064:[,220],65065:[,220],65066:[,220],65067:[,220],65068:[,220],65069:[,220],65072:[[8229],256],65073:[[8212],256],65074:[[8211],256],65075:[[95],256],65076:[[95],256],65077:[[40],256],65078:[[41],256],65079:[[123],256],65080:[[125],256],65081:[[12308],256],65082:[[12309],256],65083:[[12304],256],65084:[[12305],256],65085:[[12298],256],65086:[[12299],256],65087:[[12296],256],65088:[[12297],256],65089:[[12300],256],65090:[[12301],256],65091:[[12302],256],65092:[[12303],256],65095:[[91],256],65096:[[93],256],65097:[[8254],256],65098:[[8254],256],65099:[[8254],256],65100:[[8254],256],65101:[[95],256],65102:[[95],256],65103:[[95],256],65104:[[44],256],65105:[[12289],256],65106:[[46],256],65108:[[59],256],65109:[[58],256],65110:[[63],256],65111:[[33],256],65112:[[8212],256],65113:[[40],256],65114:[[41],256],65115:[[123],256],65116:[[125],256],65117:[[12308],256],65118:[[12309],256],65119:[[35],256],65120:[[38],256],65121:[[42],256],65122:[[43],256],65123:[[45],256],65124:[[60],256],65125:[[62],256],65126:[[61],256],65128:[[92],256],65129:[[36],256],65130:[[37],256],65131:[[64],256],65136:[[32,1611],256],65137:[[1600,1611],256],65138:[[32,1612],256],65140:[[32,1613],256],65142:[[32,1614],256],65143:[[1600,1614],256],65144:[[32,1615],256],65145:[[1600,1615],256],65146:[[32,1616],256],65147:[[1600,1616],256],65148:[[32,1617],256],65149:[[1600,1617],256],65150:[[32,1618],256],65151:[[1600,1618],256],65152:[[1569],256],65153:[[1570],256],65154:[[1570],256],65155:[[1571],256],65156:[[1571],256],65157:[[1572],256],65158:[[1572],256],65159:[[1573],256],65160:[[1573],256],65161:[[1574],256],65162:[[1574],256],65163:[[1574],256],65164:[[1574],256],65165:[[1575],256],65166:[[1575],256],65167:[[1576],256],65168:[[1576],256],65169:[[1576],256],65170:[[1576],256],65171:[[1577],256],65172:[[1577],256],65173:[[1578],256],65174:[[1578],256],65175:[[1578],256],65176:[[1578],256],65177:[[1579],256],65178:[[1579],256],65179:[[1579],256],65180:[[1579],256],65181:[[1580],256],65182:[[1580],256],65183:[[1580],256],65184:[[1580],256],65185:[[1581],256],65186:[[1581],256],65187:[[1581],256],65188:[[1581],256],65189:[[1582],256],65190:[[1582],256],65191:[[1582],256],65192:[[1582],256],65193:[[1583],256],65194:[[1583],256],65195:[[1584],256],65196:[[1584],256],65197:[[1585],256],65198:[[1585],256],65199:[[1586],256],65200:[[1586],256],65201:[[1587],256],65202:[[1587],256],65203:[[1587],256],65204:[[1587],256],65205:[[1588],256],65206:[[1588],256],65207:[[1588],256],65208:[[1588],256],65209:[[1589],256],65210:[[1589],256],65211:[[1589],256],65212:[[1589],256],65213:[[1590],256],65214:[[1590],256],65215:[[1590],256],65216:[[1590],256],65217:[[1591],256],65218:[[1591],256],65219:[[1591],256],65220:[[1591],256],65221:[[1592],256],65222:[[1592],256],65223:[[1592],256],65224:[[1592],256],65225:[[1593],256],65226:[[1593],256],65227:[[1593],256],65228:[[1593],256],65229:[[1594],256],65230:[[1594],256],65231:[[1594],256],65232:[[1594],256],65233:[[1601],256],65234:[[1601],256],65235:[[1601],256],65236:[[1601],256],65237:[[1602],256],65238:[[1602],256],65239:[[1602],256],65240:[[1602],256],65241:[[1603],256],65242:[[1603],256],65243:[[1603],256],65244:[[1603],256],65245:[[1604],256],65246:[[1604],256],65247:[[1604],256],65248:[[1604],256],65249:[[1605],256],65250:[[1605],256],65251:[[1605],256],65252:[[1605],256],65253:[[1606],256],65254:[[1606],256],65255:[[1606],256],65256:[[1606],256],65257:[[1607],256],65258:[[1607],256],65259:[[1607],256],65260:[[1607],256],65261:[[1608],256],65262:[[1608],256],65263:[[1609],256],65264:[[1609],256],65265:[[1610],256],65266:[[1610],256],65267:[[1610],256],65268:[[1610],256],65269:[[1604,1570],256],65270:[[1604,1570],256],65271:[[1604,1571],256],65272:[[1604,1571],256],65273:[[1604,1573],256],65274:[[1604,1573],256],65275:[[1604,1575],256],65276:[[1604,1575],256]}, +65280:{65281:[[33],256],65282:[[34],256],65283:[[35],256],65284:[[36],256],65285:[[37],256],65286:[[38],256],65287:[[39],256],65288:[[40],256],65289:[[41],256],65290:[[42],256],65291:[[43],256],65292:[[44],256],65293:[[45],256],65294:[[46],256],65295:[[47],256],65296:[[48],256],65297:[[49],256],65298:[[50],256],65299:[[51],256],65300:[[52],256],65301:[[53],256],65302:[[54],256],65303:[[55],256],65304:[[56],256],65305:[[57],256],65306:[[58],256],65307:[[59],256],65308:[[60],256],65309:[[61],256],65310:[[62],256],65311:[[63],256],65312:[[64],256],65313:[[65],256],65314:[[66],256],65315:[[67],256],65316:[[68],256],65317:[[69],256],65318:[[70],256],65319:[[71],256],65320:[[72],256],65321:[[73],256],65322:[[74],256],65323:[[75],256],65324:[[76],256],65325:[[77],256],65326:[[78],256],65327:[[79],256],65328:[[80],256],65329:[[81],256],65330:[[82],256],65331:[[83],256],65332:[[84],256],65333:[[85],256],65334:[[86],256],65335:[[87],256],65336:[[88],256],65337:[[89],256],65338:[[90],256],65339:[[91],256],65340:[[92],256],65341:[[93],256],65342:[[94],256],65343:[[95],256],65344:[[96],256],65345:[[97],256],65346:[[98],256],65347:[[99],256],65348:[[100],256],65349:[[101],256],65350:[[102],256],65351:[[103],256],65352:[[104],256],65353:[[105],256],65354:[[106],256],65355:[[107],256],65356:[[108],256],65357:[[109],256],65358:[[110],256],65359:[[111],256],65360:[[112],256],65361:[[113],256],65362:[[114],256],65363:[[115],256],65364:[[116],256],65365:[[117],256],65366:[[118],256],65367:[[119],256],65368:[[120],256],65369:[[121],256],65370:[[122],256],65371:[[123],256],65372:[[124],256],65373:[[125],256],65374:[[126],256],65375:[[10629],256],65376:[[10630],256],65377:[[12290],256],65378:[[12300],256],65379:[[12301],256],65380:[[12289],256],65381:[[12539],256],65382:[[12530],256],65383:[[12449],256],65384:[[12451],256],65385:[[12453],256],65386:[[12455],256],65387:[[12457],256],65388:[[12515],256],65389:[[12517],256],65390:[[12519],256],65391:[[12483],256],65392:[[12540],256],65393:[[12450],256],65394:[[12452],256],65395:[[12454],256],65396:[[12456],256],65397:[[12458],256],65398:[[12459],256],65399:[[12461],256],65400:[[12463],256],65401:[[12465],256],65402:[[12467],256],65403:[[12469],256],65404:[[12471],256],65405:[[12473],256],65406:[[12475],256],65407:[[12477],256],65408:[[12479],256],65409:[[12481],256],65410:[[12484],256],65411:[[12486],256],65412:[[12488],256],65413:[[12490],256],65414:[[12491],256],65415:[[12492],256],65416:[[12493],256],65417:[[12494],256],65418:[[12495],256],65419:[[12498],256],65420:[[12501],256],65421:[[12504],256],65422:[[12507],256],65423:[[12510],256],65424:[[12511],256],65425:[[12512],256],65426:[[12513],256],65427:[[12514],256],65428:[[12516],256],65429:[[12518],256],65430:[[12520],256],65431:[[12521],256],65432:[[12522],256],65433:[[12523],256],65434:[[12524],256],65435:[[12525],256],65436:[[12527],256],65437:[[12531],256],65438:[[12441],256],65439:[[12442],256],65440:[[12644],256],65441:[[12593],256],65442:[[12594],256],65443:[[12595],256],65444:[[12596],256],65445:[[12597],256],65446:[[12598],256],65447:[[12599],256],65448:[[12600],256],65449:[[12601],256],65450:[[12602],256],65451:[[12603],256],65452:[[12604],256],65453:[[12605],256],65454:[[12606],256],65455:[[12607],256],65456:[[12608],256],65457:[[12609],256],65458:[[12610],256],65459:[[12611],256],65460:[[12612],256],65461:[[12613],256],65462:[[12614],256],65463:[[12615],256],65464:[[12616],256],65465:[[12617],256],65466:[[12618],256],65467:[[12619],256],65468:[[12620],256],65469:[[12621],256],65470:[[12622],256],65474:[[12623],256],65475:[[12624],256],65476:[[12625],256],65477:[[12626],256],65478:[[12627],256],65479:[[12628],256],65482:[[12629],256],65483:[[12630],256],65484:[[12631],256],65485:[[12632],256],65486:[[12633],256],65487:[[12634],256],65490:[[12635],256],65491:[[12636],256],65492:[[12637],256],65493:[[12638],256],65494:[[12639],256],65495:[[12640],256],65498:[[12641],256],65499:[[12642],256],65500:[[12643],256],65504:[[162],256],65505:[[163],256],65506:[[172],256],65507:[[175],256],65508:[[166],256],65509:[[165],256],65510:[[8361],256],65512:[[9474],256],65513:[[8592],256],65514:[[8593],256],65515:[[8594],256],65516:[[8595],256],65517:[[9632],256],65518:[[9675],256]} + +}; + + /***** Module to export */ + var unorm = { + nfc: nfc, + nfd: nfd, + nfkc: nfkc, + nfkd: nfkd + }; + + /*globals module:true,define:true*/ + + // CommonJS + if (typeof module === "object") { + module.exports = unorm; + + // AMD + } else if (typeof define === "function" && define.amd) { + define("unorm", function () { + return unorm; + }); + + // Global + } else { + root.unorm = unorm; + } + + /***** Export as shim for String::normalize method *****/ + /* + http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#november_8_2013_draft_rev_21 + + 21.1.3.12 String.prototype.normalize(form="NFC") + When the normalize method is called with one argument form, the following steps are taken: + + 1. Let O be CheckObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. If form is not provided or undefined let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw a RangeError Exception. + 8. Let ns be the String value is the result of normalizing S into the normalization form named by f as specified in Unicode Standard Annex #15, UnicodeNormalizatoin Forms. + 9. Return ns. + + The length property of the normalize method is 0. + + *NOTE* The normalize function is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method. + */ + unorm.shimApplied = false; + + if (!String.prototype.normalize) { + String.prototype.normalize = function(form) { + var str = "" + this; + form = form === undefined ? "NFC" : form; + + if (form === "NFC") { + return unorm.nfc(str); + } else if (form === "NFD") { + return unorm.nfd(str); + } else if (form === "NFKC") { + return unorm.nfkc(str); + } else if (form === "NFKD") { + return unorm.nfkd(str); + } else { + throw new RangeError("Invalid normalization form: " + form); + } + }; + + unorm.shimApplied = true; + } +}(this)); + +},{}]},{},[4]); diff --git a/packages/shims/dist/index.min.js b/packages/shims/dist/index.min.js new file mode 100644 index 000000000..23b011f53 --- /dev/null +++ b/packages/shims/dist/index.min.js @@ -0,0 +1 @@ +!function(){return function t(r,e,n){function o(s,u){if(!e[s]){if(!r[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=e[s]={exports:{}};r[s][0].call(c.exports,function(t){return o(r[s][1][t]||t)},c,c.exports,t,r,e,n)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s1)for(var e=1;e255||(o=t.charCodeAt(u++))>255||(i=t.charCodeAt(u++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=n.charAt((r=e<<16|o<<8|i)>>18&63)+n.charAt(r>>12&63)+n.charAt(r>>6&63)+n.charAt(63&r)}return a?s.slice(0,a-3)+"===".substring(a):s},t.atob=function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!o.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");t+="==".slice(2-(3&t.length));for(var r,e,i,s="",u=0;u>16&255):64===i?String.fromCharCode(r>>16&255,r>>8&255):String.fromCharCode(r>>16&255,r>>8&255,255&r);return s}}},"function"==typeof define&&define.amd?define([],function(){o(n)}):o(n)},{}],3:[function(t,r,e){(function(n,o){!function(t,n){"object"==typeof e&&void 0!==r?r.exports=n():"function"==typeof define&&define.amd?define(n):t.ES6Promise=n()}(this,function(){"use strict";function r(t){return"function"==typeof t}var e=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,s=void 0,u=void 0,a=function(t,r){v[i]=t,v[i+1]=r,2===(i+=2)&&(u?u(g):_())};var f="undefined"!=typeof window?window:void 0,c=f||{},h=c.MutationObserver||c.WebKitMutationObserver,l="undefined"==typeof self&&void 0!==n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var v=new Array(1e3);function g(){for(var t=0;t>8&255]>n&&(d[r]=o),o},function(t,r,e){return e?t(r,e):new p(r,null)},function(t,r,e){var n;if(r=55296&&t<=56319},p.isLowSurrogate=function(t){return t>=56320&&t<=57343},p.prototype.prepFeature=function(){this.feature||(this.feature=p.fromCharCode(this.codepoint,!0).feature)},p.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},p.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},p.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},p.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},p.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},p.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var r=this.feature[2][t.codepoint];return r?p.fromCharCode(r):null};var w=function(t){this.str=t,this.cursor=0};w.prototype.next=function(){if(this.str&&this.cursor0;--e){if(this.resBuf[e-1].getCanonicalClass()<=t)break}this.resBuf.splice(e,0,r)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var r=this.procBuf[0].getComposite(t),e=t.getCanonicalClass();r&&(this.lastClass", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x6299bca2e9d3412b09fa525be3b771e3b87ed6c4dfee0448612b0fedd455fcf3" +} diff --git a/packages/shims/src/base64.js b/packages/shims/src/base64.js new file mode 100644 index 000000000..b4870c712 --- /dev/null +++ b/packages/shims/src/base64.js @@ -0,0 +1,99 @@ +/** + * See: https://github.com/MaxArt2501/base64-js + * The MIT License (MIT) + * + * Copyright (c) 2014 MaxArt2501 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], function() {factory(root);}); + } else factory(root); +// node.js has always supported base64 conversions, while browsers that support +// web workers support base64 too, but you may never know. +})(typeof exports !== "undefined" ? exports : this, function(root) { + if (root.atob) { + // Some browsers' implementation of atob doesn't support whitespaces + // in the encoded string (notably, IE). This wraps the native atob + // in a function that strips the whitespaces. + // The original function can be retrieved in atob.original + try { + root.atob(" "); + } catch(e) { + root.atob = (function(atob) { + var func = function(string) { + return atob(String(string).replace(/[\t\n\f\r ]+/g, "")); + }; + func.original = atob; + return func; + })(root.atob); + } + return; + } + + // base64 character set, plus padding character (=) + var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + // Regular expression to check formal correctness of base64 encoded strings + b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; + + root.btoa = function(string) { + string = String(string); + var bitmap, a, b, c, + result = "", i = 0, + rest = string.length % 3; // To determine the final padding + + for (; i < string.length;) { + if ((a = string.charCodeAt(i++)) > 255 + || (b = string.charCodeAt(i++)) > 255 + || (c = string.charCodeAt(i++)) > 255) + throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."); + + bitmap = (a << 16) | (b << 8) | c; + result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63); + } + + // If there's need of padding, replace the last 'A's with equal signs + return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result; + }; + + root.atob = function(string) { + // atob can work with strings with whitespaces, even inside the encoded part, + // but only \t, \n, \f, \r and ' ', which can be stripped. + string = String(string).replace(/[\t\n\f\r ]+/g, ""); + if (!b64re.test(string)) + throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); + + // Adding the padding if missing, for semplicity + string += "==".slice(2 - (string.length & 3)); + var bitmap, result = "", r1, r2, i = 0; + for (; i < string.length;) { + bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 + | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++))); + + result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) + : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) + : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255); + } + return result; + }; +}); diff --git a/packages/shims/src/es6-promise.auto.js b/packages/shims/src/es6-promise.auto.js new file mode 100644 index 000000000..7c1a30998 --- /dev/null +++ b/packages/shims/src/es6-promise.auto.js @@ -0,0 +1,1159 @@ +/*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE + * @version 4.1.0+f046478d + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.ES6Promise = factory()); +}(this, (function () { 'use strict'; + +function objectOrFunction(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +function isFunction(x) { + return typeof x === 'function'; +} + +var _isArray = undefined; +if (Array.isArray) { + _isArray = Array.isArray; +} else { + _isArray = function (x) { + return Object.prototype.toString.call(x) === '[object Array]'; + }; +} + +var isArray = _isArray; + +var len = 0; +var vertxNext = undefined; +var customSchedulerFn = undefined; + +var asap = function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 2, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + if (customSchedulerFn) { + customSchedulerFn(flush); + } else { + scheduleFlush(); + } + } +}; + +function setScheduler(scheduleFn) { + customSchedulerFn = scheduleFn; +} + +function setAsap(asapFn) { + asap = asapFn; +} + +var browserWindow = typeof window !== 'undefined' ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // see https://github.com/cujojs/when/issues/410 for details + return function () { + return process.nextTick(flush); + }; +} + +// vertx +function useVertxTimer() { + if (typeof vertxNext !== 'undefined') { + return function () { + vertxNext(flush); + }; + } + + return useSetTimeout(); +} + +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function () { + node.data = iterations = ++iterations % 2; + }; +} + +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + return channel.port2.postMessage(0); + }; +} + +function useSetTimeout() { + // Store setTimeout reference so es6-promise will be unaffected by + // other code modifying setTimeout (like sinon.useFakeTimers()) + var globalSetTimeout = setTimeout; + return function () { + return globalSetTimeout(flush, 1); + }; +} + +var queue = new Array(1000); +function flush() { + for (var i = 0; i < len; i += 2) { + var callback = queue[i]; + var arg = queue[i + 1]; + + callback(arg); + + queue[i] = undefined; + queue[i + 1] = undefined; + } + + len = 0; +} + +function attemptVertx() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch (e) { + return useSetTimeout(); + } +} + +var scheduleFlush = undefined; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); +} else if (isWorker) { + scheduleFlush = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush = attemptVertx(); +} else { + scheduleFlush = useSetTimeout(); +} + +function then(onFulfillment, onRejection) { + var _arguments = arguments; + + var parent = this; + + var child = new this.constructor(noop); + + if (child[PROMISE_ID] === undefined) { + makePromise(child); + } + + var _state = parent._state; + + if (_state) { + (function () { + var callback = _arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); + })(); + } else { + subscribe(parent, child, onFulfillment, onRejection); + } + + return child; +} + +/** + `Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {Any} value value that the returned promise will be resolved with + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } + + var promise = new Constructor(noop); + resolve(promise, object); + return promise; +} + +var PROMISE_ID = Math.random().toString(36).substring(16); + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function selfFulfillment() { + return new TypeError("You cannot resolve a promise with itself"); +} + +function cannotReturnOwn() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function getThen(promise) { + try { + return promise.then; + } catch (error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} + +function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { + try { + then$$1.call(value, fulfillmentHandler, rejectionHandler); + } catch (e) { + return e; + } +} + +function handleForeignThenable(promise, thenable, then$$1) { + asap(function (promise) { + var sealed = false; + var error = tryThen(then$$1, thenable, function (value) { + if (sealed) { + return; + } + sealed = true; + if (thenable !== value) { + resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function (reason) { + if (sealed) { + return; + } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); + } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function (value) { + return resolve(promise, value); + }, function (reason) { + return reject(promise, reason); + }); + } +} + +function handleMaybeThenable(promise, maybeThenable, then$$1) { + if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$1 === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + GET_THEN_ERROR.error = null; + } else if (then$$1 === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$1)) { + handleForeignThenable(promise, maybeThenable, then$$1); + } else { + fulfill(promise, maybeThenable); + } + } +} + +function resolve(promise, value) { + if (promise === value) { + reject(promise, selfFulfillment()); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} + +function publishRejection(promise) { + if (promise._onerror) { + promise._onerror(promise._result); + } + + publish(promise); +} + +function fulfill(promise, value) { + if (promise._state !== PENDING) { + return; + } + + promise._result = value; + promise._state = FULFILLED; + + if (promise._subscribers.length !== 0) { + asap(publish, promise); + } +} + +function reject(promise, reason) { + if (promise._state !== PENDING) { + return; + } + promise._state = REJECTED; + promise._result = reason; + + asap(publishRejection, promise); +} + +function subscribe(parent, child, onFulfillment, onRejection) { + var _subscribers = parent._subscribers; + var length = _subscribers.length; + + parent._onerror = null; + + _subscribers[length] = child; + _subscribers[length + FULFILLED] = onFulfillment; + _subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + asap(publish, parent); + } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; + + if (subscribers.length === 0) { + return; + } + + var child = undefined, + callback = undefined, + detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); + } + } + + promise._subscribers.length = 0; +} + +function ErrorObject() { + this.error = null; +} + +var TRY_CATCH_ERROR = new ErrorObject(); + +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch (e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value = undefined, + error = undefined, + succeeded = undefined, + failed = undefined; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value.error = null; + } else { + succeeded = true; + } + + if (promise === value) { + reject(promise, cannotReturnOwn()); + return; + } + } else { + value = detail; + succeeded = true; + } + + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} + +function initializePromise(promise, resolver) { + try { + resolver(function resolvePromise(value) { + resolve(promise, value); + }, function rejectPromise(reason) { + reject(promise, reason); + }); + } catch (e) { + reject(promise, e); + } +} + +var id = 0; +function nextId() { + return id++; +} + +function makePromise(promise) { + promise[PROMISE_ID] = id++; + promise._state = undefined; + promise._result = undefined; + promise._subscribers = []; +} + +function Enumerator$1(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); + + if (!this.promise[PROMISE_ID]) { + makePromise(this.promise); + } + + if (isArray(input)) { + this.length = input.length; + this._remaining = input.length; + + this._result = new Array(this.length); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(input); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + reject(this.promise, validationError()); + } +} + +function validationError() { + return new Error('Array Methods must be provided an Array'); +} + +Enumerator$1.prototype._enumerate = function (input) { + for (var i = 0; this._state === PENDING && i < input.length; i++) { + this._eachEntry(input[i], i); + } +}; + +Enumerator$1.prototype._eachEntry = function (entry, i) { + var c = this._instanceConstructor; + var resolve$$1 = c.resolve; + + if (resolve$$1 === resolve$1) { + var _then = getThen(entry); + + if (_then === then && entry._state !== PENDING) { + this._settledAt(entry._state, i, entry._result); + } else if (typeof _then !== 'function') { + this._remaining--; + this._result[i] = entry; + } else if (c === Promise$3) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, _then); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function (resolve$$1) { + return resolve$$1(entry); + }), i); + } + } else { + this._willSettleAt(resolve$$1(entry), i); + } +}; + +Enumerator$1.prototype._settledAt = function (state, i, value) { + var promise = this.promise; + + if (promise._state === PENDING) { + this._remaining--; + + if (state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = value; + } + } + + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; + +Enumerator$1.prototype._willSettleAt = function (promise, i) { + var enumerator = this; + + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); +}; + +/** + `Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = resolve(2); + let promise3 = resolve(3); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = reject(new Error("2")); + let promise3 = reject(new Error("3")); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all$1(entries) { + return new Enumerator$1(this, entries).promise; +} + +/** + `Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} promises array of promises to observe + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race$1(entries) { + /*jshint validthis:true */ + var Constructor = this; + + if (!isArray(entries)) { + return new Constructor(function (_, reject) { + return reject(new TypeError('You must pass an array to race.')); + }); + } else { + return new Constructor(function (resolve, reject) { + var length = entries.length; + for (var i = 0; i < length; i++) { + Constructor.resolve(entries[i]).then(resolve, reject); + } + }); + } +} + +/** + `Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {Any} reason value that the returned promise will be rejected with. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop); + reject(promise, reason); + return promise; +} + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise's eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + let promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + let xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } + }; + }); + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class Promise + @param {function} resolver + Useful for tooling. + @constructor +*/ +function Promise$3(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise$3 ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise$3.all = all$1; +Promise$3.race = race$1; +Promise$3.resolve = resolve$1; +Promise$3.reject = reject$1; +Promise$3._setScheduler = setScheduler; +Promise$3._setAsap = setAsap; +Promise$3._asap = asap; + +Promise$3.prototype = { + constructor: Promise$3, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + let result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + let author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. + @return {Promise} + */ + then: then, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function _catch(onRejection) { + return this.then(null, onRejection); + } +}; + +/*global self*/ +function polyfill$1() { + var local = undefined; + + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + + var P = local.Promise; + + if (P) { + var promiseToString = null; + try { + promiseToString = Object.prototype.toString.call(P.resolve()); + } catch (e) { + // silently ignored + } + + if (promiseToString === '[object Promise]' && !P.cast) { + return; + } + } + + local.Promise = Promise$3; +} + +// Strange compat.. +Promise$3.polyfill = polyfill$1; +Promise$3.Promise = Promise$3; + +Promise$3.polyfill(); + +return Promise$3; + +}))); + +//# sourceMappingURL=es6-promise.auto.map diff --git a/packages/shims/src/index.js b/packages/shims/src/index.js new file mode 100644 index 000000000..9057c2dc0 --- /dev/null +++ b/packages/shims/src/index.js @@ -0,0 +1,80 @@ +'use strict'; + +var shims = []; + +// Shim String.prototype.normalize +try { + var missing = []; + + // Some platforms are missing certain normalization forms + var forms = ["NFD", "NFC", "NFKD", "NFKC"]; + for (var i = 0; i < forms.length; i++) { + try { + if ("test".normalize(forms[i]) !== "test") { + throw new Error("failed to normalize"); + } + } catch(error) { + missing.push(forms[i]); + } + } + + if (missing.length) { + shims.push("String.prototype.normalize (missing: " + missing.join(", ") + ")"); + throw new Error('bad normalize'); + } + + // Some platforms have a native normalize, but it is broken; so we force our shim + if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) { + shims.push("String.prototype.normalize (broken)"); + throw new Error('bad normalize'); + } +} catch (error) { + var unorm = require('./unorm.js'); + String.prototype.normalize = function(form) { + var func = unorm[(form || 'NFC').toLowerCase()]; + if (!func) { throw new RangeError('invalid form - ' + form); } + return func(this); + } +} + +// Shim atob and btoa +var base64 = require('./base64.js'); +if (!global.atob) { + shims.push("atob"); + global.atob = base64.atob; +} +if (!global.btoa) { + shims.push("btoa"); + global.btoa = base64.btoa; +} + +// Shim Promise +// @TODO: Check first? +if (window.Promise == null) { + var promise = require('./es6-promise.auto.js'); +} + +// Shim ArrayBuffer.isView +if (!ArrayBuffer.isView) { + shims.push("ArrayBuffer.isView"); + ArrayBuffer.isView = function(obj) { + // @TODO: This should probably check various instanceof aswell + return !!(obj.buffer); + } +} + +// Shim nextTick +if (!global.nextTick) { + shims.push("nextTick"); + global.nextTick = function (callback) { setTimeout(callback, 0); } +} + +if (shims.length) { + console.log("Shims Injected:"); + for (var i = 0; i < shims.length; i++) { + console.log(' - ' + shims[i]); + } +} + +// @TOOD: Add crypto.rand? +// - https://github.com/brix/crypto-js/issues/7 diff --git a/packages/shims/src/unorm.js b/packages/shims/src/unorm.js new file mode 100644 index 000000000..92d36993d --- /dev/null +++ b/packages/shims/src/unorm.js @@ -0,0 +1,442 @@ +(function (root) { + "use strict"; + +/***** unorm.js *****/ + +/* + * UnicodeNormalizer 1.0.0 + * Copyright (c) 2008 Matsuza + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * $Date: 2008-06-05 16:44:17 +0200 (Thu, 05 Jun 2008) $ + * $Rev: 13309 $ + */ + + var DEFAULT_FEATURE = [null, 0, {}]; + var CACHE_THRESHOLD = 10; + var SBase = 0xAC00, LBase = 0x1100, VBase = 0x1161, TBase = 0x11A7, LCount = 19, VCount = 21, TCount = 28; + var NCount = VCount * TCount; // 588 + var SCount = LCount * NCount; // 11172 + + var UChar = function(cp, feature){ + this.codepoint = cp; + this.feature = feature; + }; + + // Strategies + var cache = {}; + var cacheCounter = []; + for (var i = 0; i <= 0xFF; ++i){ + cacheCounter[i] = 0; + } + + function fromCache(next, cp, needFeature){ + var ret = cache[cp]; + if(!ret){ + ret = next(cp, needFeature); + if(!!ret.feature && ++cacheCounter[(cp >> 8) & 0xFF] > CACHE_THRESHOLD){ + cache[cp] = ret; + } + } + return ret; + } + + function fromData(next, cp, needFeature){ + var hash = cp & 0xFF00; + var dunit = UChar.udata[hash] || {}; + var f = dunit[cp]; + return f ? new UChar(cp, f) : new UChar(cp, DEFAULT_FEATURE); + } + function fromCpOnly(next, cp, needFeature){ + return !!needFeature ? next(cp, needFeature) : new UChar(cp, null); + } + function fromRuleBasedJamo(next, cp, needFeature){ + var j; + if(cp < LBase || (LBase + LCount <= cp && cp < SBase) || (SBase + SCount < cp)){ + return next(cp, needFeature); + } + if(LBase <= cp && cp < LBase + LCount){ + var c = {}; + var base = (cp - LBase) * VCount; + for (j = 0; j < VCount; ++j){ + c[VBase + j] = SBase + TCount * (j + base); + } + return new UChar(cp, [,,c]); + } + + var SIndex = cp - SBase; + var TIndex = SIndex % TCount; + var feature = []; + if(TIndex !== 0){ + feature[0] = [SBase + SIndex - TIndex, TBase + TIndex]; + } else { + feature[0] = [LBase + Math.floor(SIndex / NCount), VBase + Math.floor((SIndex % NCount) / TCount)]; + feature[2] = {}; + for (j = 1; j < TCount; ++j){ + feature[2][TBase + j] = cp + j; + } + } + return new UChar(cp, feature); + } + function fromCpFilter(next, cp, needFeature){ + return cp < 60 || 13311 < cp && cp < 42607 ? new UChar(cp, DEFAULT_FEATURE) : next(cp, needFeature); + } + + var strategies = [fromCpFilter, fromCache, fromCpOnly, fromRuleBasedJamo, fromData]; + + UChar.fromCharCode = strategies.reduceRight(function (next, strategy) { + return function (cp, needFeature) { + return strategy(next, cp, needFeature); + }; + }, null); + + UChar.isHighSurrogate = function(cp){ + return cp >= 0xD800 && cp <= 0xDBFF; + }; + UChar.isLowSurrogate = function(cp){ + return cp >= 0xDC00 && cp <= 0xDFFF; + }; + + UChar.prototype.prepFeature = function(){ + if(!this.feature){ + this.feature = UChar.fromCharCode(this.codepoint, true).feature; + } + }; + + UChar.prototype.toString = function(){ + if(this.codepoint < 0x10000){ + return String.fromCharCode(this.codepoint); + } else { + var x = this.codepoint - 0x10000; + return String.fromCharCode(Math.floor(x / 0x400) + 0xD800, x % 0x400 + 0xDC00); + } + }; + + UChar.prototype.getDecomp = function(){ + this.prepFeature(); + return this.feature[0] || null; + }; + + UChar.prototype.isCompatibility = function(){ + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 8)); + }; + UChar.prototype.isExclude = function(){ + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 9)); + }; + UChar.prototype.getCanonicalClass = function(){ + this.prepFeature(); + return !!this.feature[1] ? (this.feature[1] & 0xff) : 0; + }; + UChar.prototype.getComposite = function(following){ + this.prepFeature(); + if(!this.feature[2]){ + return null; + } + var cp = this.feature[2][following.codepoint]; + return cp ? UChar.fromCharCode(cp) : null; + }; + + var UCharIterator = function(str){ + this.str = str; + this.cursor = 0; + }; + UCharIterator.prototype.next = function(){ + if(!!this.str && this.cursor < this.str.length){ + var cp = this.str.charCodeAt(this.cursor++); + var d; + if(UChar.isHighSurrogate(cp) && this.cursor < this.str.length && UChar.isLowSurrogate((d = this.str.charCodeAt(this.cursor)))){ + cp = (cp - 0xD800) * 0x400 + (d -0xDC00) + 0x10000; + ++this.cursor; + } + return UChar.fromCharCode(cp); + } else { + this.str = null; + return null; + } + }; + + var RecursDecompIterator = function(it, cano){ + this.it = it; + this.canonical = cano; + this.resBuf = []; + }; + + RecursDecompIterator.prototype.next = function(){ + function recursiveDecomp(cano, uchar){ + var decomp = uchar.getDecomp(); + if(!!decomp && !(cano && uchar.isCompatibility())){ + var ret = []; + for(var i = 0; i < decomp.length; ++i){ + var a = recursiveDecomp(cano, UChar.fromCharCode(decomp[i])); + ret = ret.concat(a); + } + return ret; + } else { + return [uchar]; + } + } + if(this.resBuf.length === 0){ + var uchar = this.it.next(); + if(!uchar){ + return null; + } + this.resBuf = recursiveDecomp(this.canonical, uchar); + } + return this.resBuf.shift(); + }; + + var DecompIterator = function(it){ + this.it = it; + this.resBuf = []; + }; + + DecompIterator.prototype.next = function(){ + var cc; + if(this.resBuf.length === 0){ + do{ + var uchar = this.it.next(); + if(!uchar){ + break; + } + cc = uchar.getCanonicalClass(); + var inspt = this.resBuf.length; + if(cc !== 0){ + for(; inspt > 0; --inspt){ + var uchar2 = this.resBuf[inspt - 1]; + var cc2 = uchar2.getCanonicalClass(); + if(cc2 <= cc){ + break; + } + } + } + this.resBuf.splice(inspt, 0, uchar); + } while(cc !== 0); + } + return this.resBuf.shift(); + }; + + var CompIterator = function(it){ + this.it = it; + this.procBuf = []; + this.resBuf = []; + this.lastClass = null; + }; + + CompIterator.prototype.next = function(){ + while(this.resBuf.length === 0){ + var uchar = this.it.next(); + if(!uchar){ + this.resBuf = this.procBuf; + this.procBuf = []; + break; + } + if(this.procBuf.length === 0){ + this.lastClass = uchar.getCanonicalClass(); + this.procBuf.push(uchar); + } else { + var starter = this.procBuf[0]; + var composite = starter.getComposite(uchar); + var cc = uchar.getCanonicalClass(); + if(!!composite && (this.lastClass < cc || this.lastClass === 0)){ + this.procBuf[0] = composite; + } else { + if(cc === 0){ + this.resBuf = this.procBuf; + this.procBuf = []; + } + this.lastClass = cc; + this.procBuf.push(uchar); + } + } + } + return this.resBuf.shift(); + }; + + var createIterator = function(mode, str){ + switch(mode){ + case "NFD": + return new DecompIterator(new RecursDecompIterator(new UCharIterator(str), true)); + case "NFKD": + return new DecompIterator(new RecursDecompIterator(new UCharIterator(str), false)); + case "NFC": + return new CompIterator(new DecompIterator(new RecursDecompIterator(new UCharIterator(str), true))); + case "NFKC": + return new CompIterator(new DecompIterator(new RecursDecompIterator(new UCharIterator(str), false))); + } + throw mode + " is invalid"; + }; + var normalize = function(mode, str){ + var it = createIterator(mode, str); + var ret = ""; + var uchar; + while(!!(uchar = it.next())){ + ret += uchar.toString(); + } + return ret; + }; + + /* API functions */ + function nfd(str){ + return normalize("NFD", str); + } + + function nfkd(str){ + return normalize("NFKD", str); + } + + function nfc(str){ + return normalize("NFC", str); + } + + function nfkc(str){ + return normalize("NFKC", str); + } + +/* Unicode data */ +UChar.udata={ +0:{60:[,,{824:8814}],61:[,,{824:8800}],62:[,,{824:8815}],65:[,,{768:192,769:193,770:194,771:195,772:256,774:258,775:550,776:196,777:7842,778:197,780:461,783:512,785:514,803:7840,805:7680,808:260}],66:[,,{775:7682,803:7684,817:7686}],67:[,,{769:262,770:264,775:266,780:268,807:199}],68:[,,{775:7690,780:270,803:7692,807:7696,813:7698,817:7694}],69:[,,{768:200,769:201,770:202,771:7868,772:274,774:276,775:278,776:203,777:7866,780:282,783:516,785:518,803:7864,807:552,808:280,813:7704,816:7706}],70:[,,{775:7710}],71:[,,{769:500,770:284,772:7712,774:286,775:288,780:486,807:290}],72:[,,{770:292,775:7714,776:7718,780:542,803:7716,807:7720,814:7722}],73:[,,{768:204,769:205,770:206,771:296,772:298,774:300,775:304,776:207,777:7880,780:463,783:520,785:522,803:7882,808:302,816:7724}],74:[,,{770:308}],75:[,,{769:7728,780:488,803:7730,807:310,817:7732}],76:[,,{769:313,780:317,803:7734,807:315,813:7740,817:7738}],77:[,,{769:7742,775:7744,803:7746}],78:[,,{768:504,769:323,771:209,775:7748,780:327,803:7750,807:325,813:7754,817:7752}],79:[,,{768:210,769:211,770:212,771:213,772:332,774:334,775:558,776:214,777:7886,779:336,780:465,783:524,785:526,795:416,803:7884,808:490}],80:[,,{769:7764,775:7766}],82:[,,{769:340,775:7768,780:344,783:528,785:530,803:7770,807:342,817:7774}],83:[,,{769:346,770:348,775:7776,780:352,803:7778,806:536,807:350}],84:[,,{775:7786,780:356,803:7788,806:538,807:354,813:7792,817:7790}],85:[,,{768:217,769:218,770:219,771:360,772:362,774:364,776:220,777:7910,778:366,779:368,780:467,783:532,785:534,795:431,803:7908,804:7794,808:370,813:7798,816:7796}],86:[,,{771:7804,803:7806}],87:[,,{768:7808,769:7810,770:372,775:7814,776:7812,803:7816}],88:[,,{775:7818,776:7820}],89:[,,{768:7922,769:221,770:374,771:7928,772:562,775:7822,776:376,777:7926,803:7924}],90:[,,{769:377,770:7824,775:379,780:381,803:7826,817:7828}],97:[,,{768:224,769:225,770:226,771:227,772:257,774:259,775:551,776:228,777:7843,778:229,780:462,783:513,785:515,803:7841,805:7681,808:261}],98:[,,{775:7683,803:7685,817:7687}],99:[,,{769:263,770:265,775:267,780:269,807:231}],100:[,,{775:7691,780:271,803:7693,807:7697,813:7699,817:7695}],101:[,,{768:232,769:233,770:234,771:7869,772:275,774:277,775:279,776:235,777:7867,780:283,783:517,785:519,803:7865,807:553,808:281,813:7705,816:7707}],102:[,,{775:7711}],103:[,,{769:501,770:285,772:7713,774:287,775:289,780:487,807:291}],104:[,,{770:293,775:7715,776:7719,780:543,803:7717,807:7721,814:7723,817:7830}],105:[,,{768:236,769:237,770:238,771:297,772:299,774:301,776:239,777:7881,780:464,783:521,785:523,803:7883,808:303,816:7725}],106:[,,{770:309,780:496}],107:[,,{769:7729,780:489,803:7731,807:311,817:7733}],108:[,,{769:314,780:318,803:7735,807:316,813:7741,817:7739}],109:[,,{769:7743,775:7745,803:7747}],110:[,,{768:505,769:324,771:241,775:7749,780:328,803:7751,807:326,813:7755,817:7753}],111:[,,{768:242,769:243,770:244,771:245,772:333,774:335,775:559,776:246,777:7887,779:337,780:466,783:525,785:527,795:417,803:7885,808:491}],112:[,,{769:7765,775:7767}],114:[,,{769:341,775:7769,780:345,783:529,785:531,803:7771,807:343,817:7775}],115:[,,{769:347,770:349,775:7777,780:353,803:7779,806:537,807:351}],116:[,,{775:7787,776:7831,780:357,803:7789,806:539,807:355,813:7793,817:7791}],117:[,,{768:249,769:250,770:251,771:361,772:363,774:365,776:252,777:7911,778:367,779:369,780:468,783:533,785:535,795:432,803:7909,804:7795,808:371,813:7799,816:7797}],118:[,,{771:7805,803:7807}],119:[,,{768:7809,769:7811,770:373,775:7815,776:7813,778:7832,803:7817}],120:[,,{775:7819,776:7821}],121:[,,{768:7923,769:253,770:375,771:7929,772:563,775:7823,776:255,777:7927,778:7833,803:7925}],122:[,,{769:378,770:7825,775:380,780:382,803:7827,817:7829}],160:[[32],256],168:[[32,776],256,{768:8173,769:901,834:8129}],170:[[97],256],175:[[32,772],256],178:[[50],256],179:[[51],256],180:[[32,769],256],181:[[956],256],184:[[32,807],256],185:[[49],256],186:[[111],256],188:[[49,8260,52],256],189:[[49,8260,50],256],190:[[51,8260,52],256],192:[[65,768]],193:[[65,769]],194:[[65,770],,{768:7846,769:7844,771:7850,777:7848}],195:[[65,771]],196:[[65,776],,{772:478}],197:[[65,778],,{769:506}],198:[,,{769:508,772:482}],199:[[67,807],,{769:7688}],200:[[69,768]],201:[[69,769]],202:[[69,770],,{768:7872,769:7870,771:7876,777:7874}],203:[[69,776]],204:[[73,768]],205:[[73,769]],206:[[73,770]],207:[[73,776],,{769:7726}],209:[[78,771]],210:[[79,768]],211:[[79,769]],212:[[79,770],,{768:7890,769:7888,771:7894,777:7892}],213:[[79,771],,{769:7756,772:556,776:7758}],214:[[79,776],,{772:554}],216:[,,{769:510}],217:[[85,768]],218:[[85,769]],219:[[85,770]],220:[[85,776],,{768:475,769:471,772:469,780:473}],221:[[89,769]],224:[[97,768]],225:[[97,769]],226:[[97,770],,{768:7847,769:7845,771:7851,777:7849}],227:[[97,771]],228:[[97,776],,{772:479}],229:[[97,778],,{769:507}],230:[,,{769:509,772:483}],231:[[99,807],,{769:7689}],232:[[101,768]],233:[[101,769]],234:[[101,770],,{768:7873,769:7871,771:7877,777:7875}],235:[[101,776]],236:[[105,768]],237:[[105,769]],238:[[105,770]],239:[[105,776],,{769:7727}],241:[[110,771]],242:[[111,768]],243:[[111,769]],244:[[111,770],,{768:7891,769:7889,771:7895,777:7893}],245:[[111,771],,{769:7757,772:557,776:7759}],246:[[111,776],,{772:555}],248:[,,{769:511}],249:[[117,768]],250:[[117,769]],251:[[117,770]],252:[[117,776],,{768:476,769:472,772:470,780:474}],253:[[121,769]],255:[[121,776]]}, +256:{256:[[65,772]],257:[[97,772]],258:[[65,774],,{768:7856,769:7854,771:7860,777:7858}],259:[[97,774],,{768:7857,769:7855,771:7861,777:7859}],260:[[65,808]],261:[[97,808]],262:[[67,769]],263:[[99,769]],264:[[67,770]],265:[[99,770]],266:[[67,775]],267:[[99,775]],268:[[67,780]],269:[[99,780]],270:[[68,780]],271:[[100,780]],274:[[69,772],,{768:7700,769:7702}],275:[[101,772],,{768:7701,769:7703}],276:[[69,774]],277:[[101,774]],278:[[69,775]],279:[[101,775]],280:[[69,808]],281:[[101,808]],282:[[69,780]],283:[[101,780]],284:[[71,770]],285:[[103,770]],286:[[71,774]],287:[[103,774]],288:[[71,775]],289:[[103,775]],290:[[71,807]],291:[[103,807]],292:[[72,770]],293:[[104,770]],296:[[73,771]],297:[[105,771]],298:[[73,772]],299:[[105,772]],300:[[73,774]],301:[[105,774]],302:[[73,808]],303:[[105,808]],304:[[73,775]],306:[[73,74],256],307:[[105,106],256],308:[[74,770]],309:[[106,770]],310:[[75,807]],311:[[107,807]],313:[[76,769]],314:[[108,769]],315:[[76,807]],316:[[108,807]],317:[[76,780]],318:[[108,780]],319:[[76,183],256],320:[[108,183],256],323:[[78,769]],324:[[110,769]],325:[[78,807]],326:[[110,807]],327:[[78,780]],328:[[110,780]],329:[[700,110],256],332:[[79,772],,{768:7760,769:7762}],333:[[111,772],,{768:7761,769:7763}],334:[[79,774]],335:[[111,774]],336:[[79,779]],337:[[111,779]],340:[[82,769]],341:[[114,769]],342:[[82,807]],343:[[114,807]],344:[[82,780]],345:[[114,780]],346:[[83,769],,{775:7780}],347:[[115,769],,{775:7781}],348:[[83,770]],349:[[115,770]],350:[[83,807]],351:[[115,807]],352:[[83,780],,{775:7782}],353:[[115,780],,{775:7783}],354:[[84,807]],355:[[116,807]],356:[[84,780]],357:[[116,780]],360:[[85,771],,{769:7800}],361:[[117,771],,{769:7801}],362:[[85,772],,{776:7802}],363:[[117,772],,{776:7803}],364:[[85,774]],365:[[117,774]],366:[[85,778]],367:[[117,778]],368:[[85,779]],369:[[117,779]],370:[[85,808]],371:[[117,808]],372:[[87,770]],373:[[119,770]],374:[[89,770]],375:[[121,770]],376:[[89,776]],377:[[90,769]],378:[[122,769]],379:[[90,775]],380:[[122,775]],381:[[90,780]],382:[[122,780]],383:[[115],256,{775:7835}],416:[[79,795],,{768:7900,769:7898,771:7904,777:7902,803:7906}],417:[[111,795],,{768:7901,769:7899,771:7905,777:7903,803:7907}],431:[[85,795],,{768:7914,769:7912,771:7918,777:7916,803:7920}],432:[[117,795],,{768:7915,769:7913,771:7919,777:7917,803:7921}],439:[,,{780:494}],452:[[68,381],256],453:[[68,382],256],454:[[100,382],256],455:[[76,74],256],456:[[76,106],256],457:[[108,106],256],458:[[78,74],256],459:[[78,106],256],460:[[110,106],256],461:[[65,780]],462:[[97,780]],463:[[73,780]],464:[[105,780]],465:[[79,780]],466:[[111,780]],467:[[85,780]],468:[[117,780]],469:[[220,772]],470:[[252,772]],471:[[220,769]],472:[[252,769]],473:[[220,780]],474:[[252,780]],475:[[220,768]],476:[[252,768]],478:[[196,772]],479:[[228,772]],480:[[550,772]],481:[[551,772]],482:[[198,772]],483:[[230,772]],486:[[71,780]],487:[[103,780]],488:[[75,780]],489:[[107,780]],490:[[79,808],,{772:492}],491:[[111,808],,{772:493}],492:[[490,772]],493:[[491,772]],494:[[439,780]],495:[[658,780]],496:[[106,780]],497:[[68,90],256],498:[[68,122],256],499:[[100,122],256],500:[[71,769]],501:[[103,769]],504:[[78,768]],505:[[110,768]],506:[[197,769]],507:[[229,769]],508:[[198,769]],509:[[230,769]],510:[[216,769]],511:[[248,769]],66045:[,220]}, +512:{512:[[65,783]],513:[[97,783]],514:[[65,785]],515:[[97,785]],516:[[69,783]],517:[[101,783]],518:[[69,785]],519:[[101,785]],520:[[73,783]],521:[[105,783]],522:[[73,785]],523:[[105,785]],524:[[79,783]],525:[[111,783]],526:[[79,785]],527:[[111,785]],528:[[82,783]],529:[[114,783]],530:[[82,785]],531:[[114,785]],532:[[85,783]],533:[[117,783]],534:[[85,785]],535:[[117,785]],536:[[83,806]],537:[[115,806]],538:[[84,806]],539:[[116,806]],542:[[72,780]],543:[[104,780]],550:[[65,775],,{772:480}],551:[[97,775],,{772:481}],552:[[69,807],,{774:7708}],553:[[101,807],,{774:7709}],554:[[214,772]],555:[[246,772]],556:[[213,772]],557:[[245,772]],558:[[79,775],,{772:560}],559:[[111,775],,{772:561}],560:[[558,772]],561:[[559,772]],562:[[89,772]],563:[[121,772]],658:[,,{780:495}],688:[[104],256],689:[[614],256],690:[[106],256],691:[[114],256],692:[[633],256],693:[[635],256],694:[[641],256],695:[[119],256],696:[[121],256],728:[[32,774],256],729:[[32,775],256],730:[[32,778],256],731:[[32,808],256],732:[[32,771],256],733:[[32,779],256],736:[[611],256],737:[[108],256],738:[[115],256],739:[[120],256],740:[[661],256],66272:[,220]}, +768:{768:[,230],769:[,230],770:[,230],771:[,230],772:[,230],773:[,230],774:[,230],775:[,230],776:[,230,{769:836}],777:[,230],778:[,230],779:[,230],780:[,230],781:[,230],782:[,230],783:[,230],784:[,230],785:[,230],786:[,230],787:[,230],788:[,230],789:[,232],790:[,220],791:[,220],792:[,220],793:[,220],794:[,232],795:[,216],796:[,220],797:[,220],798:[,220],799:[,220],800:[,220],801:[,202],802:[,202],803:[,220],804:[,220],805:[,220],806:[,220],807:[,202],808:[,202],809:[,220],810:[,220],811:[,220],812:[,220],813:[,220],814:[,220],815:[,220],816:[,220],817:[,220],818:[,220],819:[,220],820:[,1],821:[,1],822:[,1],823:[,1],824:[,1],825:[,220],826:[,220],827:[,220],828:[,220],829:[,230],830:[,230],831:[,230],832:[[768],230],833:[[769],230],834:[,230],835:[[787],230],836:[[776,769],230],837:[,240],838:[,230],839:[,220],840:[,220],841:[,220],842:[,230],843:[,230],844:[,230],845:[,220],846:[,220],848:[,230],849:[,230],850:[,230],851:[,220],852:[,220],853:[,220],854:[,220],855:[,230],856:[,232],857:[,220],858:[,220],859:[,230],860:[,233],861:[,234],862:[,234],863:[,233],864:[,234],865:[,234],866:[,233],867:[,230],868:[,230],869:[,230],870:[,230],871:[,230],872:[,230],873:[,230],874:[,230],875:[,230],876:[,230],877:[,230],878:[,230],879:[,230],884:[[697]],890:[[32,837],256],894:[[59]],900:[[32,769],256],901:[[168,769]],902:[[913,769]],903:[[183]],904:[[917,769]],905:[[919,769]],906:[[921,769]],908:[[927,769]],910:[[933,769]],911:[[937,769]],912:[[970,769]],913:[,,{768:8122,769:902,772:8121,774:8120,787:7944,788:7945,837:8124}],917:[,,{768:8136,769:904,787:7960,788:7961}],919:[,,{768:8138,769:905,787:7976,788:7977,837:8140}],921:[,,{768:8154,769:906,772:8153,774:8152,776:938,787:7992,788:7993}],927:[,,{768:8184,769:908,787:8008,788:8009}],929:[,,{788:8172}],933:[,,{768:8170,769:910,772:8169,774:8168,776:939,788:8025}],937:[,,{768:8186,769:911,787:8040,788:8041,837:8188}],938:[[921,776]],939:[[933,776]],940:[[945,769],,{837:8116}],941:[[949,769]],942:[[951,769],,{837:8132}],943:[[953,769]],944:[[971,769]],945:[,,{768:8048,769:940,772:8113,774:8112,787:7936,788:7937,834:8118,837:8115}],949:[,,{768:8050,769:941,787:7952,788:7953}],951:[,,{768:8052,769:942,787:7968,788:7969,834:8134,837:8131}],953:[,,{768:8054,769:943,772:8145,774:8144,776:970,787:7984,788:7985,834:8150}],959:[,,{768:8056,769:972,787:8000,788:8001}],961:[,,{787:8164,788:8165}],965:[,,{768:8058,769:973,772:8161,774:8160,776:971,787:8016,788:8017,834:8166}],969:[,,{768:8060,769:974,787:8032,788:8033,834:8182,837:8179}],970:[[953,776],,{768:8146,769:912,834:8151}],971:[[965,776],,{768:8162,769:944,834:8167}],972:[[959,769]],973:[[965,769]],974:[[969,769],,{837:8180}],976:[[946],256],977:[[952],256],978:[[933],256,{769:979,776:980}],979:[[978,769]],980:[[978,776]],981:[[966],256],982:[[960],256],1008:[[954],256],1009:[[961],256],1010:[[962],256],1012:[[920],256],1013:[[949],256],1017:[[931],256],66422:[,230],66423:[,230],66424:[,230],66425:[,230],66426:[,230]}, +1024:{1024:[[1045,768]],1025:[[1045,776]],1027:[[1043,769]],1030:[,,{776:1031}],1031:[[1030,776]],1036:[[1050,769]],1037:[[1048,768]],1038:[[1059,774]],1040:[,,{774:1232,776:1234}],1043:[,,{769:1027}],1045:[,,{768:1024,774:1238,776:1025}],1046:[,,{774:1217,776:1244}],1047:[,,{776:1246}],1048:[,,{768:1037,772:1250,774:1049,776:1252}],1049:[[1048,774]],1050:[,,{769:1036}],1054:[,,{776:1254}],1059:[,,{772:1262,774:1038,776:1264,779:1266}],1063:[,,{776:1268}],1067:[,,{776:1272}],1069:[,,{776:1260}],1072:[,,{774:1233,776:1235}],1075:[,,{769:1107}],1077:[,,{768:1104,774:1239,776:1105}],1078:[,,{774:1218,776:1245}],1079:[,,{776:1247}],1080:[,,{768:1117,772:1251,774:1081,776:1253}],1081:[[1080,774]],1082:[,,{769:1116}],1086:[,,{776:1255}],1091:[,,{772:1263,774:1118,776:1265,779:1267}],1095:[,,{776:1269}],1099:[,,{776:1273}],1101:[,,{776:1261}],1104:[[1077,768]],1105:[[1077,776]],1107:[[1075,769]],1110:[,,{776:1111}],1111:[[1110,776]],1116:[[1082,769]],1117:[[1080,768]],1118:[[1091,774]],1140:[,,{783:1142}],1141:[,,{783:1143}],1142:[[1140,783]],1143:[[1141,783]],1155:[,230],1156:[,230],1157:[,230],1158:[,230],1159:[,230],1217:[[1046,774]],1218:[[1078,774]],1232:[[1040,774]],1233:[[1072,774]],1234:[[1040,776]],1235:[[1072,776]],1238:[[1045,774]],1239:[[1077,774]],1240:[,,{776:1242}],1241:[,,{776:1243}],1242:[[1240,776]],1243:[[1241,776]],1244:[[1046,776]],1245:[[1078,776]],1246:[[1047,776]],1247:[[1079,776]],1250:[[1048,772]],1251:[[1080,772]],1252:[[1048,776]],1253:[[1080,776]],1254:[[1054,776]],1255:[[1086,776]],1256:[,,{776:1258}],1257:[,,{776:1259}],1258:[[1256,776]],1259:[[1257,776]],1260:[[1069,776]],1261:[[1101,776]],1262:[[1059,772]],1263:[[1091,772]],1264:[[1059,776]],1265:[[1091,776]],1266:[[1059,779]],1267:[[1091,779]],1268:[[1063,776]],1269:[[1095,776]],1272:[[1067,776]],1273:[[1099,776]]}, +1280:{1415:[[1381,1410],256],1425:[,220],1426:[,230],1427:[,230],1428:[,230],1429:[,230],1430:[,220],1431:[,230],1432:[,230],1433:[,230],1434:[,222],1435:[,220],1436:[,230],1437:[,230],1438:[,230],1439:[,230],1440:[,230],1441:[,230],1442:[,220],1443:[,220],1444:[,220],1445:[,220],1446:[,220],1447:[,220],1448:[,230],1449:[,230],1450:[,220],1451:[,230],1452:[,230],1453:[,222],1454:[,228],1455:[,230],1456:[,10],1457:[,11],1458:[,12],1459:[,13],1460:[,14],1461:[,15],1462:[,16],1463:[,17],1464:[,18],1465:[,19],1466:[,19],1467:[,20],1468:[,21],1469:[,22],1471:[,23],1473:[,24],1474:[,25],1476:[,230],1477:[,220],1479:[,18]}, +1536:{1552:[,230],1553:[,230],1554:[,230],1555:[,230],1556:[,230],1557:[,230],1558:[,230],1559:[,230],1560:[,30],1561:[,31],1562:[,32],1570:[[1575,1619]],1571:[[1575,1620]],1572:[[1608,1620]],1573:[[1575,1621]],1574:[[1610,1620]],1575:[,,{1619:1570,1620:1571,1621:1573}],1608:[,,{1620:1572}],1610:[,,{1620:1574}],1611:[,27],1612:[,28],1613:[,29],1614:[,30],1615:[,31],1616:[,32],1617:[,33],1618:[,34],1619:[,230],1620:[,230],1621:[,220],1622:[,220],1623:[,230],1624:[,230],1625:[,230],1626:[,230],1627:[,230],1628:[,220],1629:[,230],1630:[,230],1631:[,220],1648:[,35],1653:[[1575,1652],256],1654:[[1608,1652],256],1655:[[1735,1652],256],1656:[[1610,1652],256],1728:[[1749,1620]],1729:[,,{1620:1730}],1730:[[1729,1620]],1746:[,,{1620:1747}],1747:[[1746,1620]],1749:[,,{1620:1728}],1750:[,230],1751:[,230],1752:[,230],1753:[,230],1754:[,230],1755:[,230],1756:[,230],1759:[,230],1760:[,230],1761:[,230],1762:[,230],1763:[,220],1764:[,230],1767:[,230],1768:[,230],1770:[,220],1771:[,230],1772:[,230],1773:[,220]}, +1792:{1809:[,36],1840:[,230],1841:[,220],1842:[,230],1843:[,230],1844:[,220],1845:[,230],1846:[,230],1847:[,220],1848:[,220],1849:[,220],1850:[,230],1851:[,220],1852:[,220],1853:[,230],1854:[,220],1855:[,230],1856:[,230],1857:[,230],1858:[,220],1859:[,230],1860:[,220],1861:[,230],1862:[,220],1863:[,230],1864:[,220],1865:[,230],1866:[,230],2027:[,230],2028:[,230],2029:[,230],2030:[,230],2031:[,230],2032:[,230],2033:[,230],2034:[,220],2035:[,230]}, +2048:{2070:[,230],2071:[,230],2072:[,230],2073:[,230],2075:[,230],2076:[,230],2077:[,230],2078:[,230],2079:[,230],2080:[,230],2081:[,230],2082:[,230],2083:[,230],2085:[,230],2086:[,230],2087:[,230],2089:[,230],2090:[,230],2091:[,230],2092:[,230],2093:[,230],2137:[,220],2138:[,220],2139:[,220],2276:[,230],2277:[,230],2278:[,220],2279:[,230],2280:[,230],2281:[,220],2282:[,230],2283:[,230],2284:[,230],2285:[,220],2286:[,220],2287:[,220],2288:[,27],2289:[,28],2290:[,29],2291:[,230],2292:[,230],2293:[,230],2294:[,220],2295:[,230],2296:[,230],2297:[,220],2298:[,220],2299:[,230],2300:[,230],2301:[,230],2302:[,230],2303:[,230]}, +2304:{2344:[,,{2364:2345}],2345:[[2344,2364]],2352:[,,{2364:2353}],2353:[[2352,2364]],2355:[,,{2364:2356}],2356:[[2355,2364]],2364:[,7],2381:[,9],2385:[,230],2386:[,220],2387:[,230],2388:[,230],2392:[[2325,2364],512],2393:[[2326,2364],512],2394:[[2327,2364],512],2395:[[2332,2364],512],2396:[[2337,2364],512],2397:[[2338,2364],512],2398:[[2347,2364],512],2399:[[2351,2364],512],2492:[,7],2503:[,,{2494:2507,2519:2508}],2507:[[2503,2494]],2508:[[2503,2519]],2509:[,9],2524:[[2465,2492],512],2525:[[2466,2492],512],2527:[[2479,2492],512]}, +2560:{2611:[[2610,2620],512],2614:[[2616,2620],512],2620:[,7],2637:[,9],2649:[[2582,2620],512],2650:[[2583,2620],512],2651:[[2588,2620],512],2654:[[2603,2620],512],2748:[,7],2765:[,9],68109:[,220],68111:[,230],68152:[,230],68153:[,1],68154:[,220],68159:[,9],68325:[,230],68326:[,220]}, +2816:{2876:[,7],2887:[,,{2878:2891,2902:2888,2903:2892}],2888:[[2887,2902]],2891:[[2887,2878]],2892:[[2887,2903]],2893:[,9],2908:[[2849,2876],512],2909:[[2850,2876],512],2962:[,,{3031:2964}],2964:[[2962,3031]],3014:[,,{3006:3018,3031:3020}],3015:[,,{3006:3019}],3018:[[3014,3006]],3019:[[3015,3006]],3020:[[3014,3031]],3021:[,9]}, +3072:{3142:[,,{3158:3144}],3144:[[3142,3158]],3149:[,9],3157:[,84],3158:[,91],3260:[,7],3263:[,,{3285:3264}],3264:[[3263,3285]],3270:[,,{3266:3274,3285:3271,3286:3272}],3271:[[3270,3285]],3272:[[3270,3286]],3274:[[3270,3266],,{3285:3275}],3275:[[3274,3285]],3277:[,9]}, +3328:{3398:[,,{3390:3402,3415:3404}],3399:[,,{3390:3403}],3402:[[3398,3390]],3403:[[3399,3390]],3404:[[3398,3415]],3405:[,9],3530:[,9],3545:[,,{3530:3546,3535:3548,3551:3550}],3546:[[3545,3530]],3548:[[3545,3535],,{3530:3549}],3549:[[3548,3530]],3550:[[3545,3551]]}, +3584:{3635:[[3661,3634],256],3640:[,103],3641:[,103],3642:[,9],3656:[,107],3657:[,107],3658:[,107],3659:[,107],3763:[[3789,3762],256],3768:[,118],3769:[,118],3784:[,122],3785:[,122],3786:[,122],3787:[,122],3804:[[3755,3737],256],3805:[[3755,3745],256]}, +3840:{3852:[[3851],256],3864:[,220],3865:[,220],3893:[,220],3895:[,220],3897:[,216],3907:[[3906,4023],512],3917:[[3916,4023],512],3922:[[3921,4023],512],3927:[[3926,4023],512],3932:[[3931,4023],512],3945:[[3904,4021],512],3953:[,129],3954:[,130],3955:[[3953,3954],512],3956:[,132],3957:[[3953,3956],512],3958:[[4018,3968],512],3959:[[4018,3969],256],3960:[[4019,3968],512],3961:[[4019,3969],256],3962:[,130],3963:[,130],3964:[,130],3965:[,130],3968:[,130],3969:[[3953,3968],512],3970:[,230],3971:[,230],3972:[,9],3974:[,230],3975:[,230],3987:[[3986,4023],512],3997:[[3996,4023],512],4002:[[4001,4023],512],4007:[[4006,4023],512],4012:[[4011,4023],512],4025:[[3984,4021],512],4038:[,220]}, +4096:{4133:[,,{4142:4134}],4134:[[4133,4142]],4151:[,7],4153:[,9],4154:[,9],4237:[,220],4348:[[4316],256],69702:[,9],69759:[,9],69785:[,,{69818:69786}],69786:[[69785,69818]],69787:[,,{69818:69788}],69788:[[69787,69818]],69797:[,,{69818:69803}],69803:[[69797,69818]],69817:[,9],69818:[,7]}, +4352:{69888:[,230],69889:[,230],69890:[,230],69934:[[69937,69927]],69935:[[69938,69927]],69937:[,,{69927:69934}],69938:[,,{69927:69935}],69939:[,9],69940:[,9],70003:[,7],70080:[,9]}, +4608:{70197:[,9],70198:[,7],70377:[,7],70378:[,9]}, +4864:{4957:[,230],4958:[,230],4959:[,230],70460:[,7],70471:[,,{70462:70475,70487:70476}],70475:[[70471,70462]],70476:[[70471,70487]],70477:[,9],70502:[,230],70503:[,230],70504:[,230],70505:[,230],70506:[,230],70507:[,230],70508:[,230],70512:[,230],70513:[,230],70514:[,230],70515:[,230],70516:[,230]}, +5120:{70841:[,,{70832:70844,70842:70843,70845:70846}],70843:[[70841,70842]],70844:[[70841,70832]],70846:[[70841,70845]],70850:[,9],70851:[,7]}, +5376:{71096:[,,{71087:71098}],71097:[,,{71087:71099}],71098:[[71096,71087]],71099:[[71097,71087]],71103:[,9],71104:[,7]}, +5632:{71231:[,9],71350:[,9],71351:[,7]}, +5888:{5908:[,9],5940:[,9],6098:[,9],6109:[,230]}, +6144:{6313:[,228]}, +6400:{6457:[,222],6458:[,230],6459:[,220]}, +6656:{6679:[,230],6680:[,220],6752:[,9],6773:[,230],6774:[,230],6775:[,230],6776:[,230],6777:[,230],6778:[,230],6779:[,230],6780:[,230],6783:[,220],6832:[,230],6833:[,230],6834:[,230],6835:[,230],6836:[,230],6837:[,220],6838:[,220],6839:[,220],6840:[,220],6841:[,220],6842:[,220],6843:[,230],6844:[,230],6845:[,220]}, +6912:{6917:[,,{6965:6918}],6918:[[6917,6965]],6919:[,,{6965:6920}],6920:[[6919,6965]],6921:[,,{6965:6922}],6922:[[6921,6965]],6923:[,,{6965:6924}],6924:[[6923,6965]],6925:[,,{6965:6926}],6926:[[6925,6965]],6929:[,,{6965:6930}],6930:[[6929,6965]],6964:[,7],6970:[,,{6965:6971}],6971:[[6970,6965]],6972:[,,{6965:6973}],6973:[[6972,6965]],6974:[,,{6965:6976}],6975:[,,{6965:6977}],6976:[[6974,6965]],6977:[[6975,6965]],6978:[,,{6965:6979}],6979:[[6978,6965]],6980:[,9],7019:[,230],7020:[,220],7021:[,230],7022:[,230],7023:[,230],7024:[,230],7025:[,230],7026:[,230],7027:[,230],7082:[,9],7083:[,9],7142:[,7],7154:[,9],7155:[,9]}, +7168:{7223:[,7],7376:[,230],7377:[,230],7378:[,230],7380:[,1],7381:[,220],7382:[,220],7383:[,220],7384:[,220],7385:[,220],7386:[,230],7387:[,230],7388:[,220],7389:[,220],7390:[,220],7391:[,220],7392:[,230],7394:[,1],7395:[,1],7396:[,1],7397:[,1],7398:[,1],7399:[,1],7400:[,1],7405:[,220],7412:[,230],7416:[,230],7417:[,230]}, +7424:{7468:[[65],256],7469:[[198],256],7470:[[66],256],7472:[[68],256],7473:[[69],256],7474:[[398],256],7475:[[71],256],7476:[[72],256],7477:[[73],256],7478:[[74],256],7479:[[75],256],7480:[[76],256],7481:[[77],256],7482:[[78],256],7484:[[79],256],7485:[[546],256],7486:[[80],256],7487:[[82],256],7488:[[84],256],7489:[[85],256],7490:[[87],256],7491:[[97],256],7492:[[592],256],7493:[[593],256],7494:[[7426],256],7495:[[98],256],7496:[[100],256],7497:[[101],256],7498:[[601],256],7499:[[603],256],7500:[[604],256],7501:[[103],256],7503:[[107],256],7504:[[109],256],7505:[[331],256],7506:[[111],256],7507:[[596],256],7508:[[7446],256],7509:[[7447],256],7510:[[112],256],7511:[[116],256],7512:[[117],256],7513:[[7453],256],7514:[[623],256],7515:[[118],256],7516:[[7461],256],7517:[[946],256],7518:[[947],256],7519:[[948],256],7520:[[966],256],7521:[[967],256],7522:[[105],256],7523:[[114],256],7524:[[117],256],7525:[[118],256],7526:[[946],256],7527:[[947],256],7528:[[961],256],7529:[[966],256],7530:[[967],256],7544:[[1085],256],7579:[[594],256],7580:[[99],256],7581:[[597],256],7582:[[240],256],7583:[[604],256],7584:[[102],256],7585:[[607],256],7586:[[609],256],7587:[[613],256],7588:[[616],256],7589:[[617],256],7590:[[618],256],7591:[[7547],256],7592:[[669],256],7593:[[621],256],7594:[[7557],256],7595:[[671],256],7596:[[625],256],7597:[[624],256],7598:[[626],256],7599:[[627],256],7600:[[628],256],7601:[[629],256],7602:[[632],256],7603:[[642],256],7604:[[643],256],7605:[[427],256],7606:[[649],256],7607:[[650],256],7608:[[7452],256],7609:[[651],256],7610:[[652],256],7611:[[122],256],7612:[[656],256],7613:[[657],256],7614:[[658],256],7615:[[952],256],7616:[,230],7617:[,230],7618:[,220],7619:[,230],7620:[,230],7621:[,230],7622:[,230],7623:[,230],7624:[,230],7625:[,230],7626:[,220],7627:[,230],7628:[,230],7629:[,234],7630:[,214],7631:[,220],7632:[,202],7633:[,230],7634:[,230],7635:[,230],7636:[,230],7637:[,230],7638:[,230],7639:[,230],7640:[,230],7641:[,230],7642:[,230],7643:[,230],7644:[,230],7645:[,230],7646:[,230],7647:[,230],7648:[,230],7649:[,230],7650:[,230],7651:[,230],7652:[,230],7653:[,230],7654:[,230],7655:[,230],7656:[,230],7657:[,230],7658:[,230],7659:[,230],7660:[,230],7661:[,230],7662:[,230],7663:[,230],7664:[,230],7665:[,230],7666:[,230],7667:[,230],7668:[,230],7669:[,230],7676:[,233],7677:[,220],7678:[,230],7679:[,220]}, +7680:{7680:[[65,805]],7681:[[97,805]],7682:[[66,775]],7683:[[98,775]],7684:[[66,803]],7685:[[98,803]],7686:[[66,817]],7687:[[98,817]],7688:[[199,769]],7689:[[231,769]],7690:[[68,775]],7691:[[100,775]],7692:[[68,803]],7693:[[100,803]],7694:[[68,817]],7695:[[100,817]],7696:[[68,807]],7697:[[100,807]],7698:[[68,813]],7699:[[100,813]],7700:[[274,768]],7701:[[275,768]],7702:[[274,769]],7703:[[275,769]],7704:[[69,813]],7705:[[101,813]],7706:[[69,816]],7707:[[101,816]],7708:[[552,774]],7709:[[553,774]],7710:[[70,775]],7711:[[102,775]],7712:[[71,772]],7713:[[103,772]],7714:[[72,775]],7715:[[104,775]],7716:[[72,803]],7717:[[104,803]],7718:[[72,776]],7719:[[104,776]],7720:[[72,807]],7721:[[104,807]],7722:[[72,814]],7723:[[104,814]],7724:[[73,816]],7725:[[105,816]],7726:[[207,769]],7727:[[239,769]],7728:[[75,769]],7729:[[107,769]],7730:[[75,803]],7731:[[107,803]],7732:[[75,817]],7733:[[107,817]],7734:[[76,803],,{772:7736}],7735:[[108,803],,{772:7737}],7736:[[7734,772]],7737:[[7735,772]],7738:[[76,817]],7739:[[108,817]],7740:[[76,813]],7741:[[108,813]],7742:[[77,769]],7743:[[109,769]],7744:[[77,775]],7745:[[109,775]],7746:[[77,803]],7747:[[109,803]],7748:[[78,775]],7749:[[110,775]],7750:[[78,803]],7751:[[110,803]],7752:[[78,817]],7753:[[110,817]],7754:[[78,813]],7755:[[110,813]],7756:[[213,769]],7757:[[245,769]],7758:[[213,776]],7759:[[245,776]],7760:[[332,768]],7761:[[333,768]],7762:[[332,769]],7763:[[333,769]],7764:[[80,769]],7765:[[112,769]],7766:[[80,775]],7767:[[112,775]],7768:[[82,775]],7769:[[114,775]],7770:[[82,803],,{772:7772}],7771:[[114,803],,{772:7773}],7772:[[7770,772]],7773:[[7771,772]],7774:[[82,817]],7775:[[114,817]],7776:[[83,775]],7777:[[115,775]],7778:[[83,803],,{775:7784}],7779:[[115,803],,{775:7785}],7780:[[346,775]],7781:[[347,775]],7782:[[352,775]],7783:[[353,775]],7784:[[7778,775]],7785:[[7779,775]],7786:[[84,775]],7787:[[116,775]],7788:[[84,803]],7789:[[116,803]],7790:[[84,817]],7791:[[116,817]],7792:[[84,813]],7793:[[116,813]],7794:[[85,804]],7795:[[117,804]],7796:[[85,816]],7797:[[117,816]],7798:[[85,813]],7799:[[117,813]],7800:[[360,769]],7801:[[361,769]],7802:[[362,776]],7803:[[363,776]],7804:[[86,771]],7805:[[118,771]],7806:[[86,803]],7807:[[118,803]],7808:[[87,768]],7809:[[119,768]],7810:[[87,769]],7811:[[119,769]],7812:[[87,776]],7813:[[119,776]],7814:[[87,775]],7815:[[119,775]],7816:[[87,803]],7817:[[119,803]],7818:[[88,775]],7819:[[120,775]],7820:[[88,776]],7821:[[120,776]],7822:[[89,775]],7823:[[121,775]],7824:[[90,770]],7825:[[122,770]],7826:[[90,803]],7827:[[122,803]],7828:[[90,817]],7829:[[122,817]],7830:[[104,817]],7831:[[116,776]],7832:[[119,778]],7833:[[121,778]],7834:[[97,702],256],7835:[[383,775]],7840:[[65,803],,{770:7852,774:7862}],7841:[[97,803],,{770:7853,774:7863}],7842:[[65,777]],7843:[[97,777]],7844:[[194,769]],7845:[[226,769]],7846:[[194,768]],7847:[[226,768]],7848:[[194,777]],7849:[[226,777]],7850:[[194,771]],7851:[[226,771]],7852:[[7840,770]],7853:[[7841,770]],7854:[[258,769]],7855:[[259,769]],7856:[[258,768]],7857:[[259,768]],7858:[[258,777]],7859:[[259,777]],7860:[[258,771]],7861:[[259,771]],7862:[[7840,774]],7863:[[7841,774]],7864:[[69,803],,{770:7878}],7865:[[101,803],,{770:7879}],7866:[[69,777]],7867:[[101,777]],7868:[[69,771]],7869:[[101,771]],7870:[[202,769]],7871:[[234,769]],7872:[[202,768]],7873:[[234,768]],7874:[[202,777]],7875:[[234,777]],7876:[[202,771]],7877:[[234,771]],7878:[[7864,770]],7879:[[7865,770]],7880:[[73,777]],7881:[[105,777]],7882:[[73,803]],7883:[[105,803]],7884:[[79,803],,{770:7896}],7885:[[111,803],,{770:7897}],7886:[[79,777]],7887:[[111,777]],7888:[[212,769]],7889:[[244,769]],7890:[[212,768]],7891:[[244,768]],7892:[[212,777]],7893:[[244,777]],7894:[[212,771]],7895:[[244,771]],7896:[[7884,770]],7897:[[7885,770]],7898:[[416,769]],7899:[[417,769]],7900:[[416,768]],7901:[[417,768]],7902:[[416,777]],7903:[[417,777]],7904:[[416,771]],7905:[[417,771]],7906:[[416,803]],7907:[[417,803]],7908:[[85,803]],7909:[[117,803]],7910:[[85,777]],7911:[[117,777]],7912:[[431,769]],7913:[[432,769]],7914:[[431,768]],7915:[[432,768]],7916:[[431,777]],7917:[[432,777]],7918:[[431,771]],7919:[[432,771]],7920:[[431,803]],7921:[[432,803]],7922:[[89,768]],7923:[[121,768]],7924:[[89,803]],7925:[[121,803]],7926:[[89,777]],7927:[[121,777]],7928:[[89,771]],7929:[[121,771]]}, +7936:{7936:[[945,787],,{768:7938,769:7940,834:7942,837:8064}],7937:[[945,788],,{768:7939,769:7941,834:7943,837:8065}],7938:[[7936,768],,{837:8066}],7939:[[7937,768],,{837:8067}],7940:[[7936,769],,{837:8068}],7941:[[7937,769],,{837:8069}],7942:[[7936,834],,{837:8070}],7943:[[7937,834],,{837:8071}],7944:[[913,787],,{768:7946,769:7948,834:7950,837:8072}],7945:[[913,788],,{768:7947,769:7949,834:7951,837:8073}],7946:[[7944,768],,{837:8074}],7947:[[7945,768],,{837:8075}],7948:[[7944,769],,{837:8076}],7949:[[7945,769],,{837:8077}],7950:[[7944,834],,{837:8078}],7951:[[7945,834],,{837:8079}],7952:[[949,787],,{768:7954,769:7956}],7953:[[949,788],,{768:7955,769:7957}],7954:[[7952,768]],7955:[[7953,768]],7956:[[7952,769]],7957:[[7953,769]],7960:[[917,787],,{768:7962,769:7964}],7961:[[917,788],,{768:7963,769:7965}],7962:[[7960,768]],7963:[[7961,768]],7964:[[7960,769]],7965:[[7961,769]],7968:[[951,787],,{768:7970,769:7972,834:7974,837:8080}],7969:[[951,788],,{768:7971,769:7973,834:7975,837:8081}],7970:[[7968,768],,{837:8082}],7971:[[7969,768],,{837:8083}],7972:[[7968,769],,{837:8084}],7973:[[7969,769],,{837:8085}],7974:[[7968,834],,{837:8086}],7975:[[7969,834],,{837:8087}],7976:[[919,787],,{768:7978,769:7980,834:7982,837:8088}],7977:[[919,788],,{768:7979,769:7981,834:7983,837:8089}],7978:[[7976,768],,{837:8090}],7979:[[7977,768],,{837:8091}],7980:[[7976,769],,{837:8092}],7981:[[7977,769],,{837:8093}],7982:[[7976,834],,{837:8094}],7983:[[7977,834],,{837:8095}],7984:[[953,787],,{768:7986,769:7988,834:7990}],7985:[[953,788],,{768:7987,769:7989,834:7991}],7986:[[7984,768]],7987:[[7985,768]],7988:[[7984,769]],7989:[[7985,769]],7990:[[7984,834]],7991:[[7985,834]],7992:[[921,787],,{768:7994,769:7996,834:7998}],7993:[[921,788],,{768:7995,769:7997,834:7999}],7994:[[7992,768]],7995:[[7993,768]],7996:[[7992,769]],7997:[[7993,769]],7998:[[7992,834]],7999:[[7993,834]],8000:[[959,787],,{768:8002,769:8004}],8001:[[959,788],,{768:8003,769:8005}],8002:[[8000,768]],8003:[[8001,768]],8004:[[8000,769]],8005:[[8001,769]],8008:[[927,787],,{768:8010,769:8012}],8009:[[927,788],,{768:8011,769:8013}],8010:[[8008,768]],8011:[[8009,768]],8012:[[8008,769]],8013:[[8009,769]],8016:[[965,787],,{768:8018,769:8020,834:8022}],8017:[[965,788],,{768:8019,769:8021,834:8023}],8018:[[8016,768]],8019:[[8017,768]],8020:[[8016,769]],8021:[[8017,769]],8022:[[8016,834]],8023:[[8017,834]],8025:[[933,788],,{768:8027,769:8029,834:8031}],8027:[[8025,768]],8029:[[8025,769]],8031:[[8025,834]],8032:[[969,787],,{768:8034,769:8036,834:8038,837:8096}],8033:[[969,788],,{768:8035,769:8037,834:8039,837:8097}],8034:[[8032,768],,{837:8098}],8035:[[8033,768],,{837:8099}],8036:[[8032,769],,{837:8100}],8037:[[8033,769],,{837:8101}],8038:[[8032,834],,{837:8102}],8039:[[8033,834],,{837:8103}],8040:[[937,787],,{768:8042,769:8044,834:8046,837:8104}],8041:[[937,788],,{768:8043,769:8045,834:8047,837:8105}],8042:[[8040,768],,{837:8106}],8043:[[8041,768],,{837:8107}],8044:[[8040,769],,{837:8108}],8045:[[8041,769],,{837:8109}],8046:[[8040,834],,{837:8110}],8047:[[8041,834],,{837:8111}],8048:[[945,768],,{837:8114}],8049:[[940]],8050:[[949,768]],8051:[[941]],8052:[[951,768],,{837:8130}],8053:[[942]],8054:[[953,768]],8055:[[943]],8056:[[959,768]],8057:[[972]],8058:[[965,768]],8059:[[973]],8060:[[969,768],,{837:8178}],8061:[[974]],8064:[[7936,837]],8065:[[7937,837]],8066:[[7938,837]],8067:[[7939,837]],8068:[[7940,837]],8069:[[7941,837]],8070:[[7942,837]],8071:[[7943,837]],8072:[[7944,837]],8073:[[7945,837]],8074:[[7946,837]],8075:[[7947,837]],8076:[[7948,837]],8077:[[7949,837]],8078:[[7950,837]],8079:[[7951,837]],8080:[[7968,837]],8081:[[7969,837]],8082:[[7970,837]],8083:[[7971,837]],8084:[[7972,837]],8085:[[7973,837]],8086:[[7974,837]],8087:[[7975,837]],8088:[[7976,837]],8089:[[7977,837]],8090:[[7978,837]],8091:[[7979,837]],8092:[[7980,837]],8093:[[7981,837]],8094:[[7982,837]],8095:[[7983,837]],8096:[[8032,837]],8097:[[8033,837]],8098:[[8034,837]],8099:[[8035,837]],8100:[[8036,837]],8101:[[8037,837]],8102:[[8038,837]],8103:[[8039,837]],8104:[[8040,837]],8105:[[8041,837]],8106:[[8042,837]],8107:[[8043,837]],8108:[[8044,837]],8109:[[8045,837]],8110:[[8046,837]],8111:[[8047,837]],8112:[[945,774]],8113:[[945,772]],8114:[[8048,837]],8115:[[945,837]],8116:[[940,837]],8118:[[945,834],,{837:8119}],8119:[[8118,837]],8120:[[913,774]],8121:[[913,772]],8122:[[913,768]],8123:[[902]],8124:[[913,837]],8125:[[32,787],256],8126:[[953]],8127:[[32,787],256,{768:8141,769:8142,834:8143}],8128:[[32,834],256],8129:[[168,834]],8130:[[8052,837]],8131:[[951,837]],8132:[[942,837]],8134:[[951,834],,{837:8135}],8135:[[8134,837]],8136:[[917,768]],8137:[[904]],8138:[[919,768]],8139:[[905]],8140:[[919,837]],8141:[[8127,768]],8142:[[8127,769]],8143:[[8127,834]],8144:[[953,774]],8145:[[953,772]],8146:[[970,768]],8147:[[912]],8150:[[953,834]],8151:[[970,834]],8152:[[921,774]],8153:[[921,772]],8154:[[921,768]],8155:[[906]],8157:[[8190,768]],8158:[[8190,769]],8159:[[8190,834]],8160:[[965,774]],8161:[[965,772]],8162:[[971,768]],8163:[[944]],8164:[[961,787]],8165:[[961,788]],8166:[[965,834]],8167:[[971,834]],8168:[[933,774]],8169:[[933,772]],8170:[[933,768]],8171:[[910]],8172:[[929,788]],8173:[[168,768]],8174:[[901]],8175:[[96]],8178:[[8060,837]],8179:[[969,837]],8180:[[974,837]],8182:[[969,834],,{837:8183}],8183:[[8182,837]],8184:[[927,768]],8185:[[908]],8186:[[937,768]],8187:[[911]],8188:[[937,837]],8189:[[180]],8190:[[32,788],256,{768:8157,769:8158,834:8159}]}, +8192:{8192:[[8194]],8193:[[8195]],8194:[[32],256],8195:[[32],256],8196:[[32],256],8197:[[32],256],8198:[[32],256],8199:[[32],256],8200:[[32],256],8201:[[32],256],8202:[[32],256],8209:[[8208],256],8215:[[32,819],256],8228:[[46],256],8229:[[46,46],256],8230:[[46,46,46],256],8239:[[32],256],8243:[[8242,8242],256],8244:[[8242,8242,8242],256],8246:[[8245,8245],256],8247:[[8245,8245,8245],256],8252:[[33,33],256],8254:[[32,773],256],8263:[[63,63],256],8264:[[63,33],256],8265:[[33,63],256],8279:[[8242,8242,8242,8242],256],8287:[[32],256],8304:[[48],256],8305:[[105],256],8308:[[52],256],8309:[[53],256],8310:[[54],256],8311:[[55],256],8312:[[56],256],8313:[[57],256],8314:[[43],256],8315:[[8722],256],8316:[[61],256],8317:[[40],256],8318:[[41],256],8319:[[110],256],8320:[[48],256],8321:[[49],256],8322:[[50],256],8323:[[51],256],8324:[[52],256],8325:[[53],256],8326:[[54],256],8327:[[55],256],8328:[[56],256],8329:[[57],256],8330:[[43],256],8331:[[8722],256],8332:[[61],256],8333:[[40],256],8334:[[41],256],8336:[[97],256],8337:[[101],256],8338:[[111],256],8339:[[120],256],8340:[[601],256],8341:[[104],256],8342:[[107],256],8343:[[108],256],8344:[[109],256],8345:[[110],256],8346:[[112],256],8347:[[115],256],8348:[[116],256],8360:[[82,115],256],8400:[,230],8401:[,230],8402:[,1],8403:[,1],8404:[,230],8405:[,230],8406:[,230],8407:[,230],8408:[,1],8409:[,1],8410:[,1],8411:[,230],8412:[,230],8417:[,230],8421:[,1],8422:[,1],8423:[,230],8424:[,220],8425:[,230],8426:[,1],8427:[,1],8428:[,220],8429:[,220],8430:[,220],8431:[,220],8432:[,230]}, +8448:{8448:[[97,47,99],256],8449:[[97,47,115],256],8450:[[67],256],8451:[[176,67],256],8453:[[99,47,111],256],8454:[[99,47,117],256],8455:[[400],256],8457:[[176,70],256],8458:[[103],256],8459:[[72],256],8460:[[72],256],8461:[[72],256],8462:[[104],256],8463:[[295],256],8464:[[73],256],8465:[[73],256],8466:[[76],256],8467:[[108],256],8469:[[78],256],8470:[[78,111],256],8473:[[80],256],8474:[[81],256],8475:[[82],256],8476:[[82],256],8477:[[82],256],8480:[[83,77],256],8481:[[84,69,76],256],8482:[[84,77],256],8484:[[90],256],8486:[[937]],8488:[[90],256],8490:[[75]],8491:[[197]],8492:[[66],256],8493:[[67],256],8495:[[101],256],8496:[[69],256],8497:[[70],256],8499:[[77],256],8500:[[111],256],8501:[[1488],256],8502:[[1489],256],8503:[[1490],256],8504:[[1491],256],8505:[[105],256],8507:[[70,65,88],256],8508:[[960],256],8509:[[947],256],8510:[[915],256],8511:[[928],256],8512:[[8721],256],8517:[[68],256],8518:[[100],256],8519:[[101],256],8520:[[105],256],8521:[[106],256],8528:[[49,8260,55],256],8529:[[49,8260,57],256],8530:[[49,8260,49,48],256],8531:[[49,8260,51],256],8532:[[50,8260,51],256],8533:[[49,8260,53],256],8534:[[50,8260,53],256],8535:[[51,8260,53],256],8536:[[52,8260,53],256],8537:[[49,8260,54],256],8538:[[53,8260,54],256],8539:[[49,8260,56],256],8540:[[51,8260,56],256],8541:[[53,8260,56],256],8542:[[55,8260,56],256],8543:[[49,8260],256],8544:[[73],256],8545:[[73,73],256],8546:[[73,73,73],256],8547:[[73,86],256],8548:[[86],256],8549:[[86,73],256],8550:[[86,73,73],256],8551:[[86,73,73,73],256],8552:[[73,88],256],8553:[[88],256],8554:[[88,73],256],8555:[[88,73,73],256],8556:[[76],256],8557:[[67],256],8558:[[68],256],8559:[[77],256],8560:[[105],256],8561:[[105,105],256],8562:[[105,105,105],256],8563:[[105,118],256],8564:[[118],256],8565:[[118,105],256],8566:[[118,105,105],256],8567:[[118,105,105,105],256],8568:[[105,120],256],8569:[[120],256],8570:[[120,105],256],8571:[[120,105,105],256],8572:[[108],256],8573:[[99],256],8574:[[100],256],8575:[[109],256],8585:[[48,8260,51],256],8592:[,,{824:8602}],8594:[,,{824:8603}],8596:[,,{824:8622}],8602:[[8592,824]],8603:[[8594,824]],8622:[[8596,824]],8653:[[8656,824]],8654:[[8660,824]],8655:[[8658,824]],8656:[,,{824:8653}],8658:[,,{824:8655}],8660:[,,{824:8654}]}, +8704:{8707:[,,{824:8708}],8708:[[8707,824]],8712:[,,{824:8713}],8713:[[8712,824]],8715:[,,{824:8716}],8716:[[8715,824]],8739:[,,{824:8740}],8740:[[8739,824]],8741:[,,{824:8742}],8742:[[8741,824]],8748:[[8747,8747],256],8749:[[8747,8747,8747],256],8751:[[8750,8750],256],8752:[[8750,8750,8750],256],8764:[,,{824:8769}],8769:[[8764,824]],8771:[,,{824:8772}],8772:[[8771,824]],8773:[,,{824:8775}],8775:[[8773,824]],8776:[,,{824:8777}],8777:[[8776,824]],8781:[,,{824:8813}],8800:[[61,824]],8801:[,,{824:8802}],8802:[[8801,824]],8804:[,,{824:8816}],8805:[,,{824:8817}],8813:[[8781,824]],8814:[[60,824]],8815:[[62,824]],8816:[[8804,824]],8817:[[8805,824]],8818:[,,{824:8820}],8819:[,,{824:8821}],8820:[[8818,824]],8821:[[8819,824]],8822:[,,{824:8824}],8823:[,,{824:8825}],8824:[[8822,824]],8825:[[8823,824]],8826:[,,{824:8832}],8827:[,,{824:8833}],8828:[,,{824:8928}],8829:[,,{824:8929}],8832:[[8826,824]],8833:[[8827,824]],8834:[,,{824:8836}],8835:[,,{824:8837}],8836:[[8834,824]],8837:[[8835,824]],8838:[,,{824:8840}],8839:[,,{824:8841}],8840:[[8838,824]],8841:[[8839,824]],8849:[,,{824:8930}],8850:[,,{824:8931}],8866:[,,{824:8876}],8872:[,,{824:8877}],8873:[,,{824:8878}],8875:[,,{824:8879}],8876:[[8866,824]],8877:[[8872,824]],8878:[[8873,824]],8879:[[8875,824]],8882:[,,{824:8938}],8883:[,,{824:8939}],8884:[,,{824:8940}],8885:[,,{824:8941}],8928:[[8828,824]],8929:[[8829,824]],8930:[[8849,824]],8931:[[8850,824]],8938:[[8882,824]],8939:[[8883,824]],8940:[[8884,824]],8941:[[8885,824]]}, +8960:{9001:[[12296]],9002:[[12297]]}, +9216:{9312:[[49],256],9313:[[50],256],9314:[[51],256],9315:[[52],256],9316:[[53],256],9317:[[54],256],9318:[[55],256],9319:[[56],256],9320:[[57],256],9321:[[49,48],256],9322:[[49,49],256],9323:[[49,50],256],9324:[[49,51],256],9325:[[49,52],256],9326:[[49,53],256],9327:[[49,54],256],9328:[[49,55],256],9329:[[49,56],256],9330:[[49,57],256],9331:[[50,48],256],9332:[[40,49,41],256],9333:[[40,50,41],256],9334:[[40,51,41],256],9335:[[40,52,41],256],9336:[[40,53,41],256],9337:[[40,54,41],256],9338:[[40,55,41],256],9339:[[40,56,41],256],9340:[[40,57,41],256],9341:[[40,49,48,41],256],9342:[[40,49,49,41],256],9343:[[40,49,50,41],256],9344:[[40,49,51,41],256],9345:[[40,49,52,41],256],9346:[[40,49,53,41],256],9347:[[40,49,54,41],256],9348:[[40,49,55,41],256],9349:[[40,49,56,41],256],9350:[[40,49,57,41],256],9351:[[40,50,48,41],256],9352:[[49,46],256],9353:[[50,46],256],9354:[[51,46],256],9355:[[52,46],256],9356:[[53,46],256],9357:[[54,46],256],9358:[[55,46],256],9359:[[56,46],256],9360:[[57,46],256],9361:[[49,48,46],256],9362:[[49,49,46],256],9363:[[49,50,46],256],9364:[[49,51,46],256],9365:[[49,52,46],256],9366:[[49,53,46],256],9367:[[49,54,46],256],9368:[[49,55,46],256],9369:[[49,56,46],256],9370:[[49,57,46],256],9371:[[50,48,46],256],9372:[[40,97,41],256],9373:[[40,98,41],256],9374:[[40,99,41],256],9375:[[40,100,41],256],9376:[[40,101,41],256],9377:[[40,102,41],256],9378:[[40,103,41],256],9379:[[40,104,41],256],9380:[[40,105,41],256],9381:[[40,106,41],256],9382:[[40,107,41],256],9383:[[40,108,41],256],9384:[[40,109,41],256],9385:[[40,110,41],256],9386:[[40,111,41],256],9387:[[40,112,41],256],9388:[[40,113,41],256],9389:[[40,114,41],256],9390:[[40,115,41],256],9391:[[40,116,41],256],9392:[[40,117,41],256],9393:[[40,118,41],256],9394:[[40,119,41],256],9395:[[40,120,41],256],9396:[[40,121,41],256],9397:[[40,122,41],256],9398:[[65],256],9399:[[66],256],9400:[[67],256],9401:[[68],256],9402:[[69],256],9403:[[70],256],9404:[[71],256],9405:[[72],256],9406:[[73],256],9407:[[74],256],9408:[[75],256],9409:[[76],256],9410:[[77],256],9411:[[78],256],9412:[[79],256],9413:[[80],256],9414:[[81],256],9415:[[82],256],9416:[[83],256],9417:[[84],256],9418:[[85],256],9419:[[86],256],9420:[[87],256],9421:[[88],256],9422:[[89],256],9423:[[90],256],9424:[[97],256],9425:[[98],256],9426:[[99],256],9427:[[100],256],9428:[[101],256],9429:[[102],256],9430:[[103],256],9431:[[104],256],9432:[[105],256],9433:[[106],256],9434:[[107],256],9435:[[108],256],9436:[[109],256],9437:[[110],256],9438:[[111],256],9439:[[112],256],9440:[[113],256],9441:[[114],256],9442:[[115],256],9443:[[116],256],9444:[[117],256],9445:[[118],256],9446:[[119],256],9447:[[120],256],9448:[[121],256],9449:[[122],256],9450:[[48],256]}, +10752:{10764:[[8747,8747,8747,8747],256],10868:[[58,58,61],256],10869:[[61,61],256],10870:[[61,61,61],256],10972:[[10973,824],512]}, +11264:{11388:[[106],256],11389:[[86],256],11503:[,230],11504:[,230],11505:[,230]}, +11520:{11631:[[11617],256],11647:[,9],11744:[,230],11745:[,230],11746:[,230],11747:[,230],11748:[,230],11749:[,230],11750:[,230],11751:[,230],11752:[,230],11753:[,230],11754:[,230],11755:[,230],11756:[,230],11757:[,230],11758:[,230],11759:[,230],11760:[,230],11761:[,230],11762:[,230],11763:[,230],11764:[,230],11765:[,230],11766:[,230],11767:[,230],11768:[,230],11769:[,230],11770:[,230],11771:[,230],11772:[,230],11773:[,230],11774:[,230],11775:[,230]}, +11776:{11935:[[27597],256],12019:[[40863],256]}, +12032:{12032:[[19968],256],12033:[[20008],256],12034:[[20022],256],12035:[[20031],256],12036:[[20057],256],12037:[[20101],256],12038:[[20108],256],12039:[[20128],256],12040:[[20154],256],12041:[[20799],256],12042:[[20837],256],12043:[[20843],256],12044:[[20866],256],12045:[[20886],256],12046:[[20907],256],12047:[[20960],256],12048:[[20981],256],12049:[[20992],256],12050:[[21147],256],12051:[[21241],256],12052:[[21269],256],12053:[[21274],256],12054:[[21304],256],12055:[[21313],256],12056:[[21340],256],12057:[[21353],256],12058:[[21378],256],12059:[[21430],256],12060:[[21448],256],12061:[[21475],256],12062:[[22231],256],12063:[[22303],256],12064:[[22763],256],12065:[[22786],256],12066:[[22794],256],12067:[[22805],256],12068:[[22823],256],12069:[[22899],256],12070:[[23376],256],12071:[[23424],256],12072:[[23544],256],12073:[[23567],256],12074:[[23586],256],12075:[[23608],256],12076:[[23662],256],12077:[[23665],256],12078:[[24027],256],12079:[[24037],256],12080:[[24049],256],12081:[[24062],256],12082:[[24178],256],12083:[[24186],256],12084:[[24191],256],12085:[[24308],256],12086:[[24318],256],12087:[[24331],256],12088:[[24339],256],12089:[[24400],256],12090:[[24417],256],12091:[[24435],256],12092:[[24515],256],12093:[[25096],256],12094:[[25142],256],12095:[[25163],256],12096:[[25903],256],12097:[[25908],256],12098:[[25991],256],12099:[[26007],256],12100:[[26020],256],12101:[[26041],256],12102:[[26080],256],12103:[[26085],256],12104:[[26352],256],12105:[[26376],256],12106:[[26408],256],12107:[[27424],256],12108:[[27490],256],12109:[[27513],256],12110:[[27571],256],12111:[[27595],256],12112:[[27604],256],12113:[[27611],256],12114:[[27663],256],12115:[[27668],256],12116:[[27700],256],12117:[[28779],256],12118:[[29226],256],12119:[[29238],256],12120:[[29243],256],12121:[[29247],256],12122:[[29255],256],12123:[[29273],256],12124:[[29275],256],12125:[[29356],256],12126:[[29572],256],12127:[[29577],256],12128:[[29916],256],12129:[[29926],256],12130:[[29976],256],12131:[[29983],256],12132:[[29992],256],12133:[[30000],256],12134:[[30091],256],12135:[[30098],256],12136:[[30326],256],12137:[[30333],256],12138:[[30382],256],12139:[[30399],256],12140:[[30446],256],12141:[[30683],256],12142:[[30690],256],12143:[[30707],256],12144:[[31034],256],12145:[[31160],256],12146:[[31166],256],12147:[[31348],256],12148:[[31435],256],12149:[[31481],256],12150:[[31859],256],12151:[[31992],256],12152:[[32566],256],12153:[[32593],256],12154:[[32650],256],12155:[[32701],256],12156:[[32769],256],12157:[[32780],256],12158:[[32786],256],12159:[[32819],256],12160:[[32895],256],12161:[[32905],256],12162:[[33251],256],12163:[[33258],256],12164:[[33267],256],12165:[[33276],256],12166:[[33292],256],12167:[[33307],256],12168:[[33311],256],12169:[[33390],256],12170:[[33394],256],12171:[[33400],256],12172:[[34381],256],12173:[[34411],256],12174:[[34880],256],12175:[[34892],256],12176:[[34915],256],12177:[[35198],256],12178:[[35211],256],12179:[[35282],256],12180:[[35328],256],12181:[[35895],256],12182:[[35910],256],12183:[[35925],256],12184:[[35960],256],12185:[[35997],256],12186:[[36196],256],12187:[[36208],256],12188:[[36275],256],12189:[[36523],256],12190:[[36554],256],12191:[[36763],256],12192:[[36784],256],12193:[[36789],256],12194:[[37009],256],12195:[[37193],256],12196:[[37318],256],12197:[[37324],256],12198:[[37329],256],12199:[[38263],256],12200:[[38272],256],12201:[[38428],256],12202:[[38582],256],12203:[[38585],256],12204:[[38632],256],12205:[[38737],256],12206:[[38750],256],12207:[[38754],256],12208:[[38761],256],12209:[[38859],256],12210:[[38893],256],12211:[[38899],256],12212:[[38913],256],12213:[[39080],256],12214:[[39131],256],12215:[[39135],256],12216:[[39318],256],12217:[[39321],256],12218:[[39340],256],12219:[[39592],256],12220:[[39640],256],12221:[[39647],256],12222:[[39717],256],12223:[[39727],256],12224:[[39730],256],12225:[[39740],256],12226:[[39770],256],12227:[[40165],256],12228:[[40565],256],12229:[[40575],256],12230:[[40613],256],12231:[[40635],256],12232:[[40643],256],12233:[[40653],256],12234:[[40657],256],12235:[[40697],256],12236:[[40701],256],12237:[[40718],256],12238:[[40723],256],12239:[[40736],256],12240:[[40763],256],12241:[[40778],256],12242:[[40786],256],12243:[[40845],256],12244:[[40860],256],12245:[[40864],256]}, +12288:{12288:[[32],256],12330:[,218],12331:[,228],12332:[,232],12333:[,222],12334:[,224],12335:[,224],12342:[[12306],256],12344:[[21313],256],12345:[[21316],256],12346:[[21317],256],12358:[,,{12441:12436}],12363:[,,{12441:12364}],12364:[[12363,12441]],12365:[,,{12441:12366}],12366:[[12365,12441]],12367:[,,{12441:12368}],12368:[[12367,12441]],12369:[,,{12441:12370}],12370:[[12369,12441]],12371:[,,{12441:12372}],12372:[[12371,12441]],12373:[,,{12441:12374}],12374:[[12373,12441]],12375:[,,{12441:12376}],12376:[[12375,12441]],12377:[,,{12441:12378}],12378:[[12377,12441]],12379:[,,{12441:12380}],12380:[[12379,12441]],12381:[,,{12441:12382}],12382:[[12381,12441]],12383:[,,{12441:12384}],12384:[[12383,12441]],12385:[,,{12441:12386}],12386:[[12385,12441]],12388:[,,{12441:12389}],12389:[[12388,12441]],12390:[,,{12441:12391}],12391:[[12390,12441]],12392:[,,{12441:12393}],12393:[[12392,12441]],12399:[,,{12441:12400,12442:12401}],12400:[[12399,12441]],12401:[[12399,12442]],12402:[,,{12441:12403,12442:12404}],12403:[[12402,12441]],12404:[[12402,12442]],12405:[,,{12441:12406,12442:12407}],12406:[[12405,12441]],12407:[[12405,12442]],12408:[,,{12441:12409,12442:12410}],12409:[[12408,12441]],12410:[[12408,12442]],12411:[,,{12441:12412,12442:12413}],12412:[[12411,12441]],12413:[[12411,12442]],12436:[[12358,12441]],12441:[,8],12442:[,8],12443:[[32,12441],256],12444:[[32,12442],256],12445:[,,{12441:12446}],12446:[[12445,12441]],12447:[[12424,12426],256],12454:[,,{12441:12532}],12459:[,,{12441:12460}],12460:[[12459,12441]],12461:[,,{12441:12462}],12462:[[12461,12441]],12463:[,,{12441:12464}],12464:[[12463,12441]],12465:[,,{12441:12466}],12466:[[12465,12441]],12467:[,,{12441:12468}],12468:[[12467,12441]],12469:[,,{12441:12470}],12470:[[12469,12441]],12471:[,,{12441:12472}],12472:[[12471,12441]],12473:[,,{12441:12474}],12474:[[12473,12441]],12475:[,,{12441:12476}],12476:[[12475,12441]],12477:[,,{12441:12478}],12478:[[12477,12441]],12479:[,,{12441:12480}],12480:[[12479,12441]],12481:[,,{12441:12482}],12482:[[12481,12441]],12484:[,,{12441:12485}],12485:[[12484,12441]],12486:[,,{12441:12487}],12487:[[12486,12441]],12488:[,,{12441:12489}],12489:[[12488,12441]],12495:[,,{12441:12496,12442:12497}],12496:[[12495,12441]],12497:[[12495,12442]],12498:[,,{12441:12499,12442:12500}],12499:[[12498,12441]],12500:[[12498,12442]],12501:[,,{12441:12502,12442:12503}],12502:[[12501,12441]],12503:[[12501,12442]],12504:[,,{12441:12505,12442:12506}],12505:[[12504,12441]],12506:[[12504,12442]],12507:[,,{12441:12508,12442:12509}],12508:[[12507,12441]],12509:[[12507,12442]],12527:[,,{12441:12535}],12528:[,,{12441:12536}],12529:[,,{12441:12537}],12530:[,,{12441:12538}],12532:[[12454,12441]],12535:[[12527,12441]],12536:[[12528,12441]],12537:[[12529,12441]],12538:[[12530,12441]],12541:[,,{12441:12542}],12542:[[12541,12441]],12543:[[12467,12488],256]}, +12544:{12593:[[4352],256],12594:[[4353],256],12595:[[4522],256],12596:[[4354],256],12597:[[4524],256],12598:[[4525],256],12599:[[4355],256],12600:[[4356],256],12601:[[4357],256],12602:[[4528],256],12603:[[4529],256],12604:[[4530],256],12605:[[4531],256],12606:[[4532],256],12607:[[4533],256],12608:[[4378],256],12609:[[4358],256],12610:[[4359],256],12611:[[4360],256],12612:[[4385],256],12613:[[4361],256],12614:[[4362],256],12615:[[4363],256],12616:[[4364],256],12617:[[4365],256],12618:[[4366],256],12619:[[4367],256],12620:[[4368],256],12621:[[4369],256],12622:[[4370],256],12623:[[4449],256],12624:[[4450],256],12625:[[4451],256],12626:[[4452],256],12627:[[4453],256],12628:[[4454],256],12629:[[4455],256],12630:[[4456],256],12631:[[4457],256],12632:[[4458],256],12633:[[4459],256],12634:[[4460],256],12635:[[4461],256],12636:[[4462],256],12637:[[4463],256],12638:[[4464],256],12639:[[4465],256],12640:[[4466],256],12641:[[4467],256],12642:[[4468],256],12643:[[4469],256],12644:[[4448],256],12645:[[4372],256],12646:[[4373],256],12647:[[4551],256],12648:[[4552],256],12649:[[4556],256],12650:[[4558],256],12651:[[4563],256],12652:[[4567],256],12653:[[4569],256],12654:[[4380],256],12655:[[4573],256],12656:[[4575],256],12657:[[4381],256],12658:[[4382],256],12659:[[4384],256],12660:[[4386],256],12661:[[4387],256],12662:[[4391],256],12663:[[4393],256],12664:[[4395],256],12665:[[4396],256],12666:[[4397],256],12667:[[4398],256],12668:[[4399],256],12669:[[4402],256],12670:[[4406],256],12671:[[4416],256],12672:[[4423],256],12673:[[4428],256],12674:[[4593],256],12675:[[4594],256],12676:[[4439],256],12677:[[4440],256],12678:[[4441],256],12679:[[4484],256],12680:[[4485],256],12681:[[4488],256],12682:[[4497],256],12683:[[4498],256],12684:[[4500],256],12685:[[4510],256],12686:[[4513],256],12690:[[19968],256],12691:[[20108],256],12692:[[19977],256],12693:[[22235],256],12694:[[19978],256],12695:[[20013],256],12696:[[19979],256],12697:[[30002],256],12698:[[20057],256],12699:[[19993],256],12700:[[19969],256],12701:[[22825],256],12702:[[22320],256],12703:[[20154],256]}, +12800:{12800:[[40,4352,41],256],12801:[[40,4354,41],256],12802:[[40,4355,41],256],12803:[[40,4357,41],256],12804:[[40,4358,41],256],12805:[[40,4359,41],256],12806:[[40,4361,41],256],12807:[[40,4363,41],256],12808:[[40,4364,41],256],12809:[[40,4366,41],256],12810:[[40,4367,41],256],12811:[[40,4368,41],256],12812:[[40,4369,41],256],12813:[[40,4370,41],256],12814:[[40,4352,4449,41],256],12815:[[40,4354,4449,41],256],12816:[[40,4355,4449,41],256],12817:[[40,4357,4449,41],256],12818:[[40,4358,4449,41],256],12819:[[40,4359,4449,41],256],12820:[[40,4361,4449,41],256],12821:[[40,4363,4449,41],256],12822:[[40,4364,4449,41],256],12823:[[40,4366,4449,41],256],12824:[[40,4367,4449,41],256],12825:[[40,4368,4449,41],256],12826:[[40,4369,4449,41],256],12827:[[40,4370,4449,41],256],12828:[[40,4364,4462,41],256],12829:[[40,4363,4457,4364,4453,4523,41],256],12830:[[40,4363,4457,4370,4462,41],256],12832:[[40,19968,41],256],12833:[[40,20108,41],256],12834:[[40,19977,41],256],12835:[[40,22235,41],256],12836:[[40,20116,41],256],12837:[[40,20845,41],256],12838:[[40,19971,41],256],12839:[[40,20843,41],256],12840:[[40,20061,41],256],12841:[[40,21313,41],256],12842:[[40,26376,41],256],12843:[[40,28779,41],256],12844:[[40,27700,41],256],12845:[[40,26408,41],256],12846:[[40,37329,41],256],12847:[[40,22303,41],256],12848:[[40,26085,41],256],12849:[[40,26666,41],256],12850:[[40,26377,41],256],12851:[[40,31038,41],256],12852:[[40,21517,41],256],12853:[[40,29305,41],256],12854:[[40,36001,41],256],12855:[[40,31069,41],256],12856:[[40,21172,41],256],12857:[[40,20195,41],256],12858:[[40,21628,41],256],12859:[[40,23398,41],256],12860:[[40,30435,41],256],12861:[[40,20225,41],256],12862:[[40,36039,41],256],12863:[[40,21332,41],256],12864:[[40,31085,41],256],12865:[[40,20241,41],256],12866:[[40,33258,41],256],12867:[[40,33267,41],256],12868:[[21839],256],12869:[[24188],256],12870:[[25991],256],12871:[[31631],256],12880:[[80,84,69],256],12881:[[50,49],256],12882:[[50,50],256],12883:[[50,51],256],12884:[[50,52],256],12885:[[50,53],256],12886:[[50,54],256],12887:[[50,55],256],12888:[[50,56],256],12889:[[50,57],256],12890:[[51,48],256],12891:[[51,49],256],12892:[[51,50],256],12893:[[51,51],256],12894:[[51,52],256],12895:[[51,53],256],12896:[[4352],256],12897:[[4354],256],12898:[[4355],256],12899:[[4357],256],12900:[[4358],256],12901:[[4359],256],12902:[[4361],256],12903:[[4363],256],12904:[[4364],256],12905:[[4366],256],12906:[[4367],256],12907:[[4368],256],12908:[[4369],256],12909:[[4370],256],12910:[[4352,4449],256],12911:[[4354,4449],256],12912:[[4355,4449],256],12913:[[4357,4449],256],12914:[[4358,4449],256],12915:[[4359,4449],256],12916:[[4361,4449],256],12917:[[4363,4449],256],12918:[[4364,4449],256],12919:[[4366,4449],256],12920:[[4367,4449],256],12921:[[4368,4449],256],12922:[[4369,4449],256],12923:[[4370,4449],256],12924:[[4366,4449,4535,4352,4457],256],12925:[[4364,4462,4363,4468],256],12926:[[4363,4462],256],12928:[[19968],256],12929:[[20108],256],12930:[[19977],256],12931:[[22235],256],12932:[[20116],256],12933:[[20845],256],12934:[[19971],256],12935:[[20843],256],12936:[[20061],256],12937:[[21313],256],12938:[[26376],256],12939:[[28779],256],12940:[[27700],256],12941:[[26408],256],12942:[[37329],256],12943:[[22303],256],12944:[[26085],256],12945:[[26666],256],12946:[[26377],256],12947:[[31038],256],12948:[[21517],256],12949:[[29305],256],12950:[[36001],256],12951:[[31069],256],12952:[[21172],256],12953:[[31192],256],12954:[[30007],256],12955:[[22899],256],12956:[[36969],256],12957:[[20778],256],12958:[[21360],256],12959:[[27880],256],12960:[[38917],256],12961:[[20241],256],12962:[[20889],256],12963:[[27491],256],12964:[[19978],256],12965:[[20013],256],12966:[[19979],256],12967:[[24038],256],12968:[[21491],256],12969:[[21307],256],12970:[[23447],256],12971:[[23398],256],12972:[[30435],256],12973:[[20225],256],12974:[[36039],256],12975:[[21332],256],12976:[[22812],256],12977:[[51,54],256],12978:[[51,55],256],12979:[[51,56],256],12980:[[51,57],256],12981:[[52,48],256],12982:[[52,49],256],12983:[[52,50],256],12984:[[52,51],256],12985:[[52,52],256],12986:[[52,53],256],12987:[[52,54],256],12988:[[52,55],256],12989:[[52,56],256],12990:[[52,57],256],12991:[[53,48],256],12992:[[49,26376],256],12993:[[50,26376],256],12994:[[51,26376],256],12995:[[52,26376],256],12996:[[53,26376],256],12997:[[54,26376],256],12998:[[55,26376],256],12999:[[56,26376],256],13000:[[57,26376],256],13001:[[49,48,26376],256],13002:[[49,49,26376],256],13003:[[49,50,26376],256],13004:[[72,103],256],13005:[[101,114,103],256],13006:[[101,86],256],13007:[[76,84,68],256],13008:[[12450],256],13009:[[12452],256],13010:[[12454],256],13011:[[12456],256],13012:[[12458],256],13013:[[12459],256],13014:[[12461],256],13015:[[12463],256],13016:[[12465],256],13017:[[12467],256],13018:[[12469],256],13019:[[12471],256],13020:[[12473],256],13021:[[12475],256],13022:[[12477],256],13023:[[12479],256],13024:[[12481],256],13025:[[12484],256],13026:[[12486],256],13027:[[12488],256],13028:[[12490],256],13029:[[12491],256],13030:[[12492],256],13031:[[12493],256],13032:[[12494],256],13033:[[12495],256],13034:[[12498],256],13035:[[12501],256],13036:[[12504],256],13037:[[12507],256],13038:[[12510],256],13039:[[12511],256],13040:[[12512],256],13041:[[12513],256],13042:[[12514],256],13043:[[12516],256],13044:[[12518],256],13045:[[12520],256],13046:[[12521],256],13047:[[12522],256],13048:[[12523],256],13049:[[12524],256],13050:[[12525],256],13051:[[12527],256],13052:[[12528],256],13053:[[12529],256],13054:[[12530],256]}, +13056:{13056:[[12450,12497,12540,12488],256],13057:[[12450,12523,12501,12449],256],13058:[[12450,12531,12506,12450],256],13059:[[12450,12540,12523],256],13060:[[12452,12491,12531,12464],256],13061:[[12452,12531,12481],256],13062:[[12454,12457,12531],256],13063:[[12456,12473,12463,12540,12489],256],13064:[[12456,12540,12459,12540],256],13065:[[12458,12531,12473],256],13066:[[12458,12540,12512],256],13067:[[12459,12452,12522],256],13068:[[12459,12521,12483,12488],256],13069:[[12459,12525,12522,12540],256],13070:[[12460,12525,12531],256],13071:[[12460,12531,12510],256],13072:[[12462,12460],256],13073:[[12462,12491,12540],256],13074:[[12461,12517,12522,12540],256],13075:[[12462,12523,12480,12540],256],13076:[[12461,12525],256],13077:[[12461,12525,12464,12521,12512],256],13078:[[12461,12525,12513,12540,12488,12523],256],13079:[[12461,12525,12527,12483,12488],256],13080:[[12464,12521,12512],256],13081:[[12464,12521,12512,12488,12531],256],13082:[[12463,12523,12476,12452,12525],256],13083:[[12463,12525,12540,12493],256],13084:[[12465,12540,12473],256],13085:[[12467,12523,12490],256],13086:[[12467,12540,12509],256],13087:[[12469,12452,12463,12523],256],13088:[[12469,12531,12481,12540,12512],256],13089:[[12471,12522,12531,12464],256],13090:[[12475,12531,12481],256],13091:[[12475,12531,12488],256],13092:[[12480,12540,12473],256],13093:[[12487,12471],256],13094:[[12489,12523],256],13095:[[12488,12531],256],13096:[[12490,12494],256],13097:[[12494,12483,12488],256],13098:[[12495,12452,12484],256],13099:[[12497,12540,12475,12531,12488],256],13100:[[12497,12540,12484],256],13101:[[12496,12540,12524,12523],256],13102:[[12500,12450,12473,12488,12523],256],13103:[[12500,12463,12523],256],13104:[[12500,12467],256],13105:[[12499,12523],256],13106:[[12501,12449,12521,12483,12489],256],13107:[[12501,12451,12540,12488],256],13108:[[12502,12483,12471,12455,12523],256],13109:[[12501,12521,12531],256],13110:[[12504,12463,12479,12540,12523],256],13111:[[12506,12477],256],13112:[[12506,12491,12498],256],13113:[[12504,12523,12484],256],13114:[[12506,12531,12473],256],13115:[[12506,12540,12472],256],13116:[[12505,12540,12479],256],13117:[[12509,12452,12531,12488],256],13118:[[12508,12523,12488],256],13119:[[12507,12531],256],13120:[[12509,12531,12489],256],13121:[[12507,12540,12523],256],13122:[[12507,12540,12531],256],13123:[[12510,12452,12463,12525],256],13124:[[12510,12452,12523],256],13125:[[12510,12483,12495],256],13126:[[12510,12523,12463],256],13127:[[12510,12531,12471,12519,12531],256],13128:[[12511,12463,12525,12531],256],13129:[[12511,12522],256],13130:[[12511,12522,12496,12540,12523],256],13131:[[12513,12460],256],13132:[[12513,12460,12488,12531],256],13133:[[12513,12540,12488,12523],256],13134:[[12516,12540,12489],256],13135:[[12516,12540,12523],256],13136:[[12518,12450,12531],256],13137:[[12522,12483,12488,12523],256],13138:[[12522,12521],256],13139:[[12523,12500,12540],256],13140:[[12523,12540,12502,12523],256],13141:[[12524,12512],256],13142:[[12524,12531,12488,12466,12531],256],13143:[[12527,12483,12488],256],13144:[[48,28857],256],13145:[[49,28857],256],13146:[[50,28857],256],13147:[[51,28857],256],13148:[[52,28857],256],13149:[[53,28857],256],13150:[[54,28857],256],13151:[[55,28857],256],13152:[[56,28857],256],13153:[[57,28857],256],13154:[[49,48,28857],256],13155:[[49,49,28857],256],13156:[[49,50,28857],256],13157:[[49,51,28857],256],13158:[[49,52,28857],256],13159:[[49,53,28857],256],13160:[[49,54,28857],256],13161:[[49,55,28857],256],13162:[[49,56,28857],256],13163:[[49,57,28857],256],13164:[[50,48,28857],256],13165:[[50,49,28857],256],13166:[[50,50,28857],256],13167:[[50,51,28857],256],13168:[[50,52,28857],256],13169:[[104,80,97],256],13170:[[100,97],256],13171:[[65,85],256],13172:[[98,97,114],256],13173:[[111,86],256],13174:[[112,99],256],13175:[[100,109],256],13176:[[100,109,178],256],13177:[[100,109,179],256],13178:[[73,85],256],13179:[[24179,25104],256],13180:[[26157,21644],256],13181:[[22823,27491],256],13182:[[26126,27835],256],13183:[[26666,24335,20250,31038],256],13184:[[112,65],256],13185:[[110,65],256],13186:[[956,65],256],13187:[[109,65],256],13188:[[107,65],256],13189:[[75,66],256],13190:[[77,66],256],13191:[[71,66],256],13192:[[99,97,108],256],13193:[[107,99,97,108],256],13194:[[112,70],256],13195:[[110,70],256],13196:[[956,70],256],13197:[[956,103],256],13198:[[109,103],256],13199:[[107,103],256],13200:[[72,122],256],13201:[[107,72,122],256],13202:[[77,72,122],256],13203:[[71,72,122],256],13204:[[84,72,122],256],13205:[[956,8467],256],13206:[[109,8467],256],13207:[[100,8467],256],13208:[[107,8467],256],13209:[[102,109],256],13210:[[110,109],256],13211:[[956,109],256],13212:[[109,109],256],13213:[[99,109],256],13214:[[107,109],256],13215:[[109,109,178],256],13216:[[99,109,178],256],13217:[[109,178],256],13218:[[107,109,178],256],13219:[[109,109,179],256],13220:[[99,109,179],256],13221:[[109,179],256],13222:[[107,109,179],256],13223:[[109,8725,115],256],13224:[[109,8725,115,178],256],13225:[[80,97],256],13226:[[107,80,97],256],13227:[[77,80,97],256],13228:[[71,80,97],256],13229:[[114,97,100],256],13230:[[114,97,100,8725,115],256],13231:[[114,97,100,8725,115,178],256],13232:[[112,115],256],13233:[[110,115],256],13234:[[956,115],256],13235:[[109,115],256],13236:[[112,86],256],13237:[[110,86],256],13238:[[956,86],256],13239:[[109,86],256],13240:[[107,86],256],13241:[[77,86],256],13242:[[112,87],256],13243:[[110,87],256],13244:[[956,87],256],13245:[[109,87],256],13246:[[107,87],256],13247:[[77,87],256],13248:[[107,937],256],13249:[[77,937],256],13250:[[97,46,109,46],256],13251:[[66,113],256],13252:[[99,99],256],13253:[[99,100],256],13254:[[67,8725,107,103],256],13255:[[67,111,46],256],13256:[[100,66],256],13257:[[71,121],256],13258:[[104,97],256],13259:[[72,80],256],13260:[[105,110],256],13261:[[75,75],256],13262:[[75,77],256],13263:[[107,116],256],13264:[[108,109],256],13265:[[108,110],256],13266:[[108,111,103],256],13267:[[108,120],256],13268:[[109,98],256],13269:[[109,105,108],256],13270:[[109,111,108],256],13271:[[80,72],256],13272:[[112,46,109,46],256],13273:[[80,80,77],256],13274:[[80,82],256],13275:[[115,114],256],13276:[[83,118],256],13277:[[87,98],256],13278:[[86,8725,109],256],13279:[[65,8725,109],256],13280:[[49,26085],256],13281:[[50,26085],256],13282:[[51,26085],256],13283:[[52,26085],256],13284:[[53,26085],256],13285:[[54,26085],256],13286:[[55,26085],256],13287:[[56,26085],256],13288:[[57,26085],256],13289:[[49,48,26085],256],13290:[[49,49,26085],256],13291:[[49,50,26085],256],13292:[[49,51,26085],256],13293:[[49,52,26085],256],13294:[[49,53,26085],256],13295:[[49,54,26085],256],13296:[[49,55,26085],256],13297:[[49,56,26085],256],13298:[[49,57,26085],256],13299:[[50,48,26085],256],13300:[[50,49,26085],256],13301:[[50,50,26085],256],13302:[[50,51,26085],256],13303:[[50,52,26085],256],13304:[[50,53,26085],256],13305:[[50,54,26085],256],13306:[[50,55,26085],256],13307:[[50,56,26085],256],13308:[[50,57,26085],256],13309:[[51,48,26085],256],13310:[[51,49,26085],256],13311:[[103,97,108],256]}, +27136:{92912:[,1],92913:[,1],92914:[,1],92915:[,1],92916:[,1]}, +27392:{92976:[,230],92977:[,230],92978:[,230],92979:[,230],92980:[,230],92981:[,230],92982:[,230]}, +42496:{42607:[,230],42612:[,230],42613:[,230],42614:[,230],42615:[,230],42616:[,230],42617:[,230],42618:[,230],42619:[,230],42620:[,230],42621:[,230],42652:[[1098],256],42653:[[1100],256],42655:[,230],42736:[,230],42737:[,230]}, +42752:{42864:[[42863],256],43000:[[294],256],43001:[[339],256]}, +43008:{43014:[,9],43204:[,9],43232:[,230],43233:[,230],43234:[,230],43235:[,230],43236:[,230],43237:[,230],43238:[,230],43239:[,230],43240:[,230],43241:[,230],43242:[,230],43243:[,230],43244:[,230],43245:[,230],43246:[,230],43247:[,230],43248:[,230],43249:[,230]}, +43264:{43307:[,220],43308:[,220],43309:[,220],43347:[,9],43443:[,7],43456:[,9]}, +43520:{43696:[,230],43698:[,230],43699:[,230],43700:[,220],43703:[,230],43704:[,230],43710:[,230],43711:[,230],43713:[,230],43766:[,9]}, +43776:{43868:[[42791],256],43869:[[43831],256],43870:[[619],256],43871:[[43858],256],44013:[,9]}, +48128:{113822:[,1]}, +53504:{119134:[[119127,119141],512],119135:[[119128,119141],512],119136:[[119135,119150],512],119137:[[119135,119151],512],119138:[[119135,119152],512],119139:[[119135,119153],512],119140:[[119135,119154],512],119141:[,216],119142:[,216],119143:[,1],119144:[,1],119145:[,1],119149:[,226],119150:[,216],119151:[,216],119152:[,216],119153:[,216],119154:[,216],119163:[,220],119164:[,220],119165:[,220],119166:[,220],119167:[,220],119168:[,220],119169:[,220],119170:[,220],119173:[,230],119174:[,230],119175:[,230],119176:[,230],119177:[,230],119178:[,220],119179:[,220],119210:[,230],119211:[,230],119212:[,230],119213:[,230],119227:[[119225,119141],512],119228:[[119226,119141],512],119229:[[119227,119150],512],119230:[[119228,119150],512],119231:[[119227,119151],512],119232:[[119228,119151],512]}, +53760:{119362:[,230],119363:[,230],119364:[,230]}, +54272:{119808:[[65],256],119809:[[66],256],119810:[[67],256],119811:[[68],256],119812:[[69],256],119813:[[70],256],119814:[[71],256],119815:[[72],256],119816:[[73],256],119817:[[74],256],119818:[[75],256],119819:[[76],256],119820:[[77],256],119821:[[78],256],119822:[[79],256],119823:[[80],256],119824:[[81],256],119825:[[82],256],119826:[[83],256],119827:[[84],256],119828:[[85],256],119829:[[86],256],119830:[[87],256],119831:[[88],256],119832:[[89],256],119833:[[90],256],119834:[[97],256],119835:[[98],256],119836:[[99],256],119837:[[100],256],119838:[[101],256],119839:[[102],256],119840:[[103],256],119841:[[104],256],119842:[[105],256],119843:[[106],256],119844:[[107],256],119845:[[108],256],119846:[[109],256],119847:[[110],256],119848:[[111],256],119849:[[112],256],119850:[[113],256],119851:[[114],256],119852:[[115],256],119853:[[116],256],119854:[[117],256],119855:[[118],256],119856:[[119],256],119857:[[120],256],119858:[[121],256],119859:[[122],256],119860:[[65],256],119861:[[66],256],119862:[[67],256],119863:[[68],256],119864:[[69],256],119865:[[70],256],119866:[[71],256],119867:[[72],256],119868:[[73],256],119869:[[74],256],119870:[[75],256],119871:[[76],256],119872:[[77],256],119873:[[78],256],119874:[[79],256],119875:[[80],256],119876:[[81],256],119877:[[82],256],119878:[[83],256],119879:[[84],256],119880:[[85],256],119881:[[86],256],119882:[[87],256],119883:[[88],256],119884:[[89],256],119885:[[90],256],119886:[[97],256],119887:[[98],256],119888:[[99],256],119889:[[100],256],119890:[[101],256],119891:[[102],256],119892:[[103],256],119894:[[105],256],119895:[[106],256],119896:[[107],256],119897:[[108],256],119898:[[109],256],119899:[[110],256],119900:[[111],256],119901:[[112],256],119902:[[113],256],119903:[[114],256],119904:[[115],256],119905:[[116],256],119906:[[117],256],119907:[[118],256],119908:[[119],256],119909:[[120],256],119910:[[121],256],119911:[[122],256],119912:[[65],256],119913:[[66],256],119914:[[67],256],119915:[[68],256],119916:[[69],256],119917:[[70],256],119918:[[71],256],119919:[[72],256],119920:[[73],256],119921:[[74],256],119922:[[75],256],119923:[[76],256],119924:[[77],256],119925:[[78],256],119926:[[79],256],119927:[[80],256],119928:[[81],256],119929:[[82],256],119930:[[83],256],119931:[[84],256],119932:[[85],256],119933:[[86],256],119934:[[87],256],119935:[[88],256],119936:[[89],256],119937:[[90],256],119938:[[97],256],119939:[[98],256],119940:[[99],256],119941:[[100],256],119942:[[101],256],119943:[[102],256],119944:[[103],256],119945:[[104],256],119946:[[105],256],119947:[[106],256],119948:[[107],256],119949:[[108],256],119950:[[109],256],119951:[[110],256],119952:[[111],256],119953:[[112],256],119954:[[113],256],119955:[[114],256],119956:[[115],256],119957:[[116],256],119958:[[117],256],119959:[[118],256],119960:[[119],256],119961:[[120],256],119962:[[121],256],119963:[[122],256],119964:[[65],256],119966:[[67],256],119967:[[68],256],119970:[[71],256],119973:[[74],256],119974:[[75],256],119977:[[78],256],119978:[[79],256],119979:[[80],256],119980:[[81],256],119982:[[83],256],119983:[[84],256],119984:[[85],256],119985:[[86],256],119986:[[87],256],119987:[[88],256],119988:[[89],256],119989:[[90],256],119990:[[97],256],119991:[[98],256],119992:[[99],256],119993:[[100],256],119995:[[102],256],119997:[[104],256],119998:[[105],256],119999:[[106],256],120000:[[107],256],120001:[[108],256],120002:[[109],256],120003:[[110],256],120005:[[112],256],120006:[[113],256],120007:[[114],256],120008:[[115],256],120009:[[116],256],120010:[[117],256],120011:[[118],256],120012:[[119],256],120013:[[120],256],120014:[[121],256],120015:[[122],256],120016:[[65],256],120017:[[66],256],120018:[[67],256],120019:[[68],256],120020:[[69],256],120021:[[70],256],120022:[[71],256],120023:[[72],256],120024:[[73],256],120025:[[74],256],120026:[[75],256],120027:[[76],256],120028:[[77],256],120029:[[78],256],120030:[[79],256],120031:[[80],256],120032:[[81],256],120033:[[82],256],120034:[[83],256],120035:[[84],256],120036:[[85],256],120037:[[86],256],120038:[[87],256],120039:[[88],256],120040:[[89],256],120041:[[90],256],120042:[[97],256],120043:[[98],256],120044:[[99],256],120045:[[100],256],120046:[[101],256],120047:[[102],256],120048:[[103],256],120049:[[104],256],120050:[[105],256],120051:[[106],256],120052:[[107],256],120053:[[108],256],120054:[[109],256],120055:[[110],256],120056:[[111],256],120057:[[112],256],120058:[[113],256],120059:[[114],256],120060:[[115],256],120061:[[116],256],120062:[[117],256],120063:[[118],256]}, +54528:{120064:[[119],256],120065:[[120],256],120066:[[121],256],120067:[[122],256],120068:[[65],256],120069:[[66],256],120071:[[68],256],120072:[[69],256],120073:[[70],256],120074:[[71],256],120077:[[74],256],120078:[[75],256],120079:[[76],256],120080:[[77],256],120081:[[78],256],120082:[[79],256],120083:[[80],256],120084:[[81],256],120086:[[83],256],120087:[[84],256],120088:[[85],256],120089:[[86],256],120090:[[87],256],120091:[[88],256],120092:[[89],256],120094:[[97],256],120095:[[98],256],120096:[[99],256],120097:[[100],256],120098:[[101],256],120099:[[102],256],120100:[[103],256],120101:[[104],256],120102:[[105],256],120103:[[106],256],120104:[[107],256],120105:[[108],256],120106:[[109],256],120107:[[110],256],120108:[[111],256],120109:[[112],256],120110:[[113],256],120111:[[114],256],120112:[[115],256],120113:[[116],256],120114:[[117],256],120115:[[118],256],120116:[[119],256],120117:[[120],256],120118:[[121],256],120119:[[122],256],120120:[[65],256],120121:[[66],256],120123:[[68],256],120124:[[69],256],120125:[[70],256],120126:[[71],256],120128:[[73],256],120129:[[74],256],120130:[[75],256],120131:[[76],256],120132:[[77],256],120134:[[79],256],120138:[[83],256],120139:[[84],256],120140:[[85],256],120141:[[86],256],120142:[[87],256],120143:[[88],256],120144:[[89],256],120146:[[97],256],120147:[[98],256],120148:[[99],256],120149:[[100],256],120150:[[101],256],120151:[[102],256],120152:[[103],256],120153:[[104],256],120154:[[105],256],120155:[[106],256],120156:[[107],256],120157:[[108],256],120158:[[109],256],120159:[[110],256],120160:[[111],256],120161:[[112],256],120162:[[113],256],120163:[[114],256],120164:[[115],256],120165:[[116],256],120166:[[117],256],120167:[[118],256],120168:[[119],256],120169:[[120],256],120170:[[121],256],120171:[[122],256],120172:[[65],256],120173:[[66],256],120174:[[67],256],120175:[[68],256],120176:[[69],256],120177:[[70],256],120178:[[71],256],120179:[[72],256],120180:[[73],256],120181:[[74],256],120182:[[75],256],120183:[[76],256],120184:[[77],256],120185:[[78],256],120186:[[79],256],120187:[[80],256],120188:[[81],256],120189:[[82],256],120190:[[83],256],120191:[[84],256],120192:[[85],256],120193:[[86],256],120194:[[87],256],120195:[[88],256],120196:[[89],256],120197:[[90],256],120198:[[97],256],120199:[[98],256],120200:[[99],256],120201:[[100],256],120202:[[101],256],120203:[[102],256],120204:[[103],256],120205:[[104],256],120206:[[105],256],120207:[[106],256],120208:[[107],256],120209:[[108],256],120210:[[109],256],120211:[[110],256],120212:[[111],256],120213:[[112],256],120214:[[113],256],120215:[[114],256],120216:[[115],256],120217:[[116],256],120218:[[117],256],120219:[[118],256],120220:[[119],256],120221:[[120],256],120222:[[121],256],120223:[[122],256],120224:[[65],256],120225:[[66],256],120226:[[67],256],120227:[[68],256],120228:[[69],256],120229:[[70],256],120230:[[71],256],120231:[[72],256],120232:[[73],256],120233:[[74],256],120234:[[75],256],120235:[[76],256],120236:[[77],256],120237:[[78],256],120238:[[79],256],120239:[[80],256],120240:[[81],256],120241:[[82],256],120242:[[83],256],120243:[[84],256],120244:[[85],256],120245:[[86],256],120246:[[87],256],120247:[[88],256],120248:[[89],256],120249:[[90],256],120250:[[97],256],120251:[[98],256],120252:[[99],256],120253:[[100],256],120254:[[101],256],120255:[[102],256],120256:[[103],256],120257:[[104],256],120258:[[105],256],120259:[[106],256],120260:[[107],256],120261:[[108],256],120262:[[109],256],120263:[[110],256],120264:[[111],256],120265:[[112],256],120266:[[113],256],120267:[[114],256],120268:[[115],256],120269:[[116],256],120270:[[117],256],120271:[[118],256],120272:[[119],256],120273:[[120],256],120274:[[121],256],120275:[[122],256],120276:[[65],256],120277:[[66],256],120278:[[67],256],120279:[[68],256],120280:[[69],256],120281:[[70],256],120282:[[71],256],120283:[[72],256],120284:[[73],256],120285:[[74],256],120286:[[75],256],120287:[[76],256],120288:[[77],256],120289:[[78],256],120290:[[79],256],120291:[[80],256],120292:[[81],256],120293:[[82],256],120294:[[83],256],120295:[[84],256],120296:[[85],256],120297:[[86],256],120298:[[87],256],120299:[[88],256],120300:[[89],256],120301:[[90],256],120302:[[97],256],120303:[[98],256],120304:[[99],256],120305:[[100],256],120306:[[101],256],120307:[[102],256],120308:[[103],256],120309:[[104],256],120310:[[105],256],120311:[[106],256],120312:[[107],256],120313:[[108],256],120314:[[109],256],120315:[[110],256],120316:[[111],256],120317:[[112],256],120318:[[113],256],120319:[[114],256]}, +54784:{120320:[[115],256],120321:[[116],256],120322:[[117],256],120323:[[118],256],120324:[[119],256],120325:[[120],256],120326:[[121],256],120327:[[122],256],120328:[[65],256],120329:[[66],256],120330:[[67],256],120331:[[68],256],120332:[[69],256],120333:[[70],256],120334:[[71],256],120335:[[72],256],120336:[[73],256],120337:[[74],256],120338:[[75],256],120339:[[76],256],120340:[[77],256],120341:[[78],256],120342:[[79],256],120343:[[80],256],120344:[[81],256],120345:[[82],256],120346:[[83],256],120347:[[84],256],120348:[[85],256],120349:[[86],256],120350:[[87],256],120351:[[88],256],120352:[[89],256],120353:[[90],256],120354:[[97],256],120355:[[98],256],120356:[[99],256],120357:[[100],256],120358:[[101],256],120359:[[102],256],120360:[[103],256],120361:[[104],256],120362:[[105],256],120363:[[106],256],120364:[[107],256],120365:[[108],256],120366:[[109],256],120367:[[110],256],120368:[[111],256],120369:[[112],256],120370:[[113],256],120371:[[114],256],120372:[[115],256],120373:[[116],256],120374:[[117],256],120375:[[118],256],120376:[[119],256],120377:[[120],256],120378:[[121],256],120379:[[122],256],120380:[[65],256],120381:[[66],256],120382:[[67],256],120383:[[68],256],120384:[[69],256],120385:[[70],256],120386:[[71],256],120387:[[72],256],120388:[[73],256],120389:[[74],256],120390:[[75],256],120391:[[76],256],120392:[[77],256],120393:[[78],256],120394:[[79],256],120395:[[80],256],120396:[[81],256],120397:[[82],256],120398:[[83],256],120399:[[84],256],120400:[[85],256],120401:[[86],256],120402:[[87],256],120403:[[88],256],120404:[[89],256],120405:[[90],256],120406:[[97],256],120407:[[98],256],120408:[[99],256],120409:[[100],256],120410:[[101],256],120411:[[102],256],120412:[[103],256],120413:[[104],256],120414:[[105],256],120415:[[106],256],120416:[[107],256],120417:[[108],256],120418:[[109],256],120419:[[110],256],120420:[[111],256],120421:[[112],256],120422:[[113],256],120423:[[114],256],120424:[[115],256],120425:[[116],256],120426:[[117],256],120427:[[118],256],120428:[[119],256],120429:[[120],256],120430:[[121],256],120431:[[122],256],120432:[[65],256],120433:[[66],256],120434:[[67],256],120435:[[68],256],120436:[[69],256],120437:[[70],256],120438:[[71],256],120439:[[72],256],120440:[[73],256],120441:[[74],256],120442:[[75],256],120443:[[76],256],120444:[[77],256],120445:[[78],256],120446:[[79],256],120447:[[80],256],120448:[[81],256],120449:[[82],256],120450:[[83],256],120451:[[84],256],120452:[[85],256],120453:[[86],256],120454:[[87],256],120455:[[88],256],120456:[[89],256],120457:[[90],256],120458:[[97],256],120459:[[98],256],120460:[[99],256],120461:[[100],256],120462:[[101],256],120463:[[102],256],120464:[[103],256],120465:[[104],256],120466:[[105],256],120467:[[106],256],120468:[[107],256],120469:[[108],256],120470:[[109],256],120471:[[110],256],120472:[[111],256],120473:[[112],256],120474:[[113],256],120475:[[114],256],120476:[[115],256],120477:[[116],256],120478:[[117],256],120479:[[118],256],120480:[[119],256],120481:[[120],256],120482:[[121],256],120483:[[122],256],120484:[[305],256],120485:[[567],256],120488:[[913],256],120489:[[914],256],120490:[[915],256],120491:[[916],256],120492:[[917],256],120493:[[918],256],120494:[[919],256],120495:[[920],256],120496:[[921],256],120497:[[922],256],120498:[[923],256],120499:[[924],256],120500:[[925],256],120501:[[926],256],120502:[[927],256],120503:[[928],256],120504:[[929],256],120505:[[1012],256],120506:[[931],256],120507:[[932],256],120508:[[933],256],120509:[[934],256],120510:[[935],256],120511:[[936],256],120512:[[937],256],120513:[[8711],256],120514:[[945],256],120515:[[946],256],120516:[[947],256],120517:[[948],256],120518:[[949],256],120519:[[950],256],120520:[[951],256],120521:[[952],256],120522:[[953],256],120523:[[954],256],120524:[[955],256],120525:[[956],256],120526:[[957],256],120527:[[958],256],120528:[[959],256],120529:[[960],256],120530:[[961],256],120531:[[962],256],120532:[[963],256],120533:[[964],256],120534:[[965],256],120535:[[966],256],120536:[[967],256],120537:[[968],256],120538:[[969],256],120539:[[8706],256],120540:[[1013],256],120541:[[977],256],120542:[[1008],256],120543:[[981],256],120544:[[1009],256],120545:[[982],256],120546:[[913],256],120547:[[914],256],120548:[[915],256],120549:[[916],256],120550:[[917],256],120551:[[918],256],120552:[[919],256],120553:[[920],256],120554:[[921],256],120555:[[922],256],120556:[[923],256],120557:[[924],256],120558:[[925],256],120559:[[926],256],120560:[[927],256],120561:[[928],256],120562:[[929],256],120563:[[1012],256],120564:[[931],256],120565:[[932],256],120566:[[933],256],120567:[[934],256],120568:[[935],256],120569:[[936],256],120570:[[937],256],120571:[[8711],256],120572:[[945],256],120573:[[946],256],120574:[[947],256],120575:[[948],256]}, +55040:{120576:[[949],256],120577:[[950],256],120578:[[951],256],120579:[[952],256],120580:[[953],256],120581:[[954],256],120582:[[955],256],120583:[[956],256],120584:[[957],256],120585:[[958],256],120586:[[959],256],120587:[[960],256],120588:[[961],256],120589:[[962],256],120590:[[963],256],120591:[[964],256],120592:[[965],256],120593:[[966],256],120594:[[967],256],120595:[[968],256],120596:[[969],256],120597:[[8706],256],120598:[[1013],256],120599:[[977],256],120600:[[1008],256],120601:[[981],256],120602:[[1009],256],120603:[[982],256],120604:[[913],256],120605:[[914],256],120606:[[915],256],120607:[[916],256],120608:[[917],256],120609:[[918],256],120610:[[919],256],120611:[[920],256],120612:[[921],256],120613:[[922],256],120614:[[923],256],120615:[[924],256],120616:[[925],256],120617:[[926],256],120618:[[927],256],120619:[[928],256],120620:[[929],256],120621:[[1012],256],120622:[[931],256],120623:[[932],256],120624:[[933],256],120625:[[934],256],120626:[[935],256],120627:[[936],256],120628:[[937],256],120629:[[8711],256],120630:[[945],256],120631:[[946],256],120632:[[947],256],120633:[[948],256],120634:[[949],256],120635:[[950],256],120636:[[951],256],120637:[[952],256],120638:[[953],256],120639:[[954],256],120640:[[955],256],120641:[[956],256],120642:[[957],256],120643:[[958],256],120644:[[959],256],120645:[[960],256],120646:[[961],256],120647:[[962],256],120648:[[963],256],120649:[[964],256],120650:[[965],256],120651:[[966],256],120652:[[967],256],120653:[[968],256],120654:[[969],256],120655:[[8706],256],120656:[[1013],256],120657:[[977],256],120658:[[1008],256],120659:[[981],256],120660:[[1009],256],120661:[[982],256],120662:[[913],256],120663:[[914],256],120664:[[915],256],120665:[[916],256],120666:[[917],256],120667:[[918],256],120668:[[919],256],120669:[[920],256],120670:[[921],256],120671:[[922],256],120672:[[923],256],120673:[[924],256],120674:[[925],256],120675:[[926],256],120676:[[927],256],120677:[[928],256],120678:[[929],256],120679:[[1012],256],120680:[[931],256],120681:[[932],256],120682:[[933],256],120683:[[934],256],120684:[[935],256],120685:[[936],256],120686:[[937],256],120687:[[8711],256],120688:[[945],256],120689:[[946],256],120690:[[947],256],120691:[[948],256],120692:[[949],256],120693:[[950],256],120694:[[951],256],120695:[[952],256],120696:[[953],256],120697:[[954],256],120698:[[955],256],120699:[[956],256],120700:[[957],256],120701:[[958],256],120702:[[959],256],120703:[[960],256],120704:[[961],256],120705:[[962],256],120706:[[963],256],120707:[[964],256],120708:[[965],256],120709:[[966],256],120710:[[967],256],120711:[[968],256],120712:[[969],256],120713:[[8706],256],120714:[[1013],256],120715:[[977],256],120716:[[1008],256],120717:[[981],256],120718:[[1009],256],120719:[[982],256],120720:[[913],256],120721:[[914],256],120722:[[915],256],120723:[[916],256],120724:[[917],256],120725:[[918],256],120726:[[919],256],120727:[[920],256],120728:[[921],256],120729:[[922],256],120730:[[923],256],120731:[[924],256],120732:[[925],256],120733:[[926],256],120734:[[927],256],120735:[[928],256],120736:[[929],256],120737:[[1012],256],120738:[[931],256],120739:[[932],256],120740:[[933],256],120741:[[934],256],120742:[[935],256],120743:[[936],256],120744:[[937],256],120745:[[8711],256],120746:[[945],256],120747:[[946],256],120748:[[947],256],120749:[[948],256],120750:[[949],256],120751:[[950],256],120752:[[951],256],120753:[[952],256],120754:[[953],256],120755:[[954],256],120756:[[955],256],120757:[[956],256],120758:[[957],256],120759:[[958],256],120760:[[959],256],120761:[[960],256],120762:[[961],256],120763:[[962],256],120764:[[963],256],120765:[[964],256],120766:[[965],256],120767:[[966],256],120768:[[967],256],120769:[[968],256],120770:[[969],256],120771:[[8706],256],120772:[[1013],256],120773:[[977],256],120774:[[1008],256],120775:[[981],256],120776:[[1009],256],120777:[[982],256],120778:[[988],256],120779:[[989],256],120782:[[48],256],120783:[[49],256],120784:[[50],256],120785:[[51],256],120786:[[52],256],120787:[[53],256],120788:[[54],256],120789:[[55],256],120790:[[56],256],120791:[[57],256],120792:[[48],256],120793:[[49],256],120794:[[50],256],120795:[[51],256],120796:[[52],256],120797:[[53],256],120798:[[54],256],120799:[[55],256],120800:[[56],256],120801:[[57],256],120802:[[48],256],120803:[[49],256],120804:[[50],256],120805:[[51],256],120806:[[52],256],120807:[[53],256],120808:[[54],256],120809:[[55],256],120810:[[56],256],120811:[[57],256],120812:[[48],256],120813:[[49],256],120814:[[50],256],120815:[[51],256],120816:[[52],256],120817:[[53],256],120818:[[54],256],120819:[[55],256],120820:[[56],256],120821:[[57],256],120822:[[48],256],120823:[[49],256],120824:[[50],256],120825:[[51],256],120826:[[52],256],120827:[[53],256],120828:[[54],256],120829:[[55],256],120830:[[56],256],120831:[[57],256]}, +59392:{125136:[,220],125137:[,220],125138:[,220],125139:[,220],125140:[,220],125141:[,220],125142:[,220]}, +60928:{126464:[[1575],256],126465:[[1576],256],126466:[[1580],256],126467:[[1583],256],126469:[[1608],256],126470:[[1586],256],126471:[[1581],256],126472:[[1591],256],126473:[[1610],256],126474:[[1603],256],126475:[[1604],256],126476:[[1605],256],126477:[[1606],256],126478:[[1587],256],126479:[[1593],256],126480:[[1601],256],126481:[[1589],256],126482:[[1602],256],126483:[[1585],256],126484:[[1588],256],126485:[[1578],256],126486:[[1579],256],126487:[[1582],256],126488:[[1584],256],126489:[[1590],256],126490:[[1592],256],126491:[[1594],256],126492:[[1646],256],126493:[[1722],256],126494:[[1697],256],126495:[[1647],256],126497:[[1576],256],126498:[[1580],256],126500:[[1607],256],126503:[[1581],256],126505:[[1610],256],126506:[[1603],256],126507:[[1604],256],126508:[[1605],256],126509:[[1606],256],126510:[[1587],256],126511:[[1593],256],126512:[[1601],256],126513:[[1589],256],126514:[[1602],256],126516:[[1588],256],126517:[[1578],256],126518:[[1579],256],126519:[[1582],256],126521:[[1590],256],126523:[[1594],256],126530:[[1580],256],126535:[[1581],256],126537:[[1610],256],126539:[[1604],256],126541:[[1606],256],126542:[[1587],256],126543:[[1593],256],126545:[[1589],256],126546:[[1602],256],126548:[[1588],256],126551:[[1582],256],126553:[[1590],256],126555:[[1594],256],126557:[[1722],256],126559:[[1647],256],126561:[[1576],256],126562:[[1580],256],126564:[[1607],256],126567:[[1581],256],126568:[[1591],256],126569:[[1610],256],126570:[[1603],256],126572:[[1605],256],126573:[[1606],256],126574:[[1587],256],126575:[[1593],256],126576:[[1601],256],126577:[[1589],256],126578:[[1602],256],126580:[[1588],256],126581:[[1578],256],126582:[[1579],256],126583:[[1582],256],126585:[[1590],256],126586:[[1592],256],126587:[[1594],256],126588:[[1646],256],126590:[[1697],256],126592:[[1575],256],126593:[[1576],256],126594:[[1580],256],126595:[[1583],256],126596:[[1607],256],126597:[[1608],256],126598:[[1586],256],126599:[[1581],256],126600:[[1591],256],126601:[[1610],256],126603:[[1604],256],126604:[[1605],256],126605:[[1606],256],126606:[[1587],256],126607:[[1593],256],126608:[[1601],256],126609:[[1589],256],126610:[[1602],256],126611:[[1585],256],126612:[[1588],256],126613:[[1578],256],126614:[[1579],256],126615:[[1582],256],126616:[[1584],256],126617:[[1590],256],126618:[[1592],256],126619:[[1594],256],126625:[[1576],256],126626:[[1580],256],126627:[[1583],256],126629:[[1608],256],126630:[[1586],256],126631:[[1581],256],126632:[[1591],256],126633:[[1610],256],126635:[[1604],256],126636:[[1605],256],126637:[[1606],256],126638:[[1587],256],126639:[[1593],256],126640:[[1601],256],126641:[[1589],256],126642:[[1602],256],126643:[[1585],256],126644:[[1588],256],126645:[[1578],256],126646:[[1579],256],126647:[[1582],256],126648:[[1584],256],126649:[[1590],256],126650:[[1592],256],126651:[[1594],256]}, +61696:{127232:[[48,46],256],127233:[[48,44],256],127234:[[49,44],256],127235:[[50,44],256],127236:[[51,44],256],127237:[[52,44],256],127238:[[53,44],256],127239:[[54,44],256],127240:[[55,44],256],127241:[[56,44],256],127242:[[57,44],256],127248:[[40,65,41],256],127249:[[40,66,41],256],127250:[[40,67,41],256],127251:[[40,68,41],256],127252:[[40,69,41],256],127253:[[40,70,41],256],127254:[[40,71,41],256],127255:[[40,72,41],256],127256:[[40,73,41],256],127257:[[40,74,41],256],127258:[[40,75,41],256],127259:[[40,76,41],256],127260:[[40,77,41],256],127261:[[40,78,41],256],127262:[[40,79,41],256],127263:[[40,80,41],256],127264:[[40,81,41],256],127265:[[40,82,41],256],127266:[[40,83,41],256],127267:[[40,84,41],256],127268:[[40,85,41],256],127269:[[40,86,41],256],127270:[[40,87,41],256],127271:[[40,88,41],256],127272:[[40,89,41],256],127273:[[40,90,41],256],127274:[[12308,83,12309],256],127275:[[67],256],127276:[[82],256],127277:[[67,68],256],127278:[[87,90],256],127280:[[65],256],127281:[[66],256],127282:[[67],256],127283:[[68],256],127284:[[69],256],127285:[[70],256],127286:[[71],256],127287:[[72],256],127288:[[73],256],127289:[[74],256],127290:[[75],256],127291:[[76],256],127292:[[77],256],127293:[[78],256],127294:[[79],256],127295:[[80],256],127296:[[81],256],127297:[[82],256],127298:[[83],256],127299:[[84],256],127300:[[85],256],127301:[[86],256],127302:[[87],256],127303:[[88],256],127304:[[89],256],127305:[[90],256],127306:[[72,86],256],127307:[[77,86],256],127308:[[83,68],256],127309:[[83,83],256],127310:[[80,80,86],256],127311:[[87,67],256],127338:[[77,67],256],127339:[[77,68],256],127376:[[68,74],256]}, +61952:{127488:[[12411,12363],256],127489:[[12467,12467],256],127490:[[12469],256],127504:[[25163],256],127505:[[23383],256],127506:[[21452],256],127507:[[12487],256],127508:[[20108],256],127509:[[22810],256],127510:[[35299],256],127511:[[22825],256],127512:[[20132],256],127513:[[26144],256],127514:[[28961],256],127515:[[26009],256],127516:[[21069],256],127517:[[24460],256],127518:[[20877],256],127519:[[26032],256],127520:[[21021],256],127521:[[32066],256],127522:[[29983],256],127523:[[36009],256],127524:[[22768],256],127525:[[21561],256],127526:[[28436],256],127527:[[25237],256],127528:[[25429],256],127529:[[19968],256],127530:[[19977],256],127531:[[36938],256],127532:[[24038],256],127533:[[20013],256],127534:[[21491],256],127535:[[25351],256],127536:[[36208],256],127537:[[25171],256],127538:[[31105],256],127539:[[31354],256],127540:[[21512],256],127541:[[28288],256],127542:[[26377],256],127543:[[26376],256],127544:[[30003],256],127545:[[21106],256],127546:[[21942],256],127552:[[12308,26412,12309],256],127553:[[12308,19977,12309],256],127554:[[12308,20108,12309],256],127555:[[12308,23433,12309],256],127556:[[12308,28857,12309],256],127557:[[12308,25171,12309],256],127558:[[12308,30423,12309],256],127559:[[12308,21213,12309],256],127560:[[12308,25943,12309],256],127568:[[24471],256],127569:[[21487],256]}, +63488:{194560:[[20029]],194561:[[20024]],194562:[[20033]],194563:[[131362]],194564:[[20320]],194565:[[20398]],194566:[[20411]],194567:[[20482]],194568:[[20602]],194569:[[20633]],194570:[[20711]],194571:[[20687]],194572:[[13470]],194573:[[132666]],194574:[[20813]],194575:[[20820]],194576:[[20836]],194577:[[20855]],194578:[[132380]],194579:[[13497]],194580:[[20839]],194581:[[20877]],194582:[[132427]],194583:[[20887]],194584:[[20900]],194585:[[20172]],194586:[[20908]],194587:[[20917]],194588:[[168415]],194589:[[20981]],194590:[[20995]],194591:[[13535]],194592:[[21051]],194593:[[21062]],194594:[[21106]],194595:[[21111]],194596:[[13589]],194597:[[21191]],194598:[[21193]],194599:[[21220]],194600:[[21242]],194601:[[21253]],194602:[[21254]],194603:[[21271]],194604:[[21321]],194605:[[21329]],194606:[[21338]],194607:[[21363]],194608:[[21373]],194609:[[21375]],194610:[[21375]],194611:[[21375]],194612:[[133676]],194613:[[28784]],194614:[[21450]],194615:[[21471]],194616:[[133987]],194617:[[21483]],194618:[[21489]],194619:[[21510]],194620:[[21662]],194621:[[21560]],194622:[[21576]],194623:[[21608]],194624:[[21666]],194625:[[21750]],194626:[[21776]],194627:[[21843]],194628:[[21859]],194629:[[21892]],194630:[[21892]],194631:[[21913]],194632:[[21931]],194633:[[21939]],194634:[[21954]],194635:[[22294]],194636:[[22022]],194637:[[22295]],194638:[[22097]],194639:[[22132]],194640:[[20999]],194641:[[22766]],194642:[[22478]],194643:[[22516]],194644:[[22541]],194645:[[22411]],194646:[[22578]],194647:[[22577]],194648:[[22700]],194649:[[136420]],194650:[[22770]],194651:[[22775]],194652:[[22790]],194653:[[22810]],194654:[[22818]],194655:[[22882]],194656:[[136872]],194657:[[136938]],194658:[[23020]],194659:[[23067]],194660:[[23079]],194661:[[23000]],194662:[[23142]],194663:[[14062]],194664:[[14076]],194665:[[23304]],194666:[[23358]],194667:[[23358]],194668:[[137672]],194669:[[23491]],194670:[[23512]],194671:[[23527]],194672:[[23539]],194673:[[138008]],194674:[[23551]],194675:[[23558]],194676:[[24403]],194677:[[23586]],194678:[[14209]],194679:[[23648]],194680:[[23662]],194681:[[23744]],194682:[[23693]],194683:[[138724]],194684:[[23875]],194685:[[138726]],194686:[[23918]],194687:[[23915]],194688:[[23932]],194689:[[24033]],194690:[[24034]],194691:[[14383]],194692:[[24061]],194693:[[24104]],194694:[[24125]],194695:[[24169]],194696:[[14434]],194697:[[139651]],194698:[[14460]],194699:[[24240]],194700:[[24243]],194701:[[24246]],194702:[[24266]],194703:[[172946]],194704:[[24318]],194705:[[140081]],194706:[[140081]],194707:[[33281]],194708:[[24354]],194709:[[24354]],194710:[[14535]],194711:[[144056]],194712:[[156122]],194713:[[24418]],194714:[[24427]],194715:[[14563]],194716:[[24474]],194717:[[24525]],194718:[[24535]],194719:[[24569]],194720:[[24705]],194721:[[14650]],194722:[[14620]],194723:[[24724]],194724:[[141012]],194725:[[24775]],194726:[[24904]],194727:[[24908]],194728:[[24910]],194729:[[24908]],194730:[[24954]],194731:[[24974]],194732:[[25010]],194733:[[24996]],194734:[[25007]],194735:[[25054]],194736:[[25074]],194737:[[25078]],194738:[[25104]],194739:[[25115]],194740:[[25181]],194741:[[25265]],194742:[[25300]],194743:[[25424]],194744:[[142092]],194745:[[25405]],194746:[[25340]],194747:[[25448]],194748:[[25475]],194749:[[25572]],194750:[[142321]],194751:[[25634]],194752:[[25541]],194753:[[25513]],194754:[[14894]],194755:[[25705]],194756:[[25726]],194757:[[25757]],194758:[[25719]],194759:[[14956]],194760:[[25935]],194761:[[25964]],194762:[[143370]],194763:[[26083]],194764:[[26360]],194765:[[26185]],194766:[[15129]],194767:[[26257]],194768:[[15112]],194769:[[15076]],194770:[[20882]],194771:[[20885]],194772:[[26368]],194773:[[26268]],194774:[[32941]],194775:[[17369]],194776:[[26391]],194777:[[26395]],194778:[[26401]],194779:[[26462]],194780:[[26451]],194781:[[144323]],194782:[[15177]],194783:[[26618]],194784:[[26501]],194785:[[26706]],194786:[[26757]],194787:[[144493]],194788:[[26766]],194789:[[26655]],194790:[[26900]],194791:[[15261]],194792:[[26946]],194793:[[27043]],194794:[[27114]],194795:[[27304]],194796:[[145059]],194797:[[27355]],194798:[[15384]],194799:[[27425]],194800:[[145575]],194801:[[27476]],194802:[[15438]],194803:[[27506]],194804:[[27551]],194805:[[27578]],194806:[[27579]],194807:[[146061]],194808:[[138507]],194809:[[146170]],194810:[[27726]],194811:[[146620]],194812:[[27839]],194813:[[27853]],194814:[[27751]],194815:[[27926]]}, +63744:{63744:[[35912]],63745:[[26356]],63746:[[36554]],63747:[[36040]],63748:[[28369]],63749:[[20018]],63750:[[21477]],63751:[[40860]],63752:[[40860]],63753:[[22865]],63754:[[37329]],63755:[[21895]],63756:[[22856]],63757:[[25078]],63758:[[30313]],63759:[[32645]],63760:[[34367]],63761:[[34746]],63762:[[35064]],63763:[[37007]],63764:[[27138]],63765:[[27931]],63766:[[28889]],63767:[[29662]],63768:[[33853]],63769:[[37226]],63770:[[39409]],63771:[[20098]],63772:[[21365]],63773:[[27396]],63774:[[29211]],63775:[[34349]],63776:[[40478]],63777:[[23888]],63778:[[28651]],63779:[[34253]],63780:[[35172]],63781:[[25289]],63782:[[33240]],63783:[[34847]],63784:[[24266]],63785:[[26391]],63786:[[28010]],63787:[[29436]],63788:[[37070]],63789:[[20358]],63790:[[20919]],63791:[[21214]],63792:[[25796]],63793:[[27347]],63794:[[29200]],63795:[[30439]],63796:[[32769]],63797:[[34310]],63798:[[34396]],63799:[[36335]],63800:[[38706]],63801:[[39791]],63802:[[40442]],63803:[[30860]],63804:[[31103]],63805:[[32160]],63806:[[33737]],63807:[[37636]],63808:[[40575]],63809:[[35542]],63810:[[22751]],63811:[[24324]],63812:[[31840]],63813:[[32894]],63814:[[29282]],63815:[[30922]],63816:[[36034]],63817:[[38647]],63818:[[22744]],63819:[[23650]],63820:[[27155]],63821:[[28122]],63822:[[28431]],63823:[[32047]],63824:[[32311]],63825:[[38475]],63826:[[21202]],63827:[[32907]],63828:[[20956]],63829:[[20940]],63830:[[31260]],63831:[[32190]],63832:[[33777]],63833:[[38517]],63834:[[35712]],63835:[[25295]],63836:[[27138]],63837:[[35582]],63838:[[20025]],63839:[[23527]],63840:[[24594]],63841:[[29575]],63842:[[30064]],63843:[[21271]],63844:[[30971]],63845:[[20415]],63846:[[24489]],63847:[[19981]],63848:[[27852]],63849:[[25976]],63850:[[32034]],63851:[[21443]],63852:[[22622]],63853:[[30465]],63854:[[33865]],63855:[[35498]],63856:[[27578]],63857:[[36784]],63858:[[27784]],63859:[[25342]],63860:[[33509]],63861:[[25504]],63862:[[30053]],63863:[[20142]],63864:[[20841]],63865:[[20937]],63866:[[26753]],63867:[[31975]],63868:[[33391]],63869:[[35538]],63870:[[37327]],63871:[[21237]],63872:[[21570]],63873:[[22899]],63874:[[24300]],63875:[[26053]],63876:[[28670]],63877:[[31018]],63878:[[38317]],63879:[[39530]],63880:[[40599]],63881:[[40654]],63882:[[21147]],63883:[[26310]],63884:[[27511]],63885:[[36706]],63886:[[24180]],63887:[[24976]],63888:[[25088]],63889:[[25754]],63890:[[28451]],63891:[[29001]],63892:[[29833]],63893:[[31178]],63894:[[32244]],63895:[[32879]],63896:[[36646]],63897:[[34030]],63898:[[36899]],63899:[[37706]],63900:[[21015]],63901:[[21155]],63902:[[21693]],63903:[[28872]],63904:[[35010]],63905:[[35498]],63906:[[24265]],63907:[[24565]],63908:[[25467]],63909:[[27566]],63910:[[31806]],63911:[[29557]],63912:[[20196]],63913:[[22265]],63914:[[23527]],63915:[[23994]],63916:[[24604]],63917:[[29618]],63918:[[29801]],63919:[[32666]],63920:[[32838]],63921:[[37428]],63922:[[38646]],63923:[[38728]],63924:[[38936]],63925:[[20363]],63926:[[31150]],63927:[[37300]],63928:[[38584]],63929:[[24801]],63930:[[20102]],63931:[[20698]],63932:[[23534]],63933:[[23615]],63934:[[26009]],63935:[[27138]],63936:[[29134]],63937:[[30274]],63938:[[34044]],63939:[[36988]],63940:[[40845]],63941:[[26248]],63942:[[38446]],63943:[[21129]],63944:[[26491]],63945:[[26611]],63946:[[27969]],63947:[[28316]],63948:[[29705]],63949:[[30041]],63950:[[30827]],63951:[[32016]],63952:[[39006]],63953:[[20845]],63954:[[25134]],63955:[[38520]],63956:[[20523]],63957:[[23833]],63958:[[28138]],63959:[[36650]],63960:[[24459]],63961:[[24900]],63962:[[26647]],63963:[[29575]],63964:[[38534]],63965:[[21033]],63966:[[21519]],63967:[[23653]],63968:[[26131]],63969:[[26446]],63970:[[26792]],63971:[[27877]],63972:[[29702]],63973:[[30178]],63974:[[32633]],63975:[[35023]],63976:[[35041]],63977:[[37324]],63978:[[38626]],63979:[[21311]],63980:[[28346]],63981:[[21533]],63982:[[29136]],63983:[[29848]],63984:[[34298]],63985:[[38563]],63986:[[40023]],63987:[[40607]],63988:[[26519]],63989:[[28107]],63990:[[33256]],63991:[[31435]],63992:[[31520]],63993:[[31890]],63994:[[29376]],63995:[[28825]],63996:[[35672]],63997:[[20160]],63998:[[33590]],63999:[[21050]],194816:[[27966]],194817:[[28023]],194818:[[27969]],194819:[[28009]],194820:[[28024]],194821:[[28037]],194822:[[146718]],194823:[[27956]],194824:[[28207]],194825:[[28270]],194826:[[15667]],194827:[[28363]],194828:[[28359]],194829:[[147153]],194830:[[28153]],194831:[[28526]],194832:[[147294]],194833:[[147342]],194834:[[28614]],194835:[[28729]],194836:[[28702]],194837:[[28699]],194838:[[15766]],194839:[[28746]],194840:[[28797]],194841:[[28791]],194842:[[28845]],194843:[[132389]],194844:[[28997]],194845:[[148067]],194846:[[29084]],194847:[[148395]],194848:[[29224]],194849:[[29237]],194850:[[29264]],194851:[[149000]],194852:[[29312]],194853:[[29333]],194854:[[149301]],194855:[[149524]],194856:[[29562]],194857:[[29579]],194858:[[16044]],194859:[[29605]],194860:[[16056]],194861:[[16056]],194862:[[29767]],194863:[[29788]],194864:[[29809]],194865:[[29829]],194866:[[29898]],194867:[[16155]],194868:[[29988]],194869:[[150582]],194870:[[30014]],194871:[[150674]],194872:[[30064]],194873:[[139679]],194874:[[30224]],194875:[[151457]],194876:[[151480]],194877:[[151620]],194878:[[16380]],194879:[[16392]],194880:[[30452]],194881:[[151795]],194882:[[151794]],194883:[[151833]],194884:[[151859]],194885:[[30494]],194886:[[30495]],194887:[[30495]],194888:[[30538]],194889:[[16441]],194890:[[30603]],194891:[[16454]],194892:[[16534]],194893:[[152605]],194894:[[30798]],194895:[[30860]],194896:[[30924]],194897:[[16611]],194898:[[153126]],194899:[[31062]],194900:[[153242]],194901:[[153285]],194902:[[31119]],194903:[[31211]],194904:[[16687]],194905:[[31296]],194906:[[31306]],194907:[[31311]],194908:[[153980]],194909:[[154279]],194910:[[154279]],194911:[[31470]],194912:[[16898]],194913:[[154539]],194914:[[31686]],194915:[[31689]],194916:[[16935]],194917:[[154752]],194918:[[31954]],194919:[[17056]],194920:[[31976]],194921:[[31971]],194922:[[32000]],194923:[[155526]],194924:[[32099]],194925:[[17153]],194926:[[32199]],194927:[[32258]],194928:[[32325]],194929:[[17204]],194930:[[156200]],194931:[[156231]],194932:[[17241]],194933:[[156377]],194934:[[32634]],194935:[[156478]],194936:[[32661]],194937:[[32762]],194938:[[32773]],194939:[[156890]],194940:[[156963]],194941:[[32864]],194942:[[157096]],194943:[[32880]],194944:[[144223]],194945:[[17365]],194946:[[32946]],194947:[[33027]],194948:[[17419]],194949:[[33086]],194950:[[23221]],194951:[[157607]],194952:[[157621]],194953:[[144275]],194954:[[144284]],194955:[[33281]],194956:[[33284]],194957:[[36766]],194958:[[17515]],194959:[[33425]],194960:[[33419]],194961:[[33437]],194962:[[21171]],194963:[[33457]],194964:[[33459]],194965:[[33469]],194966:[[33510]],194967:[[158524]],194968:[[33509]],194969:[[33565]],194970:[[33635]],194971:[[33709]],194972:[[33571]],194973:[[33725]],194974:[[33767]],194975:[[33879]],194976:[[33619]],194977:[[33738]],194978:[[33740]],194979:[[33756]],194980:[[158774]],194981:[[159083]],194982:[[158933]],194983:[[17707]],194984:[[34033]],194985:[[34035]],194986:[[34070]],194987:[[160714]],194988:[[34148]],194989:[[159532]],194990:[[17757]],194991:[[17761]],194992:[[159665]],194993:[[159954]],194994:[[17771]],194995:[[34384]],194996:[[34396]],194997:[[34407]],194998:[[34409]],194999:[[34473]],195000:[[34440]],195001:[[34574]],195002:[[34530]],195003:[[34681]],195004:[[34600]],195005:[[34667]],195006:[[34694]],195007:[[17879]],195008:[[34785]],195009:[[34817]],195010:[[17913]],195011:[[34912]],195012:[[34915]],195013:[[161383]],195014:[[35031]],195015:[[35038]],195016:[[17973]],195017:[[35066]],195018:[[13499]],195019:[[161966]],195020:[[162150]],195021:[[18110]],195022:[[18119]],195023:[[35488]],195024:[[35565]],195025:[[35722]],195026:[[35925]],195027:[[162984]],195028:[[36011]],195029:[[36033]],195030:[[36123]],195031:[[36215]],195032:[[163631]],195033:[[133124]],195034:[[36299]],195035:[[36284]],195036:[[36336]],195037:[[133342]],195038:[[36564]],195039:[[36664]],195040:[[165330]],195041:[[165357]],195042:[[37012]],195043:[[37105]],195044:[[37137]],195045:[[165678]],195046:[[37147]],195047:[[37432]],195048:[[37591]],195049:[[37592]],195050:[[37500]],195051:[[37881]],195052:[[37909]],195053:[[166906]],195054:[[38283]],195055:[[18837]],195056:[[38327]],195057:[[167287]],195058:[[18918]],195059:[[38595]],195060:[[23986]],195061:[[38691]],195062:[[168261]],195063:[[168474]],195064:[[19054]],195065:[[19062]],195066:[[38880]],195067:[[168970]],195068:[[19122]],195069:[[169110]],195070:[[38923]],195071:[[38923]]}, +64000:{64000:[[20999]],64001:[[24230]],64002:[[25299]],64003:[[31958]],64004:[[23429]],64005:[[27934]],64006:[[26292]],64007:[[36667]],64008:[[34892]],64009:[[38477]],64010:[[35211]],64011:[[24275]],64012:[[20800]],64013:[[21952]],64016:[[22618]],64018:[[26228]],64021:[[20958]],64022:[[29482]],64023:[[30410]],64024:[[31036]],64025:[[31070]],64026:[[31077]],64027:[[31119]],64028:[[38742]],64029:[[31934]],64030:[[32701]],64032:[[34322]],64034:[[35576]],64037:[[36920]],64038:[[37117]],64042:[[39151]],64043:[[39164]],64044:[[39208]],64045:[[40372]],64046:[[37086]],64047:[[38583]],64048:[[20398]],64049:[[20711]],64050:[[20813]],64051:[[21193]],64052:[[21220]],64053:[[21329]],64054:[[21917]],64055:[[22022]],64056:[[22120]],64057:[[22592]],64058:[[22696]],64059:[[23652]],64060:[[23662]],64061:[[24724]],64062:[[24936]],64063:[[24974]],64064:[[25074]],64065:[[25935]],64066:[[26082]],64067:[[26257]],64068:[[26757]],64069:[[28023]],64070:[[28186]],64071:[[28450]],64072:[[29038]],64073:[[29227]],64074:[[29730]],64075:[[30865]],64076:[[31038]],64077:[[31049]],64078:[[31048]],64079:[[31056]],64080:[[31062]],64081:[[31069]],64082:[[31117]],64083:[[31118]],64084:[[31296]],64085:[[31361]],64086:[[31680]],64087:[[32244]],64088:[[32265]],64089:[[32321]],64090:[[32626]],64091:[[32773]],64092:[[33261]],64093:[[33401]],64094:[[33401]],64095:[[33879]],64096:[[35088]],64097:[[35222]],64098:[[35585]],64099:[[35641]],64100:[[36051]],64101:[[36104]],64102:[[36790]],64103:[[36920]],64104:[[38627]],64105:[[38911]],64106:[[38971]],64107:[[24693]],64108:[[148206]],64109:[[33304]],64112:[[20006]],64113:[[20917]],64114:[[20840]],64115:[[20352]],64116:[[20805]],64117:[[20864]],64118:[[21191]],64119:[[21242]],64120:[[21917]],64121:[[21845]],64122:[[21913]],64123:[[21986]],64124:[[22618]],64125:[[22707]],64126:[[22852]],64127:[[22868]],64128:[[23138]],64129:[[23336]],64130:[[24274]],64131:[[24281]],64132:[[24425]],64133:[[24493]],64134:[[24792]],64135:[[24910]],64136:[[24840]],64137:[[24974]],64138:[[24928]],64139:[[25074]],64140:[[25140]],64141:[[25540]],64142:[[25628]],64143:[[25682]],64144:[[25942]],64145:[[26228]],64146:[[26391]],64147:[[26395]],64148:[[26454]],64149:[[27513]],64150:[[27578]],64151:[[27969]],64152:[[28379]],64153:[[28363]],64154:[[28450]],64155:[[28702]],64156:[[29038]],64157:[[30631]],64158:[[29237]],64159:[[29359]],64160:[[29482]],64161:[[29809]],64162:[[29958]],64163:[[30011]],64164:[[30237]],64165:[[30239]],64166:[[30410]],64167:[[30427]],64168:[[30452]],64169:[[30538]],64170:[[30528]],64171:[[30924]],64172:[[31409]],64173:[[31680]],64174:[[31867]],64175:[[32091]],64176:[[32244]],64177:[[32574]],64178:[[32773]],64179:[[33618]],64180:[[33775]],64181:[[34681]],64182:[[35137]],64183:[[35206]],64184:[[35222]],64185:[[35519]],64186:[[35576]],64187:[[35531]],64188:[[35585]],64189:[[35582]],64190:[[35565]],64191:[[35641]],64192:[[35722]],64193:[[36104]],64194:[[36664]],64195:[[36978]],64196:[[37273]],64197:[[37494]],64198:[[38524]],64199:[[38627]],64200:[[38742]],64201:[[38875]],64202:[[38911]],64203:[[38923]],64204:[[38971]],64205:[[39698]],64206:[[40860]],64207:[[141386]],64208:[[141380]],64209:[[144341]],64210:[[15261]],64211:[[16408]],64212:[[16441]],64213:[[152137]],64214:[[154832]],64215:[[163539]],64216:[[40771]],64217:[[40846]],195072:[[38953]],195073:[[169398]],195074:[[39138]],195075:[[19251]],195076:[[39209]],195077:[[39335]],195078:[[39362]],195079:[[39422]],195080:[[19406]],195081:[[170800]],195082:[[39698]],195083:[[40000]],195084:[[40189]],195085:[[19662]],195086:[[19693]],195087:[[40295]],195088:[[172238]],195089:[[19704]],195090:[[172293]],195091:[[172558]],195092:[[172689]],195093:[[40635]],195094:[[19798]],195095:[[40697]],195096:[[40702]],195097:[[40709]],195098:[[40719]],195099:[[40726]],195100:[[40763]],195101:[[173568]]}, +64256:{64256:[[102,102],256],64257:[[102,105],256],64258:[[102,108],256],64259:[[102,102,105],256],64260:[[102,102,108],256],64261:[[383,116],256],64262:[[115,116],256],64275:[[1396,1398],256],64276:[[1396,1381],256],64277:[[1396,1387],256],64278:[[1406,1398],256],64279:[[1396,1389],256],64285:[[1497,1460],512],64286:[,26],64287:[[1522,1463],512],64288:[[1506],256],64289:[[1488],256],64290:[[1491],256],64291:[[1492],256],64292:[[1499],256],64293:[[1500],256],64294:[[1501],256],64295:[[1512],256],64296:[[1514],256],64297:[[43],256],64298:[[1513,1473],512],64299:[[1513,1474],512],64300:[[64329,1473],512],64301:[[64329,1474],512],64302:[[1488,1463],512],64303:[[1488,1464],512],64304:[[1488,1468],512],64305:[[1489,1468],512],64306:[[1490,1468],512],64307:[[1491,1468],512],64308:[[1492,1468],512],64309:[[1493,1468],512],64310:[[1494,1468],512],64312:[[1496,1468],512],64313:[[1497,1468],512],64314:[[1498,1468],512],64315:[[1499,1468],512],64316:[[1500,1468],512],64318:[[1502,1468],512],64320:[[1504,1468],512],64321:[[1505,1468],512],64323:[[1507,1468],512],64324:[[1508,1468],512],64326:[[1510,1468],512],64327:[[1511,1468],512],64328:[[1512,1468],512],64329:[[1513,1468],512],64330:[[1514,1468],512],64331:[[1493,1465],512],64332:[[1489,1471],512],64333:[[1499,1471],512],64334:[[1508,1471],512],64335:[[1488,1500],256],64336:[[1649],256],64337:[[1649],256],64338:[[1659],256],64339:[[1659],256],64340:[[1659],256],64341:[[1659],256],64342:[[1662],256],64343:[[1662],256],64344:[[1662],256],64345:[[1662],256],64346:[[1664],256],64347:[[1664],256],64348:[[1664],256],64349:[[1664],256],64350:[[1658],256],64351:[[1658],256],64352:[[1658],256],64353:[[1658],256],64354:[[1663],256],64355:[[1663],256],64356:[[1663],256],64357:[[1663],256],64358:[[1657],256],64359:[[1657],256],64360:[[1657],256],64361:[[1657],256],64362:[[1700],256],64363:[[1700],256],64364:[[1700],256],64365:[[1700],256],64366:[[1702],256],64367:[[1702],256],64368:[[1702],256],64369:[[1702],256],64370:[[1668],256],64371:[[1668],256],64372:[[1668],256],64373:[[1668],256],64374:[[1667],256],64375:[[1667],256],64376:[[1667],256],64377:[[1667],256],64378:[[1670],256],64379:[[1670],256],64380:[[1670],256],64381:[[1670],256],64382:[[1671],256],64383:[[1671],256],64384:[[1671],256],64385:[[1671],256],64386:[[1677],256],64387:[[1677],256],64388:[[1676],256],64389:[[1676],256],64390:[[1678],256],64391:[[1678],256],64392:[[1672],256],64393:[[1672],256],64394:[[1688],256],64395:[[1688],256],64396:[[1681],256],64397:[[1681],256],64398:[[1705],256],64399:[[1705],256],64400:[[1705],256],64401:[[1705],256],64402:[[1711],256],64403:[[1711],256],64404:[[1711],256],64405:[[1711],256],64406:[[1715],256],64407:[[1715],256],64408:[[1715],256],64409:[[1715],256],64410:[[1713],256],64411:[[1713],256],64412:[[1713],256],64413:[[1713],256],64414:[[1722],256],64415:[[1722],256],64416:[[1723],256],64417:[[1723],256],64418:[[1723],256],64419:[[1723],256],64420:[[1728],256],64421:[[1728],256],64422:[[1729],256],64423:[[1729],256],64424:[[1729],256],64425:[[1729],256],64426:[[1726],256],64427:[[1726],256],64428:[[1726],256],64429:[[1726],256],64430:[[1746],256],64431:[[1746],256],64432:[[1747],256],64433:[[1747],256],64467:[[1709],256],64468:[[1709],256],64469:[[1709],256],64470:[[1709],256],64471:[[1735],256],64472:[[1735],256],64473:[[1734],256],64474:[[1734],256],64475:[[1736],256],64476:[[1736],256],64477:[[1655],256],64478:[[1739],256],64479:[[1739],256],64480:[[1733],256],64481:[[1733],256],64482:[[1737],256],64483:[[1737],256],64484:[[1744],256],64485:[[1744],256],64486:[[1744],256],64487:[[1744],256],64488:[[1609],256],64489:[[1609],256],64490:[[1574,1575],256],64491:[[1574,1575],256],64492:[[1574,1749],256],64493:[[1574,1749],256],64494:[[1574,1608],256],64495:[[1574,1608],256],64496:[[1574,1735],256],64497:[[1574,1735],256],64498:[[1574,1734],256],64499:[[1574,1734],256],64500:[[1574,1736],256],64501:[[1574,1736],256],64502:[[1574,1744],256],64503:[[1574,1744],256],64504:[[1574,1744],256],64505:[[1574,1609],256],64506:[[1574,1609],256],64507:[[1574,1609],256],64508:[[1740],256],64509:[[1740],256],64510:[[1740],256],64511:[[1740],256]}, +64512:{64512:[[1574,1580],256],64513:[[1574,1581],256],64514:[[1574,1605],256],64515:[[1574,1609],256],64516:[[1574,1610],256],64517:[[1576,1580],256],64518:[[1576,1581],256],64519:[[1576,1582],256],64520:[[1576,1605],256],64521:[[1576,1609],256],64522:[[1576,1610],256],64523:[[1578,1580],256],64524:[[1578,1581],256],64525:[[1578,1582],256],64526:[[1578,1605],256],64527:[[1578,1609],256],64528:[[1578,1610],256],64529:[[1579,1580],256],64530:[[1579,1605],256],64531:[[1579,1609],256],64532:[[1579,1610],256],64533:[[1580,1581],256],64534:[[1580,1605],256],64535:[[1581,1580],256],64536:[[1581,1605],256],64537:[[1582,1580],256],64538:[[1582,1581],256],64539:[[1582,1605],256],64540:[[1587,1580],256],64541:[[1587,1581],256],64542:[[1587,1582],256],64543:[[1587,1605],256],64544:[[1589,1581],256],64545:[[1589,1605],256],64546:[[1590,1580],256],64547:[[1590,1581],256],64548:[[1590,1582],256],64549:[[1590,1605],256],64550:[[1591,1581],256],64551:[[1591,1605],256],64552:[[1592,1605],256],64553:[[1593,1580],256],64554:[[1593,1605],256],64555:[[1594,1580],256],64556:[[1594,1605],256],64557:[[1601,1580],256],64558:[[1601,1581],256],64559:[[1601,1582],256],64560:[[1601,1605],256],64561:[[1601,1609],256],64562:[[1601,1610],256],64563:[[1602,1581],256],64564:[[1602,1605],256],64565:[[1602,1609],256],64566:[[1602,1610],256],64567:[[1603,1575],256],64568:[[1603,1580],256],64569:[[1603,1581],256],64570:[[1603,1582],256],64571:[[1603,1604],256],64572:[[1603,1605],256],64573:[[1603,1609],256],64574:[[1603,1610],256],64575:[[1604,1580],256],64576:[[1604,1581],256],64577:[[1604,1582],256],64578:[[1604,1605],256],64579:[[1604,1609],256],64580:[[1604,1610],256],64581:[[1605,1580],256],64582:[[1605,1581],256],64583:[[1605,1582],256],64584:[[1605,1605],256],64585:[[1605,1609],256],64586:[[1605,1610],256],64587:[[1606,1580],256],64588:[[1606,1581],256],64589:[[1606,1582],256],64590:[[1606,1605],256],64591:[[1606,1609],256],64592:[[1606,1610],256],64593:[[1607,1580],256],64594:[[1607,1605],256],64595:[[1607,1609],256],64596:[[1607,1610],256],64597:[[1610,1580],256],64598:[[1610,1581],256],64599:[[1610,1582],256],64600:[[1610,1605],256],64601:[[1610,1609],256],64602:[[1610,1610],256],64603:[[1584,1648],256],64604:[[1585,1648],256],64605:[[1609,1648],256],64606:[[32,1612,1617],256],64607:[[32,1613,1617],256],64608:[[32,1614,1617],256],64609:[[32,1615,1617],256],64610:[[32,1616,1617],256],64611:[[32,1617,1648],256],64612:[[1574,1585],256],64613:[[1574,1586],256],64614:[[1574,1605],256],64615:[[1574,1606],256],64616:[[1574,1609],256],64617:[[1574,1610],256],64618:[[1576,1585],256],64619:[[1576,1586],256],64620:[[1576,1605],256],64621:[[1576,1606],256],64622:[[1576,1609],256],64623:[[1576,1610],256],64624:[[1578,1585],256],64625:[[1578,1586],256],64626:[[1578,1605],256],64627:[[1578,1606],256],64628:[[1578,1609],256],64629:[[1578,1610],256],64630:[[1579,1585],256],64631:[[1579,1586],256],64632:[[1579,1605],256],64633:[[1579,1606],256],64634:[[1579,1609],256],64635:[[1579,1610],256],64636:[[1601,1609],256],64637:[[1601,1610],256],64638:[[1602,1609],256],64639:[[1602,1610],256],64640:[[1603,1575],256],64641:[[1603,1604],256],64642:[[1603,1605],256],64643:[[1603,1609],256],64644:[[1603,1610],256],64645:[[1604,1605],256],64646:[[1604,1609],256],64647:[[1604,1610],256],64648:[[1605,1575],256],64649:[[1605,1605],256],64650:[[1606,1585],256],64651:[[1606,1586],256],64652:[[1606,1605],256],64653:[[1606,1606],256],64654:[[1606,1609],256],64655:[[1606,1610],256],64656:[[1609,1648],256],64657:[[1610,1585],256],64658:[[1610,1586],256],64659:[[1610,1605],256],64660:[[1610,1606],256],64661:[[1610,1609],256],64662:[[1610,1610],256],64663:[[1574,1580],256],64664:[[1574,1581],256],64665:[[1574,1582],256],64666:[[1574,1605],256],64667:[[1574,1607],256],64668:[[1576,1580],256],64669:[[1576,1581],256],64670:[[1576,1582],256],64671:[[1576,1605],256],64672:[[1576,1607],256],64673:[[1578,1580],256],64674:[[1578,1581],256],64675:[[1578,1582],256],64676:[[1578,1605],256],64677:[[1578,1607],256],64678:[[1579,1605],256],64679:[[1580,1581],256],64680:[[1580,1605],256],64681:[[1581,1580],256],64682:[[1581,1605],256],64683:[[1582,1580],256],64684:[[1582,1605],256],64685:[[1587,1580],256],64686:[[1587,1581],256],64687:[[1587,1582],256],64688:[[1587,1605],256],64689:[[1589,1581],256],64690:[[1589,1582],256],64691:[[1589,1605],256],64692:[[1590,1580],256],64693:[[1590,1581],256],64694:[[1590,1582],256],64695:[[1590,1605],256],64696:[[1591,1581],256],64697:[[1592,1605],256],64698:[[1593,1580],256],64699:[[1593,1605],256],64700:[[1594,1580],256],64701:[[1594,1605],256],64702:[[1601,1580],256],64703:[[1601,1581],256],64704:[[1601,1582],256],64705:[[1601,1605],256],64706:[[1602,1581],256],64707:[[1602,1605],256],64708:[[1603,1580],256],64709:[[1603,1581],256],64710:[[1603,1582],256],64711:[[1603,1604],256],64712:[[1603,1605],256],64713:[[1604,1580],256],64714:[[1604,1581],256],64715:[[1604,1582],256],64716:[[1604,1605],256],64717:[[1604,1607],256],64718:[[1605,1580],256],64719:[[1605,1581],256],64720:[[1605,1582],256],64721:[[1605,1605],256],64722:[[1606,1580],256],64723:[[1606,1581],256],64724:[[1606,1582],256],64725:[[1606,1605],256],64726:[[1606,1607],256],64727:[[1607,1580],256],64728:[[1607,1605],256],64729:[[1607,1648],256],64730:[[1610,1580],256],64731:[[1610,1581],256],64732:[[1610,1582],256],64733:[[1610,1605],256],64734:[[1610,1607],256],64735:[[1574,1605],256],64736:[[1574,1607],256],64737:[[1576,1605],256],64738:[[1576,1607],256],64739:[[1578,1605],256],64740:[[1578,1607],256],64741:[[1579,1605],256],64742:[[1579,1607],256],64743:[[1587,1605],256],64744:[[1587,1607],256],64745:[[1588,1605],256],64746:[[1588,1607],256],64747:[[1603,1604],256],64748:[[1603,1605],256],64749:[[1604,1605],256],64750:[[1606,1605],256],64751:[[1606,1607],256],64752:[[1610,1605],256],64753:[[1610,1607],256],64754:[[1600,1614,1617],256],64755:[[1600,1615,1617],256],64756:[[1600,1616,1617],256],64757:[[1591,1609],256],64758:[[1591,1610],256],64759:[[1593,1609],256],64760:[[1593,1610],256],64761:[[1594,1609],256],64762:[[1594,1610],256],64763:[[1587,1609],256],64764:[[1587,1610],256],64765:[[1588,1609],256],64766:[[1588,1610],256],64767:[[1581,1609],256]}, +64768:{64768:[[1581,1610],256],64769:[[1580,1609],256],64770:[[1580,1610],256],64771:[[1582,1609],256],64772:[[1582,1610],256],64773:[[1589,1609],256],64774:[[1589,1610],256],64775:[[1590,1609],256],64776:[[1590,1610],256],64777:[[1588,1580],256],64778:[[1588,1581],256],64779:[[1588,1582],256],64780:[[1588,1605],256],64781:[[1588,1585],256],64782:[[1587,1585],256],64783:[[1589,1585],256],64784:[[1590,1585],256],64785:[[1591,1609],256],64786:[[1591,1610],256],64787:[[1593,1609],256],64788:[[1593,1610],256],64789:[[1594,1609],256],64790:[[1594,1610],256],64791:[[1587,1609],256],64792:[[1587,1610],256],64793:[[1588,1609],256],64794:[[1588,1610],256],64795:[[1581,1609],256],64796:[[1581,1610],256],64797:[[1580,1609],256],64798:[[1580,1610],256],64799:[[1582,1609],256],64800:[[1582,1610],256],64801:[[1589,1609],256],64802:[[1589,1610],256],64803:[[1590,1609],256],64804:[[1590,1610],256],64805:[[1588,1580],256],64806:[[1588,1581],256],64807:[[1588,1582],256],64808:[[1588,1605],256],64809:[[1588,1585],256],64810:[[1587,1585],256],64811:[[1589,1585],256],64812:[[1590,1585],256],64813:[[1588,1580],256],64814:[[1588,1581],256],64815:[[1588,1582],256],64816:[[1588,1605],256],64817:[[1587,1607],256],64818:[[1588,1607],256],64819:[[1591,1605],256],64820:[[1587,1580],256],64821:[[1587,1581],256],64822:[[1587,1582],256],64823:[[1588,1580],256],64824:[[1588,1581],256],64825:[[1588,1582],256],64826:[[1591,1605],256],64827:[[1592,1605],256],64828:[[1575,1611],256],64829:[[1575,1611],256],64848:[[1578,1580,1605],256],64849:[[1578,1581,1580],256],64850:[[1578,1581,1580],256],64851:[[1578,1581,1605],256],64852:[[1578,1582,1605],256],64853:[[1578,1605,1580],256],64854:[[1578,1605,1581],256],64855:[[1578,1605,1582],256],64856:[[1580,1605,1581],256],64857:[[1580,1605,1581],256],64858:[[1581,1605,1610],256],64859:[[1581,1605,1609],256],64860:[[1587,1581,1580],256],64861:[[1587,1580,1581],256],64862:[[1587,1580,1609],256],64863:[[1587,1605,1581],256],64864:[[1587,1605,1581],256],64865:[[1587,1605,1580],256],64866:[[1587,1605,1605],256],64867:[[1587,1605,1605],256],64868:[[1589,1581,1581],256],64869:[[1589,1581,1581],256],64870:[[1589,1605,1605],256],64871:[[1588,1581,1605],256],64872:[[1588,1581,1605],256],64873:[[1588,1580,1610],256],64874:[[1588,1605,1582],256],64875:[[1588,1605,1582],256],64876:[[1588,1605,1605],256],64877:[[1588,1605,1605],256],64878:[[1590,1581,1609],256],64879:[[1590,1582,1605],256],64880:[[1590,1582,1605],256],64881:[[1591,1605,1581],256],64882:[[1591,1605,1581],256],64883:[[1591,1605,1605],256],64884:[[1591,1605,1610],256],64885:[[1593,1580,1605],256],64886:[[1593,1605,1605],256],64887:[[1593,1605,1605],256],64888:[[1593,1605,1609],256],64889:[[1594,1605,1605],256],64890:[[1594,1605,1610],256],64891:[[1594,1605,1609],256],64892:[[1601,1582,1605],256],64893:[[1601,1582,1605],256],64894:[[1602,1605,1581],256],64895:[[1602,1605,1605],256],64896:[[1604,1581,1605],256],64897:[[1604,1581,1610],256],64898:[[1604,1581,1609],256],64899:[[1604,1580,1580],256],64900:[[1604,1580,1580],256],64901:[[1604,1582,1605],256],64902:[[1604,1582,1605],256],64903:[[1604,1605,1581],256],64904:[[1604,1605,1581],256],64905:[[1605,1581,1580],256],64906:[[1605,1581,1605],256],64907:[[1605,1581,1610],256],64908:[[1605,1580,1581],256],64909:[[1605,1580,1605],256],64910:[[1605,1582,1580],256],64911:[[1605,1582,1605],256],64914:[[1605,1580,1582],256],64915:[[1607,1605,1580],256],64916:[[1607,1605,1605],256],64917:[[1606,1581,1605],256],64918:[[1606,1581,1609],256],64919:[[1606,1580,1605],256],64920:[[1606,1580,1605],256],64921:[[1606,1580,1609],256],64922:[[1606,1605,1610],256],64923:[[1606,1605,1609],256],64924:[[1610,1605,1605],256],64925:[[1610,1605,1605],256],64926:[[1576,1582,1610],256],64927:[[1578,1580,1610],256],64928:[[1578,1580,1609],256],64929:[[1578,1582,1610],256],64930:[[1578,1582,1609],256],64931:[[1578,1605,1610],256],64932:[[1578,1605,1609],256],64933:[[1580,1605,1610],256],64934:[[1580,1581,1609],256],64935:[[1580,1605,1609],256],64936:[[1587,1582,1609],256],64937:[[1589,1581,1610],256],64938:[[1588,1581,1610],256],64939:[[1590,1581,1610],256],64940:[[1604,1580,1610],256],64941:[[1604,1605,1610],256],64942:[[1610,1581,1610],256],64943:[[1610,1580,1610],256],64944:[[1610,1605,1610],256],64945:[[1605,1605,1610],256],64946:[[1602,1605,1610],256],64947:[[1606,1581,1610],256],64948:[[1602,1605,1581],256],64949:[[1604,1581,1605],256],64950:[[1593,1605,1610],256],64951:[[1603,1605,1610],256],64952:[[1606,1580,1581],256],64953:[[1605,1582,1610],256],64954:[[1604,1580,1605],256],64955:[[1603,1605,1605],256],64956:[[1604,1580,1605],256],64957:[[1606,1580,1581],256],64958:[[1580,1581,1610],256],64959:[[1581,1580,1610],256],64960:[[1605,1580,1610],256],64961:[[1601,1605,1610],256],64962:[[1576,1581,1610],256],64963:[[1603,1605,1605],256],64964:[[1593,1580,1605],256],64965:[[1589,1605,1605],256],64966:[[1587,1582,1610],256],64967:[[1606,1580,1610],256],65008:[[1589,1604,1746],256],65009:[[1602,1604,1746],256],65010:[[1575,1604,1604,1607],256],65011:[[1575,1603,1576,1585],256],65012:[[1605,1581,1605,1583],256],65013:[[1589,1604,1593,1605],256],65014:[[1585,1587,1608,1604],256],65015:[[1593,1604,1610,1607],256],65016:[[1608,1587,1604,1605],256],65017:[[1589,1604,1609],256],65018:[[1589,1604,1609,32,1575,1604,1604,1607,32,1593,1604,1610,1607,32,1608,1587,1604,1605],256],65019:[[1580,1604,32,1580,1604,1575,1604,1607],256],65020:[[1585,1740,1575,1604],256]}, +65024:{65040:[[44],256],65041:[[12289],256],65042:[[12290],256],65043:[[58],256],65044:[[59],256],65045:[[33],256],65046:[[63],256],65047:[[12310],256],65048:[[12311],256],65049:[[8230],256],65056:[,230],65057:[,230],65058:[,230],65059:[,230],65060:[,230],65061:[,230],65062:[,230],65063:[,220],65064:[,220],65065:[,220],65066:[,220],65067:[,220],65068:[,220],65069:[,220],65072:[[8229],256],65073:[[8212],256],65074:[[8211],256],65075:[[95],256],65076:[[95],256],65077:[[40],256],65078:[[41],256],65079:[[123],256],65080:[[125],256],65081:[[12308],256],65082:[[12309],256],65083:[[12304],256],65084:[[12305],256],65085:[[12298],256],65086:[[12299],256],65087:[[12296],256],65088:[[12297],256],65089:[[12300],256],65090:[[12301],256],65091:[[12302],256],65092:[[12303],256],65095:[[91],256],65096:[[93],256],65097:[[8254],256],65098:[[8254],256],65099:[[8254],256],65100:[[8254],256],65101:[[95],256],65102:[[95],256],65103:[[95],256],65104:[[44],256],65105:[[12289],256],65106:[[46],256],65108:[[59],256],65109:[[58],256],65110:[[63],256],65111:[[33],256],65112:[[8212],256],65113:[[40],256],65114:[[41],256],65115:[[123],256],65116:[[125],256],65117:[[12308],256],65118:[[12309],256],65119:[[35],256],65120:[[38],256],65121:[[42],256],65122:[[43],256],65123:[[45],256],65124:[[60],256],65125:[[62],256],65126:[[61],256],65128:[[92],256],65129:[[36],256],65130:[[37],256],65131:[[64],256],65136:[[32,1611],256],65137:[[1600,1611],256],65138:[[32,1612],256],65140:[[32,1613],256],65142:[[32,1614],256],65143:[[1600,1614],256],65144:[[32,1615],256],65145:[[1600,1615],256],65146:[[32,1616],256],65147:[[1600,1616],256],65148:[[32,1617],256],65149:[[1600,1617],256],65150:[[32,1618],256],65151:[[1600,1618],256],65152:[[1569],256],65153:[[1570],256],65154:[[1570],256],65155:[[1571],256],65156:[[1571],256],65157:[[1572],256],65158:[[1572],256],65159:[[1573],256],65160:[[1573],256],65161:[[1574],256],65162:[[1574],256],65163:[[1574],256],65164:[[1574],256],65165:[[1575],256],65166:[[1575],256],65167:[[1576],256],65168:[[1576],256],65169:[[1576],256],65170:[[1576],256],65171:[[1577],256],65172:[[1577],256],65173:[[1578],256],65174:[[1578],256],65175:[[1578],256],65176:[[1578],256],65177:[[1579],256],65178:[[1579],256],65179:[[1579],256],65180:[[1579],256],65181:[[1580],256],65182:[[1580],256],65183:[[1580],256],65184:[[1580],256],65185:[[1581],256],65186:[[1581],256],65187:[[1581],256],65188:[[1581],256],65189:[[1582],256],65190:[[1582],256],65191:[[1582],256],65192:[[1582],256],65193:[[1583],256],65194:[[1583],256],65195:[[1584],256],65196:[[1584],256],65197:[[1585],256],65198:[[1585],256],65199:[[1586],256],65200:[[1586],256],65201:[[1587],256],65202:[[1587],256],65203:[[1587],256],65204:[[1587],256],65205:[[1588],256],65206:[[1588],256],65207:[[1588],256],65208:[[1588],256],65209:[[1589],256],65210:[[1589],256],65211:[[1589],256],65212:[[1589],256],65213:[[1590],256],65214:[[1590],256],65215:[[1590],256],65216:[[1590],256],65217:[[1591],256],65218:[[1591],256],65219:[[1591],256],65220:[[1591],256],65221:[[1592],256],65222:[[1592],256],65223:[[1592],256],65224:[[1592],256],65225:[[1593],256],65226:[[1593],256],65227:[[1593],256],65228:[[1593],256],65229:[[1594],256],65230:[[1594],256],65231:[[1594],256],65232:[[1594],256],65233:[[1601],256],65234:[[1601],256],65235:[[1601],256],65236:[[1601],256],65237:[[1602],256],65238:[[1602],256],65239:[[1602],256],65240:[[1602],256],65241:[[1603],256],65242:[[1603],256],65243:[[1603],256],65244:[[1603],256],65245:[[1604],256],65246:[[1604],256],65247:[[1604],256],65248:[[1604],256],65249:[[1605],256],65250:[[1605],256],65251:[[1605],256],65252:[[1605],256],65253:[[1606],256],65254:[[1606],256],65255:[[1606],256],65256:[[1606],256],65257:[[1607],256],65258:[[1607],256],65259:[[1607],256],65260:[[1607],256],65261:[[1608],256],65262:[[1608],256],65263:[[1609],256],65264:[[1609],256],65265:[[1610],256],65266:[[1610],256],65267:[[1610],256],65268:[[1610],256],65269:[[1604,1570],256],65270:[[1604,1570],256],65271:[[1604,1571],256],65272:[[1604,1571],256],65273:[[1604,1573],256],65274:[[1604,1573],256],65275:[[1604,1575],256],65276:[[1604,1575],256]}, +65280:{65281:[[33],256],65282:[[34],256],65283:[[35],256],65284:[[36],256],65285:[[37],256],65286:[[38],256],65287:[[39],256],65288:[[40],256],65289:[[41],256],65290:[[42],256],65291:[[43],256],65292:[[44],256],65293:[[45],256],65294:[[46],256],65295:[[47],256],65296:[[48],256],65297:[[49],256],65298:[[50],256],65299:[[51],256],65300:[[52],256],65301:[[53],256],65302:[[54],256],65303:[[55],256],65304:[[56],256],65305:[[57],256],65306:[[58],256],65307:[[59],256],65308:[[60],256],65309:[[61],256],65310:[[62],256],65311:[[63],256],65312:[[64],256],65313:[[65],256],65314:[[66],256],65315:[[67],256],65316:[[68],256],65317:[[69],256],65318:[[70],256],65319:[[71],256],65320:[[72],256],65321:[[73],256],65322:[[74],256],65323:[[75],256],65324:[[76],256],65325:[[77],256],65326:[[78],256],65327:[[79],256],65328:[[80],256],65329:[[81],256],65330:[[82],256],65331:[[83],256],65332:[[84],256],65333:[[85],256],65334:[[86],256],65335:[[87],256],65336:[[88],256],65337:[[89],256],65338:[[90],256],65339:[[91],256],65340:[[92],256],65341:[[93],256],65342:[[94],256],65343:[[95],256],65344:[[96],256],65345:[[97],256],65346:[[98],256],65347:[[99],256],65348:[[100],256],65349:[[101],256],65350:[[102],256],65351:[[103],256],65352:[[104],256],65353:[[105],256],65354:[[106],256],65355:[[107],256],65356:[[108],256],65357:[[109],256],65358:[[110],256],65359:[[111],256],65360:[[112],256],65361:[[113],256],65362:[[114],256],65363:[[115],256],65364:[[116],256],65365:[[117],256],65366:[[118],256],65367:[[119],256],65368:[[120],256],65369:[[121],256],65370:[[122],256],65371:[[123],256],65372:[[124],256],65373:[[125],256],65374:[[126],256],65375:[[10629],256],65376:[[10630],256],65377:[[12290],256],65378:[[12300],256],65379:[[12301],256],65380:[[12289],256],65381:[[12539],256],65382:[[12530],256],65383:[[12449],256],65384:[[12451],256],65385:[[12453],256],65386:[[12455],256],65387:[[12457],256],65388:[[12515],256],65389:[[12517],256],65390:[[12519],256],65391:[[12483],256],65392:[[12540],256],65393:[[12450],256],65394:[[12452],256],65395:[[12454],256],65396:[[12456],256],65397:[[12458],256],65398:[[12459],256],65399:[[12461],256],65400:[[12463],256],65401:[[12465],256],65402:[[12467],256],65403:[[12469],256],65404:[[12471],256],65405:[[12473],256],65406:[[12475],256],65407:[[12477],256],65408:[[12479],256],65409:[[12481],256],65410:[[12484],256],65411:[[12486],256],65412:[[12488],256],65413:[[12490],256],65414:[[12491],256],65415:[[12492],256],65416:[[12493],256],65417:[[12494],256],65418:[[12495],256],65419:[[12498],256],65420:[[12501],256],65421:[[12504],256],65422:[[12507],256],65423:[[12510],256],65424:[[12511],256],65425:[[12512],256],65426:[[12513],256],65427:[[12514],256],65428:[[12516],256],65429:[[12518],256],65430:[[12520],256],65431:[[12521],256],65432:[[12522],256],65433:[[12523],256],65434:[[12524],256],65435:[[12525],256],65436:[[12527],256],65437:[[12531],256],65438:[[12441],256],65439:[[12442],256],65440:[[12644],256],65441:[[12593],256],65442:[[12594],256],65443:[[12595],256],65444:[[12596],256],65445:[[12597],256],65446:[[12598],256],65447:[[12599],256],65448:[[12600],256],65449:[[12601],256],65450:[[12602],256],65451:[[12603],256],65452:[[12604],256],65453:[[12605],256],65454:[[12606],256],65455:[[12607],256],65456:[[12608],256],65457:[[12609],256],65458:[[12610],256],65459:[[12611],256],65460:[[12612],256],65461:[[12613],256],65462:[[12614],256],65463:[[12615],256],65464:[[12616],256],65465:[[12617],256],65466:[[12618],256],65467:[[12619],256],65468:[[12620],256],65469:[[12621],256],65470:[[12622],256],65474:[[12623],256],65475:[[12624],256],65476:[[12625],256],65477:[[12626],256],65478:[[12627],256],65479:[[12628],256],65482:[[12629],256],65483:[[12630],256],65484:[[12631],256],65485:[[12632],256],65486:[[12633],256],65487:[[12634],256],65490:[[12635],256],65491:[[12636],256],65492:[[12637],256],65493:[[12638],256],65494:[[12639],256],65495:[[12640],256],65498:[[12641],256],65499:[[12642],256],65500:[[12643],256],65504:[[162],256],65505:[[163],256],65506:[[172],256],65507:[[175],256],65508:[[166],256],65509:[[165],256],65510:[[8361],256],65512:[[9474],256],65513:[[8592],256],65514:[[8593],256],65515:[[8594],256],65516:[[8595],256],65517:[[9632],256],65518:[[9675],256]} + +}; + + /***** Module to export */ + var unorm = { + nfc: nfc, + nfd: nfd, + nfkc: nfkc, + nfkd: nfkd + }; + + /*globals module:true,define:true*/ + + // CommonJS + if (typeof module === "object") { + module.exports = unorm; + + // AMD + } else if (typeof define === "function" && define.amd) { + define("unorm", function () { + return unorm; + }); + + // Global + } else { + root.unorm = unorm; + } + + /***** Export as shim for String::normalize method *****/ + /* + http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#november_8_2013_draft_rev_21 + + 21.1.3.12 String.prototype.normalize(form="NFC") + When the normalize method is called with one argument form, the following steps are taken: + + 1. Let O be CheckObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. If form is not provided or undefined let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw a RangeError Exception. + 8. Let ns be the String value is the result of normalizing S into the normalization form named by f as specified in Unicode Standard Annex #15, UnicodeNormalizatoin Forms. + 9. Return ns. + + The length property of the normalize method is 0. + + *NOTE* The normalize function is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method. + */ + unorm.shimApplied = false; + + if (!String.prototype.normalize) { + String.prototype.normalize = function(form) { + var str = "" + this; + form = form === undefined ? "NFC" : form; + + if (form === "NFC") { + return unorm.nfc(str); + } else if (form === "NFD") { + return unorm.nfd(str); + } else if (form === "NFKC") { + return unorm.nfkc(str); + } else if (form === "NFKD") { + return unorm.nfkd(str); + } else { + throw new RangeError("Invalid normalization form: " + form); + } + }; + + unorm.shimApplied = true; + } +}(this)); diff --git a/packages/signing-key/.npmignore b/packages/signing-key/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/signing-key/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/signing-key/LICENSE.md b/packages/signing-key/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/signing-key/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/signing-key/README.md b/packages/signing-key/README.md new file mode 100644 index 000000000..b756558bb --- /dev/null +++ b/packages/signing-key/README.md @@ -0,0 +1,5 @@ +Signing Key +=========== + +**EXPERIMENTAL** + diff --git a/packages/signing-key/package.json b/packages/signing-key/package.json new file mode 100644 index 000000000..bf2fadc0b --- /dev/null +++ b/packages/signing-key/package.json @@ -0,0 +1,25 @@ +{ + "name": "@ethersproject/signing-key", + "version": "5.0.0-beta.125", + "description": "Elliptic curve library functions for the secp256k1 curve.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "elliptic": "6.3.3" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x3f0419edaa2a79a0b62ab5221b243388c2600dec79cc169cb20b9c4ce906ce27" +} diff --git a/packages/signing-key/src.ts/_version.ts b/packages/signing-key/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/signing-key/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/signing-key/src.ts/index.ts b/packages/signing-key/src.ts/index.ts new file mode 100644 index 000000000..fa931f1cc --- /dev/null +++ b/packages/signing-key/src.ts/index.ts @@ -0,0 +1,88 @@ +"use strict"; + +import { ec as EC } from "elliptic"; + +import { arrayify, BytesLike, hexlify, hexZeroPad, Signature, SignatureLike, splitSignature } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { defineReadOnly } from "@ethersproject/properties"; + +let _curve: EC = null +function getCurve() { + if (!_curve) { + _curve = new EC("secp256k1"); + } + return _curve; +} + +export class SigningKey { + + readonly curve: string; + + readonly privateKey: string; + readonly publicKey: string; + readonly compressedPublicKey: string; + + readonly address: string; + + constructor(privateKey: BytesLike) { + defineReadOnly(this, "curve", "secp256k1"); + + defineReadOnly(this, "privateKey", hexlify(privateKey)); + + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + + defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + } + + _addPoint(other: BytesLike): string { + let p0 = getCurve().keyFromPublic(arrayify(this.publicKey)); + let p1 = getCurve().keyFromPublic(arrayify(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + } + + signDigest(digest: BytesLike): Signature { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let signature = keyPair.sign(arrayify(digest), { canonical: true }); + return splitSignature({ + recoveryParam: signature.recoveryParam, + r: hexZeroPad("0x" + signature.r.toString(16), 32), + s: hexZeroPad("0x" + signature.s.toString(16), 32), + }) + } + + computeSharedSecret(otherKey: BytesLike): string { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey))); + return hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + } +} + +export function recoverPublicKey(digest: BytesLike, signature: SignatureLike): string { + let sig = splitSignature(signature); + let rs = { r: arrayify(sig.r), s: arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(arrayify(digest), rs, sig.recoveryParam).encode("hex", false); +} + +export function computePublicKey(key: BytesLike, compressed?: boolean): string { + let bytes = arrayify(key); + + if (bytes.length === 32) { + let signingKey = new SigningKey(bytes); + if (compressed) { + return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); + } + return signingKey.publicKey; + + } else if (bytes.length === 33) { + if (compressed) { return hexlify(bytes); } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); + + } else if (bytes.length === 65) { + if (!compressed) { return hexlify(bytes); } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); + } + + return errors.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} + diff --git a/packages/signing-key/thirdparty.d.ts b/packages/signing-key/thirdparty.d.ts new file mode 100644 index 000000000..b7c9f709f --- /dev/null +++ b/packages/signing-key/thirdparty.d.ts @@ -0,0 +1,70 @@ +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; + } +} + +declare module "elliptic" { + import { BN } from "bn.js"; + export type BasicSignature = { + r: Uint8Array; + s: Uint8Array; + }; + + export type Signature = { + r: BN, + s: BN, + recoveryParam: number + } + + interface Point { + add(point: Point): Point; + encodeCompressed(enc: string): string + } + + interface KeyPair { + sign(message: Uint8Array, options: { canonical?: boolean }): Signature; + getPublic(compressed: boolean, encoding?: string): string; + getPublic(): BN; + getPrivate(encoding?: string): string; + encode(encoding: string, compressed: boolean): string; + derive(publicKey: BN): BN; + pub: Point; + priv: BN; + } + + export class ec { + constructor(curveName: string); + + n: BN; + + keyFromPublic(publicKey: Uint8Array): KeyPair; + keyFromPrivate(privateKey: Uint8Array): KeyPair; + recoverPubKey(data: Uint8Array, signature: BasicSignature, recoveryParam: number): KeyPair; + } +} diff --git a/packages/signing-key/tsconfig.json b/packages/signing-key/tsconfig.json new file mode 100644 index 000000000..a86d682a0 --- /dev/null +++ b/packages/signing-key/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/solidity/.npmignore b/packages/solidity/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/solidity/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/solidity/LICENSE.md b/packages/solidity/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/solidity/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/solidity/README.md b/packages/solidity/README.md new file mode 100644 index 000000000..a8b9e7084 --- /dev/null +++ b/packages/solidity/README.md @@ -0,0 +1,17 @@ +Solidity Packed-Encoding Utilities +================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/solidity/package.json b/packages/solidity/package.json new file mode 100644 index 000000000..38c48d567 --- /dev/null +++ b/packages/solidity/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/solidity", + "version": "5.0.0-beta.124", + "description": "Solidity coder for non-standard (tight) packing.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/sha2": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xb487ad2d0967bad47bd8829b1009dbf44109fa51734e393d767c537fa1cd95e6" +} diff --git a/packages/solidity/src.ts/_version.ts b/packages/solidity/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/solidity/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/solidity/src.ts/index.ts b/packages/solidity/src.ts/index.ts new file mode 100644 index 000000000..a0d9367cd --- /dev/null +++ b/packages/solidity/src.ts/index.ts @@ -0,0 +1,88 @@ +"use strict"; + +import { BigNumber } from "@ethersproject/bignumber"; +import { arrayify, concat, hexlify, zeroPad } from "@ethersproject/bytes"; +import { keccak256 as hashKeccak256 } from "@ethersproject/keccak256"; +import { sha256 as hashSha256 } from "@ethersproject/sha2"; +import { toUtf8Bytes } from "@ethersproject/strings"; + +const regexBytes = new RegExp("^bytes([0-9]+)$"); +const regexNumber = new RegExp("^(u?int)([0-9]*)$"); +const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); + +const Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; + +function _pack(type: string, value: any, isArray?: boolean): Uint8Array { + switch(type) { + case "address": + if (isArray) { return zeroPad(value, 32); } + return arrayify(value); + case "string": + return toUtf8Bytes(value); + case "bytes": + return arrayify(value); + case "bool": + value = (value ? "0x01": "0x00"); + if (isArray) { return zeroPad(value, 32); } + return arrayify(value); + } + + let match = type.match(regexNumber); + if (match) { + //let signed = (match[1] === "int") + let size = parseInt(match[2] || "256") + if ((size % 8 != 0) || size === 0 || size > 256) { + throw new Error("invalid number type - " + type); + } + + if (isArray) { size = 256; } + + value = BigNumber.from(value).toTwos(size); + + return zeroPad(value, size / 8); + } + + match = type.match(regexBytes); + if (match) { + let size = parseInt(match[1]); + if (String(size) != match[1] || size === 0 || size > 32) { + throw new Error("invalid number type - " + type); + } + if (arrayify(value).byteLength !== size) { throw new Error("invalid value for " + type); } + if (isArray) { return arrayify((value + Zeros).substring(0, 66)); } + return value; + } + + match = type.match(regexArray); + if (match && Array.isArray(value)) { + let baseType = match[1]; + let count = parseInt(match[2] || String(value.length)); + if (count != value.length) { throw new Error("invalid value for " + type); } + let result: Array = []; + value.forEach(function(value) { + result.push(_pack(baseType, value, true)); + }); + return concat(result); + } + + throw new Error("unknown type - " + type); +} + +// @TODO: Array Enum + +export function pack(types: Array, values: Array) { + if (types.length != values.length) { throw new Error("type/value count mismatch"); } + let tight: Array = []; + types.forEach(function(type, index) { + tight.push(_pack(type, values[index])); + }); + return hexlify(concat(tight)); +} + +export function keccak256(types: Array, values: Array) { + return hashKeccak256(pack(types, values)); +} + +export function sha256(types: Array, values: Array) { + return hashSha256(pack(types, values)); +} diff --git a/packages/solidity/tsconfig.json b/packages/solidity/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/solidity/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/strings/.npmignore b/packages/strings/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/strings/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/strings/LICENSE.md b/packages/strings/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/strings/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/strings/README.md b/packages/strings/README.md new file mode 100644 index 000000000..4b556cfdd --- /dev/null +++ b/packages/strings/README.md @@ -0,0 +1,17 @@ +String Manipulation Utilities +============================= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/strings/package.json b/packages/strings/package.json new file mode 100644 index 000000000..617d308ae --- /dev/null +++ b/packages/strings/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/strings", + "version": "5.0.0-beta.124", + "description": "String utility functions.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers", + "strings", + "utf8" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x07db51c71e10e30a890a69b4a7e7da9a052e9d2f5d736c8325de0925519e34b6" +} diff --git a/packages/strings/src.ts/_version.ts b/packages/strings/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/strings/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/strings/src.ts/index.ts b/packages/strings/src.ts/index.ts new file mode 100644 index 000000000..9768f16af --- /dev/null +++ b/packages/strings/src.ts/index.ts @@ -0,0 +1,197 @@ +"use strict"; + +import { HashZero } from "@ethersproject/constants"; +import { checkNormalize } from "@ethersproject/errors"; + +import { arrayify, BytesLike, concat, hexlify } from "@ethersproject/bytes"; + +/////////////////////////////// + +export enum UnicodeNormalizationForm { + current = "", + NFC = "NFC", + NFD = "NFD", + NFKC = "NFKC", + NFKD = "NFKD" +}; + +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +export function toUtf8Bytes(str: string, form: UnicodeNormalizationForm = UnicodeNormalizationForm.current): Uint8Array { + + if (form != UnicodeNormalizationForm.current) { + checkNormalize(); + str = str.normalize(form); + } + + let result = []; + for (let i = 0; i < str.length; i++) { + let c = str.charCodeAt(i); + + if (c < 0x80) { + result.push(c); + + } else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + + } else if ((c & 0xfc00) == 0xd800) { + i++; + let c2 = str.charCodeAt(i); + + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + + // Surrogate Pair + c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((c >> 18) | 0xf0); + result.push(((c >> 12) & 0x3f) | 0x80); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + + } else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + + return arrayify(result); +}; + + +// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 +export function toUtf8String(bytes: BytesLike, ignoreErrors?: boolean): string { + bytes = arrayify(bytes); + + let result = ""; + let i = 0; + + // Invalid bytes are ignored + while(i < bytes.length) { + + let c = bytes[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result += String.fromCharCode(c); + continue; + } + + // Multibyte; how many bytes left for this character? + let extraLength = null; + let overlongMask = null; + + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + + // 1110 xxxx 10xx xxxx 10xx xxxx + } else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + + } else { + if (!ignoreErrors) { + if ((c & 0xc0) === 0x80) { + throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); + } + throw new Error("invalid utf8 byte sequence; invalid prefix"); + } + continue; + } + + // Do we have enough bytes in our data? + if (i + extraLength > bytes.length) { + if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; too short"); } + + // If there is an invalid unprocessed byte, skip continuation bytes + for (; i < bytes.length; i++) { + if (bytes[i] >> 6 !== 0x02) { break; } + } + + continue; + } + + // Remove the length prefix from the char + let res = c & ((1 << (8 - extraLength - 1)) - 1); + + for (let j = 0; j < extraLength; j++) { + let nextChar = bytes[i]; + + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + res = null; + break; + }; + + res = (res << 6) | (nextChar & 0x3f); + i++; + } + + if (res === null) { + if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; invalid continuation byte"); } + continue; + } + + // Check for overlong seuences (more bytes than needed) + if (res <= overlongMask) { + if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; overlong"); } + continue; + } + + // Maximum code point + if (res > 0x10ffff) { + if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; out-of-range"); } + continue; + } + + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); } + continue; + } + + if (res <= 0xffff) { + result += String.fromCharCode(res); + continue; + } + + res -= 0x10000; + result += String.fromCharCode(((res >> 10) & 0x3ff) + 0xd800, (res & 0x3ff) + 0xdc00); + } + + return result; +} + +export function formatBytes32String(text: string): string { + + // Get the bytes + let bytes = toUtf8Bytes(text); + + // Check we have room for null-termination + if (bytes.length > 31) { throw new Error("bytes32 string must be less than 32 bytes"); } + + // Zero-pad (implicitly null-terminates) + return hexlify(concat([ bytes, HashZero ]).slice(0, 32)); +} + +export function parseBytes32String(bytes: BytesLike): string { + let data = arrayify(bytes); + + // Must be 32 bytes with a null-termination + if (data.length !== 32) { throw new Error("invalid bytes32 - not 32 bytes long"); } + if (data[31] !== 0) { throw new Error("invalid bytes32 sdtring - no null terminator"); } + + // Find the null termination + let length = 31; + while (data[length - 1] === 0) { length--; } + + // Determine the string value + return toUtf8String(data.slice(0, length)); +} diff --git a/packages/strings/tsconfig.json b/packages/strings/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/strings/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/testcases/.npmignore b/packages/testcases/.npmignore new file mode 100644 index 000000000..6c2fe9f67 --- /dev/null +++ b/packages/testcases/.npmignore @@ -0,0 +1,3 @@ +tsconfig.json +src.ts/ +input/ diff --git a/packages/testcases/LICENSE.md b/packages/testcases/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/testcases/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/testcases/README.md b/packages/testcases/README.md new file mode 100644 index 000000000..1c6306a31 --- /dev/null +++ b/packages/testcases/README.md @@ -0,0 +1,17 @@ +Testcases for Ethereum +====================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/testcases/browser-fs.json b/packages/testcases/browser-fs.json new file mode 100644 index 000000000..ce27a421f --- /dev/null +++ b/packages/testcases/browser-fs.json @@ -0,0 +1 @@ +{ "dirs": ["./easyseed-bip39", "./testcases", "./wordlists"] } diff --git a/packages/testcases/input/easyseed-bip39/LICENSE.txt b/packages/testcases/input/easyseed-bip39/LICENSE.txt new file mode 100755 index 000000000..925c5fd56 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/LICENSE.txt @@ -0,0 +1,52 @@ +These test cases are provided by eadyseed: + https://github.com/nym-zone/easyseed + +Please note, this is NOT a derivation work, so clause 2 and +4 are not relevant to projects which use this library. It is +used for test cases, which are not packaged in the version +installed by NPM, and are only available from the GitHub +page. + +Also, I am not a lawyer. + +---- + +By nullius +PGP: 0xC2E91CD74A4C57A105F6C21B5A00591B2F307E0C +Bitcoin: 3NULL3ZCUXr7RDLxXeLPDMZDZYxuaYkCnG + +Copyright (c) 2017-18. All rights reserved. + +The Antiviral License (AVL) v0.0.1, with added Bitcoin Consensus Clause: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of the source code must retain the above copyright + and credit notices, this list of conditions, and the following + disclaimer. +2. Redistributions in binary form must reproduce the above copyright + and credit notices, this list of conditions, and the following + disclaimer in the documentation and/or other materials provided + with the distribution. +3. Derivative works hereof MUST NOT be redistributed under any license + containing terms which require derivative works and/or usages to + publish source code, viz. what is commonly known as a "copyleft" + or "viral" license. +4. Derivative works hereof which have any functionality related to + digital money (so-called "cryptocurrency") MUST EITHER adhere to + consensus rules fully compatible with Bitcoin Core, OR use a name + which does not contain the word "Bitcoin". + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.cz.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.cz.json new file mode 100755 index 000000000..00b307893 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.cz.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace agrese", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "6e188725b15cd20cdf0061c36644844da7661ea034c4819e76cba25c8bdd02816ebd7936e4326dbf5f3c644c20098a66cdfec8ca8af3521002cb8b55a8d6676e", + "bip32_xprv": "xprv9s21ZrQH143K36RVv2FbJSwbKMNucnFP82GcKBZqnbC4sdB19uMkfq27hgMT93Vu5pMHENd4vrRcEbTqu8XNafjHBquV2qEZ6jBEncAfroU" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace babka", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "cf44ddd0488d45e46f434d8167a2f862ce42d0d686956e3e20c5fb3156a9eec058feff4453f8135fbc2c0ddbc1211d6c0bd5f73b8e0800f7d69d31e773dbcb08", + "bip32_xprv": "xprv9s21ZrQH143K3Hp3BH3xtx7VDRC8u1vWZTCav96Vnxa2uYWsnV1jzEnRVywEU7moAVYc1AywvtbT9M7fCMe6uWksw5PwQ9EPKU2i6K7dDKa" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace balonek", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "c936cfaf084af36298ae7a164a7beddbece3d01779220a46d99090da7ce4ff4b3ddc97655041af2a4a3729a24a925ce40bda447d7bc9021d08c5a34a26caa17d", + "bip32_xprv": "xprv9s21ZrQH143K31xJtWA6Kh2hRqVG9RyJxidG6GWHFT18DzB55Ji2Fguae64Bq4MZ71fVBwZTT6Limgw4Cf2cukJ9s3WtF9549qo4QdahAHM" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace bacil", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "108e2d5b369694affd646b9f730ac4975c74ea8f65e54d5dabfaa42f2e3c3c2f77ddd426589a5e7bb17e03275f8302fbaa6e88719cb7b48bee2473b499556d30", + "bip32_xprv": "xprv9s21ZrQH143K4KMnxhGyZTHC5wiSVL6Ax9sWLazEjRSkFdCdBToaNRg2iriCBTbfu1H6SvnfYH2BDCduvEEXpjhQPAmvwdi69e1QkJQnnqd" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace abdikace branka", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "2b909f12a644ec73d2560cfd266bb7f0af5b7cd810353c1fce779148e7e050aea88440de8b7eea1029eadcad4b2b9eb4b081cadb91bb150af2675b1f9bff74cf", + "bip32_xprv": "xprv9s21ZrQH143K3z8Usj5QxDRJnC2xsHpZqz8xqFc7yiH8E3rSdTzdyjH2u9787HCZgoS9Ps7JmU3TwzjYh6kCSncqS6TSWwwHUxxRhejodxJ" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle bachor", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "5524c91b83325197444612dca35d44342a3f0bb988384c28a9cb5074c9c9f6eb0c87275624366aaf593bd19864d36a35f4d6ed090c75ba0a6f07f98be271d459", + "bip32_xprv": "xprv9s21ZrQH143K4VriVxHyaHTY4j3rCLnG9SvPtTZwbSLkjjwnCjSx1mUSPUstsjCnTgiyN6aW9AHu2cwtzPm3RvPKYdVx6hcDJAQki93XAEK" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bavlna", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "2d8fae1703e526fe9c6e2ac6c356d3ba26b8068382d88df06839ec2d7d9cad71a81941750a395696f2765fbeb9cdb11060592a382f4f6f60a906fc91cacba84f", + "bip32_xprv": "xprv9s21ZrQH143K3w44THyjaefJGYcMy8GSPkAmkzzxUNbVrj5kUzJVGzq8MXghLAEF88QzCHFEo5yZTw1rBqgeZoQEAWVDNkMfKzMxqpigSbX" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bohatost", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "4a3cfe75ebc5c77bcc101165c1809cdba0a7558df661fbe5e46b61a8038372764076008e75c76445e8c9a9a635a6402fd82a5f7868277206a7de606b1acb5997", + "bip32_xprv": "xprv9s21ZrQH143K34QMFdZKdwoMau6Mvr6FgYsyJV4RfmHBxtJEhob1zqKx4ncnqYCam64kTuHYTUCqXBB2rp3jRtwAXeftwymBygePVkxwg2Z" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance cenina", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "a01fff5a068728b3d140b54599b94d4e8446b107716e3a32982c0f8d32cb32fe968c457eff2fa0515307dcd6f744a0e8d7879b22904bc0a548d280ce6cfc8cda", + "bip32_xprv": "xprv9s21ZrQH143K2CEaQarhiAiKm3t7sx84Xhcngv8cayM2AYdQRkCT4S3cYadKknZHTC2znyBBXsAGKU46rPynEJrm63KVc7Hi9fiDHHpVQSW" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta gilotina", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "d2afc855bf76ba540ccb9730c183751b311a4d84ef9a236e933873f4461b46ecd12d282e5e33807ec819181b23e00ed704a347ff7813e83284cb4d7de09281e0", + "bip32_xprv": "xprv9s21ZrQH143K3Sk5vC6PLYAHqRkw7TJ492muGepukVuHu86HsPVwog7j42LAwsLaEtGVz984nLbp1U89rDDvzL1wjfsL456yUsnGLdoQ8sz" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubr", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "b2fba2ca4540b517f96772a359058474ce44826a9e15c6cedb3b100df986a9ce072fb5640d1174da1a46537a55437f91b6e294ede790436f5e56e683c541129b", + "bip32_xprv": "xprv9s21ZrQH143K2iTmBXmPimpBqfv7FjhijaYmLvRWjSvEfapdNzCZSnqTDFgnLvVS43LZtVjvV9md8vVHHLo2VnWqDmyX2vDk9fCE5RMskUL" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zobrazit", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "c4ffe663d556a106812606462dd91a3907b9aadb05d99bb77b29922a3fc6fa9b2f74e227a5d0ed4091794598197a6c9c7b0a2f3d51a6a2f43e0145335771b2ce", + "bip32_xprv": "xprv9s21ZrQH143K29RhA8xTtqqDhf2oMnspvcdQ5ZDS5HRcULiAoWzd4wLqWFCDwCueiMfv7zYTUtch1cX1YugyFsf2MSMVSLiXL71tDVgSZ22" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec zmije", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "0812227490c96c6f267182ed76023370bd3df66ef602bbb88851e906c5cfa23527ff15dce8bf7c3dc2b8d47ad9d5266d3b3a7967f979dcb8d41d0a55292079f0", + "bip32_xprv": "xprv9s21ZrQH143K4DEuZzWpXcQkB8y6y7AEMtSMrWd1MFk8dJ6A65xUwRY8Qd6bSmcUc4FqTH3A7ab9s8BpStaTwJcB1KwudShUiaqxiGuWY9A" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zaklepat", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "5ab052abe645c668f0e96230edb4395c91ebdc6f61069e135ec43554fa80ce51eecaf156215aca5c36abeb2bd78da127f5782f2aa9034c0c105f6c8bd16d3d75", + "bip32_xprv": "xprv9s21ZrQH143K2Bn9StRKt7e5qSAyn25pXT6jD5ePcS9XLMGZzoWJzuLML2B5B5fG8vSDr82yapE216bmxLqHuFWxSMpBZ5vbSPA6bafER6y" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo veskrze", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "ebe2ab45d0e95bb324b4989ed748de50ed032f97546977b5ad2b57014fa88e3bbc313362ce2af5c18d8b47a4bc1c487e1f144e6e8b55620d48cc818e50396c48", + "bip32_xprv": "xprv9s21ZrQH143K3La9BZWP1hxip9nKKGysmQb9WdabLKXEuwZtNFNrBxxz7H8CcDRQWzb2CQdPcw3cWQCH7Es59KBV8ofaoX7hfmg9ZAyMr6E" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma akce", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "a60d43ba308e641c5b138bd9aa56fd6d3350093a8cbc6ef793764578720d2a3d8d1bfd1633546f298ec3b531b922c72a96c5e3135e6a6315d8396ebd7672ad8c", + "bip32_xprv": "xprv9s21ZrQH143K2xxLbT55NBxXgeqP33Aw9mRT5SB9Rjo9ECJxZdjM5gDAKQWZjxVpxSimaDr87CjN5MrKzZNkuoDAa6QgwmicTLkftkk2d6Q" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle anekdota", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "1797e05c366d2027c6b2acbbd700d03d5f4b7d957d6729c165193822f5706729f365c7b75c6c828d3dc484ab81590d6b38e9195d4ef5ab255617ee95fb12fd47", + "bip32_xprv": "xprv9s21ZrQH143K3LMzszRqkHarmt6psphRThweUHoZRvrUqWQRyeQxhJXgbhR2NAxdCsEJivnbHprnkmX1VXWfK9rQwDo574NY2UKKFriGiAh" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bezinka", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "62ecc35b9bef42714795e4e758d89c37e22eea676b29f5d434ea2986a87bcc568090ca5502d976a04907586a04771c499557f9fdd69f1aad57b8e16109caab7b", + "bip32_xprv": "xprv9s21ZrQH143K4DySh4RiUDAnhqjsqTiuNgMYespE1w5hiixBhsJgK5ztkyCbPb6u5HUT9oHotqnQdMR9HUsBH9CndscbGiwTtXndGEXq6xU" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bobek", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "70dd6b616bf3b9d6bb6ab2972ea99ea9251d04f6b4b6b193208cc332cfab557936fa3235d3710e63e96aa07019fc89816776379ada418ad50fda229e51e3f712", + "bip32_xprv": "xprv9s21ZrQH143K3RF6jszc7J8W4ExB8JmkCaiAt1z7MwyA36VFvf4sLCg8aoKZvb7NbSudcXMRvAjxg6e1tfZ9J3cHfyjbrNV9NpnS2GnycNV" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance butik obvinit bageta doma amputace bidlo jedle arogance cihla", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "deb14601c0db9a2e6e26be9a6055ff9ba130de517c916e818ea3924756341f0ea7a711694012d06a26c678a48de8ff9ea05be744b94f2b51b754b82b767bece2", + "bip32_xprv": "xprv9s21ZrQH143K3VS9kiYd7Z2GdpnLSvYiBnTcDEJrDoHjm7JWT8iU1NDXQFae5AZxpC8wsQStVJf3JW8HWJc3F4H9Q91kyvdy6hDgEWTjaEL" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zotavit", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "dec8787dc572a353cc9f1f91aa6b0893b6cb31b311b9db2d304cd18a5c6a345c40e68a538c0e9d1416eea8baa36522d9b90fb7c2aa4a065fb748ba7d3a8cb7be", + "bip32_xprv": "xprv9s21ZrQH143K2PKUcWtsVZJE3U3YAX5BiQ7eXNZBvM1KuxaKgUGbJdwdNVw1NKM9rijUDkFSoghsZYogPEvg5GZzp9SVs4pFZU55C6zZue1" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec zmar", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "2b137d164901d93f7d803ed6b8dba83606bd80198165fd483e2f23ad1beae333360aaf9e62bb1eb9ea755c958be5d898c3597d09580ceaf63dcb1eabd78263e4", + "bip32_xprv": "xprv9s21ZrQH143K3UWqVtAKT5UZLsnD82NTmRGozDec8EaRYwcryg9BmntMsuYLGdg2eZN34Le8mHhcjaPjQum98D12jZW9rsss6sK9K5H3rL5" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zdarma", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "32a7fdfcc8e5deb880f70c58f886e9de5789b654caea96b31418d0b9f36fb57c47137380953840105e97835ad1ed0d692483c1b128e72af3473f45d15fc220d5", + "bip32_xprv": "xprv9s21ZrQH143K4Z5rtSdE2yScsQtZR5c6u5NAoWztgYcsHLfAqdVAK4g7F7r8yfMjbF9gxp7tnXbK2kneJhczHpjVWaKv2VGE55NUwQASvSo" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vodivost", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "f196bf98086c1fac05a702f7a3f02d1e393e63ed93b1c7ce0163c677d123d6ddf14e8a6881e1b790ce6e3fbb272c5d67bf4854d397deb38050f66e842b60ca71", + "bip32_xprv": "xprv9s21ZrQH143K2sS85evpKLyGM4J4ugoxxX5PQ6SHJMdZKEtd8Rx18Zw4VU87bLpdeRDf7Mnz9EsNVfCmXeMDQo8bw6uSyX9zQMrtuMv2ekp" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak uznat zubovina zeman skupina zrcadlo vzchopit obrazec znak ubrousek", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "81233ae0b3de7d7e4e0f5f5724b3e5af4aea6656c8fe527a106cb6f3edd2b90e52405dd72595ac68dfd96582785b44400050ba24d6133c7f6345defe3667ec2b", + "bip32_xprv": "xprv9s21ZrQH143K3S3iuTpwVaXmudaNdD7uAXYgoSsXnemprjaGFWdNuYTQaxo1yShs3vxqFsi5DT3GE5RMwig5gt1a5qjZnHSz74yuPUj1pLZ" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zticha", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "26adcebcbfe87139eab30d1a832c73085a27e1256da61e01a7860e5026942df6033c0a83c9267b6b7cb3a448b613d48c4e9b472038e34b3e7cd79b5098e05775", + "bip32_xprv": "xprv9s21ZrQH143K2tExKYqSKiSdy5rsAQRfdDwhQncv8BFSTHfwXo3dQJRMpnpwQxbNLQJbPkkrAd3trMnoPoQ4La4zjaYyXSPCm8KxNhFishW" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zrychlit", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "30b188259637a8de8ce6e5ca34c332d419d16d9b87014eaee4005e2ec09a31936e382d6211ef1d253b95c7c9b2a79babf4d8c0502d3c2f9e70c298facce0a780", + "bip32_xprv": "xprv9s21ZrQH143K2PpUrwjt956i2LySEdKC1PASWCtRLP8XLLZyVu5sBRYsdpZ6mueSvrbgBZiC9DMHr7ERU9tr3WkJwy81daDEBM1ndpbEW3m" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zlehka", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "39fff562a11de3a1eaadd36757bea3b5a8779ee1875db11ad395d1ac1a0d8cfd86a393a978e29970577137965b240476d6b10824ab7715aa68e9ca607d6a994f", + "bip32_xprv": "xprv9s21ZrQH143K3QTssByy3o7q2PzWyH9E1Vv3xB3pmkihkQ5t1ELHGwefyLkNVbXCSnyekRG6VHydonTgTUQmk1xHbh2fnG1CkiyPkL4GuWn" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zajistit", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "253b55a6f8a1a3bfc7ebb399865574f353d69dbce32d834e1fc8990fe745b1e4625a3c07d17f60ff2cfb4ee4da93c7e69d6f956090ac0ea4f0a190d4ed2856ef", + "bip32_xprv": "xprv9s21ZrQH143K41NZByfmvbYcRazMisKYmqQEqBe5JTqrAwFXV4q1UtmP5RJq4q1JKZcLKY7nAb5mbLGrFfA9jAZaUKjBhTWsWw25m8vqHPB" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zvyk zavolat", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "b1d943b71df8cfaae9da978e78a4e2dd74c4772bbd2206ccdb38ad13e9a8c8b8d2c45e745c806746d4a50e04239716d8977d85b8290cffbd4a5c099a9c293c2e", + "bip32_xprv": "xprv9s21ZrQH143K3Tn1Ymx2NecDAftxThFtqUWka6MKpfUApZG1jGucAHYPD23Q9YA4ZJ2PLT67gCWHopUCkWb89QtCFoaCaoGJ8faUgK45dGo" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo kronika", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "6c51361bc4332d9ef231af22581f0bd657e8fa6dc2298feccdd56540789f765fd07078f6ab80a8e8568c0470ffcc00a0ccba63fc7b36434776fbe1a6633d5b6c", + "bip32_xprv": "xprv9s21ZrQH143K3Vr42nSYmgoU72iw3n5AnCFUjFTTNLHGbxPosFTaqV6avGzGkZaX5B5zYEoENH4wu5vQqEmhhoow1CEu6GZTH8BWkBhGie7" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok prudkost", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "547bc376fb960bb1d20f309f61db9d7a3dc2ff63fd0bd18f6871ca728440546d7692408120a5cac17cc883bf2bad1f95204e9bd32e34c435ee6da759a68cf33b", + "bip32_xprv": "xprv9s21ZrQH143K2Br79wBev2LQNK64brzoopZjHffxuemrA4xvA29Xqo2CjenKnbkHzyhsyogAihozrZaSMmwepkitEoqsZRH8rAbjU3xsKCb" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krocan", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "2a47f2565ebbacae55af62f479ef33c2658aed70a99db4fbc435cfd0f28e274295e8a3d8c4b354a17a817c491f8689dbc87dd574ac2d8c412c78b4bfc9318be0", + "bip32_xprv": "xprv9s21ZrQH143K4E1TnbHDgUMq6u6CU4sKU7Ce8HPKPGtzfWbqU274dtSbfkSwKAbUPeW56hk1aE46guoRkwUa1NVEAF5GZRip8cQghD3nHZh" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok rande", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "f943cea42e071d24b295da4bdb1c288b28aa8666ded30fe6fe4c0d3e456bb4bd31d375e1de8b01e976a00679fb1864ec9da1b200b747feb9e50baa5a660de67f", + "bip32_xprv": "xprv9s21ZrQH143K3khtTk7cPi4x5yht8Nxacm3Pgb3KUVTpSHG6EFD2MDh92eTfThAiNUmcb6KBuCkrNgSR8VhfVcEYEWGxrJdtYHPh4Ewr7hd" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo lednice", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "612f57058b142dc7b9b8e54665e4f2ecdd32e0c080318f7dfb4d483cb29d0b08853248c749e05e3fea3969b468c1461a9184a00ce7066726e320b0e0b2df03b6", + "bip32_xprv": "xprv9s21ZrQH143K3TEd3hLoUdUpgPcDJ7HAMs8pZqz1uVkVpFTzuirTVuTUffifwt9M8QcCEe9RPwAtDTUC9CzHT1kvc2TcVegK2xBXsW2bC9x" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok pukrle", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "1247923d38ede6338154f125566e8117f04f8ddf230af8c5a63186bf98339ae6831ad84c6eb1c310de97cad1fba6d35a86cce66d43078c25b5505270e9aa410e", + "bip32_xprv": "xprv9s21ZrQH143K3pqcWqhkqtCCmdam2ATpM1S7xQXD9BbfouHbTBeyqk6Zv33v3TwNZhJuZYucnCsXhbTL5jUjMCW9Tqr1EKi2NQFrsTSXK5X" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krkavec", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "cff8ea146f2f731d029ee40675d31d60fbb944f5aafb2392dc5f055bb26d9489d9f1a3f70f3ca6fe6c137f01334c0ca7f53c3ca4d7b548cb9094ed1b2db8d54d", + "bip32_xprv": "xprv9s21ZrQH143K41VWEtJNVb1Mpm1Gru38vxX4Pw9kz7ERkZ6hfngn7SyqLai7D8wiTDBBbocwL5faJfb1DrsdJG1q6d5McxrFCXrV2ctt8Z5" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok pupen", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "3e0dc622c8ba34e2cc36cfce0851311a5d957f9ae82e3e88b8b895cb54a3a970c70a7490f8000018f2d9eb0e4773a38cfa4ea1c1799cdd7a3ae1ae8bb60a47dd", + "bip32_xprv": "xprv9s21ZrQH143K3G4w7cGwhzR69QZPWzCMrtTXvu4VjboBZBvcasLQxYe59ERY4VutXQ7SCVvEZU1wQDiRdZK2amFqYRz9jan8xr8GcdaGpq6" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krkavec", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "c51002aa59061a304a2c7a764e82b9278ce5de27385bdb6d462009c4c7b74f33e219a326f9bea26b6ab8c0d7269c7f7be49c586615dd2436c6408879807bc968", + "bip32_xprv": "xprv9s21ZrQH143K2LhpYhSVRu4Ztxp2szSZB8jc1SWyqxftLV4ZJoNK1qVciNWer9sgy3Gqf17ydv56gNPuMUdYYnuyUTsAq8D6Mv74XxC6dsE" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok ptactvo krok rekrut", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "bc5af1502d6a0a8cf4990aa1154fd73f5bb4f291023c0f2b99068d9c52378b4faf01312a387e100016c2adb6465372a922da43ff50835ad2b3f29eb16dbd63d5", + "bip32_xprv": "xprv9s21ZrQH143K3fsmPicdBPHRTz9K7c5vEghkRzmh6nebVxQccrhtPW38QNDhMSr1Ey5B9YirPWsWc16V6CAKJeeerAiEYT6L7kjvFUPBMDg" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "pokoj jogurt malovat kroupa holub malvice rachot uznat hnout kasa karamel potupa", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "b6e48c665d233a0486f317e71a84fc9625de67fc59d19f3e7cd9fadc149c17d27c69008be8804834c5e7fec55d1aa053ea9286419bc43c81858ef41c5acb21af", + "bip32_xprv": "xprv9s21ZrQH143K2SNLkxUSDNWRgWp3i1nH1xLXT5UT7Kx6m59fBpPG1k6pf7TNqBKHY4zKjfKRm18KuT8a1Km7uTEHeSeNSNzKUcjRSEAJRBc" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "masakr odtok pijavice tajga upravit krmelec krvinka buditel zavinit lakomec flirt traktor kresba plevel kapitola tlupa paseka ladnost", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "65a5d85c6ac2aa958ca429284387683e28aa51704bb88783fa24ecde1d02a03c3a5793c82615c5dcc6530d148be9e17e06764d190178c1a9eb1fb9f10ca7b848", + "bip32_xprv": "xprv9s21ZrQH143K2i3LTUmkBGyGoodD7zmCWZJKPGtDSdFLAiZEMK2oJy5upiWn75eJhRMgmGn5JHpVnQR1Bi18NwTPkfk1VqazBP1gKEVQm6Z" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "migrace iluze pukavec kaktus drogerie hrobka pukavec onehdy suchar veterina rorejs cukr mihule koza makovice uvozovka oklika inzerce odhadce zprudka spousta namluvit hrobka obsluha", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "2f48e89a541f88ef78629e4796d07dd2c6c35543b26d5f0baa957c4f3c229e2ad3adb378d0d7c794aeb646af8ffef0acbdfcf24b6039e069f3de44e4abb3cba2", + "bip32_xprv": "xprv9s21ZrQH143K4BQnThamrxx1XLm7r8zuFkC2qs33cnK1AXGcaUCexaytiBRSZjQAw9ejU2XkaX3eWZ5vsVeraejmDGnNXYGtc8RdsM2bGXa" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "rovina zvenku inflace ujmout kazajka exkurze litina dorost vespodu sesuv vize koruna hrot naoko lobista", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "ca99ca7e2805d68608da88bd801f1046d72650d6f2f277afd56cd6ecc05c02cba3b6926c24baf90492a75b1572c6d21251954b4bc45bdb687f71a5e1a7e47d43", + "bip32_xprv": "xprv9s21ZrQH143K3eecPpbTyPZcBRy4Q2SJZsi3JaMiVBru2aD4pa2hxenNA9t81ZgQ8mgYHa6KAGKW5mhasPHfc8NoAMn7tTsBhd9aFEh8EGe" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "kabinet vytasit porucha komunita sysel sasanka namluvit kasa cenovka nasekat veletrh hmota okurka citrus slupka zdarma mimika klapot muflon kolo vysypat", + "passphrase": "nullius à nym.zone ¹teſts² Čeština", + "seed": "a2463c3e8ee776b39b4e0b24787aa041b60ce4080091a9cb3e979702b6b26d57d60220617f7c56eb6f9652b01ed9a7caa8ebc997ae16c77dc2b94b49afcd8074", + "bip32_xprv": "xprv9s21ZrQH143K36aRTU3a4RxusrKSeWbdUnxuytXAzXuKJ7cZVwxSMgZSWEHBkarBA4nE7rrKGkLjuLFtD5RVTyWBmppdvbpVWGmuEWCEBNB" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.en.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.en.json new file mode 100755 index 000000000..f4301e988 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.en.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "61f3aa13adcf5f4b8661fc062501d67eca3a53fc0ed129076ad7a22983b6b5ed0e84e47b24cff23b7fca57e127f62f28c1584ed487872d4bfbc773257bdbc434", + "bip32_xprv": "xprv9s21ZrQH143K2oBy4iDupX5ZdoZp2MGMoX6YbJPkYNVjrnMtYQk5EnJzqrqPABT2ScaZ9BaynRGEheG3RFGQx3wM72Yckj1qJ842y8G5SyD" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon address", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "0cca06b31cb92bea841d348862853e6240c9632fcdcba32a89f893ef7c8ec69bf7b49f7d7759fd68eacea1546caee6bf42a625979185a90cbed8698ded85ab54", + "bip32_xprv": "xprv9s21ZrQH143K3yG3FrTyi2ombDJrypw3Aront56ejDhcjpUzHooubU68U5TjxnrXRVwoauS6Jme3Homzwyp6o22fsFnt91i2rBZEEL9EAhm" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "8e0708837fa79d6a32ab5778b0030f4a0e837fc1e51e7c8093a475a9bfd7088d3679bfd5c02aec9b79297bfaf147ab46c4c76fd7f576862309d1f7d6e66b7730", + "bip32_xprv": "xprv9s21ZrQH143K491wwg1KZsQf1RTtfXKQTHRQTxD8xecRdouA5M2rNWXsXHvgbbFHPdpma2LjsA5VBGFFJK1SygMRufEVYvxkTZYp3sWQiqb" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon admit", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "03678988d02c0f7fe0c384200f6e23246099ceb8753d0a6746efd37175ac668653815e84a046450dd6bd3d1f317c63f1101e4d2d4f2ff04d510e70e799337acd", + "bip32_xprv": "xprv9s21ZrQH143K2NvnH6TvugCMsmV6uewe8RdpZgtBCCbhs37FQhc6sQW3aRqYKiVSqRw4MLXbLzaEvKNvBwBmqzdZfVk6ThmYx8hZ7K3zzBK" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "35be70fbf3fae56367a3121f25c69ddd0c4751921298402dcea25d107eb0ca2b05d165e48e4df13571ecb10dac6036864c8ea788e99d203574c8d145fc717cb9", + "bip32_xprv": "xprv9s21ZrQH143K2FxWGg9pQYbRbrPApUVBdu4r49n1n9QqD8ZMTaAdCxHgY3t3NVYhoRqiY9an4PNZrHaQ8WpL5pCQN6LNd5iJdVuT55H2XEX" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "absurd amount doctor acoustic avoid letter advice cage absurd amount doctor adjust", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "25397b8eade97482b315ad69effb6e7bfd02968e46b70a971e95a37230d416fd890ff41b3ad7f3acc369b93555a41119d7b09d957b4ef4773acbc1f3ef7543a3", + "bip32_xprv": "xprv9s21ZrQH143K3sePU7Er4npLr13HbnnsdKUXRYEHVadvHT26tVuKPyU6Rh4T4CTpMGo9cBsgaqhm9KvrwiUCYkKSEtA7cLdrsXUcAVFKirK" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter all", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3028751d811a60dc04039d4b5eebe8539a1beea2cae3e0805a0a775f8623b0f9e2a5d6b7a213c478faa0652e4eb940935ac20742171536275baccc1c46a5d016", + "bip32_xprv": "xprv9s21ZrQH143K295vt3M26MiWTsc1hSxLd18uXZbSkWjEdSX4quWMXvVTU59gaYviSp62RQMAYyQda1TGqCWzBPZVU3Qyj11BWWn2i8EWTyX" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd approve", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "5109df39def8773eeadbca1cf691d418582fbc88339fd68ae2b867eba4943676d4e51f343c425d2c38eb662a536750fbd19c5acb933c488f9defca37f3001821", + "bip32_xprv": "xprv9s21ZrQH143K2vrvMtf65ZRKiTcPWdedCkJLWSWoiDoDg4adjFCRMUPNxXXqZjV2YcCZpkts5jZv8osFA9Jp8F7tKsLzPP9EFq4u6V6ESpr" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic banana", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3ba8cbe8b2b876626700733e2827bf353775b4c639e8cdca458867c6f8ac95e28ea9863133b413459afebf6ae6fad3871a43b16fe2a03dd55a279b48ac406020", + "bip32_xprv": "xprv9s21ZrQH143K3UqU6yk1gVFtLXuacgRzuwNhMznTEr5NzWBnUoCcMRiTjxau3JiA432RdVq6Kru4CDMP5ZbY4hDzBMdis3WCNnru2iZMpTm" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice comic", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "d660b23da3fce0208800a8bc4aeac4a695c665ddcbd1d15f47733f440bfd843f29d2c8a3dfe9ef0c60bbe93e11865092ace79cd27e829b6078a7a2e80c8c4e6a", + "bip32_xprv": "xprv9s21ZrQH143K3EfaogkH9ExMUynMm9YLkNjUVxCEi7B47NnLEJMKdM1JFyUrEWnDfmUJDDQTariK3kqQmTrf2bVGsVSiLKL3bSvnPB4iDq7" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "legal winner thank year wave sausage worth useful legal winner thank yellow", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "a60764794cd73778912385c6841c1c8936998fba1f6db93f7840ebd39f3fa5931520bb4cbabac858711eaa9da676ecd50e83b25093ebb69a69ae32391d7f7222", + "bip32_xprv": "xprv9s21ZrQH143K4M5QiwPsh7Jnn7Lsddz4Fzzcs953aL96NvJhfKQcPzsxoC1tr8qPNv7FpM4ZoTLwS2LMLcZQjajuwTfSRAgKeeCMUSnr3V3" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "legal winner thank year wave sausage worth useful legal winner thank year wave sausage wise", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "dda1e7cbbebcbb1516e94eb21a09f04458dac4e52a5335fd49f2765eee25c4fa1cab492bdc9c791cec15f1c72e9eed1efff9ec1cfa068430b91c2fa8a09afdba", + "bip32_xprv": "xprv9s21ZrQH143K4CBGh64CWjhCigSEauZJng9kw2EC7HV5KLbgE5q65enTKp6GR2CjFSbmWMZkCrhtbzBAa9CMUkJauD8huqXxBZiKUuCyWB1" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "b527bb515aa1160395db2320633a76bf3143f954a5c081ca33b9ad71e8fcae2217664dc986d0588f64006b6a59e46009b99a904cbc72653fdb13d6121cbb6c18", + "bip32_xprv": "xprv9s21ZrQH143K4Y8ruYUkJT54wjW3xeGFLyqKp6Wq3saWKuxLpY1xwB2fNRgv2n95aWf1gEKeWwUepsj17qZeAg6i7w3km91tSgXUriYWNCc" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year viable", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "b2c9284e24609fad725b66776b58d84f8b45a25269de2e9aac622ad56ce62179af4582e0bd25170af7be57abf0a3858ac74018fdc2772a7cce7e2d7266752384", + "bip32_xprv": "xprv9s21ZrQH143K2KPUtPoCwQpzkKnSavjcFvhrQtyv1XaedJ8F32zEQc79QzBRUFMCgJu3PHEM8x5EnL3yE9s3F8bWsSrvo41uhMQm4vFj6PD" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "589449b6d3bdd33dad68e8bcf3ee6447f77562eb0908d999b3cb37af19c4556de80550f147b6d2d2e6d77230bf1dff639c5008e42bbf23710e5fd9e388614c1a", + "bip32_xprv": "xprv9s21ZrQH143K28trwxXVhAR3X1krcj56nCsr7X1gkNx1ZH6hFS82TBcZtxFn4yHE9euaRCtThf7w2kVD6wKQ3CyfSSDp4yz8oXHjsBLSQQn" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "letter advice cage absurd amount doctor acoustic avoid letter advice cage above", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "c426052557598fa9cdf0a9ccd7f2137f3edbc7b13049e5185f9f41ff12978ea97396afda532e1e0dd1af32f105ec8955f6891addeef9f45c82f2ad7d239ef1df", + "bip32_xprv": "xprv9s21ZrQH143K2M4CymLqsw7xDYtFSNGpnvdKG1Xc6XsRLNR4wW1k8MqZS3kSwJ46yDxhJXjV1h4ADB8Mf9ZJg25qNzPKjSJVtGzm8XVq8hs" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor accident", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "e1b10c8cf971fe5006a3745eeed6a1dd55a25bf939a967ef6230efd4976bcbd6ead845ae922739c6250e68ee892923d03a89574ab179277ea47c928dd6e839bd", + "bip32_xprv": "xprv9s21ZrQH143K3Ch4VD4ZN54z5FxMRJDFZKXFesvGDyaHvuYF8rZzDiaBXGDx91daoK2ynLVET2qUwm1imDPkaLCzfjeXCV3idYBe7bh152N" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "088a6fdd9df1c9b0c799b8b9d0214b67251035f81cc3b58edf4365294da2bfad508b2191155b5733c5e1aeca85b3da018205464c38239570e4166783e5cd0c3d", + "bip32_xprv": "xprv9s21ZrQH143K3xk8B24tqmBvCE4uwwiC9mRJRUdk4A36DMNf1djcdAKfX9SvxLtN2ETjymSzZ9UKs8y83uKfLkXDgbaE7kPhzCUSbwtujPH" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd apart", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "56486e4746789893935ebaeff4a27195143bd979bc576f9c04b4889a2628afb01ab9a4da24ab6dfb6e93b2ae2db88e5cfd43661374ae656de7f56f9e59228b0d", + "bip32_xprv": "xprv9s21ZrQH143K2wdnh72kx7rxikvE2YNQv2Vx49SyJDZGh3giGHyEEy2xRgxu2v5CzWHB1qQqmXsrEYubCDp2T8Ur7bBS4d1UpF1gY9xJjqN" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "eaa5f3e14164547a784c5ffa8ca09fa786d7ad6a975a99a4805d183b5e6c44165822abea1b4b9c24291894df146f47ad175467bf91b19c1bda46a3a44469968c", + "bip32_xprv": "xprv9s21ZrQH143K49PLUvX2vEjmkcg8oxdMnEppEZa5m5k8mYskq27ZvLRmZJNV4XXneRckMcXSxLip4S7At9tc7mKsyDe7FXvjy9h4vPjaXTC" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "year wave sausage worth useful legal winner thank year wave sausage wish", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3551c1ea38ce37d0823fb1917cfb75a4b4f9eebd7ba943403c20709dd72cf6418134aab74fcf513444ca34acec3cfae799ba5d220f22ffb3e6365cb871653bcc", + "bip32_xprv": "xprv9s21ZrQH143K2FDGfFoKBBkjfJLPYAKcibPNao2yvAtgxZh7sfayBW9RYzQiZ5WeYj5KzD1voEwuMW8dHzzqTavRGLUkHMhng4dYVP4PrZB" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "year wave sausage worth useful legal winner thank year wave sausage worth useful legal wife", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "d5028e05ac3eb5227e245b3f738fcb044fec5dc9e1992fa2ae23bc072ff29dc3588a0b96c028905580237e666b94cc924a8367f01894caff439c3a336e0abcc0", + "bip32_xprv": "xprv9s21ZrQH143K3MtYqdAF7byHottNCQHvtwoEWK7i1jaweasjCz4twmwpzDMe4inUCVB27h1LH6dJaBpuU3bA8w3z197289YWmjGsrvZKKTD" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year want", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "361bbfdfa65add06b97dc6db512f70e745e485ed95870f195bd170a67da69305cb46fb2cc6ea0298bb2b9c24f4607839511563a7e52f89f3639c4ef8d930d41b", + "bip32_xprv": "xprv9s21ZrQH143K3F6BtdnyYESrfSqMKAq769Ghn1wrXBRqZSR5QikJtx1H3h6bF7Z8UZ5R1oMcqNkt4qKsm241za729vmqZUCxTaMvAnnkQRh" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth traffic", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "39d095bafe26e7c255cb6042879fa173de6b37a02d0a2dfd3acf17ba59dc2c1ec6a705b9cb137efbe78b51675f275bd1062ae14d791885a8b8f9b529674d1851", + "bip32_xprv": "xprv9s21ZrQH143K4UwpLiMxjsARHTik9jB2AxQ8VCgNZmeccFEEf5vJWwEz2rEcyo48TdURB8K4epd8h9NFssHMw4KCYEAqJyDSXNFks57c8wn" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner sunset", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "dc351f459293bdd198d33a52c651f3c8e01d4236dbf4bbb7efb9ae7c2fbf0691e6af751bc76bcc5cfa637642b8e78b54c595a56a5a0bb1520ce0ff129293bca5", + "bip32_xprv": "xprv9s21ZrQH143K4JCY7pXXeSQmj6L8RKgSeD6qC1KzQpgeVT3MVZDwh21bNWo4Zk58DYK53ovZqcsFZnYot3Bh4TZFARJgwJve9oJkT19kjqV" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "b10ea56197d6d630a293e017635edf06d670a838cb36adfca7ff893dc158300cab9756828798bb2e288245f7e4c6c5a72278b7ebcfe90388dd17503c31aae2a8", + "bip32_xprv": "xprv9s21ZrQH143K4TmgRzwLgWnhkCYrJtbwKkmNvCLytq4JARurzoKaitRgxVwYnPrW5q2SxpTxFbDJmngvwEuhBKjGueafnbV36NFyHAPu3WT" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrist", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "41505fcb877c4818af84e319875994b755d515f648d16a9542f60c26320f461fc5b49f67a452670ffaa3d56b4b4d707b5053d6b5960690b7fd270930c5ef6c27", + "bip32_xprv": "xprv9s21ZrQH143K4V2FDoP3ESCmCBkBRWofE4o2QagvVtc36VzF4YKnAsNyyKPXhBbD54bBLEo1SVMafj8iK8bpe4T87ngjacWQbCsmoefBG1j" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3c555054296d226a55b8de8bc2a1e5515f456b26303088b0cec6f203aeff66f11e698df3ca140561a05846f7e0c5ecf3be8dd9a832249a9c8decde5296660788", + "bip32_xprv": "xprv9s21ZrQH143K27ab2NZfGWX6Cbgu8LNXcB1g5kRgVpSLGns7wHAcSUo4hHbWb7jRFfECwCNQT1uaa3zAnEKBica7EALTNWw9cLVbYDd1gUn" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo veteran", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "15b461996be50cb82bd88a64189c45ee53d3d2c2ee5b70d27171e5d8cc3ed8ddf7fde85cb71d5bd2b8025ec2a7a131752b3b2921c7edb6b0844a0850fff7c922", + "bip32_xprv": "xprv9s21ZrQH143K2zppHqmyV7LTNCXmTHJucpaC66Ey2nhFMRMtAQ6ffVfzBnrUQNiW3KJfCywJcjxNaA7vFgrXZnYekDedjc86E3y8Fpdy5kE" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "cb266ab107f38d7e0c0f24052df9e4c4d2380a0d5ac4e1fe0590c421fa628a7e4041c69e8113c9ed7435cb85b5e592f7accda83d5a0c3237699ff8b768b85b5f", + "bip32_xprv": "xprv9s21ZrQH143K2qrhjU4xqroRbcGiqaejRNfzJ2sfSGmTQY8bGGmmLEzHK6JxSQmzM2Rd3aDn3qK22yxCHMQMfEgcHTYr96Ld17SfmbDikNd" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "primary fetch primary fetch primary fetch primary fetch primary fetch primary fever", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "e3a7da5847449f39f034a2859bbd1a29d5572cfeaa4322543df2d81415c34f891345132095238414d445c06757b7898650ebef5057a6bb81761f2b7fb8c6ed61", + "bip32_xprv": "xprv9s21ZrQH143K4YZEKzskEBaTKdtNRRH3mLvPhtLZXcmyW4ubcAK1DZ7HoG44ca4ejs9UovxvQyUJYojmuqHEWMoyzxn5khFQGLmEY2Rq7Xw" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch prefer", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "945e54c7c710118e5485da990ba1330210027472dd33b559cdea5f8c5cb82535e334bed374e79c2ad4ba004e5a7bf907d9247087a1b6bc036bc757c62de0c695", + "bip32_xprv": "xprv9s21ZrQH143K3HrSPcnQxsedXwDLpjRfiZo9UQoQpQCSSXUanHfL1GCMihEg2Gm7DUc8Au3D3UwXKDZB9wMvdCX7mgWjuzM1NPeUaDxhQSi" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary festival", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "ff810961217480191fb419e2cca46845d5e029ae52c0a03b321ec901df012a49e3dcf1ace56cf010ce6ae91b16a286befee446c451da11a1a4da42c3912d6ccc", + "bip32_xprv": "xprv9s21ZrQH143K3nHSf2pwnrtgWDhZ8YygsK5eA6uppiqiFVw3FJcbCzk6U13jwnKkQBnsdx3z5C6KNPjsPEZULwNeGsPY5UHfqJkAxvg3zKH" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch purpose", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "6903ea8a4758ebc5bfd9520a30476035495c55cc8ba5aaf7ac978e072a252b6a81aed4bc8868b0adda2b3e582faa3db1cf6905873d997ccead90b2c2715ecda8", + "bip32_xprv": "xprv9s21ZrQH143K2fZ9bmLjnycoNeTi3UcJTuxK8YCvqhQPXgvumB4tUn91Dp2wSdKVrrTskHacubxJZkzF3vCDjE16KSunA2Jk8JQgKyxUM1z" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary foster", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "72e0ae5b6b4884a82e927e83430fef76ef3af622bc37eb3de743c8ff5fa228a3c7b7a132de2553b9e9810a2c689db1d0a9a623bbef87cd77766d2d52bb832b67", + "bip32_xprv": "xprv9s21ZrQH143K2YHWevpiXBrYsKGPnw1AePszvmCE5LDdTRbG7gN1PjQtjvNEXK9Uv3wRhDKahKwncAbWuMh9CM1siJqvTnenVd9r1fVX83P" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "fetch primary fetch primary fetch primary fetch primary fetch primary fetch problem", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "d31884cb4256e0a28e0034638c04878dec64b751abbcc7e257538347173d60082b9518399440169e5a85507836fb37b05b0bf3e0c3d536114ca442102a7afe30", + "bip32_xprv": "xprv9s21ZrQH143K4QTT28Rxc7QJGy7urL1RpfEbiKM1gssKrjyV5Mw7kFdkP8gYSE7Ubk4WQujgumzbA4iZ1kkbeuigvtqoMSMXdsknEC7GzQD" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary feel", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3a2e3dcc5479797e5a74ba618a18e8b1145b7c18f8e08e741649d4634ffcd2d486bea213d50247f94b23b2b2363cdbde794816840e178ae9c401c45a1ce9bc05", + "bip32_xprv": "xprv9s21ZrQH143K2CdfPEt4biSthHBjxpwMhdBWsMorhwVMscXKbwYHTUA4jmP4gy7usB6ivmRZXiy5T8B7LBDRqUSTEdkLBEMF4zGHrKeg9A9" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch program", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "d93a86b6bdbf75e7918087ec31f76669a3bdb8065de1bb0857ebd4dfebec1e8802eae715cb9a2b7476c08718b8931191623506de643ffcd98a72c62c1c08db45", + "bip32_xprv": "xprv9s21ZrQH143K2gDdf1K6WLbzrWWcNae7r9YPq3miTc2Mx3Xzxt2Kdg6XEUCkiBPHizQwRw5Midk5rGmwsauRLSRiUCNMgDoRuEeX5dGvVny" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary feel", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "9e3f7d5347735a402c309e682cf0091befcce35dbfd524425888243dee1eec458bcb8eae380233c78478f7a613736dafcd9c4f9516b92004fb1db521506eb11f", + "bip32_xprv": "xprv9s21ZrQH143K37Q2JGtJWi8p61twpDiqgD8PgvGkQ3HFpYvpG74wtkeiszwzvQaBtyLNQoPsYQtZ6eNKqZG23T1P3ojhd2qSe5skZ99oVm9" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch rack", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "2746fa9493c113bab21019ec9a42df0dc7899e5a9c8c8494db6ae46291dfb69e267911b334641732eda8e3ea9fa890f8987a9ddb396a47d2c59e83c0091c0ad3", + "bip32_xprv": "xprv9s21ZrQH143K2s9oQzr5MjxwLgyHCGxeuNE8o2KdSmNNfGfJ3W8xZEovtbmL1bqyzF8Rr3zvq4fZQctg3JpAQesDQmZw4CFVjuJGEboWfDY" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "0d17d8adad6c8c2a539d6fb2a644cd0e21a3c4869ad3f78c81d85c6b906d97a1e66acf499100c4559f80cf7f4b210dbb1373e9a8bd95587b6233e4dea93c68e6", + "bip32_xprv": "xprv9s21ZrQH143K3KFC5R3Dz36jPM68hGXyR6ykRTQowT4Aofcdi6xPHNrG6B4NqajSiPVeNrJMjqxFdbGAdoYrnHCdrMFDisoaPq5KXBRMJ3K" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "26c8aeeb114519f8ea1d9850d430917a9802aa6d926c453d22b41ce2a0365a19d44eab3901f5b84b5810b450d17371c3951ae3633ad48e30fb19f19cfa17d3bb", + "bip32_xprv": "xprv9s21ZrQH143K4NiUGbnbR1BCN2G7fpmb8LACo5gYk2uaNLrF5PJQeFc4vwzm6ku9rJgYUznSaYPZStDg7kNDGhm2w14yvDmSJ6n5JH9LaYK" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "3e1ef5f05252631077865496fa9e298e9dd6d24bf483d9e63d9621f79df236e2c63bab9ef57573fa91cf4ce665e78d93125a239166541ff8e2b5a1dcc2fed887", + "bip32_xprv": "xprv9s21ZrQH143K3g71Wg2ircXZMYA7cBhXBZjasDRyt7neWE2xUpJmM8ANoxU9d4NNvnep9d2MgvTSBXhSsYijw2KEp7ipAkhq4zZzQiNCbYW" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "recycle young diary survey elite cinnamon gasp canvas tobacco roof tooth eyebrow demand inhale gather", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "5f45cbdf0f08860f9b74ff278d72f8857223d0e2c58ec85d26e87919bd235d105f53f5b715ad963f28fcb15e35bb1ac21fc8718222a0e771257f1ab2be394ede", + "bip32_xprv": "xprv9s21ZrQH143K2QjmhwkFDYJQh8Sw1rzMXkvbuoymUBddE2Amu5Nz6QUEuNTMWoxqrvp7teNgvdgrvJ7fuuvNepicFRiJoUfXXaMN8s52fXG" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "drop upgrade pear excite solid review inflict elder bar inspire tiger crouch master blue seat want have end hurry evil update", + "passphrase": "nullius à nym.zone ¹teſts² English", + "seed": "d82344c6a7fe12f0797c81b2d727e31da983d8ca7853c6022b620cdb30b5af4fcfd793dd69573a13a48526137f96b571bd658a3ec38a90b010b040a8fcb2d7ec", + "bip32_xprv": "xprv9s21ZrQH143K2dZDex2em8CzpE177rFvSnR5gUrTA6wa6BLb3vqABDwRgujKXqrKi5maXzeMGqRb8DUFADHLpNxFRvNqMJmC1hT3vQ92k6j" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.es.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.es.json new file mode 100755 index 000000000..1d4ab149c --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.es.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco abierto", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "190f7940ceacd781f50b4c96e22a76d73db76a298f408cc0b5c3328c29aa8be62a7b9f7f650a1a2dc070a1d7acba48476b7449666648b026a66a9e1b0e0aa088", + "bip32_xprv": "xprv9s21ZrQH143K4R6v3FDQQEJiapUFyCADAXBJDpByQMgCR8WJm5kW5GR9erJcUcDGecQ2ePc5htEFhteQPDSgCXNwtxrJWBuoLFikwzRyQDY" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco actuar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "36e4cfe1733f1edd89361eca02fd2c9abe563b4d431aa849d7636643f40aa0db7b5f42c6c82c9add583737282d679e78f7703ac4682698236395fe26088fb428", + "bip32_xprv": "xprv9s21ZrQH143K3Ud1fWhtF6xj9Lc8B7t4SaVJVHX76NcKKxxqfjU5BqFCMvWocDciVbGG1vaKsoArUKtipxpnK2QvN4LQ5hm8k2eZ7PcuUw6" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco afición", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "c137d4868c17f87ac43db1551a666f378dca8ed0b4c1796d8e0cfe8734a222bbbd8637200d565c8a77da2f1783ff9c9d38bc427495d887eed8af3dddde8a1ded", + "bip32_xprv": "xprv9s21ZrQH143K2iTSJPtqUEbwtDbazRkGLd2JdC6Jnr2daVioeR7aK9gqoWyMLL6q3hjQ41NnZnCE8P9bY37oBTs4pUDu7BbmFM1Z6R5KXe3" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco acuerdo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "0c278bf458db0f0c7cfe42e8904b461db0bf13978433e9193cdb1ead376d298516a0e41367ab3e2ab205a9f1bc25fed3a1b00315a8c5abb13a7e4a0643c83b81", + "bip32_xprv": "xprv9s21ZrQH143K4KhyTsQFLiQZstXF8jG3ep8RbN2V6BydcC65GVRRurrXSBwMgofYFcACNVE1Xhm5TvaEJviDLXeNj1qMfVHQKXqyKNULsfr" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ancla", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "1ba12bc175839af985ae5d82a6f93fa8384bd4837573f924b3e034e2282886635cd9a1a07ccf4372ecb9ff808fb2451a2aa9fa321cc719f18716339149e4f45a", + "bip32_xprv": "xprv9s21ZrQH143K479nbLHG3wyJdoDAWLw29QT83yEwh53DCk6t2z4XwqqUirfGJSr5Uxp5Q61VqQjjweMZboNQ8RDMfpxsFsXsrGoB8P5wJ8g" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acudir", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "2e47528c4cf5fa95edacbe5a58634d6b8d68acd58583ef1c93d30f81549a9011636705465f140c8b35a857d24a912434b5d641fec327b9fb1230f075ce195d2c", + "bip32_xprv": "xprv9s21ZrQH143K3LgTWaXKvEUCU3VeVZiVY89Hb7wDw2FsWXFuiT2BUnv2LJn4nG99rjszSmEWSVogmh6cLUjtwamRQhpVGkfj5uHfuTECKd7" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino águila", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "038527382d6384e97849469ab4a539a31c8d6e502067b5a2cdee7bef074e163aa05c82e04a4244dcafc37f4d0d344253c1d00a1abb40214357b97d441cfefcad", + "bip32_xprv": "xprv9s21ZrQH143K2C26N8aRiZjW52cPdwVZ4EzT54LyzFyPP72vrwxHFTA3duojwLsKky3JQVHBpfHGC6E6KkLLMgBPr2to4DtpAUWN7TzqwGg" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir alzar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "c38808bd3718d818b2cfb3d4dd8c472258680c80c1705447da8102ba376d76060e5c303447d8ca04551f7714496cd272c1e5582dcc0a042e7fbdb70d4ef54243", + "bip32_xprv": "xprv9s21ZrQH143K2NofFh2xFP6tsUmCuPoghqUpADa24HPhkgMBKcZwfanaQQ65FFd7TkVPv1hxrHvTQjpwphvsADDPfcneMuBpZfoY3Tx2qfJ" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aries", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "20be236898b0f2db3118fbdec98414b5260cd0a8412c598dfdc6407105cf8f5146eb5516fcabb68dfdf94ac693b0e770009fa71f26d4635d2e6b63a9b5914eec", + "bip32_xprv": "xprv9s21ZrQH143K4AX1Frf7Up5Py65dxAW1FNiob5Sxi5vaUgJVuiGqjg7m4G2hfuM4xHUqbS8QpNaxMHzueuEGGjKVUr1ywoNxqFB7PmZW5Mk" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir ceniza", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "bd749f6868aa3a79712af648aebf5849d63663c8d6ebb290538848262b969d7467800f5b37cc79badef852661d83d6ee65011cfa6bb48b28a836db4dfb41adeb", + "bip32_xprv": "xprv9s21ZrQH143K3jJsrTyvRcUaNFbJ6ag3T5XvWTDNbNGQzvcqpLFv36VhxS8ZUX3fqy4FxYq8wgcBzgckUi4S4Rms7HrNaPuvueLFLwG852M" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "ligero vista talar yogur venta queso yacer trozo ligero vista talar zafiro", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "de29dbcf678e84df4d54a0fbda4a1b11951cf6a8d347f6c231ad42d94338ddd82e4f1c1c9f3a75a8b5aa7bbc8507134c0d7c5e65c5b9995caf20315b125fcb0e", + "bip32_xprv": "xprv9s21ZrQH143K3cf9mCPy4adBoKWD6wVGHcBYAU6MzdgrzX7aqEbkTkWVrbQh4eZtZ6GdtHYqxiv8D3fAf9jWMAuqMM8BHHkfwjrjnX8QMwT" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso vivero", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "885cadaa8ee751bd2a18db87a3ace66a7f16b78fc7ecc1cf43b932105342a30f386ea550737999ff1f46284b22137e4f92d51d364673586a613baf9f6df9e46f", + "bip32_xprv": "xprv9s21ZrQH143K4PFWKwCXRh5DwYNdapAhvFzB3oRrE2juWYXySanMv65HVrWx52HrfkFGywjT6PqrSRJoNUcZaokhnmB2bfY9tTKTWQYauc5" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero violín", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "a11ad2f6c046684bd63be4018daca2e19b8765cd1b0bb9fa0d832df41879350e9098f1abc445ad3e05af643182e95633275a5f5a5a15452234a8754eeeecb54f", + "bip32_xprv": "xprv9s21ZrQH143K3CGDvYtboB79WZMiNjeKPbvDymZ88QnkFtq1DyWcJhXkQMHzYwQWuqzoN2wMh2k9xG7oMyfd86kWpM7eXLFY86p6nzTath6" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur urna", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "6fe47df0f94ae6a75e4ff4ac168376de69e7040d8da57241de3c247297d4e13f15d6d2561b9edd9daae9955a780df2609ee26b09b318447a8ffbffbc9af92d9b", + "bip32_xprv": "xprv9s21ZrQH143K3go4PbSso9hntfj52bpsaXy5vJdr8QtTUZtEPWjti1Faie9EkKTHyTqGdgsKirDGneh9uPP9Um68z36jjLdhrDWJzZ5WtkZ" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer teatro", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "275e5cddb06446b441cbe8dd38b31e8dedf559d9fb511712eed9045ce2f8573550324de8421f225296f0b91cefed705cbf7f42639955089d779f04de8371badd", + "bip32_xprv": "xprv9s21ZrQH143K2FM1mrvGCqVqB7ne8nfWpyTDfr7MckdT91gZcXmp8zRwCNj467Usqe6bcnof1BUVnr8NSpbbDjAdrbRKcACVCjJDCMwGZmB" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abogado", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "5fc66c336878b55787dc08e39bf921e2a05e1790006d012598505f2df0a4ee51263f5d1bfab4709467b1a6ae7c0c5820935703885cfef54c386cdb03f7093725", + "bip32_xprv": "xprv9s21ZrQH143K2iBjMXkRwZ1bjQ3KftjUnovyHg77P5K1VBFZU7i2MX8eZXDsh2j9J8azXdb6ADLee7SanxdK8xeK9Z2gbtx82cMLg8ptJtQ" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acabar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "98310b73b6c1632e03982d0f0c1bb3877b79921b29fd8729844d6027043436d95a166ce4743d5ce9515973681fdbd60fb7c8a6575a7c3f6f484b9c2611ae219f", + "bip32_xprv": "xprv9s21ZrQH143K29vBJQpwQFBn57aXUUrJn6o95TLNWfa66tm2hMRk5HkX8ftFpqsxpkMSZzYgwZsJxS9oExz62dh1tS79Fq8HqvNhXwNwDsF" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino alacrán", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "905ea56b236ced7208760739b839cd6bfa5c76165d1b8daeaf482d7f39f158de265c2d31e43b9450e04116db851a4125941b611f38c8bf142f480a19b783cd5d", + "bip32_xprv": "xprv9s21ZrQH143K2LcavQUzccX9MYdLVpHE8N7VRiASb8qD6VU2hTfNe1HTaHUeySRW4rXaixbvBWLpApNVQcRcUY2PGh396dTYRQAukyT4cF5" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir altivo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "cb3e4d11a1c208eb888315956a484502e1ed1c142b69fa2cae41decab64506c97f6a3ab8518306db651f34c940e600946bf0a6b67b63b019076ace393a3fb010", + "bip32_xprv": "xprv9s21ZrQH143K29XCRuN2LXcd8SecANNvQp47gow65yL2edEkrSP89JiikEu3fZsoCFmRSMM8f1HBiiSYXmdXfgAoMuNMPfesyVX8MdHy9La" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aprender lino admitir bolero abrir álbum dejar acelga aumento", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "56301e9c9940b78247c0d236a2aff557a65a5d8d8466c5de7e9d8f4f05db1b3f0b42da04b2ca3413b03b375b206902bd769585d08d6b792351239a019cccda9b", + "bip32_xprv": "xprv9s21ZrQH143K3GkRLEkok8uENdcSVsRkYBfQGzdrhPnGXzmbitUVbT2Fx6EdNqkCvT1coymBfDVKsmjZiM5wtxZzn97AAR33CrFarTkvUwv" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "yogur venta queso yacer trozo ligero vista talar yogur venta queso vivir", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "da28ad825736bbdd2f26d92edd779e3ca4faae65740bc43c9245608ead1ba8de86d4f00d4ac39e42cf3f8f445632aed4910bc1c659e7128b668ec6c6f86f0019", + "bip32_xprv": "xprv9s21ZrQH143K3UqtViyBUvmPT9Ns6CSfwdpiZHTvQvkwsHN6BUN93BkQe2wv7k39YYSRpA581SGpzSPPqNGGHwAHANTbHAb4jwCCv6oDFqz" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vino", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "f46c329b3ad725162565d6ce360fd6579a66db8648d275679efbdd49ab7b9a7348efe92ed4f1175c7fcddace59fe6508140701baf34f4e15a5283e33df68ffc1", + "bip32_xprv": "xprv9s21ZrQH143K4FNaaCc838ZW31uicG3svcyeowazGCAru9URRJGx9s8o5aA5sbqzd567SGzA2tJHSd6FdUdh8NVmSggmbdo6MgjgdVikMa1" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur velero", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "dbd92f950bf43e661ebc14a7820b80c7cff62e1d071082dfcd5cb012b3e89239d7dff7aace1f4f34e05c1f0dc1e7abf17368d0523f845f682ba711de2cc701e0", + "bip32_xprv": "xprv9s21ZrQH143K3SRyaqWspi29DkQfmnE8dLALpZNQoUApKtRXNCZwUjuysAn5ZhedycAyajZF7Wa1QWF9AuDByYDwvUSjGstxZqVLaJUFfMZ" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer tiempo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "699545b91f1359664af13d8628744dd9e638ada3824c545af0e787df19880c798547a11f8af700dec454c36ded926c4182ffeb46e2e98520e4583f2916a39be7", + "bip32_xprv": "xprv9s21ZrQH143K4aafQBE6J2RscWNeq5g5i2Ez8tJ9zyrVYRyPnJXuRhsFAWBQshvMckq8rtMF5ketzw7ZKbVMKaqDzcFMzPhFwkhdkTGpp2h" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista talar yogur venta queso yacer trozo ligero vista sodio", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "5b19ec032bfd025a23c71a55cf277cbeaa42fce01fd3da48e86e6f5a2a89ec681a8554b47298ad2005e29388de04025c76d36aa28cf1dc7ef938fc9e12d3adc1", + "bip32_xprv": "xprv9s21ZrQH143K35LRfuhaFwwE5zky643LW5J8rf6R8PSkHCRrfWSG1ecjszTSCAYzoq7qMAMeZwmZ4QvWx6s5CEHbmvXNgXwqjg1Q6vgqGya" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo yodo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "30ca4481d75f036aab14dd7dd3413481fb1a04a35a0a6c97adf3a6979a637a1526ca80b35c0f1112bb26f3861ce957675b90a8351a0319c7eeb3029e344cb962", + "bip32_xprv": "xprv9s21ZrQH143K49baDsrcNDYuut6yLHp153N3JmdzCB2fCbB5ep3MURr6MXcxTGkrjJbeMfHH8sFvSGNMyhY2Dnybx763MdrRQggRYtqZpRL" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo yerno", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "4814ff9865f0dd9ffe9d007857b3b8d36eead26ce0c97865d9e904f521594b97ed8365eea1aae4533345aa91deca59e3f2aa4405330192938990c6c7e734c39d", + "bip32_xprv": "xprv9s21ZrQH143K41KSx675Lizb8q1RxNPUEiJCrwd3KYx46ZVKqV7DN2ST43qvENvGTRKbYTYuiPXpkEt1RG9NLFiskE7Rzfu6u8dLhbuR9aN" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo viejo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "51dbdff61933f87c5318799ca67a64a53afb77da42cd1ca7fcfcff88b925e320a2861de30383cfadede08eb03cbfd04661054d44f01bd88dcb0a2cd2920996ea", + "bip32_xprv": "xprv9s21ZrQH143K4SRQ89YFRSEbkyQ9YLbg3STahxA1Sh5DKoX5cMUi1bfkK1PtGdYwhpwCkH83yULYfkxWmkRwyUPBac7J5PA4uTHjMxAujip" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo urgente", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "83fd36ff5b9107f05424f23d9ad32f3d7fc668f4612c24317b5c3494b7091605605408cc6d963b5f70ba514c79d81f9a3361d0190dabcc54e433f67920448cf5", + "bip32_xprv": "xprv9s21ZrQH143K3x8SXr2bHnEzdBuxszpwjE7SALE6hgzJmisWQQ4pnW58pF2sQjh1ee9onGFdFNp5qzSCstjyAZZTnjdm6kGpneLJm6EByz1" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo zurdo varón", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "30a09def2634ee790d22dfea2e0cf5500b759f8fc5183ec77d468585cb03627b8bcfa88f4f5fbb983eb149147c0ebc0a58467a3b289de430929561ae8dfc0340", + "bip32_xprv": "xprv9s21ZrQH143K4VcfCScHJih2LrGHe4SWcN3TPqNCEGkG44fJx1pJTsqUdm6gAUmVjd5XpmJBx74Q5kWT8gfAALupPxEFRnj8g9cLsiMY9kZ" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papel familia papel familia papel familia papel familia papel familia papel famoso", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "6d2876c7b57e641d943e76f34f6c0c57d071400dd7f9a5e9b1a3a43212bbd4dcf54ba27f5ec149f47d1e2d5cd9e5045a9d839b7a737997cfac02ad036abe837b", + "bip32_xprv": "xprv9s21ZrQH143K3YnvitBYuhnJBcCuAEJ6JqaK4V5QbFXYBNhwHfYRCMpujcHytRGteUMUugja51NjSw4nM8DHvZGQg6cxtiUqMKQjyMx7EPR" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papel familia papel familia papel familia papel familia papel familia papel familia papel familia palpar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "f6fc8f4c4986297bd8c3567f49e6b7bce8a1c1b5ac2c4208ef92057657a84493a8d8e1a045189a2666bf4b10cda42fcd4b3693b9937573f63fdf140f065b97da", + "bip32_xprv": "xprv9s21ZrQH143K4WvS2uBsBdNxbEFmk9UnXvjMmeHCpyGxyYSPhysinBGg3G9BQHL6aQSzSHzH86FNtZzLaTrZAk8VqSjoKrUByRA1n9mC9za" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel fama", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "2dd2f7ef8028fa8d96031e67779c5fdb9d6800311f001f01bd911f0c149d6797063828d1d2d1a374eb1642aac76ae2a8b81ab7ee30a5444fbfb7555567e3bd0c", + "bip32_xprv": "xprv9s21ZrQH143K3WotSK65SqxsEnWWN88qDVUKayfXgZ9fLGBjZXqBGnffvuJwdUkgkGk9cRGmy2ouPpaHNH9j6ng6kBt29z4EgHbVs2bgy3f" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia pegar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "31978fe34540f0b4669039dfea35f80903a203aaae05a32693bcdc7642bbdfc4964f1408b9059c3fe3e578d77aa63a2f7678c46d8eb6f859508d74ac8de6acbc", + "bip32_xprv": "xprv9s21ZrQH143K3QTBSVLX6KpGk38vCczwMG62M8kA3Fq4Lqtt7EAmBfDfBd7wi8GDL2MywrDJS5oGb87ovGJcfnYFTGz1fVz3ydrFtNpbApY" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel fogón", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "834fb6b3649df29b55f381c89c8ee0e71ebd4d1e80bebaeab82514d02523a031cebd5833179e5140ba09398d459ab66904d8143a9a565d4327396ed7c7f5e969", + "bip32_xprv": "xprv9s21ZrQH143K3k5UnxZCmJWFX4wC3ckKfNgZgWFV1VBs2utGed5bvd9U7JhRKqkicSsWdPETC8bJPfjHYac9veWawprX3JSnJVfhNjTS4bt" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "familia papel familia papel familia papel familia papel familia papel familia parir", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "35dd33950dd6d065ea2b0637cdf1b47af7d05e0ad54246f2d591ff3c5275af30622bf64233d0904812525eee75a3a13e5f0366767e87f8dab4bd6617cf4f8b9c", + "bip32_xprv": "xprv9s21ZrQH143K4BPNac8DZydbqoYV9rNev4mbEaawfuTkqZscvUJtVbJLVHaAV1UFYxqbpVt2xAsDcPiDfYdYEri81b9EMHc6vrzGFpvmdp5" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "familia papel familia papel familia papel familia papel familia papel familia papel familia papel fallo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "294d982e41a25466adb226bb8283de9fb2e846b71730f372bf9f9fd9678a82779a767118edb4342940401ef16f10fc7af7d779515fa2f88ddf5f817f7a2717e9", + "bip32_xprv": "xprv9s21ZrQH143K3JhueB1xzcVozqs69pzoQyH9mhmdPMDszWJWZjsUkt2GxPwpqJ7xcGraUvedcipF225QMmygLHyTeYDBhEy2zT6kgZoBAmE" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia párrafo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "e653471b2123607f2ba35ce3b962000a25ecdacf3fc8fc5f5da15aadc0fe9c065b908478d201ec8b7872121dfcf1b531f30011590a7abb7044ba07d1c6976c3b", + "bip32_xprv": "xprv9s21ZrQH143K3MiKRYtzFUzeYGsAnTVLYevcVpt7CcEfm9qpSAzmGa3RqBRGV6xUeqdsQEAU9sqvXfTbm5KPsbqX12WMv3Gc3tJsNC3EfqX" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel fallo", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "d26e90ee9efc07b87a6a9eb7ba4c6a8fc984421656063dca616baa6497dd6a724da4245e259bbcfbbfc9f016bf0c90e1ed7141cdf43c98997d02229f29888736", + "bip32_xprv": "xprv9s21ZrQH143K3K1fTQmzMGCn8xJ2ukJ1e1Un8jXLaoEqRRVSTAma9KeG51LvNkireroi6wufNHuDqfgTMcnTxpjMVDPxHpHLm96BDkwpSRb" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia papel familia percha", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "423bdd701283857b4967c110208c0a350959f0b2d25730d09638aacff985c2a144c1f478dfedce8e35db57b8aa38941b9227c15fac2cd9219e231dd142db58ac", + "bip32_xprv": "xprv9s21ZrQH143K3WSLTiK94sHygvcCA9WPUpipT9kbZoLm6npYt4WC3fuiaK7NkDT65y2R8rDNRE5vDZ3U1qEfspdajaWZYXqTuzymaterjgs" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "obra diadema gorila farmacia colgar gorra pausa talar cocina duda dragón optar", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "0115cbe36078c6af47c834532f31b28a44192c86bf51e217787662bfea1f91133367e9e997993c10a9bbcda6847c32a212eb907317c1d221d3f759051a5c144e", + "bip32_xprv": "xprv9s21ZrQH143K3SkuWbCCMjQ6aQtqJj5hzXihsRW54JHUMwLjc5XoVnjWwnfq5HsBePGgDNizRmfZp7KDRFMKwHPdikTrdXpW8hNUTfPYqDJ" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "gráfico madera muro rutina suelo falso favor añadir variar firma casco semana fácil neón don sección morder fingir", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "452306c655923d7303950308b50f03aaeb9570386b6d3eaf80581668bd27fd1fe81c1e24dba71a3bd2527c99dea439d546d369260ba23ec8bd30e481f0e1a50f", + "bip32_xprv": "xprv9s21ZrQH143K46HLo25x4HHvYj1tKSbR8xH6NV3WbqzddUsoChKe8gsC36pGKAH3HsxVTUKZXQfETUGnWRs5VZnCh7SVPRWKffTAmVAZ8f7" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "guion culebra parcela diluir buitre crecer parcela marzo roce tejado picar azafrán guitarra exilio goloso tabla mando curar loco voto reparto insecto crecer lince", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "68d721650bbd7a3cc9b24e29e234c96f983566ff331d1432a8519e8a8f2fcc5a0d4e338b62d79335bb590129451b59e32fa79b3f084cbe1282294ecd6c9c784b", + "bip32_xprv": "xprv9s21ZrQH143K2wrk44kBjXni3WjnVckkwRimQWjGhh1k9d1rxf2KAf4jxxz7Y8QnarPfBxQnn1XpxDE77MRBKx9LcY3yuYAW64boyhgp5D3" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "pino zapato cumbre sondeo durar candil gacela bóveda tecla producto tenis eterno crema interés gaita", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "3949db5e4767e6144609a5f4fef2255c24cfd91722a61bc5bf631dc2d69f1efc5921692128eb707882a8db8614738926c9f52c35d0b7d371540086ce7a6e0aa1", + "bip32_xprv": "xprv9s21ZrQH143K2uwN6UE1UHw2PhYYiAyxNBhjNE2brGBMRYjH4QJgiTvTxB9MaBHwq9SRRgg7zeoVa6MfuvnSXJCjWwdLGRQ1xpvtUwq6CQC" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "dibujo tribu ojo erizo ruina pompa insecto duda arnés jarabe tarjeta clínica mapa avaro rayo velero hacer educar humo enseñar tres", + "passphrase": "nullius à nym.zone ¹teſts² Español", + "seed": "171c7fcf63aa803b96133dc4eaa9b8c542a634e319188740ca3abfe18f0b2550de2853947126aa66642a18f132cfebd4633b99059a2da705b610d61301ce9d0b", + "bip32_xprv": "xprv9s21ZrQH143K35dL5Ka552YxmsdNhsNsE5aMPo2qjFUXm2XN2ATuJvZ1nNpMryTzajpiMxVswtb1uUdw7bTS8SqHM7ApH4F3dDrRfoGVRPT" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.fr.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.fr.json new file mode 100755 index 000000000..0b339d829 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.fr.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abeille", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "4450d45b72d1367715bcf72f34527fddcc317531974be86055a704270d3da3edb56d7f8261ad7e29306e5566aaa172d9036777adcfcd2b0d59630773df732c54", + "bip32_xprv": "xprv9s21ZrQH143K2EvkYB8iu2Br7bduTbmKsr6T3NrCtdSYXwXaXy58gttekCacCgsKhi63YLSiEi7YjPYJXA3pjwu5YW9b94NcFtZTqbSKXxd" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser acerbe", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "02330cda5ac50ccd31cf1182e2f443489e11b80e7bb36c45220209371b43b222a81c6fb0eb584ba9df087fd7fc6573cc2c7ed59614915c68085f77738113f54d", + "bip32_xprv": "xprv9s21ZrQH143K3ifb8n19ppDLf8FjD2U6CXED4bKc3BBayBy4n2B1WS2Fujmv7mN9ht5ecD3GupRAiUsGGCBkPZ2LyfiXXUGfTAGSBzbC6Vy" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser adéquat", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "5cdcd23d9db393238b2f6428cc0445add217b00eed679d69caac9d42bfee8bb067ba804411229612f438ed47e71e7eaf119ca127ed77b8af3379a030d608deb6", + "bip32_xprv": "xprv9s21ZrQH143K4WaWqSxnHpStnpy5cA1yU7QpcZUAFc7vcGNSqYDgrbsEz2g3rLUyZTjiDgHg1v64FjSuzXdnpHWAC8rBVR9kshVY7JAWsZT" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser acheter", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "31d8c6d29db914f075fe5f945e0963875a6f9dc2fda98d43b73e6344cdf2f61f9018dc98c13097dfaf934ac98d64ca6576d33d4057dd069c8990760c8989740c", + "bip32_xprv": "xprv9s21ZrQH143K3cX7BfHqcHhqP44GF7CUEPx2ez3DhDU14iLE9c9udf7eHhdTR1rbTL5KdiyY5tnkyYrEDacYYdUZvgJkTVxEzjS7wmxoH6k" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser anaphore", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "a393fcee6b79c309db25cee09bb1c54ff6079ddb5b4bb31a1c4c0e7a691c431ea55a78603a3103d5f8aac3c98ba13af1eb5360b438d2b3b7a3376ca02897663d", + "bip32_xprv": "xprv9s21ZrQH143K3GNqtLrPTJR7NAQhcoW59yRSnfzds9u8xz89iuXcGz3z8naJvQ2VVkBbJVtHjmPLw5wBJwGBVM44izMenPrLErYMD12P3ct" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale achat", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "4fb6fa5d94a8c2153000e810feba736fd643acb9750da6b5767415c0e9636009191c08ec1061e9ee3399dee860c289823d5f66d2b5957fb0d7582a6348e2ae9e", + "bip32_xprv": "xprv9s21ZrQH143K2GjKpht6JQ3MQcGqA8h3G9LAWskpffRdhQRjH8N4prAu8NVb4qKQ7DQk25jvJivpgGcufMT4R9g6EUZWVrZQZTnykPJn1eb" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer adverbe", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "47b9ac0a41d7741041acee8371a248209763236350fc135d398c49d92e159ca6aa9775a613cbd146183f76128da1d9ffa289503a5d9ea2603bf6b7bcb2a22207", + "bip32_xprv": "xprv9s21ZrQH143K2uhLxs8xgQ3jcYUzoxYo8xB2HoxwhCTtYejh95yJvXnFunrNBvoAASa1smzSZc4R6TC1RmyGzTFwcx5Z8ZwqvbM8TGRQ6km" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif altesse", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "813d368933342e58758c0db0804d5d1f3fbf6b8f22df9365479b2758d88abebf71ee861326a2505d33475b6972c08c7c5f074b6fe9e8d348397b32dabddcff07", + "bip32_xprv": "xprv9s21ZrQH143K39yMTwnuJiKiAhyGQAzhS43pqHyd4rX5SZg6QxBBq9TvEKeM3CPxQL1HowUNwHPfUiBj6heA7Spd9uW2vbEkF1zrg8QcLWR" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif arsenic", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "d264e009c237804c5e246f2e61007670bbc4c9ceac6632ab6a2b1a61cfdeaac9be322d2ae075ce3028c128763e6a84398622cd0758609523447968fee45a1321", + "bip32_xprv": "xprv9s21ZrQH143K31brfCw8vssgfwq5pomBT1r4kj2BkMZVD4iKQTFNkHVHxLsZXB3X7B88iR6n68ovC3UFoYhs2vEwPs9Deo4ADsvQDQmrZg7" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte charbon", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "7119dd9fe4d6939ace20a8f95f769187ea2be348042ebc6b55a1a63c5bbfd1eae57507276f1cfa74275b4207885abcc68be75398f9aecee572fde7da2c3828d4", + "bip32_xprv": "xprv9s21ZrQH143K3HQ1tC8sXXL9P3yzNSV9GvVJ1t9cmmuFyEby3dSL3rfbqjuMLxhDJ8P9sC9aWRhqoMorDP7wNUrCYF2TmBZ52z29hJGJWa8" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyelle", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "6eee2d3f953ba5fb99e85c9cdd8335f19f8dd3ab21b4b5c8d105ed2f20d2c05fea74eb618829e970cff853dde5fa1d4eafa36150f3a8c546b7895e54485cc103", + "bip32_xprv": "xprv9s21ZrQH143K3Fz8X2SK9QysmjU8EPcrtBV4rhWpfqzSmR5VJcHTLYf9X28fJCXioX58DVAm3dNWV8uheQp7kPrSWjdavEzKbSU7QWugyUE" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre visuel", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "f1840d22c6dc3e2113433dfeacee01e14cbffe8ed92f2387109fc866c57dfd97b870902787fc47bf6b4465799efd728a9e6a6eb8dae475ec135d09a389c5fedc", + "bip32_xprv": "xprv9s21ZrQH143K2Pfdfyq2RoZQHCf8kNniVCeXvK6dWv4umVxMvmBXHU5yLvjkSgGeYdbpKVtn95Y9X2xWwHa3xJijxW1FNp92kL4MAKkoNYY" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer vinaigre", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "8f96e490657de18d29439f44de8bcc0971b11001a8a4aef909c5a98ea60ef98e9fd4b19e46a96e1be6595c471986750d9f12a92cbd6a2c7238ce4d424bf80f96", + "bip32_xprv": "xprv9s21ZrQH143K3hxLTRwKFMfUao75QzmNWKtTZx1VZFbLtLEdkTyQgyDyx8oHu7iQ2LuoJrcUJUuEgVZRv3rLUwPMFHbry5Y9Ah3Sj88Qv69" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage unifier", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "72d38f708ccbe70f7a259f2527a71b3593328650fb34a947fe578de8174c77f804b0f1b15c606b5915d38e9ff5003d1cae531a86e04f3d5900b4e4e3730cd4f5", + "bip32_xprv": "xprv9s21ZrQH143K2E1h8gskG2Z3igvq1Q8twkLDsABt7NuFRxgbjVYQMoazLbg3V2rKBrBgCGGmvgncsQP4yo9eJGJKKf1xzJs8MRgVuWbneeg" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille studieux", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "ab5d9c0518db841bc49d80b4ade583a35f73ad5729a342cbf32a5af28215fdf59cf8be92db842dd4dbd1bc05b321a7a75fe33d5d4a07eac70d091456d8134864", + "bip32_xprv": "xprv9s21ZrQH143K3r2pmL4DEP8h9y2yxsU8XtNf53jowDTLAvmmtCxdmUVX84CGLWnjChy5kGMae8SQCXxD1131hiV2FjoFCCUTX9d56jZ8stV" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abolir", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "bf9276ab5c7ba6908686819c83648e0f883cef83ca00908507f256ae480d7f9e127a7baaf244359c1d18bc6ef1027379d21bd0f313e4f415bb06912b4cadd611", + "bip32_xprv": "xprv9s21ZrQH143K2hCbwjY3oFwnqu8Mfi2r93NUkFKDrdTZhffckKNTYRDrn3RbPp7o3asWrsDNgF2KfLbUGi87HRoG1MWB469jYKqBX5Hdi5V" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abroger", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "93326d5b0caf00c7d4114362f5edd2ddc75fbe7abb6d676fccf4da7c5fc47a43713438038416f8213ab3fa18cbd22b46748402f14d0513445812bf88252ddaf8", + "bip32_xprv": "xprv9s21ZrQH143K4JKW32Lw9aejw4YzwUMYTpxK3NzzG7cjBeyg6Yn5GiHRgzkgyRA1Ho7vB8WZC2GfNcW2kFRWgC8tYFAErvxYa5Ce8PULdHv" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer agencer", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "97ae3d265da596ff04d4bc5ffb1c6b414c31ce24eacacf0a4355adcd8f8ae4f453d570f7ec5e32a1df4698f84df7ac852ade8c44976c0882d3fec412ce06703a", + "bip32_xprv": "xprv9s21ZrQH143K2vnFpNiUR5vRjBwjStLcUW2sHrx7cWRnb3MMVZM1yFWzVyseqg7WL9HH6iSJaLpMNRCDsEKfVyUPZmgLqEfP1tchEAFzKsM" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif allouer", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "12a9d88ecae0bc061eb3905e9ac245b4ca1729480196c4580b814b8ffb6cf5bc95cea0773f2e54b3b3a4be75fcffc980dff8dfef776ed2dd4a01213831ae38f6", + "bip32_xprv": "xprv9s21ZrQH143K4RsXKxgZ4d4acXF2j62CZAH6WCwdAmV27NQUiiBNccnYTEj612D4BmweAUibD3ArLt4jsCWvccCKFDh8onBasC4c8ncC6or" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif appuyer indexer acompte bolide abrasif agréable dédale abusif axiome", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "5450ab7127405425ac2edf53d523843485ec5d5c65409f1deb49c74af187d5cf4229965501417262a795c1075cd380e1baa89d44b4d643d6b3272d8cec2d68d1", + "bip32_xprv": "xprv9s21ZrQH143K2FHLJmso2XTvnKrdWhJK7KwzTHyGYCz4aUuumZuLcF12dS6ZBfywH7LBcUgA8wihwPYv36ZDzuiKQGzfcFgoQkJSRNfpna7" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre vital", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "b1a5a56093ca470b4ce0196260ed0207a1358c9377ea1b366b2c6f2296e783f8c18713efe0668cbcd583ae36d3a03fccca2d281ef731e2ee3a623e8220408d96", + "bip32_xprv": "xprv9s21ZrQH143K2cEjxYSMfdgAt9jcsSYeeJMxMh4o7VZT86Ux9k9vXV8KZJrpDutZCsr5t7JNESwsguh2TuCPyctiX5c6awQs8ZcYrSD9vfQ" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer vilain", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "414b9c8d0b24c2105786f235c125bafcd57dfe087c6a127a1f768caa1febfbd5756e50e184f997d03ec4b3ad88b6e088a6e42432abb0f51889ed59e3136c9330", + "bip32_xprv": "xprv9s21ZrQH143K4GuSsE8EjMmNLFP4rGeb4EqStY6ZQbfQAVoL4jd67GmNRNYwm1ESyduHqkU59NUH3Bw3mLbRAsT7CbPi7ZtQt4jGuWWDhNd" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage vaseux", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "712dae3338eebf12891a0a08bbc50e78143e0711ccc74395e18112cbd3b3008de6e8e7afb8a17cae5e7f6269af40b46e283a603105f72fe5045c4dda80c45bd6", + "bip32_xprv": "xprv9s21ZrQH143K3YP9wexxyMxDgdHBRYbh5Rn5Qns5Z1X6nT4QVdiBGFCiJeeXVxbwPT7oUsmNPXVWbrwedrVGt7bBEfyXz4HBKoexrykNdep" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tailler", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "bb5eda48eb27acf0f35e521eedc7a0f4a1d40be38c2ad971e7975351a511e696b6d6a0f246c983f3646254c32b20c64a842c10199bb8c7c9196fa0b39649cab0", + "bip32_xprv": "xprv9s21ZrQH143K3NakZYb4rPCwHmwgezgQt5XdE6vTLw1nZqWEu7PUivVPmuKcLocovCveLNrSDGE7phpirpE2dKUN4PX6pQu6BkX8Bxmp8Es" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage sonnette voyage véloce pourpre volaille tribunal implorer visage séjour", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "f60d9bceb43d1c57c7feb89738e10fc5fdcde3923e4f7199c6996e8e1727fb0731f448a830d3e616fe0d1f1368e9cb515640a6f2a8b9ae125d6b4e25296568ca", + "bip32_xprv": "xprv9s21ZrQH143K3r97wNiLX8TeEFnkgAps9VTzktpsZXFNQHTszjaUbnuezpXtm3HXgB6NBTuZGDsj2qHW8JqWPWiBVBevgQN9ey34QL8ZyLP" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie voter", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "5c1805eaaafc299aad1dbc7aad92cf6a171e5cb3236e3136ae39daaa7dbf0c4417b9f7f75f8086f92737fc06c5aef8eef31228fedfeaa39fed64068069d56441", + "bip32_xprv": "xprv9s21ZrQH143K2uBuGmtSjDHDCRvagNhJPQkpLbrfzAbdGSxqSx8SHnP2NXqrvNVNjaSW6SuFQyypx1Zsbtdur848BR3Jjfz3JeHgMumBz4K" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie vorace", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "a0b37f29ed5b2a144a222e8009ec7a16c9852c12aea458ebf19ec393bffb1ada53f4b5a2feee29c3e9159654057e9eb0c42e3162c06d43e49caea2f4c601c7df", + "bip32_xprv": "xprv9s21ZrQH143K3TmikaKvSZAb1LpmsMdobdDSEvmLur4rMu3TCctiKKwNuhZhabpK6LVBBF5fmCPe99KcG42rCR7V6QqfgNJcxYjENzCDYgG" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie viande", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "bd70280bee4bc9e87ec9f6f875593a6db8f21bc69acc865c53f2fa803aadfbf4de26c263f72a5c807e0742371be12cf3da4d75f660264731c2eaf0fcd6559534", + "bip32_xprv": "xprv9s21ZrQH143K3cyWwyjxxjBXkVZpXNc5pUvX9yFB18pc51MkdwnRmXWFznQXUKq9HhYNEcuT6HCAbNLAszapGbMjQNpqHhaz89LRaApP8L4" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie unanime", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "15ef71232aae4576ea4597cd91a0f4090e0c2f34018d62fbe783410cebdab9b2b8d47108e22b2c72dac5ac3ed9c01f040f5d6dfb79608210f39ee4e158ed5247", + "bip32_xprv": "xprv9s21ZrQH143K27LyYotPXhuVNVYf9d1MGsiMMe42Ptuzs2V67e89MjW8f4DyUEYWmjTYNhrLm7euLXpzAtTvsNGdmRBqauQstmG3Mxebj6p" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie zoologie valable", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "342dcd0927927d1b3c94f52e20d58b2dc233ed5172afe87ba4e378001c987901eb63a9600c9f927730d789fccf85aaa8d6b7ffc1033ad9f337604d7dd66f00e7", + "bip32_xprv": "xprv9s21ZrQH143K3E8m5vcjSYXrBmMS4HtJwZjaTmu2PKooBojN15NvZQ51KjQMiBSBCnshgVyuPE1NYmJNBNrQvQcPaiJLu3BEZAty7xGbwZz" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrobage", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "78c61f178003f778c90733158ad4334ab759208f542ae9a6f369af283f4997f288e073081ff8140c4351884a5fad09789b55e2908a7f34002f906a0bf9a3c158", + "bip32_xprv": "xprv9s21ZrQH143K2zN2jgaueBjxy5LvQrsFmVbe2u7ifyCg7bDn5WA821tGnuN16eLW6FWckQBtYGtGq96y9WA5fzuFMLFx91WP3jY79hHkkAH" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir octobre", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "946808bcc8e9b536b951d55bb6e066eecb55cbb1ce6f87686b384ebfa5bff764719b8a4c3ae986082e1672dfa034d49190daa75429dc277b4bcdf0ff33c1a347", + "bip32_xprv": "xprv9s21ZrQH143K3gEVsmJXF7kuqpw925751zVS3biKaRy3hkNo1oVsynpVSCqpWcxPVqbbarxLKY1DfPGn5dUGGFHG7sPDJFUT1NnedwEzH7p" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier ennuyeux", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "fe29db74ba04179d95940227c8a39cce414465ab89e97b0d86e60b0c347ec17479efb89dceeece487bf6566b87c6b14b0fa9a923d008bbec09c7c33f57f92bb5", + "bip32_xprv": "xprv9s21ZrQH143K3APZULRoQGsi7poRS72TRWDntTsqNJXFSjgePMWhseVw6kza6yyfxMAKLRkyp9GSkVLZjRQre7yTf8wsUhtxgDvY7WJVSxT" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir orque", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "be5517c14c7b48f0adf1a765f223aa87ffae4ee65af196a364f9ce25626885f29c891b2c7da504b5d82914934fafcb0d0ca571e2cd494f086d9481876adaa91e", + "bip32_xprv": "xprv9s21ZrQH143K3dawRRxDJq32Q47Z3RsnzNeS6QrZPxtpbcLbiuH4Z2TZxvPL8DQBDLkDbq4rz9WBWzRscuyFDkfQcDn19WujrAHEHezD7sf" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier étendoir", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "554d823f985e3e058c5161f54f78239da28fe27f4110cfeda6b029cd6c5355e5ece57ac8ec12fba90b82e31fb3e24897ba092706cc44baaad506c0b7c8383b38", + "bip32_xprv": "xprv9s21ZrQH143K2hokJQXCJAyqsgJm4hKL5FwRCabdobjXpacg4q6ZcUax3g2fvnvvsLJV8Ryse68fKuygA1DXFCNGjtxorfC8BJ7Uc5v94mJ" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir olivier", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "ff7fb0a7d0a73af4a5e7df6643efc08b09676d27db3bb773406973bf99783ae5564ccc974dadf0ecfed4e8b5f69cc4af7941f09203b8f2f47b8ea5e3d4db3830", + "bip32_xprv": "xprv9s21ZrQH143K43DMMBQ2ceJ83Yh2o2ijcCM27NDR85PKKd8Tn5C12GL4aJnfkjz4bz2hAEjfXm6hPubKKUwBMWQemC6otb4CjJcVN4CcrNV" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enjeu", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "f53a7ecec238bcad6b7e5373a23be02f0b437f93e560d501b254a1a5579c9bd41a3049e2e4e48d4ed2ba4b40c15dc2d9d1f57b8bdf1e6bb81f2c5dab63c4ec3b", + "bip32_xprv": "xprv9s21ZrQH143K2vYn71fNmfGJaJAu7tEb8LkgM9xdZddGxWQYeBN4UrQvwf6cbPqyaPUwg9wTceCjB4jbKpuYHX4qvBqzaegeYSjcAAPzyzd" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir onduler", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "c3624b100649745984d5227f084a9f0cda5c61561754a60b2949e747dce40a340fc704daf76d66d729e4ddf80703ccba0a293f19dcaadfae59228be331b944fd", + "bip32_xprv": "xprv9s21ZrQH143K38TQz8d1rZNk5UDQPwnQDRVC3fU6QrkvBZdkJpbWhkcp1jnku5QTepP2WvRrQpV3k9EwAVjnfG5kWGJXsFXCo9NGQ71Qjke" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enjeu", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "521ce6d133cd84bd64069c227fa0d823d6c4dad795402dcd1e6c4aac63e32b08b4a8582f228bf2de642175ea7b150d3a95ff85527ce76e2abe667b3df88e0974", + "bip32_xprv": "xprv9s21ZrQH143K48rZEm3yupZvQjsq4xXJwQuXMhBWY2h2YqJbamB2aQg6k8SCx3v43fR35zBMYs3Tc3wFZJHTLAfzQwvnbSc5GuVC37DCe2c" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir officier enrichir palmarès", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "1d4abe127dca293e037fbe99254a747a9c1cdf78bb461ea336ae5670a63ff583393281bf6042c80bd2fe2802e6848eb4075055c7e15665b9de7e1865964b251f", + "bip32_xprv": "xprv9s21ZrQH143K3q4QRqsRJhFen18wjZgqxkhrNBSUNfWjMfi67DDthQep2axvY5ibkzY4tD8J6CP3X3taoQ1kYH9JbfwwUmsaK7urePWrQT2" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "monument dépenser féroce entasser comédie ferveur optique sonnette codifier discuter dioxyde nerveux", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "d67b568d140d57fa76c5797eb9a2d75e84a336fe672316cb07cf3ae394b3af5fec88ce2cda710c476c6235d158a6be094ccfa330a24d57247b1c522d19745950", + "bip32_xprv": "xprv9s21ZrQH143K2F5TuWYgothNNHJZQrZ5wUEk1PJBuhoQi8HgeRG85vbWE95PvULd6saRN1UAeZaW4G1sYftr75EYt9kFNu7ZHRnsF3rUa7y" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "fiasco ivoire mardi révulsif signal enlever envahir anormal vaisseau essayer céleste sagesse engager mener différer ruisseau lutter esprit", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "4bb3164412ef1596b865f99b9d9f952600d405a196ecf40e86aeb3cb6ba64279ef9a59fac5fabb95bb455c801ceaf747dcf6a83cf9164c3af0dfcdd6efc5d100", + "bip32_xprv": "xprv9s21ZrQH143K2bqjZasJ3JgRbRQr8NC9uGQorQak9yKDu33asaaFM5dYXAnXbGMLEqRfh2Jj1A2nieVziXKMBBdu2waNjpVK8XCd8ceuW9Y" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "flatteur cultiver oisillon destrier brusque crainte oisillon labourer remède substrat parfumer banquier flèche enclave fémur sombre jongler damier insigne voguer rasage gomme crainte incendie", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "fed9e4aa11e4b4294f93755da5613fa8142ccdfe66394fa790087fcc3f9a244329984ad70bb99c2c9b409046a8e33b9cf65e4b66509593f2fa365157deeaa47b", + "bip32_xprv": "xprv9s21ZrQH143K3RCJrNZbdjtcAprrCLQoair94oNWyoHfoyRsTmovGicDBraYZ1xegsU9mF68vpfPPMo5sMA865wcGV9nYxuXapUHaTdZJZk" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "paternel xénon curatif séparer docile capable exigence boulon styliste plexus surface embryon crayon gorge exister", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "cff9ffd2b23549e73601db4129a334c81b28a40f0ee819b5d6a54c409999f0dfb6b89df17cae6408c96786165c205403d283baadc03ffdd391a490923b7d9493", + "bip32_xprv": "xprv9s21ZrQH143K2UjXswfAYB9whuUynvsmUtqePhpYk7TRvu7qcyvGhxgq4C7JHGC3eq1DP9JUMKUkSpkrhGmXfuEJWq4BwXzXMGpZhSWewtJ" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "déranger tragique nageur effigie retomber phrase gomme discuter article gratuit sphère cobra junior baignade progrès vaseux fluide dorure gardien écrou trafic", + "passphrase": "nullius à nym.zone ¹teſts² Français", + "seed": "e2e0ad77880fe67d5f687f80244360a33ee6589e58ae529b9b79b005553d532945db78a40eefa3af24895dde862fd039bc6e54a59f9af5229223044d7bc364c5", + "bip32_xprv": "xprv9s21ZrQH143K3jnbp6bxGpuoD5PYmyGtm22dKZECxzZCZq65LXQLrb2vJxhyVX8kiuX3QqJFb1pVnnThtWWXVQ6TsLQRfvy3LXrZMNJXWq4" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.id.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.id.json new file mode 100755 index 000000000..451cfee30 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.id.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "abad abad abad abad abad abad abad abad abad abad abad abstrak", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "11ca6bbb04770ec44d7101ca69a290c12d14128f274a3377332b8e17a399f75ff82c377e403be51cbea7c6aca4ad7e7a7f23544aedd8e3d71d41985828d1371e", + "bip32_xprv": "xprv9s21ZrQH143K4A5MZyrxaMwCbifFJFw7kkeVskuG8MK8nkpPk5rTe3BHNSPxbT8AGpcyQx98tWT2YAEJ7gks5t2n73u1n1dfBmtqZNNx1nw" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "abad abad abad abad abad abad abad abad abad abad abad abad abad abad ajaran", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "adc6f3fc1717764fb1cb0b6a538ccfb8088e9f2b6fa6abc5308b2626a4da931745a2926af178cbba757596c390cfe9f241e8fa5e45487e1e5920532cb0a85eae", + "bip32_xprv": "xprv9s21ZrQH143K3DAFz9jnB7tVfG7pfGRbSqpZLFcCD2wmcYDyqKM7e79L7ucDH1AejgeJ93gp5FnmxCt513JtUuHjEJ69hWRW2QKGbry3VHM" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad akta", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "412231f85aeaa6f486727617f4be864df7b07ec10b2b3df46f882881bad79f140850bf1af437b07b47563f8cb77c0a0903e9b5cc0a3d58f3191ff8bd403abe9a", + "bip32_xprv": "xprv9s21ZrQH143K2qBAacXpWUvhnpiuNKDGhUrWwuKdyQqhE9GLbdScALcRqadaQrACLgf1hAB5JvCjZn16rNYB7T6XByxe96THxgPSLveJcm5" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad akal", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "d8dbe3be6489b52ab8957fb215544aa1ebf5939bf421f520d4c5b87160c8f38cce9405e58e42510be1f98cbe6473d08b9326de8bc05bc525781d6fe6407f2bca", + "bip32_xprv": "xprv9s21ZrQH143K4aPKnuZ7T1e7QSyX7xMZp2pP4mgKY9AXus1mxuTm6nnejzM6WZejimzbEgsdYLGaPFxKFqgzv6xq4bhZcHrhx75zpEsqksW" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad abad arwah", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "8611834f8655ce5c44947ab3f30f8e8497ebc352bd4d898fd52d22f9b79ac8dfc03590f0583ae63da179d41c32fb97abb303ab0957b85850901dc1ff5bf40428", + "bip32_xprv": "xprv9s21ZrQH143K3a3C32oYX4Ethrn39wtfDWCCNWBV2uph5VmwV7PHmf8hZ8GRcACaBKr1HccNEiPZmMhwAK35bakw7snhobwft8gpYc9K7db" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor akademik", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "49f9603126a23dc14ab1e1c3119df1b6e9d4b546b0ff75971b82509d0b24e2d8851b9d04c85261a9d1387f1a8c1e1461a0450fd4515051089e460c994b91eff2", + "bip32_xprv": "xprv9s21ZrQH143K4LpDvMMfgVjgF5SXdgPFaE2EcVqxAHHD7jczQcAZLuNPi1FGN3EGRHGxMbug6W9GmGw5iXebxdXQ9FPzjswYu759LZ7AetX" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang albumnya", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "e22f3edc914e94f9814a9faf7e5ed31878296b886ff54f9708dc7720b6fac96e5f7246b2c2a8bfe169b33ab9a7ecbbb939fe0a108e2d045326cd7906373a675b", + "bip32_xprv": "xprv9s21ZrQH143K3bkW2R5ZuKqDqFfTfRpHkNckiJV4toMyZARoJTAWG2Rb774wGbwhf15TMLZTkgrzcRSGSTqtA4uWimX68mQXZ75eNP2yF9j" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya apapun", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "f48f7758e252af093fd70654133da18328f22c69673aca0227dd309ff6f22a85e6a896be3c204bd45d5c0a17ed14d679a396048845fed277ac3299c38f18ca7a", + "bip32_xprv": "xprv9s21ZrQH143K25mezh229c6fSc5SADSk9puUHFYxw3K7wBfvU1NTXwuQk46fxVn8Et6urC6hpqJ9u1bLEjSgDaQugGYAq5dA2ZhpH41Suoq" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan bahu", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "c11f03941080eda67f1c5326bda6b02c42f040076c160ca932ef0cebf6e2c8c904570a3e23453257e87b6af1468e9086740313576bcc48a6a95c70c8d15abc65", + "bip32_xprv": "xprv9s21ZrQH143K3KWsQTXvBdvbcHgp2LEicphaqm4tDE5JMgRYf35fYLnEkcGiNwrSoTidcbMc4NzFgas7i6iw1UP3skMJxwGcZ66Lb5d9vz2" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir deskripsi", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "45f3da312a0bb76fd3f066e99f0233b5021b990127b6791b69ed0e3c6aab991f55cef29dd2b05d94aba298d3e1b5659096ba0d8f7ea9212263cace4c454cac4b", + "bip32_xprv": "xprv9s21ZrQH143K3p4uA5PR2sbEDausdZNXsoUisMcaA2cpVWKnZWFK3Enb4aAff1RZsmJzoKDEw8Gq3RuGKp2qsLSPBchVMYPQqLgLJvLbbWk" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies yaitu", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "9c11f30e2e526dd85e50858a8a7e28dc9ebcb075b0bf1712b3c1af245bd147db7b27b6acb2fd2a363b4b7b177c835b9509643c2d395da2929da0cabaf4f27f7a", + "bip32_xprv": "xprv9s21ZrQH143K3ecdyvJtk9NcNKMKoc3TyJJsdfpmMhLZtwvGGkRU4oVNsozz5MP2rKpBdk6HWHo3qysEUTpLcTj6K4VEXwuKfzD7ZrfTm5L" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wajah", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "a4c1562fce7b0462795ae274070685d5d925e3758542e289b38d6e72caefa60d6df694eb51495f8144211c84319c3713b6d6c68d78d1f6931bba5282bfaa7d6c", + "bip32_xprv": "xprv9s21ZrQH143K2SUa58EjS4S73ERG93HEdvwSjcmZpFqsyMameAmWFoKCMDpQd7o8PQP78GHx1ZaMaU8wHE2i4uUPMNdNgZfEsyBQEh5fLh5" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit visi", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "c86a5f2ca6e543189c641493ea1960d712a709ca5ecef00545b0533ca3dd9b4b9716627e8c1112a9f33fb53f64f4764e30a8bed5c02577b35858016eb4ea5d46", + "bip32_xprv": "xprv9s21ZrQH143K2V8jHien2x2s3W7QKAJeMZ8LfYnTxXQU4E3k8at6g62Vxg89Q3urT1cX4hffrFMDeNgy5uFBrGSdKTkuptc9kYVwU7qfqeo" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud tulang", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "29076dc77b85029549f4b353c58d8756f5e88bd7c2050394ae86c3247edb3b18c584a5c235a4da72e1fe11e4348c40e84edbc66b25b637103935c47c82c7b651", + "bip32_xprv": "xprv9s21ZrQH143K3MGTXFpwQQsM3VxUJXoA9h9wxCKDLLS53QMEmsnhXnuazBCxDXJcWqMbdo7tYr9FCNM74FrUi3t5YaH13QcyBSBhnjomfUc" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan surya", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "64e68536b2ffbe2bba3f1248ae33a07a971fe57d0efb47a8801e110b27ff7abdca60e75a13a9bb87ee4d3b6e31853c8de47e3b85500e137cd7960bcd8b712da5", + "bip32_xprv": "xprv9s21ZrQH143K3SwH4MWf6Y1VUXMkw2RgwWgqG58CQwK3gV382bPdqXESLMGpnmRHJwaXtXpz2NdATdUZpY3pjPUnVxBE8MkwxYbG5xap3uW" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan acak", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "d4c50117812a5e5c94278396e23a775512ad109ab40d24b6a59c604ddbd3523220d86f74592ff8e0a89e32a818581f1b3ac4126d298ec6ab87f796ad1dc4e755", + "bip32_xprv": "xprv9s21ZrQH143K2NA9RbsQLfK5nLn8nbeCr859EvSdPJpNKyG5T7SRwQHG7RmkikcTVqDRunAAQMEecpNHG39CnMhTLiJXrXQ1oQJfyam5krz" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adegan", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "724b1659b2bcc729e9732f8ee7d1fcf798a961e9a7d328f6448febe86857a96d0231e812ba22543fd5f2ceef42f6b1b5b9819872a157ccc6defbb076ee0b0cf8", + "bip32_xprv": "xprv9s21ZrQH143K3sN3MLgneyk3u9HvbA8hyxcnHK2UqbVKgAF8MQFn6v7hfdXnkhWZ9vGyQjo7gBsRcFh6u19XWQb3HbhhNEsgx4gDVWha3QU" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang alun", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "d5c51ba7d90bb5bf58a7c63adfae4725f07d6d36379b25f72aaad9c3232451a9fca324f5ef836b0afbab3a3eca5bd2916280d05803bc8c858641e097164696a4", + "bip32_xprv": "xprv9s21ZrQH143K2d523K8scUdvSaYPvHx3PtSE7tXKHFRdUia8TsUHkJjuv6sDrKoyzsRYc1ZtRnccjnuVLuJDgeaDFC5bKf1GMihDEXrhAaQ" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya anumerta", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "bcb099b8e32a585449470ee3770fed07bc8c342bbf8d899b3b44b37599b3a92d889c888469b69e05a1fc7caf3c246a3453aa20c353415db0955477bff32a6700", + "bip32_xprv": "xprv9s21ZrQH143K38Lin18fW22iBBqZQTvW1R8uRoFm78ZhcxNtcns41tRU5g5HCrqjEDEtgmHtdScbgBpzTS4NN1DrfP8DGQgp9SsSNNT4vKa" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan audisi kurang akhir buatan adanya amat ekor adonan bencana", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "3a09e308e31f7dfb20f3fbbc8853b3195247830920e425b2071f6eb71f602d9d7c4abb0dee410e9357a79d65f0f3d0903980ff94adfec3c3e8e861c85856ddc2", + "bip32_xprv": "xprv9s21ZrQH143K3mGH5Rve98GL5Zk7G3Jgktn9bydjEeXtZguEUbeEt2Hgx19wuSmKxkBfstfj9928EB1dBrBKWK6XoCCKfvNBgP4gye3SpRB" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wajib", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "f8b19c6965ff9be2d19071ac1f3ff6f9d0520467e22628493d20287d427b9f118f8e1fdafe2a5f85b6585445b8b9ee6a00d6e75a5df8200897bec8f1e2da9cfd", + "bip32_xprv": "xprv9s21ZrQH143K2j4bfYqb8kMVw6igSXWb5bzXAbRGNcMMXDxZoqgACBnJVgcc3bqS8BcA1e7L9kXiRk5eHNMaKQFSLUERQdwfCg45yjJJig4" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit versi", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "9c048609c3c9595b3dc37da088417301b738b9638ca431cbb7e917e5581382e6b8541df46f1f5fa1be2efba8f032fedc43fe4d376f893c58631f4c46be18a991", + "bip32_xprv": "xprv9s21ZrQH143K3QqhCx38Xe2uoEFpR4w5tGjVvznsNxqTQ4odQXrjGi4Pmb2LDjMGQU2UL81EsQZwNprL8d4WqUnVbgSRErPok2d2U4WqqqK" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud umur", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "2dd31fb5f86dc6ababb2736933a51232baa4f8a34a8433e99e9051d34260082bce83d1d8f18b5f9c86c9c82987804108cd8fb6c4b67c96065a8eea281c037679", + "bip32_xprv": "xprv9s21ZrQH143K4ZQYuFsHEnWBHBJkDQa2p36SvfwtE3Bcr3YHLt62sVQ7g3J5kvgvYf8F7unWjf6tyYvJPAaY3xjJJatqeo5mgMiTERcZZtN" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tanjung", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "91f2b33a68268955dee70a07292c3c36e5a4e534c8378621277951b37b8902fa4ef06828016bcfb1a808c938c0eb94ccfc25f1997d34cb3db4f310f02c0ed4b1", + "bip32_xprv": "xprv9s21ZrQH143K34XUfauxT3dg7ZSsZgtQA7aaeRsx4Z35NgDvgutpWK4yDK3xh6Ehf2QiWQajuvsaKEJgmYy1DLnfgNK3GSMZrFW3U5UBGR5" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk subspesies wujud unsur raih wartawan tipe kulit waduk siluman", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "4c3cf01e6a68cf59ff0976d64455166e7a4bfccaf38320814ee41ac6d4559174c3c7ae2428a99eccae675dcade0ff567de408e84fd29e468b5770b3c5e42004c", + "bip32_xprv": "xprv9s21ZrQH143K2TRipBuyVghXX89YcYdcRvjDt4PXebWpBbNYPL1Pjq7GgHwibVTo1pnVXkyCVzvY3tAiW31V9zkzeRem7rhCTo45RvuCnnG" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman wilayah", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "e2850bd646c9c0455b1266cc181d106434d2d14b1a5eab10b1f2bf202a8b4d832dc03957e19c6f38775906bae58b1faae43e3d371f9cd496f2b9c42b717d0b26", + "bip32_xprv": "xprv9s21ZrQH143K2XvLUGiHQUYVJjDu98sRkY7LMDvR1Du6VgQjCt2nZ1DKzjdbb5EkgadNXHxKrHgzhTMq4my11vpHiHvTbVCstvay2LweJRs" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman wayang", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "f53f573e9a7758bffb6587a84b2d425857b741e0f2241c3f1b6ae8f5f127e0c90b1306c7d03fd99114a2fa4fa087d98b0952ea3d0df12ce45ed6dda48b3e2555", + "bip32_xprv": "xprv9s21ZrQH143K3svLtiDWgMoBPpv9ftibtHx9Y1irLmD4FnRVyVBwzEWAj2NdWR4co3GRQCvG4oyHSTo5PEwfy8sMTSYuJi96b8emCnpbnPW" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman utusan", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "b0a9536e5f9cdf6ddc0b4eb28f16c643bfe931fcb3153c4c1cb7d4ccd5fb27ab32fd3e294e69ad3bc3b79107604c7af60d0ce6750f65018d83162384702875d5", + "bip32_xprv": "xprv9s21ZrQH143K4M5aPXD5YUj6hZmau7T51rGEymKLSdMDxkbtMSVLBEJDHGxrmqFFdWqD57B6AQcBWDBLJzMa1cDhpng96yNfsgrSEQ1Cok9" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman tukang", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "a76505b83eff36f895d235970ddda9a33cb9ea3231c89d3b158f443ccae351f67221a7eeded1dcfbcf8163cd28e95c26b43ecdedfabbe8eef458480e40eafaea", + "bip32_xprv": "xprv9s21ZrQH143K3ujvg5irBtuY5UttW7meioysthcrZvYW8oPfCQd18TR611YaGS4XxUYuJ4MMNn1s52U6kypBCPZguBrhHNt9a8BNQhULgcd" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman zaman ukuran", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "8eb15cbb2ea1e3bffb742ee97253863b67fe243356fda4d4806e534ab68b5a20a054b398f67230de2fa3c261ccc543539dfa73f403955b40e512526ba29a9f9b", + "bip32_xprv": "xprv9s21ZrQH143K3Tog7rSXhKMB8mwvBuEPdcWLap3ZGLLvUgrP6McDKa6vkzpTscb4SRFK4R6bU4e2Fu6rGmgvHLJjqQ3FHQLymz8po9rTCTH" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan hingga", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "b876be4055f5b25478b505f8b39a535db4dbda452d47c7c20009f47d9a64c5cca55434776e77a6651bdbc255160e40ea729fff93a78d9d02b0fc699380db3609", + "bip32_xprv": "xprv9s21ZrQH143K2bsdmWEiy49APH8wtCmvo1tf6uMgzAEEUEM386UvGqoxpeaTSrXFVDfBcBqarG1XGnekMST2bG7QvvfCpFSw5NZzntksw7Y" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan panas", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "3dc24d43b8293cab0b158eee60faec55970790ddff8c1330550aa8b5a4a1850e416539850ca2d569795af9b7dd3a6ba7932d820e23e2137e00ffe2a65d6c9974", + "bip32_xprv": "xprv9s21ZrQH143K2D34CuAWUWAFr6NAusyUdrgqEFbt4VvbeE1Ndcbva15kFs9YGFZ9j1oLrRSTNS12fJwm52BQ1vGfAiuK3hhJyJg7JCLiXrg" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan hilir", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "43c70790a6b3887bd0b7d8b7508ec8a5eb71fae1c2447a86ce872e8baa35de55d1ea2ae82c2ac784ce2c6e3673fc937848b1db0c0c5a366ac5fc8b998fed455c", + "bip32_xprv": "xprv9s21ZrQH143K2dNyteQc118VenBX69ibgVXoTyjjUwjKypC7R8wbeo1RyrQ5hU323DddTS2KzxqJf5XWJeDW4WYQvTD2fFWyTGXv7i5zgFS" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan pekan", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "fec71dd64aaf39f8fc44b6a96c37707c8d0335e6c270f132614f8104238cc8d37501a5b2ed9e1ec57ac6c752d28077748c04dd2cafe174aa81f65fac9f4d4759", + "bip32_xprv": "xprv9s21ZrQH143K37JTSbwWieEkEZajt1nFV7xpEgeKwpGMuFmNz8KxmYTkoLhe5BV7KGrVVatzjL29HUBQYGCKEeJ66nVsAoHzgtPiU9ZqHGT" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan inovasi", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "6e6ac7ef520f739cff48165c7023641f349d8a3bce2a86d2151eb309b94d26ee5231f4a360fa7b099141ddf73f78283f61273a99d273582c9dc3cf4ffb9ebd8b", + "bip32_xprv": "xprv9s21ZrQH143K3SRZUm33VRB9bBahsH2LVtRfvcDpD6bgCkF9hUT2bNgBLNnj8dVXqrScVZenxiZbC9ukttQZ1n9J4E3p1MeyiLzkMit2jQG" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan partai", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "e2d642af25fa4fcf8402c409b7b918dab46848c51ef40d8d00a32c54ca5d2721d5463e5caf3d482eb89db88e60d5e02253af7a7f2e48e5525f3adccfa8012d6e", + "bip32_xprv": "xprv9s21ZrQH143K48QYD7Hauyp5L77MafZGRRyzmM9hZ4C5HbyqvcSoTndgJagUhmtsG9GRZrEQ16Beuw1o38MN8oEFJzzNqibtkEBNb1VKTx5" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan hijau", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "0efcb3d92ef9c6244f6fa425eb420540d811b193ede651edf211012b9e59cca28e92064e0ef9d079c0d0b016e26c5a323bc97ab4723c0e3752b40c5433eb3fc9", + "bip32_xprv": "xprv9s21ZrQH143K3Kub74NQcipybsR6mwU737sbC21eADFUbi4sjzYV3EZGJ5T1VEpodKU3CThSnWDDJeagbeTPGdAzu2fJGjacBfm5P3Fd49D" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan pasir", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "ce678c945bfaa5b2bab5c73318171d427f2bf38010d1654bc23bdbb057100e4945b8a9cf241739989061e7da79b9aae57ebdc6eaf7f5805c33190bc7b4934bf5", + "bip32_xprv": "xprv9s21ZrQH143K4Rd3wJPa47ftm2tZi6Cur8oiH1eQVfLKsnP7A13q6xxKq65s3G8TSvuh1YbUHCxGfKfGMjEVjxfpXY9Doh5VnYqLAX397dU" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan hijau", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "643d941f72cd027a42e88cfaf5e7012937b70d7584e4c4eb6487826ccd13b331a786f740a75c5c7136082517036d71fd445e9e8e4a579ef305671ba784b1a3a8", + "bip32_xprv": "xprv9s21ZrQH143K2UdUcwNp6FfKBe13szGA91NouevnPbBx3esQAfjLoChKCC3JyWYVhasEjrKgShUKhnV2YFy331ac9rcs5BrFip3qi9GxAar" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan papan himpunan pengguna", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "e6b141c121ddb1120cadd286973effb8ffd2d4807d707d39b5fa1452f745e0d6f214a0d3554718e1396fd2ef1ed25a52bd002628fe368a3ce9282bae2b34bcfa", + "bip32_xprv": "xprv9s21ZrQH143K2GmJEaqSNRTh7vMceGZptSRbGvCz4qMexnnMXmwM9n1eob3YKLf35FTTyf89TkqEJhsXHKoHhaWM6Mir46GMmQKtcCzCfmT" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "mutasi ensiklopedia kabupaten historis dilakukan kaca pecahan subspesies diizinkan fleksibel firman nyawa", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "07123ea95d56527edd2c0bb1992ff72ac217d3707eefd93bac8555d58815271ec51e1edf84fe7c85e223cbd69e731863d5de79e8d30c13e7c94fa4883947ac7a", + "bip32_xprv": "xprv9s21ZrQH143K2LKhiuWEQzBnkJLer8c7ehSD4qWpk4wNGFeD23urXKpoeLFfQanPFcrwoTxjSxM68hHB2VexemY2o8tKXsVjyCeWcAfQy2w" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "kaidah lazim menunjukkan sebuah sosial hijrah horor asuhan ukiran individu definisi sentral hiasan minuman fiktif semoga medis indah", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "cb98e4f1c959ec0850dd82cbc00c35df0c10a77e5e35b47fd69ae1b9c37e9beba58c65d39bb8c17f7dad5db0c4310c998deae97285c3686cb4e48f35c12fcfa0", + "bip32_xprv": "xprv9s21ZrQH143K3dGKKdC8hbpebXiYNG96e8hC3YujFXQAtJJebapxuxb7R6bz7yZ7EyT2jhc8cZCB4ycRoggiXQxp5yi255TpXTdfSxJstfg" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "kanji dokumen parlemen evolusi campuran disingkat parlemen literatur salah swasta perhatian berikut kanon harta juta suaminya lereng drastis lama waralaba rohani kepribadian disingkat kuning", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "4a316afc6a35d6779d554bc5921fe6e2b8ab0eebdbd7bf7f6350d8c9ebdd4e1bb31029bb1f29dd9b5ce3d3054bb7444b4ec0471e1a230ea2853084c33794e21e", + "bip32_xprv": "xprv9s21ZrQH143K2vs5iCbgSqQjgZ9GpjfcfLWPsTVayCZFo7xLPG5o5i95s39EnophjrbWsxQW7mCXDrKZYmuFGSq4oaq6XPbxMhE4pe4uPm5" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "pertama yakni domestik sirip fotografi dada janji bumbu susu proyek tahta hamba disponsori kerajaan jarak", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "289fa7b5c4a44adc18666a7932b7a9e741c8f0a7761f540b944dd989a2df1b185cd05fcb982f4124a4e8bcac623947f520c925c29d5594121181f0b11e483fe6", + "bip32_xprv": "xprv9s21ZrQH143K2DvMZPeHEnHUyzYHKGocCSGwPFBpLZwD9cPBzVvhFTKQSCdf2bm7qBmYbaN9sAqm5ygAfev77c27WKNVxtfJsH1mMGyQziD" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "enzim tiga newspaper gravitasi sawah poros kepribadian fleksibel baik ketika suntingan diikuti lilin benua realitas umur karbon gaji kehidupan gitar tidur", + "passphrase": "nullius à nym.zone ¹teſts² Bahasa Indonesia", + "seed": "3421c7b5c15e0bd5c4f7d86685a701d0b8a14eb3db6e3403fc52b52ac4dc57ccb1109c59e7211ac9df5bb1ffe8290300f09ea281836575b45ff54d309816fd49", + "bip32_xprv": "xprv9s21ZrQH143K4PpMzKACSWuF6ypc6KDo8MDCN8x2pivD6X1sC91vSwN1WezPRsEvCBn9r3LgV9Tt8u7BoGsh2pm8KX9ZzqV2SEyPAfVthjJ" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.it.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.it.json new file mode 100755 index 000000000..5ef44f86a --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.it.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abete", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "b71e2ec6581532f698d078694711674b8598cee8f80bc45fa520f2049a6adb4a8ab1382f605ba8f4c1ac5223cd2aa88da1fd9f55ebe99ba5d8b9c0f5ceb43442", + "bip32_xprv": "xprv9s21ZrQH143K4RDxCEYrbop5UxQ5koWkqyB8eVDryEZosxmQYELDGbJbFqzt2iUw6cEoNJ7YX99JvnRAVMXQ9cFoSsZR61RxtyGs5c8kRTH" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco affabile", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "138c32ed781301d293960d9278e844a45cbbe49a7f53ce52c68e18202b86d53a9c0727c232f4dea73b5575dc9339a809b696bbae72b58fb13010f3910c3c436e", + "bip32_xprv": "xprv9s21ZrQH143K4ZnDPSNde9Pkogav4GJhRZGczutjfAq52uqFm1pWzzyhdqFZijGXi7ZuCXChfNgDbpHJyt9EJyvpmfdGF7Bpmv8hH68DQPw" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco agitare", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "9650301a94b116668143554a2785ed93c7cd5a51bb0b5ab911560c4921946f03ae981be3f1256f5f78095b4ea112026b5a7c3f6cf751ebf0262b1affa7e6db51", + "bip32_xprv": "xprv9s21ZrQH143K2ix2F42mRnuLwMpKtgsuyKA6a3RCwTbRjr4RPh8LaMzUyEQuX374RjfJLtfVTdDRwo7FQmrvdWUyJnFMJ8gGvP5dGyumkWr" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco affisso", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "e77e09351459a2ba6174954ff6c4d6ec4cfc8e5aa76a0e4b590ab2ec94f9f7020da7bc2e840625c749d431cc0738040a2d61b8e9ccfc9b2aaaa3814e8e25cbe3", + "bip32_xprv": "xprv9s21ZrQH143K2gm46Ad4K8yGRrvqxhjLqdJxwRbtEWJffEP6dqVgpuBgryGnwULKfS9CfUfZNas3yPW5mvvwF9EgK1fyzXEEnKK2vNqMFsG" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco abaco angelo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "ba43ad35efa5871261adf628e8c340052028acd1ba5c30f2425552df277636d0366a190fb3902af9513dd473d8ed491daaa483e5fea9f6d30a85451baecbbb6c", + "bip32_xprv": "xprv9s21ZrQH143K2SE3HHdDNmmu5H5wGN1jipSGCGK588mzzhXqnCXZnT6RLFZFPENFDKa6npHKAzSebtSAAe2LPcARBfSdCyy2cAvQpkXphtP" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore affetto", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "a02d476cab313eaf0d51516677389ee262dfcb0cb4efe844e86012ebec1775c1b93465a4edb34630bd56085deff71f5a0151f3b4fee36100df544f073693b65b", + "bip32_xprv": "xprv9s21ZrQH143K3wUo2sznkeXA5iuWcW7DA5q2TjViuEz9YSvLyoZpgcPteQP1df77bGVQqGJKfTe3qJTHQpRYhSqaD46veWLRpPcYQWAKAEG" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare alcolico", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "900c6bb05f520af72f1d4554e0e35e9cf1d1cc053a15d16f8b01775780a9a4e3ce3e36b7685ead1c05d200ad3519c15b9b7018f4dc562a639d5e17ab29ac693b", + "bip32_xprv": "xprv9s21ZrQH143K47mk2bkzwGbhvGnMCkZ18KdB5yBG7BCWKioWZ9ZbZbSZ7ne56Ye9njyRaB8zAADdfM5vsE1CcNaJZ5rhdfr15MSfuPd6R8q" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere ammonito", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "780c5cb70b240c5200a99f41f267a4e385480898370810ad78d9c5c6f22a6ce7cd6a58f508c6e998d66452fcda9f000be52d2b32fd2af2c99bd756a98d60be33", + "bip32_xprv": "xprv9s21ZrQH143K32AbLsANv4NG7KvYx6oDkfep32b16KBAX5Z5BBhd7jrGtchVfacXo4dkfvAthsnx8hEBvkcsA2czsnqpikDG9jhq9DAT11D" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arzillo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "f91a9cbe5edcd17212ff50834c0ca4bfcb17a025007acaf5a01269c9e4b91b0e0b7cc7fed75a6b183ea87a5df3e2a5f6db049e82767537e883c77ab5be5e2308", + "bip32_xprv": "xprv9s21ZrQH143K4UNpXcBNB1Y13coUHduX1NEqRBDnLgCkwDqK7UWxpQKMKhnLb56KMsRqKq5faWY9cqhPZiuMZds2Ksf2v4KkErvZ21nD5Cq" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso cognome", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "84d362e70d7a833ca2de7f628bb7b346e61a55af76d75e0332fe0f46923f280d52c1043e44e4a5e1f15c2d43e5c83997da75acf5d6e9848ad911920e66043769", + "bip32_xprv": "xprv9s21ZrQH143K2xWcmvbLtv1EssxxSd4VpaKM26MnLWvjr2A1rHTQMoNU1uPfZzmNkzAPnaMNegjoGNnkRCPTqUcaucC82JdRdVsMschmDX6" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zircone", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "7292b151c95709310ed4f053600a8af4afcd4c7f96a5c27d1a1e2db6f4104bf54dab591b534655752359911a829bf87fb5c42cd642f6d3df2cb55e2e06bf14f1", + "bip32_xprv": "xprv9s21ZrQH143K4WdAkECyLfzt7AWHNeTD3uGUThMVgHq3Es9YopuNwwcSbw3vM2RusNM9QpaM4xtALLFevyp1kWuWqHZ9M5d4Rk5VXCSVN3d" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare vivido", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "f00c8ddfcf207f972e04141ece7a289b2d467fe1129fef9c286c8e55f0e593cbe4d5643c4ee46fb2272cfcd4e7d2c9d69f9381405a521c7facf96e47a686086c", + "bip32_xprv": "xprv9s21ZrQH143K4XvAhiaXHeXNqL1NNhcjLNR8o7vZbG4hVmvXsjBfeFmqR4Wg9ZJMwkPaE8nsru5TSXCCwRq8DASwmaKvbgJaTEL4ddZNx1S" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa virulento", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "53dfe03f01076fb6fdc0f2516d336a2a288ed49d671e6c8183c987cc236a734fc168d18cc5142dc38f9ae0c0745c0b9a712772718d6cef90584017be63220032", + "bip32_xprv": "xprv9s21ZrQH143K3J7rvhxELMdwaz8HhaAtLDD7UCCHVdPSY69yZ3rvr6ZtBwM92qhQJqJ1xFi9LBKo4VJmGpmHjyZojBdUbTB8BwbK6KQxWuU" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vaccinato", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "262e5015670e15ecb723088a68c9b77a21f84360a746dc720771a6269148fcd6931b6a074d65cf86e623e7796a0f735cf643e6aa30a9ac5e4660afaffad76013", + "bip32_xprv": "xprv9s21ZrQH143K3fZM8BaWH84asxcFWfUDw37ap8W79dmeorUumo1YMZ7PXwUaYzJoGt8aUKWPufi2kWD33F51C79BtKppZVu9CzjiPu9jsqT" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera tarpare", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "261a34e9b43f71c04326b92d51ce75e6584a8fc3c2135369585c18b0f7e5d3d5ca32cf48d2ff53d3d8645c8413b74bb81232e160e440655f5fdc2d86133073eb", + "bip32_xprv": "xprv9s21ZrQH143K4XBePc9y2FBwjKZDxWLgg4jS9kawuN6BA852fHU7TajWfAjmau9Qo7phk27vYM6LX7ucoD1fSp3Mnof2451ZvUegMAtZsYZ" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura abisso", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "815b0d731057c8d8f81c598895f4c761b11cd927521fc5b91fccb64592a3d834fe975f544aaea8c82ae8c2f26f37293b3fe427b43e47a0b39267409750d7ce3e", + "bip32_xprv": "xprv9s21ZrQH143K3qikt5HJ9XSipGLNiWGDeRYoV9JXPSaT2JrmEEtDFXT5Hj7Wq62Q4Lz7ZiNeDwhHstNqMVnQpKHRSfutieaB3tEzcZFjZTB" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acetone", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "350820751402078e84e734957541cc1b6fe46e57751f6e65aa4b03ab8533b5b14c86841782a652c50344fe3b0ab2ce0d43e7adff6c9f886d6d3147efb0cb38df", + "bip32_xprv": "xprv9s21ZrQH143K3q14VAowzQat8e5ronYtw7Y5gytXtYxKU8RPQCBcTgs8Tzgp6zYjihfKE5oUuzb9VnnyB29777qhBHzxKfcZsujNrddLe7C" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare allievo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "e6725203984fa12a3cf8d882e887e3b046d61ce0dbe6a302df990ab4c470be59bc2c1bbfc8ee0426521d8e3dcc720de5ada2d1a4c3e00f1799034b0c49fcefa8", + "bip32_xprv": "xprv9s21ZrQH143K3JJcY29dYFFE2aRzvACkcGf1ttc95s3CN8BYCVBKNy1d4hncV8kNguoTPgJNUJPopx9auhpqAGqz8Dz3DvA8aewwpgwuAN1" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere amico", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "18a44f4dc4daaaf6ef7c560909644329d0352068ced24eefaae1182ddae88bed47029833065304502163a7d178ed0bbfc2fde190af6cfd7adc21be1d333cddb8", + "bip32_xprv": "xprv9s21ZrQH143K4Wbr78VmyWYSDo5vtmhLYfewbZZ8A92r96Wxnw43r2zY5qsdMgdiqWfpmE9bGhRfiNqCtPBYpFs3RW1m9ZokFk5YHCPVhfv" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico arazzo misurare afoso bravura accadere alogeno dottore acrilico baco", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "5eedaf16f78e320dc244cf5e68b5c69202fc5f02a195adcdf7bf47cf3c5832955aaccb32bd6cd32e1b794077b70b0612661d2a5a58dfb8ea6ef5102f9a48949d", + "bip32_xprv": "xprv9s21ZrQH143K2zPDMnVr3peFX9s2ETKymKNBsNoxFUZfE4ARmT5WMh2jAMDV2BStRtGE4k3unL5xG1FA6PcFDYmbQ8pxB1zWzBGv3JDzJBj" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare viziare", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "52ed6161d457fadbc4b955ae153a8d03c34f4b947255398d81620241ed6a6a02551e2fa1018d5f018831a0928d3f3ee6501a9081f3b2739386b84c91606a9e70", + "bip32_xprv": "xprv9s21ZrQH143K2j4uV3aWJAComxWu9NbFVFK4N9qxR96BGsq61cq2PmVeW8AaNST2Nx24niMFwCqaWCxjUX65zaRjhCMatrkaPby4mbfYpVo" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa virgola", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "09b53cb30b15655cc789c8b5f16aa6aef616cc31104c80a5b95b5818e1e47034310abbf3b8796e606941c9bc33bb46ab8caa64449af1e4bdce27da62aae271d3", + "bip32_xprv": "xprv9s21ZrQH143K3fMRZG1CDfawvot42JjC5gy3LDD3JGaapt3GZpcvXRReM833n1dHpR5tVmrWpB7r15VxNpDkqPAzauX9RAzZSkie4e6xoYo" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco veloce", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "372974e9179ad6e7e8ab0b66a05dcc5efd5c1d0ff27985d40647dd7c39a575fe6c48f0ca196284a14a19e876e55fe42b92fc4a25f4394913134198ba2d8c91cd", + "bip32_xprv": "xprv9s21ZrQH143K3e1ACWW1HdmKuADaU1xSD7fEqVx8x7tkzYxFkxGJ2uofptAY9DxLfwQJMTUSpjZLP93oU9ersHLQT476XASP3KZyZmyQKoG" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera tipografo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "96a4ef2b57eced071d3870336c93e214d86047608c25c402c4cb79e6c4ef3c002876b312adf3597dc9b9362f1ddc51a0dafc94d1cfb6806a39961733613a1a10", + "bip32_xprv": "xprv9s21ZrQH143K3K4BXJj6mR6UhdL72BfVwAvFYvJiew2HHSposu2tvxGhQScHohWiybRbU4ZEaEdogyXPTRufzTUJYY44qMo921iQ6rtxXeP" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita sussurro zinco vero saltare zattera ulisse mimosa vita spirale", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "cd4940fd1931d79a0c30cf0185e582ec1e2c80c306001976b3cb53e8ab127c3f7297b24b1fb2532f8e9f08fcc34ef643bcbfa883c4caecf0550c57ef4c99b98e", + "bip32_xprv": "xprv9s21ZrQH143K2p4gZRE3x417uoQaZn1SJgzud5CTMa5bmVHE6ejpixV3Vmvo11FTiFf5ywVkLkmmg3ak7ir3rDdwTdFZQop4HZLN2mxirZD" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zerbino", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "576a78d9d776e12434689b568bd4bae9de12df1a3614ef05024b4212834022b11b353cf250fc9d9349dba4603d10e18e9f51a0a6eb6e855410aac5aea0d09b87", + "bip32_xprv": "xprv9s21ZrQH143K4NnQ9RP1pLkXsS3yVY74UryRHWCQu3cFZKHkfHS31bCnGVPTCW4SUPkLRK3mavAtqiawepJYtgqP3bGH7v7QMqehSWzvrfi" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zelo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "a4f2926c9fd0037f375777910ecb9fc330dc523a0c602d156f54176c226a3dab22e7dacb19784bb57cfc7a1d3e31342c97371f73acafd01ea8949116c1cd9021", + "bip32_xprv": "xprv9s21ZrQH143K2jM91iH9T49FzBwni8HtNMvy9sbs4hDNmRW35XMTxwvhmy2oHe4azG8bpX7MyYriDF8tzYfiDysyPi7nqF6YvDXqoEmC1Li" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa vile", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "c5a3104bf43a792c50e3b6ca284a36655d3ae8271b5e3a38062b086dcf6e4d0876632ae57fb3ab695f8935284940622722f88f277ea2d6191d48792dd1b06430", + "bip32_xprv": "xprv9s21ZrQH143K3HYc5Qyvfb8yQyACDWXuqqvYvigVsYSZAFQaipwwzQm1kY42TL2JjftiFzPvH1oSY2AMrUaE6JfGYLNBcqGUn8RWK6AwZP1" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa vacante", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "e310056c3652b01fcc6777cb9b488e389db20eacc11915e42f505954927eafde62b151c4e33230e35c504592eae4238407e3bd619540d2ce8399344285ff44a6", + "bip32_xprv": "xprv9s21ZrQH143K3QzzEdM3bZvS8X9F3k5w3JejSTJwts6VoQfKiH2GWBywwih7kpiJDLooMcaQgidT9qna7FiGKPZG6ajbhXQR29mcoA2VBb5" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa zuppa vedetta", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "efd9c8d765ae9375fdd8ed51c0687b5c3fd7b40b3e11d0d42ba13b36e1600681a28235166daa37310191d8ede94980a85a0c85f2002f900549b1ac46c873ea51", + "bip32_xprv": "xprv9s21ZrQH143K45gAxzmzMGkWU3vg7f1vHjEMwdvMnpNJLDfQx6AUkEi3QPW771tWTcMmXqkhSMTfZHLVMNssETxv6nxXMU585z1CtYatEHf" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forchetta", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "d63139e4c8574a6ba958e984a29154cf564c335d24eb7f7614e36aed7d9d55267370f20e51260cad029b35b43a5c368f237e7d47263375835d99bc72d3b80c4a", + "bip32_xprv": "xprv9s21ZrQH143K3AgePfzhk3kN1oRYEjwEmqsQ7vFcjW5Cgf1s6R8TkoeCGRKCtcdjaPEmYvYbk7RT4H6nCC9j1cfNG7GEW2ZtXtRETnog387" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito promessa", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "23974bc88e54783e4e2e5bf0140c65880fb1e1157dfffb632587fd7ff7cba6e4c2258b050b89479125a75ccd618d04cb31e642d142a90d701df04697f189fb9a", + "bip32_xprv": "xprv9s21ZrQH143K3RrQSwZeoAiB45ED3rv12k6YPnxb5vpHK2xHHfo1T5UfdzLA1wRpWjYck4kC8FEYvBJaetZV2XV25955d6dS2bTbo4KdCsk" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna fontana", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "9b06525657ef3b0d517822e2f8b58e69e930a189d049ce4baa44be78bf8cfe2ba98da1970f54c9811b3456c76d3abebf482c98a33a2341e20f036b1dd394f967", + "bip32_xprv": "xprv9s21ZrQH143K3RETaJFYYmJvX6pnyxxrYqu1r3pDAWS2WEVZjnaTZgYpAHQDDdqwQ3dBEhNxgwDwvE1BAyouNKD1VF8zuBJmMTpfeZQ1Mxb" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito randagio", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "8c4d9dbbad50f1719ca951c9574ca1ef74f87bd0e718f5dc437ec9c1956d2ee1f88f17e7add7e46285542e4763b60a0f95de342267042ead4cb86befc6e9b269", + "bip32_xprv": "xprv9s21ZrQH143K4APgTrWtfqkfzo2XcmQYh3KoCmN2VbjLm3fQpk2aLmd6iVcuZcmviWsjQezxE7uR9Mm4y6ed2zeuuimYKfgM5NvmmHZNAiD" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna gazebo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "35875c0e6ef7f04872ed47b3c0b710bb520870b3f0f519c5de7ab67ebf64ae14e73d57bb5dc4afc7f48856a2720f02b3843f5b48232c40a27b6ea44f972a8265", + "bip32_xprv": "xprv9s21ZrQH143K26kdZySK2gwEm2ZWMAqDEjpYH6b6FS71m4HDP4WaHyijMSBryqEoCBpUtbvhZWdB9ccKGq9mDHMCRa3LvdUfTS2Fgty8MJd" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito pugno", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "c916ae8698c0383501fd7601871fdf161535013288ea9e4a810e1e9d23b4861374d6ee83aef77e346d16358943d8d9cfaa74398cc10057c870c8d4cc8af48b7f", + "bip32_xprv": "xprv9s21ZrQH143K3K2iUdaNiBXE2C8tLm6PY3s8woMavFscvwrj7rqV42c5EbFW2FskbyP5oF9ihSVD3dqMbGYRqQ9NREBXfb9TY69H2mtFgwQ" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna fondente", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "33cdd3d9619c172762adab8c5ca9693bcc8cfb052f08594a7be21639ccced112b95c462f4d2e0a9c6bedacfc694853f4fb95867d4fe9e81ba633167e7a4b4d3b", + "bip32_xprv": "xprv9s21ZrQH143K3xNNpZ5RoE4cdn9htnYtkZtG4pwp2MvChyYz62tDN4Ywn6BdS47LyC2y7KzTg1fQq3oohLNF3VzyKaT1oYbCHxdiFpHQiXr" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito puntare", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "add7f1348c56564ebb89ea67f65b0a8214319e3e37f8a8592b4d6f40e163a40565668daca205f6f9a3915ad2891107b4fa508bbf294aff42c39810099926ddb8", + "bip32_xprv": "xprv9s21ZrQH143K4RXBYWbz1hzonwvDn8S1YtsP5rcR3RNyPTBqVDCrcLMjCEDtwMNHSBqgVbbbxRxMoMJ5ds4W5HVmueQRupP1eeEsm2JKXvb" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna fondente", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "458a31495e941bdeed46235007a2d7039e91dbffe33f7b84393eaaf28dbc6fceadb38a1fc1bc998822f23e38e496e38be4883c2d918e6fe81752c91a080cb99b", + "bip32_xprv": "xprv9s21ZrQH143K2qE5vVTWgxgSRDPHxSeCoQGhrrnQym11j4bDxJX1iHqaKBPrLwsmQsC4jz5wcUMSm56UTqxsBci2taJfiBSQq8EqcwaHrLm" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito prugna forbito recupero", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "859f8acd49d40e8ec5a8e7a4999a817cfaca0536b3ebcb307bb67a71e44d418408867ebae069026da1ce0a32068331b334f60ca4c8b4a0a95cf2b74bee559cb2", + "bip32_xprv": "xprv9s21ZrQH143K33weKQkCss8hkVgdtau5WQJo71y3iWK732WnwKctVrs9XbKJqmvmZX6M4SCXqMyHtLk3FuTDyNkLKrnfcnCPZuEdpA18gvE" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "pesista educare imballo formica curvo imbevuto raddoppio sussurro croce eppure epilogo poligono", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "4b7b646f5b221258d13a7840c1908891798e7ad24a49f5cb6b8912e656d969176d0dea1d34a8c1ab3b5d265a0a4aa3dbdc5f83f4f1e5fa3d9456a70cad3afe04", + "bip32_xprv": "xprv9s21ZrQH143K2gR1FbrfSHjLSR9SYz8BxoGPrnpErammgKrDrXqqvoi1AnZwTTHt54mMqRNGuYp9rjt8vauE4p7F7ZvBN4tPKxtGUqCafSY" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "immolato mummia oviparo sigla stirpe fonetico fosso appetito vasca galoppo cigno solubile foderato pargolo enduro sociale ormeggio galateo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "4d7d7262a55fba18c6521725d2e7d57d0152f6894b20289522ee299e7d823d60e4f28fcd91e44a345157cf9e700beed55e2d245383657b8574501ade0611a6c5", + "bip32_xprv": "xprv9s21ZrQH143K48iCupSpsXteUFAzPB7hQPyrCftbuDVFRxW1BHQf6AgTd7hZZWvgRVN5hJvLTYfdGWPGgHPoz99R65GhiurukDAjxvqjgge" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "infatti dire pudica elica camola deposito pudica nobile servire taverna restauro baritono inflitto flacone ilare suonare nastrare dito montato vulcano scrutinio lisca deposito mirtillo", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "c4712589ad960f5f24dfcd28e9b15e2b7ce3c5bc217d6f90eafc9d08b8de375327f5311cceea5481067a964d8d48fc21ea3f1eaf7cbbe8e27b08e2c2b981ab15", + "bip32_xprv": "xprv9s21ZrQH143K3tAAQw6t5RWBBRk5wqkGyvM5YMeCWb8Xwb1VUdpG8Rr4s9iN8nQUFAMvJuHdyUJAcWgc1upQXY2cCh7uM2kakEsQMUota2e" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "ricarica zolla disagio squillo eremita cefalo gomito bubbone tasto roditore tensione feudo derivare litigio gonfio", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "116800c2198b7b7d2e428631a397e17694bbde71bd8076c1fe13173e857538bbffa2b4fe539bca1c631e132acc30ff577bff06246feea36bd7b6039f7a6efc76", + "bip32_xprv": "xprv9s21ZrQH143K4AyD8DApU1SXGPn7W8LFWKMF4e4wBmNZoiVYUgQUU28pb8eGZeYH6Hs9sKjdVfKWt1cKSVab4aZuzGqhjJWqcgi1aKgYS7d" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "egregio tuta piramide fastoso sgonfiare rischio lisca eppure ascolto lucidato tale criceto neofita balcone sbattere veloce innesco esercito latenza fango turchino", + "passphrase": "nullius à nym.zone ¹teſts² Italiano", + "seed": "45503d7826c8ccf7cee8be6a00d2d11bf1221afe9271c3b4212f5a6f6860b78f160cb47c1305a6c508a8439cb9d86f19ec68b2720c6acf333bf6886a0add1e22", + "bip32_xprv": "xprv9s21ZrQH143K3rTkokDa2AB18t9JFQ9ieqxwbEZHZKACXBNjwGJiZWj2BSrLH8x6vmKhEb8XqnnUgpgdgWi3fmeygRLHUe16rc2hM5CL6zJ" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.ja.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.ja.json new file mode 100755 index 000000000..f33c48ca0 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.ja.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あおぞら", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "62fc5b9fa8172c3a6ea57ba02e0598c8ffcb4e81961dbd0813acf44dc7db369e06185415fd37b76bb51054970eece4ef7d6448b8a77e6ff978fa1e04aa87dac0", + "bip32_xprv": "xprv9s21ZrQH143K4bdkZK5DFM4GBTL8d5qGUJUQLeYLr3mpxRjVbc9YtN16BtHtGAgDCzZpuGNEVQFbjoUia1cC2QmNN9uzWyvejKzr8otjoif" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あひる", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "4ecf149d16b98698de079b2a7e72143a0c884a482842ee432b9dbed741279784288fd47427233f253390dfc417dcfe1df7be2f80e7567c914eadf633e575cc19", + "bip32_xprv": "xprv9s21ZrQH143K4U8WFtFEZ6GBr6JuPYB2E86RXEQmy1rutfdSyN74coTa1AiH6ha89NwDsP9kxF4pq339ppU9FZxsEbQQCq147GgM2oLY4TZ" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あらいぐま", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "5655d19b6e1f44c24244ed52899023ff35f661a2b5ff38f95c3d561094be21688714f9ee05dff886bf2365d8b2c548c7867e9bb60f895134ebf5a7489edee426", + "bip32_xprv": "xprv9s21ZrQH143K3jVy8yD5kje3euquyGLf4MeRFYkBkN2oukffU9dgkqLc3vz5JvCG6BSFQD1JFM2z9heqMHVGDpwiB71EwD81uzkrq8S8F6i" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あぶる", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "622f69030a9534b60e015955e9f0388f07e880df17b239dc200ed07a7d8d11f325c1b0f03a477437173a4df113d753914b9ca9db2c88115cab2736da0cda2ecc", + "bip32_xprv": "xprv9s21ZrQH143K3GpzUwtpQBYhnB9azGc8MoqcH4wa3xP4L8QNK1PAQJLBjPZqwu5Uq1yBYWgfEHnNULcE2F3hetQ1L61i3dbDYCMAfqj3L1K" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん いってい", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "f9f7f4d0a30285ac7a3290e9ea6cd9fe4006462842c9ad73e01a77ec0e318d26837bc3c5a9a9c3b963a1f5d7fd4a46ea6b0a7ac86207dd1ee008e26abb300fae", + "bip32_xprv": "xprv9s21ZrQH143K2BviDq8v63e1jGUS5mSfdkUjSTFmKTp7M4ojp6vcDBU1pHmmESD6Sq1HBskW6q1nNNTDi321GCEBsn9Xh3Xk3PCUBJq6MRT" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あぶら", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "89d24a909fbb4b7dcc97166c254eba63c158897908d281f5e9ef0ec985d5930fb30bbe508595a03b59d8e530119521b61bfa6581ae5acbc39ec8945636255967", + "bip32_xprv": "xprv9s21ZrQH143K3AfSC36z8PbjP96qGMQ1a61RWshPq3i4YFrkaGPPyzwMYMemtUfgzVzaWf5f2Vm5piyXXFeQsWsTfd96oFwxbtyWwVRgQ7g" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あんぜん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "bdddf688c225899e5cb16c84d8cc790b351f6589702b797c365d356b3abd567618273734188121d2689167ec28b3d2a735db637ad13ce2649c6ba688cb781a6d", + "bip32_xprv": "xprv9s21ZrQH143K3ZhWkXK1RY2pgCLnZqcSiHvZQpNUXFpDCw7EDLQfbXWEmx46LEx6XBoP2Bqe9YFR2PszgSkosoQpxUyuaeW5UawMveWERD5" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いだく", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "a2bbc448abef42b7edb8fea4cb6a4e2c2c0f3866851019c0dcbb365bb23be7248ef896837924b723842af2f085837d9fdee155d667b849542190b841a4d46cf1", + "bip32_xprv": "xprv9s21ZrQH143K3t94M4mJJbH92S6wCB3Uznv3L1EVX5WaHVGbo1ztbTSuyiJFn4fpstz1wCifk8DaS4njCVfbnZx7ps2k86dYQSC8tdmechk" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いんよう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "57697145297a2a3ae5f470759c77c12dcf28a3ff7f024e8a48352413047734fab4005ec71610ec2f1c593bc462e38c45b1305be2b1e9844ccab6764804a94bb8", + "bip32_xprv": "xprv9s21ZrQH143K2qocnFa1XhnfLvsSRbybSFuLrzoJgTnbEGnW8gPYQP2karroenGLbLF122Smcmn59oPkte4Je1pbmKBYDrd8DmSsJ6TEHVd" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど かんしゃ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "9eb4bb4b0846e0d5932758f849df2a9f7c6ddf3258b5676820f56b9a553b1a53ba1d7ff8ed5091cbabf556133c7c7d2a1b455f354bffb110169b22ffda069fd5", + "bip32_xprv": "xprv9s21ZrQH143K4aVxmBzkxrWZDa6a3RL3yNLwD3hHDDLvJwNLXgVsTkmao8VbehKPR24hqebmHj7a34AEXncBw7Qo39EY1y7fGFxHFi7y2D3" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかめ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "0e694178b4b8f880d2444018a7147436117c33bd8a6dc8905926b4157cbdce3e7ef6be077ca5d5a23cfbcf446add48cd31759865edd3927fd4dbc942e25180ca", + "bip32_xprv": "xprv9s21ZrQH143K4XRjHcmbM28vYX1fgfSeGnkgpLGBFohsLPDgQSPuvENmxCkDMhByouTUzrhw3HmSWxwurwigj9FhsGiGkED2KRyjDe5Hpuu" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか れんさい", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "50b9989e9ae761332d771e3650e1bc21072ff6a248adbc53e4cb41f916886697941cc778ce05a6e950e5a4eacb37055d1296596c72390dc143ec1317cde0fc69", + "bip32_xprv": "xprv9s21ZrQH143K3L16QUrJ1faHMKHpQCYeZzQtV8P8RPLatBXaZppNGEeEha8DHa4y2Q1qCCWzKiq5AUEVR2aWEv4gYyiQsW9N5CEJnP82tao" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れいぎ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "a7d2209ae96c89c9f00142379471a40485bad4c00b433dcc8d45281cd81027633b58e74fbabac331d45d8a9def34caa920b09463bd780ff13737ed91078f22e8", + "bip32_xprv": "xprv9s21ZrQH143K4Y1hE6272demta4GAXyX6bb4muBGU2yH5URpTSE9XMLNN9qXhfSxyGbVH5pBSB9wicZnnaCePPCnF8731xZSnvQkYe9Gf3m" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす ようす", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "daf8520fbf56655bae0f6b163a511b9ba706ac1a92fd83ed89ab243c3284ded518255934c96dc9f253c55015107b666d5d96a3da9a5fc783162e85622415869d", + "bip32_xprv": "xprv9s21ZrQH143K2wXjCLc6zfNyVS5iKVbKqbd8WbJcnxixrwQJ5tisB4A1N8gc6ikjAu3ZNUEu5W2JHrgqGVHPKGq37esiiqe4UeazzkWWkas" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん まんきつ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "096e815284e19d4e5b08f46a00c330c7c375d19a3fe063a70818e94a010d1e1889e88a7eb810308f625adf2e2704e89aaf65bb08d0316497d7308b893c7321ef", + "bip32_xprv": "xprv9s21ZrQH143K3nTNx8ftoY39YxeAzupwmSqdSxzQw1NugrYqDAJH7oWkWnMtqoguQguUbt291XyeqY41BBm3hA5BXtKGvdKPaVqHJanS9Mb" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あかちゃん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "490366170b998c6e5069118472d6a64d7035f9b53a4da83d5bf68ce98ab265b3b4a776f3381cdf5905d14892bad804dd5127474448bb8635936a87e7db9b7445", + "bip32_xprv": "xprv9s21ZrQH143K2LnusLMAz1mHJPhFL31WrHJjdXkoF2sqQ9nZbZ4w7vXGDw1eQuGhjkjhtsPsWKxnUbPEsgUvGVuPQwr5fATuTog7JKsdsCP" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あしあと", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "8af743ab1eafe407c5990fe4e7de3e2fc7742c192ec09ac6f5e807e1516dd4da685cc21a3ccc49b03d7c3c0ed93ac2e9113495f934c4ba321c98c559f1cb87dd", + "bip32_xprv": "xprv9s21ZrQH143K2ptuSWuqKv3yo9Tcm1f7Fk6pZQ4hcMSQGWFwRo5mNnhCNZjZDUooMuBjmRpZUCUBSqJhbaXccPKCy6htTV9NfXAZApBA3Q1" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら いきなり", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "14af25d73037c52c06cdf40a5e909e39439e9f528c399d65d3c23e4200755854b466999816a898571c16ed64cf520f749dab33c078fdd1e790c97861db0899c8", + "bip32_xprv": "xprv9s21ZrQH143K3rfNro1e4iRDKW6yCKDtSxjcmeTHuMjNsv8BSS74i4ydrBgPdm1uHTZ1GFo6aiPWWSuw6QZmaQeYWi7tWUZbGivYBx7F9uH" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いぜん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "c8ac15fc6c7b805b6f03509eaa3d05a70f9bcfb6c5d545c559294609060b2c72a6f1e56a8e6ef7250a5513778cda0563eedbb9521f1e4345191a2323c9119ee7", + "bip32_xprv": "xprv9s21ZrQH143K2ayVrrpNDpXkxYRHadfjeVewSVMRQb2kmfrrA17nXGr8EXZPzfmYaaZmByAgjU5T6Dp2iMAtf9gr3D2esohwUSZVvuXFbRa" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる いよく そとづら あまど おおう あこがれる いくぶん けいけん あたえる うめる", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "f0f72b6b6eff88a273d8b9676acb42f83440d2c74dce76325b1c16ad7eb2a32dfc2419349666e241dbfc88e1f595f01659a0dd875888be39d457ea3687ad59e6", + "bip32_xprv": "xprv9s21ZrQH143K2JsweaDj87HoVZWxQ9oeowPKkBSf6pca3D6g1hrybiMrHPFNm55CdW2xuLzzPotEHfuAPJJRT9m7p3gFZj55vi7f3Jy8can" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか れんしゅう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "80914ff73de8d0859728c54b26702fa33a2c63d21c863374e55e846ffedf1f514a13954538fdf0118d313277abd33b51afbeacd241a913aafb9d5b9b00969cce", + "bip32_xprv": "xprv9s21ZrQH143K3ztPW8575A2CuWNce8ph6Cv9KaxjTzCtE2fjcz6dumiiCABKPtssB7VPhvaGBg6ykpCjjiyC3ZRjCR41gnKhxYK6UzWBBBG" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう るりがわら", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "80788cd987fd5b42810209ee6f686c605345c04432e417abd1649a185ce68fe7371e54eca6b3eff77066cdb14c56b293b63130b0a44beb32747be39ae34e004d", + "bip32_xprv": "xprv9s21ZrQH143K3ZJKDpkvJNjgVhKDN6jUBjbwqsQLx3RAefJeAYDEVDMfdHg9Z7DeeorUq3yRADraWQvbYKMjSKmKzeaDt6KDtZ6kLMxq1jA" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす らたい", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "5e6d5a781dd44feb4c45aa456f48735242e05405c5c047bbfa0f28a5201a9bb9f70557f06a702804f343e00bc85856238da400cb19f14b5913c64498fed73f9e", + "bip32_xprv": "xprv9s21ZrQH143K38uU4gxWwjN7Ae63rKvMFeuuyfu9rTcaJkwp84kxyBSpPiu7fYMCkJHzSn4wkzYQRdqgeGB5yN9aYZBaF9jGAhxxkiZV1Gb" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん みんか", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "85e1e841069181c21f59ca0fdb9b975f4ef182225f95c419378c08f571ee3ab4e2803be7391f32b7d84a2930800a8c826dafae6fb11af620551b32bb9824fab1", + "bip32_xprv": "xprv9s21ZrQH143K414oPeFSvdbAQ9nr3jRtG5gFLQ6JcFdFGia7KXChDD9d5tEoTcmEh4jAb54iSwu9Dd1LfPC7ZJiqG8czy1EnPhhXKGQJpGH" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい へいねつ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "59fc94a1be1b3405da093c0655b0dc8656a471c5385831d8488e5fcd77005ab8af0e262dc2ba9f0fd82be5ef0996350b35122c4e972f2f3267176d28b999c4bc", + "bip32_xprv": "xprv9s21ZrQH143K2QyFQ2bvbWvGd9eHcvpimF3aPbJMCScuEPoEfMN5JR4y3L6GJ1M2veKNvbeJNAb7jjZ2T9rEY4Xc15e7bRP9X4g8cSGPiAS" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "われる われる われる われる われる われる われる われる われる われる われる ろんぶん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "6b5e2b1d3ce9a2e88a95c331d19b6d4d602a89a8bb165224225e5e6e25b0228eaac5833f83f827b3278bc32bedb5c272724d3867b93500bf33722801f84d1d02", + "bip32_xprv": "xprv9s21ZrQH143K25qZrhxDTnPR637GyQCimxaZgrgGiX4FHwafdnNzdfo7Up6x71s2xU6RMxzHckjdXgDrH1PCrTrVUcpGwJDeBMRXTqacehW" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "われる われる われる われる われる われる われる われる われる われる われる われる われる われる ろんぎ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "472555705994cfa9cb3838d0d1411cbdd05cb945033b4692669875f35891548dc442d93ac2a8d15e1b8b42f1285b595eeee019b9caf319b27fd3d1bc75ca8501", + "bip32_xprv": "xprv9s21ZrQH143K3u6G89Ev3W2rffrMvK2zJ2MwJ1inYKGXnHWFg6TcXgFzA4x3oSjQu1cswB1AB3enmPLWo4ioxBoCJHJYm3xJxRKmsQ5TZPN" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる りんご", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "753fe8c4f0e788758a1415b7e1486a168270316966d28eb916f392e1e48e3654b9c87f0a54165d9e8d68a8d02c604a4b7050020775ddd6f3b7e4dbe4871cc6bc", + "bip32_xprv": "xprv9s21ZrQH143K4Xmj3WcLFJzhrwZMDYjUPynLeLNZgyXAxCi3wZ4p3jDgmTvagaifETBjJLjsrrNJqHUHbwNtDVTYL8LfcfwSbUpGCHSqyKd" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる ようじ", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "b4ea9159204a85069eb1a59fed6197a12f7436a7e87a8c125ae0d30cfed1baec513d660b945c29175e44b56f4bb862668fdfb9e51bfde849c121c7e84f307563", + "bip32_xprv": "xprv9s21ZrQH143K46d27YPmtL6wcQvRTXbnPsDjcEcpTaFYs3woJ7JzZ3tufoj4ZiUpZsG7nET2ftp5tyYcum7YxxqG9CDqFc2oaDxtLCreHQ8" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる われる らいう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "58dac86d6e70ce29ca277ebea4da00efe162696ade0dff7a7436541263dd3450dc82084cd427eaee5c6ade8fbfe3c0f8c46121ad30b6dafe21af2d4cb764dd4d", + "bip32_xprv": "xprv9s21ZrQH143K3jb5dmYx4sPbHJsS4cithM6PbYUSyXpeG5muVbFw9XjV4zbQNELrHo6HQjsgkFzqJ9DCRjNBkhxwxZRpURAjBKvV7ajT2ML" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こよい", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "5daf74b7180ba3132842b927cd3140c5098a1f4c0a428af5bf0a9296c058d50f8ce5a7202e7584e13f9b82f0299476321f41e0f6fad044639532132c558eabb0", + "bip32_xprv": "xprv9s21ZrQH143K2iovjgr73F3nBXs1PtxWoL6eP6qw9RtBDqbbfXmvbaGGXkKBBDC8GzctXQotiohr9a4vsgfJ5Rfcb6BBz8r3uT8CVK2bm8E" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび とのさま", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "6988034570d17b564c206fac4cd28e32d21d0d96fa504572610ea12fd2f4a3742d65a56be6d9de74278b610e58d218e55752d99fdd37b6a44e8cfb9d9619cb35", + "bip32_xprv": "xprv9s21ZrQH143K3aHu3fF6VMTzGWFAEEEzdSVRs3NSRX4p4fAXVLuGHqGmWQs5WuHGzBZamcTRS4pkvuuK5wzjVWzePQY8d2qsUAtkZf2z8VF" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "23a65b7f39ccc3cf72b46cf2c6a678eb1370e4392c9cb54f3b2cad58ff07d6c919b8779ad0d7a79a45ab6349fb6b4570835beb88d09773076f31a3ef7a6b85d8", + "bip32_xprv": "xprv9s21ZrQH143K3xNMKRv6SjEUENe8nNePTeQGPgAniZsiuNYefCfnY1enUFSnCGboa4PJXphSadCMWPxC9bjDL4hvwS1Fje3ha2t4aEXzCw2" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび なめらか", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "48b15b9f394d88b8a38c0a9ac16d7cdcdb2aa7adfcf34204fef42adcd05234428d3f6ad48ae75ecbf9a2569c3ce5315222756a956f10df0c6e071709491b8b31", + "bip32_xprv": "xprv9s21ZrQH143K2SoiR65oV8pnFPJ4uACCUZf2JEKXpTQywvqja6xtqQEQQi645W4Q6ftLcE8sb2xaAdyjDrW1PHJxCiKefCm6hVrTdhjswqa" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる さつじん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "734862297b95972bd20b578f5b8cddfbc541dffb9633949a5158eb654850ef532373fbb81f1a62cb06792f90be8b0b4f6bd1d2d20f7d07a60f02ab3089fc0819", + "bip32_xprv": "xprv9s21ZrQH143K45vkfTt8F1dVMvhL8AQDUJDpKJw5XVnGBozTyb7eTYBnCh8Rn3jtBHQmuijzKS6BpWcHPqDCCfFYX7qDr7x1hCRrmGgHMtD" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ないこう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "7beee73c13efe33aa485ad3092f428dd81aa7d0908bd557cade15617ee1051d784a79b765ee337faea2862ae37dbb2addc68b0f65109c81da63dc80de461a982", + "bip32_xprv": "xprv9s21ZrQH143K4WKfx6rCtjUy4o9H8anpN76eshyNNtqCpVNhXqwjSx1zUDhwr5YcxPX5iuJFu9ttPZ128EsETPigPcAqu5H2bh95pR675rX" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こもん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "59ecc57ab519a55086f00c611b8812283500da9a2527a51d34bdb3b03a495b63bb9cd939509524a6f7d52c90248a438dae5ce98072ccec56ba5b08cee9e94a6d", + "bip32_xprv": "xprv9s21ZrQH143K3fJrnWRX1nZa5EFKJ58HuvqPCBmTbffA3i7uwrepnJWRKbESyZxeJaqJQnAqLgiRcSjo94zt8rgdKSsPu67K1cGRzXSUHrd" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ないそう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "4ca1e9196341e9606811a5de16e1919064283dce94c3acab8438faf6b6bf1c026d6db0c1db9f8955d41b3ae6134a42bec306f0d77214a01af08b4d0a11b1783c", + "bip32_xprv": "xprv9s21ZrQH143K3mA5jBuiD9W8q2bWrJEJmY7VFcQXePNiKUrbMizjUG76tUDWUpudD3PeTorenPDWRGtWqFa8gYp8Jr53zss8p3ASGwFd5Kh" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こもん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "ab1f45ca7c219e43d579e765e4e749c08613b0e51485369f2058535d7a3492b2852b235b78a5a0d8daccc799905c4d78fc98060edd6a7e2a70e089ae5ae97f14", + "bip32_xprv": "xprv9s21ZrQH143K3USt5wmMWsRbLSfmtr7JQ7af37KiQw5dABp3Kza86rg2fjNf1y6rbg22tnPrBkbPgFgtdJE1Lt3BhL1u5m6PqEd5HcaarKG" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび ともる こゆび にくまん", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "2eba136280d19de862d7be4cb0328c35b3244e6a81e360ebffe7dc9f8215ab2adb16bd9b5fc72a9d299b43bafc2a1a3b9baa985e24b61daa43a15cd05d016a95", + "bip32_xprv": "xprv9s21ZrQH143K2JG9NST7XinmGT2R8NHqwRgfuT1KzkpPNSUbCr6xQdkyaFTQRinXYEjv9dxBVnuxJHKdcZewhQuSKEsyFxU42niQ86q88aw" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "ておくれ げざん しねま こりる きぼう しねん ななおし ほんやく きない けむり けまり てんない", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "0615dd97d1faf733e8a5968ef543236eea6e582742af8f7516120ed7fd285093dd33b7c03ae442675da02b913cf8729667bf126d3f6fb4c4137ada8a5b08563d", + "bip32_xprv": "xprv9s21ZrQH143K2t7e6smJEw5h3yf3v6jGv9pbiJHhsDWsvsRpDQcyiTaQm6yXAeL5kWpJmcPp1QjWrhUSRbDgYr66CdUAXXMFf12kizmGh7J" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "しはつ たいちょう ちめいど ひりつ ほくろ こやく こんかい いひん よろしい さくら がはく ふっかつ こまる つごう けぬき ふすま ちから さくし", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "8a8c8ea1e91775e0aa762f85b54e015618dfd767f4ac2f4a2b53cb894d587908a2f161372b5aab529413ddadd4375c4461f4f9a8ff52296b8185a9dafc95855a", + "bip32_xprv": "xprv9s21ZrQH143K3MPmRFEQmYSNgSXrpa7T9jAhYmJKTE412tZwHzKYK6hB5DaHt3AtpiXEkKDSQbmkYRXrrbdvSJPhzNuyEFqGLRupP1wPTjd" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "しやくしょ くちこみ どんぶり けつじょ おとしもの くうぐん どんぶり たずさわる ひたむき みうち にほん うわさ しゃけん このよ じどう ほめる たいよう くふう そんちょう ろくが はんこ せあぶら くうぐん そっこう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "ec7dec67fa6f4d2210458440da5d83a5918326fb319d4aeb11817f2bfc166e5e1e752b42797df312068f1ab7be108f2d030124239a92dfc480cad3f6b3d72fcb", + "bip32_xprv": "xprv9s21ZrQH143K2Dyvj2KQuqbmye6qCrKVkxJyg2srr97vfhCCPcgDDe1mEaFyTnxgnxbc4fC44aRnBUvBKbvWmW71ycn28ZoQSyHBJ3yb6kD" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "にんげん わかれる ぐっすり べんごし けんえつ かいふく さんさい おくりがな まんなか ねんぶつ みっか こつこつ ぐうせい せいげん さんすう", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "983a1ddfc052c2113a2c63e8487154ab3e06c0891764da9fbc6abf0fb44945a2ca42084134b03b9ebb0bfbd3e15f9e5fd0a101f19e6f70327b15786bcf562bdc", + "bip32_xprv": "xprv9s21ZrQH143K4KUgjCWjCaF3qPNnJcN6KkfpNkRk2MzoixqCAhB3Emsc61qmBteRsR5rif5svNKbdZ9WDGfBFnCkjnyKJMDejYVUXJ8JaSD" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "げすと やおや てらす こくとう ひめじし ねっしん せあぶら けむり うえる せたけ まもる きつね たおれる うらぐち はしご らたい しゃたい けんとう すすむ こえる もんだい", + "passphrase": "nullius à nym.zone ¹teſts² 日本語", + "seed": "093dcb95119b38bf717bd2d90ff3679033a8193913d0c1c9ad9b7312d0cc765a954da765eea14c6c25197a62f2fdbc14a792dc42dc52f4fb52f1addadf2c2155", + "bip32_xprv": "xprv9s21ZrQH143K4PokGcq3gjhrwZsXskueq1vrKPDppF2fQ7f3gBDY581QHkKqF5NVmuwoLHrVXpmGHdmkPvakG3KxG4dSAh6x3yZKCHae5Vo" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.ko.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.ko.json new file mode 100755 index 000000000..4e4f56957 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.ko.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가능", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "a1aab56e819befcd802ca8f7f0207277e7b52c5d1c484cd80a4e7c61d0450b58f32f751f069794e10b7600954dc550cbe9921da626bc0440f0530b5b1c98a595", + "bip32_xprv": "xprv9s21ZrQH143K4PSLna2ShAbusJFUDGMRz53KP5Kmtiv89pFcGobxTpbPJ5FwYaLhBfmLeZb6BoJX818XBVfiDymuFUg3qjLKHh4TbD63w1u" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 갈비", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "1c227a72ccecf5ddcfe325c05c3285d29440cf31a7a30beb93ce1df6379c8b0a00f048bbee5b5c555a1dd16f018c79b8c326b59ae54a2a06fe635be11d88b2cd", + "bip32_xprv": "xprv9s21ZrQH143K38YAwMRhWw54RSe1Qrd7uVpApz7pxazaEtwskHMgPmJnW6o7rUQ1Vybn7WSdMVEJwLsZTnNKbFVRvUgPa2TyJYLtXi7BwaP" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 강도", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "af252340571dfa0131f7f475970555feb6a4206b479aad584e3a33eae840ae1aff7b057699620fa4394affc4976613e4f152ad1a96117125b79adeb276110e55", + "bip32_xprv": "xprv9s21ZrQH143K3h6mtwSX5FZqFbG97LD7wWiycf5CUzKwF24UG6TSgxKmmK4BwYUrX8PZ4Pjy77ZvdfT4GYinKV5FQbyg8ebmdPCYRTSxe9j" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 갈증", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "9450f7bdc77240878d63ef847cedd52ace8b5dd5bf536b84e0d2004b1eb23717015a36f4c0f27096975cc38e7e6a44f847dba4cf7a858e58905516c05b9659d3", + "bip32_xprv": "xprv9s21ZrQH143K2crrhJLRwLo7NsCoe5CdmfougR3rgLjxr8y1M2pBK4LaSm6kvbBiPBYQ7YZ5RB6T5t7f3Q35d3CMxPMzfAsfJjMybKrj1xC" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 가격 계단", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "6486fcaa1de0604a21be7412d7653547e0709d59f99fd7f0f00d322bc1d862717d5702fedcb714561f8414102c3239ee048f7cced4dfab6976231b239f48bd5a", + "bip32_xprv": "xprv9s21ZrQH143K46zyZt9zT46xWTEPB17x2L31UNs1PvQJUKxki8x1f6pMqgLds9KwomRQJSxUaMKfdNeZ9uhm5F9voWoZJ666YuqAjFU6qfo" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 갈색", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "6ccb2474d952b659a96e2d90f76994e645da1670cac4967d777699ea324da18d57ac120b94733f4980bf43eeb22be880f3a0c80b5642aa714df3316d17ebf368", + "bip32_xprv": "xprv9s21ZrQH143K3VQBXDRATcWuSp4jvXaDC7E5Y51deysFJ2hs6EZM2fXJs5VoL1LAiek84eVQsQb4zQ1vWynVfkhZe7rXC22Aj5ywtJMM2qn" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 개구리", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "5c33b1ad537488b043bb8f4e28056f2674e33d242396f704d5f25d8f68d3b7e87200444942f144c210e6843d0122a96d3214a58c3e35ca8f6e653706f6a1e887", + "bip32_xprv": "xprv9s21ZrQH143K3QaGgvSM5GHcAHNJc3a9Rt7EUP3hQyc87BmNbuD6RgxPhpYqCKDdpcLoMM1vnYz8GjMQ6ochtf2w1cZ6tNN9KLK98gQFQwj" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 경고", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "643b8dffbfc8545c31627bb84732c7f43da242ddec3e3c4f8ecf71b83587682f9b39c1071da99e635eb3c09aebf4f26068889b1e9e29f95ea8fc9d032157a992", + "bip32_xprv": "xprv9s21ZrQH143K2PUvomun9dYfxKeBKztXBPxqaVszR4Xky6GAmuCYvdsf3qBbCzmVtfMdR7jCVS7BmRTNpHR91DqJJTWMzsrV4EKAX25DbzN" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공통", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "bdd5f2dc652a54b3f674a719a0bc0b1e9dab9596dd08402b03ae5cfc3be7e6c3c071b5a2999b121ae141040b2f594754a1995ffd416f24b63aed867a1d2fa0a7", + "bip32_xprv": "xprv9s21ZrQH143K3M48Vw9bSTKU1Tkm7842XcCpR1V2PdXvWQtdtXbpt55H2BbUVvqMfy94jmTyht33Ma4vrKvxZufkKUZHrFqYLXqyKzZHXy5" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 담임", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "67263e6e5f1f00574119f2b12767a951ee182db5a274a3e914466514bc90b34918b6bf858b8cabfa467ad95cd797e2d3adc33b711e52266dd8168d1979913431", + "bip32_xprv": "xprv9s21ZrQH143K3VLD1psn871P6SSJkMpUiV9B2UKeumkRaS3U61dQ2YXAH6aDVG7YuMeCvr8mpTsP2LSHeSkDG4WNjSHiWC7mWB9e8VGiJMz" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔히", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "16e0da3c0f2372180c351be5ad922558d481b41bc85a0880fed7a71d840bde9ea0e35bc16437c35e91833a8058cbd3a9fabeec0806f5a4fd00e35d8d81949514", + "bip32_xprv": "xprv9s21ZrQH143K49NpTgmaYXoLd3AJcFyRUtPWPmwvu1svwtkMKkxyFXWXvyVpGVyxxFyLCKmFpCXWAZ1uzpVqaWr1N3uTudoK5w3nnLT2TgF" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 회견", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "5d5b517f16656926550816ac5eb3175b9fe4ad3fe18800c9beb65bb775f4e595b3cbde4de374f4a4abaafa2d5288556d83f729ac512e63848cebe530c5320b77", + "bip32_xprv": "xprv9s21ZrQH143K2DyHnkTcfpVaySZeJfdZ2k3zymtzugB1m8WJWKHVodUvC8PNVbSBFXXocpdHD5mYfYtJNDu2yU2LW6HVivsB7Lz1umGsyQD" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 환갑", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "30d50e373f5a61c5b1c51d181a695f63cc32b1d12463669439ae150d4aad8801a4e24793f4e7d4d7b6cff4d59e20b633041dbe2560a57929ef53296d7d8e38d1", + "bip32_xprv": "xprv9s21ZrQH143K2zCRW9iEnZWC31dGmBHvQyvPByAuhgBiKgr4coR4BP9Tk7u4QmuCYFLVjtPvVHnMqZ5zynJ2y2DWghgby62EbWLzrmKgNp1" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 해답", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "49608bb6978fe04467fd64a35d86b7dfd311ccccf0a7b6a979851ea239954b294c12c971a49a7b7253849a76557f0a2244e890aedd40c112da633899f153cb76", + "bip32_xprv": "xprv9s21ZrQH143K4D9M8ugTJ4bXaHu9eFyNbQNzvUchVJ2n21jKMiNPvgwecjjcPtGmK9EE4DD5fkiuvzyxTSauuvfETGfR7Qbun5aG7fAHptx" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 통로", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "aaf3a4658608ffa1732b8f70920ca86906f1f2874665e1ecb0d1cfba7f69fe0fa54260594f02fba6ffd664c32a8d16be21c8d16cfbb9141ccd4f4d53d2d0482a", + "bip32_xprv": "xprv9s21ZrQH143K3sKACtqnaAgbNne1H6CGQ746toDpbrkHjmTdrvWHydpw1QLG3QdtXZcA3rGJekh7ZtoPaHfuYJEAQ54xoyY8hUAWXuJk7nk" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가득", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "5efb2b6264604507cb066afb2ca584ba511c7fb5059dec67c256a04a956ccdf1fc30bed8df8b5f27dbf82d1cfbd17e102c2bc3641d95671b4960907eb0469f9f", + "bip32_xprv": "xprv9s21ZrQH143K2hd378z1qPgLg4zQ2Gw73SKYAjdQd9KMqNRVR5cgvQ7om9piEcDZtdBKZBDsn5RJ7TBM5AKkgGpkmFqqpJ1RzHLazswVKoA" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가을", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "2d756e45a4565df06e72889d2d9b4b6afc76a766049b995830990440be64de11684c0455f6ffba44f6e88e17d6abbab9304e3e2cba86b2af531d36fea4cb70a3", + "bip32_xprv": "xprv9s21ZrQH143K2jH6idboRugeLVwBYDums5gGBvJcDy2yVjXpNsTphjZnu8Rq2k9omvG9EruuVSDpGQarjVxfjS72QLEbjMfcahbyH36Z4jk" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 거액", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "13522740b92356d8ddb114e9caabd0d98c66a9a0fd6e8d0fc2dcae19c7ec84c8b28db32bf5c8e7308076b0bb0daba842baa8570157068060de18ca964250b075", + "bip32_xprv": "xprv9s21ZrQH143K2FS5S4iafhGPui8Z7e4Th7jgMyiZvc5hi8daNChKd8iDwj4XiNLt83xVboHPQprhkLB6s2hCy8P5UUQ63zRon8iFfxPYiNj" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 결심", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "a4b53c5c5a3f1a49bb0a213d5f38f6bbdb7c6685ed2bb3af0e4df72212b6d9419ea66a58b1b5c60b4810289303cb225da39bced79bce980c9d0c1298d6ac6b19", + "bip32_xprv": "xprv9s21ZrQH143K41xETuzusAwYvjfT376ad9beHoouGJkp1xdXMZ9LDWM65gz6u8916c6tDxZ4LgujMbUnCsJ5aC4EkTGY8inEscw3FQW7Fxd" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 공간 실현 감소 기법 가상 걱정 무슨 가족 구속", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "8807b10e91564b550e4c2455a9084223a771076a310fd6cdad440360efd41654712a408c94328a0936ac2bfb3d2bd24508cd4ac682e90737248a07316031f098", + "bip32_xprv": "xprv9s21ZrQH143K2h1jvqcuoCWBCyuP6WhZMvaMSmMv57h3QxYHnuGvxKfmq6aKViy9BFMYmkVUwygHMqZYYeSxDnvswV35LNguccSBR78FpaN" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 회관", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "871d0b90525db8bb9a311ceff96bc8fd7b077846cc75f7611da4b9446c87ed3e17c11d3bdf113f1ba5d8686baa5608a704970735cc72f63efc33f2ba2154c9f9", + "bip32_xprv": "xprv9s21ZrQH143K3KYLtQznenqwwq8x7CqWYhTpxQKnk9YrBK2A9KwTGqEDo7YP37cQkF38Mhys3zvjpMjqJuAcT31BxD87NDghiBMaeTRwJJN" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 확장", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "16a62b2f3ff9807640adc647ec994e9e14c0ad437e4e4ee076bb13c96003438a05553ae19103258d86397e8aeacaf1e181a078d815fcd4f3c960f596a7216440", + "bip32_xprv": "xprv9s21ZrQH143K3N6wVGiqbKqXN5yg3nSBDbQSk2oqwKSfS9M4yeHVu8PywHAmnuvz7TBAuBEjsZi9rcQKP6bdfvBeHdYH2pfvwDXjXkvx4sp" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 현재", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "80e52cea7a129e59359899f611349aa662c029892800fa1cd291b18b3519927745329d7ee8b1928650e2c2763b1347cbdf8aca1c8531531f7c9bab75e204303a", + "bip32_xprv": "xprv9s21ZrQH143K3uAEN5NJPYtmtoZJ6hzoJTnkGxdsCs59BNeUWaPrHAuPARbAKkWrVVPvJy7C5KieFZ7kvvctN4zvwHYZ6B5KvKXWNxvJED1" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 팝송", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "578f78a8e9570192b3ae54a28eeff77905e2403be5aa29a2361979510b8372c637bb421262312973470511b815e2819d178ced28ff3e59b52b839c68c7e60744", + "bip32_xprv": "xprv9s21ZrQH143K3oBz3bgh4G6Pm8SSm8FrxXvaPfKpD9qQxZ7frJrggAiJMPPweMszZh4nfVNpVxFYRGWxQ2TmY8hYrCTiacn8Ltf94vTgr4E" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 큰절 흔적 형제 제대로 훈련 한글 실장 활동 출산", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "ef0c19cff9a43f736c3d8ab375b0a2b7a8dce7f0fc426557ab26d5efe721df86c64abe298289d479f580ce41cbe2cb989b8f8f1876184906b365cc5a85efb612", + "bip32_xprv": "xprv9s21ZrQH143K2t8GeYx8EWXtXYxs8sK4g64WamvNB99H6wCgRW9dgcnA48YaJgBH4HDAJafVrEr79uHaQQeXxTk9yf1C2k9k5FKJnfhBxRj" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 흑백", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "4cbbc2afce579100a49b150c78dc0791aff9a9b7b45b44b5b4317d8c5fc9200886105f78197ba90a32fce7997c3ffea47462eaaaa07434f4f9c8e021dd705dd3", + "bip32_xprv": "xprv9s21ZrQH143K2QHYWzR5LBEBsUhXnsY4gGdh2x66R4GKkewAmbkAVDpCF32Fmkt195r1mesE7Pg7QQzpD6A27CKT6PSCY5AUAooQ5gw58AD" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 흉내", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "67b4f51e1850d58af6005016a27ff27b5e7cc3b601235da600b98e1a43c802664a00927fba828d2f9751c249350e64480439bbbfdc6474c796029769299d1651", + "bip32_xprv": "xprv9s21ZrQH143K3hxQeUHREDqWsJtEKwTd3WcVQqbwLh2p93CbsjHGdBGJCNP4X9x4WQfDBt7Ji42AuSb6c3yLCBYoudZZ9Ud22HJkjcXvrCw" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 화살", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "1de9549e012e0db31be3291b9e22a0819a649e4cb45e3cd18301543871142c394f90eb7f2721a4952179afe5b786e87dd67d4fc80e88500ae632ba493c75136e", + "bip32_xprv": "xprv9s21ZrQH143K39feVk1gvyDUX12MWytbG4ssMQFhw2kBJvoDZu8g8SxFW7wTdZb4AYCEuAgAyz9mT9KhZvv2J5iE2iBpd22kxNcRoh73hD9" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 해군", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "564cef4ca5f7c79312e8c19dc74274e2838b4e3dbd0055166ff63e9e9b9a86dbb62d042115cf26a0b84906fc234d42e70981dfbe14fb04b2c552d949ec24258d", + "bip32_xprv": "xprv9s21ZrQH143K2nbNStKe1HuEG1pc8kUZ6c64JMQ7AHD4sWFy2oM31Mp2iqK3L2U2E7kJh2hUXbCL3hzRVENUkQEMeQ6SF8VCsZjNv2mCWvq" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 힘껏 허용", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "f98597e3ba0c15c43715ca4d84e210ae5c719ea7df25d50cade9ef5c4ee889b22bcd149ec9944503625765bb42f1b6e2f19dbe72b609a11b225775d81b9593e0", + "bip32_xprv": "xprv9s21ZrQH143K2uniuED4SUorsQtLR5Gd9rYkkJ52ScZjmwA4XRGccAKtQLBgM5139ny66UgzNvK4fqJPdVCA6UHunvhgs7n47cPR26YsoBT" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부문", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "a91cd7cb18f7d07d74ed4976f78f32843e747621a7d6e885e3c9532889912fbb9c708515be99d53529ab8f373ce512f3504c4708c2d6a69fb24be7ad557d6a75", + "bip32_xprv": "xprv9s21ZrQH143K3t1f8Ri4BJ15aUk84ATTCK1kfrrkP7conWVnaVpjvWCn9L7M8oWu4bBBJAKoX9VDkaZWJz9zFC15CAAspA7xGsof8j31zVM" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인생", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "b982468dbe91b78c89143e99b251ffd74e7153b0c5564cea520bf5f669f570dddadc660652b6941358388ddcfd412cf44a95c7569db35d5a931b6e10a8fe5cd0", + "bip32_xprv": "xprv9s21ZrQH143K3NSM8gMEpHJgEcGwx3NYGpmrqMSFPPLGPkcf5PjEKJ2Vb4GwHRGaYLvSdEC8AtHHvHh63T1zvGb34G86ELDt4s37hnsWwL5" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부담", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "853fb5bb6fc961887f8c1aec9a1170c0ffaf5af32c412d95db3ee11402b12147223f2f78ea8caae48a9f0b6160cb26208d4dd634c2b7b31fad1a42b02a9d379d", + "bip32_xprv": "xprv9s21ZrQH143K3ty7yZpQX5k98wCSLiQRbgqCvuban9wHPfJ5Tk1wH96NvTivQjcZvnG8jGrx1XZaCwJsh7kVnfFwMNaYmr1YabxJx7umpEj" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 입사", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "bad0982e05abc064a91f49aa8bf996226a5578cd4f08f58de3ca8e9d96197e9c115704c5eade4d4ef19a97e88d0cc7ee9eeb7bd716597a00772a5a0e3f416c79", + "bip32_xprv": "xprv9s21ZrQH143K2HDnyrz7TuWLTEqh5vndkkVDB5zf37yyYyarNjeBjdZwDY4MCYm2gQugG4jEBDHmrkGz1fUERkpPL6VFWjZDSmqGEpfBGnt" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 비판", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "12e619b2c0e2bab74c49c1002eaddae3471e8e1c41db6fc8ca5ceb1fd1670f4b219d9469859a00d46eca71e829d05598da80ecb4cc4dda4dce665c92ec60b22c", + "bip32_xprv": "xprv9s21ZrQH143K3h8VBeLENWfMhFhrkXukmNy9rnrNoSXdaeFW7JVQ9TGtXAa8MwQHkXtUmYgVWNirj9HdDauFeEpHF2oT1H5J3nNe9ToVL8f" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 일단", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "6fe383ba117ea723d828ebf266f9feb78c186bfa752a15c8ae59a3f6f12dd5cb4786fd8ce1393d4fd1987c1603556d42da371d7ac771dcdc609cbde48813c51b", + "bip32_xprv": "xprv9s21ZrQH143K2813mNTGYRL7ApLs7iuuouBZQ4ygoZa6xXYX8N31MwFJ2FvHckhCGgGjeRqqEcsgbdohahLzDDxm7bDWojtBcs92NFhnanj" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 봉투", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "8befa8bc920ae3b3b243f3e4d696146531eb943106fcd12fbcf79749162854cea3e401861d466874fb5f04bd2d571b1f3cc5a97f17e01406e22dafeebe134bfe", + "bip32_xprv": "xprv9s21ZrQH143K34Zwncmc5tVNZx2SYxvoKD6SfFtqKEmzeteVWWcj2eNCHU5LYPYjP1N6rLksbea2DpU65kWmpjxFvnkzV1YrR6ArNuYaG21" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 일본", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "f7f6547088ea7f6ea3250b3546cb574589070b996c295f22e9a1faccea44a9b7f8a521b0afa2d910c029e5ae128509558a1b458e0a11006690c09f5361b8e27d", + "bip32_xprv": "xprv9s21ZrQH143K269yuT54wNHRBf5XT4G3KpdaKZaiNDpu2PYtFhxaaSX4Svw7ryhw576fkZEtk7RQ6YPigwNAMSmHCHwYsyrgFcHvMfUUtGH" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 봉투", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "53ff23877609b4d1f62110ad5b80658a9a5d70415bd80561b540a145c63fcd6dc2347c5298186ec61bb52dcfc2ed091704f64f9d93de4ce38fe9c37f1a75777c", + "bip32_xprv": "xprv9s21ZrQH143K2faVjPsTyCrinakSy2JEZTgw4odvDt1CRBroq6SmHQpFkcSjAMMq7s3PMvwCRXXpnhRZ4xFhnTNrq2oczHCHvJQ8bprNFrR" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 인체 부동산 자전거", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "ae2d2e2e8fb6a784b1dd54d546da729449c88a2a77fad1ebba491e8ca3c1be56917d78df5e5f729f178f4f3239d9faad20b04fb6746043f34c1ff4bccee333b1", + "bip32_xprv": "xprv9s21ZrQH143K2UxpeCzkUn2MNv9HFQGUpYkSuWG2vVK8mxJ3rFMnSe3eGCrSv51e8YoEJz3LDiqGvUj2jZSDfyaCgQW1qnLdSmhLzjsBahb" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "원고 물질 생일 부산 마요네즈 생활 일찍 큰절 동화책 반성 반드시 의식", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "1a486f863d97d6a37092fbf733e11e381c068d5bdd53e290252fc387240afb91a53df0db9a7395fe07991ac840a9d1622599cad316b29e4e843e01b97c596aca", + "bip32_xprv": "xprv9s21ZrQH143K4aUK3zhGV79DjVGuAptFBLizGyQswzKCpj25YvqgAtaQKkbnB4ymJn8q7YLoerXL5CeXcMVx3KtbqH59aBUvXMLfpWSjCs6" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "서비스 알코올 오로지 착각 카운터 부근 부정 고양이 허락 비디오 단맛 체온 본인 완전 바람 철학 영하 비닐", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "011cc2166a15833f22d09f75d78e6989c10db2449d1c183dc7a0412659175fa0912a74761c2c7379aa7a23d4ef88ad4d9d7b427e1b32c7eac2f4ecf282538092", + "bip32_xprv": "xprv9s21ZrQH143K2hcbLcj2G1HEydsApnL3epHBETAXmUSW7dN5zYaKHbTU4GsNK75Wvu3igW4zp19wZwCQRw5aQMXjo8H6sdynx9knVFvsPFC" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "설렁탕 모범 일곱 민간 낙엽 매스컴 일곱 언어 지진 통장 잠시 국제 설문 복도 생방송 큰딸 약수 목소리 아직 횡단보도 중독 수필 매스컴 실컷", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "cc8bad7e09efb0c0ea0804d024c25dd2b52e212d46f5d9b07fec5610f03fff732974a156b1934995ca18a39118fdeb28327d7bf44cf9655ab52fecaccbdf5314", + "bip32_xprv": "xprv9s21ZrQH143K3S22FJd9AhoG911XXDpEfqA4Ss8xDLgZevTjDnB2iCScnB4UwkgDEbeygqP4Yodxd875pZdz3wA4R5CHjNysiu1NxQ1RdLc" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "장마 흥분 모임 충분히 받침 놀이 사투리 기준 통역 절차 특별 보너스 매장 수험생 산길", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "b679457ff480a029b11070fc499ce187e492bb444347dc1166f3c02500a2eb58f2c2ea393d5a58b9c5fa62282351155f38ef719a14b6e1e011ed25bbb5bb8363", + "bip32_xprv": "xprv9s21ZrQH143K3akSsiGZFMMdoahmioCgPNRiD6pTPqkymKnvYfKQ56WswJ2vHd8h6xcyhKBvHbrQdJfiW8obqudWcs7CVZfz1Ku6NXBdEeV" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "미사일 학비 유형 범죄 차남 적응 수필 반성 공항 숫자 테스트 독립 양파 국가 조절 현재 성공 발톱 손질 번지 학부모", + "passphrase": "nullius à nym.zone ¹teſts² 한국어", + "seed": "0bab0c576d7dd9551c370a43f428e86644109abb99aabb72194a0aabfd58b26023a5b4a4f1d13c49e1dea4974a24a5c1fc8e39d7d6817d057b6fe576bb821450", + "bip32_xprv": "xprv9s21ZrQH143K4VJoApYtMMofhJUu1Tfd95yJYxRq2Ejpd2G7gyoiJLW6X7HN8BDFYms3fnByAbzn9qPhBXmH3XoagnZWLR7PhbFMDVZT2tN" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.ru.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.ru.json new file mode 100755 index 000000000..82d4d47aa --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.ru.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абордаж", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "f3efa28c32fccc90865a82f5a53248d487a789bee332cd9a27a73f85b1b5a9291798403a45e26f09136324d563a4b6ffedb3aa0b872f3072aa2695f69e1f3039", + "bip32_xprv": "xprv9s21ZrQH143K2n5bLkMeqW9QNVt8cNjHoRzLU3QyUPGLm6vZj2g2cPrCnVeiu2LG4ukScnekMEvPrTFS2khLQ2Fu1S5MkgqWY4CA91wHN1W" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур айсберг", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "c6942140871a832443edeee7b89429275fc490686fbc5935d73ef1b61fe8df475604e1c40b0f739a77722d8debb55a34058ba75202ed912a9144923bdaae3509", + "bip32_xprv": "xprv9s21ZrQH143K2sPZ9BwnJszFCyCZumrJB3ShSNXqxGzaQSkjRbDGw3rmXTngQfTVbAtQdUNNfMrWUYzdkCXkidtUSN9u9GR9zNMNEng8mLj" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур алгебра", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "775a9dfb00ab8a5428e020438ba4c1dc3aad41fcb62f548e22b9099268a0112841dfe6e31a959c6a52fbe93c29b1ab045f89e6f4e474ebd8b0203ae183229f51", + "bip32_xprv": "xprv9s21ZrQH143K3qxqUGBLaG8MN4k7i2oBTz46wZT9ZoyjCJfib4vUFCoM2nWekjkvt276bZe7o7K94w52qFu4MjQUtU2peB2yZK5p8rPUdJ5" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур аквариум", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "bb021fdce52dccdf29b75c778591ffcb89f3f7b485f834c2e6dacaa1107c0e82eda13aeaa77fff75f6314e7d55e2974de67ef360df992aba69633da775e2206a", + "bip32_xprv": "xprv9s21ZrQH143K47QEoTFRczVHARJSo53Q5uMWsfBPxnZqo73f3GH51bxpBDtQEtziW1sGbXCYvFspvKBTBzzyGNdy5qYKWkgAGWZF3rreXfR" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур абажур афоризм", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "b1a55eb90cf1da6f1c8ac039c4902525dbdec8c43e17af5d5926fe1e207852d034150ef30aeca6b8246639c51aeef57a8d2c52812ac8429251006b3d2f808240", + "bip32_xprv": "xprv9s21ZrQH143K4BLCoYUGj97sH3QsDhYD1K6iubymee7wtQrZfToZY1raZcuhzJrY4vZSCUFfa5Vo9hvrUtUvaLo55rMC7VeYGDoAXn9fewc" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "август ансамбль драка адажио батон мера акробат версия август ансамбль драка академия", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "17d178fd57c61fdcc4aac25940af1f844954979ec01aa64ebaf07c2ca28b9457d91de4cf2b66bc3ee459a2075fb3f02d10b2a40afb083ec62651e1bb9f79b58d", + "bip32_xprv": "xprv9s21ZrQH143K3ocipedXPYp4QE8kupWV5AkFebpVJSVZ1K3fDDmgFmrRE66dCAF1vWrTsKd1ajeFT4Kf1TZbPWqZsYE8KJvVgQS8kuxpbiD" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера амбар", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "0b85493b219806287ad0792b9dc84faf133bed2e3bd054bdf3721cc6f3b5a35cbb122ac7b6bb9627700cff08334b4b81e1e834a1c4abd6e2bb1df4c4042bbc8e", + "bip32_xprv": "xprv9s21ZrQH143K45yTeU4AnQsyhWCyfM3WcXis75FCaQVdoS4hgFocLtnjw34VpCsHuP6iBEYKvkCtsgt55fka2dhFHKmRzgkniXfj9JaWM5w" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат версия август архив", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "b8914ef5d8acc3f59acb94d78e5933c4ae8007a37d1baeec0b4b0dfa7c4e1a4587a324bdd4b43a8f59cc878323d36d27a178f9fc41ed9d8d7c3a0af26ebc3943", + "bip32_xprv": "xprv9s21ZrQH143K48y6jKDckZ6VggkqwEywm4gvKtj8XnDUk6Mz3v1tVeHtT11zC2heNceSaBVJJ5m2RDQVKyjuvXdoEuvw2hwpu6GkuZPXqh6" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио берег", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "b7dcbd5723daf8aded08823768e8c9db8fea674f881a174b56570b2f02ba397dbc54d635c629fb8616647c79c3b7bef568e0434f1f9a7301048a679dad463cc7", + "bip32_xprv": "xprv9s21ZrQH143K3qZDAXUeFj76Yh1a3b2K5rodJhL7fAYWjs1ZymG7SQMYXrV6JMMsY4uU5ciDQFADLWyTzw4NuhwBQaw7YzCSp9Xe91R6gd1" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат гепард", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "1089ca1a34071e79027b316445bc9db494e3a9876f00963140a0389784f144fb667d7c07e8a9512cc6930a5a8c5d269b49370c4890969d00b2457f0eb6140b45", + "bip32_xprv": "xprv9s21ZrQH143K3cxyQRk4ZxmsPX2REGLuV3J6Gmap4C8YjuL1DWRPcS4HPbmjiBPjxxZNoskLKbH2KAC8DQmA3ngcf14WUBP9fY1cranLBST" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярус", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "12b0d2fe62108e60275868147c5907cb320d950f7870ed40ab6cf8329a88805f3a6773c759d072e4ef8211a0f306670ab28e525b4e18f1904ea24783fc1b4dd2", + "bip32_xprv": "xprv9s21ZrQH143K2yRii1P7UErbWbRJJUAZa5AiVbVye4KzRqut6CRitHZxqJvSRyfmPBjSSSgcupvsGhAJrmJnMTrSuKUvT6rEyqcQcbkdizv" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба эшелон", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "03c27896340255ad6e43033d4fd6eb1314cead2c4f3f482d32d175f4f95e4542ea2ba5e1d0f3db9cd1ad84c83e3645d5c7c2d786f5578468f1744592078c55a3", + "bip32_xprv": "xprv9s21ZrQH143K4NRV3imj8Hi5bZ4VK1Ei1aPxBjFV6XAtH8fVzyU2tva681KoPhUQrHp81qG3LHacT5viv5ynepDp2CPS8Fd6yA5hkqMbtGC" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина эпизод", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "b5511027c449ef565884fc514f4b92f07378a5edbd081d5f9e0726727fa8102ff4651ac8d643171f75c5f8a4b93364c548cd00a024374e31ff41546ce3e9a9fa", + "bip32_xprv": "xprv9s21ZrQH143K4CVQxXcCJ8RBW3jRYVmabpWVnbseNhYW1aCsdLVhw2ALxs7wN1DKxDecSdoVX4HgQ9HvWMxanazpniDMdZtMmSNmzAwkuoY" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость чеснок", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "42f5671705c84f935678d5b946b76f60356de86717ac774e94c1601a38456448a773978896e5ac94d8bd5c7ecce6d1c3db785861fb2c16ea6cc85bb5789b9d9a", + "bip32_xprv": "xprv9s21ZrQH143K2HUeV5PY4MdHiWqhKzEYmesRrDJUXih5BpmcT1263ehnd5Zp4Ei8ZtKeFms2xMdPFcPd5MYDMid98g2HTeknUKsqEZnKuMp" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар улыбка", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "6d11fec7dda8917cf0fef6488f046ffe5af16895d33767c7e45229e08d5235e4d597ef8946c438fcf9a25f5c72bd21dd648f231d50fbfb83e47f87ac263c6f1e", + "bip32_xprv": "xprv9s21ZrQH143K254BR4wXnrY9oTZtQFgy5dcf8eSBvwE9pR3XnoPeiThy97VyiP1spEvYjPJ3aDGNR8Gcb4HQMvCDZdpFGn7KeBssdeRJppU" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "мера акробат версия август ансамбль драка адажио батон мера акробат версия абрикос", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "a2d7be1dd1a46718544a63d25f77b9c2961eb74a3491bf82ee8f7081e682b39949bc364f3edb1eedc417a43cabd92584ab6792cd84bae7cb5022986cf6de74e1", + "bip32_xprv": "xprv9s21ZrQH143K45oPLZWkuPLzES7Cf4aJjEfPmDENnAoru2oZiYXqQxZ3TqcB7T5q9NuJ5KSVFnoyncFUqq7tVACcmQ5X9mVnADgDRWpYjYy" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка аврал", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "1ffee57510701716ecae9e044f8d4a45050626bce7d90d99c44347ccf6c452898c87b6d6a00b9ddc8f3602cc80abb5aea8ab7bc0ad3d951ea505bc3cb4dea700", + "bip32_xprv": "xprv9s21ZrQH143K2D7aEc3SDhozGxsktVrehDbTFUBXa739cbuLk2jrQSrQHZArC4ftvkezVP4wtbPiEbUeD3xDoZT6dEp1r3GtYwVbJjGxmMG" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера анекдот", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "4cc288b3ff44d6e8b26553e7bc0c68bac71b90d8ef3d9bec85003833a3930530046b8fe8d10770caadf2b1aea0e94dbe134583a5ac06ffa48e643821363a24b5", + "bip32_xprv": "xprv9s21ZrQH143K4ALDYteknpwMeEBoZgt3my6K4jd1WFiEsokqehvdpqETRWUPSKyo8QdSGRthhvbEmYcK7KHkKqgV4U5YUdb2Xu6VGFcYNEv" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат версия август аромат", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "e9ece339b8c9ebf2d36391f5c89cdd66e97017fac6ff19948ccdb9fc6effcaa09f0eeac63a86b008d114dcd99514c5a699219c1e611cf2f4293fd150a9ea1942", + "bip32_xprv": "xprv9s21ZrQH143K3q4V83vjtKETxR35Penwze1PvFZmsR21rDF4BRyYJS3j6FyQkjEWjHVLbEunTTB1qe1jCAZqaKeAhZiHV9DJKFAQ9FZRxsi" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио батон мера акробат версия август ансамбль драка адажио бревно", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "09e7c2d02658d3dea7be035368af80316ced29487e388f4ca81d81f893b5f78f57f2173e943f598f21eaff5d52dc4f7307e91697d1590ccba611994c2d9ee9ba", + "bip32_xprv": "xprv9s21ZrQH143K4ZVcsTJRtHTfRX285bvwJWcQvTdCmKkBrVSvB9pLXMEisAWA69AjLkqysXX8ZnUEjWaoZLb8cXiqUREBfUwQR3JxaTpuSQL" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба юбилей", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "8ae7e497c2830d77779e7c145e225b1fdac469a711181c47a4dcf7df362dbfd01d76604128dbb8e2fc69221400cba7e728f3fb10f38eab874e454cdd3fb68be4", + "bip32_xprv": "xprv9s21ZrQH143K46UAGvCMhDiVDRPeM5FkmbrHmwMbQE5aPKD4B9qPchHzfwo32PNgYfCan97y5eMTTqvDRUHvp4ChFL3TE2SmVYs7LVQPJEW" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина энергия", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "c831dae45f046e6b9441f9e36e62b27ec6a848acfde3124dee8a6a7f8c936a1e2337d08b0db6a7b390ba6ebd6104d9594439a02dcb759a4aa9c880a2e3df1b43", + "bip32_xprv": "xprv9s21ZrQH143K4Mwg3tvgWyMt1zKytDDYoMBKJckYMFgNVHG5B3unP5XroWCsrZTp9CpnyUgDmmkc4UJdzjYN7n4GtCEpLPzfZBfcSJhMy64" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шкаф", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "dc7d6e2be22d3a578b7791640726d80511e8ce88afce45a3574c6049839cfebe6b14a745fceb5ec77e2cfbbfce19d5c86b1e6b87b904a40386cf16775f2919fd", + "bip32_xprv": "xprv9s21ZrQH143K3Z7oBTuYic8gSSYqoAZ5s63VJE9n2ZVj33K3Nn4v1WGwe8XXFRtts3MmfmcaxKMjWMdGTgQg1RGyJyMQvRcgBmyVjv73ntc" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар фабула", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "904f98663e1ba59a2c7b1a13b12013fc7b3d2244df50a04ee02acffdab10a5767b88a0386d3b849888c9fe41844907e93891f8701510cc484ee9e85c0109ec55", + "bip32_xprv": "xprv9s21ZrQH143K2UA9FLFyeMEquczhYuUyD8zapxGnpns4pUNKqApvVjXkihr1RgCiuFZwzNJHTt4YWgqwF1DpYKHxsDgh3fAgWBrdihevVBR" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика туман ярость шоколад рыба ягуар целина машина этика текст", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "56d1e292407057602d099d362f33bda32976f71572d2b8b09a625bedb577af131b55dae043be59a6623ccbe39fcca07c2a6213bd5793b10528e2165318640d4b", + "bip32_xprv": "xprv9s21ZrQH143K3tQbgTJdMgZ22ZVdBAaGqy62PCfiWsnjrZnxH51wT19XyYP3EBaDZajShtu4VidsWHrAAY7M8grgtRySK3rsRsSoRMRiBtQ" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик яркий", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "532b63d62f1d83799bb98a9a6442710996de11d288609f736a279c470193c797661fcad0ddc24cab1e68f8b87adcf52d7d5899608872f73ae460ff787d95a334", + "bip32_xprv": "xprv9s21ZrQH143K48SWrVQWe8dtXnfLBVzRk25v4mTrnw2KenhSJfcd7PyuEHegS4NN2j7KPbMTrdK2hBLpQveLe4Xb2eqkJVMCZ3F3KGQKdNM" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик якорь", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "8aed5b5f6125fed141757407b9e20c58f12dd48eea4c111021354086791675e4329475a2290e8765b12d51b36754c21180891dfbd02fee20b44bf5577dba704c", + "bip32_xprv": "xprv9s21ZrQH143K2Vt7foXq7mqE13gyy9v8a8cXQYqPxMeuUmAQKNk5GcM265f9JeHnML1fGW6kEYwL8xsBJCd7rr2TbW2c843hugoWfXmqsHf" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик экран", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "7193e25bef8cd4192d5d3b631b2a59efb55371f0d1cb4f4ac201c1e4c1f79ed292b0dbd674b3490eb730684bf4a8c7e21a77853209c792e88f40fb668e8562a7", + "bip32_xprv": "xprv9s21ZrQH143K2GmQSF6JG2yjXU2EVZY2biu9T8aKeUHNWrxAT4qPN98B8J1aWtUN5r3SXuddySZxiJEB762RNozoV2JpQiidKtcZHuNtdLe" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик черта", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "db90c4e129ec5f70520873828c75501a4a4d35e9089879215838193dcc94d474db8f2c3ccc13d90645785bec008357dc32ffc196a48431e948658138260e8c53", + "bip32_xprv": "xprv9s21ZrQH143K4VFtCbCKnsWRJ9yNpbVYADHmZLQ6u2kc46mNzGbGKBp8bd9bUBQNyn8hKCLqQcJhq9mrZNCt6SAPDYKuwgHP8gZHNxGE5ng" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик ящик шатер", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "7a8566e3ffaee87816c830d74ed8065f7137c6857094d808cbe14a298da5c82489da489000360a844d3f3a336e6b4cb4e2427e415deafcf838c20e1dd0ef8a8f", + "bip32_xprv": "xprv9s21ZrQH143K3aqdKK5aSPBDrSCsEEx1GUyYkHUvwuG8WLXWxuVVjRoC4HKdwmCpoewrGoaZHGkUwR9ZiHEQJ3Hb4AC29Zakoyz6rQ9syjf" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "пони известие пони известие пони известие пони известие пони известие пони изгиб", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "76ea1a49f9a840e03e443abde35dff033bbd8b26a369c49aec0bacb0e210e8e48ab39f91a8287a806af85af7919b707c934ccb09a38e0959b65618d6291e9387", + "bip32_xprv": "xprv9s21ZrQH143K2SDSuxYg5c9tr96Niv4kjmkTj4XqjxehiSmyvmKh2LVSwAis3wn936Bw3yRNBUYRQ2j6B1pvmmQb7ZTTEQGtUAb7nezHT9C" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "пони известие пони известие пони известие пони известие пони известие пони известие пони известие получка", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "3f53feb954662fb5f17d3d3c964246589065f5725d90061cae7c0f9adb74c504173c7bb0fb919546c774b8c726935bf5ad00c128456c3bc56042d2763eb0819b", + "bip32_xprv": "xprv9s21ZrQH143K2HS4ZX9n18uESGo7qtcnz6XERipvdfvYW6fv38W7HfUvuQqruUmZiK86TWrFA4eVxAhaPQLHhQBMBkja4LVMwe24fWSQkhL" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони изба", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "77d0a20e374bb786e1f047bd5c5df9e518d3f9ce1a3db3229c88d59e015605d8d52cb516824984c1c676b9a87038087397c46632b906e28331be5a5b6a43dde8", + "bip32_xprv": "xprv9s21ZrQH143K37xa7U8vox1igr9LjyiMMhKBYE5uL3RckPHhw2fN1M1ViP6kyDfkwQpxyBADXa7bqHVoxFzNw7WTW8jrHf6b1GCpJnhLR6R" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие привет", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "91ef9351c97b3aeb0d06b312113d5e8d24641d04bec1017cd4e093f26d2b36d34215339ca0407ef52564853493b80b3401e3b3007e5ac6873cbc0dfe3030b40b", + "bip32_xprv": "xprv9s21ZrQH143K2pED9kc2pqAwRvooFPUGY5gDafQQtnUkGihGoEvS2HPEhcRmrbjJKCJhDPehpsUHsfZarREN6oSpRroZ3kEi5tVX36gmDVc" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони камин", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "e453c50a03e7424b0304606e27494d2cff879a3e9e5129ef290668ef624768bbbc7737328a1d187301d9a299b11f3378d1f17095050777061c960e1a76926b65", + "bip32_xprv": "xprv9s21ZrQH143K3fTqHBLB3x1qvgZvX7MP2YhYSe8oS5he3tstgvSJgsVB6z8WGzSxcotG1WCSFK1Yq9PCqt1FC78KzvQL5Wd7nGL6KiSLEPA" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "известие пони известие пони известие пони известие пони известие пони известие порыв", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "55eb87c5577169e1c9ecdf9409029c0ec45b44db971b734803381ca5ac1d52dc743962e93099a9bd940c37aaeb33f4754ea86ea53dd9f8eaa2bbc10c67df0d3e", + "bip32_xprv": "xprv9s21ZrQH143K4Wrg4Xabf1wH5s9dPshot3yhPznrsDw7a6o1aUqFJkYm79MTdNi59zPhvYgW9PbEZi2BHCBZsPGMqUSJaDbUdNxRda4Nuiu" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "известие пони известие пони известие пони известие пони известие пони известие пони известие пони идти", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "fc76acc15faa250bb1ebbca0b4da13a47352e6caaac2cb2bb06df3d5c37546f792726de10a9201456066a702dc181d95c2113ab7326280ccca6a8dc14e7b1bf5", + "bip32_xprv": "xprv9s21ZrQH143K2QpQPsNQ8QB63uKi9Guhr3aTqudPXpVj1bxz3xDMwMtPVY7P1vZtFtSt6adL5DgWSRAzLKPVLcsfyvEyder3iGM95NvyRCV" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие посох", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "c8db817d009d62a4d33f2631c9e041d9ce457f87fb3a56839434c6d7b40f38861638c64a2ce2a3149bd1f5bef0f00b95b8d4356e6fc87547f84bd392c464c070", + "bip32_xprv": "xprv9s21ZrQH143K2JTPhbR9ymFPr2bsgXBZfr42gNEiwaWRvca7YSPJ6wKHw9tzFRSn769vmTWLxhJvr12UWDkGNwQS9WNYmNthfo73grYMdfJ" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони идти", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "5a0f8013d511993252e340ac274ce888605aa87373a2e29c550d23d200227186eb1815cd715431fb09564018c71a888f7ed4e7df51016316a973701484c70cbd", + "bip32_xprv": "xprv9s21ZrQH143K2VsCNs75rnPDDqpDxGV5Vi8ayMVMyWRx7ExYuVgL8M6Ao7KizUWjUvvES8RBwRMnT5uWQChsvQYsJiB9UeSn2Q43DxiR8oJ" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие пони известие проза", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "bd9ebc40f442024cfc033fd2b5f5b2a6449748e75d46900a4c6c6b91a03b1c35df913732c3b47feceb3469c2285a1e275f402432d0298502f611e26115d400f9", + "bip32_xprv": "xprv9s21ZrQH143K4WzzS6FLgvKau1vuhGGpnDKqMnX8buhwbAJVxDYB3wDFoC7sjd8gDzcCPr35eSHzquyeeuAHSB9gjWdfSurMFdjjTMyNw9o" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "панель дятел клуб изделие давление клумба пояс туман группа жердь жемчуг писатель", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "2a1882ef4a4d53bbbf62d15ba8f56471c318abf52881071d7712f681b051f26fa5feb579bf4731e70b6928d4b4911429edf41658b04b9b82a62a0e1eb4dd8045", + "bip32_xprv": "xprv9s21ZrQH143K2G3QNJk5Z9Am39ToonjoFk7RVW76iPUBoJRF7LMrh6sHNNR4TmAkbXU7CaP7ToXDRUgHmGcSGSuRQ9mnF4DhfLw7dJuB1ed" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "клякса моряк оппонент спина тонна иерархия имение банк шапка казино гамбит суета идеал отдел жаровня стыд овраг кадык", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "2f2603c39b16c87a4d4ddd67b07ee09f226a6f69f6005b512748799ce2227f2b64a5f340c8a09015a479c7a91c803e0369781fa0e8520259abbd7c6b2dcf0842", + "bip32_xprv": "xprv9s21ZrQH143K3PxQ61Lnvn9cDvtzJGhVLa5ApzssrT4pqcxhbEQyUtmSuhLquwYwPN1sx2wA9tJxFfRDawy8Hy8j5nA5FTYKP63KPn33oV1" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "колдун дисплей портрет ермолка внимание детство портрет напиток случай унция пузырь буйвол коллаж зрачок клинок труба мысль договор минута юрта сиденье лаваш детство медведь", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "8c0a429ba14a73954ad2031d7dc8461e8ad2fa0da21ca40d8e77f27279825f81a89262cef0d3de8071d3663e442577c37aaa80da3f0f876fbf7c2761c2717c24", + "bip32_xprv": "xprv9s21ZrQH143K32MaFJE6krKJdPwc5SL8P91bJGyWC56WVn8nKK9s4oWhboM5pM6xCLFcd1w1EbWK39izpBea2nBGrZgdBRwEPtJoR9rRAJK" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "пшеница ястреб дичь терять жилет вызов каюта взбучка умный ресурс усмешка зима деятель лавка квант", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "64d231788f709ae3d6e41497e40a82d1dee38cfc2014f0e4bff54387fb105fca187e2fdb645bf07ef824832e1c6adb1d1c312121b450c2cb1e4958a131af0e1b", + "bip32_xprv": "xprv9s21ZrQH143K4KcUsZ2HQkVrfJty21XrzB2h2Jc8zSE2faUV7pepKoJwEFihvonR3K31UdFUc5RCeRvePeq3R4V6tdbxcx1De6JUnfEvzcW" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "единица хребет песня захват состав рация лаваш жердь беседа лауреат ужин грохот навар брокер сарказм шкаф комбайн забрало кризис засада хохот", + "passphrase": "nullius à nym.zone ¹teſts² Русский", + "seed": "b27275d872e9287ac1b3aa8f0150e88dbd54e83e338f7818db24e3dbe8a78373b834680675787c014a86c1844cc6dd6ffbcf7567bfb320d464ee983ef6492c87", + "bip32_xprv": "xprv9s21ZrQH143K4ES7c7pwTFrXEAn25m3HbC86U9xucURNsGzozRhA3oGrYJnnzeWKFVRgRhuJWjtokwwJgbmGU5U7p91W76GcyjYWrSXp8tz" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.uk.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.uk.json new file mode 100755 index 000000000..cdbb2c6cf --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.uk.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абрикос", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "c5a72ab3dcd69e357bdc40adb612a25d9d44a196cc91d2692b55803229a1ee7105c2cddfc0c9ce34e4a76e260c09e5546fd2360bb6b1c36b7594d48b135dd139", + "bip32_xprv": "xprv9s21ZrQH143K2k5KWzxsSygkXoPzBKcDjs5iNikvMqhXzH1bgiGQs6e3RgfVa21MdsvS6Su6Z3jQUViD3YL6LnJPsNprw5p48LWeM1wfDoJ" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка актив", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "507663bd1212c2ba8854e75d4f194594c91b9219b8909a0b0d9d2184e787fdd66dc694bb337eb17cc7f346459a2190d401a273bcf2aa7cb68697d2a51c800576", + "bip32_xprv": "xprv9s21ZrQH143K2WKsDsThVSHUnDuyk1PK2XdUbiwGrHduzRGxJ2irqLP2dVZBwp3kHThBichkH65m4TMheEaKK3hnYp9a5YSMCkGiT64VKjf" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка алмаз", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "878e9fbac36fef21a1f147d882d15220b3629e8c34582fe384ed4236b6475e8f02ea20ddd3e982a3bbcf46ef21d150bb3c782f3a18a8c1323d9ca903e02e2c35", + "bip32_xprv": "xprv9s21ZrQH143K4JY5MrWGAbbwWB7DbowUnSewDp5rPGFcs8pBLVYdKkKWftEgYhR9Zp9hoeQeNJxS8oz8aQVmhdxEAb4DE5YWmWkPC2ah6VF" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка актриса", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "e7dcb5b056661f3c99caf45ba50003d0b361191a876d60d08aa1817b580bb7472ab022838a20b208f779cdbf8c5da617a9b41c2d4ff1b0db76e39b4a3f70a826", + "bip32_xprv": "xprv9s21ZrQH143K3z4rJwghzvxhdSKVgyFTmbmVu6y2mEk8fNeuBgHMCGKoM14fxSjPSUz5dyyVMZApjgQJ4YSomFyP6DSKHgqNrA85Cqp688Q" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка абетка бджола", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "f8be2f274b86798d4d9e2e81b755dae3df161a7786101920bdb3c28f6c1af3028b6939875de5aa6c750d61ee52be00c79f78b3a6fb17785c283e022997444829", + "bip32_xprv": "xprv9s21ZrQH143K2UrExPonrB6b9DftkdRDN8UtVViv3TiDB8LisyMgYJk7oxp2fMK5tZ8aSY8gAeTQjZCvmaN6kZHPNgHH1gotcvz5kbz5gzF" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "агент асфальт драма адреса бокс минуле акція висота агент асфальт драма актор", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "38763f63ecc7731a9cd0bcae897a73d8a44f610a1da8bb9ab02fa9b3c85f3a65aa2e52842434e715ac28c4c9497c716aa0a8e94f5e68599809033d78e437d4fc", + "bip32_xprv": "xprv9s21ZrQH143K2VP2AWLC1HPnYLdNVC8mXC1L9LF62g7bZrkEV2EPahr4YbXLz1pS2w7Sim1n7GA3vhR9jXHE3gaeSbHZCiXLHjwpspsRAJL" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле апельсин", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "79c05d3217c9233cf4c3380b9b894aa5a693d5ba8bb0e315d18cb6c87a4ab2d66d5a1a0d1d858aeec8670a95ae8ab5eadca5effb343e6c44fe713f8b4aa11c0b", + "bip32_xprv": "xprv9s21ZrQH143K42WYMJkJdUsz9RDThEYz6JTvGfapGxf8DvNsKNUmXjt68ZNh8Xv7Zq3jiL5sifrSGqTRiBHY5o5LXCrpshuUNefx3fwpTPM" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент бали", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "918893f1a4ab740da4c5848cb26cbee59623cb7344bbd7280d9059efc7da50ec339d2d62f74eb8a3238dd29399c3fb98e3fccb3aa79e8ff4334cd12f183a6afb", + "bip32_xprv": "xprv9s21ZrQH143K47xfVF91FkG55kZBCi6pvG6wnhJCqddDDm6hZJpejbauG9vDPFzTFmQhKSQbE3GT7TYZh5FRGdn7M5vgLLGk81N9QoC4zQa" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса брокер", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "f276d42722c215b973b0916e929f6e8fe4ce77d54bb56e9e12d0676d8b03f5060ee04c3c2ab16c044f655f0c95434cb7ff9253f97f0aa9e9764834492cc7e050", + "bip32_xprv": "xprv9s21ZrQH143K35Hhna4WQMPShsJNovnSwDEoWADcKvySoFco2UrT2Ur1GY3fHoMmtz6jdEx2S5pxZ3fQAM7wMkDyZr67fFvrd1EuN82quSk" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція гепард", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "21bd9c2cdf1c70c3d4a2aa90280cfd58058a8e178c938a58b7c714d42854e6771365e7008e03c7641108b02d2517122ceb0fae406786866235ff3db9e6ec5d1f", + "bip32_xprv": "xprv9s21ZrQH143K4FKZVNFyJr5zuu9fcHi7285HProsHAvbfDKYkk86Sf7kicFSJio4JawWG437AP3wANPHAS2V5xxzY95hauW2RMRvmAzz7F9" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "мета ялинка флора іноді щедрий сова їсти через мета ялинка флора інститут", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "64216f5c4d37967f3f46f3343bba8d008e700037530f6bac8bab7d49cf220e420ca1aaa78420f6b0eb20db77bb84ae97c689b3f006c43e0521582af70cd1e0b2", + "bip32_xprv": "xprv9s21ZrQH143K292timxhymabjqzE5BJcmuXivijcXAsm5MfgM8BK9h1PWbS9yuzAbZrZ4Ejic7JZAbW96Yb9PaPuT2PsRhcg4Xdf8EWk7n9" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова ярус", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "6731d537ab540d45f8a176fd6dd144257ec86401d01bf362cc90f7589406fb8f2ec20a33d58b20b36a566a81a014bfbd74286840a8d774156c76b7f80944ad21", + "bip32_xprv": "xprv9s21ZrQH143K2xSEoEL7tZ3QTAy186YASSbVatxfhs9525HJ82jcrG3KsefjZESz5pru4nb3cTBndMXyGGPM4nJ1zk2H2Khp361i73kvDcn" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета язик", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "c09f285050b8cfae3ccdc99b95f321f212a2d4c470879d4c1b6ee36ab5c9d3e3d67d1e5af13aa2c4738b90e59a1728705a23af8824b633b08abc83275d546bd4", + "bip32_xprv": "xprv9s21ZrQH143K2qiqH965BCRhnSpb9QLLvDHVRJhTJuBHVn9H8JCmKfju2JfUdUe93LvB9HRPBB3ZYveGSJChEmpq7wUq4kBScqH6MpKAVsN" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді чіпси", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "f84c7bda242bed4afc8f7bd8d141b29dde4f3709c4220712bf1a38060f325807d6dffd58865796b4c006e4c8a94dda28c590ab8b71187b17059a70bea96b722d", + "bip32_xprv": "xprv9s21ZrQH143K2v2N8pxDwJ4F7UYBsu3rBV9bAq4wDrdzV6WHXi4qC3iYGNspgcxw4kS7rDLHxrDsWoYngRnSDHCNBtz7vqLsXTWNivVB8vw" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти філе", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "bf7269ecdcbc35d3494edf09b1e0817b9c31fea3d417eb8561c40454028dfd29794ed71a65daeabd17781778b9697bae619ded23e4a62476a589c7d3da2e01cd", + "bip32_xprv": "xprv9s21ZrQH143K3NxojcQwrChVbJDpMEjGCqTocrCGQ1VR9YJpvpUtu4gF3aNWorteAqQT3eVMTwFYW2WNFJFAXrPoHdt2WEA6xLyWrySYZy4" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "минуле акція висота агент асфальт драма адреса бокс минуле акція висота аванс", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "e568f2a6c418b0aa1790218f81ac54241ead8e4b80c7ff1a6e5c4f861825a866304f7651eb8d5b51c5d37eb23a5eb795b39be55f1d6d57c9c8a6dd9f9240584d", + "bip32_xprv": "xprv9s21ZrQH143K3caXCjz98XCMZRjRhfJJBnohHduhZuBD3HvDwW7yM9RAk7nKC8tAfRVYCcMgzAo8GUtzuVBVEJf1nUEpSLrGG4HmvCGvBWe" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма агітатор", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "44b9bde9d9bc96045811dba0ed4daf35cc31fad4e33563ff4e23c44b4314b37e2623e27dda387d86f05ee335c3e9774bb79e7b740f93727a9bbff3bc142db892", + "bip32_xprv": "xprv9s21ZrQH143K3ytFHE35KNH5CL5CJgKzJwhQLMxPfSqPjEaErr6Edkk7N9SptcoCJKu9HPdv4wZbuEmfVae5gM27zqJb8ozvaf1Rm8focnL" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле архів", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "59c0922bf01c77dbfffaa1b94b337a8ac96a64c068c625a1147894f2c1b5d1f456f47ad25bc4edf1fab1e50cc9e82b289e2bca36ab40c92462640051f553eed5", + "bip32_xprv": "xprv9s21ZrQH143K3RsL1J4ivGo7QJMdWfV2bwggRLMTu9ZXh6Fuh6WF2yEv7Vo99i1NjBHYWadMMu5FX3vJk5RVo3g1mccewUpcUcBp9FAgzcD" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент байка", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "c42816f40f8ffc18632df55e9e44eb3a3fb6856654595d03e9cd82804777083caa0f2df037e4c41ebe85fb6534db0fce944f6ca2f928652a4d57b9f56e25e3d7", + "bip32_xprv": "xprv9s21ZrQH143K2p2b65u2EdHiGPfj1K1cAX5yv419oyooMpKn18aTyK1XV7hmgmSwDWBmnD7N5Whro8jHkb2RwNZiewgqSGSmW7erRj9cpw8" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса бокс минуле акція висота агент асфальт драма адреса вагон", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "ff9eb6bfa966f18d0cfb3b57f2703c995f58d605358eb83e3582ebf378cf14dd9e46669996bdd983cddd281b7388b2ef1b421a09f00f75431520eb2e9e0bdbd2", + "bip32_xprv": "xprv9s21ZrQH143K2mLK7rsQoSrjKD4qdmFE6vxA9SL8gknjppFKxL1MZTp8yk59EhJSDWR9c5uCauyUU5LHZGvRLKJXtmBDyEHyXCediXtnu4b" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова ясла", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "58634be818dfcb0f05981f935176e4531e44674a35184a9e3204500ebf6221521393ab2541812550071f2e54d9fadff7234622991fe5dfe92bee0678f726513f", + "bip32_xprv": "xprv9s21ZrQH143K4ArGb7L6idr9J6Zb7aNK6PfRnt5ecfnjMqWfRJGcfNzYPoFme8bckCyYjTqGT671dhiwe87qfpyVjazsSNCa4pWgx2QTCLp" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ягуар", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "456de95f0fd9cf28e78580c70fa54a23d2b4020bba05704bb6b44fe8df9cf72e0363d0c2fa732479c7660343eaaebcd360f4b66dbd5f8d6bbc4807754e8a5c63", + "bip32_xprv": "xprv9s21ZrQH143K2ufwRTHi6fkByidKXztAzKtDRkSiyejR4X6quXg2aQkCVbHkrxfqDoWDNL32s5EqxSmYqQTsFtacif4KTSxho73NEQKML7v" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді штани", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "b6098c61f7bde2eb99c887261db5b1eb23ad28144ad65b33ce33ad3bada626f5e74db3aac8f5c915896b0dfe8458a4674fb8bcb0cf625029dd4e03396487d3e1", + "bip32_xprv": "xprv9s21ZrQH143K3LstoSLc49oRWhhEVJmewEfDrozohnB1ByLwJjsjxdZDG2zKz9qeQFyVtPE4hHcXjCu6egRTcp5j9Pvx4Cmnxkgomh82DSL" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти хлів", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "75e0651ce0b9ccc09c3a8eb070506f12289f280269aad539585b96492f9ed2424236dcef91b3fa3281101f9bc66a07ec8b80665d663880166e530828e84e473d", + "bip32_xprv": "xprv9s21ZrQH143K2YY2bLYnNpHV1DRrsa6yQDfvM7iUvqR6FS4tTQ49Lisc1sH2HX9gjmjSLzFrD5RKQ4rTA4Lo9foiMXd4NDroTDJLYyLqNQz" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка флора іноді щедрий сова їсти через мета ялинка узлісок", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "19970134412f35a0bd10fd1ccc55ad32e62a2a429016a1bb0487d73859831b1f4d311aa98b496d49d53487cdf13bf4ff6eba5e70c071a4fd15edba6d66a10261", + "bip32_xprv": "xprv9s21ZrQH143K4JyE4aoMymhWXBBC2VrFvc4RfLhksGxaTfVPx6idsd7tSDK4xasYWoaiR7jSknvkMnhFXWNwDk4QqrFWitCqc9FbeFaEAqj" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "істота істота істота істота істота істота істота істота істота істота істота індус", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "fa752580d3fd4a97504a56270919f3efa28f6ddb8fa90495ba70d4ac59c58dd86e578d11b4da85c40989b17d54c6ca9550e964f241564a6e018644ded67782a5", + "bip32_xprv": "xprv9s21ZrQH143K4RV2aGYLqSo4jYP1AUYxQ8yP5bWvokoFcLZ76Z38kFtBW6YxPXCtgQVTPPcHrHHfSJtfatA2Ca8mTj6UzmPaof58d9FBaFi" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "істота істота істота істота істота істота істота істота істота істота істота істота істота істота індекс", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "ee5b2a75826745f55a2117f6398babf83ed187c8574c612ddf0f9a28ad5799cef6e87506fdd5987d06c5d364f53c61c54b2983d3a52b2eacc2ebc8e5016ed9c3", + "bip32_xprv": "xprv9s21ZrQH143K3NxNZ8yuLBNUVnQ6FgeMq3sdU1eJ2m5HFmnBrb2mHbmr89ubdbpFS8ieVs2988W3A2gz9KpvHovKChSd54YEuWQDacGmJHf" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота явище", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "006acb406cdd035e5a7dc089ca506ffc865afa709eca05d5d012ab198f9bb6d277ec1000e4355fa938291189b3889eb326bcbac90338c0cc3362fbc553f5024d", + "bip32_xprv": "xprv9s21ZrQH143K3oYhcESn1YhMSSMioLVXCiYCzhdab4U1x3ondxr8yZM3zSFxLfFZUHh5sZBx3vfQKid85cwC8fqbJ334TjSrbu8iLhxmy52" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота чіпати", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "1e6b6715fe5faa6c61d974d9d348c96cbedd9f3b741531af766da2d50075e5674a9b42c42adb8035022833680d01f9bb19e821d3ce5708085277ab0e38e2d19d", + "bip32_xprv": "xprv9s21ZrQH143K3T3vfjQ2kV9hZ2s8X4xwd8rkWtvWfYg4Zu6TiwNkUM7gKvFVgt4wsQPPYtqEBScmJPkPjUijthoveijsq41xgFKULKsDB2o" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота істота шкіра", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "470b13a569c704169361dc7a5eefd862fb815d6ad855932c60e44a57c07cf727d448532721328f7d36a6e4f2f54ea066f62a9dca48c23f7cfac0ca18f5b46265", + "bip32_xprv": "xprv9s21ZrQH143K3RU4XdtsuRYJZV5Cx99fNminkLFWpTLaGQA3mjEdVWiBe3kjZ8ct3BqHGhmitHZsb9H4p14BcB1WYCJFrBYoDvvS7VwJ2uh" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "птах злий птах злий птах злий птах злий птах злий птах зло", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "05cfcc0f54c6f6944609f826a88d0a7c0e442023ae5460bddb1ea82cf4f2a3842f72f63e3df9883b7d0dfd1126037fbf7cf61cdfd000b354a0d5e2c7d17c17c0", + "bip32_xprv": "xprv9s21ZrQH143K2qE6H9zPqKXVwk8EmHVCiyBEVDASn1jJa5KD68BzSDVP5RrttGZSdt7QMe6qpsBDcTWjzBPiQjMyA2T5GtH8S7CWHGThfxL" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "птах злий птах злий птах злий птах злий птах злий птах злий птах злий профі", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "11663f63269af0b8c03383c6b579547ce598f20cdb2f6e607fe8035b57500afa3600b529346ce50ea8fe26bc7eba5ebcbc0bec1474e24f3ce204ab52be50dc20", + "bip32_xprv": "xprv9s21ZrQH143K2LTT2iBRtpoGCnvxcFQVVmSSvz5ypcvwxBwfyG6QWH7kSgBcxJneyLNtfLwRPRZJNjnz7MPLMCSdjUbUK2SnAQoMjNMVDkV" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злива", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "f5c15f1a4f0d6356d5f8d8e4567120fbe4c9d9d4e80ed3f46ca3a24da624e4aab6f589def76c9eabd4bd0e6a4a3d437e9ad451c2ee3d29e8de79540bbcd97ebe", + "bip32_xprv": "xprv9s21ZrQH143K3FmkbCddRKAWoi3LMfqkneuesWoBfLRZ6oVZCynkZxjMrxF15XzZtpTBc3Mq5EZfsVWzrPEjFBxDwFN9dLq7Sxhbv1zqKZi" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий піч", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "e3674fe0a24e7b716b479647b5b2e5e203455fd195b2b659ddcadb5094653e3a703ea5bdf0a6461bef12526f83a5bd1f64dfb0bcd3e2f1bc8dc5b80b83c7c838", + "bip32_xprv": "xprv9s21ZrQH143K25UMssaifGuystTVhCr1GAYEAYEw6Qwud5xhuJRkt1GeWsD8ngQAhhqAgLUA6is5WnQu7YYjpVR2EmnYSjB7htBLwEEUW9v" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах каплиця", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "c164e6062c30fa714e320d94b61851d3d3f2bbf037041c8e0f3bdb18545f0856e488215ad59c14b686c9ac0892a470a69725bc2ad6895bfcc0946c17c6beb733", + "bip32_xprv": "xprv9s21ZrQH143K3UgNb27S8JWZJWyT8u8roDZFpuzBV1XUyN83VqZvE12m6cFth1xFWNYypEG9LERGpkxCFTxaAKX6yxZJ8kFgSrQ5bw9Tz9P" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "злий птах злий птах злий птах злий птах злий птах злий путь", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "bff431a5fcfa55ff732b1a8ed48cceeb76d6cb1772f633742cfc312be23bfcd01bfcfacee4f4bda73ecbaca085dd7ccf71261fbbeae1049b1706cd0e96b30bf3", + "bip32_xprv": "xprv9s21ZrQH143K24YebQSRRnaqNL5wBxS6RuUU56VrWQhM5eWc5HFuKqoyQ9FLJhWhNVkEhnEAgSLoB9mK9EUFowFRch97d7wk3DzSP8p5Yhv" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "злий птах злий птах злий птах злий птах злий птах злий птах злий птах зима", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "9c4c3394ddd1def07ed9ee75c10b2ec27291b94cdc2e820f0d7f927108482644a8965929d331c4831d94c47ac5d4234bc93b868001b8942b4492521b9095ad35", + "bip32_xprv": "xprv9s21ZrQH143K3VeuvATouNWeVkWsQYEkj691DDjBYHNJ2wfVYzF98PCaSiJhfPKJ7g8u6a12PH9TgivEMrydDUc4AxRMZF6Nvs8GbcPSyju" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий південь", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "8a24438a5a1a6241b78ad62dc2ee2dd5d55a0641276a3a934a2dd76ecbc74f66be69fad77726ce0ca02bd89ecd350d73c74bd878a47b21ef63544b25dfb3c6e0", + "bip32_xprv": "xprv9s21ZrQH143K38nhyPm14veVAu4SRUkVaevcBWBB8zugzDUu3pUQfRg5QjFTpLrfZv3iesXP41oYoG1A8SMQC9diSEnrCrPSxkhQFxsWpnj" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах зима", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "cff0215d72d6cf33ff290922dbcb6bb4d2ac5f062a8cbb22774fe2d080bd55afdac8a9510043d05d8dfc90c4042a7fe3a4b62f7f7f1476ccdeaf25a96525e270", + "bip32_xprv": "xprv9s21ZrQH143K4Ykmpo1G1BvizXcH1sX8cF37XLmhXpnzXrzEnTYi91iPp68cgrVHtcUmSVunih9JaRTAYS931JJTXp6sUmVrBuNrbm1vUAa" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий птах злий реалізм", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "9e1c7571cc9cc3a8e79f411c932601b2ecd847a223591ebf7540df0be6e7c5b0ec174dcddf2041070760db527921163e6311c96043db034a8511a5aaf2e7b6cd", + "bip32_xprv": "xprv9s21ZrQH143K3L16ujhS4iqu1D2Zdr6vxwHAwvAF7RDsDs2ojTEnRnEHq2Bfu6GjLA6FR3RJu88bVGFJS6xLcBR7KrWugW5d3XFNGqd8Ub8" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "пляж діва копія злочин дах корабель пізно флора гігант епілог епоха посол", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "9f91e7e1f19a79120c0d6cd7f72aa34c6bc800dabd23912971d506379812ce663384340ad483ca335297dceeae3808b1651c4a9d1b166a975b5ea1bef47c5115", + "bip32_xprv": "xprv9s21ZrQH143K33VtkWwPeGdHzgZuCyonryG8bS1FynAoJUE8aXF6jy9HpeW9jdrmkiiLCwVDiNUebxVSGFRrPhP5NsQivL3C8nSBo2RixoX" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "корінь міра отара теча утрата зимно знання блогер школа казка гальма тримати здатний парад емаль точно олія казати", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "1c3633cd35f8c7088bbd67d4c7a0d2bebc028edf749415a2cd01f2dde21f04f8750dbf90b2c65c10b41b871bd97af257d1aeb2b968bf72a9a8a6517f1c6ba160", + "bip32_xprv": "xprv9s21ZrQH143K4ZxReS1Hc7Eoe3nooDKLRSXg57FJfsbaoEwy7TBBYcUoQhbambGMCUqNZVJ65jYvPaJutBXE2CWnMaRpTfskXwCp12YTVFf" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "крило договір пункт екзотика вперше диван пункт натяк танго фінік рис варіант крок званий контакт ферма нагляд домкрат морква євнух сукня лопух диван мийка", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "ee4a0bee4c128c50a5bbdcc1b64eb4be253e427ba86ac03b588ee3f976b46b1c7640e1f515a05c87b7efa32d5256ea89c7390f1827923b80031fc8c2fedbb49d", + "bip32_xprv": "xprv9s21ZrQH143K3qxPyAg5CdSA46qQy29XmvyMAsrBbB3rqDo6s4Ud8A9z3TjYt2QeLSrxExCMGsxHwDtdKM9eYVXDKbnW5uQmdkMVFcUMNr7" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "розум інші доказ унікум ескорт візит клапан влада філія сильно харч застава диво лось клен", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "ebb1ae276ea6eb5365cbccf1cffa291c735ac79fe8486487061d5036a30b4d2688ba254f25c0a4844a3772d943e981fe1d7c9d6bc9d2a23bd1005a269b3a8653", + "bip32_xprv": "xprv9s21ZrQH143K2r69mXjc6FS5A7cgrmA37jfJ1mJQxUzgr11K8TMchjqzm5jf4H9WMYxJPodDYDWc72uj4TUyGWnyMxnrpxbW9SfTR1He2rc" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "дідусь часто помідор задача теорія сафарі лопух епілог брошура люкс фтор гурман намір валовий спокій штани куля жага ледве забутий часник", + "passphrase": "nullius à nym.zone ¹teſts² Українська", + "seed": "c8fc44f3756895ce7bdd158015275bd59d2f84e3607a4fb63246b7531910903e125b8585dbdf3c8bae9580698df5aa0fe5d7e275e846021a194daacb6edfdce6", + "bip32_xprv": "xprv9s21ZrQH143K2YkNeM3WUSVofn6AEuyEYHss6ThG8s5x4WY43q3bQEbVn2qWk84YFDFwvXFiS2MERNsqgGUfUkwdWiDrTr2r7yPkcKT6WSt" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_cn.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_cn.json new file mode 100755 index 000000000..cb46ad93d --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_cn.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 在", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "fe216d54b5731858962df10d5d5cfeb0a2d71c0e0d079e935591d34d95160b789717cdc800bb0f4f676469384f81513e38520e3a906da35c80e784939c9db066", + "bip32_xprv": "xprv9s21ZrQH143K3Up8gA8j68CUpc4NHB9oNy4fMnNC2ZHUBnHwUZg7zPHtTU6qsor2PiaVU6dHN8gYWz8tuue4vN8vViyEVTB2NaVFXe2yp2g" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 地", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "bd142fd24bcddac1d77fd74a75320776d3a6c2be8cba51d6ba7026eb29d126c0a182756991e0b3010f6e54fd65888534e2a5c4f9a3e0c70e1eff7017ed90e93e", + "bip32_xprv": "xprv9s21ZrQH143K4DUmcCSBPZW55NsL8FLbBeXVrNj8vD4DR8m518SY1tXa5LEvA8HubEzHd24QAKVhFLpdhJMywubuPsvifh63QZSWbSnzeyA" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 动", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "e39729a7d2fb07c88176fb2e91f2f45d0fb6637d2d4507a447a6386c3a1765b32e92b46b7c754ee4bcf12f1da8eaf4b84e1a166b81e82bcecbb0ee3bdd5a3ca5", + "bip32_xprv": "xprv9s21ZrQH143K2yqiv5Hr1g2gP6WURu4MAi1SJorBhWjanzddNZUtvrvdZB15r1XcsfXN899j1FViGs3uWb6xQrihQiNR4UWqSgn2ZpSxmgf" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 出", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "9facd65610788c912793e59bd78563f2c9c465d8b36dd2aea9e6bf68b81c8e2f45e3553326cae2cf9ae887b7ed7d729e4f3c490eaaaff01d2d4d5d133d037c77", + "bip32_xprv": "xprv9s21ZrQH143K42btsCiATLbCBhEdKEt5YTpPvuFajXpiwcEkjGCVU6STb6tdhHRnBpMzhRM2iYV16jEw6PsSRCiAsCLbfc9NT11hBG6wbxb" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 性", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "caf9824a76c924d999af42a482b4199739f3e1bcf9631d26a17826aa82cf0467ed68a8c5c0552d539cd49091e9d11fb5ec7a2e02cb9f66be95eed37ac35c2e17", + "bip32_xprv": "xprv9s21ZrQH143K354f1ErgYmqdMggDzc1YH8cFBytmDPiMqLnLehmLggdES9noePjz9cWfbHZ199BLRsDFpguVJ513x8ao3inW3sHG9GtxjN9" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "人 三 谈 我 表 壤 对 据 人 三 谈 于", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "d0ed65ead74fcea09523e4b3bae64ac1d8082adb1e41960ce66574de3ed714e8d7c0b0ae8ddd38bf6713ffb055f75ff88a23da7639284f13f5a836152e047ee7", + "bip32_xprv": "xprv9s21ZrQH143K2fW6V53DHtHDXGuqg16Eo9RcCbbDpt9ZkSGEBqPviSf24CNBthoFVH9veFTUG31h1s7SCEKgnAzQQXqob9zNu17w5SMP5md" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 而", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "4ce2ae1398a1c3b3f8aaeefdc4a29c251ac4914a5d10d366b25f401e0edbb798c87af278703dc54bfb754e4b8df8708a1480ca18b72a8fdc3c09d25a7ecb0c29", + "bip32_xprv": "xprv9s21ZrQH143K2Dq7QEgGH7eSDCDUZKGA185axvsdsHBCMhDMtWHRoY9fh2MjpEDGYji7K1dKJz2YuhHCGQSMYhm4qoWts3c527GVxgTg7ws" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 据 人 实", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "d6aae429dde1dd685374ed095066b4b2eca1d1f3800ee0af23bd94ff2c66f83c659e0dc366b7182a47a37ba668b53271f252d43e24365bb434367c8bcce14c6f", + "bip32_xprv": "xprv9s21ZrQH143K3GpXzfJsgxVovaMxEWFnAn1uzKJdnePrR3LyhRgcFncVfJ9fkcMHia3aJCNRvo8BuSVvZQVY7ecy3aMwynqn73e3ppYDkng" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 原", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "8add055932c967f840e30b2ab66725cdea0ebc4a0d9890a8f310b75216a2e50a8a2f4a38153b090e5a079e3885586dee2cb2ba2147ce17765cda704a88ea0d88", + "bip32_xprv": "xprv9s21ZrQH143K2MvGuB7V7cdmcjDbgdVpzUugidXTYKM6LvYjCodtNeYFtaCnoNJq7huyXFrbVvAfiW5L8TvGUMUTjEZLQEaAFubdu3y7UdD" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 研", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "709c82b309b73b72c912cbe3cedb4a50373bc8642fda4fd0aeccf2202f290e7332b8af15ad5f18cf1891877fc22e19b3fa83861a638c5f2fe04012ca75bb8199", + "bip32_xprv": "xprv9s21ZrQH143K2AkY1ZRZRH641uLdJ82bkgsc1rVa5Df9NCDfscBNjmQ1Ff5w3KzRx6mGTUEWyMXNxX4qhMg7EeS4a62WB2hakPccHwPFwkA" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 卿", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "df31d1313e4b60bd2972c5a0520721d9f821a5a8346004232c169277a15af37a9ce0787ef9ceb3d99f3af4c98c1b645c158ddfec315bfdbbf688f84e04609798", + "bip32_xprv": "xprv9s21ZrQH143K3P7yqprj5V3vPuE6mLW28SNDrZ3cg9nY6U9usRDoBM7tc6iVeje14WV3EryPcXYdfA19tbeDqH5ixvwHgyqcr3jykbivMx5" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 沫", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "2376aeef884fe4cd384d6f5c04ed49e645bdc2e8efa82c23585ae91785324a913f296bce875b61fac30ee2a81c4e91480da4b8bdc8563afbfcdf91146c68d217", + "bip32_xprv": "xprv9s21ZrQH143K3sYqvbLPQu9iggko4TYhJTyoyU1Qykr82ozFcYUCe91GFLzqVxV2VhZd9rsTW96igvvaPgCeKTmqtdwM9jaayurL2yf2TQ5" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 殿", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "ee7559788d1f993994da14a33e79b2dad5e6bd19fc8aa0499598d776a6114d4506fd13e2d432438d5ae0c331e29761ed6b5dca86c33ff9ca23e55a30a38d313b", + "bip32_xprv": "xprv9s21ZrQH143K4691B6MebQTcNzHQZuZYFWbZufvMvBcj34kjohrpJjQCEeAaMwKJDMEMgmVpLjCRXMZypBbdR3T2SnzjypwFKMZ8oWGV77L" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 盈", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "6a5fc40b4a66e5eac4bb1b6ba91171da3edc84a0f7d37025e9a489fe05a0bb715ba3e2f99170cc2575f837a761555ffb1a9d254485b879deefefb2f42cb3af2c", + "bip32_xprv": "xprv9s21ZrQH143K2jQWVD43B2UFHXTGpNBp1bx8oNGPiqYSCL92ENZzhfXZKufj31bTe4jh33zwMvCjR997j4Msns3amhjDu2dnrpW4p5EcWbF" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 搭", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "e3b214c60b5b3fd4b1c500143ac10e0338d0c78cec6332443bc75b8cba6697d717e55c1a3b77432798742d1664c63a860252527cab4903e305cc2f46d6215d6d", + "bip32_xprv": "xprv9s21ZrQH143K2SXQ6AVYrYXv2Fqs48b3NuyhcSK9FtX9nHk1tHmzhamJrGhDWjMXKhzDwdV4hiK8ktav9Uc3ihjJSkDkBYvbyhcMXRbiSf7" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "壤 对 据 人 三 谈 我 表 壤 对 据 不", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "8282fb28a53329c2312eb4a5b2e0dee0650227f4ab2e83b8e2e5327874b53b8a51311421886663146f8c0496264622763ce903f5a78371de36414d8ca10e921b", + "bip32_xprv": "xprv9s21ZrQH143K24kfdqiZyMW9Gtavb9zhSJZPfGWSDoYuvLWsGW96TMsfQQJknjMSEDrUyRd4jrSSZgbAnxtH141aHEzpRHCSGKUaUZ4cusD" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 大", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "b51140b60a06398d8121c420ed084f9e93e08f827e8797ab2d0861c7be8e99bdda01367e2bb72f9f110615f24196a7086e138bb46a6d7dba5f8d4c9c764f9b67", + "bip32_xprv": "xprv9s21ZrQH143K3CDjDPtH5nghKC2gxL4H2cU1efDb2Zi5WhwuxBUX9PWAmLZjf1huU1AarAiKo22CWU9X4B6cxS3dMQ4t7DWS3EqdryvKA6m" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 民", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "4c4b05e4dfcc65caeb68b5b24d81f65ad33d8b55cf9615e1107002b8e91bc18b16fedc72ab0a94149232bd4f936cc6a598a5abbd608410cd86f10cefbd609c46", + "bip32_xprv": "xprv9s21ZrQH143K2B1vbQAqPZmWfdoS18vMyi1riazz1a1fzBLncu8XbgFti8KKAeTspLfGfUX96YbJrbUfyzgyA87PJCwRiBnB9qU61KEdhmF" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 据 人 起", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "62af2863200e4e42f91d4a0b5f6cb9a03d3ca6fd51ce1be0765aa90e2ad02c5185c7eddf6abb755998703e2e02680081a72ab4e0bbfe430a94f600f4f3006109", + "bip32_xprv": "xprv9s21ZrQH143K26gfWu37FNRfg4XKqGiKivBABMMHh4bnaVL44EAHHFpGhEji6DSiwdnBSHfpfEnTaCxPmGfFHjSRLJ9aw4jdqAj9FhPEyXu" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 表 壤 对 据 人 三 谈 我 五", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "0f6eda9d1ac68b84a628e82ddfda9c1ce24c7d9c4132049c8c36f58a71867a41dbae0cfe14e60282fb48bd53befb28fa2509cd05cbfb079b057c553f394eae49", + "bip32_xprv": "xprv9s21ZrQH143K2NL2ownvU8k73RVUQBcc7YazsUzd8zagDHHzH1FyZe6Fkuo8uMf95j2Z4HTRanbv2XF5uPSdJxwSpeA2mSj6qTBys5d7RLK" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 皱", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "776a1d4bef24b46f16c78de781d67c6e9f511407f4196bcfcc9fbcfdfaeeba25e4cb1dd13ac5fbf2101ea593ff5f251479fddc2408ff803a5ab885b29dd7959b", + "bip32_xprv": "xprv9s21ZrQH143K467811Wrr3gR3cZ1nG1HAFqk5Emvc4UhaudH4Didt26vACMTz23RpB5cwPe5vxRyZ9shExKYB9kohyjZ1xkTAbFog4UkqMM" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 晒", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "2ea0d61b22d4f7343e65535ba95a36b4157647d3efa63de3c01d4fa848119b241a85bb22da8c9a9d06e9c2c02c6270fde152a7e3a5d51ce412e0112cfbf6617e", + "bip32_xprv": "xprv9s21ZrQH143K2on8sBXYvX6C3cdG6n9tiDVRDWYaux9LawxtpSdzYRn4i3NnWQ5z7rseDjjcxg74kYkEZyJDvFXcFSizfaDaDTmJ5uSLbt9" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 泼", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "e2ea5e461a92330b6495bc88a3cdb302e79998ef9877cef6524a621a1016a7538fb740e1e037a7758d82bdaf7be914f81d81b5374af91009d934112a17629f4d", + "bip32_xprv": "xprv9s21ZrQH143K27xWvyaktHZoi4z9ZEww4Eo3v6MyAVTwazYvYPWd9kUTGUSZ8cNBa8Z6kLtuY4E5aVBGZjP5e8hbMbMLtox1vqHc1e3MTLL" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 坯", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "0cd655dd9641a0160f13d974d6801c7f5e2fbe07220c0f7ed9f8255bbe211278073719d4c027009faff89566d2b762237bc86143e7ec4caeefdc553805d1d441", + "bip32_xprv": "xprv9s21ZrQH143K4bTMzdbZRddbWh1eUtETvVQvg4D7HsHZGW4icta6htriK5Wn4eqBQHCdjy1fWhQQbPwfYEhjcP8WtdTVyqdtebeiYiMEhRk" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 霉 尝 俩 闹 饿 贤 枪 疫 蓄", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "0f458bca65384b1605618b0f59a549d2433bcb36edb99d7c2ad803c522337a973ab99122d9f92e21c1adc7d67c1948d5697d0ab318911986bd51e64943f12873", + "bip32_xprv": "xprv9s21ZrQH143K4MFzwZMBbsNSE1TyrV18DY9Gt7iXQxYUAFbctbWcWz16XX5NdqNbMqRiii8WmwnmCLMmpSvEbUMBCiYHvtEaHtY8KyAN7o6" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 逻", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "73602246891b2a906164fda4d80375cde53d877641eed4d88e19c3b11d526fa7fefa7df37bbf17d2b7a0c9b91fc2514adde82a41e55c75f6c91bc72f4d1c81b0", + "bip32_xprv": "xprv9s21ZrQH143K4c17qY91QPvGwDKrWvrMkDR61twQKkeVMA8Q4hrDw1z6k8jJue1QJJqyJsSGm6kESB5QXpDmJfy2bhT6qMZkTpUiYi1Hq1t" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 溜", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "c065e1ff53d254b4b51859805fd0248f130a30529cc4164eb52adf9ea6ccb05820cc75e7b8c4fecc9b658df9758fe0bbd720c298f4d25e82cad15781cad83338", + "bip32_xprv": "xprv9s21ZrQH143K3vtw2ka7616TqMfD9yqiWeUgTR1HEg5S6xsecUEJMxkmgfx8Ym97oD7KCuK1RYyBbzgJPDjkCPq95gMq9k7ksQ5Pc8EWeuc" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 裕", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "06a3dcf40d778d276916804266c255d615bc417754b0c8b59c06be7ca54cbbac6e01a0573c104c606dc9f69191e3482b276c1238a6a86b1b67de7bf53dfc6ec4", + "bip32_xprv": "xprv9s21ZrQH143K4RVNo2aQivES9FDtGVsGSfH1TtVVTJnULBk8pykL9VCFBqsJ4KPjxZUHgu67hxxSmr2oVzAw9V1Tinch695m73MVqVNdeUo" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 躺", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "389769079e0ccd7fc23aa97b96843dfb2dd9a383128587fc5851d5143208a293ddd4be66581fa0964746497f4357c279762d35935395a9f38f1306a23a53b8a2", + "bip32_xprv": "xprv9s21ZrQH143K2bbG46HMeVWLxn61cdzRj7PTStfXxyyFA2iZz96RgzwVLSxPHxhvDiKgZwiPQSnDu5H6hnNcyULfRioYEzjSVdKLdL8jGSr" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 佳", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "aaf0f4e8292ea1da080391f0a51d6bb88f572d745048e630d2d2345265c6b9f3f20553560011b7a4861876852e10141de2a036a0fe9edc7a0d8900336a9cd55a", + "bip32_xprv": "xprv9s21ZrQH143K2g6y5hujcDZwpNLTarQSGWyjYxvUHgd5tDkEvxSfxTULWMpmaXEEyLGk1n6HzasP9gpex2ZZsndQbe5GB3pykVKJ34Cengb" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 找", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "b67beaa271f5b17b752ab72d9fd37dfba6eb4345a4ec02c954a7805c361cff82c06c1b3a3a3092184595b46591c7e0af01e8ed739ececbfa88308e1107fd677c", + "bip32_xprv": "xprv9s21ZrQH143K38isYxBNfJ9eiWHpKNAckfK1KDKUZXmh1CrexvufYhPnF4LCsHrSEnqeTfwd3CRs7se43mCtAUftVSiTy11m14b4fcRHhUr" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 氏", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "a95b822166e3d601775488da5148719dec79e1917855e220be56da294b83c91c5909411ff9a39ac2347ae0c8c1c166e3af2b41ce36ad8d5abe2376ec3aa5ff38", + "bip32_xprv": "xprv9s21ZrQH143K3gEPrY8ZXWq2kjWRqDvscSvc6uBHjsB7N9yrVCrYYnF8hA11cydFec2TzQJTBFv1NwttqSqv4tKc3UmxRg7ooUUrS5CADCF" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 良", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "744d58a74748deea27eb6511846d49515cfcae0bff31a49d2798fc3cce1a79bfe9f0b452dd84b10a40034f589adb181a9bfb1f82bfa52d0c7ae574acdcffd880", + "bip32_xprv": "xprv9s21ZrQH143K3RxGzZEMJ3pi2Ux53oYWK2onJWmCM1aRSAsvFDXSi57phHfFxYxGZ7XfZBe7iGid2LagtAU3gHGGALrtG7q5ep5U9fbLnVo" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 拍", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "eef28b231d319e4a9f01849d71763d2ff242651f7073b475540a9614c1d7b9f4c1e50c8588116fc279b4305cf255a1a56dfcb42531f68cbcaf10248772975892", + "bip32_xprv": "xprv9s21ZrQH143K4YFXf6RDY6xcX85so7g29vZ8Zhfvh7oDNWkvWugZB5Fv8Zs27XmY4Gu5Z9BN36QxPjHgSxaF2DM9fa59M7SQ1u16oxjGvuN" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 既", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "943dd078f051d28c92f36d6a8aa11416f27d45f338429b1aff1504efb84c97d47d228c1d601088adf709d187984a5fe3b01e35b11dc24d5019741035fa96e51a", + "bip32_xprv": "xprv9s21ZrQH143K372d5Maaj4NkHmb6aLh8hGtjCWA73eMUV8DJdB3ohZGFQVRSckFMJWHq7uRwUDzSR65yaMJhk23PnqEa1RTjbp8KZFjQX8Y" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 腰", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "8847533fe7f092bbbc90ed676f88a468128a890d7f8e14e73866ded9400c8c11e1fa80b2d85bf784f6dd0d8306c892a60ff37c8cd5620174e9852d6a30f044bc", + "bip32_xprv": "xprv9s21ZrQH143K3YLddFSUUnYAxGJN7eKfdXJUfZqTtAJinBYnZojgQgN9YKVeb7dur4cMnkwSARs5Tt1Znuo4YVjfds9dL2iVwm9L54fWJkr" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 让", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "79f70b496bcc4daf86de9417d8f261f2dcd73f5fa2e7d6088efd68bf5413ca977fe67ecb71b4b3ff217ede3dbcdb864856ce4db992f0cc8aeb112d5b04fd9597", + "bip32_xprv": "xprv9s21ZrQH143K4V2zMmnSDxUuCfneZ3CWniZiSicbWtv5dTKSfSHQHEef8evTJGz9gHmQRsZeTffsVBrYxsEyBCb69MXUpsf9Lrin3wn8KJM" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 森", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "7aeb3d6cca2e787856722599def8731453781f4f80da0a34593365a2cbf82c3c3fbe74f8d40afda6d3b04ff88c85281e3c87bafb1b4635b59a323b9d389333fd", + "bip32_xprv": "xprv9s21ZrQH143K25ch2i366x7stASW4sCrWTFGS86Ex9BAqFw3gLHguc2QzCmpLVw5u55u9XM9HcZwx21gSoaGSVx2RpEpMg1h3dxqVG2cbvr" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 让", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "733bd2103d03241067d0fecee93e59bcb03c97097e94985706ed4a6693fe623f7fe1b9ca24ca30962e787dd91a200350fcd42d10301eb48d1393e301cffe25ac", + "bip32_xprv": "xprv9s21ZrQH143K2bjuPotrbpJWzaBpT7WVj58vJPF4Vw2QsnRXMJxEp9ME75zzu1errQ55oYNo1ocVPS9EVgc8G9EXSftsDWE4ombLGkumW65" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 琴 轴 奖", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "0e810c1f122835c1afea36761558f9f884e34bc72e76e9a1c06e62bcf32ea248c176385343173ab655854c08ed5a3ef102b675eabd5654f26f621cd5aac1e14d", + "bip32_xprv": "xprv9s21ZrQH143K4WL4SjWT5XLz6xHtm2sXp5tkUa5gBXfNKfR6yMBQ8WKjsV4CpS5GTSLWNMLMULrEdzAHDKxGsN1cmQG1b6rMgd42ghH6w9d" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "蒙 台 脱 纪 构 硫 浆 霉 感 仅 鱼 汤", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "61c956de6d052a168d87d3c693f9d3d752b44ccb4ae4c921ec3cad48d64bbd35dbba8265f3db4592f730d2c0df8f765340b331463f2a8e4c681956d1f3719c81", + "bip32_xprv": "xprv9s21ZrQH143K3JvNCLt4hRjy3GETSQu8F4bdf16XTVcJ5uijUmDrxFGGdrFwD3fXFe82ZMcZHgigw1LRvRaVHpLk5TXc44CeTnPJpm7uZyP" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "父 泥 炼 胁 鞋 控 载 政 惨 逐 整 碗 环 惯 案 棒 订 移", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "ca508bd8f0bba5c53899571c6435d2cd0b679ac61b0463b7f95bf1fd10566a17931475b45f1ba7d10f555a9ae2a9d792ef350bdf5bd0d99123f610547a763daf", + "bip32_xprv": "xprv9s21ZrQH143K3UFwN6Kmb2STcCRM63PkVJoG8dgK6kfhn1cDi4LNsGH4nSuma5uSLPHNbUyonZzDLKs8XZmNUkGggrVfohZ3U6SZmdsQkDu" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "宁 照 违 材 交 养 违 野 悉 偷 梅 设 贵 帝 鲜 仰 圈 首 荷 钩 隙 抓 养 熟", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "3ddc4fbc8161d2e3c69cdd03531fd05ef21ad9ea516500ed69a8a6e7746f308e3ea86a6a6a666f527b1e625726d60c2899b6d0b4e526e67bb3c60223296d03f4", + "bip32_xprv": "xprv9s21ZrQH143K33u25a416wE5m6TAouwATstWoff7QXENqcABtPK6C1oYcb2pvqShsEFtbUjMoUY5aZbTmcmSkXXu6bYq4xCNzF2XUdNPTfA" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "懂 艇 细 斥 早 目 湖 造 笼 祥 逮 未 置 胞 损", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "18466eba6abd8cca53b0b5702fee7b668059f87063089401d0462a5ec11314582b89a17fa018c0c4e572c8a34e3755057ccba179e9c0015792bb27eaa3c58df3", + "bip32_xprv": "xprv9s21ZrQH143K3nucHk35PU1wWo4E73Phg6d2p7Zkx8h35nXwBAYJwj2GPJ29TtNyHg6zfiGJiCHXNGfB1UhGwkwGfNNMtvYXonJy9RKCasz" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "轮 醇 毕 跟 硅 隆 抓 仅 么 危 纬 约 尺 革 巩 泼 香 护 践 春 旨", + "passphrase": "nullius à nym.zone ¹teſts² 汉语", + "seed": "952fe4f30f671929b4532328ebc61f89b84f742453431fb2dc39571ed017c82ebc9212132808512d7c5ea78b310c0d716592b96d7349527eefc9deb784963d2a", + "bip32_xprv": "xprv9s21ZrQH143K3DccAaLtGLD5wV59UuGWq7Ecc3mhZvAxYsnNCG1m2mY9yj1zAJV7TGUn529JkcHBxwCLwnJNGEKgsAfge4RccgizFVcHNan" + } +] diff --git a/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_tw.json b/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_tw.json new file mode 100755 index 000000000..720bd9373 --- /dev/null +++ b/packages/testcases/input/easyseed-bip39/bip39_vectors.zh_tw.json @@ -0,0 +1,317 @@ +[ + { + "entropy": "00000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 在", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "ffcbd7bdf4e8b8fdca65edf8eaa5d23495af24eef7ecb6ede130bb754b5a7db0e3ad0f365398d4ec57114bc443e96349aeae0556f345290cd77ef69244fefc9d", + "bip32_xprv": "xprv9s21ZrQH143K3vykqRXVwNCsHv4qehHP12ohWiJmoAU5DePHiyF6eLyxJHAxgJjvdh1djBmVBmeuxyaFvJuDNNHpxEBSuQmpBQhNdUEvLx8" + }, + { + "entropy": "0000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 地", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "79643600685d29e90189a3824c11987638876cb52a09cec8a32a7c41dc7eac89e88182cbb9385309f880a96cfe49ee2a739eb3da5dfd936941ae4ffe6e764e13", + "bip32_xprv": "xprv9s21ZrQH143K4QvhoY5sn6HPGLRAziWigJBzFstcHDpWJ1VVFp8QSGP5KLeWbjSkPjGkVbKMMe7VX5ViiXPpWeeGzjUJYvzDw86UNSxjJJy" + }, + { + "entropy": "000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 動", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "e0064e96c5304d7db689e123370e1cb6595588bcbf37759b49bd7419f77da70777bb581a3d68370b21fbf1dbe5173d4eca26a1fd584f16b11d57598efed052f0", + "bip32_xprv": "xprv9s21ZrQH143K3FsUsUgZGeCzNpHDPLX3Zb4AqJHdEoTn7qrYSE64vB74MeTG9mFjQz5qNnvbPcn1e8aNfeNWkWbzbk4LrBXxNbP63mCRZ6y" + }, + { + "entropy": "00000000000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 出", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "3da50615797be8814a6412954f8c040ecf16daa3e6d59b42ca6707bed2989ca05d1d917a7bd9e7e057c962603f58f0c7943a7bba6766699b9b5149871a8a4cc6", + "bip32_xprv": "xprv9s21ZrQH143K3cxPc1em9nrJaEK7XfFyC8wKHKVWtiYCopueu4uVvJT8xTDMb95uRTMPHJKLTcYhRDTcjYtkgAutYw5LzeWLs5nYtyUaB7E" + }, + { + "entropy": "0000000000000000000000000000000000000000000000000000000000000000", + "mnemonic": "的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 的 性", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "a6795c3e0531fe201bf6b216bd54162e17c62eeadb7ff5e1f7c9c4a8d5b4b7f55008c865c2d43f76f9bb2bd407f99a2c9c2d38ba95ef74c0e79880fb84e553ef", + "bip32_xprv": "xprv9s21ZrQH143K2nhd2XxmcX42umD2MdDAJANkiKF96kPBCzCvkN3d3LwssRkiw3RsyCDea1b8m45uER2qbVGFmn4g8QLYCrFcHhW5UfaagP6" + }, + { + "entropy": "01010101010101010101010101010101", + "mnemonic": "人 三 談 我 表 壤 對 據 人 三 談 於", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "e675aaeb5f62b32d6c4926091765681ec89dbb358668bf913435d11bd7e1fdf35c32a7d65480e8ea82e044df0ea8e696c0320a62409a3229b83edb34f64869c4", + "bip32_xprv": "xprv9s21ZrQH143K2esM1rEVA48qT3fvxcu8H7TpNcxHQjpM8QMWS2ZbQaxtFmzHHWjPHX5az25GwVmvP5aArLR231wqHW2BJktAJZPauD4mida" + }, + { + "entropy": "0101010101010101010101010101010101010101", + "mnemonic": "人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 而", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "ee8581f8a234efd53a4a2e7e886cff8cd1563f3699d5e504d4881a911dd72a5335a6c059725950e75ffc9576d1fe38ce7cec5e43158cf83624ded5091e33273d", + "bip32_xprv": "xprv9s21ZrQH143K3My1E5K4KqVSTjbAGPz6scVpRPfzoTddMz8r74Boh7bEKdyuNRnTpmzEVSxSwaEqNiGdKT3BbFtUNx1W8ffvkKhfFk1E4xB" + }, + { + "entropy": "010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 據 人 實", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "5bed36f80142daffe16df01060f1417b8cb61aaec03fdc4c9600c7114768b43d295c558ffd0dc6d2a83bf79709be3e3e3c0aa3beeb359bd36d039a6582912f1b", + "bip32_xprv": "xprv9s21ZrQH143K4RV9PM8aamcfgnFwafJeU975gJ8xnozffyd59tnLAukiro5YZjJAJsWWb5Qa9iDL8uy4tuqJbYo9WNzvaY7y4EANyCYFoYF" + }, + { + "entropy": "01010101010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 原", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "4bd83974d83b702587096ca4a2b9d8b1c0b3811372ced9503c437d298e9f96467c1dc262c4d0caa9b083b9a2dbafc40dd55fe3644e88bb56f0611746af2a8362", + "bip32_xprv": "xprv9s21ZrQH143K3gsWqLoXDNEbsawcr5WZSYJMpDKBDT1MHT8ERkLtE5cCc747qMZUsXF1oLhUP1FKbs9FFYVjwi95qV6NxsqHDQVuDGBkxDu" + }, + { + "entropy": "0101010101010101010101010101010101010101010101010101010101010101", + "mnemonic": "人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 研", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "090994ff576ec6d641fa46b71821a9df7a284b0b97b8be12cb9386e5334d6f7eb8dab4c5e00c5ba0d9d0bb76d457c27971f2bc95c159fa74c781ffd9727962e7", + "bip32_xprv": "xprv9s21ZrQH143K3F6gQQbPngJLbV1as1owZioxyoKjbNBCWc46zZm3HB7hvfG19UuEsw8Tuzu6zpoAWegmhh511NtZJzLG3sbG2xUqvEq1iCK" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 卿", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "fa5c00f041f13d84d85cb2374bf544bd4fed781656af851ed1ba3e8307f5b6d6f70a9e23f962a9c14fa8b74a945c56eaea89ecce4ddadfb8aef813d16c227d9d", + "bip32_xprv": "xprv9s21ZrQH143K3WEVo9vrNmNpJ7SQx8hUJ4E3HWV65EMUTaWcCGWgQBZa45tnSxePrA9Rpw54biPmmmhgYZ55hR5wsSLbpnAVGdqAycA3XtA" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 沫", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "2976bc4eae7859b15c063983f6e8e7b6c85e8ab60403c01c5bfc7b2eab33d33b413a921136656d7a5a0a4acd86d90eeaa042fb57303de7e86b993bb115e53775", + "bip32_xprv": "xprv9s21ZrQH143K3XvvXtRPdzj5Y1mxd3dnBjENxYrrWp1oaeGtnYegHAJg7r4t7vsKwQZj3yT3p8JvHVshKUs2TonCevFNGDVJXZ9SCtFb93V" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 殿", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "ad3f915afa61165e670ef77a8e44e5614b563e8073a25ebc4e4f937d0cdcb0c998365890868b85ff83dc7d10a681fd09f4f1c2ef5d74f0c288d61a591835c9ee", + "bip32_xprv": "xprv9s21ZrQH143K48Tqe3GDX2kygZMH4ygMVSTEpoYTaRyvprVE8Hyfvm3XjuRVgWpdh7ZovNDSzxQyxwBmwhJzdwDexueMY5dnHzYW9Sn4Khs" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 盈", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "30511f67b3ef770fa315ebef96822e64026ccc9d1dd1030eeccd8397998730408077a4fd831e4a881796d699c1c71a56a5242f20b6a9df38e17db5069d2dd67b", + "bip32_xprv": "xprv9s21ZrQH143K4VKLpxqJ4sFhMSeYS9kvdv2QPDsd4KMJcSXrPPsZbTQJ5eVkKJurAyckYYFhQTnCAghgeCnQRTUG2bDSAU9vbFSsxrbrBZ8" + }, + { + "entropy": "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "mnemonic": "槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 搭", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "0bb96a63950eabb97ee63baf9a4eb4992939da546a369b052baa29a1627dc6b5ef12fa20e50c6983fc7cd9b7b7e2536c5d1565b6c716721f5516a21ffd0ecf1e", + "bip32_xprv": "xprv9s21ZrQH143K4R9PcneA9LCdbLN4qM8xCEX31Yn1DPrGAMHzw6aHuq9tFrLNdQuVFDoPCSd37tp1UHYPVZQWBjXTVrEQQagHH5gdGdjKdyf" + }, + { + "entropy": "80808080808080808080808080808080", + "mnemonic": "壤 對 據 人 三 談 我 表 壤 對 據 不", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "fc6b7f0e517ff0a75ad00789dfac1a0fe83ad622366f0034cb777fe421a45f396ac8e25305ec60eae9b9c7ea1b759cadbcc854a10232d336af3885445764531a", + "bip32_xprv": "xprv9s21ZrQH143K2V4U94YmLpmbBwYGQbiBxToG9PCrREgMnmuY395UDUG1Zs2ctERCzgSQwqM8E9k1j2pMESRnVPGQKTddH4AmpQev3QBxP7H" + }, + { + "entropy": "8080808080808080808080808080808080808080", + "mnemonic": "壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 大", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "0de3ad7d918e48a3551c99855e142c9e0d228a11a91b9b99d4662c738a776b1fa7fb9b236100c2baf9c3389f71e638320a9f87148c5efdc5283bacb781d5a773", + "bip32_xprv": "xprv9s21ZrQH143K3HuKDFMneZ1SMe1hir7KdPzmBWck8yaem7HjXD3vKCu2P1MiAiGdrQjmeYVzt2dPd7Kh6hAQq9MuvNjRsrcSPNN3WE9G789" + }, + { + "entropy": "808080808080808080808080808080808080808080808080", + "mnemonic": "壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 民", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "6b994ffd10af76495a2a3de4ba5b2bc750e96845c631749227b7254490dc210a584952831ef593ce3e8cd1b09e222dc94e8f453e7ad30b5c1f99ccd2088e95a0", + "bip32_xprv": "xprv9s21ZrQH143K2XJhgAf4kjmgPrE5p8tqoCoc1ygGEHjz26zLKxDWaDD3hxykiGyvKC9knjEQpUNUUNFgbNHAQmBVMDhK7KoCDGLq1oCAxPU" + }, + { + "entropy": "80808080808080808080808080808080808080808080808080808080", + "mnemonic": "壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 據 人 起", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "24d488e4bb7025b1d79de515350477f3e866a79b80a0d34c23f0449bc048685e7bafabc6812205da576f3ed54086f58c9a34f5fd8614567e5df9ef2c4e220231", + "bip32_xprv": "xprv9s21ZrQH143K3RASx1mZQi7jeVLqHLQSZ7zBvighdDx1WUytLU2cksYNGz5S26BxdWhsRNE4tEqvCj1k25fLr6uUoKvCdKisbVBacBBKhnw" + }, + { + "entropy": "8080808080808080808080808080808080808080808080808080808080808080", + "mnemonic": "壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 表 壤 對 據 人 三 談 我 五", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "f1bf5ea488ff2e720efe887f8b9357d345335689270beb80219cf3192474aae1e86e1a9e73f39d3f9065cc68a06a3d85582cf05e1349123baedf4c24940ce5fb", + "bip32_xprv": "xprv9s21ZrQH143K3eaW39PiyawaK42mico1MbAmkMTASSiccVwFL1VyUPma36va7SQxcjivGsc5AsgrXLsPJPcMTrHZfjp7Y19LU8NF8T58MHM" + }, + { + "entropy": "fefefefefefefefefefefefefefefefe", + "mnemonic": "嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 皺", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "018f3752ba1760be86a65337731de5eab0e11af028fc3247f22e7104739f98f94576ea0131715d0cbf0c6ea1f40a40b6aeccbb3b3f595fef64c6e1945f38f354", + "bip32_xprv": "xprv9s21ZrQH143K2pwJidqxs1Dp9wbMNjYeJWPWz6hJkq5S6X1JsFmbS537PYPt2dfvNfumFv13TVe1U1S96HTgcMQHuK5cqh1ZoejatwCpKCU" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 曬", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "b23d95709c974f4282adfe1ee4b95482b76b19cb6566ba0f8044aabe0d4df1007d892ccd6af7590860177c378ae87ce7fda5a6d284c7cffae1f0ac5ac265a999", + "bip32_xprv": "xprv9s21ZrQH143K3mDprcxhB5Yzc6D16MHJrQJLZQRLmGuHQr6sTTeAeiboVa438tV6VFCMiKaPGPmPwtYovYCmvXQMRNBZqyhosSHegDcDeEA" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 潑", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "1cd6544b7e0b6cee61b94811dfdd32a2ef89db0157212d02966bdb8d0ffcfd8e83c086c4e6754606c5d37a8246556c9b98fd1fb5481384de280d074f05c17420", + "bip32_xprv": "xprv9s21ZrQH143K26EXyqPCMVzj2bj2yVtN37Zbg4gZ6L14xrGZctJRKCTXjxTGUzGAr8TpfKbBebivmSaVHciC3PKBZQRdYE9pa714Zv3bTZF" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 坯", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "7120d92e00f3f86516658d11c694415ec72986c6ff2e446b6c1f58fc5d878dc83f52f6908eadc305bee470bd9856d4c319beb9f9ffda7f91d37922b06fc287a3", + "bip32_xprv": "xprv9s21ZrQH143K4LivfWgKkDT5ftdjYuJ7YCnZsJKHva5i2niXu9rvcMFRGyPV6kxv6mWtkRKd6Cry9TRBbdq4ECHUDVaWdyuzNrBoFJvdrwR" + }, + { + "entropy": "fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe", + "mnemonic": "嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 黴 嘗 倆 鬧 餓 賢 槍 疫 蓄", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "82cc20b41e3a2fcdfa0d5a5d9cdf3997f995be1bac66da4ab4b7e592353fbf83aa071e643034e161bef23eba4e7d4ddbaf4dc36800aa0243ce415fdd421252b0", + "bip32_xprv": "xprv9s21ZrQH143K4S59HQurGv1GPK3JU3B5AjHhguVvR16bMk9MebCJsoyJc25rPX3o1xTNg36QDnN1UjnDQZddvdz5o1PRPwFaEuz1qa2Wc6x" + }, + { + "entropy": "ffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 邏", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "8483090d4ebb5d95b067dd79700f99a7dfca5df072d99c53435d50d4f658ed5c25a6cbcf3d0cd2f558507bd23ecb3cbe938dd4c281a145e0356d702888ad86fb", + "bip32_xprv": "xprv9s21ZrQH143K2JHJbzrJA6dpxwyCSDiG42MutxtMQKu4AR79Xq57yzP6PnJuob8T42n2U1yp9WiekpnPLiE8b4yTVB85quUH6P9mhn3dxYF" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 溜", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "ea7ef94655a0818bedb430249a7542bbe8c2a2555a48ef76314b34eafd617f79128b0478aa725be8aae40fc1dd9b03b3c829695f667fd3f1550d95ed4e16180c", + "bip32_xprv": "xprv9s21ZrQH143K3jUVX73JGu4iwATbqTfFBpCyPH7KjGgUSZuGPoNzsqPQq7qNXjudT8LZBJSGRmwi122y4WFG6vnZmEpondheP1qke4CqGm6" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 裕", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "aef1e2d2def86ef048137c603f9316fc4b02b15365560c9e42b676e7a66e92f044de16d76158012030fb891ecc49fd70d842b5034a513fe892d6b02b69d14254", + "bip32_xprv": "xprv9s21ZrQH143K3JDh5HEyC27mUae1VQYm2jsurqfuZ3kvcQL9BWcZAnp4CBMCidkD2BzWowUrzcoNuuqozXgVUjqTHLi4U5t4KmbjGifsQpL" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 躺", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "5f52270a16f76d650b58397a98ca62c651c8092385bb59c1dc55aed74d77bf2f9f44e3f427a546adeb14ea88fc9f6db5686f6a150eaec37e2338836b70e4cff8", + "bip32_xprv": "xprv9s21ZrQH143K3xMQ84y2Fw3iq1Npy6hRiUxcFcXppRvrxLPsej51AmSmLzpBEZPXLhjx3AGaZCFW3xf3YpJirypzc3ySmPdpo6duwBQ66fj" + }, + { + "entropy": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "mnemonic": "歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 歇 佳", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "31b0fb9c9f0ce630d36dee706ebef9c4de58f4d418ef19b1568ab0b6cbec3dd50e99d972e308c684b8da38c98a54eb57945067f89d677652c750dd4c429aa4a3", + "bip32_xprv": "xprv9s21ZrQH143K3Mhe5DxXdEfkcZnmhcJ7RY9usXq6JD5sJ4YG1S2aiEEZPrsQueyPz4gbsWTDadPbv2sYuCQmzoWj2iNkeQCNDB1Ban8cYtJ" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 找", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "fc86a668066753181dcbac79e6ccf49c1c5526623f8be769f3b9eb3424293dddece99ec28d2a52b5b0ef4db3fc5f15b1993d663c9b0094778d46d3b8bf2a8e96", + "bip32_xprv": "xprv9s21ZrQH143K3TBhHsNpHMLSsfnNQVDBN8bvHmq6zCqEMqmE6VRrJgRRnwtyfSF18TjAM6vtx6W3WR1YRKKbf3tPpakUeHR9WnzYupC97Sy" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 氏", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "9c2e64140fbfe072c1e5f81f9b5c6498820a21843ea315ea338730181f961932b70ef4357948e8b07efdefc647bb656f292a4d3aedb1f9b40c6ff6c5df25cfe5", + "bip32_xprv": "xprv9s21ZrQH143K2PkgTb1dGG39333aHxcawggsammahuG3ZMmPEiJ5Qb781pesVUabLnHvj9zVLufhewyjigqnetZnRxx1ZH8wUvhoRfjiA9e" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 良", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "187c3cfc46a1e81035d8fdd50e3b4928a9de8bfaaad99720324e36669f91464a3accbf4f3fafceed0be03bb91844165b3f6365dec5dc5dc915069da22f1ac298", + "bip32_xprv": "xprv9s21ZrQH143K49ttyZ6CVEN4LNWxmAHiHLhEWvfbmsUzc2XYdA8oFVVk6sRXMZNxALabz7dUjScG2k1xRx4fzMKUyNuF6G1QVCHFBW5CXSa" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 拍", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "d71136f9838f15c76084781902b38cda51f1ebb422ba5f424a8363627d3841f521397fd9ee583a842eaa476c82d90e481c67a3f5fcf19f7e5774820186d9fed8", + "bip32_xprv": "xprv9s21ZrQH143K2bi4gaKr6QuKvwyo8dkYVm5oPxRchADpCTgYbJPWjCB5MvcSQiKNC8TrSf3wFmbbCAGfoCbL7j4kh12BJ9AtyrpxNe4m2y7" + }, + { + "entropy": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "mnemonic": "琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 既", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "e0270f1f594afa411909db038c338d8276f0ccb1a03473704b0fd8f5d6098baf36888ea7506202ba0c5303fd436735792fac150a5457af17a7e865c77e0b6e73", + "bip32_xprv": "xprv9s21ZrQH143K2vinfZUW7pWVq37B8R48CHWFBdnhQpHMAFjnUnRabYmUQR98Tgf1uk9ZHdyJvAjamsppT1jtjDNBxZfKu92V9vWeE6nqMvC" + }, + { + "entropy": "55555555555555555555555555555555", + "mnemonic": "軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 腰", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "4c18b927aed8436dea6c9d306b90c7df3f1dd90587422d97731a3406910698b4d6c417a19948776bae1834b892ca710da740356b79aec790109eca267c52f1d7", + "bip32_xprv": "xprv9s21ZrQH143K43ie5WmxhTc13SNu8kn2PyJa42cYYGhaHo4pL5V73dkxUGq56KBVbyb6vavRRXFJNnwY8g8kXKHgJymW9jPAyzpafyb4pW9" + }, + { + "entropy": "5555555555555555555555555555555555555555", + "mnemonic": "軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 讓", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "27483cd991a82cca06dd0eaa41f2cc7f1e1f4412787bf7d7f232361123f9ca7790d38eabe03cf3d81c60fc84943a637f8b848bf8a2760e6e1e85d71e5f46f1e4", + "bip32_xprv": "xprv9s21ZrQH143K3fUHyWqGagnwqsTaVAdp21hz6Avke6bWUpe1YGbFFbe3dR89kPT6U4BQdGPgcPapwYviokqjA3wf5jjFBQcC9PfGVW7wuxD" + }, + { + "entropy": "555555555555555555555555555555555555555555555555", + "mnemonic": "軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 森", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "ddde40fc505a58764a92d8fa74b06bfa8486cf9ecc1a6532887a2b75a39eceb55e55ac4c10be6605aadaae45f7ff6c2243e2b2c29f02c56c4b2852ce5db06f51", + "bip32_xprv": "xprv9s21ZrQH143K44wsRvcPyhXkGCmfdD1ZXeaSEuQzeGxtYBhx83AhQhUmDxue9r2nMkAMPPvucHNXzEGbELKgfYCnUvoRM5cv8tzzKfrZNHr" + }, + { + "entropy": "55555555555555555555555555555555555555555555555555555555", + "mnemonic": "軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 讓", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "f50d5c2d97b377a0e2fdbf4e3fa3994bf4b285c4428ec99f0f0310ecaa43d9d5a670160478465d54719478e5365ec9a3a096245e5653990e5554c4c90ef2b264", + "bip32_xprv": "xprv9s21ZrQH143K42ArFkxRVV5ZFPyhRRcBFEuFbdrxrAponHHWsJ5sgH56Vf5ZaGS7uvg3KRRNZMthm4gPnDDrwsXfUnZFzq72Z4yVih419gP" + }, + { + "entropy": "5555555555555555555555555555555555555555555555555555555555555555", + "mnemonic": "軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 琴 軸 獎", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "aca6b7cab8613a28665b0ad6d671e0348693a1629febd5a2debd83a1fbfe80c657fb6adbdefac8665f19b2d41d13e874164683ac912dfb5adbb302037c37344f", + "bip32_xprv": "xprv9s21ZrQH143K2wDx7i9N4aepezLWq2xTRrjBDJrsJ4NLvFz5j9LBLV6M7B4D3Xeh6YqvmuCRjRjNXpuXXUZRcwQAS6UEoUD5twM1noPeyVt" + }, + { + "entropy": "9e885d952ad362caeb4efe34a8e91bd2", + "mnemonic": "蒙 台 脫 紀 構 硫 漿 黴 感 僅 魚 湯", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "b51d582ab7007956cd310ebf342c93e0efa5ceeb86dca2ed85c8942fc3420cf4278d0b4c171b430af7c93c9945e6ae6a4ea02d984fdb0861864c559ec38abf07", + "bip32_xprv": "xprv9s21ZrQH143K3Q1xM7LbqhNj66c74dHmJrfb7ref9MvjVkMgSkfZzou1Wn5nBhATqXWyUwJByqfT4mz7WTmiP5rbB1GjuNhZbh99rr1mUWp" + }, + { + "entropy": "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "mnemonic": "父 泥 煉 脅 鞋 控 載 政 慘 逐 整 碗 環 慣 案 棒 訂 移", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "a36e504d8c1254e2eb632486397c3e14afc09adc79cf0e387ea62f98b45e1271ddc853651055ef06a4759457523669040e21066de748851a6b0b0a33e3360026", + "bip32_xprv": "xprv9s21ZrQH143K2UCcQKYBcjYeiju3rEeGq7F6ePp16ZJwp65RcHbfmLyGrK4XGDobvpuREvdzykJhf9ED64KLTvgEDnbEzFSHNGFaUGyyryE" + }, + { + "entropy": "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "mnemonic": "寧 照 違 材 交 養 違 野 悉 偷 梅 設 貴 帝 鮮 仰 圈 首 荷 鉤 隙 抓 養 熟", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "0177e904c38b9dd2722dfcf3fef64e513ad835d5afaea4b2f3675729b1ea281c9e13916a400b1b9e115ba13e738c92b3d51a7b3d020c13120851c6a83b5b5011", + "bip32_xprv": "xprv9s21ZrQH143K3s3kHEMcENfDSrCDBEex1B3FACztWXREkNAgtn5y7ZKSF4RA7s6rC49FYcauYGA7VhP8UMH8pFFTSVFNPVEZ1MwbbiMQvf6" + }, + { + "entropy": "b3ffe8f56d54805218090de337779328a3a2e758", + "mnemonic": "懂 艇 細 斥 早 目 湖 造 籠 祥 逮 未 置 胞 損", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "da352efb5b89a7a00f41efb037b4f911f15ac1cc5e61774f85db61208cfea98a1e8bfc3d0210d005dc1290714ec365521a74b8c49652d68ae5808737b81450f9", + "bip32_xprv": "xprv9s21ZrQH143K4Bh1WY87HePpcRdwNuqtkLJRNf4ECcLi1yayBt39S9GPWABo3CyWj7jqr4Fof7gJdDWNuRhNhUW342njAaFT6qz7guiRaF4" + }, + { + "entropy": "437dd688276ceb711cda3a126eab879a188a30b097b769a931bea6fe", + "mnemonic": "輪 醇 畢 跟 矽 隆 抓 僅 麼 危 緯 約 尺 革 鞏 潑 香 護 踐 春 旨", + "passphrase": "nullius à nym.zone ¹teſts² 漢語", + "seed": "59aba23fcf0e9e6439b256aa76b7bd70e06b6db7772a3e9e64cf3581d3bc68c670318a9c0c41b09beafbe67f5c3e581168dc2b9471bcfd8dd135d582409d9696", + "bip32_xprv": "xprv9s21ZrQH143K4CpADdDuSM5eintFqX4YqrprEvC76qupQ8f1kZUguXNzooCzi7wc6xe81khaYkZ8awrgbhnyumCFgzfgbPRxLPE7iUDndpS" + } +] diff --git a/packages/testcases/input/tests-trezor-bip39.json b/packages/testcases/input/tests-trezor-bip39.json new file mode 100644 index 000000000..c15add0e2 --- /dev/null +++ b/packages/testcases/input/tests-trezor-bip39.json @@ -0,0 +1,148 @@ +{ + "english": [ + [ + "00000000000000000000000000000000", + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + "c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04", + "xprv9s21ZrQH143K3h3fDYiay8mocZ3afhfULfb5GX8kCBdno77K4HiA15Tg23wpbeF1pLfs1c5SPmYHrEpTuuRhxMwvKDwqdKiGJS9XFKzUsAF" + ], + [ + "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "legal winner thank year wave sausage worth useful legal winner thank yellow", + "2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937a1c1069be3a3a5bd381ee6260e8d9739fce1f607", + "xprv9s21ZrQH143K2gA81bYFHqU68xz1cX2APaSq5tt6MFSLeXnCKV1RVUJt9FWNTbrrryem4ZckN8k4Ls1H6nwdvDTvnV7zEXs2HgPezuVccsq" + ], + [ + "80808080808080808080808080808080", + "letter advice cage absurd amount doctor acoustic avoid letter advice cage above", + "d71de856f81a8acc65e6fc851a38d4d7ec216fd0796d0a6827a3ad6ed5511a30fa280f12eb2e47ed2ac03b5c462a0358d18d69fe4f985ec81778c1b370b652a8", + "xprv9s21ZrQH143K2shfP28KM3nr5Ap1SXjz8gc2rAqqMEynmjt6o1qboCDpxckqXavCwdnYds6yBHZGKHv7ef2eTXy461PXUjBFQg6PrwY4Gzq" + ], + [ + "ffffffffffffffffffffffffffffffff", + "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong", + "ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069", + "xprv9s21ZrQH143K2V4oox4M8Zmhi2Fjx5XK4Lf7GKRvPSgydU3mjZuKGCTg7UPiBUD7ydVPvSLtg9hjp7MQTYsW67rZHAXeccqYqrsx8LcXnyd" + ], + [ + "000000000000000000000000000000000000000000000000", + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent", + "035895f2f481b1b0f01fcf8c289c794660b289981a78f8106447707fdd9666ca06da5a9a565181599b79f53b844d8a71dd9f439c52a3d7b3e8a79c906ac845fa", + "xprv9s21ZrQH143K3mEDrypcZ2usWqFgzKB6jBBx9B6GfC7fu26X6hPRzVjzkqkPvDqp6g5eypdk6cyhGnBngbjeHTe4LsuLG1cCmKJka5SMkmU" + ], + [ + "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will", + "f2b94508732bcbacbcc020faefecfc89feafa6649a5491b8c952cede496c214a0c7b3c392d168748f2d4a612bada0753b52a1c7ac53c1e93abd5c6320b9e95dd", + "xprv9s21ZrQH143K3Lv9MZLj16np5GzLe7tDKQfVusBni7toqJGcnKRtHSxUwbKUyUWiwpK55g1DUSsw76TF1T93VT4gz4wt5RM23pkaQLnvBh7" + ], + [ + "808080808080808080808080808080808080808080808080", + "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always", + "107d7c02a5aa6f38c58083ff74f04c607c2d2c0ecc55501dadd72d025b751bc27fe913ffb796f841c49b1d33b610cf0e91d3aa239027f5e99fe4ce9e5088cd65", + "xprv9s21ZrQH143K3VPCbxbUtpkh9pRG371UCLDz3BjceqP1jz7XZsQ5EnNkYAEkfeZp62cDNj13ZTEVG1TEro9sZ9grfRmcYWLBhCocViKEJae" + ], + [ + "ffffffffffffffffffffffffffffffffffffffffffffffff", + "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when", + "0cd6e5d827bb62eb8fc1e262254223817fd068a74b5b449cc2f667c3f1f985a76379b43348d952e2265b4cd129090758b3e3c2c49103b5051aac2eaeb890a528", + "xprv9s21ZrQH143K36Ao5jHRVhFGDbLP6FCx8BEEmpru77ef3bmA928BxsqvVM27WnvvyfWywiFN8K6yToqMaGYfzS6Db1EHAXT5TuyCLBXUfdm" + ], + [ + "0000000000000000000000000000000000000000000000000000000000000000", + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art", + "bda85446c68413707090a52022edd26a1c9462295029f2e60cd7c4f2bbd3097170af7a4d73245cafa9c3cca8d561a7c3de6f5d4a10be8ed2a5e608d68f92fcc8", + "xprv9s21ZrQH143K32qBagUJAMU2LsHg3ka7jqMcV98Y7gVeVyNStwYS3U7yVVoDZ4btbRNf4h6ibWpY22iRmXq35qgLs79f312g2kj5539ebPM" + ], + [ + "7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f", + "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title", + "bc09fca1804f7e69da93c2f2028eb238c227f2e9dda30cd63699232578480a4021b146ad717fbb7e451ce9eb835f43620bf5c514db0f8add49f5d121449d3e87", + "xprv9s21ZrQH143K3Y1sd2XVu9wtqxJRvybCfAetjUrMMco6r3v9qZTBeXiBZkS8JxWbcGJZyio8TrZtm6pkbzG8SYt1sxwNLh3Wx7to5pgiVFU" + ], + [ + "8080808080808080808080808080808080808080808080808080808080808080", + "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless", + "c0c519bd0e91a2ed54357d9d1ebef6f5af218a153624cf4f2da911a0ed8f7a09e2ef61af0aca007096df430022f7a2b6fb91661a9589097069720d015e4e982f", + "xprv9s21ZrQH143K3CSnQNYC3MqAAqHwxeTLhDbhF43A4ss4ciWNmCY9zQGvAKUSqVUf2vPHBTSE1rB2pg4avopqSiLVzXEU8KziNnVPauTqLRo" + ], + [ + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote", + "dd48c104698c30cfe2b6142103248622fb7bb0ff692eebb00089b32d22484e1613912f0a5b694407be899ffd31ed3992c456cdf60f5d4564b8ba3f05a69890ad", + "xprv9s21ZrQH143K2WFF16X85T2QCpndrGwx6GueB72Zf3AHwHJaknRXNF37ZmDrtHrrLSHvbuRejXcnYxoZKvRquTPyp2JiNG3XcjQyzSEgqCB" + ], + [ + "9e885d952ad362caeb4efe34a8e91bd2", + "ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic", + "274ddc525802f7c828d8ef7ddbcdc5304e87ac3535913611fbbfa986d0c9e5476c91689f9c8a54fd55bd38606aa6a8595ad213d4c9c9f9aca3fb217069a41028", + "xprv9s21ZrQH143K2oZ9stBYpoaZ2ktHj7jLz7iMqpgg1En8kKFTXJHsjxry1JbKH19YrDTicVwKPehFKTbmaxgVEc5TpHdS1aYhB2s9aFJBeJH" + ], + [ + "6610b25967cdcca9d59875f5cb50b0ea75433311869e930b", + "gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog", + "628c3827a8823298ee685db84f55caa34b5cc195a778e52d45f59bcf75aba68e4d7590e101dc414bc1bbd5737666fbbef35d1f1903953b66624f910feef245ac", + "xprv9s21ZrQH143K3uT8eQowUjsxrmsA9YUuQQK1RLqFufzybxD6DH6gPY7NjJ5G3EPHjsWDrs9iivSbmvjc9DQJbJGatfa9pv4MZ3wjr8qWPAK" + ], + [ + "68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c", + "hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length", + "64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440", + "xprv9s21ZrQH143K2XTAhys3pMNcGn261Fi5Ta2Pw8PwaVPhg3D8DWkzWQwjTJfskj8ofb81i9NP2cUNKxwjueJHHMQAnxtivTA75uUFqPFeWzk" + ], + [ + "c0ba5a8e914111210f2bd131f3d5e08d", + "scheme spot photo card baby mountain device kick cradle pact join borrow", + "ea725895aaae8d4c1cf682c1bfd2d358d52ed9f0f0591131b559e2724bb234fca05aa9c02c57407e04ee9dc3b454aa63fbff483a8b11de949624b9f1831a9612", + "xprv9s21ZrQH143K3FperxDp8vFsFycKCRcJGAFmcV7umQmcnMZaLtZRt13QJDsoS5F6oYT6BB4sS6zmTmyQAEkJKxJ7yByDNtRe5asP2jFGhT6" + ], + [ + "6d9be1ee6ebd27a258115aad99b7317b9c8d28b6d76431c3", + "horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave", + "fd579828af3da1d32544ce4db5c73d53fc8acc4ddb1e3b251a31179cdb71e853c56d2fcb11aed39898ce6c34b10b5382772db8796e52837b54468aeb312cfc3d", + "xprv9s21ZrQH143K3R1SfVZZLtVbXEB9ryVxmVtVMsMwmEyEvgXN6Q84LKkLRmf4ST6QrLeBm3jQsb9gx1uo23TS7vo3vAkZGZz71uuLCcywUkt" + ], + [ + "9f6a2878b2520799a44ef18bc7df394e7061a224d2c33cd015b157d746869863", + "panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside", + "72be8e052fc4919d2adf28d5306b5474b0069df35b02303de8c1729c9538dbb6fc2d731d5f832193cd9fb6aeecbc469594a70e3dd50811b5067f3b88b28c3e8d", + "xprv9s21ZrQH143K2WNnKmssvZYM96VAr47iHUQUTUyUXH3sAGNjhJANddnhw3i3y3pBbRAVk5M5qUGFr4rHbEWwXgX4qrvrceifCYQJbbFDems" + ], + [ + "23db8160a31d3e0dca3688ed941adbf3", + "cat swing flag economy stadium alone churn speed unique patch report train", + "deb5f45449e615feff5640f2e49f933ff51895de3b4381832b3139941c57b59205a42480c52175b6efcffaa58a2503887c1e8b363a707256bdd2b587b46541f5", + "xprv9s21ZrQH143K4G28omGMogEoYgDQuigBo8AFHAGDaJdqQ99QKMQ5J6fYTMfANTJy6xBmhvsNZ1CJzRZ64PWbnTFUn6CDV2FxoMDLXdk95DQ" + ], + [ + "8197a4a47f0425faeaa69deebc05ca29c0a5b5cc76ceacc0", + "light rule cinnamon wrap drastic word pride squirrel upgrade then income fatal apart sustain crack supply proud access", + "4cbdff1ca2db800fd61cae72a57475fdc6bab03e441fd63f96dabd1f183ef5b782925f00105f318309a7e9c3ea6967c7801e46c8a58082674c860a37b93eda02", + "xprv9s21ZrQH143K3wtsvY8L2aZyxkiWULZH4vyQE5XkHTXkmx8gHo6RUEfH3Jyr6NwkJhvano7Xb2o6UqFKWHVo5scE31SGDCAUsgVhiUuUDyh" + ], + [ + "066dca1a2bb7e8a1db2832148ce9933eea0f3ac9548d793112d9a95c9407efad", + "all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform", + "26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d", + "xprv9s21ZrQH143K3rEfqSM4QZRVmiMuSWY9wugscmaCjYja3SbUD3KPEB1a7QXJoajyR2T1SiXU7rFVRXMV9XdYVSZe7JoUXdP4SRHTxsT1nzm" + ], + [ + "f30f8c1da665478f49b001d94c5fc452", + "vessel ladder alter error federal sibling chat ability sun glass valve picture", + "2aaa9242daafcee6aa9d7269f17d4efe271e1b9a529178d7dc139cd18747090bf9d60295d0ce74309a78852a9caadf0af48aae1c6253839624076224374bc63f", + "xprv9s21ZrQH143K2QWV9Wn8Vvs6jbqfF1YbTCdURQW9dLFKDovpKaKrqS3SEWsXCu6ZNky9PSAENg6c9AQYHcg4PjopRGGKmdD313ZHszymnps" + ], + [ + "c10ec20dc3cd9f652c7fac2f1230f7a3c828389a14392f05", + "scissors invite lock maple supreme raw rapid void congress muscle digital elegant little brisk hair mango congress clump", + "7b4a10be9d98e6cba265566db7f136718e1398c71cb581e1b2f464cac1ceedf4f3e274dc270003c670ad8d02c4558b2f8e39edea2775c9e232c7cb798b069e88", + "xprv9s21ZrQH143K4aERa2bq7559eMCCEs2QmmqVjUuzfy5eAeDX4mqZffkYwpzGQRE2YEEeLVRoH4CSHxianrFaVnMN2RYaPUZJhJx8S5j6puX" + ], + [ + "f585c11aec520db57dd353c69554b21a89b20fb0650966fa0a9d6f74fd989d8f", + "void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold", + "01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998", + "xprv9s21ZrQH143K39rnQJknpH1WEPFJrzmAqqasiDcVrNuk926oizzJDDQkdiTvNPr2FYDYzWgiMiC63YmfPAa2oPyNB23r2g7d1yiK6WpqaQS" + ] + ] +} \ No newline at end of file diff --git a/packages/testcases/input/units.json b/packages/testcases/input/units.json new file mode 100644 index 000000000..83c0c0608 --- /dev/null +++ b/packages/testcases/input/units.json @@ -0,0 +1,138 @@ +[ + { + "name": "one-proper", + "wei": "1000000000000000000", + "kwei": "1000000000000000.0", + "mwei": "1000000000000.0", + "gwei": "1000000000.0", + "szabo": "1000000.0", + "finney": "1000.0", + "ether": "1.0", + "ether_format": "1.0", + "finney_format": "1000.0", + "szabo_format": "1000000.0", + "gwei_format": "1000000000.0", + "mwei_format": "1000000000000.0", + "kwei_format": "1000000000000000.0" + }, + { + "name": "one-bare", + "wei": "1000000000000000000", + "ether": "1", + "ether_format": "1.0" + }, + { + "name": "one-trailing-zero", + "wei": "1000000000000000000", + "ether": "1.00", + "ether_format": "1.0" + }, + { + "name": "one-leading-zero", + "wei": "1000000000000000000", + "ether": "01.0", + "ether_format": "1.0" + }, + { + "name": "negative-one-proper", + "wei": "-1000000000000000000", + "ether": "-1.0", + "ether_format": "-1.0" + }, + { + "name": "negative-one-leading", + "wei": "-1000000000000000000", + "ether": "-01.0", + "ether_format": "-1.0" + }, + { + "name": "tenth-proper", + "wei": "100000000000000000", + "ether": "0.1", + "ether_format": "0.1" + }, + { + "name": "tenth-bare", + "wei": "100000000000000000", + "ether": ".1", + "ether_format": "0.1" + }, + { + "name": "tenth-trailing-zero", + "wei": "100000000000000000", + "ether": "0.10", + "ether_format": "0.1" + }, + { + "name": "tenth-trailing-zeros", + "wei": "100000000000000000", + "ether": "0.100", + "ether_format": "0.1" + }, + { + "name": "tenth-trailing-and-leading", + "wei": "100000000000000000", + "ether": "00.100", + "ether_format": "0.1" + }, + { + "name": "negative-tenth-proper", + "wei": "-100000000000000000", + "ether": "-0.1", + "ether_format": "-0.1" + }, + { + "name": "hundredth-proper", + "wei": "10000000000000000", + "ether": "0.01", + "ether_format": "0.01" + }, + { + "name": "amount-fraction", + "wei": "1230000000000000000", + "ether": "1.23", + "ether_format": "1.23" + }, + { + "name": "amount-negative-fraction", + "wei": "-1230000000000000000", + "ether": "-1.23", + "ether_format": "-1.23" + }, + { + "name": "pad-negative-fraction", + "wei": "-1230000000000000000", + "ether": "-1.230000000000000000", + "ether_format": "-1.23" + }, + { + "name": "one-two-three", + "wei": "1234567890000000000000000", + "ether": "1234567.89", + "ether_format": "1234567.89" + }, + { + "name": "one-two-three-2", + "wei": "1234567890000000000000000", + "ether": "1234567.890000000000000000", + "ether_format": "1234567.89" + }, + { + "name": "one-two-three-3", + "wei": "-1234567890123456789012345", + "gwei": "-1234567890123456.789012345", + "finney": "-1234567890.123456789012345", + "ether": "-1234567.890123456789012345", + "ether_format": "-1234567.890123456789012345", + "finney_format": "-1234567890.123456789012345", + "gwei_format": "-1234567890123456.789012345" + }, + { + "name": "satoshi", + "wei": "-1234567890", + "satoshi": "-12.34567890", + "satoshi_format": "-12.3456789", + "ether": "-0.000000001234567890", + "ether_format": "-0.00000000123456789" + } +] diff --git a/packages/testcases/input/wordlists/lang-en.txt b/packages/testcases/input/wordlists/lang-en.txt new file mode 100644 index 000000000..942040ed5 --- /dev/null +++ b/packages/testcases/input/wordlists/lang-en.txt @@ -0,0 +1,2048 @@ +abandon +ability +able +about +above +absent +absorb +abstract +absurd +abuse +access +accident +account +accuse +achieve +acid +acoustic +acquire +across +act +action +actor +actress +actual +adapt +add +addict +address +adjust +admit +adult +advance +advice +aerobic +affair +afford +afraid +again +age +agent +agree +ahead +aim +air +airport +aisle +alarm +album +alcohol +alert +alien +all +alley +allow +almost +alone +alpha +already +also +alter +always +amateur +amazing +among +amount +amused +analyst +anchor +ancient +anger +angle +angry +animal +ankle +announce +annual +another +answer +antenna +antique +anxiety +any +apart +apology +appear +apple +approve +april +arch +arctic +area +arena +argue +arm +armed +armor +army +around +arrange +arrest +arrive +arrow +art +artefact +artist +artwork +ask +aspect +assault +asset +assist +assume +asthma +athlete +atom +attack +attend +attitude +attract +auction +audit +august +aunt +author +auto +autumn +average +avocado +avoid +awake +aware +away +awesome +awful +awkward +axis +baby +bachelor +bacon +badge +bag +balance +balcony +ball +bamboo +banana +banner +bar +barely +bargain +barrel +base +basic +basket +battle +beach +bean +beauty +because +become +beef +before +begin +behave +behind +believe +below +belt +bench +benefit +best +betray +better +between +beyond +bicycle +bid +bike +bind +biology +bird +birth +bitter +black +blade +blame +blanket +blast +bleak +bless +blind +blood +blossom +blouse +blue +blur +blush +board +boat +body +boil +bomb +bone +bonus +book +boost +border +boring +borrow +boss +bottom +bounce +box +boy +bracket +brain +brand +brass +brave +bread +breeze +brick +bridge +brief +bright +bring +brisk +broccoli +broken +bronze +broom +brother +brown +brush +bubble +buddy +budget +buffalo +build +bulb +bulk +bullet +bundle +bunker +burden +burger +burst +bus +business +busy +butter +buyer +buzz +cabbage +cabin +cable +cactus +cage +cake +call +calm +camera +camp +can +canal +cancel +candy +cannon +canoe +canvas +canyon +capable +capital +captain +car +carbon +card +cargo +carpet +carry +cart +case +cash +casino +castle +casual +cat +catalog +catch +category +cattle +caught +cause +caution +cave +ceiling +celery +cement +census +century +cereal +certain +chair +chalk +champion +change +chaos +chapter +charge +chase +chat +cheap +check +cheese +chef +cherry +chest +chicken +chief +child +chimney +choice +choose +chronic +chuckle +chunk +churn +cigar +cinnamon +circle +citizen +city +civil +claim +clap +clarify +claw +clay +clean +clerk +clever +click +client +cliff +climb +clinic +clip +clock +clog +close +cloth +cloud +clown +club +clump +cluster +clutch +coach +coast +coconut +code +coffee +coil +coin +collect +color +column +combine +come +comfort +comic +common +company +concert +conduct +confirm +congress +connect +consider +control +convince +cook +cool +copper +copy +coral +core +corn +correct +cost +cotton +couch +country +couple +course +cousin +cover +coyote +crack +cradle +craft +cram +crane +crash +crater +crawl +crazy +cream +credit +creek +crew +cricket +crime +crisp +critic +crop +cross +crouch +crowd +crucial +cruel +cruise +crumble +crunch +crush +cry +crystal +cube +culture +cup +cupboard +curious +current +curtain +curve +cushion +custom +cute +cycle +dad +damage +damp +dance +danger +daring +dash +daughter +dawn +day +deal +debate +debris +decade +december +decide +decline +decorate +decrease +deer +defense +define +defy +degree +delay +deliver +demand +demise +denial +dentist +deny +depart +depend +deposit +depth +deputy +derive +describe +desert +design +desk +despair +destroy +detail +detect +develop +device +devote +diagram +dial +diamond +diary +dice +diesel +diet +differ +digital +dignity +dilemma +dinner +dinosaur +direct +dirt +disagree +discover +disease +dish +dismiss +disorder +display +distance +divert +divide +divorce +dizzy +doctor +document +dog +doll +dolphin +domain +donate +donkey +donor +door +dose +double +dove +draft +dragon +drama +drastic +draw +dream +dress +drift +drill +drink +drip +drive +drop +drum +dry +duck +dumb +dune +during +dust +dutch +duty +dwarf +dynamic +eager +eagle +early +earn +earth +easily +east +easy +echo +ecology +economy +edge +edit +educate +effort +egg +eight +either +elbow +elder +electric +elegant +element +elephant +elevator +elite +else +embark +embody +embrace +emerge +emotion +employ +empower +empty +enable +enact +end +endless +endorse +enemy +energy +enforce +engage +engine +enhance +enjoy +enlist +enough +enrich +enroll +ensure +enter +entire +entry +envelope +episode +equal +equip +era +erase +erode +erosion +error +erupt +escape +essay +essence +estate +eternal +ethics +evidence +evil +evoke +evolve +exact +example +excess +exchange +excite +exclude +excuse +execute +exercise +exhaust +exhibit +exile +exist +exit +exotic +expand +expect +expire +explain +expose +express +extend +extra +eye +eyebrow +fabric +face +faculty +fade +faint +faith +fall +false +fame +family +famous +fan +fancy +fantasy +farm +fashion +fat +fatal +father +fatigue +fault +favorite +feature +february +federal +fee +feed +feel +female +fence +festival +fetch +fever +few +fiber +fiction +field +figure +file +film +filter +final +find +fine +finger +finish +fire +firm +first +fiscal +fish +fit +fitness +fix +flag +flame +flash +flat +flavor +flee +flight +flip +float +flock +floor +flower +fluid +flush +fly +foam +focus +fog +foil +fold +follow +food +foot +force +forest +forget +fork +fortune +forum +forward +fossil +foster +found +fox +fragile +frame +frequent +fresh +friend +fringe +frog +front +frost +frown +frozen +fruit +fuel +fun +funny +furnace +fury +future +gadget +gain +galaxy +gallery +game +gap +garage +garbage +garden +garlic +garment +gas +gasp +gate +gather +gauge +gaze +general +genius +genre +gentle +genuine +gesture +ghost +giant +gift +giggle +ginger +giraffe +girl +give +glad +glance +glare +glass +glide +glimpse +globe +gloom +glory +glove +glow +glue +goat +goddess +gold +good +goose +gorilla +gospel +gossip +govern +gown +grab +grace +grain +grant +grape +grass +gravity +great +green +grid +grief +grit +grocery +group +grow +grunt +guard +guess +guide +guilt +guitar +gun +gym +habit +hair +half +hammer +hamster +hand +happy +harbor +hard +harsh +harvest +hat +have +hawk +hazard +head +health +heart +heavy +hedgehog +height +hello +helmet +help +hen +hero +hidden +high +hill +hint +hip +hire +history +hobby +hockey +hold +hole +holiday +hollow +home +honey +hood +hope +horn +horror +horse +hospital +host +hotel +hour +hover +hub +huge +human +humble +humor +hundred +hungry +hunt +hurdle +hurry +hurt +husband +hybrid +ice +icon +idea +identify +idle +ignore +ill +illegal +illness +image +imitate +immense +immune +impact +impose +improve +impulse +inch +include +income +increase +index +indicate +indoor +industry +infant +inflict +inform +inhale +inherit +initial +inject +injury +inmate +inner +innocent +input +inquiry +insane +insect +inside +inspire +install +intact +interest +into +invest +invite +involve +iron +island +isolate +issue +item +ivory +jacket +jaguar +jar +jazz +jealous +jeans +jelly +jewel +job +join +joke +journey +joy +judge +juice +jump +jungle +junior +junk +just +kangaroo +keen +keep +ketchup +key +kick +kid +kidney +kind +kingdom +kiss +kit +kitchen +kite +kitten +kiwi +knee +knife +knock +know +lab +label +labor +ladder +lady +lake +lamp +language +laptop +large +later +latin +laugh +laundry +lava +law +lawn +lawsuit +layer +lazy +leader +leaf +learn +leave +lecture +left +leg +legal +legend +leisure +lemon +lend +length +lens +leopard +lesson +letter +level +liar +liberty +library +license +life +lift +light +like +limb +limit +link +lion +liquid +list +little +live +lizard +load +loan +lobster +local +lock +logic +lonely +long +loop +lottery +loud +lounge +love +loyal +lucky +luggage +lumber +lunar +lunch +luxury +lyrics +machine +mad +magic +magnet +maid +mail +main +major +make +mammal +man +manage +mandate +mango +mansion +manual +maple +marble +march +margin +marine +market +marriage +mask +mass +master +match +material +math +matrix +matter +maximum +maze +meadow +mean +measure +meat +mechanic +medal +media +melody +melt +member +memory +mention +menu +mercy +merge +merit +merry +mesh +message +metal +method +middle +midnight +milk +million +mimic +mind +minimum +minor +minute +miracle +mirror +misery +miss +mistake +mix +mixed +mixture +mobile +model +modify +mom +moment +monitor +monkey +monster +month +moon +moral +more +morning +mosquito +mother +motion +motor +mountain +mouse +move +movie +much +muffin +mule +multiply +muscle +museum +mushroom +music +must +mutual +myself +mystery +myth +naive +name +napkin +narrow +nasty +nation +nature +near +neck +need +negative +neglect +neither +nephew +nerve +nest +net +network +neutral +never +news +next +nice +night +noble +noise +nominee +noodle +normal +north +nose +notable +note +nothing +notice +novel +now +nuclear +number +nurse +nut +oak +obey +object +oblige +obscure +observe +obtain +obvious +occur +ocean +october +odor +off +offer +office +often +oil +okay +old +olive +olympic +omit +once +one +onion +online +only +open +opera +opinion +oppose +option +orange +orbit +orchard +order +ordinary +organ +orient +original +orphan +ostrich +other +outdoor +outer +output +outside +oval +oven +over +own +owner +oxygen +oyster +ozone +pact +paddle +page +pair +palace +palm +panda +panel +panic +panther +paper +parade +parent +park +parrot +party +pass +patch +path +patient +patrol +pattern +pause +pave +payment +peace +peanut +pear +peasant +pelican +pen +penalty +pencil +people +pepper +perfect +permit +person +pet +phone +photo +phrase +physical +piano +picnic +picture +piece +pig +pigeon +pill +pilot +pink +pioneer +pipe +pistol +pitch +pizza +place +planet +plastic +plate +play +please +pledge +pluck +plug +plunge +poem +poet +point +polar +pole +police +pond +pony +pool +popular +portion +position +possible +post +potato +pottery +poverty +powder +power +practice +praise +predict +prefer +prepare +present +pretty +prevent +price +pride +primary +print +priority +prison +private +prize +problem +process +produce +profit +program +project +promote +proof +property +prosper +protect +proud +provide +public +pudding +pull +pulp +pulse +pumpkin +punch +pupil +puppy +purchase +purity +purpose +purse +push +put +puzzle +pyramid +quality +quantum +quarter +question +quick +quit +quiz +quote +rabbit +raccoon +race +rack +radar +radio +rail +rain +raise +rally +ramp +ranch +random +range +rapid +rare +rate +rather +raven +raw +razor +ready +real +reason +rebel +rebuild +recall +receive +recipe +record +recycle +reduce +reflect +reform +refuse +region +regret +regular +reject +relax +release +relief +rely +remain +remember +remind +remove +render +renew +rent +reopen +repair +repeat +replace +report +require +rescue +resemble +resist +resource +response +result +retire +retreat +return +reunion +reveal +review +reward +rhythm +rib +ribbon +rice +rich +ride +ridge +rifle +right +rigid +ring +riot +ripple +risk +ritual +rival +river +road +roast +robot +robust +rocket +romance +roof +rookie +room +rose +rotate +rough +round +route +royal +rubber +rude +rug +rule +run +runway +rural +sad +saddle +sadness +safe +sail +salad +salmon +salon +salt +salute +same +sample +sand +satisfy +satoshi +sauce +sausage +save +say +scale +scan +scare +scatter +scene +scheme +school +science +scissors +scorpion +scout +scrap +screen +script +scrub +sea +search +season +seat +second +secret +section +security +seed +seek +segment +select +sell +seminar +senior +sense +sentence +series +service +session +settle +setup +seven +shadow +shaft +shallow +share +shed +shell +sheriff +shield +shift +shine +ship +shiver +shock +shoe +shoot +shop +short +shoulder +shove +shrimp +shrug +shuffle +shy +sibling +sick +side +siege +sight +sign +silent +silk +silly +silver +similar +simple +since +sing +siren +sister +situate +six +size +skate +sketch +ski +skill +skin +skirt +skull +slab +slam +sleep +slender +slice +slide +slight +slim +slogan +slot +slow +slush +small +smart +smile +smoke +smooth +snack +snake +snap +sniff +snow +soap +soccer +social +sock +soda +soft +solar +soldier +solid +solution +solve +someone +song +soon +sorry +sort +soul +sound +soup +source +south +space +spare +spatial +spawn +speak +special +speed +spell +spend +sphere +spice +spider +spike +spin +spirit +split +spoil +sponsor +spoon +sport +spot +spray +spread +spring +spy +square +squeeze +squirrel +stable +stadium +staff +stage +stairs +stamp +stand +start +state +stay +steak +steel +stem +step +stereo +stick +still +sting +stock +stomach +stone +stool +story +stove +strategy +street +strike +strong +struggle +student +stuff +stumble +style +subject +submit +subway +success +such +sudden +suffer +sugar +suggest +suit +summer +sun +sunny +sunset +super +supply +supreme +sure +surface +surge +surprise +surround +survey +suspect +sustain +swallow +swamp +swap +swarm +swear +sweet +swift +swim +swing +switch +sword +symbol +symptom +syrup +system +table +tackle +tag +tail +talent +talk +tank +tape +target +task +taste +tattoo +taxi +teach +team +tell +ten +tenant +tennis +tent +term +test +text +thank +that +theme +then +theory +there +they +thing +this +thought +three +thrive +throw +thumb +thunder +ticket +tide +tiger +tilt +timber +time +tiny +tip +tired +tissue +title +toast +tobacco +today +toddler +toe +together +toilet +token +tomato +tomorrow +tone +tongue +tonight +tool +tooth +top +topic +topple +torch +tornado +tortoise +toss +total +tourist +toward +tower +town +toy +track +trade +traffic +tragic +train +transfer +trap +trash +travel +tray +treat +tree +trend +trial +tribe +trick +trigger +trim +trip +trophy +trouble +truck +true +truly +trumpet +trust +truth +try +tube +tuition +tumble +tuna +tunnel +turkey +turn +turtle +twelve +twenty +twice +twin +twist +two +type +typical +ugly +umbrella +unable +unaware +uncle +uncover +under +undo +unfair +unfold +unhappy +uniform +unique +unit +universe +unknown +unlock +until +unusual +unveil +update +upgrade +uphold +upon +upper +upset +urban +urge +usage +use +used +useful +useless +usual +utility +vacant +vacuum +vague +valid +valley +valve +van +vanish +vapor +various +vast +vault +vehicle +velvet +vendor +venture +venue +verb +verify +version +very +vessel +veteran +viable +vibrant +vicious +victory +video +view +village +vintage +violin +virtual +virus +visa +visit +visual +vital +vivid +vocal +voice +void +volcano +volume +vote +voyage +wage +wagon +wait +walk +wall +walnut +want +warfare +warm +warrior +wash +wasp +waste +water +wave +way +wealth +weapon +wear +weasel +weather +web +wedding +weekend +weird +welcome +west +wet +whale +what +wheat +wheel +when +where +whip +whisper +wide +width +wife +wild +will +win +window +wine +wing +wink +winner +winter +wire +wisdom +wise +wish +witness +wolf +woman +wonder +wood +wool +word +work +world +worry +worth +wrap +wreck +wrestle +wrist +write +wrong +yard +year +yellow +you +young +youth +zebra +zero +zone +zoo diff --git a/packages/testcases/input/wordlists/lang-es.txt b/packages/testcases/input/wordlists/lang-es.txt new file mode 100644 index 000000000..fdbc23c73 --- /dev/null +++ b/packages/testcases/input/wordlists/lang-es.txt @@ -0,0 +1,2048 @@ +ábaco +abdomen +abeja +abierto +abogado +abono +aborto +abrazo +abrir +abuelo +abuso +acabar +academia +acceso +acción +aceite +acelga +acento +aceptar +ácido +aclarar +acné +acoger +acoso +activo +acto +actriz +actuar +acudir +acuerdo +acusar +adicto +admitir +adoptar +adorno +aduana +adulto +aéreo +afectar +afición +afinar +afirmar +ágil +agitar +agonía +agosto +agotar +agregar +agrio +agua +agudo +águila +aguja +ahogo +ahorro +aire +aislar +ajedrez +ajeno +ajuste +alacrán +alambre +alarma +alba +álbum +alcalde +aldea +alegre +alejar +alerta +aleta +alfiler +alga +algodón +aliado +aliento +alivio +alma +almeja +almíbar +altar +alteza +altivo +alto +altura +alumno +alzar +amable +amante +amapola +amargo +amasar +ámbar +ámbito +ameno +amigo +amistad +amor +amparo +amplio +ancho +anciano +ancla +andar +andén +anemia +ángulo +anillo +ánimo +anís +anotar +antena +antiguo +antojo +anual +anular +anuncio +añadir +añejo +año +apagar +aparato +apetito +apio +aplicar +apodo +aporte +apoyo +aprender +aprobar +apuesta +apuro +arado +araña +arar +árbitro +árbol +arbusto +archivo +arco +arder +ardilla +arduo +área +árido +aries +armonía +arnés +aroma +arpa +arpón +arreglo +arroz +arruga +arte +artista +asa +asado +asalto +ascenso +asegurar +aseo +asesor +asiento +asilo +asistir +asno +asombro +áspero +astilla +astro +astuto +asumir +asunto +atajo +ataque +atar +atento +ateo +ático +atleta +átomo +atraer +atroz +atún +audaz +audio +auge +aula +aumento +ausente +autor +aval +avance +avaro +ave +avellana +avena +avestruz +avión +aviso +ayer +ayuda +ayuno +azafrán +azar +azote +azúcar +azufre +azul +baba +babor +bache +bahía +baile +bajar +balanza +balcón +balde +bambú +banco +banda +baño +barba +barco +barniz +barro +báscula +bastón +basura +batalla +batería +batir +batuta +baúl +bazar +bebé +bebida +bello +besar +beso +bestia +bicho +bien +bingo +blanco +bloque +blusa +boa +bobina +bobo +boca +bocina +boda +bodega +boina +bola +bolero +bolsa +bomba +bondad +bonito +bono +bonsái +borde +borrar +bosque +bote +botín +bóveda +bozal +bravo +brazo +brecha +breve +brillo +brinco +brisa +broca +broma +bronce +brote +bruja +brusco +bruto +buceo +bucle +bueno +buey +bufanda +bufón +búho +buitre +bulto +burbuja +burla +burro +buscar +butaca +buzón +caballo +cabeza +cabina +cabra +cacao +cadáver +cadena +caer +café +caída +caimán +caja +cajón +cal +calamar +calcio +caldo +calidad +calle +calma +calor +calvo +cama +cambio +camello +camino +campo +cáncer +candil +canela +canguro +canica +canto +caña +cañón +caoba +caos +capaz +capitán +capote +captar +capucha +cara +carbón +cárcel +careta +carga +cariño +carne +carpeta +carro +carta +casa +casco +casero +caspa +castor +catorce +catre +caudal +causa +cazo +cebolla +ceder +cedro +celda +célebre +celoso +célula +cemento +ceniza +centro +cerca +cerdo +cereza +cero +cerrar +certeza +césped +cetro +chacal +chaleco +champú +chancla +chapa +charla +chico +chiste +chivo +choque +choza +chuleta +chupar +ciclón +ciego +cielo +cien +cierto +cifra +cigarro +cima +cinco +cine +cinta +ciprés +circo +ciruela +cisne +cita +ciudad +clamor +clan +claro +clase +clave +cliente +clima +clínica +cobre +cocción +cochino +cocina +coco +código +codo +cofre +coger +cohete +cojín +cojo +cola +colcha +colegio +colgar +colina +collar +colmo +columna +combate +comer +comida +cómodo +compra +conde +conejo +conga +conocer +consejo +contar +copa +copia +corazón +corbata +corcho +cordón +corona +correr +coser +cosmos +costa +cráneo +cráter +crear +crecer +creído +crema +cría +crimen +cripta +crisis +cromo +crónica +croqueta +crudo +cruz +cuadro +cuarto +cuatro +cubo +cubrir +cuchara +cuello +cuento +cuerda +cuesta +cueva +cuidar +culebra +culpa +culto +cumbre +cumplir +cuna +cuneta +cuota +cupón +cúpula +curar +curioso +curso +curva +cutis +dama +danza +dar +dardo +dátil +deber +débil +década +decir +dedo +defensa +definir +dejar +delfín +delgado +delito +demora +denso +dental +deporte +derecho +derrota +desayuno +deseo +desfile +desnudo +destino +desvío +detalle +detener +deuda +día +diablo +diadema +diamante +diana +diario +dibujo +dictar +diente +dieta +diez +difícil +digno +dilema +diluir +dinero +directo +dirigir +disco +diseño +disfraz +diva +divino +doble +doce +dolor +domingo +don +donar +dorado +dormir +dorso +dos +dosis +dragón +droga +ducha +duda +duelo +dueño +dulce +dúo +duque +durar +dureza +duro +ébano +ebrio +echar +eco +ecuador +edad +edición +edificio +editor +educar +efecto +eficaz +eje +ejemplo +elefante +elegir +elemento +elevar +elipse +élite +elixir +elogio +eludir +embudo +emitir +emoción +empate +empeño +empleo +empresa +enano +encargo +enchufe +encía +enemigo +enero +enfado +enfermo +engaño +enigma +enlace +enorme +enredo +ensayo +enseñar +entero +entrar +envase +envío +época +equipo +erizo +escala +escena +escolar +escribir +escudo +esencia +esfera +esfuerzo +espada +espejo +espía +esposa +espuma +esquí +estar +este +estilo +estufa +etapa +eterno +ética +etnia +evadir +evaluar +evento +evitar +exacto +examen +exceso +excusa +exento +exigir +exilio +existir +éxito +experto +explicar +exponer +extremo +fábrica +fábula +fachada +fácil +factor +faena +faja +falda +fallo +falso +faltar +fama +familia +famoso +faraón +farmacia +farol +farsa +fase +fatiga +fauna +favor +fax +febrero +fecha +feliz +feo +feria +feroz +fértil +fervor +festín +fiable +fianza +fiar +fibra +ficción +ficha +fideo +fiebre +fiel +fiera +fiesta +figura +fijar +fijo +fila +filete +filial +filtro +fin +finca +fingir +finito +firma +flaco +flauta +flecha +flor +flota +fluir +flujo +flúor +fobia +foca +fogata +fogón +folio +folleto +fondo +forma +forro +fortuna +forzar +fosa +foto +fracaso +frágil +franja +frase +fraude +freír +freno +fresa +frío +frito +fruta +fuego +fuente +fuerza +fuga +fumar +función +funda +furgón +furia +fusil +fútbol +futuro +gacela +gafas +gaita +gajo +gala +galería +gallo +gamba +ganar +gancho +ganga +ganso +garaje +garza +gasolina +gastar +gato +gavilán +gemelo +gemir +gen +género +genio +gente +geranio +gerente +germen +gesto +gigante +gimnasio +girar +giro +glaciar +globo +gloria +gol +golfo +goloso +golpe +goma +gordo +gorila +gorra +gota +goteo +gozar +grada +gráfico +grano +grasa +gratis +grave +grieta +grillo +gripe +gris +grito +grosor +grúa +grueso +grumo +grupo +guante +guapo +guardia +guerra +guía +guiño +guion +guiso +guitarra +gusano +gustar +haber +hábil +hablar +hacer +hacha +hada +hallar +hamaca +harina +haz +hazaña +hebilla +hebra +hecho +helado +helio +hembra +herir +hermano +héroe +hervir +hielo +hierro +hígado +higiene +hijo +himno +historia +hocico +hogar +hoguera +hoja +hombre +hongo +honor +honra +hora +hormiga +horno +hostil +hoyo +hueco +huelga +huerta +hueso +huevo +huida +huir +humano +húmedo +humilde +humo +hundir +huracán +hurto +icono +ideal +idioma +ídolo +iglesia +iglú +igual +ilegal +ilusión +imagen +imán +imitar +impar +imperio +imponer +impulso +incapaz +índice +inerte +infiel +informe +ingenio +inicio +inmenso +inmune +innato +insecto +instante +interés +íntimo +intuir +inútil +invierno +ira +iris +ironía +isla +islote +jabalí +jabón +jamón +jarabe +jardín +jarra +jaula +jazmín +jefe +jeringa +jinete +jornada +joroba +joven +joya +juerga +jueves +juez +jugador +jugo +juguete +juicio +junco +jungla +junio +juntar +júpiter +jurar +justo +juvenil +juzgar +kilo +koala +labio +lacio +lacra +lado +ladrón +lagarto +lágrima +laguna +laico +lamer +lámina +lámpara +lana +lancha +langosta +lanza +lápiz +largo +larva +lástima +lata +látex +latir +laurel +lavar +lazo +leal +lección +leche +lector +leer +legión +legumbre +lejano +lengua +lento +leña +león +leopardo +lesión +letal +letra +leve +leyenda +libertad +libro +licor +líder +lidiar +lienzo +liga +ligero +lima +límite +limón +limpio +lince +lindo +línea +lingote +lino +linterna +líquido +liso +lista +litera +litio +litro +llaga +llama +llanto +llave +llegar +llenar +llevar +llorar +llover +lluvia +lobo +loción +loco +locura +lógica +logro +lombriz +lomo +lonja +lote +lucha +lucir +lugar +lujo +luna +lunes +lupa +lustro +luto +luz +maceta +macho +madera +madre +maduro +maestro +mafia +magia +mago +maíz +maldad +maleta +malla +malo +mamá +mambo +mamut +manco +mando +manejar +manga +maniquí +manjar +mano +manso +manta +mañana +mapa +máquina +mar +marco +marea +marfil +margen +marido +mármol +marrón +martes +marzo +masa +máscara +masivo +matar +materia +matiz +matriz +máximo +mayor +mazorca +mecha +medalla +medio +médula +mejilla +mejor +melena +melón +memoria +menor +mensaje +mente +menú +mercado +merengue +mérito +mes +mesón +meta +meter +método +metro +mezcla +miedo +miel +miembro +miga +mil +milagro +militar +millón +mimo +mina +minero +mínimo +minuto +miope +mirar +misa +miseria +misil +mismo +mitad +mito +mochila +moción +moda +modelo +moho +mojar +molde +moler +molino +momento +momia +monarca +moneda +monja +monto +moño +morada +morder +moreno +morir +morro +morsa +mortal +mosca +mostrar +motivo +mover +móvil +mozo +mucho +mudar +mueble +muela +muerte +muestra +mugre +mujer +mula +muleta +multa +mundo +muñeca +mural +muro +músculo +museo +musgo +música +muslo +nácar +nación +nadar +naipe +naranja +nariz +narrar +nasal +natal +nativo +natural +náusea +naval +nave +navidad +necio +néctar +negar +negocio +negro +neón +nervio +neto +neutro +nevar +nevera +nicho +nido +niebla +nieto +niñez +niño +nítido +nivel +nobleza +noche +nómina +noria +norma +norte +nota +noticia +novato +novela +novio +nube +nuca +núcleo +nudillo +nudo +nuera +nueve +nuez +nulo +número +nutria +oasis +obeso +obispo +objeto +obra +obrero +observar +obtener +obvio +oca +ocaso +océano +ochenta +ocho +ocio +ocre +octavo +octubre +oculto +ocupar +ocurrir +odiar +odio +odisea +oeste +ofensa +oferta +oficio +ofrecer +ogro +oído +oír +ojo +ola +oleada +olfato +olivo +olla +olmo +olor +olvido +ombligo +onda +onza +opaco +opción +ópera +opinar +oponer +optar +óptica +opuesto +oración +orador +oral +órbita +orca +orden +oreja +órgano +orgía +orgullo +oriente +origen +orilla +oro +orquesta +oruga +osadía +oscuro +osezno +oso +ostra +otoño +otro +oveja +óvulo +óxido +oxígeno +oyente +ozono +pacto +padre +paella +página +pago +país +pájaro +palabra +palco +paleta +pálido +palma +paloma +palpar +pan +panal +pánico +pantera +pañuelo +papá +papel +papilla +paquete +parar +parcela +pared +parir +paro +párpado +parque +párrafo +parte +pasar +paseo +pasión +paso +pasta +pata +patio +patria +pausa +pauta +pavo +payaso +peatón +pecado +pecera +pecho +pedal +pedir +pegar +peine +pelar +peldaño +pelea +peligro +pellejo +pelo +peluca +pena +pensar +peñón +peón +peor +pepino +pequeño +pera +percha +perder +pereza +perfil +perico +perla +permiso +perro +persona +pesa +pesca +pésimo +pestaña +pétalo +petróleo +pez +pezuña +picar +pichón +pie +piedra +pierna +pieza +pijama +pilar +piloto +pimienta +pino +pintor +pinza +piña +piojo +pipa +pirata +pisar +piscina +piso +pista +pitón +pizca +placa +plan +plata +playa +plaza +pleito +pleno +plomo +pluma +plural +pobre +poco +poder +podio +poema +poesía +poeta +polen +policía +pollo +polvo +pomada +pomelo +pomo +pompa +poner +porción +portal +posada +poseer +posible +poste +potencia +potro +pozo +prado +precoz +pregunta +premio +prensa +preso +previo +primo +príncipe +prisión +privar +proa +probar +proceso +producto +proeza +profesor +programa +prole +promesa +pronto +propio +próximo +prueba +público +puchero +pudor +pueblo +puerta +puesto +pulga +pulir +pulmón +pulpo +pulso +puma +punto +puñal +puño +pupa +pupila +puré +quedar +queja +quemar +querer +queso +quieto +química +quince +quitar +rábano +rabia +rabo +ración +radical +raíz +rama +rampa +rancho +rango +rapaz +rápido +rapto +rasgo +raspa +rato +rayo +raza +razón +reacción +realidad +rebaño +rebote +recaer +receta +rechazo +recoger +recreo +recto +recurso +red +redondo +reducir +reflejo +reforma +refrán +refugio +regalo +regir +regla +regreso +rehén +reino +reír +reja +relato +relevo +relieve +relleno +reloj +remar +remedio +remo +rencor +rendir +renta +reparto +repetir +reposo +reptil +res +rescate +resina +respeto +resto +resumen +retiro +retorno +retrato +reunir +revés +revista +rey +rezar +rico +riego +rienda +riesgo +rifa +rígido +rigor +rincón +riñón +río +riqueza +risa +ritmo +rito +rizo +roble +roce +rociar +rodar +rodeo +rodilla +roer +rojizo +rojo +romero +romper +ron +ronco +ronda +ropa +ropero +rosa +rosca +rostro +rotar +rubí +rubor +rudo +rueda +rugir +ruido +ruina +ruleta +rulo +rumbo +rumor +ruptura +ruta +rutina +sábado +saber +sabio +sable +sacar +sagaz +sagrado +sala +saldo +salero +salir +salmón +salón +salsa +salto +salud +salvar +samba +sanción +sandía +sanear +sangre +sanidad +sano +santo +sapo +saque +sardina +sartén +sastre +satán +sauna +saxofón +sección +seco +secreto +secta +sed +seguir +seis +sello +selva +semana +semilla +senda +sensor +señal +señor +separar +sepia +sequía +ser +serie +sermón +servir +sesenta +sesión +seta +setenta +severo +sexo +sexto +sidra +siesta +siete +siglo +signo +sílaba +silbar +silencio +silla +símbolo +simio +sirena +sistema +sitio +situar +sobre +socio +sodio +sol +solapa +soldado +soledad +sólido +soltar +solución +sombra +sondeo +sonido +sonoro +sonrisa +sopa +soplar +soporte +sordo +sorpresa +sorteo +sostén +sótano +suave +subir +suceso +sudor +suegra +suelo +sueño +suerte +sufrir +sujeto +sultán +sumar +superar +suplir +suponer +supremo +sur +surco +sureño +surgir +susto +sutil +tabaco +tabique +tabla +tabú +taco +tacto +tajo +talar +talco +talento +talla +talón +tamaño +tambor +tango +tanque +tapa +tapete +tapia +tapón +taquilla +tarde +tarea +tarifa +tarjeta +tarot +tarro +tarta +tatuaje +tauro +taza +tazón +teatro +techo +tecla +técnica +tejado +tejer +tejido +tela +teléfono +tema +temor +templo +tenaz +tender +tener +tenis +tenso +teoría +terapia +terco +término +ternura +terror +tesis +tesoro +testigo +tetera +texto +tez +tibio +tiburón +tiempo +tienda +tierra +tieso +tigre +tijera +tilde +timbre +tímido +timo +tinta +tío +típico +tipo +tira +tirón +titán +títere +título +tiza +toalla +tobillo +tocar +tocino +todo +toga +toldo +tomar +tono +tonto +topar +tope +toque +tórax +torero +tormenta +torneo +toro +torpedo +torre +torso +tortuga +tos +tosco +toser +tóxico +trabajo +tractor +traer +tráfico +trago +traje +tramo +trance +trato +trauma +trazar +trébol +tregua +treinta +tren +trepar +tres +tribu +trigo +tripa +triste +triunfo +trofeo +trompa +tronco +tropa +trote +trozo +truco +trueno +trufa +tubería +tubo +tuerto +tumba +tumor +túnel +túnica +turbina +turismo +turno +tutor +ubicar +úlcera +umbral +unidad +unir +universo +uno +untar +uña +urbano +urbe +urgente +urna +usar +usuario +útil +utopía +uva +vaca +vacío +vacuna +vagar +vago +vaina +vajilla +vale +válido +valle +valor +válvula +vampiro +vara +variar +varón +vaso +vecino +vector +vehículo +veinte +vejez +vela +velero +veloz +vena +vencer +venda +veneno +vengar +venir +venta +venus +ver +verano +verbo +verde +vereda +verja +verso +verter +vía +viaje +vibrar +vicio +víctima +vida +vídeo +vidrio +viejo +viernes +vigor +vil +villa +vinagre +vino +viñedo +violín +viral +virgo +virtud +visor +víspera +vista +vitamina +viudo +vivaz +vivero +vivir +vivo +volcán +volumen +volver +voraz +votar +voto +voz +vuelo +vulgar +yacer +yate +yegua +yema +yerno +yeso +yodo +yoga +yogur +zafiro +zanja +zapato +zarza +zona +zorro +zumo +zurdo diff --git a/packages/testcases/input/wordlists/lang-fr.txt b/packages/testcases/input/wordlists/lang-fr.txt new file mode 100644 index 000000000..1d749904f --- /dev/null +++ b/packages/testcases/input/wordlists/lang-fr.txt @@ -0,0 +1,2048 @@ +abaisser +abandon +abdiquer +abeille +abolir +aborder +aboutir +aboyer +abrasif +abreuver +abriter +abroger +abrupt +absence +absolu +absurde +abusif +abyssal +académie +acajou +acarien +accabler +accepter +acclamer +accolade +accroche +accuser +acerbe +achat +acheter +aciduler +acier +acompte +acquérir +acronyme +acteur +actif +actuel +adepte +adéquat +adhésif +adjectif +adjuger +admettre +admirer +adopter +adorer +adoucir +adresse +adroit +adulte +adverbe +aérer +aéronef +affaire +affecter +affiche +affreux +affubler +agacer +agencer +agile +agiter +agrafer +agréable +agrume +aider +aiguille +ailier +aimable +aisance +ajouter +ajuster +alarmer +alchimie +alerte +algèbre +algue +aliéner +aliment +alléger +alliage +allouer +allumer +alourdir +alpaga +altesse +alvéole +amateur +ambigu +ambre +aménager +amertume +amidon +amiral +amorcer +amour +amovible +amphibie +ampleur +amusant +analyse +anaphore +anarchie +anatomie +ancien +anéantir +angle +angoisse +anguleux +animal +annexer +annonce +annuel +anodin +anomalie +anonyme +anormal +antenne +antidote +anxieux +apaiser +apéritif +aplanir +apologie +appareil +appeler +apporter +appuyer +aquarium +aqueduc +arbitre +arbuste +ardeur +ardoise +argent +arlequin +armature +armement +armoire +armure +arpenter +arracher +arriver +arroser +arsenic +artériel +article +aspect +asphalte +aspirer +assaut +asservir +assiette +associer +assurer +asticot +astre +astuce +atelier +atome +atrium +atroce +attaque +attentif +attirer +attraper +aubaine +auberge +audace +audible +augurer +aurore +automne +autruche +avaler +avancer +avarice +avenir +averse +aveugle +aviateur +avide +avion +aviser +avoine +avouer +avril +axial +axiome +badge +bafouer +bagage +baguette +baignade +balancer +balcon +baleine +balisage +bambin +bancaire +bandage +banlieue +bannière +banquier +barbier +baril +baron +barque +barrage +bassin +bastion +bataille +bateau +batterie +baudrier +bavarder +belette +bélier +belote +bénéfice +berceau +berger +berline +bermuda +besace +besogne +bétail +beurre +biberon +bicycle +bidule +bijou +bilan +bilingue +billard +binaire +biologie +biopsie +biotype +biscuit +bison +bistouri +bitume +bizarre +blafard +blague +blanchir +blessant +blinder +blond +bloquer +blouson +bobard +bobine +boire +boiser +bolide +bonbon +bondir +bonheur +bonifier +bonus +bordure +borne +botte +boucle +boueux +bougie +boulon +bouquin +bourse +boussole +boutique +boxeur +branche +brasier +brave +brebis +brèche +breuvage +bricoler +brigade +brillant +brioche +brique +brochure +broder +bronzer +brousse +broyeur +brume +brusque +brutal +bruyant +buffle +buisson +bulletin +bureau +burin +bustier +butiner +butoir +buvable +buvette +cabanon +cabine +cachette +cadeau +cadre +caféine +caillou +caisson +calculer +calepin +calibre +calmer +calomnie +calvaire +camarade +caméra +camion +campagne +canal +caneton +canon +cantine +canular +capable +caporal +caprice +capsule +capter +capuche +carabine +carbone +caresser +caribou +carnage +carotte +carreau +carton +cascade +casier +casque +cassure +causer +caution +cavalier +caverne +caviar +cédille +ceinture +céleste +cellule +cendrier +censurer +central +cercle +cérébral +cerise +cerner +cerveau +cesser +chagrin +chaise +chaleur +chambre +chance +chapitre +charbon +chasseur +chaton +chausson +chavirer +chemise +chenille +chéquier +chercher +cheval +chien +chiffre +chignon +chimère +chiot +chlorure +chocolat +choisir +chose +chouette +chrome +chute +cigare +cigogne +cimenter +cinéma +cintrer +circuler +cirer +cirque +citerne +citoyen +citron +civil +clairon +clameur +claquer +classe +clavier +client +cligner +climat +clivage +cloche +clonage +cloporte +cobalt +cobra +cocasse +cocotier +coder +codifier +coffre +cogner +cohésion +coiffer +coincer +colère +colibri +colline +colmater +colonel +combat +comédie +commande +compact +concert +conduire +confier +congeler +connoter +consonne +contact +convexe +copain +copie +corail +corbeau +cordage +corniche +corpus +correct +cortège +cosmique +costume +coton +coude +coupure +courage +couteau +couvrir +coyote +crabe +crainte +cravate +crayon +créature +créditer +crémeux +creuser +crevette +cribler +crier +cristal +critère +croire +croquer +crotale +crucial +cruel +crypter +cubique +cueillir +cuillère +cuisine +cuivre +culminer +cultiver +cumuler +cupide +curatif +curseur +cyanure +cycle +cylindre +cynique +daigner +damier +danger +danseur +dauphin +débattre +débiter +déborder +débrider +débutant +décaler +décembre +déchirer +décider +déclarer +décorer +décrire +décupler +dédale +déductif +déesse +défensif +défiler +défrayer +dégager +dégivrer +déglutir +dégrafer +déjeuner +délice +déloger +demander +demeurer +démolir +dénicher +dénouer +dentelle +dénuder +départ +dépenser +déphaser +déplacer +déposer +déranger +dérober +désastre +descente +désert +désigner +désobéir +dessiner +destrier +détacher +détester +détourer +détresse +devancer +devenir +deviner +devoir +diable +dialogue +diamant +dicter +différer +digérer +digital +digne +diluer +dimanche +diminuer +dioxyde +directif +diriger +discuter +disposer +dissiper +distance +divertir +diviser +docile +docteur +dogme +doigt +domaine +domicile +dompter +donateur +donjon +donner +dopamine +dortoir +dorure +dosage +doseur +dossier +dotation +douanier +double +douceur +douter +doyen +dragon +draper +dresser +dribbler +droiture +duperie +duplexe +durable +durcir +dynastie +éblouir +écarter +écharpe +échelle +éclairer +éclipse +éclore +écluse +école +économie +écorce +écouter +écraser +écrémer +écrivain +écrou +écume +écureuil +édifier +éduquer +effacer +effectif +effigie +effort +effrayer +effusion +égaliser +égarer +éjecter +élaborer +élargir +électron +élégant +éléphant +élève +éligible +élitisme +éloge +élucider +éluder +emballer +embellir +embryon +émeraude +émission +emmener +émotion +émouvoir +empereur +employer +emporter +emprise +émulsion +encadrer +enchère +enclave +encoche +endiguer +endosser +endroit +enduire +énergie +enfance +enfermer +enfouir +engager +engin +englober +énigme +enjamber +enjeu +enlever +ennemi +ennuyeux +enrichir +enrobage +enseigne +entasser +entendre +entier +entourer +entraver +énumérer +envahir +enviable +envoyer +enzyme +éolien +épaissir +épargne +épatant +épaule +épicerie +épidémie +épier +épilogue +épine +épisode +épitaphe +époque +épreuve +éprouver +épuisant +équerre +équipe +ériger +érosion +erreur +éruption +escalier +espadon +espèce +espiègle +espoir +esprit +esquiver +essayer +essence +essieu +essorer +estime +estomac +estrade +étagère +étaler +étanche +étatique +éteindre +étendoir +éternel +éthanol +éthique +ethnie +étirer +étoffer +étoile +étonnant +étourdir +étrange +étroit +étude +euphorie +évaluer +évasion +éventail +évidence +éviter +évolutif +évoquer +exact +exagérer +exaucer +exceller +excitant +exclusif +excuse +exécuter +exemple +exercer +exhaler +exhorter +exigence +exiler +exister +exotique +expédier +explorer +exposer +exprimer +exquis +extensif +extraire +exulter +fable +fabuleux +facette +facile +facture +faiblir +falaise +fameux +famille +farceur +farfelu +farine +farouche +fasciner +fatal +fatigue +faucon +fautif +faveur +favori +fébrile +féconder +fédérer +félin +femme +fémur +fendoir +féodal +fermer +féroce +ferveur +festival +feuille +feutre +février +fiasco +ficeler +fictif +fidèle +figure +filature +filetage +filière +filleul +filmer +filou +filtrer +financer +finir +fiole +firme +fissure +fixer +flairer +flamme +flasque +flatteur +fléau +flèche +fleur +flexion +flocon +flore +fluctuer +fluide +fluvial +folie +fonderie +fongible +fontaine +forcer +forgeron +formuler +fortune +fossile +foudre +fougère +fouiller +foulure +fourmi +fragile +fraise +franchir +frapper +frayeur +frégate +freiner +frelon +frémir +frénésie +frère +friable +friction +frisson +frivole +froid +fromage +frontal +frotter +fruit +fugitif +fuite +fureur +furieux +furtif +fusion +futur +gagner +galaxie +galerie +gambader +garantir +gardien +garnir +garrigue +gazelle +gazon +géant +gélatine +gélule +gendarme +général +génie +genou +gentil +géologie +géomètre +géranium +germe +gestuel +geyser +gibier +gicler +girafe +givre +glace +glaive +glisser +globe +gloire +glorieux +golfeur +gomme +gonfler +gorge +gorille +goudron +gouffre +goulot +goupille +gourmand +goutte +graduel +graffiti +graine +grand +grappin +gratuit +gravir +grenat +griffure +griller +grimper +grogner +gronder +grotte +groupe +gruger +grutier +gruyère +guépard +guerrier +guide +guimauve +guitare +gustatif +gymnaste +gyrostat +habitude +hachoir +halte +hameau +hangar +hanneton +haricot +harmonie +harpon +hasard +hélium +hématome +herbe +hérisson +hermine +héron +hésiter +heureux +hiberner +hibou +hilarant +histoire +hiver +homard +hommage +homogène +honneur +honorer +honteux +horde +horizon +horloge +hormone +horrible +houleux +housse +hublot +huileux +humain +humble +humide +humour +hurler +hydromel +hygiène +hymne +hypnose +idylle +ignorer +iguane +illicite +illusion +image +imbiber +imiter +immense +immobile +immuable +impact +impérial +implorer +imposer +imprimer +imputer +incarner +incendie +incident +incliner +incolore +indexer +indice +inductif +inédit +ineptie +inexact +infini +infliger +informer +infusion +ingérer +inhaler +inhiber +injecter +injure +innocent +inoculer +inonder +inscrire +insecte +insigne +insolite +inspirer +instinct +insulter +intact +intense +intime +intrigue +intuitif +inutile +invasion +inventer +inviter +invoquer +ironique +irradier +irréel +irriter +isoler +ivoire +ivresse +jaguar +jaillir +jambe +janvier +jardin +jauger +jaune +javelot +jetable +jeton +jeudi +jeunesse +joindre +joncher +jongler +joueur +jouissif +journal +jovial +joyau +joyeux +jubiler +jugement +junior +jupon +juriste +justice +juteux +juvénile +kayak +kimono +kiosque +label +labial +labourer +lacérer +lactose +lagune +laine +laisser +laitier +lambeau +lamelle +lampe +lanceur +langage +lanterne +lapin +largeur +larme +laurier +lavabo +lavoir +lecture +légal +léger +légume +lessive +lettre +levier +lexique +lézard +liasse +libérer +libre +licence +licorne +liège +lièvre +ligature +ligoter +ligue +limer +limite +limonade +limpide +linéaire +lingot +lionceau +liquide +lisière +lister +lithium +litige +littoral +livreur +logique +lointain +loisir +lombric +loterie +louer +lourd +loutre +louve +loyal +lubie +lucide +lucratif +lueur +lugubre +luisant +lumière +lunaire +lundi +luron +lutter +luxueux +machine +magasin +magenta +magique +maigre +maillon +maintien +mairie +maison +majorer +malaxer +maléfice +malheur +malice +mallette +mammouth +mandater +maniable +manquant +manteau +manuel +marathon +marbre +marchand +mardi +maritime +marqueur +marron +marteler +mascotte +massif +matériel +matière +matraque +maudire +maussade +mauve +maximal +méchant +méconnu +médaille +médecin +méditer +méduse +meilleur +mélange +mélodie +membre +mémoire +menacer +mener +menhir +mensonge +mentor +mercredi +mérite +merle +messager +mesure +métal +météore +méthode +métier +meuble +miauler +microbe +miette +mignon +migrer +milieu +million +mimique +mince +minéral +minimal +minorer +minute +miracle +miroiter +missile +mixte +mobile +moderne +moelleux +mondial +moniteur +monnaie +monotone +monstre +montagne +monument +moqueur +morceau +morsure +mortier +moteur +motif +mouche +moufle +moulin +mousson +mouton +mouvant +multiple +munition +muraille +murène +murmure +muscle +muséum +musicien +mutation +muter +mutuel +myriade +myrtille +mystère +mythique +nageur +nappe +narquois +narrer +natation +nation +nature +naufrage +nautique +navire +nébuleux +nectar +néfaste +négation +négliger +négocier +neige +nerveux +nettoyer +neurone +neutron +neveu +niche +nickel +nitrate +niveau +noble +nocif +nocturne +noirceur +noisette +nomade +nombreux +nommer +normatif +notable +notifier +notoire +nourrir +nouveau +novateur +novembre +novice +nuage +nuancer +nuire +nuisible +numéro +nuptial +nuque +nutritif +obéir +objectif +obliger +obscur +observer +obstacle +obtenir +obturer +occasion +occuper +océan +octobre +octroyer +octupler +oculaire +odeur +odorant +offenser +officier +offrir +ogive +oiseau +oisillon +olfactif +olivier +ombrage +omettre +onctueux +onduler +onéreux +onirique +opale +opaque +opérer +opinion +opportun +opprimer +opter +optique +orageux +orange +orbite +ordonner +oreille +organe +orgueil +orifice +ornement +orque +ortie +osciller +osmose +ossature +otarie +ouragan +ourson +outil +outrager +ouvrage +ovation +oxyde +oxygène +ozone +paisible +palace +palmarès +palourde +palper +panache +panda +pangolin +paniquer +panneau +panorama +pantalon +papaye +papier +papoter +papyrus +paradoxe +parcelle +paresse +parfumer +parler +parole +parrain +parsemer +partager +parure +parvenir +passion +pastèque +paternel +patience +patron +pavillon +pavoiser +payer +paysage +peigne +peintre +pelage +pélican +pelle +pelouse +peluche +pendule +pénétrer +pénible +pensif +pénurie +pépite +péplum +perdrix +perforer +période +permuter +perplexe +persil +perte +peser +pétale +petit +pétrir +peuple +pharaon +phobie +phoque +photon +phrase +physique +piano +pictural +pièce +pierre +pieuvre +pilote +pinceau +pipette +piquer +pirogue +piscine +piston +pivoter +pixel +pizza +placard +plafond +plaisir +planer +plaque +plastron +plateau +pleurer +plexus +pliage +plomb +plonger +pluie +plumage +pochette +poésie +poète +pointe +poirier +poisson +poivre +polaire +policier +pollen +polygone +pommade +pompier +ponctuel +pondérer +poney +portique +position +posséder +posture +potager +poteau +potion +pouce +poulain +poumon +pourpre +poussin +pouvoir +prairie +pratique +précieux +prédire +préfixe +prélude +prénom +présence +prétexte +prévoir +primitif +prince +prison +priver +problème +procéder +prodige +profond +progrès +proie +projeter +prologue +promener +propre +prospère +protéger +prouesse +proverbe +prudence +pruneau +psychose +public +puceron +puiser +pulpe +pulsar +punaise +punitif +pupitre +purifier +puzzle +pyramide +quasar +querelle +question +quiétude +quitter +quotient +racine +raconter +radieux +ragondin +raideur +raisin +ralentir +rallonge +ramasser +rapide +rasage +ratisser +ravager +ravin +rayonner +réactif +réagir +réaliser +réanimer +recevoir +réciter +réclamer +récolter +recruter +reculer +recycler +rédiger +redouter +refaire +réflexe +réformer +refrain +refuge +régalien +région +réglage +régulier +réitérer +rejeter +rejouer +relatif +relever +relief +remarque +remède +remise +remonter +remplir +remuer +renard +renfort +renifler +renoncer +rentrer +renvoi +replier +reporter +reprise +reptile +requin +réserve +résineux +résoudre +respect +rester +résultat +rétablir +retenir +réticule +retomber +retracer +réunion +réussir +revanche +revivre +révolte +révulsif +richesse +rideau +rieur +rigide +rigoler +rincer +riposter +risible +risque +rituel +rival +rivière +rocheux +romance +rompre +ronce +rondin +roseau +rosier +rotatif +rotor +rotule +rouge +rouille +rouleau +routine +royaume +ruban +rubis +ruche +ruelle +rugueux +ruiner +ruisseau +ruser +rustique +rythme +sabler +saboter +sabre +sacoche +safari +sagesse +saisir +salade +salive +salon +saluer +samedi +sanction +sanglier +sarcasme +sardine +saturer +saugrenu +saumon +sauter +sauvage +savant +savonner +scalpel +scandale +scélérat +scénario +sceptre +schéma +science +scinder +score +scrutin +sculpter +séance +sécable +sécher +secouer +sécréter +sédatif +séduire +seigneur +séjour +sélectif +semaine +sembler +semence +séminal +sénateur +sensible +sentence +séparer +séquence +serein +sergent +sérieux +serrure +sérum +service +sésame +sévir +sevrage +sextuple +sidéral +siècle +siéger +siffler +sigle +signal +silence +silicium +simple +sincère +sinistre +siphon +sirop +sismique +situer +skier +social +socle +sodium +soigneux +soldat +soleil +solitude +soluble +sombre +sommeil +somnoler +sonde +songeur +sonnette +sonore +sorcier +sortir +sosie +sottise +soucieux +soudure +souffle +soulever +soupape +source +soutirer +souvenir +spacieux +spatial +spécial +sphère +spiral +stable +station +sternum +stimulus +stipuler +strict +studieux +stupeur +styliste +sublime +substrat +subtil +subvenir +succès +sucre +suffixe +suggérer +suiveur +sulfate +superbe +supplier +surface +suricate +surmener +surprise +sursaut +survie +suspect +syllabe +symbole +symétrie +synapse +syntaxe +système +tabac +tablier +tactile +tailler +talent +talisman +talonner +tambour +tamiser +tangible +tapis +taquiner +tarder +tarif +tartine +tasse +tatami +tatouage +taupe +taureau +taxer +témoin +temporel +tenaille +tendre +teneur +tenir +tension +terminer +terne +terrible +tétine +texte +thème +théorie +thérapie +thorax +tibia +tiède +timide +tirelire +tiroir +tissu +titane +titre +tituber +toboggan +tolérant +tomate +tonique +tonneau +toponyme +torche +tordre +tornade +torpille +torrent +torse +tortue +totem +toucher +tournage +tousser +toxine +traction +trafic +tragique +trahir +train +trancher +travail +trèfle +tremper +trésor +treuil +triage +tribunal +tricoter +trilogie +triomphe +tripler +triturer +trivial +trombone +tronc +tropical +troupeau +tuile +tulipe +tumulte +tunnel +turbine +tuteur +tutoyer +tuyau +tympan +typhon +typique +tyran +ubuesque +ultime +ultrason +unanime +unifier +union +unique +unitaire +univers +uranium +urbain +urticant +usage +usine +usuel +usure +utile +utopie +vacarme +vaccin +vagabond +vague +vaillant +vaincre +vaisseau +valable +valise +vallon +valve +vampire +vanille +vapeur +varier +vaseux +vassal +vaste +vecteur +vedette +végétal +véhicule +veinard +véloce +vendredi +vénérer +venger +venimeux +ventouse +verdure +vérin +vernir +verrou +verser +vertu +veston +vétéran +vétuste +vexant +vexer +viaduc +viande +victoire +vidange +vidéo +vignette +vigueur +vilain +village +vinaigre +violon +vipère +virement +virtuose +virus +visage +viseur +vision +visqueux +visuel +vital +vitesse +viticole +vitrine +vivace +vivipare +vocation +voguer +voile +voisin +voiture +volaille +volcan +voltiger +volume +vorace +vortex +voter +vouloir +voyage +voyelle +wagon +xénon +yacht +zèbre +zénith +zeste +zoologie diff --git a/packages/testcases/input/wordlists/lang-it.txt b/packages/testcases/input/wordlists/lang-it.txt new file mode 100644 index 000000000..c47370f4e --- /dev/null +++ b/packages/testcases/input/wordlists/lang-it.txt @@ -0,0 +1,2048 @@ +abaco +abbaglio +abbinato +abete +abisso +abolire +abrasivo +abrogato +accadere +accenno +accusato +acetone +achille +acido +acqua +acre +acrilico +acrobata +acuto +adagio +addebito +addome +adeguato +aderire +adipe +adottare +adulare +affabile +affetto +affisso +affranto +aforisma +afoso +africano +agave +agente +agevole +aggancio +agire +agitare +agonismo +agricolo +agrumeto +aguzzo +alabarda +alato +albatro +alberato +albo +albume +alce +alcolico +alettone +alfa +algebra +aliante +alibi +alimento +allagato +allegro +allievo +allodola +allusivo +almeno +alogeno +alpaca +alpestre +altalena +alterno +alticcio +altrove +alunno +alveolo +alzare +amalgama +amanita +amarena +ambito +ambrato +ameba +america +ametista +amico +ammasso +ammenda +ammirare +ammonito +amore +ampio +ampliare +amuleto +anacardo +anagrafe +analista +anarchia +anatra +anca +ancella +ancora +andare +andrea +anello +angelo +angolare +angusto +anima +annegare +annidato +anno +annuncio +anonimo +anticipo +anzi +apatico +apertura +apode +apparire +appetito +appoggio +approdo +appunto +aprile +arabica +arachide +aragosta +araldica +arancio +aratura +arazzo +arbitro +archivio +ardito +arenile +argento +argine +arguto +aria +armonia +arnese +arredato +arringa +arrosto +arsenico +arso +artefice +arzillo +asciutto +ascolto +asepsi +asettico +asfalto +asino +asola +aspirato +aspro +assaggio +asse +assoluto +assurdo +asta +astenuto +astice +astratto +atavico +ateismo +atomico +atono +attesa +attivare +attorno +attrito +attuale +ausilio +austria +autista +autonomo +autunno +avanzato +avere +avvenire +avviso +avvolgere +azione +azoto +azzimo +azzurro +babele +baccano +bacino +baco +badessa +badilata +bagnato +baita +balcone +baldo +balena +ballata +balzano +bambino +bandire +baraonda +barbaro +barca +baritono +barlume +barocco +basilico +basso +batosta +battuto +baule +bava +bavosa +becco +beffa +belgio +belva +benda +benevole +benigno +benzina +bere +berlina +beta +bibita +bici +bidone +bifido +biga +bilancia +bimbo +binocolo +biologo +bipede +bipolare +birbante +birra +biscotto +bisesto +bisnonno +bisonte +bisturi +bizzarro +blando +blatta +bollito +bonifico +bordo +bosco +botanico +bottino +bozzolo +braccio +bradipo +brama +branca +bravura +bretella +brevetto +brezza +briglia +brillante +brindare +broccolo +brodo +bronzina +brullo +bruno +bubbone +buca +budino +buffone +buio +bulbo +buono +burlone +burrasca +bussola +busta +cadetto +caduco +calamaro +calcolo +calesse +calibro +calmo +caloria +cambusa +camerata +camicia +cammino +camola +campale +canapa +candela +cane +canino +canotto +cantina +capace +capello +capitolo +capogiro +cappero +capra +capsula +carapace +carcassa +cardo +carisma +carovana +carretto +cartolina +casaccio +cascata +caserma +caso +cassone +castello +casuale +catasta +catena +catrame +cauto +cavillo +cedibile +cedrata +cefalo +celebre +cellulare +cena +cenone +centesimo +ceramica +cercare +certo +cerume +cervello +cesoia +cespo +ceto +chela +chiaro +chicca +chiedere +chimera +china +chirurgo +chitarra +ciao +ciclismo +cifrare +cigno +cilindro +ciottolo +circa +cirrosi +citrico +cittadino +ciuffo +civetta +civile +classico +clinica +cloro +cocco +codardo +codice +coerente +cognome +collare +colmato +colore +colposo +coltivato +colza +coma +cometa +commando +comodo +computer +comune +conciso +condurre +conferma +congelare +coniuge +connesso +conoscere +consumo +continuo +convegno +coperto +copione +coppia +copricapo +corazza +cordata +coricato +cornice +corolla +corpo +corredo +corsia +cortese +cosmico +costante +cottura +covato +cratere +cravatta +creato +credere +cremoso +crescita +creta +criceto +crinale +crisi +critico +croce +cronaca +crostata +cruciale +crusca +cucire +cuculo +cugino +cullato +cupola +curatore +cursore +curvo +cuscino +custode +dado +daino +dalmata +damerino +daniela +dannoso +danzare +datato +davanti +davvero +debutto +decennio +deciso +declino +decollo +decreto +dedicato +definito +deforme +degno +delegare +delfino +delirio +delta +demenza +denotato +dentro +deposito +derapata +derivare +deroga +descritto +deserto +desiderio +desumere +detersivo +devoto +diametro +dicembre +diedro +difeso +diffuso +digerire +digitale +diluvio +dinamico +dinnanzi +dipinto +diploma +dipolo +diradare +dire +dirotto +dirupo +disagio +discreto +disfare +disgelo +disposto +distanza +disumano +dito +divano +divelto +dividere +divorato +doblone +docente +doganale +dogma +dolce +domato +domenica +dominare +dondolo +dono +dormire +dote +dottore +dovuto +dozzina +drago +druido +dubbio +dubitare +ducale +duna +duomo +duplice +duraturo +ebano +eccesso +ecco +eclissi +economia +edera +edicola +edile +editoria +educare +egemonia +egli +egoismo +egregio +elaborato +elargire +elegante +elencato +eletto +elevare +elfico +elica +elmo +elsa +eluso +emanato +emblema +emesso +emiro +emotivo +emozione +empirico +emulo +endemico +enduro +energia +enfasi +enoteca +entrare +enzima +epatite +epilogo +episodio +epocale +eppure +equatore +erario +erba +erboso +erede +eremita +erigere +ermetico +eroe +erosivo +errante +esagono +esame +esanime +esaudire +esca +esempio +esercito +esibito +esigente +esistere +esito +esofago +esortato +esoso +espanso +espresso +essenza +esso +esteso +estimare +estonia +estroso +esultare +etilico +etnico +etrusco +etto +euclideo +europa +evaso +evidenza +evitato +evoluto +evviva +fabbrica +faccenda +fachiro +falco +famiglia +fanale +fanfara +fango +fantasma +fare +farfalla +farinoso +farmaco +fascia +fastoso +fasullo +faticare +fato +favoloso +febbre +fecola +fede +fegato +felpa +feltro +femmina +fendere +fenomeno +fermento +ferro +fertile +fessura +festivo +fetta +feudo +fiaba +fiducia +fifa +figurato +filo +finanza +finestra +finire +fiore +fiscale +fisico +fiume +flacone +flamenco +flebo +flemma +florido +fluente +fluoro +fobico +focaccia +focoso +foderato +foglio +folata +folclore +folgore +fondente +fonetico +fonia +fontana +forbito +forchetta +foresta +formica +fornaio +foro +fortezza +forzare +fosfato +fosso +fracasso +frana +frassino +fratello +freccetta +frenata +fresco +frigo +frollino +fronde +frugale +frutta +fucilata +fucsia +fuggente +fulmine +fulvo +fumante +fumetto +fumoso +fune +funzione +fuoco +furbo +furgone +furore +fuso +futile +gabbiano +gaffe +galateo +gallina +galoppo +gambero +gamma +garanzia +garbo +garofano +garzone +gasdotto +gasolio +gastrico +gatto +gaudio +gazebo +gazzella +geco +gelatina +gelso +gemello +gemmato +gene +genitore +gennaio +genotipo +gergo +ghepardo +ghiaccio +ghisa +giallo +gilda +ginepro +giocare +gioiello +giorno +giove +girato +girone +gittata +giudizio +giurato +giusto +globulo +glutine +gnomo +gobba +golf +gomito +gommone +gonfio +gonna +governo +gracile +grado +grafico +grammo +grande +grattare +gravoso +grazia +greca +gregge +grifone +grigio +grinza +grotta +gruppo +guadagno +guaio +guanto +guardare +gufo +guidare +ibernato +icona +identico +idillio +idolo +idra +idrico +idrogeno +igiene +ignaro +ignorato +ilare +illeso +illogico +illudere +imballo +imbevuto +imbocco +imbuto +immane +immerso +immolato +impacco +impeto +impiego +importo +impronta +inalare +inarcare +inattivo +incanto +incendio +inchino +incisivo +incluso +incontro +incrocio +incubo +indagine +india +indole +inedito +infatti +infilare +inflitto +ingaggio +ingegno +inglese +ingordo +ingrosso +innesco +inodore +inoltrare +inondato +insano +insetto +insieme +insonnia +insulina +intasato +intero +intonaco +intuito +inumidire +invalido +invece +invito +iperbole +ipnotico +ipotesi +ippica +iride +irlanda +ironico +irrigato +irrorare +isolato +isotopo +isterico +istituto +istrice +italia +iterare +labbro +labirinto +lacca +lacerato +lacrima +lacuna +laddove +lago +lampo +lancetta +lanterna +lardoso +larga +laringe +lastra +latenza +latino +lattuga +lavagna +lavoro +legale +leggero +lembo +lentezza +lenza +leone +lepre +lesivo +lessato +lesto +letterale +leva +levigato +libero +lido +lievito +lilla +limatura +limitare +limpido +lineare +lingua +liquido +lira +lirica +lisca +lite +litigio +livrea +locanda +lode +logica +lombare +londra +longevo +loquace +lorenzo +loto +lotteria +luce +lucidato +lumaca +luminoso +lungo +lupo +luppolo +lusinga +lusso +lutto +macabro +macchina +macero +macinato +madama +magico +maglia +magnete +magro +maiolica +malafede +malgrado +malinteso +malsano +malto +malumore +mana +mancia +mandorla +mangiare +manifesto +mannaro +manovra +mansarda +mantide +manubrio +mappa +maratona +marcire +maretta +marmo +marsupio +maschera +massaia +mastino +materasso +matricola +mattone +maturo +mazurca +meandro +meccanico +mecenate +medesimo +meditare +mega +melassa +melis +melodia +meninge +meno +mensola +mercurio +merenda +merlo +meschino +mese +messere +mestolo +metallo +metodo +mettere +miagolare +mica +micelio +michele +microbo +midollo +miele +migliore +milano +milite +mimosa +minerale +mini +minore +mirino +mirtillo +miscela +missiva +misto +misurare +mitezza +mitigare +mitra +mittente +mnemonico +modello +modifica +modulo +mogano +mogio +mole +molosso +monastero +monco +mondina +monetario +monile +monotono +monsone +montato +monviso +mora +mordere +morsicato +mostro +motivato +motosega +motto +movenza +movimento +mozzo +mucca +mucosa +muffa +mughetto +mugnaio +mulatto +mulinello +multiplo +mummia +munto +muovere +murale +musa +muscolo +musica +mutevole +muto +nababbo +nafta +nanometro +narciso +narice +narrato +nascere +nastrare +naturale +nautica +naviglio +nebulosa +necrosi +negativo +negozio +nemmeno +neofita +neretto +nervo +nessuno +nettuno +neutrale +neve +nevrotico +nicchia +ninfa +nitido +nobile +nocivo +nodo +nome +nomina +nordico +normale +norvegese +nostrano +notare +notizia +notturno +novella +nucleo +nulla +numero +nuovo +nutrire +nuvola +nuziale +oasi +obbedire +obbligo +obelisco +oblio +obolo +obsoleto +occasione +occhio +occidente +occorrere +occultare +ocra +oculato +odierno +odorare +offerta +offrire +offuscato +oggetto +oggi +ognuno +olandese +olfatto +oliato +oliva +ologramma +oltre +omaggio +ombelico +ombra +omega +omissione +ondoso +onere +onice +onnivoro +onorevole +onta +operato +opinione +opposto +oracolo +orafo +ordine +orecchino +orefice +orfano +organico +origine +orizzonte +orma +ormeggio +ornativo +orologio +orrendo +orribile +ortensia +ortica +orzata +orzo +osare +oscurare +osmosi +ospedale +ospite +ossa +ossidare +ostacolo +oste +otite +otre +ottagono +ottimo +ottobre +ovale +ovest +ovino +oviparo +ovocito +ovunque +ovviare +ozio +pacchetto +pace +pacifico +padella +padrone +paese +paga +pagina +palazzina +palesare +pallido +palo +palude +pandoro +pannello +paolo +paonazzo +paprica +parabola +parcella +parere +pargolo +pari +parlato +parola +partire +parvenza +parziale +passivo +pasticca +patacca +patologia +pattume +pavone +peccato +pedalare +pedonale +peggio +peloso +penare +pendice +penisola +pennuto +penombra +pensare +pentola +pepe +pepita +perbene +percorso +perdonato +perforare +pergamena +periodo +permesso +perno +perplesso +persuaso +pertugio +pervaso +pesatore +pesista +peso +pestifero +petalo +pettine +petulante +pezzo +piacere +pianta +piattino +piccino +picozza +piega +pietra +piffero +pigiama +pigolio +pigro +pila +pilifero +pillola +pilota +pimpante +pineta +pinna +pinolo +pioggia +piombo +piramide +piretico +pirite +pirolisi +pitone +pizzico +placebo +planare +plasma +platano +plenario +pochezza +poderoso +podismo +poesia +poggiare +polenta +poligono +pollice +polmonite +polpetta +polso +poltrona +polvere +pomice +pomodoro +ponte +popoloso +porfido +poroso +porpora +porre +portata +posa +positivo +possesso +postulato +potassio +potere +pranzo +prassi +pratica +precluso +predica +prefisso +pregiato +prelievo +premere +prenotare +preparato +presenza +pretesto +prevalso +prima +principe +privato +problema +procura +produrre +profumo +progetto +prolunga +promessa +pronome +proposta +proroga +proteso +prova +prudente +prugna +prurito +psiche +pubblico +pudica +pugilato +pugno +pulce +pulito +pulsante +puntare +pupazzo +pupilla +puro +quadro +qualcosa +quasi +querela +quota +raccolto +raddoppio +radicale +radunato +raffica +ragazzo +ragione +ragno +ramarro +ramingo +ramo +randagio +rantolare +rapato +rapina +rappreso +rasatura +raschiato +rasente +rassegna +rastrello +rata +ravveduto +reale +recepire +recinto +recluta +recondito +recupero +reddito +redimere +regalato +registro +regola +regresso +relazione +remare +remoto +renna +replica +reprimere +reputare +resa +residente +responso +restauro +rete +retina +retorica +rettifica +revocato +riassunto +ribadire +ribelle +ribrezzo +ricarica +ricco +ricevere +riciclato +ricordo +ricreduto +ridicolo +ridurre +rifasare +riflesso +riforma +rifugio +rigare +rigettato +righello +rilassato +rilevato +rimanere +rimbalzo +rimedio +rimorchio +rinascita +rincaro +rinforzo +rinnovo +rinomato +rinsavito +rintocco +rinuncia +rinvenire +riparato +ripetuto +ripieno +riportare +ripresa +ripulire +risata +rischio +riserva +risibile +riso +rispetto +ristoro +risultato +risvolto +ritardo +ritegno +ritmico +ritrovo +riunione +riva +riverso +rivincita +rivolto +rizoma +roba +robotico +robusto +roccia +roco +rodaggio +rodere +roditore +rogito +rollio +romantico +rompere +ronzio +rosolare +rospo +rotante +rotondo +rotula +rovescio +rubizzo +rubrica +ruga +rullino +rumine +rumoroso +ruolo +rupe +russare +rustico +sabato +sabbiare +sabotato +sagoma +salasso +saldatura +salgemma +salivare +salmone +salone +saltare +saluto +salvo +sapere +sapido +saporito +saraceno +sarcasmo +sarto +sassoso +satellite +satira +satollo +saturno +savana +savio +saziato +sbadiglio +sbalzo +sbancato +sbarra +sbattere +sbavare +sbendare +sbirciare +sbloccato +sbocciato +sbrinare +sbruffone +sbuffare +scabroso +scadenza +scala +scambiare +scandalo +scapola +scarso +scatenare +scavato +scelto +scenico +scettro +scheda +schiena +sciarpa +scienza +scindere +scippo +sciroppo +scivolo +sclerare +scodella +scolpito +scomparto +sconforto +scoprire +scorta +scossone +scozzese +scriba +scrollare +scrutinio +scuderia +scultore +scuola +scuro +scusare +sdebitare +sdoganare +seccatura +secondo +sedano +seggiola +segnalato +segregato +seguito +selciato +selettivo +sella +selvaggio +semaforo +sembrare +seme +seminato +sempre +senso +sentire +sepolto +sequenza +serata +serbato +sereno +serio +serpente +serraglio +servire +sestina +setola +settimana +sfacelo +sfaldare +sfamato +sfarzoso +sfaticato +sfera +sfida +sfilato +sfinge +sfocato +sfoderare +sfogo +sfoltire +sforzato +sfratto +sfruttato +sfuggito +sfumare +sfuso +sgabello +sgarbato +sgonfiare +sgorbio +sgrassato +sguardo +sibilo +siccome +sierra +sigla +signore +silenzio +sillaba +simbolo +simpatico +simulato +sinfonia +singolo +sinistro +sino +sintesi +sinusoide +sipario +sisma +sistole +situato +slitta +slogatura +sloveno +smarrito +smemorato +smentito +smeraldo +smilzo +smontare +smottato +smussato +snellire +snervato +snodo +sobbalzo +sobrio +soccorso +sociale +sodale +soffitto +sogno +soldato +solenne +solido +sollazzo +solo +solubile +solvente +somatico +somma +sonda +sonetto +sonnifero +sopire +soppeso +sopra +sorgere +sorpasso +sorriso +sorso +sorteggio +sorvolato +sospiro +sosta +sottile +spada +spalla +spargere +spatola +spavento +spazzola +specie +spedire +spegnere +spelatura +speranza +spessore +spettrale +spezzato +spia +spigoloso +spillato +spinoso +spirale +splendido +sportivo +sposo +spranga +sprecare +spronato +spruzzo +spuntino +squillo +sradicare +srotolato +stabile +stacco +staffa +stagnare +stampato +stantio +starnuto +stasera +statuto +stelo +steppa +sterzo +stiletto +stima +stirpe +stivale +stizzoso +stonato +storico +strappo +stregato +stridulo +strozzare +strutto +stuccare +stufo +stupendo +subentro +succoso +sudore +suggerito +sugo +sultano +suonare +superbo +supporto +surgelato +surrogato +sussurro +sutura +svagare +svedese +sveglio +svelare +svenuto +svezia +sviluppo +svista +svizzera +svolta +svuotare +tabacco +tabulato +tacciare +taciturno +tale +talismano +tampone +tannino +tara +tardivo +targato +tariffa +tarpare +tartaruga +tasto +tattico +taverna +tavolata +tazza +teca +tecnico +telefono +temerario +tempo +temuto +tendone +tenero +tensione +tentacolo +teorema +terme +terrazzo +terzetto +tesi +tesserato +testato +tetro +tettoia +tifare +tigella +timbro +tinto +tipico +tipografo +tiraggio +tiro +titanio +titolo +titubante +tizio +tizzone +toccare +tollerare +tolto +tombola +tomo +tonfo +tonsilla +topazio +topologia +toppa +torba +tornare +torrone +tortora +toscano +tossire +tostatura +totano +trabocco +trachea +trafila +tragedia +tralcio +tramonto +transito +trapano +trarre +trasloco +trattato +trave +treccia +tremolio +trespolo +tributo +tricheco +trifoglio +trillo +trincea +trio +tristezza +triturato +trivella +tromba +trono +troppo +trottola +trovare +truccato +tubatura +tuffato +tulipano +tumulto +tunisia +turbare +turchino +tuta +tutela +ubicato +uccello +uccisore +udire +uditivo +uffa +ufficio +uguale +ulisse +ultimato +umano +umile +umorismo +uncinetto +ungere +ungherese +unicorno +unificato +unisono +unitario +unte +uovo +upupa +uragano +urgenza +urlo +usanza +usato +uscito +usignolo +usuraio +utensile +utilizzo +utopia +vacante +vaccinato +vagabondo +vagliato +valanga +valgo +valico +valletta +valoroso +valutare +valvola +vampata +vangare +vanitoso +vano +vantaggio +vanvera +vapore +varano +varcato +variante +vasca +vedetta +vedova +veduto +vegetale +veicolo +velcro +velina +velluto +veloce +venato +vendemmia +vento +verace +verbale +vergogna +verifica +vero +verruca +verticale +vescica +vessillo +vestale +veterano +vetrina +vetusto +viandante +vibrante +vicenda +vichingo +vicinanza +vidimare +vigilia +vigneto +vigore +vile +villano +vimini +vincitore +viola +vipera +virgola +virologo +virulento +viscoso +visione +vispo +vissuto +visura +vita +vitello +vittima +vivanda +vivido +viziare +voce +voga +volatile +volere +volpe +voragine +vulcano +zampogna +zanna +zappato +zattera +zavorra +zefiro +zelante +zelo +zenzero +zerbino +zibetto +zinco +zircone +zitto +zolla +zotico +zucchero +zufolo +zulu +zuppa diff --git a/packages/testcases/input/wordlists/lang-ja.txt b/packages/testcases/input/wordlists/lang-ja.txt new file mode 100644 index 000000000..fb8501a6e --- /dev/null +++ b/packages/testcases/input/wordlists/lang-ja.txt @@ -0,0 +1,2048 @@ +あいこくしん +あいさつ +あいだ +あおぞら +あかちゃん +あきる +あけがた +あける +あこがれる +あさい +あさひ +あしあと +あじわう +あずかる +あずき +あそぶ +あたえる +あたためる +あたりまえ +あたる +あつい +あつかう +あっしゅく +あつまり +あつめる +あてな +あてはまる +あひる +あぶら +あぶる +あふれる +あまい +あまど +あまやかす +あまり +あみもの +あめりか +あやまる +あゆむ +あらいぐま +あらし +あらすじ +あらためる +あらゆる +あらわす +ありがとう +あわせる +あわてる +あんい +あんがい +あんこ +あんぜん +あんてい +あんない +あんまり +いいだす +いおん +いがい +いがく +いきおい +いきなり +いきもの +いきる +いくじ +いくぶん +いけばな +いけん +いこう +いこく +いこつ +いさましい +いさん +いしき +いじゅう +いじょう +いじわる +いずみ +いずれ +いせい +いせえび +いせかい +いせき +いぜん +いそうろう +いそがしい +いだい +いだく +いたずら +いたみ +いたりあ +いちおう +いちじ +いちど +いちば +いちぶ +いちりゅう +いつか +いっしゅん +いっせい +いっそう +いったん +いっち +いってい +いっぽう +いてざ +いてん +いどう +いとこ +いない +いなか +いねむり +いのち +いのる +いはつ +いばる +いはん +いびき +いひん +いふく +いへん +いほう +いみん +いもうと +いもたれ +いもり +いやがる +いやす +いよかん +いよく +いらい +いらすと +いりぐち +いりょう +いれい +いれもの +いれる +いろえんぴつ +いわい +いわう +いわかん +いわば +いわゆる +いんげんまめ +いんさつ +いんしょう +いんよう +うえき +うえる +うおざ +うがい +うかぶ +うかべる +うきわ +うくらいな +うくれれ +うけたまわる +うけつけ +うけとる +うけもつ +うける +うごかす +うごく +うこん +うさぎ +うしなう +うしろがみ +うすい +うすぎ +うすぐらい +うすめる +うせつ +うちあわせ +うちがわ +うちき +うちゅう +うっかり +うつくしい +うったえる +うつる +うどん +うなぎ +うなじ +うなずく +うなる +うねる +うのう +うぶげ +うぶごえ +うまれる +うめる +うもう +うやまう +うよく +うらがえす +うらぐち +うらない +うりあげ +うりきれ +うるさい +うれしい +うれゆき +うれる +うろこ +うわき +うわさ +うんこう +うんちん +うんてん +うんどう +えいえん +えいが +えいきょう +えいご +えいせい +えいぶん +えいよう +えいわ +えおり +えがお +えがく +えきたい +えくせる +えしゃく +えすて +えつらん +えのぐ +えほうまき +えほん +えまき +えもじ +えもの +えらい +えらぶ +えりあ +えんえん +えんかい +えんぎ +えんげき +えんしゅう +えんぜつ +えんそく +えんちょう +えんとつ +おいかける +おいこす +おいしい +おいつく +おうえん +おうさま +おうじ +おうせつ +おうたい +おうふく +おうべい +おうよう +おえる +おおい +おおう +おおどおり +おおや +おおよそ +おかえり +おかず +おがむ +おかわり +おぎなう +おきる +おくさま +おくじょう +おくりがな +おくる +おくれる +おこす +おこなう +おこる +おさえる +おさない +おさめる +おしいれ +おしえる +おじぎ +おじさん +おしゃれ +おそらく +おそわる +おたがい +おたく +おだやか +おちつく +おっと +おつり +おでかけ +おとしもの +おとなしい +おどり +おどろかす +おばさん +おまいり +おめでとう +おもいで +おもう +おもたい +おもちゃ +おやつ +おやゆび +およぼす +おらんだ +おろす +おんがく +おんけい +おんしゃ +おんせん +おんだん +おんちゅう +おんどけい +かあつ +かいが +がいき +がいけん +がいこう +かいさつ +かいしゃ +かいすいよく +かいぜん +かいぞうど +かいつう +かいてん +かいとう +かいふく +がいへき +かいほう +かいよう +がいらい +かいわ +かえる +かおり +かかえる +かがく +かがし +かがみ +かくご +かくとく +かざる +がぞう +かたい +かたち +がちょう +がっきゅう +がっこう +がっさん +がっしょう +かなざわし +かのう +がはく +かぶか +かほう +かほご +かまう +かまぼこ +かめれおん +かゆい +かようび +からい +かるい +かろう +かわく +かわら +がんか +かんけい +かんこう +かんしゃ +かんそう +かんたん +かんち +がんばる +きあい +きあつ +きいろ +ぎいん +きうい +きうん +きえる +きおう +きおく +きおち +きおん +きかい +きかく +きかんしゃ +ききて +きくばり +きくらげ +きけんせい +きこう +きこえる +きこく +きさい +きさく +きさま +きさらぎ +ぎじかがく +ぎしき +ぎじたいけん +ぎじにってい +ぎじゅつしゃ +きすう +きせい +きせき +きせつ +きそう +きぞく +きぞん +きたえる +きちょう +きつえん +ぎっちり +きつつき +きつね +きてい +きどう +きどく +きない +きなが +きなこ +きぬごし +きねん +きのう +きのした +きはく +きびしい +きひん +きふく +きぶん +きぼう +きほん +きまる +きみつ +きむずかしい +きめる +きもだめし +きもち +きもの +きゃく +きやく +ぎゅうにく +きよう +きょうりゅう +きらい +きらく +きりん +きれい +きれつ +きろく +ぎろん +きわめる +ぎんいろ +きんかくじ +きんじょ +きんようび +ぐあい +くいず +くうかん +くうき +くうぐん +くうこう +ぐうせい +くうそう +ぐうたら +くうふく +くうぼ +くかん +くきょう +くげん +ぐこう +くさい +くさき +くさばな +くさる +くしゃみ +くしょう +くすのき +くすりゆび +くせげ +くせん +ぐたいてき +くださる +くたびれる +くちこみ +くちさき +くつした +ぐっすり +くつろぐ +くとうてん +くどく +くなん +くねくね +くのう +くふう +くみあわせ +くみたてる +くめる +くやくしょ +くらす +くらべる +くるま +くれる +くろう +くわしい +ぐんかん +ぐんしょく +ぐんたい +ぐんて +けあな +けいかく +けいけん +けいこ +けいさつ +げいじゅつ +けいたい +げいのうじん +けいれき +けいろ +けおとす +けおりもの +げきか +げきげん +げきだん +げきちん +げきとつ +げきは +げきやく +げこう +げこくじょう +げざい +けさき +げざん +けしき +けしごむ +けしょう +げすと +けたば +けちゃっぷ +けちらす +けつあつ +けつい +けつえき +けっこん +けつじょ +けっせき +けってい +けつまつ +げつようび +げつれい +けつろん +げどく +けとばす +けとる +けなげ +けなす +けなみ +けぬき +げねつ +けねん +けはい +げひん +けぶかい +げぼく +けまり +けみかる +けむし +けむり +けもの +けらい +けろけろ +けわしい +けんい +けんえつ +けんお +けんか +げんき +けんげん +けんこう +けんさく +けんしゅう +けんすう +げんそう +けんちく +けんてい +けんとう +けんない +けんにん +げんぶつ +けんま +けんみん +けんめい +けんらん +けんり +こあくま +こいぬ +こいびと +ごうい +こうえん +こうおん +こうかん +ごうきゅう +ごうけい +こうこう +こうさい +こうじ +こうすい +ごうせい +こうそく +こうたい +こうちゃ +こうつう +こうてい +こうどう +こうない +こうはい +ごうほう +ごうまん +こうもく +こうりつ +こえる +こおり +ごかい +ごがつ +ごかん +こくご +こくさい +こくとう +こくない +こくはく +こぐま +こけい +こける +ここのか +こころ +こさめ +こしつ +こすう +こせい +こせき +こぜん +こそだて +こたい +こたえる +こたつ +こちょう +こっか +こつこつ +こつばん +こつぶ +こてい +こてん +ことがら +ことし +ことば +ことり +こなごな +こねこね +このまま +このみ +このよ +ごはん +こひつじ +こふう +こふん +こぼれる +ごまあぶら +こまかい +ごますり +こまつな +こまる +こむぎこ +こもじ +こもち +こもの +こもん +こやく +こやま +こゆう +こゆび +こよい +こよう +こりる +これくしょん +ころっけ +こわもて +こわれる +こんいん +こんかい +こんき +こんしゅう +こんすい +こんだて +こんとん +こんなん +こんびに +こんぽん +こんまけ +こんや +こんれい +こんわく +ざいえき +さいかい +さいきん +ざいげん +ざいこ +さいしょ +さいせい +ざいたく +ざいちゅう +さいてき +ざいりょう +さうな +さかいし +さがす +さかな +さかみち +さがる +さぎょう +さくし +さくひん +さくら +さこく +さこつ +さずかる +ざせき +さたん +さつえい +ざつおん +ざっか +ざつがく +さっきょく +ざっし +さつじん +ざっそう +さつたば +さつまいも +さてい +さといも +さとう +さとおや +さとし +さとる +さのう +さばく +さびしい +さべつ +さほう +さほど +さます +さみしい +さみだれ +さむけ +さめる +さやえんどう +さゆう +さよう +さよく +さらだ +ざるそば +さわやか +さわる +さんいん +さんか +さんきゃく +さんこう +さんさい +ざんしょ +さんすう +さんせい +さんそ +さんち +さんま +さんみ +さんらん +しあい +しあげ +しあさって +しあわせ +しいく +しいん +しうち +しえい +しおけ +しかい +しかく +じかん +しごと +しすう +じだい +したうけ +したぎ +したて +したみ +しちょう +しちりん +しっかり +しつじ +しつもん +してい +してき +してつ +じてん +じどう +しなぎれ +しなもの +しなん +しねま +しねん +しのぐ +しのぶ +しはい +しばかり +しはつ +しはらい +しはん +しひょう +しふく +じぶん +しへい +しほう +しほん +しまう +しまる +しみん +しむける +じむしょ +しめい +しめる +しもん +しゃいん +しゃうん +しゃおん +じゃがいも +しやくしょ +しゃくほう +しゃけん +しゃこ +しゃざい +しゃしん +しゃせん +しゃそう +しゃたい +しゃちょう +しゃっきん +じゃま +しゃりん +しゃれい +じゆう +じゅうしょ +しゅくはく +じゅしん +しゅっせき +しゅみ +しゅらば +じゅんばん +しょうかい +しょくたく +しょっけん +しょどう +しょもつ +しらせる +しらべる +しんか +しんこう +じんじゃ +しんせいじ +しんちく +しんりん +すあげ +すあし +すあな +ずあん +すいえい +すいか +すいとう +ずいぶん +すいようび +すうがく +すうじつ +すうせん +すおどり +すきま +すくう +すくない +すける +すごい +すこし +ずさん +すずしい +すすむ +すすめる +すっかり +ずっしり +ずっと +すてき +すてる +すねる +すのこ +すはだ +すばらしい +ずひょう +ずぶぬれ +すぶり +すふれ +すべて +すべる +ずほう +すぼん +すまい +すめし +すもう +すやき +すらすら +するめ +すれちがう +すろっと +すわる +すんぜん +すんぽう +せあぶら +せいかつ +せいげん +せいじ +せいよう +せおう +せかいかん +せきにん +せきむ +せきゆ +せきらんうん +せけん +せこう +せすじ +せたい +せたけ +せっかく +せっきゃく +ぜっく +せっけん +せっこつ +せっさたくま +せつぞく +せつだん +せつでん +せっぱん +せつび +せつぶん +せつめい +せつりつ +せなか +せのび +せはば +せびろ +せぼね +せまい +せまる +せめる +せもたれ +せりふ +ぜんあく +せんい +せんえい +せんか +せんきょ +せんく +せんげん +ぜんご +せんさい +せんしゅ +せんすい +せんせい +せんぞ +せんたく +せんちょう +せんてい +せんとう +せんぬき +せんねん +せんぱい +ぜんぶ +ぜんぽう +せんむ +せんめんじょ +せんもん +せんやく +せんゆう +せんよう +ぜんら +ぜんりゃく +せんれい +せんろ +そあく +そいとげる +そいね +そうがんきょう +そうき +そうご +そうしん +そうだん +そうなん +そうび +そうめん +そうり +そえもの +そえん +そがい +そげき +そこう +そこそこ +そざい +そしな +そせい +そせん +そそぐ +そだてる +そつう +そつえん +そっかん +そつぎょう +そっけつ +そっこう +そっせん +そっと +そとがわ +そとづら +そなえる +そなた +そふぼ +そぼく +そぼろ +そまつ +そまる +そむく +そむりえ +そめる +そもそも +そよかぜ +そらまめ +そろう +そんかい +そんけい +そんざい +そんしつ +そんぞく +そんちょう +ぞんび +ぞんぶん +そんみん +たあい +たいいん +たいうん +たいえき +たいおう +だいがく +たいき +たいぐう +たいけん +たいこ +たいざい +だいじょうぶ +だいすき +たいせつ +たいそう +だいたい +たいちょう +たいてい +だいどころ +たいない +たいねつ +たいのう +たいはん +だいひょう +たいふう +たいへん +たいほ +たいまつばな +たいみんぐ +たいむ +たいめん +たいやき +たいよう +たいら +たいりょく +たいる +たいわん +たうえ +たえる +たおす +たおる +たおれる +たかい +たかね +たきび +たくさん +たこく +たこやき +たさい +たしざん +だじゃれ +たすける +たずさわる +たそがれ +たたかう +たたく +ただしい +たたみ +たちばな +だっかい +だっきゃく +だっこ +だっしゅつ +だったい +たてる +たとえる +たなばた +たにん +たぬき +たのしみ +たはつ +たぶん +たべる +たぼう +たまご +たまる +だむる +ためいき +ためす +ためる +たもつ +たやすい +たよる +たらす +たりきほんがん +たりょう +たりる +たると +たれる +たれんと +たろっと +たわむれる +だんあつ +たんい +たんおん +たんか +たんき +たんけん +たんご +たんさん +たんじょうび +だんせい +たんそく +たんたい +だんち +たんてい +たんとう +だんな +たんにん +だんねつ +たんのう +たんぴん +だんぼう +たんまつ +たんめい +だんれつ +だんろ +だんわ +ちあい +ちあん +ちいき +ちいさい +ちえん +ちかい +ちから +ちきゅう +ちきん +ちけいず +ちけん +ちこく +ちさい +ちしき +ちしりょう +ちせい +ちそう +ちたい +ちたん +ちちおや +ちつじょ +ちてき +ちてん +ちぬき +ちぬり +ちのう +ちひょう +ちへいせん +ちほう +ちまた +ちみつ +ちみどろ +ちめいど +ちゃんこなべ +ちゅうい +ちゆりょく +ちょうし +ちょさくけん +ちらし +ちらみ +ちりがみ +ちりょう +ちるど +ちわわ +ちんたい +ちんもく +ついか +ついたち +つうか +つうじょう +つうはん +つうわ +つかう +つかれる +つくね +つくる +つけね +つける +つごう +つたえる +つづく +つつじ +つつむ +つとめる +つながる +つなみ +つねづね +つのる +つぶす +つまらない +つまる +つみき +つめたい +つもり +つもる +つよい +つるぼ +つるみく +つわもの +つわり +てあし +てあて +てあみ +ていおん +ていか +ていき +ていけい +ていこく +ていさつ +ていし +ていせい +ていたい +ていど +ていねい +ていひょう +ていへん +ていぼう +てうち +ておくれ +てきとう +てくび +でこぼこ +てさぎょう +てさげ +てすり +てそう +てちがい +てちょう +てつがく +てつづき +でっぱ +てつぼう +てつや +でぬかえ +てぬき +てぬぐい +てのひら +てはい +てぶくろ +てふだ +てほどき +てほん +てまえ +てまきずし +てみじか +てみやげ +てらす +てれび +てわけ +てわたし +でんあつ +てんいん +てんかい +てんき +てんぐ +てんけん +てんごく +てんさい +てんし +てんすう +でんち +てんてき +てんとう +てんない +てんぷら +てんぼうだい +てんめつ +てんらんかい +でんりょく +でんわ +どあい +といれ +どうかん +とうきゅう +どうぐ +とうし +とうむぎ +とおい +とおか +とおく +とおす +とおる +とかい +とかす +ときおり +ときどき +とくい +とくしゅう +とくてん +とくに +とくべつ +とけい +とける +とこや +とさか +としょかん +とそう +とたん +とちゅう +とっきゅう +とっくん +とつぜん +とつにゅう +とどける +ととのえる +とない +となえる +となり +とのさま +とばす +どぶがわ +とほう +とまる +とめる +ともだち +ともる +どようび +とらえる +とんかつ +どんぶり +ないかく +ないこう +ないしょ +ないす +ないせん +ないそう +なおす +ながい +なくす +なげる +なこうど +なさけ +なたでここ +なっとう +なつやすみ +ななおし +なにごと +なにもの +なにわ +なのか +なふだ +なまいき +なまえ +なまみ +なみだ +なめらか +なめる +なやむ +ならう +ならび +ならぶ +なれる +なわとび +なわばり +にあう +にいがた +にうけ +におい +にかい +にがて +にきび +にくしみ +にくまん +にげる +にさんかたんそ +にしき +にせもの +にちじょう +にちようび +にっか +にっき +にっけい +にっこう +にっさん +にっしょく +にっすう +にっせき +にってい +になう +にほん +にまめ +にもつ +にやり +にゅういん +にりんしゃ +にわとり +にんい +にんか +にんき +にんげん +にんしき +にんずう +にんそう +にんたい +にんち +にんてい +にんにく +にんぷ +にんまり +にんむ +にんめい +にんよう +ぬいくぎ +ぬかす +ぬぐいとる +ぬぐう +ぬくもり +ぬすむ +ぬまえび +ぬめり +ぬらす +ぬんちゃく +ねあげ +ねいき +ねいる +ねいろ +ねぐせ +ねくたい +ねくら +ねこぜ +ねこむ +ねさげ +ねすごす +ねそべる +ねだん +ねつい +ねっしん +ねつぞう +ねったいぎょ +ねぶそく +ねふだ +ねぼう +ねほりはほり +ねまき +ねまわし +ねみみ +ねむい +ねむたい +ねもと +ねらう +ねわざ +ねんいり +ねんおし +ねんかん +ねんきん +ねんぐ +ねんざ +ねんし +ねんちゃく +ねんど +ねんぴ +ねんぶつ +ねんまつ +ねんりょう +ねんれい +のいず +のおづま +のがす +のきなみ +のこぎり +のこす +のこる +のせる +のぞく +のぞむ +のたまう +のちほど +のっく +のばす +のはら +のべる +のぼる +のみもの +のやま +のらいぬ +のらねこ +のりもの +のりゆき +のれん +のんき +ばあい +はあく +ばあさん +ばいか +ばいく +はいけん +はいご +はいしん +はいすい +はいせん +はいそう +はいち +ばいばい +はいれつ +はえる +はおる +はかい +ばかり +はかる +はくしゅ +はけん +はこぶ +はさみ +はさん +はしご +ばしょ +はしる +はせる +ぱそこん +はそん +はたん +はちみつ +はつおん +はっかく +はづき +はっきり +はっくつ +はっけん +はっこう +はっさん +はっしん +はったつ +はっちゅう +はってん +はっぴょう +はっぽう +はなす +はなび +はにかむ +はぶらし +はみがき +はむかう +はめつ +はやい +はやし +はらう +はろうぃん +はわい +はんい +はんえい +はんおん +はんかく +はんきょう +ばんぐみ +はんこ +はんしゃ +はんすう +はんだん +ぱんち +ぱんつ +はんてい +はんとし +はんのう +はんぱ +はんぶん +はんぺん +はんぼうき +はんめい +はんらん +はんろん +ひいき +ひうん +ひえる +ひかく +ひかり +ひかる +ひかん +ひくい +ひけつ +ひこうき +ひこく +ひさい +ひさしぶり +ひさん +びじゅつかん +ひしょ +ひそか +ひそむ +ひたむき +ひだり +ひたる +ひつぎ +ひっこし +ひっし +ひつじゅひん +ひっす +ひつぜん +ぴったり +ぴっちり +ひつよう +ひてい +ひとごみ +ひなまつり +ひなん +ひねる +ひはん +ひびく +ひひょう +ひほう +ひまわり +ひまん +ひみつ +ひめい +ひめじし +ひやけ +ひやす +ひよう +びょうき +ひらがな +ひらく +ひりつ +ひりょう +ひるま +ひるやすみ +ひれい +ひろい +ひろう +ひろき +ひろゆき +ひんかく +ひんけつ +ひんこん +ひんしゅ +ひんそう +ぴんち +ひんぱん +びんぼう +ふあん +ふいうち +ふうけい +ふうせん +ぷうたろう +ふうとう +ふうふ +ふえる +ふおん +ふかい +ふきん +ふくざつ +ふくぶくろ +ふこう +ふさい +ふしぎ +ふじみ +ふすま +ふせい +ふせぐ +ふそく +ぶたにく +ふたん +ふちょう +ふつう +ふつか +ふっかつ +ふっき +ふっこく +ぶどう +ふとる +ふとん +ふのう +ふはい +ふひょう +ふへん +ふまん +ふみん +ふめつ +ふめん +ふよう +ふりこ +ふりる +ふるい +ふんいき +ぶんがく +ぶんぐ +ふんしつ +ぶんせき +ふんそう +ぶんぽう +へいあん +へいおん +へいがい +へいき +へいげん +へいこう +へいさ +へいしゃ +へいせつ +へいそ +へいたく +へいてん +へいねつ +へいわ +へきが +へこむ +べにいろ +べにしょうが +へらす +へんかん +べんきょう +べんごし +へんさい +へんたい +べんり +ほあん +ほいく +ぼうぎょ +ほうこく +ほうそう +ほうほう +ほうもん +ほうりつ +ほえる +ほおん +ほかん +ほきょう +ぼきん +ほくろ +ほけつ +ほけん +ほこう +ほこる +ほしい +ほしつ +ほしゅ +ほしょう +ほせい +ほそい +ほそく +ほたて +ほたる +ぽちぶくろ +ほっきょく +ほっさ +ほったん +ほとんど +ほめる +ほんい +ほんき +ほんけ +ほんしつ +ほんやく +まいにち +まかい +まかせる +まがる +まける +まこと +まさつ +まじめ +ますく +まぜる +まつり +まとめ +まなぶ +まぬけ +まねく +まほう +まもる +まゆげ +まよう +まろやか +まわす +まわり +まわる +まんが +まんきつ +まんぞく +まんなか +みいら +みうち +みえる +みがく +みかた +みかん +みけん +みこん +みじかい +みすい +みすえる +みせる +みっか +みつかる +みつける +みてい +みとめる +みなと +みなみかさい +みねらる +みのう +みのがす +みほん +みもと +みやげ +みらい +みりょく +みわく +みんか +みんぞく +むいか +むえき +むえん +むかい +むかう +むかえ +むかし +むぎちゃ +むける +むげん +むさぼる +むしあつい +むしば +むじゅん +むしろ +むすう +むすこ +むすぶ +むすめ +むせる +むせん +むちゅう +むなしい +むのう +むやみ +むよう +むらさき +むりょう +むろん +めいあん +めいうん +めいえん +めいかく +めいきょく +めいさい +めいし +めいそう +めいぶつ +めいれい +めいわく +めぐまれる +めざす +めした +めずらしい +めだつ +めまい +めやす +めんきょ +めんせき +めんどう +もうしあげる +もうどうけん +もえる +もくし +もくてき +もくようび +もちろん +もどる +もらう +もんく +もんだい +やおや +やける +やさい +やさしい +やすい +やすたろう +やすみ +やせる +やそう +やたい +やちん +やっと +やっぱり +やぶる +やめる +ややこしい +やよい +やわらかい +ゆうき +ゆうびんきょく +ゆうべ +ゆうめい +ゆけつ +ゆしゅつ +ゆせん +ゆそう +ゆたか +ゆちゃく +ゆでる +ゆにゅう +ゆびわ +ゆらい +ゆれる +ようい +ようか +ようきゅう +ようじ +ようす +ようちえん +よかぜ +よかん +よきん +よくせい +よくぼう +よけい +よごれる +よさん +よしゅう +よそう +よそく +よっか +よてい +よどがわく +よねつ +よやく +よゆう +よろこぶ +よろしい +らいう +らくがき +らくご +らくさつ +らくだ +らしんばん +らせん +らぞく +らたい +らっか +られつ +りえき +りかい +りきさく +りきせつ +りくぐん +りくつ +りけん +りこう +りせい +りそう +りそく +りてん +りねん +りゆう +りゅうがく +りよう +りょうり +りょかん +りょくちゃ +りょこう +りりく +りれき +りろん +りんご +るいけい +るいさい +るいじ +るいせき +るすばん +るりがわら +れいかん +れいぎ +れいせい +れいぞうこ +れいとう +れいぼう +れきし +れきだい +れんあい +れんけい +れんこん +れんさい +れんしゅう +れんぞく +れんらく +ろうか +ろうご +ろうじん +ろうそく +ろくが +ろこつ +ろじうら +ろしゅつ +ろせん +ろてん +ろめん +ろれつ +ろんぎ +ろんぱ +ろんぶん +ろんり +わかす +わかめ +わかやま +わかれる +わしつ +わじまし +わすれもの +わらう +われる diff --git a/packages/testcases/input/wordlists/lang-ko.txt b/packages/testcases/input/wordlists/lang-ko.txt new file mode 100644 index 000000000..1acebf75a --- /dev/null +++ b/packages/testcases/input/wordlists/lang-ko.txt @@ -0,0 +1,2048 @@ +가격 +가끔 +가난 +가능 +가득 +가르침 +가뭄 +가방 +가상 +가슴 +가운데 +가을 +가이드 +가입 +가장 +가정 +가족 +가죽 +각오 +각자 +간격 +간부 +간섭 +간장 +간접 +간판 +갈등 +갈비 +갈색 +갈증 +감각 +감기 +감소 +감수성 +감자 +감정 +갑자기 +강남 +강당 +강도 +강력히 +강변 +강북 +강사 +강수량 +강아지 +강원도 +강의 +강제 +강조 +같이 +개구리 +개나리 +개방 +개별 +개선 +개성 +개인 +객관적 +거실 +거액 +거울 +거짓 +거품 +걱정 +건강 +건물 +건설 +건조 +건축 +걸음 +검사 +검토 +게시판 +게임 +겨울 +견해 +결과 +결국 +결론 +결석 +결승 +결심 +결정 +결혼 +경계 +경고 +경기 +경력 +경복궁 +경비 +경상도 +경영 +경우 +경쟁 +경제 +경주 +경찰 +경치 +경향 +경험 +계곡 +계단 +계란 +계산 +계속 +계약 +계절 +계층 +계획 +고객 +고구려 +고궁 +고급 +고등학생 +고무신 +고민 +고양이 +고장 +고전 +고집 +고춧가루 +고통 +고향 +곡식 +골목 +골짜기 +골프 +공간 +공개 +공격 +공군 +공급 +공기 +공동 +공무원 +공부 +공사 +공식 +공업 +공연 +공원 +공장 +공짜 +공책 +공통 +공포 +공항 +공휴일 +과목 +과일 +과장 +과정 +과학 +관객 +관계 +관광 +관념 +관람 +관련 +관리 +관습 +관심 +관점 +관찰 +광경 +광고 +광장 +광주 +괴로움 +굉장히 +교과서 +교문 +교복 +교실 +교양 +교육 +교장 +교직 +교통 +교환 +교훈 +구경 +구름 +구멍 +구별 +구분 +구석 +구성 +구속 +구역 +구입 +구청 +구체적 +국가 +국기 +국내 +국립 +국물 +국민 +국수 +국어 +국왕 +국적 +국제 +국회 +군대 +군사 +군인 +궁극적 +권리 +권위 +권투 +귀국 +귀신 +규정 +규칙 +균형 +그날 +그냥 +그늘 +그러나 +그룹 +그릇 +그림 +그제서야 +그토록 +극복 +극히 +근거 +근교 +근래 +근로 +근무 +근본 +근원 +근육 +근처 +글씨 +글자 +금강산 +금고 +금년 +금메달 +금액 +금연 +금요일 +금지 +긍정적 +기간 +기관 +기념 +기능 +기독교 +기둥 +기록 +기름 +기법 +기본 +기분 +기쁨 +기숙사 +기술 +기억 +기업 +기온 +기운 +기원 +기적 +기준 +기침 +기혼 +기획 +긴급 +긴장 +길이 +김밥 +김치 +김포공항 +깍두기 +깜빡 +깨달음 +깨소금 +껍질 +꼭대기 +꽃잎 +나들이 +나란히 +나머지 +나물 +나침반 +나흘 +낙엽 +난방 +날개 +날씨 +날짜 +남녀 +남대문 +남매 +남산 +남자 +남편 +남학생 +낭비 +낱말 +내년 +내용 +내일 +냄비 +냄새 +냇물 +냉동 +냉면 +냉방 +냉장고 +넥타이 +넷째 +노동 +노란색 +노력 +노인 +녹음 +녹차 +녹화 +논리 +논문 +논쟁 +놀이 +농구 +농담 +농민 +농부 +농업 +농장 +농촌 +높이 +눈동자 +눈물 +눈썹 +뉴욕 +느낌 +늑대 +능동적 +능력 +다방 +다양성 +다음 +다이어트 +다행 +단계 +단골 +단독 +단맛 +단순 +단어 +단위 +단점 +단체 +단추 +단편 +단풍 +달걀 +달러 +달력 +달리 +닭고기 +담당 +담배 +담요 +담임 +답변 +답장 +당근 +당분간 +당연히 +당장 +대규모 +대낮 +대단히 +대답 +대도시 +대략 +대량 +대륙 +대문 +대부분 +대신 +대응 +대장 +대전 +대접 +대중 +대책 +대출 +대충 +대통령 +대학 +대한민국 +대합실 +대형 +덩어리 +데이트 +도대체 +도덕 +도둑 +도망 +도서관 +도심 +도움 +도입 +도자기 +도저히 +도전 +도중 +도착 +독감 +독립 +독서 +독일 +독창적 +동화책 +뒷모습 +뒷산 +딸아이 +마누라 +마늘 +마당 +마라톤 +마련 +마무리 +마사지 +마약 +마요네즈 +마을 +마음 +마이크 +마중 +마지막 +마찬가지 +마찰 +마흔 +막걸리 +막내 +막상 +만남 +만두 +만세 +만약 +만일 +만점 +만족 +만화 +많이 +말기 +말씀 +말투 +맘대로 +망원경 +매년 +매달 +매력 +매번 +매스컴 +매일 +매장 +맥주 +먹이 +먼저 +먼지 +멀리 +메일 +며느리 +며칠 +면담 +멸치 +명단 +명령 +명예 +명의 +명절 +명칭 +명함 +모금 +모니터 +모델 +모든 +모범 +모습 +모양 +모임 +모조리 +모집 +모퉁이 +목걸이 +목록 +목사 +목소리 +목숨 +목적 +목표 +몰래 +몸매 +몸무게 +몸살 +몸속 +몸짓 +몸통 +몹시 +무관심 +무궁화 +무더위 +무덤 +무릎 +무슨 +무엇 +무역 +무용 +무조건 +무지개 +무척 +문구 +문득 +문법 +문서 +문제 +문학 +문화 +물가 +물건 +물결 +물고기 +물론 +물리학 +물음 +물질 +물체 +미국 +미디어 +미사일 +미술 +미역 +미용실 +미움 +미인 +미팅 +미혼 +민간 +민족 +민주 +믿음 +밀가루 +밀리미터 +밑바닥 +바가지 +바구니 +바나나 +바늘 +바닥 +바닷가 +바람 +바이러스 +바탕 +박물관 +박사 +박수 +반대 +반드시 +반말 +반발 +반성 +반응 +반장 +반죽 +반지 +반찬 +받침 +발가락 +발걸음 +발견 +발달 +발레 +발목 +발바닥 +발생 +발음 +발자국 +발전 +발톱 +발표 +밤하늘 +밥그릇 +밥맛 +밥상 +밥솥 +방금 +방면 +방문 +방바닥 +방법 +방송 +방식 +방안 +방울 +방지 +방학 +방해 +방향 +배경 +배꼽 +배달 +배드민턴 +백두산 +백색 +백성 +백인 +백제 +백화점 +버릇 +버섯 +버튼 +번개 +번역 +번지 +번호 +벌금 +벌레 +벌써 +범위 +범인 +범죄 +법률 +법원 +법적 +법칙 +베이징 +벨트 +변경 +변동 +변명 +변신 +변호사 +변화 +별도 +별명 +별일 +병실 +병아리 +병원 +보관 +보너스 +보라색 +보람 +보름 +보상 +보안 +보자기 +보장 +보전 +보존 +보통 +보편적 +보험 +복도 +복사 +복숭아 +복습 +볶음 +본격적 +본래 +본부 +본사 +본성 +본인 +본질 +볼펜 +봉사 +봉지 +봉투 +부근 +부끄러움 +부담 +부동산 +부문 +부분 +부산 +부상 +부엌 +부인 +부작용 +부장 +부정 +부족 +부지런히 +부친 +부탁 +부품 +부회장 +북부 +북한 +분노 +분량 +분리 +분명 +분석 +분야 +분위기 +분필 +분홍색 +불고기 +불과 +불교 +불꽃 +불만 +불법 +불빛 +불안 +불이익 +불행 +브랜드 +비극 +비난 +비닐 +비둘기 +비디오 +비로소 +비만 +비명 +비밀 +비바람 +비빔밥 +비상 +비용 +비율 +비중 +비타민 +비판 +빌딩 +빗물 +빗방울 +빗줄기 +빛깔 +빨간색 +빨래 +빨리 +사건 +사계절 +사나이 +사냥 +사람 +사랑 +사립 +사모님 +사물 +사방 +사상 +사생활 +사설 +사슴 +사실 +사업 +사용 +사월 +사장 +사전 +사진 +사촌 +사춘기 +사탕 +사투리 +사흘 +산길 +산부인과 +산업 +산책 +살림 +살인 +살짝 +삼계탕 +삼국 +삼십 +삼월 +삼촌 +상관 +상금 +상대 +상류 +상반기 +상상 +상식 +상업 +상인 +상자 +상점 +상처 +상추 +상태 +상표 +상품 +상황 +새벽 +색깔 +색연필 +생각 +생명 +생물 +생방송 +생산 +생선 +생신 +생일 +생활 +서랍 +서른 +서명 +서민 +서비스 +서양 +서울 +서적 +서점 +서쪽 +서클 +석사 +석유 +선거 +선물 +선배 +선생 +선수 +선원 +선장 +선전 +선택 +선풍기 +설거지 +설날 +설렁탕 +설명 +설문 +설사 +설악산 +설치 +설탕 +섭씨 +성공 +성당 +성명 +성별 +성인 +성장 +성적 +성질 +성함 +세금 +세미나 +세상 +세월 +세종대왕 +세탁 +센터 +센티미터 +셋째 +소규모 +소극적 +소금 +소나기 +소년 +소득 +소망 +소문 +소설 +소속 +소아과 +소용 +소원 +소음 +소중히 +소지품 +소질 +소풍 +소형 +속담 +속도 +속옷 +손가락 +손길 +손녀 +손님 +손등 +손목 +손뼉 +손실 +손질 +손톱 +손해 +솔직히 +솜씨 +송아지 +송이 +송편 +쇠고기 +쇼핑 +수건 +수년 +수단 +수돗물 +수동적 +수면 +수명 +수박 +수상 +수석 +수술 +수시로 +수업 +수염 +수영 +수입 +수준 +수집 +수출 +수컷 +수필 +수학 +수험생 +수화기 +숙녀 +숙소 +숙제 +순간 +순서 +순수 +순식간 +순위 +숟가락 +술병 +술집 +숫자 +스님 +스물 +스스로 +스승 +스웨터 +스위치 +스케이트 +스튜디오 +스트레스 +스포츠 +슬쩍 +슬픔 +습관 +습기 +승객 +승리 +승부 +승용차 +승진 +시각 +시간 +시골 +시금치 +시나리오 +시댁 +시리즈 +시멘트 +시민 +시부모 +시선 +시설 +시스템 +시아버지 +시어머니 +시월 +시인 +시일 +시작 +시장 +시절 +시점 +시중 +시즌 +시집 +시청 +시합 +시험 +식구 +식기 +식당 +식량 +식료품 +식물 +식빵 +식사 +식생활 +식초 +식탁 +식품 +신고 +신규 +신념 +신문 +신발 +신비 +신사 +신세 +신용 +신제품 +신청 +신체 +신화 +실감 +실내 +실력 +실례 +실망 +실수 +실습 +실시 +실장 +실정 +실질적 +실천 +실체 +실컷 +실태 +실패 +실험 +실현 +심리 +심부름 +심사 +심장 +심정 +심판 +쌍둥이 +씨름 +씨앗 +아가씨 +아나운서 +아드님 +아들 +아쉬움 +아스팔트 +아시아 +아울러 +아저씨 +아줌마 +아직 +아침 +아파트 +아프리카 +아픔 +아홉 +아흔 +악기 +악몽 +악수 +안개 +안경 +안과 +안내 +안녕 +안동 +안방 +안부 +안주 +알루미늄 +알코올 +암시 +암컷 +압력 +앞날 +앞문 +애인 +애정 +액수 +앨범 +야간 +야단 +야옹 +약간 +약국 +약속 +약수 +약점 +약품 +약혼녀 +양념 +양력 +양말 +양배추 +양주 +양파 +어둠 +어려움 +어른 +어젯밤 +어쨌든 +어쩌다가 +어쩐지 +언니 +언덕 +언론 +언어 +얼굴 +얼른 +얼음 +얼핏 +엄마 +업무 +업종 +업체 +엉덩이 +엉망 +엉터리 +엊그제 +에너지 +에어컨 +엔진 +여건 +여고생 +여관 +여군 +여권 +여대생 +여덟 +여동생 +여든 +여론 +여름 +여섯 +여성 +여왕 +여인 +여전히 +여직원 +여학생 +여행 +역사 +역시 +역할 +연결 +연구 +연극 +연기 +연락 +연설 +연세 +연속 +연습 +연애 +연예인 +연인 +연장 +연주 +연출 +연필 +연합 +연휴 +열기 +열매 +열쇠 +열심히 +열정 +열차 +열흘 +염려 +엽서 +영국 +영남 +영상 +영양 +영역 +영웅 +영원히 +영하 +영향 +영혼 +영화 +옆구리 +옆방 +옆집 +예감 +예금 +예방 +예산 +예상 +예선 +예술 +예습 +예식장 +예약 +예전 +예절 +예정 +예컨대 +옛날 +오늘 +오락 +오랫동안 +오렌지 +오로지 +오른발 +오븐 +오십 +오염 +오월 +오전 +오직 +오징어 +오페라 +오피스텔 +오히려 +옥상 +옥수수 +온갖 +온라인 +온몸 +온종일 +온통 +올가을 +올림픽 +올해 +옷차림 +와이셔츠 +와인 +완성 +완전 +왕비 +왕자 +왜냐하면 +왠지 +외갓집 +외국 +외로움 +외삼촌 +외출 +외침 +외할머니 +왼발 +왼손 +왼쪽 +요금 +요일 +요즘 +요청 +용기 +용서 +용어 +우산 +우선 +우승 +우연히 +우정 +우체국 +우편 +운동 +운명 +운반 +운전 +운행 +울산 +울음 +움직임 +웃어른 +웃음 +워낙 +원고 +원래 +원서 +원숭이 +원인 +원장 +원피스 +월급 +월드컵 +월세 +월요일 +웨이터 +위반 +위법 +위성 +위원 +위험 +위협 +윗사람 +유난히 +유럽 +유명 +유물 +유산 +유적 +유치원 +유학 +유행 +유형 +육군 +육상 +육십 +육체 +은행 +음력 +음료 +음반 +음성 +음식 +음악 +음주 +의견 +의논 +의문 +의복 +의식 +의심 +의외로 +의욕 +의원 +의학 +이것 +이곳 +이념 +이놈 +이달 +이대로 +이동 +이렇게 +이력서 +이론적 +이름 +이민 +이발소 +이별 +이불 +이빨 +이상 +이성 +이슬 +이야기 +이용 +이웃 +이월 +이윽고 +이익 +이전 +이중 +이튿날 +이틀 +이혼 +인간 +인격 +인공 +인구 +인근 +인기 +인도 +인류 +인물 +인생 +인쇄 +인연 +인원 +인재 +인종 +인천 +인체 +인터넷 +인하 +인형 +일곱 +일기 +일단 +일대 +일등 +일반 +일본 +일부 +일상 +일생 +일손 +일요일 +일월 +일정 +일종 +일주일 +일찍 +일체 +일치 +일행 +일회용 +임금 +임무 +입대 +입력 +입맛 +입사 +입술 +입시 +입원 +입장 +입학 +자가용 +자격 +자극 +자동 +자랑 +자부심 +자식 +자신 +자연 +자원 +자율 +자전거 +자정 +자존심 +자판 +작가 +작년 +작성 +작업 +작용 +작은딸 +작품 +잔디 +잔뜩 +잔치 +잘못 +잠깐 +잠수함 +잠시 +잠옷 +잠자리 +잡지 +장관 +장군 +장기간 +장래 +장례 +장르 +장마 +장면 +장모 +장미 +장비 +장사 +장소 +장식 +장애인 +장인 +장점 +장차 +장학금 +재능 +재빨리 +재산 +재생 +재작년 +재정 +재채기 +재판 +재학 +재활용 +저것 +저고리 +저곳 +저녁 +저런 +저렇게 +저번 +저울 +저절로 +저축 +적극 +적당히 +적성 +적용 +적응 +전개 +전공 +전기 +전달 +전라도 +전망 +전문 +전반 +전부 +전세 +전시 +전용 +전자 +전쟁 +전주 +전철 +전체 +전통 +전혀 +전후 +절대 +절망 +절반 +절약 +절차 +점검 +점수 +점심 +점원 +점점 +점차 +접근 +접시 +접촉 +젓가락 +정거장 +정도 +정류장 +정리 +정말 +정면 +정문 +정반대 +정보 +정부 +정비 +정상 +정성 +정오 +정원 +정장 +정지 +정치 +정확히 +제공 +제과점 +제대로 +제목 +제발 +제법 +제삿날 +제안 +제일 +제작 +제주도 +제출 +제품 +제한 +조각 +조건 +조금 +조깅 +조명 +조미료 +조상 +조선 +조용히 +조절 +조정 +조직 +존댓말 +존재 +졸업 +졸음 +종교 +종로 +종류 +종소리 +종업원 +종종 +종합 +좌석 +죄인 +주관적 +주름 +주말 +주머니 +주먹 +주문 +주민 +주방 +주변 +주식 +주인 +주일 +주장 +주전자 +주택 +준비 +줄거리 +줄기 +줄무늬 +중간 +중계방송 +중국 +중년 +중단 +중독 +중반 +중부 +중세 +중소기업 +중순 +중앙 +중요 +중학교 +즉석 +즉시 +즐거움 +증가 +증거 +증권 +증상 +증세 +지각 +지갑 +지경 +지극히 +지금 +지급 +지능 +지름길 +지리산 +지방 +지붕 +지식 +지역 +지우개 +지원 +지적 +지점 +지진 +지출 +직선 +직업 +직원 +직장 +진급 +진동 +진로 +진료 +진리 +진짜 +진찰 +진출 +진통 +진행 +질문 +질병 +질서 +짐작 +집단 +집안 +집중 +짜증 +찌꺼기 +차남 +차라리 +차량 +차림 +차별 +차선 +차츰 +착각 +찬물 +찬성 +참가 +참기름 +참새 +참석 +참여 +참외 +참조 +찻잔 +창가 +창고 +창구 +창문 +창밖 +창작 +창조 +채널 +채점 +책가방 +책방 +책상 +책임 +챔피언 +처벌 +처음 +천국 +천둥 +천장 +천재 +천천히 +철도 +철저히 +철학 +첫날 +첫째 +청년 +청바지 +청소 +청춘 +체계 +체력 +체온 +체육 +체중 +체험 +초등학생 +초반 +초밥 +초상화 +초순 +초여름 +초원 +초저녁 +초점 +초청 +초콜릿 +촛불 +총각 +총리 +총장 +촬영 +최근 +최상 +최선 +최신 +최악 +최종 +추석 +추억 +추진 +추천 +추측 +축구 +축소 +축제 +축하 +출근 +출발 +출산 +출신 +출연 +출입 +출장 +출판 +충격 +충고 +충돌 +충분히 +충청도 +취업 +취직 +취향 +치약 +친구 +친척 +칠십 +칠월 +칠판 +침대 +침묵 +침실 +칫솔 +칭찬 +카메라 +카운터 +칼국수 +캐릭터 +캠퍼스 +캠페인 +커튼 +컨디션 +컬러 +컴퓨터 +코끼리 +코미디 +콘서트 +콜라 +콤플렉스 +콩나물 +쾌감 +쿠데타 +크림 +큰길 +큰딸 +큰소리 +큰아들 +큰어머니 +큰일 +큰절 +클래식 +클럽 +킬로 +타입 +타자기 +탁구 +탁자 +탄생 +태권도 +태양 +태풍 +택시 +탤런트 +터널 +터미널 +테니스 +테스트 +테이블 +텔레비전 +토론 +토마토 +토요일 +통계 +통과 +통로 +통신 +통역 +통일 +통장 +통제 +통증 +통합 +통화 +퇴근 +퇴원 +퇴직금 +튀김 +트럭 +특급 +특별 +특성 +특수 +특징 +특히 +튼튼히 +티셔츠 +파란색 +파일 +파출소 +판결 +판단 +판매 +판사 +팔십 +팔월 +팝송 +패션 +팩스 +팩시밀리 +팬티 +퍼센트 +페인트 +편견 +편의 +편지 +편히 +평가 +평균 +평생 +평소 +평양 +평일 +평화 +포스터 +포인트 +포장 +포함 +표면 +표정 +표준 +표현 +품목 +품질 +풍경 +풍속 +풍습 +프랑스 +프린터 +플라스틱 +피곤 +피망 +피아노 +필름 +필수 +필요 +필자 +필통 +핑계 +하느님 +하늘 +하드웨어 +하룻밤 +하반기 +하숙집 +하순 +하여튼 +하지만 +하천 +하품 +하필 +학과 +학교 +학급 +학기 +학년 +학력 +학번 +학부모 +학비 +학생 +학술 +학습 +학용품 +학원 +학위 +학자 +학점 +한계 +한글 +한꺼번에 +한낮 +한눈 +한동안 +한때 +한라산 +한마디 +한문 +한번 +한복 +한식 +한여름 +한쪽 +할머니 +할아버지 +할인 +함께 +함부로 +합격 +합리적 +항공 +항구 +항상 +항의 +해결 +해군 +해답 +해당 +해물 +해석 +해설 +해수욕장 +해안 +핵심 +핸드백 +햄버거 +햇볕 +햇살 +행동 +행복 +행사 +행운 +행위 +향기 +향상 +향수 +허락 +허용 +헬기 +현관 +현금 +현대 +현상 +현실 +현장 +현재 +현지 +혈액 +협력 +형부 +형사 +형수 +형식 +형제 +형태 +형편 +혜택 +호기심 +호남 +호랑이 +호박 +호텔 +호흡 +혹시 +홀로 +홈페이지 +홍보 +홍수 +홍차 +화면 +화분 +화살 +화요일 +화장 +화학 +확보 +확인 +확장 +확정 +환갑 +환경 +환영 +환율 +환자 +활기 +활동 +활발히 +활용 +활짝 +회견 +회관 +회복 +회색 +회원 +회장 +회전 +횟수 +횡단보도 +효율적 +후반 +후춧가루 +훈련 +훨씬 +휴식 +휴일 +흉내 +흐름 +흑백 +흑인 +흔적 +흔히 +흥미 +흥분 +희곡 +희망 +희생 +흰색 +힘껏 diff --git a/packages/testcases/input/wordlists/lang-zh_cn.txt b/packages/testcases/input/wordlists/lang-zh_cn.txt new file mode 100644 index 000000000..b90f1ed85 --- /dev/null +++ b/packages/testcases/input/wordlists/lang-zh_cn.txt @@ -0,0 +1,2048 @@ +的 +一 +是 +在 +不 +了 +有 +和 +人 +这 +中 +大 +为 +上 +个 +国 +我 +以 +要 +他 +时 +来 +用 +们 +生 +到 +作 +地 +于 +出 +就 +分 +对 +成 +会 +可 +主 +发 +年 +动 +同 +工 +也 +能 +下 +过 +子 +说 +产 +种 +面 +而 +方 +后 +多 +定 +行 +学 +法 +所 +民 +得 +经 +十 +三 +之 +进 +着 +等 +部 +度 +家 +电 +力 +里 +如 +水 +化 +高 +自 +二 +理 +起 +小 +物 +现 +实 +加 +量 +都 +两 +体 +制 +机 +当 +使 +点 +从 +业 +本 +去 +把 +性 +好 +应 +开 +它 +合 +还 +因 +由 +其 +些 +然 +前 +外 +天 +政 +四 +日 +那 +社 +义 +事 +平 +形 +相 +全 +表 +间 +样 +与 +关 +各 +重 +新 +线 +内 +数 +正 +心 +反 +你 +明 +看 +原 +又 +么 +利 +比 +或 +但 +质 +气 +第 +向 +道 +命 +此 +变 +条 +只 +没 +结 +解 +问 +意 +建 +月 +公 +无 +系 +军 +很 +情 +者 +最 +立 +代 +想 +已 +通 +并 +提 +直 +题 +党 +程 +展 +五 +果 +料 +象 +员 +革 +位 +入 +常 +文 +总 +次 +品 +式 +活 +设 +及 +管 +特 +件 +长 +求 +老 +头 +基 +资 +边 +流 +路 +级 +少 +图 +山 +统 +接 +知 +较 +将 +组 +见 +计 +别 +她 +手 +角 +期 +根 +论 +运 +农 +指 +几 +九 +区 +强 +放 +决 +西 +被 +干 +做 +必 +战 +先 +回 +则 +任 +取 +据 +处 +队 +南 +给 +色 +光 +门 +即 +保 +治 +北 +造 +百 +规 +热 +领 +七 +海 +口 +东 +导 +器 +压 +志 +世 +金 +增 +争 +济 +阶 +油 +思 +术 +极 +交 +受 +联 +什 +认 +六 +共 +权 +收 +证 +改 +清 +美 +再 +采 +转 +更 +单 +风 +切 +打 +白 +教 +速 +花 +带 +安 +场 +身 +车 +例 +真 +务 +具 +万 +每 +目 +至 +达 +走 +积 +示 +议 +声 +报 +斗 +完 +类 +八 +离 +华 +名 +确 +才 +科 +张 +信 +马 +节 +话 +米 +整 +空 +元 +况 +今 +集 +温 +传 +土 +许 +步 +群 +广 +石 +记 +需 +段 +研 +界 +拉 +林 +律 +叫 +且 +究 +观 +越 +织 +装 +影 +算 +低 +持 +音 +众 +书 +布 +复 +容 +儿 +须 +际 +商 +非 +验 +连 +断 +深 +难 +近 +矿 +千 +周 +委 +素 +技 +备 +半 +办 +青 +省 +列 +习 +响 +约 +支 +般 +史 +感 +劳 +便 +团 +往 +酸 +历 +市 +克 +何 +除 +消 +构 +府 +称 +太 +准 +精 +值 +号 +率 +族 +维 +划 +选 +标 +写 +存 +候 +毛 +亲 +快 +效 +斯 +院 +查 +江 +型 +眼 +王 +按 +格 +养 +易 +置 +派 +层 +片 +始 +却 +专 +状 +育 +厂 +京 +识 +适 +属 +圆 +包 +火 +住 +调 +满 +县 +局 +照 +参 +红 +细 +引 +听 +该 +铁 +价 +严 +首 +底 +液 +官 +德 +随 +病 +苏 +失 +尔 +死 +讲 +配 +女 +黄 +推 +显 +谈 +罪 +神 +艺 +呢 +席 +含 +企 +望 +密 +批 +营 +项 +防 +举 +球 +英 +氧 +势 +告 +李 +台 +落 +木 +帮 +轮 +破 +亚 +师 +围 +注 +远 +字 +材 +排 +供 +河 +态 +封 +另 +施 +减 +树 +溶 +怎 +止 +案 +言 +士 +均 +武 +固 +叶 +鱼 +波 +视 +仅 +费 +紧 +爱 +左 +章 +早 +朝 +害 +续 +轻 +服 +试 +食 +充 +兵 +源 +判 +护 +司 +足 +某 +练 +差 +致 +板 +田 +降 +黑 +犯 +负 +击 +范 +继 +兴 +似 +余 +坚 +曲 +输 +修 +故 +城 +夫 +够 +送 +笔 +船 +占 +右 +财 +吃 +富 +春 +职 +觉 +汉 +画 +功 +巴 +跟 +虽 +杂 +飞 +检 +吸 +助 +升 +阳 +互 +初 +创 +抗 +考 +投 +坏 +策 +古 +径 +换 +未 +跑 +留 +钢 +曾 +端 +责 +站 +简 +述 +钱 +副 +尽 +帝 +射 +草 +冲 +承 +独 +令 +限 +阿 +宣 +环 +双 +请 +超 +微 +让 +控 +州 +良 +轴 +找 +否 +纪 +益 +依 +优 +顶 +础 +载 +倒 +房 +突 +坐 +粉 +敌 +略 +客 +袁 +冷 +胜 +绝 +析 +块 +剂 +测 +丝 +协 +诉 +念 +陈 +仍 +罗 +盐 +友 +洋 +错 +苦 +夜 +刑 +移 +频 +逐 +靠 +混 +母 +短 +皮 +终 +聚 +汽 +村 +云 +哪 +既 +距 +卫 +停 +烈 +央 +察 +烧 +迅 +境 +若 +印 +洲 +刻 +括 +激 +孔 +搞 +甚 +室 +待 +核 +校 +散 +侵 +吧 +甲 +游 +久 +菜 +味 +旧 +模 +湖 +货 +损 +预 +阻 +毫 +普 +稳 +乙 +妈 +植 +息 +扩 +银 +语 +挥 +酒 +守 +拿 +序 +纸 +医 +缺 +雨 +吗 +针 +刘 +啊 +急 +唱 +误 +训 +愿 +审 +附 +获 +茶 +鲜 +粮 +斤 +孩 +脱 +硫 +肥 +善 +龙 +演 +父 +渐 +血 +欢 +械 +掌 +歌 +沙 +刚 +攻 +谓 +盾 +讨 +晚 +粒 +乱 +燃 +矛 +乎 +杀 +药 +宁 +鲁 +贵 +钟 +煤 +读 +班 +伯 +香 +介 +迫 +句 +丰 +培 +握 +兰 +担 +弦 +蛋 +沉 +假 +穿 +执 +答 +乐 +谁 +顺 +烟 +缩 +征 +脸 +喜 +松 +脚 +困 +异 +免 +背 +星 +福 +买 +染 +井 +概 +慢 +怕 +磁 +倍 +祖 +皇 +促 +静 +补 +评 +翻 +肉 +践 +尼 +衣 +宽 +扬 +棉 +希 +伤 +操 +垂 +秋 +宜 +氢 +套 +督 +振 +架 +亮 +末 +宪 +庆 +编 +牛 +触 +映 +雷 +销 +诗 +座 +居 +抓 +裂 +胞 +呼 +娘 +景 +威 +绿 +晶 +厚 +盟 +衡 +鸡 +孙 +延 +危 +胶 +屋 +乡 +临 +陆 +顾 +掉 +呀 +灯 +岁 +措 +束 +耐 +剧 +玉 +赵 +跳 +哥 +季 +课 +凯 +胡 +额 +款 +绍 +卷 +齐 +伟 +蒸 +殖 +永 +宗 +苗 +川 +炉 +岩 +弱 +零 +杨 +奏 +沿 +露 +杆 +探 +滑 +镇 +饭 +浓 +航 +怀 +赶 +库 +夺 +伊 +灵 +税 +途 +灭 +赛 +归 +召 +鼓 +播 +盘 +裁 +险 +康 +唯 +录 +菌 +纯 +借 +糖 +盖 +横 +符 +私 +努 +堂 +域 +枪 +润 +幅 +哈 +竟 +熟 +虫 +泽 +脑 +壤 +碳 +欧 +遍 +侧 +寨 +敢 +彻 +虑 +斜 +薄 +庭 +纳 +弹 +饲 +伸 +折 +麦 +湿 +暗 +荷 +瓦 +塞 +床 +筑 +恶 +户 +访 +塔 +奇 +透 +梁 +刀 +旋 +迹 +卡 +氯 +遇 +份 +毒 +泥 +退 +洗 +摆 +灰 +彩 +卖 +耗 +夏 +择 +忙 +铜 +献 +硬 +予 +繁 +圈 +雪 +函 +亦 +抽 +篇 +阵 +阴 +丁 +尺 +追 +堆 +雄 +迎 +泛 +爸 +楼 +避 +谋 +吨 +野 +猪 +旗 +累 +偏 +典 +馆 +索 +秦 +脂 +潮 +爷 +豆 +忽 +托 +惊 +塑 +遗 +愈 +朱 +替 +纤 +粗 +倾 +尚 +痛 +楚 +谢 +奋 +购 +磨 +君 +池 +旁 +碎 +骨 +监 +捕 +弟 +暴 +割 +贯 +殊 +释 +词 +亡 +壁 +顿 +宝 +午 +尘 +闻 +揭 +炮 +残 +冬 +桥 +妇 +警 +综 +招 +吴 +付 +浮 +遭 +徐 +您 +摇 +谷 +赞 +箱 +隔 +订 +男 +吹 +园 +纷 +唐 +败 +宋 +玻 +巨 +耕 +坦 +荣 +闭 +湾 +键 +凡 +驻 +锅 +救 +恩 +剥 +凝 +碱 +齿 +截 +炼 +麻 +纺 +禁 +废 +盛 +版 +缓 +净 +睛 +昌 +婚 +涉 +筒 +嘴 +插 +岸 +朗 +庄 +街 +藏 +姑 +贸 +腐 +奴 +啦 +惯 +乘 +伙 +恢 +匀 +纱 +扎 +辩 +耳 +彪 +臣 +亿 +璃 +抵 +脉 +秀 +萨 +俄 +网 +舞 +店 +喷 +纵 +寸 +汗 +挂 +洪 +贺 +闪 +柬 +爆 +烯 +津 +稻 +墙 +软 +勇 +像 +滚 +厘 +蒙 +芳 +肯 +坡 +柱 +荡 +腿 +仪 +旅 +尾 +轧 +冰 +贡 +登 +黎 +削 +钻 +勒 +逃 +障 +氨 +郭 +峰 +币 +港 +伏 +轨 +亩 +毕 +擦 +莫 +刺 +浪 +秘 +援 +株 +健 +售 +股 +岛 +甘 +泡 +睡 +童 +铸 +汤 +阀 +休 +汇 +舍 +牧 +绕 +炸 +哲 +磷 +绩 +朋 +淡 +尖 +启 +陷 +柴 +呈 +徒 +颜 +泪 +稍 +忘 +泵 +蓝 +拖 +洞 +授 +镜 +辛 +壮 +锋 +贫 +虚 +弯 +摩 +泰 +幼 +廷 +尊 +窗 +纲 +弄 +隶 +疑 +氏 +宫 +姐 +震 +瑞 +怪 +尤 +琴 +循 +描 +膜 +违 +夹 +腰 +缘 +珠 +穷 +森 +枝 +竹 +沟 +催 +绳 +忆 +邦 +剩 +幸 +浆 +栏 +拥 +牙 +贮 +礼 +滤 +钠 +纹 +罢 +拍 +咱 +喊 +袖 +埃 +勤 +罚 +焦 +潜 +伍 +墨 +欲 +缝 +姓 +刊 +饱 +仿 +奖 +铝 +鬼 +丽 +跨 +默 +挖 +链 +扫 +喝 +袋 +炭 +污 +幕 +诸 +弧 +励 +梅 +奶 +洁 +灾 +舟 +鉴 +苯 +讼 +抱 +毁 +懂 +寒 +智 +埔 +寄 +届 +跃 +渡 +挑 +丹 +艰 +贝 +碰 +拔 +爹 +戴 +码 +梦 +芽 +熔 +赤 +渔 +哭 +敬 +颗 +奔 +铅 +仲 +虎 +稀 +妹 +乏 +珍 +申 +桌 +遵 +允 +隆 +螺 +仓 +魏 +锐 +晓 +氮 +兼 +隐 +碍 +赫 +拨 +忠 +肃 +缸 +牵 +抢 +博 +巧 +壳 +兄 +杜 +讯 +诚 +碧 +祥 +柯 +页 +巡 +矩 +悲 +灌 +龄 +伦 +票 +寻 +桂 +铺 +圣 +恐 +恰 +郑 +趣 +抬 +荒 +腾 +贴 +柔 +滴 +猛 +阔 +辆 +妻 +填 +撤 +储 +签 +闹 +扰 +紫 +砂 +递 +戏 +吊 +陶 +伐 +喂 +疗 +瓶 +婆 +抚 +臂 +摸 +忍 +虾 +蜡 +邻 +胸 +巩 +挤 +偶 +弃 +槽 +劲 +乳 +邓 +吉 +仁 +烂 +砖 +租 +乌 +舰 +伴 +瓜 +浅 +丙 +暂 +燥 +橡 +柳 +迷 +暖 +牌 +秧 +胆 +详 +簧 +踏 +瓷 +谱 +呆 +宾 +糊 +洛 +辉 +愤 +竞 +隙 +怒 +粘 +乃 +绪 +肩 +籍 +敏 +涂 +熙 +皆 +侦 +悬 +掘 +享 +纠 +醒 +狂 +锁 +淀 +恨 +牲 +霸 +爬 +赏 +逆 +玩 +陵 +祝 +秒 +浙 +貌 +役 +彼 +悉 +鸭 +趋 +凤 +晨 +畜 +辈 +秩 +卵 +署 +梯 +炎 +滩 +棋 +驱 +筛 +峡 +冒 +啥 +寿 +译 +浸 +泉 +帽 +迟 +硅 +疆 +贷 +漏 +稿 +冠 +嫩 +胁 +芯 +牢 +叛 +蚀 +奥 +鸣 +岭 +羊 +凭 +串 +塘 +绘 +酵 +融 +盆 +锡 +庙 +筹 +冻 +辅 +摄 +袭 +筋 +拒 +僚 +旱 +钾 +鸟 +漆 +沈 +眉 +疏 +添 +棒 +穗 +硝 +韩 +逼 +扭 +侨 +凉 +挺 +碗 +栽 +炒 +杯 +患 +馏 +劝 +豪 +辽 +勃 +鸿 +旦 +吏 +拜 +狗 +埋 +辊 +掩 +饮 +搬 +骂 +辞 +勾 +扣 +估 +蒋 +绒 +雾 +丈 +朵 +姆 +拟 +宇 +辑 +陕 +雕 +偿 +蓄 +崇 +剪 +倡 +厅 +咬 +驶 +薯 +刷 +斥 +番 +赋 +奉 +佛 +浇 +漫 +曼 +扇 +钙 +桃 +扶 +仔 +返 +俗 +亏 +腔 +鞋 +棱 +覆 +框 +悄 +叔 +撞 +骗 +勘 +旺 +沸 +孤 +吐 +孟 +渠 +屈 +疾 +妙 +惜 +仰 +狠 +胀 +谐 +抛 +霉 +桑 +岗 +嘛 +衰 +盗 +渗 +脏 +赖 +涌 +甜 +曹 +阅 +肌 +哩 +厉 +烃 +纬 +毅 +昨 +伪 +症 +煮 +叹 +钉 +搭 +茎 +笼 +酷 +偷 +弓 +锥 +恒 +杰 +坑 +鼻 +翼 +纶 +叙 +狱 +逮 +罐 +络 +棚 +抑 +膨 +蔬 +寺 +骤 +穆 +冶 +枯 +册 +尸 +凸 +绅 +坯 +牺 +焰 +轰 +欣 +晋 +瘦 +御 +锭 +锦 +丧 +旬 +锻 +垄 +搜 +扑 +邀 +亭 +酯 +迈 +舒 +脆 +酶 +闲 +忧 +酚 +顽 +羽 +涨 +卸 +仗 +陪 +辟 +惩 +杭 +姚 +肚 +捉 +飘 +漂 +昆 +欺 +吾 +郎 +烷 +汁 +呵 +饰 +萧 +雅 +邮 +迁 +燕 +撒 +姻 +赴 +宴 +烦 +债 +帐 +斑 +铃 +旨 +醇 +董 +饼 +雏 +姿 +拌 +傅 +腹 +妥 +揉 +贤 +拆 +歪 +葡 +胺 +丢 +浩 +徽 +昂 +垫 +挡 +览 +贪 +慰 +缴 +汪 +慌 +冯 +诺 +姜 +谊 +凶 +劣 +诬 +耀 +昏 +躺 +盈 +骑 +乔 +溪 +丛 +卢 +抹 +闷 +咨 +刮 +驾 +缆 +悟 +摘 +铒 +掷 +颇 +幻 +柄 +惠 +惨 +佳 +仇 +腊 +窝 +涤 +剑 +瞧 +堡 +泼 +葱 +罩 +霍 +捞 +胎 +苍 +滨 +俩 +捅 +湘 +砍 +霞 +邵 +萄 +疯 +淮 +遂 +熊 +粪 +烘 +宿 +档 +戈 +驳 +嫂 +裕 +徙 +箭 +捐 +肠 +撑 +晒 +辨 +殿 +莲 +摊 +搅 +酱 +屏 +疫 +哀 +蔡 +堵 +沫 +皱 +畅 +叠 +阁 +莱 +敲 +辖 +钩 +痕 +坝 +巷 +饿 +祸 +丘 +玄 +溜 +曰 +逻 +彭 +尝 +卿 +妨 +艇 +吞 +韦 +怨 +矮 +歇 diff --git a/packages/testcases/input/wordlists/lang-zh_tw.txt b/packages/testcases/input/wordlists/lang-zh_tw.txt new file mode 100644 index 000000000..9b0204792 --- /dev/null +++ b/packages/testcases/input/wordlists/lang-zh_tw.txt @@ -0,0 +1,2048 @@ +的 +一 +是 +在 +不 +了 +有 +和 +人 +這 +中 +大 +為 +上 +個 +國 +我 +以 +要 +他 +時 +來 +用 +們 +生 +到 +作 +地 +於 +出 +就 +分 +對 +成 +會 +可 +主 +發 +年 +動 +同 +工 +也 +能 +下 +過 +子 +說 +產 +種 +面 +而 +方 +後 +多 +定 +行 +學 +法 +所 +民 +得 +經 +十 +三 +之 +進 +著 +等 +部 +度 +家 +電 +力 +裡 +如 +水 +化 +高 +自 +二 +理 +起 +小 +物 +現 +實 +加 +量 +都 +兩 +體 +制 +機 +當 +使 +點 +從 +業 +本 +去 +把 +性 +好 +應 +開 +它 +合 +還 +因 +由 +其 +些 +然 +前 +外 +天 +政 +四 +日 +那 +社 +義 +事 +平 +形 +相 +全 +表 +間 +樣 +與 +關 +各 +重 +新 +線 +內 +數 +正 +心 +反 +你 +明 +看 +原 +又 +麼 +利 +比 +或 +但 +質 +氣 +第 +向 +道 +命 +此 +變 +條 +只 +沒 +結 +解 +問 +意 +建 +月 +公 +無 +系 +軍 +很 +情 +者 +最 +立 +代 +想 +已 +通 +並 +提 +直 +題 +黨 +程 +展 +五 +果 +料 +象 +員 +革 +位 +入 +常 +文 +總 +次 +品 +式 +活 +設 +及 +管 +特 +件 +長 +求 +老 +頭 +基 +資 +邊 +流 +路 +級 +少 +圖 +山 +統 +接 +知 +較 +將 +組 +見 +計 +別 +她 +手 +角 +期 +根 +論 +運 +農 +指 +幾 +九 +區 +強 +放 +決 +西 +被 +幹 +做 +必 +戰 +先 +回 +則 +任 +取 +據 +處 +隊 +南 +給 +色 +光 +門 +即 +保 +治 +北 +造 +百 +規 +熱 +領 +七 +海 +口 +東 +導 +器 +壓 +志 +世 +金 +增 +爭 +濟 +階 +油 +思 +術 +極 +交 +受 +聯 +什 +認 +六 +共 +權 +收 +證 +改 +清 +美 +再 +採 +轉 +更 +單 +風 +切 +打 +白 +教 +速 +花 +帶 +安 +場 +身 +車 +例 +真 +務 +具 +萬 +每 +目 +至 +達 +走 +積 +示 +議 +聲 +報 +鬥 +完 +類 +八 +離 +華 +名 +確 +才 +科 +張 +信 +馬 +節 +話 +米 +整 +空 +元 +況 +今 +集 +溫 +傳 +土 +許 +步 +群 +廣 +石 +記 +需 +段 +研 +界 +拉 +林 +律 +叫 +且 +究 +觀 +越 +織 +裝 +影 +算 +低 +持 +音 +眾 +書 +布 +复 +容 +兒 +須 +際 +商 +非 +驗 +連 +斷 +深 +難 +近 +礦 +千 +週 +委 +素 +技 +備 +半 +辦 +青 +省 +列 +習 +響 +約 +支 +般 +史 +感 +勞 +便 +團 +往 +酸 +歷 +市 +克 +何 +除 +消 +構 +府 +稱 +太 +準 +精 +值 +號 +率 +族 +維 +劃 +選 +標 +寫 +存 +候 +毛 +親 +快 +效 +斯 +院 +查 +江 +型 +眼 +王 +按 +格 +養 +易 +置 +派 +層 +片 +始 +卻 +專 +狀 +育 +廠 +京 +識 +適 +屬 +圓 +包 +火 +住 +調 +滿 +縣 +局 +照 +參 +紅 +細 +引 +聽 +該 +鐵 +價 +嚴 +首 +底 +液 +官 +德 +隨 +病 +蘇 +失 +爾 +死 +講 +配 +女 +黃 +推 +顯 +談 +罪 +神 +藝 +呢 +席 +含 +企 +望 +密 +批 +營 +項 +防 +舉 +球 +英 +氧 +勢 +告 +李 +台 +落 +木 +幫 +輪 +破 +亞 +師 +圍 +注 +遠 +字 +材 +排 +供 +河 +態 +封 +另 +施 +減 +樹 +溶 +怎 +止 +案 +言 +士 +均 +武 +固 +葉 +魚 +波 +視 +僅 +費 +緊 +愛 +左 +章 +早 +朝 +害 +續 +輕 +服 +試 +食 +充 +兵 +源 +判 +護 +司 +足 +某 +練 +差 +致 +板 +田 +降 +黑 +犯 +負 +擊 +范 +繼 +興 +似 +餘 +堅 +曲 +輸 +修 +故 +城 +夫 +夠 +送 +筆 +船 +佔 +右 +財 +吃 +富 +春 +職 +覺 +漢 +畫 +功 +巴 +跟 +雖 +雜 +飛 +檢 +吸 +助 +昇 +陽 +互 +初 +創 +抗 +考 +投 +壞 +策 +古 +徑 +換 +未 +跑 +留 +鋼 +曾 +端 +責 +站 +簡 +述 +錢 +副 +盡 +帝 +射 +草 +衝 +承 +獨 +令 +限 +阿 +宣 +環 +雙 +請 +超 +微 +讓 +控 +州 +良 +軸 +找 +否 +紀 +益 +依 +優 +頂 +礎 +載 +倒 +房 +突 +坐 +粉 +敵 +略 +客 +袁 +冷 +勝 +絕 +析 +塊 +劑 +測 +絲 +協 +訴 +念 +陳 +仍 +羅 +鹽 +友 +洋 +錯 +苦 +夜 +刑 +移 +頻 +逐 +靠 +混 +母 +短 +皮 +終 +聚 +汽 +村 +雲 +哪 +既 +距 +衛 +停 +烈 +央 +察 +燒 +迅 +境 +若 +印 +洲 +刻 +括 +激 +孔 +搞 +甚 +室 +待 +核 +校 +散 +侵 +吧 +甲 +遊 +久 +菜 +味 +舊 +模 +湖 +貨 +損 +預 +阻 +毫 +普 +穩 +乙 +媽 +植 +息 +擴 +銀 +語 +揮 +酒 +守 +拿 +序 +紙 +醫 +缺 +雨 +嗎 +針 +劉 +啊 +急 +唱 +誤 +訓 +願 +審 +附 +獲 +茶 +鮮 +糧 +斤 +孩 +脫 +硫 +肥 +善 +龍 +演 +父 +漸 +血 +歡 +械 +掌 +歌 +沙 +剛 +攻 +謂 +盾 +討 +晚 +粒 +亂 +燃 +矛 +乎 +殺 +藥 +寧 +魯 +貴 +鐘 +煤 +讀 +班 +伯 +香 +介 +迫 +句 +豐 +培 +握 +蘭 +擔 +弦 +蛋 +沉 +假 +穿 +執 +答 +樂 +誰 +順 +煙 +縮 +徵 +臉 +喜 +松 +腳 +困 +異 +免 +背 +星 +福 +買 +染 +井 +概 +慢 +怕 +磁 +倍 +祖 +皇 +促 +靜 +補 +評 +翻 +肉 +踐 +尼 +衣 +寬 +揚 +棉 +希 +傷 +操 +垂 +秋 +宜 +氫 +套 +督 +振 +架 +亮 +末 +憲 +慶 +編 +牛 +觸 +映 +雷 +銷 +詩 +座 +居 +抓 +裂 +胞 +呼 +娘 +景 +威 +綠 +晶 +厚 +盟 +衡 +雞 +孫 +延 +危 +膠 +屋 +鄉 +臨 +陸 +顧 +掉 +呀 +燈 +歲 +措 +束 +耐 +劇 +玉 +趙 +跳 +哥 +季 +課 +凱 +胡 +額 +款 +紹 +卷 +齊 +偉 +蒸 +殖 +永 +宗 +苗 +川 +爐 +岩 +弱 +零 +楊 +奏 +沿 +露 +桿 +探 +滑 +鎮 +飯 +濃 +航 +懷 +趕 +庫 +奪 +伊 +靈 +稅 +途 +滅 +賽 +歸 +召 +鼓 +播 +盤 +裁 +險 +康 +唯 +錄 +菌 +純 +借 +糖 +蓋 +橫 +符 +私 +努 +堂 +域 +槍 +潤 +幅 +哈 +竟 +熟 +蟲 +澤 +腦 +壤 +碳 +歐 +遍 +側 +寨 +敢 +徹 +慮 +斜 +薄 +庭 +納 +彈 +飼 +伸 +折 +麥 +濕 +暗 +荷 +瓦 +塞 +床 +築 +惡 +戶 +訪 +塔 +奇 +透 +梁 +刀 +旋 +跡 +卡 +氯 +遇 +份 +毒 +泥 +退 +洗 +擺 +灰 +彩 +賣 +耗 +夏 +擇 +忙 +銅 +獻 +硬 +予 +繁 +圈 +雪 +函 +亦 +抽 +篇 +陣 +陰 +丁 +尺 +追 +堆 +雄 +迎 +泛 +爸 +樓 +避 +謀 +噸 +野 +豬 +旗 +累 +偏 +典 +館 +索 +秦 +脂 +潮 +爺 +豆 +忽 +托 +驚 +塑 +遺 +愈 +朱 +替 +纖 +粗 +傾 +尚 +痛 +楚 +謝 +奮 +購 +磨 +君 +池 +旁 +碎 +骨 +監 +捕 +弟 +暴 +割 +貫 +殊 +釋 +詞 +亡 +壁 +頓 +寶 +午 +塵 +聞 +揭 +炮 +殘 +冬 +橋 +婦 +警 +綜 +招 +吳 +付 +浮 +遭 +徐 +您 +搖 +谷 +贊 +箱 +隔 +訂 +男 +吹 +園 +紛 +唐 +敗 +宋 +玻 +巨 +耕 +坦 +榮 +閉 +灣 +鍵 +凡 +駐 +鍋 +救 +恩 +剝 +凝 +鹼 +齒 +截 +煉 +麻 +紡 +禁 +廢 +盛 +版 +緩 +淨 +睛 +昌 +婚 +涉 +筒 +嘴 +插 +岸 +朗 +莊 +街 +藏 +姑 +貿 +腐 +奴 +啦 +慣 +乘 +夥 +恢 +勻 +紗 +扎 +辯 +耳 +彪 +臣 +億 +璃 +抵 +脈 +秀 +薩 +俄 +網 +舞 +店 +噴 +縱 +寸 +汗 +掛 +洪 +賀 +閃 +柬 +爆 +烯 +津 +稻 +牆 +軟 +勇 +像 +滾 +厘 +蒙 +芳 +肯 +坡 +柱 +盪 +腿 +儀 +旅 +尾 +軋 +冰 +貢 +登 +黎 +削 +鑽 +勒 +逃 +障 +氨 +郭 +峰 +幣 +港 +伏 +軌 +畝 +畢 +擦 +莫 +刺 +浪 +秘 +援 +株 +健 +售 +股 +島 +甘 +泡 +睡 +童 +鑄 +湯 +閥 +休 +匯 +舍 +牧 +繞 +炸 +哲 +磷 +績 +朋 +淡 +尖 +啟 +陷 +柴 +呈 +徒 +顏 +淚 +稍 +忘 +泵 +藍 +拖 +洞 +授 +鏡 +辛 +壯 +鋒 +貧 +虛 +彎 +摩 +泰 +幼 +廷 +尊 +窗 +綱 +弄 +隸 +疑 +氏 +宮 +姐 +震 +瑞 +怪 +尤 +琴 +循 +描 +膜 +違 +夾 +腰 +緣 +珠 +窮 +森 +枝 +竹 +溝 +催 +繩 +憶 +邦 +剩 +幸 +漿 +欄 +擁 +牙 +貯 +禮 +濾 +鈉 +紋 +罷 +拍 +咱 +喊 +袖 +埃 +勤 +罰 +焦 +潛 +伍 +墨 +欲 +縫 +姓 +刊 +飽 +仿 +獎 +鋁 +鬼 +麗 +跨 +默 +挖 +鏈 +掃 +喝 +袋 +炭 +污 +幕 +諸 +弧 +勵 +梅 +奶 +潔 +災 +舟 +鑑 +苯 +訟 +抱 +毀 +懂 +寒 +智 +埔 +寄 +屆 +躍 +渡 +挑 +丹 +艱 +貝 +碰 +拔 +爹 +戴 +碼 +夢 +芽 +熔 +赤 +漁 +哭 +敬 +顆 +奔 +鉛 +仲 +虎 +稀 +妹 +乏 +珍 +申 +桌 +遵 +允 +隆 +螺 +倉 +魏 +銳 +曉 +氮 +兼 +隱 +礙 +赫 +撥 +忠 +肅 +缸 +牽 +搶 +博 +巧 +殼 +兄 +杜 +訊 +誠 +碧 +祥 +柯 +頁 +巡 +矩 +悲 +灌 +齡 +倫 +票 +尋 +桂 +鋪 +聖 +恐 +恰 +鄭 +趣 +抬 +荒 +騰 +貼 +柔 +滴 +猛 +闊 +輛 +妻 +填 +撤 +儲 +簽 +鬧 +擾 +紫 +砂 +遞 +戲 +吊 +陶 +伐 +餵 +療 +瓶 +婆 +撫 +臂 +摸 +忍 +蝦 +蠟 +鄰 +胸 +鞏 +擠 +偶 +棄 +槽 +勁 +乳 +鄧 +吉 +仁 +爛 +磚 +租 +烏 +艦 +伴 +瓜 +淺 +丙 +暫 +燥 +橡 +柳 +迷 +暖 +牌 +秧 +膽 +詳 +簧 +踏 +瓷 +譜 +呆 +賓 +糊 +洛 +輝 +憤 +競 +隙 +怒 +粘 +乃 +緒 +肩 +籍 +敏 +塗 +熙 +皆 +偵 +懸 +掘 +享 +糾 +醒 +狂 +鎖 +淀 +恨 +牲 +霸 +爬 +賞 +逆 +玩 +陵 +祝 +秒 +浙 +貌 +役 +彼 +悉 +鴨 +趨 +鳳 +晨 +畜 +輩 +秩 +卵 +署 +梯 +炎 +灘 +棋 +驅 +篩 +峽 +冒 +啥 +壽 +譯 +浸 +泉 +帽 +遲 +矽 +疆 +貸 +漏 +稿 +冠 +嫩 +脅 +芯 +牢 +叛 +蝕 +奧 +鳴 +嶺 +羊 +憑 +串 +塘 +繪 +酵 +融 +盆 +錫 +廟 +籌 +凍 +輔 +攝 +襲 +筋 +拒 +僚 +旱 +鉀 +鳥 +漆 +沈 +眉 +疏 +添 +棒 +穗 +硝 +韓 +逼 +扭 +僑 +涼 +挺 +碗 +栽 +炒 +杯 +患 +餾 +勸 +豪 +遼 +勃 +鴻 +旦 +吏 +拜 +狗 +埋 +輥 +掩 +飲 +搬 +罵 +辭 +勾 +扣 +估 +蔣 +絨 +霧 +丈 +朵 +姆 +擬 +宇 +輯 +陝 +雕 +償 +蓄 +崇 +剪 +倡 +廳 +咬 +駛 +薯 +刷 +斥 +番 +賦 +奉 +佛 +澆 +漫 +曼 +扇 +鈣 +桃 +扶 +仔 +返 +俗 +虧 +腔 +鞋 +棱 +覆 +框 +悄 +叔 +撞 +騙 +勘 +旺 +沸 +孤 +吐 +孟 +渠 +屈 +疾 +妙 +惜 +仰 +狠 +脹 +諧 +拋 +黴 +桑 +崗 +嘛 +衰 +盜 +滲 +臟 +賴 +湧 +甜 +曹 +閱 +肌 +哩 +厲 +烴 +緯 +毅 +昨 +偽 +症 +煮 +嘆 +釘 +搭 +莖 +籠 +酷 +偷 +弓 +錐 +恆 +傑 +坑 +鼻 +翼 +綸 +敘 +獄 +逮 +罐 +絡 +棚 +抑 +膨 +蔬 +寺 +驟 +穆 +冶 +枯 +冊 +屍 +凸 +紳 +坯 +犧 +焰 +轟 +欣 +晉 +瘦 +禦 +錠 +錦 +喪 +旬 +鍛 +壟 +搜 +撲 +邀 +亭 +酯 +邁 +舒 +脆 +酶 +閒 +憂 +酚 +頑 +羽 +漲 +卸 +仗 +陪 +闢 +懲 +杭 +姚 +肚 +捉 +飄 +漂 +昆 +欺 +吾 +郎 +烷 +汁 +呵 +飾 +蕭 +雅 +郵 +遷 +燕 +撒 +姻 +赴 +宴 +煩 +債 +帳 +斑 +鈴 +旨 +醇 +董 +餅 +雛 +姿 +拌 +傅 +腹 +妥 +揉 +賢 +拆 +歪 +葡 +胺 +丟 +浩 +徽 +昂 +墊 +擋 +覽 +貪 +慰 +繳 +汪 +慌 +馮 +諾 +姜 +誼 +兇 +劣 +誣 +耀 +昏 +躺 +盈 +騎 +喬 +溪 +叢 +盧 +抹 +悶 +諮 +刮 +駕 +纜 +悟 +摘 +鉺 +擲 +頗 +幻 +柄 +惠 +慘 +佳 +仇 +臘 +窩 +滌 +劍 +瞧 +堡 +潑 +蔥 +罩 +霍 +撈 +胎 +蒼 +濱 +倆 +捅 +湘 +砍 +霞 +邵 +萄 +瘋 +淮 +遂 +熊 +糞 +烘 +宿 +檔 +戈 +駁 +嫂 +裕 +徙 +箭 +捐 +腸 +撐 +曬 +辨 +殿 +蓮 +攤 +攪 +醬 +屏 +疫 +哀 +蔡 +堵 +沫 +皺 +暢 +疊 +閣 +萊 +敲 +轄 +鉤 +痕 +壩 +巷 +餓 +禍 +丘 +玄 +溜 +曰 +邏 +彭 +嘗 +卿 +妨 +艇 +吞 +韋 +怨 +矮 +歇 diff --git a/packages/testcases/package.json b/packages/testcases/package.json new file mode 100644 index 000000000..bc6cf09d2 --- /dev/null +++ b/packages/testcases/package.json @@ -0,0 +1,36 @@ +{ + "name": "@ethersproject/testcases", + "version": "5.0.0-beta.125", + "description": "Testcases for Ethereum and scripts to generate testcases.", + "main": "index.js", + "browser": "browser.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "browserify-zlib": "^0.2.0" + }, + "devDependencies": { + "@types/bip39": "2.4.1", + "@types/bitcoinjs-lib": "3.3.2", + "bip39": "2.5.0", + "bitcoinjs-lib": "3.3.2", + "ethereumjs-tx": "^1.3.5", + "ethereumjs-util": "^5.2.0", + "solc": "0.5.5" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x59026aebabad3dc7c5ca94f2509e69016ccf734ecc4ea29c48da68aff7301c63" +} diff --git a/packages/testcases/scripts/browser-fs.js b/packages/testcases/scripts/browser-fs.js new file mode 100644 index 000000000..367ee0153 --- /dev/null +++ b/packages/testcases/scripts/browser-fs.js @@ -0,0 +1,29 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const through = require('through'); + +module.exports = function(pathname, options) { + + let data = ''; + return through(function(chunk) { + data += chunk; + }, function () { + if (pathname.match(/\/browser-fs\.json$/)) { + let contents = { "_": "browser-fs" }; + + let info = JSON.parse(data); + (info.dirs || []).forEach((dirname) => { + let fulldirname = path.resolve(path.dirname(pathname), dirname); + fs.readdirSync(fulldirname).forEach((filename) => { + contents[path.join(dirname, filename)] = fs.readFileSync(path.resolve(fulldirname, filename)).toString("base64"); + }); + }); + data = JSON.stringify(contents); + } + + this.queue(data); + this.queue(null); + }); +} diff --git a/packages/testcases/src.ts/_version.ts b/packages/testcases/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/testcases/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/testcases/src.ts/browser-fs.json b/packages/testcases/src.ts/browser-fs.json new file mode 100644 index 000000000..bb8f6e57f --- /dev/null +++ b/packages/testcases/src.ts/browser-fs.json @@ -0,0 +1 @@ +{ "dirs": [ "./easyseed-bip39", "./testcases", "./wordlists" ] } diff --git a/packages/testcases/src.ts/browser.ts b/packages/testcases/src.ts/browser.ts new file mode 100644 index 000000000..1b342ff3f --- /dev/null +++ b/packages/testcases/src.ts/browser.ts @@ -0,0 +1,21 @@ +'use strict'; + +import path from 'path'; + +import zlib from "browserify-zlib"; + +import * as data from "./browser-fs.json"; + + +export function loadTests(tag: string): any { + let filename = 'testcases/' + tag + ".json.gz"; + console.log("loading:", filename); + return JSON.parse(zlib.gunzipSync(new Buffer((data)[filename], "base64")).toString()); +} + +export function loadData(filename: string): Buffer { + // Strip any leading relative paths (e.g. "./foo" => "foo") + filename = path.join(filename); + console.log("loading:", filename); + return new Buffer((data)[filename], "base64"); +} diff --git a/packages/testcases/src.ts/generation-scripts/abi.ts b/packages/testcases/src.ts/generation-scripts/abi.ts new file mode 100644 index 000000000..71ccfaf32 --- /dev/null +++ b/packages/testcases/src.ts/generation-scripts/abi.ts @@ -0,0 +1,688 @@ +"use strict"; + +//let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549')); + +import { compile as _compile } from "solc"; + +import { randomHexString, randomNumber } from ".." +import { BN, keccak256, toChecksumAddress } from "ethereumjs-util"; + +function hasPrefix(str: string, prefix: string): boolean { + return (str.substring(0, prefix.length) === prefix); +} + +function repeat(str: string, count: number): string { + let result = ""; + for (let i = 0; i < count; i++) { result += str; } + return result; +} + +function indent(tabs: number): string { + let result = ''; + while (result.length < 4 * tabs) { result += " "; } + return result; +} + +function getStructName(base: string): string { + return "Struct" + keccak256(base).slice(0, 4).toString("hex"); +} + +class Code { + depth: number; + lines: Array; + + constructor() { + this.depth = 0; + this.lines = []; + } + + get code(): string { + return this.lines.join("\n"); //.replace(/ +\n/g, "\n").replace(/(\}\n\n+)/g, "}\n"); + } + + comment(line: string): void { + this.add(""); + this.add("/" + "/ " + line); + } + + add(line: string): void { + let open = (line.trim().substring(line.trim().length - 1) === "{"); + let close = line.trim()[0] === "}"; + + if (close) { this.depth--; } + + this.lines.push(indent(this.depth) + line); + //if (close) { this.lines.push(""); } + + if (open) { this.depth++; } + } +} + +function compile(source: string): string { + let input = { + language: "Solidity", + sources: { + "test.sol": { + content: source + } + }, + settings: { + optimizer: { + enabled: true, + runs: 200 + }, + evmVersion: "byzantium", + outputSelection: { + "*": { + "*": [ "evm.bytecode" ] + } + } + } + }; + + let output = JSON.parse(_compile(JSON.stringify(input))); + let errors = ((output).errors || []).filter((e : any) => (e.severity == "error")); + + if (errors.length) { + errors.forEach((error: any) => { + console.log(error.formattedMessage); + }); + process.exit(); + } + + return "0x" + output.contracts["test.sol"].Test.evm.bytecode.object; +} + +//idea: "tuple(address)/*StructABCDEFG*/" +type TestData = { + // The data type + type: string, + + // Value must normally be defined, but may be omitted for + // getting gen code for declarations + value?: any, + + // The name of the struct (Tuples only) + struct?: string +}; + +let chars: Array = []; +function addChars(start: number, length: number): void { + for (let i = start; i < start + length; i++) { + chars.push(String.fromCharCode(i)); + } +} + +addChars(48, 10); +addChars(65, 26); + +// Yen @TODO +//addChars(165, 1); + +type GenCode = { + assign: (name: string, code: Code) => void, + decl: (name: string) => string, + structs: (code: Code) => void, +}; + +// Returns the functions required to generate code for a specific parameter type and value +function getGenCode(testData: TestData): GenCode { + + let type = testData.type; + let value = (testData.value != null) ? testData.value: "__crash__"; + + let isArray = type.match(/^(.*)(\[[0-9]*\])$/); + if (isArray) { + let base = isArray[1]; + let suffix = isArray[2]; + let isDynamic = (isArray[2] === "[]"); + + return { + assign: (name: string, code: Code) => { + if (isDynamic) { + //let child = getGenCode({ type: base }); + //let decl = child.decl(name).split(" "); + let struct = base; + if (type.substring(0, 5) === "tuple") { + struct = getStructName(base); + } + code.add(name + " = new " + struct + "[](" + String(value.length) + ");"); + } + (>value).forEach((value, index) => { + console.log("SSS", base, value); + let child = getGenCode({ type: base, value: value }); + child.assign(name + "[" + String(index) + "]", code); + }); + }, + decl: (name: string) => { + let child = getGenCode({ type: isArray[1] }); + + // Inject the array suffix to the type and add memory location + // - uint256 p0 => uint256[] memory p0 + // - bytes memory p0 => bytes[] memory p0 + let result = child.decl(name).split(" "); + result[0] = result[0] + suffix; + if (result[1] !== "memory") { + result.splice(1, 0, "memory"); + } + return result.join(" "); + }, + structs: (code: Code) => { + let child = getGenCode({ type: isArray[1] }); + child.structs(code); + } + } + } + + let isTuple = type.match(/^tuple\((.*)\)$/); + if (isTuple) { + let children: Array = []; + + // Split up the child types + let accum = ""; + let balance = 0; + let types = isTuple[1]; + for (let i = 0; i < types.length; i++) { + let c = types[i]; + if (c === "(") { + balance++; + accum += c; + } else if (c === ")") { + balance--; + accum += c; + } else if (c === ",") { + if (balance === 0) { + children.push(accum); + accum = ""; + } else { + accum += c; + } + } else { + accum += c; + } + } + + if (accum) { children.push(accum); } + + return { + assign: (name: string, code: Code) => { + children.forEach((child, index) => { + console.log("TT", child, value[index]); + getGenCode({ + type: child, + value: value[index] + }).assign(name + ".m" + String(index), code); + }); + }, + decl: (name: string) => { + return (getStructName(type) + " memory " + name); + }, + structs: (code: Code) => { + + // Include any dependency Structs first + children.forEach((child) => { + getGenCode({ type: child }).structs(code); + }); + + // Add this struct + code.add("struct " + getStructName(type) + " {"); + children.forEach((child, index) => { + let decl = getGenCode({ + type: child + }).decl("m" + String(index)).replace(" memory ", " "); + code.add(decl + ";"); + }); + code.add("}"); + } + } + } + + let isFixedBytes = type.match(/^bytes([0-9]+)$/); + let isNumber = type.match(/^(u?)int([0-9]*)$/); + let isFixedNumber = type.match(/^(u?)fixed(([0-9]+)x([0-9]+))?$/); + + if (type === "address" || type === "bool" || isNumber || isFixedNumber || isFixedBytes) { + return { + assign: (name: string, code: Code) => { + if (type === "boolean") { + code.add(name + " = " + (value ? "true": "false") + ";"); + } else if (isFixedBytes) { + code.add(name + " = hex\"" + value.substring(2) + "\";"); + } else { + code.add(name + " = " + value + ";"); + } + }, + decl: (name: string) => { + return (type + " " + name); + }, + structs: (code: Code) => { } + } + } + + if (type === "string") { + return { + assign: (name: string, code: Code) => { + code.add(name + " = " + JSON.stringify(value) + ";"); + }, + decl: (name: string) => { + return ("string memory " + name); + }, + structs: (code: Code) => { } + } + } + + if (type === "bytes") { + let valueBytes = Buffer.from(value.substring(2), "hex"); + return { + assign: (name: string, code: Code) => { + code.add("{"); + + code.add("bytes memory temp = new bytes(" + valueBytes.length + ");"); + code.add(name + " = temp;"); + code.add("assembly {"); + + // Store the length + code.add("mstore(temp, " + valueBytes.length + ")"); + + // Store each byte + for (let i = 0; i < valueBytes.length; i++) { + code.add("mstore8(add(temp, " + (32 + i) + "), " + valueBytes[i] + ")"); + } + + code.add("}"); + + code.add("}"); + }, + decl: (name: string) => { + return ("bytes memory " + name); + }, + structs: (code: Code) => { } + } + } + + throw new Error("Could not produce GenCode: " + type); + return null; +} + +// Generates a random type and value for the type +function generateTest(seed: string): (seed: string) => TestData { + let basetype = randomNumber(seed + "-type", 0, 10) + + switch (basetype) { + + // Address + case 0: + return (seed: string) => { + let value = toChecksumAddress(randomHexString(seed + "-value", 20)); + return { + type: "address", + value: value + } + } + + // Boolean + case 1: + return (seed: string) => { + let value = (randomNumber(seed + "-value", 0, 2) ? true: false); + return { + type: "bool", + value: value + } + } + + // Number + case 2: { + let signed = randomNumber(seed + "-signed", 0, 2); + let width = randomNumber(seed + "-width", 0, 33) * 8; + + let type = (signed ? "": "u") + "int"; + + // Allow base int and uint + if (width) { + type += String(width); + } else { + width = 256; + } + + + return (seed: string) => { + let hex = randomHexString(seed + "-value", width / 8).substring(2); + + if (signed) { + // Sign bit set (we don't bother with 2's compliment + let msb = parseInt(hex[0], 16); + if (msb >= 8) { + hex = "-" + String(msb & 0x7) + hex.substring(1); + } + } + let value = (new BN(hex, 16)).toString(); + + return { + type: type, + value: value + } + } + } + + // Fixed + case 3: { + // Fixed Point values are not supported yet + return generateTest(seed + "-next"); + + let signed = randomNumber(seed + "-signed", 0, 2); + let width = randomNumber(seed + "-width", 0, 33) * 8; + let decimals = 0; + + let maxDecimals = (new BN(repeat("7f", ((width === 0) ? 32: (width / 8))), 16)).toString().length - 1; + + let attempt = 0; + while (true) { + decimals = randomNumber(seed + "-decimals" + String(attempt), 0, 80); + if (decimals < maxDecimals) { break; } + attempt++; + } + + let type = (signed ? "": "u") + "fixed"; + + // Allow base int and uint + if (width) { + type += String(width) + "x" + String(decimals); + } else { + width = 128; + decimals = 18; + } + + return (seed: string) => { + let hex = randomHexString(seed + "-value", width / 8).substring(2); + + // Use the top bit to indicate negative values + let negative = false; + if (signed) { + // Sign bit set (we don't bother with 2's compliment + let msb = parseInt(hex[0], 16); + if (msb >= 8) { + hex = String(msb & 0x7) + hex.substring(1); + negative = true; + } + } + + // Zero-pad the value so we get at least 1 whole digit + let dec = (new BN(hex, 16)).toString(); + while (dec.length < decimals + 1) { dec = "0" + dec; } + + // Split the decimals with the decimal point + let split = dec.length - decimals; + let value = dec.substring(0, split) + "." + dec.substring(split); + if (negative) { value = "-" + value; } + + // Prevent ending in a decimal (e.g. "45." + if (value.substring(value.length - 1) === ".") { + value = value.substring(0, value.length - 1); + } + + return { + type: type, + value: value + } + } + } + + // BytesXX + case 4: { + let length = randomNumber(seed + "-length", 1, 33); + let type = "bytes" + String(length); + + return (seed: string) => { + let value = randomHexString(seed + "-value", length); + return { + type: type, + value: value + } + } + } + + // String + case 5: + return (seed: string) => { + let length = randomNumber(seed + "-length", 0, 36) + + let value = ""; + while (value.length < length) { + value += chars[randomNumber(seed + "-value" + String(value.length), 0, chars.length)]; + } + + return { + type: "string", + value: value + } + } + + // Bytes + case 6: + return (seed: string) => { + let length = randomNumber(seed + "-length", 0, 12); // @TODO: increase this + let value = randomHexString(seed + "-value", length); + //let valueBytes = Buffer.from(value.substring(2), "hex"); + return { + type: "bytes", + value: value + } + } + + // Fixed-Length Array (e.g. address[4]) + case 7: + // Falls-through + + // Dynamic-Length Array (e.g. address[]) + case 8: { + let dynamic = (basetype === 8); + + let subType = generateTest(seed + "-subtype"); + let length = randomNumber(seed + "-length", 1, 3); + + let suffix = "[" + ((!dynamic) ? length: "") + "]"; + let type = subType("-index0").type + suffix; + + return (seed: string) => { + if (dynamic) { + length = randomNumber(seed + "-length", 0, 3); + } + + let children: Array = [ ]; + for (let i = 0; i < length; i++) { + children.push(subType(seed + "-index" + String(i))); + } + + return { + type: type, + value: children.map((data) => data.value) + } + } + } + + // Tuple + case 9: { + let count = randomNumber(seed + "-count", 1, 8); + + let subTypes: Array<(seed: string) => TestData> = [ ]; + for (let i = 0; i < count; i++) { + let cSeed = seed + "-subtype" + String(i); + subTypes.push(generateTest(cSeed)); + } + + let type = "tuple(" + subTypes.map(s => s("-index0").type).join(",") + ")"; + let struct = "Struct" + randomHexString(seed + "-name", 4).substring(2); + + return (seed: string) => { + let children: Array = [ ]; + subTypes.forEach((subType) => { + children.push(subType(seed + "-value")) + }); + + return { + type: type, + struct: struct, + value: children.map(c => c.value), + } + } + } + } + + throw new Error("bad things"); + return null; +} + + +export type TestCase = { + type: string; + bytecode: string; + encoded: string; + packed: string; + source: string; + value: any; +}; + +// Returns true iff the types are able to be non-standard pack encoded +function checkPack(types: Array): boolean { + for (let i = 0; i < types.length; i++) { + let type = types[i]; + if (hasPrefix(type, "tuple")) { return false; } + if (hasPrefix(type, "bytes[")) { return false; } + if (hasPrefix(type, "string[")) { return false; } + let firstDynamic = type.indexOf("[]"); + if (firstDynamic >= 0 && firstDynamic != type.length - 2) { + return false; + } + } + return true; +} + +// Generates a Solidity source files with the parameter types and values +function generateSolidity(params: Array): string { + let plist = [ ]; + for (let i = 0; i < params.length; i++) { plist.push("p" + String(i)); } + + let genCodes = params.map(p => getGenCode(p)); + + let code = new Code(); + + /////////////////// + // Pragma + code.add("pragma experimental ABIEncoderV2;"); + code.add("pragma solidity ^0.5.5;"); + code.add(""); + + /////////////////// + // Header + code.add("contract Test {"); + + /////////////////// + // Structs + genCodes.forEach((genCode) => { + genCode.structs(code); + }); + + /////////////////// + // test function + code.add("function test() public pure returns (" + genCodes.map((g, i) => (g.decl("p" + String(i)))).join(", ") + ") {"); + + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + + code.add("}"); + + /////////////////// + // encode + code.add("function encode() public pure returns (bytes memory data){"); + + code.comment("Declare all parameters"); + genCodes.forEach((genCode, index) => { + code.add(genCode.decl("p" + index) + ";"); + }); + + code.comment("Assign all parameters"); + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + + code.add(""); + + code.add("return abi.encode(" + params.map((p, i) => ("p" + i)).join(", ") + ");") + + code.add("}"); + + /////////////////// + // encodePacked + if (checkPack(params.map(p => p.type))) { + code.add("function encodePacked() public pure returns (bytes memory data){"); + + code.comment("Declare all parameters"); + genCodes.forEach((genCode, index) => { + code.add(genCode.decl("p" + index) + ";"); + }); + + code.comment("Assign all parameters"); + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + + code.add(""); + + code.add("return abi.encodePacked(" + params.map((p, i) => ("p" + i)).join(", ") + ");") + + code.add("}"); + } + + /////////////////// + // Footer + code.add("}"); + + return code.code; +} + +for (let i = 0; i < 100; i++) { + let params = [ ]; + console.log(i, randomNumber(String(i) + "-length", 1, 6)) + let length = randomNumber(String(i) + "-length", 1, 6); + for (let j = 0; j < length; j++) { + params.push(generateTest(String(i) + String(j) + "-type")(String(i) + String(j) + "-test")); + } + let solidity = generateSolidity(params); + console.log(solidity); + console.log(i); + let bytecode = compile(solidity); + //console.log(params.map(p => p.type).join(", ")); + //console.log(bytecode); + let testcase = { + //solidity: solidity, + bytecode: bytecode, + types: params.map(p => p.type), + value: params.map(p => p.value), + }; + console.log(testcase); +} +/* +let solidity = generateSolidity([ + generateTest("test37")("foo"), + generateTest("test2")("bar"), +]); + +console.log(solidity); +console.log(compile(solidity)); +*/ +/* +for (let i = 0; i < 20; i++) { + let test = generateTest(String(i)); + let data = test(String(i) + "-root"); + console.log(i); + console.dir(data, { depth: null }); + data.solidityDeclare("p0").forEach((line) => { + console.log(indent(1), line); + }); + data.solidityAssign("p0").forEach((line) => { + console.log(indent(1), line); + }); + console.log(""); +} +*/ diff --git a/packages/testcases/src.ts/generation-scripts/hdnode.ts b/packages/testcases/src.ts/generation-scripts/hdnode.ts new file mode 100644 index 000000000..71f6d199a --- /dev/null +++ b/packages/testcases/src.ts/generation-scripts/hdnode.ts @@ -0,0 +1,135 @@ +'use strict'; + +import fs from "fs"; +import { resolve } from "path"; + +import * as bip39 from "bip39"; +import { HDNode } from "bitcoinjs-lib"; + +import * as ethereumUtil from "ethereumjs-util"; + +import { randomHexString, randomNumber, saveTests, TestCase } from ".."; + + +function getPath(seed: string): string { + let path = "m"; + + let count = randomNumber(seed + "-getPath-1", 1, 7); + let hardened = randomNumber(seed + "-getPath-2", 0, count + 2); + for (let i = 0; i < count; i++) { + path += "/" + randomNumber(seed + "-getPath-3" + i, 0, 12); + if (i < hardened) { + path += "'"; + } + } + + return path; +} + +function getHD(seed: string): Array { + let rootNode = HDNode.fromSeedHex(seed); + + let privateKey = rootNode.keyPair.d.toBuffer(32); + let hdnodes: Array = [{ + path: 'm', + privateKey: '0x' + privateKey.toString('hex'), + address: '0x' + ethereumUtil.privateToAddress(privateKey).toString('hex'), + }]; + + for (let j = 0; j < 5; j++) { + let path = getPath(seed + '-hdnode-' + j); + let node = rootNode.derivePath(path); + let privateKey = node.keyPair.d.toBuffer(32); + hdnodes.push({ + path: path, + privateKey: '0x' + privateKey.toString('hex'), + address: '0x' + ethereumUtil.privateToAddress(privateKey).toString('hex'), + }); + } + + return hdnodes; +} + +const testcases: Array = []; + +// https://medium.com/@alexberegszaszi/why-do-my-bip32-wallets-disagree-6f3254cc5846#.6tqszlvf4 +testcases.push({ + name: "axic", + locale: "en", + entropy: '0xb0a30c7e93a58094d213c4c0aaba22da', + mnemonic: 'radar blur cabbage chef fix engine embark joy scheme fiction master release', + seed: '0xed37b3442b3d550d0fbb6f01f20aac041c245d4911e13452cac7b1676a070eda66771b71c0083b34cc57ca9c327c459a0ec3600dbaf7f238ff27626c8430a806', + hdnodes: [ + { + path: "m/44'/60'/0'/0/0", + address: '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9', + privateKey: '0xb96e9ccb774cc33213cbcb2c69d3cdae17b0fe4888a1ccd343cbd1a17fd98b18', + } + ] +}); + +["en", "es", "fr", "it", "ja", "ko", "zh_cn", "zh_tw"].forEach((locale) => { + type EasyseedTest = { + entropy: string; + seed: string; + mnemonic: string; + passphrase: string; + }; + + let tests: Array = JSON.parse(fs.readFileSync(resolve(__dirname, "../input/easyseed-bip39/bip39_vectors." + locale + ".json")).toString()); + tests.forEach((test, index) => { + testcases.push({ + name: ("easyseed-" + locale + "-" + index), + entropy: "0x" + test.entropy, + locale: locale, + mnemonic: test.mnemonic, + password: (test.passphrase || ''), + seed: "0x" + test.seed, + hdnodes: [ ] + }); + }); +}); + +console.log("@TODO: This should be 1024"); +for (let i = 0; i < 10; i++) { + let strength = 16 + 4 * randomNumber('random-1-' + i, 0, 5); + let entropy = randomHexString('random-2-' + i, strength); + + let mnemonic = bip39.entropyToMnemonic(entropy.substring(2)); + let seed = bip39.mnemonicToSeedHex(mnemonic); + + testcases.push({ + name: "random-" + i, + locale: "en", + entropy: entropy, + mnemonic: mnemonic, + seed: '0x' + seed, + hdnodes: getHD(seed), + }); +} + +let trezor: { english: Array> } = require('../input/tests-trezor-bip39.json'); +trezor.english.forEach((testcase, i) => { + testcases.push({ + name: "trezor-" + i, + locale: "en", + entropy: '0x' + testcase[0], + mnemonic: testcase[1], + seed: '0x' + testcase[2], + hdnodes: getHD(testcase[2]), + password: 'TREZOR', + }); +}); + + +/* +let seed = bip39.mnemonicToSeedHex('radar blur cabbage chef fix engine embark joy scheme fiction master release'); +console.log('Seed', seed); +let entropy = bip39.mnemonicToEntropy('radar blur cabbage chef fix engine embark joy scheme fiction master release'); +console.log('Entropy', entropy); +let rootNode = HDNode.fromSeedHex(seed); +let node = rootNode.derivePath("m/44'/60'/0'/0/0"); +console.log('PrivateKey', node.keyPair.d.toBuffer(32).toString('hex')), +*/ + +saveTests('hdnode', testcases); diff --git a/packages/testcases/src.ts/generation-scripts/units.ts b/packages/testcases/src.ts/generation-scripts/units.ts new file mode 100644 index 000000000..6000f1ef2 --- /dev/null +++ b/packages/testcases/src.ts/generation-scripts/units.ts @@ -0,0 +1,11 @@ +'use strict'; + +import fs from "fs"; +import { resolve } from "path"; + +import { saveTests, TestCase } from ".."; + +const testcases: Array = JSON.parse(fs.readFileSync(resolve(__dirname, "../input/units.json")).toString()); + +saveTests("units", testcases); + diff --git a/packages/testcases/src.ts/generation-scripts/wordlists.ts b/packages/testcases/src.ts/generation-scripts/wordlists.ts new file mode 100644 index 000000000..3df4d7368 --- /dev/null +++ b/packages/testcases/src.ts/generation-scripts/wordlists.ts @@ -0,0 +1,18 @@ +'use strict'; + +import fs from "fs"; +import { resolve } from "path"; + +import { saveTests, TestCase } from ".."; + +const testcases: Array = []; + +["en", "es", "fr", "it", "ja", "ko", "zh_cn", "zh_tw"].forEach((locale) => { + let content = fs.readFileSync(resolve(__dirname, "../input/wordlists", "lang-" + locale + ".txt")).toString(); + testcases.push({ + content: content, + locale: locale + }) +}); + +saveTests("wordlists", testcases); diff --git a/packages/testcases/src.ts/index.ts b/packages/testcases/src.ts/index.ts new file mode 100644 index 000000000..38e26bdc2 --- /dev/null +++ b/packages/testcases/src.ts/index.ts @@ -0,0 +1,101 @@ +'use strict'; + +import fs from 'fs'; +import path from 'path'; +import zlib from 'browserify-zlib'; + +import { arrayify, concat, hexlify } from "@ethersproject/bytes"; +import { keccak256 } from "@ethersproject/keccak256"; +import { toUtf8Bytes } from "@ethersproject/strings"; + +export module TestCase { + export type HDWalletNode = { + path: string; + address: string; + privateKey: string; + }; + + export type HDWallet = { + name: string; + + seed: string; + locale: string; + password?: string; + entropy: string; + mnemonic: string; + + hdnodes: Array + }; + + export type Wordlist = { + locale: string; + content: string; + }; + + export type Unit = { + name: string + + ether: string, + ether_format: string, + + wei: string, + + kwei?: string, + mwei?: string, + gwei?: string, + szabo?: string, + finney?: string, + satoshi?: string + + kwei_format?: string, + mwei_format?: string, + gwei_format?: string, + szabo_format?: string, + finney_format?: string, + satoshi_format?: string + } +} + +export function saveTests(tag: string, data: any) { + //let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + let filename = path.resolve('testcases', tag + '.json.gz'); + + fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(data, undefined, ' ') + '\n')); + + console.log('Save testcase: ' + filename); +} + +export function loadTests(tag: string): any { + let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString()); +} + +export function loadData(filename: string): Buffer { + return fs.readFileSync(path.resolve(__dirname, filename)); +} + +export function randomBytes(seed: string, lower: number, upper?: number): Uint8Array { + if (!upper) { upper = lower; } + + if (upper === 0 && upper === lower) { return new Uint8Array(0); } + + let result = arrayify(keccak256(toUtf8Bytes(seed))); + while (result.length < upper) { + result = concat([result, keccak256(result)]); + } + + let top = arrayify(keccak256(result)); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + + return result.slice(0, lower + Math.floor((upper - lower) * percent)); +} + +export function randomHexString(seed: string, lower: number, upper?: number): string { + return hexlify(randomBytes(seed, lower, upper)); +} + +export function randomNumber(seed: string, lower: number, upper: number): number { + let top = randomBytes(seed, 3); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return lower + Math.floor((upper - lower) * percent); +} diff --git a/packages/testcases/testcases/accounts.json.gz b/packages/testcases/testcases/accounts.json.gz new file mode 100644 index 000000000..f5757aef8 Binary files /dev/null and b/packages/testcases/testcases/accounts.json.gz differ diff --git a/packages/testcases/testcases/contract-events.json.gz b/packages/testcases/testcases/contract-events.json.gz new file mode 100644 index 000000000..b9173d43e Binary files /dev/null and b/packages/testcases/testcases/contract-events.json.gz differ diff --git a/packages/testcases/testcases/contract-interface-abi2.json.gz b/packages/testcases/testcases/contract-interface-abi2.json.gz new file mode 100644 index 000000000..2faead9db Binary files /dev/null and b/packages/testcases/testcases/contract-interface-abi2.json.gz differ diff --git a/packages/testcases/testcases/contract-interface.json.gz b/packages/testcases/testcases/contract-interface.json.gz new file mode 100644 index 000000000..a4e59c22b Binary files /dev/null and b/packages/testcases/testcases/contract-interface.json.gz differ diff --git a/packages/testcases/testcases/contract-signatures.json.gz b/packages/testcases/testcases/contract-signatures.json.gz new file mode 100644 index 000000000..e32f6b048 Binary files /dev/null and b/packages/testcases/testcases/contract-signatures.json.gz differ diff --git a/packages/testcases/testcases/hashes.json.gz b/packages/testcases/testcases/hashes.json.gz new file mode 100644 index 000000000..e70cd1e4e Binary files /dev/null and b/packages/testcases/testcases/hashes.json.gz differ diff --git a/packages/testcases/testcases/hdnode.json.gz b/packages/testcases/testcases/hdnode.json.gz new file mode 100644 index 000000000..69917e356 Binary files /dev/null and b/packages/testcases/testcases/hdnode.json.gz differ diff --git a/packages/testcases/testcases/namehash.json.gz b/packages/testcases/testcases/namehash.json.gz new file mode 100644 index 000000000..fc1a3d036 Binary files /dev/null and b/packages/testcases/testcases/namehash.json.gz differ diff --git a/packages/testcases/testcases/rlp-coder.json.gz b/packages/testcases/testcases/rlp-coder.json.gz new file mode 100644 index 000000000..b39749ce4 Binary files /dev/null and b/packages/testcases/testcases/rlp-coder.json.gz differ diff --git a/packages/testcases/testcases/solidity-hashes.json.gz b/packages/testcases/testcases/solidity-hashes.json.gz new file mode 100644 index 000000000..07b379a3a Binary files /dev/null and b/packages/testcases/testcases/solidity-hashes.json.gz differ diff --git a/packages/testcases/testcases/transactions.json.gz b/packages/testcases/testcases/transactions.json.gz new file mode 100644 index 000000000..ecde3aeba Binary files /dev/null and b/packages/testcases/testcases/transactions.json.gz differ diff --git a/packages/testcases/testcases/units.json.gz b/packages/testcases/testcases/units.json.gz new file mode 100644 index 000000000..36d765682 Binary files /dev/null and b/packages/testcases/testcases/units.json.gz differ diff --git a/packages/testcases/testcases/wallets.json.gz b/packages/testcases/testcases/wallets.json.gz new file mode 100644 index 000000000..09c6e3876 Binary files /dev/null and b/packages/testcases/testcases/wallets.json.gz differ diff --git a/packages/testcases/testcases/wordlists.json.gz b/packages/testcases/testcases/wordlists.json.gz new file mode 100644 index 000000000..154d1f765 Binary files /dev/null and b/packages/testcases/testcases/wordlists.json.gz differ diff --git a/packages/testcases/thirdparty.d.ts b/packages/testcases/thirdparty.d.ts new file mode 100644 index 000000000..dabba598e --- /dev/null +++ b/packages/testcases/thirdparty.d.ts @@ -0,0 +1,36 @@ +declare module "browserify-zlib" { + export interface ZlibOptions { + flush?: number; + finishFlush?: number; + chunkSize?: number; + windowBits?: number; + level?: number; + memLevel?: number; + strategy?: number; + dictionary?: any; + } + + type InputType = string | Buffer | DataView | ArrayBuffer; + + export function gzipSync(buf: InputType, options?: ZlibOptions): Buffer; + export function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer; +} + +declare module "*.json" { + const value: any; + export default value; +} + +declare module "ethereumjs-util" { + export function privateToAddress(privateKey: Buffer | Uint8Array): Buffer | Uint8Array; + export function toChecksumAddress(address: string): string; + export function keccak256(data: string): Buffer; + class BN { + constructor(value: string, radix: number); + toString(): string; + } +} + +declare module "solc" { + function compile(input: string): string; +} diff --git a/packages/testcases/tsconfig.json b/packages/testcases/tsconfig.json new file mode 100644 index 000000000..6e2cd789f --- /dev/null +++ b/packages/testcases/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./", + + "resolveJsonModule": true + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*", + "./src.ts/generation-scripts/*" + ], + "exclude": [ ] +} + diff --git a/packages/tests/.gitignore b/packages/tests/.gitignore new file mode 100644 index 000000000..49cd42df6 --- /dev/null +++ b/packages/tests/.gitignore @@ -0,0 +1,2 @@ +dist/ +tests/*.d.ts diff --git a/packages/tests/.npmignore b/packages/tests/.npmignore new file mode 100644 index 000000000..a66dcb78a --- /dev/null +++ b/packages/tests/.npmignore @@ -0,0 +1,3 @@ +tsconfig.json +src.ts/ +dist/ diff --git a/packages/tests/LICENSE.md b/packages/tests/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/tests/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/tests/README.md b/packages/tests/README.md new file mode 100644 index 000000000..dd1985d3e --- /dev/null +++ b/packages/tests/README.md @@ -0,0 +1,17 @@ +Mocha Test Suite for Ethers +=========================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/tests/contracts/test-contract.json b/packages/tests/contracts/test-contract.json new file mode 100644 index 000000000..37ae109ce --- /dev/null +++ b/packages/tests/contracts/test-contract.json @@ -0,0 +1,20 @@ +{ + "deployer": "0xE78e48deF8A432Ed0e9287d5678496E759e8A564", + "source": "pragma solidity ^0.4.20;\npragma experimental ABIEncoderV2;\n\ncontract TestContract {\n struct TestStruct {\n address p0;\n uint256 p1;\n }\n\n struct TestStructParent {\n address p0;\n uint256 p1;\n TestStruct child;\n }\n\n event Test(address p0, uint256 p2);\n event TestP0(address indexed p0, uint256 p2);\n event TestP0P1(address indexed p0, uint256 indexed p2);\n\n event TestAnon(address p0, uint256 p2) anonymous;\n event TestAnonP0(address indexed p0, uint256 p2) anonymous;\n event TestAnonP0P1(address indexed p0, uint256 indexed p2) anonymous;\n\n event TestIndexedString(string indexed p2, uint256 p1);\n\n event TestV2(TestStruct indexed p0, TestStruct p1);\n event TestV2Nested(TestStructParent indexed p0, TestStructParent p1);\n\n /*\n event TestV2Array(TestStruct indexed p0[2], TestStruct p1[2]);\n event TestV2NestedArray(TestStructParent indexed p0[2], TestStructParent p1[2]);\n\n event TestV2DynamicArray(TestStruct indexed p0[], TestStruct p1[]);\n event TestV2NestedDynamicArray(TestStructParent indexed p0[], TestStructParent p1[]);\n */\n\n event TestHash(string name, bytes32 hash);\n\n function testEvents(address p0, uint256 p1, string p2) public {\n\n Test(p0, p1);\n TestP0(p0, p1);\n TestP0P1(p0, p1);\n\n TestAnon(p0, p1);\n TestAnonP0(p0, p1);\n TestAnonP0P1(p0, p1);\n\n TestIndexedString(p2, p1);\n\n TestStruct memory testStruct;\n testStruct.p0 = p0;\n testStruct.p1 = p1;\n\n TestStructParent memory testStructParent;\n testStructParent.p0 = address(uint160(p0) + 1);\n testStructParent.p1 = p1 + 1;\n testStructParent.child = testStruct;\n\n TestV2(testStruct, testStruct);\n TestV2Nested(testStructParent, testStructParent);\n\n TestHash(\"TestStructKeccak256\", keccak256(testStruct));\n TestHash(\"TestStructParentKeccak256\", keccak256(testStructParent));\n }\n\n function testV2(TestStructParent p0) public pure returns (TestStructParent result) {\n p0.p0 = address(uint160(p0.p0) + 0xf0);\n p0.p1 += 0xf0;\n p0.child.p0 = address(uint160(p0.child.p0) + 0x0f);\n p0.child.p1 += 0x0f;\n\n return p0;\n }\n\n function testSingleResult(uint32 p0) public pure returns (uint32 r0) {\n r0 = p0 + 1;\n }\n\n function testMultiResult(uint32 p0) public pure returns (uint32 r0, uint32 r1) {\n r0 = p0 + 1;\n r1 = p0 + 2;\n }\n}\n", + "optimize": 1, + "timestamp": 1528239748494, + "bytecode": "0x6060604052341561000f57600080fd5b61088f8061001e6000396000f3006060604052600436106100615763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663132414eb811461006657806361096af31461009a57806370e4a0e6146100c6578063babf8901146100f1575b600080fd5b341561007157600080fd5b61008461007f36600461063d565b610111565b60405161009191906107b5565b60405180910390f35b34156100a557600080fd5b6100b86100b336600461063d565b610117565b6040516100919291906107c3565b34156100d157600080fd5b6100e46100df366004610617565b610124565b604051610091919061078b565b34156100fc57600080fd5b61010f61010a3660046105b2565b61017b565b005b60010190565b6001810191600290910190565b61012c610453565b8151600160a060020a0360f09182011683526020830181815101905250604082015151600f018260400151600160a060020a039091169052600f60408301516020018181510190525090919050565b610183610479565b61018b610453565b7f4ba54330f8090ac87ed0a0b470fd9c8a6bbec84bfe94f4fa7776d1dc27da9f9c85856040516101bc92919061073b565b60405180910390a184600160a060020a03167f02d0f5cbd3582d62980b4541ea596241400b46b70e62e8f5d4191b59e5256b79856040516101fd91906107a7565b60405180910390a28385600160a060020a03167f259f1a317c656f6d04907e133c9444121c489db10cc9ae0cb8e5089fb24579bd60405160405180910390a3848460405161024c92919061073b565b60405180910390a084600160a060020a03168460405161026c91906107a7565b60405180910390a18385600160a060020a031660405160405180910390a2826040518082805190602001908083835b602083106102ba5780518252601f19909201916020918201910161029b565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390207f64c167146cf1edcaf437640ce9016042b5d80b35064b04ad29af4b8b1420db908560405161031591906107a7565b60405180910390a2600160a060020a03808616835260208084018690526001808801909216835290850190820152604080820183905282907fe85f025e05a85adc87cd1791754b085143ee32261f66e8b6118e8229b494dcdb9082905161037c9190610799565b60405180910390a2807fe0f519dd634b43e6774158c4064aeaeb81762b6577a8c8b8c65b53053fd915fc826040516103b4919061078b565b60405180910390a27fd8b63a613757c85c5a7bc41a52505a0a5d424f9c1a0cdb6d86c53af2f392d8188260405190815260200160405180910390206040516103fc9190610756565b60405180910390a17fd8b63a613757c85c5a7bc41a52505a0a5d424f9c1a0cdb6d86c53af2f392d818816040519081526020016040518091039020604051610444919061077b565b60405180910390a15050505050565b60806040519081016040908152600080835260208301528101610474610479565b905290565b604080519081016040526000808252602082015290565b600061049c8235610831565b9392505050565b6000601f82018390126104b557600080fd5b81356104c86104c382610809565b6107de565b915080825260208301602083018583830111156104e457600080fd5b6104ef838284610849565b50505092915050565b60006080828403121561050a57600080fd5b61051460606107de565b905060006105228484610490565b82525060206105338484830161059a565b602083015250604061054784828501610553565b60408301525092915050565b60006040828403121561056557600080fd5b61056f60406107de565b9050600061057d8484610490565b825250602061058e8484830161059a565b60208301525092915050565b600061049c823561083d565b600061049c8235610840565b6000806000606084860312156105c757600080fd5b60006105d38686610490565b93505060206105e48682870161059a565b925050604084013567ffffffffffffffff81111561060157600080fd5b61060d868287016104a3565b9150509250925092565b60006080828403121561062957600080fd5b600061063584846104f8565b949350505050565b60006020828403121561064f57600080fd5b600061063584846105a6565b61066481610831565b82525050565b6106648161083d565b601381527f546573745374727563744b656363616b32353600000000000000000000000000602082015260400190565b601981527f54657374537472756374506172656e744b656363616b32353600000000000000602082015260400190565b6080820181516106e3848261065b565b5060208201516106f6602085018261066a565b506040820151610709604085018261070f565b50505050565b60408201815161071f848261065b565b506020820151610709602085018261066a565b61066481610840565b60408101610749828561065b565b61049c602083018461066a565b6040808252810161076681610673565b9050610775602083018461066a565b92915050565b60408082528101610766816106a3565b6080810161077582846106d3565b60408101610775828461070f565b60208101610775828461066a565b602081016107758284610732565b604081016107d18285610732565b61049c6020830184610732565b6000604051905081810181811067ffffffffffffffff8211171561080157600080fd5b604052919050565b600067ffffffffffffffff82111561082057600080fd5b506020601f91909101601f19160190565b600160a060020a031690565b90565b63ffffffff1690565b828183375060009101525600a265627a7a72305820738426ffc61b45a331eec053537d02526e13fd71949a31290da38ec04e43f1f46c6578706572696d656e74616cf50037", + "compiler": "0.4.20+commit.3155dd80", + "functionHashes": { + "testEvents(address,uint256,string)": "babf8901", + "testMultiResult(uint32)": "61096af3", + "testSingleResult(uint32)": "132414eb", + "testV2((address,uint256,(address,uint256)))": "70e4a0e6" + }, + "interface": "[{\"constant\":true,\"inputs\":[{\"name\":\"p0\",\"type\":\"uint32\"}],\"name\":\"testSingleResult\",\"outputs\":[{\"name\":\"r0\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"p0\",\"type\":\"uint32\"}],\"name\":\"testMultiResult\",\"outputs\":[{\"name\":\"r0\",\"type\":\"uint32\"},{\"name\":\"r1\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"name\":\"child\",\"type\":\"tuple\"}],\"name\":\"p0\",\"type\":\"tuple\"}],\"name\":\"testV2\",\"outputs\":[{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"name\":\"child\",\"type\":\"tuple\"}],\"name\":\"result\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"},{\"name\":\"p2\",\"type\":\"string\"}],\"name\":\"testEvents\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"Test\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"TestP0\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"TestP0P1\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":false,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"TestAnon\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"TestAnonP0\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"p0\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"p2\",\"type\":\"uint256\"}],\"name\":\"TestAnonP0P1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"p2\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"p1\",\"type\":\"uint256\"}],\"name\":\"TestIndexedString\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"indexed\":true,\"name\":\"p0\",\"type\":\"tuple\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"indexed\":false,\"name\":\"p1\",\"type\":\"tuple\"}],\"name\":\"TestV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"name\":\"child\",\"type\":\"tuple\"}],\"indexed\":true,\"name\":\"p0\",\"type\":\"tuple\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"},{\"components\":[{\"name\":\"p0\",\"type\":\"address\"},{\"name\":\"p1\",\"type\":\"uint256\"}],\"name\":\"child\",\"type\":\"tuple\"}],\"indexed\":false,\"name\":\"p1\",\"type\":\"tuple\"}],\"name\":\"TestV2Nested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"hash\",\"type\":\"bytes32\"}],\"name\":\"TestHash\",\"type\":\"event\"}]", + "runtimeBytecode": "0x6060604052600436106100615763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663132414eb811461006657806361096af31461009a57806370e4a0e6146100c6578063babf8901146100f1575b600080fd5b341561007157600080fd5b61008461007f36600461063d565b610111565b60405161009191906107b5565b60405180910390f35b34156100a557600080fd5b6100b86100b336600461063d565b610117565b6040516100919291906107c3565b34156100d157600080fd5b6100e46100df366004610617565b610124565b604051610091919061078b565b34156100fc57600080fd5b61010f61010a3660046105b2565b61017b565b005b60010190565b6001810191600290910190565b61012c610453565b8151600160a060020a0360f09182011683526020830181815101905250604082015151600f018260400151600160a060020a039091169052600f60408301516020018181510190525090919050565b610183610479565b61018b610453565b7f4ba54330f8090ac87ed0a0b470fd9c8a6bbec84bfe94f4fa7776d1dc27da9f9c85856040516101bc92919061073b565b60405180910390a184600160a060020a03167f02d0f5cbd3582d62980b4541ea596241400b46b70e62e8f5d4191b59e5256b79856040516101fd91906107a7565b60405180910390a28385600160a060020a03167f259f1a317c656f6d04907e133c9444121c489db10cc9ae0cb8e5089fb24579bd60405160405180910390a3848460405161024c92919061073b565b60405180910390a084600160a060020a03168460405161026c91906107a7565b60405180910390a18385600160a060020a031660405160405180910390a2826040518082805190602001908083835b602083106102ba5780518252601f19909201916020918201910161029b565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390207f64c167146cf1edcaf437640ce9016042b5d80b35064b04ad29af4b8b1420db908560405161031591906107a7565b60405180910390a2600160a060020a03808616835260208084018690526001808801909216835290850190820152604080820183905282907fe85f025e05a85adc87cd1791754b085143ee32261f66e8b6118e8229b494dcdb9082905161037c9190610799565b60405180910390a2807fe0f519dd634b43e6774158c4064aeaeb81762b6577a8c8b8c65b53053fd915fc826040516103b4919061078b565b60405180910390a27fd8b63a613757c85c5a7bc41a52505a0a5d424f9c1a0cdb6d86c53af2f392d8188260405190815260200160405180910390206040516103fc9190610756565b60405180910390a17fd8b63a613757c85c5a7bc41a52505a0a5d424f9c1a0cdb6d86c53af2f392d818816040519081526020016040518091039020604051610444919061077b565b60405180910390a15050505050565b60806040519081016040908152600080835260208301528101610474610479565b905290565b604080519081016040526000808252602082015290565b600061049c8235610831565b9392505050565b6000601f82018390126104b557600080fd5b81356104c86104c382610809565b6107de565b915080825260208301602083018583830111156104e457600080fd5b6104ef838284610849565b50505092915050565b60006080828403121561050a57600080fd5b61051460606107de565b905060006105228484610490565b82525060206105338484830161059a565b602083015250604061054784828501610553565b60408301525092915050565b60006040828403121561056557600080fd5b61056f60406107de565b9050600061057d8484610490565b825250602061058e8484830161059a565b60208301525092915050565b600061049c823561083d565b600061049c8235610840565b6000806000606084860312156105c757600080fd5b60006105d38686610490565b93505060206105e48682870161059a565b925050604084013567ffffffffffffffff81111561060157600080fd5b61060d868287016104a3565b9150509250925092565b60006080828403121561062957600080fd5b600061063584846104f8565b949350505050565b60006020828403121561064f57600080fd5b600061063584846105a6565b61066481610831565b82525050565b6106648161083d565b601381527f546573745374727563744b656363616b32353600000000000000000000000000602082015260400190565b601981527f54657374537472756374506172656e744b656363616b32353600000000000000602082015260400190565b6080820181516106e3848261065b565b5060208201516106f6602085018261066a565b506040820151610709604085018261070f565b50505050565b60408201815161071f848261065b565b506020820151610709602085018261066a565b61066481610840565b60408101610749828561065b565b61049c602083018461066a565b6040808252810161076681610673565b9050610775602083018461066a565b92915050565b60408082528101610766816106a3565b6080810161077582846106d3565b60408101610775828461070f565b60208101610775828461066a565b602081016107758284610732565b604081016107d18285610732565b61049c6020830184610732565b6000604051905081810181811067ffffffffffffffff8211171561080157600080fd5b604052919050565b600067ffffffffffffffff82111561082057600080fd5b506020601f91909101601f19160190565b600160a060020a031690565b90565b63ffffffff1690565b828183375060009101525600a265627a7a72305820738426ffc61b45a331eec053537d02526e13fd71949a31290da38ec04e43f1f46c6578706572696d656e74616cf50037", + "transactionHash": "0x19d1edeaa4f9b40cd0f08e8896bba04d1e74b97ddf4dabaa36e852512edf189d", + "contractAddress": "0x94d28bB6cd09f0488039a1870FbDB496Bc6ce98B", + "blockHash": "0xa5d83b96fb8002004d31ab6a5e20c48f6928169dae8bc70257b115f950e9d39c", + "blockNumber": 2411314 +} \ No newline at end of file diff --git a/packages/tests/contracts/test-contract.sol b/packages/tests/contracts/test-contract.sol new file mode 100644 index 000000000..58f62dc2e --- /dev/null +++ b/packages/tests/contracts/test-contract.sol @@ -0,0 +1,84 @@ +pragma solidity ^0.4.20; +pragma experimental ABIEncoderV2; + +contract TestContract { + struct TestStruct { + address p0; + uint256 p1; + } + + struct TestStructParent { + address p0; + uint256 p1; + TestStruct child; + } + + event Test(address p0, uint256 p2); + event TestP0(address indexed p0, uint256 p2); + event TestP0P1(address indexed p0, uint256 indexed p2); + + event TestAnon(address p0, uint256 p2) anonymous; + event TestAnonP0(address indexed p0, uint256 p2) anonymous; + event TestAnonP0P1(address indexed p0, uint256 indexed p2) anonymous; + + event TestIndexedString(string indexed p2, uint256 p1); + + event TestV2(TestStruct indexed p0, TestStruct p1); + event TestV2Nested(TestStructParent indexed p0, TestStructParent p1); + + /* + event TestV2Array(TestStruct indexed p0[2], TestStruct p1[2]); + event TestV2NestedArray(TestStructParent indexed p0[2], TestStructParent p1[2]); + + event TestV2DynamicArray(TestStruct indexed p0[], TestStruct p1[]); + event TestV2NestedDynamicArray(TestStructParent indexed p0[], TestStructParent p1[]); + */ + + event TestHash(string name, bytes32 hash); + + function testEvents(address p0, uint256 p1, string p2) public { + + Test(p0, p1); + TestP0(p0, p1); + TestP0P1(p0, p1); + + TestAnon(p0, p1); + TestAnonP0(p0, p1); + TestAnonP0P1(p0, p1); + + TestIndexedString(p2, p1); + + TestStruct memory testStruct; + testStruct.p0 = p0; + testStruct.p1 = p1; + + TestStructParent memory testStructParent; + testStructParent.p0 = address(uint160(p0) + 1); + testStructParent.p1 = p1 + 1; + testStructParent.child = testStruct; + + TestV2(testStruct, testStruct); + TestV2Nested(testStructParent, testStructParent); + + TestHash("TestStructKeccak256", keccak256(testStruct)); + TestHash("TestStructParentKeccak256", keccak256(testStructParent)); + } + + function testV2(TestStructParent p0) public pure returns (TestStructParent result) { + p0.p0 = address(uint160(p0.p0) + 0xf0); + p0.p1 += 0xf0; + p0.child.p0 = address(uint160(p0.child.p0) + 0x0f); + p0.child.p1 += 0x0f; + + return p0; + } + + function testSingleResult(uint32 p0) public pure returns (uint32 r0) { + r0 = p0 + 1; + } + + function testMultiResult(uint32 p0) public pure returns (uint32 r0, uint32 r1) { + r0 = p0 + 1; + r1 = p0 + 2; + } +} diff --git a/packages/tests/package.json b/packages/tests/package.json new file mode 100644 index 000000000..db4f60022 --- /dev/null +++ b/packages/tests/package.json @@ -0,0 +1,36 @@ +{ + "name": "@ethersproject/tests", + "version": "5.0.0-beta.127", + "description": "Testing package for ethers.", + "main": "index.js", + "browser": { + "@ethersproject/ethers": "./tests/browser-ethers.js" + }, + "scripts": { + "dist-phantomjs": "browserify -g @ethersproject/testcases/scripts/browser-fs.js -s tests ./tests/browser.js -o ./dist/tests.js", + "test": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", + "test-node": "mocha --no-colors --reporter tests/reporter tests/test-*.js", + "test-phantomjs": "npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js" + }, + "dependencies": { + "@ethersproject/testcases": ">5.0.0-beta.0", + "@types/mocha": "^5.2.0", + "ethers": ">5.0.0-beta.0", + "mocha-phantomjs-core": "2.1.2" + }, + "devDependencies": { + "browserify": "16.2.3", + "mocha": "^5.2.0", + "web3-providers-http": "1.0.0-beta.35" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x7b265e8157829c0398816e9965aa233c366097ed3a3b37bfbe614213eb50e2db" +} diff --git a/packages/tests/src.ts/_version.ts b/packages/tests/src.ts/_version.ts new file mode 100644 index 000000000..6508cc3a6 --- /dev/null +++ b/packages/tests/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.127"; diff --git a/packages/tests/src.ts/browser-ethers.ts b/packages/tests/src.ts/browser-ethers.ts new file mode 100644 index 000000000..1a0893491 --- /dev/null +++ b/packages/tests/src.ts/browser-ethers.ts @@ -0,0 +1,6 @@ +'use strict'; + +console.log("Using global.ethers"); + +module.exports = (global).ethers; +console.log("FOO"); diff --git a/packages/tests/src.ts/browser.ts b/packages/tests/src.ts/browser.ts new file mode 100644 index 000000000..43dc5a1b3 --- /dev/null +++ b/packages/tests/src.ts/browser.ts @@ -0,0 +1,23 @@ +'use strict'; + +import * as accounts from "./test-account"; +import * as contract from "./test-contract"; +import * as contractInterface from "./test-contract-interface"; +import * as hdnode from "./test-hdnode"; +import * as providers from "./test-providers"; +import * as utils from "./test-utils"; +import * as wallet from "./test-wallet"; +import * as wordlists from "./test-wordlists"; + +// build: require('./test-build'), + +export { + accounts, + contract, + contractInterface, + hdnode, + providers, + utils, + wallet, + wordlists, +} diff --git a/packages/tests/src.ts/reporter.ts b/packages/tests/src.ts/reporter.ts new file mode 100644 index 000000000..89ec1f95b --- /dev/null +++ b/packages/tests/src.ts/reporter.ts @@ -0,0 +1,131 @@ +'use strict'; + +function getTime(): number { + return (new Date()).getTime(); +} + +function trunc(value: number): number { + if (value >= 0) { return Math.floor(value); } + return Math.ceil(value); +} + +function getDelta(t0: number): string { + let ds = trunc((getTime() - t0) / 1000); + let minutes = trunc(ds / 60); + let seconds = String(trunc(ds) % 60); + while (seconds.length < 2) { seconds = '0' + seconds; } + return '(' + minutes + ':' + seconds + ')'; +} + +interface Suite { + title: string; + file: string; + suites: Array; + _t0: number; + _countFail: number; + _countPass: number; + _countTotal: number; +} + +interface Runner { + on(event: string, callback: (...args: Array) => void): Runner; +} + +function Reporter(runner: Runner) { + let suites: Array = []; + + let lastOutput = getTime(); + + function getIndent(): string { + let result = ''; + for (let i = 0; i < suites.length; i++) { result += ' '; } + return result; + } + + function log(message?: string): void { + if (!message) { message = ''; } + let indent = getIndent(); + console.log(indent + message); + lastOutput = getTime(); + } + + runner.on('suite', function(suite: Suite) { + if (!suite.title) { + log('Testing: Found ' + suite.suites.length + ' test suites'); + } else { + let filename = (suite.file || '').split('/').pop(); + if (filename) { filename = ' (' + filename + ')'; } + log('Test Suite: ' + suite.title + filename); + } + suites.push(suite); + suite._t0 = getTime(); + suite._countFail = 0; + suite._countPass = 0; + suite._countTotal = 0; + }); + + runner.on('suite end', function() { + let suite = suites.pop(); + let failure = ''; + if (suite._countTotal > suite._countPass) { + failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)'; + } + log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure); + log(); + if (suites.length > 0) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countFail += suite._countFail; + currentSuite._countPass += suite._countPass; + currentSuite._countTotal += suite._countTotal; + } + }); + + runner.on('test', function(test) { + let currentSuite = suites[suites.length - 1]; + if (((getTime() - lastOutput) / 1000) > 60) { + log('[ Still running suite - test #' + currentSuite._countTotal + ' ]'); + lastOutput = getTime(); + } + currentSuite._countTotal++; + }); + + runner.on('fail', function(test, error) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countFail++; + + let countFail = currentSuite._countFail; + + if (countFail > 100) { + if (countFail === 101) { + log('[ Over 100 errors; skipping remaining suite output ]'); + } + return; + } + + if (countFail > 25) { + log('Failure: ' + test.title + ' (too many errors; skipping dump)'); + return; + } + + log('Failure: ' + test.title); + error.toString().split('\n').forEach((line: string) => { + log(' ' + line); + }); + Object.keys(error).forEach(function(key) { + log(' ' + key + ': ' + error[key]); + }); + if (error.stack) { + log("Stack Trace:"); + error.stack.split('\n').forEach((line: string) => { + log(' ' + line); + }); + } + }); + + runner.on('pass', function(test) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countPass++; + }); +} + +export = Reporter; diff --git a/packages/tests/src.ts/test-account.ts b/packages/tests/src.ts/test-account.ts new file mode 100644 index 000000000..43ec1ad6f --- /dev/null +++ b/packages/tests/src.ts/test-account.ts @@ -0,0 +1,47 @@ +'use strict'; + +import assert from 'assert'; + +import { ethers } from "@ethersproject/ethers"; +import { loadTests } from "@ethersproject/testcases"; + + +type TestCase = { + name: string; + address: string; + checksumAddress: string; + icapAddress: string; + privateKey?: string; +}; + +describe('Private key generation', function() { + let tests: Array = loadTests('accounts'); + tests.forEach((test) => { + if (!test.privateKey) { return; } + it(('correctly converts private key - ' + test.name), function() { + let wallet = new ethers.Wallet(test.privateKey); + assert.equal(wallet.address.toLowerCase(), test.address.toLowerCase(), + 'correctly computes privateKey - ' + test.privateKey); + }); + }); +}); + +describe('Checksum and ICAP address generation', function() { + let tests: Array = loadTests('accounts'); + tests.forEach((test) => { + it(('correctly transforms address - ' + test.name), function() { + assert.equal(ethers.utils.getAddress(test.address), test.checksumAddress, + 'correctly computes checksum address from address'); + assert.equal(ethers.utils.getIcapAddress(test.address), test.icapAddress, + 'correctly computes ICAP address from address'); + assert.equal(ethers.utils.getAddress(test.checksumAddress), test.checksumAddress, + 'correctly computes checksum address from checksum address'); + assert.equal(ethers.utils.getIcapAddress(test.checksumAddress), test.icapAddress, + 'correctly computes ICAP address from checksum address'); + assert.equal(ethers.utils.getAddress(test.icapAddress), test.checksumAddress, + 'correctly computes checksum address from icap address'); + assert.equal(ethers.utils.getIcapAddress(test.icapAddress), test.icapAddress, + 'correctly computes ICAP address from icap address'); + }); + }); +}); diff --git a/packages/tests/src.ts/test-contract-interface.ts b/packages/tests/src.ts/test-contract-interface.ts new file mode 100644 index 000000000..7e5e52864 --- /dev/null +++ b/packages/tests/src.ts/test-contract-interface.ts @@ -0,0 +1,597 @@ +'use strict'; + +import assert from "assert"; + +import { ethers } from "@ethersproject/ethers"; +import { loadTests } from "@ethersproject/testcases"; + + +const bnify = ethers.BigNumber.from; + +function equals(actual: any, expected: any): boolean { + + // Array (treat recursively) + if (Array.isArray(actual)) { + if (!Array.isArray(expected) || actual.length !== expected.length) { return false; } + for (let i = 0; i < actual.length; i++) { + if (!equals(actual[i], expected[i])) { return false; } + } + return true; + } + + if (typeof(actual) === 'number') { actual = bnify(actual); } + if (typeof(expected) === 'number') { expected = bnify(expected); } + + // BigNumber + if (actual.eq) { + if (typeof(expected) === 'string' && expected.match(/^-?0x[0-9A-Fa-f]*$/)) { + let neg = (expected.substring(0, 1) === '-'); + if (neg) { expected = expected.substring(1); } + expected = bnify(expected); + if (neg) { expected = expected.mul(-1); } + } + if (!actual.eq(expected)) { return false; } + return true; + } + + // Uint8Array + if (expected.buffer) { + if (!ethers.utils.isHexString(actual)) { return false; } + actual = ethers.utils.arrayify(actual); + + if (!actual.buffer || actual.length !== expected.length) { return false; } + for (let i = 0; i < actual.length; i++) { + if (actual[i] !== expected[i]) { return false; } + } + + return true; + } + + // Maybe address? + try { + let actualAddress = ethers.utils.getAddress(actual); + let expectedAddress = ethers.utils.getAddress(expected); + return (actualAddress === expectedAddress); + } catch (error) { } + + // Something else + return (actual === expected); +} + + +function getValues(object: any, named?: boolean): any { + if (Array.isArray(object)) { + let result: Array = []; + object.forEach(function(object) { + result.push(getValues(object, named)); + }); + return result; + } + + switch (object.type) { + case 'number': + return bnify(object.value); + + case 'boolean': + case 'string': + return object.value; + + case 'buffer': + return ethers.utils.arrayify(object.value); + + case 'tuple': + let result: Array = getValues(object.value, named); + if (named) { + let namedResult: { [ name: string ]: any } = {}; + result.forEach((value, index) => { + namedResult['r' + String(index)] = value; + }); + return namedResult; + } + return result; + + default: + throw new Error('invalid type - ' + object.type); + } +} + +type TestCaseAbi = { + name: string; + +// interface: Array; + types: string; +// indexed: Array; +// data: string; + +// topics: Array; +// hashed: Array; + result: string; + values: string; + normalizedValues: string; +}; + +describe('ABI Coder Encoding', function() { + let coder = ethers.utils.defaultAbiCoder; + + let tests: Array = loadTests('contract-interface'); + + tests.forEach((test) => { + let values = getValues(JSON.parse(test.normalizedValues)); + let types = JSON.parse(test.types); + let result = test.result; + + let title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; + + it(('encodes paramters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + let encoded = coder.encode(types, values); + assert.equal(encoded, result, 'encoded data - ' + title); + }); + }); +}); + +describe('ABI Coder Decoding', function() { + let coder = ethers.utils.defaultAbiCoder; + + let tests: Array = loadTests('contract-interface'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.normalizedValues)); + let types = JSON.parse(test.types); + let result = test.result; + + let title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; + + it(('decodes parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + + let decoded = coder.decode(types, result); + + assert.ok(equals(decoded, values), 'decoded parameters - ' + title); + }); + }); +}); + +describe('ABI Coder ABIv2 Encoding', function() { + let coder = ethers.utils.defaultAbiCoder; + + let tests: Array = loadTests('contract-interface-abi2'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.values)); + //let namedValues = getValues(JSON.parse(test.values), true); + let types = JSON.parse(test.types); + let expected = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.values + ')'; + + it(('encodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + + let encoded = coder.encode(types, values); + assert.equal(encoded, expected, 'encoded positional parameters - ' + title); + + let namedEncoded = coder.encode(types, values); + assert.equal(namedEncoded, expected, 'encoded named parameters - ' + title); + }); + }); +}); + +describe('ABI Coder ABIv2 Decoding', function() { + + let coder = ethers.utils.defaultAbiCoder; + + let tests: Array = loadTests('contract-interface-abi2'); + + tests.forEach((test) => { + let values = getValues(JSON.parse(test.values)); + let types = JSON.parse(test.types); + let result = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.values + ')'; + + it(('decodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + + let decoded = coder.decode(types, result); + assert.ok(equals(decoded, values), 'decoded positional parameters - ' + title); + }); + }); +}); + +describe('Test Contract Events', function() { + type TestCase = { + name: string; + + interface: Array; + types: Array; + indexed: Array; + data: string; + + topics: Array; + hashed: Array; + normalizedValues: Array; + }; + + let tests: Array = loadTests('contract-events'); + + tests.forEach((test, index) => { + it(('decodes event parameters - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + + let iface = new ethers.utils.Interface(test.interface); + let parsed = iface.decodeEventLog(iface.events.testEvent, test.data, test.topics); + + test.normalizedValues.forEach((expected, index) => { + if (test.hashed[index]) { + assert.ok(equals(parsed[index].hash, expected), 'parsed event indexed parameter matches - ' + index); + } else { + assert.ok(equals(parsed[index], expected), 'parsed event parameter matches - ' + index); + } + }); + }); + }); + + tests.forEach((test, index) => { + it(('decodes event data - ' + test.name + ' - ' + test.types), function() { + this.timeout(120000); + + let iface = new ethers.utils.Interface(test.interface); + let parsed = iface.decodeEventLog(iface.events.testEvent, test.data); + + test.normalizedValues.forEach((expected, index) => { + if (test.indexed[index]) { + assert.ok((ethers.Contract.isIndexed(parsed[index]) && parsed[index].hash == null), 'parsed event data has empty Indexed - ' + index); + } else { + assert.ok(equals(parsed[index], expected), 'parsed event data matches - ' + index); + } + }); + }); + }); + +}); + +describe('Test Interface Signatures', function() { + + type TestCase = { + abi: Array; + name: string; + sigHash: string; + signature: string; + }; + + let tests: Array = loadTests('contract-signatures'); + + tests.forEach((test) => { + it('derives the correct signature - ' + test.name, function() { + let iface = new ethers.utils.Interface(test.abi); + this.timeout(120000); + + assert.equal(iface.functions.testSig.format(), test.signature, + 'derived the correct signature'); + assert.equal(iface.getSighash(iface.functions.testSig), test.sigHash, + 'derived the correct signature hash'); + }) + }); + + it('derives correct description for human-readable ABI', function() { + let iface = new ethers.utils.Interface([ "function transfer(address from, uint amount)" ]); + [ + "transfer", + "transfer(address,uint256)" + ].forEach(function(key) { + let descr = iface.functions[key]; + assert.equal(descr.name, "transfer", "incorrect name key - " + key); + assert.equal(descr.format(), "transfer(address,uint256)", "incorrect signature key - " + key); + assert.equal(iface.getSighash(descr), "0xa9059cbb", "incorrect sighash key - " + key); + }); + }); + + // See: https://github.com/ethers-io/ethers.js/issues/370 + it ('parses transaction function', function() { + let iface = new ethers.utils.Interface([ "function transfer(address from, uint amount)" ]); + + // Transaction: 0x820cc57bc77be44d8f4f024a18e18f64a8b6e62a82a3d7897db5970dbe181ba1 + let rawTx = "0xf8aa028502540be4008316e36094334eec1482109bd802d9e72a447848de3bcc106380b844a9059cbb000000000000000000000000851b9167b7cbf772d38efaf89705b35022880a070000000000000000000000000000000000000000000000000de0b6b3a764000026a03200bf26e5f10f7eda59c0aad9adc2334dda79e785b9b004342524d97a66fca9a0450b07a4dc450bb472e08f8370350fa365fcef6db1a95309ae4c06c9d0748092"; + let tx = ethers.utils.parseTransaction(rawTx); + + let descr = iface.parseTransaction(tx); + assert.equal(descr.args[0], '0x851b9167B7cbf772D38eFaf89705b35022880A07', 'parsed tx - args[0]'); + assert.equal(descr.args[1].toString(), '1000000000000000000', 'parsed tx - args[1]'); + assert.equal(descr.name, 'transfer', 'parsed tx - name'); + assert.equal(descr.signature, 'transfer(address,uint256)', 'parsed tx - signature'); + assert.equal(descr.sighash, '0xa9059cbb', 'parsed tx - sighash'); + assert.equal(descr.value.toString(), '0', 'parsed tx - value'); + }); +}); + +describe('Test Number Coder', function() { + let coder = ethers.utils.defaultAbiCoder; + + it('null input failed', function() { + this.timeout(120000); + + assert.throws(() => { + let result = coder.decode([ 'bool' ], '0x'); + console.log(result); + }, (error: Error) => { + assert.equal((error).reason, 'data out-of-bounds', 'got invalid bool'); + return true; + }, 'null bytes throws an error'); + }); + + let overflowAboveHex = '0x10000000000000000000000000000000000000000000000000000000000000000'; + let overflowBelowHex = '-0x10000000000000000000000000000000000000000000000000000000000000000'; + let maxHex = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + let maxLessOneHex = '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe' + let maxSignedHex = '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + let maxSignedLessOneHex = '0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe' + let minSignedHex = '-0x8000000000000000000000000000000000000000000000000000000000000000' + let minSignedHex2s = '0x8000000000000000000000000000000000000000000000000000000000000000' + let minMoreOneSignedHex = '-0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + let minMoreOneSignedHex2s = '0x8000000000000000000000000000000000000000000000000000000000000001' + let zeroHex = '0x0000000000000000000000000000000000000000000000000000000000000000'; + let oneHex = '0x0000000000000000000000000000000000000000000000000000000000000001'; + + it('encodes zero', function() { + let ZeroValues = [ + {n: 'number zero', v: 0}, + { n: 'hex zero', v: '0x0' }, + { n: 'hex leading even length', v: '0x0000' }, + { n: 'hex leading odd length', v: '0x00000' }, + { n: 'BigNumber', v: ethers.constants.Zero } + ]; + + let expected = zeroHex; + + ['uint8', 'uint256', 'int8', 'int256'].forEach(function(type) { + ZeroValues.forEach(function(value) { + let result = coder.encode([ type ], [ value.v ]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + + it('encodes one', function() { + let ZeroValues = [ + {n: 'number', v: 1}, + { n: 'hex', v: '0x1' }, + { n: 'hex leading even length', v: '0x0001' }, + { n: 'hex leading odd length', v: '0x00001' }, + { n: 'BigNumber', v: ethers.constants.One } + ]; + + let expected = oneHex; + + ['uint8', 'uint256', 'int8', 'int256'].forEach(function(type) { + ZeroValues.forEach(function(value) { + let result = coder.encode([ type ], [ value.v ]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + + it('encodes negative one', function() { + let Values = [ + {n: 'number', v: -1}, + { n: 'hex', v: '-0x1' }, + { n: 'hex leading even length', v: '-0x0001' }, + { n: 'hex leading odd length', v: '-0x00001' }, + { n: 'BigNumber', v: ethers.constants.NegativeOne } + ]; + + let expected = maxHex; + + ['int8', 'int256'].forEach(function(type) { + Values.forEach(function(value) { + let result = coder.encode([ type ], [ value.v ]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + + it('encodes full uint8 range', function() { + for (let i = 0; i < 256; i++) { + let expected = '0x00000000000000000000000000000000000000000000000000000000000000'; + expected += ethers.utils.hexlify(i).substring(2); + let result = coder.encode([ 'uint8' ], [ i ]); + assert.equal(result, expected, 'int8 ' + i); + } + }); + + it('encodes full int8 range', function() { + for (let i = -128; i < 128; i++) { + let expected = null; + if (i === -128) { + expected = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80'; + } else if (i < 0) { + expected = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; + expected += ethers.utils.hexlify(256 + i).substring(2); + } else { + expected = '0x00000000000000000000000000000000000000000000000000000000000000'; + expected += ethers.utils.hexlify(i).substring(2); + } + let result = coder.encode([ 'int8' ], [ i ]); + assert.equal(result, expected, 'int8 ' + i); + } + }); + + it('encodes uint256 end range', function() { + assert.equal(coder.encode([ 'uint256' ], [ bnify(maxHex) ]), maxHex, 'uint256 max'); + assert.equal(coder.encode([ 'uint256' ], [ bnify(maxLessOneHex) ]), maxLessOneHex, 'uint256 max'); + }); + + it('encodes int256 end ranges', function() { + assert.equal(coder.encode([ 'int256' ], [ bnify(maxSignedHex) ]), maxSignedHex, 'int256 max'); + assert.equal(coder.encode([ 'int256' ], [ bnify(maxSignedLessOneHex) ]), maxSignedLessOneHex, 'int256 max'); + assert.equal(coder.encode([ 'int256' ], [ bnify(minSignedHex) ]), minSignedHex2s, 'int256 max'); + assert.equal(coder.encode([ 'int256' ], [ bnify(minMoreOneSignedHex) ]), minMoreOneSignedHex2s, 'int256 max'); + }); + + it('fails to encode out-of-range uint8', function() { + [-128, -127, -2, -1, 256, 1000, bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function(value) { + + assert.throws(() => { + let result = coder.encode([ 'uint8' ], [ value ]); + console.log('RESULT', value, result); + }, (error: Error) => { + assert.equal((error).reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + + it('fails to encode out-of-range int8', function() { + [-129, -130, -1000, 128, 129, 1000, bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex).sub(1), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function(value) { + + assert.throws(() => { + let result = coder.encode([ 'int8' ], [ value ]); + console.log('RESULT', value, result); + }, (error: Error) => { + assert.equal((error).reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + + it('fails to encode out-of-range uint256', function() { + [-128, -127, -2, -1, bnify(maxHex).add(1), bnify('-' + maxHex), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function(value) { + + assert.throws(() => { + let result = coder.encode([ 'uint256' ], [ value ]); + console.log('RESULT', value, result); + }, (error: Error) => { + assert.equal((error).reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + + it('fails to encode out-of-range int256', function() { + [bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex).sub(1), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function(value, index) { + + assert.throws(() => { + let result = coder.encode([ 'int256' ], [ value ]); + console.log('RESULT', index, value, result); + }, (error: Error) => { + assert.equal((error).reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + +}); + +describe('Test Fixed Bytes Coder', function() { + let coder = ethers.utils.defaultAbiCoder; + + let zeroHex = '0x0000000000000000000000000000000000000000000000000000000000000000'; + + it('fails to encode out-of-range bytes4', function() { + ['0x', '0x00000', '0x000', zeroHex, '0x12345', '0x123456', '0x123', '0x12'].forEach(function(value, index) { + assert.throws(() => { + let result = coder.encode([ 'bytes4' ], [ value ]); + console.log('RESULT', index, value, result); + }, (error: Error) => { + if (value.length % 2) { + assert.equal((error).reason, 'hex data is odd-length', 'wrong error'); + } else { + assert.equal((error).reason, 'incorrect data length', 'wrong error'); + } + return true; + }, 'out-of-range fixed bytes throw an error'); + }); + }); + + it('fails to encode out-of-range bytes32', function() { + ['0x', '0x00000', '0x000', '0x12345', '0x123456', (zeroHex + '0'), (zeroHex + '00')].forEach(function(value, index) { + assert.throws(() => { + let result = coder.encode([ 'bytes32' ], [ value ]); + console.log('RESULT', index, value, result); + }, (error: Error) => { + if (value.length % 2) { + assert.equal((error).reason, 'hex data is odd-length', 'wrong error'); + } else { + assert.equal((error).reason, 'incorrect data length', 'wrong error'); + } + return true; + }, 'out-of-range fixed bytes throw an error'); + }); + }); +}); + +describe('Test Filters', function() { + type TestCase = { + name: string; + + args: Array; + + event: string; + signature: string; + + expected: Array + }; + + // @TODO: Add a LOT more tests here + function doTest(test: TestCase) { + it(test.name, function() { + let iface = new ethers.utils.Interface([ test.signature ]); + let eventDescription = iface.events[test.event]; + let filter = iface.encodeFilterTopics(eventDescription, test.args); + assert.equal(filter.length, test.expected.length, 'filter length matches - ' + test.name); + filter.forEach((expected, index) => { + assert.equal(expected, test.expected[index], 'signature topic matches - ' + index + ' - ' + test.name); + }); + }); + } + + let Tests: Array = [ + + // Skips null in non-indexed fields + // See: https://github.com/ethers-io/ethers.js/issues/305 + { + name: "creates correct filters for null non-indexed fields", + + args: [ null, 2, null, null ], + event: "LogSomething", + signature: "event LogSomething(int hup, int indexed two, bool three, address indexed four)", + + expected: [ + "0xf6b983969813047dce97b9ff8a48cfb0a13306eb2caae2ef186b280bc27491c8", + "0x0000000000000000000000000000000000000000000000000000000000000002" + ] + }, + + // https://etherscan.io/tx/0x820cc57bc77be44d8f4f024a18e18f64a8b6e62a82a3d7897db5970dbe181ba1 + { + name: "transfer filtering from", + + args: [ + "0x59DEa134510ebce4a0c7146595dc8A61Eb9D0D79" + ], + event: "Transfer", + signature: "event Transfer(address indexed from, address indexed to, uint value)", + + expected: [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x00000000000000000000000059dea134510ebce4a0c7146595dc8a61eb9d0d79" + ] + }, + { + name: "transfer filtering to", + + args: [ + null, + "0x851b9167B7cbf772D38eFaf89705b35022880A07" + ], + event: "Transfer", + signature: "event Transfer(address indexed from, address indexed to, uint value)", + + expected: [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + null, + "0x000000000000000000000000851b9167b7cbf772d38efaf89705b35022880a07" + ] + } + ]; + + Tests.forEach(function(test) { + doTest(test); + }); +}); diff --git a/packages/tests/src.ts/test-contract.ts b/packages/tests/src.ts/test-contract.ts new file mode 100644 index 000000000..794e0f885 --- /dev/null +++ b/packages/tests/src.ts/test-contract.ts @@ -0,0 +1,133 @@ +'use strict'; + +import assert from "assert"; + +import { ethers } from "@ethersproject/ethers"; + + +const provider = new ethers.providers.InfuraProvider('rinkeby'); + +const contract = (function() { + let data = require('../contracts/test-contract.json'); + return new ethers.Contract(data.contractAddress, data.interface, provider); +})(); + + +function equals(name: string, actual: any, expected: any): void { + if (Array.isArray(expected)) { + assert.equal(actual.length, expected.length, 'array length mismatch - ' + name); + expected.forEach(function(expected, index) { + equals(name + ':' + index, actual[index], expected); + }); + return; + } + + if (typeof(actual) === 'object') { + if (expected.indexed) { + assert.ok(ethers.Contract.isIndexed(actual), 'index property has index - ' + name); + if (expected.hash) { + assert.equal(actual.hash, expected.hash, 'index property with known hash matches - ' + name); + } + return; + } + + if (actual.eq) { + assert.ok(actual.eq(expected), 'numeric value matches - ' + name); + } + } + + assert.equal(actual, expected, 'value matches - ' + name); +} + +function TestContractEvents() { + return ethers.utils.fetchJson('https://api.ethers.io/api/v1/?action=triggerTest&address=' + contract.address).then(function(data) { + console.log(' *** Triggered Transaction Hash: ' + data.hash); + + function waitForEvent(eventName: string, expected: Array): Promise { + return new Promise(function(resolve, reject) { + contract.on(eventName, function() { + let args = Array.prototype.slice.call(arguments); + let event = args.pop(); + event.removeListener(); + equals(event.event, args, expected); + resolve(); + }); + }); + } + + return new Promise(function(resolve, reject) { + let p0 = '0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6'; + let p0_1 = '0x06b5955A67d827CdF91823e3Bb8F069e6C89C1d7'; + let p1 = 0x42; + let p1_1 = 0x43; + + return Promise.all([ + waitForEvent('Test', [ p0, p1 ]), + waitForEvent('TestP0', [ p0, p1 ]), + waitForEvent('TestP0P1', [ p0, p1 ]), + waitForEvent('TestIndexedString', [ { indexed: true, hash: '0x7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331' }, p1 ]), + waitForEvent('TestV2', [ { indexed: true }, [ p0, p1 ] ]), + waitForEvent('TestV2Nested', [ { indexed: true }, [ p0_1, p1_1, [ p0, p1 ] ] ]), + ]).then(function(result) { + resolve(); + }); + }); + }); +} + +describe('Test Contract Objects', function() { + + it('parses events', function() { + this.timeout(120000); + return TestContractEvents(); + }); + + it('ABIv2 parameters and return types work', function() { + this.timeout(120000); + let p0 = '0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6'; + let p0_0f = '0x06B5955a67d827cDF91823e3bB8F069E6c89c1e5'; + let p0_f0 = '0x06b5955a67D827CDF91823e3Bb8F069E6C89c2C6'; + let p1 = 0x42; + let p1_0f = 0x42 + 0x0f; + let p1_f0 = 0x42 + 0xf0; + + let expectedPosStruct: any = [ p0_f0, p1_f0, [ p0_0f, p1_0f ] ]; + + let seq = Promise.resolve(); + [ + [p0, p1, [ p0, p1 ] ], + { p0: p0, p1: p1, child: [ p0, p1 ] }, + [ p0, p1, { p0: p0, p1: p1 } ], + { p0: p0, p1: p1, child: { p0: p0, p1: p1 } } + ].forEach(function(struct) { + seq = seq.then(function() { + return contract.testV2(struct).then((result: any) => { + equals('position input', result, expectedPosStruct); + equals('keyword input p0', result.p0, expectedPosStruct[0]); + equals('keyword input p1', result.p1, expectedPosStruct[1]); + equals('keyword input child.p0', result.child.p0, expectedPosStruct[2][0]); + equals('keyword input child.p1', result.child.p1, expectedPosStruct[2][1]); + }); + }); + }); + + return seq; + }); + + it('collapses single argument solidity methods', function() { + this.timeout(120000); + return contract.testSingleResult(4).then((result: any) => { + assert.equal(result, 5, 'single value returned'); + }); + }); + + it('does not collapses multi argument solidity methods', function() { + this.timeout(120000); + return contract.testMultiResult(6).then((result: any) => { + assert.equal(result[0], 7, 'multi value [0] returned'); + assert.equal(result[1], 8, 'multi value [1] returned'); + assert.equal(result.r0, 7, 'multi value [r0] returned'); + assert.equal(result.r1, 8, 'multi value [r1] returned'); + }); + }); +}); diff --git a/packages/tests/src.ts/test-hdnode.ts b/packages/tests/src.ts/test-hdnode.ts new file mode 100644 index 000000000..d466c88bc --- /dev/null +++ b/packages/tests/src.ts/test-hdnode.ts @@ -0,0 +1,98 @@ +'use strict'; + +import assert from "assert"; + +import { loadTests, TestCase } from "@ethersproject/testcases"; +import { ethers } from "@ethersproject/ethers"; + +describe('Test HD Node Derivation from Seed', function() { + + let tests: Array = loadTests('hdnode'); + + tests.forEach((test) => { + + // If there is nothing to derive, skip this portion of the test + if (test.hdnodes.length === 0) { return; } + + it('Derives the HD nodes - ' + test.name, function() { + this.timeout(10000); + + let rootNode = ethers.utils.HDNode.fromSeed(test.seed); + test.hdnodes.forEach((nodeTest) => { + + let node = rootNode.derivePath(nodeTest.path); + assert.equal(node.privateKey, nodeTest.privateKey, + 'Generates privateKey - ' + nodeTest.privateKey); + + let wallet = new ethers.Wallet(node.privateKey); + assert.equal(wallet.address.toLowerCase(), nodeTest.address, + 'Generates address - ' + nodeTest.privateKey); + }); + }); + }); +}); + +describe('Test HD Node Derivation from Mnemonic', function() { + + let tests: Array = loadTests('hdnode'); + + tests.forEach((test) => { + + // If there is nothing to derive, skip this portion of the test + if (test.hdnodes.length === 0) { return; } + + it('Derives the HD nodes - ' + test.name, function() { + this.timeout(10000); + + let rootNode = ethers.utils.HDNode.fromMnemonic(test.mnemonic, test.password || null); + test.hdnodes.forEach((nodeTest) => { + + let node = rootNode.derivePath(nodeTest.path); + + assert.equal(node.privateKey, nodeTest.privateKey, + 'Matches privateKey - ' + nodeTest.privateKey); + assert.equal(node.mnemonic, test.mnemonic, + 'Matches mnemonic - ' + nodeTest.privateKey); + assert.equal(node.path, nodeTest.path, + 'Matches path - ' + nodeTest.privateKey); + + let wallet = new ethers.Wallet(node.privateKey); + assert.equal(wallet.address.toLowerCase(), nodeTest.address, + 'Generates address - ' + nodeTest.privateKey); + }); + }); + }); +}); + +describe('Test HD Mnemonic Phrases', function testMnemonic() { + + let tests: Array = loadTests('hdnode'); + + tests.forEach(function(test) { + it(('converts mnemonic phrases - ' + test.name), function() { + this.timeout(1000000); + + assert.equal(ethers.utils.mnemonicToSeed(test.mnemonic, test.password), test.seed, + 'Converts mnemonic to seed - ' + test.mnemonic + ':' + test.password); + + // Test default english + if (test.locale === "en") { + assert.equal(ethers.utils.entropyToMnemonic(test.entropy), test.mnemonic, + "Converts entropy to mnemonic " + test.name + " (default en)"); + + assert.equal(ethers.utils.mnemonicToEntropy(test.mnemonic), test.entropy, + "Converts mnemonic to entropy - " + test.mnemonic + " (default en)"); + } + + let wordlist = (<{ [ locale: string ]: ethers.Wordlist }>(ethers.wordlists))[test.locale]; + + let mnemonic = ethers.utils.entropyToMnemonic(test.entropy, wordlist); + assert.equal(mnemonic.normalize('NFKD'), test.mnemonic.normalize('NFKD'), + 'Converts entropy to mnemonic ' + test.name); + + assert.equal(ethers.utils.mnemonicToEntropy(test.mnemonic, wordlist), test.entropy, + 'Converts mnemonic to entropy - ' + test.mnemonic); + }); + }); +}); + diff --git a/packages/tests/src.ts/test-providers.ts b/packages/tests/src.ts/test-providers.ts new file mode 100644 index 000000000..503fb2d66 --- /dev/null +++ b/packages/tests/src.ts/test-providers.ts @@ -0,0 +1,505 @@ +'use strict'; + +import assert from "assert"; + +const Web3HttpProvider = require("web3-providers-http"); + +import { ethers } from "@ethersproject/ethers"; + +const bnify = ethers.BigNumber.from; + +type Dictionary = { [ key: string ]: any }; + +const blockchainData: any = { + homestead: { + balance: { + address: '0xAC1639CF97a3A46D431e6d1216f576622894cBB5', + balance: bnify('4918774100000000') + }, + block3: { + hash: '0x3d6122660cc824376f11ee842f83addc3525e2dd6756b9bcf0affa6aa88cf741', + parentHash: '0xb495a1d7e6663152ae92708da4843337b958146015a2802f4193a410044698c9', + number: 3, + timestamp: 1438270048, + nonce: '0x2e9344e0cbde83ce', + difficulty: 17154715646, + gasLimit: bnify('0x1388'), + gasUsed: bnify('0'), + miner: '0x5088D623ba0fcf0131E0897a91734A4D83596AA0', + extraData: '0x476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34', + transactions: [] + }, + transaction: { + hash: '0xccc90ab97a74c952fb3376c4a3efb566a58a10df62eb4d44a61e106fcf10ec61', + blockHash: '0x9653f180a5720f3634816eb945a6d722adee52cc47526f6357ac10adaf368135', + blockNumber: 4097745, + transactionIndex: 18, + from: '0x32DEF047DeFd076DB21A2D759aff2A591c972248', + gasPrice: bnify('0x4a817c800'), + gasLimit: bnify('0x3d090'), + to: '0x6fC21092DA55B392b045eD78F4732bff3C580e2c', + value: bnify('0x186cc6acd4b0000'), + nonce: 0, + data: '0xf2c298be000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067269636d6f6f0000000000000000000000000000000000000000000000000000', + r: '0x1e5605197a03e3f0a168f14749168dfeefc44c9228312dacbffdcbbb13263265', + s: '0x269c3e5b3558267ad91b0a887d51f9f10098771c67b82ea6cb74f29638754f54', + v: 38, + creates: null, + raw: '0xf8d2808504a817c8008303d090946fc21092da55b392b045ed78f4732bff3c580e2c880186cc6acd4b0000b864f2c298be000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067269636d6f6f000000000000000000000000000000000000000000000000000026a01e5605197a03e3f0a168f14749168dfeefc44c9228312dacbffdcbbb13263265a0269c3e5b3558267ad91b0a887d51f9f10098771c67b82ea6cb74f29638754f54', + networkId: 1 + }, + transactionReceipt: { + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + contractAddress: null, + cumulativeGasUsed: 0x1cca2e, + from: "0x18C6045651826824FEBBD39d8560584078d1b247", + gasUsed:0x14bb7, + logs: [ + { + address: "0x314159265dD8dbb310642f98f50C066173C1259b", + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + data: "0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247", + logIndex: 0x1a, + topics: [ "0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82", "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae", "0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1" ], + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39, + transactionLogIndex: 0x0 + }, + { + address: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef", + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + data: "0x000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000595a32ce", + logIndex: 0x1b, + topics: [ "0x0f0c27adfd84b60b6f456b0e87cdccb1e5fb9603991588d87fa99f5b6b61e670", "0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1", "0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247"], + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39, + transactionLogIndex: 0x1 + } + ], + logsBloom: "0x00000000000000040000000000100000010000000000000040000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000200000010000000004000000000000000000000000000000000002000000000000000000000000400000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000801000000000000000000000020000000000040000000040000000000000000002000000004000000000000000000000000000000000000000000000010000000000000000000000000000000000200000000000000000", + root: "0x9b550a9a640ce50331b64504ef87aaa7e2aaf97344acb6ff111f879b319d2590", + status: null, + to: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef", + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39 + }, + transactionReceiptByzantium: { + byzantium: true, + blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9", + blockNumber: 0x444f76, + contractAddress: null, + cumulativeGasUsed: 0x15bfe7, + from: "0x18C6045651826824FEBBD39d8560584078d1b247", + gasUsed: 0x1b968, + logs: [ + { + address: "0xb90E64082D00437e65A76d4c8187596BC213480a", + blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9", + blockNumber: 0x444f76, + data: "0x", + logIndex: 0x10, + topics: [ "0x748d071d1992ee1bfe7a39058114d0a50d5798fe8eb3a9bfb4687f024629a2ce", "0x5574aa58f7191ccab6de6cf75fe2ea0484f010b852fdd8c6b7ae151d6c2f4b83" ], + transactionHash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac", + transactionIndex: 0x1e, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000200000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000800000000000000000800000000000000000000000000000000000000", + status:1, + to: "0xb90E64082D00437e65A76d4c8187596BC213480a", + transactionHash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac", + transactionIndex: 0x1e + } + }, + kovan: { + balance: { + address: '0x09c967A0385eE3B3717779738cA0B9D116e0EcE7', + balance: bnify('997787946734641021') + }, + block3: { + hash: '0xf0ec9bf41b99a6bd1f6cd29f91302f71a1a82d14634d2e207edea4b7962f3676', + parentHash: '0xf110ecd84454f116e2222378e7bca81ac3e59be0dac96d7ec56d5ef1c3bc1d64', + number: 3, + timestamp: 1488459452, + difficulty: 131072, + gasLimit: bnify('0x5b48ec'), + gasUsed: bnify('0'), + miner: '0x00A0A24b9f0E5EC7Aa4c7389b8302fd0123194dE', + extraData: '0xd5830105048650617269747986312e31352e31826c69', + transactions: [] + }, + }, + rinkeby: { + balance: { + address: '0xd09a624630a656a7dbb122cb05e41c12c7cd8c0e', + balance: bnify('3000000000000000000') + }, + block3: { + hash: '0x9eb9db9c3ec72918c7db73ae44e520139e95319c421ed6f9fc11fa8dd0cddc56', + parentHash: '0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9', + number: 3, + timestamp: 1492010489, + nonce: '0x0000000000000000', + difficulty: 2, + gasLimit: bnify('0x47e7c4'), + gasUsed: bnify(0), + miner: '0x0000000000000000000000000000000000000000', + extraData: '0xd783010600846765746887676f312e372e33856c696e757800000000000000004e10f96536e45ceca7e34cc1bdda71db3f3bb029eb69afd28b57eb0202c0ec0859d383a99f63503c4df9ab6c1dc63bf6b9db77be952f47d86d2d7b208e77397301', + transactions: [] + }, + }, + ropsten: { + balance: { + address: '0x03a6F7a5ce5866d9A0CCC1D4C980b8d523f80480', + balance: bnify('15861113897828552666') + }, + block3: { + hash: '0xaf2f2d55e6514389bcc388ccaf40c6ebf7b3814a199a214f1203fb674076e6df', + parentHash: '0x88e8bc1dd383672e96d77ee247e7524622ff3b15c337bd33ef602f15ba82d920', + number: 3, + timestamp: 1479642588, + nonce: '0x04668f72247a130c', + difficulty: 996427, + gasLimit: bnify('0xff4033'), + gasUsed: bnify('0'), + miner: '0xD1aEb42885A43b72B518182Ef893125814811048', + extraData: '0xd883010503846765746887676f312e372e318664617277696e', + transactions: [] + }, + transactionReceipt: { + blockHash: "0xc9235b8253fce455942147aa8b450d23081b867ffbb2a1e4dec934827cd80f8f", + blockNumber: 0x1564d8, + contractAddress: null, + cumulativeGasUsed: bnify("0x80b9"), + from: "0xb346D5019EeafC028CfC01A5f789399C2314ae8D", + gasUsed: bnify("0x80b9"), + logs: [ + { + address: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c", + blockHash: "0xc9235b8253fce455942147aa8b450d23081b867ffbb2a1e4dec934827cd80f8f", + blockNumber: 0x1564d8, + data: "0x00000000000000000000000006b5955a67d827cdf91823e3bb8f069e6c89c1d6000000000000000000000000000000000000000000000000016345785d8a0000", + logIndex: 0x0, + topics:[ "0xac375770417e1cb46c89436efcf586a74d0298fee9838f66a38d40c65959ffda" ], + transactionHash: "0x55c477790b105e69e98afadf0505cbda606414b0187356137132bf24945016ce", + transactionIndex: 0x0, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000010000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + root: "0xf1c3506ab619ac1b5e8f1ca355b16d6b9a1b7436b2960b0e9ec9a91f4238b5cc", + to: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c", + transactionHash: "0x55c477790b105e69e98afadf0505cbda606414b0187356137132bf24945016ce", + transactionIndex: 0x0 + }, + transactionReceiptByzantium: { + byzantium: true, + blockHash: "0x61d343e0e081b60ac53bab381e07bdd5d0815b204091a576fd05106b814e7e1e", + blockNumber: 0x1e1e3b, + contractAddress: null, + cumulativeGasUsed: bnify("0x4142f"), + from: "0xdc8F20170C0946ACCF9627b3EB1513CFD1c0499f", + gasUsed: bnify("0x1eb6d"), + logs:[ + { + address: "0xCBf1735Aad8C4B337903cD44b419eFE6538aaB40", + blockHash: "0x61d343e0e081b60ac53bab381e07bdd5d0815b204091a576fd05106b814e7e1e", + blockNumber: 0x1e1e3b, + data: "0x000000000000000000000000b70560a43a9abf6ea2016f40a3e84b8821e134c5f6c95607c490f4f379c0160ef5c8898770f8a52959abf0e9de914647b377fa290000000000000000000000000000000000000000000000000000000000001c20000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000355524c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c6a736f6e2868747470733a2f2f6170692e6b72616b656e2e636f6d2f302f7075626c69632f5469636b65723f706169723d455448555344292e726573756c742e584554485a5553442e632e300000000000000000000000000000000000000000", + logIndex: 0x1, + topics: [ "0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84" ], + transactionHash: "0xf724f1d6813f13fb523c5f6af6261d06d41138dd094fff723e09fb0f893f03e6", + transactionIndex: 0x2, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000080000000202000000", + status: 1, + to: "0xB70560a43A9aBf6ea2016F40a3e84B8821E134c5", + transactionHash: "0xf724f1d6813f13fb523c5f6af6261d06d41138dd094fff723e09fb0f893f03e6", + transactionIndex: 0x2 + }, + }, + goerli: { + balance: { + address: "0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6", + balance: bnify("314159000000000000") + }, + block3: { + hash: '0xd5daa825732729bb0d2fd187a1b888e6bfc890f1fc5333984740d9052afb2920', + parentHash: '0xe675f1362d82cdd1ec260b16fb046c17f61d8a84808150f5d715ccce775f575e', + number: 3, + timestamp: 1548947483, + difficulty: 2, + gasLimit: bnify('10455073'), + gasUsed: bnify('0'), + miner: '0x0000000000000000000000000000000000000000', + extraData: '0x506172697479205465636820417574686f7269747900000000000000000000002822e1b202411c38084d96c84302b8361ec4840a51cd2fad9cb4bd9921cad7e64bc2e5dc7b41f3f75b33358be3aec718cf4d4317ace940e01b3581a95c9259ac01', + transactions: [] + }, + transactionReceipt: { + blockHash: '0x2384e8e8bdcf6eb87ec7c138fa503ac34adb32cac817e4b35f14d4339eaa1993', + blockNumber: 47464, + byzantium: true, + contractAddress: null, + cumulativeGasUsed: bnify(21000), + from: '0x8c1e1e5b47980D214965f3bd8ea34C413E120ae4', + gasUsed: bnify(21000), + logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + to: '0x58Bb4221245461E1d4cf886f18a01E3Df40Bd359', + transactionHash: '0xec8b1ac5d787f36c738cc7793fec606283b41f1efa69df4ae6b2a014dcd12797', + transactionIndex: 0, + logs: [], + status: 1 + } + } +} + +blockchainData['default'] = blockchainData.homestead; + +function equals(name: string, actual: any, expected: any): void { + if (expected && expected.eq) { + if (actual == null) { assert.ok(false, name + ' - actual big number null'); } + assert.ok(expected.eq(actual), name + ' matches'); + + } else if (Array.isArray(expected)) { + if (actual == null) { assert.ok(false, name + ' - actual array null'); } + assert.equal(actual.length, expected.length, name + ' array lengths match'); + for (let i = 0; i < expected.length; i++) { + equals('(' + name + ' - item ' + i + ')', actual[i], expected[i]); + } + } else if (typeof(expected) === 'object') { + if (actual == null) { + if (expected === actual) { return; } + assert.ok(false, name + ' - actual object null'); + } + + let keys: { [ key: string ]: boolean } = {}; + Object.keys(expected).forEach((key) => { keys[key] = true; }); + Object.keys(actual).forEach((key) => { keys[key] = true; }); + + Object.keys(keys).forEach((key) => { + equals('(' + name + ' - key + ' + key + ')', actual[key], expected[key]); + }); + + } else { + if (actual == null) { assert.ok(false, name + ' - actual null'); } + assert.equal(actual, expected, name + ' matches'); + } +} + +function testProvider(providerName: string, networkName: string) { + describe(('Read-Only ' + providerName + ' (' + networkName + ')'), function() { + let provider: ethers.providers.Provider = null; + if (networkName === 'default') { + if (providerName === 'getDefaultProvider') { + provider = ethers.getDefaultProvider(); + } else if (providerName === 'Web3Provider') { + let infuraUrl = (new ethers.providers.InfuraProvider()).connection.url; + provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl)); + } else { + provider = new ((ethers.providers))[providerName](); + } + } else { + if (providerName === 'getDefaultProvider') { + provider = ethers.getDefaultProvider(networkName); + } else if (providerName === 'Web3Provider') { + let infuraUrl = (new ethers.providers.InfuraProvider(networkName)).connection.url; + provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl), networkName); + } else { + provider = new ((ethers.providers))[providerName](networkName); + } + } + + it('fetches block #3', function() { + this.timeout(20000); + let test = blockchainData[networkName].block3; + return provider.getBlock(3).then(function(block) { + for (let key in test) { + equals('Block ' + key, (block)[key], test[key]); + } + }); + }); + + it('fetches address balance', function() { + // @TODO: These tests could be fiddled with if someone sends ether to our address + // We should set up a contract on each network like: + // + // contract TestBalance { + // function resetBalance() { + // assert(_owner.send(this.balance - 0.0000314159 ether)); + // } + // } + + this.timeout(100000); + let test = blockchainData[networkName].balance; + return provider.getBalance(test.address).then(function(balance) { + equals('Balance', test.balance, balance); + }); + }); + + function testTransactionReceipt(expected: Dictionary): Promise { + let title = ('Receipt ' + expected.transactionHash.substring(0, 10) + ' - '); + return provider.getTransactionReceipt(expected.transactionHash).then(function(receipt) { + + // This changes with every block + assert.equal(typeof(receipt.confirmations), 'number', 'confirmations is a number'); + delete receipt.confirmations; + + for (let key in receipt) { + equals((title + key), (receipt)[key], expected[key]); + } + //equals(('Receipt ' + expected.transactionHash.substring(0, 10)), receipt, expected); + }); + } + + if (blockchainData[networkName].transactionReceipt) { + it('fetches pre-Byzantium transaction receipt', function() { + this.timeout(100000); + return testTransactionReceipt(blockchainData[networkName].transactionReceipt); + }); + } + + if (blockchainData[networkName].transactionReceiptByzantium) { + it('fetches Byzantium transaction receipt', function() { + this.timeout(20000); + return testTransactionReceipt(blockchainData[networkName].transactionReceiptByzantium); + }); + } + + function testTransaction(expected: Dictionary): Promise { + let title = ('Transaction ' + expected.hash.substring(0, 10) + ' - '); + return provider.getTransaction(expected.hash).then((tx) => { + + // This changes with every block + assert.equal(typeof(tx.confirmations), 'number', 'confirmations is a number'); + delete tx.confirmations; + + assert.equal(typeof(tx.wait), 'function', 'wait is a function'); + delete tx.wait + + for (let key in tx) { + equals((title + key), (tx)[key], expected[key]); + } + }); + } + + if (blockchainData[networkName].transaction) { + it('fetches transaction', function() { + this.timeout(20000); + return testTransaction(blockchainData[networkName].transaction); + }); + } + + // Obviously many more cases to add here + // - getTransactionCount + // - getCode + // - getStorageAt + // - getBlockNumber + // - getGasPrice + // - estimateGas + // - sendTransaction + // - getTransaction (for other chains) + // - call + // - getLogs + // + // Many of these are tLegacyParametersested in run-providers, which uses nodeunit, but + // also creates a local private key which must then be funded to + // execute the tests. I am working on a better test contract to deploy + // to all the networks to help test these. + }); +} + +['default', 'homestead', 'ropsten', 'rinkeby', 'kovan', 'goerli'].forEach(function(networkName) { + ['getDefaultProvider', 'AlchemyProvider', 'InfuraProvider', 'EtherscanProvider', 'NodesmithProvider', 'Web3Provider'].forEach(function(providerName) { + if (networkName === "goerli" && providerName === "AlchemyProvider") { return; } + testProvider(providerName, networkName); + }); +}); +/* +function getDefaults(network, extra) { + let network = ethers.utils.getNetwork(network); + let result = { + chainId: network.chainId, + ensAddress: (network.ensAddress ? getAddress(network.ensAddress): null), + name: network.name, + testnet: (network.name !== 'homestead'), + }; + for (let key in extra) { + result[key] = extra[key]; + } + return result; +} +*/ +/* +describe('Test extra Etherscan operations', function() { + let provider = new providers.EtherscanProvider(); + it('fethces the current price of ether', function() { + this.timeout(20000); + return provider.getEtherPrice().then(function(price) { + assert.ok(typeof(price) === 'number', 'Etherscan price returns a number'); + assert.ok(price > 0.0, 'Etherscan price returns non-zero'); + }); + }); + it('fetches the history', function() { + this.timeout(100000); + return provider.getHistory('ricmoo.firefly.eth').then(function(history) { + assert.ok(history.length > 40, 'Etherscan history returns results'); + assert.equal(history[0].hash, '0xd25f550cfdff90c086a6496a84dbb2c4577df15b1416e5b3319a3e4ebb5b25d8', 'Etherscan history returns correct transaction'); + }); + }); +}); +*/ +describe('Test Basic Authentication', function() { + // https://stackoverflow.com/questions/6509278/authentication-test-servers#16756383 + + type TestCase = { + url: string; + user: string; + password: string; + allowInsecure?: boolean; + }; + + function test(name: string, url: TestCase): void { + it('tests ' + name, function() { + this.timeout(20000); + return ethers.utils.fetchJson(url).then((data) => { + assert.equal(data.authenticated, true, 'authenticates user'); + }); + }); + } + + let secure: TestCase = { + url: 'https://httpbin.org/basic-auth/user/passwd', + user: 'user', + password: 'passwd' + }; + + let insecure: TestCase = { + url: 'http://httpbin.org/basic-auth/user/passwd', + user: 'user', + password: 'passwd' + }; + + let insecureForced: TestCase = { + url: 'http://httpbin.org/basic-auth/user/passwd', + user: 'user', + password: 'passwd', + allowInsecure: true + }; + + test('secure url', secure); + test('insecure url', insecureForced); + + it('tests insecure connections fail', function() { + this.timeout(20000); + assert.throws(() => { + return ethers.utils.fetchJson(insecure); + }, (error: Error) => { + return ((error).reason === 'basic authentication requires a secure https url'); + }, 'throws an exception for insecure connections'); + }) +}); diff --git a/packages/tests/src.ts/test-utils.ts b/packages/tests/src.ts/test-utils.ts new file mode 100644 index 000000000..a95edc18f --- /dev/null +++ b/packages/tests/src.ts/test-utils.ts @@ -0,0 +1,380 @@ +'use strict'; + +import assert from 'assert'; + +import { ethers } from "@ethersproject/ethers"; +import { loadTests, TestCase } from "@ethersproject/testcases"; + +import * as utils from './utils'; + + +function equals(a: any, b: any): boolean { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; i++) { + if (!equals(a[i], b[i])) { return false; } + } + return true; + } + + return a === b; +} + +describe('Test Contract Address Generation', function() { + + // @TODO: Mine a large collection of these from the blockchain + + var getContractAddress = ethers.utils.getContractAddress; + + // Transaction: 0x939aa17985bc2a52a0c1cba9497ef09e092355a805a8150e30e24b753bac6864 + var Tests = [ + { + address: '0x3474627D4F63A678266BC17171D87f8570936622', + name: 'tx-0x939aa17985bc2a52a0c1cba9497ef09e092355a805a8150e30e24b753bac6864', + tx: { + from: '0xb2682160c482eb985ec9f3e364eec0a904c44c23', + nonce: 10, + } + }, + + // Ropsten: 0x5bdfd14fcc917abc2f02a30721d152a6f147f09e8cbaad4e0d5405d646c5c3e1 + { + address: '0x0CcCC7507aEDf9FEaF8C8D731421746e16b4d39D', + name: 'zero-nonce', + tx: { + from: '0xc6af6e1a78a6752c7f8cd63877eb789a2adb776c', + nonce: 0 + } + }, + ] + + Tests.forEach(function(test) { + it(('Computes the transaction address - ' + test.name), function() { + this.timeout(120000); + assert.equal(getContractAddress(test.tx), test.address, 'computes the transaction address'); + }); + }); +}); + +describe('Test RLP Coder', function() { + type TestCase = { + name: string, + + decoded: string, + encoded: string + }; + + const tests: Array = loadTests('rlp-coder'); + + tests.forEach(function(test) { + it(('RLP coder encoded - ' + test.name), function() { + this.timeout(120000); + assert.equal(ethers.utils.RLP.encode(test.decoded), test.encoded, 'RLP encoded - ' + test.name); + }); + }); + + tests.forEach((test: TestCase) => { + it(('RLP coder decoded - ' + test.name), function() { + this.timeout(120000); + assert.ok(equals(ethers.utils.RLP.decode(test.encoded), test.decoded), + 'RLP decoded - ' + test.name); + }); + }); +}); + +describe('Test Unit Conversion', function () { + + const tests: Array = loadTests('units'); + + tests.forEach((test) => { + let wei = ethers.BigNumber.from(test.wei); + + it (('parses ' + test.ether + ' ether'), function() { + assert.ok(ethers.utils.parseEther(test.ether.replace(/,/g, '')).eq(wei), + 'parsing ether failed - ' + test.name); + }); + + it (('formats ' + wei.toString() + ' wei to ether'), function() { + let actual = ethers.utils.formatEther(wei); + assert.equal(actual, test.ether_format, + 'formatting wei failed - ' + test.name); + }); + }); + + tests.forEach((test) => { + let wei = ethers.BigNumber.from(test.wei); + + type UnitName = 'kwei' | 'mwei' | 'gwei' | 'szabo' | 'finney' | 'satoshi' + type UnitNameFormat = 'kwei_format' | 'mwei_format' | 'gwei_format' | 'szabo_format' | 'finney_format' | 'satoshi_format' + + ['kwei', 'mwei', 'gwei', 'szabo', 'finney', 'satoshi'].forEach((name: UnitName) => { + + let unitName: string | number = name; + if (name === 'satoshi') { unitName = 8; } + + if (test[name]) { + it(('parses ' + test[name] + ' ' + name), function() { + this.timeout(120000); + assert.ok(ethers.utils.parseUnits(test[name].replace(/,/g, ''), unitName).eq(wei), + ('parsing ' + name + ' failed - ' + test.name)); + }); + } + + let expectedKey: UnitNameFormat = ((name + '_format')); + if (test[expectedKey]) { + it (('formats ' + wei.toString() + ' wei to ' + name + ')'), function() { + let actual = ethers.utils.formatUnits(wei, unitName); + let expected = test[expectedKey]; + assert.equal(actual, expected, + ('formats ' + name + ' - ' + test.name)); + }); + } + }); + }); +}); + + +describe('Test Namehash', function() { + type TestCase = { + expected: string, + name: string + }; + + const tests: Array = loadTests('namehash'); + + tests.forEach((test: TestCase) => { + it(('computes namehash - "' + test.name + '"'), function() { + this.timeout(120000); + assert.equal(ethers.utils.namehash(test.name), test.expected, + 'computes namehash(' + test.name + ')'); + }); + }); +}); + +describe('Test ID Hash Functione', function () { + type TestCase = { + expected: string, + name: string, + text: string + }; + + const tests: Array = [ + { + name: 'setAddr signature hash', + text: 'setAddr(bytes32,address)', + expected: '0xd5fa2b00b0756613052388dd576d941ba16904757996b8bb03a737ef4fd1f9ce' + } + ] + + tests.forEach((test: TestCase) => { + it(('computes id - ' + test.name), function() { + this.timeout(120000); + let actual = ethers.utils.id(test.text); + assert.equal(actual, test.expected, + 'computes id(' + test.text + ')'); + }); + }); +}); + +describe('Test Solidity Hash Functions', function() { + + type TestCase = { + keccak256: string, + sha256: string, + types: Array, + values: Array + }; + + const tests: Array = loadTests('solidity-hashes'); + + function test(funcName: string, testKey: 'keccak256' | 'sha256') { + it(('computes ' + funcName + ' correctly'), function() { + this.timeout(120000); + + tests.forEach((test, index) => { + let actual = ((ethers.utils))['solidity' + funcName](test.types, test.values); + let expected = test[testKey]; + assert.equal(actual, expected, + ('computes solidity-' + funcName + '(' + JSON.stringify(test.values) + ') - ' + test.types)); + }); + }); + } + + test('Keccak256', 'keccak256'); + test('Sha256', 'sha256'); +}); + +describe('Test Hash Functions', function() { + + const tests: Array<{ data: string, keccak256: string, sha256: string }> = loadTests('hashes'); + + it('computes keccak256 correctly', function() { + this.timeout(120000); + tests.forEach(function(test) { + assert.equal(ethers.utils.keccak256(test.data), test.keccak256, ('Keccak256 - ' + test.data)); + }); + }); + + it('computes sha2566 correctly', function() { + this.timeout(120000); + tests.forEach(function(test) { + assert.equal(ethers.utils.sha256(test.data), test.sha256, ('SHA256 - ' + test.data)); + }); + }); +}); + +describe('Test Solidity splitSignature', function() { + + it('splits a canonical signature', function() { + this.timeout(120000); + var r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; + var s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; + for (var v = 27; v <= 28; v++) { + var signature = ethers.utils.concat([ r, s, [ v ] ]); + var sig = ethers.utils.splitSignature(signature); + assert.equal(sig.r, r, 'split r correctly'); + assert.equal(sig.s, s, 'split s correctly'); + assert.equal(sig.v, v, 'split v correctly'); + } + }); + + it('splits a legacy signature', function() { + this.timeout(120000); + var r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; + var s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; + for (var v = 27; v <= 28; v++) { + var signature = ethers.utils.concat([ r, s, [ v - 27 ] ]); + var sig = ethers.utils.splitSignature(signature); + assert.equal(sig.r, r, 'split r correctly'); + assert.equal(sig.s, s, 'split s correctly'); + assert.equal(sig.v, v, 'split v correctly'); + } + }); +}); + +describe('Test Base64 coder', function() { + + // https://en.wikipedia.org/wiki/Base64#Examples + it('encodes and decodes the example from wikipedia', function() { + this.timeout(120000); + var decodedText = 'Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.'; + var decoded = ethers.utils.toUtf8Bytes(decodedText); + var encoded = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4='; + assert.equal(ethers.utils.base64.encode(decoded), encoded, 'encodes to base64 string'); + assert.equal(ethers.utils.toUtf8String(ethers.utils.base64.decode(encoded)), decodedText, 'decodes from base64 sstring'); + }); +}); + +describe('Test UTF-8 coder', function() { + var BadUTF = [ + // See: https://en.wikipedia.org/wiki/UTF-8#Overlong_encodings + { bytes: [ 0xF0,0x82, 0x82, 0xAC ], reason: 'overlong', name: 'wikipedia overlong encoded Euro sign' }, + { bytes: [ 0xc0, 0x80 ], reason: 'overlong', name: '2-byte overlong - 0xc080' }, + { bytes: [ 0xc0, 0xbf ], reason: 'overlong', name: '2-byte overlong - 0xc0bf' }, + { bytes: [ 0xc1, 0x80 ], reason: 'overlong', name: '2-byte overlong - 0xc180' }, + { bytes: [ 0xc1, 0xbf ], reason: 'overlong', name: '2-byte overlong - 0xc1bf' }, + + // Reserved UTF-16 Surrogate halves + { bytes: [ 0xed, 0xa0, 0x80 ], reason: 'utf-16 surrogate', name: 'utf-16 surrogate - U+d800' }, + { bytes: [ 0xed, 0xbf, 0xbf ], reason: 'utf-16 surrogate', name: 'utf-16 surrogate - U+dfff' }, + + // a leading byte not followed by enough continuation bytes + { bytes: [ 0xdf ], reason: 'too short', name: 'too short - 2-bytes - 0x00' }, + { bytes: [ 0xe0 ], reason: 'too short', name: 'too short - 3-bytes' }, + { bytes: [ 0xe0, 0x80 ], reason: 'too short', name: 'too short - 3-bytes with 1' }, + + { bytes: [ 0x80 ], reason: 'unexpected continuation byte', name: 'unexpected continuation byte' }, + { bytes: [ 0xc2, 0x00 ], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc200' }, + { bytes: [ 0xc2, 0x40 ], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc240' }, + { bytes: [ 0xc2, 0xc0 ], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc2c0' }, + + // Out of range + { bytes: [ 0xf4, 0x90, 0x80, 0x80 ], reason: 'out-of-range', name: 'out of range' }, + ]; + + BadUTF.forEach(function(test) { + it('toUtf8String - ' + test.name, function() { + assert.throws(function() { + var result = ethers.utils.toUtf8String(test.bytes); + console.log('Result', result); + }, function(error: Error) { + return (error.message.split(';').pop().trim() === test.reason) + }, test.name); + }); + }); + + it('toUtf8String - random conversions', function() { + this.timeout(200000); + + function randomChar(seed: string) { + switch (utils.randomNumber(seed + '-range', 0, 4)) { + case 0: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0, 0x100)); + case 1: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0, 0xd800)); + case 2: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0xdfff + 1, 0xffff)); + case 3: + var left = utils.randomNumber(seed + '-value', 0xd800, 0xdbff + 1); + var right = utils.randomNumber(seed + '-value', 0xdc00, 0xdfff + 1); + return String.fromCharCode(left, right); + } + + throw new Error('this should not happen'); + } + + function randomString(seed: string) { + var length = utils.randomNumber(seed + '-length', 1, 5); + var str = ''; + for (var i = 0; i < length; i++) { + str += randomChar(seed + '-char-' + i); + } + return str; + } + + for (var i = 0; i < 100000; i++) { + var seed = 'test-' + String(i); + var str = randomString(seed); + + var bytes = ethers.utils.toUtf8Bytes(str) + var str2 = ethers.utils.toUtf8String(bytes); + + assert.ok(Buffer.from(str).equals(Buffer.from(bytes)), 'bytes not generated correctly - ' + bytes) + assert.equal(str2, str, 'conversion not reflexive - ' + bytes); + } + }); +}); + +describe('Test Bytes32String coder', function() { + // @TODO: a LOT more test cases; generated from Solidity + it("encodes an ens name", function() { + var str = "ricmoo.firefly.eth"; + var bytes32 = ethers.utils.formatBytes32String(str); + var str2 = ethers.utils.parseBytes32String(bytes32); + assert.equal(bytes32, '0x7269636d6f6f2e66697265666c792e6574680000000000000000000000000000', 'formatted correctly'); + assert.equal(str2, str, "parsed correctly"); + }); +}); + +describe('Test BigNumber', function() { + it("computes absoltue values", function() { + function testAbs(test: { expected: string, value: string }) { + var value = ethers.BigNumber.from(test.value); + var expected = ethers.BigNumber.from(test.expected); + assert.ok(value.abs().eq(expected), 'BigNumber.abs - ' + test.value); + } + + [ + { value: "0x0", expected: "0x0" }, + { value: "-0x0", expected: "0x0" }, + { value: "0x5", expected: "0x5" }, + { value: "-0x5", expected: "0x5" }, + { value: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + ].forEach(testAbs); + }); +}); diff --git a/packages/tests/src.ts/test-wallet.ts b/packages/tests/src.ts/test-wallet.ts new file mode 100644 index 000000000..32ca7dcd2 --- /dev/null +++ b/packages/tests/src.ts/test-wallet.ts @@ -0,0 +1,278 @@ +'use strict'; + +import assert from "assert"; + +import { ethers } from "@ethersproject/ethers"; +import { loadTests } from "@ethersproject/testcases"; + +import * as utils from "./utils"; + + +describe('Test JSON Wallets', function() { + type TestCase = { + name: string; + json: string; + password: string; + address: string; + privateKey: string; + mnemonic: string; + }; + + let tests: Array = loadTests('wallets'); + tests.forEach(function(test) { + it(('decrypts wallet - ' + test.name), function() { + this.timeout(1200000); + + assert.ok((ethers.utils.getJsonWalletAddress(test.json) !== null), + 'detect encrypted JSON wallet'); + + return ethers.Wallet.fromEncryptedJson(test.json, test.password).then((wallet) => { + assert.equal(wallet.privateKey, test.privateKey, + 'generated correct private key - ' + wallet.privateKey); + assert.equal(wallet.address.toLowerCase(), test.address, + 'generate correct address - ' + wallet.address); + if (test.mnemonic) { + assert.equal(wallet.mnemonic, test.mnemonic, + 'mnemonic enabled encrypted wallet has a mnemonic'); + } + }); + }); + }); + + // A few extra test cases to test encrypting/decrypting + ['one', 'two', 'three'].forEach(function(i) { + let password = 'foobar' + i; + let wallet = ethers.Wallet.createRandom({ path: "m/56'/82", extraEntropy: utils.randomHexString('test-' + i, 32) }); + + it('encrypts and decrypts a random wallet - ' + i, function() { + this.timeout(1200000); + + return wallet.encrypt(password).then((json: string) => { + return ethers.Wallet.fromEncryptedJson(json, password).then((decryptedWallet) => { + assert.equal(decryptedWallet.address, wallet.address, + 'decrypted wallet - ' + wallet.privateKey); + assert.equal(decryptedWallet.mnemonic, wallet.mnemonic, + "decrypted wallet menonic - " + wallet.privateKey); + assert.equal(decryptedWallet.path, wallet.path, + "decrypted wallet path - " + wallet.privateKey); + return decryptedWallet.encrypt(password).then((encryptedWallet) => { + let parsedWallet = JSON.parse(encryptedWallet); + assert.equal(decryptedWallet.address.toLowerCase().substring(2), parsedWallet.address, + 're-encrypted wallet - ' + wallet.privateKey); + }); + }); + }); + }); + }); +}); + +describe('Test Transaction Signing and Parsing', function() { + type TestCase = { + name: string; + accountAddress: string; + privateKey: string; + + signedTransaction: string + unsignedTransaction: string; + + signedTransactionChainId5: string + unsignedTransactionChainId5: string; + + nonce: number; + gasLimit: string; + gasPrice: string; + to: string; + value: string; + data: string; + }; + type TestCaseKey = 'nonce' | 'gasLimit' | 'gasPrice' | 'to' | 'value' | 'data'; + + function checkTransaction(parsedTransaction: any, test: TestCase): any { + let transaction: any = { }; + + ['nonce', 'gasLimit', 'gasPrice', 'to', 'value', 'data'].forEach((key: TestCaseKey) => { + let expected = test[key]; + + let value = parsedTransaction[key]; + + if ([ "gasLimit", "gasPrice", "value"].indexOf(key) >= 0) { + assert.ok((ethers.BigNumber.isBigNumber(value)), + 'parsed into a big number - ' + key); + value = value.toHexString(); + + if (!expected || expected === '0x') { expected = '0x00'; } + + } else if (key === 'nonce') { + assert.equal(typeof(value), 'number', + 'parse into a number - nonce'); + + value = ethers.utils.hexlify(value); + + if (!expected || expected === '0x') { expected = '0x00'; } + + } else if (key === 'data') { + if (!expected) { expected = '0x'; } + + } else if (key === 'to') { + if (value) { + // Make sure the address is valid + ethers.utils.getAddress(value); + value = value.toLowerCase(); + } + } + + assert.equal(value, expected, 'parses ' + key + ' (legacy)'); + + transaction[key] = test[key]; + }); + + return transaction; + } + + + let tests: Array = loadTests('transactions'); + tests.forEach((test) => { + it(('parses and signs transaction - ' + test.name), function() { + this.timeout(120000); + + let signingKey = new ethers.utils.SigningKey(test.privateKey); + let signDigest = signingKey.signDigest.bind(signingKey); + + // Legacy parsing unsigned transaction + checkTransaction(ethers.utils.parseTransaction(test.unsignedTransaction), test); + + let parsedTransaction = ethers.utils.parseTransaction(test.signedTransaction); + let transaction = checkTransaction(parsedTransaction, test); + + // Legacy signed transaction ecrecover + assert.equal(parsedTransaction.from, ethers.utils.getAddress(test.accountAddress), + 'computed from'); + + // Legacy transaction chain ID + assert.equal(parsedTransaction.chainId, 0, 'parses chainId (legacy)'); + + // Legacy serializes unsigned transaction + (function() { + let unsignedTx = ethers.utils.serializeTransaction(transaction); + assert.equal(unsignedTx, test.unsignedTransaction, + 'serializes undsigned transaction (legacy)'); + + // Legacy signed serialized transaction + let signature = signDigest(ethers.utils.keccak256(unsignedTx)); + assert.equal(ethers.utils.serializeTransaction(transaction, signature), test.signedTransaction, + 'signs transaction (legacy)'); + })(); + + + // EIP155 + + // EIP-155 parsing unsigned transaction + let parsedUnsignedTransactionChainId5 = ethers.utils.parseTransaction(test.unsignedTransactionChainId5); + checkTransaction(parsedUnsignedTransactionChainId5, test); + assert.equal(parsedUnsignedTransactionChainId5.chainId, 5, 'parses chainId (eip155)'); + + // EIP-155 fields + let parsedTransactionChainId5 = ethers.utils.parseTransaction(test.signedTransactionChainId5); + + type TxStringKey = 'data' | 'from' | 'nonce' | 'to'; + ['data', 'from', 'nonce', 'to'].forEach((key: TxStringKey) => { + assert.equal(parsedTransaction[key], parsedTransactionChainId5[key], + 'parses ' + key + ' (eip155)'); + }); + + type TxNumberKey = 'gasLimit' | 'gasPrice' | 'value'; + ['gasLimit', 'gasPrice', 'value'].forEach((key: TxNumberKey) => { + assert.ok(parsedTransaction[key].eq(parsedTransactionChainId5[key]), + 'parses ' + key + ' (eip155)'); + }); + + // EIP-155 chain ID + assert.equal(parsedTransactionChainId5.chainId, 5, + 'parses chainId (eip155)'); + + transaction.chainId = 5; + + (function() { + // EIP-155 serialized unsigned transaction + let unsignedTx = ethers.utils.serializeTransaction(transaction); + assert.equal(unsignedTx, test.unsignedTransactionChainId5, + 'serializes unsigned transaction (eip155) '); + + // EIP-155 signed serialized transaction + let signature = signDigest(ethers.utils.keccak256(unsignedTx)); + assert.equal(ethers.utils.serializeTransaction(transaction, signature), test.signedTransactionChainId5, + 'signs transaction (eip155)'); + })(); + + }); + }); +}); + +describe('Test Signing Messages', function() { + type TestCase = { + address: string; + name: string; + message: string | Uint8Array; + messageHash: string; + privateKey: string; + signature: string; + } + + let tests: Array = [ + // See: https://etherscan.io/verifySig/57 + { + address: '0x14791697260E4c9A71f18484C9f997B308e59325', + name: 'string("hello world")', + message: 'hello world', + messageHash: '0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68', + privateKey: '0x0123456789012345678901234567890123456789012345678901234567890123', + signature: '0xddd0a7290af9526056b4e35a077b9a11b513aa0028ec6c9880948544508f3c63265e99e47ad31bb2cab9646c504576b3abc6939a1710afc08cbf3034d73214b81c' + }, + + // See: https://github.com/ethers-io/ethers.js/issues/80 + { + address: '0xD351c7c627ad5531Edb9587f4150CaF393c33E87', + name: 'bytes(0x47173285...4cb01fad)', + message: ethers.utils.arrayify('0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad'), + messageHash: '0x93100cc9477ba6522a2d7d5e83d0e075b167224ed8aa0c5860cfd47fa9f22797', + privateKey: '0x51d1d6047622bca92272d36b297799ecc152dc2ef91b229debf84fc41e8c73ee', + signature: '0x546f0c996fa4cfbf2b68fd413bfb477f05e44e66545d7782d87d52305831cd055fc9943e513297d0f6755ad1590a5476bf7d1761d4f9dc07dfe473824bbdec751b' + }, + + // See: https://github.com/ethers-io/ethers.js/issues/85 + { + address: '0xe7deA7e64B62d1Ca52f1716f29cd27d4FE28e3e1', + name: 'zero-prefixed signature', + message: ethers.utils.arrayify(ethers.utils.id('0x7f23b5eed5bc7e89f267f339561b2697faab234a2')), + messageHash: '0x06c9d148d268f9a13d8f94f4ce351b0beff3b9ba69f23abbf171168202b2dd67', + privateKey: '0x09a11afa58d6014843fd2c5fd4e21e7fadf96ca2d8ce9934af6b8e204314f25c', + signature: '0x7222038446034a0425b6e3f0cc3594f0d979c656206408f937c37a8180bb1bea047d061e4ded4aeac77fa86eb02d42ba7250964ac3eb9da1337090258ce798491c' + } + ]; + + tests.forEach(function(test) { + it(('signs a message "' + test.name + '"'), function() { + this.timeout(120000); + let wallet = new ethers.Wallet(test.privateKey); + return wallet.signMessage(test.message).then(function(signature: string) { + assert.equal(signature, test.signature, 'computes message signature'); + }); + }); + }); + + tests.forEach(function(test) { + it(('verifies a message "' + test.name + '"'), function() { + this.timeout(120000); +// let address = ethers.utils.verifyMessage(test.message, test.signature); +// assert.equal(address, test.address, 'verifies message signature'); + }); + }); + + tests.forEach(function(test) { + it(('hashes a message "' + test.name + '"'), function() { + this.timeout(120000); + let hash = ethers.utils.hashMessage(test.message); + assert.equal(hash, test.messageHash, 'calculates message hash'); + }); + }); +}); diff --git a/packages/tests/src.ts/test-wordlists.ts b/packages/tests/src.ts/test-wordlists.ts new file mode 100644 index 000000000..827aaeb94 --- /dev/null +++ b/packages/tests/src.ts/test-wordlists.ts @@ -0,0 +1,36 @@ +'use strict'; + +import assert from 'assert'; + +import { ethers } from "@ethersproject/ethers"; +import { loadTests, TestCase } from "@ethersproject/testcases"; + + +function checkWordlist(content: string, wordlist: ethers.Wordlist): void { + let words = content.split('\n'); + it('matches wordlists for ' + wordlist.locale, function() { + for (let i = 0; i < 2048; i++) { + let actual = wordlist.getWord(i); + let expected = words[i]; + assert.equal(actual, expected, 'failed to match word ' + i + ': ' + words[i] + ' !=' + wordlist.getWord(i)); + } + }); +} + +describe('Check Wordlists', function() { + let tests: Array = loadTests("wordlists"); + tests.forEach((test) => { + let wordlist = (<{ [ locale: string ]: ethers.Wordlist }>(ethers.wordlists))[test.locale]; + checkWordlist(test.content, wordlist); + }); +/* + checkWordlist('./wordlists/lang-es.txt', ethers.wordlists.es); + checkWordlist('./wordlists/lang-fr.txt', ethers.wordlists.fr); + checkWordlist('./wordlists/lang-it.txt', ethers.wordlists.it); + checkWordlist('./wordlists/lang-ja.txt', ethers.wordlists.ja); + checkWordlist('./wordlists/lang-ko.txt', ethers.wordlists.ko); + checkWordlist('./wordlists/lang-zh_cn.txt', ethers.wordlists.zh); + checkWordlist('./wordlists/lang-zh_cn.txt', ethers.wordlists.zh_cn); + checkWordlist('./wordlists/lang-zh_tw.txt', ethers.wordlists.zh_tw); +*/ +}); diff --git a/packages/tests/src.ts/utils.ts b/packages/tests/src.ts/utils.ts new file mode 100644 index 000000000..a4473d276 --- /dev/null +++ b/packages/tests/src.ts/utils.ts @@ -0,0 +1,68 @@ +'use strict'; + +import { ethers } from "@ethersproject/ethers"; + +function randomBytes(seed: string, lower: number, upper?: number): Uint8Array { + if (!upper) { upper = lower; } + + if (upper === 0 && upper === lower) { return new Uint8Array(0); } + + let result = ethers.utils.arrayify(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(seed))); + while (result.length < upper) { + result = ethers.utils.concat([result, ethers.utils.keccak256(ethers.utils.concat([seed, result]))]); + } + + let top = ethers.utils.arrayify(ethers.utils.keccak256(result)); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + + return result.slice(0, lower + Math.floor((upper - lower) * percent)); +} + +function randomHexString(seed: string, lower: number, upper?: number): string { + return ethers.utils.hexlify(randomBytes(seed, lower, upper)); +} + +function randomNumber(seed: string, lower: number, upper: number): number { + let top = randomBytes(seed, 3); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return lower + Math.floor((upper - lower) * percent); +} + +function equals(a: any, b: any): boolean { + + // Array (treat recursively) + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) { return false; } + for (let i = 0; i < a.length; i++) { + if (!equals(a[i], b[i])) { return false; } + } + return true; + } + + // BigNumber + if (a.eq) { + if (!b.eq || !a.eq(b)) { return false; } + return true; + } + + // Uint8Array + if (a.buffer) { + if (!b.buffer || a.length !== b.length) { return false; } + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } + } + + return true; + } + + // Something else + return a === b; +} + +export { + randomBytes, + randomHexString, + randomNumber, + + equals +} diff --git a/packages/tests/test.html b/packages/tests/test.html new file mode 100644 index 000000000..dea329d61 --- /dev/null +++ b/packages/tests/test.html @@ -0,0 +1,50 @@ + + + + Ethers Test Suite + + + + + + +
+ + + + + + + + + + + + + + + + + diff --git a/packages/tests/thirdparty.d.ts b/packages/tests/thirdparty.d.ts new file mode 100644 index 000000000..89e90f32c --- /dev/null +++ b/packages/tests/thirdparty.d.ts @@ -0,0 +1,6 @@ +declare module "web3-providers-http" { + export class Web3HttpProvider { + constructor(url: string | number); + } + export default Web3HttpProvider; +} diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json new file mode 100644 index 000000000..1fb196964 --- /dev/null +++ b/packages/tests/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./tests" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/transactions/.npmignore b/packages/transactions/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/transactions/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/transactions/LICENSE.md b/packages/transactions/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/transactions/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/transactions/README.md b/packages/transactions/README.md new file mode 100644 index 000000000..3ed096c2f --- /dev/null +++ b/packages/transactions/README.md @@ -0,0 +1,17 @@ +Ethereum Transaction Utilities +============================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/transactions/package.json b/packages/transactions/package.json new file mode 100644 index 000000000..2ba5ab682 --- /dev/null +++ b/packages/transactions/package.json @@ -0,0 +1,30 @@ +{ + "name": "@ethersproject/transactions", + "version": "5.0.0-beta.125", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/rlp": ">5.0.0-beta.0", + "@ethersproject/signing-key": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xcaa03dc68a8040bf26aedad67d79f8d0b49800290842ddd2874cfa56ba3f6a50" +} diff --git a/packages/transactions/src.ts/_version.ts b/packages/transactions/src.ts/_version.ts new file mode 100644 index 000000000..08381ee67 --- /dev/null +++ b/packages/transactions/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.125"; diff --git a/packages/transactions/src.ts/index.ts b/packages/transactions/src.ts/index.ts new file mode 100644 index 000000000..a856c202c --- /dev/null +++ b/packages/transactions/src.ts/index.ts @@ -0,0 +1,204 @@ +"use strict"; + +import { getAddress } from "@ethersproject/address"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { arrayify, BytesLike, hexDataSlice, hexlify, hexZeroPad, SignatureLike, splitSignature, stripZeros, } from "@ethersproject/bytes"; +import { Zero } from "@ethersproject/constants"; +import * as errors from "@ethersproject/errors"; +import { keccak256 } from "@ethersproject/keccak256"; +import { checkProperties } from "@ethersproject/properties"; +import * as RLP from "@ethersproject/rlp"; +import { computePublicKey, recoverPublicKey } from "@ethersproject/signing-key"; + +/////////////////////////////// +// Exported Types + +export type UnsignedTransaction = { + to?: string; + nonce?: number; + + gasLimit?: BigNumberish; + gasPrice?: BigNumberish; + + data?: BytesLike; + value?: BigNumberish; + chainId?: number; +} + +export interface Transaction { + hash?: string; + + to?: string; + from?: string; + nonce: number; + + gasLimit: BigNumber; + gasPrice: BigNumber; + + data: string; + value: BigNumber; + chainId: number; + + r?: string; + s?: string; + v?: number; +} + +/////////////////////////////// + +function handleAddress(value: string): string { + if (value === "0x") { return null; } + return getAddress(value); +} + +function handleNumber(value: string): BigNumber { + if (value === "0x") { return Zero; } + return BigNumber.from(value); +} + +const transactionFields = [ + { name: "nonce", maxLength: 32 }, + { name: "gasPrice", maxLength: 32 }, + { name: "gasLimit", maxLength: 32 }, + { name: "to", length: 20 }, + { name: "value", maxLength: 32 }, + { name: "data" }, +]; + +const allowedTransactionKeys: { [ key: string ]: boolean } = { + chainId: true, data: true, gasLimit: true, gasPrice:true, nonce: true, to: true, value: true +} + +export function computeAddress(key: BytesLike | string): string { + let publicKey = computePublicKey(key); + return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12)); +} + +export function recoverAddress(digest: BytesLike, signature: SignatureLike): string { + return computeAddress(recoverPublicKey(arrayify(digest), signature)); +} + + +export function serialize(transaction: UnsignedTransaction, signature?: SignatureLike): string { + checkProperties(transaction, allowedTransactionKeys); + + let raw: Array = []; + + transactionFields.forEach(function(fieldInfo) { + let value = (transaction)[fieldInfo.name] || ([]); + value = arrayify(hexlify(value)); + + // Fixed-width field + if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { + errors.throwError("invalid length for " + fieldInfo.name, errors.INVALID_ARGUMENT, { arg: ("transaction" + fieldInfo.name), value: value }); + } + + // Variable-width (with a maximum) + if (fieldInfo.maxLength) { + value = stripZeros(value); + if (value.length > fieldInfo.maxLength) { + errors.throwError("invalid length for " + fieldInfo.name, errors.INVALID_ARGUMENT, { arg: ("transaction" + fieldInfo.name), value: value }); + } + } + + raw.push(hexlify(value)); + }); + + if (transaction.chainId != null && transaction.chainId !== 0) { + raw.push(hexlify(transaction.chainId)); + raw.push("0x"); + raw.push("0x"); + } + + let unsignedTransaction = RLP.encode(raw); + + // Requesting an unsigned transation + if (!signature) { + return unsignedTransaction; + } + + // The splitSignature will ensure the transaction has a recoveryParam in the + // case that the signTransaction function only adds a v. + let sig = splitSignature(signature); + + // We pushed a chainId and null r, s on for hashing only; remove those + let v = 27 + sig.recoveryParam + if (raw.length === 9) { + raw.pop(); + raw.pop(); + raw.pop(); + v += transaction.chainId * 2 + 8; + } + + raw.push(hexlify(v)); + raw.push(stripZeros(arrayify(sig.r))); + raw.push(stripZeros(arrayify(sig.s))); + + return RLP.encode(raw); +} + +export function parse(rawTransaction: BytesLike): Transaction { + let transaction = RLP.decode(rawTransaction); + if (transaction.length !== 9 && transaction.length !== 6) { + errors.throwError("invalid raw transaction", errors.INVALID_ARGUMENT, { arg: "rawTransactin", value: rawTransaction }); + } + + let tx: Transaction = { + nonce: handleNumber(transaction[0]).toNumber(), + gasPrice: handleNumber(transaction[1]), + gasLimit: handleNumber(transaction[2]), + to: handleAddress(transaction[3]), + value: handleNumber(transaction[4]), + data: transaction[5], + chainId: 0 + }; + + // Legacy unsigned transaction + if (transaction.length === 6) { return tx; } + + try { + tx.v = BigNumber.from(transaction[6]).toNumber(); + + } catch (error) { + console.log(error); + return tx; + } + + tx.r = hexZeroPad(transaction[7], 32); + tx.s = hexZeroPad(transaction[8], 32); + + if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) { + // EIP-155 unsigned transaction + tx.chainId = tx.v; + tx.v = 0; + + } else { + // Signed Tranasaction + + tx.chainId = Math.floor((tx.v - 35) / 2); + if (tx.chainId < 0) { tx.chainId = 0; } + + let recoveryParam = tx.v - 27; + + let raw = transaction.slice(0, 6); + + if (tx.chainId !== 0) { + raw.push(hexlify(tx.chainId)); + raw.push("0x"); + raw.push("0x"); + recoveryParam -= tx.chainId * 2 + 8; + } + + let digest = keccak256(RLP.encode(raw)); + try { + tx.from = recoverAddress(digest, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam: recoveryParam }); + } catch (error) { + console.log(error); + } + + tx.hash = keccak256(rawTransaction); + } + + return tx; +} + diff --git a/packages/transactions/tsconfig.json b/packages/transactions/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/transactions/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/units/.npmignore b/packages/units/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/units/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/units/LICENSE.md b/packages/units/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/units/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/units/README.md b/packages/units/README.md new file mode 100644 index 000000000..bc3633540 --- /dev/null +++ b/packages/units/README.md @@ -0,0 +1,17 @@ +Ethereum Unit Conversion Utilities +================================== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/units/package.json b/packages/units/package.json new file mode 100644 index 000000000..a998ffd9a --- /dev/null +++ b/packages/units/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ethersproject/units", + "version": "5.0.0-beta.124", + "description": "Unit conversion functions for Ethereum.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/constants": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers", + "units", + "conversion" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x4b7e5d4cda519e6e142a2653feae62f677464dc4e4c82e6bb1241f77afc9c36b" +} diff --git a/packages/units/src.ts/_version.ts b/packages/units/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/units/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/units/src.ts/index.ts b/packages/units/src.ts/index.ts new file mode 100644 index 000000000..0e9ca3a3c --- /dev/null +++ b/packages/units/src.ts/index.ts @@ -0,0 +1,82 @@ +"use strict"; + +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { formatFixed, parseFixed } from "@ethersproject/bignumber/fixednumber"; +import * as errors from "@ethersproject/errors"; + + +const names = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", +]; + + +// Some environments have issues with RegEx that contain back-tracking, so we cannot +// use them. +export function commify(value: string | number): string { + let comps = String(value).split("."); + + if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { + errors.throwError("invalid value", errors.INVALID_ARGUMENT, { argument: "value", value: value }); + } + + // Make sure we have at least one whole digit (0 if none) + let whole = comps[0]; + + let negative = ""; + if (whole.substring(0, 1) === "-") { + negative = "-"; + whole = whole.substring(1); + } + + // Make sure we have at least 1 whole digit with no leading zeros + while (whole.substring(0, 1) === "0") { whole = whole.substring(1); } + if (whole === "") { whole = "0"; } + + let suffix = ""; + if (comps.length === 2) { suffix = "." + (comps[1] || "0"); } + + let formatted = []; + while (whole.length) { + if (whole.length <= 3) { + formatted.unshift(whole); + break; + } else { + let index = whole.length - 3; + formatted.unshift(whole.substring(index)); + whole = whole.substring(0, index); + } + } + + return negative + formatted.join(",") + suffix; +} + +export function formatUnits(value: BigNumberish, unitName?: string | BigNumberish): string { + if (typeof(unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { unitName = 3 * index; } + } + return formatFixed(value, (unitName != null) ? unitName: 18); +} + +export function parseUnits(value: string, unitName?: BigNumberish): BigNumber { + if (typeof(unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { unitName = 3 * index; } + } + return parseFixed(value, (unitName != null) ? unitName: 18); +} + +export function formatEther(wei: BigNumberish): string { + return formatUnits(wei, 18); +} + +export function parseEther(ether: string): BigNumber { + return parseUnits(ether, 18); +} + diff --git a/packages/units/tsconfig.json b/packages/units/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/units/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/wallet/.npmignore b/packages/wallet/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/wallet/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/wallet/LICENSE.md b/packages/wallet/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/wallet/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/wallet/README.md b/packages/wallet/README.md new file mode 100644 index 000000000..ea997424e --- /dev/null +++ b/packages/wallet/README.md @@ -0,0 +1,17 @@ +Ethereum Wallet +=============== + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/wallet/package.json b/packages/wallet/package.json new file mode 100644 index 000000000..616f963b4 --- /dev/null +++ b/packages/wallet/package.json @@ -0,0 +1,36 @@ +{ + "name": "@ethersproject/wallet", + "version": "5.0.0-beta.126", + "description": "Error utility functions for ethers.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/abstract-provider": ">5.0.0-beta.0", + "@ethersproject/abstract-signer": ">5.0.0-beta.0", + "@ethersproject/address": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">5.0.0-beta.0", + "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/hash": ">5.0.0-beta.0", + "@ethersproject/hdnode": ">5.0.0-beta.0", + "@ethersproject/json-wallets": ">5.0.0-beta.0", + "@ethersproject/keccak256": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/random": ">5.0.0-beta.0", + "@ethersproject/signing-key": ">5.0.0-beta.0", + "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/wordlists": ">5.0.0-beta.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0xd686eb36478b47f97c2355ddd7d6197ea7e78ef744b98f18054c1c9dbf3510d6" +} diff --git a/packages/wallet/src.ts/_version.ts b/packages/wallet/src.ts/_version.ts new file mode 100644 index 000000000..10730de6c --- /dev/null +++ b/packages/wallet/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.126"; diff --git a/packages/wallet/src.ts/index.ts b/packages/wallet/src.ts/index.ts new file mode 100644 index 000000000..42dbc6377 --- /dev/null +++ b/packages/wallet/src.ts/index.ts @@ -0,0 +1,161 @@ +"use strict"; + +import { getAddress } from "@ethersproject/address"; +import { Provider, TransactionRequest } from "@ethersproject/abstract-provider"; +import { ExternallyOwnedAccount, Signer } from "@ethersproject/abstract-signer"; +import { arrayify, Bytes, BytesLike, concat, hexDataSlice, isHexString, joinSignature, SignatureLike } from "@ethersproject/bytes"; +import * as errors from "@ethersproject/errors"; +import { hashMessage } from "@ethersproject/hash"; +import { defaultPath, HDNode, entropyToMnemonic } from "@ethersproject/hdnode"; +import { keccak256 } from "@ethersproject/keccak256"; +import { defineReadOnly, isNamedInstance, resolveProperties } from "@ethersproject/properties"; +import { randomBytes } from "@ethersproject/random"; +import { SigningKey } from "@ethersproject/signing-key"; +import { decryptJsonWallet, encryptKeystore, ProgressCallback } from "@ethersproject/json-wallets"; +import { computeAddress, recoverAddress, serialize } from "@ethersproject/transactions"; +import { Wordlist } from "@ethersproject/wordlists/wordlist"; + +function isAccount(value: any): value is ExternallyOwnedAccount { + return (value != null && isHexString(value.privateKey, 32) && value.address != null); +} + +export class Wallet extends Signer implements ExternallyOwnedAccount { + + readonly address: string; + readonly provider: Provider; + + readonly path: string; + + // Wrapping the _signingKey and _mnemonic in a getter function prevents + // leaking the private key in console.log; still, be careful! :) + readonly _signingKey: () => SigningKey; + readonly _mnemonic: () => string; + + constructor(privateKey: BytesLike | ExternallyOwnedAccount | SigningKey, provider?: Provider) { + errors.checkNew(new.target, Wallet); + + super(); + + if (isAccount(privateKey)) { + let signingKey = new SigningKey(privateKey.privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + + if (this.address !== getAddress(privateKey.address)) { + errors.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + } + + if (privateKey.mnemonic != null) { + let mnemonic = privateKey.mnemonic; + let path = privateKey.path || defaultPath; + defineReadOnly(this, "_mnemonic", () => mnemonic); + defineReadOnly(this, "path", privateKey.path); + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + if (computeAddress(node.privateKey) !== this.address) { + errors.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + } + } else { + defineReadOnly(this, "_mnemonic", (): string => null); + defineReadOnly(this, "path", null); + } + + + } else { + if (isNamedInstance(SigningKey, privateKey)) { + defineReadOnly(this, "_signingKey", () => privateKey); + } else { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + } + defineReadOnly(this, "_mnemonic", (): string => null); + defineReadOnly(this, "path", null); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + } + + if (provider && !isNamedInstance(Provider, provider)) { + errors.throwError("invalid provider", errors.INVALID_ARGUMENT, { + argument: "provider", + value: provider + }); + } + + defineReadOnly(this, "provider", provider || null); + } + + get mnemonic(): string { return this._mnemonic(); } + get privateKey(): string { return this._signingKey().privateKey; } + get publicKey(): string { return this._signingKey().publicKey; } + + getAddress(): Promise { + return Promise.resolve(this.address); + } + + connect(provider: Provider): Wallet { + return new Wallet(this, provider); + } + + signTransaction(transaction: TransactionRequest): Promise { + return resolveProperties(transaction).then((tx) => { + if (tx.from != null) { + if (getAddress(tx.from) !== this.address) { + throw new Error("transaction from address mismatch"); + } + delete tx.from; + } + + let signature = this._signingKey().signDigest(keccak256(serialize(tx))); + return serialize(tx, signature); + }); + } + + signMessage(message: Bytes | string): Promise { + return Promise.resolve(joinSignature(this._signingKey().signDigest(hashMessage(message)))); + } + + encrypt(password: Bytes | string, options?: any, progressCallback?: ProgressCallback): Promise { + if (typeof(options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + + if (progressCallback && typeof(progressCallback) !== "function") { + throw new Error("invalid callback"); + } + + if (!options) { options = {}; } + + return encryptKeystore(this, password, options, progressCallback); + } + + + /** + * Static methods to create Wallet instances. + */ + static createRandom(options?: any): Wallet { + let entropy: Uint8Array = randomBytes(16); + + if (!options) { options = { }; } + + if (options.extraEntropy) { + entropy = arrayify(hexDataSlice(keccak256(concat([ entropy, options.extraEntropy ])), 0, 16)); + } + + let mnemonic = entropyToMnemonic(entropy, options.locale); + return Wallet.fromMnemonic(mnemonic, options.path, options.locale); + } + + static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise { + return decryptJsonWallet(json, password, progressCallback).then((account) => { + return new Wallet(account); + }); + } + + static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet { + if (!path) { path = defaultPath; } + return new Wallet(HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + } +} + +export function verifyMessage(message: Bytes | string, signature: SignatureLike): string { + return recoverAddress(hashMessage(message), signature); +} diff --git a/packages/wallet/tsconfig.json b/packages/wallet/tsconfig.json new file mode 100644 index 000000000..f8b22b29e --- /dev/null +++ b/packages/wallet/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/web/.gitignore b/packages/web/.gitignore new file mode 100644 index 000000000..6d5a3baaf --- /dev/null +++ b/packages/web/.gitignore @@ -0,0 +1 @@ +browser-xmlhttprequest.d.ts diff --git a/packages/web/.npmignore b/packages/web/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/web/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/web/LICENSE.md b/packages/web/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/web/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/web/README.md b/packages/web/README.md new file mode 100644 index 000000000..16efcd0c4 --- /dev/null +++ b/packages/web/README.md @@ -0,0 +1,17 @@ +Web Utilities +============= + +**EXPERIMENTAL** + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +License +------- + +MIT License diff --git a/packages/web/package.json b/packages/web/package.json new file mode 100644 index 000000000..78a5be3b2 --- /dev/null +++ b/packages/web/package.json @@ -0,0 +1,29 @@ +{ + "name": "@ethersproject/web", + "version": "5.0.0-beta.124", + "description": "Error utility functions for ethers.", + "main": "index.js", + "browser": { + "xmlhttprequest": "./browser-xmlhttprequest.js" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@ethersproject/base64": ">5.0.0-beta.0", + "@ethersproject/errors": ">5.0.0-beta.0", + "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/strings": ">5.0.0-beta.0", + "xmlhttprequest": "1.8.0" + }, + "keywords": [ + "Ethereum", + "ethers" + ], + "author": "Richard Moore ", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "tarballHash": "0x99cdd9c80d988aedf6bedc30316fb519b36b4c86aadb4fd0fe6f6bf71bb2c138" +} diff --git a/packages/web/src.ts/_version.ts b/packages/web/src.ts/_version.ts new file mode 100644 index 000000000..4c7b329a3 --- /dev/null +++ b/packages/web/src.ts/_version.ts @@ -0,0 +1 @@ +export const version = "5.0.0-beta.124"; diff --git a/packages/web/src.ts/browser-xmlhttprequest.ts b/packages/web/src.ts/browser-xmlhttprequest.ts new file mode 100644 index 000000000..21cb7e121 --- /dev/null +++ b/packages/web/src.ts/browser-xmlhttprequest.ts @@ -0,0 +1,8 @@ +"use strict"; + +try { + module.exports.XMLHttpRequest = XMLHttpRequest; +} catch(error) { + console.log("Warning: XMLHttpRequest is not defined"); + module.exports.XMLHttpRequest = null; +} diff --git a/packages/web/src.ts/index.ts b/packages/web/src.ts/index.ts new file mode 100644 index 000000000..03799de7d --- /dev/null +++ b/packages/web/src.ts/index.ts @@ -0,0 +1,247 @@ +"use strict"; + +import { XMLHttpRequest } from "xmlhttprequest"; + +import { encode as base64Encode } from "@ethersproject/base64"; +import * as errors from "@ethersproject/errors"; +import { shallowCopy } from "@ethersproject/properties"; +import { toUtf8Bytes } from "@ethersproject/strings"; + + +// Exported Types +export type ConnectionInfo = { + url: string, + user?: string, + password?: string, + allowInsecure?: boolean, + timeout?: number, + headers?: { [key: string]: string | number } +}; + +export interface OnceBlockable { + once(eventName: "block", handler: () => void): void; +} + +export type PollOptions = { + timeout?: number, + floor?: number, + ceiling?: number, + interval?: number, + retryLimit?: number, + onceBlock?: OnceBlockable +}; + + + +type Header = { key: string, value: string }; + +export function fetchJson(connection: string | ConnectionInfo, json?: string, processFunc?: (value: any) => any): Promise { + let headers: { [key: string]: Header } = { }; + + let url: string = null; + + let timeout = 2 * 60 * 1000; + + if (typeof(connection) === "string") { + url = connection; + + } else if (typeof(connection) === "object") { + if (connection.url == null) { + errors.throwError("missing URL", errors.MISSING_ARGUMENT, { arg: "url" }); + } + + url = connection.url; + + if (typeof(connection.timeout) === "number" && connection.timeout > 0) { + timeout = connection.timeout; + } + + if (connection.headers) { + for (let key in connection.headers) { + headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; + } + } + + if (connection.user != null && connection.password != null) { + if (url.substring(0, 6) !== "https:" && connection.allowInsecure !== true) { + errors.throwError( + "basic authentication requires a secure https url", + errors.INVALID_ARGUMENT, + { arg: "url", url: url, user: connection.user, password: "[REDACTED]" } + ); + } + + let authorization = connection.user + ":" + connection.password; + headers["authorization"] = { + key: "Authorization", + value: "Basic " + base64Encode(toUtf8Bytes(authorization)) + }; + } + } + + return new Promise(function(resolve, reject) { + let request = new XMLHttpRequest(); + + let timer: any = null; + timer = setTimeout(() => { + if (timer == null) { return; } + timer = null; + + reject(new Error("timeout")); + setTimeout(() => { + request.abort(); + }, 0); + }, timeout); + + let cancelTimeout = () => { + if (timer == null) { return; } + clearTimeout(timer); + timer = null; + } + + if (json) { + request.open("POST", url, true); + headers["content-type"] = { key: "Content-Type", value: "application/json" }; + } else { + request.open("GET", url, true); + } + + Object.keys(headers).forEach((key) => { + let header = headers[key]; + request.setRequestHeader(header.key, header.value); + }); + + request.onreadystatechange = function() { + if (request.readyState !== 4) { return; } + + if (request.status != 200) { + cancelTimeout(); + // @TODO: not any! + let error: any = new Error("invalid response - " + request.status); + error.statusCode = request.status; + if (request.responseText) { + error.responseText = request.responseText; + } + reject(error); + return; + } + + let result: any = null; + try { + result = JSON.parse(request.responseText); + } catch (error) { + cancelTimeout(); + // @TODO: not any! + let jsonError: any = new Error("invalid json response"); + jsonError.orginialError = error; + jsonError.responseText = request.responseText; + if (json != null) { + jsonError.requestBody = json; + } + jsonError.url = url; + reject(jsonError); + return; + } + + if (processFunc) { + try { + result = processFunc(result); + } catch (error) { + cancelTimeout(); + error.url = url; + error.body = json; + error.responseText = request.responseText; + reject(error); + return; + } + } + + cancelTimeout(); + resolve(result); + }; + + request.onerror = function(error) { + cancelTimeout(); + reject(error); + } + + try { + if (json != null) { + request.send(json); + } else { + request.send(); + } + + } catch (error) { + cancelTimeout(); + // @TODO: not any! + let connectionError: any = new Error("connection error"); + connectionError.error = error; + reject(connectionError); + } + }); +} + +export function poll(func: () => Promise, options?: PollOptions): Promise { + if (!options) { options = {}; } + options = shallowCopy(options); + if (options.floor == null) { options.floor = 0; } + if (options.ceiling == null) { options.ceiling = 10000; } + if (options.interval == null) { options.interval = 250; } + + return new Promise(function(resolve, reject) { + + let timer: any = null; + let done: boolean = false; + + // Returns true if cancel was successful. Unsuccessful cancel means we're already done. + let cancel = (): boolean => { + if (done) { return false; } + done = true; + if (timer) { clearTimeout(timer); } + return true; + }; + + if (options.timeout) { + timer = setTimeout(() => { + if (cancel()) { reject(new Error("timeout")); } + }, options.timeout) + } + + let retryLimit = options.retryLimit; + + let attempt = 0; + function check() { + return func().then(function(result) { + + // If we have a result, or are allowed null then we're done + if (result !== undefined) { + if (cancel()) { resolve(result); } + + } else if (options.onceBlock) { + options.onceBlock.once("block", check); + + // Otherwise, exponential back-off (up to 10s) our next request + } else if (!done) { + attempt++; + if (attempt > retryLimit) { + if (cancel()) { reject(new Error("retry limit reached")); } + return; + } + + let timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); + if (timeout < options.floor) { timeout = options.floor; } + if (timeout > options.ceiling) { timeout = options.ceiling; } + + setTimeout(check, timeout); + } + + return null; + }, function(error) { + if (cancel()) { reject(error); } + }); + } + check(); + }); +} + diff --git a/packages/web/thirdparty.d.ts b/packages/web/thirdparty.d.ts new file mode 100644 index 000000000..72a8f6c18 --- /dev/null +++ b/packages/web/thirdparty.d.ts @@ -0,0 +1,17 @@ +declare module "xmlhttprequest" { + export class XMLHttpRequest { + readyState: number; + status: number; + responseText: string; + + constructor(); + open(method: string, url: string, async?: boolean): void; + setRequestHeader(key: string, value: string): void; + send(body?: string): void; + abort(): void; + + onreadystatechange: () => void; + onerror: (error: Error) => void; + } +} + diff --git a/packages/web/tsconfig.json b/packages/web/tsconfig.json new file mode 100644 index 000000000..026fe496a --- /dev/null +++ b/packages/web/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.package.json", + "compilerOptions": { + "rootDir": "./src.ts", + "outDir": "./" + }, + "include": [ + "./thirdparty.d.ts", + "./src.ts/*" + ], + "exclude": [ ] +} + diff --git a/packages/wordlists/.npmignore b/packages/wordlists/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/wordlists/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/wordlists/LICENSE.md b/packages/wordlists/LICENSE.md new file mode 100644 index 000000000..989e34a72 --- /dev/null +++ b/packages/wordlists/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Richard Moore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/wordlists/README.md b/packages/wordlists/README.md new file mode 100644 index 000000000..a752ea3fd --- /dev/null +++ b/packages/wordlists/README.md @@ -0,0 +1,36 @@ +BIP39 Wordlists +=============== + +**EXPERIMENTAL** + +Supported Languages: +- **en** - English +- **es** - Spanish +- **fr** - French +- **it** - Italian +- **ja** - Japanese +- **ko** - Korean +- **zh_cn** - Chinese (simplified) +- **zh_tw** - Chinese (traditional) + +Please see the [ethers](https://github.com/ethers-io/ethers.js) repository +for more informations. + +API +--- + +`@TODO` + +Browser +------- + +In the browser distribution file, only the English word list is included in the +root `ethers` pacakge. To include additional word lists, they must be added using +additional `