From e15b671226b7987999a215fc9a86d2c98af32b85 Mon Sep 17 00:00:00 2001 From: GregTheDev <40359730+0xgregthedev@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:14:44 -0700 Subject: [PATCH] fix ownership for create2 (#98) --- .gas-snapshot | 52 +++++++++++++++++++++---------------------- src/Starport.sol | 4 ++-- test/StarportTest.sol | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 837bb5a9..91954f27 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -77,14 +77,14 @@ TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 59254 TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599755) TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589973) TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579790) -TestNewLoan:testBuyNowPayLater() (gas: 3018513) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874179) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885204) +TestNewLoan:testBuyNowPayLater() (gas: 3018543) +TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874195) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885220) TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429635) TestNewLoan:testNewLoanRefinance() (gas: 589971) TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324707) TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383503) -TestNewLoan:testSettleLoan() (gas: 642156) +TestNewLoan:testSettleLoan() (gas: 642162) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) @@ -101,42 +101,42 @@ TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 907796) TestStarport:testAcquireTokensFail() (gas: 60473) TestStarport:testAcquireTokensSuccess() (gas: 162844) TestStarport:testActive() (gas: 69358) -TestStarport:testAdditionalTransfers() (gas: 300755) -TestStarport:testAdditionalTransfersOriginate() (gas: 275540) +TestStarport:testAdditionalTransfers() (gas: 300747) +TestStarport:testAdditionalTransfersOriginate() (gas: 275532) TestStarport:testAdditionalTransfersRefinance() (gas: 218120) TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129484) -TestStarport:testCannotIssueSameLoanTwice() (gas: 364125) +TestStarport:testCannotIssueSameLoanTwice() (gas: 364109) TestStarport:testCannotOriginateWhilePaused() (gas: 73479) TestStarport:testCannotSettleInvalidLoan() (gas: 74969) TestStarport:testCannotSettleUnlessValidCustodian() (gas: 71007) -TestStarport:testCaveatEnforcerRevert() (gas: 102601) -TestStarport:testDefaultFeeRake1() (gas: 383458) -TestStarport:testDefaultFeeRake2() (gas: 445821) -TestStarport:testDefaultFeeRakeExoticDebt() (gas: 394368) -TestStarport:testEIP712Signing() (gas: 83109) +TestStarport:testCaveatEnforcerRevert() (gas: 102593) +TestStarport:testDefaultFeeRake1() (gas: 383442) +TestStarport:testDefaultFeeRake2() (gas: 445805) +TestStarport:testDefaultFeeRakeExoticDebt() (gas: 394352) +TestStarport:testEIP712Signing() (gas: 83093) TestStarport:testExcessiveFeeRake() (gas: 19992) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237829) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695881) -TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376639) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237813) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695865) +TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376631) TestStarport:testIncrementCaveatNonce() (gas: 35117) TestStarport:testInitializedFlagSetProperly() (gas: 67372) -TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230426) +TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230418) TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170620) -TestStarport:testInvalidAmountCollateral() (gas: 165968) -TestStarport:testInvalidAmountCollateral721() (gas: 165968) -TestStarport:testInvalidItemType() (gas: 151916) -TestStarport:testInvalidTransferLengthCollateral() (gas: 154185) -TestStarport:testInvalidTransferLengthDebt() (gas: 175984) +TestStarport:testInvalidAmountCollateral() (gas: 165960) +TestStarport:testInvalidAmountCollateral721() (gas: 165960) +TestStarport:testInvalidItemType() (gas: 151908) +TestStarport:testInvalidTransferLengthCollateral() (gas: 154177) +TestStarport:testInvalidTransferLengthDebt() (gas: 175976) TestStarport:testInvalidateCaveatSalt() (gas: 33428) -TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264267) -TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290392) +TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264259) +TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290384) TestStarport:testNonPayableFunctions() (gas: 114479) -TestStarport:testOverrideFeeRake() (gas: 379873) +TestStarport:testOverrideFeeRake() (gas: 379857) TestStarport:testPause() (gas: 18127) TestStarport:testRefinancePostRepaymentFails() (gas: 127765) TestStarport:testStargateGetOwner() (gas: 8851) -TestStarport:testTokenNoCodeCollateral() (gas: 150707) -TestStarport:testTokenNoCodeDebt() (gas: 180980) +TestStarport:testTokenNoCodeCollateral() (gas: 150699) +TestStarport:testTokenNoCodeDebt() (gas: 180972) TestStarport:testUnpause() (gas: 17187) TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12429) TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38457) diff --git a/src/Starport.sol b/src/Starport.sol index 24c2cce6..9b9a6a52 100644 --- a/src/Starport.sol +++ b/src/Starport.sol @@ -166,7 +166,7 @@ contract Starport is PausableNonReentrant { /* CONSTRUCTOR */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - constructor(address seaport_, Stargate stargate_) { + constructor(address seaport_, Stargate stargate_, address owner_) { SG = stargate_; chainId = block.chainid; CACHED_DOMAIN_SEPARATOR = keccak256(abi.encode(EIP_DOMAIN, NAME, VERSION, block.chainid, address(this))); @@ -177,7 +177,7 @@ contract Starport is PausableNonReentrant { defaultCustodianCodeHash := extcodehash(custodian) } DEFAULT_CUSTODIAN_CODE_HASH = defaultCustodianCodeHash; - _initializeOwner(msg.sender); + _initializeOwner(owner_); } function domainSeparator() public view returns (bytes32) { diff --git a/test/StarportTest.sol b/test/StarportTest.sol index 5598fa11..3c2410a2 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -184,7 +184,7 @@ contract StarportTest is BaseOrderTest, Stargate { refinancer = makeAndAllocateAccount("refinancer"); fulfiller = makeAndAllocateAccount("fulfiller"); - SP = new Starport(address(consideration), Stargate(address(this))); + SP = new Starport(address(consideration), Stargate(address(this)), address(this)); custodian = new Custodian(SP, address(consideration)); SO = new StrategistOriginator(SP, strategist.addr, address(this)); pricing = new SimpleInterestPricing(SP);