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

Add wallet_getAssets support + Chain Abstraction demo changes #816

Merged
merged 25 commits into from
Feb 17, 2025

Conversation

KannuSingh
Copy link
Collaborator

  • Add support for wallet_getAssets rpc on sample wallet service
  • Add changes to Chain Abstraction demo to use wallet_getAssets

Copy link

vercel bot commented Feb 3, 2025

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

Name Status Preview Comments Updated (UTC)
smart-sessions-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 17, 2025 7:34am
17 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-react-ethersv5 ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
appkit-react-wagmi-example ⬜️ Ignored (Inspect) Feb 17, 2025 7:34am
appkit-solana ⬜️ Ignored (Inspect) Feb 17, 2025 7:34am
chain-abstraction-demo ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
decentralized-relay-app ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
decentralized-relay-wallet ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
malicious-dapp-verify-simulation ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-auth-dapp ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-auth-wallet ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-dapp-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-dapp-v2-cosmos-provider ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-dapp-v2-with-ethers ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-dapp-v2-with-web3js ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
react-wallet-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
svelte-web3modal ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
vue-dapp-auth ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am
vue-web-examples ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 7:34am

Copy link

cloudflare-workers-and-pages bot commented Feb 5, 2025

Deploying demo-ai-agents with  Cloudflare Pages  Cloudflare Pages

Latest commit: bb1446f
Status: ✅  Deploy successful!
Preview URL: https://92cdb92d.demo-ai-agents.pages.dev
Branch Preview URL: https://feat-wallet-getassets.demo-ai-agents.pages.dev

View logs

};

// WalletConnect specific functions
const getWalletConnectAssets = async (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this walletconnect specific or CAIP-25 specific?

Comment on lines 137 to 159
// Embedded Wallet specific functions
const getEmbeddedWalletAssets = async (
walletProvider: UniversalProvider,
request: WalletAssetRequest,
chainIdAsHex: Hex,
address: string
): Promise<Record<Hex, Asset[]>[]> => {
const capabilities = await walletProvider.request({
method: "wallet_getCapabilities",
params: [address]
}) as Capabilities;

if (!capabilities[chainIdAsHex]?.assetDiscovery?.supported) {
throw new Error("Wallet does not support wallet_getAssets");
}

const response = await walletProvider.request({
method: "wallet_getAssets",
params: [request],
}) as Record<Hex, Asset[]>;

return [response];
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this specific to our embedded wallet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

need to rename the method, its not specific to Embedded wallet.

Comment on lines 177 to 180
const assetsResponse = await (walletProviderType === "WALLET_CONNECT"
? getWalletConnectAssets(walletProvider, request, chainIdAsHex, projectId!)
: getEmbeddedWalletAssets(walletProvider, request, chainIdAsHex, address)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if I connect with browser extension wallet for example?

};
}

async function aggregateERC20Balances(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we doing this dapp side?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is in the react-wallet

@KannuSingh KannuSingh merged commit d16f84e into main Feb 17, 2025
22 checks passed
@KannuSingh KannuSingh deleted the feat/wallet_getAssets branch February 17, 2025 07:35
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.

3 participants