-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from casweeney/wallet-structure-setup
Wallet structure setup
- Loading branch information
Showing
7 changed files
with
110 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
import "./interfaces/IERC20.sol"; | ||
|
||
contract Wallet { | ||
address public owner; | ||
mapping(address => Transaction[]) transactions; | ||
mapping(address => mapping(address => uint256)) token_balance; | ||
|
||
struct Transaction { | ||
uint256 amount; | ||
address token; | ||
} | ||
|
||
modifier onlyOwner { | ||
require(msg.sender == owner, "not owner"); | ||
_; | ||
} | ||
|
||
constructor(address _owner) { | ||
require(msg.sender != address(0), "zero address found"); | ||
owner = _owner; | ||
} | ||
|
||
function createWorldId() onlyOwner external { | ||
|
||
} | ||
|
||
function transfer() onlyOwner external { | ||
|
||
} | ||
|
||
////////////////////////////////////////////// | ||
// View Functions // | ||
//////////////////////////////////////////// | ||
|
||
function getTransactionHistory() external view returns (Transaction[] memory) { | ||
|
||
} | ||
|
||
//////////////////////////////////////////////// | ||
// Private Function // | ||
////////////////////////////////////////////// | ||
|
||
function recordTransactionHistory() private { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
import "./Wallet.sol"; | ||
|
||
contract WalletFactory { | ||
Wallet[] wallets; | ||
|
||
function createWallet() external returns (Wallet newWallet_, uint256 length_) { | ||
newWallet_ = new Wallet(msg.sender); | ||
|
||
wallets.push(newWallet_); | ||
|
||
length_ = wallets.length; | ||
} | ||
|
||
function getWalletClones() external view returns(Wallet[] memory) { | ||
return wallets; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) | ||
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); | ||
|
||
function transfer(address to, uint256 value) external returns (bool); | ||
|
||
function allowance(address owner, address spender) external view returns (uint256); | ||
|
||
function approve(address spender, uint256 value) external returns (bool); | ||
|
||
function transferFrom(address from, address to, uint256 value) external returns (bool); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Test, console} from "forge-std/Test.sol"; | ||
import {WalletFactory} from "../src/WalletFactory.sol"; | ||
|
||
contract WalletFactoryTest is Test { | ||
WalletFactory public factory; | ||
|
||
function setUp() public { | ||
factory = new WalletFactory(); | ||
} | ||
|
||
function test_CreateWallet() public { | ||
factory.createWallet(); | ||
|
||
assertEq(factory.getWalletClones().length, 1); | ||
} | ||
} |