Skip to content

Commit

Permalink
update metamask adapter package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharqiewicz committed Oct 16, 2024
1 parent af2bc98 commit 9ce5b1f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"postinstall": "husky install"
},
"dependencies": {
"@chainsafe/metamask-polkadot-adapter": "^0.6.0",
"@chainsafe/metamask-polkadot-types": "^0.6.0",
"@chainsafe/metamask-polkadot-adapter": "^0.8.1",
"@chainsafe/metamask-polkadot-types": "^0.9.1",
"@heroicons/react": "^2.1.1",
"@hookform/resolvers": "^2.9.11",
"@netlify/functions": "^2.8.2",
Expand Down
7 changes: 4 additions & 3 deletions src/services/metamask/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SignerPayloadJSON, SignerPayloadRaw, SignerResult } from '@polkadot/typ
import { enablePolkadotSnap } from '@chainsafe/metamask-polkadot-adapter';
import type { MetamaskPolkadotSnap } from '@chainsafe/metamask-polkadot-adapter/build/snap';
import { MetamaskSnapApi } from '@chainsafe/metamask-polkadot-adapter/build/types';
import type { SnapNetworks } from '@chainsafe/metamask-polkadot-types';
import type { SnapNetworks, SnapConfig } from '@chainsafe/metamask-polkadot-types';

