Primitive

The GraphQL queries that can be performed on the Primitive ADO.

Response Interface

export interface PrimitiveResponse<T> {
  primitive: T;
}

queryPrimitive

Queries details about a primitive given its contract address.

export async function queryPrimitive(contractAddress: string) {
  const resp = await query<QueryPrimitive, QueryPrimitiveResponse>(
    QUERY_PRIMITIVE,
    {
      contractAddress,
    }
  );
 return resp.primitive.owner;
}
NameTypeDescription

contractAddress

string

The address of the primitive contract to query.

QueryPrimitive

export interface QueryPrimitive extends ContractAddressQuery {}

QueryPrimitiveResponse

export type QueryPrimitiveResponse = PrimitiveResponse<{
  owner: string;
}>;
NameTypeDescription

owner

string

The address of the owner of the primitive contract.

queryPrimitiveValue

Query the value stored for the specified key.

export async function queryPrimitiveValue(
  contractAddress: string,
  key: string
) {
  const resp = await query<QueryPrimitiveValue, QueryPrimitiveValueResponse>(
    QUERY_PRIMITIVE_VALUE,
    {
      contractAddress,
      key,
    }
  );
  return resp.primitive.getValue;
}
NameTypeDescription

contractAddress

string

The contract address of the primitive ADO to query.

key

string

The key to get the value for.

QueryPrimitiveValue

export interface QueryPrimitiveValue extends ContractAddressQuery {
  key: string;
}

QueryPrimitiveValueResponse

export type QueryPrimitiveValueResponse = PrimitiveResponse<{
  getValue: PrimitiveValueResponse;
}>;
NameTypeDescription

getValue

The key and value pair.

PrimitiveResponse

export interface PrimitiveValueResponse {
  key: string;
  value: PrimitiveValue;
}
NameTypeDescription

key

string

The key.

value

The value.

PrimitiveValue

export type PrimitiveValue =
  | StringPrimitive
  | Uint128Primitive
  | DecimalPrimitive
  | CoinPrimitive
  | BoolPrimitive
  | VecPrimitive;

Return the appropriate value based on its type.

Last updated