Skip to content

Commit 40465f7

Browse files
authored
feat: add eip1193-compatilble as a supported session property (#8731)
## Explanation The `@metamask/connect-evm` package is adding support for sending `sessionProperties: { 'eip1193-compatible': true }` on every `wallet_createSession` request ([MetaMask/connect-monorepo#285](MetaMask/connect-monorepo#285)). This lets the wallet distinguish EIP-1193-style connections established through `connect-evm` from pure Multichain API connections and other provider types like Solana Wallet Standard. However, the `chain-agnostic-permission` package validates session properties against a known set (`KnownSessionProperties` enum), and any unrecognized property causes the CAIP-25 caveat validator to throw. Without this change, the new `eip1193-compatible` session property would be rejected. This PR adds `Eip1193Compatible = 'eip1193-compatible'` to the `KnownSessionProperties` enum so the wallet accepts it as a valid session property. ## References - Related to [MetaMask/connect-monorepo#285](MetaMask/connect-monorepo#285) — the upstream PR that sends this session property from `connect-evm` ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: adds a new allowed CAIP-25 `sessionProperties` key and tags legacy permission conversions with it, with no changes to scope/account validation logic beyond accepting this new flag. > > **Overview** > Adds support for the `eip1193-compatible` CAIP-25 session property by extending `KnownSessionProperties` and related validation/tests so `wallet_createSession` requests carrying this flag are no longer rejected. > > Updates `getCaip25PermissionFromLegacyPermissions` to always set `sessionProperties: { 'eip1193-compatible': true }`, and adjusts unit tests plus the package changelog accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fb7fa99. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c856b75 commit 40465f7

6 files changed

Lines changed: 42 additions & 10 deletions

File tree

packages/chain-agnostic-permission/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `Eip1193Compatible` property in `KnownSessionProperties` enum to support EIP-1193-style connections established through `connect-evm` ([#8731](https://github.com/MetaMask/core/pull/8731))
13+
- Set `sessionProperties: { 'eip1193-compatible': true }` in `getCaip25PermissionFromLegacyPermissions` so that legacy EIP-1193 permission requests are tagged as EIP-1193-compatible ([#8731](https://github.com/MetaMask/core/pull/8731))
14+
1015
### Changed
1116

1217
- Bump `@metamask/permission-controller` from `^12.2.1` to `^13.1.0` ([#8317](https://github.com/MetaMask/core/pull/8317), [#8661](https://github.com/MetaMask/core/pull/8661), [#8722](https://github.com/MetaMask/core/pull/8722))

packages/chain-agnostic-permission/src/caip25Permission.test.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
20012001
},
20022002
},
20032003
isMultichainOrigin: false,
2004-
sessionProperties: {},
2004+
sessionProperties: {
2005+
'eip1193-compatible': true,
2006+
},
20052007
},
20062008
},
20072009
],
@@ -2038,7 +2040,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
20382040
},
20392041
},
20402042
isMultichainOrigin: false,
2041-
sessionProperties: {},
2043+
sessionProperties: {
2044+
'eip1193-compatible': true,
2045+
},
20422046
},
20432047
},
20442048
],
@@ -2076,7 +2080,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
20762080
},
20772081
},
20782082
isMultichainOrigin: false,
2079-
sessionProperties: {},
2083+
sessionProperties: {
2084+
'eip1193-compatible': true,
2085+
},
20802086
},
20812087
},
20822088
],
@@ -2126,7 +2132,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
21262132
},
21272133
},
21282134
isMultichainOrigin: false,
2129-
sessionProperties: {},
2135+
sessionProperties: {
2136+
'eip1193-compatible': true,
2137+
},
21302138
},
21312139
},
21322140
],
@@ -2163,7 +2171,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
21632171
},
21642172
},
21652173
isMultichainOrigin: false,
2166-
sessionProperties: {},
2174+
sessionProperties: {
2175+
'eip1193-compatible': true,
2176+
},
21672177
},
21682178
},
21692179
],
@@ -2201,7 +2211,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
22012211
},
22022212
},
22032213
isMultichainOrigin: false,
2204-
sessionProperties: {},
2214+
sessionProperties: {
2215+
'eip1193-compatible': true,
2216+
},
22052217
},
22062218
},
22072219
],
@@ -2251,7 +2263,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
22512263
},
22522264
},
22532265
isMultichainOrigin: false,
2254-
sessionProperties: {},
2266+
sessionProperties: {
2267+
'eip1193-compatible': true,
2268+
},
22552269
},
22562270
},
22572271
],
@@ -2300,7 +2314,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
23002314
},
23012315
},
23022316
isMultichainOrigin: false,
2303-
sessionProperties: {},
2317+
sessionProperties: {
2318+
'eip1193-compatible': true,
2319+
},
23042320
},
23052321
},
23062322
],
@@ -2349,7 +2365,9 @@ describe('getCaip25PermissionFromLegacyPermissions', () => {
23492365
},
23502366
},
23512367
isMultichainOrigin: false,
2352-
sessionProperties: {},
2368+
sessionProperties: {
2369+
'eip1193-compatible': true,
2370+
},
23532371
},
23542372
},
23552373
],

