Skip to content

Commit

Permalink
refactor(env): move brovider url to env file (snapshot-labs#4051)
Browse files Browse the repository at this point in the history
* refactor(env): moved brovider url to .env file

* refactor(env): change connectors to ts and replace brovider url env var

* fix(env): fix wrong url in connectors
  • Loading branch information
Todmy authored Jul 8, 2023
1 parent 861ad73 commit c955e83
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 80 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ VITE_HUB_URL=https://testnet.snapshot.org
VITE_RELAYER_URL=https://testnet.snapshot.org
VITE_SCORES_URL=https://score.snapshot.org
VITE_SIDEKICK_URL=https://sh5.co
VITE_BROVIDER_URL=https://rpc.snapshot.org
VITE_IPFS_GATEWAY=snapshot.mypinata.cloud
VITE_DEFAULT_NETWORK=1
VITE_PUSHER_BEAMS_INSTANCE_ID=2e080021-d495-456d-b2cf-84f9fd718442
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalAccount.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { getInjected } from '@snapshot-labs/lock/src/utils';
import connectors from '@/helpers/connectors.json';
import connectors from '@/helpers/connectors';
import { getIpfsUrl } from '@/helpers/utils';
const props = defineProps<{
Expand Down
6 changes: 3 additions & 3 deletions src/components/SetupStrategyBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { ERC20ABI } from '@/helpers/abi';
import { isAddress } from '@ethersproject/address';
import { shorten } from '@/helpers/utils';
const BROVIDER_URL = 'https://rpc.snapshot.org';
const DEFAULT_TOKEN = {
name: '',
logo: '',
Expand Down Expand Up @@ -84,7 +82,9 @@ async function getTokenInfo() {
isTokenLoading.value = false;
} else {
try {
const provider = new JsonRpcProvider(`${BROVIDER_URL}/${network.value}`);
const provider = new JsonRpcProvider(
`${import.meta.env.VITE_BROVIDER_URL}/${network.value}`
);
const tokenInfo = await Promise.all([
call(provider, ERC20ABI, [contract.value, 'name', []]),
call(provider, ERC20ABI, [contract.value, 'symbol', []]),
Expand Down
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface ImportMetaEnv {
readonly VITE_IPFS_GATEWAY: string;
readonly VITE_DEFAULT_NETWORK: string;
readonly VITE_PUSHER_BEAMS_INSTANCE_ID: string;
readonly VITE_BROVIDER_URL: string;
}
2 changes: 1 addition & 1 deletion src/helpers/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import injected from '@snapshot-labs/lock/connectors/injected';
import walletconnect from '@snapshot-labs/lock/connectors/walletconnect';
import portis from '@snapshot-labs/lock/connectors/portis';
import connectors from '@/helpers/connectors.json';
import connectors from '@/helpers/connectors';
import walletlink from '@snapshot-labs/lock/connectors/walletlink';
import gnosis from '@snapshot-labs/lock/connectors/gnosis';
import stargazer from '@snapshot-labs/lock/connectors/stargazer';
Expand Down
75 changes: 0 additions & 75 deletions src/helpers/connectors.json

This file was deleted.

73 changes: 73 additions & 0 deletions src/helpers/connectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const connectors = {
injected: {
id: 'injected',
name: 'MetaMask'
},
walletconnect: {
id: 'walletconnect',
name: 'WalletConnect',
network: '1',
options: {
projectId: 'e6454bd61aba40b786e866a69bd4c5c6',
chains: [1],
optionalChains: [4, 5, 10, 42, 56, 100, 137, 246, 42161, 73799],
methods: ['eth_sendTransaction', 'personal_sign', 'eth_signTypedData_v4'],
optionalMethods: ['eth_accounts'],
rpcMap: {
'1': `${import.meta.env.VITE_BROVIDER_URL}/1`,
'4': `${import.meta.env.VITE_BROVIDER_URL}/4`,
'5': `${import.meta.env.VITE_BROVIDER_URL}/5`,
'10': `${import.meta.env.VITE_BROVIDER_URL}/10`,
'42': `${import.meta.env.VITE_BROVIDER_URL}/42`,
'56': `${import.meta.env.VITE_BROVIDER_URL}/56`,
'100': `${import.meta.env.VITE_BROVIDER_URL}/100`,
'137': `${import.meta.env.VITE_BROVIDER_URL}/137`,
'246': `${import.meta.env.VITE_BROVIDER_URL}/246`,
'42161': `${import.meta.env.VITE_BROVIDER_URL}/42161`,
'73799': `${import.meta.env.VITE_BROVIDER_URL}/73799`
},
showQrModal: true
},
icon: 'ipfs://QmZRVqHpgRemw13aoovP2EaQdVtjzXRaQGQZsCLXWaNn9x'
},
walletlink: {
id: 'walletlink',
name: 'Coinbase Wallet',
network: '1',
options: {
appName: 'Snapshot',
darkMode: false,
chainId: 1,
ethJsonrpcUrl: `${import.meta.env.VITE_BROVIDER_URL}/1`
},
icon: 'ipfs://QmbJKEaeMz6qR3DmJSTxtYtrZeQPptVfnnYK72QBsvAw5q'
},
portis: {
id: 'portis',
name: 'Portis',
network: '1',
options: {
dappId: '3eb93706-c71d-456b-b4eb-322ea27f7d48',
network: 'mainnet'
},
icon: 'ipfs://QmNuLXa47xSrDNKRfpPNhoFTuoztvtWCcwGnPpT5MXJWMb'
},
stargazer: {
id: 'stargazer',
name: 'Stargazer',
icon: 'ipfs://bafkreiapdizo36f3yeg7g6l46f7ahbbkyo4otufnfyqri6louysr3grpzy'
},
gnosis: {
id: 'gnosis',
name: 'Gnosis Safe',
icon: 'ipfs://QmfJUHZLtRvadM7fvEJUWWxhS869KXXCMxPCr7TUqkwvUc',
hidden: true
},
kaikas: {
id: 'kaikas',
name: 'Kaikas',
icon: 'ipfs://QmXD4kkxKzXKbbBu3zAzZ279Sm91JhxCDAwSypyzxwe2Hj'
}
};

export default connectors;

0 comments on commit c955e83

Please sign in to comment.