fetching transactions wip
This commit is contained in:
parent
eb3708a623
commit
1a5beb16a4
|
@ -38,6 +38,6 @@ export const setOwners = async (safeAddress: string, owners: List<Owner>) => {
|
|||
|
||||
export const getOwners = async (safeAddress: string): Map<string, string> => {
|
||||
const data: Object = await loadFromStorage(`${OWNERS_KEY}-${safeAddress}`)
|
||||
|
||||
console.log(data)
|
||||
return data ? Map(data) : Map()
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ type Props = SelectorProps & {
|
|||
classes: Object,
|
||||
granted: boolean,
|
||||
createTransaction: Function,
|
||||
fetchTransactions: Function,
|
||||
}
|
||||
|
||||
type State = {
|
||||
|
@ -90,7 +91,15 @@ class Layout extends React.Component<Props, State> {
|
|||
|
||||
render() {
|
||||
const {
|
||||
safe, provider, network, classes, granted, tokens, activeTokens, createTransaction,
|
||||
safe,
|
||||
provider,
|
||||
network,
|
||||
classes,
|
||||
granted,
|
||||
tokens,
|
||||
activeTokens,
|
||||
createTransaction,
|
||||
fetchTransactions,
|
||||
} = this.props
|
||||
const { tabIndex } = this.state
|
||||
|
||||
|
@ -142,7 +151,7 @@ class Layout extends React.Component<Props, State> {
|
|||
createTransaction={createTransaction}
|
||||
/>
|
||||
)}
|
||||
{tabIndex === 1 && <Transactions />}
|
||||
{tabIndex === 1 && <Transactions fetchTransactions={fetchTransactions} safeAddress={address} />}
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,13 +3,18 @@ import * as React from 'react'
|
|||
import { List } from 'immutable'
|
||||
import NoTransactions from '~/routes/safe/components/Transactions/NoTransactions'
|
||||
|
||||
type Props = SelectorProps &
|
||||
Actions & {
|
||||
safeName: string,
|
||||
safeAddress: string,
|
||||
threshold: number,
|
||||
}
|
||||
type Props = {
|
||||
safeAddress: string,
|
||||
threshold: number,
|
||||
}
|
||||
|
||||
class Transactions extends React.Component<Props, {}> {
|
||||
componentDidMount() {
|
||||
const { safeAddress, fetchTransactions } = this.props
|
||||
|
||||
fetchTransactions(safeAddress)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { transactions = List(), safeName, threshold } = this.props
|
||||
const hasTransactions = false
|
||||
|
|
|
@ -2,15 +2,18 @@
|
|||
import fetchSafe from '~/routes/safe/store/actions/fetchSafe'
|
||||
import fetchTokenBalances from '~/routes/safe/store/actions/fetchTokenBalances'
|
||||
import createTransaction from '~/routes/safe/store/actions/createTransaction'
|
||||
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
|
||||
|
||||
export type Actions = {
|
||||
fetchSafe: typeof fetchSafe,
|
||||
fetchTokenBalances: typeof fetchTokenBalances,
|
||||
createTransaction: typeof createTransaction,
|
||||
fetchTransactions: typeof fetchTransactions,
|
||||
}
|
||||
|
||||
export default {
|
||||
fetchSafe,
|
||||
fetchTokenBalances,
|
||||
createTransaction,
|
||||
fetchTransactions,
|
||||
}
|
||||
|
|
|
@ -52,7 +52,15 @@ class SafeView extends React.Component<Props> {
|
|||
|
||||
render() {
|
||||
const {
|
||||
safe, provider, activeTokens, granted, userAddress, network, tokens, createTransaction,
|
||||
safe,
|
||||
provider,
|
||||
activeTokens,
|
||||
granted,
|
||||
userAddress,
|
||||
network,
|
||||
tokens,
|
||||
createTransaction,
|
||||
fetchTransactions,
|
||||
} = this.props
|
||||
|
||||
return (
|
||||
|
@ -66,6 +74,7 @@ class SafeView extends React.Component<Props> {
|
|||
network={network}
|
||||
granted={granted}
|
||||
createTransaction={createTransaction}
|
||||
fetchTransactions={fetchTransactions}
|
||||
/>
|
||||
</Page>
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ import { loadSafeSubjects } from '~/utils/storage/transactions'
|
|||
import { buildTxServiceUrl, type TxServiceType } from '~/logic/safe/transactions/txHistory'
|
||||
import { getOwners } from '~/logic/safe/utils'
|
||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||
import addTransactions from './addTransactions'
|
||||
import { addTransactions } from './addTransactions'
|
||||
|
||||
type ConfirmationServiceModel = {
|
||||
owner: string,
|
||||
|
@ -31,9 +31,9 @@ type TxServiceModel = {
|
|||
isExecuted: boolean,
|
||||
}
|
||||
|
||||
const buildTransactionFrom = (safeAddress: string, tx: TxServiceModel, safeSubjects: Map<string, string>) => {
|
||||
const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, safeSubjects: Map<string, string>) => {
|
||||
const name = safeSubjects.get(String(tx.nonce)) || 'Unknown'
|
||||
const storedOwners = getOwners(safeAddress)
|
||||
const storedOwners = await getOwners(safeAddress)
|
||||
const confirmations = List(
|
||||
tx.confirmations.map((conf: ConfirmationServiceModel) => {
|
||||
const ownerName = storedOwners.get(conf.owner.toLowerCase()) || 'UNKNOWN'
|
||||
|
@ -62,7 +62,9 @@ export const loadSafeTransactions = async (safeAddress: string) => {
|
|||
const response = await axios.get(url)
|
||||
const transactions: TxServiceModel[] = response.data.results
|
||||
const safeSubjects = loadSafeSubjects(safeAddress)
|
||||
const txsRecord = transactions.map((tx: TxServiceModel) => buildTransactionFrom(safeAddress, tx, safeSubjects))
|
||||
const txsRecord = transactions.map(
|
||||
async (tx: TxServiceModel) => await buildTransactionFrom(safeAddress, tx, safeSubjects),
|
||||
)
|
||||
|
||||
return Map().set(safeAddress, List(txsRecord))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
import { List, Map } from 'immutable'
|
||||
import { handleActions, type ActionType } from 'redux-actions'
|
||||
import { ADD_TRANSACTIONS } from '~/routes/safe/store/actions/createTransaction'
|
||||
import { ADD_TRANSACTIONS } from '~/routes/safe/store/actions/addTransactions'
|
||||
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||
|
||||
export const TRANSACTIONS_REDUCER_ID = 'transactions'
|
||||
|
|
Loading…
Reference in New Issue