Skip to content

Commit

Permalink
Merge branch '4.x' into fix/type-account
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad-Altabba authored Feb 7, 2024
2 parents 390d08d + 998954f commit 7321f18
Show file tree
Hide file tree
Showing 62 changed files with 599 additions and 422 deletions.
98 changes: 51 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/cache/save@v3
with:
path: ./
key: web3-${{ matrix.node }}-${{github.event.pull_request.base.sha}}
key: web3-${{ matrix.node }}-${{github.sha}}

build-esm:
name: Build ESM
Expand All @@ -42,7 +42,7 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
- run: yarn build:esm
build-types:
name: Build Types
Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
- run: yarn build:types
lint:
name: Lint
Expand All @@ -68,7 +68,7 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
- run: npx ts-node scripts/init.ts
- run: yarn lint

Expand All @@ -83,13 +83,13 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
- name: Restore default branch stats
if: github.event_name != 'push'
uses: actions/cache/restore@v3
with:
path: packages/web3/dist/4.x.json
key: web3-bundle-stats-4x-${{github.event.pull_request.base.sha}}
key: web3-bundle-stats-4x-${{github.sha}}
- run: yarn build:web:analyze
env:
STATS_FILE: ${{ github.ref_name }}.json
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-${{ matrix.node }}-${{github.event.pull_request.base.sha}}
key: web3-${{ matrix.node }}-${{github.sha}}
- run: yarn test:unit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand All @@ -131,25 +131,25 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ matrix.node == 18 }}

integration:
name: Integration (ganache) # (ganache with HTTP)
integration-hardhat:
name: Integration hardhat
needs: build
runs-on: ubuntu-latest
env:
INFURA_GOERLI_HTTP: ${{ secrets.INFURA_GOERLI_HTTP }}
INFURA_GOERLI_WS: ${{ secrets.INFURA_GOERLI_WS }}
strategy:
fail-fast: false
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
with:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
- run: yarn test:e2e:ganache:http
shell: bash
key: web3-18-${{github.sha}}
- run: npx hardhat node &
- run: yarn test:e2e:hardhat:http
shell: bash

e2e:
e2e-geth:
name: Integration # (geth with HTTP, IPC & WS)
needs: build
runs-on: ubuntu-latest
Expand All @@ -167,36 +167,36 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
- run: yarn test:e2e:geth:${{ matrix.mode }}
shell: bash

