diff --git a/api-specs/openrpc-dapp-api.json b/api-specs/openrpc-dapp-api.json index 57e34daf5..280a87901 100644 --- a/api-specs/openrpc-dapp-api.json +++ b/api-specs/openrpc-dapp-api.json @@ -335,11 +335,88 @@ }, "required": ["createdEventBlob"] }, + "CreateCommand": { + "title": "CreateCommand", + "type": "object", + "additionalProperties": false, + "required": ["CreateCommand"], + "properties": { + "CreateCommand": { + "title": "CreateCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here." + } + } + }, + "ExerciseCommand": { + "title": "ExerciseCommand", + "type": "object", + "additionalProperties": false, + "required": ["ExerciseCommand"], + "properties": { + "ExerciseCommand": { + "title": "ExerciseCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here." + } + } + }, + "CreateAndExerciseCommand": { + "title": "CreateAndExerciseCommand", + "type": "object", + "additionalProperties": false, + "required": ["CreateAndExerciseCommand"], + "properties": { + "CreateAndExerciseCommand": { + "title": "CreateAndExerciseCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here." + } + } + }, + "ExerciseByKeyCommand": { + "title": "ExerciseByKeyCommand", + "type": "object", + "additionalProperties": false, + "required": ["ExerciseByKeyCommand"], + "properties": { + "ExerciseByKeyCommand": { + "title": "ExerciseByKeyCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here." + } + } + }, + "Command": { + "title": "Command", + "description": "A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract.", + "oneOf": [ + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CreateCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/ExerciseCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CreateAndExerciseCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/ExerciseByKeyCommand" + } + ] + }, "JsCommands": { "title": "JsCommands", - "type": "object", - "description": "Structure representing JS commands for transaction execution", - "additionalProperties": true + "type": "array", + "minItems": 1, + "description": "Non-empty array of Daml command atoms to submit atomically as a single transaction.", + "items": { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Command" + } }, "JsPrepareSubmissionResponse": { "title": "JsPrepareSubmissionResponse", diff --git a/core/wallet-dapp-remote-rpc-client/src/index.ts b/core/wallet-dapp-remote-rpc-client/src/index.ts index 0a2f12bad..88db8de2c 100644 --- a/core/wallet-dapp-remote-rpc-client/src/index.ts +++ b/core/wallet-dapp-remote-rpc-client/src/index.ts @@ -14,12 +14,64 @@ export type CommandId = string type AlwaysTrue = any /** * - * Structure representing JS commands for transaction execution + * Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here. * */ -export interface JsCommands { +export interface CreateCommandPayload { [key: string]: any } +export interface CreateCommand { + CreateCommand: CreateCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here. + * + */ +export interface ExerciseCommandPayload { + [key: string]: any +} +export interface ExerciseCommand { + ExerciseCommand: ExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here. + * + */ +export interface CreateAndExerciseCommandPayload { + [key: string]: any +} +export interface CreateAndExerciseCommand { + CreateAndExerciseCommand: CreateAndExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here. + * + */ +export interface ExerciseByKeyCommandPayload { + [key: string]: any +} +export interface ExerciseByKeyCommand { + ExerciseByKeyCommand: ExerciseByKeyCommandPayload +} +/** + * + * A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract. + * + */ +export type Command = + | CreateCommand + | ExerciseCommand + | CreateAndExerciseCommand + | ExerciseByKeyCommand +/** + * + * Non-empty array of Daml command atoms to submit atomically as a single transaction. + * + */ +export type JsCommands = Command[] /** * * The party that signed the transaction. diff --git a/core/wallet-dapp-rpc-client/src/index.ts b/core/wallet-dapp-rpc-client/src/index.ts index 55205aaf1..70644a805 100644 --- a/core/wallet-dapp-rpc-client/src/index.ts +++ b/core/wallet-dapp-rpc-client/src/index.ts @@ -14,12 +14,64 @@ export type CommandId = string type AlwaysTrue = any /** * - * Structure representing JS commands for transaction execution + * Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here. * */ -export interface JsCommands { +export interface CreateCommandPayload { [key: string]: any } +export interface CreateCommand { + CreateCommand: CreateCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here. + * + */ +export interface ExerciseCommandPayload { + [key: string]: any +} +export interface ExerciseCommand { + ExerciseCommand: ExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here. + * + */ +export interface CreateAndExerciseCommandPayload { + [key: string]: any +} +export interface CreateAndExerciseCommand { + CreateAndExerciseCommand: CreateAndExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here. + * + */ +export interface ExerciseByKeyCommandPayload { + [key: string]: any +} +export interface ExerciseByKeyCommand { + ExerciseByKeyCommand: ExerciseByKeyCommandPayload +} +/** + * + * A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract. + * + */ +export type Command = + | CreateCommand + | ExerciseCommand + | CreateAndExerciseCommand + | ExerciseByKeyCommand +/** + * + * Non-empty array of Daml command atoms to submit atomically as a single transaction. + * + */ +export type JsCommands = Command[] /** * * The party that signed the transaction. diff --git a/core/wallet-dapp-rpc-client/src/openrpc.json b/core/wallet-dapp-rpc-client/src/openrpc.json index 57e34daf5..280a87901 100644 --- a/core/wallet-dapp-rpc-client/src/openrpc.json +++ b/core/wallet-dapp-rpc-client/src/openrpc.json @@ -335,11 +335,88 @@ }, "required": ["createdEventBlob"] }, + "CreateCommand": { + "title": "CreateCommand", + "type": "object", + "additionalProperties": false, + "required": ["CreateCommand"], + "properties": { + "CreateCommand": { + "title": "CreateCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here." + } + } + }, + "ExerciseCommand": { + "title": "ExerciseCommand", + "type": "object", + "additionalProperties": false, + "required": ["ExerciseCommand"], + "properties": { + "ExerciseCommand": { + "title": "ExerciseCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here." + } + } + }, + "CreateAndExerciseCommand": { + "title": "CreateAndExerciseCommand", + "type": "object", + "additionalProperties": false, + "required": ["CreateAndExerciseCommand"], + "properties": { + "CreateAndExerciseCommand": { + "title": "CreateAndExerciseCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here." + } + } + }, + "ExerciseByKeyCommand": { + "title": "ExerciseByKeyCommand", + "type": "object", + "additionalProperties": false, + "required": ["ExerciseByKeyCommand"], + "properties": { + "ExerciseByKeyCommand": { + "title": "ExerciseByKeyCommandPayload", + "type": "object", + "additionalProperties": true, + "description": "Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here." + } + } + }, + "Command": { + "title": "Command", + "description": "A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract.", + "oneOf": [ + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CreateCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/ExerciseCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CreateAndExerciseCommand" + }, + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/ExerciseByKeyCommand" + } + ] + }, "JsCommands": { "title": "JsCommands", - "type": "object", - "description": "Structure representing JS commands for transaction execution", - "additionalProperties": true + "type": "array", + "minItems": 1, + "description": "Non-empty array of Daml command atoms to submit atomically as a single transaction.", + "items": { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Command" + } }, "JsPrepareSubmissionResponse": { "title": "JsPrepareSubmissionResponse", diff --git a/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts b/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts index 52c61fb05..1a0537075 100644 --- a/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts +++ b/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts @@ -13,12 +13,64 @@ export type CommandId = string type AlwaysTrue = any /** * - * Structure representing JS commands for transaction execution + * Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here. * */ -export interface JsCommands { +export interface CreateCommandPayload { [key: string]: any } +export interface CreateCommand { + CreateCommand: CreateCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here. + * + */ +export interface ExerciseCommandPayload { + [key: string]: any +} +export interface ExerciseCommand { + ExerciseCommand: ExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here. + * + */ +export interface CreateAndExerciseCommandPayload { + [key: string]: any +} +export interface CreateAndExerciseCommand { + CreateAndExerciseCommand: CreateAndExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here. + * + */ +export interface ExerciseByKeyCommandPayload { + [key: string]: any +} +export interface ExerciseByKeyCommand { + ExerciseByKeyCommand: ExerciseByKeyCommandPayload +} +/** + * + * A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract. + * + */ +export type Command = + | CreateCommand + | ExerciseCommand + | CreateAndExerciseCommand + | ExerciseByKeyCommand +/** + * + * Non-empty array of Daml command atoms to submit atomically as a single transaction. + * + */ +export type JsCommands = Command[] /** * * The party that signed the transaction. diff --git a/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts b/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts index 52c61fb05..1a0537075 100644 --- a/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts @@ -13,12 +13,64 @@ export type CommandId = string type AlwaysTrue = any /** * - * Structure representing JS commands for transaction execution + * Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here. * */ -export interface JsCommands { +export interface CreateCommandPayload { [key: string]: any } +export interface CreateCommand { + CreateCommand: CreateCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here. + * + */ +export interface ExerciseCommandPayload { + [key: string]: any +} +export interface ExerciseCommand { + ExerciseCommand: ExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here. + * + */ +export interface CreateAndExerciseCommandPayload { + [key: string]: any +} +export interface CreateAndExerciseCommand { + CreateAndExerciseCommand: CreateAndExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here. + * + */ +export interface ExerciseByKeyCommandPayload { + [key: string]: any +} +export interface ExerciseByKeyCommand { + ExerciseByKeyCommand: ExerciseByKeyCommandPayload +} +/** + * + * A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract. + * + */ +export type Command = + | CreateCommand + | ExerciseCommand + | CreateAndExerciseCommand + | ExerciseByKeyCommand +/** + * + * Non-empty array of Daml command atoms to submit atomically as a single transaction. + * + */ +export type JsCommands = Command[] /** * * The party that signed the transaction. diff --git a/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts b/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts index c48789526..f9773d7b8 100644 --- a/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts @@ -13,12 +13,64 @@ export type CommandId = string type AlwaysTrue = any /** * - * Structure representing JS commands for transaction execution + * Inner shape is defined by the Canton Ledger API CreateCommand schema; do not re-specify here. * */ -export interface JsCommands { +export interface CreateCommandPayload { [key: string]: any } +export interface CreateCommand { + CreateCommand: CreateCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseCommand schema; do not re-specify here. + * + */ +export interface ExerciseCommandPayload { + [key: string]: any +} +export interface ExerciseCommand { + ExerciseCommand: ExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API CreateAndExerciseCommand schema; do not re-specify here. + * + */ +export interface CreateAndExerciseCommandPayload { + [key: string]: any +} +export interface CreateAndExerciseCommand { + CreateAndExerciseCommand: CreateAndExerciseCommandPayload +} +/** + * + * Inner shape is defined by the Canton Ledger API ExerciseByKeyCommand schema; do not re-specify here. + * + */ +export interface ExerciseByKeyCommandPayload { + [key: string]: any +} +export interface ExerciseByKeyCommand { + ExerciseByKeyCommand: ExerciseByKeyCommandPayload +} +/** + * + * A Daml command atom. Mirror of the Canton Ledger API Command union; inner shapes are intentionally opaque so the dApp layer never drifts from the Ledger API contract. + * + */ +export type Command = + | CreateCommand + | ExerciseCommand + | CreateAndExerciseCommand + | ExerciseByKeyCommand +/** + * + * Non-empty array of Daml command atoms to submit atomically as a single transaction. + * + */ +export type JsCommands = Command[] /** * * The party that signed the transaction. diff --git a/wallet-gateway/remote/src/utils.ts b/wallet-gateway/remote/src/utils.ts index f020a318f..f26f72c54 100644 --- a/wallet-gateway/remote/src/utils.ts +++ b/wallet-gateway/remote/src/utils.ts @@ -5,6 +5,7 @@ import { v4 } from 'uuid' import { LedgerClient, Types } from '@canton-network/core-ledger-client' import type { DisclosedContracts, + JsCommands, PackageIdSelectionPreference, } from './dapp-api/rpc-gen/typings.js' @@ -33,7 +34,7 @@ export async function networkStatus( export interface PrepareParams { commandId?: string - commands?: { [k: string]: unknown } + commands?: JsCommands actAs?: string[] readAs?: string[] disclosedContracts?: DisclosedContracts