Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: modify network fetching for por (#87) #88

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/app/hooks/use-bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useSelector } from 'react-redux';

import { customShiftValue } from '@common/utilities';
import { BitcoinNetwork } from '@models/bitcoin-network';
import { BitcoinError } from '@models/error-types';
import { ethereumArbSepolia } from '@models/ethereum-network';
import { Vault } from '@models/vault';
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
import { hex } from '@scure/base';
import * as btc from '@scure/btc-signer';
import { RootState } from '@store/index';
import { payments } from 'bitcoinjs-lib';

import { useAttestors } from './use-attestors';
Expand Down Expand Up @@ -109,6 +111,7 @@ export function useBitcoin(): UseBitcoinReturnType {
} = useEndpoints();
const { sendClosingTransactionToAttestors } = useAttestors();
const { getAttestorGroupPublicKey } = useEthereum();
const { network } = useSelector((state: RootState) => state.account);

/**
* Checks if the user's wallet is on the same network as the app.
Expand Down Expand Up @@ -439,7 +442,7 @@ export function useBitcoin(): UseBitcoinReturnType {
const userTaprootAddress = userAddresses[1] as BitcoinTaprootAddress;
const userPublicKey = userTaprootAddress.tweakedPublicKey;

const attestorGroupPublicKey = await getAttestorGroupPublicKey(ethereumArbSepolia);
const attestorGroupPublicKey = await getAttestorGroupPublicKey(network);

const userUTXOs = await getUTXOs(userAddresses[0] as BitcoinNativeSegwitAddress);
const multisigTransaction = createMultisigTransaction(
Expand Down
6 changes: 4 additions & 2 deletions src/app/hooks/use-proof-of-reserve.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useEffect, useState } from 'react';
import { useQuery } from 'react-query';
import { useSelector } from 'react-redux';

import { customShiftValue } from '@common/utilities';
import { BitcoinNetwork } from '@models/bitcoin-network';
import { BitcoinTransaction, BitcoinTransactionVectorOutput } from '@models/bitcoin-transaction';
import { ethereumArbSepolia } from '@models/ethereum-network';
import { RawVault } from '@models/vault';
import { hex } from '@scure/base';
import { p2tr, p2tr_ns, taprootTweakPubkey } from '@scure/btc-signer';
import { RootState } from '@store/index';

import { useEndpoints } from './use-endpoints';
import { useEthereum } from './use-ethereum';
Expand All @@ -19,6 +20,7 @@ interface UseProofOfReserveReturnType {
export function useProofOfReserve(): UseProofOfReserveReturnType {
const { bitcoinBlockchainAPIURL, bitcoinNetwork, enabledEthereumNetworks } = useEndpoints();
const { getAllFundedVaults, getAttestorGroupPublicKey } = useEthereum();
const { network } = useSelector((state: RootState) => state.account);

const [shouldFetch, setShouldFetch] = useState(false);

Expand Down Expand Up @@ -151,7 +153,7 @@ export function useProofOfReserve(): UseProofOfReserveReturnType {
);

// Get the Attestor Public Key from the Attestor Group
const attestorPublicKey = await getAttestorGroupPublicKey(ethereumArbSepolia);
const attestorPublicKey = await getAttestorGroupPublicKey(network);

// Create two MultiSig Transactions, because the User and Attestor can sign in any order
// Create the MultiSig Transaction A
Expand Down
Loading