Skip to content

Commit

Permalink
feat: add deeplinks for bitkeep, coin98, imtoken, metamask, okx, trust
Browse files Browse the repository at this point in the history
  • Loading branch information
alx-khramov committed Apr 16, 2024
1 parent 95c2525 commit 2d4be62
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/wallets/bitkeep/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ declare global {
// using previous "bitkeep" name here not to break metrics
export const id = 'bitget';
export const name = 'Bitget';
const currentHref = globalThis.window
? encodeURIComponent(globalThis.window.location.href)
: '';

export class BitgetConnector extends InjectedConnector {
readonly id = id;
Expand All @@ -37,6 +40,7 @@ export const Bitget: WalletAdapterType = ({ chains }) => ({
downloadURLs: {
default: 'https://web3.bitget.com/',
},
deeplink: `https://bkcode.vip?action=dapp&url=${currentHref}`,
connector: new BitgetConnector(chains),
});

Expand Down
4 changes: 3 additions & 1 deletion packages/wallets/coin98/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare global {

export const id = 'coin98';
export const name = 'Coin98';
const currentHost = globalThis.window?.location.host || '';

export class Coin98Connector extends InjectedConnector {
readonly id = id;
Expand All @@ -34,13 +35,14 @@ export class Coin98Connector extends InjectedConnector {
}
}

export const Coin98: WalletAdapterType = ({ chains }) => ({
export const Coin98: WalletAdapterType = ({ chains, defaultChain }) => ({
walletName: name,
walletId: id,
icon: WalletIcon,
detector: () =>
!!globalThis.window?.coin98?.provider ||
!!globalThis.window?.ethereum?.isCoin98,
deeplink: `https://coin98.com/dapp/${currentHost}/${defaultChain.id}`,
downloadURLs: {
default: 'https://coin98.com/wallet',
ios: 'https://ios.coin98.com',
Expand Down
4 changes: 4 additions & 0 deletions packages/wallets/imtoken/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ declare module '@wagmi/core' {

export const id = 'imToken';
export const name = 'imToken';
const currentHref = globalThis.window
? encodeURIComponent(globalThis.window.location.href)
: '';

export class ImTokenConnector extends InjectedConnector {
readonly id = id;
Expand All @@ -30,6 +33,7 @@ export const ImToken: WalletAdapterType = ({ chains }) => ({
walletId: id,
icon: WalletIcon,
detector: () => !!globalThis.window?.ethereum?.isImToken,
deeplink: `imtokenv2://navigate/DappView?url=${currentHref}`,
downloadURLs: {
default: 'https://token.im/download',
},
Expand Down
6 changes: 5 additions & 1 deletion packages/wallets/metamask/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { WalletIcon, WalletIconInverted } from './icons/index.js';

export const id = 'metamask';
export const name = 'MetaMask';
const currentHref = globalThis.window
? globalThis.window.location.hostname + globalThis.window.location.pathname // encoding not supported
: '';

export const MetaMask: WalletAdapterType = ({ chains }) => ({
walletName: name,
Expand All @@ -14,8 +17,9 @@ export const MetaMask: WalletAdapterType = ({ chains }) => ({
},
detector: () => !!globalThis.window?.ethereum?.isMetaMask,
downloadURLs: {
default: 'https://metamask.app.link/dapp/',
default: 'https://metamask.io/download/',
},
deeplink: `https://metamask.app.link/dapp/${currentHref}`,
connector: new MetaMaskConnector({
chains,
options: {
Expand Down
9 changes: 9 additions & 0 deletions packages/wallets/okx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ declare global {
export const id = 'okx';
export const name = 'OKX Wallet';

const dappUrl = globalThis.window
? encodeURIComponent(globalThis.window.location.href)
: '';
const encodedDappUrl = encodeURIComponent(dappUrl);
const deeplink = 'okx://wallet/dapp/url?dappUrl=' + encodedDappUrl;
const urlWithDeeplinkEncoded =
'https://www.okx.com/download?deeplink=' + encodeURIComponent(deeplink);

export class OkxConnector extends InjectedConnector {
readonly id = id;
readonly name = name;
Expand Down Expand Up @@ -46,5 +54,6 @@ export const Okx: WalletAdapterType = ({ chains }) => ({
downloadURLs: {
default: 'https://www.okx.com/download',
},
deeplink: urlWithDeeplinkEncoded,
connector: new OkxConnector(chains),
});
2 changes: 2 additions & 0 deletions packages/wallets/trust/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare module '@wagmi/core' {

export const id = 'trust';
export const name = 'Trust';
const currentHost = globalThis.window?.location.host || '';

export class TrustConnector extends InjectedConnector {
readonly id = id;
Expand All @@ -33,5 +34,6 @@ export const Trust: WalletAdapterType = ({ chains }) => ({
downloadURLs: {
default: 'https://trustwallet.com/browser-extension',
},
deeplink: `https://link.trustwallet.com/open_url?coin_id=60&url=${currentHost}`,
connector: new TrustConnector(chains),
});

0 comments on commit 2d4be62

Please sign in to comment.