/** * Copyright (c) Whales Corp. * All Rights Reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /// import { Address } from "../address/Address"; import { Builder } from "../boc/Builder"; import { Cell } from "../boc/Cell"; import { Slice } from "../boc/Slice"; import { BitString } from "../boc/BitString"; import { Maybe } from "../utils/maybe"; export type DictionaryKeyTypes = Address | number | bigint | Buffer | BitString; export type DictionaryKey = { bits: number; serialize(src: K): bigint; parse(src: bigint): K; }; export type DictionaryValue = { serialize(src: V, builder: Builder): void; parse(src: Slice): V; }; export declare class Dictionary { static Keys: { /** * Standard address key * @returns DictionaryKey
*/ Address: () => DictionaryKey
; /** * Create standard big integer key * @param bits number of bits * @returns DictionaryKey */ BigInt: (bits: number) => DictionaryKey; /** * Create integer key * @param bits bits of integer * @returns DictionaryKey */ Int: (bits: number) => DictionaryKey; /** * Create standard unsigned big integer key * @param bits number of bits * @returns DictionaryKey */ BigUint: (bits: number) => DictionaryKey; /** * Create standard unsigned integer key * @param bits number of bits * @returns DictionaryKey */ Uint: (bits: number) => DictionaryKey; /** * Create standard buffer key * @param bytes number of bytes of a buffer * @returns DictionaryKey */ Buffer: (bytes: number) => DictionaryKey; /** * Create BitString key * @param bits key length * @returns DictionaryKey * Point is that Buffer has to be 8 bit aligned, * while key is TVM dictionary doesn't have to be * aligned at all. */ BitString: (bits: number) => DictionaryKey; }; static Values: { /** * Create standard integer value * @returns DictionaryValue */ BigInt: (bits: number) => DictionaryValue; /** * Create standard integer value * @returns DictionaryValue */ Int: (bits: number) => DictionaryValue; /** * Create big var int * @param bits nubmer of header bits * @returns DictionaryValue */ BigVarInt: (bits: number) => DictionaryValue; /** * Create standard unsigned integer value * @param bits number of bits * @returns DictionaryValue */ BigUint: (bits: number) => DictionaryValue; /** * Create standard unsigned integer value * @param bits number of bits * @returns DictionaryValue */ Uint: (bits: number) => DictionaryValue; /** * Create big var int * @param bits nubmer of header bits * @returns DictionaryValue */ BigVarUint: (bits: number) => DictionaryValue; /** * Create standard boolean value * @returns DictionaryValue */ Bool: () => DictionaryValue; /** * Create standard address value * @returns DictionaryValue
*/ Address: () => DictionaryValue
; /** * Create standard cell value * @returns DictionaryValue */ Cell: () => DictionaryValue; /** * Create Builder value * @param bytes number of bytes of a buffer * @returns DictionaryValue */ Buffer: (bytes: number) => DictionaryValue; /** * Create BitString value * @param requested bit length * @returns DictionaryValue * Point is that Buffer is not applicable * when length is not 8 bit alligned. */ BitString: (bits: number) => DictionaryValue; /** * Create dictionary value * @param key * @param value */ Dictionary: (key: DictionaryKey, value: DictionaryValue) => DictionaryValue>; }; /** * Create an empty map * @param key key type * @param value value type * @returns Dictionary */ static empty(key?: Maybe>, value?: Maybe>): Dictionary; /** * Load dictionary from slice * @param key key description * @param value value description * @param src slice * @returns Dictionary */ static load(key: DictionaryKey, value: DictionaryValue, sc: Slice | Cell): Dictionary; /** * Low level method for rare dictionaries from system contracts. * Loads dictionary from slice directly without going to the ref. * * @param key key description * @param value value description * @param sc slice * @returns Dictionary */ static loadDirect(key: DictionaryKey, value: DictionaryValue, sc: Slice | Cell | null): Dictionary; private readonly _key; private readonly _value; private readonly _map; private constructor(); get size(): number; get(key: K): V | undefined; has(key: K): boolean; set(key: K, value: V): this; delete(key: K): boolean; clear(): void; [Symbol.iterator](): IterableIterator<[K, V]>; keys(): K[]; values(): V[]; store(builder: Builder, key?: Maybe>, value?: Maybe>): void; storeDirect(builder: Builder, key?: Maybe>, value?: Maybe>): void; generateMerkleProof(key: K): Cell; generateMerkleUpdate(key: K, newValue: V): Cell; }