UNPKG

@gear-js/api

Version:

A JavaScript library that provides functionality to connect GEAR Component APIs.

37 lines (36 loc) 2.13 kB
import { Codec } from '@polkadot/types/types'; import { Bytes } from '@polkadot/types'; import { ReadStateBatchParams, ReadStateParams, ReadStateUsingWasmParams } from '../types'; import { ProgramMetadata, StateMetadata } from '../metadata'; import { GearProgramStorage } from './Storage'; /** * @deprecated - This functionality is deprecated and will be removed from both the API and the runtime. Use `api.message.calculateReply` instead. */ export declare class GearProgramState extends GearProgramStorage { /** * @deprecated - This functionality is deprecated and will be removed from both the API and the runtime. Use `api.message.calculateReply` instead. * ## Read state using meta wasm file * @param args * @param meta StateMetadata returned from getStateMetadata function */ readUsingWasm(params: ReadStateUsingWasmParams, stateMeta: StateMetadata, programMeta: ProgramMetadata): Promise<Codec>; /** * ### Read state of program (calls `gear_readState` rpc call) * @deprecated - This functionality is deprecated and will be removed from both the API and the runtime. Use `api.message.calculateReply` instead. * @param args ProgramId, payload and hash of block where it's necessary to read state (optional) * @param meta (optional) Program metadata returned from `ProgramMetadata.from` method. If not specified, payload will be sent and state will be returned as `Bytes` * @param type (optional) Index of type to decode state. metadata.types.state.input is uesd by default * * @example * const meta = ProgramMetadata.from('0x...'); * const programId = '0x...'; * * const result = await api.programState.read({ programId, payload: { id: 1 } }, meta); * console.log(result.toJSON()); */ read<T extends Codec = Codec>(args: ReadStateParams, meta?: ProgramMetadata, type?: number): Promise<T>; /** * @deprecated - This functionality is deprecated and will be removed from both the API and the runtime. Use `api.message.calculateReply` instead. */ readBatch(args: ReadStateBatchParams): Promise<Bytes[]>; }