# g1-papi 👴🏼

A library for interacting with the [G1 duniter](https://duniter.org) API.\
Use [polkadot-api](https://papi.how) (papi) to interact with the Polkadot blockchain.\
Not ~~polkadot.js~~.

## Features

* ✨ Fully customized [eslint](https://eslint.org/) configuration based on the config by [Antfu](https://github.com/antfu/eslint-config)
* 🧪 Write tests quickly and conveniently with [vitest](https://vitest.dev/)
* 🤝 Supports [conventional commits](https://www.conventionalcommits.org/)
* 💅 Generate beautiful changelogs with [changelogen](https://github.com/unjs/changelogen)
* ♾️ GitHub CI for your build
* 📢 Issue templates
* 📝 Pull request template
* 🤖 Ready configuration for [renovatebot](https://github.com/apps/renovate) with [renovate-config](https://github.com/hywax/renovate-config)
* 🚀 Library releases with just one command

## Get started

Install dependencies:

```bash
pnpm i
```

Start a local instance of Duniter:

Place duniter-mocks next to the g1-papi project:
```bash
git clone https://github.com/duniter/duniter-mocks.git
```

Generate the local.json file:

```bash
pnpm duniter:generate
```

```bash
pnpm duniter:start
pnpm duniter:sealing # with sealing mode
```

Run tests:

```bash
pnpm test:ui
```
It runs Vitest UI in standalone mode.
Go to [http://localhost:51204/__vitest__/](http://localhost:51204/__vitest__/) to watch live tests.
Launch the tests, it will automatically restart duniter in sealing mode before running tests.

### GitHub Template

This project is based on the template [vite-vanilla-library-template](https://github.com/hywax/vite-vanilla-library-template).

## Npm scripts

It uses `pnpm` as package manager.

- `dev` - Start the development server
- `build` - Build for production
- `release` - Generate changelog and npm publish
- `lint` - Checks your code for any linting errors
- `test` - Run all tests
- `test:ui` - Run all tests with UI
- `test:watch` - Run all tests with watch mode
- `test:coverage` - Run all tests with code coverage report
- `papi` - Generate types from local instance of Duniter
- `prepare` - Script for setting up husky hooks
- `duniter:start` - Start a local instance of Duniter
- `duniter:sealing` - Start a local instance of Duniter with sealing enabled
- `duniter:stop` - Stop the local instance of Duniter

## Vault in `test/gcli.sqlite`

```
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ SS58 Address                                           Crypto    Path        Name    │
╞══════════════════════════════════════════════════════════════════════════════════════╡
│ 5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV       sr25519   <Base>      base    │
│ ├ 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY               //Alice     Alice   │
│ │ ├ 5Dc96kiTPTfZHmq6yTFSqejJzfUNfQQjneNesRWf9MDppJsd             //0         0       │
│ │ ├ 5Ecc8G1JPhegXjCruhX2xk8PcSycis136rASEKSv558XvTZu             //1         1       │
│ │ ├ 5EoE7wjzjqYJPGAs382aDWEFpMFgP4H62pRC3MR6Q9ZT6zHC             //30        30      │
│ ├ 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty               //Bob       Bob     │
│ ├ 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y               //Charlie   Charlie │
│ ├ 5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy               //Dave      Dave    │
│ ├ 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw               //Eve       Eve     │
└──────────────────────────────────────────────────────────────────────────────────────┘
```

## License

This template was created under the [MIT License](LICENSE).
