Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 2 additions & 7 deletions src/functions/OpenCapTable/shared/conversionMechanisms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 9 additions & 7 deletions test/capTable/archiveFullCapTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LedgerJsonApiClient['getActiveContracts']>[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 {
Expand Down
16 changes: 9 additions & 7 deletions test/capTable/getCapTableState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LedgerJsonApiClient['getActiveContracts']>[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)}`);
});
);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions test/client/OcpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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' },
});

Expand Down
6 changes: 2 additions & 4 deletions test/client/OcpContextManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
23 changes: 12 additions & 11 deletions test/integration/entities/acceptanceTypes.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
setupStockSecurity,
setupTestIssuer,
setupWarrantSecurity,
withCapTableContractDetails,
} from '../utils';

/**
Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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 });
Expand All @@ -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 });
Expand All @@ -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 });
Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
requireCreatedEventBlob,
setupStockSecurity,
setupTestIssuer,
withCapTableContractDetails,
} from '../utils';

createIntegrationTestSuite('Stock Class Adjustments', (getContext) => {
Expand Down Expand Up @@ -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 });
Expand All @@ -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 });
Expand All @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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 });
Expand All @@ -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 });
Expand All @@ -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],
});

Expand Down
9 changes: 5 additions & 4 deletions test/integration/entities/transferTypes.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
setupStockSecurity,
setupTestIssuer,
setupWarrantSecurity,
withCapTableContractDetails,
} from '../utils';

/** Extract a contract ID from a transaction tree response. */
Expand Down Expand Up @@ -107,7 +108,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => {
const cmd = buildUpdateCapTableCommand(
{
capTableContractId: stockSecurity.capTableContractId,
capTableContractDetails: updatedCapTableDetails,
...withCapTableContractDetails(updatedCapTableDetails),
},
{ creates: [{ type: 'stockTransfer', data: transferData }] }
);
Expand Down Expand Up @@ -185,7 +186,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => {
const cmd = buildUpdateCapTableCommand(
{
capTableContractId: convertibleSecurity.capTableContractId,
capTableContractDetails: updatedCapTableDetails,
...withCapTableContractDetails(updatedCapTableDetails),
},
{ creates: [{ type: 'convertibleTransfer', data: transferData }] }
);
Expand Down Expand Up @@ -258,7 +259,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => {
const cmd = buildUpdateCapTableCommand(
{
capTableContractId: eqCompSecurity.capTableContractId,
capTableContractDetails: updatedCapTableDetails,
...withCapTableContractDetails(updatedCapTableDetails),
},
{ creates: [{ type: 'equityCompensationTransfer', data: transferData }] }
);
Expand Down Expand Up @@ -330,7 +331,7 @@ createIntegrationTestSuite('Transfer Type operations', (getContext) => {
const cmd = buildUpdateCapTableCommand(
{
capTableContractId: warrantSecurity.capTableContractId,
capTableContractDetails: updatedCapTableDetails,
...withCapTableContractDetails(updatedCapTableDetails),
},
{ creates: [{ type: 'warrantTransfer', data: transferData }] }
);
Expand Down
11 changes: 6 additions & 5 deletions test/integration/entities/valuationVesting.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
requireCreatedEventBlob,
setupStockSecurity,
setupTestIssuer,
withCapTableContractDetails,
} from '../utils';

function extractContractIdString(cid: { value: unknown }): string {
Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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],
});

Expand Down Expand Up @@ -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 });
Expand All @@ -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],
});

Expand Down
Loading