Skip to content

Commit

Permalink
feat: add evm wallet (#100)
Browse files Browse the repository at this point in the history
Co-authored-by: naturexie <[email protected]>
  • Loading branch information
xieqiancaosissi and naturexie authored Sep 27, 2024
1 parent d69a236 commit e39ffe8
Show file tree
Hide file tree
Showing 19 changed files with 2,047 additions and 38 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
browser: true,
es2021: true,
},
ignorePatterns: ["node_modules/"],
extends: [
"airbnb",
"plugin:react/recommended",
Expand Down
2 changes: 1 addition & 1 deletion components/Header/stats/liquidity.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
import { Typography } from "@mui/material";

import Decimal from "decimal.js";
import { useFullDigits } from "../../../hooks/useFullDigits";
import { useAppSelector } from "../../../redux/hooks";
Expand Down
1 change: 1 addition & 0 deletions components/Header/stats/rewards.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useState } from "react";
import { useRewards, useDailyRewards } from "../../../hooks/useRewards";
import { TOKEN_FORMAT, USD_FORMAT, NUMBER_FORMAT } from "../../../store";
Expand Down
1 change: 1 addition & 0 deletions components/Modal/components.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useEffect, useState } from "react";
import { Box, Typography, Stack, Alert, Link, useTheme } from "@mui/material";
import { BeatLoader } from "react-spinners";
Expand Down
1 change: 1 addition & 0 deletions components/Modal/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import Decimal from "decimal.js";
import { USD_FORMAT, TOKEN_FORMAT, PERCENT_DIGITS, NEAR_STORAGE_DEPOSIT } from "../../store";
import type { UIAsset } from "../../interfaces";
Expand Down
1 change: 1 addition & 0 deletions components/Table/common/cells.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import millify from "millify";
import { Box, Tooltip, Skeleton } from "@mui/material";

Expand Down
1 change: 1 addition & 0 deletions components/Ticker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { Box, Stack, Link, useTheme } from "@mui/material";
import TimeAgo from "timeago-react";
import { motion } from "framer-motion";
Expand Down
1 change: 1 addition & 0 deletions helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import millify from "millify";
import { APY_FORMAT, DUST_FORMAT, NUMBER_FORMAT, TOKEN_FORMAT, USD_FORMAT } from "../store";

Expand Down
1 change: 1 addition & 0 deletions hooks/useRewards.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import Decimal from "decimal.js";
import { useAppSelector } from "../redux/hooks";
import {
Expand Down
6 changes: 4 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
module.exports = {
reactStrictMode: true,
trailingSlash: true,
eslint: {
ignoreDuringBuilds: true,
},
webpack(config, { isServer, webpack, buildId }) {
config.plugins.push(
new webpack.DefinePlugin({
"process.env.CONFIG_BUILD_ID": JSON.stringify(buildId),
}),
);

config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
Expand All @@ -22,7 +24,7 @@ module.exports = {
presets: ["@babel/preset-env"],
},
},
// exclude: /node_modules/,
exclude: /node_modules/,
});

if (!isServer) {
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@near-wallet-selector/bitte-wallet": "^8.9.12",
"@near-wallet-selector/coin98-wallet": "8.9.12",
"@near-wallet-selector/core": "^8.9.7",
"@near-wallet-selector/ethereum-wallets": "^8.9.13",
"@near-wallet-selector/here-wallet": "^8.9.7",
"@near-wallet-selector/ledger": "^8.9.7",
"@near-wallet-selector/meteor-wallet": "8.5.4",
Expand All @@ -47,13 +48,17 @@
"@sentry/cli": "^2.5.2",
"@sentry/react": "^7.13.0",
"@sentry/tracing": "^7.13.0",
"@tanstack/react-query": "^5.56.2",
"@types/bn.js": "^5.1.1",
"@types/jest": "^29.0.3",
"@types/lodash": "^4.14.185",
"@types/ramda": "^0.28.15",
"@types/react-redux": "^7.1.24",
"@types/react-virtualized": "^9.21.21",
"@types/styled-components": "^5.1.26",
"@wagmi/connectors": "^5.1.13",
"@wagmi/core": "^2.13.7",
"@web3modal/wagmi": "^5.1.9",
"autoprefixer": "^10.4.15",
"babel-loader": "^9.1.3",
"bn.js": "^5.2.1",
Expand Down Expand Up @@ -95,7 +100,9 @@
"swiper": "8.4.7",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",
"timeago-react": "^3.0.5"
"timeago-react": "^3.0.5",
"viem": "^2.21.15",
"wagmi": "^2.12.14"
},
"devDependencies": {
"@svgr/webpack": "^6.3.1",
Expand All @@ -122,7 +129,7 @@
"prettier": "^2.7.1",
"react-test-renderer": "^18.2.0",
"tailwindcss": "^3.3.3",
"typescript": "^4.7.4"
"typescript": "^5"
},
"resolutions": {
"@types/react": "17.0.2",
Expand Down
1 change: 1 addition & 0 deletions redux/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import Decimal from "decimal.js";
import { pick, omit } from "ramda";

Expand Down
1 change: 1 addition & 0 deletions screens/Dashboard/liquidations.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useEffect, useState } from "react";
import CustomTable from "../../components/CustomTable/CustomTable";
import { shrinkToken, TOKEN_FORMAT } from "../../store";
Expand Down
1 change: 1 addition & 0 deletions screens/Dashboard/records.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useEffect, useRef, useState } from "react";
import CustomTable from "../../components/CustomTable/CustomTable";
import Datasource from "../../data/datasource";
Expand Down
1 change: 1 addition & 0 deletions screens/Staking/components.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { Typography, Stack, Box, useTheme } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton";

