commit 0a98d041f5423a82bd9363a19eabe0425bd3e35f
parent 921d493b987145f8802f52a0cc21c3a41ae07b02
Author: nolash <dev@holbrook.no>
Date: Sat, 8 May 2021 07:51:13 +0200
Add minted at
Diffstat:
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/python/eth_devbadge/token.py b/python/eth_devbadge/token.py
@@ -168,6 +168,21 @@ class BadgeToken(ERC20):
return o
+ def minted_at(self, contract_address, token_id, sender_address=ZERO_ADDRESS):
+ o = jsonrpc_template()
+ o['method'] = 'eth_call'
+ enc = ABIContractEncoder()
+ enc.method('mintedAt')
+ enc.typ(ABIContractType.UINT256)
+ enc.uint256(token_id)
+ data = add_0x(enc.get())
+ tx = self.template(sender_address, contract_address)
+ tx = self.set_code(tx, data)
+ o['params'].append(self.normalize(tx))
+ o['params'].append('latest')
+ return o
+
+
def token_of_owner_by_index(self, contract_address, holder_address, idx, sender_address=ZERO_ADDRESS):
o = jsonrpc_template()
o['method'] = 'eth_call'
@@ -220,3 +235,8 @@ class BadgeToken(ERC20):
return abi_decode_single(ABIContractType.ADDRESS, v)
+ @classmethod
+ def parse_minted_at(self, v):
+ return abi_decode_single(ABIContractType.UINT256, v)
+
+
diff --git a/python/tests/test_app.py b/python/tests/test_app.py
@@ -65,6 +65,8 @@ class Test(EthTesterCase):
def test_mint(self):
+ self.backend.mine_blocks(42)
+
token_bytes = b'\xee' * 32
token_id = int.from_bytes(token_bytes, byteorder='big')
c = self._mint(self.accounts[1], token_id)
@@ -79,6 +81,12 @@ class Test(EthTesterCase):
self.assertEqual(supply, 1)
+ o = c.minted_at(self.address, token_id, sender_address=self.accounts[0])
+ r = self.rpc.do(o)
+ height = c.parse_minted_at(r)
+
+ self.assertEqual(height, 44)
+
def test_owner(self):
token_bytes = b'\xee' * 32