-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Atatakai
authored and
Atatakai
committed
May 30, 2024
1 parent
7ef7e50
commit 019554f
Showing
5 changed files
with
148 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { DeploymentStatus } from '@/client'; | ||
|
||
import { useBalance } from './useBalance'; | ||
import { useMasterSafe } from './useMasterSafe'; | ||
import { useServices } from './useServices'; | ||
import { useStore } from './useStore'; | ||
import { useWallet } from './useWallet'; | ||
|
||
const useAddressesLogs = () => { | ||
const { wallets, masterEoaAddress, masterSafeAddress } = useWallet(); | ||
|
||
const { backupSafeAddress, masterSafeOwners } = useMasterSafe(); | ||
|
||
return { | ||
isLoaded: wallets?.length !== 0 && !!masterSafeOwners, | ||
data: [ | ||
{ backupSafeAddress: backupSafeAddress ?? 'undefined' }, | ||
{ masterSafeAddress: masterSafeAddress ?? 'undefined' }, | ||
{ masterEoaAddress: masterEoaAddress ?? 'undefined' }, | ||
{ masterSafeOwners: masterSafeOwners ?? 'undefined' }, | ||
], | ||
}; | ||
}; | ||
|
||
const useBalancesLogs = () => { | ||
const { | ||
isBalanceLoaded, | ||
totalEthBalance, | ||
totalOlasBalance, | ||
wallets, | ||
walletBalances, | ||
totalOlasStakedBalance, | ||
} = useBalance(); | ||
|
||
return { | ||
isLoaded: isBalanceLoaded, | ||
data: [ | ||
{ wallets: wallets ?? 'undefined' }, | ||
{ walletBalances: walletBalances ?? 'undefined' }, | ||
{ totalOlasStakedBalance: totalOlasStakedBalance ?? 'undefined' }, | ||
{ totalEthBalance: totalEthBalance ?? 'undefined' }, | ||
{ totalOlasBalance: totalOlasBalance ?? 'undefined' }, | ||
], | ||
}; | ||
}; | ||
|
||
const useServicesLogs = () => { | ||
const { serviceStatus, services, hasInitialLoaded } = useServices(); | ||
|
||
return { | ||
isLoaded: hasInitialLoaded, | ||
data: { | ||
serviceStatus: serviceStatus | ||
? DeploymentStatus[serviceStatus] | ||
: 'undefined', | ||
services: | ||
services?.map((item) => ({ | ||
...item, | ||
keys: item.keys.map((key) => key.address), | ||
})) ?? 'undefined', | ||
}, | ||
}; | ||
}; | ||
|
||
export const useLogs = () => { | ||
const { storeState } = useStore(); | ||
|
||
const { isLoaded: isServicesLoaded, data: services } = useServicesLogs(); | ||
const { isLoaded: isBalancesLoaded, data: balances } = useBalancesLogs(); | ||
const { isLoaded: isAddressesLoaded, data: addresses } = useAddressesLogs(); | ||
|
||
const logs = useMemo(() => { | ||
if (isServicesLoaded && isBalancesLoaded && isAddressesLoaded) { | ||
return { | ||
store: storeState, | ||
debugData: { | ||
services, | ||
addresses, | ||
balances, | ||
}, | ||
}; | ||
} | ||
}, [ | ||
addresses, | ||
balances, | ||
isAddressesLoaded, | ||
isBalancesLoaded, | ||
isServicesLoaded, | ||
services, | ||
storeState, | ||
]); | ||
|
||
return logs; | ||
}; |