Skip to content

Commit

Permalink
feat: add BitKeep wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
alx-khramov committed Jul 11, 2023
1 parent 8316987 commit 224a39e
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/wallets-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions packages/wallets-list/src/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,4 +20,5 @@ export const WalletsListEthereum: WalletsListType = {
zengo: Zengo,
ambire: Ambire,
phantom: Phantom,
bitkeep: BitKeep,
};
9 changes: 9 additions & 0 deletions packages/wallets/bitkeep/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"root": true,
"extends": [
"custom"
],
"rules": {
"import/no-extraneous-dependencies": "warn"
}
}
42 changes: 42 additions & 0 deletions packages/wallets/bitkeep/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
56 changes: 56 additions & 0 deletions packages/wallets/bitkeep/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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/<package>/<exports-field-entry>
/^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,
});
4 changes: 4 additions & 0 deletions packages/wallets/bitkeep/src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg' {
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
export default content;
}
4 changes: 4 additions & 0 deletions packages/wallets/bitkeep/src/icons/bitkeep.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/wallets/bitkeep/src/index.ts
Original file line number Diff line number Diff line change
@@ -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,
},
}),
});
8 changes: 8 additions & 0 deletions packages/wallets/bitkeep/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "tsconfig/react-library.json",
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.*"],
"compilerOptions": {
"rootDir": "src",
}
}

0 comments on commit 224a39e

Please sign in to comment.