From 06f4a9678981cebca7ad986a567f5f881618e735 Mon Sep 17 00:00:00 2001 From: "nature.xie" Date: Tue, 28 Nov 2023 11:58:18 +0800 Subject: [PATCH 1/3] add ledger wallet --- next.config.js | 10 +++ package.json | 2 + styles/global.css | 41 ++++++++++ utils/wallet-selector-compat.ts | 2 + yarn.lock | 139 +++++++++++++++++++++++++++++++- 5 files changed, 192 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index 72d4eefe..451c42ed 100644 --- a/next.config.js +++ b/next.config.js @@ -14,6 +14,16 @@ module.exports = { issuer: /\.[jt]sx?$/, use: ["@svgr/webpack"], }); + config.module.rules.push({ + test: /.js$/, + use: { + loader: "babel-loader", + options: { + presets: ["@babel/preset-env"], + }, + }, + // exclude: /node_modules/, + }); if (!isServer) { config.resolve.fallback.fs = false; diff --git a/package.json b/package.json index 427e7015..bf8f6b93 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@mui/utils": "^5.10.6", "@near-wallet-selector/core": "^8.5.4", "@near-wallet-selector/here-wallet": "^8.5.4", + "@near-wallet-selector/ledger": "^8.5.4", "@near-wallet-selector/meteor-wallet": "^8.5.4", "@near-wallet-selector/modal-ui": "^8.5.4", "@near-wallet-selector/my-near-wallet": "^8.5.4", @@ -50,6 +51,7 @@ "@types/react-virtualized": "^9.21.21", "@types/styled-components": "^5.1.26", "autoprefixer": "^10.4.15", + "babel-loader": "^9.1.3", "better-sqlite3": "^7.6.2", "bn.js": "^5.2.1", "borsh": "^0.7.0", diff --git a/styles/global.css b/styles/global.css index 450fc62c..37b604cd 100644 --- a/styles/global.css +++ b/styles/global.css @@ -730,6 +730,47 @@ options-list::-webkit-scrollbar { .nws-modal-wrapper .nws-modal .connecting-details span { color: #fff; } +.nws-form-control .account label { + display: block; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.nws-form-control .account br { + display: none; +} +.nws-modal-wrapper + .nws-modal + .choose-ledger-account-form-wrapper + .nws-form-control + .account { + display: flex; + align-items: center; + gap: 4px; + border-bottom: 1px solid #42525c; +} +.nws-modal-wrapper + .nws-modal + .choose-ledger-account-form-wrapper + .nws-form-control + .account + input[type='checkbox'] { + transform: scale(1.2); +} +.nws-modal-wrapper .nws-modal .overview-wrapper .account { + border-bottom: 1px solid #42525c; +} +.nws-modal-wrapper .nws-modal .overview-wrapper .account span { + display: block; + overflow: hidden; + width: 100%; + text-overflow: ellipsis; + white-space: nowrap; +} +.nws-modal-wrapper .nws-modal .modal-right::-webkit-scrollbar { + width: 2px; +} .noselect { -webkit-touch-callout: none; /* iOS Safari */ diff --git a/utils/wallet-selector-compat.ts b/utils/wallet-selector-compat.ts index 2fe3c6b9..ec9d56f6 100644 --- a/utils/wallet-selector-compat.ts +++ b/utils/wallet-selector-compat.ts @@ -10,6 +10,7 @@ import { setupWalletConnect } from "@near-wallet-selector/wallet-connect"; import { setupNeth } from "@near-wallet-selector/neth"; import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet"; import { setupModal } from "@near-wallet-selector/modal-ui"; +import { setupLedger } from "@near-wallet-selector/ledger"; import type { WalletSelectorModal } from "@near-wallet-selector/modal-ui"; import { Near } from "near-api-js/lib/near"; import { Account } from "near-api-js/lib/account"; @@ -90,6 +91,7 @@ export const getWalletSelector = async ({ onAccountChange }: GetWalletSelectorAr name: "NEAR Wallet Selector", }, }), + setupLedger(), ], network: defaultNetwork, debug: !!isTestnet, diff --git a/yarn.lock b/yarn.lock index ec652d54..efd5d9f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1924,6 +1924,16 @@ rxjs "6" semver "^7.3.5" +"@ledgerhq/devices@^6.27.1": + version "6.27.1" + resolved "https://registry.npmjs.org/@ledgerhq/devices/-/devices-6.27.1.tgz#3b13ab1d1ba8201e9e74a08f390560483978c962" + integrity sha512-jX++oy89jtv7Dp2X6gwt3MMkoajel80JFWcdc0HCouwDsV1mVJ3SQdwl/bQU0zd8HI6KebvUP95QTwbQLLK/RQ== + dependencies: + "@ledgerhq/errors" "^6.10.0" + "@ledgerhq/logs" "^6.10.0" + rxjs "6" + semver "^7.3.5" + "@ledgerhq/devices@^7.0.1": version "7.0.1" resolved "https://registry.npmjs.org/@ledgerhq/devices/-/devices-7.0.1.tgz" @@ -1934,11 +1944,26 @@ rxjs "6" semver "^7.3.5" +"@ledgerhq/devices@^8.1.0": + version "8.1.0" + resolved "https://registry.npmjs.org/@ledgerhq/devices/-/devices-8.1.0.tgz#39b12feabe1c7a99b86667bedf2eafbd125cf217" + integrity sha512-Vsdv84Nwzee0qhObdwVzhkxW1+h2cFoD1AWuU8N1V/2OJKiVS35A1qloSCF0oHapg+KTJvim8tr5rRvlkCYyzQ== + dependencies: + "@ledgerhq/errors" "^6.16.0" + "@ledgerhq/logs" "^6.12.0" + rxjs "^7.8.1" + semver "^7.3.5" + "@ledgerhq/errors@^5.34.0", "@ledgerhq/errors@^5.50.0": version "5.50.0" resolved "https://registry.npmjs.org/@ledgerhq/errors/-/errors-5.50.0.tgz" integrity sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow== +"@ledgerhq/errors@^6.10.0", "@ledgerhq/errors@^6.16.0": + version "6.16.0" + resolved "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.16.0.tgz#0aaf16bbf649a3b43867746781b2e3adebf7fe3a" + integrity sha512-vnew6lf4jN6E+WI0DFhD4WY0uM8LYL8HCumtUr86hNwvmEfebi7LxxpJGmYfVQD5TgEC7NibYnQ+2q9XWAc02A== + "@ledgerhq/errors@^6.10.2": version "6.12.1" resolved "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.12.1.tgz" @@ -1979,6 +2004,16 @@ "@ledgerhq/logs" "^5.30.0" u2f-api "0.2.7" +"@ledgerhq/hw-transport-webhid@6.27.1": + version "6.27.1" + resolved "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.27.1.tgz#8fd1710d23b6bd7cbe2382dd02054dfabe788447" + integrity sha512-u74rBYlibpbyGblSn74fRs2pMM19gEAkYhfVibq0RE1GNFjxDMFC1n7Sb+93Jqmz8flyfB4UFJsxs8/l1tm2Kw== + dependencies: + "@ledgerhq/devices" "^6.27.1" + "@ledgerhq/errors" "^6.10.0" + "@ledgerhq/hw-transport" "^6.27.1" + "@ledgerhq/logs" "^6.10.0" + "@ledgerhq/hw-transport-webhid@^5.51.1": version "5.51.1" resolved "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-5.51.1.tgz" @@ -1999,6 +2034,15 @@ "@ledgerhq/hw-transport" "^5.51.1" "@ledgerhq/logs" "^5.50.0" +"@ledgerhq/hw-transport@6.27.1": + version "6.27.1" + resolved "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.27.1.tgz#88072278f69c279cb6569352acd4ae2fec33ace3" + integrity sha512-hnE4/Fq1YzQI4PA1W0H8tCkI99R3UWDb3pJeZd6/Xs4Qw/q1uiQO+vNLC6KIPPhK0IajUfuI/P2jk0qWcMsuAQ== + dependencies: + "@ledgerhq/devices" "^6.27.1" + "@ledgerhq/errors" "^6.10.0" + events "^3.3.0" + "@ledgerhq/hw-transport@^5.34.0", "@ledgerhq/hw-transport@^5.51.1": version "5.51.1" resolved "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-5.51.1.tgz" @@ -2008,6 +2052,16 @@ "@ledgerhq/errors" "^5.50.0" events "^3.3.0" +"@ledgerhq/hw-transport@^6.27.1": + version "6.30.0" + resolved "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.30.0.tgz#9c8a8f2c8281fbc4a3db1d1f3ac44a456b38281a" + integrity sha512-wrAwn/wCAaGP2Yuy78cLyqmQNzbuDvUv4gJYF/UO4djvUz0jjvD2w5kxRWxF/W93vyKT+/RplRtFk3CJzD3e3A== + dependencies: + "@ledgerhq/devices" "^8.1.0" + "@ledgerhq/errors" "^6.16.0" + "@ledgerhq/logs" "^6.12.0" + events "^3.3.0" + "@ledgerhq/hw-transport@^6.27.4": version "6.27.4" resolved "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.27.4.tgz" @@ -2027,6 +2081,11 @@ resolved "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.10.1.tgz" integrity sha512-z+ILK8Q3y+nfUl43ctCPuR4Y2bIxk/ooCQFwZxhtci1EhAtMDzMAx2W25qx8G1PPL9UUOdnUax19+F0OjXoj4w== +"@ledgerhq/logs@^6.12.0": + version "6.12.0" + resolved "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.12.0.tgz#ad903528bf3687a44da435d7b2479d724d374f5d" + integrity sha512-ExDoj1QV5eC6TEbMdLUMMk9cfvNKhhv5gXol4SmULRVCx/3iyCPhJ74nsb3S0Vb+/f+XujBEj3vQn5+cwS0fNA== + "@lezer/common@^1.0.0": version "1.1.1" resolved "https://registry.npmjs.org/@lezer/common/-/common-1.1.1.tgz#4a06a0e1b9214d7eb2ea4a9354d47a63044cee49" @@ -2450,6 +2509,16 @@ js-sha256 "0.9.0" rxjs "7.8.1" +"@near-wallet-selector/core@8.9.0": + version "8.9.0" + resolved "https://registry.npmjs.org/@near-wallet-selector/core/-/core-8.9.0.tgz#a362934cbbce63d3165308bf92036c62095722e2" + integrity sha512-z7Fe/AdkB9ER7YxQrLhaAgffflsjdUxx3dNU6Su8scBcn2kTTtGKiRGyfD9CEqfed08n+RFbxH+7XA2FclKS+g== + dependencies: + borsh "0.7.0" + events "3.3.0" + js-sha256 "0.9.0" + rxjs "7.8.1" + "@near-wallet-selector/here-wallet@^8.5.4": version "8.7.0" resolved "https://registry.npmjs.org/@near-wallet-selector/here-wallet/-/here-wallet-8.7.0.tgz#be01991208baf5f18d19074da8f676cc07911813" @@ -2459,6 +2528,19 @@ "@near-wallet-selector/core" "8.7.0" bn.js "5.2.1" +"@near-wallet-selector/ledger@^8.5.4": + version "8.9.0" + resolved "https://registry.npmjs.org/@near-wallet-selector/ledger/-/ledger-8.9.0.tgz#7f1196e34c6b30b1e084d06270b8513b7aba0b60" + integrity sha512-gRqLcbETGEzDLUjwkfQ4eh7V1pUnFG8yfHDF2dKvZTVaVm6yQmosy29caw7L7a5jZ3eDVd8V6KzPbepLu6RCtA== + dependencies: + "@ledgerhq/hw-transport" "6.27.1" + "@ledgerhq/hw-transport-webhid" "6.27.1" + "@near-wallet-selector/core" "8.9.0" + "@near-wallet-selector/wallet-utils" "8.9.0" + bn.js "5.2.1" + is-mobile "4.0.0" + ts-essentials "7.0.3" + "@near-wallet-selector/meteor-wallet@^8.5.4": version "8.7.0" resolved "https://registry.npmjs.org/@near-wallet-selector/meteor-wallet/-/meteor-wallet-8.7.0.tgz#1faeb7024e4767bf2e3738d2305ab052fc0e1b70" @@ -2558,6 +2640,14 @@ "@near-wallet-selector/core" "8.7.0" bn.js "5.2.1" +"@near-wallet-selector/wallet-utils@8.9.0": + version "8.9.0" + resolved "https://registry.npmjs.org/@near-wallet-selector/wallet-utils/-/wallet-utils-8.9.0.tgz#0e278712ffa2ffcfbdd75b36a6705b93d5bb388a" + integrity sha512-n4maYvoTjc5xy/6mNhBtSW4aUKcmKv/gatOzlpxWJngiL+449/PPAtHx4++sdrFnG0tyVDlAKSSylYmFrug3xQ== + dependencies: + "@near-wallet-selector/core" "8.9.0" + bn.js "5.2.1" + "@next/env@12.3.1": version "12.3.1" resolved "https://registry.npmjs.org/@next/env/-/env-12.3.1.tgz" @@ -4537,6 +4627,13 @@ ajv-formats@^2.1.1: dependencies: ajv "^8.0.0" +ajv-keywords@^5.1.0: + version "5.1.0" + resolved "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" + integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== + dependencies: + fast-deep-equal "^3.1.3" + ajv@8.11.0: version "8.11.0" resolved "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz" @@ -4557,7 +4654,7 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.0, ajv@^8.11.2: +ajv@^8.0.0, ajv@^8.11.2, ajv@^8.9.0: version "8.12.0" resolved "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== @@ -4890,6 +4987,14 @@ babel-jest@^29.0.3: graceful-fs "^4.2.9" slash "^3.0.0" +babel-loader@^9.1.3: + version "9.1.3" + resolved "https://registry.npmjs.org/babel-loader/-/babel-loader-9.1.3.tgz#3d0e01b4e69760cc694ee306fe16d358aa1c6f9a" + integrity sha512-xG3ST4DglodGf8qSwv0MdeWLhrDsw/32QMdTO5T1ZIp9gQur0HkCyFs7Awskr10JKXFXwpAhiCuYX5oGXnRGbw== + dependencies: + find-cache-dir "^4.0.0" + schema-utils "^4.0.0" + babel-plugin-istanbul@^6.1.1: version "6.1.1" resolved "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz" @@ -6854,6 +6959,14 @@ filter-obj@^1.1.0: resolved "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz" integrity sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ== +find-cache-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-4.0.0.tgz#a30ee0448f81a3990708f6453633c733e2f6eec2" + integrity sha512-9ZonPT4ZAK4a+1pUPVPZJapbi7O5qbbJPdYw/NOQWZZbVLdDTYM3A4R9z/DpAM08IDaFGsvPgiGZ82WEwUDWjg== + dependencies: + common-path-prefix "^3.0.0" + pkg-dir "^7.0.0" + find-root@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz" @@ -6875,7 +6988,7 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -find-up@^6.0.0: +find-up@^6.0.0, find-up@^6.3.0: version "6.3.0" resolved "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz" integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw== @@ -10089,6 +10202,13 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +pkg-dir@^7.0.0: + version "7.0.0" + resolved "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz#8f0c08d6df4476756c5ff29b3282d0bab7517d11" + integrity sha512-Ie9z/WINcxxLp27BKOCHGde4ITq9UklYKDzVo1nhk5sqGEXU3FpkwP5GM2voTGJkGd9B3Otl+Q4uwSOeSUtOBA== + dependencies: + find-up "^6.3.0" + platform@^1.3.6: version "1.3.6" resolved "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz" @@ -11010,6 +11130,16 @@ scheduler@^0.23.0: dependencies: loose-envify "^1.1.0" +schema-utils@^4.0.0: + version "4.2.0" + resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz#70d7c93e153a273a805801882ebd3bff20d89c8b" + integrity sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw== + dependencies: + "@types/json-schema" "^7.0.9" + ajv "^8.9.0" + ajv-formats "^2.1.1" + ajv-keywords "^5.1.0" + screenfull@^5.1.0: version "5.2.0" resolved "https://registry.npmjs.org/screenfull/-/screenfull-5.2.0.tgz" @@ -11823,6 +11953,11 @@ ts-easing@^0.2.0: resolved "https://registry.npmjs.org/ts-easing/-/ts-easing-0.2.0.tgz" integrity sha512-Z86EW+fFFh/IFB1fqQ3/+7Zpf9t2ebOAxNI/V6Wo7r5gqiqtxmgTlQ1qbqQcjLKYeSHPTsEmvlJUDg/EuL0uHQ== +ts-essentials@7.0.3: + version "7.0.3" + resolved "https://registry.npmjs.org/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" + integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== + ts-interface-checker@^0.1.9: version "0.1.13" resolved "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz" From 33b26eaef80ef428e53a1ca247dc59d4e43dfe7e Mon Sep 17 00:00:00 2001 From: "nature.xie" Date: Wed, 29 Nov 2023 11:20:19 +0800 Subject: [PATCH 2/3] hidden usn token in market page --- utils/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/config.ts b/utils/config.ts index a44d48ee..d936653e 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -3,7 +3,7 @@ import { ConnectConfig } from "near-api-js"; export const LOGIC_CONTRACT_NAME = process.env.NEXT_PUBLIC_CONTRACT_NAME as string; export const DUST_THRESHOLD = 0.001; -export const hiddenAssets = ["meta-token.near"]; +export const hiddenAssets = ["meta-token.near", "usn"]; export const defaultNetwork = (process.env.NEXT_PUBLIC_DEFAULT_NETWORK || process.env.NODE_ENV || From cd8ea01f5101b18bb97c3b1f2fcdb37672344d05 Mon Sep 17 00:00:00 2001 From: "nature.xie" Date: Wed, 29 Nov 2023 11:35:49 +0800 Subject: [PATCH 3/3] remove usn link --- screens/Dashboard/index.tsx | 5 ++++- screens/Dashboard/supplyBorrowListMobile.tsx | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/screens/Dashboard/index.tsx b/screens/Dashboard/index.tsx index 24cdfbc7..9356d99f 100644 --- a/screens/Dashboard/index.tsx +++ b/screens/Dashboard/index.tsx @@ -21,6 +21,7 @@ import DashboardOverview from "./dashboardOverview"; import { ConnectWalletButton } from "../../components/Header/WalletButton"; import SupplyBorrowListMobile from "./supplyBorrowListMobile"; import { AdjustButton, WithdrawButton, RepayButton, MarketButton } from "./supplyBorrowButtons"; +import { hiddenAssets } from "../../utils/config"; const Index = () => { const accountId = useAccountId(); @@ -194,7 +195,9 @@ const YourSupplied = ({ suppliedRows, accountId, total }) => { selectedRowIndex={selected?.index} actionRow={
- + {hiddenAssets.includes(selected?.data?.tokenId || "") ? null : ( + + )} {canUseAsCollateral && }
diff --git a/screens/Dashboard/supplyBorrowListMobile.tsx b/screens/Dashboard/supplyBorrowListMobile.tsx index f3d03e8e..cae3e0d9 100644 --- a/screens/Dashboard/supplyBorrowListMobile.tsx +++ b/screens/Dashboard/supplyBorrowListMobile.tsx @@ -7,6 +7,7 @@ import DashboardReward from "./dashboardReward"; import { formatTokenValue, formatUSDValue, millifyNumber } from "../../helpers/helpers"; import { AdjustButton, MarketButton, RepayButton, WithdrawButton } from "./supplyBorrowButtons"; import { NoDataMascot } from "../../components/Icons/Icons"; +import { hiddenAssets } from "../../utils/config"; const SupplyBorrowListMobile = ({ suppliedRows, borrowedRows, accountId }) => { const [tabIndex, setTabIndex] = useState(0); @@ -135,14 +136,16 @@ const SupplyItem = ({ data }) => { token
{data?.symbol}
- + {hiddenAssets.includes(data?.tokenId || "") ? null : ( + + )}