OperatingSystemAPI

Class

Class to interact with teh aOS contracts.

export default class OperatingSystemAPI extends ADOAPI {
  public vfs?: VirtualFileSystemAPI;
  public adoDB?: ADODatabaseAPI;

  constructor(client: AndromedaClient, public address: string = "") {
    super(client, address);
  }
NameTypeDescription

vfs

The VFS API.

adoDB

The ADODB API.

assignKernelAddress

Assigns the kernel address before fetching any key addresses

async assignKernelAddress(address: string) {
    this.address = address;
    await this.fetchVFSAddress();
    await this.fetchADODBAddress();
  }
NameTypeDescription

address

string

The address of the kernel to assign.

fetchVFSAddress

Fetches the current VFS address from the kernel

async fetchVFSAddress() {
    const vfsKey = "vfs";
    const vfsAddress = await this.fetchKeyAddress(vfsKey);

    this.vfs = new VirtualFileSystemAPI(this.client, vfsAddress);
  }

fetchADODBAddress

Fetches the current ADODB address from the kernel.

async fetchADODBAddress() {
    const adoDBKey = "adodb";
    const adoDBAddress = await this.fetchKeyAddress(adoDBKey);
    this.adoDB = new ADODatabaseAPI(this.client, adoDBAddress);
  }

getKeyAddressMessage

Generates a 'KeyAddress' kernel query for a given key

getKeyAddressMessage(key: string) {
    return {
      key_address: {
        key,
      },
    };
  }
NameTypeDescription

key

string

The key to get the address for.

fetchKeyAddress

Fetches a key address for a given key from the currently assigned kernel

 async fetchKeyAddress(key: string) {
    this.preMessage();
    if (!key || key.length === 0)
      throw new Error("Cannot fetch empty key address from kernel");

    return this.client.queryContract(
      this.address,
      this.getKeyAddressMessage(key)
    );
  }
}
NameTypeDescription

address

string

The address of the kernel to assign.

Last updated