Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configure the plugin, add first method #1

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 40 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
web3-plugin-template
===========
# Web3.js Plugin for Wallet RPC methods

This is a template for creating a repository for web3.js plugin.
This Web3.js plugin adds support for the following wallet-related RPC methods:

How to use
------------
- wallet_addEthereumChain (EIP-3085)
- wallet_updateEthereumChain (EIP-2015)
- wallet_switchEthereumChain (EIP-3326)
- wallet_getOwnedAssets (EIP-2256)
- wallet_watchAsset (EIP-747)
- wallet_requestPermissions (EIP-2255)
- wallet_getPermissions (EIP-2255)

1. Create your project out of this template.
## Installation

You can do so by pressing on `Use this template` on the above right corner and then select `Create new Repositor`. Please, use the convention `web3-plugin-<name>` for your repo name.
2. Update the `name` and `description` fileds at your `package.json`.
Use your preferred package manager. Ensure that `web3` is also installed and integrated into your project.

Chose a name like: `@<organization>/web3-plugin-<name>` (or the less better `web3-plugin-<name>`).
3. Update the code inside `src` folder.
```bash
npm install web3-plugin-wallet-rpc
```

4. Modify and add tests inside `test` folder.
```bash
yarn add web3-plugin-wallet-rpc
```

5. Publish to the npm registry.
```bash
pnpm add web3-plugin-wallet-rpc
```

You can publish with something like: `yarn build && npm publish --access public`.
## Usage

Contributing
------------
### Register plugin

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.
```typescript
import { WalletRpcPlugin } from "web3-plugin-wallet-rpc";
web3 = new Web3(/* provider here */);
web3.registerPlugin(new WalletRpcPlugin());
```

Please make sure to update tests as appropriate.
### Methods

License
-------
#### addEthereumChain

```typescript
await web3.walletRpc.addEthereumChain({ chainId: "0x1388" }); // chainId 5000 is Mantle Mainnet
```

## Contributing

We welcome pull requests! For major changes, please open an issue 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/)
23 changes: 23 additions & 0 deletions examples/react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
21 changes: 21 additions & 0 deletions examples/react/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 web3js-react-dapp-demo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions examples/react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Web3.js + React Demonstration dApp

This project is a demonstration dApp built with [Web3.js](https://web3js.org/)
and [React](https://react.dev/).

- [Web3.js Docs](https://docs.web3js.org/)
- [React Docs](https://react.dev/learn)

This project was bootstrapped with
[Create React App](https://github.com/facebook/create-react-app).

## Getting Started

Install the project dependencies with a dependency manager like npm or Yarn. Use
`npm start` to start a local development server and navigate to
http://localhost:3000 to view the dApp.
Loading
Loading