Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the balance in the event #7

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# acc-bridge-contracts-v2

12 changes: 6 additions & 6 deletions packages/contracts/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contract Bridge is BridgeStorage, Initializable, OwnableUpgradeable, UUPSUpgrade

DepositData memory data = DepositData({ tokenId: _tokenId, account: msg.sender, amount: msg.value });
deposits[_depositId] = data;
emit BridgeDeposited(_tokenId, _depositId, data.account, data.amount, 0);
emit BridgeDeposited(_tokenId, _depositId, data.account, data.amount);
} else {
require(_amount % 1 gwei == 0, "1030");
require(_amount > tokenInfos[_tokenId].fee, "1031");
Expand All @@ -123,7 +123,7 @@ contract Bridge is BridgeStorage, Initializable, OwnableUpgradeable, UUPSUpgrade
if (token.delegatedTransfer(_account, address(this), _amount, _expiry, _signature)) {
DepositData memory data = DepositData({ tokenId: _tokenId, account: _account, amount: _amount });
deposits[_depositId] = data;
emit BridgeDeposited(_tokenId, _depositId, data.account, data.amount, 0);
emit BridgeDeposited(_tokenId, _depositId, data.account, data.amount);
}
}
}
Expand Down Expand Up @@ -160,7 +160,7 @@ contract Bridge is BridgeStorage, Initializable, OwnableUpgradeable, UUPSUpgrade
payable(_account).transfer(withdrawalAmount);
payable(protocolFeeAccount).transfer(tokenInfos[_tokenId].fee);
withdraws[_withdrawId].executed = true;
emit BridgeWithdrawn(_tokenId, _withdrawId, _account, withdrawalAmount, 0);
emit BridgeWithdrawn(_tokenId, _withdrawId, _account, withdrawalAmount);
}
}
} else {
Expand Down Expand Up @@ -188,7 +188,7 @@ contract Bridge is BridgeStorage, Initializable, OwnableUpgradeable, UUPSUpgrade
token.transfer(_account, withdrawalAmount);
token.transfer(protocolFeeAccount, tokenInfos[_tokenId].fee);
withdraws[_withdrawId].executed = true;
emit BridgeWithdrawn(_tokenId, _withdrawId, _account, withdrawalAmount, 0);
emit BridgeWithdrawn(_tokenId, _withdrawId, _account, withdrawalAmount);
}
}
}
Expand All @@ -208,15 +208,15 @@ contract Bridge is BridgeStorage, Initializable, OwnableUpgradeable, UUPSUpgrade
payable(withdraws[_withdrawId].account).transfer(withdrawalAmount);
payable(protocolFeeAccount).transfer(tokenInfos[tokenId].fee);
withdraws[_withdrawId].executed = true;
emit BridgeWithdrawn(tokenId, _withdrawId, withdraws[_withdrawId].account, withdrawalAmount, 0);
emit BridgeWithdrawn(tokenId, _withdrawId, withdraws[_withdrawId].account, withdrawalAmount);
}
} else {
BIP20DelegatedTransfer token = tokenInfos[tokenId].token;
if (token.balanceOf(address(this)) >= withdraws[_withdrawId].amount) {
token.transfer(withdraws[_withdrawId].account, withdrawalAmount);
token.transfer(protocolFeeAccount, tokenInfos[tokenId].fee);
withdraws[_withdrawId].executed = true;
emit BridgeWithdrawn(tokenId, _withdrawId, withdraws[_withdrawId].account, withdrawalAmount, 0);
emit BridgeWithdrawn(tokenId, _withdrawId, withdraws[_withdrawId].account, withdrawalAmount);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/contracts/interfaces/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
pragma solidity ^0.8.2;

interface IBridge {
event BridgeDeposited(bytes32 tokenId, bytes32 depositId, address account, uint256 amount, uint256 balance);
event BridgeWithdrawn(bytes32 tokenId, bytes32 withdrawId, address account, uint256 amount, uint256 balance);
event BridgeDeposited(bytes32 tokenId, bytes32 depositId, address account, uint256 amount);
event BridgeWithdrawn(bytes32 tokenId, bytes32 withdrawId, address account, uint256 amount);

struct DepositData {
bytes32 tokenId;
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts/contracts/token/TestLYT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ contract TestLYT is BIP20DelegatedTransfer {
/*
* Public functions
*/
constructor(address owner_, address feeAccount_) BIP20DelegatedTransfer("Loyalty Coin", "LYT", owner_, feeAccount_) {
constructor(
address owner_,
address feeAccount_
) BIP20DelegatedTransfer("Loyalty Coin", "LYT", owner_, feeAccount_) {
_mint(owner_, 1e10 * 1e18);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acc-bridge-contracts-v2",
"version": "2.3.1",
"version": "2.4.0",
"description": "Bridge smart contracts of for decentralized loyalty systems",
"files": [
"**/*.sol"
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/test/helper/Deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ async function deployToken(accounts: IAccount, deployment: Deployments) {
console.log(`Deploy ${contractName}...`);

const factory = await ethers.getContractFactory("TestLYT");
const contract = (await factory.connect(accounts.deployer).deploy(accounts.deployer.address, accounts.protocolFee.address)) as TestLYT;
const contract = (await factory
.connect(accounts.deployer)
.deploy(accounts.deployer.address, accounts.protocolFee.address)) as TestLYT;
await contract.deployed();
await contract.deployTransaction.wait();

Expand Down
2 changes: 1 addition & 1 deletion packages/library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acc-bridge-contracts-lib-v2",
"version": "2.3.0",
"version": "2.4.0",
"description": "",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/validator/contracts/token/TestLYT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ contract TestLYT is BIP20DelegatedTransfer {
/*
* Public functions
*/
constructor(address owner_, address feeAccount_) BIP20DelegatedTransfer("Loyalty Coin", "LYT", owner_, feeAccount_) {
constructor(
address owner_,
address feeAccount_
) BIP20DelegatedTransfer("Loyalty Coin", "LYT", owner_, feeAccount_) {
_mint(owner_, 1e10 * 1e18);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@types/urijs": "^1.19.12"
},
"dependencies": {
"acc-bridge-contracts-v2": "~2.3.1",
"acc-bridge-contracts-v2": "~2.4.0",
"argparse": "^2.0.1",
"assert": "^2.0.0",
"axios": "^1.6.7",
Expand Down
4 changes: 3 additions & 1 deletion packages/validator/test/helper/Deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ async function deployToken(accounts: IAccount, deployment: Deployments) {

await hre.changeNetwork(deployment.network);
const factory = await hre.ethers.getContractFactory("TestLYT");
const contract = (await factory.connect(accounts.deployer).deploy(accounts.deployer.address, accounts.protocolFee.address)) as TestLYT;
const contract = (await factory
.connect(accounts.deployer)
.deploy(accounts.deployer.address, accounts.protocolFee.address)) as TestLYT;
await contract.deployed();
await contract.deployTransaction.wait();

Expand Down
Loading