Skip to content

Commit

Permalink
ran forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Dprof-in-tech committed Dec 16, 2024
1 parent 9697f50 commit 0355482
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 29 deletions.
18 changes: 6 additions & 12 deletions src/Wallet.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "./interfaces/IERC20.sol";
import "./IWorldID.sol";

Expand All @@ -16,7 +17,7 @@ contract Wallet {
address token;
}

modifier onlyOwner {
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
Expand All @@ -27,17 +28,14 @@ contract Wallet {
_;
}


constructor(address _owner, address _worldID, address _usdt) {
require(msg.sender != address(0), "zero address found");
owner = _owner;
worldID = IWorldID(_worldID);
worldID = IWorldID(_worldID);
usdt = IERC20(_usdt);
}

function createWorldId() onlyOwner external {

}
function createWorldId() external onlyOwner {}

function transfer(address _recipient, uint256 _amount) external onlyVerified(msg.sender) {
require(_recipient != address(0), "Zero address detected");
Expand All @@ -52,7 +50,6 @@ contract Wallet {
// View Functions //
////////////////////////////////////////////


function getTransactionHistory(address _user) external view returns (Transaction[] memory) {
return transactions[_user];
}
Expand All @@ -62,11 +59,8 @@ contract Wallet {
//////////////////////////////////////////////

function recordTransactionHistory(address _user, uint256 _amount, address _token) private {
Transaction memory newTransaction = Transaction({
amount: _amount,
token: _token
});

Transaction memory newTransaction = Transaction({amount: _amount, token: _token});

transactions[_user].push(newTransaction);
}
}
7 changes: 4 additions & 3 deletions src/WalletFactory.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "./Wallet.sol";

contract WalletFactory {
Wallet[] wallets;

function createWallet( address _worldID, address _usdt) external returns (Wallet newWallet_, uint256 length_) {
newWallet_ = new Wallet(msg.sender , _worldID, _usdt);
function createWallet(address _worldID, address _usdt) external returns (Wallet newWallet_, uint256 length_) {
newWallet_ = new Wallet(msg.sender, _worldID, _usdt);

wallets.push(newWallet_);

length_ = wallets.length;
}

function getWalletClones() external view returns(Wallet[] memory) {
function getWalletClones() external view returns (Wallet[] memory) {
return wallets;
}
}
4 changes: 2 additions & 2 deletions src/interfaces/IERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.13;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);

function totalSupply() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);
Expand All @@ -17,4 +17,4 @@ interface IERC20 {
function approve(address spender, uint256 value) external returns (bool);

function transferFrom(address from, address to, uint256 value) external returns (bool);
}
}
3 changes: 1 addition & 2 deletions test/Transfer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ contract USDTTransferTest is Test {
uint256 private initialBalance = 1000e18;
address _owner = address(this);


// Setup function to deploy mocks and the transfer contract
function setUp() public {
mockWorldID = new MockWorldIDContract();
mockUSDT = new MockERC20Token();
transferContract = new Wallet(address(_owner), address(mockWorldID), address(mockUSDT));
transferContract = new Wallet(address(_owner), address(mockWorldID), address(mockUSDT));

// Mint some USDT for user1
mockUSDT.mint(user1, initialBalance);
Expand Down
12 changes: 6 additions & 6 deletions test/Wallet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract WalletTest is Test {
worldID = new MockWorldID();

factory = new WalletFactory();
(wallet, ) = factory.createWallet(address(worldID), address(usdt));
(wallet,) = factory.createWallet(address(worldID), address(usdt));

// Fund users
usdt.mint(user1, 1000);
Expand Down Expand Up @@ -62,7 +62,7 @@ contract WalletTest is Test {
vm.startPrank(user1);
wallet.transfer(user2, 100);
wallet.transfer(user2, 200);

Wallet.Transaction[] memory history = wallet.getTransactionHistory();
vm.stopPrank();

Expand All @@ -80,13 +80,13 @@ contract WalletTest is Test {

vm.prank(user1);
wallet.transfer(user2, 50);

vm.prank(user2);
wallet.transfer(user1, 50);

vm.prank(user1);
Wallet.Transaction[] memory user1History = wallet.getTransactionHistory();

vm.prank(user2);
Wallet.Transaction[] memory user2History = wallet.getTransactionHistory();

Expand All @@ -112,4 +112,4 @@ contract WalletTest is Test {
assertEq(history[0].amount, largeAmount, "Recorded amount does not match");
assertEq(history[0].token, address(usdt), "Recorded token address does not match");
}
}
}
3 changes: 1 addition & 2 deletions test/WalletFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ contract WalletFactoryTest is Test {
MockERC20Token public mockUSDT;
MockWorldIDContract public mockWorldID;


function setUp() public {
factory = new WalletFactory();
}

function test_CreateWallet() public {
factory.createWallet(address (mockWorldID), address(mockUSDT));
factory.createWallet(address(mockWorldID), address(mockUSDT));

assertEq(factory.getWalletClones().length, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ contract MockERC20 is IERC20 {
}
}
}
}
}
2 changes: 1 addition & 1 deletion test/mocks/MockWorldID.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ contract MockWorldID is IWorldID {
function setVerified(address user, bool status) external {
_verified[user] = status;
}
}
}

0 comments on commit 0355482

Please sign in to comment.