Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata to interface state #2503

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "3cyrvn8TOcqu5AG1BfJ+bHNhlGzJNjD1WrvZnGzA9cM=",
"shasum": "xWXsw5LjFwQRaufki1t/iampdYMdJH4k3k7mu2t5egc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "PvcD86EO/ZJWmK+OjX1S9Dx7JbLENispYZ0TlxqyBWg=",
"shasum": "O/w/gpIoCZLlBU7v8HlCelxUq+A47R+yhWHFzAP+5sU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Z7bFULEf26ABMGWFe56MUwxdFqqk7wSXpEqBnVOc0QI=",
"shasum": "X2vOy1ncPOAfKxbSEM/AO0ubcSVqntFIIOtHLrQaOTM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "gkiI/1xzz3QLou/HR+0p8nPGdrr6s3EoVKSIEhpHSEc=",
"shasum": "4Qn0ULfxP+10Fgc4owpRcjwPNk79L0iQDavQwfNyXFE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "QR/NJxBMFk0XrPJyuVgcFuR/YiqLKdj2JZjxkY4lZj0=",
"shasum": "DvdA5FUwoN/JNzeXBfont4//3v4mX20PN2eOqTwqGsI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/cronjobs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "+4Yl3+BXI3uaZfjSrQxuPMLQY2476cAO/FcR/a2jycU=",
"shasum": "qqZwJjSmhOoSLgFDJCLUqI4QYUQ+Ig/erSJKxOHsuuk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/dialogs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "g2p8BK9pJXrC9/hJw+n3BkBKDfS0Dng/oR1cJGLrnuc=",
"shasum": "layewHpnFhX6O3TE2XVOubS6LanUXgTxkchzQ2XRSxo=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "8cRG0o0f7+IZWgMNYyAHRO3Nrht3779FDBiNclCYxYU=",
"shasum": "fYwoCqxiXH9CeaKasOHRuQHPZrky7FjclslIlEqcCok=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Zqdf6Sl/sfvJYl7A87/BB7e0nhdXqe+0KxIeGxnjr5g=",
"shasum": "SZGja3r8voeQPoASG8C/1kRbeLq0iJRu8eu5xIq9zaQ=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Ko0mJ92OTHqNdBu/CHrMImRa+Afyr8AsEyojCczLLsc=",
"shasum": "WivEfGs9i26XuaoXhzYyw74jagvrJ3aqSRzJYrabqXI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Ii9gvF7VRzccakiuibaWqR5fcGUmn3bADL6vSxr5Lc8=",
"shasum": "3a26x4h/EN0xQdsEzMLFk/62vAcT2l1lX9k9pjk4Dd8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-file/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "d7GagnmYnwhrnLc+oQQV7IC9f4cPRM8BZUeQ50cuydA=",
"shasum": "sLPMU1UnLtRzV8c/5o9fOrowYDkgQnmOALauSDDAUOQ=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/home-page/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "YMn4Z3+ddOce0OOYrk39M+kmlaIXfYaurjAOWpJhzp0=",
"shasum": "/+paPL+SWumPGtVX2jLLY+OFOWEeHT8LcHNmCeB1vx4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/images/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "roTBoTud+bVBTfv04q2wAIOzbV75XAIPTa+fbs+u4S0=",
"shasum": "hNZ6qo8t1RH8+As3gJ2mu4VwcfeqWKmhZ2HxsfAgQZI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "6k3MXI/vf6lRt5uVk586yydm6LZaqS0NZ4TP2se6XBg=",
"shasum": "JR7eQdPo8TM5uLTyMIhpNLEDaiZW6PkE+54syXGX2Tw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "wWbKF414M1/e1r9bG0Y+Ntbcn1XX7DIml4pwl041Uug=",
"shasum": "LxSwsGjDv2U4dz1Y58Z8kCNjErxQgsJkySfkr9cwt8k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "xvwZwBbmoekH92t7tYei5dZ5uKxtdvz85kesxMab8mo=",
"shasum": "WbIJsP+TbOyq1TaqyctQ5JTlyLoHta94tQaozw4Azr4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/json-rpc/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "WxAHmnlgdoRw7w0u8B9N3C8aB52epM3JUy2TpFRu46g=",
"shasum": "qKiHk6XvwHtGV/bJOba3n4spGWPG76FiI9F8SD/A/3o=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/jsx/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "yP7SkzjBPN5/uvEnqGjTGGyq5GBHPm8py/VNJW0h//4=",
"shasum": "VOsd46ulxkzN4nGHhDJTov5UKM84YpvmYGZZaFRbFdU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "/WjyMJSHqfad0PNKZGei84ChfrZQiQpOCumQpDxSZ7A=",
"shasum": "zuKxAh/8so9bC0WwSsEoXeNCXdCPTWpUpTGS5cJL54c=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "xnBCnKIYB1IJXLUx0iDC4U+QdGVDM72i4uQ9+vVupBo=",
"shasum": "2s0C8J6NK2q5XDJjmPABEdU9BEhWa79bhmBt4zUD+uU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "SRpkwJ5zj0JuY112AOcufRVqqsAheKhEtv4D9WqVvZY=",
"shasum": "9zISfOgwECMw5QUInlwm9BYthXi8qIkPZZDvmnUWS/c=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "JZ2kwUDXE7cu77OVONa8GdxwjUSqMqgv3JKUPSArElg=",
"shasum": "hDslA6wk04fYto1u0qW5Lgge9kG0Gd8Nx67ZlvdN8m0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "JR9gpxBsEizgvJLKe7cjMHnEUks/dlmK/kTq+OcdcIo=",
"shasum": "opFjKht+K7XFm8QczfBNKcqiafkfaMQ8CI0iGJyDhI4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "NVGTP6xdPKOSoReiGTr18o8r08qTsQqAE4JP+f9aisU=",
"shasum": "cFvHPCVfRrSorz939WQ6KOhB1GVhfp4oGrMg00XZLss=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "X8e8OA1+EUjGr0uVpwkvmKEFGdOE8Sif1ngaGEh5SmU=",
"shasum": "6CYAvvQA8tjddm13YblRAApORMK6yb5Ohmp6aLubvH4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "w7qMjYQa/4n/DMD33zMRIW6YGtp4vOiAC1GIzebGF6M=",
"shasum": "qz7638J0CvhehIGgkx9i+UzYWRgRajAoGoIH3o7DsNU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/wasm/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "afWjohN+iHMlPf+cooYW1l9bkvdxHNu5coHTSIVixlI=",
"shasum": "qt4KP5CPWCc9OkOmA/dS74ESPlbxTdlHcCVGjHbTbKk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "Vqgei7k5/YlpTKwwRtQMltlGMZJF6AWR/2UY9UYjMAo=",
"shasum": "Nm2zazUdQaJe8m5O6dNc8UpSX7u/1nY3xKjEkI/qgQM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/coverage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"branches": 91.98,
"functions": 96.73,
"functions": 96.74,
"lines": 97.95,
"statements": 97.63
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SnapId } from '@metamask/snaps-sdk';
import type { InterfaceState, SnapId } from '@metamask/snaps-sdk';
import { form, image, input, panel, text } from '@metamask/snaps-sdk';
import {
Box,
Expand Down Expand Up @@ -63,7 +63,17 @@ describe('SnapInterfaceController', () => {
);

expect(content).toStrictEqual(getJsxElementFromComponent(components));
expect(state).toStrictEqual({ foo: { bar: null } });
expect(state).toStrictEqual({
foo: {
type: 'Form',
value: {
bar: {
type: 'Input',
value: null,
},
},
},
});
});

