Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aquiladev/bls-snap
The MetaMask Snap for BLS Wallet
https://github.com/aquiladev/bls-snap
bls bls-wallet metamask snap
Last synced: about 1 month ago
JSON representation
The MetaMask Snap for BLS Wallet
- Host: GitHub
- URL: https://github.com/aquiladev/bls-snap
- Owner: aquiladev
- License: apache-2.0
- Created: 2022-10-08T02:41:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-26T20:57:47.000Z (about 1 year ago)
- Last Synced: 2024-11-02T11:22:55.641Z (about 2 months ago)
- Topics: bls, bls-wallet, metamask, snap
- Language: TypeScript
- Homepage: https://aquiladev.github.io/bls-snap
- Size: 14.8 MB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.APACHE2
Awesome Lists containing this project
- awesome-metamask-snaps - aquiladev/bls-snap - The MetaMask Snap for BLS Wallet (Snaps)
README
# BLS Snap · [![npm version](https://img.shields.io/npm/v/@aquiladev/bls-snap.svg?style=flat)](https://www.npmjs.com/package/@aquiladev/bls-snap)
The MetaMask Snap for [BLS Wallet](https://blswallet.org/)
https://user-images.githubusercontent.com/1164492/214146350-eb910e0c-fcb3-4656-965d-6cbf19021675.mov
## Terminology
1. Action - Smart contract calldata (includes target contract, data and value).
2. Operation - Ordered list of actions.
3. Bundle - Ordered list of operations.
4. Aggreegator - Service which accepts BLS signed transactions and bundles them into one for submission.## Prerequisites
1. [Chrome browser](https://www.google.com/chrome/)
2. [MetaMask Flask](https://metamask.io/flask/)Install MetaMask Flask in your Chrome browser. If you have MetaMask installed, you need to disable it because MetaMask does not support Snaps and cannot work with MetaMask Flask at the same time. Take a look [FAQ](https://metamask.io/flask/#flask-fa-qs)
3. [Node.js v16+](https://nodejs.org/download/release/v16.13.2/)
4. [Yarn](https://yarnpkg.com/getting-started/install)## Getting Started
1. Clone the repository
```
mkdir ./bls-snap
cd ./bls-snap
git clone https://github.com/aquiladev/bls-snap.git .
```
2. Install dependencies
```
yarn install
```
3. Run snap with UI
```
yarn start
```
**Note:** If you have issues on the snap installation, take a look **Troubleshooting** block.
4. Run tests
```
yarn test
```## Snap APIs
The snap has APIs which allow dapps communicate with it.
A dapp must request MetaMask, in order to invoke snap API
```
await ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId,
request: {
method: {SNAP_API},
params: {SNAP_API_PARAMS},
},
},
})
```### List of APIs
- `ping` - Test API, dapp can hit the API and receive `pong` in response.
- `bls_getNetworks` - Returns list of supported networks with their configurations.
- `bls_recoverAccounts` - Returns list of accounts from snap state.
- `bls_createAccount` - Creates and returns new account. Snap uses seedprase from MetaMask through its API `snap_getBip44Entropy` in order to generate accounts. It allows to re-create the same accounts after snap re-installation.
- `bls_addErc20Token` - Adds ERC20 token to snap state.
- `bls_getErc20Tokens` - Returns list of ERC20 tokens from snap state.
- `bls_removeErc20Token` - Removes ERC20 token from snap state.
- `bls_getErc20TokenBalance` - Returns ERC20 token balance from snap state.
- `bls_getActions` - Returns list of actions from snap state.
- `bls_addAction` - Adds new action to snap state.
- `bls_removeAction` - Removes action from snap state.
- `bls_getBundles` - Returns list of bundles from snap state.
- `bls_getBundle` - Returns the bundle from snap state with status check.
- `bls_sendBundle` - Signs and sends new bundle with ordered list of operations to an aggreegator.### API params
| API | Required | Optional |
| -------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------- |
| `ping` | |
| `bls_getNetworks` | |
| `bls_recoverAccounts` | `chainId` |
| `bls_createAccount` | `chainId` | `addressIndex` |
| `bls_addErc20Token` | `chainId`,
`tokenAddress`,
`tokenName`,
`tokenSymbol` | `tokenDecimals` (default: 18) |
| `bls_getErc20Tokens` | `chainId` |
| `bls_removeErc20Token` | `chainId`,
`tokenAddress` |
| `bls_getErc20TokenBalance` | `chainId`,
`tokenAddress`,
`userAddress` |
| `bls_getActions` | `chainId`,
`senderAddress` |
| `bls_addAction` | `chainId`,
`senderAddress`,
`contractAddress`,
`encodedFunction` | `value` (default: 0),
`functionFragment` |
| `bls_removeAction` | `chainId`,
`id` |
| `bls_getBundles` | `chainId`,
`senderAddress` |
| `bls_getBundle` | `chainId`,
`bundleHash` |
| `bls_sendBundle` | `chainId`,
`senderAddress`,
`actionIds` |## Troubleshooting
1. `mcl-wasm` has strange behaviour during execution in snap sandbox.
one line changed in file `mcl_c.js`:
```
if (scriptDirectory.indexOf("blob:") !== 0) {
```
to
```
if (typeof scriptDirectory === 'string' && scriptDirectory.indexOf("blob:") !== 0) {
```
**Note:** This fix requires snap re-installation. You need to build the snap, remove it from MetaMask and install it again.