* Export artifacts and addresses from abi-gen-wrappers * only export addresses, not artifacts * abi-gen-wrappers no longer accept ContractAbi as constructor param ABI is now hardcoded when wrapper is generated * remove unused imports * remove unused import * changes after review * fix method ordering * update constructor args * prettier * statically enumerate ABI properties * remove abi-gen-wrappers generated-wrappers from prettierignore * add template for recursive components * add `indexed` field for EventParameter * prettier * update known-good wrappers with ABIs and fix Python ABI loading * remove generated-artifacts and update gitignore
58 lines
1.7 KiB
Handlebars
58 lines
1.7 KiB
Handlebars
"""Generated wrapper for {{contractName}} Solidity contract."""
|
|
|
|
import json
|
|
from typing import Optional, Tuple, Union
|
|
|
|
from hexbytes import HexBytes
|
|
from web3.datastructures import AttributeDict
|
|
from web3.providers.base import BaseProvider
|
|
|
|
from zero_ex.contract_wrappers._base_contract_wrapper import BaseContractWrapper
|
|
from zero_ex.contract_wrappers.tx_params import TxParams
|
|
|
|
|
|
class {{contractName}}(BaseContractWrapper):
|
|
"""Wrapper class for {{contractName}} Solidity contract."""
|
|
|
|
def __init__(
|
|
self,
|
|
provider: BaseProvider,
|
|
contract_address: str,
|
|
private_key: str = None,
|
|
):
|
|
"""Get an instance of wrapper for smart contract.
|
|
|
|
:param provider: instance of :class:`web3.providers.base.BaseProvider`
|
|
:param contract_address: where the contract has been deployed
|
|
:param private_key: If specified, transactions will be signed locally,
|
|
via Web3.py's `eth.account.signTransaction()`:code:, before being
|
|
sent via `eth.sendRawTransaction()`:code:.
|
|
"""
|
|
super().__init__(
|
|
provider=provider,
|
|
contract_address=contract_address,
|
|
private_key=private_key,
|
|
)
|
|
|
|
def _get_contract_instance(self, token_address):
|
|
"""Get an instance of the smart contract at a specific address.
|
|
|
|
:returns: contract object
|
|
"""
|
|
return self._contract_instance(
|
|
address=token_address, abi={{contractName}}.abi()
|
|
)
|
|
{{#each methods}}
|
|
{{> call contractName=../contractName}}
|
|
{{/each}}
|
|
{{#each events}}
|
|
{{> event}}
|
|
{{/each}}
|
|
|
|
@staticmethod
|
|
def abi():
|
|
"""Return the ABI to the underlying contract."""
|
|
return json.loads(
|
|
'{{{ABIString}}}' # noqa: E501 (line-too-long)
|
|
)
|