-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bug/multisig nonce selection #1516
Changes from 10 commits
d259700
932fc1b
b9171bb
cd8c7ce
24c4401
4698383
b1f5800
2e252ab
6fe9a41
19e9ae4
c37ac43
697a310
43253a1
95f769b
418892d
b5247fc
773bb5e
6e9a076
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ import { NodeAction } from '../../../providers/App/node/action'; | |
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; | ||
import { Node } from '../../../types'; | ||
import { mapChildNodes } from '../../../utils/hierarchy'; | ||
import { useAsyncRetry } from '../../utils/useAsyncRetry'; | ||
import { useLazyDAOName } from '../useDAOName'; | ||
import { useFractalModules } from './useFractalModules'; | ||
|
||
|
@@ -33,7 +32,6 @@ export const useFractalNode = ( | |
const { getDaoName } = useLazyDAOName(); | ||
|
||
const lookupModules = useFractalModules(); | ||
const { requestWithRetries } = useAsyncRetry(); | ||
|
||
const formatDAOQuery = useCallback((result: { data?: DAOQueryQuery }, _daoAddress: string) => { | ||
if (!result.data) { | ||
|
@@ -103,20 +101,15 @@ export const useFractalNode = ( | |
try { | ||
if (!safeAPI) throw new Error('SafeAPI not set'); | ||
|
||
safeInfo = await requestWithRetries( | ||
() => safeAPI.getSafeInfo(utils.getAddress(_daoAddress)), | ||
5, | ||
); | ||
const address = utils.getAddress(_daoAddress); | ||
const safeInfoResponse = await safeAPI.getSafeInfo(address); | ||
const nextNonce = await safeAPI.getNextNonce(address); | ||
safeInfo = { ...safeInfoResponse, nonce: nextNonce }; | ||
} catch (e) { | ||
reset({ error: true }); | ||
return; | ||
} | ||
|
||
if (!safeInfo) { | ||
reset({ error: true }); | ||
return; | ||
} | ||
|
||
Comment on lines
-113
to
-117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't ever be null/undefined, the |
||
// if here, we have a valid Safe! | ||
|
||
action.dispatch({ | ||
|
@@ -129,7 +122,7 @@ export const useFractalNode = ( | |
payload: safeInfo, | ||
}); | ||
}, | ||
[action, lookupModules, requestWithRetries, reset, safeAPI], | ||
[action, lookupModules, reset, safeAPI], | ||
); | ||
|
||
useEffect(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,14 +54,16 @@ export const useLoadDAONode = () => { | |
logError('graphQL query failed'); | ||
return { error: 'errorFailedSearch' }; | ||
} | ||
const safe = await safeAPI.getSafeInfo(_daoAddress); | ||
const fractalModules = await lookupModules(safe.modules); | ||
const daoName = await getDaoName(utils.getAddress(safe.address), graphNodeInfo.daoName); | ||
|
||
const sanitizedDaoAddress = utils.getAddress(_daoAddress); | ||
const safeInfo = await safeAPI.getSafeInfo(sanitizedDaoAddress); | ||
const nextNonce = await safeAPI.getNextNonce(sanitizedDaoAddress); | ||
const safeInfoWithGuard = { ...safeInfo, nonce: nextNonce }; | ||
|
||
const node: FractalNode = Object.assign(graphNodeInfo, { | ||
daoName, | ||
safe, | ||
fractalModules, | ||
daoName: await getDaoName(sanitizedDaoAddress, graphNodeInfo.daoName), | ||
safe: safeInfoWithGuard, | ||
fractalModules: await lookupModules(safeInfo.modules), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's a place where we're loading up Safe data and not getting it from / putting it into global state, so want to make sure to put the proper next nonce on this one. |
||
}); | ||
|
||
// TODO we could cache node here, but should be careful not to cache | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,11 @@ export default function useClawBack({ childSafeInfo, parentAddress }: IUseClawBa | |
const childSafeBalance = await safeAPI.getBalances( | ||
utils.getAddress(childSafeInfo.daoAddress), | ||
); | ||
const parentSafeInfo = await safeAPI.getSafeInfo(utils.getAddress(parentAddress)); | ||
|
||
const santitizedParentAddress = utils.getAddress(parentAddress); | ||
const parentSafeInfo = await safeAPI.getSafeInfo(santitizedParentAddress); | ||
const parentSafeNextNonce = await safeAPI.getNextNonce(santitizedParentAddress); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's a place where we're loading up Safe data and not getting it from / putting it into global state, so want to make sure to put the proper next nonce on this one. |
||
if (canUserCreateProposal && parentAddress && childSafeInfo && parentSafeInfo) { | ||
const abiCoder = new ethers.utils.AbiCoder(); | ||
const fractalModule = childSafeInfo.fractalModules!.find( | ||
|
@@ -88,7 +92,7 @@ export default function useClawBack({ childSafeInfo, parentAddress }: IUseClawBa | |
values: transactions.map(tx => tx.value), | ||
calldatas: transactions.map(tx => tx.calldata), | ||
}, | ||
nonce: parentSafeInfo.nonce, | ||
nonce: parentSafeNextNonce, | ||
pendingToastMessage: t('clawBackPendingToastMessage'), | ||
failedToastMessage: t('clawBackFailedToastMessage'), | ||
successToastMessage: t('clawBackSuccessToastMessage'), | ||
|
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.
Look at that, there's a function right on the Safe API for getting the next nonce.
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.
Lool I'm glad you didn't discover this before having to implement it yourself, which led to me understanding a wee bit more what's going on behind the scenes