Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: link mode #5141

Merged
merged 59 commits into from
Sep 6, 2024
Merged

feat: link mode #5141

merged 59 commits into from
Sep 6, 2024

Conversation

ignaciosantise
Copy link
Contributor

@ignaciosantise ignaciosantise commented Jul 2, 2024

Description

  • Enable link-mode for mobile dapps/wallets
  • Reworked relayer to start wss connection only when required i.e. topics present in storage

TODO: cleanup logs before merging

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

Tested in RN sample dapp and wallet

Checklist

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Additional Information (Optional)

Please include any additional information that may be useful for the reviewer.

Copy link
Member

@ganchoradkov ganchoradkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking lit! writing down my initial thoughts, will dig more 💯

packages/utils/src/crypto.ts Outdated Show resolved Hide resolved
packages/utils/src/crypto.ts Outdated Show resolved Hide resolved
packages/types/src/sign-client/engine.ts Outdated Show resolved Hide resolved
packages/sign-client/src/controllers/engine.ts Outdated Show resolved Hide resolved
@ignaciosantise ignaciosantise marked this pull request as ready for review August 2, 2024 20:18
@ignaciosantise ignaciosantise marked this pull request as draft August 2, 2024 20:18
Copy link
Contributor

@Cali93 Cali93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments but very good job 💪

