Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into nh/web3-4x-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Aug 8, 2022
2 parents 29671cc + e7dfcde commit 514a291
Show file tree
Hide file tree
Showing 43 changed files with 447 additions and 263 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ packages/truffle/$RECYCLE.BIN/
packages/debugger/.tmp

# @truffle/contract
packages/contract/dist
packages/contract/browser-dist
11 changes: 11 additions & 0 deletions packages/abi-utils/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": ["../../.eslintrc.package.json"],
"overrides": [
{
"files": ["./lib/**/*.test.[tj]s"],
"env": {
"jest": true
}
}
]
}
2 changes: 1 addition & 1 deletion packages/abi-utils/lib/arbitrary.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testProp } from "jest-fast-check";
import { testProp } from "@fast-check/jest";
import * as abiSchema from "@truffle/contract-schema/spec/abi.spec.json";
import { matchers } from "jest-json-schema";

Expand Down
8 changes: 5 additions & 3 deletions packages/abi-utils/lib/arbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ export const ConstructorEntry = () =>
type: fc.constant("constructor"),
inputs: fc.array(Parameter(), { maxLength: 10 }).filter(inputs => {
// names that are not blank should be unique
const names = inputs.map(({ name }) => name).filter(name => name !== "");
const names = inputs
.map(({ name }) => name)
.filter(name => name !== "");
return names.length === new Set(names).size;
})
}),
Expand Down Expand Up @@ -248,7 +250,7 @@ const Type: fc.Memo<string> = fc.memo(n =>

const ArrayFixed = fc.memo(n =>
fc
.tuple(Type(n - 1), fc.integer(1, 256))
.tuple(Type(n - 1), fc.integer({ min: 1, max: 256 }))
.map(([type, length]) => `${type}[${length}]`)
);

Expand Down Expand Up @@ -405,7 +407,7 @@ const fakerToArb = (template: string, transform = camelCase) => {
};

const ParameterName = () =>
fc.frequency(
fc.oneof(
{ arbitrary: fakerToArb("{{hacker.noun}}"), weight: 9 },
{ arbitrary: fc.constant(""), weight: 1 }
);
Expand Down
6 changes: 2 additions & 4 deletions packages/abi-utils/lib/normalize.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "jest-extended";
import { testProp } from "jest-fast-check";
import { testProp } from "@fast-check/jest";

import * as Arbitrary from "./arbitrary";

Expand Down Expand Up @@ -48,9 +48,7 @@ describe("normalize", () => {

expect(
abi.filter(({ type }) => type !== "event" && type !== "error")
).toSatisfyAll(
entry => "stateMutability" in entry
);
).toSatisfyAll(entry => "stateMutability" in entry);
}
);

Expand Down
6 changes: 3 additions & 3 deletions packages/abi-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
"dependencies": {
"change-case": "3.0.2",
"faker": "5.5.3",
"fast-check": "2.15.1"
"fast-check": "3.1.1"
},
"devDependencies": {
"@fast-check/jest": "^1.0.1",
"@truffle/contract-schema": "^3.4.8",
"@types/faker": "^5.1.2",
"@types/jest": "27.4.1",
"@types/jest-json-schema": "^2.1.2",
"jest": "28.1.3",
"jest-extended": "^0.11.5",
"jest-fast-check": "2.0.0",
"jest-json-schema": "^2.1.0",
"ts-jest": "28.0.6",
"ts-jest": "28.0.7",
"ts-node": "10.7.0",
"typescript": "^4.1.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"types": ["node", "jest"], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
Expand Down
4 changes: 2 additions & 2 deletions packages/artifactor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "4.0.163",
"version": "4.0.164",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
Expand All @@ -27,7 +27,7 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@truffle/contract": "^4.5.19",
"@truffle/contract": "^4.5.20",
"@types/fs-extra": "^8.1.0",
"@types/lodash": "^4.14.179",
"@types/node": "12.12.21",
Expand Down
3 changes: 2 additions & 1 deletion packages/codec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "0.13.3",
"version": "0.14.0",
"main": "dist/lib/index.js",
"files": [
"dist"
Expand Down Expand Up @@ -47,6 +47,7 @@
"@types/semver": "^6.0.0",
"@types/utf8": "^2.1.6",
"@zerollup/ts-transform-paths": "^1.7.3",
"ts-node": "10.7.0",
"ttypescript": "1.5.13",
"typedoc": "0.20.37",
"typedoc-plugin-remove-references": "^0.0.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/compile-solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "6.0.37",
"version": "6.0.38",
"main": "dist/index.js",
"scripts": {
"build": "ttsc",
Expand All @@ -38,9 +38,9 @@
"solc": "0.8.15"
},
"devDependencies": {
"@truffle/artifactor": "^4.0.163",
"@truffle/artifactor": "^4.0.164",
"@truffle/box": "^2.1.54",
"@truffle/resolver": "^9.0.10",
"@truffle/resolver": "^9.0.11",
"babel-core": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/compile-vyper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "3.1.72",
"version": "3.1.73",
"main": "index.js",
"scripts": {
"prepare": "exit 0",
Expand All @@ -23,7 +23,7 @@
"@truffle/config": "^1.3.34",
"@truffle/contract-sources": "^0.2.0",
"@truffle/profiler": "^0.1.26",
"@truffle/resolver": "^9.0.10",
"@truffle/resolver": "^9.0.11",
"colors": "1.4.0",
"debug": "^4.3.1",
"lodash": "^4.17.21",
Expand Down
6 changes: 3 additions & 3 deletions packages/contract-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "0.1.100",
"version": "0.1.101",
"scripts": {
"prepare": "exit 0",
"test": "./scripts/test.sh",
Expand All @@ -22,8 +22,8 @@
},
"devDependencies": {
"@truffle/blockchain-utils": "^0.1.3",
"@truffle/compile-solidity": "^6.0.37",
"@truffle/contract": "^4.5.19",
"@truffle/compile-solidity": "^6.0.38",
"@truffle/contract": "^4.5.20",
"bignumber.js": "^7.2.1",
"chai": "^4.2.0",
"debug": "^4.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"version": "4.5.19",
"version": "4.5.20",
"main": "index.js",
"scripts": {
"build": "yarn compile",
Expand All @@ -24,7 +24,7 @@
"@ensdomains/ensjs": "^2.1.0",
"@truffle/blockchain-utils": "^0.1.3",
"@truffle/contract-schema": "^3.4.8",
"@truffle/debug-utils": "^6.0.29",
"@truffle/debug-utils": "^6.0.30",
"@truffle/error": "^0.1.0",
"@truffle/interface-adapter": "^0.5.20",
"bignumber.js": "^7.2.1",
Expand Down
91 changes: 90 additions & 1 deletion packages/core/lib/command-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const globalCommandOptions = require("./global-command-options");
const debugModule = require("debug");
const debug = debugModule("core:command:run");
const commands = require("./commands/commands");
const Web3 = require("web3");

const defaultHost = "127.0.0.1";
const managedGanacheDefaultPort = 9545;
const managedGanacheDefaultNetworkId = 5777;
const managedDashboardDefaultPort = 24012;

// this function takes an object with an array of input strings, an options
// object, and a boolean determining whether we allow inexact matches for
Expand Down Expand Up @@ -206,9 +212,92 @@ const displayGeneralHelp = () => {
.showHelp();
};

/**
* This is a function to configure the url from the user specified network settings in the config.
* @param {TruffleConfig} customConfig - Default config with user specified settings.
* @param {boolean} isDashboardNetwork - Check if the network is dashboard or not.
* @returns a string with the configured url
*/
const getConfiguredNetworkUrl = function (customConfig, isDashboardNetwork) {
const defaultPort = isDashboardNetwork
? managedDashboardDefaultPort
: managedGanacheDefaultPort;
const configuredNetworkOptions = {
host: customConfig.host || defaultHost,
port: customConfig.port || defaultPort
};
const urlSuffix = isDashboardNetwork ? "/rpc" : "";
return `http://${configuredNetworkOptions.host}:${configuredNetworkOptions.port}${urlSuffix}`;
};

/**
* This is a function to derive the config environment from the user specified settings.
* @param {TruffleConfig} detectedConfig - Default config with user specified settings.
* @param {string} network - Network name specified with the `--network` option.
* @param {string} url - URL specified with the `--url` option.
* @returns a TruffleConfig object with the user specified settings in the config
*/
const deriveConfigEnvironment = function (detectedConfig, network, url) {
let configuredNetwork;

const configDefinesProvider =
detectedConfig.networks[network] &&
detectedConfig.networks[network].provider;

if (configDefinesProvider) {
// Use "provider" specified in the config to connect to the network
// along with the other network properties
configuredNetwork = {
network_id: "*",
...detectedConfig.networks[network]
};
} else if (url) {
// Use "url" to configure network (implies not "develop" and not "dashboard")
configuredNetwork = {
network_id: "*",
url,
provider: function () {
return new Web3.providers.HttpProvider(url, {
keepAlive: false
});
}
};
} else {
// Otherwise derive network settings
const customConfig = detectedConfig.networks[network] || {};
const isDashboardNetwork = network === "dashboard";
const configuredNetworkUrl = getConfiguredNetworkUrl(
customConfig,
isDashboardNetwork
);
const defaultNetworkId = isDashboardNetwork
? "*"
: managedGanacheDefaultNetworkId;

configuredNetwork = {
network_id: customConfig.network_id || defaultNetworkId,
provider: function () {
return new Web3.providers.HttpProvider(configuredNetworkUrl, {
keepAlive: false
});
},
// customConfig will spread only when it is defined and ignored when undefined
...customConfig
};
}

detectedConfig.networks[network] = {
...configuredNetwork
};

return detectedConfig;
};

module.exports = {
displayGeneralHelp,
getCommand,
prepareOptions,
runCommand
runCommand,
getConfiguredNetworkUrl,
deriveConfigEnvironment
};
2 changes: 1 addition & 1 deletion packages/core/lib/configAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function configureManagedGanache(config, networkConfig, mnemonic) {
gasPrice,
time: genesisTime,
miner: {
instamine: "strict"
instamine: "eager"
}
};

Expand Down

0 comments on commit 514a291

Please sign in to comment.