Skip to content

Commit

Permalink
Merge branch '4.x' into dependabot/npm_and_yarn/follow-redirects-1.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevcs committed Jan 31, 2024
2 parents 39486fb + a72e99a commit 04d13d9
Show file tree
Hide file tree
Showing 14 changed files with 308 additions and 361 deletions.
551 changes: 266 additions & 285 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

28 changes: 0 additions & 28 deletions .github/workflows/deploy-docs.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Further details about versioning can be found in the [semver 2.0.0 specification

`E2E Network Tests` will be triggered to run via a Github workflow when a PR is open for a branch prefixed with `release/` and is being merged into `4.x` branch. These tests depend on a couple of ENVs to be set that are configurable in Github's Action Secrets when running these tests in CI. The following required secrets are:

- `E2E_TESTS_ALLOWED_SEND_TRANSACTION`: If set to `false` this will keep the Sepolia tests that spend ETH from runnning, setting to anything else will cause them to run
- `E2E_TESTS_ALLOWED_SEND_TRANSACTION`: If set to `false` this will keep the Sepolia tests that spend ETH from running, setting to anything else will cause them to run
- `TEST_ACCOUNT_PRIVATE_KEY`: The private key of the Sepolia account to use when submitting transactions
- `INFURA_SEPOLIA_HTTP`: The provider to be used to access the Sepolia network
- `INFURA_MAINNET_HTTP`: The provider to be used to access Mainnet
Expand Down Expand Up @@ -54,7 +54,7 @@ Further details about versioning can be found in the [semver 2.0.0 specification

- Select recently pushed tag in `choose a tag` drop down

- Check `Set as the latest release` if its latest release else select `This is a pre-release` if its not main release e.g. if its `RC` or `alpha`
- Check `Set as the latest release` if its latest release else select `This is a pre-release` if it's not main release e.g. if it's `RC` or `alpha`

- Check `Create a discussion for this release`

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/smart_contracts/infer_contract_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import path from 'path';
//read destination directory submitted as first param
var destination = process.argv.slice(2)[0];

//read all contract artifacts from artifacts.json which should be in the directoy from where script should be executed
//read all contract artifacts from artifacts.json which should be in the directory from where script should be executed
const artifactContent = fs.readFileSync('./artifacts.json', 'utf-8');

const artifacts: string[] = JSON.parse(artifactContent);
Expand Down
66 changes: 30 additions & 36 deletions docs/docs/guides/wallet/local_wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,47 @@ If used within the browser, wallets are not saved anywhere and disappear when th
If used within your application, wallets will disappear after the program is completed.
:::

## Create an account and add it to an empty `Wallet`
## Create a `Wallet` with a random account

```ts title='Creating an Account and Adding it to an Empty Wallet'
import { Web3 } from 'web3';
```ts title= Create Wallet with random account
import { Web3 } from "web3";

const web3 = new Web3(/* PROVIDER */);

// 1st - creating a new empty wallet (0 accounts inside)
const wallet = web3.eth.accounts.wallet.create();

console.log(wallet);
/*
* creates wallet with 1 account
* @param: number of accounts you want to create within the wallet
*/
const wallet = web3.eth.accounts.wallet.create(1);
/*
Wallet(0) [
Wallet(1) [
{
address: '0xE0A7859c5454B369Ab8089890A11efcB458eA13c',
privateKey: '0x0199829f0c95213670d48aa48abdb36c16c2ec3d11fe20e1fa8c0270ffb64110',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
_accountProvider: {
create: [Function: createWithContext],
privateKeyToAccount: [Function: privateKeyToAccountWithContext],
decrypt: [Function: decryptWithContext]
},
_addressMap: Map(0) {},
_addressMap: Map(1) { '0xe0a7859c5454b369ab8089890a11efcb458ea13c' => 0 },
_defaultKeyName: 'web3js_wallet'
]
*/
```

// 2nd - create an account
const account = web3.eth.accounts.create();
## Create an account and add it to an empty `Wallet`

```ts title='Creating an Account and add it to a Wallet'
import { Web3 } from "web3";

const web3 = new Web3(/* PROVIDER */);

console.log(account)
// 1st - creating a new account
const account = web3.eth.accounts.create();
/*
{
address: '0x0770B4713B62E0c08C43743bCFcfBAA39Fa703EF',
Expand All @@ -50,10 +64,8 @@ console.log(account)
}
*/

// 3rd - add the account to the wallet
web3.eth.accounts.wallet.add(account);

console.log(wallet);
// 2nd - add the account to the wallet
const wallet = web3.eth.accounts.wallet.add(account);
/*
Wallet(1) [
{
Expand Down Expand Up @@ -81,27 +93,9 @@ import { Web3 } from 'web3';

const web3 = new Web3(/* PROVIDER */);

// 1st - creating a new empty wallet
const wallet = web3.eth.accounts.wallet.create()

console.log(wallet);
/*
> Wallet(0) [
_accountProvider: {
create: [Function: createWithContext],
privateKeyToAccount: [Function: privateKeyToAccountWithContext],
decrypt: [Function: decryptWithContext]
},
_addressMap: Map(0) {},
_defaultKeyName: 'web3js_wallet'
]
*/

// 2nd - add an account to the wallet using a private key
// add an account to the wallet using a private key
const privateKey = '0x4651f9c219fc6401fe0b3f82129467c717012287ccb61950d2a8ede0687857ba'
web3.eth.accounts.wallet.add(privateKey);

console.log(wallet);
const wallet = web3.eth.accounts.wallet.add(privateKey);
/*
Wallet(1) [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_eth/eth.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ transactionHash {
98999580000000000000 + 1000000000000000000 + (20000000000\*21000) = 100 Ether
:::

In the next example, we are going to use `estimateGas` function to see the expected gas for contract deployment. (For more on contracts, please see the corresponding tutotial). Create a file named `estimate.ts` and fill it with the following code:
In the next example, we are going to use `estimateGas` function to see the expected gas for contract deployment. (For more on contracts, please see the corresponding tutorial). Create a file named `estimate.ts` and fill it with the following code:

```typescript
import { Web3, ETH_DATA_FORMAT, DEFAULT_RETURN_FORMAT } from 'web3';
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_plugin_guide/plugin_authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ It is important to note that the plugin name should be structured as `@<organiza
}
```

When your users install your plugin, this will allow the package manager to make use of the user installed `web3` if available and if the version satisfies the version constraints instead of installing it's own version of `web3`.
When your users install your plugin, this will allow the package manager to make use of the user installed `web3` if available and if the version satisfies the version constraints instead of installing its own version of `web3`.

## Add New Transaction Type

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ WebSocket Provider allows us to communicate with the Ethereum node via WebSocket
Follow these steps to connect to the Ethereum network using WebSocket provider:

:::tip
The first 3 steps are the same as in the pervious section. So, you may skip them if you already executed the previous section.
The first 3 steps are the same as in the previous section. So, you may skip them if you already executed the previous section.
:::

1. Open a command prompt or terminal window and navigate to where you would like to create the folder for this example.
Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const config = {
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:title', content: 'Web3.js Documentation' },
{ name: 'twitter:description', content: 'Official documentation for web3.js, the Type/JavaScript library for interacting with the Ethereum blockchain.' },
{ name: 'twitter:image', content: 'https://pbs.twimg.com/profile_images/1746099108937363456/duG_Pqem_400x400.jpg' },
{ name: 'twitter:image', content: 'https://raw.githubusercontent.com/web3/web3.js/4.x/assets/logo/web3js.jpg' },
],
}),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const parseAndValidatePrivateKey = (data: Bytes, ignoreLength?: boolean):
/**
*
* Hashes the given message. The data will be `UTF-8 HEX` decoded and enveloped as follows:
* `"\\x19Ethereum Signed Message:\\n" + message.length + message` and hashed using keccak256.
* `"\x19Ethereum Signed Message:\n" + message.length + message` and hashed using keccak256.
*
* @param message - A message to hash, if its HEX it will be UTF8 decoded.
* @returns The hashed message
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/test/unit/tx/legacy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('[Transaction]', () => {
expect(tx.r!.toString(16)).toBe('5');
});

it('Initialization -> throws when creating a a transaction with incompatible chainid and v value', () => {
it('Initialization -> throws when creating a transaction with incompatible chainid and v value', () => {
let common = new Common({ chain: Chain.Goerli, hardfork: Hardfork.Petersburg });
let tx = Transaction.fromTxData({}, { common });
expect(tx.common.chainId()).toEqual(BigInt(5));
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-validator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ yarn add web3-validator

### Usage

You can use the the validator by importing as and using to validate;
You can use the validator by importing as and using to validate;

```ts
import { validator } from 'web3-validator';
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/test/e2e/get_balance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe(`${getSystemTestBackend()} tests - getBalance`, () => {
switch (format) {
case 'NUMBER_HEX':
/**
* @NOTE toHex assumes if a string is passed it's a hexidecimal
* @NOTE toHex assumes if a string is passed it's a hexadecimal
* which is why the number string, expectedBalance, is being
* converted to a BigInt
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/test/integration/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
jest.mock('web3-eth');

describe('Contract', () => {
describe('Contract use the the context wallet', () => {
describe('Contract use the context wallet', () => {
it('should work when created as web.eth.Contract', async () => {
const web3 = new Web3('https://rpc2.sepolia.org');
const contract = new web3.eth.Contract(
Expand Down

1 comment on commit 04d13d9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 04d13d9 Previous: 6c075db Ratio
processingTx 9417 ops/sec (±4.24%) 9301 ops/sec (±4.81%) 0.99
processingContractDeploy 41203 ops/sec (±6.92%) 39129 ops/sec (±7.62%) 0.95
processingContractMethodSend 19673 ops/sec (±7.31%) 19443 ops/sec (±5.19%) 0.99
processingContractMethodCall 39309 ops/sec (±5.71%) 38971 ops/sec (±6.34%) 0.99
abiEncode 45126 ops/sec (±6.81%) 44252 ops/sec (±6.92%) 0.98
abiDecode 31515 ops/sec (±8.55%) 30419 ops/sec (±8.89%) 0.97
sign 1630 ops/sec (±3.44%) 1656 ops/sec (±4.08%) 1.02
verify 382 ops/sec (±0.62%) 373 ops/sec (±0.78%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.