assembly/connectors/index.ts

66 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-09-03 13:59:09 +00:00
import { setWeb3LibraryCallback } from "@instadapp/vue-web3";
2021-08-31 19:23:47 +00:00
import { InjectedConnector } from "@web3-react/injected-connector";
import { WalletConnectConnector } from "@web3-react/walletconnect-connector";
2021-09-02 22:19:19 +00:00
import { PortisConnector } from "@web3-react/portis-connector";
import { WalletLinkConnector } from "@web3-react/walletlink-connector";
2021-09-07 17:00:30 +00:00
// import { LedgerConnector } from "@web3-react/ledger-connector";
import { LedgerConnector } from "./ledger-connector";
2021-09-02 22:19:19 +00:00
import INSTADAPP_LOGO_URL from "~/assets/logo/instadapp-logo-icon.svg?inline";
2021-08-31 19:23:47 +00:00
import Web3 from "web3";
2021-09-06 16:31:40 +00:00
import { SafeAppConnector } from "@gnosis.pm/safe-apps-web3-react/dist/connector";
2021-08-31 19:23:47 +00:00
setWeb3LibraryCallback(provider => new Web3(provider));
export const injected = new InjectedConnector({
2021-10-08 15:49:24 +00:00
supportedChainIds: [1, 137, 42161]
2021-08-31 19:23:47 +00:00
});
export const walletconnect = new WalletConnectConnector({
rpc: {
1: `https://mainnet.infura.io/v3/${process.env.INFURA_ID}`,
2021-10-08 15:49:24 +00:00
137: "https://rpc-mainnet.maticvigil.com",
42161: "https://arb1.arbitrum.io/rpc"
2021-08-31 19:23:47 +00:00
},
2021-10-08 15:49:24 +00:00
supportedChainIds: [1, 137, 42161]
2021-08-31 19:23:47 +00:00
});
2021-09-02 22:19:19 +00:00
// mainnet only
export const portis = new PortisConnector({
2021-09-02 22:35:19 +00:00
dAppId: process.env.PORTIS_ID as string,
2021-09-06 16:31:40 +00:00
networks: [1]
2021-09-02 22:19:19 +00:00
});
export const walletlink = new WalletLinkConnector({
url: `https://mainnet.infura.io/v3/${process.env.INFURA_ID}`,
appName: "Instadapp",
appLogoUrl: INSTADAPP_LOGO_URL
});
2021-09-06 16:31:40 +00:00
let gnosisSafe = null;
if (process.client) {
gnosisSafe = new SafeAppConnector({
2021-10-08 15:49:24 +00:00
supportedChainIds: [1, 137, 42161]
2021-09-06 16:31:40 +00:00
});
}
export { gnosisSafe };
2021-09-07 16:27:25 +00:00
const POLLING_INTERVAL = 12000;
2021-09-07 17:00:30 +00:00
export enum LedgerDerivationPath {
"Legacy" = "44'/60'/0'/x",
"LedgerLive" = "44'/60'/x'/0/0"
}
2021-09-07 16:27:25 +00:00
export const ledger = new LedgerConnector({
chainId: 1,
url: `https://mainnet.infura.io/v3/${process.env.INFURA_ID}`,
2021-09-07 17:00:30 +00:00
pollingInterval: POLLING_INTERVAL,
2021-09-08 17:12:01 +00:00
baseDerivationPath: LedgerDerivationPath.LedgerLive,
2021-09-07 17:00:30 +00:00
accountsOffset: 0,
2021-09-08 17:12:01 +00:00
accountsLength: 4
2021-09-07 16:27:25 +00:00
});