Skip to content

Commit

Permalink
use polkagate package
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Dec 4, 2023
1 parent aefddc9 commit f309e61
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/dapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import TransferFund from './TransferFund';
import React, { useCallback, useEffect, useState } from 'react';
import type { InjectedAccountWithMeta, InjectedExtension } from '@polkadot/extension-inject/types';
import './App.css';
import { web3Accounts, web3Enable } from '@polkadot/extension-dapp';
import { web3Accounts, web3Enable } from '@polkagate/extension-dapp';
import { Box, Tabs, Tab, Button, Grid, Typography } from '@mui/material';
import { ApiPromise, WsProvider } from '@polkadot/api';
import useEndpoint from './hooks/useEndpoint';
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import './App.css';
import LoadingButton from '@mui/lab/LoadingButton';
import { Key as KeyIcon, CheckCircle as CheckCircleIcon } from '@mui/icons-material';
import { web3FromSource } from '@polkadot/extension-dapp';
import { web3FromSource } from '@polkagate/extension-dapp';
import { Divider, Grid, TextField, Typography } from '@mui/material';
import { ApiPromise } from '@polkadot/api';
import type { DeriveBalancesAll } from '@polkadot/api-derive/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/TransferFund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import './App.css';
import LoadingButton from '@mui/lab/LoadingButton';
import SendIcon from '@mui/icons-material/Send';
import { web3FromSource } from '@polkadot/extension-dapp';
import { web3FromSource } from '@polkagate/extension-dapp';
import { Box, CircularProgress, Divider, Grid, InputAdornment, Link, Skeleton, TextField, Typography } from '@mui/material';
import { ApiPromise } from '@polkadot/api';
import type { DeriveBalancesAll } from '@polkadot/api-derive/types';
Expand Down
25 changes: 20 additions & 5 deletions packages/dapp/src/util/consts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
const LOCAL_SNAP_ID = 'local:http://localhost:8080';
// const NPM_SNAP_ID = 'npm:@polkagate/snap';
import { getLatestPackageVersion } from "./getLatestPackageVersion";

let SNAP_VERSION = '>=0.1.5';

// Example usage
const packageName = '@polkagate/snap';
getLatestPackageVersion(packageName)
.then((latestVersion) => {
SNAP_VERSION = latestVersion;
console.log(`Latest version of ${packageName}: ${latestVersion}`);
})
.catch((error) => {
console.error('Failed to get the latest version:', error);
});

// const LOCAL_SNAP_ID = 'local:http://localhost:8080';
const NPM_SNAP_ID = 'npm:@polkagate/snap';

// export const POLKAMASK_SNAP_IDS = [LOCAL_SNAP_ID, NPM_SNAP_ID]

export const DEFAULT_SNAP_ORIGIN =
// process.env.SNAP_ORIGIN ?? `npm:@polkagate/snap`;
process.env.SNAP_ORIGIN ?? LOCAL_SNAP_ID;
process.env.SNAP_ORIGIN ?? NPM_SNAP_ID;
// process.env.SNAP_ORIGIN ?? LOCAL_SNAP_ID;

export const SUPPORTED_SNAPS = {
[DEFAULT_SNAP_ORIGIN]: { version: '>=0.1.4' },
[DEFAULT_SNAP_ORIGIN]: { version: SNAP_VERSION },
// 'npm:@chainsafe/polkadot-snap': {},
};

Expand Down
37 changes: 19 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5715,23 +5715,6 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/extension-dapp@file:../../../polkadot-js-extension/packages/extension-dapp/build::locator=dapp%40workspace%3Apackages%2Fdapp":
version: 0.46.6-7-x
resolution: "@polkadot/extension-dapp@file:../../../polkadot-js-extension/packages/extension-dapp/build#../../../polkadot-js-extension/packages/extension-dapp/build::hash=e4fe7b&locator=dapp%40workspace%3Apackages%2Fdapp"
dependencies:
"@polkadot/extension-inject": latest
"@polkadot/types": ^10.10.1
"@polkadot/util": ^12.5.1
"@polkadot/util-crypto": ^12.5.1
tslib: ^2.6.2
peerDependencies:
"@polkadot/api": "*"
"@polkadot/util": "*"
"@polkadot/util-crypto": "*"
checksum: 9802f5dab5adb9ad706085f57cf281658172c4db08da74fa35dad5def1e94e03f9136c20e48082db99f2a55767eeb384b5d1a1e81af5b192926644e173a2e5d3
languageName: node
linkType: hard

"@polkadot/extension-inject@npm:latest":
version: 0.46.6
resolution: "@polkadot/extension-inject@npm:0.46.6"
Expand Down Expand Up @@ -7107,6 +7090,23 @@ __metadata:
languageName: node
linkType: hard

"@polkagate/extension-dapp@npm:^0.46.6-17":
version: 0.46.6-17
resolution: "@polkagate/extension-dapp@npm:0.46.6-17"
dependencies:
"@polkadot/extension-inject": latest
"@polkadot/types": ^10.10.1
"@polkadot/util": ^12.5.1
"@polkadot/util-crypto": ^12.5.1
tslib: ^2.6.2
peerDependencies:
"@polkadot/api": "*"
"@polkadot/util": "*"
"@polkadot/util-crypto": "*"
checksum: 647b396c4709eb1150f3df6e9e9409ed6ffe019d16cec78cfea2fbb9d202abe1bf92608c0bd9223a96d5d4882338445e9478f1254aff676e804d0765bd68a6c9
languageName: node
linkType: hard

"@polkagate/polkamask@workspace:.":
version: 0.0.0-use.local
resolution: "@polkagate/polkamask@workspace:."
Expand Down Expand Up @@ -11969,15 +11969,16 @@ __metadata:
dependencies:
"@emotion/react": latest
"@emotion/styled": latest
"@metamask/detect-provider": ^2.0.0
"@metamask/providers": latest
"@mui/icons-material": latest
"@mui/lab": latest
"@mui/material": latest
"@polkadot/api": latest
"@polkadot/api-derive": latest
"@polkadot/apps-config": latest
"@polkadot/extension-dapp": ../../../polkadot-js-extension/packages/extension-dapp/build
"@polkadot/extension-inject": latest
"@polkagate/extension-dapp": ^0.46.6-17
"@testing-library/jest-dom": ^5.17.0
"@testing-library/react": ^13.4.0
"@testing-library/user-event": ^13.5.0
Expand Down

0 comments on commit f309e61

Please sign in to comment.