Skip to content

Latest commit

 

History

History
202 lines (147 loc) · 12.6 KB

File metadata and controls

202 lines (147 loc) · 12.6 KB

Nodes

(nodes)

Overview

Nodes Management

Available Operations

nodesCreate

This endpoint allows nodes to register or update their public address in the system. When a node comes online or changes its address, it can use this endpoint to ensure the system has its current address for routing requests.

Errors

Returns various AtomaProxyError variants:

  • MissingHeader - If the signature header is missing
  • InvalidHeader - If the signature header is malformed
  • InvalidBody - If:
    • The request body cannot be read
    • The signature is invalid
    • The body cannot be parsed
    • The sui address doesn't match the signature
  • InternalError - If:
    • The state manager channel is closed
    • The registration event cannot be sent
    • Node Sui address lookup fails

Example Usage

import { AtomaSDK } from "atoma-sdk";

const atomaSDK = new AtomaSDK({
  bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});

async function run() {
  const result = await atomaSDK.nodes.nodesCreate({
    data: {
      country: "Andorra",
      nodeSmallId: 3665,
      publicAddress: "<value>",
    },
    signature: "<value>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AtomaSDKCore } from "atoma-sdk/core.js";
import { nodesNodesCreate } from "atoma-sdk/funcs/nodesNodesCreate.js";

// Use `AtomaSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const atomaSDK = new AtomaSDKCore({
  bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await nodesNodesCreate(atomaSDK, {
    data: {
      country: "Andorra",
      nodeSmallId: 3665,
      publicAddress: "<value>",
    },
    signature: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.NodesCreateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.NodesCreateResponse>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

nodesCreateLock

This endpoint attempts to find a suitable node and retrieve its public key for encryption through a two-step process:

  1. First, it tries to select an existing node with a public key directly.
  2. If no node is immediately available, it falls back to finding the cheapest compatible node and acquiring a new stack entry for it.

This endpoint is specifically designed for confidential compute scenarios where requests need to be encrypted before being processed by nodes.

Errors

  • INTERNAL_SERVER_ERROR - Communication errors or missing node public keys
  • SERVICE_UNAVAILABLE - No nodes available for confidential compute

Example Usage

import { AtomaSDK } from "atoma-sdk";

const atomaSDK = new AtomaSDK({
  bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});

async function run() {
  const result = await atomaSDK.nodes.nodesCreateLock({
    model: "Focus",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AtomaSDKCore } from "atoma-sdk/core.js";
import { nodesNodesCreateLock } from "atoma-sdk/funcs/nodesNodesCreateLock.js";

// Use `AtomaSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const atomaSDK = new AtomaSDKCore({
  bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});

async function run() {
  const res = await nodesNodesCreateLock(atomaSDK, {
    model: "Focus",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.NodesCreateLockRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.NodesCreateLockResponse>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*