Skip to content

Commit

Permalink
DDEX standalone node (#7281)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellebrier authored Jan 23, 2024
1 parent 568d677 commit 582c37d
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 284 deletions.
2 changes: 1 addition & 1 deletion packages/ddex/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ WORKDIR /app
COPY --from=app-builder --chown=nodejs:nodejs /app .
WORKDIR /app/packages/ddex/server

EXPOSE 8926
EXPOSE 3000
CMD ["node", "dist/index.js"]
2 changes: 1 addition & 1 deletion packages/ddex/Dockerfile.fast
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ COPY packages/ddex/server/dist /app/packages/ddex/server/public

WORKDIR /app/packages/ddex/server

EXPOSE 8926
EXPOSE 3000
CMD [ "node", "dist/index.js" ]
1 change: 0 additions & 1 deletion packages/ddex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ If you want to run the frontend locally, you'll need to:

Notes:
* When running on stage or prod, the backend serves the frontend as static assets at the root path
* (for now) When ran on stage or prod, the app will query its local `/d_api/env` endpoint to get environment variables that are set on the node. TODO: The backend can just read these from the environment directly.
31 changes: 0 additions & 31 deletions packages/ddex/client/.env.dev
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
# For testing staging locally (ie, npm run stage)
VITE_ENV_OVERRIDE=sandbox
VITE_NODE_TYPE_OVERRIDE=discovery
VITE_NODE_URL_OVERRIDE=https://localhost:5000
VITE_AUDIUS_URL_OVERRIDE=

VITE_ETH_NETWORK_ID_OVERRIDE=5
VITE_ETH_TOKEN_ADDRESS_OVERRIDE=0x855FA758c77D68a04990E992aA4dcdeF899F654A
VITE_ETH_REGISTRY_ADDRESS_OVERRIDE=0xABbfF712977dB51f9f212B85e8A4904c818C2b63
VITE_ETH_PROVIDER_URL_OVERRIDE=http://localhost:8546
VITE_ETH_OWNER_WALLET_OVERRIDE=0x855FA758c77D68a04990E992aA4dcdeF899F654A # it's blank in other stage configs

VITE_QUERY_PROPOSAL_START_BLOCK_OVERRIDE=1
VITE_GQL_URI_OVERRIDE=
VITE_GQL_BACKUP_URI_OVERRIDE=

VITE_ENTITY_MANAGER_ADDRESS_OVERRIDE=0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B

VITE_IDENTITY_SERVICE_ENDPOINT_OVERRIDE=localhost:7000

# not found in local
VITE_WORMHOLE_CONTRACT_ADDRESS_OVERRIDE=0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7

VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS_OVERRIDE=0x74b89B916c97d50557E8F944F32662fE52Ce378d
VITE_SOLANA_CLUSTER_ENDPOINT_OVERRIDE=http://localhost:8899
VITE_WAUDIO_MINT_ADDRESS_OVERRIDE=37RCjhgV1qGV2Q54EHFScdxZ22ydRMdKMtVgod47fDP3
VITE_USDC_MINT_ADDRESS_OVERRIDE=26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y
VITE_SOLANA_TOKEN_PROGRAM_ADDRESS_OVERRIDE=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
VITE_CLAIMABLE_TOKEN_PDA_OVERRIDE=testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9
VITE_SOLANA_FEE_PAYER_ADDRESS_OVERRIDE=HunCgdP91aVeoh8J7cbKTcFRoUwwhHwqYqVVLVkkqQjg
VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS_OVERRIDE=testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9
VITE_REWARDS_MANAGER_PROGRAM_ID_OVERRIDE=testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb
VITE_REWARDS_MANAGER_PROGRAM_PDA_OVERRIDE=DJPzVothq58SmkpRb1ATn5ddN2Rpv1j2TcGvM3XsHf1c
VITE_REWARDS_MANAGER_TOKEN_PDA_OVERRIDE=FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ
VITE_OPTIMIZELY_SDK_KEY_OVERRIDE=MX4fYBgANQetvmBXGpuxzF
34 changes: 2 additions & 32 deletions packages/ddex/client/.env.stage.local
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
# For testing staging locally (ie, npm run stage)
VITE_ENV_OVERRIDE=stage
VITE_NODE_TYPE_OVERRIDE=discovery
VITE_NODE_URL_OVERRIDE=https://discoveryprovider2.staging.audius.co
VITE_AUDIUS_URL_OVERRIDE=https://staging.audius.co

VITE_DDEX_KEY_OVERRIDE=388c38db7bae770d5f371f9d02bebcac4da5e1e9

VITE_ETH_NETWORK_ID_OVERRIDE=5
VITE_ETH_TOKEN_ADDRESS_OVERRIDE=0x5375BE4c52fA29b26077B0F15ee5254D779676A6
VITE_ETH_REGISTRY_ADDRESS_OVERRIDE=0xF27A9c44d7d5DDdA29bC1eeaD94718EeAC1775e3
VITE_ETH_PROVIDER_URL_OVERRIDE=https://eth-goerli.g.alchemy.com/v2/OeXKHus0Nn5z_O7VZjzbprNtKjrYCdUX
VITE_ETH_OWNER_WALLET_OVERRIDE= # 0x5375BE4c52fA29b26077B0F15ee5254D779676A6 # it's blank in other stage configs

VITE_QUERY_PROPOSAL_START_BLOCK_OVERRIDE=1
VITE_GQL_URI_OVERRIDE=https://api.thegraph.com/subgraphs/name/audius-infra/audius-network-goerli
VITE_GQL_BACKUP_URI_OVERRIDE= # it's staging so having a backup isn't as important

VITE_ENTITY_MANAGER_ADDRESS_OVERRIDE=0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64

VITE_IDENTITY_SERVICE_ENDPOINT_OVERRIDE=https://identityservice.staging.audius.co

VITE_WORMHOLE_CONTRACT_ADDRESS_OVERRIDE=0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7
VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS_OVERRIDE=0x74b89B916c97d50557E8F944F32662fE52Ce378d
VITE_SOLANA_CLUSTER_ENDPOINT_OVERRIDE=https://solana-mainnet.g.alchemy.com/v2/N_o4w4Lgk2afO8uho9uuZu0LNi6gldVz
VITE_WAUDIO_MINT_ADDRESS_OVERRIDE=BELGiMZQ34SDE6x2FUaML2UHDAgBLS64xvhXjX5tBBZo
VITE_USDC_MINT_ADDRESS_OVERRIDE=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
VITE_SOLANA_TOKEN_PROGRAM_ADDRESS_OVERRIDE=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
VITE_CLAIMABLE_TOKEN_PDA_OVERRIDE=Aw5AjygeMf9Nvg61BXvFSAzkqxcLqL8koepb14kvfc3W
VITE_SOLANA_FEE_PAYER_ADDRESS_OVERRIDE=E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h
VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS_OVERRIDE=2sjQNmUfkV6yKKi4dPR8gWRgtyma5aiymE3aXL2RAZww
VITE_REWARDS_MANAGER_PROGRAM_ID_OVERRIDE=CDpzvz7DfgbF95jSSCHLX3ERkugyfgn9Fw8ypNZ1hfXp
VITE_REWARDS_MANAGER_PROGRAM_PDA_OVERRIDE=GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq
VITE_REWARDS_MANAGER_TOKEN_PDA_OVERRIDE=HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ
VITE_NODE_URL_OVERRIDE=https://audius-ddex.staging.audius.co
VITE_DDEX_KEY_OVERRIDE=49d5e13d355709b615b7cce7369174fb240b6b39
VITE_OPTIMIZELY_SDK_KEY_OVERRIDE=MX4fYBgANQetvmBXGpuxzF
2 changes: 1 addition & 1 deletion packages/ddex/client/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Layout from './Layout'

const App = () => {
return (
<Router basename='/ddex'>
<Router>
<Layout>
<Routes>
<Route path='/' element={<Ddex />} />
Expand Down
13 changes: 5 additions & 8 deletions packages/ddex/client/src/components/AppWithProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { httpBatchLink } from '@trpc/client'
import Web3 from 'web3'

import { AudiusLibsProvider } from 'providers/AudiusLibsProvider'
import { AudiusSdkProvider } from 'providers/AudiusSdkProvider'
import { RemoteConfigProvider } from 'providers/RemoteConfigProvider'
import { ThemeProvider } from 'providers/ThemeProvider'
Expand Down Expand Up @@ -38,13 +37,11 @@ const AppWithProviders = () => {
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
<RemoteConfigProvider>
<AudiusLibsProvider>
<AudiusSdkProvider>
<ThemeProvider>
<App />
</ThemeProvider>
</AudiusSdkProvider>
</AudiusLibsProvider>
<AudiusSdkProvider>
<ThemeProvider>
<App />
</ThemeProvider>
</AudiusSdkProvider>
</RemoteConfigProvider>
</QueryClientProvider>
</trpc.Provider>
Expand Down
124 changes: 0 additions & 124 deletions packages/ddex/client/src/providers/AudiusLibsProvider.tsx

This file was deleted.

81 changes: 2 additions & 79 deletions packages/ddex/client/src/providers/EnvVarsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,13 @@ import {

interface EnvVars {
env: string
nodeType: string
audiusUrl: string

ethNetworkId: string
ethTokenAddress: string
ethRegistryAddress: string
ethProviderUrl: string
ethOwnerWallet: string

queryProposalStartBlock: string // call parseInt(queryProposalStartBlock || '0') when using
gqlUri: string
gqlBackupUri: string

entityManagerAddress: string

identityServiceEndpoint: string

wormholeContractAddress: string
claimDistributionContractAddress: string
solanaClusterEndpoint: string
wAudioMintAddress: string
usdcMintAddress: string
solanaTokenProgramAddress: string
claimableTokenPda: string
solanaFeePayerAddress: string
claimableTokenProgramAddress: string
rewardsManagerProgramId: string
rewardsManagerProgramPda: string
rewardsManagerTokenPda: string
optimizelySdkKey: string
ddexKey: string
}

// Local testing sets overrides for env vars that would normally be fetched from the node
const envVarOverrides = {
env: (import.meta.env.VITE_ENV_OVERRIDE ?? '') as string,
nodeType: (import.meta.env.VITE_NODE_TYPE_OVERRIDE ?? '') as string,
audiusUrl: (import.meta.env.VITE_AUDIUS_URL_OVERRIDE ?? '') as string,

ethNetworkId: (import.meta.env.VITE_ETH_NETWORK_ID_OVERRIDE ?? '') as string,
ethTokenAddress: (import.meta.env.VITE_ETH_TOKEN_ADDRESS_OVERRIDE ??
'') as string,
ethRegistryAddress: (import.meta.env.VITE_ETH_REGISTRY_ADDRESS_OVERRIDE ??
'') as string,
ethProviderUrl: (import.meta.env.VITE_ETH_PROVIDER_URL_OVERRIDE ??
'') as string,
ethOwnerWallet: (import.meta.env.VITE_ETH_OWNER_WALLET_OVERRIDE ??
'') as string,

queryProposalStartBlock: (import.meta.env
.VITE_QUERY_PROPOSAL_START_BLOCK_OVERRIDE ?? '') as string,
gqlUri: (import.meta.env.VITE_QQL_URI_OVERRIDE ?? '') as string,
gqlBackupUri: (import.meta.env.VITE_QQL_BACKUP_URI_OVERRIDE ?? '') as string,

entityManagerAddress: (import.meta.env.VITE_ENTITY_MANAGER_ADDRESS_OVERRIDE ??
'') as string,

identityServiceEndpoint: (import.meta.env
.VITE_IDENTITY_SERVICE_ENDPOINT_OVERRIDE ?? '') as string,

wormholeContractAddress: (import.meta.env
.VITE_WORMHOLE_CONTRACT_ADDRESS_OVERRIDE ?? '') as string,
claimDistributionContractAddress: (import.meta.env
.VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS_OVERRIDE ?? '') as string,
solanaClusterEndpoint: (import.meta.env
.VITE_SOLANA_CLUSTER_ENDPOINT_OVERRIDE ?? '') as string,
wAudioMintAddress: (import.meta.env.VITE_WAUDIO_MINT_ADDRESS_OVERRIDE ??
'') as string,
usdcMintAddress: (import.meta.env.VITE_USDC_MINT_ADDRESS_OVERRIDE ??
'') as string,
solanaTokenProgramAddress: (import.meta.env
.VITE_SOLANA_TOKEN_PROGRAM_ADDRESS_OVERRIDE ?? '') as string,
claimableTokenPda: (import.meta.env.VITE_CLAIMABLE_TOKEN_PDA_OVERRIDE ??
'') as string,
solanaFeePayerAddress: (import.meta.env
.VITE_SOLANA_FEE_PAYER_ADDRESS_OVERRIDE ?? '') as string,
claimableTokenProgramAddress: (import.meta.env
.VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS_OVERRIDE ?? '') as string,
rewardsManagerProgramId: (import.meta.env
.VITE_REWARDS_MANAGER_PROGRAM_ID_OVERRIDE ?? '') as string,
rewardsManagerProgramPda: (import.meta.env
.VITE_REWARDS_MANAGER_PROGRAM_PDA_OVERRIDE ?? '') as string,
rewardsManagerTokenPda: (import.meta.env
.VITE_REWARDS_MANAGER_TOKEN_PDA_OVERRIDE ?? '') as string,
optimizelySdkKey: (import.meta.env.VITE_OPTIMIZELY_SDK_KEY_OVERRIDE ??
'') as string,
ddexKey: (import.meta.env.VITE_DDEX_KEY_OVERRIDE ?? '') as string
Expand All @@ -111,7 +34,7 @@ export const EnvVarsProvider = ({ children }: { children: ReactNode }) => {
useEffect(() => {
const fetchEnvVars = async () => {
try {
const response = await fetch(`${endpoint}/d_api/env`)
const response = await fetch(`${endpoint}/api/env`)
if (!response.ok) {
throw new Error('Network response was not ok')
}
Expand All @@ -123,7 +46,7 @@ export const EnvVarsProvider = ({ children }: { children: ReactNode }) => {
}

// Stage and prod nodes fetch env vars exposed in audius-docker-compose
if (!envVars.env || !envVars.nodeType) {
if (!envVars.env) {
fetchEnvVars()
}
})
Expand Down
5 changes: 2 additions & 3 deletions packages/ddex/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default defineConfig({
server: {
proxy: isDevelopment
? {
'/api': 'http://localhost:8926', // Assuming port for ../server Express server is unchanged
'/trpc': 'http://localhost:8926'
'/api': 'http://localhost:3000', // Assuming port for ../server Express server is unchanged
'/trpc': 'http://localhost:3000'
}
: {}
},
Expand Down Expand Up @@ -38,7 +38,6 @@ export default defineConfig({
assets: '/src/assets'
}
},
base: '/ddex/',
build: {
commonjsOptions: {
transformMixedEsModules: true
Expand Down
6 changes: 4 additions & 2 deletions packages/ddex/server/.env.stage
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
DDEX_SECRET='54abb93ab41afeeb99a411502ea1ee9b36ec8221cdc7c80a0ceef84c8ca95fc0'
DDEX_KEY='be46e3e1cc722d2ae306f93f21f5b4f08bbd0d53'
NODE_ENV='stage'
DDEX_KEY='49d5e13d355709b615b7cce7369174fb240b6b39'
DDEX_SECRET='2b2c2b90d9a489234ae629a5284de84fb0633306257f17667aaebf2345d92152'
OPTIMIZELY_SDK_KEY='MX4fYBgANQetvmBXGpuxzF'
Loading

0 comments on commit 582c37d

Please sign in to comment.