From b582d00ac9aa162abe931f134171ad779aed8060 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 28 Nov 2023 10:10:26 +0100 Subject: [PATCH 1/3] Automatically pull chain id --- .../getting-started/networks-endpoints.mdx | 5 +- theme/package.json | 3 +- theme/src/theme/GetChainId/index.tsx | 26 ++ yarn.lock | 395 +++++++++++++++++- 4 files changed, 424 insertions(+), 5 deletions(-) create mode 100644 theme/src/theme/GetChainId/index.tsx diff --git a/docs/build/getting-started/networks-endpoints.mdx b/docs/build/getting-started/networks-endpoints.mdx index 8f8db9f08d4..2625d15dc99 100644 --- a/docs/build/getting-started/networks-endpoints.mdx +++ b/docs/build/getting-started/networks-endpoints.mdx @@ -14,6 +14,7 @@ keywords: --- import { AddToMetaMaskButton, EVMNetworks } from '@theme/AddToMetaMaskButton'; +import { GetChainId } from '@theme/GetChainId'; # Networks & Endpoints @@ -57,7 +58,7 @@ Mainnet. | Base Token | Protocol | Chain ID | RPC URL | Explorer | | ------------- | --------- | -------- | ----------------------------------------------------------------------------- | ------------------------------------ | -| Shimmer Token | ISC / EVM | 148 | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network | +| Shimmer Token | ISC / EVM | | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network | ## Public Testnet @@ -86,7 +87,7 @@ This network is subject to occasional resets (no data retention) which are usual | Base Token | Protocol | Chain ID | RPC URL | Faucet | Explorer | | ------------------------- | --------- | -------- | -------------------------------------------- | ------------------------------------------ | -------------------------------------------- | -| Testnet Tokens (no value) | ISC / EVM | 1073 | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network | +| Testnet Tokens (no value) | ISC / EVM | | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network | ## DevNet diff --git a/theme/package.json b/theme/package.json index ce17a559b92..941dd190742 100644 --- a/theme/package.json +++ b/theme/package.json @@ -20,7 +20,8 @@ "@metamask/providers": "^10.2.1", "clsx": "^1.2.1", "html-react-parser": "^4.2.2", - "react-markdown": "6" + "react-markdown": "6", + "web3": "^4.2.2" }, "devDependencies": { "@docusaurus/types": "2.4.1", diff --git a/theme/src/theme/GetChainId/index.tsx b/theme/src/theme/GetChainId/index.tsx new file mode 100644 index 00000000000..62ab6a4d09d --- /dev/null +++ b/theme/src/theme/GetChainId/index.tsx @@ -0,0 +1,26 @@ +import React, { useEffect, useState } from 'react'; +import { Web3 } from 'web3'; + +interface GetChainIdProps { + url: string; +} + +export function GetChainId(props: GetChainIdProps) { + const [chainId, setChainId] = useState(null); + const [error, setError] = useState(null); + + console.log(props.url); + + useEffect(() => { + const web3 = new Web3(props.url); + web3.eth.getChainId().then(setChainId).catch(setError); + }, []); + + console.log(chainId); + return ( + <> + {chainId !== null && {chainId.toString()}} + {error !== null && Error: {error.message}} + + ); +} diff --git a/yarn.lock b/yarn.lock index 3357dc57618..0fd4021a2a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19,6 +19,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:^1.8.8": + version: 1.10.0 + resolution: "@adraffy/ens-normalize@npm:1.10.0" + checksum: af0540f963a2632da2bbc37e36ea6593dcfc607b937857133791781e246d47f870d5e3d21fa70d5cfe94e772c284588c81ea3f5b7f4ea8fbb824369444e4dbcb + languageName: node + linkType: hard + "@algolia/autocomplete-core@npm:1.9.3": version: 1.9.3 resolution: "@algolia/autocomplete-core@npm:1.9.3" @@ -2585,6 +2592,15 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/rlp@npm:^4.0.1": + version: 4.0.1 + resolution: "@ethereumjs/rlp@npm:4.0.1" + bin: + rlp: bin/rlp + checksum: 30db19c78faa2b6ff27275ab767646929207bb207f903f09eb3e4c273ce2738b45f3c82169ddacd67468b4f063d8d96035f2bf36f02b6b7e4d928eefe2e3ecbc + languageName: node + linkType: hard + "@exodus/schemasafe@npm:^1.0.0-rc.2": version: 1.0.1 resolution: "@exodus/schemasafe@npm:1.0.1" @@ -2899,6 +2915,7 @@ __metadata: react: 18.2.0 react-markdown: 6 typescript: ^4.9 + web3: ^4.2.2 peerDependencies: react: "*" languageName: unknown @@ -3151,6 +3168,29 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:1.1.0, @noble/curves@npm:~1.1.0": + version: 1.1.0 + resolution: "@noble/curves@npm:1.1.0" + dependencies: + "@noble/hashes": 1.3.1 + checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.3.1": + version: 1.3.1 + resolution: "@noble/hashes@npm:1.3.1" + checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 + languageName: node + linkType: hard + +"@noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.1": + version: 1.3.2 + resolution: "@noble/hashes@npm:1.3.2" + checksum: fe23536b436539d13f90e4b9be843cc63b1b17666a07634a2b1259dded6f490be3d050249e6af98076ea8f2ea0d56f578773c2197f2aa0eeaa5fba5bc18ba474 + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -4224,6 +4264,34 @@ __metadata: languageName: node linkType: hard +"@scure/base@npm:~1.1.0": + version: 1.1.3 + resolution: "@scure/base@npm:1.1.3" + checksum: 1606ab8a4db898cb3a1ada16c15437c3bce4e25854fadc8eb03ae93cbbbac1ed90655af4b0be3da37e12056fef11c0374499f69b9e658c9e5b7b3e06353c630c + languageName: node + linkType: hard + +"@scure/bip32@npm:1.3.1": + version: 1.3.1 + resolution: "@scure/bip32@npm:1.3.1" + dependencies: + "@noble/curves": ~1.1.0 + "@noble/hashes": ~1.3.1 + "@scure/base": ~1.1.0 + checksum: 394d65f77a40651eba21a5096da0f4233c3b50d422864751d373fcf142eeedb94a1149f9ab1dbb078086dab2d0bc27e2b1afec8321bf22d4403c7df2fea5bfe2 + languageName: node + linkType: hard + +"@scure/bip39@npm:1.2.1": + version: 1.2.1 + resolution: "@scure/bip39@npm:1.2.1" + dependencies: + "@noble/hashes": ~1.3.0 + "@scure/base": ~1.1.0 + checksum: c5bd6f1328fdbeae2dcdd891825b1610225310e5e62a4942714db51066866e4f7bef242c7b06a1b9dcc8043a4a13412cf5c5df76d3b10aa9e36b82e9b6e3eeaa + languageName: node + linkType: hard + "@sideway/address@npm:^4.1.3": version: 4.1.4 resolution: "@sideway/address@npm:4.1.4" @@ -5293,6 +5361,15 @@ __metadata: languageName: node linkType: hard +"@types/ws@npm:8.5.3": + version: 8.5.3 + resolution: "@types/ws@npm:8.5.3" + dependencies: + "@types/node": "*" + checksum: 0ce46f850d41383fcdc2149bcacc86d7232fa7a233f903d2246dff86e31701a02f8566f40af5f8b56d1834779255c04ec6ec78660fe0f9b2a69cf3d71937e4ae + languageName: node + linkType: hard + "@types/ws@npm:^8.5.5": version: 8.5.5 resolution: "@types/ws@npm:8.5.5" @@ -5719,6 +5796,19 @@ __metadata: languageName: node linkType: hard +"abitype@npm:0.7.1": + version: 0.7.1 + resolution: "abitype@npm:0.7.1" + peerDependencies: + typescript: ">=4.9.4" + zod: ^3 >=3.19.1 + peerDependenciesMeta: + zod: + optional: true + checksum: de0d7082d28a4835b3d8dc4d8c75e9222c95a1f9eed13d6b2381403b46f46b68ea7a281e8ba6628d259a98c54ea466ebc206eec21db6205fa1641c7393854f5e + languageName: node + linkType: hard + "abort-controller@npm:^3.0.0": version: 3.0.0 resolution: "abort-controller@npm:3.0.0" @@ -7565,7 +7655,7 @@ __metadata: languageName: node linkType: hard -"crc-32@npm:^1.2.0": +"crc-32@npm:^1.2.0, crc-32@npm:^1.2.2": version: 1.2.2 resolution: "crc-32@npm:1.2.2" bin: @@ -7620,6 +7710,15 @@ __metadata: languageName: node linkType: hard +"cross-fetch@npm:^4.0.0": + version: 4.0.0 + resolution: "cross-fetch@npm:4.0.0" + dependencies: + node-fetch: ^2.6.12 + checksum: ecca4f37ffa0e8283e7a8a590926b66713a7ef7892757aa36c2d20ffa27b0ac5c60dcf453119c809abe5923fc0bae3702a4d896bfb406ef1077b0d0018213e24 + languageName: node + linkType: hard + "cross-spawn@npm:7.0.3, cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -9092,6 +9191,18 @@ __metadata: languageName: node linkType: hard +"ethereum-cryptography@npm:^2.0.0": + version: 2.1.2 + resolution: "ethereum-cryptography@npm:2.1.2" + dependencies: + "@noble/curves": 1.1.0 + "@noble/hashes": 1.3.1 + "@scure/bip32": 1.3.1 + "@scure/bip39": 1.2.1 + checksum: 2e8f7b8cc90232ae838ab6a8167708e8362621404d26e79b5d9e762c7b53d699f7520aff358d9254de658fcd54d2d0af168ff909943259ed27dc4cef2736410c + languageName: node + linkType: hard + "ev-emitter@npm:^1.0.0, ev-emitter@npm:^1.0.1, ev-emitter@npm:^1.1.1": version: 1.1.1 resolution: "ev-emitter@npm:1.1.1" @@ -11672,6 +11783,15 @@ __metadata: languageName: node linkType: hard +"isomorphic-ws@npm:^5.0.0": + version: 5.0.0 + resolution: "isomorphic-ws@npm:5.0.0" + peerDependencies: + ws: "*" + checksum: e20eb2aee09ba96247465fda40c6d22c1153394c0144fa34fe6609f341af4c8c564f60ea3ba762335a7a9c306809349f9b863c8beedf2beea09b299834ad5398 + languageName: node + linkType: hard + "jackspeak@npm:^2.0.3": version: 2.2.1 resolution: "jackspeak@npm:2.2.1" @@ -18672,7 +18792,7 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard -"util@npm:^0.12.0, util@npm:^0.12.4": +"util@npm:^0.12.0, util@npm:^0.12.4, util@npm:^0.12.5": version: 0.12.5 resolution: "util@npm:0.12.5" dependencies: @@ -19004,6 +19124,255 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard +"web3-core@npm:^4.3.0, web3-core@npm:^4.3.1": + version: 4.3.1 + resolution: "web3-core@npm:4.3.1" + dependencies: + web3-errors: ^1.1.4 + web3-eth-iban: ^4.0.7 + web3-providers-http: ^4.1.0 + web3-providers-ipc: ^4.0.7 + web3-providers-ws: ^4.0.7 + web3-types: ^1.3.1 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + dependenciesMeta: + web3-providers-ipc: + optional: true + checksum: f6ba6ef0154d9523aee5d9b375f339bf5b817be88fa6f574bde80359104d93c50586c09db3b42044c5ee6a970f84fce5554de5067d17934daa59fb92f4cc9dd5 + languageName: node + linkType: hard + +"web3-errors@npm:^1.1.3, web3-errors@npm:^1.1.4": + version: 1.1.4 + resolution: "web3-errors@npm:1.1.4" + dependencies: + web3-types: ^1.3.1 + checksum: d93cebc391880fa50052e31f05e3b33234e4c230be3172d1c046ae8f52d962f846b5fc002c201d53562f806e0645c5e7eca64c510b57bcfec1afbd294f0b2ffe + languageName: node + linkType: hard + +"web3-eth-abi@npm:^4.1.4": + version: 4.1.4 + resolution: "web3-eth-abi@npm:4.1.4" + dependencies: + abitype: 0.7.1 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: 35b1db84ab4490e71d79709676e173883295225fe433f3f75b77a7ebc5be4474a8feccc19b08ddece292f7195bfa9658f8f312822ac52165d9796c275ac4dd6d + languageName: node + linkType: hard + +"web3-eth-accounts@npm:^4.1.0": + version: 4.1.0 + resolution: "web3-eth-accounts@npm:4.1.0" + dependencies: + "@ethereumjs/rlp": ^4.0.1 + crc-32: ^1.2.2 + ethereum-cryptography: ^2.0.0 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: 9ba35c7dc1ae8e9b4e6873c08d1d2c4ef0c9e12b813fb336f0b9e21aeb7bf71755b62b18ed177c63d9fc79cacaab6e3d24ff74556280e70f414c95ecd3fe7d9d + languageName: node + linkType: hard + +"web3-eth-contract@npm:^4.1.2, web3-eth-contract@npm:^4.1.3": + version: 4.1.3 + resolution: "web3-eth-contract@npm:4.1.3" + dependencies: + web3-core: ^4.3.1 + web3-errors: ^1.1.4 + web3-eth: ^4.3.1 + web3-eth-abi: ^4.1.4 + web3-types: ^1.3.1 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: 3e578ecffb982e67e06269fa53099b39634c81843abdf8b2d048d35089b6d1a8332e9ceba837aec2496740f1f3c620086c6e802cc9be15538e43bb5c74951cd6 + languageName: node + linkType: hard + +"web3-eth-ens@npm:^4.0.8": + version: 4.0.8 + resolution: "web3-eth-ens@npm:4.0.8" + dependencies: + "@adraffy/ens-normalize": ^1.8.8 + web3-core: ^4.3.0 + web3-errors: ^1.1.3 + web3-eth: ^4.3.1 + web3-eth-contract: ^4.1.2 + web3-net: ^4.0.7 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: 78c47d003b7b36845886ca85d815d4209d83f2f112b32abb9a996a87a849840cb79391b40ddd5273337e29642e5b59afecc6e2143a19462cda7bf59f4cba1c2c + languageName: node + linkType: hard + +"web3-eth-iban@npm:^4.0.7": + version: 4.0.7 + resolution: "web3-eth-iban@npm:4.0.7" + dependencies: + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: c21785ece6c69146a605f60ebdd530e8a3faeda4302cbecef4665639c297fc11edd2f0dc8a6f6ba50b3f32d2c252d106687c24e31af3d297d5365a90f9badae0 + languageName: node + linkType: hard + +"web3-eth-personal@npm:^4.0.8": + version: 4.0.8 + resolution: "web3-eth-personal@npm:4.0.8" + dependencies: + web3-core: ^4.3.0 + web3-eth: ^4.3.1 + web3-rpc-methods: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: 73e6f4f10548c1a564a0c8d34b8c841b9c52281a6b19a368d7dcdb4910c7c60310f954c14b05932062fb2f3343cb4102d282399ca1a900e44d4e2317ee8d5d7c + languageName: node + linkType: hard + +"web3-eth@npm:^4.3.1": + version: 4.3.1 + resolution: "web3-eth@npm:4.3.1" + dependencies: + setimmediate: ^1.0.5 + web3-core: ^4.3.0 + web3-errors: ^1.1.3 + web3-eth-abi: ^4.1.4 + web3-eth-accounts: ^4.1.0 + web3-net: ^4.0.7 + web3-providers-ws: ^4.0.7 + web3-rpc-methods: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: b92d363886e62f676ebc94ee83aa9cbe4dff2cafad86e40ca7b182332b0a89ee1ca0ab3a8a6dabb6dcb58ae70f894c1c648bc6683866724e9c8a55ce123fc74d + languageName: node + linkType: hard + +"web3-net@npm:^4.0.7": + version: 4.0.7 + resolution: "web3-net@npm:4.0.7" + dependencies: + web3-core: ^4.3.0 + web3-rpc-methods: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + checksum: c0692e14c13556f2af4fd538c336f59ae347abf441328dd0301dbbd4d380f663869b208d61dcfa14bfbdf00826d6891f577653734dbe1a6367179a84e60cafa8 + languageName: node + linkType: hard + +"web3-providers-http@npm:^4.1.0": + version: 4.1.0 + resolution: "web3-providers-http@npm:4.1.0" + dependencies: + cross-fetch: ^4.0.0 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + checksum: 04275604e0be1d18e6229d51088ebb1399ec726e8134d2a31c398ee7a28c97132718fb4cc7cbc9ff9c50fe6c8200b5d7d7224b2dca7149aa95a63f4777b8164e + languageName: node + linkType: hard + +"web3-providers-ipc@npm:^4.0.7": + version: 4.0.7 + resolution: "web3-providers-ipc@npm:4.0.7" + dependencies: + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + checksum: 83e734d833bd3663bc6d4a802c3eea83144a54244635d81d714913bd2f08a7463610fdb574bbbb1328c730340fea13730d4e33465fbf175d1c747170c142c7a7 + languageName: node + linkType: hard + +"web3-providers-ws@npm:^4.0.7": + version: 4.0.7 + resolution: "web3-providers-ws@npm:4.0.7" + dependencies: + "@types/ws": 8.5.3 + isomorphic-ws: ^5.0.0 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-utils: ^4.0.7 + ws: ^8.8.1 + checksum: 3409aca1965cbefad0d2928f21a3c69176d89e8b77d8a04ad5363a38acb6731caaaf2ad6bd8f24b17a54dbdc51d39ee4041eaa06a3f1ea598d343a626650298f + languageName: node + linkType: hard + +"web3-rpc-methods@npm:^1.1.3": + version: 1.1.3 + resolution: "web3-rpc-methods@npm:1.1.3" + dependencies: + web3-core: ^4.3.0 + web3-types: ^1.3.0 + web3-validator: ^2.0.3 + checksum: 27127cdf20f3951593ec45661fb61e78a26e0fde1bab585a8dc9c676d0daa17902ed7a2f5360f5b5e92b0ba6c675783382a99ed92336b932884b77a378ad8dec + languageName: node + linkType: hard + +"web3-types@npm:^1.3.0, web3-types@npm:^1.3.1": + version: 1.3.1 + resolution: "web3-types@npm:1.3.1" + checksum: 02819f803f926b45843335705343ace1ee6fe84bf5d09be9382532389ce7ef47ed7f95b23ef61330979039442062f0089ab4bac6000cb7246202b17a14b44878 + languageName: node + linkType: hard + +"web3-utils@npm:^4.0.7": + version: 4.0.7 + resolution: "web3-utils@npm:4.0.7" + dependencies: + ethereum-cryptography: ^2.0.0 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + web3-validator: ^2.0.3 + checksum: 8dbf36d1813164efdc70c98ffac86c265c029b4df63a5b5833ad19520ac6782c26d3444fc1f95e1abbc95f17b4041f36f66664d552f5038543805fe5a5260ded + languageName: node + linkType: hard + +"web3-validator@npm:^2.0.3": + version: 2.0.3 + resolution: "web3-validator@npm:2.0.3" + dependencies: + ethereum-cryptography: ^2.0.0 + util: ^0.12.5 + web3-errors: ^1.1.3 + web3-types: ^1.3.0 + zod: ^3.21.4 + checksum: 523eeb48e3b5a04faa53e9073e4b07a6cf493174d3a211c7f299f9efb54e5e555a953e424aae49b7c53d57c2372ce943154c1bfbe8f072a5867550a8dc9ac989 + languageName: node + linkType: hard + +"web3@npm:^4.2.2": + version: 4.2.2 + resolution: "web3@npm:4.2.2" + dependencies: + web3-core: ^4.3.1 + web3-errors: ^1.1.4 + web3-eth: ^4.3.1 + web3-eth-abi: ^4.1.4 + web3-eth-accounts: ^4.1.0 + web3-eth-contract: ^4.1.3 + web3-eth-ens: ^4.0.8 + web3-eth-iban: ^4.0.7 + web3-eth-personal: ^4.0.8 + web3-net: ^4.0.7 + web3-providers-http: ^4.1.0 + web3-providers-ws: ^4.0.7 + web3-rpc-methods: ^1.1.3 + web3-types: ^1.3.1 + web3-utils: ^4.0.7 + web3-validator: ^2.0.3 + checksum: b04f51380196b0b774a90090e10968395beda4a61d3a829e216b302173cd476f8e6e40b81c2691c502b068d6c7fe859df594991a4375023b13a19743e5ef4686 + languageName: node + linkType: hard + "webextension-polyfill-ts@npm:^0.25.0": version: 0.25.0 resolution: "webextension-polyfill-ts@npm:0.25.0" @@ -19394,6 +19763,21 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard +"ws@npm:^8.8.1": + version: 8.14.2 + resolution: "ws@npm:8.14.2" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ">=5.0.2" + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 3ca0dad26e8cc6515ff392b622a1467430814c463b3368b0258e33696b1d4bed7510bc7030f7b72838b9fdeb8dbd8839cbf808367d6aae2e1d668ce741d4308b + languageName: node + linkType: hard + "xdg-basedir@npm:^4.0.0": version: 4.0.0 resolution: "xdg-basedir@npm:4.0.0" @@ -19573,6 +19957,13 @@ plugin-image-zoom@flexanalytics/plugin-image-zoom: languageName: node linkType: hard +"zod@npm:^3.21.4": + version: 3.22.4 + resolution: "zod@npm:3.22.4" + checksum: 80bfd7f8039b24fddeb0718a2ec7c02aa9856e4838d6aa4864335a047b6b37a3273b191ef335bf0b2002e5c514ef261ffcda5a589fb084a48c336ffc4cdbab7f + languageName: node + linkType: hard + "zwitch@npm:^1.0.0": version: 1.0.5 resolution: "zwitch@npm:1.0.5" From cdcddc2a9cb1977ea907da30fdced26997408c08 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Sat, 2 Dec 2023 15:40:12 +0100 Subject: [PATCH 2/3] Update theme/src/theme/GetChainId/index.tsx Co-authored-by: Jeroen van den Hout --- theme/src/theme/GetChainId/index.tsx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/theme/src/theme/GetChainId/index.tsx b/theme/src/theme/GetChainId/index.tsx index 62ab6a4d09d..7fc3b73e32f 100644 --- a/theme/src/theme/GetChainId/index.tsx +++ b/theme/src/theme/GetChainId/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Web3 } from 'web3'; interface GetChainIdProps { @@ -6,21 +6,15 @@ interface GetChainIdProps { } export function GetChainId(props: GetChainIdProps) { - const [chainId, setChainId] = useState(null); - const [error, setError] = useState(null); - - console.log(props.url); + const [value, setValue] = useState(null); useEffect(() => { const web3 = new Web3(props.url); - web3.eth.getChainId().then(setChainId).catch(setError); + web3.eth + .getChainId() + .then((chainId) => setValue(chainId.toString())) + .catch((error) => setValue(`Error: ${error.message}`)); }, []); - console.log(chainId); - return ( - <> - {chainId !== null && {chainId.toString()}} - {error !== null && Error: {error.message}} - - ); + return value; } From fc226f63156c1be35b268375b1077d417c965f10 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Sat, 2 Dec 2023 15:48:32 +0100 Subject: [PATCH 3/3] Rename GetChainId to ChainId --- docs/build/getting-started/networks-endpoints.mdx | 6 +++--- theme/src/theme/{GetChainId => ChainId}/index.tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename theme/src/theme/{GetChainId => ChainId}/index.tsx (82%) diff --git a/docs/build/getting-started/networks-endpoints.mdx b/docs/build/getting-started/networks-endpoints.mdx index 2625d15dc99..e7ba8a4132e 100644 --- a/docs/build/getting-started/networks-endpoints.mdx +++ b/docs/build/getting-started/networks-endpoints.mdx @@ -14,7 +14,7 @@ keywords: --- import { AddToMetaMaskButton, EVMNetworks } from '@theme/AddToMetaMaskButton'; -import { GetChainId } from '@theme/GetChainId'; +import { ChainId } from '@theme/ChainId'; # Networks & Endpoints @@ -58,7 +58,7 @@ Mainnet. | Base Token | Protocol | Chain ID | RPC URL | Explorer | | ------------- | --------- | -------- | ----------------------------------------------------------------------------- | ------------------------------------ | -| Shimmer Token | ISC / EVM | | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network | +| Shimmer Token | ISC / EVM | | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network | ## Public Testnet @@ -87,7 +87,7 @@ This network is subject to occasional resets (no data retention) which are usual | Base Token | Protocol | Chain ID | RPC URL | Faucet | Explorer | | ------------------------- | --------- | -------- | -------------------------------------------- | ------------------------------------------ | -------------------------------------------- | -| Testnet Tokens (no value) | ISC / EVM | | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network | +| Testnet Tokens (no value) | ISC / EVM | | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network | ## DevNet diff --git a/theme/src/theme/GetChainId/index.tsx b/theme/src/theme/ChainId/index.tsx similarity index 82% rename from theme/src/theme/GetChainId/index.tsx rename to theme/src/theme/ChainId/index.tsx index 7fc3b73e32f..e77396f980a 100644 --- a/theme/src/theme/GetChainId/index.tsx +++ b/theme/src/theme/ChainId/index.tsx @@ -1,11 +1,11 @@ import { useEffect, useState } from 'react'; import { Web3 } from 'web3'; -interface GetChainIdProps { +interface ChainIdProps { url: string; } -export function GetChainId(props: GetChainIdProps) { +export function ChainId(props: ChainIdProps) { const [value, setValue] = useState(null); useEffect(() => {