import { AbstractCheqdSDKModule, MinimalImportableCheqdSDKModule } from './_.js'; import { CheqdSigningStargateClient } from '../signer.js'; import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing'; import { DidFeeOptions, DidStdFee, IContext, ISignInputs, QueryExtensionSetup } from '../types.js'; import { Metadata, MsgCreateResource, MsgCreateResourcePayload, QueryCollectionResourcesResponse, QueryParamsResponse, ResourceWithMetadata } from '@cheqd/ts-proto/cheqd/resource/v2/index.js'; import { DeliverTxResponse, QueryClient } from '@cosmjs/stargate'; import { FeeRange, SignInfo } from '@cheqd/ts-proto/cheqd/did/v2/index.js'; import { CheqdQuerier } from '../querier.js'; import { OracleExtension } from './oracle.js'; import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin.js'; /** Default extension key for resource-related query operations */ export declare const defaultResourceExtensionKey: "resource"; /** * Protobuf message type literals for resource operations. * Used for consistent message type identification across the module. */ export declare const protobufLiterals: { /** Create resource message type */ readonly MsgCreateResource: "MsgCreateResource"; /** Create resource response message type */ readonly MsgCreateResourceResponse: "MsgCreateResourceResponse"; }; /** Type URL for MsgCreateResource messages */ export declare const typeUrlMsgCreateResource: "/cheqd.resource.v2.MsgCreateResource"; /** Type URL for MsgCreateResourceResponse messages */ export declare const typeUrlMsgCreateResourceResponse: "/cheqd.resource.v2.MsgCreateResourceResponse"; /** * Encode object interface for MsgCreateResource messages. * Used for type-safe message encoding in resource creation transactions. */ export interface MsgCreateResourceEncodeObject extends EncodeObject { readonly typeUrl: typeof typeUrlMsgCreateResource; readonly value: Partial; } /** * Type guard function to check if an object is a MsgCreateResourceEncodeObject. * * @param obj - EncodeObject to check * @returns True if the object is a MsgCreateResourceEncodeObject */ export declare function isMsgCreateResourceEncodeObject(obj: EncodeObject): obj is MsgCreateResourceEncodeObject; /** Minimal importable version of the resource module for clean external interfaces */ export type MinimalImportableResourceModule = MinimalImportableCheqdSDKModule; /** * Resource extension interface for querier functionality. * Provides methods for querying resources and their metadata. */ export type ResourceExtension = { readonly [defaultResourceExtensionKey]: { /** Query a specific resource by collection and resource ID */ readonly resource: (collectionId: string, resourceId: string) => Promise; /** Query metadata for a specific resource */ readonly resourceMetadata: (collectionId: string, resourceId: string) => Promise; /** Query all resources in a collection with pagination support */ readonly collectionResources: (collectionId: string, paginationKey?: Uint8Array) => Promise; /** Query latest resource version */ readonly latestResourceVersion: (collectionId: string, name: string, type: string) => Promise; /** Query latest resource metadata */ readonly latestResourceVersionMetadata: (collectionId: string, name: string, type: string) => Promise; /** Query parameters for resource module */ readonly params: () => Promise; }; }; /** * Sets up the resource extension for the querier client. * Creates and configures the resource-specific query methods. * * @param base - Base QueryClient to extend * @returns Configured resource extension with query methods */ export declare const setupResourceExtension: (base: QueryClient) => ResourceExtension; /** * Resource Module class providing comprehensive linked resource functionality. * Handles creation, querying, and metadata management of resources linked to DID documents. */ export declare class ResourceModule extends AbstractCheqdSDKModule { static readonly registryTypes: Iterable<[string, GeneratedType]>; /** Base denomination for Cheqd network transactions */ static readonly baseMinimalDenom: "ncheq"; /** Base denomination in USD for Cheqd network transactions */ static readonly baseUsdDenom: "usd"; /** Default slippage tolerance in base points (BPS) */ static readonly defaultSlippageBps = 500n; /** * Standard fee amounts for different resource types. * Fees vary based on resource content type and processing requirements. */ static readonly fees: { /** Default fee for creating image resources */ readonly DefaultCreateResourceImageFee: { readonly amount: "10000000000"; readonly denom: "ncheq"; }; /** Default fee for creating JSON resources */ readonly DefaultCreateResourceJsonFee: { readonly amount: "10000000000"; readonly denom: "ncheq"; }; /** Default fee for creating other types of resources */ readonly DefaultCreateResourceDefaultFee: { readonly amount: "10000000000"; readonly denom: "ncheq"; }; /** Default fee for creating image resources in USD */ readonly DefaultCreateResourceImageFeeUsd: { readonly amount: "100000000000000000"; readonly denom: "usd"; }; /** Default fee for creating JSON resources in USD */ readonly DefaultCreateResourceJsonFeeUsd: { readonly amount: "400000000000000000"; readonly denom: "usd"; }; /** Default fee for creating other types of resources in USD */ readonly DefaultCreateResourceDefaultFeeUsd: { readonly amount: "200000000000000000"; readonly denom: "usd"; }; }; /** Standard gas limits for DLR operations. * These represent the default gas limits for various DLR-related transactions. */ static readonly gasLimits: { /** Gas limit for creating linked resources */ readonly CreateLinkedResourceImageGasLimit: "1000000"; /** Gas limit for creating linked JSON resources */ readonly CreateLinkedResourceJsonGasLimit: "1000000"; /** Gas limit for creating other types of linked resources */ readonly CreateLinkedResourceDefaultGasLimit: "1000000"; }; /** Querier extension setup function for resource operations */ static readonly querierExtensionSetup: QueryExtensionSetup; /** Querier instance with resource extension capabilities */ querier: CheqdQuerier & ResourceExtension & OracleExtension; private oracleFeesAvailability?; /** * Constructs a new resource module instance. * * @param signer - Signing client for blockchain transactions * @param querier - Querier client with resource extension for data retrieval */ constructor(signer: CheqdSigningStargateClient, querier: CheqdQuerier & ResourceExtension & OracleExtension); /** * Gets the registry types for resource message encoding/decoding. * * @returns Iterable of [typeUrl, GeneratedType] pairs for the registry */ getRegistryTypes(): Iterable<[string, GeneratedType]>; /** * Gets the querier extension setup for resource operations. * * @returns Query extension setup function for resource functionality */ getQuerierExtensionSetup(): QueryExtensionSetup; /** * Signs a resource payload with provided signature inputs. * Creates a complete signed resource message ready for blockchain submission. * * @param payload - Resource payload to sign * @param signInputs - Signing inputs or pre-computed signatures * @returns Promise resolving to the signed resource message */ static signPayload(payload: MsgCreateResourcePayload, signInputs: ISignInputs[] | SignInfo[]): Promise; /** * Creates a linked resource transaction on the blockchain. * Handles automatic fee calculation based on resource content type and size. * * @param signInputs - Signing inputs or pre-computed signatures for the transaction * @param resourcePayload - Resource payload containing data and metadata * @param address - Address of the account submitting the transaction * @param fee - Transaction fee configuration or 'auto' for automatic calculation * @param memo - Optional transaction memo * @param feeOptions - Optional fee options for the transaction * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the transaction response * @throws Error if linked resource data is empty when automatic fee calculation is requested */ createLinkedResourceTx(signInputs: ISignInputs[] | SignInfo[], resourcePayload: Partial, address: string, fee?: DidStdFee | 'auto' | number, memo?: string, feeOptions?: DidFeeOptions, context?: IContext): Promise; /** * Queries a specific linked resource by collection and resource ID. * Retrieves the complete resource data along with its metadata. * * @param collectionId - ID of the collection containing the resource * @param resourceId - ID of the resource to query * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the resource with metadata */ queryLinkedResource(collectionId: string, resourceId: string, context?: IContext): Promise; /** * Queries metadata for a specific linked resource. * Retrieves only the metadata without the resource content data. * * @param collectionId - ID of the collection containing the resource * @param resourceId - ID of the resource to query metadata for * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the resource metadata */ queryLinkedResourceMetadata(collectionId: string, resourceId: string, context?: IContext): Promise; /** * Queries all resources in a collection with pagination support. * Retrieves a list of all resources belonging to a specific collection. * * @param collectionId - ID of the collection to query resources for * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the collection resources response with pagination */ queryLinkedResources(collectionId: string, context?: IContext): Promise; /** * Queries the latest version of a linked resource by collection ID, name, and type. * Retrieves the most recent version of the specified resource. * * @param collectionId - ID of the collection containing the resource * @param name - Name of the resource * @param type - Type of the resource * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the latest resource version with metadata */ queryLatestLinkedResourceVersion(collectionId: string, name: string, type: string, context?: IContext): Promise; /** * Queries the latest metadata of a linked resource by collection ID, name, and type. * Retrieves only the metadata of the most recent version of the specified resource. * * @param collectionId - ID of the collection containing the resource * @param name - Name of the resource * @param type - Type of the resource * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the latest resource metadata */ queryLatestLinkedResourceVersionMetadata(collectionId: string, name: string, type: string, context?: IContext): Promise; private shouldUseOracleFees; /** * Queries the Resource module parameters from the blockchain. * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the Resource module parameters */ queryResourceParams(context?: IContext): Promise; /** * Generates oracle-powered fees for creating image DID-Linked Resources. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @param feeOptions - Options for fetching oracle fees * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the fee configuration for DLR creation */ generateCreateResourceImageFees(feePayer: string, granter?: string, feeOptions?: DidFeeOptions, context?: IContext): Promise; /** * Generates oracle-powered fees for creating JSON DID-Linked Resources. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @param feeOptions - Options for fetching oracle fees * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the fee configuration for DLR creation */ generateCreateResourceJsonFees(feePayer: string, granter?: string, feeOptions?: DidFeeOptions, context?: IContext): Promise; /** * Generates oracle-powered fees for creating default DID-Linked Resources. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @param feeOptions - Options for fetching oracle fees * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the fee configuration for DLR creation */ generateCreateResourceDefaultFees(feePayer: string, granter?: string, feeOptions?: DidFeeOptions, context?: IContext): Promise; /** * Gets the fee range for a specific DID operation from the module parameters. * @param feeParams - DID module fee parameters * @param operation - DID operation type ('create', 'update', 'deactivate') * @param feeOptions - Options for fee retrieval * @returns Promise resolving to the fee range for the specified operation */ getPriceRangeFromResourceParams(feeParams: QueryParamsResponse, operation: 'image' | 'json' | 'default', feeOptions?: DidFeeOptions): Promise; /** * Calculates the oracle fee amount based on the provided fee range and options. * @param feeRange - Fee range for the DID operation * @param feeOptions - Options for fee calculation * @param context - Optional SDK context for accessing clients * @returns Promise resolving to the calculated fee amount as a Coin */ private calculateOracleFeeAmount; /** * Applies slippage to a given coin amount based on the specified basis points. * @param coin - Coin amount to apply slippage to * @param slippageBps - Slippage in basis points (bps) * @returns Coin with adjusted amount after applying slippage */ static applySlippageToCoin(coin: Coin, slippageBps: number): Coin; /** * Checks if a fee range represents a fixed fee (minAmount equals maxAmount). * @param feeRange - Fee range to check * @returns True if the fee range is fixed, false otherwise */ static isFixedRange(feeRange: FeeRange): boolean; /** * Reads and determines the MIME type of resource content. * Analyzes the content to identify the appropriate MIME type for fee calculation and validation. * * @param content - Resource content as byte array * @returns Promise resolving to the detected MIME type string */ static readMimeType(content: Uint8Array): Promise; /** * Generates fee configuration for image resource creation transactions. * Uses higher gas limits appropriate for image processing and storage. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @returns Promise resolving to the fee configuration for image resources */ static generateCreateResourceImageFees(feePayer: string, granter?: string): Promise; /** * Generates fee configuration for JSON resource creation transactions. * Uses gas limits optimized for JSON data processing and validation. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @returns Promise resolving to the fee configuration for JSON resources */ static generateCreateResourceJsonFees(feePayer: string, granter?: string): Promise; /** * Generates fee configuration for default resource creation transactions. * Uses standard gas limits for generic resource types and binary data. * * @param feePayer - Address of the account that will pay the transaction fees * @param granter - Optional address of the account granting fee payment permissions * @returns Promise resolving to the fee configuration for default resources */ static generateCreateResourceDefaultFees(feePayer: string, granter?: string): Promise; } //# sourceMappingURL=resource.d.ts.map