Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6a44988
feat: add token standard v2 allocation helpers
HardlyDifficult Jul 10, 2026
6cd2f88
feat: resolve token standard v2 settlement factories
HardlyDifficult Jul 10, 2026
eb9d7e5
fix: harden token standard v2 allocation helpers
HardlyDifficult Jul 10, 2026
0a38862
fix: enforce daml decimal bounds
HardlyDifficult Jul 10, 2026
6be1bee
fix: resolve settlement factories through registries
HardlyDifficult Jul 10, 2026
e8a6a69
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult Jul 10, 2026
d92059b
style: align allocation error conventions
HardlyDifficult Jul 10, 2026
75dde9d
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult Jul 10, 2026
4cd2a7a
fix: enforce daml json decimal syntax
HardlyDifficult Jul 10, 2026
1d224cf
fix: enforce daml json decimal syntax
HardlyDifficult Jul 10, 2026
40513db
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult Jul 10, 2026
d728421
fix: validate allocation helper runtime inputs
HardlyDifficult Jul 10, 2026
6c2f2f0
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult Jul 10, 2026
34346f2
fix: require positive iteration funding
HardlyDifficult Jul 10, 2026
03f4fa0
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult Jul 10, 2026
0751da8
Merge remote-tracking branch 'origin/main' into codex/token-standard-…
HardlyDifficult Jul 10, 2026
f22dbee
docs: clarify settlement funding default
HardlyDifficult Jul 10, 2026
7bdcd47
Merge origin/main into token standard settlement factory
HardlyDifficult Jul 10, 2026
c0093c9
Apply remaining changes
Copilot Jul 10, 2026
7d5c236
Merge remote settlement branch updates
HardlyDifficult Jul 10, 2026
7e6477c
chore: remove unintended wiki gitlink
HardlyDifficult Jul 10, 2026
aa6e9d0
fix: validate settlement prepare inputs
HardlyDifficult Jul 10, 2026
8450754
Merge origin/main into token standard settlement factory
HardlyDifficult Jul 10, 2026
201d148
fix: harden settlement registry values
HardlyDifficult Jul 10, 2026
c5acfd9
fix: reject non-json settlement context
HardlyDifficult Jul 10, 2026
bbe685e
fix: validate settlement builder inputs
HardlyDifficult Jul 10, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './v2';
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { z } from 'zod';
import { createApiOperation } from '../../../../../../../core';
import { RecordSchema } from '../../../../../../ledger-json-api/schemas/base';

const endpoint = '/registry/allocation/v2/settlement-factory';
const TRAILING_SLASHES_PATTERN = /\/+$/;
const publicRequestConfig = {
contentType: 'application/json',
includeBearerToken: false,
} as const;

const RegistryUrlSchema = z.url().refine((value) => {
try {
const { protocol } = new URL(value);
return protocol === 'http:' || protocol === 'https:';
} catch {
return false;
}
}, 'registryUrl must use http or https');

export const GetSettlementFactoryFromRegistryParamsSchema = z.object({
/** Base URL advertised for the instrument admin's Token Standard registry. */
registryUrl: RegistryUrlSchema,
/** Complete SettlementFactory_SettleBatch choice argument with empty context and metadata. */
choiceArguments: RecordSchema,
excludeDebugFields: z.boolean().optional(),
});

export type GetSettlementFactoryFromRegistryParams = z.infer<typeof GetSettlementFactoryFromRegistryParamsSchema>;

/** Request body from the CIP-112 allocation V2 registry API. */
export interface GetSettlementFactoryFromRegistryRequest {
readonly choiceArguments: Readonly<Record<string, unknown>>;
readonly excludeDebugFields: boolean;
}

/** Required disclosed-contract fields from the CIP-112 allocation V2 registry API. */
export interface GetSettlementFactoryFromRegistryDisclosedContract {
readonly templateId: string;
readonly contractId: string;
readonly createdEventBlob: string;
readonly synchronizerId: string;
}

/** ChoiceContext record returned by the CIP-112 allocation V2 registry API. */
export interface GetSettlementFactoryFromRegistryChoiceContextData {
readonly values: Readonly<Record<string, unknown>>;
}

/** Response from the CIP-112 allocation V2 settlement-factory registry API. */
export interface GetSettlementFactoryFromRegistryResponse {
readonly factoryId: string;
readonly choiceContext: {
readonly choiceContextData: GetSettlementFactoryFromRegistryChoiceContextData;
readonly disclosedContracts: readonly GetSettlementFactoryFromRegistryDisclosedContract[];
};
}

function buildRegistryEndpoint(registryUrl: string): string {
const url = new URL(registryUrl);
url.username = '';
url.password = '';
url.search = '';
url.hash = '';
url.pathname = `${url.pathname.replace(TRAILING_SLASHES_PATTERN, '')}${endpoint}`;
return url.toString();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
* Fetch the CIP-112 V2 SettlementFactory and per-choice context from any Token Standard registry. The request is
* deliberately unauthenticated so Scan credentials are never forwarded to a third-party instrument registry.
*/
export const GetSettlementFactoryFromRegistry = createApiOperation<
GetSettlementFactoryFromRegistryParams,
GetSettlementFactoryFromRegistryResponse
>({
paramsSchema: GetSettlementFactoryFromRegistryParamsSchema,
method: 'POST',
buildUrl: (params) => buildRegistryEndpoint(params.registryUrl),
buildRequestData: (params) =>
({
choiceArguments: params.choiceArguments,
excludeDebugFields: params.excludeDebugFields ?? false,
}) satisfies GetSettlementFactoryFromRegistryRequest,
requestConfig: publicRequestConfig,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './get-settlement-factory-from-registry';
1 change: 1 addition & 0 deletions src/clients/scan-api/operations/v0/registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './allocation';
export * from './allocation-instruction';
export * from './metadata';
1 change: 1 addition & 0 deletions src/utils/token-standard/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './allocation';
export * from './holdings';
export * from './settlement-factory';
export * from './types';
Loading
Loading