Skip to Content
Hydra@exodus/domain-serialization

@exodus/domain-serialization

Version: 0.0.0

AssetApiProxyFunction

type
A function to handle proxy calls for asset APIs, allowing dynamic routing of API calls to specific asset instances. This function serializes arguments for remote execution and handles the return of deserialized results.

DictionaryOrArray

type

DomainDeserializationHandler

type
Deserializes a string representation of a domain object instance.

DomainSerialization

type
Wrapper containing handlers for serialization and deserialization of domain objects

DomainSerializationConfig

type
The configuration for trivial serialization and deserialization of domain objects.

Properties

deserializeAsset?
Function to customize the assets deserialization
any
deserializeAssets?
Function to customize assets deserialization, is preferred over `deserializeAsset` if both are informed
any
excludeSerialization?
A dictionary of domain object types to be skipped from domain serialization, keys should be in lowercase
Record
extraTypeDefinitions?
An array of extra type definitions that are specific to a project and don't make sense to be upstreamed into this library
serializeAsset?
Function to customize the assets serialization
any

DomainSerializationHandler

type
Serializes a domain object to a string representation

TypeDefinition

type

Properties

deserialize
any
serialize
any
test
any
type
string

UIDomainSerializationConfig

type
The configuration for serializaton and deserialization of domain objects, tweaked to work with the UI process

Properties

getStoredAssets
any

assetsApi

function

Signature

assetsApi(asset: object, functionName: string, args: any[]): Promise
Proxy function to perform API calls on an asset, calling the appropriate method on the asset's API. Serializes arguments for the API call and deserializes the response.

Parameters:

asset: object
The asset object to call the API on
functionName: string
Name of the function to call on the asset's API
args: any[]
Arguments for the function

Returns:

Promise
A promise that resolves with the serialized result of the API call

createBackendDomainSerialization

function

Signature

createBackendDomainSerialization(): DomainSerialization
Creates a domain serialization handler specifically for backend wallet processes. This handler customizes serialization and deserialization of assets for backend use cases, including error handling for deserialization attempts in unsupported scenarios.

Returns:

DomainSerialization
Serialization handlers tweaked to work in the UI process

createDomainSerialization

function

Signature

createDomainSerialization(config?: DomainSerializationConfig): DomainSerialization
Create serialization handlers for a wide range of domain and native objects

Parameters:

config (optional): DomainSerializationConfig
Overrides and tweaks for serialization/deserialization

Returns:

DomainSerialization
The handlers for both serialization and deserialization of domain objects

createUIDomainSerialization

function

Signature

createUIDomainSerialization(config: UIDomainSerializationConfig): DomainSerialization
Creates a domain serialization handler specifically for UI wallet processes. This handler customizes serialization and deserialization of assets, ensuring assets are serialized in a lightweight, proxied form suitable for the UI.

Parameters:

config: UIDomainSerializationConfig
Configuration object for UI domain serialization

Returns:

DomainSerialization
Serialization handlers tweaked to work in the UI process

deserializeAssets

function

Signature

deserializeAssets(assetsList: string[], assets: Record, proxyFunction: any): object[]
Deserializes an array of assets for use in the application. Also takes into consideration dependencies between assets

Parameters:

assetsList: string[]
List of assets to deserialize
assets: Record
All available assets
proxyFunction: any
A function to handle proxy calls for asset APIs

Returns:

object[]
An array of fully deserialized asset objects

serializeAsset

function

Signature

serializeAsset(asset: AbstractAsset): string
Serializes an asset object to a serializable format. Removes server-side-only properties and serializes specific fields.

Parameters:

asset: AbstractAsset
The asset object to be serialized

Returns:

string
An object representing the serialized asset

serializeAssets

function

Signature

serializeAssets(assets: DictionaryOrArray): DictionaryOrArray
Serializes an array or dictionary of assets.

Parameters:

assets: DictionaryOrArray
Assets to be serialized

Returns:

DictionaryOrArray
The deserialized assets

Start building

XO

Request Demo

Schedule a call with our team

Select a product
Arrow right

Start building
Grateful

Contact Us

We're here to help