diff --git a/apps/walletd/components/Wallet/WalletActionsMenu.tsx b/apps/walletd/components/Wallet/WalletActionsMenu.tsx
index af07edcb5..990e4becc 100644
--- a/apps/walletd/components/Wallet/WalletActionsMenu.tsx
+++ b/apps/walletd/components/Wallet/WalletActionsMenu.tsx
@@ -36,11 +36,11 @@ export function WalletActionsMenu() {
variant="accent"
onClick={() => {
if (wallet?.type === 'seed') {
- openDialog('walletSendSiacoinSeed', {
+ openDialog('walletSendSeed', {
walletId,
})
} else if (wallet?.type === 'ledger') {
- openDialog('walletSendSiacoinLedger', {
+ openDialog('walletSendLedger', {
walletId,
})
}
diff --git a/apps/walletd/contexts/dialog.tsx b/apps/walletd/contexts/dialog.tsx
index ad58e2149..fb0f60d18 100644
--- a/apps/walletd/contexts/dialog.tsx
+++ b/apps/walletd/contexts/dialog.tsx
@@ -51,13 +51,13 @@ import {
AddressRemoveDialogParams,
} from '../dialogs/AddressRemoveDialog'
import {
- WalletSendSiacoinSeedDialog,
- WalletSendSiacoinSeedDialogParams,
+ WalletSendSeedDialog,
+ WalletSendSeedDialogParams,
} from '../dialogs/WalletSendSiacoinSeedDialog'
import {
- WalletSendSiacoinLedgerDialog,
- WalletSendSiacoinLedgerDialogParams,
-} from '../dialogs/WalletSendSiacoinLedgerDialog'
+ WalletSendLedgerDialog,
+ WalletSendLedgerDialogParams,
+} from '../dialogs/WalletSendLedgerDialog'
import {
WalletUnlockDialog,
WalletUnlockDialogParams,
@@ -75,8 +75,8 @@ import {
type DialogParams = {
cmdk?: void
settings?: WalletdSettingsDialogParams
- walletSendSiacoinSeed?: WalletSendSiacoinSeedDialogParams
- walletSendSiacoinLedger?: WalletSendSiacoinLedgerDialogParams
+ walletSendSeed?: WalletSendSeedDialogParams
+ walletSendLedger?: WalletSendLedgerDialogParams
transactionDetails?: void
addressUpdate?: AddressUpdateDialogParams
addressRemove?: AddressRemoveDialogParams
@@ -255,22 +255,18 @@ export function Dialogs() {
}
onOpenChange={(val) => (val ? openDialog(dialog) : closeDialog())}
/>
-
- val
- ? openDialog(dialog, params['walletSendSiacoinSeed'])
- : closeDialog()
+ val ? openDialog(dialog, params['walletSendSeed']) : closeDialog()
}
/>
-
- val
- ? openDialog(dialog, params['walletSendSiacoinLedger'])
- : closeDialog()
+ val ? openDialog(dialog, params['walletSendLedger']) : closeDialog()
}
/>
{
+ if (!transactionId) {
+ return null
+ }
+ return (
+
+ )
+ },
+ },
{
id: 'type',
label: 'type',
@@ -67,21 +81,6 @@ export const columns: EventsTableColumn[] = [
)
},
},
- {
- id: 'maturityHeight',
- label: 'maturity height',
- category: 'general',
- render: ({ data: { maturityHeight } }) => {
- if (!maturityHeight) {
- return null
- }
- return (
-
- {maturityHeight.toLocaleString()}
-
- )
- },
- },
{
id: 'timestamp',
label: 'timestamp',
@@ -106,11 +105,18 @@ export const columns: EventsTableColumn[] = [
label: 'amount',
category: 'general',
contentClassName: 'w-[120px] justify-end',
- render: ({ data: { amount } }) => {
- if (!amount) {
+ render: ({ data: { amountSc, amountSf } }) => {
+ if (!amountSc) {
return null
}
- return
+ return (
+
+ {!amountSc.isZero() && (
+
+ )}
+ {!!amountSf && }
+
+ )
},
},
{
@@ -125,19 +131,6 @@ export const columns: EventsTableColumn[] = [
return
},
},
- {
- id: 'transactionId',
- label: 'transaction ID',
- category: 'general',
- render: ({ data: { transactionId } }) => {
- if (!transactionId) {
- return null
- }
- return (
-
- )
- },
- },
{
id: 'contractId',
label: 'contract ID',
@@ -149,37 +142,4 @@ export const columns: EventsTableColumn[] = [
return
},
},
- {
- id: 'outputId',
- label: 'output ID',
- category: 'general',
- render: ({ data: { outputId } }) => {
- if (!outputId) {
- return null
- }
- return
- },
- },
- {
- id: 'netAddress',
- label: 'net address',
- category: 'general',
- render: ({ data: { netAddress } }) => {
- if (!netAddress) {
- return null
- }
- return
- },
- },
- {
- id: 'publicKey',
- label: 'public key',
- category: 'general',
- render: ({ data: { publicKey } }) => {
- if (!publicKey) {
- return null
- }
- return
- },
- },
]
diff --git a/apps/walletd/contexts/events/index.tsx b/apps/walletd/contexts/events/index.tsx
index c23b151e0..84f3a611a 100644
--- a/apps/walletd/contexts/events/index.tsx
+++ b/apps/walletd/contexts/events/index.tsx
@@ -74,26 +74,52 @@ export function useEventsMain() {
return null
}
const dataTxPool: EventData[] = responseTxPool.data.map((e) => ({
- id: e.ID,
+ id: e.id,
+ transactionId: e.id,
timestamp: 0,
pending: true,
type: e.type,
amount: new BigNumber(e.received).minus(e.sent),
}))
const dataEvents: EventData[] = responseEvents.data.map((e, index) => {
- let amount = new BigNumber(0)
- if (e.type === 'siacoin transfer') {
- const inputsTotal =
- e.val?.inputs?.reduce(
- (acc, o) => acc.plus(o.value),
- new BigNumber(0)
- ) || new BigNumber(0)
- const outputsTotal =
- e.val?.outputs?.reduce(
- (acc, o) => acc.plus(o.value),
- new BigNumber(0)
- ) || new BigNumber(0)
- amount = outputsTotal.minus(inputsTotal)
+ let amountSc = new BigNumber(0)
+ let amountSf = 0
+ if (e.type === 'transaction') {
+ const inputsScTotal =
+ e.val?.siacoinInputs?.reduce((acc, o) => {
+ if (e.relevant.includes(o.siacoinOutput.address)) {
+ return acc.plus(o.siacoinOutput.value)
+ }
+ return acc
+ }, new BigNumber(0)) || new BigNumber(0)
+ const outputsScTotal =
+ e.val?.siacoinOutputs?.reduce((acc, o) => {
+ if (e.relevant.includes(o.siacoinOutput.address)) {
+ return acc.plus(o.siacoinOutput.value)
+ }
+ return acc
+ }, new BigNumber(0)) || new BigNumber(0)
+ amountSc = outputsScTotal.minus(inputsScTotal)
+
+ const inputsSfTotal =
+ e.val?.siafundInputs?.reduce((acc, o) => {
+ if (e.relevant.includes(o.siafundElement.siafundOutput.address)) {
+ return acc + o.siafundElement.siafundOutput.value
+ }
+ return acc
+ }, 0) || 0
+ const outputsSfTotal =
+ e.val?.siafundOutputs?.reduce((acc, o) => {
+ if (e.relevant.includes(o.siafundOutput.address)) {
+ return acc + o.siafundOutput.value
+ }
+ return acc
+ }, 0) || 0
+ amountSf = outputsSfTotal - inputsSfTotal
+ }
+
+ if (e.type === 'miner payout') {
+ amountSc = new BigNumber(e.val.siacoinOutput.siacoinOutput.value)
}
const id = String(index)
@@ -103,30 +129,18 @@ export function useEventsMain() {
timestamp: new Date(e.timestamp).getTime(),
height: e.index.height,
pending: false,
- amount,
- }
- if ('maturityHeight' in e.val) {
- res.maturityHeight = e.val.maturityHeight
+ amountSc,
+ amountSf,
}
if ('fee' in e.val) {
res.fee = new BigNumber(e.val.fee)
}
- if ('contractID' in e.val) {
- res.contractId = e.val.contractID
- }
- if ('transactionID' in e.val) {
- res.id += e.val.transactionID
- res.transactionId = e.val.transactionID
- }
- if ('outputID' in e.val) {
- res.id += e.val.outputID
- res.outputId = e.val.outputID
- }
- if ('netAddress' in e.val) {
- res.netAddress = e.val.netAddress
+ if ('fileContract' in e.val) {
+ res.contractId = e.val.fileContract.id
}
- if ('publicKey' in e.val) {
- res.publicKey = e.val.publicKey
+ if ('id' in e.val) {
+ res.id += e.val.id
+ res.transactionId = e.val.id
}
return res
})
diff --git a/apps/walletd/contexts/events/types.ts b/apps/walletd/contexts/events/types.ts
index a6420d49f..9038cb5dd 100644
--- a/apps/walletd/contexts/events/types.ts
+++ b/apps/walletd/contexts/events/types.ts
@@ -2,38 +2,33 @@ import BigNumber from 'bignumber.js'
export type EventData = {
id: string
+ transactionId?: string
timestamp: number
height?: number
- maturityHeight?: number
pending: boolean
type: string
fee?: BigNumber
- amount?: BigNumber
- transactionId?: string
+ amountSc?: BigNumber
+ amountSf?: number
contractId?: string
- outputId?: string
- netAddress?: string
- publicKey?: string
}
export type TableColumnId =
// | 'actions'
// | 'id'
+ | 'transactionId'
| 'type'
| 'height'
- | 'maturityHeight'
| 'timestamp'
| 'amount'
| 'fee'
| 'transactionId'
| 'contractId'
- | 'outputId'
- | 'netAddress'
- | 'publicKey'
export const columnsDefaultVisible: TableColumnId[] = [
// 'actions',
// 'id',
+ 'transactionId',
'type',
'height',
'timestamp',
diff --git a/apps/walletd/dialogs/WalletAddressesGenerateLedgerDialog/index.tsx b/apps/walletd/dialogs/WalletAddressesGenerateLedgerDialog/index.tsx
index eabc61a8b..c79cdeda7 100644
--- a/apps/walletd/dialogs/WalletAddressesGenerateLedgerDialog/index.tsx
+++ b/apps/walletd/dialogs/WalletAddressesGenerateLedgerDialog/index.tsx
@@ -132,12 +132,6 @@ export function WalletAddressesGenerateLedgerDialog({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nextIndex])
- const { handleOpenChange, closeAndReset } = useDialogFormHelpers({
- form,
- onOpenChange,
- defaultValues,
- })
-
const formIndex = form.watch('index')
const formCount = form.watch('count')
@@ -230,7 +224,7 @@ export function WalletAddressesGenerateLedgerDialog({
return indiciesWithAddresses
}, [existingAddresses, indices])
- const newAddresses = useMemo(
+ const newGeneratedAddresses = useMemo(
() =>
Object.entries(indiciesWithAddresses)
.filter(([index, item]) => item.isNew && item.address)
@@ -239,8 +233,11 @@ export function WalletAddressesGenerateLedgerDialog({
)
const saveAddresses = useCallback(async () => {
- const count = newAddresses.length
- for (const [i, { address, publicKey, index }] of newAddresses.entries()) {
+ const count = newGeneratedAddresses.length
+ for (const [
+ i,
+ { address, publicKey, index },
+ ] of newGeneratedAddresses.entries()) {
const response = await addressAdd.put({
params: {
id: walletId,
@@ -270,19 +267,27 @@ export function WalletAddressesGenerateLedgerDialog({
triggerSuccessToast(`Successfully added ${count} addresses.`)
}
return
- }, [addressAdd, walletId, newAddresses])
+ }, [addressAdd, walletId, newGeneratedAddresses])
+
+ const { handleOpenChange, closeAndReset } = useDialogFormHelpers({
+ form,
+ onOpenChange: (open: boolean) => {
+ setIndicies({})
+ onOpenChange(open)
+ },
+ defaultValues,
+ })
const onSubmit = useCallback(async () => {
- if (newAddresses.length === 0) {
+ if (newGeneratedAddresses.length === 0) {
triggerErrorToast(
'Add and generate addresses with your Ledger device to continue.'
)
return
}
await saveAddresses()
- setIndicies({})
closeAndReset()
- }, [newAddresses, saveAddresses, closeAndReset])
+ }, [newGeneratedAddresses, saveAddresses, closeAndReset])
return (