-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix and optimise fetching the recovery state #2807
Conversation
Branch preview⏳ Deploying a preview site... |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Coverage report❌ An unexpected error occurred. For more details, check console
Test suite run failedFailed tests: 1/1139. Failed suites: 1/159.
Report generated by 🧪jest coverage report action from 3d5e88f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far! I'm sure you're aware but there are some breaking tests.
|
||
const MAX_PAGE_SIZE = 100 | ||
|
||
export const _getQueuedTransactionsAdded = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the unit test for this.
@@ -48,7 +41,7 @@ export const _getSafeCreationReceipt = memoize( | |||
safeAddress: string | |||
provider: JsonRpcProvider | |||
}): Promise<TransactionReceipt> => { | |||
const url = `${transactionService}/v1/${safeAddress}/creation/` | |||
const url = `${transactionService}api/v1/safes/${safeAddress}/creation/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems as though there can be a forward slash on some networks. Perhaps we should check if one is required and/or fix the configs.
@@ -63,6 +56,28 @@ export const _getSafeCreationReceipt = memoize( | |||
({ transactionService, safeAddress }) => transactionService + safeAddress, | |||
) | |||
|
|||
const queryAddedTransactions = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a unit test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more tests for it's outside function effectively also testing this logic.
|
||
const transactionAddedFilter = delayModifier.filters.TransactionAdded() | ||
|
||
const diff = queueNonce.sub(txNonce).toNumber() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move this into the if
below.
|
||
const diff = queueNonce.sub(txNonce).toNumber() | ||
if (transactionAddedFilter.topics) { | ||
const queueNonceFilter = Array.from({ length: diff }, (_, idx) => hexZeroPad(txNonce.add(idx).toHexString(), 32)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment explaining this?
const { blockHash } = await _getSafeCreationReceipt(rest) | ||
|
||
const transactionAddedFilter = delayModifier.filters.TransactionAdded() | ||
const { blockNumber } = await _getSafeCreationReceipt(rest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this into queryAddedTransactions
so it doesn't call _getSafeCreationReceipt
when no queued transactions exist.
// Only queued transactions with queueNonce >= current txNonce | ||
return transactionsAdded.filter(({ args }) => args.queueNonce.gte(txNonce)) | ||
} | ||
export const normalizeTxServiceUrl = (url: string): string => (url.endsWith('/') ? url : `${url}/`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there is a trimTrailingSlash
function in @/utils/url.ts
that we could export and use instead of this. We would then have to append the /
within _getSafeCreationReceipt
.
What it solves
Querying the recovery state does not work.
How this PR fixes it
blockNumber
instead ofblockHash
How to test it
Checklist