diff --git a/.circleci/src/commands/@web-commands.yml b/.circleci/src/commands/@web-commands.yml index a5d99720a69..13121e6fa50 100644 --- a/.circleci/src/commands/@web-commands.yml +++ b/.circleci/src/commands/@web-commands.yml @@ -51,7 +51,7 @@ web-pr-comment: web-build: parameters: build-type: - default: 'prod-source-maps' + default: 'prod' type: string build-directory: default: 'packages/web/build-production' diff --git a/.circleci/src/jobs/@mobile-jobs.yml b/.circleci/src/jobs/@mobile-jobs.yml index 1a892eaf57e..63b9483a9fc 100644 --- a/.circleci/src/jobs/@mobile-jobs.yml +++ b/.circleci/src/jobs/@mobile-jobs.yml @@ -8,13 +8,11 @@ mobile-init: name: copy staging env command: | cd packages/mobile - echo "FCM_SENDER_ID=$FCM_SENDER_ID" >> .env.stage echo "AMPLITUDE_WRITE_KEY=$AMPLITUDE_WRITE_KEY_STAGE" >> .env.stage - run: name: copy production env command: | cd packages/mobile - echo "FCM_SENDER_ID=$FCM_SENDER_ID" >> .env.prod echo "AMPLITUDE_WRITE_KEY=$AMPLITUDE_WRITE_KEY_PROD" >> .env.prod - create_concatenated_patch_file: diff --git a/.circleci/src/jobs/@web-jobs.yml b/.circleci/src/jobs/@web-jobs.yml index 7a47cff8c76..ae6d69b0d44 100644 --- a/.circleci/src/jobs/@web-jobs.yml +++ b/.circleci/src/jobs/@web-jobs.yml @@ -51,15 +51,15 @@ web-build-demo: - run: name: build-demo no_output_timeout: 30m - # Set the branch name as the VITE_PUBLIC_URL so that relative paths work, e.g. + # Set the branch name as the VITE_BASENAME so that relative paths work, e.g. # demo.audius.co/some-branch/handle/track resolves as /handle/track would at audius.co command: | cd packages/web - cp ./.env/.env.stage ./.env/.env.stage.tmp - echo -e "\nVITE_PUBLIC_URL=/${CIRCLE_BRANCH}" >> ./.env/.env.stage + cp ./env/.env.stage ./env/.env.stage.tmp + echo -e "\nVITE_BASENAME=/${CIRCLE_BRANCH}" >> ./env/.env.stage CI=false npm run build:stage -w audius-client mv build-staging build-demo - cp ./.env/.env.stage.tmp ./.env/.env.stage + cp ./env/.env.stage.tmp ./env/.env.stage - persist_to_workspace: root: ./ paths: @@ -104,7 +104,7 @@ web-build-production: resource_class: xlarge steps: - web-build: - build-type: prod-source-maps + build-type: prod build-directory: packages/web/build-production build-name: build-production diff --git a/packages/common/src/services/env.ts b/packages/common/src/services/env.ts index 1aa5c78206e..3dff3318b3c 100644 --- a/packages/common/src/services/env.ts +++ b/packages/common/src/services/env.ts @@ -1,13 +1,80 @@ +import { Nullable } from 'utils/typeUtils' + export type Environment = 'development' | 'staging' | 'production' export type Env = { - AAO_ENDPOINT?: string - EAGER_DISCOVERY_NODES?: string - EXPLORE_CONTENT_URL?: string - ENVIRONMENT?: Environment - ORACLE_ETH_ADDRESSES?: string - SUGGESTED_FOLLOW_HANDLES?: string - GENERAL_ADMISSION?: string - IDENTITY_SERVICE?: string - PUBLIC_HOSTNAME?: string + AAO_ENDPOINT: string + AMPLITUDE_API_KEY: Nullable + AMPLITUDE_PROXY: Nullable + AMPLITUDE_WRITE_KEY: Nullable + AUDIUS_URL: string + BITSKI_CALLBACK_URL: string + BITSKI_CLIENT_ID: string + CACHE_PRUNE_MIN: string + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: Nullable + CLAIMABLE_TOKEN_PDA: string + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: string + COINFLOW_APP_ID: string + COINFLOW_MERCHANT_ID: string + COINFLOW_PARTNER_ID: string + COGNITO_KEY: Nullable + COGNITO_TEMPLATE_ID: Nullable + EAGER_DISCOVERY_NODES: string + ENTITY_MANAGER_ADDRESS: string + ENVIRONMENT: Environment + ETH_BRIDGE_ADDRESS: Nullable + ETH_NETWORK_ID: string + ETH_OWNER_WALLET: Nullable + ETH_PROVIDER_URL: string + ETH_REGISTRY_ADDRESS: string + ETH_TOKEN_ADDRESS: string + ETH_TOKEN_BRIDGE_ADDRESS: Nullable + EXPLORE_CONTENT_URL: string + FCM_PUSH_PUBLIC_KEY: Nullable + FINGERPRINT_ENDPOINT: Nullable + FINGERPRINT_PUBLIC_API_KEY: Nullable + GA_HOSTNAME: string + GA_MEASUREMENT_ID: string + GENERAL_ADMISSION: string + HCAPTCHA_BASE_URL: string + HCAPTCHA_SITE_KEY: string + IDENTITY_SERVICE: string + INSTAGRAM_APP_ID: string + INSTAGRAM_REDIRECT_URL: string + METADATA_PROGRAM_ID: string + OPENSEA_API_URL: string + OPTIMIZELY_KEY: string + ORACLE_ETH_ADDRESSES: string + PAYMENT_ROUTER_PROGRAM_ID: string + PUBLIC_HOSTNAME: string + PUBLIC_PROTOCOL: string + BASENAME: string + REACHABILITY_URL: string + STRIPE_CLIENT_PUBLISHABLE_KEY: string + RECAPTCHA_SITE_KEY: string + REGISTRY_ADDRESS: string + REWARDS_MANAGER_PROGRAM_ID: string + REWARDS_MANAGER_PROGRAM_PDA: string + REWARDS_MANAGER_TOKEN_PDA: string + SAFARI_WEB_PUSH_ID: string + SCHEME: string + SENTRY_DSN: string + SOL_BRIDGE_ADDRESS: Nullable + SOL_TOKEN_BRIDGE_ADDRESS: Nullable + SOLANA_CLUSTER_ENDPOINT: string + SOLANA_FEE_PAYER_ADDRESS: string + SOLANA_RELAY_ENDPOINT: string + SOLANA_TOKEN_PROGRAM_ADDRESS: string + SOLANA_WEB3_CLUSTER: string + SUGGESTED_FOLLOW_HANDLES: string + TIKTOK_APP_ID: string + TRPC_ENDPOINT: string + USDC_MINT_ADDRESS: string + USER_NODE: string + USE_HASH_ROUTING: boolean + WAUDIO_MINT_ADDRESS: string + WEB3_NETWORK_ID: string + WEB3_PROVIDER_URL: string + WORMHOLE_ADDRESS: Nullable + WORMHOLE_RPC_HOSTS: Nullable } diff --git a/packages/common/src/store/buy-usdc/sagas.ts b/packages/common/src/store/buy-usdc/sagas.ts index 519945f6395..02b76db99e9 100644 --- a/packages/common/src/store/buy-usdc/sagas.ts +++ b/packages/common/src/store/buy-usdc/sagas.ts @@ -8,6 +8,7 @@ import { call, put, race, select, take, takeLeading } from 'typed-redux-saga' import { Name } from 'models/Analytics' import { ErrorLevel } from 'models/ErrorReporting' import { PurchaseVendor } from 'models/PurchaseContent' +import { Status } from 'models/Status' import { createPaymentRouterRouteTransaction, createTransferToUserBankTransaction, @@ -44,7 +45,6 @@ import { } from './slice' import { BuyUSDCError, BuyUSDCErrorCode } from './types' import { getBuyUSDCRemoteConfig, getUSDCUserBank } from './utils' -import { Status } from 'models/Status' type PurchaseStepParams = { desiredAmount: number diff --git a/packages/common/src/store/buy-usdc/slice.ts b/packages/common/src/store/buy-usdc/slice.ts index 23b82702c98..fd296957f99 100644 --- a/packages/common/src/store/buy-usdc/slice.ts +++ b/packages/common/src/store/buy-usdc/slice.ts @@ -1,10 +1,10 @@ import { Action, createSlice, PayloadAction } from '@reduxjs/toolkit' import { PurchaseVendor } from 'models/PurchaseContent' +import { Status } from 'models/Status' import { StripeSessionCreationError } from 'store/ui/stripe-modal/types' import { BuyUSDCStage, PurchaseInfo, BuyUSDCError } from './types' -import { Status } from 'models/Status' type StripeSessionStatus = | 'initialized' diff --git a/packages/common/src/store/ui/mobile-overflow-menu/types.ts b/packages/common/src/store/ui/mobile-overflow-menu/types.ts index 4ce45a12612..4bbe80dc7f2 100644 --- a/packages/common/src/store/ui/mobile-overflow-menu/types.ts +++ b/packages/common/src/store/ui/mobile-overflow-menu/types.ts @@ -10,6 +10,7 @@ export enum OverflowAction { ADD_TO_ALBUM = 'ADD_TO_ALBUM', ADD_TO_PLAYLIST = 'ADD_TO_PLAYLIST', REMOVE_FROM_PLAYLIST = 'REMOVE_FROM_PLAYLIST', + EDIT_ALBUM = 'EDIT_ALBUM', EDIT_PLAYLIST = 'EDIT_PLAYLIST', DELETE_PLAYLIST = 'DELETE_PLAYLIST', PUBLISH_PLAYLIST = 'PUBLISH_PLAYLIST', diff --git a/packages/ddex/Dockerfile b/packages/ddex/Dockerfile index e29bd97eab4..c1406f32612 100644 --- a/packages/ddex/Dockerfile +++ b/packages/ddex/Dockerfile @@ -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"] diff --git a/packages/ddex/Dockerfile.fast b/packages/ddex/Dockerfile.fast index f25ce28f4ff..fbc58f00f89 100644 --- a/packages/ddex/Dockerfile.fast +++ b/packages/ddex/Dockerfile.fast @@ -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" ] diff --git a/packages/ddex/README.md b/packages/ddex/README.md index dab40b8b83b..d19df93647c 100644 --- a/packages/ddex/README.md +++ b/packages/ddex/README.md @@ -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. diff --git a/packages/ddex/client/.env.dev b/packages/ddex/client/.env.dev index f99a4753af5..9256d057e4e 100644 --- a/packages/ddex/client/.env.dev +++ b/packages/ddex/client/.env.dev @@ -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 diff --git a/packages/ddex/client/.env.stage.local b/packages/ddex/client/.env.stage.local index e038a2328e3..6eecd8fa933 100644 --- a/packages/ddex/client/.env.stage.local +++ b/packages/ddex/client/.env.stage.local @@ -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 diff --git a/packages/ddex/client/src/components/App.tsx b/packages/ddex/client/src/components/App.tsx index cba736e58ab..114f96267c5 100644 --- a/packages/ddex/client/src/components/App.tsx +++ b/packages/ddex/client/src/components/App.tsx @@ -6,7 +6,7 @@ import Layout from './Layout' const App = () => { return ( - + } /> diff --git a/packages/ddex/client/src/components/AppWithProviders.tsx b/packages/ddex/client/src/components/AppWithProviders.tsx index d3df5b2c2a2..a076529715e 100644 --- a/packages/ddex/client/src/components/AppWithProviders.tsx +++ b/packages/ddex/client/src/components/AppWithProviders.tsx @@ -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' @@ -38,13 +37,11 @@ const AppWithProviders = () => { - - - - - - - + + + + + diff --git a/packages/ddex/client/src/providers/AudiusLibsProvider.tsx b/packages/ddex/client/src/providers/AudiusLibsProvider.tsx deleted file mode 100644 index 4706303bc2a..00000000000 --- a/packages/ddex/client/src/providers/AudiusLibsProvider.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { - ReactNode, - createContext, - useContext, - useState, - useEffect -} from 'react' - -import type { AudiusLibs as AudiusLibsType } from '@audius/sdk/dist/WebAudiusLibs.d.ts' - -import { useEnvVars } from './EnvVarsProvider' - -type AudiusLibsContextType = { - audiusLibs: AudiusLibsType | null - isLoading: boolean - isReadOnly: boolean // read-only means the user can't approve transactions (i.e., no external wallet connected) -} -const AudiusLibsContext = createContext({ - audiusLibs: null, - isLoading: true, - isReadOnly: true -}) - -export const AudiusLibsProvider = ({ children }: { children: ReactNode }) => { - const [audiusLibs, setAudiusLibs] = useState(null) - const [isLoading, setIsLoading] = useState(true) - const [isReadOnly, setIsReadOnly] = useState(true) - const envVars = useEnvVars() - - // @ts-expect-error (TS2741). This is only here for debugging and should eventually be removed - window.audiusLibs = audiusLibs - - const initLibraries = async () => { - const audiusLibs = await initLibsWithoutAccount(envVars) - setAudiusLibs(audiusLibs) - setIsReadOnly(true) - setIsLoading(false) - } - - useEffect(() => { - if (envVars.ethProviderUrl) { - initLibraries() - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [envVars]) - - const contextValue = { - audiusLibs, - isLoading, - isReadOnly - } - return ( - - {children} - - ) -} - -export const useAudiusLibs = () => useContext(AudiusLibsContext) - -// Returns an Audius libs instance that isn't connected to any wallet, so it can't approve transactions -const initLibsWithoutAccount = async ( - envVars: ReturnType -): Promise => { - // Dynamically import hefty libraries so that we don't have to include them in the main index bundle - const audiusSdkModule = await import('@audius/sdk/dist/web-libs.js') - const AudiusLibs = audiusSdkModule.libs as unknown as typeof AudiusLibsType - - const web3ProviderEndpoints = - envVars.env === 'stage' - ? ['https://poa-gateway.staging.audius.co'] - : ['https://poa-gateway.audius.co'] - const web3Config = { - registryAddress: envVars.ethRegistryAddress, - entityManagerAddress: envVars.entityManagerAddress, - useExternalWeb3: false, - internalWeb3Config: { - web3ProviderEndpoints - } - } - - const ethWeb3Config = AudiusLibs.configEthWeb3( - envVars.ethTokenAddress, - envVars.ethRegistryAddress, - envVars.ethProviderUrl, - envVars.ethOwnerWallet, - envVars.claimDistributionContractAddress, - envVars.wormholeContractAddress - ) - - const solanaWeb3Config = AudiusLibs.configSolanaWeb3({ - claimableTokenPDA: envVars.claimableTokenPda, - solanaClusterEndpoint: envVars.solanaClusterEndpoint, - mintAddress: envVars.wAudioMintAddress, - usdcMintAddress: envVars.usdcMintAddress, - solanaTokenAddress: envVars.solanaTokenProgramAddress, - // @ts-expect-error (TS2322) Type 'string' is not assignable to type 'PublicKey'. This happens because libs has a bug where it sets the wrong type. - feePayerAddress: envVars.solanaFeePayerAddress, - claimableTokenProgramAddress: envVars.claimableTokenProgramAddress, - rewardsManagerProgramId: envVars.rewardsManagerProgramId, - rewardsManagerProgramPDA: envVars.rewardsManagerProgramPda, - rewardsManagerTokenPDA: envVars.rewardsManagerTokenPda, - useRelay: true - }) - - const identityServiceConfig = { - url: envVars.identityServiceEndpoint - } - - const audiusLibsConfig = { - web3Config, - ethWeb3Config, - solanaWeb3Config, - identityServiceConfig, - discoveryProviderConfig: {}, - isServer: false, - isDebug: envVars.env === 'staging' || envVars.env === 'development' - } - - // @ts-expect-error (TS2345). It's complaining about not passing all the config args, but they're optional so we can ignore - const audiusLibs = new AudiusLibs(audiusLibsConfig) - await audiusLibs.init() - return audiusLibs -} diff --git a/packages/ddex/client/src/providers/EnvVarsProvider.tsx b/packages/ddex/client/src/providers/EnvVarsProvider.tsx index c129cea5a76..e1174893770 100644 --- a/packages/ddex/client/src/providers/EnvVarsProvider.tsx +++ b/packages/ddex/client/src/providers/EnvVarsProvider.tsx @@ -8,35 +8,6 @@ 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 } @@ -44,54 +15,6 @@ interface EnvVars { // 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 @@ -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') } @@ -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() } }) diff --git a/packages/ddex/client/vite.config.ts b/packages/ddex/client/vite.config.ts index 19e44010582..b9d38074dbd 100644 --- a/packages/ddex/client/vite.config.ts +++ b/packages/ddex/client/vite.config.ts @@ -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' } : {} }, @@ -38,7 +38,6 @@ export default defineConfig({ assets: '/src/assets' } }, - base: '/ddex/', build: { commonjsOptions: { transformMixedEsModules: true diff --git a/packages/ddex/server/.env.stage b/packages/ddex/server/.env.stage index 72d697b7388..03713b9f835 100644 --- a/packages/ddex/server/.env.stage +++ b/packages/ddex/server/.env.stage @@ -1,2 +1,4 @@ -DDEX_SECRET='54abb93ab41afeeb99a411502ea1ee9b36ec8221cdc7c80a0ceef84c8ca95fc0' -DDEX_KEY='be46e3e1cc722d2ae306f93f21f5b4f08bbd0d53' +NODE_ENV='stage' +DDEX_KEY='49d5e13d355709b615b7cce7369174fb240b6b39' +DDEX_SECRET='2b2c2b90d9a489234ae629a5284de84fb0633306257f17667aaebf2345d92152' +OPTIMIZELY_SDK_KEY='MX4fYBgANQetvmBXGpuxzF' diff --git a/packages/ddex/server/src/app.ts b/packages/ddex/server/src/app.ts index 7be92876876..40d4dd0cb2f 100644 --- a/packages/ddex/server/src/app.ts +++ b/packages/ddex/server/src/app.ts @@ -23,6 +23,16 @@ export default function createApp( * Define API routes */ + app.get('/api/env', (_req: Request, res: Response) => { + const envData = { + data: { + env: process.env.NODE_ENV, + ddexKey: process.env.DDEX_KEY, + optimizelySdkKey: process.env.OPTIMIZELY_SDK_KEY, + }, + } + res.json(envData) + }) app.get('/api/releases', uploadController.getReleases(sql)) app.get('/api/uploads', uploadController.getUploads(sql)) app.post('/api/upload', uploadController.postUploadXml(xmlProcessorService)) diff --git a/packages/ddex/server/src/index.ts b/packages/ddex/server/src/index.ts index 8cbe7df5c83..1290e778363 100644 --- a/packages/ddex/server/src/index.ts +++ b/packages/ddex/server/src/index.ts @@ -20,7 +20,7 @@ const appRouter = router({ export type AppRouter = typeof appRouter -const port = process.env.DDEX_PORT || 8926 +const port = process.env.DDEX_PORT || 3000 ;(async () => { try { diff --git a/packages/discovery-provider/src/queries/query_helpers.py b/packages/discovery-provider/src/queries/query_helpers.py index 8c29512b7fe..3035b7f7176 100644 --- a/packages/discovery-provider/src/queries/query_helpers.py +++ b/packages/discovery-provider/src/queries/query_helpers.py @@ -578,7 +578,7 @@ def _populate_gated_track_metadata(session, tracks, current_user_id): gated_track_access = {track["track_id"]: defaultdict() for track in tracks} gated_tracks = list( filter( - lambda track: track["stream_conditions"] or track["download_conditions"], + lambda track: track.get("stream_conditions") or track.get("download_conditions"), tracks, ) ) diff --git a/packages/mobile/.env.dev b/packages/mobile/.env.dev index 52af3d62eb3..a67e869d6a5 100644 --- a/packages/mobile/.env.dev +++ b/packages/mobile/.env.dev @@ -1,59 +1,2 @@ ENVIRONMENT=development -IS_PRODUCTION=true -USER_METADATA_NODE=http://audius-protocol-creator-node-1 -AUDIUS_URL=https://staging.audius.co -USER_NODE=http://audius-protocol-creator-node-1 -IDENTITY_SERVICE=http://audius-protocol-identity-service-1 -HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea -HCAPTCHA_BASE_URL=https://staging.audius.co -AMPLITUDE_WRITE_KEY=abc -OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF - -REGISTRY_ADDRESS=0xCfEB869F69431e42cdB54A4F4f105C19C080A601 -ENTITY_MANAGER_ADDRESS=0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B -WEB3_PROVIDER_URL=http://audius-protocol-poa-ganache-1 - -ETH_REGISTRY_ADDRESS=0xABbfF712977dB51f9f212B85e8A4904c818C2b63 -ETH_PROVIDER_URL=http://audius-protocol-eth-ganache-1 -ETH_TOKEN_ADDRESS=0xdcB2fC9469808630DD0744b0adf97C0003fC29B2 -ETH_OWNER_WALLET=0x855FA758c77D68a04990E992aA4dcdeF899F654A - -SOLANA_WEB3_CLUSTER=devnet -SOLANA_RELAY_ENDPOINT=http://audius-protocol-discovery-provider-1 -SOLANA_CLUSTER_ENDPOINT=http://audius-protocol-solana-test-validator-1 -WAUDIO_MINT_ADDRESS=37RCjhgV1qGV2Q54EHFScdxZ22ydRMdKMtVgod47fDP3 -USDC_MINT_ADDRESS=26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y -SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -SOLANA_FEE_PAYER_ADDRESS=E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h -CLAIMABLE_TOKEN_PROGRAM_ADDRESS=testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9 -REWARDS_MANAGER_PROGRAM_ID=testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb -REWARDS_MANAGER_PROGRAM_PDA=FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ -REWARDS_MANAGER_TOKEN_PDA=FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ -PAYMENT_ROUTER_PROGRAM_ID=apaySbqV1XAmuiGszeN4NyWrXkkMrnuJVoNhzmS1AMa - -METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -CACHE_PRUNE_MIN=250 - -PUBLIC_PROTOCOL=https: -PUBLIC_HOSTNAME=staging.audius.co -GA_HOSTNAME=staging.audius.co -REACHABILITY_URL=https://staging.audius.co/204 - -SCHEME=audius-staging - -EXPLORE_CONTENT_URL=https://download.staging.audius.co/static-resources/explore-content.json -SUGGESTED_FOLLOW_HANDLES=https://download.staging.audius.co/static-resources/signup-follows.json -EAGER_DISCOVERY_NODES=https://discoveryprovider.staging.audius.co,https://discoveryprovider2.staging.audius.co,https://discoveryprovider3.staging.audius.co - -SENTRY_DSN=https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611 -RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea - -OPENSEA_API_URL=https://rinkeby-api.opensea.io/api/v1 - -REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY= - -COINFLOW_MERCHANT_ID=audius -COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ -COINFLOW_PARTNER_ID=AUDIUS \ No newline at end of file +TIKTOK_APP_ID=awlrj83t4nx6qc5a \ No newline at end of file diff --git a/packages/mobile/.env.prod b/packages/mobile/.env.prod index 4efa852e974..9569ac667cd 100644 --- a/packages/mobile/.env.prod +++ b/packages/mobile/.env.prod @@ -1,101 +1,2 @@ ENVIRONMENT=production -IS_PRODUCTION=true -USER_METADATA_NODE=https://usermetadata.audius.co -AUDIUS_URL=https://audius.co -USER_NODE=https://usermetadata.audius.co -IDENTITY_SERVICE=https://identityservice.audius.co -HCAPTCHA_SITE_KEY=b250803e-dcba-428c-bc87-8acf559aacb9 -HCAPTCHA_BASE_URL=https://audius.co -AMPLITUDE_WRITE_KEY=abc -OPTIMIZELY_KEY=DAJbGEJBC21dzFRPv8snxs - -GENERAL_ADMISSION=https://general-admission.audius.co - -REGISTRY_ADDRESS=0xC611C82150b56E6e4Ec5973AcAbA8835Dd0d75A2 -ENTITY_MANAGER_ADDRESS=0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64 -WEB3_PROVIDER_URL=https://poa-gateway.audius.co -WEB3_NETWORK_ID=99 - -ETH_REGISTRY_ADDRESS=0xd976d3b4f4e22a238c1A736b6612D22f17b6f64C -ETH_PROVIDER_URL=https://eth.audius.co -ETH_NETWORK_ID=1 -ETH_TOKEN_ADDRESS=0x18aAA7115705e8be94bfFEBDE57Af9BFc265B998 -ETH_OWNER_WALLET=0xC7310a03e930DD659E15305ed7e1F5Df0F0426C5 -WORMHOLE_ADDRESS=0x6E7a1F7339bbB62b23D44797b63e4258d283E095 -CLAIM_DISTRIBUTION_CONTRACT_ADDRESS=0x683c19E621A0F107a291fdAB38f80179809d61B5 - -SOLANA_WEB3_CLUSTER=mainnet-beta -SOLANA_RELAY_ENDPOINT=http://discoveryprovider.audius.co -SOLANA_CLUSTER_ENDPOINT=https://audius-fe.rpcpool.com -WAUDIO_MINT_ADDRESS=9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM -USDC_MINT_ADDRESS=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -CLAIMABLE_TOKEN_PDA=5ZiE3vAkrdXBgyFL7KqG3RoEGBws4CjRcXVbABDLZTgx -SOLANA_FEE_PAYER_ADDRESS=pqx3fvvh6b2eZBfLhTtQ5KxzU3CginmgGTmDCjk8TPP -CLAIMABLE_TOKEN_PROGRAM_ADDRESS=Ewkv3JahEFRKkcJmpoKB7pXbnUHwjAyXiwEo4ZY2rezQ -REWARDS_MANAGER_PROGRAM_ID=DDZDcYdQFEMwcu2Mwo75yGFjJ1mUQyyXLWzhZLEVFcei -REWARDS_MANAGER_PROGRAM_PDA=71hWFVYokLaN1PNYzTAWi13EfJ7Xt9VbSWUKsXUT8mxE -REWARDS_MANAGER_TOKEN_PDA=3V9opXNpHmPPymKeq7CYD8wWMH8wzFXmqEkNdzfsZhYq -PAYMENT_ROUTER_PROGRAM_ID=paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa - -WORMHOLE_RPC_HOSTS=https://wormhole-v2-mainnet-api.certus.one,https://wormhole.inotel.ro,https://wormhole-v2-mainnet-api.mcf.rocks,https://wormhole-v2-mainnet-api.chainlayer.network,https://wormhole-v2-mainnet-api.staking.fund,https://wormhole-v2-mainnet-api.chainlayer.network -ETH_BRIDGE_ADDRESS=0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B -ETH_TOKEN_BRIDGE_ADDRESS=0x3ee18B2214AFF97000D974cf647E7C347E8fa585 -SOL_BRIDGE_ADDRESS=worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth -SOL_TOKEN_BRIDGE_ADDRESS=wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb - -METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -CACHE_PRUNE_MIN=250 - -GA_MEASUREMENT_ID=UA-120325397-2 - -PUBLIC_PROTOCOL=https: -PUBLIC_HOSTNAME=audius.co -GA_HOSTNAME=audius.co -REACHABILITY_URL=https://audius.co/204 -NOTIFICATION_URL=https://download.audius.co/whatsnew - -SCHEME=audius - -EXPLORE_CONTENT_URL=https://download.audius.co/static-resources/explore-content.json -SUGGESTED_FOLLOW_HANDLES=https://download.audius.co/static-resources/signup-follows.json -EAGER_DISCOVERY_NODES=https://discoveryprovider.audius.co,https://discoveryprovider2.audius.co,https://discoveryprovider3.audius.co - -SENTRY_DSN=https://e26d2b01488f4b538ea235de6466c40a@s.audius.co/1457231 - -SEGMENT_WEB=mGyaUaZz6IZwAM6taytNhubjCX4RPR0x -SEGMENT_MOBILE=AbVxGDZBuVRCAVuhRaoF3cNsOB3vUCos -SEGMENT_ELECTRON=eMGe35ghRLWsEWX9EpzblQInDH1CmzAa -AMPLITUDE_API_KEY=86760558b8bb1b3aae61656efd4ddacb -AMPLITUDE_PROXY=https://gain.audius.co -ADROLL_AVD_ID=SDJ23TS7DBFPLMXRDF6JQY -ADROLL_PIX_ID=JZSZK5GWHBFL3FQ3NRFPNY -FCM_PUSH_PUBLIC_KEY=BDBRR9S_UczQBflfaFPQf1JuCIZhMk90G_QnRI9wWuoObt7Ck6sRCxPDJfB_mJY3p55WdAO4C4xVJTAMoiv6JJQ -SAFARI_WEB_PUSH_ID=web.co.audius - -OPTIMIZELY_KEY=DAJbGEJBC21dzFRPv8snxs -INSTAGRAM_APP_ID=189700309435573 -INSTAGRAM_REDIRECT_URL=https://audius.co/ -TIKTOK_APP_ID=awa9re2w7ec3xrn6 - -GENERATE_SOURCEMAP=false - -RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -HCAPTCHA_SITE_KEY=b250803e-dcba-428c-bc87-8acf559aacb9 - -BITSKI_CLIENT_ID=661ce11a-3e0f-4659-b365-795ad2111f42 -BITSKI_CALLBACK_URL=https://audius.co/bitski-callback.html - -OPENSEA_API_URL=https://collectibles.audius.co/api/v1 - -FINGERPRINT_PUBLIC_API_KEY=MNtDQ4NCsNSP7YOkOiQT -FINGERPRINT_ENDPOINT=https://fp.audius.co - -OLD_WEB_APP_STATIC_SERVER_PORT=3100 - -REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY=pk_live_51LPsGuCJOWtpH6AEKshlCs3L8QhAfevNvhev8K9a0u92O5ku83KRjLIqCdxgf3NhitdtmMGlw0Wjf33NjZJjZUBz006A3IoSiQ - -COINFLOW_MERCHANT_ID=tikilabs -COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ -COINFLOW_PARTNER_ID=AUDIUS +TIKTOK_APP_ID=awa9re2w7ec3xrn6 \ No newline at end of file diff --git a/packages/mobile/.env.stage b/packages/mobile/.env.stage index cbc0a9066de..cefa07bf10a 100644 --- a/packages/mobile/.env.stage +++ b/packages/mobile/.env.stage @@ -1,86 +1,2 @@ ENVIRONMENT=staging -IS_PRODUCTION=true -USER_METADATA_NODE=https://usermetadata.audius.co -AUDIUS_URL=https://staging.audius.co -USER_NODE=https://usermetadata.staging.audius.co -IDENTITY_SERVICE=https://identityservice.staging.audius.co -HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea -HCAPTCHA_BASE_URL=https://staging.audius.co -AMPLITUDE_WRITE_KEY=abc -OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF - -GENERAL_ADMISSION=https://general-admission.staging.audius.co - -REGISTRY_ADDRESS=0x793373aBF96583d5eb71a15d86fFE732CD04D452 -ENTITY_MANAGER_ADDRESS=0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64 -WEB3_PROVIDER_URL=https://poa-gateway.staging.audius.co -WEB3_NETWORK_ID=77 -ETH_REGISTRY_ADDRESS=0xF27A9c44d7d5DDdA29bC1eeaD94718EeAC1775e3 -ETH_PROVIDER_URL=https://eth.staging.audius.co -ETH_NETWORK_ID=5 -ETH_TOKEN_ADDRESS=0x5375BE4c52fA29b26077B0F15ee5254D779676A6 -ETH_OWNER_WALLET= -WORMHOLE_ADDRESS=0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7 -CLAIM_DISTRIBUTION_CONTRACT_ADDRESS=0x74b89B916c97d50557E8F944F32662fE52Ce378d - -SOLANA_WEB3_CLUSTER=mainnet-beta -SOLANA_RELAY_ENDPOINT=https://discoveryprovider.staging.audius.co -SOLANA_CLUSTER_ENDPOINT=https://audius-fe.rpcpool.com -WAUDIO_MINT_ADDRESS=BELGiMZQ34SDE6x2FUaML2UHDAgBLS64xvhXjX5tBBZo -USDC_MINT_ADDRESS=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -CLAIMABLE_TOKEN_PDA=Aw5AjygeMf9Nvg61BXvFSAzkqxcLqL8koepb14kvfc3W -SOLANA_FEE_PAYER_ADDRESS=E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h -CLAIMABLE_TOKEN_PROGRAM_ADDRESS=2sjQNmUfkV6yKKi4dPR8gWRgtyma5aiymE3aXL2RAZww -REWARDS_MANAGER_PROGRAM_ID=CDpzvz7DfgbF95jSSCHLX3ERkugyfgn9Fw8ypNZ1hfXp -REWARDS_MANAGER_PROGRAM_PDA=GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq -REWARDS_MANAGER_TOKEN_PDA=HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ -PAYMENT_ROUTER_PROGRAM_ID=sp38CXGL9FoWPp9Avo4fevewEX4UqNkTSTFUPpQFRry - -METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -CACHE_PRUNE_MIN=250 -NOTIFICATION_URL=https://download.staging.audius.co/notifications - -PUBLIC_PROTOCOL=https: -PUBLIC_HOSTNAME=staging.audius.co -GA_HOSTNAME=staging.audius.co -REACHABILITY_URL=https://staging.audius.co/204 - -SCHEME=audius-staging - -EXPLORE_CONTENT_URL=https://download.staging.audius.co/static-resources/explore-content.json -SUGGESTED_FOLLOW_HANDLES=https://download.staging.audius.co/static-resources/signup-follows.json -EAGER_DISCOVERY_NODES=https://discoveryprovider.staging.audius.co,https://discoveryprovider2.staging.audius.co,https://discoveryprovider3.staging.audius.co - -SENTRY_DSN=https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611 - -SEGMENT_WEB=gDCBr11kRsaR4owd6WutXDQ2GjICZogl -SEGMENT_MOBILE=2foKN924MI4ZkzIuBzGVExkpBjZ3NpE6 -SEGMENT_ELECTRON=v5lPmEQXo91XfB4fdqW8x6GCJQ9ZMnrq -AMPLITUDE_API_KEY=72a58ce4ad1f9bafcba0b92bedb6c33d -AMPLITUDE_PROXY=https://gain.audius.co -FCM_PUSH_PUBLIC_KEY=BIQQAP1Cb5LvBTkUknmRxCiQ-lHD1GjjsLFX4fo7c70FGHTSpN4iTNePCck7fCk9XBGIfwTxoDbNQO1vRiYSUFA -SAFARI_WEB_PUSH_ID=web.co.audius.staging -INSTAGRAM_APP_ID=2875320099414320 -INSTAGRAM_REDIRECT_URL=https://staging.audius.co/ -TIKTOK_APP_ID=awlrj83t4nx6qc5a - -RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea - -BITSKI_CLIENT_ID=7a543ec2-b55f-45d6-a5d4-0448c5a23485 -BITSKI_CALLBACK_URL=https://staging.audius.co/bitski-callback.html - -OPENSEA_API_URL=https://rinkeby-api.opensea.io/api/v1 - -FINGERPRINT_PUBLIC_API_KEY=Rz2A3Y5YGSg9K80VgKPi -FINGERPRINT_ENDPOINT=https://fp.staging.audius.co - -OLD_WEB_APP_STATIC_SERVER_PORT=3101 - -REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY=pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi - -COINFLOW_MERCHANT_ID=audius -COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ -COINFLOW_PARTNER_ID=AUDIUS \ No newline at end of file +TIKTOK_APP_ID=awlrj83t4nx6qc5a \ No newline at end of file diff --git a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/AudiusReactNative.xcscheme b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/AudiusReactNative.xcscheme index f740b8a9424..c3f18a7b943 100644 --- a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/AudiusReactNative.xcscheme +++ b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/AudiusReactNative.xcscheme @@ -10,7 +10,7 @@ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> + scriptText = " "> diff --git a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Dev.xcscheme b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Dev.xcscheme index 706c4e810c1..4676fb051bd 100644 --- a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Dev.xcscheme +++ b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Dev.xcscheme @@ -10,7 +10,7 @@ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> + scriptText = "# Type a script or drag a script file from your workspace to insert its path."> diff --git a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Staging.xcscheme b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Staging.xcscheme index b3706d3646a..dd649564dc1 100644 --- a/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Staging.xcscheme +++ b/packages/mobile/ios/AudiusReactNative.xcodeproj/xcshareddata/xcschemes/Staging.xcscheme @@ -10,7 +10,7 @@ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> + scriptText = "# Type a script or drag a script file from your workspace to insert its path."> diff --git a/packages/mobile/ios/fastlane/Fastfile b/packages/mobile/ios/fastlane/Fastfile index 28447178e82..3463822850a 100644 --- a/packages/mobile/ios/fastlane/Fastfile +++ b/packages/mobile/ios/fastlane/Fastfile @@ -75,25 +75,25 @@ platform :ios do if options[:bundle_id] === AUDIUSMUSIC_ID appId = AUDIUSMUSIC_ID provisioningProfile = AUDIUSMUSIC_PROFILE - environment = 'production' + environment = 'prod' scheme = 'AudiusReactNative' configuration = 'Release' elsif options[:bundle_id] === AUDIUSMUSIC_STAGING_ID appId = AUDIUSMUSIC_STAGING_ID provisioningProfile = AUDIUSMUSIC_STAGING_PROFILE - environment = 'staging' + environment = 'stage' scheme = 'Staging' configuration = 'Staging.Release' elsif options[:bundle_id] === AUDIUSMUSIC_RELEASECANDIDATE_ID appId = AUDIUSMUSIC_RELEASECANDIDATE_ID provisioningProfile = AUDIUSMUSIC_RELEASECANDIDATE_PROFILE - environment = 'production' + environment = 'prod' scheme = 'AudiusReactNative' configuration = 'ReleaseCandidate' elsif options[:bundle_id] === AUDIUSMUSIC_STAGING_RELEASECANDIDATE_ID appId = AUDIUSMUSIC_STAGING_RELEASECANDIDATE_ID provisioningProfile = AUDIUSMUSIC_STAGING_RELEASECANDIDATE_PROFILE - environment = 'staging' + environment = 'stage' scheme = 'Staging' configuration = 'Staging.ReleaseCandidate' end @@ -110,11 +110,8 @@ platform :ios do :DEVELOPMENT_TEAM => TEAM } - if ENV["IS_PRODUCTION"] == "true" - ENV["ENVFILE"]=".env.#{environment}" - puts "IS_PRODUCTION: #{ENV['IS_PRODUCTION']}" - puts "ENVFILE: #{ENV['ENVFILE']}" - end + ENV["ENVFILE"]=".env.#{environment}" + puts "ENVFILE: #{ENV['ENVFILE']}" plistVersionNumber = options[:plist_version] ? (options[:plist_version]) : (Gem::Version.new get_version_number_from_plist( scheme: scheme diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 2afffdff01a..4364989bdba 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -10,13 +10,13 @@ "android:prod": "ENVFILE=.env.prod turbo run android -- --mode=prodDebug", "android:release": "ENVFILE=.env.prod turbo run android -- --mode=prodRelease", "ios": "react-native run-ios", - "ios:dev": "turbo run ios -- --scheme 'Dev' --simulator \"iPhone 15 Pro\"", - "ios:stage": "turbo run ios -- --scheme 'Staging' --mode Staging.Debug --simulator \"iPhone 15 Pro\"", - "ios:prod": "turbo run ios -- --simulator \"iPhone 15 Pro\"", + "ios:dev": "ENVFILE=.env.dev turbo run ios -- --scheme 'Dev' --simulator \"iPhone 15 Pro\"", + "ios:stage": "ENVFILE=.env.stage turbo run ios -- --scheme 'Staging' --mode Staging.Debug --simulator \"iPhone 15 Pro\"", + "ios:prod": "ENVFILE=.env.prod turbo run ios -- --scheme 'AudiusReactNative' --simulator \"iPhone 15 Pro\"", "ios:release": "turbo run ios -- --simulator \"iPhone 15 Pro\" --mode Release", - "ios:device:dev": "turbo run ios -- --scheme 'Dev' --device", - "ios:device:stage": "turbo run ios -- --scheme 'Staging' --mode Staging.Debug --device", - "ios:device:prod": "turbo run ios -- --device", + "ios:device:dev": "ENVFILE=.env.dev turbo run ios -- --scheme 'Dev' --device", + "ios:device:stage": "ENVFILE=.env.stage turbo run ios -- --scheme 'Staging' --mode Staging.Debug --device", + "ios:device:prod": "ENVFILE=.env.prod turbo run ios -- --scheme 'AudiusReactNative' --device", "ios:update-signing-cert": "cd ios && fastlane match development -a co.audius.audiusmusic,co.audius.audiusmusic.staging && cd ..", "bundle:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'", "build:e2e": "detox build --configuration ios.sim.debug", diff --git a/packages/mobile/src/app/App.tsx b/packages/mobile/src/app/App.tsx index 1ab87be90a0..01a51b7812b 100644 --- a/packages/mobile/src/app/App.tsx +++ b/packages/mobile/src/app/App.tsx @@ -1,7 +1,6 @@ import { PortalProvider, PortalHost } from '@gorhom/portal' import * as Sentry from '@sentry/react-native' import { Platform, UIManager } from 'react-native' -import Config from 'react-native-config' import { GestureHandlerRootView } from 'react-native-gesture-handler' import { SafeAreaProvider, @@ -18,6 +17,7 @@ import { NotificationReminder } from 'app/components/notification-reminder/Notif import OAuthWebView from 'app/components/oauth/OAuthWebView' import { RateCtaReminder } from 'app/components/rate-cta-drawer/RateCtaReminder' import { Toasts } from 'app/components/toasts' +import { env } from 'app/env' import { useEnterForeground } from 'app/hooks/useAppState' import { incrementSessionCount } from 'app/hooks/useSessionCount' import { RootScreen } from 'app/screens/root-screen' @@ -37,7 +37,7 @@ import { ThemeProvider } from './ThemeProvider' import { AudiusTrpcProvider } from './TrpcProvider' Sentry.init({ - dsn: Config.SENTRY_DSN + dsn: env.SENTRY_DSN }) const Airplay = Platform.select({ diff --git a/packages/mobile/src/app/AudiusQueryProvider.tsx b/packages/mobile/src/app/AudiusQueryProvider.tsx index 208a9bff34d..4de7fe5bb64 100644 --- a/packages/mobile/src/app/AudiusQueryProvider.tsx +++ b/packages/mobile/src/app/AudiusQueryProvider.tsx @@ -2,9 +2,9 @@ import type { ReactNode } from 'react' import { AudiusQueryContext } from '@audius/common' +import { env } from 'app/env' import { apiClient } from 'app/services/audius-api-client' import { audiusBackendInstance } from 'app/services/audius-backend-instance' -import { env } from 'app/services/env' import { remoteConfigInstance } from 'app/services/remote-config' import { audiusSdk } from 'app/services/sdk/audius-sdk' import { store } from 'app/store' diff --git a/packages/mobile/src/components/coinflow-onramp-drawer/CoinflowOnrampDrawer.tsx b/packages/mobile/src/components/coinflow-onramp-drawer/CoinflowOnrampDrawer.tsx index bab3edc35c1..90a42b60620 100644 --- a/packages/mobile/src/components/coinflow-onramp-drawer/CoinflowOnrampDrawer.tsx +++ b/packages/mobile/src/components/coinflow-onramp-drawer/CoinflowOnrampDrawer.tsx @@ -8,13 +8,12 @@ import { import { CoinflowPurchase } from '@coinflowlabs/react-native' import { Transaction } from '@solana/web3.js' import { TouchableOpacity, View } from 'react-native' -import Config from 'react-native-config' import { useDispatch } from 'react-redux' import IconCloseAlt from 'app/assets/images/iconCloseAlt.svg' import { AppDrawer } from 'app/components/drawer' +import { env } from 'app/env' import { getCoinflowDeviceId } from 'app/services/coinflow' -import { env } from 'app/services/env' import { makeStyles } from 'app/styles' import { spacing } from 'app/styles/spacing' import { useThemeColors } from 'app/utils/theme' @@ -22,7 +21,7 @@ import { zIndex } from 'app/utils/zIndex' const MODAL_NAME = 'CoinflowOnramp' -const { ENVIRONMENT } = Config +const { ENVIRONMENT } = env const IS_PRODUCTION = ENVIRONMENT === 'production' const useStyles = makeStyles(({ spacing, palette }) => ({ diff --git a/packages/mobile/src/components/details-tile/DetailsTile.tsx b/packages/mobile/src/components/details-tile/DetailsTile.tsx index a3d0097fbb1..aa3edd51f83 100644 --- a/packages/mobile/src/components/details-tile/DetailsTile.tsx +++ b/packages/mobile/src/components/details-tile/DetailsTile.tsx @@ -174,7 +174,7 @@ export const DetailsTile = ({ isPlaying, isPreviewing, isPlayable = true, - isPlaylist = false, + isCollection = false, isPublished = true, isUnlisted = false, onPressEdit, @@ -431,7 +431,7 @@ export const DetailsTile = ({ hideRepost={hideRepost} hideShare={hideShare} isOwner={isOwner} - isPlaylist={isPlaylist} + isCollection={isCollection} collectionId={collectionId} isPublished={isPublished} onPressEdit={onPressEdit} diff --git a/packages/mobile/src/components/details-tile/DetailsTileActionButtons.tsx b/packages/mobile/src/components/details-tile/DetailsTileActionButtons.tsx index b2443c4282b..d237967ef1f 100644 --- a/packages/mobile/src/components/details-tile/DetailsTileActionButtons.tsx +++ b/packages/mobile/src/components/details-tile/DetailsTileActionButtons.tsx @@ -1,5 +1,11 @@ import type { CommonState, ID } from '@audius/common' -import { cacheCollectionsSelectors } from '@audius/common' +import { + FeatureFlags, + cacheCollectionsSelectors, + useFeatureFlag, + useGetCurrentUserId, + useGetPlaylistById +} from '@audius/common' import { View } from 'react-native' import { useSelector } from 'react-redux' @@ -29,7 +35,7 @@ type DetailsTileActionButtonsProps = { hasReposted: boolean hasSaved: boolean isOwner: boolean - isPlaylist?: boolean + isCollection?: boolean isPublished?: boolean hideFavorite?: boolean hideOverflow?: boolean @@ -65,7 +71,7 @@ export const DetailsTileActionButtons = ({ collectionId, hasReposted, hasSaved, - isPlaylist, + isCollection, isOwner, isPublished, hideFavorite, @@ -84,9 +90,20 @@ export const DetailsTileActionButtons = ({ const isCollectionEmpty = useSelector((state: CommonState) => getIsCollectionEmpty(state, { id: collectionId }) ) + const { data: currentUserId } = useGetCurrentUserId({}) + const { data: collection } = useGetPlaylistById( + { + playlistId: collectionId!, + currentUserId + }, + { disabled: !collectionId || !isCollection } + ) const collectionHasHiddenTracks = useSelector((state: CommonState) => getCollecitonHasHiddenTracks(state, { id: collectionId }) ) + const { isEnabled: isEditAlbumsEnabled } = useFeatureFlag( + FeatureFlags.EDIT_ALBUMS + ) const repostButton = ( ) - const isPlaylistOwner = isPlaylist && isOwner + const isAlbum = isCollection && collection?.is_album + const isCollectionOwner = isCollection && isOwner return ( - {isPlaylistOwner ? editButton : hideRepost ? null : repostButton} - {isPlaylistOwner || hideFavorite ? null : favoriteButton} + {isCollectionOwner + ? !isAlbum || isEditAlbumsEnabled + ? editButton + : null + : hideRepost + ? null + : repostButton} + {isCollectionOwner || hideFavorite ? null : favoriteButton} {hideShare ? null : shareButton} - {isPlaylistOwner && !isPublished ? publishButton : null} + {isCollectionOwner && !isPublished && (!isAlbum || isEditAlbumsEnabled) + ? publishButton + : null} {hideOverflow ? null : overflowMenu} ) diff --git a/packages/mobile/src/components/details-tile/types.ts b/packages/mobile/src/components/details-tile/types.ts index 341b659000b..08bf86ef274 100644 --- a/packages/mobile/src/components/details-tile/types.ts +++ b/packages/mobile/src/components/details-tile/types.ts @@ -71,8 +71,8 @@ export type DetailsTileProps = { /** Is the item loaded and in a playable state */ isPlayable?: boolean - /** Is the tile being loaded for a playlist */ - isPlaylist?: boolean + /** Is the tile being loaded for a collection */ + isCollection?: boolean /** Is the item loaded published */ isPublished?: boolean diff --git a/packages/mobile/src/components/hcaptcha/HCaptcha.tsx b/packages/mobile/src/components/hcaptcha/HCaptcha.tsx index ff55e4b8afb..2b01852841c 100644 --- a/packages/mobile/src/components/hcaptcha/HCaptcha.tsx +++ b/packages/mobile/src/components/hcaptcha/HCaptcha.tsx @@ -9,9 +9,10 @@ import { } from '@audius/common' import ConfirmHcaptcha from '@hcaptcha/react-native-hcaptcha' import type { NativeSyntheticEvent } from 'react-native' -import Config from 'react-native-config' import { useDispatch, useSelector } from 'react-redux' +import { env } from 'app/env' + const { setVisibility } = modalsActions const { getModalVisibility } = modalsSelectors const { getHCaptchaStatus } = audioRewardsPageSelectors @@ -21,8 +22,8 @@ type HCaptchaMessage = { data: string } -const siteKey = Config.HCAPTCHA_SITE_KEY as string -const baseUrl = Config.HCAPTCHA_BASE_URL +const siteKey = env.HCAPTCHA_SITE_KEY as string +const baseUrl = env.HCAPTCHA_BASE_URL const HCAPTCHA_MODAL_NAME = 'HCaptcha' const REWARD_MODAL_NAME = 'ChallengeRewardsExplainer' diff --git a/packages/mobile/src/components/oauth/OAuthWebView.tsx b/packages/mobile/src/components/oauth/OAuthWebView.tsx index d4965772d70..3a739e48f92 100644 --- a/packages/mobile/src/components/oauth/OAuthWebView.tsx +++ b/packages/mobile/src/components/oauth/OAuthWebView.tsx @@ -1,17 +1,17 @@ import type { NativeSyntheticEvent } from 'react-native' import { Modal, View, Button } from 'react-native' -import Config from 'react-native-config' import { WebView } from 'react-native-webview' import type { WebViewMessage } from 'react-native-webview/lib/WebViewTypes' import { useDispatch, useSelector } from 'react-redux' +import { env } from 'app/env' import { closePopup, setCredentials } from 'app/store/oauth/actions' import { Provider } from 'app/store/oauth/reducer' import { getUrl, getIsOpen, getAuthProvider } from 'app/store/oauth/selectors' import type { Credentials } from 'app/store/oauth/types' import { AUTH_RESPONSE_MESSAGE_TYPE } from 'app/store/oauth/types' -const IDENTITY_SERVICE = Config.IDENTITY_SERVICE +const IDENTITY_SERVICE = env.IDENTITY_SERVICE const TWITTER_POLLER = ` (function() { diff --git a/packages/mobile/src/components/overflow-menu-drawer/CollectionOverflowMenuDrawer.tsx b/packages/mobile/src/components/overflow-menu-drawer/CollectionOverflowMenuDrawer.tsx index 8d50e02ff3b..e83b96fdb17 100644 --- a/packages/mobile/src/components/overflow-menu-drawer/CollectionOverflowMenuDrawer.tsx +++ b/packages/mobile/src/components/overflow-menu-drawer/CollectionOverflowMenuDrawer.tsx @@ -96,6 +96,9 @@ const CollectionOverflowMenuDrawer = ({ render }: Props) => { [OverflowAction.VIEW_ARTIST_PAGE]: () => { navigation?.push('Profile', { handle }) }, + [OverflowAction.EDIT_ALBUM]: () => { + navigation?.push('EditPlaylist', { id }) + }, [OverflowAction.EDIT_PLAYLIST]: () => { navigation?.push('EditPlaylist', { id }) }, diff --git a/packages/mobile/src/components/overflow-menu-drawer/OverflowMenuDrawer.tsx b/packages/mobile/src/components/overflow-menu-drawer/OverflowMenuDrawer.tsx index 3974bbff367..be74a6e4cb9 100644 --- a/packages/mobile/src/components/overflow-menu-drawer/OverflowMenuDrawer.tsx +++ b/packages/mobile/src/components/overflow-menu-drawer/OverflowMenuDrawer.tsx @@ -26,6 +26,7 @@ const overflowRowConfig: Record = { text: 'Remove From This Playlist', isDestructive: true }, + [OverflowAction.EDIT_ALBUM]: { text: 'Edit Album' }, [OverflowAction.EDIT_PLAYLIST]: { text: 'Edit Playlist' }, [OverflowAction.DELETE_PLAYLIST]: { text: 'Delete Playlist', diff --git a/packages/mobile/src/components/share-drawer/useShareToStory.tsx b/packages/mobile/src/components/share-drawer/useShareToStory.tsx index 40bbe01daaf..3781a4fe397 100644 --- a/packages/mobile/src/components/share-drawer/useShareToStory.tsx +++ b/packages/mobile/src/components/share-drawer/useShareToStory.tsx @@ -19,7 +19,6 @@ import { CreativeKit } from '@snapchat/snap-kit-react-native' import type { FFmpegSession } from 'ffmpeg-kit-react-native' import { FFmpegKit, FFmpegKitConfig, ReturnCode } from 'ffmpeg-kit-react-native' import { Platform, View } from 'react-native' -import Config from 'react-native-config' import RNFS from 'react-native-fs' import { check, PERMISSIONS, request, RESULTS } from 'react-native-permissions' import type { ShareSingleOptions } from 'react-native-share' @@ -33,6 +32,7 @@ import { useDispatch, useSelector } from 'react-redux' import IconWavform from 'app/assets/images/iconWavform.svg' import { Button, LinearProgress, Text } from 'app/components/core' +import { env } from 'app/env' import { isImageUriSource } from 'app/hooks/useContentNodeImage' import { useToast } from 'app/hooks/useToast' import { make, track } from 'app/services/analytics' @@ -236,9 +236,9 @@ export const useShareToStory = ({ const shareOptions: ShareSingleOptions = { backgroundVideo: videoUri, stickerImage: stickerUri, - attributionURL: Config.AUDIUS_URL, + attributionURL: env.AUDIUS_URL, social: Social.InstagramStories, - appId: Config.INSTAGRAM_APP_ID as string + appId: env.INSTAGRAM_APP_ID } await Share.shareSingle(shareOptions) }, @@ -268,7 +268,7 @@ export const useShareToStory = ({ ) const pasteToTikTokApp = useCallback((videoUri: string) => { - initTikTokShare(Config.TIKTOK_APP_ID as string) + initTikTokShare(env.TIKTOK_APP_ID as string) shareToTikTok(videoUri, (_code) => { // TODO: Handle errors handed back from TikTok }) diff --git a/packages/mobile/src/components/stripe-onramp-drawer/StripeOnrampEmbed.tsx b/packages/mobile/src/components/stripe-onramp-drawer/StripeOnrampEmbed.tsx index 7768be950c7..e15c8ca08f4 100644 --- a/packages/mobile/src/components/stripe-onramp-drawer/StripeOnrampEmbed.tsx +++ b/packages/mobile/src/components/stripe-onramp-drawer/StripeOnrampEmbed.tsx @@ -6,8 +6,8 @@ import { View } from 'react-native' import { WebView } from 'react-native-webview' import { useDispatch, useSelector } from 'react-redux' +import { env } from 'app/env' import { useIsUSDCEnabled } from 'app/hooks/useIsUSDCEnabled' -import { env } from 'app/services/env' import { makeStyles } from 'app/styles' import LoadingSpinner from '../loading-spinner/LoadingSpinner' @@ -15,7 +15,7 @@ import LoadingSpinner from '../loading-spinner/LoadingSpinner' const { getStripeClientSecret } = stripeModalUISelectors const { stripeSessionStatusChanged, cancelStripeOnramp } = stripeModalUIActions -const STRIPE_PUBLISHABLE_KEY = env.REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY +const STRIPE_PUBLISHABLE_KEY = env.STRIPE_CLIENT_PUBLISHABLE_KEY const useStyles = makeStyles(() => ({ root: { diff --git a/packages/mobile/src/env/env.dev.ts b/packages/mobile/src/env/env.dev.ts new file mode 100644 index 00000000000..6d630b5a266 --- /dev/null +++ b/packages/mobile/src/env/env.dev.ts @@ -0,0 +1,84 @@ +import type { Env } from '@audius/common' +import Config from 'react-native-config' + +export const env: Env = { + AAO_ENDPOINT: 'http://audius-protocol-anti-abuse-oracle-1', + AMPLITUDE_API_KEY: null, + AMPLITUDE_PROXY: null, + AMPLITUDE_WRITE_KEY: null, + AUDIUS_URL: 'https://staging.audius.co', + BITSKI_CALLBACK_URL: 'https://staging.audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '7a543ec2-b55f-45d6-a5d4-0448c5a23485', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: null, + CLAIMABLE_TOKEN_PDA: '7vKR1WSmyHvBmCvKPZBiN66PHZqYQbXw51SZdwtVd9Dt', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + 'testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'audius', + COINFLOW_PARTNER_ID: 'AUDIUS', + COGNITO_KEY: 'sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b', + COGNITO_TEMPLATE_ID: 'flwtmp_7ZUYaBUFLeNhJw', + EAGER_DISCOVERY_NODES: 'http://audius-protocol-discovery-provider-1', + ENTITY_MANAGER_ADDRESS: '0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B', + ENVIRONMENT: 'development', + ETH_BRIDGE_ADDRESS: null, + ETH_NETWORK_ID: '1337', + ETH_OWNER_WALLET: '0x855FA758c77D68a04990E992aA4dcdeF899F654A', + ETH_PROVIDER_URL: 'http://audius-protocol-eth-ganache-1', + ETH_REGISTRY_ADDRESS: '0xABbfF712977dB51f9f212B85e8A4904c818C2b63', + ETH_TOKEN_ADDRESS: '0xdcB2fC9469808630DD0744b0adf97C0003fC29B2', + ETH_TOKEN_BRIDGE_ADDRESS: null, + EXPLORE_CONTENT_URL: + 'https://download.staging.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: null, + FINGERPRINT_ENDPOINT: null, + FINGERPRINT_PUBLIC_API_KEY: null, + GA_HOSTNAME: 'staging.audius.co', + GA_MEASUREMENT_ID: 'G-XXXXX', + GENERAL_ADMISSION: 'http://audius-protocol-general-admission-1', + HCAPTCHA_BASE_URL: 'https://staging.audius.co', + HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea', + IDENTITY_SERVICE: 'http://audius-protocol-identity-service-1', + INSTAGRAM_APP_ID: '2875320099414320', + INSTAGRAM_REDIRECT_URL: 'http://localhost:3000', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://rinkeby-api.opensea.io/api/v1', + OPTIMIZELY_KEY: 'MX4fYBgANQetvmBXGpuxzF', + ORACLE_ETH_ADDRESSES: + '0xF0D5BC18421fa04D0a2A2ef540ba5A9f04014BE3,0x325A621DeA613BCFb5B1A69a7aCED0ea4AfBD73A,0x3fD652C93dFA333979ad762Cf581Df89BaBa6795', + PAYMENT_ROUTER_PROGRAM_ID: 'apaySbqV1XAmuiGszeN4NyWrXkkMrnuJVoNhzmS1AMa', + PUBLIC_HOSTNAME: 'staging.audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: '/', + REACHABILITY_URL: 'https://staging.audius.co/204', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0xCfEB869F69431e42cdB54A4F4f105C19C080A601', + REWARDS_MANAGER_PROGRAM_ID: 'testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb', + REWARDS_MANAGER_PROGRAM_PDA: 'DJPzVothq58SmkpRb1ATn5ddN2Rpv1j2TcGvM3XsHf1c', + REWARDS_MANAGER_TOKEN_PDA: 'FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ', + SAFARI_WEB_PUSH_ID: 'web.co.audius.staging', + SCHEME: 'audius-staging', + SENTRY_DSN: 'https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611', + SOL_BRIDGE_ADDRESS: null, + SOL_TOKEN_BRIDGE_ADDRESS: null, + SOLANA_CLUSTER_ENDPOINT: 'http://audius-protocol-solana-test-validator-1', + SOLANA_FEE_PAYER_ADDRESS: 'E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h', + SOLANA_RELAY_ENDPOINT: 'http://audius-protocol-discovery-provider-1', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'devnet', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.staging.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: Config.TIKTOK_APP_ID!, + TRPC_ENDPOINT: 'http://localhost:2022/trpc', + USDC_MINT_ADDRESS: '26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y', + USER_NODE: 'http://audius-protocol-creator-node-1', + USE_HASH_ROUTING: false, + WAUDIO_MINT_ADDRESS: '37RCjhgV1qGV2Q54EHFScdxZ22ydRMdKMtVgod47fDP3', + WEB3_NETWORK_ID: '1337', + WEB3_PROVIDER_URL: 'http://audius-protocol-poa-ganache-1', + WORMHOLE_ADDRESS: null, + WORMHOLE_RPC_HOSTS: null +} diff --git a/packages/mobile/src/env/env.prod.ts b/packages/mobile/src/env/env.prod.ts new file mode 100644 index 00000000000..8ce424675f6 --- /dev/null +++ b/packages/mobile/src/env/env.prod.ts @@ -0,0 +1,86 @@ +import type { Env } from '@audius/common' +import Config from 'react-native-config' + +export const env: Env = { + AAO_ENDPOINT: 'https://antiabuseoracle.audius.co', + AMPLITUDE_API_KEY: '86760558b8bb1b3aae61656efd4ddacb', + AMPLITUDE_PROXY: 'https://gain.audius.co', + AMPLITUDE_WRITE_KEY: Config.AMPLITUDE_WRITE_KEY as string, + AUDIUS_URL: 'https://audius.co', + BITSKI_CALLBACK_URL: 'https://audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '661ce11a-3e0f-4659-b365-795ad2111f42', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: + '0x683c19E621A0F107a291fdAB38f80179809d61B5', + CLAIMABLE_TOKEN_PDA: '5ZiE3vAkrdXBgyFL7KqG3RoEGBws4CjRcXVbABDLZTgx', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + 'Ewkv3JahEFRKkcJmpoKB7pXbnUHwjAyXiwEo4ZY2rezQ', + COGNITO_KEY: 'live_publishable_key_9afb0a1e2e32ba707a70e66c6d309500', + COGNITO_TEMPLATE_ID: 'flwtmp_eMMe8VQGrKvLCX', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'tikilabs', + COINFLOW_PARTNER_ID: 'AUDIUS', + EAGER_DISCOVERY_NODES: + 'https://discoveryprovider.audius.co,https://discoveryprovider2.audius.co,https://discoveryprovider3.audius.co', + ENTITY_MANAGER_ADDRESS: '0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64', + ENVIRONMENT: 'production', + ETH_BRIDGE_ADDRESS: '0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B', + ETH_NETWORK_ID: '1', + ETH_OWNER_WALLET: '0xC7310a03e930DD659E15305ed7e1F5Df0F0426C5', + ETH_PROVIDER_URL: 'https://eth.audius.co', + ETH_REGISTRY_ADDRESS: '0xd976d3b4f4e22a238c1A736b6612D22f17b6f64C', + ETH_TOKEN_ADDRESS: '0x18aAA7115705e8be94bfFEBDE57Af9BFc265B998', + ETH_TOKEN_BRIDGE_ADDRESS: '0x3ee18B2214AFF97000D974cf647E7C347E8fa585', + EXPLORE_CONTENT_URL: + 'https://download.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: null, + FINGERPRINT_ENDPOINT: 'https://fp.audius.co', + FINGERPRINT_PUBLIC_API_KEY: 'MNtDQ4NCsNSP7YOkOiQT', + GA_HOSTNAME: 'audius.co', + GA_MEASUREMENT_ID: 'UA-120325397-2', + GENERAL_ADMISSION: 'https://general-admission.audius.co', + HCAPTCHA_BASE_URL: 'https://audius.co', + HCAPTCHA_SITE_KEY: 'b250803e-dcba-428c-bc87-8acf559aacb9', + IDENTITY_SERVICE: 'https://identityservice.audius.co', + INSTAGRAM_APP_ID: '189700309435573', + INSTAGRAM_REDIRECT_URL: 'https://audius.co/', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://collectibles.audius.co/api/v1', + OPTIMIZELY_KEY: 'DAJbGEJBC21dzFRPv8snxs', + ORACLE_ETH_ADDRESSES: '0x9811BA3eAB1F2Cd9A2dFeDB19e8c2a69729DC8b6', + PAYMENT_ROUTER_PROGRAM_ID: 'paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa', + PUBLIC_HOSTNAME: 'audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: '/', + REACHABILITY_URL: 'https://audius.co/204', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_live_51LPsGuCJOWtpH6AEKshlCs3L8QhAfevNvhev8K9a0u92O5ku83KRjLIqCdxgf3NhitdtmMGlw0Wjf33NjZJjZUBz006A3IoSiQ', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0xC611C82150b56E6e4Ec5973AcAbA8835Dd0d75A2', + REWARDS_MANAGER_PROGRAM_ID: 'DDZDcYdQFEMwcu2Mwo75yGFjJ1mUQyyXLWzhZLEVFcei', + REWARDS_MANAGER_PROGRAM_PDA: '71hWFVYokLaN1PNYzTAWi13EfJ7Xt9VbSWUKsXUT8mxE', + REWARDS_MANAGER_TOKEN_PDA: '3V9opXNpHmPPymKeq7CYD8wWMH8wzFXmqEkNdzfsZhYq', + SAFARI_WEB_PUSH_ID: 'web.co.audius', + SCHEME: 'audius', + SENTRY_DSN: 'https://e26d2b01488f4b538ea235de6466c40a@s.audius.co/1457231', + SOL_BRIDGE_ADDRESS: 'worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth', + SOL_TOKEN_BRIDGE_ADDRESS: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb', + SOLANA_CLUSTER_ENDPOINT: 'https://audius-fe.rpcpool.com', + SOLANA_FEE_PAYER_ADDRESS: 'pqx3fvvh6b2eZBfLhTtQ5KxzU3CginmgGTmDCjk8TPP', + SOLANA_RELAY_ENDPOINT: 'http://discoveryprovider.audius.co', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'mainnet-beta', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: Config.TIKTOK_APP_ID!, + TRPC_ENDPOINT: 'https://discoveryprovider3.audius.co/trpc/trpc', + USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', + USER_NODE: 'https://usermetadata.audius.co', + USE_HASH_ROUTING: false, + WAUDIO_MINT_ADDRESS: '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM', + WEB3_NETWORK_ID: '99', + WEB3_PROVIDER_URL: 'https://poa-gateway.audius.co', + WORMHOLE_ADDRESS: '0x6E7a1F7339bbB62b23D44797b63e4258d283E095', + WORMHOLE_RPC_HOSTS: + 'https://wormhole-v2-mainnet-api.certus.one,https://wormhole.inotel.ro,https://wormhole-v2-mainnet-api.mcf.rocks,https://wormhole-v2-mainnet-api.chainlayer.network,https://wormhole-v2-mainnet-api.staking.fund,https://wormhole-v2-mainnet-api.chainlayer.network' +} diff --git a/packages/mobile/src/env/env.stage.ts b/packages/mobile/src/env/env.stage.ts new file mode 100644 index 00000000000..7ec0533b7c6 --- /dev/null +++ b/packages/mobile/src/env/env.stage.ts @@ -0,0 +1,85 @@ +import type { Env } from '@audius/common' +import Config from 'react-native-config' + +export const env: Env = { + AAO_ENDPOINT: 'https://antiabuseoracle.staging.audius.co', + AMPLITUDE_API_KEY: '72a58ce4ad1f9bafcba0b92bedb6c33d', + AMPLITUDE_PROXY: 'https://gain.audius.co', + AMPLITUDE_WRITE_KEY: Config.AMPLITUDE_WRITE_KEY as string, + AUDIUS_URL: 'https://staging.audius.co', + BITSKI_CALLBACK_URL: 'https://staging.audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '7a543ec2-b55f-45d6-a5d4-0448c5a23485', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: + '0x74b89B916c97d50557E8F944F32662fE52Ce378d', + CLAIMABLE_TOKEN_PDA: 'Aw5AjygeMf9Nvg61BXvFSAzkqxcLqL8koepb14kvfc3W', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + '2sjQNmUfkV6yKKi4dPR8gWRgtyma5aiymE3aXL2RAZww', + COGNITO_KEY: 'sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b', + COGNITO_TEMPLATE_ID: 'flwtmp_7ZUYaBUFLeNhJw', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'audius', + COINFLOW_PARTNER_ID: 'AUDIUS', + EAGER_DISCOVERY_NODES: + 'https://discoveryprovider.staging.audius.co,https://discoveryprovider2.staging.audius.co,https://discoveryprovider3.staging.audius.co', + ENTITY_MANAGER_ADDRESS: '0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64', + ENVIRONMENT: 'staging', + ETH_BRIDGE_ADDRESS: null, + ETH_NETWORK_ID: '5', + ETH_OWNER_WALLET: null, + ETH_PROVIDER_URL: 'https://eth.staging.audius.co', + ETH_REGISTRY_ADDRESS: '0xF27A9c44d7d5DDdA29bC1eeaD94718EeAC1775e3', + ETH_TOKEN_ADDRESS: '0x5375BE4c52fA29b26077B0F15ee5254D779676A6', + ETH_TOKEN_BRIDGE_ADDRESS: null, + EXPLORE_CONTENT_URL: + 'https://download.staging.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: null, + FINGERPRINT_ENDPOINT: 'https://fp.staging.audius.co', + FINGERPRINT_PUBLIC_API_KEY: 'Rz2A3Y5YGSg9K80VgKPi', + GA_HOSTNAME: 'staging.audius.co', + GA_MEASUREMENT_ID: 'G-CH6BY2X2WL', + GENERAL_ADMISSION: 'https://general-admission.staging.audius.co', + HCAPTCHA_BASE_URL: 'https://staging.audius.co', + HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea', + IDENTITY_SERVICE: 'https://identityservice.staging.audius.co', + INSTAGRAM_APP_ID: '2875320099414320', + INSTAGRAM_REDIRECT_URL: 'https://staging.audius.co/', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://rinkeby-api.opensea.io/api/v1', + OPTIMIZELY_KEY: 'MX4fYBgANQetvmBXGpuxzF', + ORACLE_ETH_ADDRESSES: '0x00b6462e955dA5841b6D9e1E2529B830F00f31Bf', + PAYMENT_ROUTER_PROGRAM_ID: 'sp38CXGL9FoWPp9Avo4fevewEX4UqNkTSTFUPpQFRry', + PUBLIC_HOSTNAME: 'staging.audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: '/', + REACHABILITY_URL: 'https://staging.audius.co/204', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0x793373aBF96583d5eb71a15d86fFE732CD04D452', + REWARDS_MANAGER_PROGRAM_ID: 'CDpzvz7DfgbF95jSSCHLX3ERkugyfgn9Fw8ypNZ1hfXp', + REWARDS_MANAGER_PROGRAM_PDA: 'GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq', + REWARDS_MANAGER_TOKEN_PDA: 'HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ', + SAFARI_WEB_PUSH_ID: 'web.co.audius.staging', + SCHEME: 'audius-staging', + SENTRY_DSN: 'https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611', + SOL_BRIDGE_ADDRESS: null, + SOL_TOKEN_BRIDGE_ADDRESS: null, + SOLANA_CLUSTER_ENDPOINT: 'https://audius-fe.rpcpool.com', + SOLANA_FEE_PAYER_ADDRESS: 'E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h', + SOLANA_RELAY_ENDPOINT: 'https://discoveryprovider.staging.audius.co', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'mainnet-beta', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.staging.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: Config.TIKTOK_APP_ID!, + TRPC_ENDPOINT: 'https://discoveryprovider3.staging.audius.co/trpc/trpc', + USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', + USER_NODE: 'https://usermetadata.staging.audius.co', + USE_HASH_ROUTING: false, + WAUDIO_MINT_ADDRESS: 'BELGiMZQ34SDE6x2FUaML2UHDAgBLS64xvhXjX5tBBZo', + WEB3_NETWORK_ID: '77', + WEB3_PROVIDER_URL: 'https://poa-gateway.staging.audius.co', + WORMHOLE_ADDRESS: '0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7', + WORMHOLE_RPC_HOSTS: null +} diff --git a/packages/mobile/src/env/index.ts b/packages/mobile/src/env/index.ts new file mode 100644 index 00000000000..f74cfedf0f7 --- /dev/null +++ b/packages/mobile/src/env/index.ts @@ -0,0 +1,26 @@ +import type { Env } from '@audius/common' +import Config from 'react-native-config' + +import { env as envDev } from './env.dev' +import { env as envProd } from './env.prod' +import { env as envStage } from './env.stage' + +const environment = Config.ENVIRONMENT + +let env: Env + +switch (environment) { + case 'development': + env = envDev + break + case 'production': + env = envProd + break + case 'staging': + env = envStage + break + default: + throw new Error(`Unknown environment: ${environment}`) +} + +export { env } diff --git a/packages/mobile/src/hooks/useTikTokAuth.ts b/packages/mobile/src/hooks/useTikTokAuth.ts index cb4316ee8cd..11315528513 100644 --- a/packages/mobile/src/hooks/useTikTokAuth.ts +++ b/packages/mobile/src/hooks/useTikTokAuth.ts @@ -3,20 +3,20 @@ import { createUseTikTokAuthHook } from '@audius/common' import AsyncStorage from '@react-native-async-storage/async-storage' import CookieManager from '@react-native-cookies/cookies' import { Linking } from 'react-native' -import Config from 'react-native-config' import { init as tikTokInit, auth as tikTokAuth, events as tikTokEvents } from 'react-native-tiktok' +import { env } from 'app/env' import { track, make } from 'app/services/analytics' import { dispatch } from 'app/store' import * as oauthActions from 'app/store/oauth/actions' import { Provider } from 'app/store/oauth/reducer' import { EventNames } from 'app/types/analytics' -const authenticationUrl = `${Config.IDENTITY_SERVICE}/tiktok` +const authenticationUrl = `${env.IDENTITY_SERVICE}/tiktok` const canOpenTikTok = () => { return Linking.canOpenURL('tiktok://app') @@ -44,7 +44,7 @@ const authenticate = async (): Promise => { }) } - tikTokInit(Config.TIKTOK_APP_ID!) + tikTokInit(env.TIKTOK_APP_ID!) return new Promise((resolve, reject) => { let authDone = false @@ -64,14 +64,14 @@ const authenticate = async (): Promise => { } // Need to set a csrf cookie because it is required for web - await CookieManager.set(Config.IDENTITY_SERVICE!, { + await CookieManager.set(env.IDENTITY_SERVICE!, { name: 'csrfState', value: 'true' }) try { const response = await fetch( - `${Config.IDENTITY_SERVICE}/tiktok/access_token`, + `${env.IDENTITY_SERVICE}/tiktok/access_token`, { credentials: 'include', method: 'POST', diff --git a/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavDrawer.tsx b/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavDrawer.tsx index 4822133e644..e1db07d2825 100644 --- a/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavDrawer.tsx +++ b/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavDrawer.tsx @@ -9,7 +9,6 @@ import { } from '@audius/common' import type { DrawerContentComponentProps } from '@react-navigation/drawer' import { DrawerContentScrollView } from '@react-navigation/drawer' -import Config from 'react-native-config' import { useSelector } from 'react-redux' import IconCrown from 'app/assets/images/iconCrown.svg' @@ -22,6 +21,7 @@ import IconUpload from 'app/assets/images/iconUpload.svg' import IconUser from 'app/assets/images/iconUser.svg' import { AudioBalancePill } from 'app/components/audio-balance-pill/AUDIOBalancePill' import { USDCBalancePill } from 'app/components/usdc-balance-pill/USDCBalancePill' +import { env } from 'app/env' import { useFeatureFlag, useRemoteVar } from 'app/hooks/useRemoteConfig' import { make, track } from 'app/services/analytics' import { spacing } from 'app/styles/spacing' @@ -35,7 +35,7 @@ import { VanityMetrics } from './VanityMetrics' const { getAccountUser } = accountSelectors const { getHasUnreadMessages } = chatSelectors -const isStaging = Config.ENVIRONMENT === 'staging' +const isStaging = env.ENVIRONMENT === 'staging' const messages = { profile: 'Your Profile', diff --git a/packages/mobile/src/screens/collection-screen/CollectionScreen.tsx b/packages/mobile/src/screens/collection-screen/CollectionScreen.tsx index bfb0e3b2190..7083253a363 100644 --- a/packages/mobile/src/screens/collection-screen/CollectionScreen.tsx +++ b/packages/mobile/src/screens/collection-screen/CollectionScreen.tsx @@ -189,7 +189,9 @@ const CollectionScreenComponent = (props: CollectionScreenComponentProps) => { const handlePressOverflow = useCallback(() => { const overflowActions = [ - !is_album && isOwner ? OverflowAction.EDIT_PLAYLIST : null, + (!is_album || isEditAlbumsEnabled) && isOwner + ? OverflowAction.EDIT_PLAYLIST + : null, isOwner && !is_album && is_private ? OverflowAction.PUBLISH_PLAYLIST : null, @@ -204,7 +206,14 @@ const CollectionScreenComponent = (props: CollectionScreenComponentProps) => { overflowActions }) ) - }, [dispatch, playlist_id, isOwner, is_album, is_private]) + }, [ + is_album, + isEditAlbumsEnabled, + isOwner, + is_private, + dispatch, + playlist_id + ]) const handlePressEdit = useCallback(() => { navigation?.push('EditPlaylist', { id: playlist_id }) diff --git a/packages/mobile/src/screens/collection-screen/CollectionScreenDetailsTile.tsx b/packages/mobile/src/screens/collection-screen/CollectionScreenDetailsTile.tsx index cd2d632a924..ae543d73880 100644 --- a/packages/mobile/src/screens/collection-screen/CollectionScreenDetailsTile.tsx +++ b/packages/mobile/src/screens/collection-screen/CollectionScreenDetailsTile.tsx @@ -274,7 +274,7 @@ export const CollectionScreenDetailsTile = ({ hideRepost={hideRepost || !isReachable} isPlaying={isPlaying && isQueued} isPublished={!isPrivate || isPublishing} - isPlaylist={!isAlbum} + isCollection={true} renderBottomContent={renderTrackList} renderHeader={renderHeader} renderImage={renderImage} diff --git a/packages/mobile/src/screens/edit-playlist-screen/EditPlaylistForm.tsx b/packages/mobile/src/screens/edit-playlist-screen/EditPlaylistForm.tsx index d66b641aa33..93a35622881 100644 --- a/packages/mobile/src/screens/edit-playlist-screen/EditPlaylistForm.tsx +++ b/packages/mobile/src/screens/edit-playlist-screen/EditPlaylistForm.tsx @@ -1,8 +1,13 @@ import { useCallback } from 'react' -import { deletePlaylistConfirmationModalUIActions } from '@audius/common' +import { + deletePlaylistConfirmationModalUIActions, + useGetCurrentUserId, + useGetPlaylistById +} from '@audius/common' import type { EditPlaylistValues } from '@audius/common' import type { FormikProps } from 'formik' +import { capitalize } from 'lodash' import { View } from 'react-native' import { useDispatch } from 'react-redux' @@ -28,12 +33,12 @@ import { TrackListFieldArray } from './TrackListFieldArray' const { requestOpen: openDeletePlaylist } = deletePlaylistConfirmationModalUIActions -const messages = { - screenTitle: 'Edit Playlist', - deletePlaylist: 'Delete Playlist', +const getMessages = (collectionType: 'album' | 'playlist') => ({ + screenTitle: `Edit ${capitalize(collectionType)}`, + deletePlaylist: `Delete ${capitalize(collectionType)}`, cancel: 'Cancel', save: 'Save' -} +}) const useStyles = makeStyles(({ palette, spacing, typography }) => ({ titleContainer: { @@ -78,6 +83,11 @@ export const EditPlaylistForm = ( const navigation = useNavigation() const dispatch = useDispatch() + const { data: currentUserId } = useGetCurrentUserId({}) + const { data: collection } = useGetPlaylistById({ playlistId, currentUserId }) + const collectionType = collection?.is_album ? 'album' : 'playlist' + const messages = getMessages(collectionType) + const openDeleteDrawer = useCallback(() => { dispatch(openDeletePlaylist({ playlistId })) }, [dispatch, playlistId]) diff --git a/packages/mobile/src/screens/settings-screen/AppearanceSettingsRow.tsx b/packages/mobile/src/screens/settings-screen/AppearanceSettingsRow.tsx index e663d1bd62c..5f56856b8a1 100644 --- a/packages/mobile/src/screens/settings-screen/AppearanceSettingsRow.tsx +++ b/packages/mobile/src/screens/settings-screen/AppearanceSettingsRow.tsx @@ -7,11 +7,11 @@ import { themeSelectors, useSelectTierInfo } from '@audius/common' -import Config from 'react-native-config' import { useDispatch, useSelector } from 'react-redux' import IconAppearance from 'app/assets/images/iconAppearance.svg' import { SegmentedControl } from 'app/components/core' +import { env } from 'app/env' import { make, track } from 'app/services/analytics' import { Theme } from 'app/utils/theme' @@ -23,7 +23,7 @@ const { getUserId } = accountSelectors const { setTheme } = themeActions const { getTheme } = themeSelectors -const isStaging = Config.ENVIRONMENT === 'staging' +const isStaging = env.ENVIRONMENT === 'staging' const messages = { appearance: 'Appearance', diff --git a/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowInstagramAuth.tsx b/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowInstagramAuth.tsx index d031ac9a46b..a91e7352b6a 100644 --- a/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowInstagramAuth.tsx +++ b/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowInstagramAuth.tsx @@ -7,13 +7,12 @@ import { useAudiusQueryContext } from '@audius/common' import * as signOnActions from 'common/store/pages/signon/actions' -import Config from 'react-native-config' import { useDispatch } from 'react-redux' import { SocialButton } from '@audius/harmony-native' +import { env } from 'app/env' import { restrictedHandles } from 'app/screens/sign-on-screen/utils/restrictedHandles' import { make, track } from 'app/services/analytics' -import { env } from 'app/services/env' import { Provider } from 'app/store/oauth/reducer' import { getInstagramProfile } from 'app/store/oauth/sagas' import type { InstagramCredentials } from 'app/store/oauth/types' @@ -33,8 +32,8 @@ type SignUpFlowInstagramAuthProps = Partial & { onClose?: () => void } -const instagramAppId = Config.INSTAGRAM_APP_ID! -const instagramRedirectUrl = Config.INSTAGRAM_REDIRECT_URL! +const instagramAppId = env.INSTAGRAM_APP_ID +const instagramRedirectUrl = env.INSTAGRAM_REDIRECT_URL const signUpFlowInstagramAuthorizeUrl = `https://api.instagram.com/oauth/authorize?client_id=${instagramAppId}&redirect_uri=${encodeURIComponent( instagramRedirectUrl @@ -47,7 +46,7 @@ const useSetProfileFromInstagram = () => { return async ({ code }: { code: string }) => { const { igUserProfile: profile } = await getInstagramProfile( code, - env.IDENTITY_SERVICE! + env.IDENTITY_SERVICE ) // Update info in redux dispatch( diff --git a/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowTwitterAuth.tsx b/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowTwitterAuth.tsx index 05208db1c83..62b074b5c0d 100644 --- a/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowTwitterAuth.tsx +++ b/packages/mobile/src/screens/sign-on-screen/components/SignUpFlowTwitterAuth.tsx @@ -6,12 +6,11 @@ import { socialMediaMessages, useAudiusQueryContext } from '@audius/common' -import Config from 'react-native-config' import { useAsync } from 'react-use' import { SocialButton } from '@audius/harmony-native' +import { env } from 'app/env' import { restrictedHandles } from 'app/screens/sign-on-screen/utils/restrictedHandles' -import { env } from 'app/services/env' import * as oauthActions from 'app/store/oauth/actions' import { Provider } from 'app/store/oauth/reducer' @@ -37,8 +36,8 @@ const twitterApi = { credentialsType: 'same-origin' as CredentialsType, headers: { 'Content-Type': 'application/json', - origin: Config.AUDIUS_URL!, - referrer: Config.AUDIUS_URL! + origin: env.AUDIUS_URL, + referrer: env.AUDIUS_URL } } diff --git a/packages/mobile/src/services/analytics.ts b/packages/mobile/src/services/analytics.ts index ad15549f836..664cfad3449 100644 --- a/packages/mobile/src/services/analytics.ts +++ b/packages/mobile/src/services/analytics.ts @@ -1,7 +1,7 @@ import { Amplitude } from '@amplitude/react-native' -import Config from 'react-native-config' import VersionNumber from 'react-native-version-number' +import { env } from 'app/env' import { versionInfo } from 'app/utils/appVersionWithCodepush' import packageInfo from '../../package.json' @@ -12,8 +12,8 @@ const { version: clientVersion } = packageInfo let analyticsSetupStatus: 'ready' | 'pending' | 'error' = 'pending' -const AmplitudeWriteKey = Config.AMPLITUDE_WRITE_KEY -const AmplitudeProxy = Config.AMPLITUDE_PROXY +const AmplitudeWriteKey = env.AMPLITUDE_WRITE_KEY +const AmplitudeProxy = env.AMPLITUDE_PROXY const amplitudeInstance = Amplitude.getInstance() const IS_PRODUCTION_BUILD = process.env.NODE_ENV === 'production' diff --git a/packages/mobile/src/services/audius-api-client/apiClient.ts b/packages/mobile/src/services/audius-api-client/apiClient.ts index 7ecc5e62e65..2fe3b40e9d5 100644 --- a/packages/mobile/src/services/audius-api-client/apiClient.ts +++ b/packages/mobile/src/services/audius-api-client/apiClient.ts @@ -1,10 +1,10 @@ import { AudiusAPIClient } from '@audius/common' -import { audiusBackendInstance } from '../audius-backend-instance' -import { env } from '../env' -import { audiusLibs, waitForLibsInit } from '../libs' -import { localStorage } from '../local-storage' -import { remoteConfigInstance } from '../remote-config' +import { env } from 'app/env' +import { audiusBackendInstance } from 'app/services/audius-backend-instance' +import { audiusLibs, waitForLibsInit } from 'app/services/libs' +import { localStorage } from 'app/services/local-storage' +import { remoteConfigInstance } from 'app/services/remote-config' export const apiClient = new AudiusAPIClient({ audiusBackendInstance, diff --git a/packages/mobile/src/services/audius-backend-instance.ts b/packages/mobile/src/services/audius-backend-instance.ts index cd129c933c7..dde077fdccd 100644 --- a/packages/mobile/src/services/audius-backend-instance.ts +++ b/packages/mobile/src/services/audius-backend-instance.ts @@ -2,14 +2,13 @@ import { audiusBackend } from '@audius/common' import * as nativeLibs from '@audius/sdk/dist/native-libs' import AsyncStorage from '@react-native-async-storage/async-storage' import { Image } from 'react-native' -import Config from 'react-native-config' +import { env } from 'app/env' import { track } from 'app/services/analytics' import { reportToSentry } from 'app/utils/reportToSentry' import { createPrivateKey } from './createPrivateKey' import { withEagerOption } from './eagerLoadUtils' -import { env } from './env' import { libsInitEventEmitter, LIBS_INITTED_EVENT, @@ -26,16 +25,17 @@ import { getStorageNodeSelector } from './sdk/storageNodeSelector' * audiusBackend initialized for a mobile environment */ export const audiusBackendInstance = audiusBackend({ - claimDistributionContractAddress: Config.CLAIM_DISTRIBUTION_CONTRACT_ADDRESS, + claimDistributionContractAddress: + env.CLAIM_DISTRIBUTION_CONTRACT_ADDRESS ?? undefined, env, - ethOwnerWallet: Config.ETH_OWNER_WALLET, - ethProviderUrls: (Config.ETH_PROVIDER_URL || '').split(','), - ethRegistryAddress: Config.ETH_REGISTRY_ADDRESS, - ethTokenAddress: Config.ETH_TOKEN_ADDRESS, + ethOwnerWallet: env.ETH_OWNER_WALLET ?? undefined, + ethProviderUrls: (env.ETH_PROVIDER_URL || '').split(','), + ethRegistryAddress: env.ETH_REGISTRY_ADDRESS, + ethTokenAddress: env.ETH_TOKEN_ADDRESS, discoveryNodeSelectorService, getFeatureEnabled, getHostUrl: () => { - return `${Config.PUBLIC_PROTOCOL}//${Config.PUBLIC_HOSTNAME}` + return `${env.PUBLIC_PROTOCOL}//${env.PUBLIC_HOSTNAME}` }, getStorageNodeSelector, getWeb3Config: async ( @@ -55,8 +55,8 @@ export const audiusBackendInstance = audiusBackend({ hedgehogConfig: { createKey: createPrivateKey }, - identityServiceUrl: Config.IDENTITY_SERVICE, - generalAdmissionUrl: Config.GENERAL_ADMISSION, + identityServiceUrl: env.IDENTITY_SERVICE, + generalAdmissionUrl: env.GENERAL_ADMISSION, isElectron: false, isMobile: true, localStorage: AsyncStorage, @@ -66,37 +66,37 @@ export const audiusBackendInstance = audiusBackend({ setLibs(libs) libsInitEventEmitter.emit(LIBS_INITTED_EVENT) }, - recaptchaSiteKey: Config.RECAPTCHA_SITE_KEY, + recaptchaSiteKey: env.RECAPTCHA_SITE_KEY, recordAnalytics: track, reportError: reportToSentry, - registryAddress: Config.REGISTRY_ADDRESS, - entityManagerAddress: Config.ENTITY_MANAGER_ADDRESS, + registryAddress: env.REGISTRY_ADDRESS, + entityManagerAddress: env.ENTITY_MANAGER_ADDRESS, remoteConfigInstance, setLocalStorageItem: async (key, value) => AsyncStorage.setItem(key, value), solanaConfig: { - claimableTokenPda: Config.CLAIMABLE_TOKEN_PDA, - claimableTokenProgramAddress: Config.CLAIMABLE_TOKEN_PROGRAM_ADDRESS, - rewardsManagerProgramId: Config.REWARDS_MANAGER_PROGRAM_ID, - rewardsManagerProgramPda: Config.REWARDS_MANAGER_PROGRAM_PDA, - rewardsManagerTokenPda: Config.REWARDS_MANAGER_TOKEN_PDA, + claimableTokenPda: env.CLAIMABLE_TOKEN_PDA, + claimableTokenProgramAddress: env.CLAIMABLE_TOKEN_PROGRAM_ADDRESS, + rewardsManagerProgramId: env.REWARDS_MANAGER_PROGRAM_ID, + rewardsManagerProgramPda: env.REWARDS_MANAGER_PROGRAM_PDA, + rewardsManagerTokenPda: env.REWARDS_MANAGER_TOKEN_PDA, paymentRouterProgramId: env.PAYMENT_ROUTER_PROGRAM_ID, - solanaClusterEndpoint: Config.SOLANA_CLUSTER_ENDPOINT, - solanaFeePayerAddress: Config.SOLANA_FEE_PAYER_ADDRESS, - solanaTokenAddress: Config.SOLANA_TOKEN_PROGRAM_ADDRESS, - waudioMintAddress: Config.WAUDIO_MINT_ADDRESS, - usdcMintAddress: Config.USDC_MINT_ADDRESS, - wormholeAddress: Config.WORMHOLE_ADDRESS + solanaClusterEndpoint: env.SOLANA_CLUSTER_ENDPOINT, + solanaFeePayerAddress: env.SOLANA_FEE_PAYER_ADDRESS, + solanaTokenAddress: env.SOLANA_TOKEN_PROGRAM_ADDRESS, + waudioMintAddress: env.WAUDIO_MINT_ADDRESS, + usdcMintAddress: env.USDC_MINT_ADDRESS, + wormholeAddress: env.WORMHOLE_ADDRESS ?? undefined }, - userNodeUrl: Config.USER_NODE, - web3NetworkId: Config.WEB3_NETWORK_ID, - web3ProviderUrls: (Config.WEB3_PROVIDER_URL || '').split(','), + userNodeUrl: env.USER_NODE, + web3NetworkId: env.WEB3_NETWORK_ID, + web3ProviderUrls: (env.WEB3_PROVIDER_URL || '').split(','), waitForWeb3: async () => {}, wormholeConfig: { - ethBridgeAddress: Config.ETH_BRIDGE_ADDRESS, - ethTokenBridgeAddress: Config.ETH_TOKEN_BRIDGE_ADDRESS, - solBridgeAddress: Config.SOL_BRIDGE_ADDRESS, - solTokenBridgeAddress: Config.SOL_TOKEN_BRIDGE_ADDRESS, - wormholeRpcHosts: Config.WORMHOLE_RPC_HOSTS + ethBridgeAddress: env.ETH_BRIDGE_ADDRESS ?? undefined, + ethTokenBridgeAddress: env.ETH_TOKEN_BRIDGE_ADDRESS ?? undefined, + solBridgeAddress: env.SOL_BRIDGE_ADDRESS ?? undefined, + solTokenBridgeAddress: env.SOL_TOKEN_BRIDGE_ADDRESS ?? undefined, + wormholeRpcHosts: env.WORMHOLE_RPC_HOSTS ?? undefined }, getLibs: async () => nativeLibs, waitForLibsInit, diff --git a/packages/mobile/src/services/coinflow.ts b/packages/mobile/src/services/coinflow.ts index bf32850eb25..28fda130671 100644 --- a/packages/mobile/src/services/coinflow.ts +++ b/packages/mobile/src/services/coinflow.ts @@ -1,6 +1,7 @@ import { NativeModules, Platform } from 'react-native' -import { env } from 'app/services/env' +import { env } from 'app/env' + const nsureSDK = NativeModules.NSureSDK let deviceId: string diff --git a/packages/mobile/src/services/eagerLoadUtils.ts b/packages/mobile/src/services/eagerLoadUtils.ts index 3ce713bbca7..d7d819de52a 100644 --- a/packages/mobile/src/services/eagerLoadUtils.ts +++ b/packages/mobile/src/services/eagerLoadUtils.ts @@ -5,7 +5,8 @@ import { getEagerDiscprov, makeEagerRequest } from '@audius/common' -import { env } from './env' +import { env } from 'app/env' + import { audiusLibs, waitForLibsInit } from './libs' import { localStorage } from './local-storage' diff --git a/packages/mobile/src/services/env.ts b/packages/mobile/src/services/env.ts deleted file mode 100644 index 14783cc6bf0..00000000000 --- a/packages/mobile/src/services/env.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Environment } from '@audius/common' -import Config from 'react-native-config' - -export const env = { - EAGER_DISCOVERY_NODES: Config.EAGER_DISCOVERY_NODES, - ENVIRONMENT: Config.ENVIRONMENT as Environment, - EXPLORE_CONTENT_URL: Config.EXPLORE_CONTENT_URL, - SUGGESTED_FOLLOW_HANDLES: Config.SUGGESTED_FOLLOW_HANDLES, - AAO_ENDPOINT: Config.AAO_ENDPOINT, - ORACLE_ETH_ADDRESSES: Config.ORACLE_ETH_ADDRESSES, - GENERAL_ADMISSION: Config.GENERAL_ADMISSION, - IDENTITY_SERVICE: Config.IDENTITY_SERVICE, - REACHABILITY_URL: Config.REACHABILITY_URL, - PUBLIC_HOSTNAME: Config.PUBLIC_HOSTNAME, - REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY: - Config.REACT_APP_STRIPE_CLIENT_PUBLISHABLE_KEY, - SOLANA_RELAY_ENDPOINT: Config.SOLANA_RELAY_ENDPOINT, - SOLANA_CLUSTER_ENDPOINT: Config.SOLANA_CLUSTER_ENDPOINT, - WAUDIO_MINT_ADDRESS: Config.WAUDIO_MINT_ADDRESS, - USDC_MINT_ADDRESS: Config.USDC_MINT_ADDRESS, - CLAIMABLE_TOKEN_PROGRAM_ADDRESS: Config.CLAIMABLE_TOKEN_PROGRAM_ADDRESS, - REWARDS_MANAGER_PROGRAM_ID: Config.REWARDS_MANAGER_PROGRAM_ID, - PAYMENT_ROUTER_PROGRAM_ID: - Config.PAYMENT_ROUTER_PROGRAM_ID ?? - 'paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa', - COINFLOW_MERCHANT_ID: Config.COINFLOW_MERCHANT_ID ?? 'tikilabs', - COINFLOW_APP_ID: Config.COINFLOW_APP_ID, - COINFLOW_PARTNER_ID: Config.COINFLOW_PARTNER_ID ?? 'AUDIUS' -} diff --git a/packages/mobile/src/services/fingerprint.ts b/packages/mobile/src/services/fingerprint.ts index 3b70a081583..9a30ae75342 100644 --- a/packages/mobile/src/services/fingerprint.ts +++ b/packages/mobile/src/services/fingerprint.ts @@ -1,10 +1,11 @@ import { FingerprintClient } from '@audius/common' import { FingerprintJsProAgent } from '@fingerprintjs/fingerprintjs-pro-react-native' -import Config from 'react-native-config' -const apiKey = Config.FINGERPRINT_PUBLIC_API_KEY || '' -const endpoint = Config.FINGERPRINT_ENDPOINT || '' -const identityService = Config.IDENTITY_SERVICE || '' +import { env } from 'app/env' + +const apiKey = env.FINGERPRINT_PUBLIC_API_KEY || '' +const endpoint = env.FINGERPRINT_ENDPOINT || '' +const identityService = env.IDENTITY_SERVICE || '' export const fingerprintClient = new FingerprintClient({ apiKey, diff --git a/packages/mobile/src/services/remote-config/remote-config-instance.ts b/packages/mobile/src/services/remote-config/remote-config-instance.ts index ffab8707ab9..235d475ab03 100644 --- a/packages/mobile/src/services/remote-config/remote-config-instance.ts +++ b/packages/mobile/src/services/remote-config/remote-config-instance.ts @@ -8,6 +8,7 @@ import codePush from 'react-native-code-push' import Config from 'react-native-config' import VersionNumber from 'react-native-version-number' +import { env } from 'app/env' import { reportToSentry } from 'app/utils/reportToSentry' import packageInfo from '../../../package.json' @@ -16,7 +17,7 @@ export const FEATURE_FLAG_ASYNC_STORAGE_SESSION_KEY = 'featureFlagSessionId-2' const { version: appVersion } = packageInfo -const OPTIMIZELY_KEY = Config.OPTIMIZELY_KEY +const OPTIMIZELY_KEY = env.OPTIMIZELY_KEY const DATA_FILE_URL = 'https://experiments.audius.co/datafiles/%s.json' /** Returns mobile platform (ios or android), mobile app version, and code push update number (if any) */ diff --git a/packages/mobile/src/services/sdk/discoveryNodeSelector.ts b/packages/mobile/src/services/sdk/discoveryNodeSelector.ts index f657cacf40c..93da0493d7c 100644 --- a/packages/mobile/src/services/sdk/discoveryNodeSelector.ts +++ b/packages/mobile/src/services/sdk/discoveryNodeSelector.ts @@ -1,7 +1,7 @@ import { DiscoveryNodeSelectorService } from '@audius/common' -import { env } from '../env' -import { remoteConfigInstance } from '../remote-config/remote-config-instance' +import { env } from 'app/env' +import { remoteConfigInstance } from 'app/services/remote-config/remote-config-instance' export const discoveryNodeSelectorService = new DiscoveryNodeSelectorService({ env, diff --git a/packages/mobile/src/services/sdk/solana.ts b/packages/mobile/src/services/sdk/solana.ts index 27a4de05c52..5cbe5972690 100644 --- a/packages/mobile/src/services/sdk/solana.ts +++ b/packages/mobile/src/services/sdk/solana.ts @@ -1,7 +1,7 @@ import { Solana } from '@audius/sdk' import { PublicKey } from '@solana/web3.js' -import { env } from '../env' +import { env } from 'app/env' export const solanaService = new Solana({ middleware: [ @@ -13,7 +13,7 @@ export const solanaService = new Solana({ } } ], - rpcEndpoint: process.env.SOLANA_CLUSTER_ENDPOINT, + rpcEndpoint: env.SOLANA_CLUSTER_ENDPOINT, mints: { wAUDIO: new PublicKey(env.WAUDIO_MINT_ADDRESS!), USDC: new PublicKey(env.USDC_MINT_ADDRESS!) diff --git a/packages/mobile/src/services/sdk/storageNodeSelector.ts b/packages/mobile/src/services/sdk/storageNodeSelector.ts index 3858f5da5df..6288723981b 100644 --- a/packages/mobile/src/services/sdk/storageNodeSelector.ts +++ b/packages/mobile/src/services/sdk/storageNodeSelector.ts @@ -1,6 +1,6 @@ import { makeGetStorageNodeSelector } from '@audius/common' -import { env } from '../env' +import { env } from 'app/env' import { auth } from './auth' import { discoveryNodeSelectorService } from './discoveryNodeSelector' diff --git a/packages/mobile/src/services/trpc-client-mobile.ts b/packages/mobile/src/services/trpc-client-mobile.ts index 69e5433c90f..ed82fe44a7b 100644 --- a/packages/mobile/src/services/trpc-client-mobile.ts +++ b/packages/mobile/src/services/trpc-client-mobile.ts @@ -1,7 +1,8 @@ import type { AppRouter } from '@audius/trpc-server' import { httpBatchLink } from '@trpc/client' import { createTRPCReact } from '@trpc/react-query' -import Config from 'react-native-config' + +import { env } from 'app/env' export const trpc = createTRPCReact() @@ -26,11 +27,5 @@ export function createAudiusTrpcClient(currentUserId: number | null) { // since tRPC server is deployed manually atm. // in the future some tRPC middleware can set host to currently selected DN per request function getTrpcEndpoint() { - switch (Config.ENVIRONMENT) { - case 'production': - return 'https://discoveryprovider3.audius.co/trpc/trpc' - case 'staging': - return 'https://discoveryprovider3.staging.audius.co/trpc/trpc' - } - return 'http://localhost:2022/trpc' + return env.TRPC_ENDPOINT } diff --git a/packages/mobile/src/store/storeContext.ts b/packages/mobile/src/store/storeContext.ts index 604da43d752..39f266df526 100644 --- a/packages/mobile/src/store/storeContext.ts +++ b/packages/mobile/src/store/storeContext.ts @@ -2,13 +2,12 @@ import type { CommonStoreContext } from '@audius/common' import { OpenSeaClient, SolanaClient } from '@audius/common' import AsyncStorage from '@react-native-async-storage/async-storage' import * as Sentry from '@sentry/react-native' -import Config from 'react-native-config' +import { env } from 'app/env' import * as analytics from 'app/services/analytics' import { audioPlayer } from 'app/services/audio-player' import { apiClient } from 'app/services/audius-api-client' import { audiusBackendInstance } from 'app/services/audius-backend-instance' -import { env } from 'app/services/env' import { explore } from 'app/services/explore' import { fingerprintClient } from 'app/services/fingerprint' import { localStorage } from 'app/services/local-storage' @@ -40,18 +39,18 @@ export const storeContext: CommonStoreContext = { env, explore, solanaClient: new SolanaClient({ - solanaClusterEndpoint: Config.SOLANA_CLUSTER_ENDPOINT, - metadataProgramId: Config.METADATA_PROGRAM_ID + solanaClusterEndpoint: env.SOLANA_CLUSTER_ENDPOINT, + metadataProgramId: env.METADATA_PROGRAM_ID }), sentry: Sentry, reportToSentry, // Shim in main, but defined in native-reloaded branch audioPlayer, trackDownload, - instagramAppId: Config.INSTAGRAM_APP_ID, - instagramRedirectUrl: Config.INSTAGRAM_REDIRECT_URL, + instagramAppId: env.INSTAGRAM_APP_ID, + instagramRedirectUrl: env.INSTAGRAM_REDIRECT_URL, share: (url: string, message?: string) => share({ url, message }), - openSeaClient: new OpenSeaClient(Config.OPENSEA_API_URL!), + openSeaClient: new OpenSeaClient(env.OPENSEA_API_URL!), audiusSdk, imageUtils: { generatePlaylistArtwork diff --git a/packages/mobile/src/utils/reachability.ts b/packages/mobile/src/utils/reachability.ts index 8ef77070358..ea069845b7c 100644 --- a/packages/mobile/src/utils/reachability.ts +++ b/packages/mobile/src/utils/reachability.ts @@ -4,7 +4,7 @@ import NetInfo from '@react-native-community/netinfo' import { debounce } from 'lodash' import { AppState } from 'react-native' -import { env } from 'app/services/env' +import { env } from 'app/env' import { dispatch } from 'app/store' import { setCurrentNetworkType } from 'app/store/offline-downloads/slice' diff --git a/packages/mobile/src/utils/routes.tsx b/packages/mobile/src/utils/routes.tsx index 8acbe1a4098..d7839804e59 100644 --- a/packages/mobile/src/utils/routes.tsx +++ b/packages/mobile/src/utils/routes.tsx @@ -1,10 +1,11 @@ import type { UserCollection, User } from '@audius/common' import { getHash, encodeUrlName } from '@audius/common' -import Config from 'react-native-config' + +import { env } from 'app/env' type UserHandle = Pick -const { AUDIUS_URL } = Config +const { AUDIUS_URL } = env export const getTrackRoute = ( track: { permalink: string }, diff --git a/packages/mobile/src/utils/share.ts b/packages/mobile/src/utils/share.ts index b6a279114ed..3088df3d0a6 100644 --- a/packages/mobile/src/utils/share.ts +++ b/packages/mobile/src/utils/share.ts @@ -1,5 +1,6 @@ import { Share } from 'react-native' -import Config from 'react-native-config' + +import { env } from 'app/env' // Docs for react native share: https://facebook.github.io/react-native/docs/share @@ -9,7 +10,7 @@ type ShareProps = { } const share = async ({ message, url }: ShareProps) => { - const fullUrl = `${Config.AUDIUS_URL}${url}` + const fullUrl = `${env.AUDIUS_URL}${url}` try { // on iOS we can have both message and URL, on android, we need to concat diff --git a/packages/trpc-server/README.md b/packages/trpc-server/README.md index 13d3a826050..3b9d5376118 100644 --- a/packages/trpc-server/README.md +++ b/packages/trpc-server/README.md @@ -47,8 +47,8 @@ Start server: npm run dev ``` -Finally start client but override `VITE_TRPC_ENDPOINT`: +Override `TRPC_ENDPOINT`` in the appropriate env (e.g. env.prod.ts) ``` -VITE_TRPC_ENDPOINT=http://localhost:2022/trpc npm run web:prod +npm run web:prod ``` diff --git a/packages/web/.env/.env b/packages/web/.env/.env deleted file mode 100644 index f5fe60280fd..00000000000 --- a/packages/web/.env/.env +++ /dev/null @@ -1 +0,0 @@ -NODE_PATH=src diff --git a/packages/web/.env/.env.dev b/packages/web/.env/.env.dev deleted file mode 100644 index 6a809f0210c..00000000000 --- a/packages/web/.env/.env.dev +++ /dev/null @@ -1,55 +0,0 @@ -VITE_ENVIRONMENT=development -VITE_PORT=3000 - -VITE_USER_NODE=http://audius-protocol-creator-node-1 -VITE_IDENTITY_SERVICE=http://audius-protocol-identity-service-1 - -VITE_EAGER_DISCOVERY_NODES=http://audius-protocol-discovery-provider-1 - -VITE_REGISTRY_ADDRESS=0xCfEB869F69431e42cdB54A4F4f105C19C080A601 -VITE_ENTITY_MANAGER_ADDRESS=0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B -VITE_WEB3_PROVIDER_URL=http://audius-protocol-poa-ganache-1 - -VITE_ETH_REGISTRY_ADDRESS=0xABbfF712977dB51f9f212B85e8A4904c818C2b63 -VITE_ETH_PROVIDER_URL=http://audius-protocol-eth-ganache-1 -VITE_ETH_TOKEN_ADDRESS=0xdcB2fC9469808630DD0744b0adf97C0003fC29B2 -VITE_ETH_OWNER_WALLET=0x855FA758c77D68a04990E992aA4dcdeF899F654A - -VITE_RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -VITE_HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea - -VITE_COGNITO_KEY=sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b -VITE_COGNITO_TEMPLATE_ID=flwtmp_7ZUYaBUFLeNhJw - -VITE_OPENSEA_API_URL=https://rinkeby-api.opensea.io/api/v1 - -VITE_SOLANA_WEB3_CLUSTER=devnet -VITE_SOLANA_RELAY_ENDPOINT=http://audius-protocol-discovery-provider-1 -VITE_SOLANA_CLUSTER_ENDPOINT=http://audius-protocol-solana-test-validator-1 -VITE_WAUDIO_MINT_ADDRESS=37RCjhgV1qGV2Q54EHFScdxZ22ydRMdKMtVgod47fDP3 -VITE_USDC_MINT_ADDRESS=26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y -VITE_SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -VITE_SOLANA_FEE_PAYER_ADDRESS=HunCgdP91aVeoh8J7cbKTcFRoUwwhHwqYqVVLVkkqQjg -VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS=testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9 -VITE_ANCHOR_ADMIN_ACCOUNT=C8c4bF1Nqi3wnwgQuXBp3SHWKadQU3XZuLCFarsJD1tz -VITE_REWARDS_MANAGER_PROGRAM_ID=testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb -VITE_REWARDS_MANAGER_PROGRAM_PDA=DJPzVothq58SmkpRb1ATn5ddN2Rpv1j2TcGvM3XsHf1c -VITE_REWARDS_MANAGER_TOKEN_PDA=FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ -VITE_PAYMENT_ROUTER_PROGRAM_ID=apaySbqV1XAmuiGszeN4NyWrXkkMrnuJVoNhzmS1AMa - -VITE_METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -VITE_ORACLE_ETH_ADDRESSES=0xF0D5BC18421fa04D0a2A2ef540ba5A9f04014BE3,0x325A621DeA613BCFb5B1A69a7aCED0ea4AfBD73A,0x3fD652C93dFA333979ad762Cf581Df89BaBa6795 -VITE_AAO_ENDPOINT=http://audius-protocol-anti-abuse-oracle-1:8000 - -VITE_USE_HASH_ROUTING=false - -VITE_STRIPE_CLIENT_PUBLISHABLE_KEY= - -# Stage optimizely key -VITE_OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF - -VITE_USE_HASH_ROUTING=false - -VITE_COINFLOW_MERCHANT_ID=audius -VITE_COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ \ No newline at end of file diff --git a/packages/web/.env/.env.prod b/packages/web/.env/.env.prod deleted file mode 100644 index ffd5421e9a0..00000000000 --- a/packages/web/.env/.env.prod +++ /dev/null @@ -1,95 +0,0 @@ -VITE_ENVIRONMENT=production -VITE_PORT=3002 - -VITE_USER_NODE=https://usermetadata.audius.co -VITE_IDENTITY_SERVICE=https://identityservice.audius.co -VITE_GENERAL_ADMISSION=https://general-admission.audius.co - -VITE_REGISTRY_ADDRESS=0xC611C82150b56E6e4Ec5973AcAbA8835Dd0d75A2 -VITE_ENTITY_MANAGER_ADDRESS=0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64 -VITE_WEB3_PROVIDER_URL=https://poa-gateway.audius.co -VITE_WEB3_NETWORK_ID=31524 - -VITE_ETH_REGISTRY_ADDRESS=0xd976d3b4f4e22a238c1A736b6612D22f17b6f64C -VITE_ETH_PROVIDER_URL=https://eth.audius.co -VITE_ETH_NETWORK_ID=1 -VITE_ETH_TOKEN_ADDRESS=0x18aAA7115705e8be94bfFEBDE57Af9BFc265B998 -VITE_ETH_OWNER_WALLET=0xC7310a03e930DD659E15305ed7e1F5Df0F0426C5 -VITE_WORMHOLE_ADDRESS=0x6E7a1F7339bbB62b23D44797b63e4258d283E095 -VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS=0x683c19E621A0F107a291fdAB38f80179809d61B5 - -VITE_SOLANA_WEB3_CLUSTER=mainnet-beta -VITE_SOLANA_RELAY_ENDPOINT=http://discoveryprovider.audius.co -VITE_SOLANA_CLUSTER_ENDPOINT=https://audius-fe.rpcpool.com -VITE_WAUDIO_MINT_ADDRESS=9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM -VITE_USDC_MINT_ADDRESS=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -VITE_SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -VITE_CLAIMABLE_TOKEN_PDA=5ZiE3vAkrdXBgyFL7KqG3RoEGBws4CjRcXVbABDLZTgx -VITE_SOLANA_FEE_PAYER_ADDRESS=pqx3fvvh6b2eZBfLhTtQ5KxzU3CginmgGTmDCjk8TPP -VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS=Ewkv3JahEFRKkcJmpoKB7pXbnUHwjAyXiwEo4ZY2rezQ -VITE_REWARDS_MANAGER_PROGRAM_ID=DDZDcYdQFEMwcu2Mwo75yGFjJ1mUQyyXLWzhZLEVFcei -VITE_REWARDS_MANAGER_PROGRAM_PDA=71hWFVYokLaN1PNYzTAWi13EfJ7Xt9VbSWUKsXUT8mxE -VITE_REWARDS_MANAGER_TOKEN_PDA=3V9opXNpHmPPymKeq7CYD8wWMH8wzFXmqEkNdzfsZhYq -VITE_PAYMENT_ROUTER_PROGRAM_ID=paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa - -VITE_WORMHOLE_RPC_HOSTS=https://wormhole-v2-mainnet-api.certus.one,https://wormhole.inotel.ro,https://wormhole-v2-mainnet-api.mcf.rocks,https://wormhole-v2-mainnet-api.chainlayer.network,https://wormhole-v2-mainnet-api.staking.fund,https://wormhole-v2-mainnet-api.chainlayer.network -VITE_ETH_BRIDGE_ADDRESS=0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B -VITE_ETH_TOKEN_BRIDGE_ADDRESS=0x3ee18B2214AFF97000D974cf647E7C347E8fa585 -VITE_SOL_BRIDGE_ADDRESS=worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth -VITE_SOL_TOKEN_BRIDGE_ADDRESS=wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb - -VITE_METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -VITE_GA_MEASUREMENT_ID=G-V6N1ZTVGS5 - -VITE_PUBLIC_PROTOCOL=https: -VITE_PUBLIC_HOSTNAME=audius.co -VITE_GA_HOSTNAME=audius.co -VITE_REACHABILITY_URL=https://audius.co/204 -VITE_NOTIFICATION_URL=https://download.audius.co/whatsnew - -VITE_SCHEME=audius - -VITE_EXPLORE_CONTENT_URL=https://download.audius.co/static-resources/explore-content.json -VITE_SUGGESTED_FOLLOW_HANDLES=https://download.audius.co/static-resources/signup-follows.json -VITE_EAGER_DISCOVERY_NODES=https://discoveryprovider.audius.co,https://discoveryprovider2.audius.co,https://discoveryprovider3.audius.co - -VITE_SENTRY_DSN=https://e26d2b01488f4b538ea235de6466c40a@s.audius.co/1457231 - -VITE_SEGMENT_WEB=mGyaUaZz6IZwAM6taytNhubjCX4RPR0x -VITE_SEGMENT_MOBILE=AbVxGDZBuVRCAVuhRaoF3cNsOB3vUCos -VITE_SEGMENT_ELECTRON=eMGe35ghRLWsEWX9EpzblQInDH1CmzAa -VITE_AMPLITUDE_API_KEY=86760558b8bb1b3aae61656efd4ddacb -VITE_AMPLITUDE_PROXY=gain.audius.co -VITE_ADROLL_AVD_ID=SDJ23TS7DBFPLMXRDF6JQY -VITE_ADROLL_PIX_ID=JZSZK5GWHBFL3FQ3NRFPNY -VITE_FCM_PUSH_PUBLIC_KEY=BDBRR9S_UczQBflfaFPQf1JuCIZhMk90G_QnRI9wWuoObt7Ck6sRCxPDJfB_mJY3p55WdAO4C4xVJTAMoiv6JJQ -VITE_SAFARI_WEB_PUSH_ID=web.co.audius - -VITE_OPTIMIZELY_KEY=DAJbGEJBC21dzFRPv8snxs -VITE_INSTAGRAM_APP_ID=189700309435573 -VITE_INSTAGRAM_REDIRECT_URL=https://audius.co/ - -GENERATE_SOURCEMAP=false - -VITE_RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -VITE_HCAPTCHA_SITE_KEY=b250803e-dcba-428c-bc87-8acf559aacb9 - -VITE_BITSKI_CLIENT_ID=661ce11a-3e0f-4659-b365-795ad2111f42 -VITE_BITSKI_CALLBACK_URL=https://audius.co/bitski-callback.html - -VITE_OPENSEA_API_URL=https://collectibles.audius.co/api/v1 -VITE_COGNITO_KEY=live_publishable_key_9afb0a1e2e32ba707a70e66c6d309500 -VITE_COGNITO_TEMPLATE_ID=flwtmp_eMMe8VQGrKvLCX - -VITE_FINGERPRINT_PUBLIC_API_KEY=MNtDQ4NCsNSP7YOkOiQT -VITE_FINGERPRINT_ENDPOINT=https://fp.audius.co - -VITE_OTEL_TRACING_ENABLED=true - -VITE_STRIPE_CLIENT_PUBLISHABLE_KEY=pk_live_51LPsGuCJOWtpH6AEKshlCs3L8QhAfevNvhev8K9a0u92O5ku83KRjLIqCdxgf3NhitdtmMGlw0Wjf33NjZJjZUBz006A3IoSiQ - -VITE_USE_HASH_ROUTING=false - -VITE_COINFLOW_MERCHANT_ID=tikilabs -VITE_COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ \ No newline at end of file diff --git a/packages/web/.env/.env.source-maps b/packages/web/.env/.env.source-maps deleted file mode 100644 index c2974ee2564..00000000000 --- a/packages/web/.env/.env.source-maps +++ /dev/null @@ -1 +0,0 @@ -GENERATE_SOURCEMAP=true diff --git a/packages/web/.env/.env.stage b/packages/web/.env/.env.stage deleted file mode 100644 index 3e37e29fcbe..00000000000 --- a/packages/web/.env/.env.stage +++ /dev/null @@ -1,83 +0,0 @@ -VITE_ENVIRONMENT=staging -VITE_PORT=3001 - -VITE_USER_NODE=https://usermetadata.staging.audius.co -VITE_IDENTITY_SERVICE=https://identityservice.staging.audius.co -VITE_GENERAL_ADMISSION=https://general-admission.staging.audius.co - -VITE_REGISTRY_ADDRESS=0x793373aBF96583d5eb71a15d86fFE732CD04D452 -VITE_ENTITY_MANAGER_ADDRESS=0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64 -VITE_WEB3_PROVIDER_URL=https://poa-gateway.staging.audius.co -VITE_WEB3_NETWORK_ID=1056801 -VITE_ETH_REGISTRY_ADDRESS=0xF27A9c44d7d5DDdA29bC1eeaD94718EeAC1775e3 -VITE_ETH_PROVIDER_URL=https://eth.staging.audius.co -VITE_ETH_NETWORK_ID=5 -VITE_ETH_TOKEN_ADDRESS=0x5375BE4c52fA29b26077B0F15ee5254D779676A6 -VITE_ETH_OWNER_WALLET= -VITE_WORMHOLE_ADDRESS=0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7 -VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS=0x74b89B916c97d50557E8F944F32662fE52Ce378d -VITE_SOLANA_WEB3_CLUSTER=mainnet-beta -VITE_SOLANA_RELAY_ENDPOINT=https://discoveryprovider.staging.audius.co -VITE_SOLANA_CLUSTER_ENDPOINT=https://audius-fe.rpcpool.com -VITE_WAUDIO_MINT_ADDRESS=BELGiMZQ34SDE6x2FUaML2UHDAgBLS64xvhXjX5tBBZo -VITE_USDC_MINT_ADDRESS=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -VITE_SOLANA_TOKEN_PROGRAM_ADDRESS=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -VITE_CLAIMABLE_TOKEN_PDA=Aw5AjygeMf9Nvg61BXvFSAzkqxcLqL8koepb14kvfc3W -VITE_SOLANA_FEE_PAYER_ADDRESS=E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h -VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS=2sjQNmUfkV6yKKi4dPR8gWRgtyma5aiymE3aXL2RAZww -VITE_REWARDS_MANAGER_PROGRAM_ID=CDpzvz7DfgbF95jSSCHLX3ERkugyfgn9Fw8ypNZ1hfXp -VITE_REWARDS_MANAGER_PROGRAM_PDA=GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq -VITE_REWARDS_MANAGER_TOKEN_PDA=HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ -VITE_PAYMENT_ROUTER_PROGRAM_ID=sp38CXGL9FoWPp9Avo4fevewEX4UqNkTSTFUPpQFRry - -VITE_METADATA_PROGRAM_ID=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s - -VITE_NOTIFICATION_URL=https://download.staging.audius.co/notifications - -VITE_PUBLIC_PROTOCOL=https: -VITE_PUBLIC_HOSTNAME=staging.audius.co -VITE_GA_HOSTNAME=staging.audius.co -VITE_REACHABILITY_URL=https://staging.audius.co/204 - -VITE_SCHEME=audius-staging - -VITE_EXPLORE_CONTENT_URL=https://download.staging.audius.co/static-resources/explore-content.json -VITE_SUGGESTED_FOLLOW_HANDLES=https://download.staging.audius.co/static-resources/signup-follows.json -VITE_EAGER_DISCOVERY_NODES=https://discoveryprovider.staging.audius.co,https://discoveryprovider2.staging.audius.co,https://discoveryprovider3.staging.audius.co - -VITE_SENTRY_DSN=https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611 - -VITE_SEGMENT_WEB=gDCBr11kRsaR4owd6WutXDQ2GjICZogl -VITE_SEGMENT_MOBILE=2foKN924MI4ZkzIuBzGVExkpBjZ3NpE6 -VITE_SEGMENT_ELECTRON=v5lPmEQXo91XfB4fdqW8x6GCJQ9ZMnrq -VITE_AMPLITUDE_API_KEY=72a58ce4ad1f9bafcba0b92bedb6c33d -VITE_AMPLITUDE_PROXY=gain.audius.co -VITE_FCM_PUSH_PUBLIC_KEY=BIQQAP1Cb5LvBTkUknmRxCiQ-lHD1GjjsLFX4fo7c70FGHTSpN4iTNePCck7fCk9XBGIfwTxoDbNQO1vRiYSUFA -VITE_SAFARI_WEB_PUSH_ID=web.co.audius.staging -VITE_INSTAGRAM_APP_ID=2875320099414320 -VITE_INSTAGRAM_REDIRECT_URL=https://staging.audius.co/ - -VITE_OPTIMIZELY_KEY=MX4fYBgANQetvmBXGpuxzF -VITE_B_ITEMS_URL= - -VITE_RECAPTCHA_SITE_KEY=6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q -VITE_HCAPTCHA_SITE_KEY=2abe61f1-af6e-4707-be19-a9a4146a9bea - -VITE_BITSKI_CLIENT_ID=7a543ec2-b55f-45d6-a5d4-0448c5a23485 -VITE_BITSKI_CALLBACK_URL=https://staging.audius.co/bitski-callback.html - -VITE_OPENSEA_API_URL=https://rinkeby-api.opensea.io/api/v1 -VITE_COGNITO_KEY=sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b -VITE_COGNITO_TEMPLATE_ID=flwtmp_7ZUYaBUFLeNhJw - -VITE_FINGERPRINT_PUBLIC_API_KEY=Rz2A3Y5YGSg9K80VgKPi -VITE_FINGERPRINT_ENDPOINT=https://fp.staging.audius.co - -VITE_OTEL_TRACING_ENABLED=true - -VITE_STRIPE_CLIENT_PUBLISHABLE_KEY=pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi - -VITE_USE_HASH_ROUTING=false - -VITE_COINFLOW_MERCHANT_ID=audius -VITE_COINFLOW_APP_ID=9JBW2RHC7JNJN8ZQ \ No newline at end of file diff --git a/packages/web/.gitignore b/packages/web/.gitignore index fb103863500..a48ee82c4b3 100644 --- a/packages/web/.gitignore +++ b/packages/web/.gitignore @@ -8,7 +8,7 @@ !/public/scripts/sw.js # env -.env/.env.dev.local +env/.env.dev.local # testing /coverage diff --git a/packages/web/.env/.env.bundle b/packages/web/env/.env.bundle similarity index 100% rename from packages/web/.env/.env.bundle rename to packages/web/env/.env.bundle diff --git a/packages/web/env/.env.dev b/packages/web/env/.env.dev new file mode 100644 index 00000000000..7c66b06ed6c --- /dev/null +++ b/packages/web/env/.env.dev @@ -0,0 +1,2 @@ +VITE_ENVIRONMENT=development +VITE_PORT=3000 diff --git a/packages/web/env/.env.prod b/packages/web/env/.env.prod new file mode 100644 index 00000000000..d1c237fb22d --- /dev/null +++ b/packages/web/env/.env.prod @@ -0,0 +1,2 @@ +VITE_ENVIRONMENT=production +VITE_PORT=3002 \ No newline at end of file diff --git a/packages/web/env/.env.stage b/packages/web/env/.env.stage new file mode 100644 index 00000000000..c0e3f19f82f --- /dev/null +++ b/packages/web/env/.env.stage @@ -0,0 +1,2 @@ +VITE_ENVIRONMENT=staging +VITE_PORT=3001 \ No newline at end of file diff --git a/packages/web/index.html b/packages/web/index.html index d5e2fff60d6..d90c58b927e 100644 --- a/packages/web/index.html +++ b/packages/web/index.html @@ -71,7 +71,7 @@ // Account recovery try { const urlParams = new URLSearchParams(window.location.search) - const useHashRouting = '%VITE_USE_HASH_ROUTING%' === 'true' + const useHashRouting = '%USE_HASH_ROUTING%' const login = urlParams.get('login') const warning = urlParams.get('warning') @@ -110,61 +110,23 @@ - - - - diff --git a/packages/web/package.json b/packages/web/package.json index 479a2df444f..ce3faf32dd4 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -8,16 +8,15 @@ "scripts": { "publish-scripts": "./scripts/publishScripts.sh", "start": "vite", - "start:dev": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.dev turbo run start", - "start:stage": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.stage turbo run start", - "start:prod": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.prod env-cmd ./.env/.env.source-maps turbo run start", + "start:dev": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.dev turbo run start", + "start:stage": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.stage turbo run start", + "start:prod": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.prod turbo run start", "preview:prod": "npm run build:prod && vite preview --outDir build-production", "prebuild": "npm run publish-scripts", "build": "vite build && cp package.json build/package.json", - "build:dev": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.dev turbo run build && rm -rf build-development && mv build build-development", - "build:stage": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.stage turbo run build && rm -rf build-staging && mv build build-staging", - "build:prod": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.prod turbo run build && rm -rf build-production && mv build build-production", - "build:prod-source-maps": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.prod env-cmd ./.env/.env.source-maps turbo run build && rm -rf build-production && mv build build-production", + "build:dev": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.dev turbo run build && rm -rf build-development && mv build build-development", + "build:stage": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.stage turbo run build && rm -rf build-staging && mv build build-staging", + "build:prod": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.prod turbo run build && rm -rf build-production && mv build build-production", "test": "vitest", "test:coverage": "vitest --resetMocks=false --coverage --watchAll=false", "eject": "react-scripts eject", @@ -45,7 +44,7 @@ "dist:linux-publish-production": "npm run dist -- --linux --publish always --env production", "dist:win:linux-publish-production": "npm run dist -- --win --linux --publish always --env production", "write-sha": "./scripts/writeSHA.sh", - "analyze": "env-cmd ./.env/.env.bundle npm run build:prod", + "analyze": "env-cmd ./env/.env.bundle npm run build:prod", "typecheck": "tsc", "typecheck:watch": "tsc --watch", "install-dmg-license": "npm add dmg-license -w audius-client", diff --git a/packages/web/scripts/writeSHA.sh b/packages/web/scripts/writeSHA.sh index c02865fdfbc..a4d47c22d58 100755 --- a/packages/web/scripts/writeSHA.sh +++ b/packages/web/scripts/writeSHA.sh @@ -1,3 +1,3 @@ CURRENT_SHA=$(git rev-parse HEAD) -rm -rf .env/.env.git -echo "VITE_CURRENT_GIT_SHA=$CURRENT_SHA" > .env/.env.git +rm -rf env/.env.git +echo "VITE_CURRENT_GIT_SHA=$CURRENT_SHA" > env/.env.git diff --git a/packages/web/src/app/App.tsx b/packages/web/src/app/App.tsx index 0af61dd5c67..c63b3f9eecd 100644 --- a/packages/web/src/app/App.tsx +++ b/packages/web/src/app/App.tsx @@ -8,6 +8,7 @@ import { Redirect, Route, Switch } from 'react-router-dom' import { CoinbasePayButtonProvider } from 'components/coinbase-pay-button' import { SomethingWrong } from 'pages/something-wrong/SomethingWrong' +import { env } from 'services/env' import { SIGN_IN_PAGE, SIGN_ON_ALIASES, SIGN_UP_PAGE } from 'utils/route' import { AppErrorBoundary } from './AppErrorBoundary' @@ -22,8 +23,8 @@ const OAuthLoginPage = lazy(() => import('pages/oauth-login-page')) const DemoTrpcPage = lazy(() => import('pages/demo-trpc/DemoTrpcPage')) const TrpcHistoryPage = lazy(() => import('pages/demo-trpc/TrpcHistory')) -const MERCHANT_ID = process.env.VITE_COINFLOW_MERCHANT_ID -const IS_PRODUCTION = process.env.VITE_ENVIRONMENT === 'production' +const MERCHANT_ID = env.COINFLOW_MERCHANT_ID +const IS_PRODUCTION = env.ENVIRONMENT === 'production' export const AppInner = () => { const { isEnabled: isSignInRedesignEnabled, isLoaded } = useFeatureFlag( diff --git a/packages/web/src/common/store/pages/audio-transactions/sagas.ts b/packages/web/src/common/store/pages/audio-transactions/sagas.ts index 5254a26e094..4df69be38f1 100644 --- a/packages/web/src/common/store/pages/audio-transactions/sagas.ts +++ b/packages/web/src/common/store/pages/audio-transactions/sagas.ts @@ -14,8 +14,6 @@ import { AudiusLibs, full } from '@audius/sdk' import { call, takeLatest, put } from 'typed-redux-saga' import { fetchUsers } from 'common/store/cache/users/sagas' -import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' -import { waitForLibsInit } from 'services/audius-backend/eagerLoadUtils' const { fetchAudioTransactions, @@ -105,6 +103,7 @@ function* fetchAudioTransactionsAsync() { yield* takeLatest( fetchAudioTransactions.type, function* (action: ReturnType): any { + const audiusBackendInstance = yield* getContext('audiusBackendInstance') const { data, signature } = yield* call([ audiusBackendInstance, audiusBackendInstance.signDiscoveryNodeRequest @@ -155,7 +154,9 @@ function* fetchTransactionMetadata() { if (txDetails.transactionType !== TransactionType.PURCHASE) { return } - yield* call(waitForLibsInit) + const apiClient = yield* getContext('apiClient') + const audiusBackendInstance = yield* getContext('audiusBackendInstance') + yield* call([apiClient, apiClient.waitForLibsInit]) const libs: AudiusLibs = yield* call(audiusBackendInstance.getAudiusLibs) const response = yield* call( [ @@ -179,6 +180,7 @@ function* fetchTransactionMetadata() { function* fetchTransactionsCount() { yield* takeLatest(fetchAudioTransactionsCount.type, function* () { + const audiusBackendInstance = yield* getContext('audiusBackendInstance') const { data, signature } = yield* call([ audiusBackendInstance, audiusBackendInstance.signDiscoveryNodeRequest diff --git a/packages/web/src/common/store/pages/explore/sagas.ts b/packages/web/src/common/store/pages/explore/sagas.ts index 89f1cad7a5e..52aafe23901 100644 --- a/packages/web/src/common/store/pages/explore/sagas.ts +++ b/packages/web/src/common/store/pages/explore/sagas.ts @@ -21,16 +21,13 @@ const { } = explorePageActions const { getPlaylistIds, getProfileIds } = explorePageSelectors -const EXPLORE_CONTENT_URL = - process.env.VITE_EXPLORE_CONTENT_URL || STATIC_EXPLORE_CONTENT_URL - type ExploreContent = { featuredPlaylists: ID[] featuredProfiles: ID[] } export const fetchExploreContent = async ( - exploreContentUrl = EXPLORE_CONTENT_URL + exploreContentUrl: string = STATIC_EXPLORE_CONTENT_URL ): Promise => { const response = await fetch(exploreContentUrl) return await response.json() diff --git a/packages/web/src/common/store/pages/signon/actions.ts b/packages/web/src/common/store/pages/signon/actions.ts index 2fe08254ba9..28ca0247dd0 100644 --- a/packages/web/src/common/store/pages/signon/actions.ts +++ b/packages/web/src/common/store/pages/signon/actions.ts @@ -6,6 +6,7 @@ import { TikTokProfile, Image } from '@audius/common' +import { createCustomAction } from 'typesafe-actions' import { UiErrorCode } from 'store/errors/actions' @@ -77,6 +78,7 @@ export const FETCH_FOLLOW_ARTISTS_FAILED = 'SIGN_ON/FETCH_FOLLOW_ARTISTS_FAILED' export const SET_FOLLOW_ARTIST_CATEGORY = 'SIGN_ON/SET_FOLLOW_ARTIST_CATEGORY' export const ADD_FOLLOW_ARTISTS = 'SIGN_ON/ADD_FOLLOW_ARTISTS' export const REMOVE_FOLLOW_ARTISTS = 'SIGN_ON/REMOVE_FOLLOW_ARTISTS' +export const COMPLETE_FOLLOW_ARTISTS = 'SIGN_ON/COMPLETE_FOLLOW_ARTISTS' export const SEND_WELCOME_EMAIL = 'SIGN_ON/SEND_WELCOME_EMAIL' @@ -375,8 +377,11 @@ export function setTikTokProfileError(error: string) { * Follows users in signup flow after user is created * @param userIds array of userIds to follow */ -export function followArtists(userIds: ID[]) { - return { type: FOLLOW_ARTISTS, userIds } +export function followArtists( + userIds: ID[], + skipDefaultFollows: boolean = false +) { + return { type: FOLLOW_ARTISTS, userIds, skipDefaultFollows } } /** @@ -484,3 +489,9 @@ export const setReferrer = (userId: ID) => ({ type: SET_REFERRER, userId }) + +/* + * Triggers completeFollowArtists saga that determines the best way to follow artists based on + * the potentially ongoing account creation logic + */ +export const completeFollowArtists = createCustomAction(COMPLETE_FOLLOW_ARTISTS) diff --git a/packages/web/src/common/store/pages/signon/sagas.js b/packages/web/src/common/store/pages/signon/sagas.js index c3dc19b9141..caa796d103a 100644 --- a/packages/web/src/common/store/pages/signon/sagas.js +++ b/packages/web/src/common/store/pages/signon/sagas.js @@ -716,17 +716,33 @@ function* followCollections(collectionIds, favoriteSource) { } } -function* followArtists() { +/* This saga makes sure that artists chosen in sign up get followed accordingly */ +export function* completeFollowArtists(action) { + const accountId = yield select(accountSelectors.getUserId) + if (accountId) { + // If account creation has finished we need to make sure followArtists gets called + // Also we specifically request to not follow the defaults (Audius user, Hot & New Playlist) since that should have already occurred + yield put(signOnActions.followArtists(action.userIds, true)) + } + // Otherwise, Account creation still in progress and followArtists will get called already, no need to call here +} + +function* followArtists(action) { + const { skipDefaultFollows } = action const audiusBackendInstance = yield getContext('audiusBackendInstance') const { ENVIRONMENT } = yield getContext('env') - const defaultFollowUserIds = yield call(getDefautFollowUserIds) + const defaultFollowUserIds = skipDefaultFollows + ? [] + : yield call(getDefautFollowUserIds) yield call(waitForWrite) try { // Auto-follow Hot & New Playlist - if (ENVIRONMENT === 'production') { - yield fork(followCollections, [4281], FavoriteSource.SIGN_UP) - } else if (ENVIRONMENT === 'staging') { - yield fork(followCollections, [555], FavoriteSource.SIGN_UP) + if (!skipDefaultFollows) { + if (ENVIRONMENT === 'production') { + yield fork(followCollections, [4281], FavoriteSource.SIGN_UP) + } else if (ENVIRONMENT === 'staging') { + yield fork(followCollections, [555], FavoriteSource.SIGN_UP) + } } const signOn = yield select(getSignOn) @@ -780,6 +796,10 @@ function* configureMetaMask() { } } +export function* watchCompleteFollowArtists() { + yield takeEvery(signOnActions.COMPLETE_FOLLOW_ARTISTS, completeFollowArtists) +} + function* watchGetArtistsToFollow() { yield takeEvery(signOnActions.GET_USERS_TO_FOLLOW, getArtistsToFollow) } @@ -851,6 +871,7 @@ function* watchSendWelcomeEmail() { export default function sagas() { const sagas = [ + watchCompleteFollowArtists, watchFetchAllFollowArtists, watchFetchReferrer, watchCheckEmail, diff --git a/packages/web/src/common/store/upload/sagaHelpers.ts b/packages/web/src/common/store/upload/sagaHelpers.ts index a823746cc63..36730080561 100644 --- a/packages/web/src/common/store/upload/sagaHelpers.ts +++ b/packages/web/src/common/store/upload/sagaHelpers.ts @@ -21,8 +21,6 @@ import { TrackForUpload } from 'pages/upload-page/types' import { waitForWrite } from 'utils/sagaHelpers' const { getAccountUser } = accountSelectors -const ENVIRONMENT = process.env.VITE_ENVIRONMENT - export function* reportResultEvents({ numSuccess, numFailure, @@ -107,6 +105,7 @@ export function* recordGatedTracks(tracks: (TrackForUpload | TrackMetadata)[]) { } export function* processTracksForUpload(tracks: TrackForUpload[]) { + const { ENVIRONMENT } = yield* getContext('env') const getFeatureEnabled = yield* getContext('getFeatureEnabled') const isUsdcPurchaseEnabled = yield* call( getFeatureEnabled, diff --git a/packages/web/src/components/coinflow-onramp-modal/CoinflowOnrampModal.tsx b/packages/web/src/components/coinflow-onramp-modal/CoinflowOnrampModal.tsx index 83feb83c9b8..9aee9472716 100644 --- a/packages/web/src/components/coinflow-onramp-modal/CoinflowOnrampModal.tsx +++ b/packages/web/src/components/coinflow-onramp-modal/CoinflowOnrampModal.tsx @@ -10,6 +10,7 @@ import { Transaction } from '@solana/web3.js' import { useDispatch } from 'react-redux' import ModalDrawer from 'pages/audio-rewards-page/components/modals/ModalDrawer' +import { env } from 'services/env' import { isElectron } from 'utils/clientUtil' import zIndex from 'utils/zIndex' @@ -17,8 +18,8 @@ import styles from './CoinflowOnrampModal.module.css' const { transactionSucceeded, transactionCanceled } = coinflowModalUIActions -const MERCHANT_ID = process.env.VITE_COINFLOW_MERCHANT_ID -const IS_PRODUCTION = process.env.VITE_ENVIRONMENT === 'production' +const MERCHANT_ID = env.COINFLOW_MERCHANT_ID +const IS_PRODUCTION = env.ENVIRONMENT === 'production' export const CoinflowOnrampModal = () => { const { diff --git a/packages/web/src/components/collection/mobile/CollectionHeader.jsx b/packages/web/src/components/collection/mobile/CollectionHeader.jsx index e7aa1c43b66..15e1496f373 100644 --- a/packages/web/src/components/collection/mobile/CollectionHeader.jsx +++ b/packages/web/src/components/collection/mobile/CollectionHeader.jsx @@ -6,7 +6,8 @@ import { formatCount, formatSecondsAsText, formatDate, - OverflowAction + OverflowAction, + FeatureFlags } from '@audius/common' import { Button, ButtonType, IconPause, IconPlay } from '@audius/stems' import cn from 'classnames' @@ -17,6 +18,7 @@ import { UserLink } from 'components/link' import Skeleton from 'components/skeleton/Skeleton' import { UserGeneratedText } from 'components/user-generated-text' import { useCollectionCoverArt } from 'hooks/useCollectionCoverArt' +import { useFlag } from 'hooks/useRemoteConfig' import ActionButtonRow from 'pages/track-page/components/mobile/ActionButtonRow' import StatsButtonRow from 'pages/track-page/components/mobile/StatsButtonRow' import { isShareToastDisabled } from 'utils/clipboardUtil' @@ -106,6 +108,7 @@ const CollectionHeader = ({ const onSaveCollection = () => { if (!isOwner) onSave() } + const { isEnabled: isEditAlbumsEnabled } = useFlag(FeatureFlags.EDIT_ALBUMS) const onClickOverflow = () => { const overflowActions = [ @@ -119,7 +122,9 @@ const CollectionHeader = ({ : isSaved ? OverflowAction.UNFAVORITE : OverflowAction.FAVORITE, - !isAlbum && isOwner ? OverflowAction.EDIT_PLAYLIST : null, + (!isAlbum || isEditAlbumsEnabled) && isOwner + ? OverflowAction.EDIT_PLAYLIST + : null, isOwner && !isAlbum && !isPublished ? OverflowAction.PUBLISH_PLAYLIST : null, diff --git a/packages/web/src/components/edit-playlist/mobile/EditPlaylistPage.tsx b/packages/web/src/components/edit-playlist/mobile/EditPlaylistPage.tsx index 129f3f83ebf..eec1eab3cb3 100644 --- a/packages/web/src/components/edit-playlist/mobile/EditPlaylistPage.tsx +++ b/packages/web/src/components/edit-playlist/mobile/EditPlaylistPage.tsx @@ -16,6 +16,7 @@ import { cacheCollectionsSelectors, useEditPlaylistModal } from '@audius/common' +import { capitalize } from 'lodash' import { connect } from 'react-redux' import { Dispatch } from 'redux' @@ -43,12 +44,12 @@ const { getCollection, getCollectionTracksWithUsers } = cacheCollectionsSelectors const getAccountUser = accountSelectors.getAccountUser -const messages = { - editPlaylist: 'Edit Playlist', +const getMessages = (collectionType: 'album' | 'playlist') => ({ + editPlaylist: `Edit ${capitalize(collectionType)}`, randomPhoto: 'Get Random Artwork', - placeholderName: 'My Playlist', - placeholderDescription: 'Give your playlist a description' -} + placeholderName: `My ${collectionType}`, + placeholderDescription: `Give your ${collectionType} a description` +}) const initialFormFields = { artwork: {}, @@ -74,6 +75,7 @@ const EditPlaylistPage = g( const tracks = useSelector((state) => getCollectionTracksWithUsers(state, { id: collectionId ?? undefined }) ) + const messages = getMessages(metadata?.is_album ? 'album' : 'playlist') // Close the page if the route was changed useHasChangedRoute(onClose) @@ -324,7 +326,7 @@ const EditPlaylistPage = g( /> ) }), - [formFields, onSave] + [formFields.playlist_name, messages.editPlaylist, onSave] ) useTemporaryNavContext(setters) diff --git a/packages/web/src/components/instagram-auth/InstagramAuth.tsx b/packages/web/src/components/instagram-auth/InstagramAuth.tsx index fb788631be7..e85c8656569 100644 --- a/packages/web/src/components/instagram-auth/InstagramAuth.tsx +++ b/packages/web/src/components/instagram-auth/InstagramAuth.tsx @@ -5,10 +5,11 @@ import cn from 'classnames' import 'url-search-params-polyfill' import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' +import { env } from 'services/env' -const HOSTNAME = process.env.VITE_PUBLIC_HOSTNAME -const INSTAGRAM_APP_ID = process.env.VITE_INSTAGRAM_APP_ID -const INSTAGRAM_REDIRECT_URL = process.env.VITE_INSTAGRAM_REDIRECT_URL || '' +const HOSTNAME = env.PUBLIC_HOSTNAME +const INSTAGRAM_APP_ID = env.INSTAGRAM_APP_ID +const INSTAGRAM_REDIRECT_URL = env.INSTAGRAM_REDIRECT_URL || '' const INSTAGRAM_AUTHORIZE_URL = `https://api.instagram.com/oauth/authorize?client_id=${INSTAGRAM_APP_ID}&redirect_uri=${encodeURIComponent( INSTAGRAM_REDIRECT_URL )}&scope=user_profile,user_media&response_type=code` diff --git a/packages/web/src/components/stripe-on-ramp-modal/StripeOnRampModal.tsx b/packages/web/src/components/stripe-on-ramp-modal/StripeOnRampModal.tsx index d6b5f85a3a8..cb9f32ea7a0 100644 --- a/packages/web/src/components/stripe-on-ramp-modal/StripeOnRampModal.tsx +++ b/packages/web/src/components/stripe-on-ramp-modal/StripeOnRampModal.tsx @@ -6,11 +6,12 @@ import cn from 'classnames' import { useDispatch, useSelector } from 'react-redux' import { useModalState } from 'common/hooks/useModalState' +import { env } from 'services/env' import zIndex from 'utils/zIndex' import styles from './StripeOnRampModal.module.css' -const STRIPE_PUBLISHABLE_KEY = process.env.VITE_STRIPE_CLIENT_PUBLISHABLE_KEY +const STRIPE_PUBLISHABLE_KEY = env.STRIPE_CLIENT_PUBLISHABLE_KEY const { getStripeModalState } = stripeModalUISelectors const { cancelStripeOnramp, stripeSessionStatusChanged } = stripeModalUIActions diff --git a/packages/web/src/components/track-overflow-modal/ConnectedMobileOverflowModal.tsx b/packages/web/src/components/track-overflow-modal/ConnectedMobileOverflowModal.tsx index 35014db51fe..8bb07bb6b64 100644 --- a/packages/web/src/components/track-overflow-modal/ConnectedMobileOverflowModal.tsx +++ b/packages/web/src/components/track-overflow-modal/ConnectedMobileOverflowModal.tsx @@ -20,12 +20,14 @@ import { modalsSelectors, queueSelectors, shareModalUIActions, - useEditPlaylistModal + useEditPlaylistModal, + FeatureFlags } from '@audius/common' import { push as pushRoute } from 'connected-react-router' import { connect } from 'react-redux' import { Dispatch } from 'redux' +import { useFlag } from 'hooks/useRemoteConfig' import { AppState } from 'store/types' import { collectibleDetailsPage, @@ -101,6 +103,7 @@ const ConnectedMobileOverflowModal = ({ unfollow, shareUser }: ConnectedMobileOverflowModalProps) => { + const { isEnabled: isEditAlbumsEnabled } = useFlag(FeatureFlags.EDIT_ALBUMS) // Create callbacks const { onOpen: onOpenEditPlaylist } = useEditPlaylistModal() const { @@ -180,9 +183,10 @@ const ConnectedMobileOverflowModal = ({ ), onVisitCollectiblePage: () => visitCollectiblePage(handle, id as string), - onEditPlaylist: isAlbum - ? () => {} - : () => onOpenEditPlaylist({ collectionId: id as ID }), + onEditPlaylist: + !isAlbum || isEditAlbumsEnabled + ? () => onOpenEditPlaylist({ collectionId: id as ID }) + : () => {}, onDeletePlaylist: isAlbum ? () => {} : () => deletePlaylist(id as ID), onPublishPlaylist: isAlbum ? () => {} diff --git a/packages/web/src/components/track-overflow-modal/components/MobileOverflowModal.tsx b/packages/web/src/components/track-overflow-modal/components/MobileOverflowModal.tsx index 7e6044bae3f..e16cbb17b46 100644 --- a/packages/web/src/components/track-overflow-modal/components/MobileOverflowModal.tsx +++ b/packages/web/src/components/track-overflow-modal/components/MobileOverflowModal.tsx @@ -36,6 +36,7 @@ const rowMessageMap = { [OverflowAction.ADD_TO_ALBUM]: 'Add To Album', [OverflowAction.ADD_TO_PLAYLIST]: 'Add To Playlist', [OverflowAction.REMOVE_FROM_PLAYLIST]: 'Remove From This Playlist', + [OverflowAction.EDIT_ALBUM]: 'Edit Album', [OverflowAction.EDIT_PLAYLIST]: 'Edit Playlist', [OverflowAction.DELETE_PLAYLIST]: 'Delete Playlist', [OverflowAction.PUBLISH_PLAYLIST]: 'Publish Playlist', @@ -89,6 +90,7 @@ const MobileOverflowModal = ({ [OverflowAction.SHARE]: onShare, [OverflowAction.ADD_TO_ALBUM]: onAddToAlbum, [OverflowAction.ADD_TO_PLAYLIST]: onAddToPlaylist, + [OverflowAction.EDIT_ALBUM]: onEditPlaylist, [OverflowAction.EDIT_PLAYLIST]: onEditPlaylist, [OverflowAction.DELETE_PLAYLIST]: onDeletePlaylist, [OverflowAction.PUBLISH_PLAYLIST]: onPublishPlaylist, diff --git a/packages/web/src/components/withdraw-usdc-modal/components/CoinflowWithdrawPage.tsx b/packages/web/src/components/withdraw-usdc-modal/components/CoinflowWithdrawPage.tsx index 1cda32ccfa2..afb2e15f833 100644 --- a/packages/web/src/components/withdraw-usdc-modal/components/CoinflowWithdrawPage.tsx +++ b/packages/web/src/components/withdraw-usdc-modal/components/CoinflowWithdrawPage.tsx @@ -6,6 +6,8 @@ import { useField } from 'formik' import { useDispatch } from 'react-redux' import { useUnmount } from 'react-use' +import { env } from 'services/env' + import { AMOUNT, WithdrawFormValues } from '../types' const { coinflowWithdrawalCanceled, coinflowWithdrawalSucceeded } = @@ -23,8 +25,8 @@ const parseTransactionFromSuccessParams = (params: string) => { } } -const MERCHANT_ID = process.env.VITE_COINFLOW_MERCHANT_ID -const IS_PRODUCTION = process.env.VITE_ENVIRONMENT === 'production' +const MERCHANT_ID = env.COINFLOW_MERCHANT_ID +const IS_PRODUCTION = env.ENVIRONMENT === 'production' export const CoinflowWithdrawPage = () => { const adapter = useCoinflowAdapter() diff --git a/packages/web/src/hooks/useHotkey.ts b/packages/web/src/hooks/useHotkey.ts index 12f0b2f333e..efdaf1ca914 100644 --- a/packages/web/src/hooks/useHotkey.ts +++ b/packages/web/src/hooks/useHotkey.ts @@ -1,5 +1,6 @@ import { useCallback, useEffect, useState } from 'react' +import { env } from 'services/env' import { setupHotkeys, removeHotkeys } from 'utils/hotkeyUtil' enum Modifier { @@ -36,7 +37,7 @@ export const useDevModeHotkey = (keyCode: number) => { const listener = useCallback(() => { if ( - process.env.VITE_ENVIRONMENT === 'production' && + env.ENVIRONMENT === 'production' && (!window.localStorage || !window.localStorage.getItem(ENABLE_DEV_MODE_KEY)) ) diff --git a/packages/web/src/pages/audio-rewards-page/components/modals/HCaptchaModal.tsx b/packages/web/src/pages/audio-rewards-page/components/modals/HCaptchaModal.tsx index 943364fc573..b9861faa492 100644 --- a/packages/web/src/pages/audio-rewards-page/components/modals/HCaptchaModal.tsx +++ b/packages/web/src/pages/audio-rewards-page/components/modals/HCaptchaModal.tsx @@ -6,12 +6,13 @@ import { useDispatch } from 'react-redux' import { useModalState } from 'common/hooks/useModalState' import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' +import { env } from 'services/env' import styles from './HCaptchaModal.module.css' import ModalDrawer from './ModalDrawer' const { setHCaptchaStatus } = audioRewardsPageActions -const sitekey = process.env.VITE_HCAPTCHA_SITE_KEY +const sitekey = env.HCAPTCHA_SITE_KEY const messages = { title: 'Complete Captcha Verification' diff --git a/packages/web/src/pages/check-page/CheckPage.tsx b/packages/web/src/pages/check-page/CheckPage.tsx index 141d6485177..b7d8adac9d8 100644 --- a/packages/web/src/pages/check-page/CheckPage.tsx +++ b/packages/web/src/pages/check-page/CheckPage.tsx @@ -6,10 +6,12 @@ import { useDispatch, useSelector } from 'react-redux' import { useScript } from 'hooks/useScript' import { getCognitoSignature } from 'services/audius-backend/Cognito' +import { env } from 'services/env' import { COGNITO_SCRIPT_URL } from 'utils/constants' import { SIGN_IN_PAGE, TRENDING_PAGE } from 'utils/route' import './CheckPage.module.css' + const { getAccountUser, getAccountStatus } = accountSelectors declare global { @@ -18,8 +20,8 @@ declare global { } } -const COGNITO_KEY = process.env.VITE_COGNITO_KEY -const COGNITO_TEMPLATE_ID = process.env.VITE_COGNITO_TEMPLATE_ID +const COGNITO_KEY = env.COGNITO_KEY +const COGNITO_TEMPLATE_ID = env.COGNITO_TEMPLATE_ID const CheckPage = () => { const dispatch = useDispatch() diff --git a/packages/web/src/pages/demo-trpc/DemoTrpcPage.tsx b/packages/web/src/pages/demo-trpc/DemoTrpcPage.tsx index ae4c3bad9a2..a19ffb73938 100644 --- a/packages/web/src/pages/demo-trpc/DemoTrpcPage.tsx +++ b/packages/web/src/pages/demo-trpc/DemoTrpcPage.tsx @@ -5,6 +5,7 @@ import { RouterInput } from '@audius/trpc-server' import { useSelector } from 'react-redux' import { create } from 'zustand' +import { env } from 'services/env' import { trpc } from 'utils/trpcClientWeb' // ==================== Store ==================== @@ -507,7 +508,7 @@ export function CidImage({ } const host = - process.env.VITE_ENVIRONMENT === 'staging' + env.ENVIRONMENT === 'staging' ? 'https://creatornode12.staging.audius.co' : 'https://creatornode2.audius.co' diff --git a/packages/web/src/pages/fb-share-page/FbSharePage.tsx b/packages/web/src/pages/fb-share-page/FbSharePage.tsx index 190b2c47053..b0087c71b70 100644 --- a/packages/web/src/pages/fb-share-page/FbSharePage.tsx +++ b/packages/web/src/pages/fb-share-page/FbSharePage.tsx @@ -4,11 +4,12 @@ import { accountSelectors } from '@audius/common' import cn from 'classnames' import { Text } from 'components/typography' +import { env } from 'services/env' import { useSelector } from 'utils/reducer' import styles from './FbSharePage.module.css' -const PUBLIC_HOSTNAME = process.env.VITE_PUBLIC_HOSTNAME +const PUBLIC_HOSTNAME = env.PUBLIC_HOSTNAME const messages = { share: 'Share your profile with your friends on Facebook!' diff --git a/packages/web/src/pages/search-page/helpers.ts b/packages/web/src/pages/search-page/helpers.ts index 1642bd28953..c9d10f68f27 100644 --- a/packages/web/src/pages/search-page/helpers.ts +++ b/packages/web/src/pages/search-page/helpers.ts @@ -1,9 +1,10 @@ import { SearchKind } from '@audius/common' import { matchPath } from 'react-router' +import { env } from 'services/env' import { getPathname } from 'utils/route' -const USE_HASH_ROUTING = process.env.VITE_USE_HASH_ROUTING === 'true' +const USE_HASH_ROUTING = env.USE_HASH_ROUTING type matchParams = { category?: string diff --git a/packages/web/src/pages/settings-page/SettingsPageProvider.tsx b/packages/web/src/pages/settings-page/SettingsPageProvider.tsx index aba916287f6..c15fddc04a0 100644 --- a/packages/web/src/pages/settings-page/SettingsPageProvider.tsx +++ b/packages/web/src/pages/settings-page/SettingsPageProvider.tsx @@ -26,6 +26,7 @@ import { Dispatch } from 'redux' import { make, TrackEvent } from 'common/store/analytics/actions' import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' +import { env } from 'services/env' import { AppState } from 'store/types' import { isPushManagerAvailable, @@ -62,7 +63,7 @@ const { getUserName } = accountSelectors -const isStaging = process.env.VITE_ENVIRONMENT === 'staging' +const isStaging = env.ENVIRONMENT === 'staging' const messages = { title: 'Settings', diff --git a/packages/web/src/pages/sign-in-page/SignInPage.tsx b/packages/web/src/pages/sign-in-page/SignInPage.tsx index 17ea808738c..f5e9815ad01 100644 --- a/packages/web/src/pages/sign-in-page/SignInPage.tsx +++ b/packages/web/src/pages/sign-in-page/SignInPage.tsx @@ -91,8 +91,8 @@ export const SignInPage = () => { diff --git a/packages/web/src/pages/sign-on/SignOnProvider.tsx b/packages/web/src/pages/sign-on/SignOnProvider.tsx index 12ab812c568..95980ddc26f 100644 --- a/packages/web/src/pages/sign-on/SignOnProvider.tsx +++ b/packages/web/src/pages/sign-on/SignOnProvider.tsx @@ -213,16 +213,21 @@ export class SignOnProvider extends Component { } if (page === Pages.FOLLOW) { const { - followArtists: { selectedUserIds }, - email, - handle - } = this.props.fields + fields: { + followArtists: { selectedUserIds }, + email, + handle + }, + completeFollowArtists + } = this.props + this.props.recordCompleteFollow( selectedUserIds.join('|'), selectedUserIds.length, email.value, handle.value ) + completeFollowArtists() } if (page === Pages.LOADING) { const { email, handle } = this.props.fields @@ -567,6 +572,7 @@ function mapDispatchToProps(dispatch: Dispatch) { goToPage: (page: Pages) => dispatch(signOnAction.goToPage(page)), addFollows: (userIds: ID[]) => dispatch(signOnAction.addFollowArtists(userIds)), + completeFollowArtists: () => dispatch(signOnAction.completeFollowArtists()), removeFollows: (userIds: ID[]) => dispatch(signOnAction.removeFollowArtists(userIds)), onSetupMetaMask: () => dispatch(signOnAction.configureMetaMask()), diff --git a/packages/web/src/pages/sign-on/components/ProfilePage.tsx b/packages/web/src/pages/sign-on/components/ProfilePage.tsx index fc6be1199e2..56adab4ccf2 100644 --- a/packages/web/src/pages/sign-on/components/ProfilePage.tsx +++ b/packages/web/src/pages/sign-on/components/ProfilePage.tsx @@ -17,12 +17,13 @@ import CompleteProfileWithSocial from 'pages/sign-on/components/CompleteProfileW import ProfileForm, { ProfileFormProps } from 'pages/sign-on/components/ProfileForm' +import { env } from 'services/env' import { isMobile as getIsMobile } from 'utils/clientUtil' import { resizeImage } from 'utils/imageProcessingUtil' import styles from './ProfilePage.module.css' -const GENERAL_ADMISSION = process.env.VITE_GENERAL_ADMISSION ?? '' +const GENERAL_ADMISSION = env.GENERAL_ADMISSION ?? '' const isMobile = getIsMobile() const messages = { diff --git a/packages/web/src/pages/sign-on/components/desktop/FollowPage.tsx b/packages/web/src/pages/sign-on/components/desktop/FollowPage.tsx index b65a7b8a7df..ae68c640113 100644 --- a/packages/web/src/pages/sign-on/components/desktop/FollowPage.tsx +++ b/packages/web/src/pages/sign-on/components/desktop/FollowPage.tsx @@ -11,6 +11,7 @@ import { } from 'common/store/pages/signon/types' import UserCard from 'components/card/UserCard' import SelectablePills from 'components/selectable-pill/SelectablePills' +import { env } from 'services/env' import styles from './FollowPage.module.css' @@ -22,7 +23,7 @@ const messages = { following: 'Following' } -const ENVIRONMENT = process.env.VITE_ENVIRONMENT +const ENVIRONMENT = env.ENVIRONMENT const MINIMUM_FOLLOWER_COUNT = ENVIRONMENT === 'production' || ENVIRONMENT === 'staging' ? 3 : 0 diff --git a/packages/web/src/pages/sign-on/components/desktop/MetaMaskModal.jsx b/packages/web/src/pages/sign-on/components/desktop/MetaMaskModal.jsx index cb4d443a1f5..8b3b3f8cc27 100644 --- a/packages/web/src/pages/sign-on/components/desktop/MetaMaskModal.jsx +++ b/packages/web/src/pages/sign-on/components/desktop/MetaMaskModal.jsx @@ -7,10 +7,11 @@ import cn from 'classnames' import PropTypes from 'prop-types' import { waitForLibsInit } from 'services/audius-backend/eagerLoadUtils' +import { env } from 'services/env' import styles from './MetaMaskModal.module.css' -const WEB3_NETWORK_ID = process.env.VITE_WEB3_NETWORK_ID +const WEB3_NETWORK_ID = env.WEB3_NETWORK_ID const messages = { title: ' Are You Sure You Want To Continue With MetaMask? ', diff --git a/packages/web/src/pages/sign-up-page/components/layout.tsx b/packages/web/src/pages/sign-up-page/components/layout.tsx index e7fa62e3c05..de9baae78b6 100644 --- a/packages/web/src/pages/sign-up-page/components/layout.tsx +++ b/packages/web/src/pages/sign-up-page/components/layout.tsx @@ -193,10 +193,10 @@ type PageFooterProps = { export const PageFooter = (props: PageFooterProps) => { const { prefix, postfix, buttonProps, centered, sticky, ...other } = props const { isMobile } = useMedia() - // On the MobileCTAPage we use this footer outside a formik context - const { isSubmitting, dirty, isValid } = useFormikContext() ?? { + // On the MobileCTAPage we use this footer outside a formik context, hence the default values + const { isSubmitting, touched, isValid } = useFormikContext() ?? { isSubmitting: false, - dirty: true, + touched: true, isValid: true } @@ -227,7 +227,7 @@ export const PageFooter = (props: PageFooterProps) => { fullWidth isLoading={isSubmitting} css={!isMobile && centered && { width: 343 }} - disabled={!dirty || !isValid} + disabled={!touched || !isValid} {...buttonProps} > {messages.continue} diff --git a/packages/web/src/pages/sign-up-page/hooks/socialMediaLogin.ts b/packages/web/src/pages/sign-up-page/hooks/socialMediaLogin.ts index 8b6eebf9f05..d8e84d74fee 100644 --- a/packages/web/src/pages/sign-up-page/hooks/socialMediaLogin.ts +++ b/packages/web/src/pages/sign-up-page/hooks/socialMediaLogin.ts @@ -17,10 +17,11 @@ import { setTikTokProfile, setTwitterProfile } from 'common/store/pages/signon/actions' +import { env } from 'services/env' import { resizeImage } from 'utils/imageProcessingUtil' import { restrictedHandles } from 'utils/restrictedHandles' -const GENERAL_ADMISSION = process.env.VITE_GENERAL_ADMISSION ?? '' +const GENERAL_ADMISSION = env.GENERAL_ADMISSION ?? '' export const useSetProfileFromTwitter = () => { const dispatch = useDispatch() diff --git a/packages/web/src/pages/sign-up-page/pages/CreateEmailPage.tsx b/packages/web/src/pages/sign-up-page/pages/CreateEmailPage.tsx index 16d124d9507..b342030d987 100644 --- a/packages/web/src/pages/sign-up-page/pages/CreateEmailPage.tsx +++ b/packages/web/src/pages/sign-up-page/pages/CreateEmailPage.tsx @@ -114,7 +114,7 @@ export const CreateEmailPage = () => { validateOnChange={false} > {({ isSubmitting }) => ( - + {isMobile ? ( diff --git a/packages/web/src/pages/sign-up-page/pages/ReviewHandlePage.tsx b/packages/web/src/pages/sign-up-page/pages/ReviewHandlePage.tsx index 71d1e6da940..1d1f6883aa6 100644 --- a/packages/web/src/pages/sign-up-page/pages/ReviewHandlePage.tsx +++ b/packages/web/src/pages/sign-up-page/pages/ReviewHandlePage.tsx @@ -79,7 +79,7 @@ export const ReviewHandlePage = () => { validateOnMount > {({ isValid }) => ( - + { const handleSubmit = useCallback( (values: SelectArtistsValues) => { const { selectedArtists } = values - dispatch(addFollowArtists([...selectedArtists])) + const artistsIDArray = [...selectedArtists].map((a) => Number(a)) + dispatch(addFollowArtists(artistsIDArray)) + dispatch(completeFollowArtists()) if (isMobile) { navigate(SIGN_UP_COMPLETED_REDIRECT) } else { diff --git a/packages/web/src/pages/sign-up-page/pages/SelectGenresPage.tsx b/packages/web/src/pages/sign-up-page/pages/SelectGenresPage.tsx index 3cfaa60b488..5cbf637310b 100644 --- a/packages/web/src/pages/sign-up-page/pages/SelectGenresPage.tsx +++ b/packages/web/src/pages/sign-up-page/pages/SelectGenresPage.tsx @@ -62,7 +62,6 @@ export const SelectGenresPage = () => { { // If requested route is allowed return that, otherwise return the last step in the route stack const correctedPath = isAllowedRoute ? attemptedPath + : // IF we attempted to go to /signup directly, that means it was a link from somewhere else in the app, so we should start back at the beginning + attemptedPath === '/signup' + ? allowedRoutes[0] : allowedRoutes[allowedRoutes.length - 1] if (correctedPath === SignUpPath.completedRedirect) { diff --git a/packages/web/src/public-site/PublicSite.tsx b/packages/web/src/public-site/PublicSite.tsx index 771aabcae02..114d098ad15 100644 --- a/packages/web/src/public-site/PublicSite.tsx +++ b/packages/web/src/public-site/PublicSite.tsx @@ -4,6 +4,7 @@ import { BrowserRouter as Router, Route } from 'react-router-dom' import LoadingSpinnerFullPage from 'components/loading-spinner-full-page/LoadingSpinnerFullPage' import NavScreen from 'public-site/components/NavOverlay' +import { env } from 'services/env' import { TRENDING_PAGE, SIGN_UP_PAGE, @@ -16,7 +17,7 @@ import { AppContextProvider } from '../app/AppContextProvider' import LandingPage from './pages/landing-page/LandingPage' -const BASENAME = process.env.VITE_PUBLIC_URL +const BASENAME = env.BASENAME const PrivacyPolicyPage = lazy( () => import('./pages/privacy-policy-page/PrivacyPolicyPage') diff --git a/packages/web/src/public-site/pages/landing-page/components/FeaturedContent.tsx b/packages/web/src/public-site/pages/landing-page/components/FeaturedContent.tsx index 6f29d6521bd..98056681fe8 100644 --- a/packages/web/src/public-site/pages/landing-page/components/FeaturedContent.tsx +++ b/packages/web/src/public-site/pages/landing-page/components/FeaturedContent.tsx @@ -23,6 +23,7 @@ import useCardWeight from 'hooks/useCardWeight' import useHasViewed from 'hooks/useHasViewed' import { handleClickRoute } from 'public-site/components/handleClickRoute' import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' +import { env } from 'services/env' import { collectionPage } from 'utils/route' import styles from './FeaturedContent.module.css' @@ -151,7 +152,7 @@ const FeaturedContent = (props: FeaturedContentProps) => { const { storageNodeSelector } = useAppContext() const [trendingPlaylistsResponse, fetchTrendingPlaylists] = useAsyncFn(async () => { - const featuredContent = await fetchExploreContent() + const featuredContent = await fetchExploreContent(env.EXPLORE_CONTENT_URL) const ids = featuredContent.featuredPlaylists const playlists = audiusBackendInstance.getPlaylists( null, diff --git a/packages/web/src/public-site/pages/privacy-policy-page/PrivacyPolicyPage.tsx b/packages/web/src/public-site/pages/privacy-policy-page/PrivacyPolicyPage.tsx index 5cd3b65d759..909a72cbe41 100644 --- a/packages/web/src/public-site/pages/privacy-policy-page/PrivacyPolicyPage.tsx +++ b/packages/web/src/public-site/pages/privacy-policy-page/PrivacyPolicyPage.tsx @@ -1,9 +1,10 @@ import Footer from 'public-site/components/Footer' import NavBanner from 'public-site/components/NavBanner' +import { env } from 'services/env' import styles from './PrivacyPolicyPage.module.css' -const BASENAME = process.env.VITE_PUBLIC_URL +const BASENAME = env.BASENAME const messages = { download: 'Download Privacy Policy' diff --git a/packages/web/src/public-site/pages/terms-of-use-page/TermsOfUsePage.tsx b/packages/web/src/public-site/pages/terms-of-use-page/TermsOfUsePage.tsx index 26e96faf248..747a57718ad 100644 --- a/packages/web/src/public-site/pages/terms-of-use-page/TermsOfUsePage.tsx +++ b/packages/web/src/public-site/pages/terms-of-use-page/TermsOfUsePage.tsx @@ -1,9 +1,10 @@ import Footer from 'public-site/components/Footer' import NavBanner from 'public-site/components/NavBanner' +import { env } from 'services/env' import styles from './TermsOfUsePage.module.css' -const BASENAME = process.env.VITE_PUBLIC_URL +const BASENAME = env.BASENAME const messages = { download: 'Download Terms of Use' diff --git a/packages/web/src/services/WebWorker.js b/packages/web/src/services/WebWorker.js index 35735737218..8d923fbcb7e 100644 --- a/packages/web/src/services/WebWorker.js +++ b/packages/web/src/services/WebWorker.js @@ -1,7 +1,9 @@ import importWorkerScript from 'workers/importWorkerScript' +import { env } from './env' + const importWorkScriptCode = importWorkerScript.toString() -const basename = process.env.VITE_PUBLIC_URL +const basename = env.BASENAME export default class WebWorker { /** diff --git a/packages/web/src/services/analytics/amplitude.ts b/packages/web/src/services/analytics/amplitude.ts index 26e950964e1..ecee3e16fb4 100644 --- a/packages/web/src/services/analytics/amplitude.ts +++ b/packages/web/src/services/analytics/amplitude.ts @@ -2,14 +2,15 @@ import { MobileOS, Name, Nullable } from '@audius/common' import amplitude from 'amplitude-js' +import { env } from 'services/env' import { isMobile as getIsMobile, isElectron as getIsElectron, getMobileOS } from 'utils/clientUtil' -const AMP_API_KEY = process.env.VITE_AMPLITUDE_API_KEY -const AMPLITUDE_PROXY = process.env.VITE_AMPLITUDE_PROXY +const AMP_API_KEY = env.AMPLITUDE_API_KEY +const AMPLITUDE_PROXY = env.AMPLITUDE_PROXY const getSource = () => { const mobileOS = getMobileOS() @@ -49,7 +50,7 @@ const getSource = () => { let amp: Nullable = null export const init = async () => { try { - if (!amp && AMP_API_KEY) { + if (!amp && AMP_API_KEY && AMPLITUDE_PROXY) { amplitude .getInstance() // Note: https is prepended to the apiEndpoint url specified diff --git a/packages/web/src/services/analytics/index.ts b/packages/web/src/services/analytics/index.ts index e05bc8a9bb9..71b3ddb18cc 100644 --- a/packages/web/src/services/analytics/index.ts +++ b/packages/web/src/services/analytics/index.ts @@ -1,5 +1,6 @@ import { AnalyticsEvent, Nullable, AllTrackingEvents } from '@audius/common' +import { env } from 'services/env' import { remoteConfigInstance } from 'services/remote-config/remote-config-instance' import packageInfo from '../../../package.json' @@ -7,7 +8,7 @@ import packageInfo from '../../../package.json' import * as amplitude from './amplitude' const { version } = packageInfo -const IS_PRODUCTION_BUILD = process.env.VITE_ENVIRONMENT === 'production' +const IS_PRODUCTION_BUILD = env.ENVIRONMENT === 'production' let resolveCallback: Nullable<(value?: any) => void> = null let rejectCallback: Nullable<(value?: any) => void> = null diff --git a/packages/web/src/services/audius-backend/audius-backend-instance.ts b/packages/web/src/services/audius-backend/audius-backend-instance.ts index b937d684c5e..bafdfda3f19 100644 --- a/packages/web/src/services/audius-backend/audius-backend-instance.ts +++ b/packages/web/src/services/audius-backend/audius-backend-instance.ts @@ -28,12 +28,12 @@ declare global { */ export const audiusBackendInstance = audiusBackend({ claimDistributionContractAddress: - process.env.VITE_CLAIM_DISTRIBUTION_CONTRACT_ADDRESS, + env.CLAIM_DISTRIBUTION_CONTRACT_ADDRESS ?? undefined, env, - ethOwnerWallet: process.env.VITE_ETH_OWNER_WALLET, - ethProviderUrls: (process.env.VITE_ETH_PROVIDER_URL || '').split(','), - ethRegistryAddress: process.env.VITE_ETH_REGISTRY_ADDRESS, - ethTokenAddress: process.env.VITE_ETH_TOKEN_ADDRESS, + ethOwnerWallet: env.ETH_OWNER_WALLET ?? undefined, + ethProviderUrls: (env.ETH_PROVIDER_URL || '').split(','), + ethRegistryAddress: env.ETH_REGISTRY_ADDRESS, + ethTokenAddress: env.ETH_TOKEN_ADDRESS, getFeatureEnabled, getHostUrl: () => window.location.origin, getLibs: () => import('@audius/sdk/dist/web-libs'), @@ -85,8 +85,8 @@ export const audiusBackendInstance = audiusBackend({ ) } }, - identityServiceUrl: process.env.VITE_IDENTITY_SERVICE, - generalAdmissionUrl: process.env.VITE_GENERAL_ADMISSION, + identityServiceUrl: env.IDENTITY_SERVICE, + generalAdmissionUrl: env.GENERAL_ADMISSION, isElectron: isElectron(), isMobile: isMobile(), monitoringCallbacks, @@ -96,32 +96,31 @@ export const audiusBackendInstance = audiusBackend({ const event = new CustomEvent(LIBS_INITTED_EVENT) window.dispatchEvent(event) }, - recaptchaSiteKey: process.env.VITE_RECAPTCHA_SITE_KEY, + recaptchaSiteKey: env.RECAPTCHA_SITE_KEY, recordAnalytics: track, reportError: reportToSentry, - registryAddress: process.env.VITE_REGISTRY_ADDRESS, - entityManagerAddress: process.env.VITE_ENTITY_MANAGER_ADDRESS, + registryAddress: env.REGISTRY_ADDRESS, + entityManagerAddress: env.ENTITY_MANAGER_ADDRESS, remoteConfigInstance, setLocalStorageItem: async (key, value) => window.localStorage.setItem(key, value), solanaConfig: { - claimableTokenPda: process.env.VITE_CLAIMABLE_TOKEN_PDA, - claimableTokenProgramAddress: - process.env.VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS, - rewardsManagerProgramId: process.env.VITE_REWARDS_MANAGER_PROGRAM_ID, - rewardsManagerProgramPda: process.env.VITE_REWARDS_MANAGER_PROGRAM_PDA, - rewardsManagerTokenPda: process.env.VITE_REWARDS_MANAGER_TOKEN_PDA, - paymentRouterProgramId: process.env.VITE_PAYMENT_ROUTER_PROGRAM_ID, - solanaClusterEndpoint: process.env.VITE_SOLANA_CLUSTER_ENDPOINT, - solanaFeePayerAddress: process.env.VITE_SOLANA_FEE_PAYER_ADDRESS, - solanaTokenAddress: process.env.VITE_SOLANA_TOKEN_PROGRAM_ADDRESS, - waudioMintAddress: process.env.VITE_WAUDIO_MINT_ADDRESS, - usdcMintAddress: process.env.VITE_USDC_MINT_ADDRESS, - wormholeAddress: process.env.VITE_WORMHOLE_ADDRESS + claimableTokenPda: env.CLAIMABLE_TOKEN_PDA, + claimableTokenProgramAddress: env.CLAIMABLE_TOKEN_PROGRAM_ADDRESS, + rewardsManagerProgramId: env.REWARDS_MANAGER_PROGRAM_ID, + rewardsManagerProgramPda: env.REWARDS_MANAGER_PROGRAM_PDA, + rewardsManagerTokenPda: env.REWARDS_MANAGER_TOKEN_PDA, + paymentRouterProgramId: env.PAYMENT_ROUTER_PROGRAM_ID, + solanaClusterEndpoint: env.SOLANA_CLUSTER_ENDPOINT, + solanaFeePayerAddress: env.SOLANA_FEE_PAYER_ADDRESS, + solanaTokenAddress: env.SOLANA_TOKEN_PROGRAM_ADDRESS, + waudioMintAddress: env.WAUDIO_MINT_ADDRESS, + usdcMintAddress: env.USDC_MINT_ADDRESS, + wormholeAddress: env.WORMHOLE_ADDRESS ?? undefined }, - userNodeUrl: process.env.VITE_USER_NODE, - web3NetworkId: process.env.VITE_WEB3_NETWORK_ID, - web3ProviderUrls: (process.env.VITE_WEB3_PROVIDER_URL || '').split(','), + userNodeUrl: env.USER_NODE, + web3NetworkId: env.WEB3_NETWORK_ID, + web3ProviderUrls: (env.WEB3_PROVIDER_URL || '').split(','), waitForLibsInit, waitForWeb3: async () => { if (!window.web3Loaded) { @@ -137,10 +136,10 @@ export const audiusBackendInstance = audiusBackend({ withEagerOption, wormholeConfig: { - ethBridgeAddress: process.env.VITE_ETH_BRIDGE_ADDRESS, - ethTokenBridgeAddress: process.env.VITE_ETH_TOKEN_BRIDGE_ADDRESS, - solBridgeAddress: process.env.VITE_SOL_BRIDGE_ADDRESS, - solTokenBridgeAddress: process.env.VITE_SOL_TOKEN_BRIDGE_ADDRESS, - wormholeRpcHosts: process.env.VITE_WORMHOLE_RPC_HOSTS + ethBridgeAddress: env.ETH_BRIDGE_ADDRESS ?? undefined, + ethTokenBridgeAddress: env.ETH_TOKEN_BRIDGE_ADDRESS ?? undefined, + solBridgeAddress: env.SOL_BRIDGE_ADDRESS ?? undefined, + solTokenBridgeAddress: env.SOL_TOKEN_BRIDGE_ADDRESS ?? undefined, + wormholeRpcHosts: env.WORMHOLE_RPC_HOSTS ?? undefined } }) diff --git a/packages/web/src/services/audius-sdk/solana.ts b/packages/web/src/services/audius-sdk/solana.ts index f4ce536bf82..b631decbd94 100644 --- a/packages/web/src/services/audius-sdk/solana.ts +++ b/packages/web/src/services/audius-sdk/solana.ts @@ -1,26 +1,26 @@ import { Solana } from '@audius/sdk' import { PublicKey } from '@solana/web3.js' +import { env } from 'services/env' + export const solanaService = new Solana({ middleware: [ { pre: async (context) => { - const endpoint = process.env.VITE_SOLANA_RELAY_ENDPOINT + const endpoint = env.SOLANA_RELAY_ENDPOINT const url = `${endpoint}${context.url}` return { url, init: context.init } } } ], - rpcEndpoint: process.env.VITE_SOLANA_CLUSTER_ENDPOINT, + rpcEndpoint: env.SOLANA_CLUSTER_ENDPOINT, mints: { - wAUDIO: new PublicKey(process.env.VITE_WAUDIO_MINT_ADDRESS!), - USDC: new PublicKey(process.env.VITE_USDC_MINT_ADDRESS!) + wAUDIO: new PublicKey(env.WAUDIO_MINT_ADDRESS!), + USDC: new PublicKey(env.USDC_MINT_ADDRESS!) }, programIds: { - claimableTokens: new PublicKey( - process.env.VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS! - ), - rewardManager: new PublicKey(process.env.VITE_REWARDS_MANAGER_PROGRAM_ID!), - paymentRouter: new PublicKey(process.env.VITE_PAYMENT_ROUTER_PROGRAM_ID!) + claimableTokens: new PublicKey(env.CLAIMABLE_TOKEN_PROGRAM_ADDRESS!), + rewardManager: new PublicKey(env.REWARDS_MANAGER_PROGRAM_ID!), + paymentRouter: new PublicKey(env.PAYMENT_ROUTER_PROGRAM_ID!) } }) diff --git a/packages/web/src/services/download-app/DownloadApp.ts b/packages/web/src/services/download-app/DownloadApp.ts index 8b3a8b0a4f8..96525aab111 100644 --- a/packages/web/src/services/download-app/DownloadApp.ts +++ b/packages/web/src/services/download-app/DownloadApp.ts @@ -1,6 +1,8 @@ import { OS } from '@audius/common' -const ENVIRONMENT = process.env.VITE_ENVIRONMENT +import { env } from 'services/env' + +const ENVIRONMENT = env.ENVIRONMENT let APP_DOWNLOAD_URL: string switch (ENVIRONMENT) { diff --git a/packages/web/src/services/env.ts b/packages/web/src/services/env.ts deleted file mode 100644 index e3fd7d91f3d..00000000000 --- a/packages/web/src/services/env.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Environment } from '@audius/common' - -export const env = { - AAO_ENDPOINT: process.env.VITE_AAO_ENDPOINT, - EAGER_DISCOVERY_NODES: process.env.VITE_EAGER_DISCOVERY_NODES, - EXPLORE_CONTENT_URL: process.env.VITE_EXPLORE_CONTENT_URL, - ENVIRONMENT: process.env.VITE_ENVIRONMENT as Environment, - ORACLE_ETH_ADDRESSES: process.env.VITE_ORACLE_ETH_ADDRESSES, - SUGGESTED_FOLLOW_HANDLES: process.env.VITE_SUGGESTED_FOLLOW_HANDLES as string, - GENERAL_ADMISSION: process.env.VITE_GENERAL_ADMISSION, - IDENTITY_SERVICE: process.env.VITE_IDENTITY_SERVICE, - PUBLIC_HOSTNAME: process.env.VITE_PUBLIC_HOSTNAME -} diff --git a/packages/web/src/services/env/env.dev.ts b/packages/web/src/services/env/env.dev.ts new file mode 100644 index 00000000000..c699d2ae143 --- /dev/null +++ b/packages/web/src/services/env/env.dev.ts @@ -0,0 +1,83 @@ +import { Env } from '@audius/common' + +export const env: Env = { + AAO_ENDPOINT: 'http://audius-protocol-anti-abuse-oracle-1', + AMPLITUDE_API_KEY: null, + AMPLITUDE_PROXY: null, + AMPLITUDE_WRITE_KEY: null, + AUDIUS_URL: 'https://staging.audius.co', + BITSKI_CALLBACK_URL: 'https://staging.audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '7a543ec2-b55f-45d6-a5d4-0448c5a23485', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: null, + CLAIMABLE_TOKEN_PDA: '7vKR1WSmyHvBmCvKPZBiN66PHZqYQbXw51SZdwtVd9Dt', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + 'testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'audius', + COINFLOW_PARTNER_ID: 'AUDIUS', + COGNITO_KEY: 'sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b', + COGNITO_TEMPLATE_ID: 'flwtmp_7ZUYaBUFLeNhJw', + EAGER_DISCOVERY_NODES: 'http://audius-protocol-discovery-provider-1', + ENTITY_MANAGER_ADDRESS: '0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B', + ENVIRONMENT: 'development', + ETH_BRIDGE_ADDRESS: null, + ETH_NETWORK_ID: '1337', + ETH_OWNER_WALLET: '0x855FA758c77D68a04990E992aA4dcdeF899F654A', + ETH_PROVIDER_URL: 'http://audius-protocol-eth-ganache-1', + ETH_REGISTRY_ADDRESS: '0xABbfF712977dB51f9f212B85e8A4904c818C2b63', + ETH_TOKEN_ADDRESS: '0xdcB2fC9469808630DD0744b0adf97C0003fC29B2', + ETH_TOKEN_BRIDGE_ADDRESS: null, + EXPLORE_CONTENT_URL: + 'https://download.staging.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: null, + FINGERPRINT_ENDPOINT: null, + FINGERPRINT_PUBLIC_API_KEY: null, + GA_HOSTNAME: 'staging.audius.co', + GA_MEASUREMENT_ID: 'G-XXXXX', + GENERAL_ADMISSION: 'http://audius-protocol-general-admission-1', + HCAPTCHA_BASE_URL: 'https://staging.audius.co', + HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea', + IDENTITY_SERVICE: 'http://audius-protocol-identity-service-1', + INSTAGRAM_APP_ID: '2875320099414320', + INSTAGRAM_REDIRECT_URL: 'http://localhost:3000', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://rinkeby-api.opensea.io/api/v1', + OPTIMIZELY_KEY: 'MX4fYBgANQetvmBXGpuxzF', + ORACLE_ETH_ADDRESSES: + '0xF0D5BC18421fa04D0a2A2ef540ba5A9f04014BE3,0x325A621DeA613BCFb5B1A69a7aCED0ea4AfBD73A,0x3fD652C93dFA333979ad762Cf581Df89BaBa6795', + PAYMENT_ROUTER_PROGRAM_ID: 'apaySbqV1XAmuiGszeN4NyWrXkkMrnuJVoNhzmS1AMa', + PUBLIC_HOSTNAME: 'staging.audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: process.env.VITE_BASENAME || '', + REACHABILITY_URL: 'https://staging.audius.co/204', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0xCfEB869F69431e42cdB54A4F4f105C19C080A601', + REWARDS_MANAGER_PROGRAM_ID: 'testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb', + REWARDS_MANAGER_PROGRAM_PDA: 'DJPzVothq58SmkpRb1ATn5ddN2Rpv1j2TcGvM3XsHf1c', + REWARDS_MANAGER_TOKEN_PDA: 'FRk4j95RG2kSk3BHXBPVgKszFc2rLQ8K6RS83k3dmzvQ', + SAFARI_WEB_PUSH_ID: 'web.co.audius.staging', + SCHEME: 'audius-staging', + SENTRY_DSN: 'https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611', + SOL_BRIDGE_ADDRESS: null, + SOL_TOKEN_BRIDGE_ADDRESS: null, + SOLANA_CLUSTER_ENDPOINT: 'http://audius-protocol-solana-test-validator-1', + SOLANA_FEE_PAYER_ADDRESS: 'E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h', + SOLANA_RELAY_ENDPOINT: 'http://audius-protocol-discovery-provider-1', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'devnet', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.staging.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: 'awlrj83t4nx6qc5a', + TRPC_ENDPOINT: 'http://localhost:2022/trpc', + USDC_MINT_ADDRESS: '26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y', + USER_NODE: 'http://audius-protocol-creator-node-1', + USE_HASH_ROUTING: false, + WAUDIO_MINT_ADDRESS: '37RCjhgV1qGV2Q54EHFScdxZ22ydRMdKMtVgod47fDP3', + WEB3_NETWORK_ID: '1337', + WEB3_PROVIDER_URL: 'http://audius-protocol-poa-ganache-1', + WORMHOLE_ADDRESS: null, + WORMHOLE_RPC_HOSTS: null +} diff --git a/packages/web/src/services/env/env.prod.ts b/packages/web/src/services/env/env.prod.ts new file mode 100644 index 00000000000..1d7d993e943 --- /dev/null +++ b/packages/web/src/services/env/env.prod.ts @@ -0,0 +1,86 @@ +import { Env } from '@audius/common' + +export const env: Env = { + AAO_ENDPOINT: 'https://antiabuseoracle.audius.co', + AMPLITUDE_API_KEY: '86760558b8bb1b3aae61656efd4ddacb', + AMPLITUDE_PROXY: 'gain.audius.co', + AMPLITUDE_WRITE_KEY: null, + AUDIUS_URL: 'https://audius.co', + BITSKI_CALLBACK_URL: 'https://audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '661ce11a-3e0f-4659-b365-795ad2111f42', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: + '0x683c19E621A0F107a291fdAB38f80179809d61B5', + CLAIMABLE_TOKEN_PDA: '5ZiE3vAkrdXBgyFL7KqG3RoEGBws4CjRcXVbABDLZTgx', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + 'Ewkv3JahEFRKkcJmpoKB7pXbnUHwjAyXiwEo4ZY2rezQ', + COGNITO_KEY: 'live_publishable_key_9afb0a1e2e32ba707a70e66c6d309500', + COGNITO_TEMPLATE_ID: 'flwtmp_eMMe8VQGrKvLCX', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'tikilabs', + COINFLOW_PARTNER_ID: 'AUDIUS', + EAGER_DISCOVERY_NODES: + 'https://discoveryprovider.audius.co,https://discoveryprovider2.audius.co,https://discoveryprovider3.audius.co', + ENTITY_MANAGER_ADDRESS: '0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64', + ENVIRONMENT: 'production', + ETH_BRIDGE_ADDRESS: '0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B', + ETH_NETWORK_ID: '1', + ETH_OWNER_WALLET: '0xC7310a03e930DD659E15305ed7e1F5Df0F0426C5', + ETH_PROVIDER_URL: 'https://eth.audius.co', + ETH_REGISTRY_ADDRESS: '0xd976d3b4f4e22a238c1A736b6612D22f17b6f64C', + ETH_TOKEN_ADDRESS: '0x18aAA7115705e8be94bfFEBDE57Af9BFc265B998', + ETH_TOKEN_BRIDGE_ADDRESS: '0x3ee18B2214AFF97000D974cf647E7C347E8fa585', + EXPLORE_CONTENT_URL: + 'https://download.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: + 'BDBRR9S_UczQBflfaFPQf1JuCIZhMk90G_QnRI9wWuoObt7Ck6sRCxPDJfB_mJY3p55WdAO4C4xVJTAMoiv6JJQ', + FINGERPRINT_ENDPOINT: 'https://fp.audius.co', + FINGERPRINT_PUBLIC_API_KEY: 'MNtDQ4NCsNSP7YOkOiQT', + GA_HOSTNAME: 'audius.co', + GA_MEASUREMENT_ID: 'G-V6N1ZTVGS5', + GENERAL_ADMISSION: 'https://general-admission.audius.co', + HCAPTCHA_BASE_URL: 'https://audius.co', + HCAPTCHA_SITE_KEY: 'b250803e-dcba-428c-bc87-8acf559aacb9', + IDENTITY_SERVICE: 'https://identityservice.audius.co', + INSTAGRAM_APP_ID: '189700309435573', + INSTAGRAM_REDIRECT_URL: 'https://audius.co/', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://collectibles.audius.co/api/v1', + OPTIMIZELY_KEY: 'DAJbGEJBC21dzFRPv8snxs', + ORACLE_ETH_ADDRESSES: '0x9811BA3eAB1F2Cd9A2dFeDB19e8c2a69729DC8b6', + PAYMENT_ROUTER_PROGRAM_ID: 'paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa', + PUBLIC_HOSTNAME: 'audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: process.env.VITE_BASENAME || '', + REACHABILITY_URL: 'https://audius.co/204', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0xC611C82150b56E6e4Ec5973AcAbA8835Dd0d75A2', + REWARDS_MANAGER_PROGRAM_ID: 'DDZDcYdQFEMwcu2Mwo75yGFjJ1mUQyyXLWzhZLEVFcei', + REWARDS_MANAGER_PROGRAM_PDA: '71hWFVYokLaN1PNYzTAWi13EfJ7Xt9VbSWUKsXUT8mxE', + REWARDS_MANAGER_TOKEN_PDA: '3V9opXNpHmPPymKeq7CYD8wWMH8wzFXmqEkNdzfsZhYq', + SAFARI_WEB_PUSH_ID: 'web.co.audius', + SCHEME: 'audius', + SENTRY_DSN: 'https://e26d2b01488f4b538ea235de6466c40a@s.audius.co/1457231', + SOL_BRIDGE_ADDRESS: 'worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth', + SOL_TOKEN_BRIDGE_ADDRESS: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb', + SOLANA_CLUSTER_ENDPOINT: 'https://audius-fe.rpcpool.com', + SOLANA_FEE_PAYER_ADDRESS: 'pqx3fvvh6b2eZBfLhTtQ5KxzU3CginmgGTmDCjk8TPP', + SOLANA_RELAY_ENDPOINT: 'http://discoveryprovider.audius.co', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'mainnet-beta', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_live_51LPsGuCJOWtpH6AEKshlCs3L8QhAfevNvhev8K9a0u92O5ku83KRjLIqCdxgf3NhitdtmMGlw0Wjf33NjZJjZUBz006A3IoSiQ', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: 'awa9re2w7ec3xrn6', + TRPC_ENDPOINT: 'https://discoveryprovider3.audius.co/trpc/trpc', + USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', + USE_HASH_ROUTING: false, + USER_NODE: 'https://usermetadata.audius.co', + WAUDIO_MINT_ADDRESS: '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM', + WEB3_NETWORK_ID: '31524', + WEB3_PROVIDER_URL: 'https://poa-gateway.audius.co', + WORMHOLE_ADDRESS: '0x6E7a1F7339bbB62b23D44797b63e4258d283E095', + WORMHOLE_RPC_HOSTS: + 'https://wormhole-v2-mainnet-api.certus.one,https://wormhole.inotel.ro,https://wormhole-v2-mainnet-api.mcf.rocks,https://wormhole-v2-mainnet-api.chainlayer.network,https://wormhole-v2-mainnet-api.staking.fund,https://wormhole-v2-mainnet-api.chainlayer.network' +} diff --git a/packages/web/src/services/env/env.stage.ts b/packages/web/src/services/env/env.stage.ts new file mode 100644 index 00000000000..0b45d6f5c77 --- /dev/null +++ b/packages/web/src/services/env/env.stage.ts @@ -0,0 +1,85 @@ +import { Env } from '@audius/common' + +export const env: Env = { + AAO_ENDPOINT: 'https://antiabuseoracle.staging.audius.co', + AMPLITUDE_API_KEY: '72a58ce4ad1f9bafcba0b92bedb6c33d', + AMPLITUDE_PROXY: 'gain.audius.co', + AMPLITUDE_WRITE_KEY: null, + AUDIUS_URL: 'https://staging.audius.co', + BITSKI_CALLBACK_URL: 'https://staging.audius.co/bitski-callback.html', + BITSKI_CLIENT_ID: '7a543ec2-b55f-45d6-a5d4-0448c5a23485', + CACHE_PRUNE_MIN: '250', + CLAIM_DISTRIBUTION_CONTRACT_ADDRESS: + '0x74b89B916c97d50557E8F944F32662fE52Ce378d', + CLAIMABLE_TOKEN_PDA: 'Aw5AjygeMf9Nvg61BXvFSAzkqxcLqL8koepb14kvfc3W', + CLAIMABLE_TOKEN_PROGRAM_ADDRESS: + '2sjQNmUfkV6yKKi4dPR8gWRgtyma5aiymE3aXL2RAZww', + COGNITO_KEY: 'sandbox_publishable_key_e61e1acfe63bd1760827b68d4f00245b', + COGNITO_TEMPLATE_ID: 'flwtmp_7ZUYaBUFLeNhJw', + COINFLOW_APP_ID: '9JBW2RHC7JNJN8ZQ', + COINFLOW_MERCHANT_ID: 'audius', + COINFLOW_PARTNER_ID: 'AUDIUS', + EAGER_DISCOVERY_NODES: + 'https://discoveryprovider.staging.audius.co,https://discoveryprovider2.staging.audius.co,https://discoveryprovider3.staging.audius.co', + ENTITY_MANAGER_ADDRESS: '0x1Cd8a543596D499B9b6E7a6eC15ECd2B7857Fd64', + ENVIRONMENT: 'staging', + ETH_BRIDGE_ADDRESS: null, + ETH_NETWORK_ID: '5', + ETH_OWNER_WALLET: '', + ETH_PROVIDER_URL: 'https://eth.staging.audius.co', + ETH_REGISTRY_ADDRESS: '0xF27A9c44d7d5DDdA29bC1eeaD94718EeAC1775e3', + ETH_TOKEN_ADDRESS: '0x5375BE4c52fA29b26077B0F15ee5254D779676A6', + ETH_TOKEN_BRIDGE_ADDRESS: null, + EXPLORE_CONTENT_URL: + 'https://download.staging.audius.co/static-resources/explore-content.json', + FCM_PUSH_PUBLIC_KEY: + 'BIQQAP1Cb5LvBTkUknmRxCiQ-lHD1GjjsLFX4fo7c70FGHTSpN4iTNePCck7fCk9XBGIfwTxoDbNQO1vRiYSUFA', + FINGERPRINT_ENDPOINT: 'https://fp.staging.audius.co', + FINGERPRINT_PUBLIC_API_KEY: 'Rz2A3Y5YGSg9K80VgKPi', + GA_HOSTNAME: 'staging.audius.co', + GA_MEASUREMENT_ID: 'G-CH6BY2X2WL', + GENERAL_ADMISSION: 'https://general-admission.staging.audius.co', + HCAPTCHA_BASE_URL: 'https://staging.audius.co', + HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea', + IDENTITY_SERVICE: 'https://identityservice.staging.audius.co', + INSTAGRAM_APP_ID: '2875320099414320', + INSTAGRAM_REDIRECT_URL: 'https://staging.audius.co/', + METADATA_PROGRAM_ID: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', + OPENSEA_API_URL: 'https://rinkeby-api.opensea.io/api/v1', + OPTIMIZELY_KEY: 'MX4fYBgANQetvmBXGpuxzF', + ORACLE_ETH_ADDRESSES: '0x00b6462e955dA5841b6D9e1E2529B830F00f31Bf', + PAYMENT_ROUTER_PROGRAM_ID: 'sp38CXGL9FoWPp9Avo4fevewEX4UqNkTSTFUPpQFRry', + PUBLIC_HOSTNAME: 'staging.audius.co', + PUBLIC_PROTOCOL: 'https:', + BASENAME: process.env.VITE_BASENAME || '', + REACHABILITY_URL: 'https://staging.audius.co/204', + RECAPTCHA_SITE_KEY: '6LfVR-0ZAAAAADFcqNM1P1IafKwQwN0E_l-gxQ9q', + REGISTRY_ADDRESS: '0x793373aBF96583d5eb71a15d86fFE732CD04D452', + REWARDS_MANAGER_PROGRAM_ID: 'CDpzvz7DfgbF95jSSCHLX3ERkugyfgn9Fw8ypNZ1hfXp', + REWARDS_MANAGER_PROGRAM_PDA: 'GaiG9LDYHfZGqeNaoGRzFEnLiwUT7WiC6sA6FDJX9ZPq', + REWARDS_MANAGER_TOKEN_PDA: 'HJQj8P47BdA7ugjQEn45LaESYrxhiZDygmukt8iumFZJ', + SAFARI_WEB_PUSH_ID: 'web.co.audius.staging', + SCHEME: 'audius-staging', + SENTRY_DSN: 'https://4b15a7a2f2e2459997408b39a0c4942c@s.audius.co/1851611', + SOL_BRIDGE_ADDRESS: null, + SOL_TOKEN_BRIDGE_ADDRESS: null, + SOLANA_CLUSTER_ENDPOINT: 'https://audius-fe.rpcpool.com', + SOLANA_FEE_PAYER_ADDRESS: 'E3CfijtAJwBSHfwFEViAUd3xp7c8TBxwC1eXn1Fgxp8h', + SOLANA_RELAY_ENDPOINT: 'https://discoveryprovider.staging.audius.co', + SOLANA_TOKEN_PROGRAM_ADDRESS: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + SOLANA_WEB3_CLUSTER: 'mainnet-beta', + STRIPE_CLIENT_PUBLISHABLE_KEY: + 'pk_test_51LPsGuCJOWtpH6AEZT3Wf2U2xmLZQrEV56yha7HEVTEyhYYVrWCdknml3t4gkSe9Nagd1o9Royy8zL3XEAmRzeHS00xAKTfgpi', + SUGGESTED_FOLLOW_HANDLES: + 'https://download.staging.audius.co/static-resources/signup-follows.json', + TIKTOK_APP_ID: 'awlrj83t4nx6qc5a', + TRPC_ENDPOINT: 'https://discoveryprovider3.staging.audius.co/trpc/trpc', + USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', + USE_HASH_ROUTING: false, + USER_NODE: 'https://usermetadata.staging.audius.co', + WAUDIO_MINT_ADDRESS: 'BELGiMZQ34SDE6x2FUaML2UHDAgBLS64xvhXjX5tBBZo', + WEB3_NETWORK_ID: '1056801', + WEB3_PROVIDER_URL: 'https://poa-gateway.staging.audius.co', + WORMHOLE_ADDRESS: '0xf6f45e4d836da1d4ecd43bb1074620bfb0b7e0d7', + WORMHOLE_RPC_HOSTS: null +} diff --git a/packages/web/src/services/env/index.ts b/packages/web/src/services/env/index.ts new file mode 100644 index 00000000000..74b19ac19b6 --- /dev/null +++ b/packages/web/src/services/env/index.ts @@ -0,0 +1,26 @@ +import { Environment } from '@audius/common' +import type { Env } from '@audius/common' + +import { env as envDev } from './env.dev' +import { env as envProd } from './env.prod' +import { env as envStage } from './env.stage' + +const environment = process.env.VITE_ENVIRONMENT as Environment + +let env: Env + +switch (environment) { + case 'development': + env = envDev + break + case 'production': + env = envProd + break + case 'staging': + env = envStage + break + default: + throw new Error(`Unknown environment: ${environment}`) +} + +export { env } diff --git a/packages/web/src/services/fingerprint.ts b/packages/web/src/services/fingerprint.ts index f2a3c4cfc3c..e6ca6d8a194 100644 --- a/packages/web/src/services/fingerprint.ts +++ b/packages/web/src/services/fingerprint.ts @@ -1,9 +1,11 @@ import { FingerprintClient } from '@audius/common' import FingerprintJS, { Agent } from '@fingerprintjs/fingerprintjs-pro' -const apiKey = process.env.VITE_FINGERPRINT_PUBLIC_API_KEY || '' -const endpoint = process.env.VITE_FINGERPRINT_ENDPOINT || '' -const identityService = process.env.VITE_IDENTITY_SERVICE || '' +import { env } from './env' + +const apiKey = env.FINGERPRINT_PUBLIC_API_KEY || '' +const endpoint = env.FINGERPRINT_ENDPOINT || '' +const identityService = env.IDENTITY_SERVICE || '' export const fingerprintClient = new FingerprintClient({ apiKey, diff --git a/packages/web/src/services/remote-config/remote-config-instance.ts b/packages/web/src/services/remote-config/remote-config-instance.ts index 347b814ae79..14125a64c99 100644 --- a/packages/web/src/services/remote-config/remote-config-instance.ts +++ b/packages/web/src/services/remote-config/remote-config-instance.ts @@ -1,7 +1,8 @@ -import { Environment, ErrorLevel, remoteConfig } from '@audius/common' +import { ErrorLevel, remoteConfig } from '@audius/common' import optimizely, { Config } from '@optimizely/optimizely-sdk' import { isEmpty } from 'lodash' +import { env } from 'services/env' import { reportToSentry } from 'store/errors/reportToSentry' import { isElectron } from 'utils/clientUtil' @@ -63,7 +64,7 @@ export const remoteConfigInstance = remoteConfig({ id.toString() ), setLogLevel: () => optimizely.setLogLevel('warn'), - environment: process.env.VITE_ENVIRONMENT as Environment + environment: env.ENVIRONMENT }) remoteConfigInstance.init() diff --git a/packages/web/src/services/sentry.ts b/packages/web/src/services/sentry.ts index 9a74ee72e8e..68be8abe23c 100644 --- a/packages/web/src/services/sentry.ts +++ b/packages/web/src/services/sentry.ts @@ -1,6 +1,8 @@ import { init } from '@sentry/browser' import { CaptureConsole } from '@sentry/integrations' +import { env } from './env' + const analyticsBlacklist = [ 'google-analytics', 'stats.g', @@ -14,7 +16,7 @@ const MAX_BREADCRUMBS = 300 export const initializeSentry = () => { init({ - dsn: process.env.VITE_SENTRY_DSN, + dsn: env.SENTRY_DSN, // Need to give Sentry a version so it can // associate stacktraces with sourcemaps diff --git a/packages/web/src/services/web3-modal/index.ts b/packages/web/src/services/web3-modal/index.ts index a883f2e7bbe..9192c54dd74 100644 --- a/packages/web/src/services/web3-modal/index.ts +++ b/packages/web/src/services/web3-modal/index.ts @@ -3,12 +3,13 @@ import type { IProviderOptions } from 'web3modal' import phantomIconPurpleSvg from 'assets/img/phantom-icon-purple.svg' import walletLinkSvg from 'assets/img/wallet-link.svg' +import { env } from 'services/env' -const CHAIN_ID = process.env.VITE_ETH_NETWORK_ID -const BITSKI_CLIENT_ID = process.env.VITE_BITSKI_CLIENT_ID -const BITSKI_CALLBACK_URL = process.env.VITE_BITSKI_CALLBACK_URL -const WEB3_NETWORK_ID = parseInt(process.env.VITE_ETH_NETWORK_ID || '') -const ETH_PROVIDER_URLS = (process.env.VITE_ETH_PROVIDER_URL || '').split(',') +const CHAIN_ID = env.ETH_NETWORK_ID +const BITSKI_CLIENT_ID = env.BITSKI_CLIENT_ID +const BITSKI_CALLBACK_URL = env.BITSKI_CALLBACK_URL +const WEB3_NETWORK_ID = parseInt(env.ETH_NETWORK_ID || '') +const ETH_PROVIDER_URLS = (env.ETH_PROVIDER_URL || '').split(',') type Config = { isBitSkiEnabled: boolean diff --git a/packages/web/src/store/analytics/sagas.ts b/packages/web/src/store/analytics/sagas.ts index 96432de2f4f..3462d12dc76 100644 --- a/packages/web/src/store/analytics/sagas.ts +++ b/packages/web/src/store/analytics/sagas.ts @@ -2,6 +2,8 @@ import { Name, getContext } from '@audius/common' import { LOCATION_CHANGE } from 'connected-react-router' import { take } from 'redux-saga/effects' +import { env } from 'services/env' + function* trackLocation() { const analytics = yield* getContext('analytics') while (true) { @@ -12,7 +14,7 @@ function* trackLocation() { } = yield take(LOCATION_CHANGE) if (pathname) { if ((window as any).gtag) { - ;(window as any).gtag('config', process.env.VITE_GA_MEASUREMENT_ID, { + ;(window as any).gtag('config', env.GA_MEASUREMENT_ID, { page_path: pathname }) } diff --git a/packages/web/src/store/reachability/sagas.ts b/packages/web/src/store/reachability/sagas.ts index 8988db8c8f5..f5816d14468 100644 --- a/packages/web/src/store/reachability/sagas.ts +++ b/packages/web/src/store/reachability/sagas.ts @@ -1,4 +1,8 @@ -import { reachabilityActions, reachabilitySelectors } from '@audius/common' +import { + reachabilityActions, + reachabilitySelectors, + getContext +} from '@audius/common' import { delay, race, put, all, take, select, call } from 'typed-redux-saga' import { isMobileWeb } from 'common/utils/isMobileWeb' @@ -6,8 +10,6 @@ import { isMobileWeb } from 'common/utils/isMobileWeb' const { getIsReachable } = reachabilitySelectors const { setUnreachable, setReachable } = reachabilityActions -const REACHABILITY_URL = process.env.VITE_REACHABILITY_URL - // Property values borrowed from // https://github.com/react-native-community/react-native-netinfo export const REACHABILITY_LONG_TIMEOUT = 10 * 1000 // 10s @@ -19,6 +21,7 @@ const isResponseValid = (response: Response | undefined) => response && response.ok function* ping() { + const { REACHABILITY_URL } = yield* getContext('env') // If there's no reachability url available, consider ourselves reachable if (!REACHABILITY_URL) { console.warn('No reachability url provided') diff --git a/packages/web/src/store/storeContext.ts b/packages/web/src/store/storeContext.ts index 8e2d73eeff9..186a22d6bcd 100644 --- a/packages/web/src/store/storeContext.ts +++ b/packages/web/src/store/storeContext.ts @@ -53,16 +53,16 @@ export const storeContext: CommonStoreContext = { getLineupSelectorForRoute, audioPlayer, solanaClient: new SolanaClient({ - solanaClusterEndpoint: process.env.VITE_SOLANA_CLUSTER_ENDPOINT, - metadataProgramId: process.env.VITE_METADATA_PROGRAM_ID + solanaClusterEndpoint: env.SOLANA_CLUSTER_ENDPOINT, + metadataProgramId: env.METADATA_PROGRAM_ID }), sentry: { setTag, configureScope }, reportToSentry, trackDownload, - instagramAppId: process.env.VITE_INSTAGRAM_APP_ID, - instagramRedirectUrl: process.env.VITE_INSTAGRAM_REDIRECT_URL, + instagramAppId: env.INSTAGRAM_APP_ID, + instagramRedirectUrl: env.INSTAGRAM_REDIRECT_URL, share, - openSeaClient: new OpenSeaClient(process.env.VITE_OPENSEA_API_URL as string), + openSeaClient: new OpenSeaClient(env.OPENSEA_API_URL as string), audiusSdk, imageUtils: { generatePlaylistArtwork diff --git a/packages/web/src/utils/browserNotifications.ts b/packages/web/src/utils/browserNotifications.ts index 7437a923ff3..cc8389e8ff7 100644 --- a/packages/web/src/utils/browserNotifications.ts +++ b/packages/web/src/utils/browserNotifications.ts @@ -1,5 +1,6 @@ import { AudiusBackend } from '@audius/common' +import { env } from 'services/env' import { isElectron } from 'utils/clientUtil' export enum Permission { @@ -35,10 +36,10 @@ declare global { * */ -const basename = process.env.VITE_PUBLIC_URL +const basename = env.BASENAME -const fcmWebPushPublicKey = process.env.VITE_FCM_PUSH_PUBLIC_KEY as string -const safariWebPushID = process.env.VITE_SAFARI_WEB_PUSH_ID +const fcmWebPushPublicKey = env.FCM_PUSH_PUBLIC_KEY +const safariWebPushID = env.SAFARI_WEB_PUSH_ID const applicationServerPublicKey = fcmWebPushPublicKey export const isPushManagerAvailable = !isElectron() && 'serviceWorker' in navigator && 'PushManager' in window @@ -66,7 +67,7 @@ function urlB64ToUint8Array(base64String: string) { // Subscribes the browser to the push api export const subscribePushManagerBrowser = async () => { try { - if (isPushManagerAvailable) { + if (isPushManagerAvailable && applicationServerPublicKey) { if (!isServiceWorkerRegistered()) { const isRegistered = await registerServiceWorker() if (!isRegistered) return null diff --git a/packages/web/src/utils/clipboardUtil.ts b/packages/web/src/utils/clipboardUtil.ts index 13e30498569..dba5109d5ac 100644 --- a/packages/web/src/utils/clipboardUtil.ts +++ b/packages/web/src/utils/clipboardUtil.ts @@ -1,5 +1,7 @@ -const PUBLIC_PROTOCOL = process.env.VITE_PUBLIC_PROTOCOL -const PUBLIC_HOSTNAME = process.env.VITE_PUBLIC_HOSTNAME +import { env } from 'services/env' + +const PUBLIC_PROTOCOL = env.PUBLIC_PROTOCOL +const PUBLIC_HOSTNAME = env.PUBLIC_HOSTNAME const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) diff --git a/packages/web/src/utils/gdpr.ts b/packages/web/src/utils/gdpr.ts index 6835027b554..c1d1182b5c2 100644 --- a/packages/web/src/utils/gdpr.ts +++ b/packages/web/src/utils/gdpr.ts @@ -1,6 +1,7 @@ import { Nullable } from '@audius/common' import { getLocation } from 'services/Location' +import { env } from 'services/env' import { localStorage } from 'services/local-storage' const DISMISSED_COOKIE_BANNER_KEY = 'dismissCookieBanner' @@ -26,7 +27,7 @@ export const getIsInEU = async () => { } export const shouldShowCookieBanner = async (): Promise => { - if (process.env.VITE_ENVIRONMENT === 'production') { + if (env.ENVIRONMENT === 'production') { const isDimissed = await localStorage.getItem(DISMISSED_COOKIE_BANNER_KEY) if (isDimissed) return false const isInEU = await getIsInEU() diff --git a/packages/web/src/utils/history.ts b/packages/web/src/utils/history.ts index 9918db44b30..4c5e7a9bb65 100644 --- a/packages/web/src/utils/history.ts +++ b/packages/web/src/utils/history.ts @@ -6,8 +6,10 @@ import { History } from 'history' -const USE_HASH_ROUTING = process.env.VITE_USE_HASH_ROUTING === 'true' -const basename = process.env.VITE_PUBLIC_URL +import { env } from 'services/env' + +const USE_HASH_ROUTING = env.USE_HASH_ROUTING +const basename = env.BASENAME let history: History if (USE_HASH_ROUTING) { diff --git a/packages/web/src/utils/logger.js b/packages/web/src/utils/logger.js index 064544fb530..f15a103c71b 100644 --- a/packages/web/src/utils/logger.js +++ b/packages/web/src/utils/logger.js @@ -1,9 +1,11 @@ +import { env } from 'services/env' + /* eslint-disable no-console */ const preserveLogs = window.localStorage && window.localStorage.getItem('preserve-logs') export const storeLogger = (store) => { - if (process.env.VITE_ENVIRONMENT === 'production' && !preserveLogs) { + if (env.ENVIRONMENT === 'production' && !preserveLogs) { console.log('%cStop!', 'color: red; font-size: 56px; font-weight: bold;') console.log( `%cThis is a browser feature intended for developers. If someone told you to copy-paste something here to enable a feature or "hack" someone's account, it is a scam and will give them access to your Audius account.`, diff --git a/packages/web/src/utils/redirect.js b/packages/web/src/utils/redirect.js index e2787e69ccc..97dc4cb226c 100644 --- a/packages/web/src/utils/redirect.js +++ b/packages/web/src/utils/redirect.js @@ -1,7 +1,8 @@ +import { env } from 'services/env' import { isElectron } from 'utils/clientUtil' -const ENV = process.env.VITE_ENVIRONMENT -// const SCHEME = process.env.VITE_SCHEME +const ENV = env.ENVIRONMENT +// const SCHEME = env.SCHEME // On startup, when this script is included, create a link to the // downloaded electron app (if available) and try redirecting to it. diff --git a/packages/web/src/utils/route.ts b/packages/web/src/utils/route.ts index 512532c1098..ab4fdf3e696 100644 --- a/packages/web/src/utils/route.ts +++ b/packages/web/src/utils/route.ts @@ -1,18 +1,24 @@ -import { ID, encodeUrlName, getHash } from '@audius/common' +import { Env, ID, encodeUrlName, getHash } from '@audius/common' import { push as pushRoute } from 'connected-react-router' import { Location as HistoryLocation } from 'history' import { matchPath } from 'react-router' -const USE_HASH_ROUTING = process.env.VITE_USE_HASH_ROUTING === 'true' +// TODO: Move routing to @audius/common with an injected env +// so that it can properly handle routing to the correct environment. +// These values are defaulted to the production context. +const env: Partial = { + BASENAME: '/', + USE_HASH_ROUTING: false, + PUBLIC_PROTOCOL: 'https:', + PUBLIC_HOSTNAME: 'audius.co' +} + +const USE_HASH_ROUTING = env.USE_HASH_ROUTING // Host/protocol. -export const BASE_URL = `${process.env.VITE_PUBLIC_PROTOCOL || 'https:'}//${ - process.env.VITE_PUBLIC_HOSTNAME || 'audius.co' -}` -export const BASE_GA_URL = `${process.env.VITE_PUBLIC_PROTOCOL || 'https:'}//${ - process.env.VITE_GA_HOSTNAME || 'audius.co' -}` -export const BASENAME = process.env.VITE_PUBLIC_URL +export const BASE_URL = `${env.PUBLIC_PROTOCOL}//${env.PUBLIC_HOSTNAME}` +export const BASE_GA_URL = `${env.PUBLIC_PROTOCOL}//${env.PUBLIC_HOSTNAME}` +export const BASENAME = env.BASENAME // External Routes export const PRIVACY_POLICY = '/legal/privacy-policy' diff --git a/packages/web/src/utils/trpcClientWeb.ts b/packages/web/src/utils/trpcClientWeb.ts index 0e8b173daff..8c76b89fee2 100644 --- a/packages/web/src/utils/trpcClientWeb.ts +++ b/packages/web/src/utils/trpcClientWeb.ts @@ -2,6 +2,8 @@ import type { AppRouter } from '@audius/trpc-server' import { httpBatchLink } from '@trpc/client' import { createTRPCReact } from '@trpc/react-query' +import { env } from 'services/env' + export const trpc = createTRPCReact() export function createAudiusTrpcClient(currentUserId: number | null) { @@ -25,13 +27,5 @@ export function createAudiusTrpcClient(currentUserId: number | null) { // since tRPC server is deployed manually atm. // in the future some tRPC middleware can set host to currently selected DN per request function getTrpcEndpoint() { - if (process.env.VITE_TRPC_ENDPOINT) return process.env.VITE_TRPC_ENDPOINT - - switch (process.env.VITE_ENVIRONMENT) { - case 'production': - return 'https://discoveryprovider3.audius.co/trpc/trpc' - case 'staging': - return 'https://discoveryprovider3.staging.audius.co/trpc/trpc' - } - return 'http://localhost:2022/trpc' + return env.TRPC_ENDPOINT } diff --git a/packages/web/vite.config.ts b/packages/web/vite.config.ts index 01ec56efd6f..8bd07cd78ec 100644 --- a/packages/web/vite.config.ts +++ b/packages/web/vite.config.ts @@ -8,6 +8,8 @@ import { defineConfig, loadEnv } from 'vite' import glslify from 'vite-plugin-glslify' import svgr from 'vite-plugin-svgr' +import { env as APP_ENV } from './src/services/env' + const fixAcceptHeader404 = () => ({ // Fix issue with vite dev server and `wait-on` // https://github.com/vitejs/vite/issues/9520 @@ -27,10 +29,10 @@ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), 'VITE_') const port = parseInt(env.VITE_PORT ?? '3000') const analyze = env.VITE_BUNDLE_ANALYZE === 'true' - env.VITE_PUBLIC_URL = env.VITE_PUBLIC_URL ?? '' + env.VITE_BASENAME = env.VITE_BASENAME ?? '' return { - base: env.VITE_PUBLIC_URL || '/', + base: env.VITE_BASENAME || '/', build: { outDir: 'build', sourcemap: true, @@ -79,6 +81,21 @@ export default defineConfig(({ mode }) => { } } }, + { + transformIndexHtml(html) { + // Replace HTML env vars with values from the system env + return html.replace(/%(\S+?)%/g, (text: string, key) => { + if (key in APP_ENV) { + const value = APP_ENV[key as keyof typeof APP_ENV] + if (value !== null) { + return value as string + } + } + console.warn(`Missing environment variable: ${key}`) + return text + }) + } + }, react({ jsxImportSource: '@emotion/react', babel: {