Skip to content

Commit

Permalink
feat: modify readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Mar 29, 2024
1 parent 8823ee6 commit db23d7c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 37 deletions.
26 changes: 13 additions & 13 deletions .env template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
66 changes: 47 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
1 change: 0 additions & 1 deletion src/app/hooks/use-bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/app/hooks/use-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/app/hooks/use-ethereum-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/hooks/use-ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit db23d7c

Please sign in to comment.