diff --git a/.env template b/.env template index 7611381f..d0ad74f8 100644 --- a/.env template +++ b/.env template @@ -16,16 +16,16 @@ # ------------------------------------ # Endpoints of the Attestor Group API -# ATTESTOR_API_URLS=https://example.com/attestor-1,https://example.com/attestor-2,https://example.com/attestor-3 +# VITE_ATTESTOR_API_URLS=https://example.com/attestor-1,https://example.com/attestor-2,https://example.com/attestor-3 # ---------------------------------------- # Locally Run Attestors / Regtest Bitcoin # ---------------------------------------- -# ETHEREUM_DEPLOYMENT_BRANCH=dev -# ETHEREUM_DEPLOYMENT_VERSION=1 +# VITE_ETHEREUM_DEPLOYMENT_BRANCH=dev +# VITE_ETHEREUM_DEPLOYMENT_VERSION=1 # VITE_ENABLED_ETHEREUM_NETWORKS='11155111' -# ATTESTOR_API_URLS= +# VITE_ATTESTOR_API_URLS= # VITE_BITCOIN_NETWORK=regtest # VITE_BITCOIN_EXPLORER_API_URL=https://devnet.dlc.link/electrs # VITE_BITCOIN_BLOCKCHAIN_API_URL=https://devnet.dlc.link/electrs @@ -34,10 +34,10 @@ # Deployed Devnet Attestors / Regtest Bitcoin # ------------------------------------------- -# ETHEREUM_DEPLOYMENT_BRANCH=dev -# ETHEREUM_DEPLOYMENT_VERSION=1 +# VITE_ETHEREUM_DEPLOYMENT_BRANCH=dev +# VITE_ETHEREUM_DEPLOYMENT_VERSION=1 # VITE_ENABLED_ETHEREUM_NETWORKS='11155111' -# ATTESTOR_API_URLS= +# VITE_ATTESTOR_API_URLS= # VITE_BITCOIN_NETWORK=regtest # VITE_BITCOIN_EXPLORER_API_URL=https://devnet.dlc.link/electrs # VITE_BITCOIN_BLOCKCHAIN_API_URL=https://devnet.dlc.link/electrs @@ -46,10 +46,10 @@ # Deployed Testnet Attestors / Testnet Bitcoin # -------------------------------------------- -# ETHEREUM_DEPLOYMENT_BRANCH=testnet -# ETHEREUM_DEPLOYMENT_VERSION=1 +# VITE_ETHEREUM_DEPLOYMENT_BRANCH=testnet +# VITE_ETHEREUM_DEPLOYMENT_VERSION=1 # VITE_ENABLED_ETHEREUM_NETWORKS='11155111' -# ATTESTOR_API_URLS= +# VITE_ATTESTOR_API_URLS= # VITE_BITCOIN_NETWORK=testnet # VITE_BITCOIN_EXPLORER_API_URL=https://mempool.space/testnet # VITE_BITCOIN_BLOCKCHAIN_API_URL=https://testnet.dlc.link/electrs @@ -58,10 +58,10 @@ # Deployed Mainnet Attestors / Mainnet Bitcoin # -------------------------------------------- -# ETHEREUM_DEPLOYMENT_BRANCH=mainnet -# ETHEREUM_DEPLOYMENT_VERSION=1 +# VITE_ETHEREUM_DEPLOYMENT_BRANCH=mainnet +# VITE_ETHEREUM_DEPLOYMENT_VERSION=1 # VITE_ENABLED_ETHEREUM_NETWORKS='11155111' -# ATTESTOR_API_URLS= +# VITE_ATTESTOR_API_URLS= # VITE_BITCOIN_NETWORK=mainnet # VITE_BITCOIN_EXPLORER_API_URL=https://mempool.space # VITE_BITCOIN_BLOCKCHAIN_API_URL=https://mainnet.dlc.link/electrs diff --git a/README.md b/README.md index 46d304f3..80a0351f 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,56 @@ -# React + TypeScript + Vite +# DLC.Link - dlcBTC Bridge -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +## Installation -Currently, two official plugins are available: +To install all the dependencies, run the following command: -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh +```bash +yarn install +``` + +or + +```bash +npm install +``` + +## Setup Environment Variables + +This application uses environment variables for configuration. These are stored in `.env` files. There are different `.env` files for different environments: + +- `.env.localhost`: For locally run attestors / regtest bitcoin. +- `.env.devnet`: For deployed devnet attestors / regtest bitcoin. +- `.env.testnet`: For deployed testnet attestors / testnet bitcoin. +- `.env.mainnet`: For deployed mainnet attestors / mainnet bitcoin. + +Copy the contents of the `.env` template file into the appropriate `.env` file for your environment and fill in the values. The template for the environment variables can be found in the `.env.template` file in the root directory of this project. + +Please ensure that you replace the placeholders with your actual values. -## Expanding the ESLint configuration +## Running the Application -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: +According to the environment you want to run the application in, you can run the following commands: -- Configure the top-level `parserOptions` property like this: +- For locally ran attestors / regtest bitcoin: -```js - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json', './tsconfig.node.json'], - tsconfigRootDir: __dirname, - }, +```bash + yarn localhost ``` -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list -# dlc-btc-website +- For deployed devnet attestors / regtest bitcoin: + +```bash + yarn devnet +``` + +- For deployed testnet attestors / testnet bitcoin: + +```bash + yarn testnet +``` + +- For deployed mainnet attestors / mainnet bitcoin: + +```bash + yarn mainnet +``` diff --git a/src/app/hooks/use-bitcoin.ts b/src/app/hooks/use-bitcoin.ts index b8fd7c96..55a7af6e 100644 --- a/src/app/hooks/use-bitcoin.ts +++ b/src/app/hooks/use-bitcoin.ts @@ -339,7 +339,6 @@ export function useBitcoin(): UseBitcoinReturnType { fundingTransaction: btc.Transaction; multisigTransaction: btc.P2TROut; userNativeSegwitAddress: string; - attestorGroupPublicKey: string; }> { const userAddresses = await getBitcoinAddresses(); const userNativeSegwitAccount = userAddresses[0] as BitcoinNativeSegwitAddress; diff --git a/src/app/hooks/use-endpoints.ts b/src/app/hooks/use-endpoints.ts index 4eb73742..344f0d0f 100644 --- a/src/app/hooks/use-endpoints.ts +++ b/src/app/hooks/use-endpoints.ts @@ -51,6 +51,8 @@ export function useEndpoints(): NetworkEndpoints { }, [network]); function getEndpoints(): 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; diff --git a/src/app/hooks/use-ethereum-contracts.ts b/src/app/hooks/use-ethereum-contracts.ts index 3d85f256..69336d44 100644 --- a/src/app/hooks/use-ethereum-contracts.ts +++ b/src/app/hooks/use-ethereum-contracts.ts @@ -72,8 +72,8 @@ export function useEthereumContracts(): UseEthereumContractsReturnType { contractName: string, ethereumNetwork: EthereumNetwork ) { - const branchName = import.meta.env.ETHEREUM_DEPLOYMENT_BRANCH; - const contractVersion = import.meta.env.ETHEREUM_DEPLOYMENT_VERSION; + const branchName = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_BRANCH; + const contractVersion = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_VERSION; const deploymentPlanURL = `https://raw.githubusercontent.com/DLC-link/dlc-solidity/${branchName}/deploymentFiles/${ethereumNetwork.name.toLowerCase()}/v${contractVersion}/${contractName}.json`; // eslint-disable-next-line no-console diff --git a/src/app/hooks/use-ethereum.ts b/src/app/hooks/use-ethereum.ts index 0c4466eb..42d83a82 100644 --- a/src/app/hooks/use-ethereum.ts +++ b/src/app/hooks/use-ethereum.ts @@ -67,8 +67,8 @@ export function useEthereum(): UseEthereumReturnType { const provider = ethers.providers.getDefaultProvider( 'https://ethereum-sepolia.publicnode.com/' ); - const branchName = import.meta.env.ETHEREUM_DEPLOYMENT_BRANCH; - const contractVersion = import.meta.env.ETHEREUM_DEPLOYMENT_VERSION; + const branchName = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_BRANCH; + const contractVersion = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_VERSION; const deploymentPlanURL = `https://raw.githubusercontent.com/DLC-link/dlc-solidity/${branchName}/deploymentFiles/sepolia/v${contractVersion}/DLCBTC.json`; try { diff --git a/yarn.lock b/yarn.lock index 661266a9..843906b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1773,6 +1773,16 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@fontsource-variable/onest@^5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@fontsource-variable/onest/-/onest-5.0.3.tgz#9484facb7c8468bb064658a0eabd9c2d6366a778" + integrity sha512-vqeDrKg3Ysl4rOepz2N6PnFZ+/EjrmhOv9/pJ+tCn0y00ralsEsCog0xPK6T1hx8Vt70agNR4Jb9C+KWr/K3sg== + +"@fontsource/onest@^5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@fontsource/onest/-/onest-5.0.3.tgz#e6ab3491779014abf532942da59431e3c9cc8acb" + integrity sha512-I0JytH9nHWq949RmPLLga0/QlUoFhWKOg+OO0TTarMeYDrMaAOEKlXjry/5Wm0fqi98xUnbc2iFfHF4s6qgu3g== + "@fontsource/poppins@^5.0.8": version "5.0.12" resolved "https://registry.yarnpkg.com/@fontsource/poppins/-/poppins-5.0.12.tgz#f1e53d2a6b987cf7f186114f9711aba0c66d3848"