Skip to content

Commit

Permalink
Merge pull request #74 from skalenetwork/hotfix-consistent-sign-and-send
Browse files Browse the repository at this point in the history
Hotfix consistent sign and send
  • Loading branch information
dmytrotkk authored Jan 2, 2020
2 parents 1dbcdec + 274824c commit bed3f10
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion skale/wallets/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def sign(self, tx):
pass

@abstractmethod
def sign_and_send(self, tx_dict):
def sign_and_send(self, tx_dict) -> str:
pass

@property
Expand Down
8 changes: 4 additions & 4 deletions skale/wallets/ledger_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def sign(self, tx_dict):
exchange_result = self.exchange_sign_payload_by_chunks(payload)
return LedgerWallet.parse_sign_result(tx, exchange_result)

def sign_and_send(self, tx):
def sign_and_send(self, tx) -> str:
signed_tx = self.sign(tx)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction).hex()

@classmethod
def parse_derive_result(cls, exchange_result):
Expand All @@ -164,15 +164,15 @@ def get_address_with_public_key(self):
return LedgerWallet.parse_derive_result(exchange_result)


def hardware_sign_and_send(web3, method, gas_amount, wallet):
def hardware_sign_and_send(web3, method, gas_amount, wallet) -> str:
address_from = wallet['address']
eth_nonce = get_eth_nonce(web3, address_from)
tx_dict = method.buildTransaction({
'gas': gas_amount,
'nonce': eth_nonce
})
signed_txn = wallet.sign(tx_dict)
tx = web3.eth.sendRawTransaction(signed_txn.rawTransaction)
tx = web3.eth.sendRawTransaction(signed_txn.rawTransaction).hex()
logger.info(
f'{method.__class__.__name__} - transaction_hash: {web3.toHex(tx)}'
)
Expand Down
4 changes: 2 additions & 2 deletions skale/wallets/sgx_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def sign(self, tx_dict):
tx_dict['nonce'] = get_eth_nonce(self._web3, self._address)
return self.sgx_client.sign(tx_dict, self.key_name)

def sign_and_send(self, tx):
def sign_and_send(self, tx) -> str:
signed_tx = self.sgx_client.sign(tx, self.key_name)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction).hex()

@property
def address(self):
Expand Down
4 changes: 2 additions & 2 deletions skale/wallets/web3_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def sign(self, tx_dict):
private_key=self._private_key
)

def sign_and_send(self, tx_dict):
def sign_and_send(self, tx_dict) -> str:
signed_tx = self.sign(tx_dict)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction)
return self._web3.eth.sendRawTransaction(signed_tx.rawTransaction).hex()

@property
def address(self):
Expand Down

0 comments on commit bed3f10

Please sign in to comment.