ReadonlyordersReadonlyorderReadonlyregistryReadonlyregistryReadonlysettingsReadonlysettingsGets details for all orders in the registry.
This method extracts name and description information for each order, useful for building the initial order selection UI.
const result = await registry.getAllOrderDetails();
if (result.error) {
console.error("Failed to get order details:", result.error.readableMsg);
return;
}
const orderDetails = result.value;
// Map of order key -> {name, description, short_description}
for (const [orderKey, details] of orderDetails) {
console.log(`${orderKey}: ${details.name}`);
}
Map of order key to order metadata
Gets deployment details for a specific order.
This method extracts deployment information for a given order, useful for building the deployment selection UI.
const result = await registry.getDeploymentDetails("fixed-limit");
if (result.error) {
console.error("Failed to get deployment details:", result.error.readableMsg);
return;
}
const deploymentDetails = result.value;
// Map of deployment key -> {name, description, short_description}
for (const [deploymentKey, details] of deploymentDetails) {
console.log(`${deploymentKey}: ${details.name}`);
}
Order key to get deployment details for
Map of deployment key to deployment metadata
Creates a DotrainOrderGui instance for a specific order and deployment.
This is a convenience method that combines getting a DotrainOrder and creating a GUI.
// Simple usage without state callback
const result = await registry.getGui("fixed-limit", "mainnet-deployment");
if (result.error) {
console.error("Failed to create GUI:", result.error.readableMsg);
return;
}
const gui = result.value;
// Usage with state update callback for auto-saving
const stateCallback = (newState) => {
localStorage.setItem('gui-state', JSON.stringify(newState));
};
const resultWithCallback = await registry.getGui(
"fixed-limit",
"mainnet-deployment",
undefined,
stateCallback
);
// Usage restoring from serialized state (with optional callback)
const savedState = localStorage.getItem('gui-state');
const resultFromState = await registry.getGui(
"fixed-limit",
"mainnet-deployment",
savedState,
stateCallback
);
Order key to fetch the GUI for
Deployment key to create the GUI for
OptionalserializedState: null | stringOptional serialized GUI state string used to restore form progress before falling back to deployment defaults
OptionalstateUpdateCallback: null | FunctionOptional function called on state changes. After a state change (deposit, field value, vault id, select token, etc.), the callback is called with the new state. This is useful for auto-saving the state of the GUI across sessions.
DotrainOrderGui instance for the specified order and deployment
Returns a list of all order keys available in the registry.
Use this method to get the available order identifiers.
const result = await registry.getOrderKeys();
if (result.error) {
console.error("Failed to fetch order keys:", result.error.readableMsg);
return;
}
const keys = result.value;
console.log("Available orders:", keys);
Array of order keys available in the registry
StaticnewCreates a new DotrainRegistry instance by fetching and parsing the registry file.
The registry file should contain a settings YAML URL on the first line (without a key), followed by order entries in the format "key url".
const result = await DotrainRegistry.new("https://example.com/registry.txt");
if (result.error) {
console.error("Registry creation failed:", result.error.readableMsg);
return;
}
const registry = result.value;
URL to the registry file containing settings and order definitions
DotrainRegistry instance with settings and orders loaded
A registry system for managing dotrain order configurations with layered content merging.
The
DotrainRegistryprovides a centralized way to fetch, parse, and manage dotrain order strategies from remote sources. It supports a layered architecture where shared settings are merged with individual order configurations.Registry File Format
The registry file follows a specific format:
Content Merging
For each order, the final dotrain content is created by merging:
This allows strategies to share common network configurations, tokens, and other settings while maintaining their individual logic.
Usage Flow
Examples