Skip to content

Commit

Permalink
fix: Using metaMask sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Dec 2, 2024
1 parent 3e65bf8 commit 55e3443
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-hotels-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@node-real/walletkit': patch
---

Using metaMask sdk
2 changes: 1 addition & 1 deletion packages/walletkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@node-real/walletkit",
"version": "2.4.1-alpha.9",
"version": "2.6.0",
"author": "node-real",
"private": false,
"description": "WalletKit is a React component library for easily connecting a wallet to your dApp.",
Expand Down
26 changes: 15 additions & 11 deletions packages/walletkit/src/evm/wallets/metaMask/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { metaMaskConfig } from '@/core/configs/metaMask';
import { hasEvmInjectedProvider } from '../utils';
import { injected } from '../injected';
import { InjectedEvmWalletOptions, EvmWallet } from '../types';
import { isAndroid, isTMA } from '@/core/base/utils/mobile';
import { EvmWallet } from '../types';
import { MetaMaskParameters, metaMask as metaMaskSDk } from 'wagmi/connectors';
import { openLink } from '@/core/utils/common';

export function metaMask(props: InjectedEvmWalletOptions = {}): EvmWallet {
export interface MetaMaskOptions extends Partial<EvmWallet> {
connectorOptions?: MetaMaskParameters;
}

export function metaMask(props: MetaMaskOptions = {}): EvmWallet {
const { connectorOptions, ...restProps } = props;

return {
Expand All @@ -20,16 +24,16 @@ export function metaMask(props: InjectedEvmWalletOptions = {}): EvmWallet {
return `https://metamask.app.link/dapp/${dappPath}`;
},
getUri(uri) {
let encodedUri = encodeURIComponent(uri);
if (isTMA() && isAndroid()) {
encodedUri = encodeURIComponent(encodedUri);
}
const encodedUri = encodeURIComponent(uri);
return `https://metamask.app.link/wc?uri=${encodedUri}`;
},
getCreateConnectorFn() {
return injected({
shimDisconnect: true,
target: 'metaMask',
return metaMaskSDk({
useDeeplink: false,
headless: true,
openDeeplink(arg) {
openLink(arg);
},
...connectorOptions,
});
},
Expand Down

0 comments on commit 55e3443

Please sign in to comment.