diff --git a/README.md b/README.md index bc19b7a..f18b2cf 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,6 @@ This Web3.js plugin adds support for the following wallet-related RPC methods: - [wallet_getPermissions (EIP-2255)](https://eips.ethereum.org/EIPS/eip-2255) - [wallet_revokePermissions](https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_revokepermissions/) -Experimental - These methods require further investigation, as other libraries don’t implement them and wallets appear not to support them: - -- [wallet_updateEthereumChain (EIP-2015)](https://eips.ethereum.org/EIPS/eip-2015) -- [wallet_getOwnedAssets (EIP-2256)](https://eips.ethereum.org/EIPS/eip-2256) - Keep reading for more information, or refer to the comprehensive [API documentation](https://web3.github.io/web3-wallet-rpc-utils/). ## Installation @@ -119,7 +114,7 @@ const permissions = await web3.walletRpc.revokePermissions({ ## Contributing -We welcome pull requests! For major changes, please open an issue first to discuss the proposed modifications. +We welcome pull requests! For major changes, please [open an issue](https://github.com/web3/web3-wallet-rpc-utils) first to discuss the proposed modifications. Also, ensure that you update tests as needed to reflect the changes. ## License diff --git a/packages/web3-plugin-wallet-rpc/README.md b/packages/web3-plugin-wallet-rpc/README.md index 7d48434..cf66ba0 100644 --- a/packages/web3-plugin-wallet-rpc/README.md +++ b/packages/web3-plugin-wallet-rpc/README.md @@ -1,120 +1,3 @@ # Web3.js Plugin for Wallet RPC methods -This Web3.js plugin adds support for the following wallet-related RPC methods: - -- [wallet_addEthereumChain (EIP-3085)](https://eips.ethereum.org/EIPS/eip-3085) -- [wallet_switchEthereumChain (EIP-3326)](https://eips.ethereum.org/EIPS/eip-3326) -- [wallet_watchAsset (EIP-747)](https://eips.ethereum.org/EIPS/eip-747) -- [wallet_requestPermissions (EIP-2255)](https://eips.ethereum.org/EIPS/eip-2255) -- [wallet_getPermissions (EIP-2255)](https://eips.ethereum.org/EIPS/eip-2255) -- [wallet_revokePermissions](https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_revokepermissions/) - -## Installation - -Use your preferred package manager. Ensure that `web3` is also installed and integrated into your project. - -```bash -npm install web3-plugin-wallet-rpc -``` - -```bash -yarn add web3-plugin-wallet-rpc -``` - -```bash -pnpm add web3-plugin-wallet-rpc -``` - -## Usage - -### Register plugin - -```typescript -import { Web3 } from 'web3'; -import { WalletRpcPlugin } from 'web3-plugin-wallet-rpc'; - -const web3 = new Web3('https://eth.llamarpc.com'); -web3.registerPlugin(new WalletRpcPlugin()); -``` - -### Methods - -Click on the method name for detailed documentation. - -#### [addEthereumChain](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#addEthereumChain) - -Invokes the `wallet_addEthereumChain` method as defined in [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085#wallet_addethereumchain). - -```typescript -await web3.walletRpc.addEthereumChain({ - chainId: 5000, - blockExplorerUrls: ['https://mantlescan.xyz'], - chainName: 'Mantle', - iconUrls: ['https://icons.llamao.fi/icons/chains/rsz_mantle.jpg'], - nativeCurrency: { - name: 'Mantle', - symbol: 'MNT', - decimals: 18, - }, - rpcUrls: ['https://rpc.mantle.xyz'], -}); -``` - -#### [switchEthereumChain](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#switchEthereumChain) - -Invokes the `wallet_switchEthereumChain` method as defined in [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain). - -```typescript -await web3.walletRpc.switchEthereumChain(5000); -``` - -#### [watchAsset](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#watchAsset) - -Invokes the `wallet_watchAsset` method as defined in [EIP-747](https://eips.ethereum.org/EIPS/eip-747#specification). - -```typescript -await web3.walletRpc.watchAsset({ - type: 'ERC20', - options: { - address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - symbol: 'USDC', - }, -}); -``` - -#### [requestPermissions](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#requestPermissions) - -Invokes the `wallet_requestPermissions` method as defined in [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255#specification). - -```typescript -const permissions = await web3.walletRpc.requestPermissions({ - eth_accounts: {}, -}); -``` - -#### [getPermissions](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#getPermissions) - -Invokes the `wallet_getPermissions` method as defined in [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255#specification). - -```typescript -const permissions = await web3.walletRpc.getPermissions(); -``` - -#### [revokePermissions](https://web3.github.io/web3-wallet-rpc-utils/classes/WalletRpcPlugin.html#revokePermissions) - -Invokes the `wallet_revokePermissions` method as defined in [MetaMask docs](https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_revokepermissions/). - -```typescript -const permissions = await web3.walletRpc.revokePermissions({ - eth_accounts: {}, -}); -``` - -## Contributing - -We welcome pull requests! For major changes, please [open an issue](https://github.com/web3/web3-wallet-rpc-utils) first to discuss the proposed modifications. -Also, ensure that you update tests as needed to reflect the changes. - -## License - -[MIT](https://choosealicense.com/licenses/mit/) +Refer to the [README](../../README.md) file located in the root of this repository. diff --git a/packages/web3-plugin-wallet-rpc/package.json b/packages/web3-plugin-wallet-rpc/package.json index 9761dea..86d67a1 100644 --- a/packages/web3-plugin-wallet-rpc/package.json +++ b/packages/web3-plugin-wallet-rpc/package.json @@ -11,7 +11,7 @@ "scripts": { "lint": "eslint '{src,test}/**/*.ts'", "build": "tsc --project tsconfig.build.json", - "build:docs": "npx typedoc ./src/index.ts", + "build:docs": "npx typedoc ./src/index.ts --readme ../../README.md", "test": "jest --config=./test/jest.config.js" }, "contributors": [