MCPcopy Index your code
hub / github.com/raiden-network/raiden / token_network_register

Method token_network_register

raiden/api/python.py:265–323  ·  view source on GitHub ↗

Register the `token_address` in the blockchain. If the address is already registered but the event has not been processed this function will block until the next block to make sure the event is processed. Raises: InvalidBinaryAddress: If the registry_addres

(
        self,
        registry_address: TokenNetworkRegistryAddress,
        token_address: TokenAddress,
        channel_participant_deposit_limit: TokenAmount,
        token_network_deposit_limit: TokenAmount,
        retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
    )

Source from the content-addressed store, hash-verified

263 return channel_list[0]
264
265 def token_network_register(
266 self,
267 registry_address: TokenNetworkRegistryAddress,
268 token_address: TokenAddress,
269 channel_participant_deposit_limit: TokenAmount,
270 token_network_deposit_limit: TokenAmount,
271 retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
272 ) -> TokenNetworkAddress:
273 """Register the `token_address` in the blockchain. If the address is already
274 registered but the event has not been processed this function will block
275 until the next block to make sure the event is processed.
276
277 Raises:
278 InvalidBinaryAddress: If the registry_address or token_address is not a valid address.
279 AlreadyRegisteredTokenAddress: If the token is already registered.
280 RaidenRecoverableError: If the register transaction failed, this may
281 happen because the account has not enough balance to pay for the
282 gas or this register call raced with another transaction and lost.
283 InvalidTokenAddress: If token_address is the null address (0x000000....00).
284 """
285
286 if not is_binary_address(registry_address):
287 raise InvalidBinaryAddress("registry_address must be a valid address in binary")
288
289 if not is_binary_address(token_address):
290 raise InvalidBinaryAddress("token_address must be a valid address in binary")
291
292 if token_address == NULL_ADDRESS_BYTES:
293 raise InvalidTokenAddress("token_address must be non-zero")
294
295 # The following check is on the same chain state as the
296 # `chainstate` variable defined below because the chain state does
297 # not change between this line and seven lines below.
298 # views.state_from_raiden() returns the same state again and again
299 # as far as this gevent context is running.
300 if token_address in self.get_tokens_list(registry_address):
301 raise AlreadyRegisteredTokenAddress("Token already registered")
302
303 chainstate = views.state_from_raiden(self.raiden)
304
305 registry = self.raiden.proxy_manager.token_network_registry(
306 registry_address, block_identifier=chainstate.block_hash
307 )
308
309 _, token_network_address = registry.add_token(
310 token_address=token_address,
311 channel_participant_deposit_limit=channel_participant_deposit_limit,
312 token_network_deposit_limit=token_network_deposit_limit,
313 given_block_identifier=chainstate.block_hash,
314 )
315
316 waiting.wait_for_token_network(
317 raiden=self.raiden,
318 token_network_registry_address=registry_address,
319 token_address=token_address,
320 retry_timeout=retry_timeout,
321 )
322

Calls 6

get_tokens_listMethod · 0.95
InvalidTokenAddressClass · 0.90
add_tokenMethod · 0.80