Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

feat(ui): Introduce experimental walletconnect #952

Closed
wants to merge 11 commits into from

Conversation

NunoAlexandre
Copy link
Contributor

@NunoAlexandre NunoAlexandre commented Sep 23, 2020

Closes #940

In this branch, we introduce an experimental feature where we use walletconnect to connect an Eth wallet to the Upstream. This experiment lives under the Wallet section for now and allows us to connect by scanning a QR Code using a compatible wallet. We also introduce a dependency on the Radicle Contracts and a script to deploy them to a local blockchain instance.

When building/running, we see js warnings which I don't yet know how to solve which does not get in the way.
I am also seeing an issue with disconnecting from a connected wallet, where it seems that the underlying components don't quite expect to disconnect and a consecutive connecti attempt does nothing. This is ok for now and can be walked around by switching tabs, which creates a fresh wallet.

To give it a try, go to Wallet > Connect, use your preferred wallet and scan the QR Code the app shows. Once you approve the connection on your wallet, you should see your balance and address in the app. Try switching accounts from your wallet app to see how it reflects in the app.

@NunoAlexandre NunoAlexandre self-assigned this Sep 23, 2020
@NunoAlexandre NunoAlexandre added this to To Do in Funding via automation Sep 23, 2020
@NunoAlexandre NunoAlexandre added dependencies feature Something that doesn't exist yet labels Sep 23, 2020
@xla xla removed this from To Do in Funding Sep 23, 2020
@NunoAlexandre NunoAlexandre marked this pull request as ready for review September 23, 2020 12:49
Copy link
Member

@rudolfs rudolfs left a comment

Choose a reason for hiding this comment

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

As discussed with @NunoAlexandre on IRC: I would prefer if we leave this in a feature branch until we have a clearer plan on how the functionality will look like and it is a bit more polished.

I fear that the added clutter of warnings might prevent us from detecting actual problems in future pull-requests if this gets merged.

