Struct raiden_blockchain::proxies::TokenNetworkProxy
source · pub struct TokenNetworkProxy<T: Transport> { /* private fields */ }
Expand description
Token network proxy to interact with the on-chain contract.
Implementations§
source§impl<T> TokenNetworkProxy<T>
impl<T> TokenNetworkProxy<T>
sourcepub fn new(
web3: Web3<T>,
gas_metadata: Arc<GasMetadata>,
contract: Contract<T>,
token_proxy: TokenProxy<T>
) -> Self
pub fn new( web3: Web3<T>, gas_metadata: Arc<GasMetadata>, contract: Contract<T>, token_proxy: TokenProxy<T> ) -> Self
Returns a new instance of TokenNetworkProxy
.
sourcepub async fn new_channel(
&mut self,
account: Account<T>,
partner: Address,
settle_timeout: SettleTimeout,
block: BlockHash
) -> Result<ChannelIdentifier>
pub async fn new_channel( &mut self, account: Account<T>, partner: Address, settle_timeout: SettleTimeout, block: BlockHash ) -> Result<ChannelIdentifier>
Creates a new channel in the TokenNetwork contract.
sourcepub async fn close(
&self,
account: Account<T>,
partner: Address,
channel_identifier: ChannelIdentifier,
nonce: Nonce,
balance_hash: BalanceHash,
additional_hash: H256,
non_closing_signature: Signature,
closing_signature: Signature,
block_hash: BlockHash
) -> Result<TransactionHash>
pub async fn close( &self, account: Account<T>, partner: Address, channel_identifier: ChannelIdentifier, nonce: Nonce, balance_hash: BalanceHash, additional_hash: H256, non_closing_signature: Signature, closing_signature: Signature, block_hash: BlockHash ) -> Result<TransactionHash>
Close the channel using the provided balance proof.
Note: This method must not be called without updating the application state, otherwise the node may accept new transfers which cannot be used, because the closer is not allowed to update the balance proof submitted on chain after closing
sourcepub async fn approve_and_set_total_deposit(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
partner: Address,
total_deposit: TokenAmount,
block_hash: BlockHash
) -> Result<()>
pub async fn approve_and_set_total_deposit( &self, account: Account<T>, channel_identifier: ChannelIdentifier, partner: Address, total_deposit: TokenAmount, block_hash: BlockHash ) -> Result<()>
Set channel’s total deposit.
total_deposit
has to be monotonically increasing, this is enforced by
the TokenNetwork
smart contract. This is done for the same reason why
the balance proofs have a monotonically increasing transferred amount,
it simplifies the analysis of bad behavior and the handling code of
out-dated balance proofs.
Races to approve_and_set_total_deposit
are handled by the smart contract, where
largest total deposit wins. The end balance of the funding accounts is
undefined. E.g.
-
Acc1 calls approve_and_set_total_deposit with 10 tokens
-
Acc2 calls approve_and_set_total_deposit with 13 tokens
-
If Acc2’s transaction is mined first, then Acc1 token supply is left intact.
-
If Acc1’s transaction is mined first, then Acc2 will only move 3 tokens.
Races for the same account don’t have any unexpected side-effect.
sourcepub async fn set_total_withdraw(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
total_withdraw: TokenAmount,
participant: Address,
partner: Address,
participant_signature: Signature,
partner_signature: Signature,
expiration_block: BlockExpiration,
block_hash: BlockHash
) -> Result<()>
pub async fn set_total_withdraw( &self, account: Account<T>, channel_identifier: ChannelIdentifier, total_withdraw: TokenAmount, participant: Address, partner: Address, participant_signature: Signature, partner_signature: Signature, expiration_block: BlockExpiration, block_hash: BlockHash ) -> Result<()>
Set total token withdraw in the channel to total_withdraw.
sourcepub async fn update_transfer(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
nonce: Nonce,
partner: Address,
balance_hash: BalanceHash,
additional_hash: H256,
closing_signature: Signature,
non_closing_signature: Signature,
block_hash: BlockHash
) -> Result<TransactionHash>
pub async fn update_transfer( &self, account: Account<T>, channel_identifier: ChannelIdentifier, nonce: Nonce, partner: Address, balance_hash: BalanceHash, additional_hash: H256, closing_signature: Signature, non_closing_signature: Signature, block_hash: BlockHash ) -> Result<TransactionHash>
Sets the on-chain balance proof to match the latest one received from partner.
sourcepub async fn settle(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
our_transferred_amount: TokenAmount,
our_locked_amount: LockedAmount,
our_locksroot: Locksroot,
partner_address: Address,
partner_transferred_amount: TokenAmount,
partner_locked_amount: LockedAmount,
partner_locksroot: Locksroot,
block_hash: BlockHash
) -> Result<TransactionHash>
pub async fn settle( &self, account: Account<T>, channel_identifier: ChannelIdentifier, our_transferred_amount: TokenAmount, our_locked_amount: LockedAmount, our_locksroot: Locksroot, partner_address: Address, partner_transferred_amount: TokenAmount, partner_locked_amount: LockedAmount, partner_locksroot: Locksroot, block_hash: BlockHash ) -> Result<TransactionHash>
Settle a channel.
sourcepub async fn unlock(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
sender: Address,
receiver: Address,
pending_locks: PendingLocksState,
block_hash: BlockHash
) -> Result<TransactionHash>
pub async fn unlock( &self, account: Account<T>, channel_identifier: ChannelIdentifier, sender: Address, receiver: Address, pending_locks: PendingLocksState, block_hash: BlockHash ) -> Result<TransactionHash>
Unlock a channel’s balances.
sourcepub async fn coop_settle(
&self,
account: Account<T>,
channel_identifier: ChannelIdentifier,
withdraw_partner: WithdrawInput,
withdraw_initiator: WithdrawInput,
block_hash: BlockHash
) -> Result<TransactionHash>
pub async fn coop_settle( &self, account: Account<T>, channel_identifier: ChannelIdentifier, withdraw_partner: WithdrawInput, withdraw_initiator: WithdrawInput, block_hash: BlockHash ) -> Result<TransactionHash>
Cooperatively settle a channel on-chain.
sourcepub async fn get_channel_identifier(
&self,
participant1: Address,
participant2: Address,
block: Option<H256>
) -> Result<Option<U256>>
pub async fn get_channel_identifier( &self, participant1: Address, participant2: Address, block: Option<H256> ) -> Result<Option<U256>>
Retrieve channel identifier by participants.
sourcepub async fn address_by_token_address(
&self,
token_address: TokenAddress,
block: H256
) -> Result<Address>
pub async fn address_by_token_address( &self, token_address: TokenAddress, block: H256 ) -> Result<Address>
Get token network address by token address.
sourcepub async fn safety_deprecation_switch(&self, block: H256) -> Result<bool>
pub async fn safety_deprecation_switch(&self, block: H256) -> Result<bool>
Returns a bool indicating whether a contract is deprecated.
sourcepub async fn channel_participant_deposit_limit(
&self,
block: H256
) -> Result<U256>
pub async fn channel_participant_deposit_limit( &self, block: H256 ) -> Result<U256>
Returns the channel participant deposit limit.
sourcepub async fn participants_details(
&self,
channel_identifier: U256,
address: Address,
partner: Address,
block: Option<H256>
) -> Result<ParticipantsDetails>
pub async fn participants_details( &self, channel_identifier: U256, address: Address, partner: Address, block: Option<H256> ) -> Result<ParticipantsDetails>
Queries contract and returns details of both participants.
sourcepub async fn channel_details(
&self,
channel_identifier: Option<U256>,
address: Address,
partner: Address,
block: H256
) -> Result<ChannelData>
pub async fn channel_details( &self, channel_identifier: Option<U256>, address: Address, partner: Address, block: H256 ) -> Result<ChannelData>
Returns the channel details.
sourcepub async fn chain_id(&self, block: H256) -> Result<ChainID>
pub async fn chain_id(&self, block: H256) -> Result<ChainID>
Returns the chain ID indicated by contract.
sourcepub async fn settlement_timeout_min(&self, block: H256) -> Result<SettleTimeout>
pub async fn settlement_timeout_min(&self, block: H256) -> Result<SettleTimeout>
Returns the minimum settlement timeout.
sourcepub async fn settlement_timeout_max(&self, block: H256) -> Result<SettleTimeout>
pub async fn settlement_timeout_max(&self, block: H256) -> Result<SettleTimeout>
Returns the maximum settlement timeout.
sourcepub async fn token_network_deposit_limit(&self, block: H256) -> Result<U256>
pub async fn token_network_deposit_limit(&self, block: H256) -> Result<U256>
Returns the token network total deposit limit.
sourcepub async fn participant_details(
&self,
channel_identifier: U256,
address: Address,
partner: Address,
block: Option<H256>
) -> Result<ParticipantDetails>
pub async fn participant_details( &self, channel_identifier: U256, address: Address, partner: Address, block: Option<H256> ) -> Result<ParticipantDetails>
Returns the details of a participant in a channel.