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
chore: add needed packages for WalletConnect implementation #19758
Conversation
a0bdb3b
to
c3d6dfe
Compare
Jenkins BuildsClick to see older builds (32)
|
c3d6dfe
to
0c8ad7a
Compare
[] | ||
(let [core (wallet-connect-core) | ||
metadata (clj->js config/default-wallet-connect-metadata)] | ||
(promesa/create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clauxx - looks good here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks weird. If Web3Wallet.init already returns a promise, there's no need to create another promise with promesa/create
. Just return the promise and it would be handled in the effect it's called from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clauxx makes sense, I'll modify it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata can be moved to a (defonce metadata #js {...})
.
It never changes so clj->js is redundant.
src/status_im/config.cljs
Outdated
"Status is a secure messaging app, crypto wallet, and Web3 browser built with state of the art technology." | ||
:url "https://status.app" | ||
:icons | ||
["https://res.cloudinary.com/dhgck7ebz/image/upload/f_auto,c_limit,w_1080,q_auto/Brand/Logo%20Section/Mark/Mark_01"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the formatting looks weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted it from our website just to provide some values, but we can update it later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to care about translations here ? Should we wrap description in (i18n)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a change, but is it possible to pass icon from disk rather than a link?
What if the infra team stops using Cloudinary tomorrow ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a change, but is it possible to pass icon from disk rather than a link? What if the infra team stops using Cloudinary tomorrow ?
From all examples I've seen, only urls are passed for icons. I think we could do some research and update this part in a follow up in case it is needed. Also copies should be temporal, we should get better ones from the marketing or design team ultimately.
@@ -0,0 +1,21 @@ | |||
(ns status-im.contexts.wallet.common.utils.wallet-connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about having the wallet-connect stuff in its own namespace e.g. status-im.contexts.wallet.wallet-connect
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it 👍
[] | ||
(let [core (wallet-connect-core) | ||
metadata (clj->js config/default-wallet-connect-metadata)] | ||
(promesa/create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks weird. If Web3Wallet.init already returns a promise, there's no need to create another promise with promesa/create
. Just return the promise and it would be handled in the effect it's called from.
|
||
(defn- wallet-connect-core | ||
[] | ||
(Core. (clj->js {:project-id config/wallet-connect-project-id}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we going to have a different project-id for testnet mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be the same project id, we should just connect to different chains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move the {:project-id ...}
to a defonce
with #js
. clj->js
is redundant because project id is static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/status_im/config.cljs
Outdated
(def default-wallet-connect-metadata | ||
{:name "Status" | ||
:description | ||
"Status is a secure messaging app, crypto wallet, and Web3 browser built with state of the art technology." | ||
:url "https://status.app" | ||
:icons | ||
["https://res.cloudinary.com/dhgck7ebz/image/upload/f_auto,c_limit,w_1080,q_auto/Brand/Logo%20Section/Mark/Mark_01"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if makes sense to keep it in the config. Doesn't look like something that will be used outside the initialisation from status-im.contexts.wallet.common.utils.wallet-connect
and might be easier to just keep them together.
src/status_im/config.cljs
Outdated
@@ -36,6 +37,7 @@ | |||
(def goerli-chain-explorer-link "https://goerli.etherscan.io/address/") | |||
(def optimism-goerli-chain-explorer-link "https://goerli-optimistic.etherscan.io/address/") | |||
(def opensea-api-key OPENSEA_API_KEY) | |||
(def wallet-connect-project-id WALLET_CONNECT_PROJECT_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we do this but we can use the WALLET_CONNECT_PROJECT_ID
directly in other places.
@@ -0,0 +1,21 @@ | |||
(ns status-im.contexts.wallet.common.utils.wallet-connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. 👍
(promesa/create | ||
(fn [p-resolve p-reject] | ||
(-> (Web3Wallet.init | ||
(clj->js {:core core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@briansztamfater, a few suggestions for this namespace:
- The code
(clj->js {:project-id config/wallet-connect-project-id})
can be changed to#js {:project-id config/WALLET_CONNECT_PROJECT_ID}
. I tend to prefer the#js
literal for small, non-nested maps because it's significantly faster thanclj->js
. Theinit
function will be called once, so it won't be a problem, but sharing as a reminder that we should be mindful ofclj->js
. - I would make
default-wallet-connect-metadata
a private var in this namespace and remove it fromstatus-im.config
because the map doesn't depend on any value coming from an external env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 👍
|
||
(defn- wallet-connect-core | ||
[] | ||
(Core. (clj->js {:project-id config/wallet-connect-project-id}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure the option is in kebab-case? Here https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/core/src/core.ts#L67 I see there it should be projectId
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/status_im/config.cljs
Outdated
"Status is a secure messaging app, crypto wallet, and Web3 browser built with state of the art technology." | ||
:url "https://status.app" | ||
:icons | ||
["https://res.cloudinary.com/dhgck7ebz/image/upload/f_auto,c_limit,w_1080,q_auto/Brand/Logo%20Section/Mark/Mark_01"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to care about translations here ? Should we wrap description in (i18n)
?
src/status_im/config.cljs
Outdated
"Status is a secure messaging app, crypto wallet, and Web3 browser built with state of the art technology." | ||
:url "https://status.app" | ||
:icons | ||
["https://res.cloudinary.com/dhgck7ebz/image/upload/f_auto,c_limit,w_1080,q_auto/Brand/Logo%20Section/Mark/Mark_01"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a change, but is it possible to pass icon from disk rather than a link?
What if the infra team stops using Cloudinary tomorrow ?
|
||
(defn- wallet-connect-core | ||
[] | ||
(Core. (clj->js {:project-id config/wallet-connect-project-id}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move the {:project-id ...}
to a defonce
with #js
. clj->js
is redundant because project id is static.
[] | ||
(let [core (wallet-connect-core) | ||
metadata (clj->js config/default-wallet-connect-metadata)] | ||
(promesa/create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata can be moved to a (defonce metadata #js {...})
.
It never changes so clj->js is redundant.
0c8ad7a
to
e223a4f
Compare
05f8ffd
to
2d95457
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @briansztamfater! Looks good!
@siddarthkay is everything good dependency-wise here?
It was the last time I had looked at it. |
Hmm Indeed entries are missing from @briansztamfater : please could you run |
@siddarthkay @jakubgs pushed changes from Also @shivekkhurana can you re-review? |
a9a21f3
to
0a2d615
Compare
I'm okay with this PR except for this comment: |
["@walletconnect/web3wallet" :refer [Web3Wallet]] | ||
[status-im.config :as config])) | ||
|
||
(defonce ^:private wallet-connect-metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@briansztamfater @shivekkhurana defonce
shouldn't be used in a case like this. As far as I've seen, defonce
is basically a tool to help devs take control in the REPL of when side-effects should happen. A common example in the wild is to initialize global atoms, as in (defonce foo (atom :bar))
.
There's no side-effect to evaluate wallet-connect-metadata
(ignoring memory allocation could fail in a parallel universe), hence just def
is sufficient. In fact, when I see defonce
, I instantly search for the line of code with side-effects to understand why it's being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I added translated strings, so probably defn
is a better choice than def
because language could change while the app is active 🤔 wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question @briansztamfater. I have the impression our app doesn't react to system language changes and thus, requires a full restart. This means it's okay to use def
and not worry about reactiveness. Not saying this is the best approach, but it's how I see our app behaving now.
Note: on emulated Android, when the whole system language changes, even after a full app restart it doesn't pick up the correct language and English is still seen everywhere. Maybe this is a problem deserving investigation in the near future.
8cb0e38
to
7f2a1c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Can be merged I guess as it doesn't affect any existing functionality 👍
@shivekkhurana can you give it a re-review when you have the chance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know WalletConnect project ID is not a secret.
@clauxx if Project ID was a key it would be called a Project Key. |
@jakubgs can't say about their naming consistency, but they advise hiding the "project keys" on the same page they introduce the Project ID, while "project keys" are not mentioned anywhere else in their documentation. Didn't look too much into it, but I'd rather be on the safer side and hide it. |
75% of end-end tests have passed
Failed tests (11)Click to expandClass TestDeepLinksOneDevice:
Class TestWalletMultipleDevice:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestWalletOneDevice:
Class TestActivityCenterContactRequestMultipleDevicePR:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestCommunityMultipleDeviceMerged:
Class TestActivityMultipleDevicePR:
Expected to fail tests (2)Click to expandClass TestGroupChatMultipleDeviceMergedNewUI:
Class TestCommunityOneDeviceMerged:
Passed tests (39)Click to expandClass TestCommunityMultipleDeviceMergedTwo:
Class TestActivityMultipleDevicePR:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestCommunityOneDeviceMerged:
Class TestActivityCenterContactRequestMultipleDevicePR:
Class TestGroupChatMultipleDeviceMergedNewUI:
Class TestCommunityMultipleDeviceMerged:
Class TestActivityMultipleDevicePRTwo:
Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:
|
Signed-off-by: Brian Sztamfater <[email protected]>
c96818c
to
6d7e7f9
Compare
This PR adds WalletConnect Web3Wallet library and required additional libraries as their documentation describes. Also defines
WALLET_CONNECT_PROJECT_ID
key for env var and a basic utils file to creating a Web3Wallet instance. Manual QA can be skipped, no new features nor bug fixes are included in this PR, we just need to make sure new packages don't make the app to crash.Also not sure if I am making correct use of promesa so feedback is appreciated.
status: ready