diff --git a/.env.example b/.env.example index 5fcecb7..f925a0e 100644 --- a/.env.example +++ b/.env.example @@ -19,3 +19,4 @@ DATABASE_NAME= DATABASE_SCHEMA_NAME=arka DATABASE_SSL_ENABLED=false DATABASE_SSL_REJECT_UNAUTHORIZED=false +PRICE_UPDATE_CRON_EXP="0 0 * * *" diff --git a/backend/.env.example b/backend/.env.example index 9b1855a..4ee8d46 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -20,3 +20,5 @@ DATABASE_SSL_REJECT_UNAUTHORIZED="false" DATABASE_USER="" DATABASE_PASSWORD="" DATABASE_NAME="" + +PRICE_UPDATE_CRON_EXP="0 0 * * *" diff --git a/backend/package.json b/backend/package.json index 8373699..ce00744 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "1.4.0", + "version": "1.4.1", "description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software", "type": "module", "directories": { diff --git a/backend/src/constants/Pimlico.ts b/backend/src/constants/Pimlico.ts index a226ede..bf5624b 100644 --- a/backend/src/constants/Pimlico.ts +++ b/backend/src/constants/Pimlico.ts @@ -127,10 +127,12 @@ export const CustomDeployedPaymasters: Record> = "FRAX": "0xE0221Db5bF2F3C22d6639a749B764f52f5B05dfb" }, "114": { - "USDC": "0x8b067387ec0B922483Eadb771bc9290194685522" + "USDC": "0x8b067387ec0B922483Eadb771bc9290194685522", + "USDT": "0xED35f8fa422Ba95A52A000236F1EAFd7e4fA4D52" }, "14": { - "eUSDT": "0x6Bb048981E67f1a0aD41c0BD05635244d3ADaA2c" + "eUSDT": "0x6Bb048981E67f1a0aD41c0BD05635244d3ADaA2c", + "eUSDC": "0xA5589D278778Eaae346383dD710D7913d8A6a2aA" }, "5001": { "USDCT": "0x6Ea25cbb60360243E871dD935225A293a78704a8" @@ -176,6 +178,12 @@ export const PAYMASTER_ADDRESS: Record> = { 80001: { USDC: "0x000000000009B901DeC1aaB9389285965F49D387" }, + 114: { + USDT: "0xED35f8fa422Ba95A52A000236F1EAFd7e4fA4D52" + }, + 14: { + eUSDC: "0xA5589D278778Eaae346383dD710D7913d8A6a2aA" + } } /** diff --git a/backend/src/server.ts b/backend/src/server.ts index f532946..5255ff5 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -77,8 +77,6 @@ const initializeServer = async (): Promise => { server.log.info('registered sequelizePlugin...') const arkaConfigRepository = new ArkaConfigRepository(server.sequelize); - const configDatas = await arkaConfigRepository.findAll(); - const configData: ArkaConfig | null = configDatas.length > 0 ? configDatas[0] : null; await server.register(fastifyCron, { jobs: [ @@ -86,14 +84,41 @@ const initializeServer = async (): Promise => { // Only these two properties are required, // the rest is from the node-cron API: // https://github.com/kelektiv/node-cron#api - cronTime: configData?.cronTime ?? '0 0 * * *', // Default: Everyday at midnight UTC, + cronTime: process.env.PRICE_UPDATE_CRON_EXP ?? '0 0 * * *', // Default: Everyday at midnight UTC, name: 'PriceUpdate', // Note: the callbacks (onTick & onComplete) take the server // as an argument, as opposed to nothing in the node-cron API: onTick: async () => { + let configData: any if (process.env.CRON_PRIVATE_KEY) { - const paymastersAdrbase64 = configData?.deployedErc20Paymasters ?? '' + const unsafeMode = process.env.UNSAFE_MODE === "true" ? true : false; + if(!unsafeMode) { + const client = new SecretsManagerClient(); + const api_key = process.env.DEFAULT_API_KEY; + const prefixSecretId = "arka_"; + const AWSresponse = await client.send( + new GetSecretValueCommand({ + SecretId: prefixSecretId + api_key, + }) + ); + const secrets = JSON.parse(AWSresponse.SecretString ?? '{}'); + configData = { + coingeckoApiUrl: secrets["COINGECKO_API_URL"], + coingeckoIds: secrets["COINGECKO_IDS"], + customChainlinkDeployed: secrets["CUSTOM_CHAINLINK_DEPLOYED"], + deployedErc20Paymasters: secrets["DEPLOYED_ERC20_PAYMASTERS"], + pythMainnetChainIds: secrets["PYTH_MAINNET_CHAINIDS"], + pythMainnetUrl: secrets["PYTH_MAINNET_URL"], + pythTestnetChainIds: secrets["PYTH_TESTNET_CHAINIDS"], + pythTestnetUrl: secrets["PYTH_TESTNET_URL"] + } + client.destroy(); + } else { + const configDatas = await arkaConfigRepository.findAll(); + configData = configDatas.length > 0 ? configDatas[0] : null; + } + const paymastersAdrbase64 = configData?.deployedErc20Paymasters ?? ''; if (paymastersAdrbase64) { const buffer = Buffer.from(paymastersAdrbase64, 'base64'); const DEPLOYED_ERC20_PAYMASTERS = JSON.parse(buffer.toString());