diff --git a/.env b/.env new file mode 100644 index 00000000..bd1023a6 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +PUBLIC_BLOCKCHAIN=gnosis +PUBLIC_WAKU=production diff --git a/.gitignore b/.gitignore index 6635cf55..9d54a5d7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ node_modules /build /.svelte-kit /package -.env .env.* !.env.example vite.config.js.timestamp-* diff --git a/README.md b/README.md index f609d3ee..ae7684cb 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,27 @@ pnpm build You can preview the production build with `pnpm preview`. +## Config + +Use env variables to specify: + +```bash +# Which waku node to connect to +# Options: +# local single waku node running in docker +# production waku nodes used for production deployment +# Defaults to +PUBLIC_WAKU='production' + +# Which blockchain to connect to +# Options: +# local local chain running in docker +# chiado chiado testnet +# gnosis gnosis mainnet +# Defaults to +PUBLIC_BLOCKCHAIN='gnosis' +``` + ## CLI There is a built-in command line tool for making development easier. diff --git a/src/lib/adapters/transaction.ts b/src/lib/adapters/transaction.ts index acdf6873..2f05f76d 100644 --- a/src/lib/adapters/transaction.ts +++ b/src/lib/adapters/transaction.ts @@ -9,6 +9,7 @@ import { Contract, } from 'ethers' import abi from '$lib/abis/erc20.json' +import { PUBLIC_BLOCKCHAIN } from '$env/static/public' interface BlockchainExplorer { name: string @@ -26,8 +27,7 @@ interface BlockchainNetwork { } } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const testBlockchain: BlockchainNetwork = { +const localBlockchain: BlockchainNetwork = { name: 'Local testnet', provider: 'http://127.0.0.1:8545', nativeToken: { @@ -41,7 +41,6 @@ const testBlockchain: BlockchainNetwork = { }, } -// eslint-disable-next-line @typescript-eslint/no-unused-vars const chiadoBlockchain: BlockchainNetwork = { name: 'Chiado testnet', provider: 'https://rpc.chiado.apyos.dev/', @@ -69,7 +68,6 @@ const chiadoBlockchain: BlockchainNetwork = { }, } -// eslint-disable-next-line @typescript-eslint/no-unused-vars const gnosisBlockchain: BlockchainNetwork = { name: 'Gnosis', provider: 'https://gnosis-erigon.apyos.dev/', @@ -97,26 +95,22 @@ const gnosisBlockchain: BlockchainNetwork = { }, } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const sepoliaBlockchain: BlockchainNetwork = { - name: 'Sepolia testnet', - provider: 'https://rpc2.sepolia.org/ ', - explorer: { - name: 'Etherscan', - url: 'https://sepolia.etherscan.io/', - }, - nativeToken: { - name: 'Sepolia ETH', - symbol: 'SEP', - decimals: 18, - image: 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png', - }, - objects: { - splitterFactory: '0x0', - }, +function getBlockchainNetwork(): BlockchainNetwork { + switch (PUBLIC_BLOCKCHAIN) { + case 'local': + return localBlockchain + + case 'chiado': + return chiadoBlockchain + + // Defaults to production + case 'gnosis': + default: + return gnosisBlockchain + } } -export const defaultBlockchainNetwork = gnosisBlockchain +export const defaultBlockchainNetwork = getBlockchainNetwork() export function getProvider(): Provider { const providerUrl = defaultBlockchainNetwork.provider diff --git a/src/lib/adapters/waku/waku.ts b/src/lib/adapters/waku/waku.ts index d082891e..03e6b391 100644 --- a/src/lib/adapters/waku/waku.ts +++ b/src/lib/adapters/waku/waku.ts @@ -15,24 +15,28 @@ import { type StoreQueryOptions, type Unsubscribe, } from '@waku/interfaces' +import { PUBLIC_WAKU } from '$env/static/public' + +function getPeers(): string[] { + switch (PUBLIC_WAKU) { + // Local version in docker + case 'local': + return [ + '/ip4/127.0.0.1/tcp/8000/ws/p2p/16Uiu2HAm53sojJN72rFbYg6GV2LpRRER9XeWkiEAhjKy3aL9cN5Z', + ] + + // Defaults to production + case 'production': + default: + return [ + '/dns4/go-waku.gra.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmMafTFmwN9xat1jw7eHnwZJruQiezttwfRaeSgY5hkwe5', + '/dns4/go-waku.de.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmTwF1VMGkNLXJDj7jLNLMeFwZt8jP8qKS1uojQSCiHib6', + '/dns4/go-waku.bhs.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAm2RwLYewyx3UWZgKT7SQPjASF8AYE3WCyWiM9xupZNCmW', + ] + } +} -const peers = [ - // use this address for local testing - // '/ip4/127.0.0.1/tcp/8000/ws/p2p/16Uiu2HAm53sojJN72rFbYg6GV2LpRRER9XeWkiEAhjKy3aL9cN5Z', - - // '/dns4/ws.waku.apyos.dev/tcp/443/wss/p2p/16Uiu2HAm5wH4dPAV6zDfrBHkWt9Wu9iiXT4ehHdUArDUbEevzmBY', - // '/dns4/ws.waku-1.apyos.dev/tcp/443/wss/p2p/16Uiu2HAm8gXHntr3SB5sde11pavjptaoiqyvwoX3GyEZWKMPiuBu', - - // '/dns4/waku.gra.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmDvywnsGaB32tFqwjTsg8sfC1ZV2EXo3xjxM4V2gvH6Up', - // '/dns4/waku.bhs.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAkvrRkEHRMfe26F8NCWUfzMuaCfyCzwoPSUYG7yminM5Bn', - // '/dns4/waku.de.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmRgjA134DcoyK8r44pKWJQ69C7McLSWtRgxUVwkKAsbGx', - - '/dns4/go-waku.gra.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmMafTFmwN9xat1jw7eHnwZJruQiezttwfRaeSgY5hkwe5', - '/dns4/go-waku.de.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmTwF1VMGkNLXJDj7jLNLMeFwZt8jP8qKS1uojQSCiHib6', - '/dns4/go-waku.bhs.nomad.apyos.dev/tcp/443/wss/p2p/16Uiu2HAm2RwLYewyx3UWZgKT7SQPjASF8AYE3WCyWiM9xupZNCmW', - - // '/dns4/go-waku.srv02.apyos.dev/tcp/443/wss/p2p/16Uiu2HAmPwoBY7YzjGAkHDzd93wX1rXks7MRMCX7m1Jr2b8jSSwQ', -] +const peers = getPeers() export type ContentTopic = 'private-message' | 'profile' | 'chats' | 'objects' | 'group-chats'