ALM: Do not show unneeded failed confirmations (#641)
This commit is contained in:
parent
2b51d4c209
commit
9c2d2f404c
@ -69,7 +69,7 @@ export const ExecutionConfirmation = ({
|
|||||||
|
|
||||||
const getExecutionStatusElement = (validatorStatus = '') => {
|
const getExecutionStatusElement = (validatorStatus = '') => {
|
||||||
switch (validatorStatus) {
|
switch (validatorStatus) {
|
||||||
case VALIDATOR_CONFIRMATION_STATUS.SUCCESS:
|
case VALIDATOR_CONFIRMATION_STATUS.EXECUTION_SUCCESS:
|
||||||
return <SuccessLabel>{validatorStatus}</SuccessLabel>
|
return <SuccessLabel>{validatorStatus}</SuccessLabel>
|
||||||
case VALIDATOR_CONFIRMATION_STATUS.FAILED:
|
case VALIDATOR_CONFIRMATION_STATUS.FAILED:
|
||||||
return <RedLabel>{validatorStatus}</RedLabel>
|
return <RedLabel>{validatorStatus}</RedLabel>
|
||||||
|
@ -94,7 +94,7 @@ export const ValidatorsConfirmations = ({
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<RequiredConfirmations>
|
<RequiredConfirmations>
|
||||||
{requiredSignatures} of {validatorList.length} confirmations required
|
At least <strong>{requiredSignatures}</strong> of <strong>{validatorList.length}</strong> confirmations required
|
||||||
</RequiredConfirmations>
|
</RequiredConfirmations>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -54,7 +54,8 @@ export const CONFIRMATIONS_STATUS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const VALIDATOR_CONFIRMATION_STATUS = {
|
export const VALIDATOR_CONFIRMATION_STATUS = {
|
||||||
SUCCESS: 'Success',
|
SUCCESS: 'Confirmed',
|
||||||
|
EXECUTION_SUCCESS: 'Executed',
|
||||||
FAILED: 'Failed',
|
FAILED: 'Failed',
|
||||||
PENDING: 'Pending',
|
PENDING: 'Pending',
|
||||||
WAITING: 'Waiting',
|
WAITING: 'Waiting',
|
||||||
|
@ -343,7 +343,10 @@ export const useMessageConfirmations = ({
|
|||||||
// Sets the message status based in the collected information
|
// Sets the message status based in the collected information
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (executionData.status === VALIDATOR_CONFIRMATION_STATUS.SUCCESS && existsConfirmation(confirmations)) {
|
if (
|
||||||
|
executionData.status === VALIDATOR_CONFIRMATION_STATUS.EXECUTION_SUCCESS &&
|
||||||
|
existsConfirmation(confirmations)
|
||||||
|
) {
|
||||||
const newStatus = executionData.executionResult
|
const newStatus = executionData.executionResult
|
||||||
? CONFIRMATIONS_STATUS.SUCCESS
|
? CONFIRMATIONS_STATUS.SUCCESS
|
||||||
: CONFIRMATIONS_STATUS.SUCCESS_MESSAGE_FAILED
|
: CONFIRMATIONS_STATUS.SUCCESS_MESSAGE_FAILED
|
||||||
|
@ -281,9 +281,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
)
|
)
|
||||||
expect(res2).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res3).toEqual(
|
expect(res3).toEqual(
|
||||||
@ -382,25 +382,25 @@ describe('getConfirmationsForTx', () => {
|
|||||||
)
|
)
|
||||||
expect(res2).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res3).toEqual(
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res4).toEqual(
|
expect(res4).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@ -492,15 +492,15 @@ describe('getConfirmationsForTx', () => {
|
|||||||
)
|
)
|
||||||
expect(res2).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res3).toEqual(
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@ -596,9 +596,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
)
|
)
|
||||||
expect(res2).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res3).toEqual(
|
expect(res3).toEqual(
|
||||||
@ -610,9 +610,13 @@ describe('getConfirmationsForTx', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
test('should remove pending state after transaction mined', async () => {
|
test('should remove pending state after transaction mined', async () => {
|
||||||
// Validator1 success
|
const validator4 = '0x9d2dC11C342F4eF3C5491A048D0f0eBCd2D8f7C3'
|
||||||
// Validator2 failed
|
const validatorList = [validator1, validator2, validator3, validator4]
|
||||||
// Validator3 Pending
|
|
||||||
|
// Validator1 success (ts=100)
|
||||||
|
// Validator2 failed (ts=200)
|
||||||
|
// Validator3 Pending (ts=300)
|
||||||
|
// Validator4 Excess confirmation (Failed) (ts=400)
|
||||||
|
|
||||||
getValidatorConfirmation
|
getValidatorConfirmation
|
||||||
.mockImplementationOnce(() => async (validator: string) => ({
|
.mockImplementationOnce(() => async (validator: string) => ({
|
||||||
@ -623,30 +627,44 @@ describe('getConfirmationsForTx', () => {
|
|||||||
.mockImplementation(() => async (validator: string) => ({
|
.mockImplementation(() => async (validator: string) => ({
|
||||||
validator,
|
validator,
|
||||||
status:
|
status:
|
||||||
validator !== validator2 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
validator === validator1 || validator === validator3
|
||||||
|
? VALIDATOR_CONFIRMATION_STATUS.SUCCESS
|
||||||
|
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getSuccessExecutionTransaction
|
getSuccessExecutionTransaction
|
||||||
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator === validator1 ? '0x123' : '',
|
txHash: validatorData.validator === validator1 ? '0x100' : '',
|
||||||
timestamp: validatorData.validator === validator1 ? 123 : 0
|
timestamp: validatorData.validator === validator1 ? 100 : 0
|
||||||
}))
|
}))
|
||||||
.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator !== validator2 ? '0x123' : '',
|
txHash:
|
||||||
timestamp: validatorData.validator !== validator2 ? 123 : 0
|
validatorData.validator === validator1 ? '0x100' : validatorData.validator === validator3 ? '0x300' : '',
|
||||||
|
timestamp: validatorData.validator === validator1 ? 100 : validatorData.validator === validator3 ? 300 : ''
|
||||||
|
}))
|
||||||
|
getValidatorFailedTransaction
|
||||||
|
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
|
validator: validatorData.validator,
|
||||||
|
status:
|
||||||
|
validatorData.validator === validator2
|
||||||
|
? VALIDATOR_CONFIRMATION_STATUS.FAILED
|
||||||
|
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
||||||
|
txHash: validatorData.validator === validator2 ? '0x200' : '',
|
||||||
|
timestamp: validatorData.validator === validator2 ? 200 : 0
|
||||||
|
}))
|
||||||
|
.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
|
validator: validatorData.validator,
|
||||||
|
status:
|
||||||
|
validatorData.validator === validator2 || validatorData.validator === validator4
|
||||||
|
? VALIDATOR_CONFIRMATION_STATUS.FAILED
|
||||||
|
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
||||||
|
txHash:
|
||||||
|
validatorData.validator === validator2 ? '0x200' : validatorData.validator === validator4 ? '0x400' : '',
|
||||||
|
timestamp: validatorData.validator === validator2 ? 200 : validatorData.validator === validator4 ? 400 : ''
|
||||||
}))
|
}))
|
||||||
getValidatorFailedTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
|
||||||
validator: validatorData.validator,
|
|
||||||
status:
|
|
||||||
validatorData.validator === validator2
|
|
||||||
? VALIDATOR_CONFIRMATION_STATUS.FAILED
|
|
||||||
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
|
||||||
txHash: validatorData.validator === validator2 ? '0x123' : '',
|
|
||||||
timestamp: validatorData.validator === validator2 ? 123 : 0
|
|
||||||
}))
|
|
||||||
getValidatorPendingTransaction
|
getValidatorPendingTransaction
|
||||||
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
@ -654,8 +672,8 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validatorData.validator === validator3
|
validatorData.validator === validator3
|
||||||
? VALIDATOR_CONFIRMATION_STATUS.PENDING
|
? VALIDATOR_CONFIRMATION_STATUS.PENDING
|
||||||
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
||||||
txHash: validatorData.validator === validator3 ? '0x123' : '',
|
txHash: validatorData.validator === validator3 ? '0x300' : '',
|
||||||
timestamp: validatorData.validator === validator3 ? 123 : 0
|
timestamp: validatorData.validator === validator3 ? 300 : 0
|
||||||
}))
|
}))
|
||||||
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
@ -712,28 +730,32 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res2).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res3).toEqual(
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x300', timestamp: 300 },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res4).toEqual(
|
expect(res4).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x200', timestamp: 200 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x300', timestamp: 300 },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -781,23 +803,26 @@ describe('getConfirmationsForTx', () => {
|
|||||||
const res7 = setResult.mock.calls[6][0](res6)
|
const res7 = setResult.mock.calls[6][0](res6)
|
||||||
expect(res5).toEqual(
|
expect(res5).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x200', timestamp: 200 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res6).toEqual(
|
expect(res6).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x200', timestamp: 200 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x300', timestamp: 300 },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(res7).toEqual(
|
expect(res7).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x100', timestamp: 100 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x200', timestamp: 200 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x300', timestamp: 300 },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x400', timestamp: 400 }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -84,7 +84,7 @@ describe('getFinalizationEvent', () => {
|
|||||||
expect(setResult).toBeCalledTimes(1)
|
expect(setResult).toBeCalledTimes(1)
|
||||||
expect(setResult.mock.calls[0][0]).toEqual({
|
expect(setResult.mock.calls[0][0]).toEqual({
|
||||||
validator: validator1,
|
validator: validator1,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.EXECUTION_SUCCESS,
|
||||||
txHash,
|
txHash,
|
||||||
timestamp,
|
timestamp,
|
||||||
executionResult: true
|
executionResult: true
|
||||||
|
@ -72,6 +72,28 @@ export const getConfirmationsForTx = async (
|
|||||||
updateConfirmations(validatorConfirmations)
|
updateConfirmations(validatorConfirmations)
|
||||||
setSignatureCollected(hasEnoughSignatures)
|
setSignatureCollected(hasEnoughSignatures)
|
||||||
|
|
||||||
|
if (hasEnoughSignatures) {
|
||||||
|
setPendingConfirmations(false)
|
||||||
|
if (fromHome) {
|
||||||
|
// fetch collected signatures for possible manual processing
|
||||||
|
setSignatureCollected(
|
||||||
|
await Promise.all(
|
||||||
|
Array.from(Array(requiredSignatures).keys()).map(i => bridgeContract.methods.signature(hashMsg, i).call())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get transactions from success signatures
|
||||||
|
const successConfirmationWithData = await Promise.all(
|
||||||
|
successConfirmations.map(
|
||||||
|
getSuccessExecutionTransaction(web3, bridgeContract, fromHome, messageData, startBlock, getSuccessTransactions)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const successConfirmationWithTxFound = successConfirmationWithData.filter(v => v.txHash !== '')
|
||||||
|
updateConfirmations(successConfirmationWithTxFound)
|
||||||
|
|
||||||
// If signatures not collected, look for pending transactions
|
// If signatures not collected, look for pending transactions
|
||||||
if (!hasEnoughSignatures) {
|
if (!hasEnoughSignatures) {
|
||||||
// Check if confirmation is pending
|
// Check if confirmation is pending
|
||||||
@ -84,16 +106,6 @@ export const getConfirmationsForTx = async (
|
|||||||
)
|
)
|
||||||
updateConfirmations(validatorPendingConfirmations)
|
updateConfirmations(validatorPendingConfirmations)
|
||||||
setPendingConfirmations(validatorPendingConfirmations.length > 0)
|
setPendingConfirmations(validatorPendingConfirmations.length > 0)
|
||||||
} else {
|
|
||||||
setPendingConfirmations(false)
|
|
||||||
if (fromHome) {
|
|
||||||
// fetch collected signatures for possible manual processing
|
|
||||||
setSignatureCollected(
|
|
||||||
await Promise.all(
|
|
||||||
Array.from(Array(requiredSignatures).keys()).map(i => bridgeContract.methods.signature(hashMsg, i).call())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const undefinedConfirmations = validatorConfirmations.filter(
|
const undefinedConfirmations = validatorConfirmations.filter(
|
||||||
@ -106,9 +118,21 @@ export const getConfirmationsForTx = async (
|
|||||||
getValidatorFailedTransaction(bridgeContract, messageData, startBlock, getFailedTransactions)
|
getValidatorFailedTransaction(bridgeContract, messageData, startBlock, getFailedTransactions)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
const validatorFailedConfirmations = validatorFailedConfirmationsChecks.filter(
|
let validatorFailedConfirmations = validatorFailedConfirmationsChecks.filter(
|
||||||
c => c.status === VALIDATOR_CONFIRMATION_STATUS.FAILED
|
c => c.status === VALIDATOR_CONFIRMATION_STATUS.FAILED
|
||||||
)
|
)
|
||||||
|
if (hasEnoughSignatures) {
|
||||||
|
const lastTS = Math.max(...successConfirmationWithTxFound.map(c => c.timestamp || 0))
|
||||||
|
validatorFailedConfirmations = validatorFailedConfirmations.map(
|
||||||
|
c =>
|
||||||
|
c.timestamp < lastTS
|
||||||
|
? c
|
||||||
|
: {
|
||||||
|
...c,
|
||||||
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
setFailedConfirmations(validatorFailedConfirmations.length > validatorList.length - requiredSignatures)
|
setFailedConfirmations(validatorFailedConfirmations.length > validatorList.length - requiredSignatures)
|
||||||
updateConfirmations(validatorFailedConfirmations)
|
updateConfirmations(validatorFailedConfirmations)
|
||||||
|
|
||||||
@ -125,16 +149,6 @@ export const getConfirmationsForTx = async (
|
|||||||
updateConfirmations(notRequiredConfirmations)
|
updateConfirmations(notRequiredConfirmations)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get transactions from success signatures
|
|
||||||
const successConfirmationWithData = await Promise.all(
|
|
||||||
successConfirmations.map(
|
|
||||||
getSuccessExecutionTransaction(web3, bridgeContract, fromHome, messageData, startBlock, getSuccessTransactions)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
const successConfirmationWithTxFound = successConfirmationWithData.filter(v => v.txHash !== '')
|
|
||||||
updateConfirmations(successConfirmationWithTxFound)
|
|
||||||
|
|
||||||
// retry if not all signatures are collected and some confirmations are still missing
|
// retry if not all signatures are collected and some confirmations are still missing
|
||||||
// or some success transactions were not fetched successfully
|
// or some success transactions were not fetched successfully
|
||||||
if (
|
if (
|
||||||
|
@ -59,7 +59,7 @@ export const getSuccessExecutionData = async (
|
|||||||
const validatorAddress = web3.utils.toChecksumAddress(txReceipt.from)
|
const validatorAddress = web3.utils.toChecksumAddress(txReceipt.from)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.EXECUTION_SUCCESS,
|
||||||
validator: validatorAddress,
|
validator: validatorAddress,
|
||||||
txHash: event.transactionHash,
|
txHash: event.transactionHash,
|
||||||
timestamp: blockTimestamp,
|
timestamp: blockTimestamp,
|
||||||
|
Loading…
Reference in New Issue
Block a user