import { Converter } from "@iota/util.js" ; import { SingleNodeClient } from "../clients/singleNodeClient" ; import type { IClient } from "../models/IClient" ; import { IIndexationPayload , INDEXATION_PAYLOAD_TYPE } from "../models/IIndexationPayload" ; import { TRANSACTION_PAYLOAD_TYPE } from "../models/ITransactionPayload" ; param client param messageId returns export async function retrieveData ( client , messageId ) { const localClient = typeof client === "string" ? new SingleNodeClient ( client ) : client ; const message = await localClient . message ( messageId ) ; if ( message ?. payload ) { let indexationPayload ; if ( message . payload . type === TRANSACTION_PAYLOAD_TYPE ) { indexationPayload = message . payload . essence . payload ; } else if ( message . payload . type === INDEXATION_PAYLOAD_TYPE ) { indexationPayload = message . payload ; } if ( indexationPayload ) { return { index : Converter . hexToBytes ( indexationPayload . index ) , data : indexationPayload . data ? Converter . hexToBytes ( indexationPayload . data ) : undefined } ; } } }