Skip to content

Commit

Permalink
add readme + license
Browse files Browse the repository at this point in the history
  • Loading branch information
voliva committed Aug 21, 2024
1 parent 683636a commit 0d941af
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Streamsphere Labs

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.
65 changes: 24 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
# React + TypeScript + Vite
# PAPI Actions

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
This is a proof-of-concept for an intent system to simplify common use cases when interacting with blockchains.

Currently, two official plugins are available:
This will be a series of intents, a routing system that uniquely identifies one action to be performed, which can be implemented by dApps or extensions.

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
The idea is that anyone can "Create an action", which is serialised into a route, and then this route can be shared to other peers. A dApp implementation that supports that intent can then perform the action based on the user's state.

## Expanding the ESLint configuration
As an example, the `send` action defines the intent of sending a specified amount of a specific token to an address of a chain, through the route `/send/${chain}/${address}?amount=${amount}&token=${token}`.

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
When a user opens this route with a dApp that supports this intent, the dApp should look at the user's accounts, find where it has balances throughout the addresses and offer the user the choice of where the tokens should come from. It can then hide all the complexity of whether the `send` action is executed as a `Balances.transfer_keep_alive`, `XcmPallet.teleport_assets` or `XcmPallet.reserve_transfer_assets`, as it's not necessarily something a user needs to be familiar with in order to complete the action.

- Configure the top-level `parserOptions` property like this:
The intent system is completely independent from the dApp implementation though. There could be dApps that target more technically-experienced users, and dApps which are more user-friendly.

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```
## Getting started

To run the demo of this PoC, you need NodeJS and pnpm installed, then run the following commands:

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react'

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```sh
pnpm i
pnpm vite dev
```

You can now open the address vite is listening with your browser of choice. You can set the route in the URL for some example actions:

- Send 3 WND to a `westend` account: `/send/westend/5FxrUu1PUugUYs6HQ83bDswjGLyHYTEzm7yqmrkKVPaYe71Y?amount=3&token=WND`
- Delegate vote to an account in `polkadot`: `/delegate/polkadot/13EyMuuDHwtq5RD6w3psCJ9WvJFZzDDion6Fd2FVAqxz1g7K`

You can also create your own actions from the landing page of the dApp.

## License

MIT - Refer to [LICENSE](https://github.com/polkadot-api/web3-blockspace-actions/blob/main/LICENSE)

0 comments on commit 0d941af

Please sign in to comment.