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

Allow for metamask: schemed URLs #2719

Merged
merged 29 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7710379
Add navigation to button
hmalik88 Sep 12, 2024
b1c97e9
update shasums
hmalik88 Sep 12, 2024
393094c
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 12, 2024
cf1b918
recalculate shasums
hmalik88 Sep 12, 2024
38e10b5
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 12, 2024
8a28736
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 13, 2024
a531f15
add icon as link child, introduce metamask urls
hmalik88 Sep 13, 2024
432a509
add getSnap function for updated validation function signature
hmalik88 Sep 13, 2024
3b3ebdd
update link validation functions to check for metamask scheme
hmalik88 Sep 13, 2024
dabf345
update validate link call
hmalik88 Sep 13, 2024
b732264
recalculate shasums
hmalik88 Sep 13, 2024
1ef2fc6
update tests
hmalik88 Sep 13, 2024
082292e
fix lint issue
hmalik88 Sep 13, 2024
870f5de
add more tests, fix logic
hmalik88 Sep 13, 2024
c672e2b
made some changes per review
hmalik88 Sep 16, 2024
b211949
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 16, 2024
eaa563b
make changes per comments
hmalik88 Sep 17, 2024
bb80c95
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 17, 2024
396bc37
add note to jsdoc
hmalik88 Sep 17, 2024
9b5f00b
make changes per review
hmalik88 Sep 19, 2024
2dcc0fe
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 19, 2024
34cb66a
update jsdoc
hmalik88 Sep 19, 2024
28089ac
Merge branch 'main' into hm/add-navigation-to-button
hmalik88 Sep 23, 2024
e6009c3
rebuild
hmalik88 Sep 23, 2024
972329b
apply code review
hmalik88 Sep 24, 2024
cc5b1e9
fix order
hmalik88 Sep 24, 2024
f361fd6
fix test
hmalik88 Sep 24, 2024
f92e768
fix coverage
hmalik88 Sep 24, 2024
11bfb5b
fix coverage again
hmalik88 Sep 24, 2024
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
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": "jBWYn37FTI6J3QI2ORlw36g4uXpIcBdH3n4o0CRdDvk=",
"shasum": "oqO5wicjNs9i86WgNV2vx79nOYYD/uxnOtAOECtWqzU=",
"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": "GKhf9ua3RUl21+DodL6sdx+DQFBkkdjVHMxHQy0GjGE=",
"shasum": "LQJI6F5ptgr0wY9vQ+58Q8Tv8VyMx/8lvkDSmDgdqVM=",
"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": "v2oIs3UY5j/3dXW5eRh3rg7Tv5qcVzHon7qzPQeRsAE=",
"shasum": "zuBFS3XWpLP7vKsIJqiecvXakBW9rgzuVToBRS0ItSg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/file-upload/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": "z4vMdrs40TdVE+vk7sPruIvWi0q669V+p3jc6WQIib4=",
"shasum": "exoRIe26MvGPe9XZxn8uq/xBn8uYvzvn0y6L5uTPlKM=",
"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": "emnlXHvrhsGBMi/y1IPhiQPX9ogHmjmOU/iujBu5GB8=",
"shasum": "x94obetFeJZPEwAU/DsNvFj5/eotAwlylCGS7IfM+84=",
"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": "uOuMArCEwmOmCl0Bl1WnRRm+DKcq0Y+O+5n8Z1KBMr8=",
"shasum": "iN1fXS+FpkQR21mGkHO0N+xo4nW3HFwsfXOsGTpiM68=",
"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": "3U9+Lvmmdc9JRmaHLcwGgi9lpnaj25joBF9+zXY4644=",
"shasum": "Rv/yARDSnZz9twUQ/mUWpNFSjjRkNy68DUy2gTwq+ZA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
13 changes: 13 additions & 0 deletions packages/snaps-sdk/src/jsx/components/form/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ describe('Button', () => {
key: null,
});
});

it('returns a button element with navigation props', () => {
const result = <Button navigateTo="home">bar</Button>;

expect(result).toStrictEqual({
type: 'Button',
props: {
children: 'bar',
navigateTo: 'home',
},
key: null,
});
});
});
7 changes: 7 additions & 0 deletions packages/snaps-sdk/src/jsx/components/form/Button.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import type { EnumToUnion } from 'src/internals';

import type { SnapsChildren, StringElement } from '../../component';
import { createSnapComponent } from '../../component';
import type { IconElement } from '../Icon';
import type { ImageElement } from '../Image';

export enum SnapRoutes {
Home = 'home',
}

hmalik88 marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Add the `onClick` prop to the `ButtonProps` type.

/**
Expand All @@ -25,6 +31,7 @@ export type ButtonProps = {
variant?: 'primary' | 'destructive' | undefined;
disabled?: boolean | undefined;
form?: string | undefined;
navigateTo?: EnumToUnion<SnapRoutes> | undefined;
};

const TYPE = 'Button';
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/jsx/validation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ describe('ButtonStruct', () => {
<Image src="<svg></svg>" />
</Button>,
<Button form="foo">bar</Button>,
<Button navigateTo="home">Go home</Button>,
])('validates a button element', (value) => {
expect(is(value, ButtonStruct)).toBe(true);
});
Expand All @@ -192,6 +193,8 @@ describe('ButtonStruct', () => {
<Row label="label">
<Image src="<svg />" alt="alt" />
</Row>,
// @ts-expect-error - Invalid props.
<Button navigateTo="foo">Go foo</Button>,
])('does not validate "%p"', (value) => {
expect(is(value, ButtonStruct)).toBe(false);
});
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const ButtonStruct: Describe<ButtonElement> = element('Button', {
variant: optional(nullUnion([literal('primary'), literal('destructive')])),
disabled: optional(boolean()),
form: optional(string()),
navigateTo: optional(nullUnion([literal('home')])),
});

/**
Expand Down
Loading