diff --git a/package.json b/package.json index 04ac6dc6..b4f99715 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,10 @@ "test:coverage": "jest --coverage --passWithNoTests", "test:declarations": "ts-node --project tsconfig.tests.json scripts/check-declarations.ts && tsc -p tsconfig.declaration-tests.json --noEmit && npm run -s test:exact-public-config", "test:exact-public-config": "tsc -p tsconfig.exact-public-config-tests.json --noEmit", - "test:exact-source": "tsc -p tsconfig.exact-source.json --noEmit", "test:integration": "npm run -s typecheck && jest -c jest.integration.config.js --passWithNoTests", "test:integration:ci": "npm run -s typecheck && jest -c jest.integration.config.js --runInBand", "test:watch": "jest --watch", - "typecheck": "tsc -p tsconfig.tests.json --noEmit && npm run -s test:exact-source" + "typecheck": "tsc -p tsconfig.tests.json --noEmit" }, "config": { "localnet_quickstart_ref": "5c90cf4d0eb934712fd8c269b56e6272b605ccad" diff --git a/src/functions/OpenCapTable/shared/conversionMechanisms.ts b/src/functions/OpenCapTable/shared/conversionMechanisms.ts index a143d47b..d28324ab 100644 --- a/src/functions/OpenCapTable/shared/conversionMechanisms.ts +++ b/src/functions/OpenCapTable/shared/conversionMechanisms.ts @@ -617,13 +617,8 @@ export function warrantMechanismToDaml(mechanism: WarrantConversionMechanism): D description: mechanism.description, discount: mechanism.discount, discount_percentage: - 'discount_percentage' in mechanism && mechanism.discount_percentage !== undefined - ? normalizeNumericString(mechanism.discount_percentage) - : null, - discount_amount: - 'discount_amount' in mechanism && mechanism.discount_amount - ? monetaryToDaml(mechanism.discount_amount) - : null, + mechanism.discount_percentage !== undefined ? normalizeNumericString(mechanism.discount_percentage) : null, + discount_amount: mechanism.discount_amount !== undefined ? monetaryToDaml(mechanism.discount_amount) : null, }, }; default: diff --git a/test/capTable/archiveFullCapTable.test.ts b/test/capTable/archiveFullCapTable.test.ts index 94f1bf34..8db31db0 100644 --- a/test/capTable/archiveFullCapTable.test.ts +++ b/test/capTable/archiveFullCapTable.test.ts @@ -42,14 +42,16 @@ function mockActiveContractsForCapTableState( responses: { current?: unknown[] } ): void { const current = responses.current ?? []; - mockClient.getActiveContracts.mockImplementation(async (req: { templateIds?: string[] }) => { - await Promise.resolve(); - const ids = req.templateIds; - if (isCurrentTemplateQuery(ids)) { - return current as never; + mockClient.getActiveContracts.mockImplementation( + async (req: Parameters[0]) => { + await Promise.resolve(); + const ids = req.templateIds; + if (isCurrentTemplateQuery(ids)) { + return current as never; + } + throw new Error(`Unexpected getActiveContracts templateIds in test: ${JSON.stringify(ids)}`); } - throw new Error(`Unexpected getActiveContracts templateIds in test: ${JSON.stringify(ids)}`); - }); + ); } interface TestIssuerData { diff --git a/test/capTable/getCapTableState.test.ts b/test/capTable/getCapTableState.test.ts index d3dae296..b990ebab 100644 --- a/test/capTable/getCapTableState.test.ts +++ b/test/capTable/getCapTableState.test.ts @@ -41,14 +41,16 @@ function mockActiveContractsForCapTableState( responses: { current?: unknown[] } ): void { const current = responses.current ?? []; - mockClient.getActiveContracts.mockImplementation(async (req: { templateIds?: string[] }) => { - await Promise.resolve(); - const ids = req.templateIds; - if (isCurrentTemplateQuery(ids)) { - return current as never; + mockClient.getActiveContracts.mockImplementation( + async (req: Parameters[0]) => { + await Promise.resolve(); + const ids = req.templateIds; + if (isCurrentTemplateQuery(ids)) { + return current as never; + } + throw new Error(`Unexpected getActiveContracts templateIds in test: ${JSON.stringify(ids)}`); } - throw new Error(`Unexpected getActiveContracts templateIds in test: ${JSON.stringify(ids)}`); - }); + ); } /** diff --git a/test/client/OcpClient.test.ts b/test/client/OcpClient.test.ts index c9455ab6..04b3484a 100644 --- a/test/client/OcpClient.test.ts +++ b/test/client/OcpClient.test.ts @@ -296,7 +296,7 @@ describe('OcpClient OpenCapTable.issuerAuthorization.authorize', () => { expect(mockedAuthorizeIssuer).toHaveBeenCalledTimes(1); }); - it('keeps client-level observability defaults when per-call fields are undefined', async () => { + it('keeps client-level observability defaults when per-call fields are omitted', async () => { const ledger = createLedgerJsonApiClient(config); const logger = { debug: jest.fn(), @@ -318,9 +318,6 @@ describe('OcpClient OpenCapTable.issuerAuthorization.authorize', () => { await ocp.OpenCapTable.issuerAuthorization.authorize({ issuer: 'issuer::party', - logger: undefined, - metrics: undefined, - defaultContext: undefined, context: { commandId: 'command-call' }, }); diff --git a/test/client/OcpContextManager.test.ts b/test/client/OcpContextManager.test.ts index 4f4a4445..89f66469 100644 --- a/test/client/OcpContextManager.test.ts +++ b/test/client/OcpContextManager.test.ts @@ -77,11 +77,9 @@ describe('OcpContextManager', () => { expect(contextManager.issuerParty).toBeNull(); }); - it('should not change values when undefined is passed', () => { + it('should not change omitted values', () => { contextManager.setIssuerParty('issuer::party-123'); - contextManager.setAll({ - issuerParty: undefined, - }); + contextManager.setAll({}); expect(contextManager.issuerParty).toBe('issuer::party-123'); }); diff --git a/test/integration/entities/acceptanceTypes.integration.test.ts b/test/integration/entities/acceptanceTypes.integration.test.ts index d27d132d..3eb2a0a3 100644 --- a/test/integration/entities/acceptanceTypes.integration.test.ts +++ b/test/integration/entities/acceptanceTypes.integration.test.ts @@ -33,6 +33,7 @@ import { setupStockSecurity, setupTestIssuer, setupWarrantSecurity, + withCapTableContractDetails, } from '../utils'; /** @@ -141,7 +142,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -189,7 +190,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -239,7 +240,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: convertibleSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -287,7 +288,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -336,7 +337,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const warrantSecurity = await setupWarrantSecurity(ctx.ocp, { issuerContractId: stockSecurity.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: warrantSecurity.capTableContractId }); @@ -353,7 +354,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const convertibleSecurity = await setupConvertibleSecurity(ctx.ocp, { issuerContractId: warrantSecurity.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: convertibleSecurity.capTableContractId }); @@ -370,7 +371,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const eqCompSecurity = await setupEquityCompensationSecurity(ctx.ocp, { issuerContractId: convertibleSecurity.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: eqCompSecurity.capTableContractId }); @@ -402,7 +403,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: finalCapTableDetails, + ...withCapTableContractDetails(finalCapTableDetails), actAs: [ctx.issuerParty], }); @@ -459,7 +460,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -512,7 +513,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { // Create the acceptance first const createBatch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), actAs: [ctx.issuerParty], }); @@ -594,7 +595,7 @@ createIntegrationTestSuite('Acceptance Type operations', (getContext) => { // Create the acceptance first const createBatch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), actAs: [ctx.issuerParty], }); diff --git a/test/integration/entities/stockClassAdjustments.integration.test.ts b/test/integration/entities/stockClassAdjustments.integration.test.ts index 92e1fab6..96854030 100644 --- a/test/integration/entities/stockClassAdjustments.integration.test.ts +++ b/test/integration/entities/stockClassAdjustments.integration.test.ts @@ -27,6 +27,7 @@ import { requireCreatedEventBlob, setupStockSecurity, setupTestIssuer, + withCapTableContractDetails, } from '../utils'; createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { @@ -178,7 +179,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const stockSecurity2 = await setupStockSecurity(ctx.ocp, { issuerContractId: stockSecurity1.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: stockSecurity2.capTableContractId }); @@ -194,7 +195,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const stockSecurity3 = await setupStockSecurity(ctx.ocp, { issuerContractId: stockSecurity2.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: stockSecurity3.capTableContractId }); @@ -212,7 +213,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity3.capTableContractId, - capTableContractDetails: finalCapTableDetails, + ...withCapTableContractDetails(finalCapTableDetails), actAs: [ctx.issuerParty], }); @@ -269,7 +270,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -325,7 +326,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const stockSecurity2 = await setupStockSecurity(ctx.ocp, { issuerContractId: stockSecurity1.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: stockSecurity2.capTableContractId }); @@ -341,7 +342,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const stockSecurity3 = await setupStockSecurity(ctx.ocp, { issuerContractId: stockSecurity2.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: stockSecurity3.capTableContractId }); @@ -356,7 +357,7 @@ createIntegrationTestSuite('Stock Class Adjustments', (getContext) => { const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity3.capTableContractId, - capTableContractDetails: finalCapTableDetails, + ...withCapTableContractDetails(finalCapTableDetails), actAs: [ctx.issuerParty], }); diff --git a/test/integration/entities/transferTypes.integration.test.ts b/test/integration/entities/transferTypes.integration.test.ts index b72a8d38..9381ddd7 100644 --- a/test/integration/entities/transferTypes.integration.test.ts +++ b/test/integration/entities/transferTypes.integration.test.ts @@ -34,6 +34,7 @@ import { setupStockSecurity, setupTestIssuer, setupWarrantSecurity, + withCapTableContractDetails, } from '../utils'; /** Extract a contract ID from a transaction tree response. */ @@ -107,7 +108,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => { const cmd = buildUpdateCapTableCommand( { capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), }, { creates: [{ type: 'stockTransfer', data: transferData }] } ); @@ -185,7 +186,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => { const cmd = buildUpdateCapTableCommand( { capTableContractId: convertibleSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), }, { creates: [{ type: 'convertibleTransfer', data: transferData }] } ); @@ -258,7 +259,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => { const cmd = buildUpdateCapTableCommand( { capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), }, { creates: [{ type: 'equityCompensationTransfer', data: transferData }] } ); @@ -330,7 +331,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => { const cmd = buildUpdateCapTableCommand( { capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), }, { creates: [{ type: 'warrantTransfer', data: transferData }] } ); diff --git a/test/integration/entities/valuationVesting.integration.test.ts b/test/integration/entities/valuationVesting.integration.test.ts index 5f0b028d..b52ea9ac 100644 --- a/test/integration/entities/valuationVesting.integration.test.ts +++ b/test/integration/entities/valuationVesting.integration.test.ts @@ -29,6 +29,7 @@ import { requireCreatedEventBlob, setupStockSecurity, setupTestIssuer, + withCapTableContractDetails, } from '../utils'; function extractContractIdString(cid: { value: unknown }): string { @@ -193,7 +194,7 @@ createIntegrationTestSuite('Valuation and Vesting types via batch API', (getCont const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -254,7 +255,7 @@ createIntegrationTestSuite('Valuation and Vesting types via batch API', (getCont const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -314,7 +315,7 @@ createIntegrationTestSuite('Valuation and Vesting types via batch API', (getCont const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -365,7 +366,7 @@ createIntegrationTestSuite('Valuation and Vesting types via batch API', (getCont const stockSecurity2 = await setupStockSecurity(ctx.ocp, { issuerContractId: stockSecurity1.capTableContractId, issuerParty: ctx.issuerParty, - capTableContractDetails: currentCapTableDetails, + ...withCapTableContractDetails(currentCapTableDetails), }); events = await ctx.ocp.ledger.getEventsByContractId({ contractId: stockSecurity2.capTableContractId }); @@ -380,7 +381,7 @@ createIntegrationTestSuite('Valuation and Vesting types via batch API', (getCont const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity2.capTableContractId, - capTableContractDetails: finalCapTableDetails, + ...withCapTableContractDetails(finalCapTableDetails), actAs: [ctx.issuerParty], }); diff --git a/test/integration/production/productionDataRoundtrip.integration.test.ts b/test/integration/production/productionDataRoundtrip.integration.test.ts index 1c51255b..296f1e45 100644 --- a/test/integration/production/productionDataRoundtrip.integration.test.ts +++ b/test/integration/production/productionDataRoundtrip.integration.test.ts @@ -38,6 +38,7 @@ import { setupTestIssuer, setupTestStakeholder, setupWarrantSecurity, + withCapTableContractDetails, } from '../utils'; /** @@ -121,7 +122,7 @@ async function createStockPlanPrerequisite( } ) { const stockPlanData = createTestStockPlanData({ - id: params.stockPlanId, + ...(params.stockPlanId === undefined ? {} : { id: params.stockPlanId }), stock_class_ids: [params.stockClassId], }); @@ -497,14 +498,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -540,14 +541,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -583,14 +584,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -748,14 +749,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: convertibleSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: convertibleSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -850,14 +851,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: eqCompSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -895,14 +896,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: eqCompSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1139,14 +1140,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1187,14 +1188,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1229,14 +1230,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1310,14 +1311,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1353,14 +1354,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1399,14 +1400,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: convertibleSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: convertibleSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1443,14 +1444,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: convertibleSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: convertibleSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1487,14 +1488,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: eqCompSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1529,14 +1530,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: eqCompSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1571,14 +1572,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: eqCompSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: eqCompSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1693,14 +1694,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: warrantSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1735,14 +1736,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: warrantSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1777,14 +1778,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: warrantSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1858,14 +1859,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: warrantSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: warrantSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1902,14 +1903,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); @@ -1944,14 +1945,14 @@ createIntegrationTestSuite('Production Data Round-Trip Tests', (getContext) => { ? { templateId: events.created.createdEvent.templateId, contractId: stockSecurity.capTableContractId, - createdEventBlob: events.created.createdEvent.createdEventBlob, + createdEventBlob: requireCreatedEventBlob(events.created.createdEvent), synchronizerId: issuerSetup.capTableContractDetails.synchronizerId, } : undefined; const batch = ctx.ocp.OpenCapTable.capTable.update({ capTableContractId: stockSecurity.capTableContractId, - capTableContractDetails: updatedCapTableDetails, + ...withCapTableContractDetails(updatedCapTableDetails), actAs: [ctx.issuerParty], }); diff --git a/test/integration/utils/setupTestData.ts b/test/integration/utils/setupTestData.ts index 6d8c0cca..46b304e0 100644 --- a/test/integration/utils/setupTestData.ts +++ b/test/integration/utils/setupTestData.ts @@ -83,6 +83,13 @@ export function generateTestId(prefix: string): string { return `${prefix}-${timestamp}-${random}`; } +/** Omit optional disclosed-contract input rather than materializing it as `undefined`. */ +export function withCapTableContractDetails( + capTableContractDetails: T | undefined +): { capTableContractDetails?: T } { + return capTableContractDetails === undefined ? {} : { capTableContractDetails }; +} + /** Get updated CapTable contract details after a batch operation. */ export async function getCapTableDetails( ocp: OcpClient, @@ -405,8 +412,8 @@ export function createTestEquityCompensationIssuanceData( security_id: securityId, custom_id: `OPT-${securityId.substring(0, 8)}`, stakeholder_id, - stock_plan_id, - stock_class_id, + ...(stock_plan_id === undefined ? {} : { stock_plan_id }), + ...(stock_class_id === undefined ? {} : { stock_class_id }), compensation_type: 'OPTION_ISO', quantity: '50000', exercise_price: { amount: '0.50', currency: 'USD' }, @@ -823,7 +830,7 @@ export async function setupTestStakeholder( const cmd = buildUpdateCapTableCommand( { capTableContractId: options.issuerContractId, - capTableContractDetails: options.capTableContractDetails, + ...withCapTableContractDetails(options.capTableContractDetails), }, { creates: [{ type: 'stakeholder', data: stakeholderData }] } ); @@ -1087,7 +1094,7 @@ export async function setupStockSecurity( const batch1 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result1 = await batch1.create('stakeholder', stakeholderData).execute(); @@ -1113,7 +1120,7 @@ export async function setupStockSecurity( const batch2 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result2 = await batch2.create('stockClass', stockClassData).execute(); @@ -1140,7 +1147,7 @@ export async function setupStockSecurity( const batch3 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result3 = await batch3.create('stockIssuance', stockIssuanceData).execute(); @@ -1185,7 +1192,7 @@ export async function setupWarrantSecurity( const batch1 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result1 = await batch1.create('stakeholder', stakeholderData).execute(); @@ -1211,7 +1218,7 @@ export async function setupWarrantSecurity( const batch2 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result2 = await batch2.create('warrantIssuance', warrantIssuanceData).execute(); @@ -1257,7 +1264,7 @@ export async function setupEquityCompensationSecurity( const batch1 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result1 = await batch1.create('stakeholder', stakeholderData).execute(); @@ -1283,7 +1290,7 @@ export async function setupEquityCompensationSecurity( const batch2 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result2 = await batch2.create('stockClass', stockClassData).execute(); @@ -1310,7 +1317,7 @@ export async function setupEquityCompensationSecurity( const batch3 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result3 = await batch3.create('equityCompensationIssuance', eqCompIssuanceData).execute(); @@ -1358,7 +1365,7 @@ export async function setupConvertibleSecurity( const batch1 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result1 = await batch1.create('stakeholder', stakeholderData).execute(); @@ -1384,7 +1391,7 @@ export async function setupConvertibleSecurity( const batch2 = ocp.OpenCapTable.capTable.update({ capTableContractId, - capTableContractDetails, + ...withCapTableContractDetails(capTableContractDetails), actAs: [options.issuerParty], }); const result2 = await batch2.create('convertibleIssuance', convertibleIssuanceData).execute(); diff --git a/test/mocks/fairmint-canton-node-sdk.ts b/test/mocks/fairmint-canton-node-sdk.ts index 69495f33..43757bbe 100644 --- a/test/mocks/fairmint-canton-node-sdk.ts +++ b/test/mocks/fairmint-canton-node-sdk.ts @@ -4,7 +4,7 @@ import type { ClientConfig } from '@fairmint/canton-node-sdk'; import type { SubmitAndWaitForTransactionTreeResponse } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/operations'; export class LedgerJsonApiClient { - private readonly config?: ClientConfig; + private readonly config: ClientConfig | undefined; public static __instances: LedgerJsonApiClient[] = []; public lastAuthToken?: string; private __getAuthToken?: () => Promise | string; @@ -147,7 +147,7 @@ export class Canton { public readonly ledger: LedgerJsonApiClient; public readonly validator: ValidatorApiClient; public readonly scan: unknown; - private partyId?: string; + private partyId: string | undefined; constructor(public readonly config: ClientConfig) { this.ledger = new LedgerJsonApiClient(config); diff --git a/test/validation/boundaries.test.ts b/test/validation/boundaries.test.ts index e10d4487..e3358fa9 100644 --- a/test/validation/boundaries.test.ts +++ b/test/validation/boundaries.test.ts @@ -192,13 +192,12 @@ describe('Boundary Condition Tests', () => { }); describe('Null vs Undefined Handling', () => { - test('DAML optional fields use null, not undefined', () => { + test('omitted OCF optional fields become null in DAML', () => { const data: OcfStakeholder = { id: 'sh-null-test', object_type: 'STAKEHOLDER', name: { legal_name: 'Test' }, stakeholder_type: 'INDIVIDUAL', - issuer_assigned_id: undefined, // Should become null in DAML }; const result = stakeholderDataToDaml(data); diff --git a/tsconfig.exact-source.json b/tsconfig.exact-source.json deleted file mode 100644 index b2c49bea..00000000 --- a/tsconfig.exact-source.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "exactOptionalPropertyTypes": true, - "noEmit": true - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist"] -} diff --git a/tsconfig.json b/tsconfig.json index 0d965d86..7a964bba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "./dist", "rootDir": "./src", "strict": true, + "exactOptionalPropertyTypes": true, "noImplicitReturns": true, "noImplicitOverride": true, "noUnusedLocals": true,