Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: rename project, use automated release, update configs and dependencies #28

Merged
merged 5 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
110 changes: 1 addition & 109 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,111 +1,3 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'header', 'deprecation', 'eslint-plugin-tsdoc', 'no-null'],
extends: [
'airbnb-base',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
rules: {
'deprecation/deprecation': 'error',
'class-methods-use-this': ['error'],
'no-unused-expressions': ['error'],
'no-continue': 'off',
'no-underscore-dangle': 'off',
'import/prefer-default-export': 'off',
'lines-between-class-members': 'off',
'no-use-before-define': ['error'],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'no-console': ['error', { allow: ['error', 'info', 'warn'] }],
'@typescript-eslint/no-floating-promises': ['error'],
'@typescript-eslint/prefer-for-of': ['error'],
'@typescript-eslint/consistent-type-assertions': ['error'],
'@typescript-eslint/explicit-member-accessibility': ['error'],
'@typescript-eslint/member-delimiter-style': ['error'],
'@typescript-eslint/member-ordering': [
'error',
{ default: ['public-static-field', 'public-instance-method'] },
],
'@typescript-eslint/no-extraneous-class': ['error'],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
'@typescript-eslint/no-unnecessary-qualifier': ['error'],
'@typescript-eslint/no-unnecessary-type-arguments': ['error'],
'@typescript-eslint/prefer-function-type': ['error'],
'@typescript-eslint/prefer-includes': ['error'],
'@typescript-eslint/prefer-nullish-coalescing': ['error'],
'@typescript-eslint/prefer-optional-chain': ['error'],
'@typescript-eslint/prefer-readonly': ['error'],
'@typescript-eslint/prefer-reduce-type-parameter': ['error'],
'@typescript-eslint/prefer-string-starts-ends-with': ['error'],
'@typescript-eslint/prefer-ts-expect-error': ['error'],
'@typescript-eslint/promise-function-async': ['error'],
'@typescript-eslint/require-array-sort-compare': ['error'],
'@typescript-eslint/switch-exhaustiveness-check': ['error'],
'@typescript-eslint/type-annotation-spacing': ['error'],
// Multiple constructors are more readable
'@typescript-eslint/unified-signatures': 'off',
'@typescript-eslint/no-unused-expressions': ['error'],
'@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
null: "Use 'undefined' instead of 'null'",
},
},
],
'@typescript-eslint/no-unused-vars': 'warn',
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'no-await-in-loop': ['error'],
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message:
'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.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
'no-null/no-null': ['error'],
'tsdoc/syntax': 'warn',
},
globals: {
BigInt: true,
},
parserOptions: {
ecmaVersion: 2016,
project: './tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
extends: "@chainsafe"
};
11 changes: 11 additions & 0 deletions .github/.dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "yarn"
schedule:
interval: weekly
requiredLabels:
- dependencies
commit-message:
prefix: fix
prefix-development: chore
include: scope
23 changes: 23 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Semantic PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore
revert
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
branches:
- master
jobs:
maybe-release:
name: release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:

- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: release-please-action
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":true},{"type":"revert","hidden":true}]'

- uses: actions/checkout@v3
if: ${{ steps.release.outputs.releases_created }}

- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 18
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.releases_created }}

- run: corepack enable
if: ${{ steps.release.outputs.releases_created }}

- run: yarn install --immutable
if: ${{ steps.release.outputs.releases_created }}

- run: yarn build
if: ${{ steps.release.outputs.releases_created }}

- run: yarn build:web
if: ${{ steps.release.outputs.releases_created }}

- env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.releases_created }}
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml

- run: yarn publish --access public
if: ${{ steps.release.outputs.releases_created }}
17 changes: 5 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Test
on:
pull_request:
push:
branches:
- master
types:
- opened
- reopened
- synchronize
pull_request:

jobs:
build:
name: Build TSC
Expand Down Expand Up @@ -40,18 +38,13 @@ jobs:
name: Build Webpack
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node:
- 16
- 18
steps:
- uses: actions/download-artifact@v3
with:
name: 'chainlink-plugin-${{ matrix.node }}.js.tar.gz'
name: 'chainlink-plugin-18.js.tar.gz'
path: /tmp
- run: corepack enable
- run: 'tar -xf /tmp/chainlink-plugin-${{ matrix.node }}.js.tar.gz -C ./'
- run: 'tar -xf /tmp/chainlink-plugin-18.js.tar.gz -C ./'
- run: 'yarn build:web'
lint:
name: lint
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

5 changes: 0 additions & 5 deletions .lintstagedrc.json

This file was deleted.

17 changes: 0 additions & 17 deletions .npmignore

This file was deleted.

44 changes: 0 additions & 44 deletions CHANGELOG.md

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ yarn add @chainsafe/web3.js-chainlink-plugin

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

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:
When adding the `web3` package to your project, make sure to use version `4.x`:

- `npm i -S web3@4.0.2-dev.af57eae.0`
- `yarn add web3@4.0.2-dev.af57eae.0`
- `npm i -S web3@4.0.3`
- `yarn add web3@4.0.3`

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

```json
"dependencies": {
"web3": "4.0.2-dev.af57eae.0"
"web3": "4.0.3"
}
```

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

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:
After importing `ChainlinkPlugin` from `@chainsafe/web3-plugin-chainlink` and `Web3` from `web3`, register an instance of `ChainlinkPlugin` with an instance of `Web3` like so:

```typescript
import { ChainlinkPlugin } from '@chainsafe/web3.js-chainlink-plugin';
import { ChainlinkPlugin } from '@chainsafe/web3-plugin-chainlink';
import { Web3 } from 'web3';

const web3 = new Web3('YOUR_PROVIDER_URL');
Expand Down Expand Up @@ -81,7 +81,7 @@ The `getPrice` method, accepts `MainnetPriceFeeds | GoerliPriceFeeds | Address`
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).

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

const web3 = new Web3('YOUR_PROVIDER_URL');
Expand Down
12 changes: 0 additions & 12 deletions cypress/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@ module.exports = {
},
],
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
fs: false,
net: false,
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('readable-stream'),
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
Expand Down
Loading
Loading