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:
Vojtech Simetka
2021-05-20 18:45:35 +02:00
committed by GitHub
parent edd4a2fc11
commit 7f5fbd3fb6
11 changed files with 70 additions and 123 deletions
+8 -9
View File
@@ -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'),
}
}
+8 -8
View File
@@ -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
View File
@@ -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,