diff --git a/app/scripts/controllers/permissions/background-api.test.js b/app/scripts/controllers/permissions/background-api.test.js index 3deca2135f68..babfee85ce49 100644 --- a/app/scripts/controllers/permissions/background-api.test.js +++ b/app/scripts/controllers/permissions/background-api.test.js @@ -137,6 +137,26 @@ describe('permission background API methods', () => { 'eip155:1:0x4', ], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: [ + 'wallet:eip155:0x2', + 'wallet:eip155:0x3', + 'wallet:eip155:0x1', + 'wallet:eip155:0x4', + ], + }, + wallet: { + methods: [], + notifications: [], + accounts: [ + 'wallet:eip155:0x2', + 'wallet:eip155:0x3', + 'wallet:eip155:0x1', + 'wallet:eip155:0x4', + ], + }, }, isMultichainOrigin: true, }, @@ -267,6 +287,28 @@ describe('permission background API methods', () => { 'eip155:1:0x5', ], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: [ + 'wallet:eip155:0x2', + 'wallet:eip155:0x3', + 'wallet:eip155:0x1', + 'wallet:eip155:0x4', + 'wallet:eip155:0x5', + ], + }, + wallet: { + methods: [], + notifications: [], + accounts: [ + 'wallet:eip155:0x2', + 'wallet:eip155:0x3', + 'wallet:eip155:0x1', + 'wallet:eip155:0x4', + 'wallet:eip155:0x5', + ], + }, }, isMultichainOrigin: true, }, @@ -462,6 +504,16 @@ describe('permission background API methods', () => { notifications: [], accounts: ['eip155:1:0x3', 'eip155:1:0x1'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x3', 'wallet:eip155:0x1'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x3', 'wallet:eip155:0x1'], + }, }, isMultichainOrigin: true, }, @@ -549,6 +601,16 @@ describe('permission background API methods', () => { notifications: KnownNotifications.eip155, accounts: ['eip155:5:0xdeadbeef'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0xdeadbeef'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0xdeadbeef'], + }, }, isMultichainOrigin: false, }, @@ -670,6 +732,16 @@ describe('permission background API methods', () => { notifications: KnownNotifications.eip155, accounts: ['eip155:1337:0x1', 'eip155:1337:0x2'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, }, isMultichainOrigin: true, }, @@ -792,6 +864,16 @@ describe('permission background API methods', () => { notifications: KnownNotifications.eip155, accounts: ['eip155:5:0x1', 'eip155:5:0x2'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, }, isMultichainOrigin: true, }, diff --git a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.test.ts b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.test.ts index aa125193ce95..8fe89acacc2f 100644 --- a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.test.ts +++ b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.test.ts @@ -69,6 +69,10 @@ describe('CAIP-25 permittedChains adapters', () => { notifications: [], accounts: ['eip155:100:0x100'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + }, }, isMultichainOrigin: false, }, @@ -94,6 +98,60 @@ describe('CAIP-25 permittedChains adapters', () => { notifications: KnownNotifications.eip155, accounts: [], }, + 'wallet:eip155': { + methods: [], + notifications: [], + }, + }, + isMultichainOrigin: false, + }); + }); + + it('adds an optional scope for "wallet:eip155" if it does not already exist in the optional scopes', () => { + const result = addPermittedEthChainId( + { + requiredScopes: { + 'eip155:1': { + methods: [], + notifications: [], + accounts: ['eip155:1:0x1', 'eip155:1:0x2'], + }, + }, + optionalScopes: { + 'eip155:100': { + methods: [], + notifications: [], + accounts: ['eip155:100:0x100'], + }, + }, + isMultichainOrigin: false, + }, + '0x65', + ); + + expect(result).toStrictEqual({ + requiredScopes: { + 'eip155:1': { + methods: [], + notifications: [], + accounts: ['eip155:1:0x1', 'eip155:1:0x2'], + }, + }, + optionalScopes: { + 'eip155:100': { + methods: [], + notifications: [], + accounts: ['eip155:100:0x100'], + }, + 'eip155:101': { + methods: KnownRpcMethods.eip155, + notifications: KnownNotifications.eip155, + accounts: [], + }, + 'wallet:eip155': { + methods: [], + notifications: [], + }, }, isMultichainOrigin: false, }); @@ -277,6 +335,10 @@ describe('CAIP-25 permittedChains adapters', () => { notifications: KnownNotifications.eip155, accounts: [], }, + 'wallet:eip155': { + methods: [], + notifications: [], + }, }, isMultichainOrigin: false, }); diff --git a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.ts b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.ts index 8e840c6c327e..b08d86d2f764 100644 --- a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.ts +++ b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-permittedChains.ts @@ -44,6 +44,10 @@ export const addPermittedEthChainId = ( return { ...caip25CaveatValue, optionalScopes: { + 'wallet:eip155': { + methods: [], + notifications: [], + }, ...caip25CaveatValue.optionalScopes, [scopeString]: { methods: KnownRpcMethods.eip155, diff --git a/app/scripts/lib/multichain-api/caip25permissions.test.ts b/app/scripts/lib/multichain-api/caip25permissions.test.ts index 97fce8f631d6..129003f8aefe 100644 --- a/app/scripts/lib/multichain-api/caip25permissions.test.ts +++ b/app/scripts/lib/multichain-api/caip25permissions.test.ts @@ -2,7 +2,6 @@ import { CaveatConstraint, CaveatMutatorOperation, PermissionType, - SubjectType, } from '@metamask/permission-controller'; import { NonEmptyArray } from '@metamask/controller-utils'; import * as Scope from './scope'; @@ -46,7 +45,6 @@ describe('endowment:caip25', () => { targetName: Caip25EndowmentPermissionName, endowmentGetter: expect.any(Function), allowedCaveats: [Caip25CaveatType], - subjectTypes: [SubjectType.Website], validator: expect.any(Function), }); diff --git a/app/scripts/lib/multichain-api/wallet-createSession/handler.test.js b/app/scripts/lib/multichain-api/wallet-createSession/handler.test.js index 345ab09e0154..ce2870378aa7 100644 --- a/app/scripts/lib/multichain-api/wallet-createSession/handler.test.js +++ b/app/scripts/lib/multichain-api/wallet-createSession/handler.test.js @@ -510,6 +510,16 @@ describe('wallet_createSession', () => { notifications: KnownNotifications.eip155, accounts: ['eip155:1337:0x1', 'eip155:1337:0x2'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, }, isMultichainOrigin: true, }, @@ -608,6 +618,16 @@ describe('wallet_createSession', () => { notifications: ['chainChanged'], accounts: ['eip155:100:0x1', 'eip155:100:0x2'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, + wallet: { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x1', 'wallet:eip155:0x2'], + }, }, }); }); diff --git a/yarn.lock b/yarn.lock index ccfa5fd86c2c..82c0a9b0f85a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4177,20 +4177,13 @@ __metadata: languageName: node linkType: hard -"@json-schema-tools/traverse@npm:^1.10.4": +"@json-schema-tools/traverse@npm:^1.10.4, @json-schema-tools/traverse@npm:^1.7.5, @json-schema-tools/traverse@npm:^1.7.8": version: 1.10.4 resolution: "@json-schema-tools/traverse@npm:1.10.4" checksum: 10/0027bc90df01c5eeee0833e722b7320b53be8b5ce3f4e0e4a6e45713a38e6f88f21aba31e3dd973093ef75cd21a40c07fe8f112da8f49a7919b1c0e44c904d20 languageName: node linkType: hard -"@json-schema-tools/traverse@npm:^1.7.5, @json-schema-tools/traverse@npm:^1.7.8": - version: 1.10.3 - resolution: "@json-schema-tools/traverse@npm:1.10.3" - checksum: 10/690623740d223ea373d8e561dad5c70bf86461bcedc5fc45da01c87bcdf3284bbdbad3006d4a423f8d82e4b2d4580e45f92c0b272f006024fb597d7f01876215 - languageName: node - linkType: hard - "@juggle/resize-observer@npm:^3.3.1": version: 3.4.0 resolution: "@juggle/resize-observer@npm:3.4.0"