From a0620875e5d0754389783a66d8a3fa0f9b191c85 Mon Sep 17 00:00:00 2001 From: Adam Majmudar <64697628+adam-maj@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:51:05 -0700 Subject: [PATCH] Add events support to custom contracts (#141) Add events suport to custom contracts --- pyproject.toml | 2 +- thirdweb/contracts/custom.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 71b10b8..4a05801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ packages = [ {include = "thirdweb"}, ] readme = "README.md" -version = "3.1.0" +version = "3.1.1" [tool.poetry.dependencies] python = ">=3.7.1" diff --git a/thirdweb/contracts/custom.py b/thirdweb/contracts/custom.py index eb0511f..d68e807 100644 --- a/thirdweb/contracts/custom.py +++ b/thirdweb/contracts/custom.py @@ -1,5 +1,6 @@ from typing import Any, Final, Optional, cast from eth_typing import Address +from thirdweb.core.classes.contract_events import ContractEvents from web3 import Web3 from web3.contract import ContractFunctions, ContractFunction @@ -74,6 +75,7 @@ class CustomContract(BaseContract[Any]): contract_type: Final[ContractType] = ContractType.CUSTOM functions: ContractFunctions + events: ContractEvents def __init__( self, @@ -105,6 +107,8 @@ def __init__( self.erc721 = self._detect_erc_721() self.erc1155 = self._detect_erc_1155() + self.events = ContractEvents(contract_wrapper) + def call(self, fn: str, *args) -> Any: func = cast(ContractFunction, getattr(self.functions, fn, None)) if func is None: