Skip to content

Use cached wallet_getCapabilities #542

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 3 commits into from
Apr 24, 2024
Merged

Conversation

KannuSingh
Copy link
Contributor

@KannuSingh KannuSingh commented Apr 23, 2024

Action wallet_getCapabilities will return cached data from session.sessioProperties if present else it will send a call to wallet to get the capabilities.

Added RequestLoaderModal.tsx for waiting for request to get fulfil from the wallet, this modal have different display message, RequestModal can be refactored to support both, but for simplicity created a separate modal to handle request which don't need a user action

Removed hardcoded userOperation hash value in wallet_getCallsStatus to the value returned from last successful call to wallet_sendCalls
Action wallet_getCapabilities will return cached data from session.sessioProperties if present else it will send a call to wallet to get the capabilities.

Added RequestLoaderModal.tsx for waiting for request to get fulfil from the wallet, this modal have different message, RequestModal can be refactored to support both, but for simplicity created a separate modal to handle request which don't need a user action
Copy link

vercel bot commented Apr 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
decentralized-relay-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 1:38pm
malicious-dapp-verify-simulation ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 1:38pm
react-dapp-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 1:38pm
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
decentralized-relay-wallet ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-auth-dapp ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-auth-wallet ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-dapp-v2-cosmos-provider ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-dapp-v2-with-ethers ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-dapp-v2-with-web3js ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
react-wallet-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
svelte-web3modal ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm
vue-dapp-auth ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 1:38pm

Copy link
Contributor

@arein arein left a comment

Choose a reason for hiding this comment

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

The wallet_getCapabilities "caching" should ultimately move into the provider. No concern with this PR but @KannuSingh can you leave a comment in the code reminding us to clean up after it's done.

@ganchoradkov the ERC is in review now. When do you think is the right time to move this logic into the provider?

@@ -0,0 +1,52 @@
import * as React from "react";
Copy link
Contributor

Choose a reason for hiding this comment

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

looks very similar to the old one - why a new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its just some text changes on the modal, it don't need any approval or reject action on wallet side.
I can refactor the old one to take these messages as props.

@arein arein requested a review from bkrem April 24, 2024 04:10
@@ -518,15 +518,21 @@ export function JsonRpcContextProvider({
}

const params = [address]
// check the session.sessioProperties first for capabilities
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// check the session.sessioProperties first for capabilities
// check the session.sessionProperties first for capabilities

@@ -548,8 +554,9 @@ export function JsonRpcContextProvider({
`Missing rpcProvider definition for chainId: ${chainId}`
);
}
if(lastTxId == undefined) throw new Error(`Last transaction id ${lastTxId}, make sure call to sendCalls returns successfully. `);
//hardcoded valid userOpHash
Copy link
Member

Choose a reason for hiding this comment

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

No longer hardcoded based on the change (I presume)

Suggested change
//hardcoded valid userOpHash

@@ -548,8 +554,9 @@ export function JsonRpcContextProvider({
`Missing rpcProvider definition for chainId: ${chainId}`
);
}
if(lastTxId == undefined) throw new Error(`Last transaction id ${lastTxId}, make sure call to sendCalls returns successfully. `);
Copy link
Member

Choose a reason for hiding this comment

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

Better to use === strict comparison here if the possible values are string | undefined

Suggested change
if(lastTxId == undefined) throw new Error(`Last transaction id ${lastTxId}, make sure call to sendCalls returns successfully. `);
if (lastTxId === undefined) throw new Error(`Last transaction ID is undefined, make sure previous call to sendCalls returns successfully. `);

@KannuSingh KannuSingh merged commit 704e55b into main Apr 24, 2024
15 checks passed
@KannuSingh KannuSingh deleted the use-cached-wallet_getCapabilities branch April 24, 2024 14:11
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