Skip to content

Commit

Permalink
Merge pull request #150 from P4-Games/feature/externalize-push-env
Browse files Browse the repository at this point in the history
merge feature/externalize-push-env into develop
  • Loading branch information
dappsar authored Dec 28, 2024
2 parents 21757dc + 64c1987 commit c2c95e5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ARG NEXT_PUBLIC_USE_MOCK
ARG NEXT_PUBLIC_UI_URL
ARG NEXT_PUBLIC_ALLOWED_ORIGINS
ARG RECAPTCHA_API_KEY
ARG PUSH_NETWORK
ARG PUSH_ENVIRONMENT
ARG NEXT_PUBLIC_RECAPTCHA_SITE_KEY
ARG NEXT_PUBLIC_NFT_IMAGE_REPOSITORY
ARG NEXT_PUBLIC_NFT_MARKETPLACE_URL
Expand Down Expand Up @@ -58,6 +60,8 @@ ENV NEXT_PUBLIC_USE_MOCK $NEXT_PUBLIC_USE_MOCK
ENV NEXT_PUBLIC_UI_URL $NEXT_PUBLIC_UI_URL
ENV NEXT_PUBLIC_ALLOWED_ORIGINS $NEXT_PUBLIC_ALLOWED_ORIGINS
ENV RECAPTCHA_API_KEY $RECAPTCHA_API_KEY
ENV PUSH_NETWORK $PUSH_NETWORK
ENV PUSH_ENVIRONMENT $PUSH_ENVIRONMENT
ENV NEXT_PUBLIC_RECAPTCHA_SITE_KEY $NEXT_PUBLIC_RECAPTCHA_SITE_KEY
ENV NEXT_PUBLIC_NFT_IMAGE_REPOSITORY $NEXT_PUBLIC_NFT_IMAGE_REPOSITORY
ENV NEXT_PUBLIC_NFT_MARKETPLACE_URL $NEXT_PUBLIC_NFT_MARKETPLACE_URL
Expand Down
4 changes: 4 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ steps:
- NEXT_PUBLIC_UI_URL=${_NEXT_PUBLIC_UI_URL}
- NEXT_PUBLIC_ALLOWED_ORIGINS=${_NEXT_PUBLIC_ALLOWED_ORIGINS}
- RECAPTCHA_API_KEY=${_RECAPTCHA_API_KEY}
- PUSH_NETWORK=${_PUSH_NETWORK}
- PUSH_ENVIRONMENT=${_PUSH_ENVIRONMENT}
- NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${_NEXT_PUBLIC_RECAPTCHA_SITE_KEY}
- NEXT_PUBLIC_NFT_IMAGE_REPOSITORY=${_NEXT_PUBLIC_NFT_IMAGE_REPOSITORY}
- NEXT_PUBLIC_NFT_MARKETPLACE_URL=${_NEXT_PUBLIC_NFT_MARKETPLACE_URL}
Expand All @@ -52,6 +54,8 @@ steps:
'--build-arg', 'MONGODB_BOT=${_MONGODB_BOT}',
'--build-arg', 'DB_CHATTERPAY_NAME=${_DB_CHATTERPAY_NAME}',
'--build-arg', 'RECAPTCHA_API_KEY=${_RECAPTCHA_API_KEY}',
'--build-arg', 'PUSH_NETWORK=${_PUSH_NETWORK}',
'--build-arg', 'PUSH_ENVIRONMENT=${_PUSH_ENVIRONMENT}',
'--build-arg', 'NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${_NEXT_PUBLIC_RECAPTCHA_SITE_KEY}',
'--build-arg', 'NEXT_PUBLIC_NFT_IMAGE_REPOSITORY=${_NEXT_PUBLIC_NFT_IMAGE_REPOSITORY}',
'--build-arg', 'NEXT_PUBLIC_NFT_MARKETPLACE_URL=${_NEXT_PUBLIC_NFT_MARKETPLACE_URL}',
Expand Down
2 changes: 2 additions & 0 deletions example_env
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ API3_ENABLED=false
JWT_SECRET={some secret text}
NEXT_PUBLIC_FROM_ICP=true
RECAPTCHA_API_KEY={recaptcha api key}
PUSH_NETWORK= 11155111 | 421614 | 42161
PUSH_ENVIRONMENT= dev | staging | prod

# client-side
NEXT_PUBLIC_USE_MOCK=true
Expand Down
2 changes: 2 additions & 0 deletions scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ docker build \
--build-arg MONGODB_BOT="$MONGODB_BOT" \
--build-arg DB_CHATTERPAY_NAME="$DB_CHATTERPAY_NAME" \
--build-arg RECAPTCHA_API_KEY="$RECAPTCHA_API_KEY" \
--build-arg PUSH_NETWORK="$PUSH_NETWORK" \
--build-arg PUSH_ENVIRONMENT="$PUSH_ENVIRONMENT" \
--build-arg NEXT_PUBLIC_RECAPTCHA_SITE_KEY="$NEXT_PUBLIC_RECAPTCHA_SITE_KEY" \
--build-arg NEXT_PUBLIC_NFT_IMAGE_REPOSITORY="$NEXT_PUBLIC_NFT_IMAGE_REPOSITORY" \
--build-arg NEXT_PUBLIC_NFT_MARKETPLACE_URL="$NEXT_PUBLIC_NFT_MARKETPLACE_URL" \
Expand Down
10 changes: 3 additions & 7 deletions src/app/api/v1/wallet/[id]/notifications/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { NextResponse } from 'next/server'
import * as PushAPI from '@pushprotocol/restapi'
import { ENV } from '@pushprotocol/restapi/src/lib/constants'

import { APP_ENV } from 'src/config-global'
import { PUSH_NETWORK, PUSH_ENVIRONMENT } from 'src/config-global'

import { IErrorResponse } from 'src/types/api'

Expand Down Expand Up @@ -34,12 +33,9 @@ export async function GET(request: Request, { params }: { params: IParams }) {
}

try {
const pushEnv: ENV = APP_ENV === 'development' ? ENV.DEV : ENV.PROD
const network = APP_ENV === 'development' ? '421614' : '42161'

const notifications = await PushAPI.user.getFeeds({
user: `eip155:${network}:${params.id}`,
env: pushEnv
user: `eip155:${PUSH_NETWORK}:${params.id}`,
env: PUSH_ENVIRONMENT
})

return NextResponse.json(notifications)
Expand Down
4 changes: 4 additions & 0 deletions src/config-global.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ENV } from '@pushprotocol/uiweb'

import { Network } from './types/networks'
import { IBalance, IBalances } from './types/wallet'

Expand All @@ -17,6 +19,8 @@ export const JWT_SECRET = process.env.JWT_SECRET || 'some_secr3t'
export const API3_ENABLED = (process.env.API3_ENABLED || 'false') === 'true'
export const DB_CHATTERPAY_NAME = process.env.DB_CHATTERPAY_NAME || 'chatterpay_dev'
export const RECAPTCHA_API_KEY = process.env.RECAPTCHA_API_KEY || ''
export const PUSH_NETWORK: string = process.env.PUSH_NETWORK || '11155111'
export const PUSH_ENVIRONMENT: ENV = (process.env.PUSH_ENVIRONMENT as ENV) || ENV.DEV

// Vercel has a timeout of 10 seconds (only for free plan) in the APIs.
// The login has certain logic between ChatterPay and the backend of the Chatizalo,
Expand Down

0 comments on commit c2c95e5

Please sign in to comment.