Skip to content

Commit

Permalink
fix: repeat use caveat validation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xgregthedev committed Jan 19, 2024
1 parent a6aaccb commit 6585fdc
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 114 deletions.
226 changes: 113 additions & 113 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,145 +1,145 @@
IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130019)
IntegrationTestCaveats:testInvalidCaveats() (gas: 162046)
IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332147)
IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283288)
IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 306526)
IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159299)
IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 167791)
IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 284586)
IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 141962)
IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283408)
IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053605)
IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407716)
IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347568)
IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456374)
IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377067)
IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402764)
ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 438033)
ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441409)
ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440947)
ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437045)
ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437844)
ModuleTesting:testModuleValidation() (gas: 1274232)
IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130030)
IntegrationTestCaveats:testInvalidCaveats() (gas: 162079)
IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332191)
IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283321)
IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308842)
IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159245)
IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 167737)
IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 284597)
IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 141984)
IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283441)
IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053638)
IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407738)
IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347534)
IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456351)
IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377100)
IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402797)
ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 438055)
ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441431)
ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440880)
ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437089)
ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437866)
ModuleTesting:testModuleValidation() (gas: 1274276)
PausableNonReentrantImpl:test() (gas: 2464)
PausableNonReentrantImpl:testReentrancy() (gas: 2757)
TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462)
TestBorrowerEnforcer:testBERevertInvalidLoanTerms() (gas: 81160)
TestBorrowerEnforcer:testBEValidLoanTerms() (gas: 72257)
TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72321)
TestCustodian:testCannotLazyMintTwice() (gas: 82131)
TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72437)
TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77947)
TestCustodian:testCustodianCannotBeAuthorized() (gas: 142196)
TestCustodian:testCustodySelector() (gas: 2731904)
TestCustodian:testDefaultCustodySelectorRevert() (gas: 72420)
TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 173073)
TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163214)
TestCustodian:testGenerateOrderRepay() (gas: 177231)
TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193695)
TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 876053)
TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804641)
TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97653)
TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92014)
TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106914)
TestCustodian:testGenerateOrderSettlement() (gas: 154947)
TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160344)
TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163392)
TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101879)
TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461629)
TestCustodian:testGetBorrower() (gas: 78621)
TestCustodian:testInvalidAction() (gas: 173362)
TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130206)
TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130166)
TestCustodian:testInvalidEncodedData() (gas: 26170)
TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366745)
TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64632)
TestCustodian:testMintWithApprovalSetNotAuthorized() (gas: 66873)
TestCustodian:testName() (gas: 7099)
TestCustodian:testNonPayableFunctions() (gas: 215173)
TestCustodian:testOnlySeaport() (gas: 17918)
TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105759)
TestCustodian:testPreviewOrderRepay() (gas: 230241)
TestCustodian:testPreviewOrderSettlement() (gas: 191969)
TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108320)
TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117031)
TestCustodian:testRatifyOrder() (gas: 184052)
TestCustodian:testSeaportMetadata() (gas: 8644)
TestCustodian:testCannotLazyMintTwice() (gas: 82189)
TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72517)
TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77917)
TestCustodian:testCustodianCannotBeAuthorized() (gas: 142208)
TestCustodian:testCustodySelector() (gas: 2731984)
TestCustodian:testDefaultCustodySelectorRevert() (gas: 72370)
TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 173068)
TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163231)
TestCustodian:testGenerateOrderRepay() (gas: 177226)
TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193712)
TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 876087)
TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804675)
TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97670)
TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92031)
TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106931)
TestCustodian:testGenerateOrderSettlement() (gas: 154942)
TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160339)
TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163409)
TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101896)
TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461657)
TestCustodian:testGetBorrower() (gas: 78643)
TestCustodian:testInvalidAction() (gas: 173596)
TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130218)
TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130156)
TestCustodian:testInvalidEncodedData() (gas: 26160)
TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366778)
TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64523)
TestCustodian:testMintWithApprovalSetNotAuthorized() (gas: 66842)
TestCustodian:testName() (gas: 7121)
TestCustodian:testNonPayableFunctions() (gas: 215289)
TestCustodian:testOnlySeaport() (gas: 17829)
TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105776)
TestCustodian:testPreviewOrderRepay() (gas: 230253)
TestCustodian:testPreviewOrderSettlement() (gas: 191981)
TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108337)
TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117048)
TestCustodian:testRatifyOrder() (gas: 184047)
TestCustodian:testSeaportMetadata() (gas: 8666)
TestCustodian:testSupportsInterface() (gas: 9428)
TestCustodian:testSymbol() (gas: 7216)
TestCustodian:testTokenURI() (gas: 84908)
TestCustodian:testTokenURIInvalidLoan() (gas: 13157)
TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76455)
TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096)
TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169)
TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72323)
TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525)
TestCustodian:testSymbol() (gas: 7127)
TestCustodian:testTokenURI() (gas: 85046)
TestCustodian:testTokenURIInvalidLoan() (gas: 13179)
TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76366)
TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81118)
TestLenderEnforcer:testLEValidLoanTerms() (gas: 72191)
TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234)
TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73547)
TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 593006)
TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 600197)
TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590370)
TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580232)
TestNewLoan:testBuyNowPayLater() (gas: 3018439)
TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874205)
TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885161)
TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429545)
TestNewLoan:testNewLoanRefinance() (gas: 590031)
TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 600219)
TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590392)
TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580254)
TestNewLoan:testBuyNowPayLater() (gas: 3018461)
TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874132)
TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885135)
TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429567)
TestNewLoan:testNewLoanRefinance() (gas: 590053)
TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 325963)
TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 384859)
TestNewLoan:testSettleLoan() (gas: 642103)
TestPausableNonReentrant:testNotOwner() (gas: 21254)
TestPausableNonReentrant:testPauseAndUnpause() (gas: 22621)
TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 384892)
TestNewLoan:testSettleLoan() (gas: 642147)
TestPausableNonReentrant:testNotOwner() (gas: 21276)
TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643)
TestPausableNonReentrant:testReentrancy() (gas: 15404)
TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12582)
TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667101)
TestRepayLoan:testRepayLoanBase() (gas: 599887)
TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438687)
TestRepayLoan:testRepayLoanInSettlement() (gas: 585679)
TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603988)
TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858619)
TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604)
TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667145)
TestRepayLoan:testRepayLoanBase() (gas: 599909)
TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438709)
TestRepayLoan:testRepayLoanInSettlement() (gas: 585701)
TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 604010)
TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858641)
TestSimpleInterestPricing:test_calculateInterest() (gas: 881296)
TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510)
TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314)
TestStarport:testAcquireTokensFail() (gas: 60430)
TestStarport:testAcquireTokensSuccess() (gas: 162999)
TestStarport:testActive() (gas: 69224)
TestStarport:testAdditionalTransfers() (gas: 300721)
TestStarport:testAdditionalTransfersOriginate() (gas: 275417)
TestStarport:testAdditionalTransfers() (gas: 300732)
TestStarport:testAdditionalTransfersOriginate() (gas: 275428)
TestStarport:testAdditionalTransfersRefinance() (gas: 218147)
TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129974)
TestStarport:testCannotIssueSameLoanTwice() (gas: 364057)
TestStarport:testCannotIssueSameLoanTwice() (gas: 364079)
TestStarport:testCannotOriginateWhilePaused() (gas: 73567)
TestStarport:testCannotSettleInvalidLoan() (gas: 74903)
TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70963)
TestStarport:testCaveatEnforcerRevert() (gas: 100284)
TestStarport:testDefaultFeeRake1() (gas: 387812)
TestStarport:testDefaultFeeRake2() (gas: 450155)
TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397641)
TestStarport:testEIP712Signing() (gas: 83089)
TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237771)
TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692792)
TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376819)
TestStarport:testCaveatEnforcerRevert() (gas: 102578)
TestStarport:testDefaultFeeRake1() (gas: 387823)
TestStarport:testDefaultFeeRake2() (gas: 450166)
TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397652)
TestStarport:testEIP712Signing() (gas: 83020)
TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237782)
TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692803)
TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376830)
TestStarport:testIncrementCaveatNonce() (gas: 35006)
TestStarport:testInitializedFlagSetProperly() (gas: 67438)
TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230392)
TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230403)
TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170796)
TestStarport:testInvalidAmountCollateral() (gas: 165912)
TestStarport:testInvalidAmountCollateral721() (gas: 165934)
TestStarport:testInvalidItemType() (gas: 151860)
TestStarport:testInvalidTransferLengthCollateral() (gas: 154173)
TestStarport:testInvalidTransferLengthDebt() (gas: 175950)
TestStarport:testInvalidAmountCollateral() (gas: 165945)
TestStarport:testInvalidAmountCollateral721() (gas: 165945)
TestStarport:testInvalidItemType() (gas: 151893)
TestStarport:testInvalidTransferLengthCollateral() (gas: 154184)
TestStarport:testInvalidTransferLengthDebt() (gas: 175961)
TestStarport:testInvalidateCaveatSalt() (gas: 33450)
TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264255)
TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290380)
TestStarport:testNonPayableFunctions() (gas: 112229)
TestStarport:testOverrideFeeRake() (gas: 384046)
TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264266)
TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290391)
TestStarport:testNonPayableFunctions() (gas: 114523)
TestStarport:testOverrideFeeRake() (gas: 384057)
TestStarport:testPause() (gas: 18259)
TestStarport:testRefinancePostRepaymentFails() (gas: 127973)
TestStarport:testRefinancePostRepaymentFails() (gas: 127886)
TestStarport:testStargateGetOwner() (gas: 8808)
TestStarport:testTokenNoCodeCollateral() (gas: 150695)
TestStarport:testTokenNoCodeDebt() (gas: 180946)
TestStarport:testTokenNoCodeCollateral() (gas: 150706)
TestStarport:testTokenNoCodeDebt() (gas: 180957)
TestStarport:testUnpause() (gas: 17363)
TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12330)
TestStrategistOriginator:testGetStrategistData() (gas: 1790990)
TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38465)
TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38488)
TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13423)
TestStrategistOriginator:testInvalidCollateral() (gas: 211094)
TestStrategistOriginator:testInvalidDeadline() (gas: 216915)
Expand All @@ -148,7 +148,7 @@ TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 2131
TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 213486)
TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 213441)
TestStrategistOriginator:testInvalidDebtLength() (gas: 212096)
TestStrategistOriginator:testInvalidOffer() (gas: 427919)
TestStrategistOriginator:testInvalidOffer() (gas: 427930)
TestStrategistOriginator:testInvalidSigner() (gas: 215234)
TestStrategistOriginator:testSetStrategist() (gas: 17884)
TestStrategistOriginator:testWithdraw() (gas: 168001)
4 changes: 3 additions & 1 deletion src/Starport.sol
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,10 @@ contract Starport is PausableNonReentrant {
);

if (signedCaveats.singleUse) {
invalidSalts.validateSalt(validator, signedCaveats.salt);
invalidSalts.validateSalt(validator, signedCaveats.salt); //Validates and invalidates salt
emit CaveatFilled(validator, hash, signedCaveats.salt);
} else if (invalidSalts[validator][signedCaveats.salt]) {
revert StarportLib.InvalidSalt();
}

if (block.timestamp > signedCaveats.deadline) {
Expand Down

0 comments on commit 6585fdc

Please sign in to comment.