diff --git a/cli/map-subscribers-to-participants.ts b/cli/map-subscribers-to-participants.ts index 172469f..cd3f772 100644 --- a/cli/map-subscribers-to-participants.ts +++ b/cli/map-subscribers-to-participants.ts @@ -41,18 +41,18 @@ async function processSubscribers(client: StargateClient, participants: any[], s // Map kyc_id to participant data const kycMap: Record = {}; participants.forEach((participant: any) => { - kycMap[participant.kyc_id] = participant; + kycMap[participant.kycId] = participant; }); const onboardedSubscribers: any[] = []; - subscribers.forEach(async (subscriber) => { + for (const subscriber of subscribers) { const hashedSubscriberId = hashSubscriberId(subscriber['subscriber_id']); const participant = kycMap[hashedSubscriberId]; if (!participant) { - return; + continue; } - const participantAddresss = participant['cosmos_address']; + const participantAddresss = participant['cosmosAddress']; // Fetch participant's Laconic pubkey const participantAccount = await client.getAccount(participantAddresss); @@ -61,13 +61,13 @@ async function processSubscribers(client: StargateClient, participants: any[], s // Skip participant if pubkey not found // (account may have funds but hasn't done any tx till now) if (!participantPubkey) { - return; + continue; } // Skip participant if an onboarding tx not found const onboardingTxs = await client.searchTx(`message.sender='${participantAddresss}' AND message.action='/cerc.onboarding.v1.MsgOnboardParticipant'`); if (onboardingTxs.length === 0) { - return; + continue; } const latestOnboardingTx = onboardingTxs.reduce((prev, current) => { @@ -81,15 +81,15 @@ async function processSubscribers(client: StargateClient, participants: any[], s 'premium?': subscriber['premium?'], created_at: subscriber['created_at'], cosmos_address: participantAddresss, - nitro_address: participant['nitro_address'], + nitro_address: participant['nitroAddress'], role: participant['role'], - hashed_subscriber_id: participant['kyc_id'], - laconic_pubkey: participantPubkey, + hashed_subscriber_id: participant['kycId'], + laconic_pubkey: participantPubkey.value, onboarding_height: latestOnboardingTx.height }; onboardedSubscribers.push(onboardedSubscriber); - }); + } const writer = csvWriter.createObjectCsvWriter({ path: path.resolve(outputPath),