e2e-browsers:
name: End-to-End ganache:ws
name: End-to-End hardhat:ws
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: ['electron', 'chrome', 'firefox']
fail-fast: false
matrix:
browser: ['electron', 'chrome', 'firefox']
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: browser-actions/setup-firefox@latest
if: matrix.browser == 'firefox'
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
- run: npm install --no-package-lock --no-save --force cypress
- run: npx ts-node scripts/init.ts
- name: Cypress run
uses: cypress-io/github-action@v4
with:
install: false
command: yarn test:e2e:ganache:ws:${{ matrix.browser }}
cache-key: node-v${{ matrix.node }}-on-${{ matrix.browser }}-hash-${{ hashFiles('yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: browser-actions/setup-firefox@latest
if: matrix.browser == 'firefox'
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.sha}}
- run: npx hardhat node &
- run: npm install --no-package-lock --no-save --force cypress
- name: Cypress run
uses: cypress-io/github-action@v4
with:
install: false
command: yarn test:e2e:hardhat:ws:${{ matrix.browser }}
cache-key: node-v18-on-${{ matrix.browser }}-hash-${{ hashFiles('yarn.lock') }}

deploy-docs:
name: Docs CloudFlare Deploy
Expand All @@ -206,14 +206,18 @@ jobs:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
node-version: '18'
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
- run: npm run build:docs
key: web3-18-${{github.sha}}
- run: yarn install --ignore-scripts
- run: yarn build:cjs
- run: yarn run build:docs
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
Expand All @@ -233,7 +237,7 @@ jobs:
- uses: actions/cache/restore@v3
with:
path: ./
key: web3-18-${{github.event.pull_request.base.sha}}
key: web3-18-${{github.sha}}
# @octokit/core not supported on node 16, so I can't add it to the package.json
- run: npm install --no-package-lock --no-save --force @octokit/core
- name: Restore main branch benchmark data
Expand Down
6 changes: 5 additions & 1 deletion docs/docs/guides/getting_started/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,8 @@ const subscription = uniswapToken.events.Transfer();
//listen to the events
subscription.on('data',console.log);
// ↳ [{...},{...}, ...] live events will be printed in the console
```
```

## Live code editor

<iframe width="100%" height="700px" src="https://stackblitz.com/edit/vitejs-vite-aksddx?embed=1&file=main.js&showSidebar=1"></iframe>
7 changes: 6 additions & 1 deletion docs/docs/guides/wallet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,9 @@ The following is a list of `Accounts` [methods](/libdocs/Wallet) in the `web3.et
- [recover](/libdocs/Accounts#recover)
- [recoverTransaction](/libdocs/Accounts#recovertransaction)
- [sign](/libdocs/Accounts#sign)
- [signTransaction](/libdocs/Accounts#signtransaction)
- [signTransaction](/libdocs/Accounts#signtransaction)


## Live code editor

<iframe width="100%" height="700px" src="https://stackblitz.com/edit/vitejs-vite-mhuwrk?embed=1&file=main.js&showSidebar=1"></iframe>
14 changes: 8 additions & 6 deletions docs/docs/guides/wallet/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ const account = web3.eth.accounts.privateKeyToAccount('0x4651f9c219fc6401fe0b3f8
// 3rd - create a raw transaction object
const rawTransaction = {
from: account.address,
to: '0x5875da5854c2adadbc1a7a448b5b2a09b26baff8', //random wallet
value: 1, //1 wei
gasPrice: await web3.eth.getGasPrice(),
gasLimit: 300000,
nonce: await web3.eth.getTransactionCount(account.address), //get the current nonce of the account
to: '0x5875da5854c2adadbc1a7a448b5b2a09b26baff8', //random wallet or contract address
value: 1, //optional - value in wei
maxFeePerGas: (await web3.eth.getBlock()).baseFeePerGas * 2n, //updated depending on the network
maxPriorityFeePerGas: 100000, //high
gasLimit: 2000000
nonce: await web3.eth.getTransactionCount(account.address), //optional - get the current nonce of the account
data: "0x0" //optional - encoded function signature and arguments
};

// 4th - sign the raw transaction with the private key
Expand Down Expand Up @@ -342,4 +344,4 @@ Confirmation: {
latestBlockHash: '0xb52380054ad2382620615ba7b7b40638021d85c5904a402cd11d00fd4db9fba9'
}
*/
```
```
8 changes: 7 additions & 1 deletion docs/docs/guides/web3_providers_guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,10 @@ provider.on('error', (error) => {
// the `maxAttempts` is equal to the provided value by the user, or the default value `5`.
}
});
```
```



## Live code editor

<iframe width="100%" height="700px" src="https://stackblitz.com/edit/vitejs-vite-zfusfd?embed=1&file=main.js&showSidebar=1"></iframe>
13 changes: 13 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type import('hardhat/config').HardhatUserConfig */

module.exports = {
solidity: "0.8.17",
networks: {
hardhat: {
chainId: 1337,
accounts: {

}
}
}
};
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@
"build:docs": "yarn generate:docs && cd docs && yarn install && yarn build",
"changelog": "ts-node -P scripts/changelog/tsconfig.json scripts/changelog/src/index.ts",
"clean": "lerna run clean --stream --parallel",
"ganache:start": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start",
"ganache:start:background": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start 1",
"ganache:stop": "./scripts/ganache.sh stop",
"geth:start": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth.sh start",
"geth:start:background": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth.sh start 1",
"geth:stop": "./scripts/geth.sh stop",
"geth-binary:start": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh start",
"geth-binary:start:background": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh start 1",
"geth-binary:stop": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh stop",
"hardhat:start": "WEB3_SYSTEM_TEST_BACKEND=hardhat && ./scripts/hardhat.sh start",
"hardhat:stop": "./scripts/hardhat.sh stop",
"geth-manual:start:background": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh manualStart 1",
"geth-manual:stop": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh stop",
"lint": "lerna run lint --stream --parallel",
Expand All @@ -65,14 +64,10 @@
"test:integration": "lerna run test:integration --stream",
"test:benchmark": "lerna run test:benchmark",
"test:integration:stress": "lerna run test:integration:stress --stream",
"test:e2e:ganache:http": "./scripts/test-runner.sh ganache http",
"test:e2e:ganache:ws": "./scripts/test-runner.sh ganache ws",
"test:e2e:geth:http": "./scripts/test-runner.sh geth http",
"test:e2e:geth:ws": "./scripts/test-runner.sh geth ws",
"test:e2e:geth:ipc": "./scripts/test-runner.sh geth ipc",
"test:e2e:ganache:ws:electron": "./scripts/test-runner.sh ganache ws electron",
"test:e2e:ganache:ws:chrome": "./scripts/test-runner.sh ganache ws chrome",
"test:e2e:ganache:ws:firefox": "./scripts/test-runner.sh ganache ws firefox",
"test:e2e:hardhat:http": "./scripts/test-runner.sh hardhat http",
"test:e2e:coverage": "./scripts/test-runner.sh coverage",
"test:e2e:mainnet:http": "./scripts/test-runner.sh mainnet http",
"test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws",
Expand All @@ -85,12 +80,15 @@
"generate:accounts": "node ./scripts/gen_accounts.js",
"pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"",
"post-blackbox": "./scripts/verdaccio.sh stop",
"post-blackbox:ganache": "yarn ganache:stop && yarn post-blackbox",
"post-blackbox:geth": "yarn geth:stop && yarn post-blackbox",
"test:blackbox:ganache:http": "yarn pre-blackbox && yarn ganache:start:background && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:ganache:http --stream && yarn post-blackbox:ganache",
"test:blackbox:ganache:ws": "yarn pre-blackbox && yarn ganache:start:background && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:ganache:ws --stream && yarn post-blackbox:ganache",
"test:blackbox:geth:http": "yarn pre-blackbox && yarn geth:start:background && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:geth:http --stream && yarn post-blackbox:geth",
"test:blackbox:geth:ws": "yarn pre-blackbox && yarn geth:start:background && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:geth:ws --stream && yarn post-blackbox:geth",
"test:e2e:geth:ws:electron": "./scripts/test-runner.sh hardhat ws electron",
"test:e2e:geth:ws:chrome": "./scripts/test-runner.sh hardhat ws chrome",
"test:e2e:geth:ws:firefox": "./scripts/test-runner.sh hardhat ws firefox",
"test:e2e:hardhat:ws:electron": "./scripts/test-runner.sh hardhat http electron",
"test:e2e:hardhat:ws:chrome": "./scripts/test-runner.sh hardhat http chrome",
"test:e2e:hardhat:ws:firefox": "./scripts/test-runner.sh hardhat http firefox",
"test:blackbox:infura:http": "yarn pre-blackbox && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:infura:http --stream && yarn post-blackbox",
"test:blackbox:infura:ws": "yarn pre-blackbox && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:infura:ws --stream && yarn post-blackbox",
"test:manual:long-connection-ws": "node packages/web3/test/stress/long_ws_tests/nodejs_test/long_connection_ws.js",
Expand Down Expand Up @@ -138,6 +136,7 @@
"typedoc-plugin-merge-modules": "^5.1.0",
"typescript": "^4.7.4",
"utf-8-validate": "^5.0.9",
"web3-hardhat-plugin": "^1.0.0",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/web3-core/src/web3_request_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class Web3RequestManager<
} else if ((response as unknown) instanceof Error) {
error = response as unknown as JsonRpcError;
}

// This message means that there was an error while executing the code of the smart contract
// However, more processing will happen at a higher level to decode the error data,
// according to the Error ABI, if it was available as of EIP-838.
// according to the Error ABI, if it was available as of EIP-838.
if (error?.message.includes('revert')) throw new ContractExecutionError(error);

return false;
Expand Down
Loading

0 comments on commit 7321f18

Please sign in to comment.