Skip to content

Commit

Permalink
sdk: small fix to allow LC to start on registries without TNs
Browse files Browse the repository at this point in the history
If starting with userDepositContractAddress as contract's entrypoint,
it'd crash if the `TokenNetworkRegistry` didn't have any registered
`TokenNetwork`. This fix allows the client to start, so one can use
`registerToken` to register a TN from this session.
  • Loading branch information
andrevmatos committed Oct 11, 2021
1 parent e6ee970 commit d35310c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions raiden-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
- [#2965] Remove `options.subkey` on certain `Raiden` public methods; if you need to force subkey or main account usage for single txs, set `config.subkey` then reset after tx is sent; default behavior is kept

### Fixed
- [#2913] Fix crash when starting client with `userDepositContractAddress` as contracts entrypoint on a `TokenNetworkRegistry` with no registered tokens yet
- [#2963] Don't set channel as `closing` upon `channelClose.request`, allowing user to cancel Metamask's prompt and keep an usable channel; Channel becomes `closing` only after tx is sent

[#2913]: https://github.com/raiden-network/light-client/issues/2913
[#2949]: https://github.com/raiden-network/light-client/issues/2949
[#2952]: https://github.com/raiden-network/light-client/issues/2952
[#2953]: https://github.com/raiden-network/light-client/pull/2953
Expand Down
4 changes: 2 additions & 2 deletions raiden-ts/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ export async function fetchContractsInfo(
const serviceRegistry = (await monitoringServiceContract.service_registry()) as Address;

const toBlock = await provider.getBlockNumber();
let firstBlock = await firstValueFrom(
const firstBlock = await firstValueFrom(
getLogsByChunk$(provider, {
...tokenNetworkRegistryContract.filters.TokenNetworkCreated(null, null),
fromBlock: 1,
toBlock,
}).pipe(pluck('blockNumber'), filter(isntNil)),
{ defaultValue: toBlock },
);
firstBlock ??= 0;

const oneToN = (await userDepositContract.one_to_n_address()) as Address;

Expand Down

0 comments on commit d35310c

Please sign in to comment.