web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Init `web3-rpc-methods` package

Open spacesailor24 opened this issue 3 years ago • 1 comments

Note There are a huge amount of files changed, but most of these files are tests where the only change was an import change to import { ethRpcMethods } from 'web3-rpc-methods';

This PR pulls out necessary changes for #5426 into a separate PR to reduce the amount of changes that need to be reviewed in a single PR

Why This PR Exists

One of the first problems I ran into when working on #5426 was circular dependencies. This was primarily because certain test utils (e.g. creating and funding accounts) needed to send RPC request to fetch accounts and send transactions (imported via web3-eth). Naturally, the test utils that currently exist and the refactor (#5426) are intended to be used by packages such as web3-eth, and this is where the circular dependencies start to show up: web3-test-utils -> web3-eth -> web3-test-utils (Note circular dependencies currently exist with current test utils, they just aren't reported via Lerna/Yarn because the test utils are symlinked into each package instead of actually being apart of each package with their dependencies declared via package.json). This PR alone does not address all the circular dependency issues I discovered while working on #5426, there will be a subsequent PR that depends on this one that will address other issues via a web3-transaction-utils package

What This PR Does

CHANGELOG.mds with specific changes are provided below, but as a high level overview:

  • Bare bone RPC method wrapper functions (not the rpc_method_wrappers.ts that provide niceties such as formatting) are moved from packages: web3-eth, web3-eth-net, and web3-eth-personal to a new package: web3-rpc-methods
    • This helps alleviate circular dependency issues by allowing other packages (e.g. web3-test-utils from #5426) to use the RPC method wrappers without having to import packages such as web3-eth or having to write one-off RPC method wrappers like so)
  • Moves:
    • EthPersonalAPI
    • Web3EthExecutionAPI
    • Web3NetAPI into web3-types from their original packages (web3-eth-personal, web3-eth, and web3-net respectively)

web3-eth-ens

Changed

  • Web3NetAPI is now imported from web3-types instead of web3-types (#5441)

web3-eth-personal

Added

  • web3-rpc-methods dependency (#5441)

Changed

  • Import EthPersonalAPI from web3-types instead of local import (#5441)
  • Replace the imported methods from rcp_methods.ts with personalRpcMethods imports from web3-rpc-methods (#5441)
  • Replace use of EthPersonalAPIManager with Web3RequestManager<EthPersonalAPI> (#5441)

Removed

  • Exported type EthPersonalAPIManager, EthPersonalAPI is not exported via web3-types (#5441)

web3-eth

Added

  • web3-rpc-methods dependency (#5441)

Changed

  • Web3EthExecutionAPI is now imported via web3-types instead of web3_eth_execution_api.ts (#5441)
  • Replace the imported methods from rpc_methods.ts with ethRpcMethods imports from web3-rpc-methods (#5441)
  • Web3NetAPI is now imported from web3-types instead of web3-net (#5441)
  • Moved rpc_methods tests to web3-rpc-methods (#5441)

web3-net

Added

  • web3-rpc-methods dependency (#5441)

Changed

  • Web3NetAPI is now imported from web3-types instead of web3_net_api.ts (#5441)
  • Replace the imported methods from rpc_methods.ts with netRpcMethods imports from web3-rpc-methods (#5441)

Removed

  • rpcMethods export, these methods are now exported via web3-rpc-methods as netRpcMethods (#5441)
  • Web3NetAPI export, now exported via web3-types as Web3NetAPI (#5441)

web3-types

Added

  • Web3EthExecutionAPI export (#5441)
  • Web3NetAPI export (#5441)
  • EthPersonalAPI export (#5441)

spacesailor24 avatar Sep 15 '22 01:09 spacesailor24

Your Render PR Server URL is https://web3js-docs-pr-5441.onrender.com.

Follow its progress at https://dashboard.render.com/static/srv-cch7slqrrk02bi4tu4l0.

render[bot] avatar Sep 15 '22 01:09 render[bot]