DappJson
Wire codec for the CIP-0103 types, written against OpenRPC 0.5.0.
Hand-written over kotlinx-serialization's JsonElement API rather than generated from @Serializable: no compiler plugin, no reflection, and therefore nothing for R8 to strip on Android — the same choice :canton-wallet-sdk made for the registry APIs.
Encoding rule, applied throughout: omit absent optionals, never emit null for them. A wallet that emits "reason": null is not wrong by JSON-RPC, but round-tripping it changes the document, and the golden vectors in testdata/dapp/ assert that decode-then-encode is a fixpoint. Decoding is the tolerant direction — an explicit null reads as absent.
Every decode… throws DappException with DappErrorCode.INVALID_PARAMS, naming the field that was missing or of the wrong shape; every encode… is total.
Functions
Decodes a ListAccountsResult.
Decodes a ConnectResult.
Decodes a notification into a DappEvent, or null when notification names a method that is not an event. Null rather than an exception: an unknown notification is something to ignore, not something to fail a session over.
Decodes a prepareExecuteAndWaitResult, insisting the nested tx is in the executed state — any other state there is a protocol error.
Decodes LedgerApiRequest params. An unknown requestMethod is rejected.
Decodes a MessageSignatureEvent, picking the sealed case from status. An unknown status is rejected.
Decodes a Network.
Decodes JsPrepareSubmissionRequest params; absent lists read as empty.
Decodes a JsPrepareSubmissionResponse.
Decodes a Provider. An unknown providerType is rejected rather than dropped.
Decodes a Session.
Decodes SignMessageRequest params.
Decodes a SignMessageResult.
Decodes a StatusEvent.
Decodes a TxChangedEvent, picking the sealed case from status. An unknown status is rejected.
Decodes one Wallet. An unknown status is rejected rather than dropped.
Encodes a ConnectResult.
Encodes a Network.
Encodes a Provider.
Encodes a Session.
Encodes a StatusEvent, nesting the provider, connection, network and session shapes.
Encodes one Wallet.
Encodes LedgerApiRequest params; body, query and path are passed through as raw JSON.
Encodes a MessageSignatureEvent; signature is present only for signed.
Encodes JsPrepareSubmissionRequest params. Empty party and package lists are omitted, not emitted as [].
Encodes a JsPrepareSubmissionResponse.
Encodes SignMessageRequest params.
Encodes a SignMessageResult.
Encodes a TxChangedEvent: status and commandId always, payload only for signed and executed.
Encodes a ListAccountsResult: an array of Wallet.
A wallet-to-dApp event as a JSON-RPC notification. The event name is the notification's method, and its payload is params.
prepareExecuteAndWaitResult — an executed txChanged under tx.