Skip to content

Commit

Permalink
feat: dynamically load supported RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhwu committed Nov 27, 2024
1 parent ec81bcf commit 6b91e15
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dotenv from 'dotenv';
import { STAGE } from '../lib/util/stage';
import { SERVICE_NAME } from './constants';
import { APIStack } from './stacks/api-stack';
import { ChainId, supportedChains } from '../lib/util/chains';

dotenv.config();

Expand Down Expand Up @@ -118,17 +119,26 @@ export class APIPipeline extends Stack {
'arn:aws:secretsmanager:us-east-2:644039819003:secret:prod/param-api/rpc-urls-HJyniu',
});

// Beta us-east-2
const jsonRpcProviders = {} as {[chainKey: string]: string};
supportedChains.forEach(
(chainId: ChainId) => {
const mapKey = `RPC_${chainId}`;
jsonRpcProviders[mapKey] = rpcUrls
.secretValueFromJson(mapKey)
.toString();
}
);

// Beta us-east-2
const betaUsEast2Stage = new APIStage(this, 'beta-us-east-2', {
env: { account: '801328487475', region: 'us-east-2' },
provisionedConcurrency: 2,
internalApiKey: internalApiKey.secretValue.toString(),
stage: STAGE.BETA,
envVars: {
...jsonRpcProviders,
RFQ_WEBHOOK_CONFIG: rfqWebhookConfig.secretValue.toString(),
ORDER_SERVICE_URL: urlSecrets.secretValueFromJson('GOUDA_SERVICE_BETA').toString(),
RPC_42161: rpcUrls.secretValueFromJson('RPC_42161').toString(),
FILL_LOG_SENDER_ACCOUNT: '321377678687',
ORDER_LOG_SENDER_ACCOUNT: '321377678687',
URA_ACCOUNT: '665191769009',
Expand All @@ -147,9 +157,9 @@ export class APIPipeline extends Stack {
internalApiKey: internalApiKey.secretValue.toString(),
chatbotSNSArn: 'arn:aws:sns:us-east-2:644039819003:SlackChatbotTopic',
envVars: {
...jsonRpcProviders,
RFQ_WEBHOOK_CONFIG: rfqWebhookConfig.secretValue.toString(),
ORDER_SERVICE_URL: urlSecrets.secretValueFromJson('GOUDA_SERVICE_PROD').toString(),
RPC_42161: rpcUrls.secretValueFromJson('RPC_42161').toString(),
FILL_LOG_SENDER_ACCOUNT: '316116520258',
ORDER_LOG_SENDER_ACCOUNT: '316116520258',
URA_ACCOUNT: '652077092967',
Expand Down Expand Up @@ -251,7 +261,13 @@ envVars['URA_ACCOUNT'] = process.env['URA_ACCOUNT'] || '';
envVars['BOT_ACCOUNT'] = process.env['BOT_ACCOUNT'] || '';
envVars['UNISWAP_API'] = process.env['UNISWAP_API'] || '';
envVars['ORDER_SERVICE_URL'] = process.env['ORDER_SERVICE_URL'] || '';
envVars['RPC_42161'] = process.env['RPC_42161'] || '';
const jsonRpcProviders = {} as {[chainKey: string]: string};
supportedChains.forEach(
(chainId: ChainId) => {
const mapKey = `RPC_${chainId}`;
jsonRpcProviders[mapKey] = process.env[mapKey] || '';
}
);

new APIStack(app, `${SERVICE_NAME}Stack`, {
env: {
Expand All @@ -263,7 +279,10 @@ new APIStack(app, `${SERVICE_NAME}Stack`, {
throttlingOverride: process.env.THROTTLE_PER_FIVE_MINS,
chatbotSNSArn: process.env.CHATBOT_SNS_ARN,
stage: STAGE.LOCAL,
envVars,
envVars: {
...envVars,
...jsonRpcProviders,
},
});

new APIPipeline(app, `${SERVICE_NAME}PipelineStack`, {
Expand Down

0 comments on commit 6b91e15

Please sign in to comment.