From 539f14cbfd7ab1e06b43ed8e1d995d074715e171 Mon Sep 17 00:00:00 2001 From: Alexander Khramov Date: Wed, 5 Jul 2023 17:11:04 +0300 Subject: [PATCH] feat: add BitKeep wallet --- packages/wallets-list/package.json | 3 +- packages/wallets-list/src/ethereum.ts | 2 + packages/wallets/bitkeep/.eslintrc.json | 9 +++ packages/wallets/bitkeep/package.json | 42 ++++++++++++++ packages/wallets/bitkeep/rollup.config.js | 56 +++++++++++++++++++ packages/wallets/bitkeep/src/custom.d.ts | 4 ++ .../wallets/bitkeep/src/icons/bitkeep.svg | 4 ++ packages/wallets/bitkeep/src/index.ts | 29 ++++++++++ packages/wallets/bitkeep/tsconfig.json | 8 +++ 9 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 packages/wallets/bitkeep/.eslintrc.json create mode 100644 packages/wallets/bitkeep/package.json create mode 100644 packages/wallets/bitkeep/rollup.config.js create mode 100644 packages/wallets/bitkeep/src/custom.d.ts create mode 100644 packages/wallets/bitkeep/src/icons/bitkeep.svg create mode 100644 packages/wallets/bitkeep/src/index.ts create mode 100644 packages/wallets/bitkeep/tsconfig.json diff --git a/packages/wallets-list/package.json b/packages/wallets-list/package.json index c04cc529..22c61adf 100644 --- a/packages/wallets-list/package.json +++ b/packages/wallets-list/package.json @@ -45,7 +45,8 @@ "@reef-knot/wallet-adapter-blockchaincom": "1.2.2", "@reef-knot/wallet-adapter-zerion": "1.2.2", "@reef-knot/wallet-adapter-zengo": "1.2.2", - "@reef-knot/wallet-adapter-ambire": "1.2.2" + "@reef-knot/wallet-adapter-ambire": "1.2.2", + "@reef-knot/wallet-adapter-bitkeep": "0.0.0" }, "devDependencies": { "@reef-knot/types": "^1.2.1" diff --git a/packages/wallets-list/src/ethereum.ts b/packages/wallets-list/src/ethereum.ts index 8ef74e13..9a1303a6 100644 --- a/packages/wallets-list/src/ethereum.ts +++ b/packages/wallets-list/src/ethereum.ts @@ -8,6 +8,7 @@ import { Zerion } from '@reef-knot/wallet-adapter-zerion'; import { Zengo } from '@reef-knot/wallet-adapter-zengo'; import { Ambire } from '@reef-knot/wallet-adapter-ambire'; import { Phantom } from '@reef-knot/wallet-adapter-phantom'; +import { BitKeep } from '@reef-knot/wallet-adapter-bitkeep'; export const WalletsListEthereum: WalletsListType = { okx: Okx, @@ -19,4 +20,5 @@ export const WalletsListEthereum: WalletsListType = { zengo: Zengo, ambire: Ambire, phantom: Phantom, + bitkeep: BitKeep, }; diff --git a/packages/wallets/bitkeep/.eslintrc.json b/packages/wallets/bitkeep/.eslintrc.json new file mode 100644 index 00000000..06342be5 --- /dev/null +++ b/packages/wallets/bitkeep/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "root": true, + "extends": [ + "custom" + ], + "rules": { + "import/no-extraneous-dependencies": "warn" + } +} diff --git a/packages/wallets/bitkeep/package.json b/packages/wallets/bitkeep/package.json new file mode 100644 index 00000000..6d8cb8a1 --- /dev/null +++ b/packages/wallets/bitkeep/package.json @@ -0,0 +1,42 @@ +{ + "name": "@reef-knot/wallet-adapter-bitkeep", + "version": "0.0.0", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, + "typesVersions": { + "*": { + ".": [ + "dist/index.d.ts" + ] + } + }, + "type": "module", + "files": [ + "dist" + ], + "license": "MIT", + "homepage": "https://github.com/lidofinance/reef-knot", + "bugs": { + "url": "https://github.com/lidofinance/reef-knot/issues" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "scripts": { + "build": "rollup -c", + "dev": "dev=on rollup -c -w", + "lint": "eslint" + }, + "devDependencies": { + "@reef-knot/types": "^1.2.1", + "@svgr/rollup": "^6.5.1" + }, + "peerDependencies": { + "wagmi": "^0.12.18", + "@reef-knot/types": "^1.2.1" + } +} diff --git a/packages/wallets/bitkeep/rollup.config.js b/packages/wallets/bitkeep/rollup.config.js new file mode 100644 index 00000000..a90d041a --- /dev/null +++ b/packages/wallets/bitkeep/rollup.config.js @@ -0,0 +1,56 @@ +import * as process from 'node:process'; +import fs from 'node:fs'; +import ts from 'typescript'; +import { defineConfig } from 'rollup'; +import del from 'rollup-plugin-delete'; +import resolve from '@rollup/plugin-node-resolve'; +import typescript from 'rollup-plugin-typescript2'; +import { babel } from '@rollup/plugin-babel'; +import svgr from '@svgr/rollup'; + +const extensions = ['.js', '.jsx', '.ts', '.tsx', '.svg']; +const { dependencies = {}, peerDependencies = {} } = + JSON.parse(fs.readFileSync('package.json', 'utf-8')); +const commonExternal = [ + 'react/jsx-runtime', + // Do not include in the bundle subpath exports like: + /^@reef-knot\/.*/, // e.g. @reef-knot// + /^reef-knot\/.*/, // e.g. reef-knot/wallets-icons/react +]; +const external = [ + ...commonExternal, + ...Object.keys({ ...dependencies, ...peerDependencies }), + /node_modules/ +]; +const isDevMode = process.env.dev === 'on'; + +export default defineConfig({ + input: './src/index', + output: { + format: 'es', + dir: 'dist', + preserveModules: true, + preserveModulesRoot: 'src', + generatedCode: 'es2015' + }, + plugins: [ + isDevMode ? null : del({ targets: 'dist/*', runOnce: true }), + resolve({ extensions, preferBuiltins: true }), + svgr({ + typescript: true, + prettier: false, + memo: true, + svgo: false, + }), + typescript({ + typescript: ts, + tsconfig: 'tsconfig.json', + }), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'bundled', + extensions, + }), + ], + external, +}); diff --git a/packages/wallets/bitkeep/src/custom.d.ts b/packages/wallets/bitkeep/src/custom.d.ts new file mode 100644 index 00000000..006534e2 --- /dev/null +++ b/packages/wallets/bitkeep/src/custom.d.ts @@ -0,0 +1,4 @@ +declare module '*.svg' { + const content: React.FunctionComponent>; + export default content; +} diff --git a/packages/wallets/bitkeep/src/icons/bitkeep.svg b/packages/wallets/bitkeep/src/icons/bitkeep.svg new file mode 100644 index 00000000..c7be2f3a --- /dev/null +++ b/packages/wallets/bitkeep/src/icons/bitkeep.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/wallets/bitkeep/src/index.ts b/packages/wallets/bitkeep/src/index.ts new file mode 100644 index 00000000..6910390c --- /dev/null +++ b/packages/wallets/bitkeep/src/index.ts @@ -0,0 +1,29 @@ +import { WalletAdapterType } from '@reef-knot/types'; +import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; +import { InjectedConnector } from 'wagmi/connectors/injected'; +import WalletIcon from './icons/bitkeep.svg'; + +declare global { + interface Window { + bitkeep?: { + ethereum?: EthereumTypeWagmi; + }; + } +} + +export const BitKeep: WalletAdapterType = ({ chains }) => ({ + walletName: 'BitKeep', + walletId: 'bitkeep', + icon: WalletIcon, + detector: () => !!globalThis.window?.bitkeep?.ethereum, + downloadURLs: { + default: 'https://bitkeep.com/en/download/', + }, + connector: new InjectedConnector({ + chains, + options: { + name: 'BitKeep', + getProvider: () => globalThis.window?.bitkeep?.ethereum, + }, + }), +}); diff --git a/packages/wallets/bitkeep/tsconfig.json b/packages/wallets/bitkeep/tsconfig.json new file mode 100644 index 00000000..23709e73 --- /dev/null +++ b/packages/wallets/bitkeep/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "tsconfig/react-library.json", + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "**/*.test.*"], + "compilerOptions": { + "rootDir": "src", + } +}