it('can create a new interface from JSX', async () => {
Expand Down Expand Up @@ -113,7 +123,17 @@ describe('SnapInterfaceController', () => {
);

expect(content).toStrictEqual(element);
expect(state).toStrictEqual({ foo: { bar: null } });
expect(state).toStrictEqual({
foo: {
type: 'Form',
value: {
bar: {
type: 'Input',
value: null,
},
},
},
});
});

it('supports providing interface context', async () => {
Expand Down Expand Up @@ -474,7 +494,17 @@ describe('SnapInterfaceController', () => {
);

expect(content).toStrictEqual(getJsxElementFromComponent(newContent));
expect(state).toStrictEqual({ foo: { baz: null } });
expect(state).toStrictEqual({
foo: {
type: 'Form',
value: {
baz: {
type: 'Input',
value: null,
},
},
},
});
});

it('can update an interface using JSX', async () => {
Expand Down Expand Up @@ -523,7 +553,17 @@ describe('SnapInterfaceController', () => {
);

expect(content).toStrictEqual(newElement);
expect(state).toStrictEqual({ foo: { baz: null } });
expect(state).toStrictEqual({
foo: {
type: 'Form',
value: {
baz: {
type: 'Input',
value: null,
},
},
},
});
});

it('throws if a link is on the phishing list', async () => {
Expand Down Expand Up @@ -828,7 +868,17 @@ describe('SnapInterfaceController', () => {

const content = form({ name: 'foo', children: [input({ name: 'bar' })] });

const newState = { foo: { bar: 'baz' } };
const newState: InterfaceState = {
foo: {
type: 'Form',
value: {
bar: {
type: 'Input',
value: 'baz',
},
},
},
};

const id = await rootMessenger.call(
'SnapInterfaceController:createInterface',
Expand Down Expand Up @@ -869,13 +919,19 @@ describe('SnapInterfaceController', () => {
</Form>
);

const newState = {
const newState: InterfaceState = {
foo: {
bar: {
name: 'test.png',
size: 123,
contentType: 'image/png',
contents: 'foo',
type: 'Form',
value: {
bar: {
type: 'FileInput',
value: {
name: 'test.png',
size: 123,
contentType: 'image/png',
contents: 'foo',
},
},
},
},
};
Expand Down
Loading
Loading