ADODatabaseAPI

Class

API for ADODB specific messages.

export default class ADODatabaseAPI extends ADOAPI {
  constructor(client: AndromedaClient, public address: string = "") {
    super(client, address);
  }

getCodeIdQuery

Provides a message object for the factory's GetCodeId query.

  getCodeIdQuery(name: string) {
    return {
      code_id: {
        key: name,
      },
    };
  }

getCodeId

Gets the code ID for an ADO type from the ADO DB

 async getCodeId(name: string, address?: string) {
    if (!this.address && !address)
      throw new Error("No provided ADO DB address to retrieve code ID");

    const msg = this.getCodeIdQuery(name);

    return this.client.queryContract<number>(address ?? this.address, msg);
  }

getADOType

Retrieves the type of ADO from the provided code ID and ADO DB contract address.

async getAdoType(codeId: number, address?: string) {
    if (!this.address && !address)
      throw new Error("No provided ADO DB address to retrieve code ID");

    const msg = this.getAdoTypeQuery(codeId);

    return this.client.queryContract<string>(address ?? this.address, msg);
  }

getAllADOQuery

Provides a message object for the ADO DB's 'getAllADO' query.

  getAllADOQuery(startAfter = '', limit = 100) {
    return {
      all_ado_types: {
        limit,
        start_after: startAfter
      },
    };
  }

getAllADO

  async getAllADO(startAfter = '', limit = 100, address?: string) {
    if (!this.address && !address)
      throw new Error("No provided ADO DB address to retrieve code ID");

    const msg = this.getAllADOQuery(startAfter, limit);

    return this.client.queryContract<string[]>(address ?? this.address, msg);
  }
}

Last updated