Expand Down
1 change: 1 addition & 0 deletions screens/Staking/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useEffect, useState } from "react";
import { Modal, Stack, Box, Typography, Alert, useTheme } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton";
Expand Down
59 changes: 56 additions & 3 deletions utils/wallet-selector-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ import BN from "bn.js";
import { map, distinctUntilChanged } from "rxjs";
import { setupKeypom } from "@keypom/selector";
import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
// @ts-nocheck
import type { Config } from "@wagmi/core";
// @ts-nocheck
import { reconnect, http, createConfig } from "@wagmi/core";
// @ts-nocheck
import { walletConnect, injected } from "@wagmi/connectors";
// @ts-nocheck
import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets";
// @ts-nocheck
import { createWeb3Modal } from "@web3modal/wagmi";
// @ts-nocheck
import { getRpcList } from "../components/Rpc/tool";

import getConfig, {
Expand Down Expand Up @@ -57,8 +68,45 @@ let near: Near;
let accountId: string;
let init = false;
let selector: WalletSelector | null = null;

const walletConnect = setupWalletConnect({
const nearBlock = {
id: 397,
name: "NEAR Mainnet",
nativeCurrency: {
decimals: 18,
name: "NEAR",
symbol: "NEAR",
},
rpcUrls: {
default: { http: ["https://eth-rpc.mainnet.near.org"] },
public: { http: ["https://eth-rpc.mainnet.near.org"] },
},
blockExplorers: {
default: {
name: "NEAR Explorer",
url: "https://eth-explorer.near.org",
},
},
testnet: false,
};
const wagmiConfig: Config = createConfig({
chains: [nearBlock],
transports: {
[nearBlock.id]: http(),
},
connectors: [
walletConnect({
projectId: WALLET_CONNECT_ID,
showQrModal: false,
}),
injected({ shimDisconnect: true }),
],
});
reconnect(wagmiConfig);
const web3Modal = createWeb3Modal({
wagmiConfig,
projectId: WALLET_CONNECT_ID,
});
const walletConnect2 = setupWalletConnect({
projectId: WALLET_CONNECT_ID,
metadata: {
name: "Burrow Finance",
Expand Down Expand Up @@ -106,7 +154,7 @@ export const getWalletSelector = async ({ onAccountChange }: GetWalletSelectorAr
myNearWallet,
setupSender() as any,
setupMeteorWallet(),
walletConnect,
walletConnect2,
setupNearMobileWallet({
dAppMetadata: {
logoUrl: "https://ref-finance-images-v2.s3.amazonaws.com/images/burrowIcon.png",
Expand Down Expand Up @@ -142,6 +190,11 @@ export const getWalletSelector = async ({ onAccountChange }: GetWalletSelectorAr
deprecated: false,
}),
setupCoin98Wallet(),
setupEthereumWallets({
wagmiConfig,
web3Modal,
alwaysOnboardDuringSignIn: true,
} as any),
],
network: {
networkId: defaultNetwork,
Expand Down
Loading

0 comments on commit e39ffe8

Please sign in to comment.