Skip to content

Commit

Permalink
chore: snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
androolloyd committed Nov 14, 2023
1 parent 91e848c commit 4554785
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 329 deletions.
12 changes: 6 additions & 6 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ TestCustodian:testSupportsInterface() (gas: 9428)
TestCustodian:testSymbol() (gas: 7105)
TestCustodian:testTokenURI() (gas: 67024)
TestCustodian:testTokenURIInvalidLoan() (gas: 13151)
TestFuzzStarport:testFuzzNewOrigination((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8)) (runs: 256, μ: 446125, ~: 443966)
TestFuzzStarport:testFuzzRefinance(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),string,uint8,uint256,uint256,uint256)) (runs: 256, μ: 1291907, ~: 1289231)
TestFuzzStarport:testFuzzRepaymentFails(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 760129, ~: 762045)
TestFuzzStarport:testFuzzRepaymentSuccess(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 642621, ~: 640510)
TestFuzzStarport:testFuzzSettlementFails(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 738608, ~: 738208)
TestFuzzStarport:testFuzzSettlementSuccess(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),uint256)) (runs: 256, μ: 604776, ~: 601720)
TestFuzzStarport:testFuzzNewOrigination((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8)) (runs: 256, μ: 445408, ~: 442561)
TestFuzzStarport:testFuzzRefinance(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),string,uint8,uint256,uint256,uint256)) (runs: 256, μ: 1291763, ~: 1288019)
TestFuzzStarport:testFuzzRepaymentFails(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 761212, ~: 762045)
TestFuzzStarport:testFuzzRepaymentSuccess(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 644506, ~: 641869)
TestFuzzStarport:testFuzzSettlementFails(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),(uint8,address,uint256,uint256)[10],(uint8,address,uint256,uint256)[10],address[3],uint256)) (runs: 256, μ: 739572, ~: 739346)
TestFuzzStarport:testFuzzSettlementSuccess(((address,uint256,uint256,uint256,uint256,(uint8,address,uint256,uint256)[],uint8),uint256)) (runs: 256, μ: 603888, ~: 602287)
TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76210)
TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 80962)
TestLenderEnforcer:testLEValidLoanTerms() (gas: 71955)
Expand Down
10 changes: 5 additions & 5 deletions src/Starport.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ contract Starport is PausableNonReentrant {
bytes32 public constant EIP_DOMAIN =
keccak256("EIP712Domain(string version,uint256 chainId,address verifyingContract)");
bytes32 public constant INTENT_ORIGINATION_TYPEHASH =
keccak256("Origination(uint256 userNonce,bool invalidate,bytes32 salt,uint256 deadline, bytes32 caveatHash");
keccak256("Origination(uint256 userNonce,bool singleUse,bytes32 salt,uint256 deadline, bytes32 caveatHash");
bytes32 public constant VERSION = keccak256("0");

mapping(address => mapping(bytes32 => bool)) public invalidSalts;
Expand Down Expand Up @@ -349,9 +349,9 @@ contract Starport is PausableNonReentrant {
Starport.Loan memory loan
) internal {
bytes32 hash = hashCaveatWithSaltAndNonce(
validator, signedCaveats.invalidate, signedCaveats.salt, signedCaveats.deadline, signedCaveats.caveats
validator, signedCaveats.singleUse, signedCaveats.salt, signedCaveats.deadline, signedCaveats.caveats
);
if (signedCaveats.invalidate) {
if (signedCaveats.singleUse) {
invalidSalts.validateSalt(validator, signedCaveats.salt);
}

Expand All @@ -374,7 +374,7 @@ contract Starport is PausableNonReentrant {

function hashCaveatWithSaltAndNonce(
address validator,
bool invalidate,
bool singleUse,
bytes32 salt,
uint256 deadline,
CaveatEnforcer.Caveat[] calldata caveats
Expand All @@ -388,7 +388,7 @@ contract Starport is PausableNonReentrant {
abi.encode(
INTENT_ORIGINATION_TYPEHASH,
caveatNonces[validator],
invalidate,
singleUse,
salt,
deadline,
keccak256(abi.encode(caveats))
Expand Down
2 changes: 1 addition & 1 deletion src/enforcers/CaveatEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract contract CaveatEnforcer {
}

struct SignedCaveats {
bool invalidate;
bool singleUse;
uint256 deadline;
bytes32 salt;
Caveat[] caveats;
Expand Down
14 changes: 7 additions & 7 deletions test/StarportTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ contract StarportTest is BaseOrderTest {
function _emptyCaveat() internal returns (CaveatEnforcer.SignedCaveats memory) {
return CaveatEnforcer.SignedCaveats({
signature: "",
invalidate: true,
singleUse: true,
deadline: 0,
salt: bytes32(0),
caveats: new CaveatEnforcer.Caveat[](0)
Expand Down Expand Up @@ -343,15 +343,15 @@ contract StarportTest is BaseOrderTest {
) public view returns (CaveatEnforcer.SignedCaveats memory signedCaveats) {
signedCaveats = CaveatEnforcer.SignedCaveats({
signature: "",
invalidate: invalidate,
singleUse: invalidate,
deadline: block.timestamp + 1 days,
salt: salt,
caveats: new CaveatEnforcer.Caveat[](1)
});

signedCaveats.caveats[0] = caveat;
bytes32 hash = SP.hashCaveatWithSaltAndNonce(
signer.addr, signedCaveats.invalidate, salt, signedCaveats.deadline, signedCaveats.caveats
signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats
);
(uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, hash);
signedCaveats.signature = abi.encodePacked(r, s, v);
Expand Down Expand Up @@ -439,11 +439,11 @@ contract StarportTest is BaseOrderTest {
) public view returns (CaveatEnforcer.SignedCaveats memory signedCaveats) {
signedCaveats.caveats = new CaveatEnforcer.Caveat[](1);
signedCaveats.salt = salt;
signedCaveats.invalidate = true;
signedCaveats.singleUse = true;
signedCaveats.deadline = block.timestamp + 1 days;
signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)});
bytes32 hash = SP.hashCaveatWithSaltAndNonce(
signer.addr, signedCaveats.invalidate, salt, signedCaveats.deadline, signedCaveats.caveats
signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats
);

(uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, hash);
Expand All @@ -458,11 +458,11 @@ contract StarportTest is BaseOrderTest {
) public view returns (CaveatEnforcer.SignedCaveats memory signedCaveats) {
signedCaveats.caveats = new CaveatEnforcer.Caveat[](1);
signedCaveats.salt = salt;
signedCaveats.invalidate = true;
signedCaveats.singleUse = true;
signedCaveats.deadline = block.timestamp + 1 days;
signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)});
bytes32 hash = SP.hashCaveatWithSaltAndNonce(
signer.addr, signedCaveats.invalidate, salt, signedCaveats.deadline, signedCaveats.caveats
signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats
);

(uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, hash);
Expand Down
Loading

0 comments on commit 4554785

Please sign in to comment.