mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-25 01:16:45 +01:00
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
# external imports
|
|
from chainlib.eth.tx import (
|
|
TxFactory,
|
|
TxFormat,
|
|
)
|
|
from chainlib.eth.contract import (
|
|
ABIContractEncoder,
|
|
ABIContractType,
|
|
abi_decode_single,
|
|
)
|
|
from chainlib.eth.constant import ZERO_ADDRESS
|
|
|
|
|
|
class ExpiryContract(TxFactory):
|
|
|
|
def set_expire_period(self, contract_address, sender_address, expire_timestamp, tx_format=TxFormat.JSONRPC):
|
|
enc = ABIContractEncoder()
|
|
enc.method('setExpirePeriod')
|
|
enc.typ(ABIContractType.UINT256)
|
|
enc.uint256(expire_timestamp)
|
|
data = enc.get()
|
|
tx = self.template(sender_address, contract_address, use_nonce=True)
|
|
tx = self.set_code(tx, data)
|
|
tx = self.finalize(tx, tx_format)
|
|
return tx
|
|
|
|
|
|
def expires(self, contract_address, sender_address=ZERO_ADDRESS):
|
|
return self.call_noarg('expires', contract_address, sender_address=sender_address)
|
|
|
|
|
|
@classmethod
|
|
def parse_expires(self, v):
|
|
return abi_decode_single(ABIContractType.UINT256, v)
|
|
|
|
|