Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use env for blockchain network mode #417

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading