-
Notifications
You must be signed in to change notification settings - Fork 0
Resolve Token Standard V2 settlement factories #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HardlyDifficult
merged 26 commits into
main
from
codex/token-standard-settlement-factory
Jul 13, 2026
Merged
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 6cd2f88
feat: resolve token standard v2 settlement factories
HardlyDifficult eb9d7e5
fix: harden token standard v2 allocation helpers
HardlyDifficult 0a38862
fix: enforce daml decimal bounds
HardlyDifficult 6be1bee
fix: resolve settlement factories through registries
HardlyDifficult e8a6a69
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult d92059b
style: align allocation error conventions
HardlyDifficult 75dde9d
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult 4cd2a7a
fix: enforce daml json decimal syntax
HardlyDifficult 1d224cf
fix: enforce daml json decimal syntax
HardlyDifficult 40513db
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult d728421
fix: validate allocation helper runtime inputs
HardlyDifficult 6c2f2f0
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult 34346f2
fix: require positive iteration funding
HardlyDifficult 03f4fa0
Merge branch 'codex/token-standard-allocation' into codex/token-stand…
HardlyDifficult 0751da8
Merge remote-tracking branch 'origin/main' into codex/token-standard-…
HardlyDifficult f22dbee
docs: clarify settlement funding default
HardlyDifficult 7bdcd47
Merge origin/main into token standard settlement factory
HardlyDifficult c0093c9
Apply remaining changes
Copilot 7d5c236
Merge remote settlement branch updates
HardlyDifficult 7e6477c
chore: remove unintended wiki gitlink
HardlyDifficult aa6e9d0
fix: validate settlement prepare inputs
HardlyDifficult 8450754
Merge origin/main into token standard settlement factory
HardlyDifficult 201d148
fix: harden settlement registry values
HardlyDifficult c5acfd9
fix: reject non-json settlement context
HardlyDifficult bbe685e
fix: validate settlement builder inputs
HardlyDifficult File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/clients/scan-api/operations/v0/registry/allocation/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './v2'; |
86 changes: 86 additions & 0 deletions
86
...nts/scan-api/operations/v0/registry/allocation/v2/get-settlement-factory-from-registry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
|
|
||
| /** | ||
| * 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, | ||
| }); | ||
1 change: 1 addition & 0 deletions
1
src/clients/scan-api/operations/v0/registry/allocation/v2/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './get-settlement-factory-from-registry'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './allocation'; | ||
| export * from './allocation-instruction'; | ||
| export * from './metadata'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.