Skip to content

Commit

Permalink
Merge pull request #353 from algorandfoundation/use-wallet-v3
Browse files Browse the repository at this point in the history
feat: upgrade to use-wallet v3
  • Loading branch information
PatrickDinh authored Dec 2, 2024
2 parents 5109c7b + 8d14c41 commit f881259
Show file tree
Hide file tree
Showing 35 changed files with 375 additions and 426 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="AlgoKit lora, the Algorand live on-chain resource analyzer." />
<meta name="name" content="AlgoKit - lora" />
<title>AlgoKit - lora</title>
</head>
<body>
Expand Down
152 changes: 94 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@hookform/resolvers": "^3.9.0",
"@perawallet/connect": "^1.3.4",
"@perawallet/connect": "^1.3.5",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.0.5",
Expand All @@ -55,7 +55,8 @@
"@tauri-apps/plugin-cli": "^2.0.0",
"@tauri-apps/plugin-deep-link": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@txnlab/use-wallet": "2.8.2",
"@txnlab/use-wallet": "^3.10.1",
"@txnlab/use-wallet-react": "^3.10.1",
"@xstate/react": "^4.1.1",
"algosdk": "2.9.0",
"class-variance-authority": "^0.7.0",
Expand Down Expand Up @@ -196,4 +197,4 @@
"path-to-regexp@>= 0.2.0 <8.0.0": "8.0.0",
"cross-spawn": "^7.0.6"
}
}
}
32 changes: 0 additions & 32 deletions patches/@txnlab+use-wallet+2.8.2.patch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
BuildMethodCallTransactionResult,
BuildTransactionResult,
} from '@/features/transaction-wizard/models'
import { useWallet } from '@txnlab/use-wallet'
import { useWallet } from '@txnlab/use-wallet-react'
import { DialogBodyProps, useDialogForm } from '@/features/common/hooks/use-dialog-form'
import algosdk from 'algosdk'
import { TransactionBuilder } from '@/features/transaction-wizard/components/transaction-builder'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useMemo } from 'react'
import { useCreateAppInterfaceStateMachine } from '../../data'
import { Card, CardContent } from '@/features/common/components/card'
import { Button } from '@/features/common/components/button'
import { useWallet } from '@txnlab/use-wallet'
import { useWallet } from '@txnlab/use-wallet-react'
import { deployAppLabel } from '../labels'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { afterEach, beforeEach, describe, expect, it, vi, vitest } from 'vitest'
import { CreateAppInterfacePage } from './create-app-interface-page'
import { deployAppLabel } from '../components/labels'
import { useWallet } from '@txnlab/use-wallet'
import { useWallet } from '@txnlab/use-wallet-react'
import SampleSixAppSpec from '@/tests/test-app-specs/sample-six.arc32.json'
import { Arc32AppSpec } from '../data/types'
import { selectOption } from '@/tests/utils/select-option'
Expand Down Expand Up @@ -213,14 +213,12 @@ describe('create-app-interface', () => {

describe('when a wallet is not connected', () => {
beforeEach(async () => {
const original = await vi.importActual<{ useWallet: () => ReturnType<typeof useWallet> }>('@txnlab/use-wallet')
const original = await vi.importActual<{ useWallet: () => ReturnType<typeof useWallet> }>('@txnlab/use-wallet-react')
vi.mocked(useWallet).mockImplementation(() => {
return {
...original.useWallet(),
activeAddress: undefined,
isActive: false,
isReady: true,
}
activeAddress: null,
} satisfies ReturnType<typeof useWallet>
})
})

Expand Down
17 changes: 7 additions & 10 deletions src/features/common/components/wallet-provider-inner.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { useInitializeProviders, useWallet } from '@txnlab/use-wallet'
import { PropsWithChildren } from 'react'
import { WalletProvider as UseWalletProvider } from '@txnlab/use-wallet'
import { useSetActiveWalletState } from '@/features/wallet/data/active-wallet'
import { useWallet, WalletManager, WalletProvider } from '@txnlab/use-wallet-react'

type Props = PropsWithChildren<{
initOptions: Parameters<typeof useInitializeProviders>[0]
walletManager: WalletManager
}>

function SetActiveWalletState({ children }: PropsWithChildren) {
const { activeAddress, isReady, signer } = useWallet()
useSetActiveWalletState(isReady, activeAddress, signer)
const { activeAddress, transactionSigner } = useWallet()
useSetActiveWalletState(activeAddress ?? undefined, transactionSigner)

return <>{children}</>
}

export function WalletProviderInner({ initOptions, children }: Props) {
const walletProviders = useInitializeProviders(initOptions)

export function WalletProviderInner({ walletManager, children }: Props) {
return (
<UseWalletProvider value={walletProviders}>
<WalletProvider manager={walletManager}>
<SetActiveWalletState>{children}</SetActiveWalletState>
</UseWalletProvider>
</WalletProvider>
)
}
Loading

0 comments on commit f881259

Please sign in to comment.