Skip to content

Commit

Permalink
feat: add talisman
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Jul 26, 2023
1 parent a8c910a commit 5581ec7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@react-stately/tooltip": "^3.2.3",
"@react-stately/tree": "^3.4.1",
"@tailwindcss/forms": "^0.3.2",
"@talismn/connect-wallets": "^1.2.3",
"big.js": "^6.1.1",
"chart.js": "^2.9.4",
"clsx": "^1.1.1",
Expand Down
14 changes: 14 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './i18n';

import { FaucetClient, SecurityStatusCode } from '@interlay/interbtc-api';
import { Keyring } from '@polkadot/keyring';
import { getWallets } from '@talismn/connect-wallets';
import * as React from 'react';
import { useErrorHandler, withErrorBoundary } from 'react-error-boundary';
import { useQuery } from 'react-query';
Expand Down Expand Up @@ -91,6 +92,19 @@ const App = (): JSX.Element => {
);
useErrorHandler(vaultsError);

// get an array of wallets which are installed
const installedWallets = getWallets().filter((wallet) => wallet.installed);

console.log(getWallets());

// get talisman from the array of installed wallets
const talismanWallet = installedWallets.find((wallet) => wallet.extensionName === 'subwallet');

// enable the wallet
if (talismanWallet) {
console.log(talismanWallet.enable('myCoolDapp'));
}

// Initializes data on app bootstrap
React.useEffect(() => {
if (!dispatch) return;
Expand Down
16 changes: 16 additions & 0 deletions src/lib/wallet/WalletProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

// eslint-disable-next-line @typescript-eslint/ban-types
type WalletConfig = {};

const defaultContext: WalletConfig = {} as WalletConfig;

const WalletContext = React.createContext(defaultContext);

const useWallet = (): WalletConfig => React.useContext(WalletContext);

const WalletProvider: React.FC<unknown> = ({ children }) => {
return <WalletContext.Provider value={{}}>{children}</WalletContext.Provider>;
};

export { useWallet, WalletContext, WalletProvider };
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5887,6 +5887,11 @@
resolve "^1.20.0"
tmp "^0.2.1"

"@talismn/connect-wallets@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@talismn/connect-wallets/-/connect-wallets-1.2.3.tgz#4aa91f2c554d692e9f49472f74dcc96fca319df5"
integrity sha512-6hLYeDnMjrlsNLF6a9e7ngxKMkKW3uTC2IbBjtTPq9fxA1VvApmxR8egboPzU7sgFQEuUFP36KN1hFAtfRIVhw==

"@testing-library/dom@^8.0.0":
version "8.20.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.0.tgz#914aa862cef0f5e89b98cc48e3445c4c921010f6"
Expand Down

0 comments on commit 5581ec7

Please sign in to comment.