From e8028d0e73368257b76b394bb8e2bf63f8aecd71 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 12:25:17 -0400 Subject: [PATCH] Updated TypeScript version. --- admin/cmds/update-exports.js | 20 +++++++++ package.json | 5 ++- packages/address/src.ts/index.ts | 6 +-- packages/bignumber/src.ts/bignumber.ts | 14 +++--- packages/cli/package.json | 6 ++- packages/ethers/src.ts/index.ts | 59 +++++++++++++++++++++++++- packages/providers/package.json | 4 +- packages/random/package.json | 4 +- rollup.config.js | 16 +++++-- 9 files changed, 111 insertions(+), 23 deletions(-) create mode 100644 admin/cmds/update-exports.js diff --git a/admin/cmds/update-exports.js b/admin/cmds/update-exports.js new file mode 100644 index 00000000..0d16f9e3 --- /dev/null +++ b/admin/cmds/update-exports.js @@ -0,0 +1,20 @@ +"use strict"; + +const fs = require("fs"); +const { resolve } = require("path"); + +const sourceEthers = fs.readFileSync(resolve(__dirname, "../../packages/ethers/src.ts/ethers.ts")).toString(); +const targets = sourceEthers.match(/export\s*{\s*((.|\s)*)}/)[1].trim(); + +const output = `"use strict"; + +import * as ethers from "./ethers"; + +export { ethers }; + +export { + ${ targets } +} from "./ethers"; +`; + +fs.writeFileSync(resolve(__dirname, "../../packages/ethers/src.ts/index.ts"), output); diff --git a/package.json b/package.json index b71bbc04..b0da4890 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", "build": "tsc --build ./tsconfig.project.json", "clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json", - "_dist_prepare": "npm run clean && npm run bootstrap && npm run build", + "_dist_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js", "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", @@ -27,6 +27,7 @@ "devDependencies": { "@types/assert": "^1.4.1", "@types/mocha": "^5.2.0", + "@types/node": "^12.7.4", "aes-js": "3.0.0", "browserify": "16.2.3", "diff": "4.0.1", @@ -38,7 +39,7 @@ "scrypt-js": "2.0.4", "semver": "^5.6.0", "tar": "4.4.8", - "typescript": "3.3.3", + "typescript": "3.6.2", "rollup": "1.20.1", "rollup-plugin-commonjs": "10.0.2", "rollup-plugin-json": "4.0.0", diff --git a/packages/address/src.ts/index.ts b/packages/address/src.ts/index.ts index 2fcdebe0..1d5a226d 100644 --- a/packages/address/src.ts/index.ts +++ b/packages/address/src.ts/index.ts @@ -1,7 +1,7 @@ "use strict"; // We use this for base 36 maths -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { arrayify, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes"; import { BigNumberish } from "@ethersproject/bignumber"; @@ -106,7 +106,7 @@ export function getAddress(address: string): string { logger.throwArgumentError("bad icap checksum", "address", address); } - result = (new BN.BN(address.substring(4), 36)).toString(16); + result = (new BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = "0" + result; } result = getChecksumAddress("0x" + result); @@ -126,7 +126,7 @@ export function isAddress(address: string): boolean { } export function getIcapAddress(address: string): string { - let base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + let base36 = (new BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } return "XE" + ibanChecksum("XE00" + base36) + base36; } diff --git a/packages/bignumber/src.ts/bignumber.ts b/packages/bignumber/src.ts/bignumber.ts index d8829edf..8550f867 100644 --- a/packages/bignumber/src.ts/bignumber.ts +++ b/packages/bignumber/src.ts/bignumber.ts @@ -8,7 +8,7 @@ * */ -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { Bytes, Hexable, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; @@ -154,7 +154,7 @@ export class BigNumber implements Hexable { } if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + return new BigNumber(_constructorGuard, toHex(new BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); @@ -200,7 +200,7 @@ export class BigNumber implements Hexable { } // Normalize the hex string -function toHex(value: string | BN.BN): string { +function toHex(value: string | BN): string { // For BN, call on the hex string if (typeof(value) !== "string") { @@ -242,16 +242,16 @@ function toHex(value: string | BN.BN): string { return value; } -function toBigNumber(value: BN.BN): BigNumber { +function toBigNumber(value: BN): BigNumber { return BigNumber.from(toHex(value)); } -function toBN(value: BigNumberish): BN.BN { +function toBN(value: BigNumberish): BN { let hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); + return (new BN("-" + hex.substring(3), 16)); } - return new BN.BN(hex.substring(2), 16); + return new BN(hex.substring(2), 16); } function throwFault(fault: string, operation: string, value?: any): never { diff --git a/packages/cli/package.json b/packages/cli/package.json index c4fdfefc..22707696 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -12,7 +12,6 @@ "ethers-ts": "./lib/bin/ethers-ts.js" }, "dependencies": { - "@types/node": "10.3.2", "@ethersproject/basex": ">=5.0.0-beta.127", "ethers": ">=5.0.0-beta.156", "mime-types": "2.1.11", @@ -20,6 +19,9 @@ "solc": "0.5.10", "solidity-parser-antlr": "^0.3.2" }, + "devDependencies": { + "@types/node": "^12.7.4" + }, "keywords": [ "Ethereum", "ethers", @@ -36,5 +38,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x045c7d61113b060ecb79426c442a9bcc28c3ed5baebd6c324b8c5ccdd83aa39c" + "tarballHash": "0x7224b7a62cd2554bab3585709e8016fc4a7672c33c568dcbdfbf63d838c18283" } diff --git a/packages/ethers/src.ts/index.ts b/packages/ethers/src.ts/index.ts index b7fc3fe0..74141c45 100644 --- a/packages/ethers/src.ts/index.ts +++ b/packages/ethers/src.ts/index.ts @@ -4,4 +4,61 @@ import * as ethers from "./ethers"; export { ethers }; -export * from "./ethers"; +export { + Signer, + + Wallet, + VoidSigner, + + getDefaultProvider, + providers, + + Contract, + ContractFactory, + + BigNumber, + FixedNumber, + + constants, + errors, + + logger, + + utils, + + wordlists, + + + //////////////////////// + // Compile-Time Constants + + version, + + + //////////////////////// + // Types + + ContractFunction, + ContractReceipt, + ContractTransaction, + Event, + EventFilter, + + Overrides, + PayableOverrides, + CallOverrides, + + ContractInterface, + + BigNumberish, + + Bytes, + BytesLike, + + Signature, + + Transaction, + UnsignedTransaction, + + Wordlist +} from "./ethers"; diff --git a/packages/providers/package.json b/packages/providers/package.json index bc779947..c00884f7 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -28,7 +28,7 @@ "@ethersproject/web": ">=5.0.0-beta.129" }, "devDependencies": { - "@types/node": "10.3.2" + "@types/node": "^12.7.4" }, "keywords": [ "Ethereum", @@ -45,5 +45,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x655b117ac21836fcd5bed6025dbd53583596f141bc2b67b833342f60e37038d4" + "tarballHash": "0xc0b5e1a60b427d64d93f366727dc57777d24bfd92b8ddeb6408b367a7780f045" } diff --git a/packages/random/package.json b/packages/random/package.json index aa7b0131..c956d7f5 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -12,7 +12,7 @@ "@ethersproject/logger": ">=5.0.0-beta.129" }, "devDependencies": { - "@types/node": "10.3.2" + "@types/node": "^12.7.4" }, "keywords": [ "Ethereum", @@ -30,5 +30,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x45c2e53529bd3cf7b1ba4bbbe448813aa2540b792fab4db7bdfbac9c204f1d7e" + "tarballHash": "0x884bc62b2feb8949cbbf59bb1fea3ca8c671ab16149e1688d74b9f1bd360e89c" } diff --git a/rollup.config.js b/rollup.config.js index fba61512..771e55fa 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -12,8 +12,15 @@ function Replacer(options = {}) { return { name: "file-replacer", transform(code, id) { - //console.log(id, code.length); + /* + console.log("------"); + console.log("NAME", id, id.match("node-resolve:empty.js$")); + console.log(code); + console.log("------"); + */ + if (!filter(id)) { return null; } + for (let i = 0; i < suffixes.length; i++) { const suffix = suffixes[i]; if (id.match(new RegExp(suffix))) { @@ -21,7 +28,8 @@ function Replacer(options = {}) { let newCode = options.replace[suffix]; console.log(`Replace: ${ id } (${ code.length } => ${ newCode.length })`); return { - code: newCode + code: newCode, + map: { mappings: '' } }; } } @@ -89,8 +97,8 @@ export default commandLineArgs => { namedExports: { "bn.js": [ "BN" ], "elliptic": [ "ec" ] - } - }) + }, + }), ]; if (minify) {