Skip to content

Commit 5121d9a

Browse files
committed
✅ contracts: make script helper bytecode explicit
1 parent f1788f9 commit 5121d9a

3 files changed

Lines changed: 38 additions & 45 deletions

File tree

contracts/.gas-snapshot

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 5861692, ~: 5360703)
2-
ExaAccountFactoryTest:test_deploy_deploysToSameAddress() (gas: 15501257)
1+
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 5850672, ~: 5347535)
2+
ExaAccountFactoryTest:test_deploy_deploysToSameAddress() (gas: 17070402)
33
ExaPluginTest:testFork_claimAndVestEscrowedEXA_claimsAndVests() (gas: 38997698)
44
ExaPluginTest:testFork_collectCollateral_collects() (gas: 32212349)
55
ExaPluginTest:testFork_crossRepay_repays() (gas: 34034503)
@@ -232,24 +232,24 @@ IssuerCheckerTest:test_setPrevIssuerWindow_emits_PrevIssuerWindowSet() (gas: 526
232232
IssuerCheckerTest:test_setPrevIssuerWindow_reverts_whenNotAdmin() (gas: 45548)
233233
MockSwapperTest:test_swapExactAmountIn_swaps() (gas: 269414)
234234
MockSwapperTest:test_swapExactAmountOut_swaps() (gas: 269410)
235-
RedeployerTest:test_deployEXA_allowsProxyAdminV4Upgrade_onBase() (gas: 27526539)
236-
RedeployerTest:test_deployEXA_deploysAtSameAddress_onBase() (gas: 57398324)
237-
RedeployerTest:test_deployEXA_migratesProxyAdmin_onBase() (gas: 24777692)
238-
RedeployerTest:test_deployEXA_preservesERC20_onBase() (gas: 24752420)
239-
RedeployerTest:test_deployEXA_revokesOldProxyAdmin_onBase() (gas: 26379358)
240-
RedeployerTest:test_deployEXA_usesProtectedEXAProxy() (gas: 60044599)
241-
RedeployerTest:test_deployExaFactoryWithProxy_reverts_whenNotPrepared() (gas: 16538703)
242-
RedeployerTest:test_deployExaFactoryWithProxy_succeeds_whenAlreadyUpgraded() (gas: 31831188)
243-
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onEthereum() (gas: 260992218)
244-
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onPolygon() (gas: 356584181)
245-
RedeployerTest:test_deployExaFactory_deploysViaCreate3AtSameAddress_onPolygon() (gas: 35022276)
246-
RedeployerTest:test_deployExaFactory_reverts_whenNotPrepared() (gas: 16564048)
247-
RedeployerTest:test_deployExaFactory_succeeds_whenVersionAlreadyDeployed() (gas: 32379246)
248-
RedeployerTest:test_prepare_reusesExistingDeps_onBase() (gas: 20088136)
249-
RedeployerTest:test_prepare_reverts_whenAdminIsDeployer() (gas: 16569857)
250-
RedeployerTest:test_prepare_succeeds_whenCalledTwice() (gas: 31323188)
251-
RedeployerTest:test_recoversNativeETHOnPolygon() (gas: 35194339)
252-
RedeployerTest:test_serialProxies_reverts_whenTargetNonceTooLow() (gas: 44967553)
235+
RedeployerTest:test_deployEXA_allowsProxyAdminV4Upgrade_onBase() (gas: 45106860)
236+
RedeployerTest:test_deployEXA_deploysAtSameAddress_onBase() (gas: 74903890)
237+
RedeployerTest:test_deployEXA_migratesProxyAdmin_onBase() (gas: 42358013)
238+
RedeployerTest:test_deployEXA_preservesERC20_onBase() (gas: 42332741)
239+
RedeployerTest:test_deployEXA_revokesOldProxyAdmin_onBase() (gas: 43959679)
240+
RedeployerTest:test_deployEXA_usesProtectedEXAProxy() (gas: 77550165)
241+
RedeployerTest:test_deployExaFactoryWithProxy_reverts_whenNotPrepared() (gas: 34197420)
242+
RedeployerTest:test_deployExaFactoryWithProxy_succeeds_whenAlreadyUpgraded() (gas: 49403260)
243+
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onEthereum() (gas: 278536812)
244+
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onPolygon() (gas: 374127001)
245+
RedeployerTest:test_deployExaFactory_deploysViaCreate3AtSameAddress_onPolygon() (gas: 52590492)
246+
RedeployerTest:test_deployExaFactory_reverts_whenNotPrepared() (gas: 34222722)
247+
RedeployerTest:test_deployExaFactory_succeeds_whenVersionAlreadyDeployed() (gas: 49947419)
248+
RedeployerTest:test_prepare_reusesExistingDeps_onBase() (gas: 37743086)
249+
RedeployerTest:test_prepare_reverts_whenAdminIsDeployer() (gas: 34228488)
250+
RedeployerTest:test_prepare_succeeds_whenCalledTwice() (gas: 48895217)
251+
RedeployerTest:test_recoversNativeETHOnPolygon() (gas: 52762555)
252+
RedeployerTest:test_serialProxies_reverts_whenTargetNonceTooLow() (gas: 80177392)
253253
RefunderTest:test_refund_refunds() (gas: 263288)
254254
RefunderTest:test_refund_reverts_whenExpired() (gas: 88359)
255255
RefunderTest:test_refund_reverts_whenNotKeeper() (gas: 68861)

contracts/script/ExaAccountFactory.s.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ contract DeployExaAccountFactory is BaseScript {
2323
payable(CREATE3_FACTORY.deploy(
2424
_salt(IPlugin(exaPlugin)),
2525
abi.encodePacked(
26-
vm.getCode("ExaAccountFactory.sol:ExaAccountFactory"),
27-
abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
26+
type(ExaAccountFactory).creationCode, abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
2827
)
2928
))
3029
);

contracts/script/Redeployer.s.sol

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import {
1515
import { IPlugin, PluginMetadata } from "modular-account-libs/interfaces/IPlugin.sol";
1616

1717
import { ACCOUNT_IMPL, ENTRYPOINT } from "webauthn-owner-plugin/../script/Factory.s.sol";
18+
import { WebauthnOwnerPlugin } from "webauthn-owner-plugin/WebauthnOwnerPlugin.sol";
1819

1920
import { EXA } from "@exactly/protocol/periphery/EXA.sol";
2021

2122
import { ExaAccountFactory } from "../src/ExaAccountFactory.sol";
2223
import {
24+
ExaPlugin,
2325
IAuditor,
2426
IDebtManager,
2527
IFlashLoaner,
@@ -67,56 +69,51 @@ contract Redeployer is BaseScript {
6769
if (admin == acct("redeployer")) revert AdminIsDeployer();
6870
vm.startBroadcast(admin);
6971
if (address(dummy).code.length == 0) {
70-
dummy = Dummy(CREATE3_FACTORY.deploy(keccak256(abi.encode("Dummy")), vm.getCode("Redeployer.s.sol:Dummy")));
72+
dummy = Dummy(CREATE3_FACTORY.deploy(keccak256(abi.encode("Dummy")), type(Dummy).creationCode));
7173
}
7274
if (address(proxyAdmin).code.length == 0) {
7375
proxyAdmin = ProxyAdmin(
7476
CREATE3_FACTORY.deploy(
75-
keccak256(abi.encode("ProxyAdmin")),
76-
abi.encodePacked(vm.getCode("ProxyAdmin.sol:ProxyAdmin"), abi.encode(admin))
77+
keccak256(abi.encode("ProxyAdmin")), abi.encodePacked(type(ProxyAdmin).creationCode, abi.encode(admin))
7778
)
7879
);
7980
}
8081
if (address(auditor).code.length == 0) {
81-
auditor = IAuditor(
82-
CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAuditor")), vm.getCode("Redeployer.s.sol:StubAuditor"))
83-
);
82+
auditor = IAuditor(CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAuditor")), type(StubAuditor).creationCode));
8483
}
8584
if (address(marketUSDC).code.length == 0 || address(marketWETH).code.length == 0) {
8685
address stubAsset = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("StubAsset")));
8786
if (stubAsset.code.length == 0) {
88-
stubAsset = CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset"));
87+
stubAsset = CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), type(StubAsset).creationCode);
8988
}
9089
if (address(marketUSDC).code.length == 0) {
9190
marketUSDC = IMarket(
9291
CREATE3_FACTORY.deploy(
9392
keccak256(abi.encode("StubMarketUSDC")),
94-
abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset))
93+
abi.encodePacked(type(StubMarket).creationCode, abi.encode(stubAsset))
9594
)
9695
);
9796
}
9897
if (address(marketWETH).code.length == 0) {
9998
marketWETH = IMarket(
10099
CREATE3_FACTORY.deploy(
101100
keccak256(abi.encode("StubMarketWETH")),
102-
abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset))
101+
abi.encodePacked(type(StubMarket).creationCode, abi.encode(stubAsset))
103102
)
104103
);
105104
}
106105
}
107106
if (address(ownerPlugin).code.length == 0) {
108107
ownerPlugin = IPlugin(
109-
CREATE3_FACTORY.deploy(
110-
keccak256(abi.encode("WebauthnOwnerPlugin")), vm.getCode("WebauthnOwnerPlugin.sol:WebauthnOwnerPlugin")
111-
)
108+
CREATE3_FACTORY.deploy(keccak256(abi.encode("WebauthnOwnerPlugin")), type(WebauthnOwnerPlugin).creationCode)
112109
);
113110
}
114111
address proposalManagerAddr = _broadcastOrCreate3("broadcast/ProposalManager", "ProposalManager");
115112
if (proposalManagerAddr.code.length == 0) {
116113
proposalManagerAddr = CREATE3_FACTORY.deploy(
117114
keccak256(abi.encode("ProposalManager")),
118115
abi.encodePacked(
119-
vm.getCode("ProposalManager.sol:ProposalManager"),
116+
type(ProposalManager).creationCode,
120117
abi.encode(admin, auditor, IDebtManager(address(1)), IInstallmentsRouter(address(1)), admin, _allowlist(), 1)
121118
)
122119
);
@@ -126,7 +123,7 @@ contract Redeployer is BaseScript {
126123
CREATE3_FACTORY.deploy(
127124
keccak256(abi.encode("ExaPlugin")),
128125
abi.encodePacked(
129-
vm.getCode("ExaPlugin.sol:ExaPlugin"),
126+
type(ExaPlugin).creationCode,
130127
abi.encode(
131128
Parameters({
132129
owner: admin,
@@ -155,8 +152,7 @@ contract Redeployer is BaseScript {
155152
payable(CREATE3_FACTORY.deploy(
156153
keccak256(abi.encode("ExaAccountFactory")),
157154
abi.encodePacked(
158-
vm.getCode("ExaAccountFactory.sol:ExaAccountFactory"),
159-
abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
155+
type(ExaAccountFactory).creationCode, abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
160156
)
161157
))
162158
);
@@ -196,14 +192,13 @@ contract Redeployer is BaseScript {
196192

197193
exa = EXA(CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("EXA"))));
198194
if (address(exa).code.length == 0) {
199-
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), vm.getCode("EXA.sol:EXA")));
195+
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), type(EXA).creationCode));
200196
}
201197

