Skip to content

Commit

Permalink
feat/wallet_getAssets rpc (#3797)
Browse files Browse the repository at this point in the history
Co-authored-by: tomiir <[email protected]>
  • Loading branch information
KannuSingh and tomiir authored Feb 5, 2025
1 parent 5900a70 commit 420cfe5
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion packages/appkit/src/connectors/WalletConnectConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,7 @@ const OPTIONAL_METHODS = [
'wallet_getCapabilities',
// EIP-7715
'wallet_grantPermissions',
'wallet_revokePermissions'
'wallet_revokePermissions',
//EIP-7811
'wallet_getAssets'
]
4 changes: 3 additions & 1 deletion packages/appkit/src/utils/HelpersUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const WcHelpersUtil = {
'wallet_getCallsStatus',
'wallet_grantPermissions',
'wallet_revokePermissions',
'wallet_switchEthereumChain'
'wallet_switchEthereumChain',
//EIP-7811
'wallet_getAssets'
]
case 'bip122':
return ['sendTransfer', 'signMessage', 'signPsbt', 'getAccountAddresses']
Expand Down
4 changes: 3 additions & 1 deletion packages/appkit/tests/mocks/UniversalProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const mockProvider = {
'wallet_getCallsStatus',
'wallet_grantPermissions',
'wallet_revokePermissions',
'wallet_switchEthereumChain'
'wallet_switchEthereumChain',
//EIP-7811
'wallet_getAssets'
],
rpcMap: {
'1': 'https://rpc.walletconnect.org/v1/?chainId=eip155%3A1&projectId=test-project-id'
Expand Down
3 changes: 2 additions & 1 deletion packages/appkit/tests/utils/HelpersUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ describe('WcHelpersUtil', () => {
'wallet_getCallsStatus',
'wallet_grantPermissions',
'wallet_revokePermissions',
'wallet_switchEthereumChain'
'wallet_switchEthereumChain',
'wallet_getAssets'
])
})

Expand Down
4 changes: 3 additions & 1 deletion packages/wallet/src/W3mFrameConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export const W3mFrameRpcConstants = {
'eth_getUserOperationReceipt',
'eth_estimateUserOperationGas',
'eth_getUserOperationByHash',
'eth_supportedEntryPoints'
'eth_supportedEntryPoints',
//EIP-7811
'wallet_getAssets'
],
NOT_SAFE_RPC_METHODS: [
'personal_sign',
Expand Down
1 change: 0 additions & 1 deletion packages/wallet/src/W3mFrameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ export class W3mFrameProvider {
const id = Math.random().toString(36).substring(7)
this.w3mLogger?.logger.info?.({ event, id }, 'Sending app event')
this.w3mFrame.events.postAppEvent({ ...event, id } as W3mFrameTypes.AppEvent)

if (type === 'RPC_REQUEST') {
const rpcEvent = event as Extract<W3mFrameTypes.AppEvent, { type: '@w3m-app/RPC_REQUEST' }>
this.openRpcRequests = [...this.openRpcRequests, { ...rpcEvent.payload, abortController }]
Expand Down
7 changes: 5 additions & 2 deletions packages/wallet/src/W3mFrameSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ export const WalletRevokePermissionsRequest = z.object({
method: z.literal('wallet_revokePermissions'),
params: z.any()
})

export const WalletGetAssetsRequest = z.object({
method: z.literal('wallet_getAssets'),
params: z.array(z.any())
})
export const FrameSession = z.object({
token: z.string()
})
Expand Down Expand Up @@ -482,7 +485,7 @@ export const W3mFrameSchema = {
.or(
EventSchema.extend({
type: zType('APP_RPC_REQUEST'),
payload: RpcPersonalSignRequest.or(RpcEthSendTransactionRequest)
payload: RpcPersonalSignRequest.or(WalletGetAssetsRequest)
.or(RpcEthAccountsRequest)
.or(RpcEthBlockNumber)
.or(RpcEthCall)
Expand Down
2 changes: 2 additions & 0 deletions packages/wallet/src/W3mFrameTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
RpcSolanaSignTransactionRequest,
RpcUnistallFilter,
W3mFrameSchema,
WalletGetAssetsRequest,
WalletGetCallsReceiptRequest,
WalletGetCapabilitiesRequest,
WalletGrantPermissionsRequest,
Expand Down Expand Up @@ -188,6 +189,7 @@ export namespace W3mFrameTypes {
| z.infer<typeof WalletGetCapabilitiesRequest>
| z.infer<typeof WalletGrantPermissionsRequest>
| z.infer<typeof WalletRevokePermissionsRequest>
| z.infer<typeof WalletGetAssetsRequest>

export type RPCResponse = z.infer<typeof RpcResponse>

Expand Down

0 comments on commit 420cfe5

Please sign in to comment.