Skip to content

feat: add accept choiceContext endpoint to usdcx-registry service #259

@sadiq1971

Description

@sadiq1971

Background

scripts/setup/usdcx-registry.go currently only serves the sender-side endpoint:

POST /registry/transfer-instruction/v1/transfer-factory

It returns choiceContext: null always.

On Canton devnet, DA's registrar also serves the receiver-side endpoint:

POST /api/token-standard/v0/registrars/{registrarParty}/registry/transfer-instruction/v1/{cid}/choice-contexts/accept

This endpoint returns:

  • choiceContextDataMap Text AnyValue (e.g., TransferRule CID, InstrumentConfig CID as AV_ContractId values)
  • disclosedContracts — array of { contractId, createdEventBlob (base64), templateId, synchronizerId } for the contracts referenced in the choiceContext

Without this endpoint, the receiver cannot call TransferInstruction_Accept (the Splice interface choice requires choiceContext + disclosed contracts).

Depends On

#257 (must know the exact choiceContextData field names and which ACS contracts to include)

Changes

File: scripts/setup/usdcx-registry.go

Add handler for:

POST /api/token-standard/v0/registrars/{registrarParty}/registry/transfer-instruction/v1/{cid}/choice-contexts/accept

Request body (from accept-via-interface.go reference):

{"meta": {}, "excludeDebugFields": false}

Response body:

{
  "choiceContextData": {
    "values": {
      "<key>": {"tag": "AV_ContractId", "value": "<contract-id>"},
      ...
    }
  },
  "disclosedContracts": [
    {
      "contractId": "...",
      "createdEventBlob": "<base64>",
      "templateId": "<pkg>:<module>:<entity>",
      "synchronizerId": "..."
    }
  ]
}

Implementation: Query P2's ACS for the TransferRule and InstrumentConfig (or equivalent) contracts relevant to the instrument in the TransferOffer referenced by {cid}. Build the choiceContext from their contract IDs.

docker-compose.yaml: The usdcx-registry service is already on port 8090 — no structural change needed.

tests/e2e/docker-compose.e2e.yaml: Add usdcx-registry service entry (see #263).

Verification

curl -X POST http://localhost:8090/api/token-standard/v0/registrars/{issuer}/registry/transfer-instruction/v1/{offerCID}/choice-contexts/accept \
  -H 'Content-Type: application/json' \
  -d '{"meta":{},"excludeDebugFields":false}'

Response should have non-null choiceContextData with at least one AV_ContractId entry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: P1Added to issues and PRs relating to a high severity bugs.Type: FeatureAdded to issues and PRs to identify that the change is a new feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions