@exodus/domain-serialization
Version: 0.0.0
Functions
Type Aliases
AssetApiProxyFunction
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
DomainDeserializationHandler
Deserializes a string representation of a domain object instance.
DomainSerialization
Wrapper containing handlers for serialization and deserialization of domain objects
DomainSerializationConfig
The configuration for trivial serialization and deserialization of domain objects.
DomainSerializationHandler
Serializes a domain object to a string representation
TypeDefinition
UIDomainSerializationConfig
The configuration for serializaton and deserialization of domain objects, tweaked to work with the UI process
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
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:
PromiseA 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.
createDomainSerialization
function
Signature
createDomainSerialization(config?: DomainSerializationConfig): DomainSerialization
Create serialization handlers for a wide range of domain and native objects
Parameters:
Returns:
DomainSerializationThe 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:
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:
Returns:
stringAn object representing the serialized asset
serializeAssets
function
Signature
serializeAssets(assets: DictionaryOrArray): DictionaryOrArray
Serializes an array or dictionary of assets.
