-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integration web3-google-hsm module to sign txs using gcp HSM key (
#271) - Add: Google Cloud HSM hardware wallet support in `eth_defi.gcloud_hsm_wallet`
- Loading branch information
1 parent
cf109a2
commit 0ca0156
Showing
11 changed files
with
1,664 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from abc import ABC, abstractmethod | ||
from decimal import Decimal | ||
from typing import Optional | ||
|
||
from eth_typing import HexAddress | ||
from web3 import Web3 | ||
from web3.contract.contract import ContractFunction | ||
|
||
from eth_defi.hotwallet import SignedTransactionWithNonce | ||
|
||
|
||
class BaseWallet(ABC): | ||
"""Abstract base class for Ethereum wallets. | ||
This interface defines the common contract that both HotWallet and HSM-based | ||
wallets must implement. | ||
""" | ||
|
||
@property | ||
@abstractmethod | ||
def address(self) -> HexAddress: | ||
"""Get the wallet's Ethereum address.""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_main_address(self) -> HexAddress: | ||
"""Get the main Ethereum address for this wallet.""" | ||
pass | ||
|
||
@abstractmethod | ||
def sync_nonce(self, web3: Web3) -> None: | ||
"""Synchronize the nonce with the blockchain.""" | ||
pass | ||
|
||
@abstractmethod | ||
def allocate_nonce(self) -> int: | ||
"""Get the next available nonce.""" | ||
pass | ||
|
||
@abstractmethod | ||
def sign_transaction_with_new_nonce(self, tx: dict) -> SignedTransactionWithNonce: | ||
"""Sign a transaction with a new nonce.""" | ||
pass | ||
|
||
@abstractmethod | ||
def sign_bound_call_with_new_nonce(self, func: ContractFunction, tx_params: Optional[dict] = None) -> SignedTransactionWithNonce: | ||
"""Sign a contract function call with a new nonce.""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_native_currency_balance(self, web3: Web3) -> Decimal: | ||
"""Get the wallet's native currency balance.""" | ||
pass | ||
|
||
@staticmethod | ||
@abstractmethod | ||
def fill_in_gas_price(web3: Web3, tx: dict) -> dict: | ||
"""Fill in gas price details for a transaction.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.