From e6a11f30f392bf7f8e8b0ce988ae4395bd4610b5 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:41:39 +0100 Subject: [PATCH] Node.js update query parameters (#1550) * Node.js: update query parameters * Use HexEncodedString instead of String * Update bindings/nodejs/lib/types/client/query-parameters.ts * Update bindings/nodejs/lib/types/client/bridge/client.ts --------- Co-authored-by: Thibault Martinez Co-authored-by: Thibault Martinez --- .../examples/client/05-get-address-balance.ts | 12 +- .../how_tos/account_wallet/transaction.ts | 8 +- .../examples/how_tos/client/get-outputs.ts | 16 +- bindings/nodejs/lib/client/client.ts | 442 +++++++++--------- .../nodejs/lib/types/client/bridge/client.ts | 184 ++++---- .../lib/types/client/query-parameters.ts | 317 ++++++------- .../node_api/indexer/query_parameters.rs | 21 +- 7 files changed, 491 insertions(+), 509 deletions(-) diff --git a/bindings/nodejs/examples/client/05-get-address-balance.ts b/bindings/nodejs/examples/client/05-get-address-balance.ts index 9f8491b8cb..1c9b3f6b2d 100644 --- a/bindings/nodejs/examples/client/05-get-address-balance.ts +++ b/bindings/nodejs/examples/client/05-get-address-balance.ts @@ -38,12 +38,12 @@ async function run() { }); // Get output ids of basic outputs that can be controlled by this address without further unlock constraints - const outputIdsResponse = await client.basicOutputIds([ - { address: addresses[0] }, - { hasExpiration: false }, - { hasTimelock: false }, - { hasStorageDepositReturn: false }, - ]); + const outputIdsResponse = await client.basicOutputIds({ + address: addresses[0], + hasExpiration: false, + hasTimelock: false, + hasStorageDepositReturn: false, + }); // Get outputs by their IDs const addressOutputs = await client.getOutputs(outputIdsResponse.items); diff --git a/bindings/nodejs/examples/how_tos/account_wallet/transaction.ts b/bindings/nodejs/examples/how_tos/account_wallet/transaction.ts index 3d5b375a90..aa7176e992 100644 --- a/bindings/nodejs/examples/how_tos/account_wallet/transaction.ts +++ b/bindings/nodejs/examples/how_tos/account_wallet/transaction.ts @@ -54,11 +54,9 @@ async function run() { ); // Find first output unlockable by the account address - const queryParameters = [ - { - address: accountAddress, - }, - ]; + const queryParameters = { + address: accountAddress, + }; const input = ( await (await wallet.getClient()).basicOutputIds(queryParameters) ).items[0]; diff --git a/bindings/nodejs/examples/how_tos/client/get-outputs.ts b/bindings/nodejs/examples/how_tos/client/get-outputs.ts index ebbef29b82..0f58a6b84d 100644 --- a/bindings/nodejs/examples/how_tos/client/get-outputs.ts +++ b/bindings/nodejs/examples/how_tos/client/get-outputs.ts @@ -21,15 +21,13 @@ async function run() { try { // Get output ids of basic outputs that can be controlled by this address without further unlock constraints - const outputIdsResponse = await client.basicOutputIds([ - { - address: - 'rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy', - }, - { hasExpiration: false }, - { hasTimelock: false }, - { hasStorageDepositReturn: false }, - ]); + const outputIdsResponse = await client.basicOutputIds({ + address: + 'rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy', + hasExpiration: false, + hasTimelock: false, + hasStorageDepositReturn: false, + }); console.log('First output of query:'); console.log('ID: ', outputIdsResponse.items[0]); diff --git a/bindings/nodejs/lib/client/client.ts b/bindings/nodejs/lib/client/client.ts index c74553c68c..26e4eb1213 100644 --- a/bindings/nodejs/lib/client/client.ts +++ b/bindings/nodejs/lib/client/client.ts @@ -4,21 +4,21 @@ import { ClientMethodHandler } from './client-method-handler'; import { IClientOptions, - QueryParameter, PreparedTransactionData, INetworkInfo, INode, IAuth, - BasicOutputBuilderParams, AccountOutputBuilderParams, + BasicOutputBuilderParams, FoundryOutputBuilderParams, NftOutputBuilderParams, - FoundryQueryParameter, - NftQueryParameter, - AccountQueryParameter, - AnchorQueryParameter, - GenericQueryParameter, - DelegationQueryParameter, + AccountOutputQueryParameters, + AnchorOutputQueryParameters, + BasicOutputQueryParameters, + DelegationOutputQueryParameters, + FoundryOutputQueryParameters, + NftOutputQueryParameters, + OutputQueryParameters, } from '../types/client'; import type { INodeInfoWrapper } from '../types/client/nodeInfo'; import { @@ -100,38 +100,6 @@ export class Client { return JSON.parse(response).payload; } - /** - * Fetch alias/basic/NFT/foundry output IDs based on the given query parameters. - */ - async outputIds( - queryParameters: GenericQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'outputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Fetch basic output IDs based on the given query parameters. - */ - async basicOutputIds( - queryParameters: QueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'basicOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - /** * Get output from a given output ID. */ @@ -571,186 +539,6 @@ export class Client { return JSON.parse(response).payload; } - /** - * Get the corresponding output IDs given a list of account query parameters. - * - * @param queryParameters An array of `AccountQueryParameter`s. - * @returns A paginated query response of corresponding output IDs. - */ - async accountOutputIds( - queryParameters: AccountQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'accountOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output ID from an account ID. - * - * @param accountId An account ID. - * @returns The corresponding output ID. - */ - async accountOutputId(accountId: AccountId): Promise { - const response = await this.methodHandler.callMethod({ - name: 'accountOutputId', - data: { - accountId, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output IDs given a list of anchor query parameters. - * - * @param queryParameters An array of `AnchorQueryParameter`s. - * @returns A paginated query response of corresponding output IDs. - */ - async anchorOutputIds( - queryParameters: AnchorQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'anchorOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output ID from an anchor ID. - * - * @param anchorId An anchor ID. - * @returns The corresponding output ID. - */ - async anchorOutputId(anchorId: AnchorId): Promise { - const response = await this.methodHandler.callMethod({ - name: 'anchorOutputId', - data: { - anchorId, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output IDs given a list of delegation query parameters. - * - * @param queryParameters An array of `DelegationQueryParameter`s. - * @returns A paginated query response of corresponding output IDs. - */ - async delegationOutputIds( - queryParameters: DelegationQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'delegationOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output ID from an delegation ID. - * - * @param delegationId A delegation ID. - * @returns The corresponding output ID. - */ - async delegationOutputId(delegationId: DelegationId): Promise { - const response = await this.methodHandler.callMethod({ - name: 'delegationOutputId', - data: { - delegationId, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output IDs given a list of Foundry query parameters. - * - * @param queryParameters An array of `FoundryQueryParameter`s. - * @returns A paginated query response of corresponding output IDs. - */ - async foundryOutputIds( - queryParameters: FoundryQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'foundryOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output ID from a Foundry ID. - * - * @param foundryId A Foundry ID. - * @returns The corresponding output ID. - */ - async foundryOutputId(foundryId: FoundryId): Promise { - const response = await this.methodHandler.callMethod({ - name: 'foundryOutputId', - data: { - foundryId, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output IDs given a list of NFT query parameters. - * - * @param queryParameters An array of `NftQueryParameter`s. - * @returns A paginated query response of corresponding output IDs. - */ - async nftOutputIds( - queryParameters: NftQueryParameter[], - ): Promise { - const response = await this.methodHandler.callMethod({ - name: 'nftOutputIds', - data: { - queryParameters, - }, - }); - - return JSON.parse(response).payload; - } - - /** - * Get the corresponding output ID from an NFT ID. - * - * @param nftId An NFT ID. - * @returns The corresponding output ID. - */ - async nftOutputId(nftId: NftId): Promise { - const response = await this.methodHandler.callMethod({ - name: 'nftOutputId', - data: { - nftId, - }, - }); - - return JSON.parse(response).payload; - } - /** * Get outputs from provided output IDs (requests are sent * in parallel and errors are ignored, can be useful for spent outputs) @@ -970,4 +758,218 @@ export class Client { return JSON.parse(response).payload; } + + // inx-indexer routes + + /** + * Fetch account/anchor/basic/delegation/NFT/foundry output IDs based on the given query parameters. + */ + async outputIds( + queryParameters: OutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'outputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Fetch basic output IDs based on the given query parameters. + */ + async basicOutputIds( + queryParameters: BasicOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'basicOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output IDs given a list of account query parameters. + * + * @param outputQueryParameters `AccountOutputQueryParameters`. + * @returns A paginated query response of corresponding output IDs. + */ + async accountOutputIds( + queryParameters: AccountOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'accountOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output ID from an account ID. + * + * @param accountId An account ID. + * @returns The corresponding output ID. + */ + async accountOutputId(accountId: AccountId): Promise { + const response = await this.methodHandler.callMethod({ + name: 'accountOutputId', + data: { + accountId, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output IDs given a list of anchor query parameters. + * + * @param outputQueryParameters `AnchorOutputQueryParameters`. + * @returns A paginated query response of corresponding output IDs. + */ + async anchorOutputIds( + queryParameters: AnchorOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'anchorOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output ID from an anchor ID. + * + * @param anchorId An anchor ID. + * @returns The corresponding output ID. + */ + async anchorOutputId(anchorId: AnchorId): Promise { + const response = await this.methodHandler.callMethod({ + name: 'anchorOutputId', + data: { + anchorId, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output IDs given a list of delegation query parameters. + * + * @param outputQueryParameters `DelegationOutputQueryParameters`. + * @returns A paginated query response of corresponding output IDs. + */ + async delegationOutputIds( + queryParameters: DelegationOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'delegationOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output ID from an delegation ID. + * + * @param delegationId A delegation ID. + * @returns The corresponding output ID. + */ + async delegationOutputId(delegationId: DelegationId): Promise { + const response = await this.methodHandler.callMethod({ + name: 'delegationOutputId', + data: { + delegationId, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output IDs given a list of Foundry query parameters. + * + * @param outputQueryParameters `FoundryOutputQueryParameters`. + * @returns A paginated query response of corresponding output IDs. + */ + async foundryOutputIds( + queryParameters: FoundryOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'foundryOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output ID from a Foundry ID. + * + * @param foundryId A Foundry ID. + * @returns The corresponding output ID. + */ + async foundryOutputId(foundryId: FoundryId): Promise { + const response = await this.methodHandler.callMethod({ + name: 'foundryOutputId', + data: { + foundryId, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output IDs given a list of NFT query parameters. + * + * @param outputQueryParameters `NftOutputQueryParameters`. + * @returns A paginated query response of corresponding output IDs. + */ + async nftOutputIds( + queryParameters: NftOutputQueryParameters, + ): Promise { + const response = await this.methodHandler.callMethod({ + name: 'nftOutputIds', + data: { + queryParameters, + }, + }); + + return JSON.parse(response).payload; + } + + /** + * Get the corresponding output ID from an NFT ID. + * + * @param nftId An NFT ID. + * @returns The corresponding output ID. + */ + async nftOutputId(nftId: NftId): Promise { + const response = await this.methodHandler.callMethod({ + name: 'nftOutputId', + data: { + nftId, + }, + }); + + return JSON.parse(response).payload; + } } diff --git a/bindings/nodejs/lib/types/client/bridge/client.ts b/bindings/nodejs/lib/types/client/bridge/client.ts index 0837c9f808..913a5500f9 100644 --- a/bindings/nodejs/lib/types/client/bridge/client.ts +++ b/bindings/nodejs/lib/types/client/bridge/client.ts @@ -20,13 +20,13 @@ import type { } from '../../block'; import type { PreparedTransactionData } from '../prepared-transaction-data'; import type { - AccountQueryParameter, - AnchorQueryParameter, - FoundryQueryParameter, - GenericQueryParameter, - NftQueryParameter, - QueryParameter, - DelegationQueryParameter, + AccountOutputQueryParameters, + AnchorOutputQueryParameters, + BasicOutputQueryParameters, + DelegationOutputQueryParameters, + FoundryOutputQueryParameters, + NftOutputQueryParameters, + OutputQueryParameters, } from '../query-parameters'; import type { IAuth } from '../network'; import type { BasicOutputBuilderParams } from '../output_builder_params/basic-output-params'; @@ -47,20 +47,6 @@ export interface __GetOutputMethod__ { }; } -export interface __GetOutputIdsMethod__ { - name: 'outputIds'; - data: { - queryParameters: GenericQueryParameter[]; - }; -} - -export interface __GetBasicOutputIdsMethod__ { - name: 'basicOutputIds'; - data: { - queryParameters: QueryParameter[]; - }; -} - export interface __GetOutputsMethod__ { name: 'getOutputs'; data: { @@ -225,76 +211,6 @@ export interface __HexPublicKeyToBech32AddressMethod__ { }; } -export interface __AccountOutputIdsMethod__ { - name: 'accountOutputIds'; - data: { - queryParameters: AccountQueryParameter[]; - }; -} - -export interface __AccountOutputIdMethod__ { - name: 'accountOutputId'; - data: { - accountId: AccountId; - }; -} - -export interface __AnchorOutputIdsMethod__ { - name: 'anchorOutputIds'; - data: { - queryParameters: AnchorQueryParameter[]; - }; -} - -export interface __AnchorOutputIdMethod__ { - name: 'anchorOutputId'; - data: { - anchorId: AnchorId; - }; -} - -export interface __DelegationOutputIdsMethod__ { - name: 'delegationOutputIds'; - data: { - queryParameters: DelegationQueryParameter[]; - }; -} - -export interface __DelegationOutputIdMethod__ { - name: 'delegationOutputId'; - data: { - delegationId: DelegationId; - }; -} - -export interface __FoundryOutputIdsMethod__ { - name: 'foundryOutputIds'; - data: { - queryParameters: FoundryQueryParameter[]; - }; -} - -export interface __FoundryOutputIdMethod__ { - name: 'foundryOutputId'; - data: { - foundryId: FoundryId; - }; -} - -export interface __NftOutputIdsMethod__ { - name: 'nftOutputIds'; - data: { - queryParameters: NftQueryParameter[]; - }; -} - -export interface __NftOutputIdMethod__ { - name: 'nftOutputId'; - data: { - nftId: NftId; - }; -} - export interface __GetOutputsIgnoreErrorsMethod__ { name: 'getOutputsIgnoreErrors'; data: { @@ -365,3 +281,89 @@ export type __CallPluginRouteMethod__ = { request?: string; }; }; + +// inx-indexer methods + +export interface __GetOutputIdsMethod__ { + name: 'outputIds'; + data: { + queryParameters: OutputQueryParameters; + }; +} + +export interface __GetBasicOutputIdsMethod__ { + name: 'basicOutputIds'; + data: { + queryParameters: BasicOutputQueryParameters; + }; +} + +export interface __AccountOutputIdsMethod__ { + name: 'accountOutputIds'; + data: { + queryParameters: AccountOutputQueryParameters; + }; +} + +export interface __AccountOutputIdMethod__ { + name: 'accountOutputId'; + data: { + accountId: AccountId; + }; +} + +export interface __AnchorOutputIdsMethod__ { + name: 'anchorOutputIds'; + data: { + queryParameters: AnchorOutputQueryParameters; + }; +} + +export interface __AnchorOutputIdMethod__ { + name: 'anchorOutputId'; + data: { + anchorId: AnchorId; + }; +} + +export interface __DelegationOutputIdsMethod__ { + name: 'delegationOutputIds'; + data: { + queryParameters: DelegationOutputQueryParameters; + }; +} + +export interface __DelegationOutputIdMethod__ { + name: 'delegationOutputId'; + data: { + delegationId: DelegationId; + }; +} + +export interface __FoundryOutputIdsMethod__ { + name: 'foundryOutputIds'; + data: { + queryParameters: FoundryOutputQueryParameters; + }; +} + +export interface __FoundryOutputIdMethod__ { + name: 'foundryOutputId'; + data: { + foundryId: FoundryId; + }; +} + +export interface __NftOutputIdsMethod__ { + name: 'nftOutputIds'; + data: { + queryParameters: NftOutputQueryParameters; + }; +} + +export interface __NftOutputIdMethod__ { + name: 'nftOutputId'; + data: { + nftId: NftId; + }; +} diff --git a/bindings/nodejs/lib/types/client/query-parameters.ts b/bindings/nodejs/lib/types/client/query-parameters.ts index 7dcf40375e..29c9cab157 100644 --- a/bindings/nodejs/lib/types/client/query-parameters.ts +++ b/bindings/nodejs/lib/types/client/query-parameters.ts @@ -2,187 +2,162 @@ // SPDX-License-Identifier: Apache-2.0 import { SlotIndex } from '../block/slot'; -import { Bech32Address } from '../block'; +import { Bech32Address, TokenId } from '../block'; +import { HexEncodedString } from '../utils/hex-encoding'; /** - * Query parameter for filtering output requests + * Common query parameters for output requests. */ -export type QueryParameter = - | Address - | AccountAddress - | HasStorageDepositReturn - | StorageDepositReturnAddress - | HasTimelock - | TimelockedBefore - | TimelockedAfter - | HasExpiration - | ExpiresBefore - | ExpiresAfter - | ExpirationReturnAddress - | Sender - | Tag - | Issuer - | StateController - | Governor - | UnlockableByAddress - | CommonQueryParameters; - -/** Query parameters for filtering Account Outputs */ -export type AccountQueryParameter = - | Address - | Issuer - | Sender - | UnlockableByAddress - | CommonQueryParameters; - -/** Query parameters for filtering Anchor Outputs */ -// TODO https://github.com/iotaledger/iota-sdk/issues/1503 -export type AnchorQueryParameter = any; - -/** Query parameters for filtering Delegation Outputs */ -// TODO https://github.com/iotaledger/iota-sdk/issues/1503 -export type DelegationQueryParameter = any; - -/** Query parameters for filtering Foundry Outputs */ -export type FoundryQueryParameter = AccountAddress | CommonQueryParameters; - -/** Query parameters for filtering Nft Outputs */ -export type NftQueryParameter = - | Address - | HasStorageDepositReturn - | StorageDepositReturnAddress - | HasTimelock - | TimelockedBefore - | TimelockedAfter - | HasExpiration - | ExpiresBefore - | ExpiresAfter - | ExpirationReturnAddress - | Issuer - | Sender - | Tag - | UnlockableByAddress - | CommonQueryParameters; - -/** Shared query parameters*/ -type CommonQueryParameters = - | HasNativeTokens - | MinNativeTokenCount - | MaxNativeTokenCount - | CreatedAfter - | CreatedBefore - | PageSize - | Cursor; - -/** Query parameters for filtering alias/basic/NFT/foundry Outputs*/ -export type GenericQueryParameter = - | UnlockableByAddress - | HasNativeTokens - | MinNativeTokenCount - | MaxNativeTokenCount - | CreatedAfter - | CreatedBefore - | PageSize - | Cursor; - -/** Bech32-encoded address that should be searched for. */ -interface Address { - address: Bech32Address; -} -/** Filter foundry outputs based on bech32-encoded address of the controlling account. */ -interface AccountAddress { - accountAddress: Bech32Address; +export interface CommonOutputQueryParameters { + /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is + /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. + pageSize?: number; + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty string is provided, only + /// the first page is returned. + cursor?: string; + /// Returns outputs that were created before a certain slot index. + createdBefore?: SlotIndex; + /// Returns outputs that were created after a certain slot index. + createdAfter?: SlotIndex; } -/** Filters outputs based on the presence of storage deposit return unlock condition. */ -interface HasStorageDepositReturn { - hasStorageDepositReturn: boolean; -} -/** Filter outputs based on the presence of a specific Bech32-encoded return address - * in the storage deposit return unlock condition. + +/** + * Query parameters for output requests. */ -interface StorageDepositReturnAddress { - storageDepositReturnAddress: Bech32Address; -} -/** Filters outputs based on the presence of timelock unlock condition. */ -interface HasTimelock { - hasTimelock: boolean; -} -/** Return outputs that are timelocked before a certain slot index. */ -interface TimelockedBefore { - timelockedBefore: SlotIndex; -} -/** Return outputs that are timelocked after a certain slot index. */ -interface TimelockedAfter { - timelockedAfter: SlotIndex; +export interface OutputQueryParameters extends CommonOutputQueryParameters { + /// Filters outputs based on the presence of a native token. + hasNativeToken?: boolean; + /// Filters outputs based on the presence of a specific native token. + nativeToken?: TokenId; + /// Returns outputs that are unlockable by the bech32 address. + unlockableByAddress?: Bech32Address; } -/** Filters outputs based on the presence of expiration unlock condition. */ -interface HasExpiration { - hasExpiration: boolean; -} -/** Filters outputs based on the presence of native tokens. */ -interface HasNativeTokens { - hasNativeTokens: boolean; -} -/** Filters outputs that have at most a certain number of distinct native tokens. */ -interface MaxNativeTokenCount { - maxNativeTokenCount: number; -} -/** Filters outputs that have at least a certain number of distinct native tokens. */ -interface MinNativeTokenCount { - minNativeTokenCount: number; -} -/** Return outputs that expire before a certain slot index. */ -interface ExpiresBefore { - expiresBefore: SlotIndex; -} -/** Return outputs that expire after a certain slot index. */ -interface ExpiresAfter { - expiresAfter: SlotIndex; -} -/** Filter outputs based on the presence of a specific Bech32-encoded return - * address in the expiration unlock condition. - * */ -interface ExpirationReturnAddress { - expirationReturnAddress: Bech32Address; -} -/** Filter for a certain sender */ -interface Sender { - sender: string; -} -/** Filter for a certain tag */ -interface Tag { - tag: string; -} -/** Return outputs that were created before a certain slot index. */ -interface CreatedBefore { - createdBefore: SlotIndex; -} -/** Return outputs that were created after a certain slot index. */ -interface CreatedAfter { - createdAfter: SlotIndex; -} -/** Pass the cursor(confirmationMS+outputId.pageSize) to start the results from */ -interface Cursor { - cursor: string; +/** + * Query parameters for basic output requests. + */ +export interface BasicOutputQueryParameters + extends CommonOutputQueryParameters { + /// Filters outputs based on the presence of a native token. + hasNativeToken?: boolean; + /// Filters outputs based on the presence of a specific native token. + nativeToken?: TokenId; + /// Returns outputs that are unlockable by the bech32 address. + unlockableByAddress?: Bech32Address; + /// Bech32-encoded address that should be searched for. + address?: Bech32Address; + /// Filters outputs based on the presence of storage deposit return unlock condition. + hasStorageDepositReturn?: boolean; + /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock + /// condition. + storageDepositReturnAddress?: Bech32Address; + /// Filters outputs based on the presence of expiration unlock condition. + hasExpiration?: boolean; + /// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock + /// condition. + expirationReturnAddress?: Bech32Address; + /// Returns outputs that expire before a certain slot index. + expiresBefore?: SlotIndex; + /// Returns outputs that expire after a certain slot index. + expiresAfter?: SlotIndex; + /// Filters outputs based on the presence of timelock unlock condition. + hasTimelock?: boolean; + /// Returns outputs that are timelocked before a certain slot index. + timelockedBefore?: SlotIndex; + /// Returns outputs that are timelocked after a certain slot index. + timelockedAfter?: SlotIndex; + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender?: Bech32Address; + /// Filters outputs based on matching Tag Block. + tag?: HexEncodedString; } -/** Filter for a certain issuer */ -interface Issuer { - issuer: string; + +/** + * Query parameters for account output requests. + */ +export interface AccountOutputQueryParameters + extends CommonOutputQueryParameters { + /// Bech32-encoded address that should be searched for. + address?: Bech32Address; + /// Filters outputs based on bech32-encoded issuer address. + issuer?: Bech32Address; + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender?: Bech32Address; } -/** Filter outputs based on bech32-encoded state controller address. */ -interface StateController { - stateController: Bech32Address; + +/** + * Query parameters for anchor output requests. + */ +export interface AnchorOutputQueryParameters + extends CommonOutputQueryParameters { + /// Returns outputs that are unlockable by the bech32 address. + unlockableByAddress?: Bech32Address; + /// Filters outputs based on bech32-encoded state controller address. + stateController?: Bech32Address; + /// Filters outputs based on bech32-encoded governor (governance controller) address. + governor?: Bech32Address; + /// Filters outputs based on bech32-encoded issuer address. + issuer?: Bech32Address; + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender?: Bech32Address; } -/** Filter outputs based on bech32-encoded governor (governance controller) address. */ -interface Governor { - governor: Bech32Address; + +/** + * Query parameters for delegation output requests. + */ +export interface DelegationOutputQueryParameters + extends CommonOutputQueryParameters { + /// Bech32-encoded address that should be searched for. + address?: Bech32Address; + /// Filter foundry outputs based on bech32-encoded address of the validator. + validator?: Bech32Address; } -/** Define the page size for the results. */ -interface PageSize { - pageSize: number; + +/** + * Query parameters for foundry output requests. + */ +export interface FoundryOutputQueryParameters + extends CommonOutputQueryParameters { + /// Filters outputs based on the presence of a native token. + hasNativeToken?: boolean; + /// Filters outputs based on the presence of a specific native token. + nativeToken?: TokenId; + /// Filter foundry outputs based on bech32-encoded address of the controlling account. + account?: Bech32Address; } -/** Returns outputs that are unlockable by the bech32 address. */ -interface UnlockableByAddress { - unlockableByAddress: Bech32Address; + +/** + * Query parameters for NFT output requests. + */ +export interface NftOutputQueryParameters extends CommonOutputQueryParameters { + /// Returns outputs that are unlockable by the bech32 address. + unlockableByAddress?: Bech32Address; + /// Bech32-encoded address that should be searched for. + address?: Bech32Address; + /// Filters outputs based on the presence of storage deposit return unlock condition. + hasStorageDepositReturn?: boolean; + /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock + /// condition. + storageDepositReturnAddress?: Bech32Address; + /// Filters outputs based on the presence of expiration unlock condition. + hasExpiration?: boolean; + /// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock + /// condition. + expirationReturnAddress?: Bech32Address; + /// Returns outputs that expire before a certain slot index. + expiresBefore?: SlotIndex; + /// Returns outputs that expire after a certain slot index. + expiresAfter?: SlotIndex; + /// Filters outputs based on the presence of timelock unlock condition. + hasTimelock?: boolean; + /// Returns outputs that are timelocked before a certain slot index. + timelockedBefore?: SlotIndex; + /// Returns outputs that are timelocked after a certain slot index. + timelockedAfter?: SlotIndex; + /// Filters outputs based on bech32-encoded issuer address. + issuer?: Bech32Address; + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender?: Bech32Address; + /// Filters outputs based on matching Tag Block. + tag?: HexEncodedString; } diff --git a/sdk/src/client/node_api/indexer/query_parameters.rs b/sdk/src/client/node_api/indexer/query_parameters.rs index 5f63a6cacd..8027cea872 100644 --- a/sdk/src/client/node_api/indexer/query_parameters.rs +++ b/sdk/src/client/node_api/indexer/query_parameters.rs @@ -71,7 +71,8 @@ pub struct OutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -121,7 +122,8 @@ pub struct BasicOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -157,7 +159,8 @@ pub struct AccountOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -185,7 +188,8 @@ pub struct AnchorOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -207,7 +211,8 @@ pub struct DelegationOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -231,7 +236,8 @@ pub struct FoundryOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option, @@ -279,7 +285,8 @@ pub struct NftOutputQueryParameters { /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. The parameter is ignored when pageSize is defined via the cursor parameter. page_size: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). If an empty String is provided, only + /// the first page is returned. cursor: Option, /// Returns outputs that were created before a certain slot index. created_before: Option,