@taquito/michelson-encoder
Version:
Michelson encoding and decoding utilities for Taquito.
98 lines (97 loc) • 3.54 kB
TypeScript
import { MichelsonV1Expression, ScriptResponse } from '@taquito/rpc';
import { BigMapKeyType, Semantic, SemanticEncoding, Token } from '../tokens/token';
import { TokenSchema } from './types';
declare const schemaTypeSymbol: unique symbol;
export declare function deepEqual(a: MichelsonV1Expression | undefined, b: MichelsonV1Expression | undefined): boolean;
/**
* @remarks Our current smart contract abstraction feature is currently in preview. Its API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.
*/
export declare class Schema {
readonly val: MichelsonV1Expression;
private root;
[schemaTypeSymbol]: boolean;
static isSchema(obj: Schema): boolean;
private bigMap?;
/**
* @throws {@link InvalidRpcResponseError}
*/
static fromRPCResponse(val: {
script: ScriptResponse;
}): Schema;
private isExpressionExtended;
constructor(val: MichelsonV1Expression);
private removeTopLevelAnnotation;
Execute(val: any, semantics?: Semantic): any;
/**
* Validates that a value matches the schema type.
* Performs type checking with special handling for BigMap, Ticket, and nested Map tokens.
*
* @param val - The value to validate against the schema
* @returns Returns true if validation passes, false if validation fails
*/
Typecheck(val: any): boolean;
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link InvalidBigMapDiffError}
*/
ExecuteOnBigMapDiff(diff: any[], semantics?: Semantic): any;
/**
* @throws {@link InvalidBigMapSchemaError}
*/
ExecuteOnBigMapValue(key: any, semantics?: Semantic): any;
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link BigMapEncodingError}
*/
EncodeBigMapKey(key: BigMapKeyType): {
key: {
[key: string]: string | object[];
};
type: {
prim: string;
args?: object[];
};
};
/**
* @throws TokenValidationError
* @throws {@link StorageEncodingError}
*/
Encode(value?: any, semantics?: SemanticEncoding): any;
/**
* Produce a representation of the storage schema.
* Note: Provide guidance on how to write the storage object for the origination operation with Taquito.
*/
generateSchema(): TokenSchema;
/**
* Look up in top-level pairs of the storage to find a value matching the specified type
*
* @returns The first value found that match the type or `undefined` if no value is found
*
* @param storage storage to parse to find the value
* @param valueType type of value to look for
*
*/
FindFirstInTopLevelPair<T extends MichelsonV1Expression>(storage: any, valueType: any): T | undefined;
/**
* @throws {@link MissingArgumentError}
*/
private findValue;
/**
* Look up the schema to find any occurrence of a particular token.
*
* @returns an array of tokens of the specified kind or an empty array if no token was found
*
* @param tokenToFind string representing the prim property of the token to find
*
* @example
* ```
* Useful to find all global constants in a script, an array of GlobalConstantToken is returned:
*
* const schema = new Schema(script);
* const allGlobalConstantTokens = schema.findToken('constant');
* ```
*
*/
findToken(tokenToFind: string): Array<Token>;
}
export {};