Skip to content

Commit

Permalink
fixing contract
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Mar 11, 2024
1 parent 4b4bca4 commit a31337b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/erc20_payment_lib/config-payments.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ transaction-timeout = 100
token = { address = "0x8888888815bf4DB87e57B609A50f938311EEd068", symbol = "tGLM" }
multi-contract = { address = "0xAaAAAaA00E1841A63342db7188abA84BDeE236c7", max-at-once = 10 }
mint-contract = { address = "0xFACe100969FF47EB58d2CF603321B581A84bcEaC", max-glm-allowed = 400 }
lock-contract = { address = "0xD8b2D4e53350075333c2f6B90314518e01F42b2f" }
lock-contract = { address = "0xfe1B27Bac0e3Ad39d55C9459ae59894De847dcbf" }
faucet-client = { max-eth-allowed = 0.009, faucet-srv = "_holesky-faucet._tcp", faucet-host = "faucet.testnet.golem.network", faucet-lookup-domain = "dev.golem.network", faucet-srv-port = 4002 }
confirmation-blocks = 0
block-explorer-url = "https://holesky.etherscan.io"
Expand Down
13 changes: 7 additions & 6 deletions yatestnet/contracts/contracts/LockPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ contract LockPayment {
deposits[id].feeAmount = 0;
}

// funder can terminate deposit after validTo date elapses
// Funder can terminate deposit after validTo date elapses
function terminateDeposit(uint64 nonce) public {
uint256 id = idFromNonce(nonce);
Deposit memory deposit = deposits[id];
// customer cannot return funds before block_no
// sender can return funds at any time
require(deposit.validTo < block.timestamp);
//The following check is not needed (Funder is in id), but added for clarity
require(funderFromId(id) == msg.sender, "funderFromId(id) == msg.sender");
// Check for time condition
require(deposit.validTo < block.timestamp, "deposit.validTo < block.timestamp");
require(GLM.transfer(msg.sender, deposit.amount + deposit.feeAmount), "transfer failed");
deposits[id].amount = 0;
deposits[id].feeAmount = 0;
Expand All @@ -149,7 +150,7 @@ contract LockPayment {
Deposit memory deposit = deposits[id];
require(msg.sender == deposit.spender, "msg.sender == deposit.spender");
require(addr != deposit.spender, "cannot transfer to spender");
require(GLM.transferFrom(address(this), addr, amount), "transferFrom failed");
require(GLM.transfer(addr, amount), "transferFrom failed");
require(deposit.amount >= amount, "deposit.amount >= amount");
deposit.amount -= amount;
deposits[id].amount = deposit.amount;
Expand All @@ -167,7 +168,7 @@ contract LockPayment {
address addr = address(bytes20(payment));
uint128 amount = uint128(uint256(payment) % 2 ** 96);
require(addr != deposit.spender, "cannot transfer to spender");
require(GLM.transferFrom(address(this), addr, amount), "transferFrom failed");
require(GLM.transfer(addr, amount), "transferFrom failed");
require(deposit.amount >= amount, "deposit.amount >= amount");
deposit.amount -= amount;
}
Expand Down

0 comments on commit a31337b

Please sign in to comment.