* don't use nonce in tx reducer * remove displaying of pending status if tx has no confirmations * Fix test for transactions pending status Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
parent
b04ec4337b
commit
396f6dd99b
|
@ -572,18 +572,6 @@ describe('calculateTransactionStatus', () => {
|
|||
// then
|
||||
expect(result).toBe(TransactionStatus.PENDING)
|
||||
})
|
||||
it('It should return PENDING if the tx has no confirmations', () => {
|
||||
// given
|
||||
const transaction = makeTransaction({ confirmations: List(), isPending: false })
|
||||
const safe = makeSafe({ threshold: 3 })
|
||||
const currentUser = safeAddress
|
||||
|
||||
// when
|
||||
const result = calculateTransactionStatus(transaction, safe, currentUser)
|
||||
|
||||
// then
|
||||
expect(result).toBe(TransactionStatus.PENDING)
|
||||
})
|
||||
it('It should return AWAITING_CONFIRMATIONS if the tx has confirmations bellow the threshold, the user is owner and signed', () => {
|
||||
// given
|
||||
const userAddress = 'address1'
|
||||
|
|
|
@ -175,20 +175,20 @@ export const isTransactionCancelled = (
|
|||
|
||||
export const calculateTransactionStatus = (
|
||||
tx: Transaction,
|
||||
{ owners, threshold }: SafeRecord,
|
||||
{ owners, threshold, nonce }: SafeRecord,
|
||||
currentUser?: string | null,
|
||||
): TransactionStatusValues => {
|
||||
let txStatus
|
||||
|
||||
if (tx.isExecuted && tx.isSuccessful) {
|
||||
txStatus = TransactionStatus.SUCCESS
|
||||
} else if (tx.cancelled) {
|
||||
} else if (tx.cancelled || nonce > tx.nonce) {
|
||||
txStatus = TransactionStatus.CANCELLED
|
||||
} else if (tx.confirmations.size === threshold) {
|
||||
txStatus = TransactionStatus.AWAITING_EXECUTION
|
||||
} else if (tx.creationTx) {
|
||||
txStatus = TransactionStatus.SUCCESS
|
||||
} else if (!tx.confirmations.size || !!tx.isPending) {
|
||||
} else if (!!tx.isPending) {
|
||||
txStatus = TransactionStatus.PENDING
|
||||
} else {
|
||||
const userConfirmed = tx.confirmations.filter((conf) => conf.owner === currentUser).size === 1
|
||||
|
|
|
@ -31,6 +31,7 @@ export const makeTransaction = Record<TransactionProps>({
|
|||
isCancellationTx: false,
|
||||
isCollectibleTransfer: false,
|
||||
isExecuted: false,
|
||||
isPending: false,
|
||||
isSuccessful: true,
|
||||
isTokenTransfer: false,
|
||||
masterCopy: '',
|
||||
|
|
|
@ -21,7 +21,7 @@ export default handleActions(
|
|||
if (stateTransactionsList) {
|
||||
const txsToStore = stateTransactionsList.withMutations((txsList) => {
|
||||
transactions.forEach((updateTx) => {
|
||||
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.nonce === updateTx.nonce)
|
||||
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.safeTxHash === updateTx.safeTxHash)
|
||||
|
||||
if (storedTxIndex !== -1) {
|
||||
// Update
|
||||
|
|
|
@ -114,7 +114,6 @@ const OwnersColumn = ({
|
|||
}: ownersColumnProps): React.ReactElement => {
|
||||
const classes = useStyles()
|
||||
let showOlderTxAnnotation
|
||||
|
||||
if (tx.isExecuted || cancelTx.isExecuted) {
|
||||
showOlderTxAnnotation = false
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue