UNPKG

@fairmint/canton-node-sdk

Version:
91 lines 3.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildAmuletDisclosedContracts = buildAmuletDisclosedContracts; exports.createContractInfo = createContractInfo; /** * Builds disclosed contracts array for Amulet operations * * @param params - Contract information for disclosure * @returns Array of disclosed contracts */ function buildAmuletDisclosedContracts(params) { const disclosedContracts = []; // Add AmuletRules contract (required) disclosedContracts.push({ contractId: params.amuletRules.contractId, templateId: params.amuletRules.templateId, createdEventBlob: params.amuletRules.createdEventBlob, synchronizerId: params.amuletRules.synchronizerId, }); // Add open mining round contract if provided if (params.openMiningRound) { disclosedContracts.push({ contractId: params.openMiningRound.contractId, templateId: params.openMiningRound.templateId, createdEventBlob: params.openMiningRound.createdEventBlob, synchronizerId: params.openMiningRound.synchronizerId, }); } // Add issuing mining rounds contracts if provided if (params.issuingMiningRounds) { for (const round of params.issuingMiningRounds) { disclosedContracts.push({ contractId: round.contractId, templateId: round.templateId, createdEventBlob: round.createdEventBlob, synchronizerId: round.synchronizerId, }); } } // Add featured app right contract if provided if (params.featuredAppRight) { disclosedContracts.push({ contractId: params.featuredAppRight.contractId, templateId: params.featuredAppRight.templateId, createdEventBlob: params.featuredAppRight.createdEventBlob, synchronizerId: params.featuredAppRight.synchronizerId, }); } // Add additional contracts if provided if (params.additionalContracts) { for (const contract of params.additionalContracts) { disclosedContracts.push({ contractId: contract.contractId, templateId: contract.templateId, createdEventBlob: contract.createdEventBlob, synchronizerId: contract.synchronizerId, }); } } return disclosedContracts; } /** * Helper function to create ContractInfo from API responses * * @param contractId - The contract ID * @param templateId - The template ID (optional) * @param createdEventBlob - The created event blob * @param synchronizerId - The synchronizer ID * @returns ContractInfo object */ function createContractInfo(contractId, createdEventBlob, synchronizerId, templateId) { if (!contractId || contractId.trim() === '') { throw new Error('Contract ID is required'); } if (!createdEventBlob || createdEventBlob.trim() === '') { throw new Error('Created event blob is required'); } if (!synchronizerId || synchronizerId.trim() === '') { throw new Error('Synchronizer ID is required'); } if (!templateId || templateId.trim() === '') { throw new Error('Template ID is required'); } return { contractId, templateId, createdEventBlob, synchronizerId, }; } //# sourceMappingURL=disclosed-contracts.js.map