Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/tx-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@nomiclabs/hardhat-etherscan": "^3.1.5",
"@types/react-beautiful-dnd": "^13.1.2",
"ethers": "^5.7.2",
"hardhat": "^2.12.6",
"hardhat": "^2.19.0",
"hardhat-deploy": "^0.11.22"
},
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions apps/tx-builder/src/lib/simulation/simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ const getSimulationLink = (simulationId: string): string => {
return `https://dashboard.tenderly.co/public/${TENDERLY_ORG_NAME}/${TENDERLY_PROJECT_NAME}/simulator/${simulationId}`
}

const GUARD_STORAGE_POSITION = '0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8'

/* We need to overwrite the threshold stored in smart contract storage to 1
to do a proper simulation that takes transaction guards into account.
The threshold is stored in storage slot 4 and uses full 32 bytes slot
Safe storage layout can be found here:
https://github.com/gnosis/safe-contracts/blob/main/contracts/libraries/GnosisSafeStorage.sol */
const THRESHOLD_ONE_STORAGE_OVERRIDE = {
https://github.com/safe-global/safe-smart-account/blob/main/contracts/libraries/SafeStorage.sol */
const STORAGE_OVERRIDE = {
// Threshold: 1
[`0x${'4'.padStart(64, '0')}`]: `0x${'1'.padStart(64, '0')}`,
// Guard: 0x0000000000000000000000000000000000000000000000000000000000000000
[GUARD_STORAGE_POSITION]: `0x${'0'.padStart(64, '0')}`,
}

const getStateOverride = (
Expand Down Expand Up @@ -197,7 +202,7 @@ const getSimulationPayload = (tx: SimulationTxParams): TenderlySimulatePayload =
tx.safeAddress,
undefined,
undefined,
THRESHOLD_ONE_STORAGE_OVERRIDE,
STORAGE_OVERRIDE,
)

return {
Expand Down
Loading
Loading