API for ADODB specific messages.
export default class ADODatabaseAPI extends ADOAPI {
constructor(client: AndromedaClient, public address: string = "") {
super(client, address);
}
getCodeIdQuery(name: string) {
return {
code_id: {
key: name,
},
};
}
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);
}
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);
}
Provides a message object for the ADO DB's 'getAllADO' query.
getAllADOQuery(startAfter = '', limit = 100) {
return {
all_ado_types: {
limit,
start_after: startAfter
},
};
}
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);
}
}