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

Dependency update: Bump web3 to version 1.2.2 & implement typings #2558

Merged
merged 58 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
523e6d0
Bump web3 to version 1.2.2
eggplantzzz Oct 24, 2019
4b66872
Regenerate yarn.lock
eggplantzzz Oct 25, 2019
f42aae3
Merge in develop branch
eggplantzzz Oct 29, 2019
eb769b8
rm @types/web3 path ref (box/tsconfig)
CruzMolina Nov 4, 2019
36636da
rm @types/web3 path ref (artifactor/tsconfig)
CruzMolina Nov 4, 2019
c0516ed
rm @types/web3 path ref (decode-utils/tsconfig)
CruzMolina Nov 4, 2019
bd0d76f
rm @types/web3 path ref (blockchain-utils/tsconfig)
CruzMolina Nov 4, 2019
fd4ca1a
rm @types/web3 path ref (code-utils/tsconfig)
CruzMolina Nov 4, 2019
98f343d
updated yarn.lock
CruzMolina Nov 4, 2019
9611f38
yarn remove @types/web3 (decoder)
CruzMolina Nov 4, 2019
1554a18
rm @types/web3 path refs (decoder/tsconfig)
CruzMolina Nov 4, 2019
150b027
rm @types/web3 typeRoots ref (blockchain-utils/tsconfig)
CruzMolina Nov 4, 2019
049c353
yarn remove @types/web3 (blockchain-utils)
CruzMolina Nov 4, 2019
534c121
yarn remove @types/web3 (decode-utils)
CruzMolina Nov 4, 2019
ae12178
rm @types/web3 path refs (interface-adapter/tsconfig)
CruzMolina Nov 4, 2019
1033937
yarn remove @types/web3 (interface-adapter)
CruzMolina Nov 4, 2019
4d3084f
yarn add -D @types/node web3-core-helpers (blockchain-utils)
CruzMolina Nov 5, 2019
44497df
add paths ref for Net module typings (blockchain-utils/tsconfig)
CruzMolina Nov 5, 2019
7b02eef
import Provider typings from web3-core-helpers (blockchain-utils/index)
CruzMolina Nov 5, 2019
e728f41
create union Provider type (blockchain-utils/index)
CruzMolina Nov 5, 2019
0cc7101
pull out JsonRpcResponse interface from @types/web3 (blockchain-utils…
CruzMolina Nov 5, 2019
d2f7061
pull out Callback interface from @types/web3 (blockchain-utils/index)
CruzMolina Nov 5, 2019
2d99351
adjust JsonRpcResponse vars for correct camelCasing (blockchain-utils…
CruzMolina Nov 5, 2019
68594a5
mv typings into type def file & import appropriately (blockchain-utils)
CruzMolina Nov 5, 2019
31f7f1b
import & use typings from @truffle/blockchain-utils (hdwallet-provide…
CruzMolina Nov 5, 2019
3421325
import & use typings from @truffle/blockchain-utils (hdwallet-provide…
CruzMolina Nov 5, 2019
ff8b743
yarn add @truffle/blockchain-utils (hdwallet-provider)
CruzMolina Nov 5, 2019
41f31d1
incl blockchain-utils typings in typeRoots (hdwallet-provider/tsconfig)
CruzMolina Nov 5, 2019
330dcef
yarn remove web3 && yarn add -D web3 (hdwallet-provider)
CruzMolina Nov 5, 2019
9e4ac63
mv more typings into type def file & import appropriately (blockchain…
CruzMolina Nov 5, 2019
3d14ddd
Merge branch 'develop' into update-web3-types
CruzMolina Nov 5, 2019
8f94ebe
swap out web3-core-helpers devDep for web3-providers-http, web3-provi…
CruzMolina Nov 5, 2019
fe28f60
import & apply class provider typings (blockchain-utils/typings/index)
CruzMolina Nov 5, 2019
63ad9ce
yarn add web3-eth @truffle/blockchain-utils for typings (interface-ad…
CruzMolina Nov 5, 2019
b6c8461
update & add typeRoots path for @truffle/blockchain-utils/typings (in…
CruzMolina Nov 5, 2019
a7085e4
update typing imports (interface-adapter/lib/interface-adapter)
CruzMolina Nov 5, 2019
0b46fad
add EvmBlockType typing (interface-adapter/lib/interface-adapter)
CruzMolina Nov 5, 2019
91bc8c3
update typings (interface-adapter/lib/web3-interface-adapter)
CruzMolina Nov 5, 2019
3e49dca
update typings (interface-adapter/lib/ethereum-overloads)
CruzMolina Nov 5, 2019
d177f98
update typings (interface-adapter/lib/web3-shim)
CruzMolina Nov 5, 2019
61d2133
add @ts-ignore to allow empty Web3 constructor (interface-adapter/lib…
CruzMolina Nov 5, 2019
b414ef2
yarn add @truffle/blockchain-utils web3-core for typings (decoder)
CruzMolina Nov 5, 2019
94df58c
update typing imports (decoder/lib/interface/contract-decoder)
CruzMolina Nov 5, 2019
376bf2c
add BlockType typing (decoder/lib/interface/contract-decoder)
CruzMolina Nov 5, 2019
8f5e4c2
add @ts-ignore's to bypass web3 typings (decoder/lib/interface/contra…
CruzMolina Nov 5, 2019
7380a90
update typing import (decoder/lib/interface/index)
CruzMolina Nov 5, 2019
21141b3
update typeRoots paths for new typings (decoder/tsconfig)
CruzMolina Nov 5, 2019
ae2a1e1
updated yarn.lock
CruzMolina Nov 5, 2019
a2cc65f
add @ts-ignore to allow empty Web3 constructor call (hdwallet-provide…
CruzMolina Nov 5, 2019
a10a1d4
type getBlockNumber callback (hdwallet-provider/test/provider)
CruzMolina Nov 5, 2019
3c75cc5
rm duplicate typeRoots path to lodash.merge (packages/decoder/tsconfig)
CruzMolina Nov 6, 2019
e647059
rm web3-core dep & update tsconfig path ref (decoder)
CruzMolina Nov 6, 2019
3938d22
rm web3-eth dep & update tsconfig path ref (interface-adapter)
CruzMolina Nov 6, 2019
41e740d
pull out Web3 provider typings & mv from @truffle/blockchain-utils to…
CruzMolina Nov 7, 2019
e8a97d6
update paths related to Web3 provider typings re-org
CruzMolina Nov 7, 2019
416923b
update deps for Web3 provider typings re-org
CruzMolina Nov 7, 2019
edd5337
export Web3 provider typings (provider)
CruzMolina Nov 7, 2019
66764d7
fix missing web3 dep (hdwallet-provider)
CruzMolina Nov 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/artifactor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"temp": "^0.8.3",
"ts-node": "^8.3.0",
"typescript": "^3.6.3",
"web3": "1.2.1"
"web3": "1.2.2"
},
"publishConfig": {
"access": "public"
Expand Down
7 changes: 1 addition & 6 deletions packages/artifactor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"outDir": "dist",
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
]
},
"paths": {},
"rootDir": ".",
"typeRoots": [
"./typings",
Expand Down
88 changes: 56 additions & 32 deletions packages/blockchain-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Provider, Callback, JsonRPCResponse } from "web3/providers"
import { parsedUriObject } from "typings"
import { parsedUriObject } from "typings";
eggplantzzz marked this conversation as resolved.
Show resolved Hide resolved
import { Callback, JsonRpcResponse, Provider } from "@truffle/provider";

const Blockchain = {
getBlockByNumber(blockNumber: string, provider: Provider, callback: Callback<JsonRPCResponse>) {
getBlockByNumber(
blockNumber: string,
provider: Provider,
callback: Callback<JsonRpcResponse>
) {
const params = [blockNumber, true];
provider.send(
{
Expand All @@ -15,7 +19,11 @@ const Blockchain = {
);
},

getBlockByHash(blockHash: string, provider: Provider, callback: Callback<JsonRPCResponse>) {
getBlockByHash(
blockHash: string,
provider: Provider,
callback: Callback<JsonRpcResponse>
) {
const params = [blockHash, true];
provider.send(
{
Expand Down Expand Up @@ -45,20 +53,28 @@ const Blockchain = {
asURI(provider: Provider, callback: Callback<any>) {
let genesis: any, latest;

this.getBlockByNumber("0x0", provider, (err: Error, { result } : JsonRPCResponse) => {
if (err) return callback(err);
genesis = result;

this.getBlockByNumber("latest", provider, (err: Error, { result } : JsonRPCResponse) => {
this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
callback(null, url);
});
});
genesis = result;

this.getBlockByNumber(
"latest",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
callback(null, url);
}
);
}
);
},

matches(uri: string, provider: Provider, callback: Callback<any>) {
Expand All @@ -67,22 +83,30 @@ const Blockchain = {
const expected_genesis = parsedUri.genesis_hash;
const expected_block = parsedUri.block_hash;

this.getBlockByNumber("0x0", provider, (err: Error, { result } : JsonRPCResponse) => {
if (err) return callback(err);
const block = result;
if (block.hash !== expected_genesis) return callback(null, false);

this.getBlockByHash(expected_block, provider, (err: Error, { result } : JsonRPCResponse) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
const block = result;
if (err || block == null) {
return callback(null, false);
}

callback(null, true);
});
});
if (block.hash !== expected_genesis) return callback(null, false);

this.getBlockByHash(
expected_block,
provider,
(err: Error, { result }: JsonRpcResponse) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
const block = result;
if (err || block == null) {
return callback(null, false);
}

callback(null, true);
}
);
}
);
}
};

Expand Down
5 changes: 4 additions & 1 deletion packages/blockchain-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"types": "./typings/index.d.ts",
"devDependencies": {
"@types/assert": "^1.4.2",
"@types/web3": "^1.0.19",
"@types/node": "^12.12.5",
"mocha": "5.2.0",
"ts-node": "^8.3.0",
"typescript": "^3.6.3"
Expand All @@ -30,5 +30,8 @@
],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@truffle/provider": "^0.2.0"
}
}
7 changes: 3 additions & 4 deletions packages/blockchain-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
"net": [
"../../node_modules/@types/node",
"node_modules/@types/node"
]
},
"rootDir": ".",
"typeRoots": [
"./typings",
"../../**/node_modules/@types/mocha",
"../../**/node_modules/@types/web3",
"../../**/node_modules/@types/assert"
]
},
Expand Down
7 changes: 1 addition & 6 deletions packages/box/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"outDir": "dist",
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
]
},
"paths": {},
"rootDir": ".",
"typeRoots": [
"./typings",
Expand Down
7 changes: 1 addition & 6 deletions packages/code-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"outDir": "dist",
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
]
},
"paths": {},
"rootDir": ".",
"typeRoots": [
"./typings",
Expand Down
8 changes: 4 additions & 4 deletions packages/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"@truffle/interface-adapter": "^0.3.1",
"bignumber.js": "^7.2.1",
"ethers": "^4.0.0-beta.1",
"web3": "1.2.1",
"web3-core-promievent": "1.2.1",
"web3-eth-abi": "1.2.1",
"web3-utils": "1.2.1"
"web3": "1.2.2",
"web3-core-promievent": "1.2.2",
"web3-eth-abi": "1.2.2",
"web3-utils": "1.2.2"
},
"devDependencies": {
"@truffle/compile-solidity": "^4.2.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"spawn-args": "^0.1.0",
"temp": "^0.8.3",
"universal-analytics": "^0.4.17",
"web3": "1.2.1",
"web3": "1.2.2",
"xregexp": "^4.2.4",
"yargs": "^8.0.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"redux-saga": "1.0.0",
"remote-redux-devtools": "^0.5.12",
"reselect-tree": "^1.3.1",
"web3": "1.2.1",
"web3-eth-abi": "1.2.1"
"web3": "1.2.2",
"web3-eth-abi": "1.2.2"
},
"devDependencies": {
"@truffle/artifactor": "^4.0.37",
Expand Down
3 changes: 1 addition & 2 deletions packages/decode-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
"bn.js": "^4.11.8",
"lodash.clonedeep": "^4.5.0",
"lodash.escaperegexp": "^4.1.2",
"web3": "1.2.1",
"web3": "1.2.2",
"web3-eth-abi": "1.0.0-beta.52"
},
"devDependencies": {
"@types/bn.js": "^4.11.2",
"@types/lodash.clonedeep": "^4.5.4",
"@types/lodash.escaperegexp": "^4.1.6",
"@types/web3": "^1.0.5",
"typescript": "^3.1.3"
},
"publishConfig": {
Expand Down
7 changes: 1 addition & 6 deletions packages/decode-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"outDir": "dist",
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
]
},
"paths": {},
"rootDir": "src",
"typeRoots": [
"../../**/node_modules/@types/bn.js",
Expand Down
9 changes: 6 additions & 3 deletions packages/decoder/lib/interface/contract-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ import {
AstDefinition,
AstReferences
} from "@truffle/decode-utils";
import { BlockType, Transaction } from "web3/eth/types";
import { EventLog, Log } from "web3/types";
import { Provider } from "web3/providers";
import { Transaction, EventLog, Log } from "web3-core";
import { Provider } from "@truffle/provider";
import abiDecoder from "abi-decoder";
import isEqual from "lodash.isequal"; //util.isDeepStrictEqual doesn't exist in Node 8

type BlockType = number | string;

export interface EvmMapping {
name: string;
type: string;
Expand Down Expand Up @@ -373,6 +374,7 @@ export default class TruffleContractDecoder extends AsyncEventEmitter {
}
//otherwise, get it, cache it, and return it
let word = DecodeUtils.Conversion.toBytes(
// @ts-ignore
await this.web3.eth.getStorageAt(address, slot, block),
DecodeUtils.EVM.WORD_SIZE
);
Expand Down Expand Up @@ -502,6 +504,7 @@ export default class TruffleContractDecoder extends AsyncEventEmitter {
block: BlockType = "latest"
): Promise<ContractEvent[]> {
const web3Contract = new this.web3.eth.Contract(
// @ts-ignore
this.contract.abi,
this.contractAddress
);
Expand Down
15 changes: 12 additions & 3 deletions packages/decoder/lib/interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EvmInfo } from "../types/evm";
import decode from "../decode";
import TruffleDecoder from "./contract-decoder";
import { ContractObject } from "@truffle/contract-schema/spec";
import { Provider } from "web3/providers";
import { Provider } from "@truffle/provider";
import { DecoderRequest } from "../types/request";

export { getStorageAllocations, storageSize } from "../allocate/storage";
Expand All @@ -13,10 +13,19 @@ export { getMemoryAllocations } from "../allocate/memory";
export { readStack } from "../read/stack";
export { slotAddress } from "../read/storage";

export function forContract(contract: ContractObject, relevantContracts: ContractObject[], provider: Provider, address?: string): TruffleDecoder {
export function forContract(
contract: ContractObject,
relevantContracts: ContractObject[],
provider: Provider,
address?: string
): TruffleDecoder {
return new TruffleDecoder(contract, relevantContracts, provider, address);
}

export function* forEvmState(definition: AstDefinition, pointer: DataPointer, info: EvmInfo): IterableIterator<any | DecoderRequest> {
export function* forEvmState(
definition: AstDefinition,
pointer: DataPointer,
info: EvmInfo
): IterableIterator<any | DecoderRequest> {
return yield* decode(definition, pointer, info);
}
4 changes: 2 additions & 2 deletions packages/decoder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"types": "lib/interface/index.ts",
"dependencies": {
"@truffle/decode-utils": "^1.0.18",
"@truffle/provider": "^0.2.0",
"abi-decoder": "^1.2.0",
"async-eventemitter": "^0.2.4",
"bn.js": "^4.11.8",
Expand All @@ -30,7 +31,7 @@
"lodash.isequal": "^4.5.0",
"lodash.merge": "^4.6.1",
"utf8": "^3.0.0",
"web3": "1.2.1"
"web3": "1.2.2"
},
"peerDependencies": {
"truffle": "^5.0.14"
Expand All @@ -47,7 +48,6 @@
"@types/lodash.isequal": "^4.5.4",
"@types/lodash.merge": "^4.6.4",
"@types/utf8": "^2.1.6",
"@types/web3": "^1.0.5",
"json-schema-to-typescript": "^5.5.0",
"typescript": "^3.6.3"
},
Expand Down
10 changes: 6 additions & 4 deletions packages/decoder/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"web3": ["../../node_modules/@types/web3/index", "node_modules/web3/index"],
"web3/types": ["../../node_modules/@types/web3/types", "node_modules/web3/types"],
"web3/eth/types": ["../../node_modules/@types/web3/eth/types", "node_modules/web3/eth/types"]
"web3-core": [
"../../node_modules/web3/node_modules/web3-core/types",
eggplantzzz marked this conversation as resolved.
Show resolved Hide resolved
"node_modules/web3/node_modules/web3-core/types"
]
},
"rootDir": "lib",
"typeRoots": [
Expand All @@ -22,7 +23,8 @@
"../../**/node_modules/@types/lodash",
"../../**/node_modules/@types/lodash.clonedeep",
"../../**/node_modules/@types/lodash.isequal",
"../../**/node_modules/@types/lodash.merge"
"../../**/node_modules/@types/lodash.merge",
"../../node_modules/@truffle/provider/typings"
]

},
Expand Down
2 changes: 1 addition & 1 deletion packages/deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@truffle/workflow-compile": "^2.1.11",
"ganache-core": "2.7.0",
"mocha": "5.2.0",
"web3": "1.2.1"
"web3": "1.2.2"
},
"keywords": [
"contracts",
Expand Down
Loading