Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
abi-gen/Py: add build_tx to contract methods
Browse files Browse the repository at this point in the history
  • Loading branch information
feuGeneA committed Nov 15, 2019
1 parent b99396f commit 99a4794
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ class {{toPythonClassname this.languageSpecificName}}Method(ContractMethod):
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method({{> params}}).transact(tx_params.as_dict())

def build_transaction(self, {{#if inputs}}{{> typed_params inputs=inputs}}, {{/if}}tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
{{#if inputs}}
({{> params }}) = self.validate_and_normalize_inputs({{> params}})
{{/if}}
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method({{> params}}).buildTransaction(tx_params.as_dict())

{{/if}}
def estimate_gas(self, {{#if inputs}}{{> typed_params inputs=inputs}}, {{/if}}tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
Expand Down
25 changes: 25 additions & 0 deletions packages/abi-gen/test-cli/output/python/abi_gen_dummy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ def send_transaction(
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().transact(tx_params.as_dict())

def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().buildTransaction(tx_params.as_dict())

def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
Expand Down Expand Up @@ -780,6 +785,11 @@ def send_transaction(
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().transact(tx_params.as_dict())

def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().buildTransaction(tx_params.as_dict())

def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
Expand Down Expand Up @@ -821,6 +831,11 @@ def send_transaction(
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().transact(tx_params.as_dict())

def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method().buildTransaction(tx_params.as_dict())

def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
Expand Down Expand Up @@ -1428,6 +1443,16 @@ def send_transaction(
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method(wad).transact(tx_params.as_dict())

def build_transaction(
self, wad: int, tx_params: Optional[TxParams] = None
) -> dict:
"""Construct calldata to be used as input to the method."""
(wad) = self.validate_and_normalize_inputs(wad)
tx_params = super().normalize_tx_params(tx_params)
return self.underlying_method(wad).buildTransaction(
tx_params.as_dict()
)

def estimate_gas(
self, wad: int, tx_params: Optional[TxParams] = None
) -> int:
Expand Down

0 comments on commit 99a4794

Please sign in to comment.