Skip to content

Commit

Permalink
use IBTCProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarkhatov committed Dec 16, 2024
1 parent c9625b3 commit 365b9b7
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/core/wallets/bbn/injectable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const metadata: WalletMetadata<BBNProvider, BBNConfig> = {
wallet: "bbnwallet",
createProvider: (wallet) => wallet,
networks: [Network.MAINNET, Network.SIGNET],
label: 'Injectable'
label: "Injectable",
};

export default metadata;
90 changes: 0 additions & 90 deletions src/core/wallets/btc/BTCProvider.ts

This file was deleted.

6 changes: 2 additions & 4 deletions src/core/wallets/btc/bitget/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import type { BTCProvider } from "../BTCProvider";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import logo from "./logo.svg";
import { BitgetProvider, WALLET_PROVIDER_NAME } from "./provider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "bitget",
name: WALLET_PROVIDER_NAME,
icon: logo,
Expand Down
8 changes: 4 additions & 4 deletions src/core/wallets/btc/bitget/provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Psbt } from "bitcoinjs-lib";

import type { BTCConfig, InscriptionIdentifier, WalletInfo } from "@/core/types";
import type { BTCConfig, IBTCProvider, InscriptionIdentifier, WalletInfo } from "@/core/types";
import { Network } from "@/core/types";
import { validateAddress } from "@/core/utils/wallet";
import { BTCProvider } from "@/core/wallets/btc/BTCProvider";

import logo from "./logo.svg";

