From 1b05ae73deac7209d9622605a5f68deb277d83de Mon Sep 17 00:00:00 2001
From: bitkeepwallet <85662627+bitkeepwallet@users.noreply.github.com>
Date: Thu, 16 Sep 2021 15:36:07 +0800
Subject: [PATCH 1/3] Add files via upload
---
assets/wallets/bitkeep.svg | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 assets/wallets/bitkeep.svg
diff --git a/assets/wallets/bitkeep.svg b/assets/wallets/bitkeep.svg
new file mode 100644
index 00000000..e5261df9
--- /dev/null
+++ b/assets/wallets/bitkeep.svg
@@ -0,0 +1,5 @@
+
From 14f8f3baebc92880dd0ada0acec419ab569c544e Mon Sep 17 00:00:00 2001
From: bitkeepwallet <85662627+bitkeepwallet@users.noreply.github.com>
Date: Thu, 16 Sep 2021 15:49:29 +0800
Subject: [PATCH 2/3] Update wallet.tsx
---
packages/common/src/contexts/wallet.tsx | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/packages/common/src/contexts/wallet.tsx b/packages/common/src/contexts/wallet.tsx
index 8061e004..9090b9af 100644
--- a/packages/common/src/contexts/wallet.tsx
+++ b/packages/common/src/contexts/wallet.tsx
@@ -18,6 +18,7 @@ import { TorusWalletAdapter } from '../wallet-adapters/torus';
import { useLocation } from 'react-router';
import { LedgerWalletAdapter } from '@solana/wallet-ledger';
import {MathWalletAdapter} from "../wallet-adapters/mathWallet";
+import { BitKeepWalletAdapter } from "../wallet-adapters/bitkeep";
const ASSETS_URL =
'https://raw.githubusercontent.com/solana-labs/oyster/main/assets/wallets/';
@@ -52,6 +53,12 @@ export const WALLET_PROVIDERS = [
icon: `${ASSETS_URL}mathwallet.svg`,
adapter: MathWalletAdapter,
},
+ {
+ name: 'BitKeep',
+ url: 'https://bitkeep.com',
+ icon: `${ASSETS_URL}bitkeep.svg`,
+ adapter: MathWalletAdapter,
+ },
// {
// name: 'Torus',
// url: 'https://tor.us',
From 5533eddc693a9d299e77e21c054d2a85e43863b1 Mon Sep 17 00:00:00 2001
From: bitkeepwallet <85662627+bitkeepwallet@users.noreply.github.com>
Date: Thu, 16 Sep 2021 15:51:42 +0800
Subject: [PATCH 3/3] Create index.tsx
---
.../src/wallet-adapters/bitkeep/index.tsx | 92 +++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 packages/common/src/wallet-adapters/bitkeep/index.tsx
diff --git a/packages/common/src/wallet-adapters/bitkeep/index.tsx b/packages/common/src/wallet-adapters/bitkeep/index.tsx
new file mode 100644
index 00000000..967c4454
--- /dev/null
+++ b/packages/common/src/wallet-adapters/bitkeep/index.tsx
@@ -0,0 +1,92 @@
+import EventEmitter from 'eventemitter3';
+import { PublicKey, Transaction } from '@solana/web3.js';
+import { WalletAdapter } from '@solana/wallet-base';
+import { notify } from '../../utils/notifications';
+
+export class BitKeepWalletAdapter extends EventEmitter implements WalletAdapter {
+ _publicKey: PublicKey | null;
+ _onProcess: boolean;
+ _connected: boolean;
+ constructor() {
+ super();
+ this._publicKey = null;
+ this._onProcess = false;
+ this._connected = false;
+ this.connect = this.connect.bind(this);
+ }
+
+ get publicKey() {
+ return this._publicKey;
+ }
+
+ get connected() {
+ return this._connected;
+ }
+
+ get autoApprove() {
+ return false;
+ }
+
+ // eslint-disable-next-line
+ async signAllTransactions(
+ transactions: Transaction[],
+ ): Promise {
+ if (!this._provider) {
+ return transactions;
+ }
+
+ return this._provider.signAllTransactions(transactions);
+ }
+
+ private get _provider() {
+ if ((window as any)?.solana?.isBitKeep) {
+ return (window as any).solana;
+ }
+ return undefined;
+ }
+
+ signTransaction(transaction: Transaction) {
+ if (!this._provider) {
+ return transaction;
+ }
+
+ return this._provider.signTransaction(transaction);
+ }
+
+ connect() {
+ if (this._onProcess) {
+ return;
+ }
+ if (!this._provider) {
+ notify({
+ message: 'BitKeep Error',
+ description:
+ 'Please open it in BitKeep Wallet',
+ });
+ return;
+ }
+
+ this._onProcess = true;
+ this._provider
+ .getAccount()
+ .then((account: any) => {
+ this._publicKey = new PublicKey(account);
+ this._connected = true;
+ this.emit('connect', this._publicKey);
+ })
+ .catch(() => {
+ this.disconnect();
+ })
+ .finally(() => {
+ this._onProcess = false;
+ });
+ }
+
+ disconnect() {
+ if (this._publicKey) {
+ this._publicKey = null;
+ this._connected = false;
+ this.emit('disconnect');
+ }
+ }
+}