expiry.py (1046B)
1 # external imports 2 from chainlib.eth.tx import ( 3 TxFactory, 4 TxFormat, 5 ) 6 from chainlib.eth.contract import ( 7 ABIContractEncoder, 8 ABIContractType, 9 abi_decode_single, 10 ) 11 from chainlib.eth.constant import ZERO_ADDRESS 12 13 14 class ExpiryContract(TxFactory): 15 16 def set_expire_period(self, contract_address, sender_address, expire_timestamp, tx_format=TxFormat.JSONRPC): 17 enc = ABIContractEncoder() 18 enc.method('setExpirePeriod') 19 enc.typ(ABIContractType.UINT256) 20 enc.uint256(expire_timestamp) 21 data = enc.get() 22 tx = self.template(sender_address, contract_address, use_nonce=True) 23 tx = self.set_code(tx, data) 24 tx = self.finalize(tx, tx_format) 25 return tx 26 27 28 def expires(self, contract_address, sender_address=ZERO_ADDRESS): 29 return self.call_noarg('expires', contract_address, sender_address=sender_address) 30 31 32 @classmethod 33 def parse_expires(self, v): 34 return abi_decode_single(ABIContractType.UINT256, v) 35 36