diff --git a/api-specs/openrpc-dapp-api.json b/api-specs/openrpc-dapp-api.json index e5ffc419..3b9d71e7 100644 --- a/api-specs/openrpc-dapp-api.json +++ b/api-specs/openrpc-dapp-api.json @@ -12,7 +12,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Returns the current status of the wallet gateway session." @@ -23,7 +23,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId." @@ -34,7 +34,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/Null" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Null" } }, "description": "Invoke a disconnect of the wallet gateway session." @@ -69,7 +69,7 @@ "name": "params", "schema": { "title": "prepareReturnParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -79,7 +79,7 @@ "title": "prepareReturnResult", "properties": { "response": { - "$ref": "#/components/schemas/JsPrepareSubmissionResponse" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionResponse" } }, "required": ["response"] @@ -94,7 +94,7 @@ "name": "params", "schema": { "title": "prepareExecuteParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -105,7 +105,7 @@ "type": "object", "properties": { "tx": { - "$ref": "#/components/schemas/TxChangedExecutedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedEvent" } }, "required": ["tx"] @@ -120,30 +120,14 @@ "name": "params", "schema": { "title": "ledgerApiParams", - "type": "object", - "properties": { - "requestMethod": { - "title": "requestMethod", - "type": "string", - "enum": ["GET", "POST", "PUT", "DELETE"] - }, - "resource": { - "title": "resource", - "type": "string" - }, - "body": { - "title": "body", - "type": "string" - } - }, - "required": ["requestMethod", "resource"] + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiRequest" } } ], "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/LedgerApiResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiResult" } }, "description": "Proxy for the JSON-API endpoints. Injects authorization headers automatically." @@ -154,7 +138,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/AccountsChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/AccountsChangedEvent" } } }, @@ -164,7 +148,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/RequestAccountsResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/RequestAccountsResult" } }, "description": "Lists the addresses (wallets) with their properties; including which network they are associated to and with signing provider is used." @@ -175,7 +159,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/TxChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedEvent" } } } @@ -209,7 +193,7 @@ "description": "The URL of the Wallet Gateway." }, "userUrl": { - "$ref": "#/components/schemas/UserUrl" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" } }, "required": ["id", "clientType"] @@ -238,10 +222,10 @@ "description": "Structure representing the request for prepare and execute calls", "properties": { "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "commands": { - "$ref": "#/components/schemas/JsCommands" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsCommands" }, "actAs": { "title": "actAs", @@ -266,7 +250,7 @@ "type": "array", "description": "List of contract IDs to be disclosed with the command.", "items": { - "$ref": "#/components/schemas/DisclosedContract" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/DisclosedContract" } }, "synchronizerId": { @@ -336,6 +320,27 @@ } } }, + "LedgerApiRequest": { + "title": "LedgerApiRequest", + "type": "object", + "description": "Ledger API request structure", + "properties": { + "requestMethod": { + "title": "requestMethod", + "type": "string", + "enum": ["GET", "POST", "PUT", "DELETE"] + }, + "resource": { + "title": "resource", + "type": "string" + }, + "body": { + "title": "body", + "type": "string" + } + }, + "required": ["requestMethod", "resource"] + }, "AccountsChangedEvent": { "title": "AccountsChangedEvent", "type": "array", @@ -370,7 +375,7 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" } }, "required": ["status", "commandId"] @@ -412,10 +417,10 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "payload": { - "$ref": "#/components/schemas/TxChangedSignedPayload" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedSignedPayload" } }, "required": ["status", "commandId", "payload"] @@ -451,10 +456,10 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "payload": { - "$ref": "#/components/schemas/TxChangedExecutedPayload" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedPayload" } }, "required": ["status", "commandId", "payload"] @@ -472,7 +477,7 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" } }, "required": ["status", "commandId"] @@ -482,16 +487,16 @@ "description": "Event emitted when a transaction changes.", "oneOf": [ { - "$ref": "#/components/schemas/TxChangedPendingEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedPendingEvent" }, { - "$ref": "#/components/schemas/TxChangedSignedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedSignedEvent" }, { - "$ref": "#/components/schemas/TxChangedExecutedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedEvent" }, { - "$ref": "#/components/schemas/TxChangedFailedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedFailedEvent" } ] }, @@ -500,7 +505,7 @@ "type": "object", "properties": { "kernel": { - "$ref": "#/components/schemas/KernelInfo" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/KernelInfo" }, "isConnected": { "title": "isConnected", @@ -517,9 +522,6 @@ "type": "string", "description": "If not connected to a network, the reason why." }, - "userUrl": { - "$ref": "#/components/schemas/UserUrl" - }, "network": { "title": "network", "type": "object", diff --git a/api-specs/openrpc-dapp-remote-api.json b/api-specs/openrpc-dapp-remote-api.json index b7bc620d..447077fd 100644 --- a/api-specs/openrpc-dapp-remote-api.json +++ b/api-specs/openrpc-dapp-remote-api.json @@ -12,7 +12,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Returns the current status of the wallet gateway session." @@ -23,7 +23,21 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "title": "StatusEventAsync", + "allOf": [ + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" + }, + { + "type": "object", + "properties": { + "userUrl": { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" + } + }, + "required": ["userUrl"] + } + ] } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. NetworkId should follow CAIP-2 and represent the synchronizerId." @@ -34,7 +48,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/Null" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Null" } }, "description": "Invoke a disconnect of the wallet gateway session." @@ -69,7 +83,7 @@ "name": "params", "schema": { "title": "prepareReturnParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -79,7 +93,7 @@ "title": "prepareReturnResult", "properties": { "response": { - "$ref": "#/components/schemas/JsPrepareSubmissionResponse" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionResponse" } }, "required": ["response"] @@ -94,7 +108,7 @@ "name": "params", "schema": { "title": "prepareExecuteParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -105,7 +119,7 @@ "type": "object", "properties": { "userUrl": { - "$ref": "#/components/schemas/UserUrl" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" } }, "required": ["userUrl"] @@ -120,30 +134,14 @@ "name": "params", "schema": { "title": "ledgerApiParams", - "type": "object", - "properties": { - "requestMethod": { - "title": "requestMethod", - "type": "string", - "enum": ["GET", "POST", "PUT", "DELETE"] - }, - "resource": { - "title": "resource", - "type": "string" - }, - "body": { - "title": "body", - "type": "string" - } - }, - "required": ["requestMethod", "resource"] + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiRequest" } } ], "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/LedgerApiResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiResult" } }, "description": "Proxy for the JSON-API endpoints. Injects authorization headers automatically." @@ -154,7 +152,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Informs when the user connects to a network." @@ -165,7 +163,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } } }, @@ -175,7 +173,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/AccountsChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/AccountsChangedEvent" } } }, @@ -185,7 +183,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/RequestAccountsResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/RequestAccountsResult" } } }, @@ -195,7 +193,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/TxChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedEvent" } } } @@ -206,384 +204,6 @@ "title": "Null", "type": "null", "description": "Represents a null value, used in responses where no data is returned." - }, - "KernelInfo": { - "title": "KernelInfo", - "type": "object", - "description": "Represents a Wallet Gateway.", - "properties": { - "id": { - "title": "id", - "type": "string", - "description": "The unique identifier of the Wallet Gateway." - }, - "clientType": { - "title": "clientType", - "type": "string", - "enum": ["browser", "desktop", "mobile", "remote"], - "description": "The type of client that implements the Wallet Gateway." - }, - "url": { - "title": "url", - "type": "string", - "description": "The URL of the Wallet Gateway." - } - }, - "required": ["id", "clientType"] - }, - "LedgerApiResult": { - "title": "LedgerApiResult", - "type": "object", - "description": "Ledger Api configuration options", - "properties": { - "response": { - "title": "response", - "type": "string" - } - }, - "required": ["response"] - }, - "UserUrl": { - "title": "UserUrl", - "type": "string", - "format": "uri", - "description": "A URL that points to a user interface." - }, - "JsPrepareSubmissionRequest": { - "title": "JsPrepareSubmissionRequest", - "type": "object", - "description": "Structure representing the request for prepare and execute calls", - "properties": { - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "commands": { - "$ref": "#/components/schemas/JsCommands" - }, - "actAs": { - "title": "actAs", - "type": "array", - "description": "Set of parties on whose behalf the command should be executed, if submitted. If not set, the primary wallet's party is used.", - "items": { - "title": "party", - "type": "string" - } - }, - "readAs": { - "title": "readAs", - "type": "array", - "description": "Set of parties that should be granted read access to the command, if submitted. If not set, no additional read parties are granted.", - "items": { - "title": "party", - "type": "string" - } - }, - "disclosedContracts": { - "title": "disclosedContracts", - "type": "array", - "description": "List of contract IDs to be disclosed with the command.", - "items": { - "$ref": "#/components/schemas/DisclosedContract" - } - }, - "synchronizerId": { - "title": "synchronizerId", - "type": "string", - "description": "If not set, a suitable synchronizer that this node is connected to will be chosen." - }, - "packageIdSelectionPreference": { - "title": "packageIdSelectionPreference", - "type": "array", - "description": "The package-id selection preference of the client for resolving package names and interface instances in command submission and interpretation", - "items": { - "title": "packageId", - "type": "string" - } - } - }, - "required": ["commands"] - }, - "DisclosedContract": { - "title": "DisclosedContract", - "type": "object", - "description": "Structure representing a disclosed contract for transaction execution", - "properties": { - "templateId": { - "title": "templateId", - "type": "string", - "description": "The template identifier of the disclosed contract." - }, - "contractId": { - "title": "contractId", - "type": "string", - "description": "The unique identifier of the disclosed contract." - }, - "createdEventBlob": { - "title": "createdEventBlob", - "type": "string", - "description": "The blob data of the created event for the disclosed contract." - }, - "synchronizerId": { - "title": "synchronizerId", - "type": "string", - "description": "The synchronizer identifier associated with the disclosed contract." - } - }, - "required": ["createdEventBlob"] - }, - "JsCommands": { - "title": "JsCommands", - "type": "object", - "description": "Structure representing JS commands for transaction execution" - }, - "JsPrepareSubmissionResponse": { - "title": "JsPrepareSubmissionResponse", - "type": "object", - "description": "Structure representing the result of a prepareReturn call", - "properties": { - "preparedTransaction": { - "title": "preparedTransaction", - "type": "string", - "description": "The prepared transaction data." - }, - "preparedTransactionHash": { - "title": "preparedTransactionHash", - "type": "string", - "description": "The hash of the prepared transaction." - } - } - }, - "AccountsChangedEvent": { - "title": "AccountsChangedEvent", - "type": "array", - "description": "Event emitted when the user's accounts change.", - "items": { - "$ref": "api-specs/openrpc-user-api.json#/components/schemas/Wallet" - } - }, - "RequestAccountsResult": { - "title": "RequestAccountsResult", - "type": "array", - "description": "An array of accounts that the user has authorized the dapp to access..", - "items": { - "$ref": "api-specs/openrpc-user-api.json#/components/schemas/Wallet" - } - }, - "CommandId": { - "title": "CommandId", - "type": "string", - "description": "The unique identifier of the command associated with the transaction." - }, - "TxChangedPendingEvent": { - "title": "TxChangedPendingEvent", - "description": "Event emitted when a transaction is pending.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusPending", - "type": "string", - "enum": ["pending"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - } - }, - "required": ["status", "commandId"] - }, - "TxChangedSignedPayload": { - "type": "object", - "title": "TxChangedSignedPayload", - "description": "Payload for the TxChangedSignedEvent.", - "additionalProperties": false, - "properties": { - "signature": { - "title": "signature", - "type": "string", - "description": "The signature of the transaction." - }, - "signedBy": { - "title": "signedBy", - "type": "string", - "description": "The identifier of the provider that signed the transaction." - }, - "party": { - "title": "party", - "type": "string", - "description": "The party that signed the transaction." - } - }, - "required": ["signature", "signedBy", "party"] - }, - "TxChangedSignedEvent": { - "title": "TxChangedSignedEvent", - "description": "Event emitted when a transaction has been signed.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusSigned", - "type": "string", - "enum": ["signed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "payload": { - "$ref": "#/components/schemas/TxChangedSignedPayload" - } - }, - "required": ["status", "commandId", "payload"] - }, - "TxChangedExecutedPayload": { - "type": "object", - "title": "TxChangedExecutedPayload", - "description": "Payload for the TxChangedExecutedEvent.", - "additionalProperties": false, - "properties": { - "updateId": { - "title": "updateId", - "type": "string", - "description": "The update ID corresponding to the transaction." - }, - "completionOffset": { - "title": "completionOffset", - "type": "integer" - } - }, - "required": ["updateId", "completionOffset"] - }, - "TxChangedExecutedEvent": { - "title": "TxChangedExecutedEvent", - "description": "Event emitted when a transaction is executed against the participant.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusExecuted", - "type": "string", - "enum": ["executed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "payload": { - "$ref": "#/components/schemas/TxChangedExecutedPayload" - } - }, - "required": ["status", "commandId", "payload"] - }, - "TxChangedFailedEvent": { - "title": "TxChangedFailedEvent", - "description": "Event emitted when a transaction has failed.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusFailed", - "type": "string", - "enum": ["failed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - } - }, - "required": ["status", "commandId"] - }, - "TxChangedEvent": { - "title": "TxChangedEvent", - "description": "Event emitted when a transaction changes.", - "oneOf": [ - { - "$ref": "#/components/schemas/TxChangedPendingEvent" - }, - { - "$ref": "#/components/schemas/TxChangedSignedEvent" - }, - { - "$ref": "#/components/schemas/TxChangedExecutedEvent" - }, - { - "$ref": "#/components/schemas/TxChangedFailedEvent" - } - ] - }, - "StatusEvent": { - "title": "StatusEvent", - "type": "object", - "properties": { - "kernel": { - "$ref": "#/components/schemas/KernelInfo" - }, - "isConnected": { - "title": "isConnected", - "type": "boolean", - "description": "Whether or not the user is authenticated with the Wallet." - }, - "isNetworkConnected": { - "title": "isNetworkConnected", - "type": "boolean", - "description": "Whether or not a connection to a network is established." - }, - "networkReason": { - "title": "networkReason", - "type": "string", - "description": "If not connected to a network, the reason why." - }, - "userUrl": { - "$ref": "#/components/schemas/UserUrl" - }, - "network": { - "title": "network", - "type": "object", - "description": "Network information, if connected to a network.", - "properties": { - "networkId": { - "title": "networkId", - "type": "string", - "description": "A CAIP-2 compliant chain ID, e.g. 'canton:da-mainnet'." - }, - "ledgerApi": { - "title": "LedgerApiConfig", - "type": "object", - "description": "Ledger API configuration.", - "properties": { - "baseUrl": { - "title": "baseUrl", - "type": "string", - "format": "uri", - "description": "The base URL of the ledger API." - } - }, - "required": ["baseUrl"] - } - }, - "required": ["networkId"] - }, - "session": { - "title": "session", - "type": "object", - "description": "Session information, if authenticated.", - "properties": { - "accessToken": { - "title": "accessToken", - "type": "string", - "description": "JWT authentication token." - }, - "userId": { - "title": "userId", - "type": "string", - "description": "The user identifier." - } - }, - "required": ["accessToken", "userId"] - } - }, - "required": ["kernel", "isConnected", "isNetworkConnected"] } } } diff --git a/core/wallet-dapp-remote-rpc-client/src/index.ts b/core/wallet-dapp-remote-rpc-client/src/index.ts index 08db76f2..44126bc4 100644 --- a/core/wallet-dapp-remote-rpc-client/src/index.ts +++ b/core/wallet-dapp-remote-rpc-client/src/index.ts @@ -105,6 +105,12 @@ export type ClientType = 'browser' | 'desktop' | 'mobile' | 'remote' * */ export type Url = string +/** + * + * A URL that points to a user interface. + * + */ +export type UserUrl = string /** * * Represents a Wallet Gateway. @@ -114,6 +120,7 @@ export interface KernelInfo { id: Id clientType: ClientType url?: Url + userUrl?: UserUrl [k: string]: any } /** @@ -134,12 +141,6 @@ export type IsNetworkConnected = boolean * */ export type NetworkReason = string -/** - * - * A URL that points to a user interface. - * - */ -export type UserUrl = string /** * * The network ID the wallet corresponds to. @@ -193,6 +194,19 @@ export interface Session { userId: UserId [k: string]: any } +export interface StatusEvent { + kernel: KernelInfo + isConnected: IsConnected + isNetworkConnected: IsNetworkConnected + networkReason?: NetworkReason + network?: Network + session?: Session + [k: string]: any +} +export interface ObjectOfUserUrlMkZ1IR2Z { + userUrl: UserUrl + [k: string]: any +} export type Dar = string export type Dars = Dar[] /** @@ -420,22 +434,18 @@ export interface PrepareExecuteParams { packageIdSelectionPreference?: PackageIdSelectionPreference [k: string]: any } +/** + * + * Ledger API request structure + * + */ export interface LedgerApiParams { requestMethod: RequestMethod resource: Resource body?: Body [k: string]: any } -export interface StatusEvent { - kernel: KernelInfo - isConnected: IsConnected - isNetworkConnected: IsNetworkConnected - networkReason?: NetworkReason - userUrl?: UserUrl - network?: Network - session?: Session - [k: string]: any -} +export type StatusEventAsync = StatusEvent & ObjectOfUserUrlMkZ1IR2Z /** * * Represents a null value, used in responses where no data is returned. @@ -489,7 +499,7 @@ export type TxChangedEvent = */ export type Status = () => Promise -export type Connect = () => Promise +export type Connect = () => Promise export type Disconnect = () => Promise export type DarsAvailable = () => Promise export type PrepareReturn = ( diff --git a/core/wallet-dapp-remote-rpc-client/src/openrpc.json b/core/wallet-dapp-remote-rpc-client/src/openrpc.json index b7bc620d..447077fd 100644 --- a/core/wallet-dapp-remote-rpc-client/src/openrpc.json +++ b/core/wallet-dapp-remote-rpc-client/src/openrpc.json @@ -12,7 +12,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Returns the current status of the wallet gateway session." @@ -23,7 +23,21 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "title": "StatusEventAsync", + "allOf": [ + { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" + }, + { + "type": "object", + "properties": { + "userUrl": { + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" + } + }, + "required": ["userUrl"] + } + ] } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. NetworkId should follow CAIP-2 and represent the synchronizerId." @@ -34,7 +48,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/Null" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Null" } }, "description": "Invoke a disconnect of the wallet gateway session." @@ -69,7 +83,7 @@ "name": "params", "schema": { "title": "prepareReturnParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -79,7 +93,7 @@ "title": "prepareReturnResult", "properties": { "response": { - "$ref": "#/components/schemas/JsPrepareSubmissionResponse" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionResponse" } }, "required": ["response"] @@ -94,7 +108,7 @@ "name": "params", "schema": { "title": "prepareExecuteParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -105,7 +119,7 @@ "type": "object", "properties": { "userUrl": { - "$ref": "#/components/schemas/UserUrl" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" } }, "required": ["userUrl"] @@ -120,30 +134,14 @@ "name": "params", "schema": { "title": "ledgerApiParams", - "type": "object", - "properties": { - "requestMethod": { - "title": "requestMethod", - "type": "string", - "enum": ["GET", "POST", "PUT", "DELETE"] - }, - "resource": { - "title": "resource", - "type": "string" - }, - "body": { - "title": "body", - "type": "string" - } - }, - "required": ["requestMethod", "resource"] + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiRequest" } } ], "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/LedgerApiResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiResult" } }, "description": "Proxy for the JSON-API endpoints. Injects authorization headers automatically." @@ -154,7 +152,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Informs when the user connects to a network." @@ -165,7 +163,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } } }, @@ -175,7 +173,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/AccountsChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/AccountsChangedEvent" } } }, @@ -185,7 +183,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/RequestAccountsResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/RequestAccountsResult" } } }, @@ -195,7 +193,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/TxChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedEvent" } } } @@ -206,384 +204,6 @@ "title": "Null", "type": "null", "description": "Represents a null value, used in responses where no data is returned." - }, - "KernelInfo": { - "title": "KernelInfo", - "type": "object", - "description": "Represents a Wallet Gateway.", - "properties": { - "id": { - "title": "id", - "type": "string", - "description": "The unique identifier of the Wallet Gateway." - }, - "clientType": { - "title": "clientType", - "type": "string", - "enum": ["browser", "desktop", "mobile", "remote"], - "description": "The type of client that implements the Wallet Gateway." - }, - "url": { - "title": "url", - "type": "string", - "description": "The URL of the Wallet Gateway." - } - }, - "required": ["id", "clientType"] - }, - "LedgerApiResult": { - "title": "LedgerApiResult", - "type": "object", - "description": "Ledger Api configuration options", - "properties": { - "response": { - "title": "response", - "type": "string" - } - }, - "required": ["response"] - }, - "UserUrl": { - "title": "UserUrl", - "type": "string", - "format": "uri", - "description": "A URL that points to a user interface." - }, - "JsPrepareSubmissionRequest": { - "title": "JsPrepareSubmissionRequest", - "type": "object", - "description": "Structure representing the request for prepare and execute calls", - "properties": { - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "commands": { - "$ref": "#/components/schemas/JsCommands" - }, - "actAs": { - "title": "actAs", - "type": "array", - "description": "Set of parties on whose behalf the command should be executed, if submitted. If not set, the primary wallet's party is used.", - "items": { - "title": "party", - "type": "string" - } - }, - "readAs": { - "title": "readAs", - "type": "array", - "description": "Set of parties that should be granted read access to the command, if submitted. If not set, no additional read parties are granted.", - "items": { - "title": "party", - "type": "string" - } - }, - "disclosedContracts": { - "title": "disclosedContracts", - "type": "array", - "description": "List of contract IDs to be disclosed with the command.", - "items": { - "$ref": "#/components/schemas/DisclosedContract" - } - }, - "synchronizerId": { - "title": "synchronizerId", - "type": "string", - "description": "If not set, a suitable synchronizer that this node is connected to will be chosen." - }, - "packageIdSelectionPreference": { - "title": "packageIdSelectionPreference", - "type": "array", - "description": "The package-id selection preference of the client for resolving package names and interface instances in command submission and interpretation", - "items": { - "title": "packageId", - "type": "string" - } - } - }, - "required": ["commands"] - }, - "DisclosedContract": { - "title": "DisclosedContract", - "type": "object", - "description": "Structure representing a disclosed contract for transaction execution", - "properties": { - "templateId": { - "title": "templateId", - "type": "string", - "description": "The template identifier of the disclosed contract." - }, - "contractId": { - "title": "contractId", - "type": "string", - "description": "The unique identifier of the disclosed contract." - }, - "createdEventBlob": { - "title": "createdEventBlob", - "type": "string", - "description": "The blob data of the created event for the disclosed contract." - }, - "synchronizerId": { - "title": "synchronizerId", - "type": "string", - "description": "The synchronizer identifier associated with the disclosed contract." - } - }, - "required": ["createdEventBlob"] - }, - "JsCommands": { - "title": "JsCommands", - "type": "object", - "description": "Structure representing JS commands for transaction execution" - }, - "JsPrepareSubmissionResponse": { - "title": "JsPrepareSubmissionResponse", - "type": "object", - "description": "Structure representing the result of a prepareReturn call", - "properties": { - "preparedTransaction": { - "title": "preparedTransaction", - "type": "string", - "description": "The prepared transaction data." - }, - "preparedTransactionHash": { - "title": "preparedTransactionHash", - "type": "string", - "description": "The hash of the prepared transaction." - } - } - }, - "AccountsChangedEvent": { - "title": "AccountsChangedEvent", - "type": "array", - "description": "Event emitted when the user's accounts change.", - "items": { - "$ref": "api-specs/openrpc-user-api.json#/components/schemas/Wallet" - } - }, - "RequestAccountsResult": { - "title": "RequestAccountsResult", - "type": "array", - "description": "An array of accounts that the user has authorized the dapp to access..", - "items": { - "$ref": "api-specs/openrpc-user-api.json#/components/schemas/Wallet" - } - }, - "CommandId": { - "title": "CommandId", - "type": "string", - "description": "The unique identifier of the command associated with the transaction." - }, - "TxChangedPendingEvent": { - "title": "TxChangedPendingEvent", - "description": "Event emitted when a transaction is pending.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusPending", - "type": "string", - "enum": ["pending"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - } - }, - "required": ["status", "commandId"] - }, - "TxChangedSignedPayload": { - "type": "object", - "title": "TxChangedSignedPayload", - "description": "Payload for the TxChangedSignedEvent.", - "additionalProperties": false, - "properties": { - "signature": { - "title": "signature", - "type": "string", - "description": "The signature of the transaction." - }, - "signedBy": { - "title": "signedBy", - "type": "string", - "description": "The identifier of the provider that signed the transaction." - }, - "party": { - "title": "party", - "type": "string", - "description": "The party that signed the transaction." - } - }, - "required": ["signature", "signedBy", "party"] - }, - "TxChangedSignedEvent": { - "title": "TxChangedSignedEvent", - "description": "Event emitted when a transaction has been signed.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusSigned", - "type": "string", - "enum": ["signed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "payload": { - "$ref": "#/components/schemas/TxChangedSignedPayload" - } - }, - "required": ["status", "commandId", "payload"] - }, - "TxChangedExecutedPayload": { - "type": "object", - "title": "TxChangedExecutedPayload", - "description": "Payload for the TxChangedExecutedEvent.", - "additionalProperties": false, - "properties": { - "updateId": { - "title": "updateId", - "type": "string", - "description": "The update ID corresponding to the transaction." - }, - "completionOffset": { - "title": "completionOffset", - "type": "integer" - } - }, - "required": ["updateId", "completionOffset"] - }, - "TxChangedExecutedEvent": { - "title": "TxChangedExecutedEvent", - "description": "Event emitted when a transaction is executed against the participant.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusExecuted", - "type": "string", - "enum": ["executed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - }, - "payload": { - "$ref": "#/components/schemas/TxChangedExecutedPayload" - } - }, - "required": ["status", "commandId", "payload"] - }, - "TxChangedFailedEvent": { - "title": "TxChangedFailedEvent", - "description": "Event emitted when a transaction has failed.", - "type": "object", - "additionalProperties": false, - "properties": { - "status": { - "title": "statusFailed", - "type": "string", - "enum": ["failed"], - "description": "The status of the transaction." - }, - "commandId": { - "$ref": "#/components/schemas/CommandId" - } - }, - "required": ["status", "commandId"] - }, - "TxChangedEvent": { - "title": "TxChangedEvent", - "description": "Event emitted when a transaction changes.", - "oneOf": [ - { - "$ref": "#/components/schemas/TxChangedPendingEvent" - }, - { - "$ref": "#/components/schemas/TxChangedSignedEvent" - }, - { - "$ref": "#/components/schemas/TxChangedExecutedEvent" - }, - { - "$ref": "#/components/schemas/TxChangedFailedEvent" - } - ] - }, - "StatusEvent": { - "title": "StatusEvent", - "type": "object", - "properties": { - "kernel": { - "$ref": "#/components/schemas/KernelInfo" - }, - "isConnected": { - "title": "isConnected", - "type": "boolean", - "description": "Whether or not the user is authenticated with the Wallet." - }, - "isNetworkConnected": { - "title": "isNetworkConnected", - "type": "boolean", - "description": "Whether or not a connection to a network is established." - }, - "networkReason": { - "title": "networkReason", - "type": "string", - "description": "If not connected to a network, the reason why." - }, - "userUrl": { - "$ref": "#/components/schemas/UserUrl" - }, - "network": { - "title": "network", - "type": "object", - "description": "Network information, if connected to a network.", - "properties": { - "networkId": { - "title": "networkId", - "type": "string", - "description": "A CAIP-2 compliant chain ID, e.g. 'canton:da-mainnet'." - }, - "ledgerApi": { - "title": "LedgerApiConfig", - "type": "object", - "description": "Ledger API configuration.", - "properties": { - "baseUrl": { - "title": "baseUrl", - "type": "string", - "format": "uri", - "description": "The base URL of the ledger API." - } - }, - "required": ["baseUrl"] - } - }, - "required": ["networkId"] - }, - "session": { - "title": "session", - "type": "object", - "description": "Session information, if authenticated.", - "properties": { - "accessToken": { - "title": "accessToken", - "type": "string", - "description": "JWT authentication token." - }, - "userId": { - "title": "userId", - "type": "string", - "description": "The user identifier." - } - }, - "required": ["accessToken", "userId"] - } - }, - "required": ["kernel", "isConnected", "isNetworkConnected"] } } } diff --git a/core/wallet-dapp-rpc-client/src/index.ts b/core/wallet-dapp-rpc-client/src/index.ts index 5542a348..5b119a85 100644 --- a/core/wallet-dapp-rpc-client/src/index.ts +++ b/core/wallet-dapp-rpc-client/src/index.ts @@ -421,6 +421,11 @@ export interface PrepareExecuteParams { packageIdSelectionPreference?: PackageIdSelectionPreference [k: string]: any } +/** + * + * Ledger API request structure + * + */ export interface LedgerApiParams { requestMethod: RequestMethod resource: Resource @@ -432,7 +437,6 @@ export interface StatusEvent { isConnected: IsConnected isNetworkConnected: IsNetworkConnected networkReason?: NetworkReason - userUrl?: UserUrl network?: Network session?: Session [k: string]: any diff --git a/core/wallet-dapp-rpc-client/src/openrpc.json b/core/wallet-dapp-rpc-client/src/openrpc.json index e5ffc419..3b9d71e7 100644 --- a/core/wallet-dapp-rpc-client/src/openrpc.json +++ b/core/wallet-dapp-rpc-client/src/openrpc.json @@ -12,7 +12,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Returns the current status of the wallet gateway session." @@ -23,7 +23,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/StatusEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/StatusEvent" } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId." @@ -34,7 +34,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/Null" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/Null" } }, "description": "Invoke a disconnect of the wallet gateway session." @@ -69,7 +69,7 @@ "name": "params", "schema": { "title": "prepareReturnParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -79,7 +79,7 @@ "title": "prepareReturnResult", "properties": { "response": { - "$ref": "#/components/schemas/JsPrepareSubmissionResponse" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionResponse" } }, "required": ["response"] @@ -94,7 +94,7 @@ "name": "params", "schema": { "title": "prepareExecuteParams", - "$ref": "#/components/schemas/JsPrepareSubmissionRequest" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsPrepareSubmissionRequest" } } ], @@ -105,7 +105,7 @@ "type": "object", "properties": { "tx": { - "$ref": "#/components/schemas/TxChangedExecutedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedEvent" } }, "required": ["tx"] @@ -120,30 +120,14 @@ "name": "params", "schema": { "title": "ledgerApiParams", - "type": "object", - "properties": { - "requestMethod": { - "title": "requestMethod", - "type": "string", - "enum": ["GET", "POST", "PUT", "DELETE"] - }, - "resource": { - "title": "resource", - "type": "string" - }, - "body": { - "title": "body", - "type": "string" - } - }, - "required": ["requestMethod", "resource"] + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiRequest" } } ], "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/LedgerApiResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/LedgerApiResult" } }, "description": "Proxy for the JSON-API endpoints. Injects authorization headers automatically." @@ -154,7 +138,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/AccountsChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/AccountsChangedEvent" } } }, @@ -164,7 +148,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/RequestAccountsResult" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/RequestAccountsResult" } }, "description": "Lists the addresses (wallets) with their properties; including which network they are associated to and with signing provider is used." @@ -175,7 +159,7 @@ "result": { "name": "result", "schema": { - "$ref": "#/components/schemas/TxChangedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedEvent" } } } @@ -209,7 +193,7 @@ "description": "The URL of the Wallet Gateway." }, "userUrl": { - "$ref": "#/components/schemas/UserUrl" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/UserUrl" } }, "required": ["id", "clientType"] @@ -238,10 +222,10 @@ "description": "Structure representing the request for prepare and execute calls", "properties": { "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "commands": { - "$ref": "#/components/schemas/JsCommands" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/JsCommands" }, "actAs": { "title": "actAs", @@ -266,7 +250,7 @@ "type": "array", "description": "List of contract IDs to be disclosed with the command.", "items": { - "$ref": "#/components/schemas/DisclosedContract" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/DisclosedContract" } }, "synchronizerId": { @@ -336,6 +320,27 @@ } } }, + "LedgerApiRequest": { + "title": "LedgerApiRequest", + "type": "object", + "description": "Ledger API request structure", + "properties": { + "requestMethod": { + "title": "requestMethod", + "type": "string", + "enum": ["GET", "POST", "PUT", "DELETE"] + }, + "resource": { + "title": "resource", + "type": "string" + }, + "body": { + "title": "body", + "type": "string" + } + }, + "required": ["requestMethod", "resource"] + }, "AccountsChangedEvent": { "title": "AccountsChangedEvent", "type": "array", @@ -370,7 +375,7 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" } }, "required": ["status", "commandId"] @@ -412,10 +417,10 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "payload": { - "$ref": "#/components/schemas/TxChangedSignedPayload" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedSignedPayload" } }, "required": ["status", "commandId", "payload"] @@ -451,10 +456,10 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" }, "payload": { - "$ref": "#/components/schemas/TxChangedExecutedPayload" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedPayload" } }, "required": ["status", "commandId", "payload"] @@ -472,7 +477,7 @@ "description": "The status of the transaction." }, "commandId": { - "$ref": "#/components/schemas/CommandId" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/CommandId" } }, "required": ["status", "commandId"] @@ -482,16 +487,16 @@ "description": "Event emitted when a transaction changes.", "oneOf": [ { - "$ref": "#/components/schemas/TxChangedPendingEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedPendingEvent" }, { - "$ref": "#/components/schemas/TxChangedSignedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedSignedEvent" }, { - "$ref": "#/components/schemas/TxChangedExecutedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedExecutedEvent" }, { - "$ref": "#/components/schemas/TxChangedFailedEvent" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/TxChangedFailedEvent" } ] }, @@ -500,7 +505,7 @@ "type": "object", "properties": { "kernel": { - "$ref": "#/components/schemas/KernelInfo" + "$ref": "api-specs/openrpc-dapp-api.json#/components/schemas/KernelInfo" }, "isConnected": { "title": "isConnected", @@ -517,9 +522,6 @@ "type": "string", "description": "If not connected to a network, the reason why." }, - "userUrl": { - "$ref": "#/components/schemas/UserUrl" - }, "network": { "title": "network", "type": "object", 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 546e1e4d..86309f37 100644 --- a/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts +++ b/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts @@ -421,6 +421,11 @@ export interface PrepareExecuteParams { packageIdSelectionPreference?: PackageIdSelectionPreference [k: string]: any } +/** + * + * Ledger API request structure + * + */ export interface LedgerApiParams { requestMethod: RequestMethod resource: Resource @@ -432,7 +437,6 @@ export interface StatusEvent { isConnected: IsConnected isNetworkConnected: IsNetworkConnected networkReason?: NetworkReason - userUrl?: UserUrl network?: Network session?: Session [k: string]: any diff --git a/sdk/dapp-sdk/src/provider/open.ts b/sdk/dapp-sdk/src/provider/open.ts index b08de093..cf6f2b0c 100644 --- a/sdk/dapp-sdk/src/provider/open.ts +++ b/sdk/dapp-sdk/src/provider/open.ts @@ -15,5 +15,5 @@ export async function open(): Promise { throw new Error('No previous session found') } - openKernelUserUI(discovery.walletType, session.status.kernel.userUrl ?? '') + openKernelUserUI(discovery.walletType, session.userUrl ?? '') } 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 546e1e4d..86309f37 100644 --- a/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts @@ -421,6 +421,11 @@ export interface PrepareExecuteParams { packageIdSelectionPreference?: PackageIdSelectionPreference [k: string]: any } +/** + * + * Ledger API request structure + * + */ export interface LedgerApiParams { requestMethod: RequestMethod resource: Resource @@ -432,7 +437,6 @@ export interface StatusEvent { isConnected: IsConnected isNetworkConnected: IsNetworkConnected networkReason?: NetworkReason - userUrl?: UserUrl network?: Network session?: Session [k: string]: any diff --git a/wallet-gateway/remote/src/dapp-api/controller.ts b/wallet-gateway/remote/src/dapp-api/controller.ts index 2c8b9ac8..03eb6441 100644 --- a/wallet-gateway/remote/src/dapp-api/controller.ts +++ b/wallet-gateway/remote/src/dapp-api/controller.ts @@ -9,6 +9,7 @@ import { PrepareExecuteParams, PrepareReturnParams, StatusEvent, + StatusEventAsync, } from './rpc-gen/typings.js' import { Store } from '@canton-network/core-wallet-store' import { @@ -58,7 +59,6 @@ export const dappController = ( isConnected: true, isNetworkConnected: status.isConnected, networkReason: status.reason ? status.reason : 'OK', - userUrl: `${userUrl}/login/`, network: { networkId: network.id, ledgerApi: { @@ -69,7 +69,8 @@ export const dappController = ( accessToken: context.accessToken, userId: context.userId, }, - } + userUrl: `${userUrl}/login/`, + } as StatusEventAsync }, disconnect: async () => { if (!context) { @@ -234,7 +235,8 @@ export const dappController = ( accessToken: context.accessToken, userId: context.userId, }, - } + userUrl: `${userUrl}/login/`, + } as StatusEventAsync }, onConnected: async () => { throw new Error('Only for events.') 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 8c9616eb..56a83837 100644 --- a/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts @@ -105,6 +105,12 @@ export type ClientType = 'browser' | 'desktop' | 'mobile' | 'remote' * */ export type Url = string +/** + * + * A URL that points to a user interface. + * + */ +export type UserUrl = string /** * * Represents a Wallet Gateway. @@ -114,6 +120,7 @@ export interface KernelInfo { id: Id clientType: ClientType url?: Url + userUrl?: UserUrl [k: string]: any } /** @@ -134,12 +141,6 @@ export type IsNetworkConnected = boolean * */ export type NetworkReason = string -/** - * - * A URL that points to a user interface. - * - */ -export type UserUrl = string /** * * The network ID the wallet corresponds to. @@ -193,6 +194,19 @@ export interface Session { userId: UserId [k: string]: any } +export interface StatusEvent { + kernel: KernelInfo + isConnected: IsConnected + isNetworkConnected: IsNetworkConnected + networkReason?: NetworkReason + network?: Network + session?: Session + [k: string]: any +} +export interface ObjectOfUserUrlMkZ1IR2Z { + userUrl: UserUrl + [k: string]: any +} export type Dar = string export type Dars = Dar[] /** @@ -420,22 +434,18 @@ export interface PrepareExecuteParams { packageIdSelectionPreference?: PackageIdSelectionPreference [k: string]: any } +/** + * + * Ledger API request structure + * + */ export interface LedgerApiParams { requestMethod: RequestMethod resource: Resource body?: Body [k: string]: any } -export interface StatusEvent { - kernel: KernelInfo - isConnected: IsConnected - isNetworkConnected: IsNetworkConnected - networkReason?: NetworkReason - userUrl?: UserUrl - network?: Network - session?: Session - [k: string]: any -} +export type StatusEventAsync = StatusEvent & ObjectOfUserUrlMkZ1IR2Z /** * * Represents a null value, used in responses where no data is returned. @@ -489,7 +499,7 @@ export type TxChangedEvent = */ export type Status = () => Promise -export type Connect = () => Promise +export type Connect = () => Promise export type Disconnect = () => Promise export type DarsAvailable = () => Promise export type PrepareReturn = ( diff --git a/wallet-gateway/remote/src/user-api/controller.ts b/wallet-gateway/remote/src/user-api/controller.ts index 1dbdf0c6..e1994be7 100644 --- a/wallet-gateway/remote/src/user-api/controller.ts +++ b/wallet-gateway/remote/src/user-api/controller.ts @@ -586,7 +586,10 @@ export const userController = ( }) const status = await networkStatus(ledgerClient) notifier.emit('onConnected', { - kernel: kernelInfo, + kernel: { + ...kernelInfo, + userUrl: `${userUrl}/login/`, + }, isConnected: true, isNetworkConnected: status.isConnected, networkReason: status.reason ? status.reason : 'OK', diff --git a/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts b/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts index 7ca2c7b0..d70933ae 100644 --- a/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts +++ b/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts @@ -342,7 +342,6 @@ export interface ExecuteParams { } export interface AddSessionParams { networkId: NetworkId - idp: Idp [k: string]: any } export interface GetTransactionParams {