Skip to content

Commit

Permalink
chore: add code standard and remove unused packages
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Aug 26, 2024
1 parent bf02d49 commit 65e87b1
Show file tree
Hide file tree
Showing 14 changed files with 1,500 additions and 875 deletions.
7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Lint
on: [push]
jobs:
lint:
uses: snapshot-labs/actions/.github/workflows/lint.yml@main
secrets: inherit
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

3 changes: 2 additions & 1 deletion connectors/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default class Connector extends LockConnector {
let SafeAppProvider = await import('@safe-global/safe-apps-provider'!);
if (SafeAppProvider?.default) SafeAppProvider = SafeAppProvider.default;
if (SafeAppProvider?.default) SafeAppProvider = SafeAppProvider.default;
if (SafeAppProvider?.SafeAppProvider) SafeAppProvider = SafeAppProvider.SafeAppProvider;
if (SafeAppProvider?.SafeAppProvider)
SafeAppProvider = SafeAppProvider.SafeAppProvider;

provider = new SafeAppProvider(safe, sdk);
} catch (e) {
Expand Down
14 changes: 7 additions & 7 deletions connectors/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default class Connector extends LockConnector {
if (window['ethereum']) {
provider = window['ethereum'];
try {
await window['ethereum'].request({ method: 'eth_requestAccounts' })
await window['ethereum'].request({ method: 'eth_requestAccounts' });
} catch (e: any) {
if (e.message.includes("Already processing eth_requestAccounts")) {
if (e.message.includes('Already processing eth_requestAccounts')) {
try {
await provider.request({
method: "wallet_requestPermissions",
params: [{ eth_accounts: {} }],
method: 'wallet_requestPermissions',
params: [{ eth_accounts: {} }]
});
} catch (e: any) {
if (e.code === 4001 || e.code === -32002) return;
Expand All @@ -29,8 +29,8 @@ export default class Connector extends LockConnector {

async isLoggedIn() {
if (!window['ethereum']) return false;
if (window['ethereum'].request({method: 'eth_accounts'})) return true;
await new Promise((r) => setTimeout(r, 400));
return !!window['ethereum'].request({method: 'eth_accounts'});
if (window['ethereum'].request({ method: 'eth_accounts' })) return true;
await new Promise(r => setTimeout(r, 400));
return !!window['ethereum'].request({ method: 'eth_accounts' });
}
}
2 changes: 1 addition & 1 deletion connectors/kaikas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Connector extends LockConnector {
async isLoggedIn() {
if (!window['klaytn']) return false;
if (window['klaytn'].selectedAddress) return true;
await new Promise((r) => setTimeout(r, 400));
await new Promise(r => setTimeout(r, 400));
return !!window['klaytn'].selectedAddress;
}
}
14 changes: 7 additions & 7 deletions connectors/stargazer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import LockConnector from '../src/connector';

export default class Connector extends LockConnector {
getProvider(){
getProvider() {
const walletProvider = window['stargazer'];

if(!walletProvider){
if (!walletProvider) {
return null;
}

Expand All @@ -14,17 +14,17 @@ export default class Connector extends LockConnector {
async connect() {
const provider = this.getProvider();

if(!provider){
if (!provider) {
return;
}
try{

try {
await provider.activate();
}catch(e){
} catch (e) {
console.error(e);
return;
}

return provider;
}

Expand Down
3 changes: 2 additions & 1 deletion connectors/torus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const get = () => import(/* webpackChunkName: "torus" */ '@toruslabs/torus-embed');
const get = () =>
import(/* webpackChunkName: "torus" */ '@toruslabs/torus-embed');
import LockConnector from '../src/connector';

export default class Connector extends LockConnector {
Expand Down
6 changes: 2 additions & 4 deletions connectors/walletconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ let provider: any;
export default class Connector extends LockConnector {
async connect() {
try {
const imports = await import(
"@walletconnect/ethereum-provider"!
);
const imports = await import('@walletconnect/ethereum-provider'!);
const { EthereumProvider } = imports;

provider = await EthereumProvider.init(this.options);
Expand All @@ -15,7 +13,7 @@ export default class Connector extends LockConnector {
console.error(e);
return;
}
provider.connectorName = "walletconnect";
provider.connectorName = 'walletconnect';
return provider;
}

Expand Down
10 changes: 5 additions & 5 deletions connectors/walletlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export default class Connector extends LockConnector {
async connect() {
let provider;
try {
let CoinbaseWalletSDK = await import(
"@coinbase/wallet-sdk"!
)
if (CoinbaseWalletSDK.default) CoinbaseWalletSDK = CoinbaseWalletSDK.default;
if (CoinbaseWalletSDK.default) CoinbaseWalletSDK = CoinbaseWalletSDK.default;
let CoinbaseWalletSDK = await import('@coinbase/wallet-sdk'!);
if (CoinbaseWalletSDK.default)
CoinbaseWalletSDK = CoinbaseWalletSDK.default;
if (CoinbaseWalletSDK.default)
CoinbaseWalletSDK = CoinbaseWalletSDK.default;
const walletSDK = new CoinbaseWalletSDK(this.options);
provider = walletSDK.makeWeb3Provider(
this.options.ethJsonrpcUrl,
Expand Down
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,32 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@snapshot-labs/eslint-config": "^0.1.0-beta.18",
"@snapshot-labs/prettier-config": "^0.1.0-beta.18",
"@types/node": "^13.9.5",
"bluebird": "^3.7.2",
"cross-fetch": "^3.1.5",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"prettier": "2.2.0",
"eslint": "^8.56.0",
"prettier": "^3.1.0",
"rollup": "^2.35.1",
"rollup-plugin-filesize": "^9.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"typescript": "^3.8.3"
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
},
"eslintConfig": {
"extends": "@snapshot-labs"
},
"prettier": "@snapshot-labs/prettier-config",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"pretest": "npm run build",
"lint": "prettier 'plugins/**/*.ts' -w -c"
"lint": "eslint src/ connectors/ plugins/ --ext .ts",
"lint:fix": "yarn lint --fix",
"typecheck": "tsc --noEmit"
},
"files": [
"dist",
Expand Down
154 changes: 84 additions & 70 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,90 @@ export function getInjected() {
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.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',
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"module": "es6",
"noImplicitAny": false,
"outDir": "./dist",
"target": "es5"
"target": "es5",
"moduleResolution": "node"
},
"include": [
"src/**/*"
Expand Down
Loading

0 comments on commit 65e87b1

Please sign in to comment.