Raindex SDK Documentation
    Preparing search index...

    Class DotrainRegistry

    WASM wrapper around [raindex_common::registry::DotrainRegistry].

    The registry system manages dotrain order configurations with layered content merging. The platform-agnostic business logic (fetching, parsing, validation, metadata extraction) lives in raindex_common::registry; this type adds the WASM bindings, js_sys::Function state-update callbacks, and JsValue error conversions on top.

    The registry file follows a specific format:

    • First line: URL to shared settings YAML file (without a key)
    • Subsequent lines: Order entries in format "key url"
    https://example.com/shared-settings.yaml
    fixed-limit https://example.com/fixed-limit.rain
    auction-dca https://example.com/auction-dca.rain
    
    // Initialize registry
    const registry = await DotrainRegistry.new("https://example.com/registry.txt");

    // Get available orders
    const orders = await registry.getAllOrderDetails();

    // Get deployments for specific order
    const deployments = await registry.getDeploymentDetails("fixed-limit");

    // Create order builder instance
    const builder = await registry.getOrderBuilder("fixed-limit", "mainnet", stateCallback);
    Index

    Properties

    orders: OrderUrls
    orderUrls: OrderUrls
    registry: string
    registryUrl: string
    settings: string
    settingsUrl: string

    Methods

    • Returns void

    • Returns void

    • Gets 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. Any order that fails to parse/validate will be placed in the invalid map with its corresponding error.

      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}`);
      }

      Returns WasmEncodedResult<
          {
              invalid: Map<string, WasmEncodedError>;
              valid: Map<string, NameAndDescriptionCfg>;
          },
      >

      Valid and invalid order metadata grouped by order key

    • 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}`);
      }

      Parameters

      • orderKey: string

        Order key to get deployment details for

      Returns WasmEncodedResult<Map<string, NameAndDescriptionCfg>>

      Map of deployment key to deployment metadata

    • Creates a RaindexOrderBuilder instance for a specific order and deployment.

      This is a convenience method that combines getting a DotrainOrder and creating a builder.

      // Simple usage without state callback
      const result = await registry.getOrderBuilder("fixed-limit", "mainnet-deployment");
      if (result.error) {
      console.error("Failed to create order builder:", result.error.readableMsg);
      return;
      }
      const builder = result.value;

      // Usage with state update callback for auto-saving
      const stateCallback = (newState) => {
      localStorage.setItem('builder-state', JSON.stringify(newState));
      };
      const resultWithCallback = await registry.getOrderBuilder(
      "fixed-limit",
      "mainnet-deployment",
      undefined,
      stateCallback
      );

      // Usage restoring from serialized state (with optional callback)
      const savedState = localStorage.getItem('builder-state');
      const resultFromState = await registry.getOrderBuilder(
      "fixed-limit",
      "mainnet-deployment",
      savedState,
      stateCallback
      );

      Parameters

      • orderKey: string

        Order key to fetch the order builder for

      • deploymentKey: string

        Deployment key to create the order builder for

      • OptionalserializedState: null | string

        Optional serialized builder state string used to restore form progress before falling back to deployment defaults

      • OptionalstateUpdateCallback: null | Function

        Optional 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 builder across sessions.

      Returns Promise<WasmEncodedResult<RaindexOrderBuilder>>

      RaindexOrderBuilder 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);

      Returns WasmEncodedResult<string[]>

      Array of order keys available in the registry

    • Creates a RaindexClient instance from the registry's shared settings.

      const clientResult = await registry.getRaindexClient({
      localDb,
      statusCallback: updateStatus,
      });
      if (clientResult.error) {
      console.error("Failed to get RaindexClient:", clientResult.error.readableMsg);
      return;
      }
      const raindexClient = clientResult.value;

      Parameters

      • Optionaloptions: any

        Optional setup object with localDb and statusCallback

      Returns Promise<WasmEncodedResult<RaindexClient>>

      RaindexClient instance from registry settings

    • Creates an RaindexYaml instance from the registry's shared settings.

      This method provides access to the RaindexYaml SDK, allowing you to query tokens, networks, raindexes, and other configuration from the shared settings YAML.

      const yamlResult = registry.getRaindexYaml();
      if (yamlResult.error) {
      console.error("Failed to get RaindexYaml:", yamlResult.error.readableMsg);
      return;
      }
      const raindexYaml = yamlResult.value;

      Returns WasmEncodedResult<RaindexYaml>

      RaindexYaml instance from registry settings

    • Creates 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;

      Parameters

      • registryUrl: string

        URL to the registry file containing settings and order definitions

      Returns Promise<WasmEncodedResult<DotrainRegistry>>

      DotrainRegistry instance with settings and orders loaded

    • Validates a registry file without downloading settings or order content.

      Useful for lightweight format checks (e.g., user-input registry URLs) before performing a full registry load.

      Parameters

      • registryUrl: string

        URL to the registry file containing settings and order definitions

      Returns Promise<WasmEncodedResult<void>>

      Validates the registry URL and format without fetching settings or orders