fix ts errors
This commit is contained in:
@@ -4,6 +4,7 @@ import React from 'react'
|
|||||||
import { YStack, XStack, Text } from 'tamagui'
|
import { YStack, XStack, Text } from 'tamagui'
|
||||||
import { StatusBadge } from './StatusBadge'
|
import { StatusBadge } from './StatusBadge'
|
||||||
import type { EscrowAccountWithPda } from '@descro/sdk'
|
import type { EscrowAccountWithPda } from '@descro/sdk'
|
||||||
|
import { lamports } from '@solana/kit'
|
||||||
import { lamportsToSolString } from '@/util/lamports'
|
import { lamportsToSolString } from '@/util/lamports'
|
||||||
function truncAddr(addr: string): string {
|
function truncAddr(addr: string): string {
|
||||||
return `${addr.slice(0, 4)}…${addr.slice(-4)}`
|
return `${addr.slice(0, 4)}…${addr.slice(-4)}`
|
||||||
@@ -17,7 +18,7 @@ interface EscrowCardProps {
|
|||||||
|
|
||||||
export function EscrowCard({ item, selected, onSelect }: EscrowCardProps) {
|
export function EscrowCard({ item, selected, onSelect }: EscrowCardProps) {
|
||||||
const { pda, account } = item
|
const { pda, account } = item
|
||||||
const solAmount = lamportsToSolString(account.amount, 4)
|
const solAmount = lamportsToSolString(lamports(account.amount), 4)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<YStack
|
<YStack
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
assertIsTransactionWithBlockhashLifetime,
|
assertIsTransactionWithBlockhashLifetime,
|
||||||
getSignatureFromTransaction,
|
getSignatureFromTransaction,
|
||||||
isSome,
|
isSome,
|
||||||
|
lamports,
|
||||||
} from '@solana/kit'
|
} from '@solana/kit'
|
||||||
import { useKitTransactionSigner, useWallet, useSolanaClient } from '@solana/connector/react'
|
import { useKitTransactionSigner, useWallet, useSolanaClient } from '@solana/connector/react'
|
||||||
import { StatusBadge } from './StatusBadge'
|
import { StatusBadge } from './StatusBadge'
|
||||||
@@ -53,7 +54,7 @@ export function EscrowDetail({ item, onAction }: EscrowDetailProps) {
|
|||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
const [success, setSuccess] = useState<string | null>(null)
|
const [success, setSuccess] = useState<string | null>(null)
|
||||||
|
|
||||||
const solAmount = lamportsToSolString(escrow.amount, 4)
|
const solAmount = lamportsToSolString(lamports(escrow.amount), 4)
|
||||||
const isSeller = address != null && address === escrow.seller
|
const isSeller = address != null && address === escrow.seller
|
||||||
const isBuyer = address != null && address === escrow.buyer
|
const isBuyer = address != null && address === escrow.buyer
|
||||||
const resolverAddr = isSome(escrow.disputeResolver) ? escrow.disputeResolver.value : null
|
const resolverAddr = isSome(escrow.disputeResolver) ? escrow.disputeResolver.value : null
|
||||||
@@ -79,7 +80,7 @@ export function EscrowDetail({ item, onAction }: EscrowDetailProps) {
|
|||||||
)
|
)
|
||||||
const signed = await signTransactionMessageWithSigners(txMsg)
|
const signed = await signTransactionMessageWithSigners(txMsg)
|
||||||
assertIsTransactionWithBlockhashLifetime(signed)
|
assertIsTransactionWithBlockhashLifetime(signed)
|
||||||
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions })(signed, { commitment: 'confirmed' })
|
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions: rpcSubscriptions as never })(signed, { commitment: 'confirmed' })
|
||||||
const sig = getSignatureFromTransaction(signed)
|
const sig = getSignatureFromTransaction(signed)
|
||||||
setSuccess(`Done! Tx: ${sig.slice(0, 20)}…`)
|
setSuccess(`Done! Tx: ${sig.slice(0, 20)}…`)
|
||||||
onAction?.()
|
onAction?.()
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export function ResolverPanel() {
|
|||||||
)
|
)
|
||||||
const signed = await signTransactionMessageWithSigners(txMsg)
|
const signed = await signTransactionMessageWithSigners(txMsg)
|
||||||
assertIsTransactionWithBlockhashLifetime(signed)
|
assertIsTransactionWithBlockhashLifetime(signed)
|
||||||
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions })(signed, { commitment: 'confirmed' })
|
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions: rpcSubscriptions as never })(signed, { commitment: 'confirmed' })
|
||||||
const sig = getSignatureFromTransaction(signed)
|
const sig = getSignatureFromTransaction(signed)
|
||||||
|
|
||||||
setSuccess(`Registered! Tx: ${sig.slice(0, 20)}…`)
|
setSuccess(`Registered! Tx: ${sig.slice(0, 20)}…`)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function useEscrowDetail(pda: Address | null) {
|
|||||||
if (!cancelled) setLoading(false)
|
if (!cancelled) setLoading(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
const unsub = subscribeEscrow(rpcSubscriptions, pda, (updated) => {
|
const unsub = subscribeEscrow(rpcSubscriptions as never, pda, (updated) => {
|
||||||
if (!cancelled) setAccount(updated)
|
if (!cancelled) setAccount(updated)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user