Skip to content

Commit

Permalink
feat: add Defly Web extension wallet provider (#317)
Browse files Browse the repository at this point in the history
* refactor(wallets): create extendable AVMProvider for Kibisis client

This refactors the Kibisis wallet client to use an extendable `AVMProvider` class, laying the groundwork for future wallet implementations that also use `@agoralabs-sh/avm-web-provider`.

- Created new `AVMProvider` abstract class
- Refactored `KibisisWallet` to extend `AVMProvider`
- Moved common AVM Web Provider functionality to `AVMProvider`
- Implemented abstract methods in `KibisisWallet` for Kibisis-specific behavior

* feat: add Defly Web Wallet initial support

- Created new `DeflyWebWallet` class extending `AVMProvider`
- Implemented Defly-specific methods for enable, disable, and sign transactions
- Added `DEFLY_WEB` to `WalletId` enum and `WalletMap`
- Updated utility functions to include Defly Web Wallet

* fix(avm): resolve dynamic import issues with AVM Web Provider

This addresses an issue where certain frameworks are unable to dynamically import `@agoralabs-sh/avm-web-provider` due to module format incompatibilities.

- Modified `_initializeAVMWebProviderSDK` method to handle both default and named exports
- Ensured compatibility between CommonJS (AVM Web Provider) and ESM (use-wallet)

* chore: restore comments and JSDoc blocks

* docs(avm): update comments for abstract and common methods

* chore: fix import order

* test(kibisis): fix failing test

* fix(defly-web): use correct provider ID in constructor

* feat(examples): add Defly Web provider

* test(defly-web): add tests for Defly Web provider

* refactor(provider): extract shared AVM provider functionality

Extract common AVM Web Provider functionality into abstract base class to support
both Kibisis and Defly Web providers. Update implementations to use `algosdk` v3
and new network configuration system.

- Create abstract `AVMProvider` class with shared provider logic
- Move common methods from Kibisis to `AVMProvider`
- Update transaction handling for `algosdk` v3 API
- Add network configuration and genesis hash fallback
- Implement Defly Web provider using shared base class

* refactor(tests): remove ts-nocheck from AVM wallet provider tests

Enable proper TypeScript type checking in AVM provider tests by introducing
type-safe utility types for testing protected methods.

- Remove `@ts-nocheck` comments from Defly Web and Kibisis tests
- Add `TestableDeflyWebWallet` and `TestableKibisisWallet` utility types
- Update `vi.spyOn` calls to use proper type assertions
- Remove unnecessary type assertions from mock implementations
- Add proper return type to `mockSignTransactionsResponseOnce`
  • Loading branch information
drichar authored Nov 26, 2024
1 parent 9fc4365 commit 412e688
Show file tree
Hide file tree
Showing 13 changed files with 1,100 additions and 331 deletions.
1 change: 1 addition & 0 deletions examples/nextjs/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NetworkId, WalletId, WalletManager, WalletProvider } from '@txnlab/use-
const walletManager = new WalletManager({
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
1 change: 1 addition & 0 deletions examples/nuxt/plugins/walletManager.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(WalletManagerPlugin, {
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
1 change: 1 addition & 0 deletions examples/react-ts/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './App.css'
const walletManager = new WalletManager({
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
1 change: 1 addition & 0 deletions examples/solid-ts/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './App.css'
const walletManager = new WalletManager({
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
1 change: 1 addition & 0 deletions examples/vanilla-ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { WalletComponent } from './WalletComponent'
const walletManager = new WalletManager({
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
1 change: 1 addition & 0 deletions examples/vue-ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const app = createApp(App)
app.use(WalletManagerPlugin, {
wallets: [
WalletId.DEFLY,
WalletId.DEFLY_WEB,
WalletId.EXODUS,
WalletId.PERA,
{
Expand Down
Loading

0 comments on commit 412e688

Please sign in to comment.