Skip to content

Commit

Permalink
feat(wallet-mimir): mimir wallet integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Feb 24, 2025
1 parent 6606324 commit 1c60402
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/loose-lemons-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reactive-dot/wallet-mimir": minor
---

Added Mimir wallet integration.
10 changes: 9 additions & 1 deletion apps/docs/react/getting-started/connect-wallets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,27 @@ npm install @reactive-dot/wallet-walletconnect
npm install @reactive-dot/wallet-ledger
```

### [Mimir](https://mimir.global/)

```bash npm2yarn
npm install @reactive-dot/wallet-mimir
```

## Add wallets to the config

```ts title="config.ts"
import { defineConfig } from "@reactive-dot/core";
import { InjectedWalletProvider } from "@reactive-dot/core/wallets.js";
import { LedgerWallet } from "@reactive-dot/wallet-ledger";
import { MimirWalletProvider } from "@reactive-dot/wallet-mimir";
import { WalletConnect } from "@reactive-dot/wallet-walletconnect";

export const config = defineConfig({
// ...
wallets: [
new InjectedWalletProvider(),
new LedgerWalet(),
new LedgerWallet(),
new MimirWalletProvider(),
new WalletConnect({
projectId: "WALLET_CONNECT_PROJECT_ID",
providerOptions: {
Expand Down
10 changes: 9 additions & 1 deletion apps/docs/vue/getting-started/connect-wallets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,27 @@ npm install @reactive-dot/wallet-walletconnect
npm install @reactive-dot/wallet-ledger
```

### [Mimir](https://mimir.global/)

```bash npm2yarn
npm install @reactive-dot/wallet-mimir
```

## Add wallets to the config

```ts title="config.ts"
import { defineConfig } from "@reactive-dot/core";
import { InjectedWalletProvider } from "@reactive-dot/core/wallets.js";
import { LedgerWallet } from "@reactive-dot/wallet-ledger";
import { MimirWalletProvider } from "@reactive-dot/wallet-mimir";
import { WalletConnect } from "@reactive-dot/wallet-walletconnect";

export const config = defineConfig({
// ...
wallets: [
new InjectedWalletProvider(),
new LedgerWalet(),
new LedgerWallet(),
new MimirWalletProvider(),
new WalletConnect({
projectId: "WALLET_CONNECT_PROJECT_ID",
providerOptions: {
Expand Down
1 change: 1 addition & 0 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@polkadot-api/descriptors": "portal:.papi/descriptors",
"@reactive-dot/react": "workspace:^",
"@reactive-dot/wallet-ledger": "workspace:^",
"@reactive-dot/wallet-mimir": "workspace:^",
"@reactive-dot/wallet-walletconnect": "workspace:^",
"date-fns": "^4.1.0",
"jotai-devtools": "^0.11.0",
Expand Down
2 changes: 2 additions & 0 deletions examples/react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { defineConfig } from "@reactive-dot/core";
import { createLightClientProvider } from "@reactive-dot/core/providers/light-client.js";
import { InjectedWalletProvider } from "@reactive-dot/core/wallets.js";
import { LedgerWallet } from "@reactive-dot/wallet-ledger";
import { MimirWalletProvider } from "@reactive-dot/wallet-mimir";
import { WalletConnect } from "@reactive-dot/wallet-walletconnect";

const lightClientProvider = createLightClientProvider();
Expand Down Expand Up @@ -55,6 +56,7 @@ export const config = defineConfig({
targetChains: ["polkadot", "kusama", "westend"],
wallets: [
new InjectedWalletProvider({ originName: "ReactiveDOT React Example" }),
new MimirWalletProvider({ originName: "ReactiveDOT React Example" }),
new LedgerWallet(),
new WalletConnect({
projectId: "68f5b7e972a51cf379b127f51a791c34",
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"cache": true
}
},
"parallel": 9
"parallel": 10
}
33 changes: 16 additions & 17 deletions packages/core/src/wallets/injected/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type InjectedExtension,
type InjectedPolkadotAccount,
} from "polkadot-api/pjs-signer";
import { BehaviorSubject, Observable } from "rxjs";
import { BehaviorSubject, Observable, of } from "rxjs";
import { map, switchMap } from "rxjs/operators";

export type InjectedWalletOptions = WalletOptions & { originName?: string };
Expand All @@ -33,7 +33,7 @@ export class InjectedWallet extends Wallet<InjectedWalletOptions, "connected"> {
}
}

connected$ = this.#extension$.pipe(
readonly connected$ = this.#extension$.pipe(
map((extension) => extension !== undefined),
);

Expand All @@ -53,21 +53,20 @@ export class InjectedWallet extends Wallet<InjectedWalletOptions, "connected"> {
}

readonly accounts$ = this.#extension$.pipe(
switchMap(
(extension) =>
new Observable<PolkadotSignerAccount[]>((subscriber) => {
if (extension === undefined) {
subscriber.next([]);
} else {
subscriber.next(this.#withIds(extension.getAccounts()));
subscriber.add(
extension.subscribe((accounts) =>
subscriber.next(this.#withIds(accounts)),
),
);
}
}),
),
switchMap((extension) => {
if (extension === undefined) {
return of([]);
}

return new Observable<PolkadotSignerAccount[]>((subscriber) => {
subscriber.next(this.#withIds(extension.getAccounts()));
subscriber.add(
extension.subscribe((accounts) =>
subscriber.next(this.#withIds(accounts)),
),
);
});
}),
);

override getAccounts() {
Expand Down
1 change: 1 addition & 0 deletions packages/wallet-mimir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
174 changes: 174 additions & 0 deletions packages/wallet-mimir/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# @reactive-dot/wallet-ledger

## 0.16.25

### Patch Changes

- Updated dependencies [[`b6c5cc7`](https://github.com/tien/reactive-dot/commit/b6c5cc7a9d4ba82b2d8c890cfcc569fe6703951f)]:
- @reactive-dot/core@0.33.0

## 0.16.24

### Patch Changes

- [#495](https://github.com/tien/reactive-dot/pull/495) [`3372262`](https://github.com/tien/reactive-dot/commit/33722622b1a8104e71ae3ce0776f7ef9609da922) Thanks [@tien](https://github.com/tien)! - Excluded tests from bundle.

- Updated dependencies []:
- @reactive-dot/core@0.32.0

## 0.16.23

### Patch Changes

- Updated dependencies [[`776d1ef`](https://github.com/tien/reactive-dot/commit/776d1ef29777550fdcec83b11713e53a68624d14)]:
- @reactive-dot/core@0.31.0

## 0.16.22

### Patch Changes

- Updated dependencies [[`821f21b`](https://github.com/tien/reactive-dot/commit/821f21b511b4c7ef8b0eff2e3f9eb0a3addb36ac), [`dcc8c24`](https://github.com/tien/reactive-dot/commit/dcc8c241c7543bebecdc73438f627d6f7fd0610e)]:
- @reactive-dot/core@0.30.0

## 0.16.21

### Patch Changes

- Updated dependencies [[`6e1ded0`](https://github.com/tien/reactive-dot/commit/6e1ded07876d9ee6471830038e8910c369f14a4b)]:
- @reactive-dot/core@0.29.0

## 0.16.20

### Patch Changes

- Updated dependencies [[`aeef030`](https://github.com/tien/reactive-dot/commit/aeef0303347668d7c53de3373f581b95a723fb17)]:
- @reactive-dot/core@0.27.1

## 0.16.19

### Patch Changes

- Updated dependencies [[`f1d984f`](https://github.com/tien/reactive-dot/commit/f1d984f0347de0928e09ab9b99a9989586031d52)]:
- @reactive-dot/core@0.27.0

## 0.16.18

### Patch Changes

- Updated dependencies [[`a3da0de`](https://github.com/tien/reactive-dot/commit/a3da0de4207499ff6e766f7affd08d086803a897)]:
- @reactive-dot/core@0.26.2

## 0.16.17

### Patch Changes

- Updated dependencies [[`a638b48`](https://github.com/tien/reactive-dot/commit/a638b48e595f5dd6d87141f12f62616b507f3ed8), [`e5c37d0`](https://github.com/tien/reactive-dot/commit/e5c37d04fbdf5515c09f65875c4f8f6c6c1c5f01)]:
- @reactive-dot/core@0.26.1

## 0.16.16

### Patch Changes

- Updated dependencies [[`ee5d6a3`](https://github.com/tien/reactive-dot/commit/ee5d6a305cd1bfe9213ea82d5c81d0e1bcce2dfa)]:
- @reactive-dot/core@0.26.0

## 0.16.15

### Patch Changes

- Updated dependencies [[`ed4e82d`](https://github.com/tien/reactive-dot/commit/ed4e82d3eed9499f0c59d3bb1fceb151ce1e305a)]:
- @reactive-dot/core@0.25.1

## 0.16.14

### Patch Changes

- [#304](https://github.com/tien/reactive-dot/pull/304) [`0958ce1`](https://github.com/tien/reactive-dot/commit/0958ce1f6c06f6e163b4ce6e8f012caf4fb34040) Thanks [@tien](https://github.com/tien)! - Added default implementation for `Wallet.getAccounts`.

- Updated dependencies [[`bbda9ef`](https://github.com/tien/reactive-dot/commit/bbda9ef093e87a96d6eb23ba51464ec02ba08bb2), [`0958ce1`](https://github.com/tien/reactive-dot/commit/0958ce1f6c06f6e163b4ce6e8f012caf4fb34040), [`13c5dae`](https://github.com/tien/reactive-dot/commit/13c5dae1a0ca5500d798ac31e3a8b81bc9d3f78a)]:
- @reactive-dot/core@0.24.1

## 0.16.13

### Patch Changes

- Updated dependencies [[`2bdab49`](https://github.com/tien/reactive-dot/commit/2bdab4925c736a81245936fb4034984dd4211f23)]:
- @reactive-dot/core@0.24.0

## 0.16.12

### Patch Changes

- Updated dependencies [[`fccd977`](https://github.com/tien/reactive-dot/commit/fccd9778365d71a6903560513455f033fded0b4c)]:
- @reactive-dot/core@0.23.0

## 0.16.11

### Patch Changes

- Updated dependencies [[`02b5633`](https://github.com/tien/reactive-dot/commit/02b56338948e32463b9b3e682340a25920386d91)]:
- @reactive-dot/core@0.22.0

## 0.16.10

### Patch Changes

- Updated dependencies [[`2c30634`](https://github.com/tien/reactive-dot/commit/2c3063493977b78c95312b507332cced8296e66b)]:
- @reactive-dot/core@0.21.0

## 0.16.9

### Patch Changes

- Updated dependencies [[`08e5517`](https://github.com/tien/reactive-dot/commit/08e5517f01bb24285ef4684f6de27753e3a9f2e9)]:
- @reactive-dot/core@0.20.0

## 0.16.8

### Patch Changes

- Updated dependencies [[`98bb09e`](https://github.com/tien/reactive-dot/commit/98bb09e623805cf772dd42ce1ed144f569a71bae)]:
- @reactive-dot/core@0.19.0

## 0.16.7

### Patch Changes

- Updated dependencies [[`42d6d34`](https://github.com/tien/reactive-dot/commit/42d6d343bb299d56b14a18dd0d7e54c90d20c1b6)]:
- @reactive-dot/core@0.18.0

## 0.16.6

### Patch Changes

- [#257](https://github.com/tien/reactive-dot/pull/257) [`ce4db82`](https://github.com/tien/reactive-dot/commit/ce4db82577957a7d029c072d953b4c5e6e6462aa) Thanks [@tien](https://github.com/tien)! - Fixed `Wallet.getAccounts` incorrectly used `lastValueFrom` instead of `firstValueFrom`.

## 0.16.5

### Patch Changes

- Updated dependencies []:
- @reactive-dot/core@0.16.5

## 0.16.3

### Patch Changes

- [#219](https://github.com/tien/reactive-dot/pull/219) [`50107c5`](https://github.com/tien/reactive-dot/commit/50107c56c8b8e6bc1adb3a1f6dc9cda60150838a) Thanks [@tien](https://github.com/tien)! - Sort Ledger accounts by derivation path.

## 0.16.1

### Patch Changes

- [#214](https://github.com/tien/reactive-dot/pull/214) [`24913cb`](https://github.com/tien/reactive-dot/commit/24913cb9340e8f2752269d1abcbdf900ecfdabf8) Thanks [@tien](https://github.com/tien)! - Fixed incorrect CommonJS import for Buffer polyfill.

## 0.16.0

### Minor Changes

- [#168](https://github.com/tien/reactive-dot/pull/168) [`1c4fdee`](https://github.com/tien/reactive-dot/commit/1c4fdee520b066254c48ba58562c50d75473da69) Thanks [@tien](https://github.com/tien)! - Added Ledger wallet integration.

### Patch Changes

- Updated dependencies [[`1c4fdee`](https://github.com/tien/reactive-dot/commit/1c4fdee520b066254c48ba58562c50d75473da69)]:
- @reactive-dot/core@0.16.0
4 changes: 4 additions & 0 deletions packages/wallet-mimir/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import recommended from "@reactive-dot/eslint-config";
import tseslint from "typescript-eslint";

export default tseslint.config(...recommended);
47 changes: 47 additions & 0 deletions packages/wallet-mimir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@reactive-dot/wallet-mimir",
"version": "0.0.0",
"description": "Mimir adapter for Reactive DOT",
"keywords": [
"substrate",
"polkadot",
"mimir"
],
"homepage": "https://reactivedot.dev/",
"bugs": {
"url": "https://github.com/tien/reactive-dot/issues",
"email": "tien.nguyenkhac@icloud.com"
},
"license": "LGPL-3.0-or-later",
"author": "Tiến Nguyễn Khắc <tien.nguyenkhac@icloud.com> (https://tien.zone/)",
"repository": {
"type": "git",
"url": "https://github.com/tien/reactive-dot.git",
"directory": "packages/wallet-mimir"
},
"type": "module",
"files": [
"src",
"build"
],
"exports": "./build/index.js",
"scripts": {
"dev": "tsc --build --watch",
"build": "rm -rf build && tsc --build",
"lint": "eslint src",
"test": "vitest"
},
"dependencies": {
"@mimirdev/apps-inject": "^3.1.1",
"@mimirdev/papi-signer": "^3.1.0",
"@reactive-dot/core": "workspace:^"
},
"devDependencies": {
"@reactive-dot/eslint-config": "workspace:^",
"@tsconfig/recommended": "^1.0.8",
"@tsconfig/strictest": "^2.0.5",
"eslint": "^9.21.0",
"typescript": "^5.7.3",
"vitest": "^3.0.6"
}
}
10 changes: 10 additions & 0 deletions packages/wallet-mimir/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as exports from "./index.js";
import { expect, it } from "vitest";

it("should match inline snapshot", () =>
expect(Object.keys(exports)).toMatchInlineSnapshot(`
[
"MimirWalletProvider",
"MimirWallet",
]
`));
2 changes: 2 additions & 0 deletions packages/wallet-mimir/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { MimirWalletProvider } from "./mimir-wallet-provider.js";
export { MimirWallet } from "./mimir-wallet.js";
Loading

0 comments on commit 1c60402

Please sign in to comment.