From f3a81e14691ca4d48b53b74eede3f8517634606c Mon Sep 17 00:00:00 2001 From: Dan Forbes Date: Wed, 23 Oct 2024 14:46:00 -0700 Subject: [PATCH] chore: format all files according tolatest prettier config:wq --- .github/workflows/ci.yaml | 100 +++++++++--------- .github/workflows/docs.yml | 2 +- .github/workflows/pr_title.yml | 2 +- .prettierrc.json | 8 +- README.md | 36 +++---- package.json | 7 +- packages/example-react-app/package.json | 18 ++-- packages/example-react-app/public/index.html | 7 +- .../example-react-app/src/AccountDetail.tsx | 29 ++--- packages/example-react-app/src/Accounts.tsx | 19 ++-- packages/example-react-app/src/App.tsx | 68 +++++------- .../example-react-app/src/ProviderButton.tsx | 8 +- .../src/WalletRpcPlugComponent.tsx | 4 +- packages/example-react-app/src/index.tsx | 14 ++- .../src/web3/AccountContext.tsx | 19 +--- .../src/web3/Web3Context.tsx | 31 +++--- .../src/web3/useProviders.ts | 8 +- packages/example-react-app/tsconfig.json | 10 +- packages/web3-plugin-wallet-rpc/.eslintrc.js | 2 +- .../src/WalletRpcPlugin.ts | 56 +++++----- packages/web3-plugin-wallet-rpc/src/index.ts | 4 +- packages/web3-plugin-wallet-rpc/src/types.ts | 2 +- packages/web3-plugin-wallet-rpc/src/utils.ts | 2 +- .../test/WalletRpcPlugin.test.ts | 10 +- .../test/jest.config.js | 4 +- .../test/wallet_addEthereumChain.test.ts | 36 +++---- .../test/wallet_getOwnedAssets.test.ts | 26 ++--- .../test/wallet_getPermissions.test.ts | 14 +-- .../test/wallet_requestPermissions.test.ts | 14 +-- .../test/wallet_revokePermissions.test.ts | 14 +-- .../test/wallet_switchEthereumChain.test.ts | 18 ++-- .../test/wallet_updateEthereumChain.test.ts | 34 +++--- .../test/wallet_watchAsset.test.ts | 26 ++--- packages/web3-plugin-wallet-rpc/tsconfig.json | 48 ++++----- yarn.lock | 2 +- 35 files changed, 328 insertions(+), 374 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f77bc21..3fc52d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,53 +9,53 @@ on: - '**' jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - cache: yarn - node-version: '18' - - name: Install deps - run: yarn install --frozen-lockfile - - name: Build - run: yarn build - - name: Lint - run: yarn run lint - - name: Tests - run: yarn run test - - maybe-release: - name: release - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - 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}]' - - - uses: actions/checkout@v3 - if: ${{ steps.release.outputs.release_created }} - - - uses: actions/setup-node@v3 - with: - cache: 'yarn' - node-version: 18 - registry-url: 'https://registry.npmjs.org' - if: ${{ steps.release.outputs.release_created }} - - - run: yarn install --frozen-lockfile - if: ${{ steps.release.outputs.release_created }} - - - run: yarn build - if: ${{ steps.release.outputs.release_created }} - - - run: yarn publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - if: ${{ steps.release.outputs.release_created }} \ No newline at end of file + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + cache: yarn + node-version: '18' + - name: Install deps + run: yarn install --frozen-lockfile + - name: Build + run: yarn build + - name: Lint + run: yarn run lint + - name: Tests + run: yarn run test + + maybe-release: + name: release + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + 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}]' + + - uses: actions/checkout@v3 + if: ${{ steps.release.outputs.release_created }} + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + node-version: 18 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + + - run: yarn install --frozen-lockfile + if: ${{ steps.release.outputs.release_created }} + + - run: yarn build + if: ${{ steps.release.outputs.release_created }} + + - run: yarn publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4c4cd73..ef04d01 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,7 +19,7 @@ permissions: # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: "pages" + group: 'pages' cancel-in-progress: false jobs: diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml index 61a69c4..f01597c 100644 --- a/.github/workflows/pr_title.yml +++ b/.github/workflows/pr_title.yml @@ -1,4 +1,4 @@ -name: "Semantic PR" +name: 'Semantic PR' on: pull_request_target: diff --git a/.prettierrc.json b/.prettierrc.json index bf357fb..f133c83 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,3 +1,9 @@ { - "trailingComma": "all" + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 90, + "tabWidth": 2, + "endOfLine": "auto", + "bracketSpacing": true } diff --git a/README.md b/README.md index b7a19c4..435f932 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ pnpm add web3-plugin-wallet-rpc ### Register plugin ```typescript -import { Web3 } from "web3"; -import { WalletRpcPlugin } from "web3-plugin-wallet-rpc"; +import { Web3 } from 'web3'; +import { WalletRpcPlugin } from 'web3-plugin-wallet-rpc'; -const web3 = new Web3("https://eth.llamarpc.com"); +const web3 = new Web3('https://eth.llamarpc.com'); web3.registerPlugin(new WalletRpcPlugin()); ``` @@ -51,15 +51,15 @@ Invokes the `wallet_addEthereumChain` method as defined in [EIP-3085](https://ei ```typescript await web3.walletRpc.addEthereumChain({ chainId: 5000, - blockExplorerUrls: ["https://mantlescan.xyz"], - chainName: "Mantle", - iconUrls: ["https://icons.llamao.fi/icons/chains/rsz_mantle.jpg"], + blockExplorerUrls: ['https://mantlescan.xyz'], + chainName: 'Mantle', + iconUrls: ['https://icons.llamao.fi/icons/chains/rsz_mantle.jpg'], nativeCurrency: { - name: "Mantle", - symbol: "MNT", + name: 'Mantle', + symbol: 'MNT', decimals: 18, }, - rpcUrls: ["https://rpc.mantle.xyz"], + rpcUrls: ['https://rpc.mantle.xyz'], }); ``` @@ -77,10 +77,10 @@ Invokes the `wallet_watchAsset` method as defined in [EIP-747](https://eips.ethe ```typescript await web3.walletRpc.watchAsset({ - type: "ERC20", + type: 'ERC20', options: { - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - symbol: "USDC", + address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + symbol: 'USDC', }, }); ``` @@ -122,14 +122,14 @@ Invokes the `wallet_updateEthereumChain` method as defined in [EIP-2015](https:/ ```typescript await web3.walletRpc.updateEthereumChain({ chainId: 5000, - blockExplorerUrls: ["https://mantlescan.xyz"], - chainName: "Mantle", + blockExplorerUrls: ['https://mantlescan.xyz'], + chainName: 'Mantle', nativeCurrency: { - name: "Mantle", - symbol: "MNT", + name: 'Mantle', + symbol: 'MNT', decimals: 18, }, - rpcUrls: ["https://rpc.mantle.xyz"], + rpcUrls: ['https://rpc.mantle.xyz'], }); ``` @@ -139,7 +139,7 @@ Invokes the `wallet_getOwnedAssets` method as defined in [EIP-2256](https://eips ```typescript const ownedAssets = await web3.walletRpc.getOwnedAssets({ - address: "0xa5653e88D9c352387deDdC79bcf99f0ada62e9c6", + address: '0xa5653e88D9c352387deDdC79bcf99f0ada62e9c6', }); ``` diff --git a/package.json b/package.json index 0025e9c..19a8a1f 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,16 @@ ], "packageManager": "yarn@1.22.15", "scripts": { - "lint": "cd packages/web3-plugin-wallet-rpc && yarn lint", "build": "cd packages/web3-plugin-wallet-rpc && yarn build", "build:docs": "cd packages/web3-plugin-wallet-rpc && yarn build:docs", "test": "cd packages/web3-plugin-wallet-rpc && yarn test", + "lint": "yarn lint:plugin && yarn lint:example", + "lint:plugin": "cd packages/web3-plugin-wallet-rpc && yarn lint", "lint:example": "cd packages/example-react-app && yarn lint", + "format": "prettier --write .", "start:example": "cd packages/example-react-app && yarn start" + }, + "devDependencies": { + "prettier": "^3.3.3" } } diff --git a/packages/example-react-app/package.json b/packages/example-react-app/package.json index 0d814c7..f3374c6 100644 --- a/packages/example-react-app/package.json +++ b/packages/example-react-app/package.json @@ -8,22 +8,24 @@ ], "license": "MIT", "dependencies": { - "@types/node": "^16.18.108", - "@types/react": "^18.3.8", - "@types/react-dom": "^18.3.0", - "@types/uuid": "^10.0.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-scripts": "5.0.1", - "typescript": "5.3.x", "uuid": "^10.0.0", "web3": "^4.14.0", - "web3-eth": "^4.9.0", "web3-plugin-wallet-rpc": "*" }, + "devDependencies": { + "@types/node": "^16.18.108", + "@types/react": "^18.3.8", + "@types/react-dom": "^18.3.0", + "@types/uuid": "^10.0.0", + "eslint": "8", + "react-scripts": "5.0.1", + "typescript": "5.3.x" + }, "scripts": { "start": "react-scripts start", - "lint": "eslint 'src/**/*.{ts,tsx}'" + "lint": "eslint 'src/**/*.{js,ts,tsx}'" }, "eslintConfig": { "extends": [ diff --git a/packages/example-react-app/public/index.html b/packages/example-react-app/public/index.html index 2fd78ab..454360c 100644 --- a/packages/example-react-app/public/index.html +++ b/packages/example-react-app/public/index.html @@ -1,14 +1,11 @@ - + - +