202198
address proxyTransferer = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("ProxyTransferer")));
203199
if (proxyTransferer.code.length == 0) {
204-
proxyTransferer = CREATE3_FACTORY.deploy(
205-
keccak256(abi.encode("ProxyTransferer")), vm.getCode("Redeployer.s.sol:ProxyTransferer")
206-
);
200+
proxyTransferer =
201+
CREATE3_FACTORY.deploy(keccak256(abi.encode("ProxyTransferer")), type(ProxyTransferer).creationCode);
207202
}
208203

209204
proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(proxy), address(exa), abi.encodeCall(EXA.initialize, ()));
@@ -227,7 +222,7 @@ contract Redeployer is BaseScript {
227222
exa = EXA(CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("EXA"))));
228223
if (address(exa).code.length != 0) return;
229224
vm.broadcast(admin);
230-
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), vm.getCode("EXA.sol:EXA")));
225+
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), type(EXA).creationCode));
231226
}
232227

233228
/// @notice Upgrades a proxy to the cached ExaAccountFactory implementation.
@@ -251,8 +246,7 @@ contract Redeployer is BaseScript {
251246
payable(CREATE3_FACTORY.deploy(
252247
salt,
253248
abi.encodePacked(
254-
vm.getCode("ExaAccountFactory.sol:ExaAccountFactory"),
255-
abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
249+
type(ExaAccountFactory).creationCode, abi.encode(admin, ownerPlugin, exaPlugin, ACCOUNT_IMPL, ENTRYPOINT)
256250
)
257251
))
258252
);

0 commit comments

Comments
 (0)