Skip to content

Support connection from smart wallets #416

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

Merged
merged 2 commits into from
Mar 16, 2021
Merged

Conversation

pacwoodson
Copy link
Member

Trying to fix #413

As this does change the backend, preview will not be working here.

Smart wallets use a different mechanism when signing messages. See https://docs.argent.xyz/wallet-connect-and-argent

This implementation works with Argent, but may not work with other wallets which doesn't implement the EIP in the same fashion.

The biggest problem here is that the authentication hook, which is called everytime there is a request on hasura, has to query on-chain information (contract code + verify signature), which will slow down a lot execution times. Auth hooks must be super-fast.

The mechanism we have setup previously only required to verify a signature off-chain, which is not super cheap but neither super expensive. Now we're going through async requests on infura nodes ... But has the advantage to be trust-less, with the user self-signing tokens.

We have to lookup for better solutions to be able to authenticate in a DID (decentralized-identity) way, without lags on requests. Maybe IDX will provide something better for that. At the moment I don't see any faster way of doing it apart from the traditional centralized JWS mechanism.

@vercel
Copy link

vercel bot commented Mar 16, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

the-game – ./packages/web

🔍 Inspect: https://vercel.com/metafam/the-game/BVRoiR6YbDW7XFJC22tyduwxHt6V
✅ Preview: https://the-game-git-feat-smart-wallets-metafam.vercel.app

[Deployment for d820fc7 failed]

testing-the-game – ./packages/web

🔍 Inspect: https://vercel.com/metafam/testing-the-game/4tLeEmU1nvaU7bxEN73wM83e4rHb
✅ Preview: Failed

[Deployment for d820fc7 failed]

@pacwoodson pacwoodson added backend Backend related issues frontend Front end related issues / features WIP labels Mar 16, 2021

return returnValue;
}
throw new Error('unsupported wallet type');
Copy link
Member

Choose a reason for hiding this comment

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

This code is unreachable.
Instead do you think we should wrap the previous logic in a try catch and throw 'unsupported wallet type' if something throws inside?
I say this because (as you have mentioned) other smart wallets will have non-0x code but may not always support isValidSignature.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, this condition is here because I started to use the argent-sdk which returns a specific type for argent.

I'll correct this. But I was more asking for help on the bigger picture, see the PR main post ;)

Copy link
Member

Choose a reason for hiding this comment

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

Yes I've shared my thoughts below :)

const hexArray = utils.arrayify(hexMessage);
const hashMessage = utils.hashMessage(hexArray);

const contract = new Contract(address, smartWalletABI, provider);
Copy link
Member

Choose a reason for hiding this comment

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

This also throws sometimes if the contract doesn't support the ABI, and should be inside the try-catch

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure about this ? It is a constructor, so it's sync, so I don't think it can go check the contract code and throw here

Copy link
Member

Choose a reason for hiding this comment

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

True. I've had some issues with ethersJS sometimes though. But never mind. Lets go ahead with this

Copy link
Member

@dan13ram dan13ram left a comment

Choose a reason for hiding this comment

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

Just a small change, otherwise looks good!

In general, its great that we are supporting smart-wallets! 🤓️

Regarding supporting other wallets: It will be tedious to support every kind of wallet out there. We can strive to support standards only such as eip-1271 in this case.

Regarding the issue of speed: The speed issue appears only in the case of smart-wallets, and imo this is a trade-off the user is bearing vs the added security that they gain by the use of smart-contract wallets.

@pacwoodson
Copy link
Member Author

Regarding supporting other wallets: It will be tedious to support every kind of wallet out there. We can strive to support standards only such as eip-1271 in this case.
We'd have to list the wallet we want to support and track their implementation. For now, the only ones I know supporting EIP 1271 are Pillar and Argent. Gnosis Safe talks about it in their doc, but their code throws 'unsupported'.

Regarding the issue of speed: The speed issue appears only in the case of smart-wallets, and imo this is a trade-off the user is bearing vs the added security that they gain by the use of smart-contract wallets.

If you feel it's not a problem to have long query time, lets go for it, but we may have to find some trick later ...

@dan13ram
Copy link
Member

If you feel it's not a problem to have long query time, lets go for it, but we may have to find some trick later ...

Correct me if I'm wrong but this long query time is only in case of smart-wallets, which were rendered useless earlier?
Now with these changes, atleast the users can login albeit with a delay; which imo is better than not being able to login.

We can create a separate issue to research this and find a better solution if-need-be in the future. Along with that maybe we could do some user testing or a survey to find out how many of our users really use smart-wallets and how many of them have an issue with the delay.

@pacwoodson
Copy link
Member Author

Correct me if I'm wrong but this long query time is only in case of smart-wallets, which were rendered useless earlier?

Yes the delay will only happen for users logged in with smart wallet, but will apply to every request they will do.

Lets go for this and see how we can do better later

@pacwoodson pacwoodson merged commit a02d864 into master Mar 16, 2021
@pacwoodson pacwoodson deleted the feat/smart-wallets branch March 16, 2021 13:42
alalonde pushed a commit that referenced this pull request Mar 29, 2021
* Support connection from smart wallets

* Fix unreachable code
lucidcyborg pushed a commit that referenced this pull request Mar 29, 2021
* Support connection from smart wallets

* Fix unreachable code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related issues frontend Front end related issues / features WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MyMeta] Fix connection from smart wallets
2 participants