(!) Circular dependencies
node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js
node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js
node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js -> /Users/rudolfs/work/radicle-upstream-2/node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js?commonjs-proxy -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js
...and 13 more
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules/@ethersproject/properties/lib.esm/index.js
1: "use strict";
2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                    ^
3:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4:     return new (P || (P = Promise))(function (resolve, reject) {
...and 1 other occurrence
(!) Plugin inject: rollup-plugin-inject: failed to parse /Users/rudolfs/work/radicle-upstream-2/node_modules/eccrypto-js/node_modules/secp256k1/lib/messages.json. Consider restricting the plugin to particular files via options.include
node_modules/eccrypto-js/node_modules/secp256k1/lib/messages.json

"marked": "^1.1.1",
"pure-svg-code": "^1.0.6",
"radicle-contracts": "https://buildkite.com/organizations/monadic/pipelines/radicle-contracts/builds/72/jobs/e036d8ff-a6e5-4bf4-9d63-fd02bd297b2a/artifacts/b2ac2a23-6183-4219-ac35-1e36c444f7b2",
Copy link
Member

Choose a reason for hiding this comment

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

Is there a plan to publish the contracts somewhere in a stable location? I'm not sure how long these build artefacts are kept around...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not for now, but this is a stable location for the period we are concerned with. We can’t point to the GitHub project directly (i.e. yarn add https://github.com/radicle-dev/radicle-contracts.git) because we need to create build artefacts (compile TS and the contracts) and yarn doesn't do this for git dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should definitely publish an npm package though soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Installing from the git dependency should be possible with this yarnpkg/yarn#5235 (comment) in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Does that mean that if we had a .npmignore file to the Radicle Contracts that pointing to the git project should work?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIU yes as the issue seems to be that yarn cleans up the build artefacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will give it a shot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gave it a try but it doesn't work. the issue being that Yarn does not run prepack when installing Git dependencies

rollup.app.js Outdated Show resolved Hide resolved
scripts/deploy-dev-contracts.js Show resolved Hide resolved

async function main() {
const provider = new ethers.providers.JsonRpcProvider(
"http://localhost:8545"
Copy link
Member

Choose a reason for hiding this comment

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

Will this be user configurable at some point? Or will it always be hardcoded?

For hardcoded configuration variables we have src/config.ts, for everything user configurable we write the initial value to a kv store on disk and allow users to modify it later in the Settings screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that in the future this should point to the mainnet instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the script installing dev contracsts? Maybe some documentation would help explaining the utility of this script and what the expected workflow should look like. A lot of maintainers won't have much context to these changes otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a yarn command as suggested by @rudolfs and a corresponding (minimal) documentation on DEVELOPMENT.md. I'd prefer to not be more extensive now or else we might be documenting stuff that will change soon enough.

ui/Screen/Profile/Wallet.svelte Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
@NunoAlexandre NunoAlexandre changed the base branch from master to feat/funding September 23, 2020 18:40
@NunoAlexandre
Copy link
Contributor Author

As discussed with @NunoAlexandre on IRC: I would prefer if we leave this in a feature branch until we have a clearer plan on how the functionality will look like and it is a bit more polished.

I fear that the added clutter of warnings might prevent us from detecting actual problems in future pull-requests if this gets merged.

(!) Circular dependencies
node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js
node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js
node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js -> /Users/rudolfs/work/radicle-upstream-2/node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js?commonjs-proxy -> node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js
...and 13 more
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules/@ethersproject/properties/lib.esm/index.js
1: "use strict";
2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                    ^
3:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4:     return new (P || (P = Promise))(function (resolve, reject) {
...and 1 other occurrence
(!) Plugin inject: rollup-plugin-inject: failed to parse /Users/rudolfs/work/radicle-upstream-2/node_modules/eccrypto-js/node_modules/secp256k1/lib/messages.json. Consider restricting the plugin to particular files via options.include
node_modules/eccrypto-js/node_modules/secp256k1/lib/messages.json

Yes let's do that. Created feat/funding, to which this PR is now targeted.

ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
@sarahscott
Copy link
Contributor

Looks awesome so far 💯 ! In the interest of keeping things moving and not letting this feature branch diverge from master for too long, maybe we can aim to merge this in once the console error concerns are figured out.

@rudolfs
Copy link
Member

rudolfs commented Sep 24, 2020

maybe we can aim to merge this in once the console error concerns are figured out

That would be fine by me.

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

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

Extra dope!

take my money

"marked": "^1.1.1",
"pure-svg-code": "^1.0.6",
"radicle-contracts": "https://buildkite.com/organizations/monadic/pipelines/radicle-contracts/builds/72/jobs/e036d8ff-a6e5-4bf4-9d63-fd02bd297b2a/artifacts/b2ac2a23-6183-4219-ac35-1e36c444f7b2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Installing from the git dependency should be possible with this yarnpkg/yarn#5235 (comment) in mind.

inject({
modules: {
process: "_process",
Buffer: ["buffer", "Buffer"],
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 something one of the new dependencies needs, or is used by changes introduced in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added by Thomas fyi, and I believe that yes, it's necessary by some of the new dependencies. Will double-check.


async function main() {
const provider = new ethers.providers.JsonRpcProvider(
"http://localhost:8545"
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the script installing dev contracsts? Maybe some documentation would help explaining the utility of this script and what the expected workflow should look like. A lot of maintainers won't have much context to these changes otherwise.

"exclude": ["native/*", "node_modules/*", "public/*"],
"compilerOptions": {
"skipLibCheck": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain why this is a good config change for upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as #952 (comment)

ui/Screen/Profile/Wallet.svelte Outdated Show resolved Hide resolved
ui/Screen/Profile/Wallet.svelte Show resolved Hide resolved

type State =
| { status: Status.NotConnected }
| { status: Status.Connected; connected: Connected };
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a lot of connecting in this pr. 😆 It would be helpful to give at leas this field and type a different name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you have a suggestion? thought the same but name it Wallet doesn't help and could come up with a better name.

ui/src/wallet.ts Outdated Show resolved Hide resolved
ui/src/wallet.ts Outdated Show resolved Hide resolved
@rudolfs
Copy link
Member

rudolfs commented Sep 24, 2020

I tried to connect my mobile Metamask wallet. The connection seemed to work, but I don't see my balance, do I need to run some daemon locally (if so, how do I set that up)?

Screenshot 2020-09-24 at 12 59 51

Screenshot 2020-09-24 at 13 00 08

@NunoAlexandre
Copy link
Contributor Author

I tried to connect my mobile Metamask wallet. The connection seemed to work, but I don't see my balance, do I need to run some daemon locally (if so, how do I set that up)?

Screenshot 2020-09-24 at 12 59 51 Screenshot 2020-09-24 at 13 00 08

ah, that is right, sorry! This should answer all your getting started needs: https://www.notion.so/monadic/Spike-Walletconnect-on-Upstream-18a27328098845b091f25bf0b429a375

NunoAlexandre and others added 4 commits September 25, 2020 12:06
Co-Authored-By: geigerzaehler
Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
@NunoAlexandre
Copy link
Contributor Author

Superseded by #974

@geigerzaehler leave it up to you to close it since there are open discussions that'd be better addressed by you 👍

@geigerzaehler geigerzaehler deleted the walletconnect branch September 30, 2020 14:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Something that doesn't exist yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(ui): Integrate eth wallet using walletconnect
6 participants