Skip to content

Commit

Permalink
Merge pull request #112 from burrowHQ/btc-wallet-v
Browse files Browse the repository at this point in the history
Btc wallet v
  • Loading branch information
xieqiancaosissi authored Feb 18, 2025
2 parents 2e344a1 + cd18479 commit d558d2e
Show file tree
Hide file tree
Showing 6 changed files with 706 additions and 25 deletions.
8 changes: 7 additions & 1 deletion api/get-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ViewMethodsREFV1,
IShadowRecordInfo,
} from "../interfaces";
import { lpTokenPrefix } from "../utils/config";
import { lpTokenPrefix, NBTCTokenId } from "../utils/config";

export const getTokenContract = async (tokenContractAddress: string): Promise<Contract> => {
const { account } = await getBurrow();
Expand Down Expand Up @@ -47,6 +47,12 @@ const getBalance = async (
account_id: accountId,
},
)) as string;
if (
tokenId === NBTCTokenId &&
window.selector?.store?.getState()?.selectedWalletId === "btc-wallet"
) {
return Decimal.max(new Decimal(balanceInYocto || 0).minus(1000), "0").toFixed();
}
}
return balanceInYocto;
} catch (err: any) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"babel-loader": "^9.1.3",
"bn.js": "^5.2.1",
"borsh": "^0.7.0",
"btc-wallet": "^0.5.21-beta",
"crypto-browserify": "3.12.0",
"decimal.js": "^10.4.1",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
22 changes: 12 additions & 10 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Integrations } from "@sentry/tracing";
import posthogJs from "posthog-js";
import { useIdle, useInterval } from "react-use";
import ModalReact from "react-modal";

import { BtcWalletSelectorContextProvider } from "btc-wallet";
import "../styles/global.css";
import LoadingBar from "react-top-loading-bar";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -198,15 +198,17 @@ export default function MyApp({ Component, pageProps }: AppProps) {
progress={progress}
onLoaderFinished={() => setProgress(0)}
/>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Burrow Finance</title>
</Head>
<Upgrade Component={Component} pageProps={pageProps} />
</PersistGate>
</Provider>
<BtcWalletSelectorContextProvider>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Burrow Finance</title>
</Head>
<Upgrade Component={Component} pageProps={pageProps} />
</PersistGate>
</Provider>
</BtcWalletSelectorContextProvider>
{isBlocked && blockFeatureEnabled && (
<div
className="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center"
Expand Down
5 changes: 4 additions & 1 deletion utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export const BRRR_LABS_TOKEN = {
testnet: "brrr.ft.ref-labs.testnet",
mainnet: "brrr.ft.ref-labs.testnet",
};

export const NBTCTokenId = {
testnet: "nbtc-dev.testnet",
mainnet: "nbtc.bridge.near",
}[defaultNetwork];
export const WALLET_CONNECT_ID =
process.env.NEXT_PUBLIC_WALLET_CONNECT_ID || ("87e549918631f833447b56c15354e450" as string);

Expand Down
5 changes: 5 additions & 0 deletions utils/wallet-selector-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import BN from "bn.js";
import { map, distinctUntilChanged } from "rxjs";
import { setupKeypom } from "@keypom/selector";
import { setupOKXWallet } from "@near-wallet-selector/okx-wallet";
import { setupBTCWallet } from "btc-wallet";
// @ts-nocheck
import type { Config } from "@wagmi/core";
// @ts-nocheck
Expand Down Expand Up @@ -156,6 +157,10 @@ export const getWalletSelector = async ({ onAccountChange }: GetWalletSelectorAr
web3Modal,
alwaysOnboardDuringSignIn: true,
} as any),
setupBTCWallet({
autoConnect: true,
env: "mainnet",
}) as any,
setupOKXWallet({}),
myNearWallet,
setupSender() as any,
Expand Down
Loading

0 comments on commit d558d2e

Please sign in to comment.