Skip to content

Commit d29710b

Browse files
committed
feat: rename, update dependencies and configs.
Signed-off-by: Marin Petrunic <[email protected]>
1 parent e09caf8 commit d29710b

File tree

10 files changed

+676
-2323
lines changed

10 files changed

+676
-2323
lines changed

.eslintrc.js

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,3 @@
11
module.exports = {
2-
root: true,
3-
env: {
4-
browser: true,
5-
node: true,
6-
},
7-
parser: '@typescript-eslint/parser',
8-
plugins: ['@typescript-eslint', 'header', 'deprecation', 'eslint-plugin-tsdoc', 'no-null'],
9-
extends: [
10-
'airbnb-base',
11-
'eslint:recommended',
12-
'plugin:@typescript-eslint/recommended',
13-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14-
'prettier',
15-
'plugin:import/errors',
16-
'plugin:import/warnings',
17-
'plugin:import/typescript',
18-
],
19-
rules: {
20-
'deprecation/deprecation': 'error',
21-
'class-methods-use-this': ['error'],
22-
'no-unused-expressions': ['error'],
23-
'no-continue': 'off',
24-
'no-underscore-dangle': 'off',
25-
'import/prefer-default-export': 'off',
26-
'lines-between-class-members': 'off',
27-
'no-use-before-define': ['error'],
28-
'no-shadow': 'off',
29-
'@typescript-eslint/no-shadow': ['error'],
30-
'no-console': ['error', { allow: ['error', 'info', 'warn'] }],
31-
'@typescript-eslint/no-floating-promises': ['error'],
32-
'@typescript-eslint/prefer-for-of': ['error'],
33-
'@typescript-eslint/consistent-type-assertions': ['error'],
34-
'@typescript-eslint/explicit-member-accessibility': ['error'],
35-
'@typescript-eslint/member-delimiter-style': ['error'],
36-
'@typescript-eslint/member-ordering': [
37-
'error',
38-
{ default: ['public-static-field', 'public-instance-method'] },
39-
],
40-
'@typescript-eslint/no-extraneous-class': ['error'],
41-
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
42-
'@typescript-eslint/no-unnecessary-qualifier': ['error'],
43-
'@typescript-eslint/no-unnecessary-type-arguments': ['error'],
44-
'@typescript-eslint/prefer-function-type': ['error'],
45-
'@typescript-eslint/prefer-includes': ['error'],
46-
'@typescript-eslint/prefer-nullish-coalescing': ['error'],
47-
'@typescript-eslint/prefer-optional-chain': ['error'],
48-
'@typescript-eslint/prefer-readonly': ['error'],
49-
'@typescript-eslint/prefer-reduce-type-parameter': ['error'],
50-
'@typescript-eslint/prefer-string-starts-ends-with': ['error'],
51-
'@typescript-eslint/prefer-ts-expect-error': ['error'],
52-
'@typescript-eslint/promise-function-async': ['error'],
53-
'@typescript-eslint/require-array-sort-compare': ['error'],
54-
'@typescript-eslint/switch-exhaustiveness-check': ['error'],
55-
'@typescript-eslint/type-annotation-spacing': ['error'],
56-
// Multiple constructors are more readable
57-
'@typescript-eslint/unified-signatures': 'off',
58-
'@typescript-eslint/no-unused-expressions': ['error'],
59-
'@typescript-eslint/no-useless-constructor': ['error'],
60-
'@typescript-eslint/explicit-module-boundary-types': 'off',
61-
'@typescript-eslint/ban-types': [
62-
'error',
63-
{
64-
types: {
65-
null: "Use 'undefined' instead of 'null'",
66-
},
67-
},
68-
],
69-
'@typescript-eslint/no-unused-vars': 'warn',
70-
'import/extensions': [
71-
'error',
72-
'ignorePackages',
73-
{
74-
js: 'never',
75-
jsx: 'never',
76-
ts: 'never',
77-
tsx: 'never',
78-
},
79-
],
80-
'no-await-in-loop': ['error'],
81-
'no-restricted-syntax': [
82-
'error',
83-
{
84-
selector: 'ForInStatement',
85-
message:
86-
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
87-
},
88-
{
89-
selector: 'LabeledStatement',
90-
message:
91-
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
92-
},
93-
{
94-
selector: 'WithStatement',
95-
message:
96-
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
97-
},
98-
],
99-
'no-null/no-null': ['error'],
100-
'tsdoc/syntax': 'warn',
101-
},
102-
globals: {
103-
BigInt: true,
104-
},
105-
parserOptions: {
106-
ecmaVersion: 2016,
107-
project: './tsconfig.json',
108-
tsconfigRootDir: __dirname,
109-
sourceType: 'module',
110-
},
2+
extends: "@chainsafe"
1113
};

