-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet-mimir): mimir wallet integration
- Loading branch information
Showing
19 changed files
with
519 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@reactive-dot/wallet-mimir": minor | ||
--- | ||
|
||
Added Mimir wallet integration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,5 @@ | |
"cache": true | ||
} | ||
}, | ||
"parallel": 9 | ||
"parallel": 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] | ||
`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { MimirWalletProvider } from "./mimir-wallet-provider.js"; | ||
import { MimirWallet } from "./mimir-wallet.js"; | ||
import { isMimirReady } from "@mimirdev/apps-inject"; | ||
import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
|
||
vi.mock("@mimirdev/apps-inject"); | ||
vi.mock("./mimir-wallet.js"); | ||
|
||
let provider: MimirWalletProvider; | ||
|
||
beforeEach(() => { | ||
provider = new MimirWalletProvider(); | ||
|
||
vi.clearAllMocks(); | ||
}); | ||
|
||
describe("getWallets", () => { | ||
it("should return empty array when Mimir is not ready", async () => { | ||
vi.mocked(isMimirReady).mockResolvedValue(null); | ||
const wallets = await provider.getWallets(); | ||
|
||
expect(wallets).toEqual([]); | ||
expect(isMimirReady).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should return MimirWallet instance when Mimir is ready", async () => { | ||
vi.mocked(isMimirReady).mockResolvedValue("origin"); | ||
const wallets = await provider.getWallets(); | ||
|
||
expect(wallets).toHaveLength(1); | ||
expect(wallets[0]).toBeInstanceOf(MimirWallet); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MimirWallet, type MimirWalletOptions } from "./mimir-wallet.js"; | ||
import { isMimirReady } from "@mimirdev/apps-inject"; | ||
import { WalletProvider } from "@reactive-dot/core/wallets.js"; | ||
|
||
export class MimirWalletProvider extends WalletProvider { | ||
constructor(private readonly options?: MimirWalletOptions) { | ||
super(); | ||
} | ||
|
||
async getWallets() { | ||
const origin = await isMimirReady(); | ||
|
||
if (origin === null) { | ||
return []; | ||
} | ||
|
||
return [new MimirWallet(this.options)]; | ||
} | ||
} |
Oops, something went wrong.