Skip to content

Commit dd5912d

Browse files
committed
make expiry relative in createLock
1 parent 9831aba commit dd5912d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

contracts/escrow/Escrow.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ contract Escrow is
246246
require(jobId>0,"Invalid jobId");
247247
auth memory tempAuth=auth(address(0),0,0,0,0,0);
248248
uint256 index;
249-
uint256 ts=block.timestamp;
250249
require(funds[payer][token].available>=amount,"Payer does not have enough funds");
251250
uint256 length=userAuths[payer][token].length;
252251
for(index=0;index<length;index++){
@@ -256,7 +255,7 @@ contract Escrow is
256255
}
257256
}
258257
require(tempAuth.payee==msg.sender,"No auth found");
259-
require(expiry>ts && expiry <= (ts+tempAuth.maxLockSeconds),"Invalid expiry");
258+
require(expiry<=tempAuth.maxLockSeconds,"Expiry too high");
260259
require(amount<= tempAuth.maxLockedAmount,"Amount too high");
261260
require(tempAuth.currentLockedAmount+amount<=tempAuth.maxLockedAmount,"Exceeds maxLockedAmount");
262261
require(tempAuth.currentLocks<tempAuth.maxLockCounts,"Exceeds maxLockCounts");
@@ -274,7 +273,7 @@ contract Escrow is
274273
funds[payer][token].available-=amount;
275274
funds[payer][token].locked+=amount;
276275
// create the lock
277-
locks.push(lock(jobId,payer,msg.sender,amount,expiry,token));
276+
locks.push(lock(jobId,payer,msg.sender,amount,block.timestamp+expiry,token));
278277
emit Lock(payer,msg.sender,jobId,amount,expiry,token);
279278
}
280279

test/unit/escrow/Escrow.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ it('Escrow - lock', async function () {
9999

100100
let jobId=1 // full claim
101101
const now=Math.floor(Date.now() / 1000)
102-
const expire = Math.round(await blocktimestamp()) + 60
102+
const expire = 60
103103
await expect(EscrowContract.connect(payee1).createLock(jobId,Mock20Contract.address,payer2.address,web3.utils.toWei("50"),expire)).to.be.revertedWith("Payer does not have enough funds")
104104
//payer2 has funds, but no auth
105105
await Mock20Contract.connect(payer2).approve(EscrowContract.address, web3.utils.toWei("10000"));

0 commit comments

Comments
 (0)