test
This commit is contained in:
@ -61,10 +61,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"generate:app-clients": "algokit project link --all",
|
||||
"build:dev": "npm run generate:app-clients && tsc && vite build",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"generate:app-clients": "sh -c 'command -v algokit >/dev/null 2>&1 && algokit project link --all || echo \"algokit not found; skipping client generation\"'",
|
||||
"build": "npm run generate:app-clients && tsc && vite build"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
|
||||
@ -7,7 +7,7 @@ import { ellipseAddress } from './utils/ellipseAddress'
|
||||
|
||||
export default function Layout() {
|
||||
const [openWalletModal, setOpenWalletModal] = useState(false)
|
||||
const { activeAddress, isActive } = useWallet()
|
||||
const { activeAddress } = useWallet()
|
||||
|
||||
const toggleWalletModal = () => setOpenWalletModal(!openWalletModal)
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
|
||||
import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
|
||||
import { useWallet } from '@txnlab/use-wallet-react'
|
||||
import { useSnackbar } from 'notistack'
|
||||
import { useState } from 'react'
|
||||
import { HelloWorldFactory } from '../contracts/HelloWorld'
|
||||
import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
|
||||
import { HelloWorldFactory } from '../../TokenizeRWATemplate-contracts/smart_contracts/artifacts/hello_world/HelloWorldClient'
|
||||
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
|
||||
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
|
||||
|
||||
interface AppCallsInterface {
|
||||
openModal: boolean
|
||||
@ -23,11 +23,20 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
|
||||
algodConfig,
|
||||
indexerConfig,
|
||||
})
|
||||
algorand.setDefaultSigner(transactionSigner)
|
||||
if (transactionSigner) {
|
||||
// @ts-expect-error - optional API depending on algokit-utils version
|
||||
algorand.setDefaultSigner?.(transactionSigner)
|
||||
}
|
||||
|
||||
const sendAppCall = async () => {
|
||||
setLoading(true)
|
||||
|
||||
if (!activeAddress || !transactionSigner) {
|
||||
enqueueSnackbar('Please connect a wallet first.', { variant: 'warning' })
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// Please note, in typical production scenarios,
|
||||
// you wouldn't want to use deploy directly from your frontend.
|
||||
// Instead, you would deploy your contract on your backend and reference it by id.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useWallet, WalletId, type BaseWallet } from '@txnlab/use-wallet-react'
|
||||
import { useWallet, WalletId } from '@txnlab/use-wallet-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { ellipseAddress } from '../utils/ellipseAddress'
|
||||
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
|
||||
@ -17,7 +17,10 @@ const ConnectWallet = ({ openModal, closeModal }: ConnectWalletProps) => {
|
||||
|
||||
// Get network config for Lora link
|
||||
const algoConfig = getAlgodConfigFromViteEnvironment()
|
||||
const networkName = useMemo(() => (algoConfig.network === '' ? 'localnet' : algoConfig.network.toLowerCase()), [algoConfig.network])
|
||||
const networkName = useMemo(() => {
|
||||
const n = (algoConfig.network ?? '').toString()
|
||||
return n === '' ? 'localnet' : n.toLowerCase()
|
||||
}, [algoConfig.network])
|
||||
|
||||
const visibleWallets = useMemo(() => (wallets ?? []).filter(Boolean), [wallets])
|
||||
|
||||
@ -31,7 +34,7 @@ const ConnectWallet = ({ openModal, closeModal }: ConnectWalletProps) => {
|
||||
// Capture wallet ID for logout (before disconnect clears it)
|
||||
const activeWalletId = activeWallet?.id
|
||||
|
||||
const connectWallet = async (wallet: BaseWallet) => {
|
||||
const connectWallet = async (wallet: any) => {
|
||||
setLastError('')
|
||||
setConnectingKey(wallet.id)
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
|
||||
import { useWallet } from '@txnlab/use-wallet-react'
|
||||
import { sha512_256 } from 'js-sha512'
|
||||
import { useSnackbar } from 'notistack'
|
||||
import { ChangeEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { AiOutlineCloudUpload, AiOutlineInfoCircle, AiOutlineLoading3Quarters } from 'react-icons/ai'
|
||||
import { BsCoin } from 'react-icons/bs'
|
||||
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
|
||||
import { useWallet } from '@txnlab/use-wallet-react'
|
||||
|
||||
/**
|
||||
* Type for created assets stored in browser localStorage
|
||||
@ -178,7 +178,7 @@ export default function TokenizeAsset() {
|
||||
// ===== use-wallet (Web3Auth OR WalletConnect) =====
|
||||
// Use transactionSigner (not signer) - this is the correct property name from use-wallet
|
||||
const { transactionSigner, activeAddress } = useWallet()
|
||||
|
||||
|
||||
// Alias for backward compatibility in the code
|
||||
const signer = transactionSigner
|
||||
|
||||
@ -227,10 +227,7 @@ export default function TokenizeAsset() {
|
||||
let apiCallSucceeded = false
|
||||
|
||||
try {
|
||||
holding = await algorand.asset.getAccountInformation(
|
||||
activeAddress,
|
||||
BigInt(TESTNET_USDC_ASSET_ID),
|
||||
)
|
||||
holding = await algorand.asset.getAccountInformation(activeAddress, BigInt(TESTNET_USDC_ASSET_ID))
|
||||
apiCallSucceeded = true
|
||||
} catch (assetApiError: unknown) {
|
||||
// API call failed - account is likely not opted in
|
||||
@ -343,12 +340,7 @@ export default function TokenizeAsset() {
|
||||
// 1. Actually switching TO usdc mode (not just re-render)
|
||||
// 2. Blockchain check is complete (status confirmed)
|
||||
// 3. Warning hasn't been shown already
|
||||
if (
|
||||
modeChanged &&
|
||||
hasCheckedUsdcOnChain &&
|
||||
!hasShownUsdcWarningRef.current &&
|
||||
usdcStatus === 'not-opted-in'
|
||||
) {
|
||||
if (modeChanged && hasCheckedUsdcOnChain && !hasShownUsdcWarningRef.current && usdcStatus === 'not-opted-in') {
|
||||
enqueueSnackbar('You are not opted in to USDC yet. Please opt in before receiving or sending USDC.', {
|
||||
variant: 'info',
|
||||
})
|
||||
@ -394,7 +386,7 @@ export default function TokenizeAsset() {
|
||||
enqueueSnackbar('Please connect a wallet or continue with Google first.', { variant: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!signer) {
|
||||
enqueueSnackbar('Wallet signer not available. Please try reconnecting your wallet.', { variant: 'error' })
|
||||
return
|
||||
@ -529,7 +521,7 @@ export default function TokenizeAsset() {
|
||||
enqueueSnackbar('Please connect a wallet or continue with Google first.', { variant: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!signer) {
|
||||
enqueueSnackbar('Wallet signer not available. Please try reconnecting your wallet.', { variant: 'error' })
|
||||
return
|
||||
@ -627,7 +619,7 @@ export default function TokenizeAsset() {
|
||||
enqueueSnackbar('Please connect a wallet or continue with Google first.', { variant: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!signer) {
|
||||
enqueueSnackbar('Wallet signer not available. Please try reconnecting your wallet.', { variant: 'error' })
|
||||
return
|
||||
@ -681,7 +673,7 @@ export default function TokenizeAsset() {
|
||||
sender: activeAddress,
|
||||
signer,
|
||||
receiver: receiverAddress,
|
||||
amount: { microAlgo: Number(microAlgos) },
|
||||
amount: algorand.microAlgos(microAlgos),
|
||||
})
|
||||
|
||||
const txId = (result as { txId?: string }).txId
|
||||
@ -811,7 +803,7 @@ export default function TokenizeAsset() {
|
||||
enqueueSnackbar('Please connect a wallet or continue with Google first.', { variant: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!signer) {
|
||||
enqueueSnackbar('Wallet signer not available. Please try reconnecting your wallet.', { variant: 'error' })
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user