Skip to content

Commit e09caf8

Browse files
Merge pull request #27 from ChainSafe/1-use-only-web3-as-dependency
* Use only web3 as a dependency * Update web3 to the latest canary version * Updated README.md
2 parents d59f013 + d7c9487 commit e09caf8

File tree

10 files changed

+412
-416
lines changed

10 files changed

+412
-416
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ yarn add @chainsafe/web3.js-chainlink-plugin
2121

2222
### Installing Version `4.x` of `web3`
2323

24-
When adding the `web3` package to your project, make sure to use version `4.x`. You can append `@4.0.1-rc.2` tag to install RC2 of version 4:
24+
When adding the `web3` package to your project, make sure to use version `4.x`. You can append `@4.0.2-dev.af57eae.0` tag to install the latest version of 4 that this plugin was tested with:
2525

26-
- `npm i -S web3@4.0.1-rc.2`
27-
- `yarn add web3@4.0.1-rc.2`
26+
- `npm i -S web3@4.0.2-dev.af57eae.0`
27+
- `yarn add web3@4.0.2-dev.af57eae.0`
2828

2929
> **_NOTE_**
3030
> If 4.x was already released, you are good to just use `web3` without appending anything to it.
@@ -33,7 +33,7 @@ To verify you have the correct `web3` version installed, after adding the packag
3333

3434
```json
3535
"dependencies": {
36-
"web3": "4.0.1-rc.2"
36+
"web3": "4.0.2-dev.af57eae.0"
3737
}
3838
```
3939

package.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chainsafe/web3.js-chainlink-plugin",
3-
"version": "0.1.0-alpha.0",
3+
"version": "9.9.9",
44
"description": "A Web3.js 4.x Plugin for Interacting With Chainlink Smart Contracts",
55
"main": "lib/index.js",
66
"repository": {
@@ -31,14 +31,16 @@
3131
"test:e2e:chrome": "npx cypress run --headless --browser chrome",
3232
"test:e2e:firefox": "npx cypress run --headless --browser firefox",
3333
"test:e2e:electron": "npx cypress run --headless --browser electron",
34-
"test:unit": "jest --config=./test/unit/jest.config.js"
34+
"test:unit": "jest --config=./test/unit/jest.config.js",
35+
"test:all": "yarn && yarn build && yarn test && yarn run test:e2e:firefox && yarn run test:black-box"
3536
},
3637
"devDependencies": {
3738
"@babel/core": "^7.20.2",
3839
"@babel/preset-env": "^7.20.2",
3940
"@cypress/webpack-preprocessor": "^5.15.5",
4041
"@types/jest": "^28.1.6",
4142
"@types/node": "^18.7.23",
43+
"@types/ws": "^8.5.4",
4244
"@typescript-eslint/eslint-plugin": "^5.30.7",
4345
"@typescript-eslint/parser": "^5.30.7",
4446
"assert": "^2.0.0",
@@ -68,18 +70,11 @@
6870
"ts-loader": "^9.4.1",
6971
"ts-node": "^10.9.1",
7072
"typescript": "^4.7.4",
71-
"web3": "4.0.1-rc.2",
72-
"web3-core": "4.0.1-rc.2",
73-
"web3-eth": "4.0.1-rc.2",
73+
"web3": "^4.0.2-dev.af57eae.0",
7474
"webpack": "^5.75.0",
7575
"webpack-cli": "^5.0.1"
7676
},
7777
"peerDependencies": {
78-
"web3-core": ">= 4.0.1-rc.2 < 5",
79-
"web3-eth": ">= 4.0.1-rc.2 < 5",
80-
"web3-eth-abi": ">= 4.0.1-rc.2 < 5",
81-
"web3-eth-contract": ">= 4.0.1-rc.2 < 5",
82-
"web3-types": ">= 1.0.0-rc.2 < 5",
83-
"web3-validator": ">= 1.0.0-rc.2 < 5"
78+
"web3": ">= 4.0.2-dev.af57eae.0 < 5"
8479
}
8580
}

src/chainlink_plugin.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import { Web3PluginBase } from 'web3-core';
2-
import { Contract } from 'web3-eth-contract';
3-
import { Address, ContractAbi } from 'web3-types';
4-
import { isAddress } from 'web3-validator';
5-
1+
import { Address, Contract, ContractAbi, Web3PluginBase, validator } from 'web3';
62
import { AggregatorV3InterfaceABI } from './aggregator_v3_interface_abi';
7-
import { Web3Context } from './reexported_web3_context';
83
import { GoerliPriceFeeds, MainnetPriceFeeds } from './types';
94

105
export class ChainlinkPlugin extends Web3PluginBase {
@@ -31,7 +26,7 @@ export class ChainlinkPlugin extends Web3PluginBase {
3126
priceFeedAddress: MainnetPriceFeeds | GoerliPriceFeeds | Address,
3227
aggregatorInterfaceAbi: ContractAbi = this.defaultAggregatorInterfaceAbi,
3328
) {
34-
if (!isAddress(priceFeedAddress)) {
29+
if (!validator.isAddress(priceFeedAddress)) {
3530
throw new Error(
3631
`Provided priceFeedAddress is not a valid address: ${priceFeedAddress}`,
3732
);
@@ -56,10 +51,8 @@ export class ChainlinkPlugin extends Web3PluginBase {
5651
}
5752

5853
// Module Augmentation
59-
declare module './reexported_web3_context' {
54+
declare module 'web3' {
6055
interface Web3Context {
6156
chainlink: ChainlinkPlugin;
6257
}
6358
}
64-
65-
export { Web3Context };

src/reexported_web3_context.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/black_box/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
"devDependencies": {
1414
"jest": "^28.1.3",
1515
"ts-jest": "^28.0.7",
16-
"web3": "^4.0.1-rc.2",
17-
"web3-core": "^4.0.1-rc.2",
18-
"web3-eth": "^4.0.1-rc.2"
16+
"web3": "^4.0.2-dev.af57eae.0"
1917
}
2018
}

test/black_box/test/chainlink_plugin.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { core, Web3, Web3Eth } from 'web3';
1+
import { Web3, Web3Context, Web3Eth } from 'web3';
22

33
// https://github.com/ChainSafe/web3.js-plugin-chainlink/issues/15
44
// @ts-ignore
55
import { ChainlinkPlugin, MainnetPriceFeeds } from '@chainsafe/web3.js-chainlink-plugin';
66

77
describe('ChainlinkPlugin Tests', () => {
88
it('should register ChainlinkPlugin plugin on Web3Context instance', () => {
9-
const web3Context = new core.Web3Context('http://127.0.0.1:8545');
9+
const web3Context = new Web3Context('http://127.0.0.1:8545');
10+
web3Context.registerPlugin(new ChainlinkPlugin());
11+
expect(web3Context.chainlink).toBeDefined();
12+
});
13+
14+
it('should register ChainlinkPlugin plugin on Web3Context instance', () => {
15+
const web3Context = new Web3Context('http://127.0.0.1:8545');
1016
web3Context.registerPlugin(new ChainlinkPlugin());
1117
expect(web3Context.chainlink).toBeDefined();
1218
});

0 commit comments

Comments
 (0)