From c44dbee8e328212efc22e3bab9d5e0e002b419be Mon Sep 17 00:00:00 2001 From: less Date: Sun, 1 Dec 2024 15:10:13 +0700 Subject: [PATCH] feat: add new injected wallets --- src/utils.ts | 113 ++++++----------------------------------- src/wallets.json | 128 +++++++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 4 +- 3 files changed, 146 insertions(+), 99 deletions(-) create mode 100644 src/wallets.json diff --git a/src/utils.ts b/src/utils.ts index 391fab0..8f8c0f0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,106 +1,23 @@ +import wallets from './wallets.json'; + export function getInjected() { const web3: any = window['ethereum']; + if (!web3) return; - let injected = { + + for (const wallet of wallets) { + if (web3[wallet.flag]) { + return { + name: wallet.name, + id: wallet.id, + icon: wallet.icon + }; + } + } + + return { name: 'Injected', id: 'web3', icon: 'ipfs://QmXUov1JMszHkizCf3HvmcKWKm9PrG2KHpd5bDnE5YbZN8' }; - if (web3.isMetaMask) - injected = { - name: 'MetaMask', - id: 'metamask', - icon: 'ipfs://QmTE7VPXMhriKAobMWEiC5S3oG22p4G6AXGyGdNWQTQ3Fv' - }; - if (web3.isCoinbaseWallet) - injected = { - name: 'Coinbase', - id: 'coinbase', - icon: 'ipfs://QmbJKEaeMz6qR3DmJSTxtYtrZeQPptVfnnYK72QBsvAw5q' - }; - if (web3.isTrust) - injected = { - name: 'Trust Wallet', - id: 'trustwallet', - icon: 'ipfs://QmQzchPwEa7UnRqSS7kSt4EJWMw5mcj9u3YtTp9uig9UT5' - }; - if (web3.isMixin) - injected = { - name: 'Mixin Messenger', - id: 'mixinmessenger', - icon: 'ipfs://QmT4ZcGMNoW34ZNgzjPJ6pqaoB5Fpk7z2d9yQqwGtCuEJC' - }; - if (web3.isStatus) - injected = { - name: 'Status', - id: 'status', - icon: 'ipfs://QmWQhPEvpEH3xW8wwuTr9G5vsUz8ufy25dqe394UJzwsXE' - }; - if (web3.isFrame) - injected = { - name: 'Frame', - id: 'frame', - icon: 'ipfs://QmReuKRvC7YTTEmW521nKJwEMFuocWgM9GYwUFedF6Q1BL' - }; - if (web3.isAlphaWallet) - injected = { - name: 'AlphaWallet', - id: 'alphawallet', - icon: 'ipfs://QmT7mrsAgpu4V2UJAukaEU9V6fEWYHAo7aahUxfyDdBns9' - }; - if (web3.isImToken) - injected = { - name: 'imToken', - id: 'imtoken', - icon: 'ipfs://QmacaenFbh6WXfoPVWzXiijRC8gcBT8N6yt4ZsdMWTWX5J' - }; - if (web3.isTokenPocket) - injected = { - name: 'TokenPocket', - id: 'tokenpocket', - icon: 'ipfs://QmSetXfvpWqZVCzh23XQthPFYNQTPAfJaZbkHbWdDdCHzx' - }; - if (web3.isBitpie) - injected = { - name: 'Bitpie', - id: 'bitpie', - icon: 'ipfs://QmVUZ8gznsZ2nNv85GFZuTQj31YenyUi5K4HGfhXB3jrAF' - }; - if (web3.isTally) - injected = { - name: 'Tally', - id: 'tally', - icon: 'ipfs://Qma4EJoXZ2CyPfKQHbtjqnLVXP28xFwiXg3KwZa7nMZC19' - }; - if (web3.isBitKeep) - injected = { - name: 'Bitget Wallet', - id: 'bitkeep', - icon: 'ipfs://bafkreigkcq5ntckkv3x6xs4qysngwgh77pmbj7apzq4ptavs4lvczq7kni' - }; - if (web3.isExodus) - injected = { - name: 'Exodus', - id: 'exodus', - icon: 'ipfs://bafkreigvws44zebhc7unv6o2or5erxaizgvkymmnor4desblddl6a2zzya' - }; - if (web3.isXDCPay) - injected = { - name: 'XDCPay', - id: 'xdcpay', - icon: 'ipfs://QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111' - }; - if (web3.isBraveWallet) - injected = { - name: 'Brave', - id: 'brave', - icon: 'ipfs://bafkreibwywapshu3b7f26o2wmx5o4hlvkbtlduubo2r2gcgfsscylh72ca' - }; - if (web3.__XDEFI) - injected = { - name: 'XDEFI Wallet', - id: 'xdefi', - icon: 'ipfs://QmR9khDAzYSAzRJvzoWVwm91QcbdhLcnZQR8t7NUDPpeyu' - }; - return injected; } diff --git a/src/wallets.json b/src/wallets.json new file mode 100644 index 0000000..8780d39 --- /dev/null +++ b/src/wallets.json @@ -0,0 +1,128 @@ +[ + { + "flag": "isMetaMask", + "name": "MetaMask", + "id": "metamask", + "icon": "ipfs://QmTE7VPXMhriKAobMWEiC5S3oG22p4G6AXGyGdNWQTQ3Fv" + }, + { + "flag": "isCoinbaseWallet", + "name": "Coinbase", + "id": "coinbase", + "icon": "ipfs://QmbJKEaeMz6qR3DmJSTxtYtrZeQPptVfnnYK72QBsvAw5q" + }, + { + "flag": "isTrust", + "name": "Trust Wallet", + "id": "trustwallet", + "icon": "ipfs://QmQzchPwEa7UnRqSS7kSt4EJWMw5mcj9u3YtTp9uig9UT5" + }, + { + "flag": "isMixin", + "name": "Mixin Messenger", + "id": "mixinmessenger", + "icon": "ipfs://QmT4ZcGMNoW34ZNgzjPJ6pqaoB5Fpk7z2d9yQqwGtCuEJC" + }, + { + "flag": "isStatus", + "name": "Status", + "id": "status", + "icon": "ipfs://QmWQhPEvpEH3xW8wwuTr9G5vsUz8ufy25dqe394UJzwsXE" + }, + { + "flag": "isFrame", + "name": "Frame", + "id": "frame", + "icon": "ipfs://QmReuKRvC7YTTEmW521nKJwEMFuocWgM9GYwUFedF6Q1BL" + }, + { + "flag": "isAlphaWallet", + "name": "AlphaWallet", + "id": "alphawallet", + "icon": "ipfs://QmT7mrsAgpu4V2UJAukaEU9V6fEWYHAo7aahUxfyDdBns9" + }, + { + "flag": "isImToken", + "name": "imToken", + "id": "imtoken", + "icon": "ipfs://QmacaenFbh6WXfoPVWzXiijRC8gcBT8N6yt4ZsdMWTWX5J" + }, + { + "flag": "isTokenPocket", + "name": "TokenPocket", + "id": "tokenpocket", + "icon": "ipfs://QmSetXfvpWqZVCzh23XQthPFYNQTPAfJaZbkHbWdDdCHzx" + }, + { + "flag": "isBitpie", + "name": "Bitpie", + "id": "bitpie", + "icon": "ipfs://QmVUZ8gznsZ2nNv85GFZuTQj31YenyUi5K4HGfhXB3jrAF" + }, + { + "flag": "isTally", + "name": "Tally", + "id": "tally", + "icon": "ipfs://Qma4EJoXZ2CyPfKQHbtjqnLVXP28xFwiXg3KwZa7nMZC19" + }, + { + "flag": "isBitKeep", + "name": "Bitget Wallet", + "id": "bitkeep", + "icon": "ipfs://bafkreigkcq5ntckkv3x6xs4qysngwgh77pmbj7apzq4ptavs4lvczq7kni" + }, + { + "flag": "isExodus", + "name": "Exodus", + "id": "exodus", + "icon": "ipfs://bafkreigvws44zebhc7unv6o2or5erxaizgvkymmnor4desblddl6a2zzya" + }, + { + "flag": "isXDCPay", + "name": "XDCPay", + "id": "xdcpay", + "icon": "ipfs://QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111" + }, + { + "flag": "isBraveWallet", + "name": "Brave", + "id": "brave", + "icon": "ipfs://bafkreibwywapshu3b7f26o2wmx5o4hlvkbtlduubo2r2gcgfsscylh72ca" + }, + { + "flag": "__XDEFI", + "name": "XDEFI Wallet", + "id": "xdefi", + "icon": "ipfs://QmR9khDAzYSAzRJvzoWVwm91QcbdhLcnZQR8t7NUDPpeyu" + }, + { + "flag": "isUniswapWallet", + "name": "Uniswap Wallet", + "id": "uniswap", + "icon": "ipfs://bafkreifgmrzdpybyn3r4k237ezbh75435gunbx5ge5yyzz7sdrljz2n35e" + }, + { + "flag": "isRainbow", + "name": "Rainbow", + "id": "rainbow", + "icon": "ipfs://bafkreih43rhelvsujcaqlepauc5timgckmm4x6kegrhivrthzy7syptgye" + }, + { + "flag": "isFamily", + "name": "Family Wallet", + "id": "Family", + "icon": "ipfs://bafkreifu2f2xjihcsazqcpucw4ryaufy4bhlffijs732f2nviqbnvgiuvy" + }, + { + "flag": "isRabby", + "name": "Rabby Wallet", + "id": "rabby", + "icon": "ipfs://bafkreih6dp7hhqwwdireoxd2jqs5ath3rl32lieta4iksydanrtzzssr5q" + }, + { + "flag": "isOneInchIOSWallet", + "name": "1inch Wallet", + "id": "1inch", + "icon": "ipfs://bafkreia2o6gwjmvsf4thcvnehyiknya6ryygphsq5r2zbitkub7jdlirnu" + } +] diff --git a/tsconfig.json b/tsconfig.json index 32cd8b6..e483dd1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,9 @@ "noImplicitAny": false, "outDir": "./dist", "target": "es5", - "moduleResolution": "node" + "moduleResolution": "node", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true }, "include": [ "src/**/*"