Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to use-wallet v3 #353

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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