Skip to content

Commit

Permalink
feat: wallet_revokePermissions (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino authored Jun 17, 2024
1 parent 23c3e31 commit e56d86c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rainbow-me/provider",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/index.js",
"license": "MIT",
"files": [
Expand Down Expand Up @@ -40,6 +40,7 @@
"viem": "1.21.4"
},
"resolutions": {
"vite": "5.1.7"
"vite": "5.1.7",
"braces": "3.0.3"
}
}
16 changes: 16 additions & 0 deletions src/handleProviderRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { toHex } from './utils/hex';
import { errorCodes } from './references/errorCodes';
import { ChainNativeCurrency } from 'viem/_types/types/chain';

interface WalletPermissionsParams {
eth_accounts: object;
}

const buildError = ({
id,
message,
Expand Down Expand Up @@ -48,6 +52,7 @@ export const handleProviderRequest = ({
checkRateLimit,
isSupportedChain,
getActiveSession,
removeAppSession,
getChainNativeCurrency,
getProvider,
messengerProviderRequest,
Expand All @@ -68,6 +73,7 @@ export const handleProviderRequest = ({
}) => Promise<{ id: number; error: Error } | undefined>;
isSupportedChain: (chainId: number) => boolean;
getActiveSession: ({ host }: { host: string }) => ActiveSession;
removeAppSession?: ({ host }: { host: string }) => void;
getChainNativeCurrency: (chainId: number) => ChainNativeCurrency | undefined;
getProvider: (options: { chainId?: number }) => Provider;
messengerProviderRequest: (
Expand Down Expand Up @@ -458,6 +464,16 @@ export const handleProviderRequest = ({
});
break;
}
case 'wallet_revokePermissions': {
if (
!!removeAppSession &&
(params?.[0] as WalletPermissionsParams)?.eth_accounts
) {
removeAppSession?.({ host });
response = null;
}
throw new Error('next');
}
default: {
try {
if (method?.substring(0, 7) === 'wallet_') {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,12 @@ brace-expansion@^2.0.1:
dependencies:
balanced-match "^1.0.0"

braces@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
braces@3.0.3, braces@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

brorand@^1.1.0:
version "1.1.0"
Expand Down Expand Up @@ -1351,10 +1351,10 @@ file-entry-cache@^6.0.1:
dependencies:
flat-cache "^3.0.4"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down

0 comments on commit e56d86c

Please sign in to comment.