add eth balance to safe model
This commit is contained in:
parent
be295d1ef5
commit
5f142bcc75
|
@ -7,7 +7,7 @@ import SafeRecord, { type SafeProps } from '~/routes/safe/store/model/safe'
|
|||
import updateSafe from '~/routes/safe/store/actions/updateSafe'
|
||||
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
||||
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { getWeb3, getBalanceInEtherOf } from '~/logic/wallets/getWeb3'
|
||||
|
||||
const buildOwnersFrom = (
|
||||
safeOwners: string[],
|
||||
|
@ -21,6 +21,7 @@ export const buildSafe = async (safeAddress: string, safeName: string) => {
|
|||
const web3 = getWeb3()
|
||||
const SafeContract = await getGnosisSafeContract(web3)
|
||||
const gnosisSafe = await SafeContract.at(safeAddress)
|
||||
const ethBalance = await getBalanceInEtherOf(safeAddress)
|
||||
|
||||
const threshold = Number(await gnosisSafe.getThreshold())
|
||||
const owners = List(buildOwnersFrom(await gnosisSafe.getOwners(), await getOwners(safeAddress)))
|
||||
|
@ -30,6 +31,7 @@ export const buildSafe = async (safeAddress: string, safeName: string) => {
|
|||
name: safeName,
|
||||
threshold,
|
||||
owners,
|
||||
ethBalance,
|
||||
}
|
||||
|
||||
return SafeRecord(safe)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
import { List, Record, Map } from 'immutable'
|
||||
import type { RecordFactory, RecordOf } from 'immutable'
|
||||
import type { Owner } from '~/routes/safe/store/model/owner'
|
||||
import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers'
|
||||
|
||||
export type SafeProps = {
|
||||
name: string,
|
||||
address: string,
|
||||
threshold: number,
|
||||
ethBalance: string,
|
||||
owners: List<Owner>,
|
||||
tokens?: List<Object>,
|
||||
}
|
||||
|
@ -16,13 +16,9 @@ const SafeRecord: RecordFactory<SafeProps> = Record({
|
|||
name: '',
|
||||
address: '',
|
||||
threshold: 0,
|
||||
ethBalance: 0,
|
||||
owners: List([]),
|
||||
tokens: List([
|
||||
{
|
||||
address: ETH_ADDRESS,
|
||||
balance: '0',
|
||||
},
|
||||
]),
|
||||
tokens: List([]),
|
||||
})
|
||||
|
||||
// Tokens is a list of currently enabled tokens for the safe with balances
|
||||
|
|
Loading…
Reference in New Issue