diff --git a/package.json b/package.json index 1365b7a8895deb3aa2ff7293cddda7e5dd56f9ff..cc7fe506c8464d2235ec26bfa3779b8bcb0dd9d5 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "license": "MIT", "type": "module", "files": [ - "dist/index.html", - "dist/assets" + "dist" ], "scripts": { "start": "vite", @@ -24,7 +23,6 @@ }, "dependencies": {}, "devDependencies": { - "@hiveio/metamask-snap": "1.0.0", "@hiveio/wax": "1.27.6-rc7-250304235913", "@mdi/js": "^7.4.47", "@metamask/providers": "^16.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 282e338539b1925da46cb6a9419db6ea48901a0e..2e8ca622634e4aff39a2a11937af46e654d1033b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: devDependencies: - '@hiveio/metamask-snap': - specifier: 1.0.0 - version: 1.0.0 '@hiveio/wax': specifier: 1.27.6-rc7-250304235913 version: 1.27.6-rc7-250304235913 @@ -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} 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': 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} @@ -1639,8 +1632,6 @@ snapshots: '@hiveio/beekeeper@1.27.9-stable.250219154236': {} - '@hiveio/metamask-snap@1.0.0': {} - '@hiveio/wax@1.27.6-rc7-250304235913': dependencies: '@hiveio/beekeeper': 1.27.9-stable.250219154236 diff --git a/public/dist/bundle.js b/public/dist/bundle.js deleted file mode 120000 index 7735287f474919783ebe4a0030c413f12632d0ba..0000000000000000000000000000000000000000 --- a/public/dist/bundle.js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/@hiveio/metamask-snap/dist/bundle.js \ No newline at end of file diff --git a/public/snap.manifest.json b/public/snap.manifest.json deleted file mode 120000 index f36a9f0773fe6e1cafbdf5d05ab6831795d9e24a..0000000000000000000000000000000000000000 --- a/public/snap.manifest.json +++ /dev/null @@ -1 +0,0 @@ -../node_modules/@hiveio/metamask-snap/snap.manifest.json \ No newline at end of file diff --git a/public/src/assets/icon.svg b/public/src/assets/icon.svg deleted file mode 120000 index 913d5945cabab987f6622d28b97f7c624daf8aa3..0000000000000000000000000000000000000000 --- a/public/src/assets/icon.svg +++ /dev/null @@ -1 +0,0 @@ -../../../node_modules/@hiveio/metamask-snap/src/assets/icon.svg \ No newline at end of file diff --git a/src/utils/wallet/metamask/metamask.ts b/src/utils/wallet/metamask/metamask.ts index d965c294c356cef59f617f50e74877f0731af57d..1da6ed0b51281d81e690ab30592f99ab43346c40 100644 --- a/src/utils/wallet/metamask/metamask.ts +++ b/src/utils/wallet/metamask/metamask.ts @@ -1,5 +1,5 @@ import type { MetaMaskInpageProvider } from "@metamask/providers"; -import { defaultSnapOrigin, isLocalSnap } from "./snap"; +import { defaultSnapOrigin, defaultSnapVersion, isLocalSnap } from "./snap"; export type MetamaskSnapData = { permissionName: string; @@ -37,9 +37,9 @@ export class MetamaskWallet { * Request the snap to be installed or reinstalled. * 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', { - [defaultSnapOrigin]: version ? { version } : {} + [defaultSnapOrigin]: (typeof version === "undefined" || version.length === 0) ? {} : { version } }) as MetamaskSnapsResponse; this.currentSnap = snaps[defaultSnapOrigin]!; diff --git a/src/utils/wallet/metamask/snap.ts b/src/utils/wallet/metamask/snap.ts index 423a4298cce798341a7c0d7a5d965552d044169e..8d313dffc610ffbf2649e68b82df20547c90df86 100644 --- a/src/utils/wallet/metamask/snap.ts +++ b/src/utils/wallet/metamask/snap.ts @@ -6,7 +6,9 @@ * 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. */ -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.