From 27f9652b3d5463569294cb8bbd3e78886ecfff90 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 22 May 2023 11:43:50 -0400 Subject: [PATCH] update docs so web is imported by default --- docs/docs/guides/sign_and_send_tx/local_wallet.md | 4 ++-- docs/docs/guides/sign_and_send_tx/raw.md | 4 ++-- docs/docs/guides/sign_and_send_tx/wallet_of_eth_node.md | 4 ++-- docs/docs/guides/web3_providers_guide/events_listening.md | 2 +- docs/docs/guides/web3_providers_guide/index.md | 2 +- .../deploying_and_interacting_with_smart_contracts.md | 6 +++--- packages/web3-eth/src/index.ts | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/docs/guides/sign_and_send_tx/local_wallet.md b/docs/docs/guides/sign_and_send_tx/local_wallet.md index 408c1aaea57..d1300a29d59 100644 --- a/docs/docs/guides/sign_and_send_tx/local_wallet.md +++ b/docs/docs/guides/sign_and_send_tx/local_wallet.md @@ -11,7 +11,7 @@ The simplest way to sign and send transactions is using a local wallet: ```ts // First step: initialize `web3` instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: add an account to wallet @@ -45,7 +45,7 @@ List of references: ```ts // First step: initialize `web3` instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: add an account to wallet diff --git a/docs/docs/guides/sign_and_send_tx/raw.md b/docs/docs/guides/sign_and_send_tx/raw.md index 73f3d268ba0..518c54fbf08 100644 --- a/docs/docs/guides/sign_and_send_tx/raw.md +++ b/docs/docs/guides/sign_and_send_tx/raw.md @@ -9,7 +9,7 @@ sidebar_label: 'Raw Transaction' ```ts // First step: initialize web3 instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: convert private key to account @@ -43,7 +43,7 @@ List of references: ```ts // First step: initialize web3 instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: convert private key to account diff --git a/docs/docs/guides/sign_and_send_tx/wallet_of_eth_node.md b/docs/docs/guides/sign_and_send_tx/wallet_of_eth_node.md index 5cf557a2dc7..a42494281a2 100644 --- a/docs/docs/guides/sign_and_send_tx/wallet_of_eth_node.md +++ b/docs/docs/guides/sign_and_send_tx/wallet_of_eth_node.md @@ -11,7 +11,7 @@ If Eth node have unlocked account in its wallet you can send transaction without ```ts // First step: initialize web3 instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: add an account to the Ethereum node and unlock it @@ -54,7 +54,7 @@ List of references: ```ts // First step: initialize web3 instance -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); // Second step: add an account to the Ethereum node and unlock it diff --git a/docs/docs/guides/web3_providers_guide/events_listening.md b/docs/docs/guides/web3_providers_guide/events_listening.md index 13e134ca003..99badf989a3 100644 --- a/docs/docs/guides/web3_providers_guide/events_listening.md +++ b/docs/docs/guides/web3_providers_guide/events_listening.md @@ -21,7 +21,7 @@ Actually, the events can be categorized as follows ([according to EIP 1193](http Below a sample code for listening and remove listening to EIP 1193 events: ```ts -import { Web3 } from 'web3' +import Web3 from 'web3' const web3 = new Web3(/* PROVIDER*/); diff --git a/docs/docs/guides/web3_providers_guide/index.md b/docs/docs/guides/web3_providers_guide/index.md index 236bba2ac0e..3d1b0cd29e1 100644 --- a/docs/docs/guides/web3_providers_guide/index.md +++ b/docs/docs/guides/web3_providers_guide/index.md @@ -8,7 +8,7 @@ sidebar_label: 'Providers' Connecting to a chain happens through a provider. You can pass the provider to the constructor as in the following example: ```ts -import { Web3 } from 'web3'; +import Web3 from 'web3'; const web3 = new Web3(/* PROVIDER*/); diff --git a/docs/docs/tutorials/deploying_and_interacting_with_smart_contracts.md b/docs/docs/tutorials/deploying_and_interacting_with_smart_contracts.md index 3657fc12993..5da74ab75a2 100644 --- a/docs/docs/tutorials/deploying_and_interacting_with_smart_contracts.md +++ b/docs/docs/tutorials/deploying_and_interacting_with_smart_contracts.md @@ -179,7 +179,7 @@ Note that we are installing the latest version of 4.x, at the time of this tutor Next, create a new file called `index.js` in your project directory and add the following code to it: ```javascript -const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import { Web3 } from 'web3'`) +const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import Web3 from 'web3'`) // Set up a connection to the Ganache network const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545')); @@ -214,7 +214,7 @@ Create a file named `deploy.js` and fill it with the following code: ```javascript // For simplicity we use `web3` package here. However, if you are concerned with the size, // you may import individual packages like 'web3-eth', 'web3-eth-contract' and 'web3-providers-http'. -const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import { Web3 } from 'web3'`) +const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import Web3 from 'web3'`) const fs = require('fs'); const path = require('path'); @@ -289,7 +289,7 @@ In this step, we will use web3.js to interact with the smart contract on the Gan Create a file named `interact.js` and fill it with the following code: ```javascript -const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import { Web3 } from 'web3'`) +const { Web3 } = require('web3'); // web3.js has native ESM builds and (`import Web3 from 'web3'`) const fs = require('fs'); const path = require('path'); diff --git a/packages/web3-eth/src/index.ts b/packages/web3-eth/src/index.ts index 989e19efe12..a04620d500a 100644 --- a/packages/web3-eth/src/index.ts +++ b/packages/web3-eth/src/index.ts @@ -36,7 +36,7 @@ along with web3.js. If not, see . * * To use this package within the `web3` object use: * ```ts - * import { Web3 } from 'web3'; + * import Web3 from 'web3'; * * const web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546'); * web3.eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1').then(console.log);