.lintstagedrc.json

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

.npmignore

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

CHANGELOG.md

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

README.md

Lines changed: 7 additions & 7 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.2-dev.af57eae.0` tag to install the latest version of 4 that this plugin was tested with:
24+
When adding the `web3` package to your project, make sure to use version `4.x`:
2525

26-
- `npm i -S [email protected].2-dev.af57eae.0`
27-
- `yarn add [email protected].2-dev.af57eae.0`
26+
- `npm i -S [email protected].3`
27+
- `yarn add [email protected].3`
2828

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

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

4040
### Registering the Plugin with a web3.js Instance
4141

42-
After importing `ChainlinkPlugin` from `@chainsafe/web3.js-chainlink-plugin` and `Web3` from `web3`, register an instance of `ChainlinkPlugin` with an instance of `Web3` like so:
42+
After importing `ChainlinkPlugin` from `@chainsafe/web3-plugin-chainlink` and `Web3` from `web3`, register an instance of `ChainlinkPlugin` with an instance of `Web3` like so:
4343

4444
```typescript
45-
import { ChainlinkPlugin } from '@chainsafe/web3.js-chainlink-plugin';
45+
import { ChainlinkPlugin } from '@chainsafe/web3-plugin-chainlink';
4646
import { Web3 } from 'web3';
4747

