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>
where T: Transport + Send + Sync, T::Out: Send,

source

pub fn new( web3: Web3<T>, gas_metadata: Arc<GasMetadata>, contract: Contract<T>, token_proxy: TokenProxy<T> ) -> Self

Returns a new instance of TokenNetworkProxy.

source

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.

source

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

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub async fn get_channel_identifier( &self, participant1: Address, participant2: Address, block: Option<H256> ) -> Result<Option<U256>>

Retrieve channel identifier by participants.

source

pub async fn address_by_token_address( &self, token_address: TokenAddress, block: H256 ) -> Result<Address>

Get token network address by token address.

source

pub async fn safety_deprecation_switch(&self, block: H256) -> Result<bool>

Returns a bool indicating whether a contract is deprecated.

source

pub async fn channel_participant_deposit_limit( &self, block: H256 ) -> Result<U256>

Returns the channel participant deposit limit.

source

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.

source

pub async fn channel_details( &self, channel_identifier: Option<U256>, address: Address, partner: Address, block: H256 ) -> Result<ChannelData>

Returns the channel details.

source

pub async fn chain_id(&self, block: H256) -> Result<ChainID>

Returns the chain ID indicated by contract.

source

pub async fn settlement_timeout_min(&self, block: H256) -> Result<SettleTimeout>

Returns the minimum settlement timeout.

source

pub async fn settlement_timeout_max(&self, block: H256) -> Result<SettleTimeout>

Returns the maximum settlement timeout.

source

pub async fn token_network_deposit_limit(&self, block: H256) -> Result<U256>

Returns the token network total deposit limit.

source

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.

Trait Implementations§

source§

impl<T: Clone + Transport> Clone for TokenNetworkProxy<T>

source§

fn clone(&self) -> TokenNetworkProxy<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TokenNetworkProxy<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for TokenNetworkProxy<T>

§

impl<T> Send for TokenNetworkProxy<T>
where T: Send,

§

impl<T> Sync for TokenNetworkProxy<T>
where T: Sync,

§

impl<T> Unpin for TokenNetworkProxy<T>
where T: Unpin,

§

impl<T> !UnwindSafe for TokenNetworkProxy<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.