Skip to content
Snippets Groups Projects
Verified Commit 142d0b0b authored by Mateusz Tyszczak's avatar Mateusz Tyszczak :scroll:
Browse files

Use snap from npm

parent a1cb093f
No related branches found
No related tags found
No related merge requests found
Pipeline #117414 passed
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"files": [ "files": [
"dist/index.html", "dist"
"dist/assets"
], ],
"scripts": { "scripts": {
"start": "vite", "start": "vite",
...@@ -24,7 +23,6 @@ ...@@ -24,7 +23,6 @@
}, },
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"@hiveio/metamask-snap": "1.0.0",
"@hiveio/wax": "1.27.6-rc7-250304235913", "@hiveio/wax": "1.27.6-rc7-250304235913",
"@mdi/js": "^7.4.47", "@mdi/js": "^7.4.47",
"@metamask/providers": "^16.0.0", "@metamask/providers": "^16.0.0",
......
...@@ -8,9 +8,6 @@ importers: ...@@ -8,9 +8,6 @@ importers:
.: .:
devDependencies: devDependencies:
'@hiveio/metamask-snap':
specifier: 1.0.0
version: 1.0.0
'@hiveio/wax': '@hiveio/wax':
specifier: 1.27.6-rc7-250304235913 specifier: 1.27.6-rc7-250304235913
version: 1.27.6-rc7-250304235913 version: 1.27.6-rc7-250304235913
...@@ -287,10 +284,6 @@ packages: ...@@ -287,10 +284,6 @@ packages:
resolution: {integrity: sha1-6fL+OgTwp6MSp0Xm3fwj+kFLzD8=, tarball: https://gitlab.syncad.com/api/v4/projects/198/packages/npm/@hiveio/beekeeper/-/@hiveio/beekeeper-1.27.9-stable.250219154236.tgz} resolution: {integrity: sha1-6fL+OgTwp6MSp0Xm3fwj+kFLzD8=, tarball: https://gitlab.syncad.com/api/v4/projects/198/packages/npm/@hiveio/beekeeper/-/@hiveio/beekeeper-1.27.9-stable.250219154236.tgz}
engines: {node: ^20.11 || >= 21.2} engines: {node: ^20.11 || >= 21.2}
'@hiveio/metamask-snap@1.0.0':
resolution: {integrity: sha1-J1nqU58VQL1u50HG17e3W+ScKMw=, tarball: https://gitlab.syncad.com/api/v4/projects/514/packages/npm/@hiveio/metamask-snap/-/@hiveio/metamask-snap-1.0.0.tgz}
engines: {node: ^20.18.1 || >= 21.2}
'@hiveio/wax@1.27.6-rc7-250304235913': '@hiveio/wax@1.27.6-rc7-250304235913':
resolution: {integrity: sha1-Dk27ws/cbPd8P+aomJlGCzL98rI=, tarball: https://gitlab.syncad.com/api/v4/projects/419/packages/npm/@hiveio/wax/-/@hiveio/wax-1.27.6-rc7-250304235913.tgz} resolution: {integrity: sha1-Dk27ws/cbPd8P+aomJlGCzL98rI=, tarball: https://gitlab.syncad.com/api/v4/projects/419/packages/npm/@hiveio/wax/-/@hiveio/wax-1.27.6-rc7-250304235913.tgz}
engines: {node: ^20.11 || >= 21.2} engines: {node: ^20.11 || >= 21.2}
...@@ -1639,8 +1632,6 @@ snapshots: ...@@ -1639,8 +1632,6 @@ snapshots:
'@hiveio/beekeeper@1.27.9-stable.250219154236': {} '@hiveio/beekeeper@1.27.9-stable.250219154236': {}
'@hiveio/metamask-snap@1.0.0': {}
'@hiveio/wax@1.27.6-rc7-250304235913': '@hiveio/wax@1.27.6-rc7-250304235913':
dependencies: dependencies:
'@hiveio/beekeeper': 1.27.9-stable.250219154236 '@hiveio/beekeeper': 1.27.9-stable.250219154236
......
../../node_modules/@hiveio/metamask-snap/dist/bundle.js
\ No newline at end of file
../node_modules/@hiveio/metamask-snap/snap.manifest.json
\ No newline at end of file
../../../node_modules/@hiveio/metamask-snap/src/assets/icon.svg
\ No newline at end of file
import type { MetaMaskInpageProvider } from "@metamask/providers"; import type { MetaMaskInpageProvider } from "@metamask/providers";
import { defaultSnapOrigin, isLocalSnap } from "./snap"; import { defaultSnapOrigin, defaultSnapVersion, isLocalSnap } from "./snap";
export type MetamaskSnapData = { export type MetamaskSnapData = {
permissionName: string; permissionName: string;
...@@ -37,9 +37,9 @@ export class MetamaskWallet { ...@@ -37,9 +37,9 @@ export class MetamaskWallet {
* Request the snap to be installed or reinstalled. * Request the snap to be installed or reinstalled.
* You can check if snap is installed using {@link isInstalled} * You can check if snap is installed using {@link isInstalled}
*/ */
public async installSnap(version?: string) { public async installSnap(version: string | undefined = defaultSnapVersion) {
const snaps = await this.request('wallet_requestSnaps', { const snaps = await this.request('wallet_requestSnaps', {
[defaultSnapOrigin]: version ? { version } : {} [defaultSnapOrigin]: (typeof version === "undefined" || version.length === 0) ? {} : { version }
}) as MetamaskSnapsResponse; }) as MetamaskSnapsResponse;
this.currentSnap = snaps[defaultSnapOrigin]!; this.currentSnap = snaps[defaultSnapOrigin]!;
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
* don't. Instead, rename `.env.production.dist` to `.env.production` and set the production URL * don't. Instead, rename `.env.production.dist` to `.env.production` and set the production URL
* there. Running `yarn build` will automatically use the production environment variables. * there. Running `yarn build` will automatically use the production environment variables.
*/ */
export const defaultSnapOrigin = import.meta.env.SNAP_ORIGIN ?? `local:${window.location.protocol}//${window.location.host}`; export const defaultSnapOrigin = import.meta.env.SNAP_ORIGIN ?? `npm:@hiveio/metamask-snap`;
export const defaultSnapVersion: string | undefined = import.meta.env.SNAP_VERSION ?? '1.0.1';
/** /**
* Check if a snap ID is a local snap ID. * Check if a snap ID is a local snap ID.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment