Set the `total_deposit` in the channel with the peer at `partner_address` and the given `token_address` in order to be able to do transfers. Raises: InvalidBinaryAddress: If either token_address or partner_address is not 20 bytes long. RaidenR
(
self,
registry_address: TokenNetworkRegistryAddress,
token_address: TokenAddress,
partner_address: Address,
total_deposit: TokenAmount,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
)
| 613 | ) |
| 614 | |
| 615 | def set_total_channel_deposit( |
| 616 | self, |
| 617 | registry_address: TokenNetworkRegistryAddress, |
| 618 | token_address: TokenAddress, |
| 619 | partner_address: Address, |
| 620 | total_deposit: TokenAmount, |
| 621 | retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT, |
| 622 | ) -> None: |
| 623 | """Set the `total_deposit` in the channel with the peer at `partner_address` and the |
| 624 | given `token_address` in order to be able to do transfers. |
| 625 | |
| 626 | Raises: |
| 627 | InvalidBinaryAddress: If either token_address or partner_address is not |
| 628 | 20 bytes long. |
| 629 | RaidenRecoverableError: May happen for multiple reasons: |
| 630 | - If the token approval fails, e.g. the token may validate if |
| 631 | account has enough balance for the allowance. |
| 632 | - The deposit failed, e.g. the allowance did not set the token |
| 633 | aside for use and the user spent it before deposit was called. |
| 634 | - The channel was closed/settled between the allowance call and |
| 635 | the deposit call. |
| 636 | AddressWithoutCode: The channel was settled during the deposit |
| 637 | execution. |
| 638 | DepositOverLimit: The total deposit amount is higher than the limit. |
| 639 | UnexpectedChannelState: The channel is no longer in an open state. |
| 640 | """ |
| 641 | chain_state = views.state_from_raiden(self.raiden) |
| 642 | |
| 643 | token_addresses = views.get_token_identifiers(chain_state, registry_address) |
| 644 | channel_state = views.get_channelstate_for( |
| 645 | chain_state=chain_state, |
| 646 | token_network_registry_address=registry_address, |
| 647 | token_address=token_address, |
| 648 | partner_address=partner_address, |
| 649 | ) |
| 650 | |
| 651 | if not is_binary_address(token_address): |
| 652 | raise InvalidBinaryAddress( |
| 653 | "Expected binary address format for token in channel deposit" |
| 654 | ) |
| 655 | |
| 656 | if not is_binary_address(partner_address): |
| 657 | raise InvalidBinaryAddress( |
| 658 | "Expected binary address format for partner in channel deposit" |
| 659 | ) |
| 660 | |
| 661 | if token_address not in token_addresses: |
| 662 | raise UnknownTokenAddress("Unknown token address") |
| 663 | |
| 664 | if channel_state is None: |
| 665 | raise NonexistingChannel("No channel with partner_address for the given token") |
| 666 | |
| 667 | confirmed_block_identifier = chain_state.block_hash |
| 668 | token = self.raiden.proxy_manager.token( |
| 669 | token_address, block_identifier=confirmed_block_identifier |
| 670 | ) |
| 671 | token_network_registry = self.raiden.proxy_manager.token_network_registry( |
| 672 | registry_address, block_identifier=confirmed_block_identifier |