import { TenantName } from '../../models/Tenant';
import { trimAddress } from '../../helpers/addressFormatter';
Expand All @@ -21,7 +21,7 @@ export function tenantToSnapNetwork(tenantName: TenantName): SnapNetworks {

export async function installPolkadotSnap(relayChain: SnapNetworks): Promise<boolean> {
try {
await enablePolkadotSnap({ networkName: relayChain });
await enablePolkadotSnap({ networkName: relayChain } as SnapConfig);
return true;
} catch (err) {
console.error('Failed to install PolkadotSnap, ', err);
Expand All @@ -36,7 +36,7 @@ export interface InitiatePolkadotSnapResponse {

export async function initiatePolkadotSnap(relayChain: SnapNetworks): Promise<InitiatePolkadotSnapResponse> {
try {
const metamaskPolkadotSnap = await enablePolkadotSnap({ networkName: relayChain });
const metamaskPolkadotSnap = await enablePolkadotSnap({ networkName: relayChain } as SnapConfig);
return { isSnapInstalled: true, snap: metamaskPolkadotSnap };
} catch (e) {
console.error(e);
Expand All @@ -60,6 +60,7 @@ const getProvider = async (tenantName: TenantName) => {

const getSigner = (api: MetamaskSnapApi) => ({
signPayload: async (payload: SignerPayloadJSON) => {
// @ts-expect-error The types are compatible, the library uses an older version of types definition
const stringResult = await api.signPayloadJSON(payload);
// Metamask snap doesn't provide a request Id, but just the hex string, so
// adding id: 1 to be compliant with SignerResult
Expand Down
95 changes: 76 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1539,23 +1539,23 @@ __metadata:
languageName: node
linkType: hard

"@chainsafe/metamask-polkadot-adapter@npm:^0.6.0":
version: 0.6.0
resolution: "@chainsafe/metamask-polkadot-adapter@npm:0.6.0"
"@chainsafe/metamask-polkadot-adapter@npm:^0.8.1":
version: 0.8.1
resolution: "@chainsafe/metamask-polkadot-adapter@npm:0.8.1"
dependencies:
"@polkadot/api": "npm:^10.9.1"
"@polkadot/extension-inject": "npm:^0.46.5"
"@polkadot/types-augment": "npm:^10.9.1"
checksum: 10c0/a9cdfdd175dc6d9f6aa1d6f4515185d3f2b4089154dd0cd47749f66c6e5965cd7ff0187245763f7aafa1be49d41e1d2e8d721c78a0e831afc506fb6ff229ae15
"@polkadot/api": "npm:^12.4.2"
"@polkadot/extension-inject": "npm:^0.52.3"
"@polkadot/types-augment": "npm:^12.4.2"
checksum: 10c0/b23d8c84d05d490ac4e92e2082bd1c1fe395a82f52837aa8034f962b21bb21a0d1dfee2728517af682449ab2bce119aea1334dcac9dee5ceac0696250b97571c
languageName: node
linkType: hard

"@chainsafe/metamask-polkadot-types@npm:^0.6.0":
version: 0.6.0
resolution: "@chainsafe/metamask-polkadot-types@npm:0.6.0"
"@chainsafe/metamask-polkadot-types@npm:^0.9.1":
version: 0.9.1
resolution: "@chainsafe/metamask-polkadot-types@npm:0.9.1"
dependencies:
"@polkadot/api": "npm:^10.9.1"
checksum: 10c0/fa1ffef61ec33bfd3020e7629efac0bfe62d164f4dcc6fa1efd9424a266f6ca94447688a1afd0d403c69b1e127082d4fd68dfedf35ef6c70fa2594dc96b6a359
"@polkadot/api": "npm:^12.4.2"
checksum: 10c0/1728e5ae35aaa48cc9f415fb228fc2b1becaab2f34e151b6a8139150f32ea1ae0ead68dfa11e4bb2d44d9ed5cce224670113a16ba4ca7cd5468ddbddfb6e2d89
languageName: node
linkType: hard

Expand Down Expand Up @@ -3845,7 +3845,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/keyring@npm:^13.1.1":
"@polkadot/keyring@npm:^13.0.2, @polkadot/keyring@npm:^13.1.1":
version: 13.1.1
resolution: "@polkadot/keyring@npm:13.1.1"
dependencies:
Expand Down Expand Up @@ -3956,7 +3956,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/types-augment@npm:10.13.1, @polkadot/types-augment@npm:^10.9.1":
"@polkadot/types-augment@npm:10.13.1":
version: 10.13.1
resolution: "@polkadot/types-augment@npm:10.13.1"
dependencies:
Expand All @@ -3968,6 +3968,18 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/types-augment@npm:12.4.2, @polkadot/types-augment@npm:^12.4.2":
version: 12.4.2
resolution: "@polkadot/types-augment@npm:12.4.2"
dependencies:
"@polkadot/types": "npm:12.4.2"
"@polkadot/types-codec": "npm:12.4.2"
"@polkadot/util": "npm:^13.0.2"
tslib: "npm:^2.6.3"
checksum: 10c0/9dcae5ec9fd7aaac9d3ffe2f5adb9b5c4704376018db4860215ca38805b189c5ef2f90360da0ff29d8b9a9715617bb5eabf6870bcfd8f9eeba974d6eb9b5bfab
languageName: node
linkType: hard

"@polkadot/types-augment@npm:13.2.1, @polkadot/types-augment@npm:^13.2.1":
version: 13.2.1
resolution: "@polkadot/types-augment@npm:13.2.1"
Expand All @@ -3991,6 +4003,17 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/types-codec@npm:12.4.2":
version: 12.4.2
resolution: "@polkadot/types-codec@npm:12.4.2"
dependencies:
"@polkadot/util": "npm:^13.0.2"
"@polkadot/x-bigint": "npm:^13.0.2"
tslib: "npm:^2.6.3"
checksum: 10c0/2a56694e6998fc2afbe4fe8a9f9805eb251e880f1343af380f70c42965d30bae2249e5a5f346e675d5f78173770ebd4fa0758ed8b9f1397db8183eb686d11842
languageName: node
linkType: hard

"@polkadot/types-codec@npm:13.2.1, @polkadot/types-codec@npm:^13.2.1":
version: 13.2.1
resolution: "@polkadot/types-codec@npm:13.2.1"
Expand All @@ -4013,6 +4036,17 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/types-create@npm:12.4.2":
version: 12.4.2
resolution: "@polkadot/types-create@npm:12.4.2"
dependencies:
"@polkadot/types-codec": "npm:12.4.2"
"@polkadot/util": "npm:^13.0.2"
tslib: "npm:^2.6.3"
checksum: 10c0/c075d07c2d3212f0ab9772cd008bfadccde7a35f6366c6704a326f8e5199fce7e7eb7959a6bd229b69fcbc3900c522892f94b08b4cd991be6e42f2a786585d0f
languageName: node
linkType: hard

"@polkadot/types-create@npm:13.2.1, @polkadot/types-create@npm:^13.2.1":
version: 13.2.1
resolution: "@polkadot/types-create@npm:13.2.1"
Expand Down Expand Up @@ -4074,6 +4108,22 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/types@npm:12.4.2":
version: 12.4.2
resolution: "@polkadot/types@npm:12.4.2"
dependencies:
"@polkadot/keyring": "npm:^13.0.2"
"@polkadot/types-augment": "npm:12.4.2"
"@polkadot/types-codec": "npm:12.4.2"
"@polkadot/types-create": "npm:12.4.2"
"@polkadot/util": "npm:^13.0.2"
"@polkadot/util-crypto": "npm:^13.0.2"
rxjs: "npm:^7.8.1"
tslib: "npm:^2.6.3"
checksum: 10c0/bdea1658a367678a158d5d6ba6224a081cfd5fb38b6d56c360321e40628a23261261c869e7ab1ac0c89c0140777f532963c46999e5fb0f13233599a32eabdf99
languageName: node
linkType: hard

"@polkadot/types@npm:13.2.1, @polkadot/types@npm:^13.2.1":
version: 13.2.1
resolution: "@polkadot/types@npm:13.2.1"
Expand Down Expand Up @@ -4110,7 +4160,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/util-crypto@npm:13.1.1, @polkadot/util-crypto@npm:^13.1.1":
"@polkadot/util-crypto@npm:13.1.1, @polkadot/util-crypto@npm:^13.0.2, @polkadot/util-crypto@npm:^13.1.1":
version: 13.1.1
resolution: "@polkadot/util-crypto@npm:13.1.1"
dependencies:
Expand Down Expand Up @@ -4145,7 +4195,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/util@npm:13.1.1, @polkadot/util@npm:^13.1.1":
"@polkadot/util@npm:13.1.1, @polkadot/util@npm:^13.0.2, @polkadot/util@npm:^13.1.1":
version: 13.1.1
resolution: "@polkadot/util@npm:13.1.1"
dependencies:
Expand Down Expand Up @@ -4250,7 +4300,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/x-bigint@npm:13.1.1, @polkadot/x-bigint@npm:^13.1.1":
"@polkadot/x-bigint@npm:13.1.1, @polkadot/x-bigint@npm:^13.0.2, @polkadot/x-bigint@npm:^13.1.1":
version: 13.1.1
resolution: "@polkadot/x-bigint@npm:13.1.1"
dependencies:
Expand Down Expand Up @@ -14065,8 +14115,8 @@ __metadata:
"@babel/plugin-proposal-class-properties": "npm:^7.18.6"
"@babel/preset-env": "npm:^7.23.7"
"@babel/preset-typescript": "npm:^7.24.1"
"@chainsafe/metamask-polkadot-adapter": "npm:^0.6.0"
"@chainsafe/metamask-polkadot-types": "npm:^0.6.0"
"@chainsafe/metamask-polkadot-adapter": "npm:^0.8.1"
"@chainsafe/metamask-polkadot-types": "npm:^0.9.1"
"@graphql-codegen/cli": "npm:^5.0.2"
"@graphql-codegen/client-preset": "npm:^4.2.6"
"@heroicons/react": "npm:^2.1.1"
Expand Down Expand Up @@ -17275,6 +17325,13 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.6.3":
version: 2.8.0
resolution: "tslib@npm:2.8.0"
checksum: 10c0/31e4d14dc1355e9b89e4d3c893a18abb7f90b6886b089c2da91224d0a7752c79f3ddc41bc1aa0a588ac895bd97bb99c5bc2bfdb2f86de849f31caeb3ba79bbe5
languageName: node
linkType: hard

"tslib@npm:^2.7.0":
version: 2.7.0
resolution: "tslib@npm:2.7.0"
Expand Down

0 comments on commit 9ce5b1f

Please sign in to comment.