Skip to content

Commit

Permalink
feat: add new injected wallets (#122)
Browse files Browse the repository at this point in the history
* feat: add new injected wallets

* chore: update rollup version

* add Phantom
  • Loading branch information
bonustrack authored Dec 1, 2024
1 parent 6763bc1 commit 74bd389
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 111 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/lock",
"version": "0.2.8",
"version": "0.2.9",
"repository": "snapshot-labs/lock",
"license": "MIT",
"main": "dist/lock.cjs.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"@types/node": "^13.9.5",
"eslint": "^8.56.0",
"prettier": "^3.1.0",
"rollup": "^2.35.1",
"rollup": "^2.79.2",
"rollup-plugin-filesize": "^9.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-builtins": "^2.1.2",
Expand Down
113 changes: 15 additions & 98 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
}
134 changes: 134 additions & 0 deletions src/wallets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
[
{
"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": "isPhantom",
"name": "Phantom",
"id": "phantom",
"icon": "ipfs://bafkreifsncdauiiwlvpcr2fm4cbwqheot2e2fwe7l5ixvwmayzc3nq6xai"
},
{
"flag": "isOneInchIOSWallet",
"name": "1inch Wallet",
"id": "1inch",
"icon": "ipfs://bafkreia2o6gwjmvsf4thcvnehyiknya6ryygphsq5r2zbitkub7jdlirnu"
}
]
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"noImplicitAny": false,
"outDir": "./dist",
"target": "es5",
"moduleResolution": "node"
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*"
Expand Down
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3739,11 +3739,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

fsevents@~2.1.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e"
integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==

fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
Expand Down Expand Up @@ -6326,12 +6321,12 @@ rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.5.0:
dependencies:
estree-walker "^0.6.1"

rollup@^2.35.1:
version "2.35.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.35.1.tgz#e6bc8d10893556a638066f89e8c97f422d03968c"
integrity sha512-q5KxEyWpprAIcainhVy6HfRttD9kutQpHbeqDTWnqAFNJotiojetK6uqmcydNMymBEtC4I8bCYR+J3mTMqeaUA==
rollup@^2.79.2:
version "2.79.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.2.tgz#f150e4a5db4b121a21a747d762f701e5e9f49090"
integrity sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==
optionalDependencies:
fsevents "~2.1.2"
fsevents "~2.3.2"

run-parallel@^1.1.9:
version "1.2.0"
Expand Down

0 comments on commit 74bd389

Please sign in to comment.