Rename --contracts-dir to --abi-dir

This commit is contained in:
nolash 2020-12-11 16:42:47 +01:00
parent 6ab532e741
commit 706a1fcd65
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 9 additions and 9 deletions

View File

@ -30,7 +30,7 @@ argparser.add_argument('-d', '--decimals', dest='d', default=18, type=int, help=
argparser.add_argument('-o', '--owner', dest='o', type=str, help='Reserve owner account') argparser.add_argument('-o', '--owner', dest='o', type=str, help='Reserve owner account')
argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to fund') argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to fund')
argparser.add_argument('-m', '--minter', dest='m', action='append', type=str, help='Minter to add') argparser.add_argument('-m', '--minter', dest='m', action='append', type=str, help='Minter to add')
argparser.add_argument('--contracts-dir', dest='contracts_dir', type=str, default='.', help='Directory containing bytecode and abi') argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default='.', help='Directory containing bytecode and abi')
argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)') argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)')
args = argparser.parse_args() args = argparser.parse_args()
@ -41,11 +41,11 @@ if args.v:
def main(): def main():
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p)) w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
f = open(os.path.join(args.contracts_dir, 'GiftableToken.abi.json'), 'r') f = open(os.path.join(args.abi_dir, 'GiftableToken.abi.json'), 'r')
abi = json.load(f) abi = json.load(f)
f.close() f.close()
f = open(os.path.join(args.contracts_dir, 'GiftableToken.bin'), 'r') f = open(os.path.join(args.abi_dir, 'GiftableToken.bin'), 'r')
bytecode = f.read() bytecode = f.read()
f.close() f.close()

View File

@ -26,7 +26,7 @@ argparser = argparse.ArgumentParser()
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)') argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)')
argparser.add_argument('-t', '--token-address', required='True', dest='t', type=str, help='Giftable token address') argparser.add_argument('-t', '--token-address', required='True', dest='t', type=str, help='Giftable token address')
argparser.add_argument('-m', '--minter-address', dest='m', type=str, help='Minter account address') argparser.add_argument('-m', '--minter-address', dest='m', type=str, help='Minter account address')
argparser.add_argument('--contracts-dir', dest='contracts_dir', type=str, default='.', help='Directory containing bytecode and abi') argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default='.', help='Directory containing bytecode and abi')
argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-r', '--recipient-address', dest='r', type=str, help='Recipient account address') argparser.add_argument('-r', '--recipient-address', dest='r', type=str, help='Recipient account address')
argparser.add_argument('amount', type=int, help='Amount of tokens to mint and gift') argparser.add_argument('amount', type=int, help='Amount of tokens to mint and gift')
@ -38,7 +38,7 @@ if args.v:
def main(): def main():
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p)) w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
f = open(os.path.join(args.contracts_dir, 'GiftableToken.abi.json'), 'r') f = open(os.path.join(args.abi_dir, 'GiftableToken.abi.json'), 'r')
abi = json.load(f) abi = json.load(f)
f.close() f.close()

View File

@ -12,7 +12,7 @@ contract GiftableToken {
uint8 public decimals; uint8 public decimals;
uint256 public totalSupply; uint256 public totalSupply;
mapping (address => uint256) public balanceOf; mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowances; mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed _from, address indexed _to, uint256 _value); event Transfer(address indexed _from, address indexed _to, uint256 _value);
event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value); event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value);
@ -60,9 +60,9 @@ contract GiftableToken {
} }
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(allowances[_from][msg.sender] >= _value); require(allowance[_from][msg.sender] >= _value);
require(balanceOf[_from] >= _value); require(balanceOf[_from] >= _value);
allowances[_from][msg.sender] = allowances[_from][msg.sender] - _value; allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value;
balanceOf[_from] -= _value; balanceOf[_from] -= _value;
balanceOf[_to] += _value; balanceOf[_to] += _value;
emit TransferFrom(_from, _to, msg.sender, _value); emit TransferFrom(_from, _to, msg.sender, _value);
@ -70,7 +70,7 @@ contract GiftableToken {
} }
function approve(address _spender, uint256 _value) public returns (bool) { function approve(address _spender, uint256 _value) public returns (bool) {
allowances[msg.sender][_spender] += _value; allowance[msg.sender][_spender] += _value;
emit Approval(msg.sender, _spender, _value); emit Approval(msg.sender, _spender, _value);
return true; return true;
} }