Skip to content

Commit

Permalink
Merge branch '4.x' into fix/web3-validator-browser-dist-7015
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex authored May 8, 2024
2 parents e847f60 + f216540 commit e4a46bf
Show file tree
Hide file tree
Showing 45 changed files with 530 additions and 285 deletions.
85 changes: 70 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: yarn install --ignore-scripts
- run: npx ts-node scripts/init.ts
- run: yarn build:cjs
- uses: actions/cache/save@v3
- uses: actions/cache/save@v4
with:
path: ./
key: web3-${{ matrix.node }}-${{github.sha}}
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -65,12 +65,63 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
- run: npx ts-node scripts/init.ts
- name: Restore eslint caches
uses: actions/cache/restore@v4
with:
path: |
packages/web3/.eslintcache
packages/web3-core/.eslintcache
packages/web3-eth/.eslintcache
packages/web3-eth-abi/.eslintcache
packages/web3-eth-accounts/.eslintcache
packages/web3-eth-contract/.eslintcache
packages/web3-eth-ens/.eslintcache
packages/web3-eth-iban/.eslintcache
packages/web3-eth-personal/.eslintcache
packages/web3-net/.eslintcache
packages/web3-providers-http/.eslintcache
packages/web3-providers-ws/.eslintcache
packages/web3-rpc-methods/.eslintcache
packages/web3-types/.eslintcache
packages/web3-utils/.eslintcache
packages/web3-validator/.eslintcache
tools/web3-plugin-example/.eslintcache
key: ${{ runner.os }}-eslintcache

- run: yarn lint
- run: gh cache delete "${{ runner.os }}-eslintcache"
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Save eslint caches
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
uses: actions/cache/save@v4
with:
path: |
packages/web3/.eslintcache
packages/web3-core/.eslintcache
packages/web3-eth/.eslintcache
packages/web3-eth-abi/.eslintcache
packages/web3-eth-accounts/.eslintcache
packages/web3-eth-contract/.eslintcache
packages/web3-eth-ens/.eslintcache
packages/web3-eth-iban/.eslintcache
packages/web3-eth-personal/.eslintcache
packages/web3-net/.eslintcache
packages/web3-providers-http/.eslintcache
packages/web3-providers-ws/.eslintcache
packages/web3-rpc-methods/.eslintcache
packages/web3-types/.eslintcache
packages/web3-utils/.eslintcache
packages/web3-validator/.eslintcache
tools/web3-plugin-example/.eslintcache
key: ${{ runner.os }}-eslintcache

build-web:
name: Build Web
Expand All @@ -80,13 +131,13 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
- name: Restore default branch stats
if: github.event_name != 'push'
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: packages/web3/dist/4.x.json
key: web3-bundle-stats-4x-${{github.event.pull_request.base.sha}}
Expand All @@ -101,7 +152,7 @@ jobs:
current-stats-json-path: "packages/web3/dist/${{ github.ref_name }}.json"
base-stats-json-path: "packages/web3/dist/4.x.json"
- name: Cache default branch stats
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
with:
path: packages/web3/dist/${{ github.ref_name }}.json
Expand All @@ -120,7 +171,7 @@ jobs:
with:
architecture: x64
node-version: ${{ matrix.node }}
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-${{ matrix.node }}-${{github.sha}}
Expand All @@ -142,7 +193,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -165,7 +216,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -186,7 +237,7 @@ jobs:
node-version: 18
- uses: browser-actions/setup-firefox@latest
if: matrix.browser == 'firefox'
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -212,7 +263,7 @@ jobs:
with:
cache: yarn
node-version: '18'
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
key: web3-18-${{github.sha}}
Expand All @@ -235,14 +286,14 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
with:
path: ./
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/[email protected]
- name: Restore main branch benchmark data
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: web3-benchmark-main.json
key: ${{ runner.os }}-web3-benchmark-main.json
Expand Down Expand Up @@ -279,8 +330,12 @@ jobs:
# Enable alert commit comment
alert-threshold: '200%'
comment-always: false
- run: gh cache delete "${{ runner.os }}-web3-benchmark-main.json"
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save main branch benchmark data
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
with:
path: web3-benchmark-main.json
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ packages/web3/.in3/

# benchmark results
benchmark-data.txt

.eslintcache
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2448,13 +2448,18 @@ If there are any bugs, improvements, optimizations or any new feature proposal f

### Added

#### web3

- Updated type `Web3EthInterface.accounts` to includes `privateKeyToAccount`,`privateKeyToAddress`,and `privateKeyToPublicKey` (#6762)

#### web3-core

- `defaultReturnFormat` was added to the configuration options. (#6947)

#### web3-eth

- `defaultReturnFormat` was added to all methods that have `ReturnType` param. (#6947)
- `getTransactionFromOrToAttr`, `waitForTransactionReceipt`, `trySendTransaction`, `SendTxHelper` was exported (#7000)

#### web3-eth-contract

Expand All @@ -2473,8 +2478,27 @@ If there are any bugs, improvements, optimizations or any new feature proposal f
- Added `signature` to type `AbiFunctionFragment` (#6922)
- update type `Withdrawals`, `block` and `BlockHeaderOutput` to include properties of eip 4844, 4895, 4788 (#6933)

#### web3-utils


### Fixed

#### web3-utils


#### web3-validator

- The JSON schema conversion process now correctly assigns an id when the `abi.name` is not available, for example, in the case of public mappings. (#6981)

### Changed

#### web3-core

- Interface `RequestManagerMiddleware` was changed (#7003)

#### web3-eth

- Added parameter `customTransactionReceiptSchema` into methods `emitConfirmation`, `waitForTransactionReceipt`, `watchTransactionByPolling`, `watchTransactionBySubscription`, `watchTransactionForConfirmations` (#7000)

#### web3-rpc-methods

- Change `estimateGas` method to add possibility pass Transaction type (#7000)
7 changes: 7 additions & 0 deletions FUNDING.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"drips": {
"ethereum": {
"ownedBy": "0x689f1278469c6146d835CB99BbfF818fB62989FE"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
---
sidebar_position: 16
sidebar_label: '📚 Resources'
sidebar_label: '📚 Resources & Troubleshooting'
---
# Resources
# Resources & Troubleshooting

## [Web3.js v4 course](https://www.youtube.com/watch?v=3ZO_t-Kyr1g&list=PLPn3rQCo3XrP4LbQcOyyHQR8McV7w3HZT)
## Troubleshooting

### ReferenceError: Can't find variable: BigInt using React

Occasionally, users encounter errors in web3.js due to external dependencies, which may seem challenging to resolve within the web3.js framework alone.

**Resolution Steps:**

1. Install `rn-nodeify` as a development dependency:
```bash
yarn add --dev rn-nodeify
```

2. Add the `big-integer` package:
```bash
yarn add big-integer
```

3. Create a file named `shim.js` at the root of your project and include the following polyfill:
```ts
if (typeof BigInt === 'undefined') {
global.BigInt = require('big-integer');
}
```

4. Import shim.js at the top of your App.js:
```ts
// Make sure you use `import` and not `require`!
import './shim.js'
```

Additional Info:

[Facebook/React-native Issue #28492](https://github.com/facebook/react-native/issues/28492#issuecomment-824698934)

## Resources

### [Web3.js v4 course](https://www.youtube.com/watch?v=3ZO_t-Kyr1g&list=PLPn3rQCo3XrP4LbQcOyyHQR8McV7w3HZT)

This comprehensive 14-part video course from ChainSafe equips you with the skills to conquer the blockchain using web3.js v4. Unlock the potential of web3.js v4 and build cutting-edge dApps. This course caters to all skill levels.

[![Web3.js v4 course](https://img.youtube.com/vi/3ZO_t-Kyr1g/0.jpg)](https://www.youtube.com/watch?v=3ZO_t-Kyr1g&list=PLPn3rQCo3XrP4LbQcOyyHQR8McV7w3HZT)


## [Web3.js series](https://www.youtube.com/watch?v=BQ_bDH91S4k&list=PLPn3rQCo3XrNf__8irs4-MjMt4fJqW2I_)
### [Web3.js series](https://www.youtube.com/watch?v=BQ_bDH91S4k&list=PLPn3rQCo3XrNf__8irs4-MjMt4fJqW2I_)

This series of 3 videos takes you on a journey through web3.js. Whether you're a complete beginner or want to refine your skills, these videos have something for you:

Expand All @@ -23,6 +60,6 @@ This series of 3 videos takes you on a journey through web3.js. Whether you're a

[![Web3.js series](https://img.youtube.com/vi/BQ_bDH91S4k/0.jpg)](https://www.youtube.com/watch?v=BQ_bDH91S4k&list=PLPn3rQCo3XrNf__8irs4-MjMt4fJqW2I_)

## Hackathons
## Hackathons and Bounties

You'll find the latest hackathons opportunities by following [web3js](https://twitter.com/web3_js) on X.
6 changes: 6 additions & 0 deletions packages/web3-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,10 @@ Documentation:
## [Unreleased]

### Added

- `defaultReturnFormat` was added to the configuration options. (#6947)

### Changed

- Interface `RequestManagerMiddleware` was changed (#7003)

2 changes: 1 addition & 1 deletion packages/web3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
Expand Down
33 changes: 19 additions & 14 deletions packages/web3-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

import { HexString, JsonRpcResponse, Transaction, Web3APIMethod, Web3APIRequest, Web3APIReturnType } from 'web3-types';
import {
HexString,
JsonRpcPayload,
JsonRpcResponse,
Transaction,
Web3APIMethod,
Web3APIReturnType,
} from 'web3-types';

export type TransactionTypeParser = (
transaction: Transaction,
) => HexString | undefined;
export type TransactionTypeParser = (transaction: Transaction) => HexString | undefined;

export interface Method {
name: string;
Expand All @@ -32,16 +37,16 @@ export interface ExtensionObject {
}

export interface RequestManagerMiddleware<API> {
processRequest<
AnotherMethod extends Web3APIMethod<API>
>(
request: Web3APIRequest<API, AnotherMethod>,
options?: { [key: string]: unknown }): Promise<Web3APIRequest<API, AnotherMethod>>;
processRequest<ParamType = unknown[]>(
request: JsonRpcPayload<ParamType>,
options?: { [key: string]: unknown },
): Promise<JsonRpcPayload<ParamType>>;

processResponse<
AnotherMethod extends Web3APIMethod<API>,
ResponseType = Web3APIReturnType<API, AnotherMethod>>
(
response: JsonRpcResponse<ResponseType>,
options?: { [key: string]: unknown }): Promise<JsonRpcResponse<ResponseType>>;
}
ResponseType = Web3APIReturnType<API, AnotherMethod>,
>(
response: JsonRpcResponse<ResponseType>,
options?: { [key: string]: unknown },
): Promise<JsonRpcResponse<ResponseType>>;
}
Loading

0 comments on commit e4a46bf

Please sign in to comment.