feat: update to bee 0.6.0 and bee-js 0.9.0 (#99)
* chore: update the interfaces to latest bee-js * chore: update to latest bee-js * chore: removed upload page, updated to latest bee-js * chore: typo in src/pages/files/index.tsx Co-authored-by: Attila Gazso <agazso@gmail.com> * chore: update to bee-js 0.9.0 Co-authored-by: Attila Gazso <agazso@gmail.com>
This commit is contained in:
@@ -67,10 +67,8 @@ function mergeAccounting(
|
||||
// If there are no cheques (and hence last cashout actions), we don't need to sort and can return values right away
|
||||
if (!uncashedAmounts) return Object.values(accounting)
|
||||
|
||||
uncashedAmounts?.forEach(({ peer, cumulativePayout }) => {
|
||||
accounting[peer].uncashedAmount = new Token(
|
||||
accounting[peer].received.toBigNumber.minus(cumulativePayout.toString()),
|
||||
)
|
||||
uncashedAmounts?.forEach(({ peer, uncashedAmount }) => {
|
||||
accounting[peer].uncashedAmount = new Token(uncashedAmount)
|
||||
})
|
||||
|
||||
return Object.values(accounting).sort((a, b) =>
|
||||
@@ -93,9 +91,10 @@ export const useAccounting = (): UseAccountingHook => {
|
||||
if (isLoadingUncashed || !settlements.settlements || uncashedAmounts || error) return
|
||||
|
||||
setIsloadingUncashed(true)
|
||||
const promises = settlements.settlements.settlements.map(({ peer }) =>
|
||||
beeDebugApi.chequebook.getPeerLastCashout(peer),
|
||||
)
|
||||
const promises = settlements.settlements.settlements
|
||||
.filter(({ received }) => received.toBigNumber.gt('0'))
|
||||
.map(({ peer }) => beeDebugApi.chequebook.getPeerLastCashout(peer))
|
||||
|
||||
Promise.all(promises)
|
||||
.then(setUncashedAmounts)
|
||||
.catch(setErr)
|
||||
@@ -109,7 +108,7 @@ export const useAccounting = (): UseAccountingHook => {
|
||||
isLoadingUncashed,
|
||||
error,
|
||||
accounting,
|
||||
totalsent: settlements.settlements?.totalsent || new Token('0'),
|
||||
totalreceived: settlements.settlements?.totalreceived || new Token('0'),
|
||||
totalsent: settlements.settlements?.totalSent || new Token('0'),
|
||||
totalreceived: settlements.settlements?.totalReceived || new Token('0'),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +325,8 @@ export interface Settlement {
|
||||
}
|
||||
|
||||
export interface Settlements {
|
||||
totalreceived: Token
|
||||
totalsent: Token
|
||||
totalReceived: Token
|
||||
totalSent: Token
|
||||
settlements: Settlement[]
|
||||
}
|
||||
|
||||
@@ -345,10 +345,10 @@ export const useApiSettlements = (): SettlementsHook => {
|
||||
setLoading(true)
|
||||
beeDebugApi.settlements
|
||||
.getSettlements()
|
||||
.then(({ totalreceived, settlements, totalsent }) => {
|
||||
.then(({ totalReceived, settlements, totalSent }) => {
|
||||
const set = {
|
||||
totalreceived: new Token(totalreceived),
|
||||
totalsent: new Token(totalsent),
|
||||
totalReceived: new Token(totalReceived),
|
||||
totalSent: new Token(totalSent),
|
||||
settlements: settlements.map(({ peer, received, sent }) => ({
|
||||
peer,
|
||||
received: new Token(received),
|
||||
@@ -370,7 +370,7 @@ export const useApiSettlements = (): SettlementsHook => {
|
||||
|
||||
export interface LastCashout {
|
||||
peer: string
|
||||
cumulativePayout: Token
|
||||
uncashedAmount: Token
|
||||
}
|
||||
|
||||
export interface PeerLastCashoutHook {
|
||||
@@ -388,8 +388,8 @@ export const useApiPeerLastCashout = (peerId: string): PeerLastCashoutHook => {
|
||||
setLoading(true)
|
||||
beeDebugApi.chequebook
|
||||
.getPeerLastCashout(peerId)
|
||||
.then(({ peer, cumulativePayout }) => {
|
||||
setPeerCashout({ peer, cumulativePayout: new Token(cumulativePayout) })
|
||||
.then(({ peer, uncashedAmount }) => {
|
||||
setPeerCashout({ peer, uncashedAmount: new Token(uncashedAmount.toString()) })
|
||||
})
|
||||
.catch(error => {
|
||||
setError(error)
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ export const useStatusChequebook = (): StatusChequebookHook => {
|
||||
return {
|
||||
isLoading: isLoadingChequebookAddress || isLoadingChequebookBalance,
|
||||
isOk:
|
||||
Boolean(chequebookAddress?.chequebookaddress) &&
|
||||
Boolean(chequebookAddress?.chequebookAddress) &&
|
||||
chequebookBalance !== null &&
|
||||
chequebookBalance?.totalBalance.toBigNumber.isGreaterThan(0),
|
||||
chequebookBalance,
|
||||
|
||||
Reference in New Issue
Block a user