add ERC20 read-only interface
This commit is contained in:
parent
c453c0e56c
commit
8caeef1ae4
|
@ -3,6 +3,7 @@ pragma solidity >=0.5.0 <0.7.0;
|
|||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";
|
||||
import "@openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol";
|
||||
|
||||
import "./IBlockRelay.sol";
|
||||
|
@ -69,6 +70,38 @@ contract StatusPay is BlockConsumer {
|
|||
));
|
||||
}
|
||||
|
||||
function totalSupply() external view returns (uint256) {
|
||||
return token.balanceOf(address(this));
|
||||
}
|
||||
|
||||
function balanceOf(address _account) external view returns (uint256) {
|
||||
Account storage account = accounts[_account];
|
||||
|
||||
if (!account.exists) {
|
||||
account = accounts[owners[_account]];
|
||||
|
||||
if (!account.exists) {
|
||||
account = accounts[keycards[_account]];
|
||||
}
|
||||
}
|
||||
|
||||
return account.balance;
|
||||
}
|
||||
|
||||
function name() public view returns (string memory) {
|
||||
string memory sym = ERC20Detailed(address(token)).symbol();
|
||||
return string(abi.encodePacked(sym, " in Status Pay"));
|
||||
}
|
||||
|
||||
function symbol() public view returns (string memory) {
|
||||
string memory sym = ERC20Detailed(address(token)).symbol();
|
||||
return string(abi.encodePacked("s", sym));
|
||||
}
|
||||
|
||||
function decimals() public view returns (uint8) {
|
||||
return ERC20Detailed(address(token)).decimals();
|
||||
}
|
||||
|
||||
function createAccount(address _keycard, uint256 _minBlockDistance, uint256 _maxTxAmount) public {
|
||||
require(owners[msg.sender] == address(0), "already exists");
|
||||
owners[msg.sender] = address(nextAccount);
|
||||
|
@ -104,6 +137,18 @@ contract StatusPay is BlockConsumer {
|
|||
owners[msg.sender] = address(0);
|
||||
}
|
||||
|
||||
function setMaxTxAmount(uint256 _amount) public {
|
||||
Account storage account = accounts[owners[msg.sender]];
|
||||
require(account.exists, "no account found");
|
||||
account.maxTxAmount = _amount;
|
||||
}
|
||||
|
||||
function setMinBlockDistance(uint256 _distance) public {
|
||||
Account storage account = accounts[owners[msg.sender]];
|
||||
require(account.exists, "no account found");
|
||||
account.minBlockDistance = _distance;
|
||||
}
|
||||
|
||||
function addKeycard(address _keycard) public {
|
||||
address account = owners[msg.sender];
|
||||
require(account != address(0), "no account for this address");
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
"typeface-roboto": "^0.0.54"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eth-optimism/solc": "^0.5.16-alpha.2",
|
||||
"@eth-optimism/solc": "^0.5.16-alpha.3",
|
||||
"@openzeppelin/cli": "^2.8.2",
|
||||
"@openzeppelin/contracts-ethereum-package": "^2.5.0",
|
||||
"@eth-optimism/ovm-toolchain": "^0.0.1-alpha.7",
|
||||
"@eth-optimism/ovm-toolchain": "^0.0.1-alpha.11",
|
||||
"@openzeppelin/truffle-upgrades": "^1.0.2",
|
||||
"bip39": "^3.0.2",
|
||||
"ethereumjs-wallet": "^1.0.0"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue