pub trait BoundEthInterface:
AsRef<DynClient<L1>>
+ 'static
+ Sync
+ Send
+ Debug {
// Required methods
fn clone_boxed(&self) -> Box<dyn BoundEthInterface>;
fn for_component(
self: Box<Self>,
component_name: &'static str,
) -> Box<dyn BoundEthInterface>;
fn contract(&self) -> &Contract;
fn contract_addr(&self) -> H160;
fn chain_id(&self) -> L1ChainId;
fn sender_account(&self) -> Address;
fn allowance_on_account<'life0, 'life1, 'async_trait>(
&'life0 self,
token_address: Address,
address: Address,
erc20_abi: &'life1 Contract,
) -> Pin<Box<dyn Future<Output = Result<U256, ContractCallError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn sign_prepared_tx_for_addr<'life0, 'async_trait>(
&'life0 self,
data: Vec<u8>,
contract_addr: H160,
options: Options,
) -> Pin<Box<dyn Future<Output = Result<SignedCallResult, SigningError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
An extension of EthInterface trait, which is used to perform queries that are bound to
a certain contract and account.
The example use cases for this trait would be:
- An operator that sends transactions and interacts with ZKsync contract.
- A wallet implementation in the SDK that is tied to a user’s account.
When adding a method to this trait:
- Make sure that it’s indeed “bound”. If not, add it to the
EthInterfacetrait instead. - Consider adding the “unbound” version to the
EthInterfacetrait and create a default method implementation that invokescontract/contract_addr/sender_accountmethods.
Required Methods§
Sourcefn clone_boxed(&self) -> Box<dyn BoundEthInterface>
fn clone_boxed(&self) -> Box<dyn BoundEthInterface>
Clones this client.
Sourcefn for_component(
self: Box<Self>,
component_name: &'static str,
) -> Box<dyn BoundEthInterface>
fn for_component( self: Box<Self>, component_name: &'static str, ) -> Box<dyn BoundEthInterface>
Tags this client as working for a specific component. The component name can be used in logging, metrics etc. The component name should be copied to the clones of this client, but should not be passed upstream.
Sourcefn contract_addr(&self) -> H160
fn contract_addr(&self) -> H160
Address of the contract that is used by the implementer.
Sourcefn chain_id(&self) -> L1ChainId
fn chain_id(&self) -> L1ChainId
Chain ID of the L1 network the client is configured to connected to.
This value should be externally provided by the user rather than requested from the network to avoid accidental network mismatch.
Sourcefn sender_account(&self) -> Address
fn sender_account(&self) -> Address
Address of the account associated with the object implementing the trait.
Sourcefn allowance_on_account<'life0, 'life1, 'async_trait>(
&'life0 self,
token_address: Address,
address: Address,
erc20_abi: &'life1 Contract,
) -> Pin<Box<dyn Future<Output = Result<U256, ContractCallError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn allowance_on_account<'life0, 'life1, 'async_trait>(
&'life0 self,
token_address: Address,
address: Address,
erc20_abi: &'life1 Contract,
) -> Pin<Box<dyn Future<Output = Result<U256, ContractCallError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the certain ERC20 token allowance for the pair (Self::sender_account(), address).
Sourcefn sign_prepared_tx_for_addr<'life0, 'async_trait>(
&'life0 self,
data: Vec<u8>,
contract_addr: H160,
options: Options,
) -> Pin<Box<dyn Future<Output = Result<SignedCallResult, SigningError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sign_prepared_tx_for_addr<'life0, 'async_trait>(
&'life0 self,
data: Vec<u8>,
contract_addr: H160,
options: Options,
) -> Pin<Box<dyn Future<Output = Result<SignedCallResult, SigningError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Signs the transaction and sends it to the Ethereum network.
Expected to use credentials associated with Self::sender_account().
Implementations§
Source§impl dyn BoundEthInterface
impl dyn BoundEthInterface
Sourcepub async fn nonce_at(&self, block: BlockNumber) -> EnrichedClientResult<U256>
pub async fn nonce_at(&self, block: BlockNumber) -> EnrichedClientResult<U256>
Returns the nonce of the Self::sender_account() at the specified block.
Sourcepub async fn current_nonce(&self) -> EnrichedClientResult<U256>
pub async fn current_nonce(&self) -> EnrichedClientResult<U256>
Returns the current nonce of the Self::sender_account().
Sourcepub async fn pending_nonce(&self) -> EnrichedClientResult<U256>
pub async fn pending_nonce(&self) -> EnrichedClientResult<U256>
Returns the pending nonce of the Self::sender_account().
Sourcepub async fn sign_prepared_tx(
&self,
data: Vec<u8>,
options: Options,
) -> Result<SignedCallResult, SigningError>
pub async fn sign_prepared_tx( &self, data: Vec<u8>, options: Options, ) -> Result<SignedCallResult, SigningError>
Similar to [EthInterface::sign_prepared_tx_for_addr], but is fixed over Self::contract_addr().
Sourcepub async fn sender_eth_balance(&self) -> EnrichedClientResult<U256>
pub async fn sender_eth_balance(&self) -> EnrichedClientResult<U256>
Returns the ETH balance of Self::sender_account().