REinstate owner as minter by default

This commit is contained in:
lash 2023-02-19 08:07:25 +00:00
parent 5d585fc208
commit 75c16b7198
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 39 additions and 16 deletions

View File

@ -1,3 +1,5 @@
- 0.3.6
* Reinstate owner as minter by default
- 0.3.0
* 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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -77,12 +77,6 @@ class TestTokenDeploy:
r = rpc.do(o)
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

View File

@ -1,6 +1,6 @@
[metadata]
name = erc20-demurrage-token
version = 0.3.5
version = 0.3.6
description = ERC20 token with redistributed continual demurrage
author = Louis Holbrook
author_email = dev@holbrook.no

View File

@ -36,7 +36,6 @@ class TestAmounts(TestDemurrageDefault):
o = block_by_number(r)
r = self.rpc.do(o)
ta = r['timestamp']
logg.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< {} {} {}'.format(tb, ta, ta-tb))
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
@ -47,5 +46,32 @@ class TestAmounts(TestDemurrageDefault):
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__':
unittest.main()

View File

@ -115,19 +115,18 @@ contract DemurrageTokenSingleNocap {
// EIP173
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
event SealStateChange(uint256 _sealState);
event Expired(uint256 _timestamp);
event Cap(uint256 indexed _oldCap, uint256 _newCap);
// property sealing
// Implements Sealer
uint256 public sealState;
uint8 constant MINTER_STATE = 1;
uint8 constant SINK_STATE = 2;
uint8 constant EXPIRY_STATE = 4;
uint8 constant CAP_STATE = 8;
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) {
@ -158,15 +157,17 @@ contract DemurrageTokenSingleNocap {
sinkAddress = _defaultSinkAddress;
}
// Implements Sealer
function seal(uint256 _state) public returns(uint256) {
require(_state < 16, 'ERR_INVALID_STATE');
require(_state & sealState == 0, 'ERR_ALREADY_LOCKED');
sealState |= _state;
emit SealStateChange(sealState);
emit SealStateChange(sealState == maxSealState, sealState);
return uint256(sealState);
}
function isSealed(uint256 _state) public returns(bool) {
// Implements Sealer
function isSealed(uint256 _state) public view returns(bool) {
require(_state < maxSealState);
if (_state == 0) {
return sealState == maxSealState;
@ -297,7 +298,7 @@ contract DemurrageTokenSingleNocap {
uint256 baseAmount;
require(applyExpiry() == 0);
require(minter[msg.sender], 'ERR_ACCESS');
require(minter[msg.sender] || msg.sender == owner, 'ERR_ACCESS');
changePeriod();
if (maxSupply > 0) {