Queries

Create a query into Axiom with the Axiom SDK

Creating a query

newQueryBuilder

newQueryBuilder(): QueryBuilder

Construct a new query instance.

append

async append(queryRow: QueryRow)

Appends a QueryRow to the current QueryBuilder instance. If the QueryBuilder has reached its maximum size, or if validation for that QueryRow fails, then an error will be thrown.

appendWithoutValidation

async appendWithoutValidation(queryRow: QueryRow)

Appends a QueryRow to the current QueryBuilder instance without validating the values first. If there are invalid values (such as the account address being an empty account at the specified block number), then the proof generation of the query will fail after submitting the transaction, making it impossible to fulfill the query onchain.

build

async build(): Promise<QueryBuilderResponse>

Builds the query response and query data to be sent to the Axiom contract.

Returns an object with the following values:

keccackQueryResponse:an identifier associated with the query onchain.

queryHash: an identifier associated with the query offchain.

query:

getCurrentSize

getCurrentSize(): number

Returns the current number of QueryRows appended to the instance of QueryBuilder.

getRemainingSize

 getRemainingSize(): number

Returns the number of QueryRows that can still be appended

getMaxSize

getMaxSize(): number

Returns the maximum number of QueryRows that the current instance of QueryBuilder supports.

getResponseTree

getResponseTree(): ResponseTree | undefined

Returns the ResponseTree for the current set of queries if build() has been called.

sortQueries

private sortQueries(): QueryRow[]

Sorts queries in order of blockNumber, address, and slot.

formatQueries

private formatQueries(queries: QueryRow[]): string

Formats queries into a pretty-printable string.

asFormattedString

asFormattedString(): string

Returns the current QueryRow values as a formatted string in the order that they were appended.

buildQueryResponse

private async buildQueryResponse(sortedQueries: QueryRow[]): Promise<string> 

Builds a queryResponse from the sorted queries.

Returns a queryResponse.

Last updated