4848
const web3 = new Web3('YOUR_PROVIDER_URL');
@@ -81,7 +81,7 @@ The `getPrice` method, accepts `MainnetPriceFeeds | GoerliPriceFeeds | Address`
8181
Under the hood, this method is calling the `latestRoundData` for the specified price feed, more information about it can be found [here](https://docs.chain.link/data-feeds/price-feeds/api-reference#latestrounddata).
8282

8383
```typescript
84-
import { ChainlinkPlugin, MainnetPriceFeeds } from '@chainsafe/web3.js-chainlink-plugin';
84+
import { ChainlinkPlugin, MainnetPriceFeeds } from '@chainsafe/web3-plugin-chainlink';
8585
import { Web3 } from 'web3';
8686

8787
const web3 = new Web3('YOUR_PROVIDER_URL');

cypress/webpack.config.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,7 @@ module.exports = {
1818
},
1919
],
2020
},
21-
resolve: {
22-
extensions: ['.ts', '.js'],
23-
fallback: {
24-
fs: false,
25-
net: false,
26-
crypto: require.resolve('crypto-browserify'),
27-
stream: require.resolve('readable-stream'),
28-
},
29-
},
3021
plugins: [
31-
new webpack.ProvidePlugin({
32-
Buffer: ['buffer', 'Buffer'],
33-
}),
3422
new webpack.ProvidePlugin({
3523
process: 'process/browser',
3624
}),

package.json

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@chainsafe/web3.js-chainlink-plugin",
3-
"version": "9.9.9",
2+
"name": "@chainsafe/web3-plugin-chainlink",
3+
"version": "0.1.0-alpha.0",
44
"description": "A Web3.js 4.x Plugin for Interacting With Chainlink Smart Contracts",
55
"main": "lib/index.js",
66
"repository": {
@@ -16,65 +16,42 @@
1616
],
1717
"scripts": {
1818
"build": "tsc --build",
19-
"build:web": "npx webpack",
19+
"build:web": "webpack",
2020
"clean": "rimraf lib && rimraf dist",
21-
"format": "prettier --write '**/*'",
2221
"lint": "eslint --ext .js,.ts .",
2322
"lint:fix": "eslint --fix --ext .js,.ts .",
2423
"post-black-box": "./scripts/black_box_test_helpers.sh stop",
2524
"pre-black-box": "./scripts/black_box_test_helpers.sh startBackgroundAndPublish",
2625
"prebuild": "yarn clean",
27-
"prepare": "husky install",
2826
"test": "jest --config=./test/unit/jest.config.js",
2927
"test:black-box": "yarn pre-black-box && ./scripts/black_box_test_helpers.sh runTests",
3028
"test:coverage": "jest --config=./test/unit/jest.config.js --coverage=true --coverage-reporters=text",
31-
"test:e2e:chrome": "npx cypress run --headless --browser chrome",
32-
"test:e2e:firefox": "npx cypress run --headless --browser firefox",
33-
"test:e2e:electron": "npx cypress run --headless --browser electron",
29+
"test:e2e:chrome": "cypress run --headless --browser chrome",
30+
"test:e2e:firefox": "cypress run --headless --browser firefox",
31+
"test:e2e:electron": "cypress run --headless --browser electron",
3432
"test:unit": "jest --config=./test/unit/jest.config.js",
3533
"test:all": "yarn && yarn build && yarn test && yarn run test:e2e:firefox && yarn run test:black-box"
3634
},
3735
"devDependencies": {
38-
"@babel/core": "^7.20.2",
39-
"@babel/preset-env": "^7.20.2",
36+
"@chainsafe/eslint-config": "^2.0.0",
4037
"@cypress/webpack-preprocessor": "^5.15.5",
4138
"@types/jest": "^28.1.6",
4239
"@types/node": "^18.7.23",
4340
"@types/ws": "^8.5.4",
44-
"@typescript-eslint/eslint-plugin": "^5.30.7",
45-
"@typescript-eslint/parser": "^5.30.7",
46-
"assert": "^2.0.0",
47-
"babel-loader": "^8.0.2",
48-
"crypto-browserify": "^3.12.0",
4941
"cypress": "^12.3.0",
5042
"cypress-jest-adapter": "^0.1.1",
51-
"declaration-bundler-webpack-plugin": "^1.0.3",
52-
"eslint": "^8.20.0",
53-
"eslint-config-airbnb-base": "^15.0.0",
54-
"eslint-config-prettier": "^8.5.0",
55-
"eslint-plugin-deprecation": "^1.3.2",
56-
"eslint-plugin-header": "^3.1.1",
57-
"eslint-plugin-import": "^2.26.0",
58-
"eslint-plugin-jest": "^27.0.4",
59-
"eslint-plugin-no-null": "^1.0.2",
60-
"eslint-plugin-tsdoc": "^0.2.17",
61-
"husky": "^8.0.1",
43+
"eslint": "^8",
6244
"jest": "^28.1.3",
6345
"jest-extended": "^3.0.1",
64-
"lint-staged": "^13.0.3",
65-
"npm-auth-to-token": "^1.0.0",
66-
"prettier": "^2.7.1",
67-
"prettier-plugin-solidity": "^1.0.0-beta.24",
6846
"process": "^0.11.10",
6947
"ts-jest": "^28.0.7",
7048
"ts-loader": "^9.4.1",
71-
"ts-node": "^10.9.1",
7249
"typescript": "^4.7.4",
73-
"web3": "^4.0.2-dev.af57eae.0",
50+
"web3": "^4.0.3",
7451
"webpack": "^5.75.0",
7552
"webpack-cli": "^5.0.1"
7653
},
7754
"peerDependencies": {
78-
"web3": ">= 4.0.2-dev.af57eae.0 < 5"
55+
"web3": ">= 4.0.3"
7956
}
8057
}

src/chainlink_plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Address, Contract, ContractAbi, Web3PluginBase, validator } from 'web3';
22
import { AggregatorV3InterfaceABI } from './aggregator_v3_interface_abi';
3-
import { GoerliPriceFeeds, MainnetPriceFeeds } from './types';
3+
import { GoerliPriceFeeds, MainnetPriceFeeds, Price } from './types';
44

55
export class ChainlinkPlugin extends Web3PluginBase {
66
public pluginNamespace: string;
@@ -25,14 +25,14 @@ export class ChainlinkPlugin extends Web3PluginBase {
2525
public async getPrice(
2626
priceFeedAddress: MainnetPriceFeeds | GoerliPriceFeeds | Address,
2727
aggregatorInterfaceAbi: ContractAbi = this.defaultAggregatorInterfaceAbi,
28-
) {
28+
): Promise<Price> {
2929
if (!validator.isAddress(priceFeedAddress)) {
3030
throw new Error(
3131
`Provided priceFeedAddress is not a valid address: ${priceFeedAddress}`,
3232
);
3333
}
3434

35-
const _contract: Contract<typeof aggregatorInterfaceAbi> = new Contract(
35+
const _contract: Contract<typeof AggregatorV3InterfaceABI> = new Contract(
3636
aggregatorInterfaceAbi,
3737
priceFeedAddress,
3838
);

webpack.config.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,4 @@ module.exports = {
2626
},
2727
],
2828
},
29-
resolve: {
30-
extensions: ['.ts', '.js'],
31-
fallback: {
32-
fs: false,
33-
net: false,
34-
crypto: require.resolve('crypto-browserify'),
35-
stream: require.resolve('readable-stream'),
36-
},
37-
},
38-
plugins: [
39-
new webpack.ProvidePlugin({
40-
Buffer: ['buffer', 'Buffer'],
41-
}),
42-
new webpack.ProvidePlugin({
43-
process: 'process/browser',
44-
}),
45-
],
4629
};

0 commit comments

Comments
 (0)