UNPKG

@gear-js/api

Version:

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

38 lines (37 loc) 1.63 kB
import type { Option } from '@polkadot/types'; import type { CodeUploadResult, GearCoreCodeInstrumentedInstrumentedCodeBeforeV1900, GearCoreCodeMetadataCodeMetadata, HexString } from '../types'; import { GearTransaction } from './Transaction'; export declare class GearCode extends GearTransaction { /** * ### Submit code without initialization * @param code * @returns Code hash */ upload(code: Uint8Array): Promise<CodeUploadResult>; /** * ### Check that codeId exists on chain * @param codeId */ exists(codeId: string): Promise<boolean>; private _storageV1900; private _storageBeforeV1900; /** * ### Get code storage * @param codeId * @returns ___[CodeMetadata](https://github.com/gear-tech/gear/blob/master/core/src/code/metadata.rs#L52)___ if connected to the node with version >= 1900, * otherwise ___[InstrumentedCode](https://github.com/gear-tech/gear/blob/290c4953a2fd54270ec34333d8cd3f7b97591635/core/src/code/instrumented.rs#L67)___ */ storage(codeId: HexString): Promise<Option<GearCoreCodeMetadataCodeMetadata | GearCoreCodeInstrumentedInstrumentedCodeBeforeV1900>>; /** * ### Get static pages of code * @param codeId */ staticPages(codeId: HexString): Promise<number | null>; /** * ### Get all ids of codes uploaded on connected chain * @returns array of code ids uploaded on chain */ all(count?: number): Promise<HexString[]>; metaHash(codeId: HexString): Promise<HexString>; metaHashFromWasm(wasm: ArrayBuffer | HexString | Uint8Array): Promise<`0x${string}`>; }