Skip to content
Snippets Groups Projects
Commit e15228d6 authored by Krzysztof Mochocki's avatar Krzysztof Mochocki Committed by Jakub Ziebinski
Browse files

Add misssing methodes to transaction interface

parent f0f4ad70
No related branches found
No related tags found
1 merge request!230Implementation of the python wax interface
...@@ -35,6 +35,7 @@ from wax.proto.transaction_pb2 import transaction as proto_transaction ...@@ -35,6 +35,7 @@ from wax.proto.transaction_pb2 import transaction as proto_transaction
if TYPE_CHECKING: if TYPE_CHECKING:
from datetime import timedelta from datetime import timedelta
from beekeepy._interface.abc.asynchronous.wallet import UnlockedWallet as AsyncUnlockedWallet
from beekeepy._interface.abc.synchronous.wallet import UnlockedWallet from beekeepy._interface.abc.synchronous.wallet import UnlockedWallet
from wax import IWaxBaseInterface from wax import IWaxBaseInterface
from wax._private.models.basic import AccountName, Hex, PublicKey, SigDigest, Signature, TransactionId from wax._private.models.basic import AccountName, Hex, PublicKey, SigDigest, Signature, TransactionId
...@@ -114,6 +115,13 @@ class Transaction(ITransaction): ...@@ -114,6 +115,13 @@ class Transaction(ITransaction):
self._target.signatures.append(sig) self._target.signatures.append(sig)
return sig return sig
async def async_sign(self, wallet: AsyncUnlockedWallet, public_key: PublicKey) -> Signature:
self.validate()
sig = await wallet.sign_digest(sig_digest=self.sig_digest, key=public_key)
self._target.signatures.append(sig)
return sig
def add_signature(self, signature: Signature) -> Signature: def add_signature(self, signature: Signature) -> Signature:
self._target.signatures.append(signature) self._target.signatures.append(signature)
return signature return signature
......
...@@ -12,6 +12,7 @@ if TYPE_CHECKING: ...@@ -12,6 +12,7 @@ if TYPE_CHECKING:
from datetime import datetime from datetime import datetime
from decimal import Decimal from decimal import Decimal
from beekeepy._interface.abc.asynchronous.wallet import UnlockedWallet as AsyncUnlockedWallet
from beekeepy._interface.abc.synchronous.wallet import UnlockedWallet from beekeepy._interface.abc.synchronous.wallet import UnlockedWallet
from wax._private.models.asset import ( from wax._private.models.asset import (
AssetFactory, AssetFactory,
...@@ -144,6 +145,22 @@ class ITransactionBase(ABC): ...@@ -144,6 +145,22 @@ class ITransactionBase(ABC):
WaxValidationFailedError: When the transaction is incorrect. WaxValidationFailedError: When the transaction is incorrect.
""" """
@abstractmethod
async def async_sign(self, wallet: AsyncUnlockedWallet, public_key: PublicKey) -> Signature:
"""
Signs asynchronously the transaction using given public key. Applies the transaction expiration time.
Args:
wallet: Unlocked wallet to be used for signing.
public_key: Public key for signing (remember that should be available in the wallet!)
Returns:
Signature: Transaction signature signed using given key.
Raises:
WaxValidationFailedError: When the transaction is incorrect.
"""
@abstractmethod @abstractmethod
def add_signature(self, signature: Signature) -> Signature: def add_signature(self, signature: Signature) -> Signature:
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment