Skip to content

Commit

Permalink
chore: enhanced JSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmain committed Apr 25, 2024
1 parent 26f0ddb commit d147d47
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/hardware-ledger/src/transformers/votingProcedures.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This function needs to correctly differentiate between different Voter types.
// Here, we assume that each Voter type has a 'type' property that can be used for mapping.
// This is a placeholder; you need to replace this with actual mapping logic based on your Voter types.

import {
CommitteeKeyHashVoter,
CommitteeScriptHashVoter,
Expand All @@ -17,10 +13,10 @@ import {
import { CoreVote, CoreVoter, VotingProcedures } from '@cardano-sdk/core/dist/cjs/Cardano';

/**
* Maps a CoreVoter to a Voter.
* Maps a CoreVoter to a Voter from the LedgerJS public types.
*
* @param coreVoter The CoreVoter object.
* @returns The corresponding Voter object.
* @param {CoreVoter} coreVoter - The voter object defined in Core types.
* @returns {Voter} Corresponding Voter object for use with LedgerJS.
*/
export const mapCoreVoterToVoter = (coreVoter: CoreVoter): Voter => {
switch (coreVoter.__typename) {
Expand Down Expand Up @@ -60,9 +56,10 @@ export const mapCoreVoterToVoter = (coreVoter: CoreVoter): Voter => {
};

/**
* Assuming this function exists to correctly convert integer or any format to VoteOption.
* Maps CoreVote to a LedgerJS VoteOption.
*
* @param vote Raw vote data that needs to be converted to VoteOption.
* @param {CoreVote} vote - The vote integer representing a voting decision.
* @returns {VoteOption} The corresponding LedgerJS VoteOption.
*/
const mapVoteOption = (vote: CoreVote): VoteOption => {
// Implement this based on how the raw data translates to VoteOption
Expand All @@ -78,6 +75,15 @@ const mapVoteOption = (vote: CoreVote): VoteOption => {
}
};

/**
* Maps voting procedures from Core to LedgerJS.
*
* Converts a list of Core voting procedures into a format compatible with LedgerJS. This includes converting voters,
* votes, and anchoring data.
*
* @param {VotingProcedures | undefined} votingProcedures - Array of voting procedures from Core.
* @returns {VoterVotes[] | null} Array of LedgerJS-compatible voting records or null if input is undefined.
*/
export const mapVotingProcedures = (votingProcedures: VotingProcedures | undefined): VoterVotes[] | null => {
if (!votingProcedures) {
return null;
Expand Down

0 comments on commit d147d47

Please sign in to comment.