Skip to content

Commit 95da57c

Browse files
committed
fix: do preview correctly
1 parent a47f2e1 commit 95da57c

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

multisig_ci/ci_override.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,41 +75,7 @@ def preview(self, safe_tx: SafeTx, events=True, call_trace=False, reset=True):
7575
events = False
7676
call_trace = False
7777

78-
"""
79-
Dry run a Safe transaction in a forked network environment.
80-
"""
81-
if reset:
82-
chain.reset()
83-
84-
tx = copy(safe_tx)
85-
safe = Contract.from_abi('Gnosis Safe', self.address, self.get_contract().abi)
86-
# Replace pending nonce with the subsequent nonce, this could change the safe_tx_hash
87-
tx.safe_nonce = safe.nonce()
88-
# Forge signatures from the needed amount of owners, skip the one which submits the tx
89-
# Owners must be sorted numerically, sorting as checksum addresses may yield wrong order
90-
threshold = safe.getThreshold()
91-
sorted_owners = sorted(safe.getOwners(), key=lambda x: int(x, 16))
92-
owners = [accounts.at(owner, force=True) for owner in sorted_owners[:threshold]]
93-
for owner in owners:
94-
safe.approveHash(tx.safe_tx_hash, {'from': owner})
95-
96-
# Signautres are encoded as [bytes32 r, bytes32 s, bytes8 v]
97-
# Pre-validated signatures are encoded as r=owner, s unused and v=1.
98-
# https://docs.gnosis.io/safe/docs/contracts_signatures/#pre-validated-signatures
99-
tx.signatures = b''.join([encode_abi(['address', 'uint'], [str(owner), 0]) + b'\x01' for owner in owners])
100-
payload = tx.w3_tx.buildTransaction({'gas': str(chain.block_gas_limit)})
101-
receipt = owners[0].transfer(payload['to'], payload['value'], gas_limit=payload['gas'], data=payload['data'])
102-
103-
if 'ExecutionSuccess' not in receipt.events:
104-
receipt.info()
105-
receipt.call_trace(True)
106-
raise ApeSafe.ExecutionFailure()
107-
if events:
108-
receipt.info()
109-
if call_trace:
110-
receipt.call_trace(True)
111-
return receipt
112-
78+
return super().preview(safe_tx, events, call_trace, reset)
11379

11480
def get_signer(self, signer: Optional[Union[LocalAccount, str]] = None) -> LocalAccount:
11581
if not self.is_ci:

0 commit comments

Comments
 (0)