Expand All @@ -15,12 +14,13 @@ const INTERNAL_NETWORK_NAMES = {

export const WALLET_PROVIDER_NAME = "Bitget";

export class BitgetProvider extends BTCProvider {
export class BitgetProvider implements IBTCProvider {
private provider: any;
private walletInfo: WalletInfo | undefined;
private config: BTCConfig;

constructor(wallet: any, config: BTCConfig) {
super(config);
this.config = config;

// check whether there is an Bitget Wallet extension
if (!wallet?.unisat) {
Expand Down
6 changes: 2 additions & 4 deletions src/core/wallets/btc/cactus/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import type { BTCProvider } from "../BTCProvider";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import logo from "./logo.svg";
import { CactusLinkProvider, WALLET_PROVIDER_NAME } from "./provider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "cactus",
name: WALLET_PROVIDER_NAME,
icon: logo,
Expand Down
8 changes: 4 additions & 4 deletions src/core/wallets/btc/cactus/provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { BTCConfig, InscriptionIdentifier, WalletInfo } from "@/core/types";
import type { BTCConfig, IBTCProvider, InscriptionIdentifier, WalletInfo } from "@/core/types";
import { Network } from "@/core/types";
import { validateAddress } from "@/core/utils/wallet";
import { BTCProvider } from "@/core/wallets/btc/BTCProvider";

import logo from "./logo.svg";

Expand All @@ -13,12 +12,13 @@ const INTERNAL_NETWORK_NAMES = {

export const WALLET_PROVIDER_NAME = "Cactus Link";

export class CactusLinkProvider extends BTCProvider {
export class CactusLinkProvider implements IBTCProvider {
private provider: any;
private walletInfo: WalletInfo | undefined;
private config: BTCConfig;

constructor(wallet: any, config: BTCConfig) {
super(config);
this.config = config;

// check whether there is a Cactus Link Wallet extension
if (!wallet) {
Expand Down
5 changes: 2 additions & 3 deletions src/core/wallets/btc/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { BTCConfig, ChainMetadata } from "@/core/types";
import type { BTCConfig, ChainMetadata, IBTCProvider } from "@/core/types";

import { BTCProvider } from "./BTCProvider";
import icon from "./bitcoin.png";
import bitget from "./bitget";
import cactus from "./cactus";
Expand All @@ -9,7 +8,7 @@ import keystone from "./keystone";
import okx from "./okx";
import onekey from "./onekey";

const metadata: ChainMetadata<"BTC", BTCProvider, BTCConfig> = {
const metadata: ChainMetadata<"BTC", IBTCProvider, BTCConfig> = {
chain: "BTC",
name: "Bitcoin",
icon,
Expand Down
6 changes: 2 additions & 4 deletions src/core/wallets/btc/injectable/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import { BTCProvider } from "../BTCProvider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "injectable",
name: (wallet) => wallet.getWalletProviderName?.(),
icon: (wallet) => wallet.getWalletProviderIcon?.(),
Expand Down
6 changes: 2 additions & 4 deletions src/core/wallets/btc/keystone/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import type { BTCProvider } from "../BTCProvider";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import logo from "./logo.svg";
import { KeystoneProvider, WALLET_PROVIDER_NAME } from "./provider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "keystone",
name: WALLET_PROVIDER_NAME,
icon: logo,
Expand Down
9 changes: 5 additions & 4 deletions src/core/wallets/btc/keystone/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import { toXOnly } from "bitcoinjs-lib/src/psbt/bip371";
import { pubkeyInScript } from "bitcoinjs-lib/src/psbt/psbtutils";

import type { BTCConfig, InscriptionIdentifier } from "@/core/types";
import { Network } from "@/core/types";
import { IBTCProvider, Network } from "@/core/types";
import BIP322 from "@/core/utils/bip322";
import { toNetwork } from "@/core/utils/wallet";
import { BTCProvider } from "@/core/wallets/btc/BTCProvider";

import logo from "./logo.svg";

Expand All @@ -29,13 +28,15 @@ type KeystoneWalletInfo = {

export const WALLET_PROVIDER_NAME = "Keystone";

export class KeystoneProvider extends BTCProvider {
export class KeystoneProvider implements IBTCProvider {
private keystoneWaleltInfo: KeystoneWalletInfo | undefined;
private viewSdk: typeof sdk;
private dataSdk: KeystoneSDK;
private config: BTCConfig;

constructor(_wallet: any, config: BTCConfig) {
super(config);
this.config = config;

if (sdk?.bootstrap) {
sdk.bootstrap();
this.viewSdk = sdk;
Expand Down
6 changes: 2 additions & 4 deletions src/core/wallets/btc/okx/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import type { BTCProvider } from "../BTCProvider";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import logo from "./logo.svg";
import { OKXProvider, WALLET_PROVIDER_NAME } from "./provider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "okx",
name: WALLET_PROVIDER_NAME,
icon: logo,
Expand Down
8 changes: 4 additions & 4 deletions src/core/wallets/btc/okx/provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { BTCConfig, InscriptionIdentifier, WalletInfo } from "@/core/types";
import { Network } from "@/core/types";
import { IBTCProvider, Network } from "@/core/types";
import { validateAddress } from "@/core/utils/wallet";
import { BTCProvider } from "@/core/wallets/btc/BTCProvider";

import logo from "./logo.svg";

Expand All @@ -13,15 +12,16 @@ const PROVIDER_NAMES = {

export const WALLET_PROVIDER_NAME = "OKX";

export class OKXProvider extends BTCProvider {
export class OKXProvider implements IBTCProvider {
private provider: any;
private walletInfo: WalletInfo | undefined;
private config: BTCConfig;

constructor(
private wallet: any,
config: BTCConfig,
) {
super(config);
this.config = config;

// check whether there is an OKX Wallet extension
if (!wallet) {
Expand Down
6 changes: 2 additions & 4 deletions src/core/wallets/btc/onekey/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import type { BTCProvider } from "../BTCProvider";
import { IBTCProvider, Network, type BTCConfig, type WalletMetadata } from "@/core/types";

import logo from "./logo.svg";
import { OneKeyProvider, WALLET_PROVIDER_NAME } from "./provider";

const metadata: WalletMetadata<BTCProvider, BTCConfig> = {
const metadata: WalletMetadata<IBTCProvider, BTCConfig> = {
id: "onekey",
name: WALLET_PROVIDER_NAME,
icon: logo,
Expand Down
8 changes: 4 additions & 4 deletions src/core/wallets/btc/onekey/provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { BTCConfig, InscriptionIdentifier, WalletInfo } from "@/core/types";
import type { BTCConfig, IBTCProvider, InscriptionIdentifier, WalletInfo } from "@/core/types";
import { Network } from "@/core/types";
import { validateAddress } from "@/core/utils/wallet";
import { BTCProvider } from "@/core/wallets/btc/BTCProvider";

import logo from "./logo.svg";

Expand All @@ -13,12 +12,13 @@ const INTERNAL_NETWORK_NAMES = {

export const WALLET_PROVIDER_NAME = "OneKey";

export class OneKeyProvider extends BTCProvider {
export class OneKeyProvider implements IBTCProvider {
private provider: any;
private walletInfo: WalletInfo | undefined;
private config: BTCConfig;

constructor(wallet: any, config: BTCConfig) {
super(config);
this.config = config;

// check whether there is an OneKey extension
if (!wallet?.btcwallet) {
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ export * from "@/context/State.context";
export { createExternalWallet } from "@/core";
export * from "@/core/types";
export * from "@/core/wallets/bbn/BBNProvider";
export * from "@/core/wallets/btc/BTCProvider";

0 comments on commit 365b9b7

Please sign in to comment.