mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-12 11:04:07 +00:00
* 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
|
// then
|
||||||
expect(result).toBe(TransactionStatus.PENDING)
|
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', () => {
|
it('It should return AWAITING_CONFIRMATIONS if the tx has confirmations bellow the threshold, the user is owner and signed', () => {
|
||||||
// given
|
// given
|
||||||
const userAddress = 'address1'
|
const userAddress = 'address1'
|
||||||
|
@ -175,20 +175,20 @@ export const isTransactionCancelled = (
|
|||||||
|
|
||||||
export const calculateTransactionStatus = (
|
export const calculateTransactionStatus = (
|
||||||
tx: Transaction,
|
tx: Transaction,
|
||||||
{ owners, threshold }: SafeRecord,
|
{ owners, threshold, nonce }: SafeRecord,
|
||||||
currentUser?: string | null,
|
currentUser?: string | null,
|
||||||
): TransactionStatusValues => {
|
): TransactionStatusValues => {
|
||||||
let txStatus
|
let txStatus
|
||||||
|
|
||||||
if (tx.isExecuted && tx.isSuccessful) {
|
if (tx.isExecuted && tx.isSuccessful) {
|
||||||
txStatus = TransactionStatus.SUCCESS
|
txStatus = TransactionStatus.SUCCESS
|
||||||
} else if (tx.cancelled) {
|
} else if (tx.cancelled || nonce > tx.nonce) {
|
||||||
txStatus = TransactionStatus.CANCELLED
|
txStatus = TransactionStatus.CANCELLED
|
||||||
} else if (tx.confirmations.size === threshold) {
|
} else if (tx.confirmations.size === threshold) {
|
||||||
txStatus = TransactionStatus.AWAITING_EXECUTION
|
txStatus = TransactionStatus.AWAITING_EXECUTION
|
||||||
} else if (tx.creationTx) {
|
} else if (tx.creationTx) {
|
||||||
txStatus = TransactionStatus.SUCCESS
|
txStatus = TransactionStatus.SUCCESS
|
||||||
} else if (!tx.confirmations.size || !!tx.isPending) {
|
} else if (!!tx.isPending) {
|
||||||
txStatus = TransactionStatus.PENDING
|
txStatus = TransactionStatus.PENDING
|
||||||
} else {
|
} else {
|
||||||
const userConfirmed = tx.confirmations.filter((conf) => conf.owner === currentUser).size === 1
|
const userConfirmed = tx.confirmations.filter((conf) => conf.owner === currentUser).size === 1
|
||||||
|
@ -31,6 +31,7 @@ export const makeTransaction = Record<TransactionProps>({
|
|||||||
isCancellationTx: false,
|
isCancellationTx: false,
|
||||||
isCollectibleTransfer: false,
|
isCollectibleTransfer: false,
|
||||||
isExecuted: false,
|
isExecuted: false,
|
||||||
|
isPending: false,
|
||||||
isSuccessful: true,
|
isSuccessful: true,
|
||||||
isTokenTransfer: false,
|
isTokenTransfer: false,
|
||||||
masterCopy: '',
|
masterCopy: '',
|
||||||
|
@ -21,7 +21,7 @@ export default handleActions(
|
|||||||
if (stateTransactionsList) {
|
if (stateTransactionsList) {
|
||||||
const txsToStore = stateTransactionsList.withMutations((txsList) => {
|
const txsToStore = stateTransactionsList.withMutations((txsList) => {
|
||||||
transactions.forEach((updateTx) => {
|
transactions.forEach((updateTx) => {
|
||||||
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.nonce === updateTx.nonce)
|
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.safeTxHash === updateTx.safeTxHash)
|
||||||
|
|
||||||
if (storedTxIndex !== -1) {
|
if (storedTxIndex !== -1) {
|
||||||
// Update
|
// Update
|
||||||
|
@ -114,7 +114,6 @@ const OwnersColumn = ({
|
|||||||
}: ownersColumnProps): React.ReactElement => {
|
}: ownersColumnProps): React.ReactElement => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
let showOlderTxAnnotation
|
let showOlderTxAnnotation
|
||||||
|
|
||||||
if (tx.isExecuted || cancelTx.isExecuted) {
|
if (tx.isExecuted || cancelTx.isExecuted) {
|
||||||
showOlderTxAnnotation = false
|
showOlderTxAnnotation = false
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user