packages/chain-agnostic-permission/src/caip25Permission.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
setPermittedEthChainIds,
3636
} from './operators/caip-permission-operator-permittedChains';
3737
import { assertIsInternalScopesObject } from './scope/assert';
38+
import { KnownSessionProperties } from './scope/constants';
3839
import {
3940
isSupportedAccount,
4041
isSupportedScopeString,
@@ -632,7 +633,9 @@ export const getCaip25PermissionFromLegacyPermissions =
632633
accounts: [],
633634
},
634635
},
635-
sessionProperties: {},
636+
sessionProperties: {
637+
[KnownSessionProperties.Eip1193Compatible]: true,
638+
},
636639
isMultichainOrigin: false,
637640
};
638641

packages/chain-agnostic-permission/src/scope/constants.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ describe('KnownSessionProperties', () => {
6565
expect(KnownSessionProperties).toMatchInlineSnapshot(`
6666
{
6767
"Bip122AccountChangedNotifications": "bip122_accountChanged_notifications",
68+
"Eip1193Compatible": "eip1193-compatible",
6869
"SolanaAccountChangedNotifications": "solana_accountChanged_notifications",
6970
"TronAccountChangedNotifications": "tron_accountChanged_notifications",
7071
}
@@ -74,6 +75,7 @@ describe('KnownSessionProperties', () => {
7475

7576
describe('isKnownSessionPropertyValue', () => {
7677
it('should return true for known session property values', () => {
78+
expect(isKnownSessionPropertyValue('eip1193-compatible')).toBe(true);
7779
expect(
7880
isKnownSessionPropertyValue('solana_accountChanged_notifications'),
7981
).toBe(true);

packages/chain-agnostic-permission/src/scope/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]> =
9898
* Session properties for known CAIP namespaces.
9999
*/
100100
export enum KnownSessionProperties {
101+
Eip1193Compatible = 'eip1193-compatible',
101102
SolanaAccountChangedNotifications = 'solana_accountChanged_notifications',
102103
TronAccountChangedNotifications = 'tron_accountChanged_notifications',
103104
Bip122AccountChangedNotifications = 'bip122_accountChanged_notifications',

packages/chain-agnostic-permission/src/scope/supported.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ describe('Scope Support', () => {
495495

496496
describe('isSupportedSessionProperty', () => {
497497
it('returns true for the session property', () => {
498+
expect(
499+
isSupportedSessionProperty(KnownSessionProperties.Eip1193Compatible),
500+
).toBe(true);
498501
expect(
499502
isSupportedSessionProperty(
500503
KnownSessionProperties.SolanaAccountChangedNotifications,

0 commit comments

Comments
 (0)