Skip to content

Commit 75cf685

Browse files
committed
fix: walletd events update
1 parent e989296 commit 75cf685

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.changeset/gentle-zoos-love.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'walletd': minor
3+
'@siafoundation/walletd-types': minor
4+
---
5+
6+
Updated wallet events to include maturityHeight and renamed val to data. Closes https://github.com/SiaFoundation/walletd/issues/114

apps/walletd/contexts/events/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ export function useEventsMain() {
6868
let amountSf = 0
6969
if (e.type === 'transaction') {
7070
const inputsScTotal =
71-
e.val?.siacoinInputs?.reduce((acc, o) => {
71+
e.data?.siacoinInputs?.reduce((acc, o) => {
7272
if (e.relevant.includes(o.siacoinOutput.address)) {
7373
return acc.plus(o.siacoinOutput.value)
7474
}
7575
return acc
7676
}, new BigNumber(0)) || new BigNumber(0)
7777
const outputsScTotal =
78-
e.val?.siacoinOutputs?.reduce((acc, o) => {
78+
e.data?.siacoinOutputs?.reduce((acc, o) => {
7979
if (e.relevant.includes(o.siacoinOutput.address)) {
8080
return acc.plus(o.siacoinOutput.value)
8181
}
@@ -84,14 +84,14 @@ export function useEventsMain() {
8484
amountSc = outputsScTotal.minus(inputsScTotal)
8585

8686
const inputsSfTotal =
87-
e.val?.siafundInputs?.reduce((acc, o) => {
87+
e.data?.siafundInputs?.reduce((acc, o) => {
8888
if (e.relevant.includes(o.siafundElement.siafundOutput.address)) {
8989
return acc + o.siafundElement.siafundOutput.value
9090
}
9191
return acc
9292
}, 0) || 0
9393
const outputsSfTotal =
94-
e.val?.siafundOutputs?.reduce((acc, o) => {
94+
e.data?.siafundOutputs?.reduce((acc, o) => {
9595
if (e.relevant.includes(o.siafundOutput.address)) {
9696
return acc + o.siafundOutput.value
9797
}
@@ -101,10 +101,10 @@ export function useEventsMain() {
101101
}
102102

103103
if (e.type === 'miner payout') {
104-
amountSc = new BigNumber(e.val.siacoinOutput.siacoinOutput.value)
104+
amountSc = new BigNumber(e.data.siacoinOutput.siacoinOutput.value)
105105
}
106106
if (e.type === 'foundation subsidy') {
107-
amountSc = new BigNumber(e.val.siacoinOutput.siacoinOutput.value)
107+
amountSc = new BigNumber(e.data.siacoinOutput.siacoinOutput.value)
108108
}
109109

110110
const res: EventData = {
@@ -117,10 +117,10 @@ export function useEventsMain() {
117117
amountSf,
118118
}
119119
if (e.type === 'transaction') {
120-
res.fee = new BigNumber(e.val.fee)
120+
res.fee = new BigNumber(e.data.fee)
121121
}
122122
if (e.type === 'contract payout') {
123-
res.contractId = e.val.fileContract.id
123+
res.contractId = e.data.fileContract.id
124124
}
125125
return res
126126
})

libs/walletd-types/src/types.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type WalletEventBase = {
3939
id: Hash256
4040
timestamp: string
4141
index: ChainIndex
42+
maturityHeight: number
4243
relevant: Address[]
4344
}
4445

@@ -67,7 +68,7 @@ export type WalletHostAnnouncement = {
6768

6869
export type WalletEventTransaction = WalletEventBase & {
6970
type: 'transaction'
70-
val: {
71+
data: {
7172
siacoinInputs?: SiacoinElement[]
7273
siacoinOutputs?: SiacoinElement[]
7374
siafundInputs?: WalletSiafundInput[]
@@ -81,14 +82,14 @@ export type WalletEventTransaction = WalletEventBase & {
8182

8283
export type WalletEventMinerPayout = WalletEventBase & {
8384
type: 'miner payout'
84-
val: {
85+
data: {
8586
siacoinOutput: SiacoinElement
8687
}
8788
}
8889

8990
export type WalletEventContractPayout = WalletEventBase & {
9091
type: 'contract payout'
91-
val: {
92+
data: {
9293
fileContract: FileContractElement
9394
siacoinOutput: SiacoinElement
9495
missed: boolean
@@ -101,7 +102,7 @@ export type WalletEventSiafundClaim = WalletEventBase & {
101102

102103
export type WalletEventFoundationSubsidy = WalletEventBase & {
103104
type: 'foundation subsidy'
104-
val: {
105+
data: {
105106
siacoinOutput: SiacoinElement
106107
}
107108
}

0 commit comments

Comments
 (0)