diff --git a/.env template b/.env template new file mode 100644 index 00000000..ce6eff6f --- /dev/null +++ b/.env template @@ -0,0 +1,20 @@ +# VITE_ATTESTOR_API_URLS_EXAMPLE: https://example/attestor-1,https://example/attestor-2,https://example/attestor-3 + +# Regtest + +VITE_ETHEREUM_DEPLOYMENT_BRANCH=dev +VITE_ETHEREUM_DEPLOYMENT_VERSION=1 +VITE_ENABLED_ETHEREUM_NETWORKS='11155111' +VITE_ATTESTOR_API_URLS= +VITE_BITCOIN_NETWORK=regtest +VITE_BITCOIN_EXPLORER_API_URL=https://devnet.dlc.link/electrs/tx/ +VITE_BITCOIN_BLOCKCHAIN_API_URL=https://devnet.dlc.link/electrs + +# # Testnet +# VITE_ETHEREUM_DEPLOYMENT_BRANCH=dev +# VITE_ETHEREUM_DEPLOYMENT_VERSION=1 +# VITE_ENABLED_ETHEREUM_NETWORKS='11155111' +# VITE_ATTESTOR_API_URLS= +# VITE_BITCOIN_NETWORK=testnet +# VITE_BITCOIN_EXPLORER_API_URL=https://mempool.space/testnet/tx/ +# VITE_BITCOIN_BLOCKCHAIN_API_URL=https://testnet.dlc.link/electrs diff --git a/src/app/components/modals/select-wallet-modal/select-wallet-modal.tsx b/src/app/components/modals/select-wallet-modal/select-wallet-modal.tsx index f86ba27e..e04565d7 100644 --- a/src/app/components/modals/select-wallet-modal/select-wallet-modal.tsx +++ b/src/app/components/modals/select-wallet-modal/select-wallet-modal.tsx @@ -7,13 +7,13 @@ import { ModalLayout } from '@components/modals/components/modal.layout'; import { SelectWalletMenu } from '@components/modals/select-wallet-modal/components/select-wallet-menu'; import { SelectNetworkButton } from '@components/select-network-button/select-network-button'; import { useEthereumAccount } from '@hooks/use-ethereum-account'; -import { Network } from '@models/ethereum-network'; +import { EthereumNetwork } from '@models/ethereum-network'; import { WalletType, ethereumWallets } from '@models/wallet'; export function SelectWalletModal({ isOpen, handleClose }: ModalComponentProps): React.JSX.Element { const ethereumAccountHandler = useEthereumAccount(); - const [currentNetwork, setCurrentNetwork] = useState(undefined); + const [currentNetwork, setCurrentNetwork] = useState(undefined); async function handleLogin(walletType: WalletType) { if (!currentNetwork) throw new Error('No network selected'); @@ -22,7 +22,7 @@ export function SelectWalletModal({ isOpen, handleClose }: ModalComponentProps): handleClose(); } - const handleNetworkChange = (currentNetwork: Network) => { + const handleNetworkChange = (currentNetwork: EthereumNetwork) => { setCurrentNetwork(currentNetwork); }; diff --git a/src/app/components/select-network-button/select-network-button.tsx b/src/app/components/select-network-button/select-network-button.tsx index 262681a7..9a907d9c 100644 --- a/src/app/components/select-network-button/select-network-button.tsx +++ b/src/app/components/select-network-button/select-network-button.tsx @@ -1,10 +1,10 @@ import { ChevronDownIcon } from '@chakra-ui/icons'; import { HStack, Menu, MenuButton, MenuItem, MenuList, Text } from '@chakra-ui/react'; -import { Network, ethereumNetworks } from '@models/ethereum-network'; +import { EthereumNetwork, ethereumNetworks } from '@models/ethereum-network'; interface SelectNetworkButtonProps { - handleClick: (network: Network) => void; - currentNetwork?: Network; + handleClick: (network: EthereumNetwork) => void; + currentNetwork?: EthereumNetwork; } export function SelectNetworkButton({ diff --git a/src/app/hooks/use-attestors.ts b/src/app/hooks/use-attestors.ts index c63e745a..cfd16042 100644 --- a/src/app/hooks/use-attestors.ts +++ b/src/app/hooks/use-attestors.ts @@ -2,7 +2,7 @@ import { AttestorError } from '@models/error-types'; import { useEndpoints } from './use-endpoints'; -export interface UseAttestorsReturnType { +interface UseAttestorsReturnType { getAttestorGroupPublicKey: () => Promise; sendClosingTransactionToAttestors: ( closingPSBT: string, diff --git a/src/app/hooks/use-bitcoin-price.ts b/src/app/hooks/use-bitcoin-price.ts index 9b2463a4..9ad18a8b 100644 --- a/src/app/hooks/use-bitcoin-price.ts +++ b/src/app/hooks/use-bitcoin-price.ts @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { BitcoinError } from '@models/error-types'; -export interface UseBitcoinPriceReturnType { +interface UseBitcoinPriceReturnType { bitcoinPrice: number; } diff --git a/src/app/hooks/use-bitcoin.ts b/src/app/hooks/use-bitcoin.ts index 20a93450..10737f0e 100644 --- a/src/app/hooks/use-bitcoin.ts +++ b/src/app/hooks/use-bitcoin.ts @@ -71,7 +71,7 @@ interface RpcResponse { result: RpcResult; } -export interface UseBitcoinReturnType { +interface UseBitcoinReturnType { signAndBroadcastFundingPSBT: (btcAmount: number) => Promise<{ fundingTransaction: btc.Transaction; multisigTransaction: btc.P2TROut; diff --git a/src/app/hooks/use-endpoints.ts b/src/app/hooks/use-endpoints.ts index 6d341fbf..961357c1 100644 --- a/src/app/hooks/use-endpoints.ts +++ b/src/app/hooks/use-endpoints.ts @@ -53,6 +53,8 @@ export function useEndpoints(): NetworkEndpoints { const attestorAPIURLs: string[] = import.meta.env.VITE_ATTESTOR_API_URLS.split(','); const bitcoinNetworkName = import.meta.env.VITE_BITCOIN_NETWORK; + const bitcoinBlockchainAPIURL = import.meta.env.VITE_BITCOIN_BLOCKCHAIN_API_URL; + const bitcoinExplorerAPIURL = import.meta.env.VITE_BITCOIN_EXPLORER_API_URL; let bitcoinNetwork; switch (bitcoinNetworkName) { @@ -72,8 +74,8 @@ export function useEndpoints(): NetworkEndpoints { attestorAPIURLs, ethereumExplorerAPIURL: 'https://sepolia.etherscan.io/tx/', ethereumAttestorChainID: 'evm-sepolia', - bitcoinExplorerAPIURL: 'http://devnet.dlc.link/electrs/tx/', - bitcoinBlockchainAPIURL: 'https://devnet.dlc.link/electrs', + bitcoinExplorerAPIURL, + bitcoinBlockchainAPIURL, bitcoinNetwork, bitcoinNetworkName, }; @@ -82,8 +84,8 @@ export function useEndpoints(): NetworkEndpoints { attestorAPIURLs, ethereumExplorerAPIURL: 'https://goerli.etherscan.io/tx/', ethereumAttestorChainID: 'evm-goerli', - bitcoinExplorerAPIURL: 'https://blockstream.info/testnet/tx/', - bitcoinBlockchainAPIURL: 'https://devnet.dlc.link/electrs', + bitcoinExplorerAPIURL, + bitcoinBlockchainAPIURL, bitcoinNetwork, bitcoinNetworkName, }; @@ -92,8 +94,8 @@ export function useEndpoints(): NetworkEndpoints { attestorAPIURLs, ethereumExplorerAPIURL: 'https://www.oklink.com/x1-test/tx/', ethereumAttestorChainID: 'evm-x1-test', - bitcoinExplorerAPIURL: 'http://devnet.dlc.link/electrs/tx/', - bitcoinBlockchainAPIURL: 'https://devnet.dlc.link/electrs', + bitcoinExplorerAPIURL, + bitcoinBlockchainAPIURL, bitcoinNetwork, bitcoinNetworkName, }; diff --git a/src/app/hooks/use-ethereum-account.ts b/src/app/hooks/use-ethereum-account.ts index 79512f8d..af0b1186 100644 --- a/src/app/hooks/use-ethereum-account.ts +++ b/src/app/hooks/use-ethereum-account.ts @@ -16,7 +16,7 @@ import { ethers } from 'ethers'; import { throwEthereumError } from './use-ethereum'; import { useEthereumContext } from './use-ethereum-context'; -export interface UseEthereumReturnType { +interface UseEthereumAccountReturnType { connectEthereumAccount: (walletType: WalletType, network: EthereumNetwork) => Promise; recommendTokenToMetamask: () => Promise; isLoaded: boolean; @@ -41,7 +41,7 @@ function alertNetworkNotSupported(ethereumNetworkID: string): void { throw new Error(`Unsupported Ethereum network, ID: ${ethereumNetworkID}`); } -export function useEthereumAccount(): UseEthereumReturnType { +export function useEthereumAccount(): UseEthereumAccountReturnType { const { dlcBTCContract, getEthereumContracts } = useEthereumContext(); const { address, walletType, network } = useSelector((state: RootState) => state.account); diff --git a/src/app/hooks/use-ethereum-contracts.ts b/src/app/hooks/use-ethereum-contracts.ts index 96f52f0b..41ad3ea5 100644 --- a/src/app/hooks/use-ethereum-contracts.ts +++ b/src/app/hooks/use-ethereum-contracts.ts @@ -5,7 +5,7 @@ import { EthereumError } from '@models/error-types'; import { EthereumNetwork } from '@models/ethereum-network'; import { Contract, ethers } from 'ethers'; -export interface UseEthereumContractsReturnType { +interface UseEthereumContractsReturnType { getEthereumContracts: ( ethereumSigner: ethers.providers.JsonRpcSigner, ethereumNetwork: EthereumNetwork diff --git a/src/app/hooks/use-ethereum.ts b/src/app/hooks/use-ethereum.ts index 70dd7e48..df3efb6d 100644 --- a/src/app/hooks/use-ethereum.ts +++ b/src/app/hooks/use-ethereum.ts @@ -13,7 +13,7 @@ import { Logger } from 'ethers/lib/utils'; import { useEthereumContext } from './use-ethereum-context'; -export interface UseEthereumReturnType { +interface UseEthereumReturnType { getDLCBTCBalance: () => Promise; getLockedBTCBalance: () => Promise; getProtocolFee: () => Promise; diff --git a/src/app/hooks/use-psbt.ts b/src/app/hooks/use-psbt.ts index 6a89d82f..0649d49f 100644 --- a/src/app/hooks/use-psbt.ts +++ b/src/app/hooks/use-psbt.ts @@ -10,12 +10,12 @@ import { vaultActions } from '@store/slices/vault/vault.actions'; import { useBitcoin } from './use-bitcoin'; -export interface UseSignPSBTReturnType { +interface UsePSBTReturnType { handleSignFundingTransaction: (btcAmount: number, vaultUUID: string) => Promise; handleSignClosingTransaction: () => Promise; } -export function usePSBT(): UseSignPSBTReturnType { +export function usePSBT(): UsePSBTReturnType { const dispatch = useDispatch(); const { signAndBroadcastFundingPSBT, signAndSendClosingPSBT, broadcastTransaction } = useBitcoin();