Skip to content

Commit

Permalink
feat: use env for blockchain network mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Dec 4, 2024
1 parent 07aa94e commit bb53cab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const envVarsSchema = Joi.object()
OCI_BACKEND_URL: Joi.string().required().description('Oci Backend url'),
TEMPORAL_URI: Joi.string().required().description('Temporal address'),
TEMPORAL_QUEUE_HEAVY: Joi.string().required().description('Queue for heavy workflows'),
BLOCKCHAIN_NETWORK_MODE: Joi.string().valid('mainnet', 'testnet').required(),
})
.unknown();

Expand Down Expand Up @@ -162,4 +163,5 @@ export default {
heavyQueue: envVars.TEMPORAL_QUEUE_HEAVY,
},
ociBackendURL: envVars.OCI_BACKEND_URL,
blockchainNetworkMode: envVars.BLOCKCHAIN_NETWORK_MODE,
};
2 changes: 2 additions & 0 deletions src/constants/chains.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const MAINNET_CHAIN_IDS = [42161]; //arbitrum
export const TESTNET_CHAIN_IDS = [84532]; // base sepolia
8 changes: 5 additions & 3 deletions src/services/nft.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import moduleService from './module.service';
import platformService from './platform.service';
import ociService from './oci.service';
import communityService from './community.service';
import { MAINNET_CHAIN_IDS, TESTNET_CHAIN_IDS } from '../constants/chains.constant';
import config from '../config';

const logger = parentLogger.child({ module: 'NftService' });

Expand Down Expand Up @@ -54,9 +56,9 @@ const getReputationScore = async (tokenId: string, address: string) => {

async function getProfiles(address: string) {
let profiles: Array<any> = [];
const supportedChainIds = [84532, 42161];
for (let i = 0; i < supportedChainIds.length; i++) {
const chainProfiles = await ociService.getProfiles(address, supportedChainIds[i]);
const supportedChainIds = config.blockchainNetworkMode === 'mainnet' ? MAINNET_CHAIN_IDS : TESTNET_CHAIN_IDS;
for (const chainId of supportedChainIds) {
const chainProfiles = await ociService.getProfiles(address, chainId);
profiles = profiles.concat(chainProfiles);
}
return profiles;
Expand Down

0 comments on commit bb53cab

Please sign in to comment.