Skip to content

Commit 172c2e0

Browse files
authored
feat: replace caip-x with caip-348 for CAIP-294 announcement and Multichain API externally_connectable protocol (#32070)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32070?quickstart=1) ## **Related issues** See: MetaMask/test-dapp-multichain#53 See: MetaMask/providers#413 See: MetaMask/multichain-api-client#40 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 5fd4689 commit 172c2e0

8 files changed

Lines changed: 53 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Support for Solana Devnet ([#31702](https://github.com/MetaMask/metamask-extension/pull/31702))
1111
- [Beta] Create Solana account automatically on wallet creation or SRP import [#32038](https://github.com/MetaMask/metamask-extension/pull/32038)
1212
- Support for Solana on Firefox ([#32104](https://github.com/MetaMask/metamask-extension/pull/32104))
13+
- Update CAIP-294 wallet announcement event to include `targets` property and new `caip-348` target object ([#32070](https://github.com/MetaMask/metamask-extension/pull/32070))
14+
- Replace `caip-x` with `caip-348` in Multichain API over externally_connectable ([#32070](https://github.com/MetaMask/metamask-extension/pull/32070))
1315

1416
### Fixed
1517
- Fix NFT removal on different networks ([#32102](https://github.com/MetaMask/metamask-extension/pull/32102))

app/scripts/metamask-controller.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,7 @@ describe('MetaMaskController', () => {
26452645
await new Promise((resolve) => {
26462646
streamTest.write(
26472647
{
2648-
type: 'caip-x',
2648+
type: 'caip-348',
26492649
data: {
26502650
method: 'wallet_invokeMethod',
26512651
params: {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
"@metamask/message-manager": "^12.0.1",
295295
"@metamask/message-signing-snap": "^1.1.1",
296296
"@metamask/metamask-eth-abis": "^3.1.1",
297-
"@metamask/multichain-api-client": "^0.2.0",
297+
"@metamask/multichain-api-client": "^0.3.0",
298298
"@metamask/multichain-api-middleware": "^0.1.1",
299299
"@metamask/multichain-network-controller": "^0.4.0",
300300
"@metamask/multichain-transactions-controller": "^0.9.0",
@@ -311,7 +311,7 @@
311311
"@metamask/ppom-validator": "0.36.0",
312312
"@metamask/preinstalled-example-snap": "^0.3.0",
313313
"@metamask/profile-sync-controller": "^12.0.0",
314-
"@metamask/providers": "^21.0.0",
314+
"@metamask/providers": "^22.0.0",
315315
"@metamask/rate-limit-controller": "^6.0.3",
316316
"@metamask/remote-feature-flag-controller": "^1.6.0",
317317
"@metamask/rpc-errors": "^7.0.0",
@@ -450,7 +450,7 @@
450450
"@metamask/preferences-controller": "^17.0.0",
451451
"@metamask/test-bundler": "^1.0.0",
452452
"@metamask/test-dapp": "9.3.0",
453-
"@metamask/test-dapp-multichain": "^0.9.0",
453+
"@metamask/test-dapp-multichain": "^0.10.0",
454454
"@octokit/core": "^3.6.0",
455455
"@open-rpc/meta-schema": "^1.14.6",
456456
"@open-rpc/mock-server": "^1.7.5",

shared/modules/caip-stream.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ class MockStream extends Duplex {
4242

4343
describe('CAIP Stream', () => {
4444
describe('createCaipStream', () => {
45-
it('pipes and unwraps a caip-x message from source stream to the substream', async () => {
45+
it('pipes and unwraps a caip-348 message from source stream to the substream', async () => {
4646
const sourceStream = new PassThrough({ objectMode: true });
4747
const sourceStreamChunks = readFromStream(sourceStream);
4848

4949
const providerStream = createCaipStream(sourceStream);
5050
const providerStreamChunks = readFromStream(providerStream);
5151

5252
await writeToStream(sourceStream, {
53-
type: 'caip-x',
53+
type: 'caip-348',
5454
data: { foo: 'bar' },
5555
});
5656

5757
expect(sourceStreamChunks).toStrictEqual([
58-
{ type: 'caip-x', data: { foo: 'bar' } },
58+
{ type: 'caip-348', data: { foo: 'bar' } },
5959
]);
6060
expect(providerStreamChunks).toStrictEqual([{ foo: 'bar' }]);
6161
});
@@ -74,7 +74,7 @@ describe('CAIP Stream', () => {
7474
// Note that it's not possible to verify the output side of the internal SplitStream
7575
// instantiated inside createCaipStream as only the substream is actually exported
7676
expect(sourceStream.chunks).toStrictEqual([
77-
{ type: 'caip-x', data: { foo: 'bar' } },
77+
{ type: 'caip-348', data: { foo: 'bar' } },
7878
]);
7979
});
8080

shared/modules/caip-stream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Substream extends Duplex {
2121
callback: (error?: Error | null) => void,
2222
) {
2323
this.parent.push({
24-
type: 'caip-x',
24+
type: 'caip-348',
2525
data: value,
2626
});
2727
callback();
@@ -45,7 +45,7 @@ export class CaipStream extends Duplex {
4545
_encoding: BufferEncoding,
4646
callback: (error?: Error | null) => void,
4747
) {
48-
if (isObject(value) && value.type === 'caip-x') {
48+
if (isObject(value) && value.type === 'caip-348') {
4949
this.substream.push(value.data);
5050
}
5151
callback();

test/e2e/api-specs/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const createCaip27DriverTransport = (
119119
type: string;
120120
data: JsonRpcResponse<Json>;
121121
}) => {
122-
if (type !== 'caip-x') {
122+
if (type !== 'caip-348') {
123123
return;
124124
}
125125
if (data?.id !== g) {
@@ -134,7 +134,7 @@ export const createCaip27DriverTransport = (
134134

135135
extensionPort.onMessage.addListener(listener);
136136
const msg = {
137-
type: 'caip-x',
137+
type: 'caip-348',
138138
data: {
139139
jsonrpc: '2.0',
140140
method: 'wallet_invokeMethod',
@@ -203,7 +203,7 @@ export const createMultichainDriverTransport = (
203203
type: string;
204204
data: JsonRpcResponse<Json>;
205205
}) => {
206-
if (type !== 'caip-x') {
206+
if (type !== 'caip-348') {
207207
return;
208208
}
209209
if (data?.id !== g) {
@@ -218,7 +218,7 @@ export const createMultichainDriverTransport = (
218218

219219
extensionPort.onMessage.addListener(listener);
220220
const msg = {
221-
type: 'caip-x',
221+
type: 'caip-348',
222222
data: {
223223
jsonrpc: '2.0',
224224
method: m,

test/e2e/flask/multichain-api/testHelpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const sendMultichainApiRequest = ({
211211
const data = ${JSON.stringify(requestWithNewId)};
212212
const result = new Promise((resolve) => {
213213
port.onMessage.addListener((msg) => {
214-
if (msg.type !== 'caip-x') {
214+
if (msg.type !== 'caip-348') {
215215
return;
216216
}
217217
if (msg.data?.id !== ${id}) {
@@ -221,7 +221,7 @@ export const sendMultichainApiRequest = ({
221221
resolve(msg.data);
222222
})
223223
})
224-
port.postMessage({ type: 'caip-x', data });
224+
port.postMessage({ type: 'caip-348', data });
225225
return result;`;
226226
}
227227

yarn.lock

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5777,10 +5777,10 @@ __metadata:
57775777
languageName: node
57785778
linkType: hard
57795779

5780-
"@metamask/multichain-api-client@npm:^0.2.0":
5781-
version: 0.2.0
5782-
resolution: "@metamask/multichain-api-client@npm:0.2.0"
5783-
checksum: 10/39509819e8304e5adee96d242c4fe73f39fe92f07102faf373c902fded2617bd023ea7423e84dcea47980c752d5233742d05ca45ff040db664ea883db128cc7c
5780+
"@metamask/multichain-api-client@npm:^0.3.0":
5781+
version: 0.3.0
5782+
resolution: "@metamask/multichain-api-client@npm:0.3.0"
5783+
checksum: 10/3a82a36dbdad88f16464e7655d77a5562d636a387b93d69438421c1fd25f4767eb28ed4c423647b6b06fb0c85cf7dcbe7e4bca474cddd022c78652d631de23fe
57845784
languageName: node
57855785
linkType: hard
57865786

@@ -6175,6 +6175,27 @@ __metadata:
61756175
languageName: node
61766176
linkType: hard
61776177

6178+
"@metamask/providers@npm:^22.0.0":
6179+
version: 22.0.0
6180+
resolution: "@metamask/providers@npm:22.0.0"
6181+
dependencies:
6182+
"@metamask/json-rpc-engine": "npm:^10.0.2"
6183+
"@metamask/json-rpc-middleware-stream": "npm:^8.0.6"
6184+
"@metamask/object-multiplex": "npm:^2.0.0"
6185+
"@metamask/rpc-errors": "npm:^7.0.2"
6186+
"@metamask/safe-event-emitter": "npm:^3.1.1"
6187+
"@metamask/utils": "npm:^11.0.1"
6188+
detect-browser: "npm:^5.2.0"
6189+
extension-port-stream: "npm:^4.1.0"
6190+
fast-deep-equal: "npm:^3.1.3"
6191+
is-stream: "npm:^2.0.0"
6192+
readable-stream: "npm:^3.6.2"
6193+
peerDependencies:
6194+
webextension-polyfill: ^0.10.0 || ^0.11.0 || ^0.12.0
6195+
checksum: 10/b9bd381e5669e07ecee0a98f8748993fed4e02bc855e2ad342db9b9bb8b2d453a01c0e4c9f1e2c7b80929c5ce15d7aafa88c0a6a78651737efdb16f707a84017
6196+
languageName: node
6197+
linkType: hard
6198+
61786199
"@metamask/rate-limit-controller@npm:^6.0.3":
61796200
version: 6.0.3
61806201
resolution: "@metamask/rate-limit-controller@npm:6.0.3"
@@ -6519,10 +6540,10 @@ __metadata:
65196540
languageName: node
65206541
linkType: hard
65216542

6522-
"@metamask/test-dapp-multichain@npm:^0.9.0":
6523-
version: 0.9.0
6524-
resolution: "@metamask/test-dapp-multichain@npm:0.9.0"
6525-
checksum: 10/6d317402bc59165559fad9b1e681ea1437858158f102cced86b7c52da115c7a991e7012906f6bad06f7f55ffa36a30ffe4651b29375d769989eba5611540f530
6543+
"@metamask/test-dapp-multichain@npm:^0.10.0":
6544+
version: 0.10.0
6545+
resolution: "@metamask/test-dapp-multichain@npm:0.10.0"
6546+
checksum: 10/9840f9dbbfe289de159dc9d950aea923a4154980e5e31fd68a67bc21437f23c35d85ce8a4fc36e7f51234353a5d2ec83af04e56ad95ded93f624ee63050e55bb
65266547
languageName: node
65276548
linkType: hard
65286549

@@ -15696,9 +15717,9 @@ __metadata:
1569615717
linkType: hard
1569715718

1569815719
"caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001599, caniuse-lite@npm:^1.0.30001669":
15699-
version: 1.0.30001669
15700-
resolution: "caniuse-lite@npm:1.0.30001669"
15701-
checksum: 10/cd0b481bb997703cb7651e55666b4aa4e7b4ecf9784796e2393179a15e55c71a6abc6ff865c922bbd3bbfa4a4bf0530d8da13989b97ff8c7850c8a5bd4e00491
15720+
version: 1.0.30001707
15721+
resolution: "caniuse-lite@npm:1.0.30001707"
15722+
checksum: 10/5c5f9aad651f4d957cc59c8b4ac22bb7ac3a1c86c26ee7d5c59b00062bdc1c421980513179da1f5e20cade2da8d7f3c41d482ce7d4a8d9f411e4a827fe092d29
1570215723
languageName: node
1570315724
linkType: hard
1570415725

@@ -27630,7 +27651,7 @@ __metadata:
2763027651
"@metamask/message-manager": "npm:^12.0.1"
2763127652
"@metamask/message-signing-snap": "npm:^1.1.1"
2763227653
"@metamask/metamask-eth-abis": "npm:^3.1.1"
27633-
"@metamask/multichain-api-client": "npm:^0.2.0"
27654+
"@metamask/multichain-api-client": "npm:^0.3.0"
2763427655
"@metamask/multichain-api-middleware": "npm:^0.1.1"
2763527656
"@metamask/multichain-network-controller": "npm:^0.4.0"
2763627657
"@metamask/multichain-transactions-controller": "npm:^0.9.0"
@@ -27649,7 +27670,7 @@ __metadata:
2764927670
"@metamask/preferences-controller": "npm:^17.0.0"
2765027671
"@metamask/preinstalled-example-snap": "npm:^0.3.0"
2765127672
"@metamask/profile-sync-controller": "npm:^12.0.0"
27652-
"@metamask/providers": "npm:^21.0.0"
27673+
"@metamask/providers": "npm:^22.0.0"
2765327674
"@metamask/rate-limit-controller": "npm:^6.0.3"
2765427675
"@metamask/remote-feature-flag-controller": "npm:^1.6.0"
2765527676
"@metamask/rpc-errors": "npm:^7.0.0"
@@ -27667,7 +27688,7 @@ __metadata:
2766727688
"@metamask/solana-wallet-standard": "npm:^0.1.1"
2766827689
"@metamask/test-bundler": "npm:^1.0.0"
2766927690
"@metamask/test-dapp": "npm:9.3.0"
27670-
"@metamask/test-dapp-multichain": "npm:^0.9.0"
27691+
"@metamask/test-dapp-multichain": "npm:^0.10.0"
2767127692
"@metamask/transaction-controller": "npm:^54.1.0"
2767227693
"@metamask/user-operation-controller": "npm:^31.0.0"
2767327694
"@metamask/utils": "npm:^11.1.0"

0 commit comments

Comments
 (0)