packages/core/src/controllers/crypto.ts Outdated Show resolved Hide resolved
packages/core/src/controllers/relayer.ts Outdated Show resolved Hide resolved
Comment on lines +242 to +249
if (transportType === TRANSPORT_TYPES.link_mode) {
setTimeout(() => {
if (this.relayer.connected || this.relayer.connecting) {
this.relayer.request(request).catch((e) => this.logger.warn(e));
}
}, toMiliseconds(ONE_SECOND));
return subId;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kind of delay really needed ? Wouldn't this add a 1 second delay in every case (even if airplane mode is off).

On another note we should clear the timeout.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this add a 1 second delay in every case (even if airplane mode is off).

with link mode, yes but it doesn't cause any issues as we need sometime for the react-native netinfo to register network changes when the app is back in foreground

On another note we should clear the timeout.

why? there isn't a case where the timeout has to be stopped mid execution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with link mode, yes but it doesn't cause any issues as we need sometime for the react-native netinfo to register network changes when the app is back in foreground

Ideally we should detect when this operation is needed instead of having the delay in every situation but I understand it's probably not trivial.

why? there isn't a case where the timeout has to be stopped mid execution

It's just a good practice I've been used to because of React development.

From Chat GPT

Using clearTimeout is not strictly necessary every time you use setTimeout, but there are specific situations where it is beneficial or required:

Preventing Unwanted Execution: If there's a possibility that the action scheduled with setTimeout should not occur in certain conditions (for example, if the user navigates away from a page or a component is unmounted), then you should clear the timeout to prevent the action from executing when it's no longer needed or relevant.

Memory Leaks: In React components or other dynamic UI environments, not clearing timeouts can lead to memory leaks. If a timeout is set on a component and the component is unmounted before the timeout fires, the callback function may still be executed, which can lead to errors or unintended behavior, especially if the callback modifies component state.

Resource Management: Timers hold onto resources until they execute. Clearing them when no longer needed frees up these resources, which is beneficial for performance, especially in environments with limited resources like mobile devices.

Control Over Asynchronous Actions: In complex applications where multiple timeouts might be set and their behavior could overlap or interfere with each other, managing timeouts with clearTimeout ensures that only the desired timers are running at any given time.

packages/utils/src/crypto.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Cali93 Cali93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one Nacho 💪

@ganchoradkov ganchoradkov merged commit 3f74884 into v2.0 Sep 6, 2024
3 checks passed
@ganchoradkov ganchoradkov deleted the feat/link-mode branch September 6, 2024 09:15
github-merge-queue bot referenced this pull request in valora-inc/wallet Sep 10, 2024
…^2.16.0 (#5951)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@walletconnect/react-native-compat](https://redirect.github.com/walletconnect/walletconnect-monorepo)
| [`^2.15.2` ->
`^2.16.0`](https://renovatebot.com/diffs/npm/@walletconnect%2freact-native-compat/2.15.2/2.16.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@walletconnect%2freact-native-compat/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@walletconnect%2freact-native-compat/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@walletconnect%2freact-native-compat/2.15.2/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@walletconnect%2freact-native-compat/2.15.2/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>walletconnect/walletconnect-monorepo
(@&#8203;walletconnect/react-native-compat)</summary>

###
[`v2.16.0`](https://redirect.github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.16.0)

[Compare
Source](https://redirect.github.com/walletconnect/walletconnect-monorepo/compare/2.15.3...2.16.0)

#### What's Changed

- chore: prep for 2.15.3 release by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5331](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5331)
- feat: link mode by
[@&#8203;ignaciosantise](https://redirect.github.com/ignaciosantise) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5141](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5141)

**Full Changelog**:
WalletConnect/walletconnect-monorepo@2.15.3...2.16.0

###
[`v2.15.3`](https://redirect.github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.15.3)

[Compare
Source](https://redirect.github.com/walletconnect/walletconnect-monorepo/compare/2.15.2...2.15.3)

#### What's Changed

- chore: prep for `2.15.2` release by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5319](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5319)
- Fix getVerifyContext when onSessionAuthenticateRequest by
[@&#8203;quetool](https://redirect.github.com/quetool) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5324](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5324)
- fix: avoid deeplinking if document isn't in focus by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5229](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5229)
- fix: enforces origin url to be verified to produce verify context by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5327](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5327)
- feat: auto publish to npm by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5202](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5202)

**Full Changelog**:
WalletConnect/walletconnect-monorepo@2.15.2...2.15.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsibnBtIiwicmVub3ZhdGUiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <valorabot@valoraapp.com>
github-merge-queue bot referenced this pull request in valora-inc/wallet Sep 10, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@walletconnect/utils](https://redirect.github.com/walletconnect/walletconnect-monorepo)
| [`^2.15.2` ->
`^2.16.0`](https://renovatebot.com/diffs/npm/@walletconnect%2futils/2.15.2/2.16.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@walletconnect%2futils/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@walletconnect%2futils/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@walletconnect%2futils/2.15.2/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@walletconnect%2futils/2.15.2/2.16.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>walletconnect/walletconnect-monorepo
(@&#8203;walletconnect/utils)</summary>

###
[`v2.16.0`](https://redirect.github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.16.0)

[Compare
Source](https://redirect.github.com/walletconnect/walletconnect-monorepo/compare/2.15.3...2.16.0)

#### What's Changed

- chore: prep for 2.15.3 release by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5331](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5331)
- feat: link mode by
[@&#8203;ignaciosantise](https://redirect.github.com/ignaciosantise) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5141](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5141)

**Full Changelog**:
WalletConnect/walletconnect-monorepo@2.15.3...2.16.0

###
[`v2.15.3`](https://redirect.github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.15.3)

[Compare
Source](https://redirect.github.com/walletconnect/walletconnect-monorepo/compare/2.15.2...2.15.3)

#### What's Changed

- chore: prep for `2.15.2` release by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5319](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5319)
- Fix getVerifyContext when onSessionAuthenticateRequest by
[@&#8203;quetool](https://redirect.github.com/quetool) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5324](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5324)
- fix: avoid deeplinking if document isn't in focus by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5229](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5229)
- fix: enforces origin url to be verified to produce verify context by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5327](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5327)
- feat: auto publish to npm by
[@&#8203;ganchoradkov](https://redirect.github.com/ganchoradkov) in
[https://github.com/WalletConnect/walletconnect-monorepo/pull/5202](https://redirect.github.com/WalletConnect/walletconnect-monorepo/pull/5202)

**Full Changelog**:
WalletConnect/walletconnect-monorepo@2.15.2...2.15.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsibnBtIiwicmVub3ZhdGUiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jean Regisser <jean.regisser@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants