Skip to content

Commit bae99ad

Browse files
committed
simplify, only set_code with incremented nonce
1 parent ef6bb0e commit bae99ad

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

crates/cheatcodes/src/script.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,13 @@ fn write_delegation(ccx: &mut CheatsCtxt, auth: SignedAuthorization) -> Result<(
127127
let authority = auth.recover_authority().map_err(|e| format!("{e}"))?;
128128
let authority_acc = ccx.ecx.journaled_state.load_account(authority, &mut ccx.ecx.db)?;
129129

130-
// Create and set bytecode with incremented nonce.
131-
authority_acc.data.info.nonce += 1;
132-
if authority_acc.data.info.nonce != auth.nonce {
130+
if authority_acc.data.info.nonce + 1 != auth.nonce {
133131
return Err("invalid nonce".into());
134132
}
135133

136134
let bytecode = Bytecode::new_eip7702(*auth.address());
137135
ccx.ecx.journaled_state.set_code(authority, bytecode);
138136

139-
// Reset authority nonce.
140-
let authority_acc = ccx.ecx.journaled_state.load_account(authority, &mut ccx.ecx.db)?;
141-
authority_acc.data.info.nonce -= 1;
142137
Ok(())
143138
}
144139

testdata/default/cheats/AttachDelegation.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ contract AttachDelegationTest is DSTest {
4646
vm._expectCheatcodeRevert("vm.attachDelegation: invalid nonce");
4747
vm.attachDelegation(signedDelegation);
4848

49-
signedDelegation = vm.signDelegation(address(implementation), alice_pk, 2);
49+
signedDelegation = vm.signDelegation(address(implementation), alice_pk, 1);
5050
vm.attachDelegation(signedDelegation);
5151
}
5252

@@ -143,7 +143,7 @@ contract AttachDelegationTest is DSTest {
143143
vm._expectCheatcodeRevert("vm.signAndAttachDelegation: invalid nonce");
144144
vm.signAndAttachDelegation(address(implementation), alice_pk, 11);
145145

146-
vm.signAndAttachDelegation(address(implementation), alice_pk, 2);
146+
vm.signAndAttachDelegation(address(implementation), alice_pk, 1);
147147
}
148148
}
149149

0 commit comments

Comments
 (0)