mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-05 02:06:45 +01:00
REinstate owner as minter by default
This commit is contained in:
parent
5d585fc208
commit
75c16b7198
@ -1,3 +1,5 @@
|
|||||||
|
- 0.3.6
|
||||||
|
* Reinstate owner as minter by default
|
||||||
- 0.3.0
|
- 0.3.0
|
||||||
* Smart contracts use abdk math libraries, all exponential operations are static gas cost
|
* Smart contracts use abdk math libraries, all exponential operations are static gas cost
|
||||||
* Add expiry features, after which balances are frozen and no more transfers or demurrage will occur
|
* Add expiry features, after which balances are frozen and no more transfers or demurrage will occur
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -77,12 +77,6 @@ class TestTokenDeploy:
|
|||||||
r = rpc.do(o)
|
r = rpc.do(o)
|
||||||
self.start_time = r['timestamp']
|
self.start_time = r['timestamp']
|
||||||
|
|
||||||
(tx_hash, o) = interface.add_writer(self.address, deployer_address, deployer_address)
|
|
||||||
r = rpc.do(o)
|
|
||||||
o = receipt(tx_hash)
|
|
||||||
r = rpc.do(o)
|
|
||||||
assert r['status'] == 1
|
|
||||||
|
|
||||||
return self.address
|
return self.address
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = erc20-demurrage-token
|
name = erc20-demurrage-token
|
||||||
version = 0.3.5
|
version = 0.3.6
|
||||||
description = ERC20 token with redistributed continual demurrage
|
description = ERC20 token with redistributed continual demurrage
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -36,7 +36,6 @@ class TestAmounts(TestDemurrageDefault):
|
|||||||
o = block_by_number(r)
|
o = block_by_number(r)
|
||||||
r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
ta = r['timestamp']
|
ta = r['timestamp']
|
||||||
logg.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< {} {} {}'.format(tb, ta, ta-tb))
|
|
||||||
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -47,5 +46,32 @@ class TestAmounts(TestDemurrageDefault):
|
|||||||
self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_writer(self):
|
||||||
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[1], 1000)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 0)
|
||||||
|
|
||||||
|
|
||||||
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.add_writer(self.address, self.accounts[0], self.accounts[1])
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[1], 1000)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -115,19 +115,18 @@ contract DemurrageTokenSingleNocap {
|
|||||||
// EIP173
|
// EIP173
|
||||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
|
||||||
|
|
||||||
event SealStateChange(uint256 _sealState);
|
|
||||||
|
|
||||||
event Expired(uint256 _timestamp);
|
event Expired(uint256 _timestamp);
|
||||||
|
|
||||||
event Cap(uint256 indexed _oldCap, uint256 _newCap);
|
event Cap(uint256 indexed _oldCap, uint256 _newCap);
|
||||||
|
|
||||||
// property sealing
|
// Implements Sealer
|
||||||
uint256 public sealState;
|
uint256 public sealState;
|
||||||
uint8 constant MINTER_STATE = 1;
|
uint8 constant MINTER_STATE = 1;
|
||||||
uint8 constant SINK_STATE = 2;
|
uint8 constant SINK_STATE = 2;
|
||||||
uint8 constant EXPIRY_STATE = 4;
|
uint8 constant EXPIRY_STATE = 4;
|
||||||
uint8 constant CAP_STATE = 8;
|
uint8 constant CAP_STATE = 8;
|
||||||
uint256 constant public maxSealState = 15;
|
uint256 constant public maxSealState = 15;
|
||||||
|
event SealStateChange(bool indexed _final, uint256 _sealState);
|
||||||
|
|
||||||
|
|
||||||
constructor(string memory _name, string memory _symbol, uint8 _decimals, int128 _taxLevel, uint256 _periodMinutes, address _defaultSinkAddress) {
|
constructor(string memory _name, string memory _symbol, uint8 _decimals, int128 _taxLevel, uint256 _periodMinutes, address _defaultSinkAddress) {
|
||||||
@ -158,15 +157,17 @@ contract DemurrageTokenSingleNocap {
|
|||||||
sinkAddress = _defaultSinkAddress;
|
sinkAddress = _defaultSinkAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implements Sealer
|
||||||
function seal(uint256 _state) public returns(uint256) {
|
function seal(uint256 _state) public returns(uint256) {
|
||||||
require(_state < 16, 'ERR_INVALID_STATE');
|
require(_state < 16, 'ERR_INVALID_STATE');
|
||||||
require(_state & sealState == 0, 'ERR_ALREADY_LOCKED');
|
require(_state & sealState == 0, 'ERR_ALREADY_LOCKED');
|
||||||
sealState |= _state;
|
sealState |= _state;
|
||||||
emit SealStateChange(sealState);
|
emit SealStateChange(sealState == maxSealState, sealState);
|
||||||
return uint256(sealState);
|
return uint256(sealState);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSealed(uint256 _state) public returns(bool) {
|
// Implements Sealer
|
||||||
|
function isSealed(uint256 _state) public view returns(bool) {
|
||||||
require(_state < maxSealState);
|
require(_state < maxSealState);
|
||||||
if (_state == 0) {
|
if (_state == 0) {
|
||||||
return sealState == maxSealState;
|
return sealState == maxSealState;
|
||||||
@ -297,7 +298,7 @@ contract DemurrageTokenSingleNocap {
|
|||||||
uint256 baseAmount;
|
uint256 baseAmount;
|
||||||
|
|
||||||
require(applyExpiry() == 0);
|
require(applyExpiry() == 0);
|
||||||
require(minter[msg.sender], 'ERR_ACCESS');
|
require(minter[msg.sender] || msg.sender == owner, 'ERR_ACCESS');
|
||||||
|
|
||||||
changePeriod();
|
changePeriod();
|
||||||
if (maxSupply > 0) {
|
if (maxSupply > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user