import { ResponseHandler } from "./bin"; interface IClient { request(functionName: string, functionParams?: any, responseHandler?: ResponseHandler): Promise; resolve_app_request(app_request_id: number | null, result: any): Promise; reject_app_request(app_request_id: number | null, error: any): Promise; } export declare enum ClientErrorCode { NotImplemented = 1, InvalidHex = 2, InvalidBase64 = 3, InvalidAddress = 4, CallbackParamsCantBeConvertedToJson = 5, WebsocketConnectError = 6, WebsocketReceiveError = 7, WebsocketSendError = 8, HttpClientCreateError = 9, HttpRequestCreateError = 10, HttpRequestSendError = 11, HttpRequestParseError = 12, CallbackNotRegistered = 13, NetModuleNotInit = 14, InvalidConfig = 15, CannotCreateRuntime = 16, InvalidContextHandle = 17, CannotSerializeResult = 18, CannotSerializeError = 19, CannotConvertJsValueToJson = 20, CannotReceiveSpawnedResult = 21, SetTimerError = 22, InvalidParams = 23, ContractsAddressConversionFailed = 24, UnknownFunction = 25, AppRequestError = 26, NoSuchRequest = 27, CanNotSendRequestResult = 28, CanNotReceiveRequestResult = 29, CanNotParseRequestResult = 30, UnexpectedCallbackResponse = 31, CanNotParseNumber = 32, InternalError = 33, InvalidHandle = 34, LocalStorageError = 35 } export declare type ClientError = { /** */ code: number; /** */ message: string; /** */ data: any; }; export declare type ClientConfig = { /** */ network?: NetworkConfig; /** */ crypto?: CryptoConfig; /** */ abi?: AbiConfig; /** */ boc?: BocConfig; /** */ proofs?: ProofsConfig; /** * For file based storage is a folder name where SDK will store its data. For browser based is a browser async storage key prefix. Default (recommended) value is "~/.tonclient" for native environments and ".tonclient" for web-browser. */ local_storage_path?: string; }; export declare type NetworkConfig = { /** * DApp Server public address. For instance, for `net.ton.dev/graphql` GraphQL endpoint the server address will be net.ton.dev */ server_address?: string; /** * List of DApp Server addresses. * * @remarks * Any correct URL format can be specified, including IP addresses This parameter is prevailing over `server_address`. */ endpoints?: string[]; /** * Deprecated. * * @remarks * You must use `network.max_reconnect_timeout` that allows to specify maximum network resolving timeout. */ network_retries_count?: number; /** * Maximum time for sequential reconnections. * * @remarks * Must be specified in milliseconds. Default is 120000 (2 min). */ max_reconnect_timeout?: number; /** * Deprecated */ reconnect_timeout?: number; /** * The number of automatic message processing retries that SDK performs in case of `Message Expired (507)` error - but only for those messages which local emulation was successful or failed with replay protection error. * * @remarks * Default is 5. */ message_retries_count?: number; /** * Timeout that is used to process message delivery for the contracts which ABI does not include "expire" header. If the message is not delivered within the specified timeout the appropriate error occurs. * * @remarks * Must be specified in milliseconds. Default is 40000 (40 sec). */ message_processing_timeout?: number; /** * Maximum timeout that is used for query response. * * @remarks * Must be specified in milliseconds. Default is 40000 (40 sec). */ wait_for_timeout?: number; /** * Maximum time difference between server and client. * * @remarks * If client's device time is out of sync and difference is more than the threshold then error will occur. Also an error will occur if the specified threshold is more than * `message_processing_timeout/2`. * * Must be specified in milliseconds. Default is 15000 (15 sec). */ out_of_sync_threshold?: number; /** * Maximum number of randomly chosen endpoints the library uses to broadcast a message. * * @remarks * Default is 2. */ sending_endpoint_count?: number; /** * Frequency of sync latency detection. * * @remarks * Library periodically checks the current endpoint for blockchain data syncronization latency. * If the latency (time-lag) is less then `NetworkConfig.max_latency` * then library selects another endpoint. * * Must be specified in milliseconds. Default is 60000 (1 min). */ latency_detection_interval?: number; /** * Maximum value for the endpoint's blockchain data syncronization latency (time-lag). Library periodically checks the current endpoint for blockchain data synchronization latency. If the latency (time-lag) is less then `NetworkConfig.max_latency` then library selects another endpoint. * * @remarks * Must be specified in milliseconds. Default is 60000 (1 min). */ max_latency?: number; /** * Default timeout for http requests. * * @remarks * Is is used when no timeout specified for the request to limit the answer waiting time. If no answer received during the timeout requests ends with * error. * * Must be specified in milliseconds. Default is 60000 (1 min). */ query_timeout?: number; /** * Access key to GraphQL API. * * @remarks * At the moment is not used in production. */ access_key?: string; }; export declare type CryptoConfig = { /** * Mnemonic dictionary that will be used by default in crypto functions. If not specified, 1 dictionary will be used. */ mnemonic_dictionary?: number; /** * Mnemonic word count that will be used by default in crypto functions. If not specified the default value will be 12. */ mnemonic_word_count?: number; /** * Derivation path that will be used by default in crypto functions. If not specified `m/44'/396'/0'/0/0` will be used. */ hdkey_derivation_path?: string; }; export declare type AbiConfig = { /** * Workchain id that is used by default in DeploySet */ workchain?: number; /** * Message lifetime for contracts which ABI includes "expire" header. The default value is 40 sec. */ message_expiration_timeout?: number; /** * Factor that increases the expiration timeout for each retry The default value is 1.5 */ message_expiration_timeout_grow_factor?: number; }; export declare type BocConfig = { /** * Maximum BOC cache size in kilobytes. * * @remarks * Default is 10 MB */ cache_max_size?: number; }; export declare type ProofsConfig = { /** * Cache proofs in the local storage. * * @remarks * Default is `true`. If this value is set to `true`, downloaded proofs and master-chain BOCs are saved into the * persistent local storage (e.g. file system for native environments or browser's IndexedDB * for the web); otherwise all the data is cached only in memory in current client's context * and will be lost after destruction of the client. */ cache_in_local_storage?: boolean; }; export declare type BuildInfoDependency = { /** * Dependency name. * * @remarks * Usually it is a crate name. */ name: string; /** * Git commit hash of the related repository. */ git_commit: string; }; export declare type ParamsOfAppRequest = { /** * Request ID. * * @remarks * Should be used in `resolve_app_request` call */ app_request_id: number; /** * Request describing data */ request_data: any; }; export declare type AppRequestResult = { type: 'Error'; /** * Error description */ text: string; } | { type: 'Ok'; /** * Request processing result */ result: any; }; export declare function appRequestResultError(text: string): AppRequestResult; export declare function appRequestResultOk(result: any): AppRequestResult; export declare type ResultOfGetApiReference = { /** */ api: any; }; export declare type ResultOfVersion = { /** * Core Library version */ version: string; }; export declare type ResultOfBuildInfo = { /** * Build number assigned to this build by the CI. */ build_number: number; /** * Fingerprint of the most important dependencies. */ dependencies: BuildInfoDependency[]; }; export declare type ParamsOfResolveAppRequest = { /** * Request ID received from SDK */ app_request_id: number; /** * Result of request processing */ result: AppRequestResult; }; /** * Provides information about library. */ export declare class ClientModule { client: IClient; constructor(client: IClient); /** * Returns Core Library API reference * @returns ResultOfGetApiReference */ get_api_reference(): Promise; /** * Returns Core Library version * @returns ResultOfVersion */ version(): Promise; /** * Returns detailed information about this build. * @returns ResultOfBuildInfo */ build_info(): Promise; /** * Resolves application request processing result * * @param {ParamsOfResolveAppRequest} params * @returns */ resolve_app_request(params: ParamsOfResolveAppRequest): Promise; } export declare enum CryptoErrorCode { InvalidPublicKey = 100, InvalidSecretKey = 101, InvalidKey = 102, InvalidFactorizeChallenge = 106, InvalidBigInt = 107, ScryptFailed = 108, InvalidKeySize = 109, NaclSecretBoxFailed = 110, NaclBoxFailed = 111, NaclSignFailed = 112, Bip39InvalidEntropy = 113, Bip39InvalidPhrase = 114, Bip32InvalidKey = 115, Bip32InvalidDerivePath = 116, Bip39InvalidDictionary = 117, Bip39InvalidWordCount = 118, MnemonicGenerationFailed = 119, MnemonicFromEntropyFailed = 120, SigningBoxNotRegistered = 121, InvalidSignature = 122, EncryptionBoxNotRegistered = 123, InvalidIvSize = 124, UnsupportedCipherMode = 125, CannotCreateCipher = 126, EncryptDataError = 127, DecryptDataError = 128, IvRequired = 129 } export declare type SigningBoxHandle = number; export declare type EncryptionBoxHandle = number; export declare type EncryptionBoxInfo = { /** * Derivation path, for instance "m/44'/396'/0'/0/0" */ hdpath?: string; /** * Cryptographic algorithm, used by this encryption box */ algorithm?: string; /** * Options, depends on algorithm and specific encryption box implementation */ options?: any; /** * Public information, depends on algorithm */ public?: any; }; export declare type EncryptionAlgorithm = ({ type: 'AES'; } & AesParams); export declare function encryptionAlgorithmAES(params: AesParams): EncryptionAlgorithm; export declare enum CipherMode { CBC = "CBC", CFB = "CFB", CTR = "CTR", ECB = "ECB", OFB = "OFB" } export declare type AesParams = { /** */ mode: CipherMode; /** */ key: string; /** */ iv?: string; }; export declare type AesInfo = { /** */ mode: CipherMode; /** */ iv?: string; }; export declare type ParamsOfFactorize = { /** * Hexadecimal representation of u64 composite number. */ composite: string; }; export declare type ResultOfFactorize = { /** * Two factors of composite or empty if composite can't be factorized. */ factors: string[]; }; export declare type ParamsOfModularPower = { /** * `base` argument of calculation. */ base: string; /** * `exponent` argument of calculation. */ exponent: string; /** * `modulus` argument of calculation. */ modulus: string; }; export declare type ResultOfModularPower = { /** * Result of modular exponentiation */ modular_power: string; }; export declare type ParamsOfTonCrc16 = { /** * Input data for CRC calculation. * * @remarks * Encoded with `base64`. */ data: string; }; export declare type ResultOfTonCrc16 = { /** * Calculated CRC for input data. */ crc: number; }; export declare type ParamsOfGenerateRandomBytes = { /** * Size of random byte array. */ length: number; }; export declare type ResultOfGenerateRandomBytes = { /** * Generated bytes encoded in `base64`. */ bytes: string; }; export declare type ParamsOfConvertPublicKeyToTonSafeFormat = { /** * Public key - 64 symbols hex string */ public_key: string; }; export declare type ResultOfConvertPublicKeyToTonSafeFormat = { /** * Public key represented in TON safe format. */ ton_public_key: string; }; export declare type KeyPair = { /** * Public key - 64 symbols hex string */ public: string; /** * Private key - u64 symbols hex string */ secret: string; }; export declare type ParamsOfSign = { /** * Data that must be signed encoded in `base64`. */ unsigned: string; /** * Sign keys. */ keys: KeyPair; }; export declare type ResultOfSign = { /** * Signed data combined with signature encoded in `base64`. */ signed: string; /** * Signature encoded in `hex`. */ signature: string; }; export declare type ParamsOfVerifySignature = { /** * Signed data that must be verified encoded in `base64`. */ signed: string; /** * Signer's public key - 64 symbols hex string */ public: string; }; export declare type ResultOfVerifySignature = { /** * Unsigned data encoded in `base64`. */ unsigned: string; }; export declare type ParamsOfHash = { /** * Input data for hash calculation. * * @remarks * Encoded with `base64`. */ data: string; }; export declare type ResultOfHash = { /** * Hash of input `data`. * * @remarks * Encoded with 'hex'. */ hash: string; }; export declare type ParamsOfScrypt = { /** * The password bytes to be hashed. Must be encoded with `base64`. */ password: string; /** * Salt bytes that modify the hash to protect against Rainbow table attacks. Must be encoded with `base64`. */ salt: string; /** * CPU/memory cost parameter */ log_n: number; /** * The block size parameter, which fine-tunes sequential memory read size and performance. */ r: number; /** * Parallelization parameter. */ p: number; /** * Intended output length in octets of the derived key. */ dk_len: number; }; export declare type ResultOfScrypt = { /** * Derived key. * * @remarks * Encoded with `hex`. */ key: string; }; export declare type ParamsOfNaclSignKeyPairFromSecret = { /** * Secret key - unprefixed 0-padded to 64 symbols hex string */ secret: string; }; export declare type ParamsOfNaclSign = { /** * Data that must be signed encoded in `base64`. */ unsigned: string; /** * Signer's secret key - unprefixed 0-padded to 128 symbols hex string (concatenation of 64 symbols secret and 64 symbols public keys). See `nacl_sign_keypair_from_secret_key`. */ secret: string; }; export declare type ResultOfNaclSign = { /** * Signed data, encoded in `base64`. */ signed: string; }; export declare type ParamsOfNaclSignOpen = { /** * Signed data that must be unsigned. * * @remarks * Encoded with `base64`. */ signed: string; /** * Signer's public key - unprefixed 0-padded to 64 symbols hex string */ public: string; }; export declare type ResultOfNaclSignOpen = { /** * Unsigned data, encoded in `base64`. */ unsigned: string; }; export declare type ResultOfNaclSignDetached = { /** * Signature encoded in `hex`. */ signature: string; }; export declare type ParamsOfNaclSignDetachedVerify = { /** * Unsigned data that must be verified. * * @remarks * Encoded with `base64`. */ unsigned: string; /** * Signature that must be verified. * * @remarks * Encoded with `hex`. */ signature: string; /** * Signer's public key - unprefixed 0-padded to 64 symbols hex string. */ public: string; }; export declare type ResultOfNaclSignDetachedVerify = { /** * `true` if verification succeeded or `false` if it failed */ succeeded: boolean; }; export declare type ParamsOfNaclBoxKeyPairFromSecret = { /** * Secret key - unprefixed 0-padded to 64 symbols hex string */ secret: string; }; export declare type ParamsOfNaclBox = { /** * Data that must be encrypted encoded in `base64`. */ decrypted: string; /** * Nonce, encoded in `hex` */ nonce: string; /** * Receiver's public key - unprefixed 0-padded to 64 symbols hex string */ their_public: string; /** * Sender's private key - unprefixed 0-padded to 64 symbols hex string */ secret: string; }; export declare type ResultOfNaclBox = { /** * Encrypted data encoded in `base64`. */ encrypted: string; }; export declare type ParamsOfNaclBoxOpen = { /** * Data that must be decrypted. * * @remarks * Encoded with `base64`. */ encrypted: string; /** */ nonce: string; /** * Sender's public key - unprefixed 0-padded to 64 symbols hex string */ their_public: string; /** * Receiver's private key - unprefixed 0-padded to 64 symbols hex string */ secret: string; }; export declare type ResultOfNaclBoxOpen = { /** * Decrypted data encoded in `base64`. */ decrypted: string; }; export declare type ParamsOfNaclSecretBox = { /** * Data that must be encrypted. * * @remarks * Encoded with `base64`. */ decrypted: string; /** * Nonce in `hex` */ nonce: string; /** * Secret key - unprefixed 0-padded to 64 symbols hex string */ key: string; }; export declare type ParamsOfNaclSecretBoxOpen = { /** * Data that must be decrypted. * * @remarks * Encoded with `base64`. */ encrypted: string; /** * Nonce in `hex` */ nonce: string; /** * Public key - unprefixed 0-padded to 64 symbols hex string */ key: string; }; export declare type ParamsOfMnemonicWords = { /** * Dictionary identifier */ dictionary?: number; }; export declare type ResultOfMnemonicWords = { /** * The list of mnemonic words */ words: string; }; export declare type ParamsOfMnemonicFromRandom = { /** * Dictionary identifier */ dictionary?: number; /** * Mnemonic word count */ word_count?: number; }; export declare type ResultOfMnemonicFromRandom = { /** * String of mnemonic words */ phrase: string; }; export declare type ParamsOfMnemonicFromEntropy = { /** * Entropy bytes. * * @remarks * Hex encoded. */ entropy: string; /** * Dictionary identifier */ dictionary?: number; /** * Mnemonic word count */ word_count?: number; }; export declare type ResultOfMnemonicFromEntropy = { /** * Phrase */ phrase: string; }; export declare type ParamsOfMnemonicVerify = { /** * Phrase */ phrase: string; /** * Dictionary identifier */ dictionary?: number; /** * Word count */ word_count?: number; }; export declare type ResultOfMnemonicVerify = { /** * Flag indicating if the mnemonic is valid or not */ valid: boolean; }; export declare type ParamsOfMnemonicDeriveSignKeys = { /** * Phrase */ phrase: string; /** * Derivation path, for instance "m/44'/396'/0'/0/0" */ path?: string; /** * Dictionary identifier */ dictionary?: number; /** * Word count */ word_count?: number; }; export declare type ParamsOfHDKeyXPrvFromMnemonic = { /** * String with seed phrase */ phrase: string; /** * Dictionary identifier */ dictionary?: number; /** * Mnemonic word count */ word_count?: number; }; export declare type ResultOfHDKeyXPrvFromMnemonic = { /** * Serialized extended master private key */ xprv: string; }; export declare type ParamsOfHDKeyDeriveFromXPrv = { /** * Serialized extended private key */ xprv: string; /** * Child index (see BIP-0032) */ child_index: number; /** * Indicates the derivation of hardened/not-hardened key (see BIP-0032) */ hardened: boolean; }; export declare type ResultOfHDKeyDeriveFromXPrv = { /** * Serialized extended private key */ xprv: string; }; export declare type ParamsOfHDKeyDeriveFromXPrvPath = { /** * Serialized extended private key */ xprv: string; /** * Derivation path, for instance "m/44'/396'/0'/0/0" */ path: string; }; export declare type ResultOfHDKeyDeriveFromXPrvPath = { /** * Derived serialized extended private key */ xprv: string; }; export declare type ParamsOfHDKeySecretFromXPrv = { /** * Serialized extended private key */ xprv: string; }; export declare type ResultOfHDKeySecretFromXPrv = { /** * Private key - 64 symbols hex string */ secret: string; }; export declare type ParamsOfHDKeyPublicFromXPrv = { /** * Serialized extended private key */ xprv: string; }; export declare type ResultOfHDKeyPublicFromXPrv = { /** * Public key - 64 symbols hex string */ public: string; }; export declare type ParamsOfChaCha20 = { /** * Source data to be encrypted or decrypted. * * @remarks * Must be encoded with `base64`. */ data: string; /** * 256-bit key. * * @remarks * Must be encoded with `hex`. */ key: string; /** * 96-bit nonce. * * @remarks * Must be encoded with `hex`. */ nonce: string; }; export declare type ResultOfChaCha20 = { /** * Encrypted/decrypted data. * * @remarks * Encoded with `base64`. */ data: string; }; export declare type RegisteredSigningBox = { /** * Handle of the signing box. */ handle: SigningBoxHandle; }; export declare type ParamsOfAppSigningBox = { type: 'GetPublicKey'; } | { type: 'Sign'; /** * Data to sign encoded as base64 */ unsigned: string; }; export declare function paramsOfAppSigningBoxGetPublicKey(): ParamsOfAppSigningBox; export declare function paramsOfAppSigningBoxSign(unsigned: string): ParamsOfAppSigningBox; export declare type ResultOfAppSigningBox = { type: 'GetPublicKey'; /** * Signing box public key */ public_key: string; } | { type: 'Sign'; /** * Data signature encoded as hex */ signature: string; }; export declare function resultOfAppSigningBoxGetPublicKey(public_key: string): ResultOfAppSigningBox; export declare function resultOfAppSigningBoxSign(signature: string): ResultOfAppSigningBox; export declare type ResultOfSigningBoxGetPublicKey = { /** * Public key of signing box. * * @remarks * Encoded with hex */ pubkey: string; }; export declare type ParamsOfSigningBoxSign = { /** * Signing Box handle. */ signing_box: SigningBoxHandle; /** * Unsigned user data. * * @remarks * Must be encoded with `base64`. */ unsigned: string; }; export declare type ResultOfSigningBoxSign = { /** * Data signature. * * @remarks * Encoded with `hex`. */ signature: string; }; export declare type RegisteredEncryptionBox = { /** * Handle of the encryption box */ handle: EncryptionBoxHandle; }; export declare type ParamsOfAppEncryptionBox = { type: 'GetInfo'; } | { type: 'Encrypt'; /** * Data, encoded in Base64 */ data: string; } | { type: 'Decrypt'; /** * Data, encoded in Base64 */ data: string; }; export declare function paramsOfAppEncryptionBoxGetInfo(): ParamsOfAppEncryptionBox; export declare function paramsOfAppEncryptionBoxEncrypt(data: string): ParamsOfAppEncryptionBox; export declare function paramsOfAppEncryptionBoxDecrypt(data: string): ParamsOfAppEncryptionBox; export declare type ResultOfAppEncryptionBox = { type: 'GetInfo'; /** */ info: EncryptionBoxInfo; } | { type: 'Encrypt'; /** * Encrypted data, encoded in Base64 */ data: string; } | { type: 'Decrypt'; /** * Decrypted data, encoded in Base64 */ data: string; }; export declare function resultOfAppEncryptionBoxGetInfo(info: EncryptionBoxInfo): ResultOfAppEncryptionBox; export declare function resultOfAppEncryptionBoxEncrypt(data: string): ResultOfAppEncryptionBox; export declare function resultOfAppEncryptionBoxDecrypt(data: string): ResultOfAppEncryptionBox; export declare type ParamsOfEncryptionBoxGetInfo = { /** * Encryption box handle */ encryption_box: EncryptionBoxHandle; }; export declare type ResultOfEncryptionBoxGetInfo = { /** * Encryption box information */ info: EncryptionBoxInfo; }; export declare type ParamsOfEncryptionBoxEncrypt = { /** * Encryption box handle */ encryption_box: EncryptionBoxHandle; /** * Data to be encrypted, encoded in Base64 */ data: string; }; export declare type ResultOfEncryptionBoxEncrypt = { /** * Encrypted data, encoded in Base64. * * @remarks * Padded to cipher block size */ data: string; }; export declare type ParamsOfEncryptionBoxDecrypt = { /** * Encryption box handle */ encryption_box: EncryptionBoxHandle; /** * Data to be decrypted, encoded in Base64 */ data: string; }; export declare type ResultOfEncryptionBoxDecrypt = { /** * Decrypted data, encoded in Base64. */ data: string; }; export declare type ParamsOfCreateEncryptionBox = { /** * Encryption algorithm specifier including cipher parameters (key, IV, etc) */ algorithm: EncryptionAlgorithm; }; declare type ResultOfAppSigningBoxGetPublicKey = { public_key: string; }; declare type ParamsOfAppSigningBoxSign = { unsigned: string; }; declare type ResultOfAppSigningBoxSign = { signature: string; }; export interface AppSigningBox { get_public_key(): Promise; sign(params: ParamsOfAppSigningBoxSign): Promise; } declare type ResultOfAppEncryptionBoxGetInfo = { info: EncryptionBoxInfo; }; declare type ParamsOfAppEncryptionBoxEncrypt = { data: string; }; declare type ResultOfAppEncryptionBoxEncrypt = { data: string; }; declare type ParamsOfAppEncryptionBoxDecrypt = { data: string; }; declare type ResultOfAppEncryptionBoxDecrypt = { data: string; }; export interface AppEncryptionBox { get_info(): Promise; encrypt(params: ParamsOfAppEncryptionBoxEncrypt): Promise; decrypt(params: ParamsOfAppEncryptionBoxDecrypt): Promise; } /** * Crypto functions. */ export declare class CryptoModule { client: IClient; constructor(client: IClient); /** * Integer factorization * * @remarks * Performs prime factorization – decomposition of a composite number * into a product of smaller prime integers (factors). * See [https://en.wikipedia.org/wiki/Integer_factorization] * * @param {ParamsOfFactorize} params * @returns ResultOfFactorize */ factorize(params: ParamsOfFactorize): Promise; /** * Modular exponentiation * * @remarks * Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`). * See [https://en.wikipedia.org/wiki/Modular_exponentiation] * * @param {ParamsOfModularPower} params * @returns ResultOfModularPower */ modular_power(params: ParamsOfModularPower): Promise; /** * Calculates CRC16 using TON algorithm. * * @param {ParamsOfTonCrc16} params * @returns ResultOfTonCrc16 */ ton_crc16(params: ParamsOfTonCrc16): Promise; /** * Generates random byte array of the specified length and returns it in `base64` format * * @param {ParamsOfGenerateRandomBytes} params * @returns ResultOfGenerateRandomBytes */ generate_random_bytes(params: ParamsOfGenerateRandomBytes): Promise; /** * Converts public key to ton safe_format * * @param {ParamsOfConvertPublicKeyToTonSafeFormat} params * @returns ResultOfConvertPublicKeyToTonSafeFormat */ convert_public_key_to_ton_safe_format(params: ParamsOfConvertPublicKeyToTonSafeFormat): Promise; /** * Generates random ed25519 key pair. * @returns KeyPair */ generate_random_sign_keys(): Promise; /** * Signs a data using the provided keys. * * @param {ParamsOfSign} params * @returns ResultOfSign */ sign(params: ParamsOfSign): Promise; /** * Verifies signed data using the provided public key. Raises error if verification is failed. * * @param {ParamsOfVerifySignature} params * @returns ResultOfVerifySignature */ verify_signature(params: ParamsOfVerifySignature): Promise; /** * Calculates SHA256 hash of the specified data. * * @param {ParamsOfHash} params * @returns ResultOfHash */ sha256(params: ParamsOfHash): Promise; /** * Calculates SHA512 hash of the specified data. * * @param {ParamsOfHash} params * @returns ResultOfHash */ sha512(params: ParamsOfHash): Promise; /** * Perform `scrypt` encryption * * @remarks * Derives key from `password` and `key` using `scrypt` algorithm. * See [https://en.wikipedia.org/wiki/Scrypt]. * * # Arguments * - `log_n` - The log2 of the Scrypt parameter `N` * - `r` - The Scrypt parameter `r` * - `p` - The Scrypt parameter `p` * # Conditions * - `log_n` must be less than `64` * - `r` must be greater than `0` and less than or equal to `4294967295` * - `p` must be greater than `0` and less than `4294967295` * # Recommended values sufficient for most use-cases * - `log_n = 15` (`n = 32768`) * - `r = 8` * - `p = 1` * * @param {ParamsOfScrypt} params * @returns ResultOfScrypt */ scrypt(params: ParamsOfScrypt): Promise; /** * Generates a key pair for signing from the secret key * * @remarks * **NOTE:** In the result the secret key is actually the concatenation * of secret and public keys (128 symbols hex string) by design of [NaCL](http://nacl.cr.yp.to/sign.html). * See also [the stackexchange question](https://crypto.stackexchange.com/questions/54353/). * * @param {ParamsOfNaclSignKeyPairFromSecret} params * @returns KeyPair */ nacl_sign_keypair_from_secret_key(params: ParamsOfNaclSignKeyPairFromSecret): Promise; /** * Signs data using the signer's secret key. * * @param {ParamsOfNaclSign} params * @returns ResultOfNaclSign */ nacl_sign(params: ParamsOfNaclSign): Promise; /** * Verifies the signature and returns the unsigned message * * @remarks * Verifies the signature in `signed` using the signer's public key `public` * and returns the message `unsigned`. * * If the signature fails verification, crypto_sign_open raises an exception. * * @param {ParamsOfNaclSignOpen} params * @returns ResultOfNaclSignOpen */ nacl_sign_open(params: ParamsOfNaclSignOpen): Promise; /** * Signs the message using the secret key and returns a signature. * * @remarks * Signs the message `unsigned` using the secret key `secret` * and returns a signature `signature`. * * @param {ParamsOfNaclSign} params * @returns ResultOfNaclSignDetached */ nacl_sign_detached(params: ParamsOfNaclSign): Promise; /** * Verifies the signature with public key and `unsigned` data. * * @param {ParamsOfNaclSignDetachedVerify} params * @returns ResultOfNaclSignDetachedVerify */ nacl_sign_detached_verify(params: ParamsOfNaclSignDetachedVerify): Promise; /** * Generates a random NaCl key pair * @returns KeyPair */ nacl_box_keypair(): Promise; /** * Generates key pair from a secret key * * @param {ParamsOfNaclBoxKeyPairFromSecret} params * @returns KeyPair */ nacl_box_keypair_from_secret_key(params: ParamsOfNaclBoxKeyPairFromSecret): Promise; /** * Public key authenticated encryption * * @remarks * Encrypt and authenticate a message using the senders secret key, the receivers public * key, and a nonce. * * @param {ParamsOfNaclBox} params * @returns ResultOfNaclBox */ nacl_box(params: ParamsOfNaclBox): Promise; /** * Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce. * * @param {ParamsOfNaclBoxOpen} params * @returns ResultOfNaclBoxOpen */ nacl_box_open(params: ParamsOfNaclBoxOpen): Promise; /** * Encrypt and authenticate message using nonce and secret key. * * @param {ParamsOfNaclSecretBox} params * @returns ResultOfNaclBox */ nacl_secret_box(params: ParamsOfNaclSecretBox): Promise; /** * Decrypts and verifies cipher text using `nonce` and secret `key`. * * @param {ParamsOfNaclSecretBoxOpen} params * @returns ResultOfNaclBoxOpen */ nacl_secret_box_open(params: ParamsOfNaclSecretBoxOpen): Promise; /** * Prints the list of words from the specified dictionary * * @param {ParamsOfMnemonicWords} params * @returns ResultOfMnemonicWords */ mnemonic_words(params: ParamsOfMnemonicWords): Promise; /** * Generates a random mnemonic * * @remarks * Generates a random mnemonic from the specified dictionary and word count * * @param {ParamsOfMnemonicFromRandom} params * @returns ResultOfMnemonicFromRandom */ mnemonic_from_random(params: ParamsOfMnemonicFromRandom): Promise; /** * Generates mnemonic from pre-generated entropy * * @param {ParamsOfMnemonicFromEntropy} params * @returns ResultOfMnemonicFromEntropy */ mnemonic_from_entropy(params: ParamsOfMnemonicFromEntropy): Promise; /** * Validates a mnemonic phrase * * @remarks * The phrase supplied will be checked for word length and validated according to the checksum * specified in BIP0039. * * @param {ParamsOfMnemonicVerify} params * @returns ResultOfMnemonicVerify */ mnemonic_verify(params: ParamsOfMnemonicVerify): Promise; /** * Derives a key pair for signing from the seed phrase * * @remarks * Validates the seed phrase, generates master key and then derives * the key pair from the master key and the specified path * * @param {ParamsOfMnemonicDeriveSignKeys} params * @returns KeyPair */ mnemonic_derive_sign_keys(params: ParamsOfMnemonicDeriveSignKeys): Promise; /** * Generates an extended master private key that will be the root for all the derived keys * * @param {ParamsOfHDKeyXPrvFromMnemonic} params * @returns ResultOfHDKeyXPrvFromMnemonic */ hdkey_xprv_from_mnemonic(params: ParamsOfHDKeyXPrvFromMnemonic): Promise; /** * Returns extended private key derived from the specified extended private key and child index * * @param {ParamsOfHDKeyDeriveFromXPrv} params * @returns ResultOfHDKeyDeriveFromXPrv */ hdkey_derive_from_xprv(params: ParamsOfHDKeyDeriveFromXPrv): Promise; /** * Derives the extended private key from the specified key and path * * @param {ParamsOfHDKeyDeriveFromXPrvPath} params * @returns ResultOfHDKeyDeriveFromXPrvPath */ hdkey_derive_from_xprv_path(params: ParamsOfHDKeyDeriveFromXPrvPath): Promise; /** * Extracts the private key from the serialized extended private key * * @param {ParamsOfHDKeySecretFromXPrv} params * @returns ResultOfHDKeySecretFromXPrv */ hdkey_secret_from_xprv(params: ParamsOfHDKeySecretFromXPrv): Promise; /** * Extracts the public key from the serialized extended private key * * @param {ParamsOfHDKeyPublicFromXPrv} params * @returns ResultOfHDKeyPublicFromXPrv */ hdkey_public_from_xprv(params: ParamsOfHDKeyPublicFromXPrv): Promise; /** * Performs symmetric `chacha20` encryption. * * @param {ParamsOfChaCha20} params * @returns ResultOfChaCha20 */ chacha20(params: ParamsOfChaCha20): Promise; /** * Register an application implemented signing box. * @returns RegisteredSigningBox */ register_signing_box(obj: AppSigningBox): Promise; /** * Creates a default signing box implementation. * * @param {KeyPair} params * @returns RegisteredSigningBox */ get_signing_box(params: KeyPair): Promise; /** * Returns public key of signing key pair. * * @param {RegisteredSigningBox} params * @returns ResultOfSigningBoxGetPublicKey */ signing_box_get_public_key(params: RegisteredSigningBox): Promise; /** * Returns signed user data. * * @param {ParamsOfSigningBoxSign} params * @returns ResultOfSigningBoxSign */ signing_box_sign(params: ParamsOfSigningBoxSign): Promise; /** * Removes signing box from SDK. * * @param {RegisteredSigningBox} params * @returns */ remove_signing_box(params: RegisteredSigningBox): Promise; /** * Register an application implemented encryption box. * @returns RegisteredEncryptionBox */ register_encryption_box(obj: AppEncryptionBox): Promise; /** * Removes encryption box from SDK * * @param {RegisteredEncryptionBox} params * @returns */ remove_encryption_box(params: RegisteredEncryptionBox): Promise; /** * Queries info from the given encryption box * * @param {ParamsOfEncryptionBoxGetInfo} params * @returns ResultOfEncryptionBoxGetInfo */ encryption_box_get_info(params: ParamsOfEncryptionBoxGetInfo): Promise; /** * Encrypts data using given encryption box Note. * * @remarks * Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data. Client should store the original data size after encryption and use it after * decryption to retrieve the original data from decrypted data. * * @param {ParamsOfEncryptionBoxEncrypt} params * @returns ResultOfEncryptionBoxEncrypt */ encryption_box_encrypt(params: ParamsOfEncryptionBoxEncrypt): Promise; /** * Decrypts data using given encryption box Note. * * @remarks * Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data. Client should store the original data size after encryption and use it after * decryption to retrieve the original data from decrypted data. * * @param {ParamsOfEncryptionBoxDecrypt} params * @returns ResultOfEncryptionBoxDecrypt */ encryption_box_decrypt(params: ParamsOfEncryptionBoxDecrypt): Promise; /** * Creates encryption box with specified algorithm * * @param {ParamsOfCreateEncryptionBox} params * @returns RegisteredEncryptionBox */ create_encryption_box(params: ParamsOfCreateEncryptionBox): Promise; } export declare enum AbiErrorCode { RequiredAddressMissingForEncodeMessage = 301, RequiredCallSetMissingForEncodeMessage = 302, InvalidJson = 303, InvalidMessage = 304, EncodeDeployMessageFailed = 305, EncodeRunMessageFailed = 306, AttachSignatureFailed = 307, InvalidTvcImage = 308, RequiredPublicKeyMissingForFunctionHeader = 309, InvalidSigner = 310, InvalidAbi = 311, InvalidFunctionId = 312, InvalidData = 313, EncodeInitialDataFailed = 314 } export declare type Abi = { type: 'Contract'; /** */ value: AbiContract; } | { type: 'Json'; /** */ value: string; } | { type: 'Handle'; /** */ value: AbiHandle; } | { type: 'Serialized'; /** */ value: AbiContract; }; export declare function abiContract(value: AbiContract): Abi; export declare function abiJson(value: string): Abi; export declare function abiHandle(value: AbiHandle): Abi; export declare function abiSerialized(value: AbiContract): Abi; export declare type AbiHandle = number; export declare type FunctionHeader = { /** * Message expiration time in seconds. If not specified - calculated automatically from message_expiration_timeout(), try_index and message_expiration_timeout_grow_factor() (if ABI includes `expire` header). */ expire?: number; /** * Message creation time in milliseconds. * * @remarks * If not specified, `now` is used (if ABI includes `time` header). */ time?: bigint; /** * Public key is used by the contract to check the signature. * * @remarks * Encoded in `hex`. If not specified, method fails with exception (if ABI includes `pubkey` header).. */ pubkey?: string; }; export declare type CallSet = { /** * Function name that is being called. Or function id encoded as string in hex (starting with 0x). */ function_name: string; /** * Function header. * * @remarks * If an application omits some header parameters required by the * contract's ABI, the library will set the default values for * them. */ header?: FunctionHeader; /** * Function input parameters according to ABI. */ input?: any; }; export declare type DeploySet = { /** * Content of TVC file encoded in `base64`. */ tvc: string; /** * Target workchain for destination address. * * @remarks * Default is `0`. */ workchain_id?: number; /** * List of initial values for contract's public variables. */ initial_data?: any; /** * Optional public key that can be provided in deploy set in order to substitute one in TVM file or provided by Signer. * * @remarks * Public key resolving priority: * 1. Public key from deploy set. * 2. Public key, specified in TVM file. * 3. Public key, provided by Signer. */ initial_pubkey?: string; }; export declare type Signer = { type: 'None'; } | { type: 'External'; /** */ public_key: string; } | { type: 'Keys'; /** */ keys: KeyPair; } | { type: 'SigningBox'; /** */ handle: SigningBoxHandle; }; export declare function signerNone(): Signer; export declare function signerExternal(public_key: string): Signer; export declare function signerKeys(keys: KeyPair): Signer; export declare function signerSigningBox(handle: SigningBoxHandle): Signer; export declare enum MessageBodyType { Input = "Input", Output = "Output", InternalOutput = "InternalOutput", Event = "Event" } export declare type StateInitSource = { type: 'Message'; /** */ source: MessageSource; } | { type: 'StateInit'; /** * Code BOC. * * @remarks * Encoded in `base64`. */ code: string; /** * Data BOC. * * @remarks * Encoded in `base64`. */ data: string; /** * Library BOC. * * @remarks * Encoded in `base64`. */ library?: string; } | { type: 'Tvc'; /** */ tvc: string; /** */ public_key?: string; /** */ init_params?: StateInitParams; }; export declare function stateInitSourceMessage(source: MessageSource): StateInitSource; export declare function stateInitSourceStateInit(code: string, data: string, library?: string): StateInitSource; export declare function stateInitSourceTvc(tvc: string, public_key?: string, init_params?: StateInitParams): StateInitSource; export declare type StateInitParams = { /** */ abi: Abi; /** */ value: any; }; export declare type MessageSource = { type: 'Encoded'; /** */ message: string; /** */ abi?: Abi; } | ({ type: 'EncodingParams'; } & ParamsOfEncodeMessage); export declare function messageSourceEncoded(message: string, abi?: Abi): MessageSource; export declare function messageSourceEncodingParams(params: ParamsOfEncodeMessage): MessageSource; export declare type AbiParam = { /** */ name: string; /** */ type: string; /** */ components?: AbiParam[]; }; export declare type AbiEvent = { /** */ name: string; /** */ inputs: AbiParam[]; /** */ id?: string | null; }; export declare type AbiData = { /** */ key: number; /** */ name: string; /** */ type: string; /** */ components?: AbiParam[]; }; export declare type AbiFunction = { /** */ name: string; /** */ inputs: AbiParam[]; /** */ outputs: AbiParam[]; /** */ id?: string | null; }; export declare type AbiContract = { /** */ 'ABI version'?: number; /** */ abi_version?: number; /** */ version?: string | null; /** */ header?: string[]; /** */ functions?: AbiFunction[]; /** */ events?: AbiEvent[]; /** */ data?: AbiData[]; /** */ fields?: AbiParam[]; }; export declare type ParamsOfEncodeMessageBody = { /** * Contract ABI. */ abi: Abi; /** * Function call parameters. * * @remarks * Must be specified in non deploy message. * * In case of deploy message contains parameters of constructor. */ call_set: CallSet; /** * True if internal message body must be encoded. */ is_internal: boolean; /** * Signing parameters. */ signer: Signer; /** * Processing try index. * * @remarks * Used in message processing with retries. * * Encoder uses the provided try index to calculate message * expiration time. * * Expiration timeouts will grow with every retry. * * Default value is 0. */ processing_try_index?: number; }; export declare type ResultOfEncodeMessageBody = { /** * Message body BOC encoded with `base64`. */ body: string; /** * Optional data to sign. * * @remarks * Encoded with `base64`. * Presents when `message` is unsigned. Can be used for external * message signing. Is this case you need to sing this data and * produce signed message using `abi.attach_signature`. */ data_to_sign?: string; }; export declare type ParamsOfAttachSignatureToMessageBody = { /** * Contract ABI */ abi: Abi; /** * Public key. * * @remarks * Must be encoded with `hex`. */ public_key: string; /** * Unsigned message body BOC. * * @remarks * Must be encoded with `base64`. */ message: string; /** * Signature. * * @remarks * Must be encoded with `hex`. */ signature: string; }; export declare type ResultOfAttachSignatureToMessageBody = { /** */ body: string; }; export declare type ParamsOfEncodeMessage = { /** * Contract ABI. */ abi: Abi; /** * Target address the message will be sent to. * * @remarks * Must be specified in case of non-deploy message. */ address?: string; /** * Deploy parameters. * * @remarks * Must be specified in case of deploy message. */ deploy_set?: DeploySet; /** * Function call parameters. * * @remarks * Must be specified in case of non-deploy message. * * In case of deploy message it is optional and contains parameters * of the functions that will to be called upon deploy transaction. */ call_set?: CallSet; /** * Signing parameters. */ signer: Signer; /** * Processing try index. * * @remarks * Used in message processing with retries (if contract's ABI includes "expire" header). * * Encoder uses the provided try index to calculate message * expiration time. The 1st message expiration time is specified in * Client config. * * Expiration timeouts will grow with every retry. * Retry grow factor is set in Client config: * <.....add config parameter with default value here> * * Default value is 0. */ processing_try_index?: number; }; export declare type ResultOfEncodeMessage = { /** * Message BOC encoded with `base64`. */ message: string; /** * Optional data to be signed encoded in `base64`. * * @remarks * Returned in case of `Signer::External`. Can be used for external * message signing. Is this case you need to use this data to create signature and * then produce signed message using `abi.attach_signature`. */ data_to_sign?: string; /** * Destination address. */ address: string; /** * Message id. */ message_id: string; }; export declare type ParamsOfEncodeInternalMessage = { /** * Contract ABI. * * @remarks * Can be None if both deploy_set and call_set are None. */ abi?: Abi; /** * Target address the message will be sent to. * * @remarks * Must be specified in case of non-deploy message. */ address?: string; /** * Source address of the message. */ src_address?: string; /** * Deploy parameters. * * @remarks * Must be specified in case of deploy message. */ deploy_set?: DeploySet; /** * Function call parameters. * * @remarks * Must be specified in case of non-deploy message. * * In case of deploy message it is optional and contains parameters * of the functions that will to be called upon deploy transaction. */ call_set?: CallSet; /** * Value in nanotokens to be sent with message. */ value: string; /** * Flag of bounceable message. * * @remarks * Default is true. */ bounce?: boolean; /** * Enable Instant Hypercube Routing for the message. * * @remarks * Default is false. */ enable_ihr?: boolean; }; export declare type ResultOfEncodeInternalMessage = { /** * Message BOC encoded with `base64`. */ message: string; /** * Destination address. */ address: string; /** * Message id. */ message_id: string; }; export declare type ParamsOfAttachSignature = { /** * Contract ABI */ abi: Abi; /** * Public key encoded in `hex`. */ public_key: string; /** * Unsigned message BOC encoded in `base64`. */ message: string; /** * Signature encoded in `hex`. */ signature: string; }; export declare type ResultOfAttachSignature = { /** * Signed message BOC */ message: string; /** * Message ID */ message_id: string; }; export declare type ParamsOfDecodeMessage = { /** * contract ABI */ abi: Abi; /** * Message BOC */ message: string; }; export declare type DecodedMessageBody = { /** * Type of the message body content. */ body_type: MessageBodyType; /** * Function or event name. */ name: string; /** * Parameters or result value. */ value?: any; /** * Function header. */ header?: FunctionHeader; }; export declare type ParamsOfDecodeMessageBody = { /** * Contract ABI used to decode. */ abi: Abi; /** * Message body BOC encoded in `base64`. */ body: string; /** * True if the body belongs to the internal message. */ is_internal: boolean; }; export declare type ParamsOfEncodeAccount = { /** * Source of the account state init. */ state_init: StateInitSource; /** * Initial balance. */ balance?: bigint; /** * Initial value for the `last_trans_lt`. */ last_trans_lt?: bigint; /** * Initial value for the `last_paid`. */ last_paid?: number; /** * Cache type to put the result. * * @remarks * The BOC itself returned if no cache type provided */ boc_cache?: BocCacheType; }; export declare type ResultOfEncodeAccount = { /** * Account BOC encoded in `base64`. */ account: string; /** * Account ID encoded in `hex`. */ id: string; }; export declare type ParamsOfDecodeAccountData = { /** * Contract ABI */ abi: Abi; /** * Data BOC or BOC handle */ data: string; }; export declare type ResultOfDecodeAccountData = { /** * Decoded data as a JSON structure. */ data: any; }; export declare type ParamsOfUpdateInitialData = { /** * Contract ABI */ abi?: Abi; /** * Data BOC or BOC handle */ data: string; /** * List of initial values for contract's static variables. * * @remarks * `abi` parameter should be provided to set initial data */ initial_data?: any; /** * Initial account owner's public key to set into account data */ initial_pubkey?: string; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfUpdateInitialData = { /** * Updated data BOC or BOC handle */ data: string; }; export declare type ParamsOfEncodeInitialData = { /** * Contract ABI */ abi?: Abi; /** * List of initial values for contract's static variables. * * @remarks * `abi` parameter should be provided to set initial data */ initial_data?: any; /** * Initial account owner's public key to set into account data */ initial_pubkey?: string; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfEncodeInitialData = { /** * Updated data BOC or BOC handle */ data: string; }; export declare type ParamsOfDecodeInitialData = { /** * Contract ABI. * * @remarks * Initial data is decoded if this parameter is provided */ abi?: Abi; /** * Data BOC or BOC handle */ data: string; }; export declare type ResultOfDecodeInitialData = { /** * List of initial values of contract's public variables. * * @remarks * Initial data is decoded if `abi` input parameter is provided */ initial_data?: any; /** * Initial account owner's public key */ initial_pubkey: string; }; export declare type ParamsOfDecodeBoc = { /** * Parameters to decode from BOC */ params: AbiParam[]; /** * Data BOC or BOC handle */ boc: string; /** */ allow_partial: boolean; }; export declare type ResultOfDecodeBoc = { /** * Decoded data as a JSON structure. */ data: any; }; export declare type ParamsOfAbiEncodeBoc = { /** * Parameters to encode into BOC */ params: AbiParam[]; /** * Parameters and values as a JSON structure */ data: any; /** * Cache type to put the result. * * @remarks * The BOC itself returned if no cache type provided */ boc_cache?: BocCacheType; }; export declare type ResultOfAbiEncodeBoc = { /** * BOC encoded as base64 */ boc: string; }; /** * Provides message encoding and decoding according to the ABI specification. */ export declare class AbiModule { client: IClient; constructor(client: IClient); /** * Encodes message body according to ABI function call. * * @param {ParamsOfEncodeMessageBody} params * @returns ResultOfEncodeMessageBody */ encode_message_body(params: ParamsOfEncodeMessageBody): Promise; /** * * @param {ParamsOfAttachSignatureToMessageBody} params * @returns ResultOfAttachSignatureToMessageBody */ attach_signature_to_message_body(params: ParamsOfAttachSignatureToMessageBody): Promise; /** * Encodes an ABI-compatible message * * @remarks * Allows to encode deploy and function call messages, * both signed and unsigned. * * Use cases include messages of any possible type: * - deploy with initial function call (i.e. `constructor` or any other function that is used for some kind * of initialization); * - deploy without initial function call; * - signed/unsigned + data for signing. * * `Signer` defines how the message should or shouldn't be signed: * * `Signer::None` creates an unsigned message. This may be needed in case of some public methods, * that do not require authorization by pubkey. * * `Signer::External` takes public key and returns `data_to_sign` for later signing. * Use `attach_signature` method with the result signature to get the signed message. * * `Signer::Keys` creates a signed message with provided key pair. * * [SOON] `Signer::SigningBox` Allows using a special interface to implement signing * without private key disclosure to SDK. For instance, in case of using a cold wallet or HSM, * when application calls some API to sign data. * * There is an optional public key can be provided in deploy set in order to substitute one * in TVM file. * * Public key resolving priority: * 1. Public key from deploy set. * 2. Public key, specified in TVM file. * 3. Public key, provided by signer. * * @param {ParamsOfEncodeMessage} params * @returns ResultOfEncodeMessage */ encode_message(params: ParamsOfEncodeMessage): Promise; /** * Encodes an internal ABI-compatible message * * @remarks * Allows to encode deploy and function call messages. * * Use cases include messages of any possible type: * - deploy with initial function call (i.e. `constructor` or any other function that is used for some kind * of initialization); * - deploy without initial function call; * - simple function call * * There is an optional public key can be provided in deploy set in order to substitute one * in TVM file. * * Public key resolving priority: * 1. Public key from deploy set. * 2. Public key, specified in TVM file. * * @param {ParamsOfEncodeInternalMessage} params * @returns ResultOfEncodeInternalMessage */ encode_internal_message(params: ParamsOfEncodeInternalMessage): Promise; /** * Combines `hex`-encoded `signature` with `base64`-encoded `unsigned_message`. Returns signed message encoded in `base64`. * * @param {ParamsOfAttachSignature} params * @returns ResultOfAttachSignature */ attach_signature(params: ParamsOfAttachSignature): Promise; /** * Decodes message body using provided message BOC and ABI. * * @param {ParamsOfDecodeMessage} params * @returns DecodedMessageBody */ decode_message(params: ParamsOfDecodeMessage): Promise; /** * Decodes message body using provided body BOC and ABI. * * @param {ParamsOfDecodeMessageBody} params * @returns DecodedMessageBody */ decode_message_body(params: ParamsOfDecodeMessageBody): Promise; /** * Creates account state BOC * * @remarks * Creates account state provided with one of these sets of data : * 1. BOC of code, BOC of data, BOC of library * 2. TVC (string in `base64`), keys, init params * * @param {ParamsOfEncodeAccount} params * @returns ResultOfEncodeAccount */ encode_account(params: ParamsOfEncodeAccount): Promise; /** * Decodes account data using provided data BOC and ABI. * * @remarks * Note: this feature requires ABI 2.1 or higher. * * @param {ParamsOfDecodeAccountData} params * @returns ResultOfDecodeAccountData */ decode_account_data(params: ParamsOfDecodeAccountData): Promise; /** * Updates initial account data with initial values for the contract's static variables and owner's public key. This operation is applicable only for initial account data (before deploy). If the contract is already deployed, its data doesn't contain this data section any more. * * @param {ParamsOfUpdateInitialData} params * @returns ResultOfUpdateInitialData */ update_initial_data(params: ParamsOfUpdateInitialData): Promise; /** * Encodes initial account data with initial values for the contract's static variables and owner's public key into a data BOC that can be passed to `encode_tvc` function afterwards. * * @remarks * This function is analogue of `tvm.buildDataInit` function in Solidity. * * @param {ParamsOfEncodeInitialData} params * @returns ResultOfEncodeInitialData */ encode_initial_data(params: ParamsOfEncodeInitialData): Promise; /** * Decodes initial values of a contract's static variables and owner's public key from account initial data This operation is applicable only for initial account data (before deploy). If the contract is already deployed, its data doesn't contain this data section any more. * * @param {ParamsOfDecodeInitialData} params * @returns ResultOfDecodeInitialData */ decode_initial_data(params: ParamsOfDecodeInitialData): Promise; /** * Decodes BOC into JSON as a set of provided parameters. * * @remarks * Solidity functions use ABI types for [builder encoding](https://github.com/tonlabs/TON-Solidity-Compiler/blob/master/API.md#tvmbuilderstore). * The simplest way to decode such a BOC is to use ABI decoding. * ABI has it own rules for fields layout in cells so manually encoded * BOC can not be described in terms of ABI rules. * * To solve this problem we introduce a new ABI type `Ref()` * which allows to store `ParamType` ABI parameter in cell reference and, thus, * decode manually encoded BOCs. This type is available only in `decode_boc` function * and will not be available in ABI messages encoding until it is included into some ABI revision. * * Such BOC descriptions covers most users needs. If someone wants to decode some BOC which * can not be described by these rules (i.e. BOC with TLB containing constructors of flags * defining some parsing conditions) then they can decode the fields up to fork condition, * check the parsed data manually, expand the parsing schema and then decode the whole BOC * with the full schema. * * @param {ParamsOfDecodeBoc} params * @returns ResultOfDecodeBoc */ decode_boc(params: ParamsOfDecodeBoc): Promise; /** * Encodes given parameters in JSON into a BOC using param types from ABI. * * @param {ParamsOfAbiEncodeBoc} params * @returns ResultOfAbiEncodeBoc */ encode_boc(params: ParamsOfAbiEncodeBoc): Promise; } export declare type BocCacheType = { type: 'Pinned'; /** */ pin: string; } | { type: 'Unpinned'; }; export declare function bocCacheTypePinned(pin: string): BocCacheType; export declare function bocCacheTypeUnpinned(): BocCacheType; export declare enum BocErrorCode { InvalidBoc = 201, SerializationError = 202, InappropriateBlock = 203, MissingSourceBoc = 204, InsufficientCacheSize = 205, BocRefNotFound = 206, InvalidBocRef = 207 } export declare type ParamsOfParse = { /** * BOC encoded as base64 */ boc: string; }; export declare type ResultOfParse = { /** * JSON containing parsed BOC */ parsed: any; }; export declare type ParamsOfParseShardstate = { /** * BOC encoded as base64 */ boc: string; /** * Shardstate identificator */ id: string; /** * Workchain shardstate belongs to */ workchain_id: number; }; export declare type ParamsOfGetBlockchainConfig = { /** * Key block BOC or zerostate BOC encoded as base64 */ block_boc: string; }; export declare type ResultOfGetBlockchainConfig = { /** * Blockchain config BOC encoded as base64 */ config_boc: string; }; export declare type ParamsOfGetBocHash = { /** * BOC encoded as base64 or BOC handle */ boc: string; }; export declare type ResultOfGetBocHash = { /** * BOC root hash encoded with hex */ hash: string; }; export declare type ParamsOfGetBocDepth = { /** * BOC encoded as base64 or BOC handle */ boc: string; }; export declare type ResultOfGetBocDepth = { /** * BOC root cell depth */ depth: number; }; export declare type ParamsOfGetCodeFromTvc = { /** * Contract TVC image or image BOC handle */ tvc: string; }; export declare type ResultOfGetCodeFromTvc = { /** * Contract code encoded as base64 */ code: string; }; export declare type ParamsOfBocCacheGet = { /** * Reference to the cached BOC */ boc_ref: string; }; export declare type ResultOfBocCacheGet = { /** * BOC encoded as base64. */ boc?: string; }; export declare type ParamsOfBocCacheSet = { /** * BOC encoded as base64 or BOC reference */ boc: string; /** * Cache type */ cache_type: BocCacheType; }; export declare type ResultOfBocCacheSet = { /** * Reference to the cached BOC */ boc_ref: string; }; export declare type ParamsOfBocCacheUnpin = { /** * Pinned name */ pin: string; /** * Reference to the cached BOC. * * @remarks * If it is provided then only referenced BOC is unpinned */ boc_ref?: string; }; export declare type BuilderOp = { type: 'Integer'; /** * Bit size of the value. */ size: number; /** * Value: - `Number` containing integer number. * * @remarks * e.g. `123`, `-123`. - Decimal string. e.g. `"123"`, `"-123"`. * - `0x` prefixed hexadecimal string. * e.g `0x123`, `0X123`, `-0x123`. */ value: any; } | { type: 'BitString'; /** * Bit string content using bitstring notation. See `TON VM specification` 1.0. * * @remarks * Contains hexadecimal string representation: * - Can end with `_` tag. * - Can be prefixed with `x` or `X`. * - Can be prefixed with `x{` or `X{` and ended with `}`. * * Contains binary string represented as a sequence * of `0` and `1` prefixed with `n` or `N`. * * Examples: * `1AB`, `x1ab`, `X1AB`, `x{1abc}`, `X{1ABC}` * `2D9_`, `x2D9_`, `X2D9_`, `x{2D9_}`, `X{2D9_}` * `n00101101100`, `N00101101100` */ value: string; } | { type: 'Cell'; /** * Nested cell builder. */ builder: BuilderOp[]; } | { type: 'CellBoc'; /** * Nested cell BOC encoded with `base64` or BOC cache key. */ boc: string; } | { type: 'Address'; /** * Address in a common `workchain:account` or base64 format. */ address: string; }; export declare function builderOpInteger(size: number, value: any): BuilderOp; export declare function builderOpBitString(value: string): BuilderOp; export declare function builderOpCell(builder: BuilderOp[]): BuilderOp; export declare function builderOpCellBoc(boc: string): BuilderOp; export declare function builderOpAddress(address: string): BuilderOp; export declare type ParamsOfEncodeBoc = { /** * Cell builder operations. */ builder: BuilderOp[]; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfEncodeBoc = { /** * Encoded cell BOC or BOC cache key. */ boc: string; }; export declare type ParamsOfGetCodeSalt = { /** * Contract code BOC encoded as base64 or code BOC handle */ code: string; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfGetCodeSalt = { /** * Contract code salt if present. * * @remarks * BOC encoded as base64 or BOC handle */ salt?: string; }; export declare type ParamsOfSetCodeSalt = { /** * Contract code BOC encoded as base64 or code BOC handle */ code: string; /** * Code salt to set. * * @remarks * BOC encoded as base64 or BOC handle */ salt: string; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfSetCodeSalt = { /** * Contract code with salt set. * * @remarks * BOC encoded as base64 or BOC handle */ code: string; }; export declare type ParamsOfDecodeTvc = { /** * Contract TVC image BOC encoded as base64 or BOC handle */ tvc: string; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfDecodeTvc = { /** * Contract code BOC encoded as base64 or BOC handle */ code?: string; /** * Contract code hash */ code_hash?: string; /** * Contract code depth */ code_depth?: number; /** * Contract data BOC encoded as base64 or BOC handle */ data?: string; /** * Contract data hash */ data_hash?: string; /** * Contract data depth */ data_depth?: number; /** * Contract library BOC encoded as base64 or BOC handle */ library?: string; /** * `special.tick` field. * * @remarks * Specifies the contract ability to handle tick transactions */ tick?: boolean; /** * `special.tock` field. * * @remarks * Specifies the contract ability to handle tock transactions */ tock?: boolean; /** * Is present and non-zero only in instances of large smart contracts */ split_depth?: number; /** * Compiler version, for example 'sol 0.49.0' */ compiler_version?: string; }; export declare type ParamsOfEncodeTvc = { /** * Contract code BOC encoded as base64 or BOC handle */ code?: string; /** * Contract data BOC encoded as base64 or BOC handle */ data?: string; /** * Contract library BOC encoded as base64 or BOC handle */ library?: string; /** * `special.tick` field. * * @remarks * Specifies the contract ability to handle tick transactions */ tick?: boolean; /** * `special.tock` field. * * @remarks * Specifies the contract ability to handle tock transactions */ tock?: boolean; /** * Is present and non-zero only in instances of large smart contracts */ split_depth?: number; /** * Cache type to put the result. The BOC itself returned if no cache type provided. */ boc_cache?: BocCacheType; }; export declare type ResultOfEncodeTvc = { /** * Contract TVC image BOC encoded as base64 or BOC handle of boc_cache parameter was specified */ tvc: string; }; export declare type ParamsOfEncodeExternalInMessage = { /** * Source address. */ src?: string; /** * Destination address. */ dst: string; /** * Bag of cells with state init (used in deploy messages). */ init?: string; /** * Bag of cells with the message body encoded as base64. */ body?: string; /** * Cache type to put the result. * * @remarks * The BOC itself returned if no cache type provided */ boc_cache?: BocCacheType; }; export declare type ResultOfEncodeExternalInMessage = { /** * Message BOC encoded with `base64`. */ message: string; /** * Message id. */ message_id: string; }; export declare type ParamsOfGetCompilerVersion = { /** * Contract code BOC encoded as base64 or code BOC handle */ code: string; }; export declare type ResultOfGetCompilerVersion = { /** * Compiler version, for example 'sol 0.49.0' */ version?: string; }; /** * BOC manipulation module. */ export declare class BocModule { client: IClient; constructor(client: IClient); /** * Parses message boc into a JSON * * @remarks * JSON structure is compatible with GraphQL API message object * * @param {ParamsOfParse} params * @returns ResultOfParse */ parse_message(params: ParamsOfParse): Promise; /** * Parses transaction boc into a JSON * * @remarks * JSON structure is compatible with GraphQL API transaction object * * @param {ParamsOfParse} params * @returns ResultOfParse */ parse_transaction(params: ParamsOfParse): Promise; /** * Parses account boc into a JSON * * @remarks * JSON structure is compatible with GraphQL API account object * * @param {ParamsOfParse} params * @returns ResultOfParse */ parse_account(params: ParamsOfParse): Promise; /** * Parses block boc into a JSON * * @remarks * JSON structure is compatible with GraphQL API block object * * @param {ParamsOfParse} params * @returns ResultOfParse */ parse_block(params: ParamsOfParse): Promise; /** * Parses shardstate boc into a JSON * * @remarks * JSON structure is compatible with GraphQL API shardstate object * * @param {ParamsOfParseShardstate} params * @returns ResultOfParse */ parse_shardstate(params: ParamsOfParseShardstate): Promise; /** * Extract blockchain configuration from key block and also from zerostate. * * @param {ParamsOfGetBlockchainConfig} params * @returns ResultOfGetBlockchainConfig */ get_blockchain_config(params: ParamsOfGetBlockchainConfig): Promise; /** * Calculates BOC root hash * * @param {ParamsOfGetBocHash} params * @returns ResultOfGetBocHash */ get_boc_hash(params: ParamsOfGetBocHash): Promise; /** * Calculates BOC depth * * @param {ParamsOfGetBocDepth} params * @returns ResultOfGetBocDepth */ get_boc_depth(params: ParamsOfGetBocDepth): Promise; /** * Extracts code from TVC contract image * * @param {ParamsOfGetCodeFromTvc} params * @returns ResultOfGetCodeFromTvc */ get_code_from_tvc(params: ParamsOfGetCodeFromTvc): Promise; /** * Get BOC from cache * * @param {ParamsOfBocCacheGet} params * @returns ResultOfBocCacheGet */ cache_get(params: ParamsOfBocCacheGet): Promise; /** * Save BOC into cache * * @param {ParamsOfBocCacheSet} params * @returns ResultOfBocCacheSet */ cache_set(params: ParamsOfBocCacheSet): Promise; /** * Unpin BOCs with specified pin. * * @remarks * BOCs which don't have another pins will be removed from cache * * @param {ParamsOfBocCacheUnpin} params * @returns */ cache_unpin(params: ParamsOfBocCacheUnpin): Promise; /** * Encodes bag of cells (BOC) with builder operations. This method provides the same functionality as Solidity TvmBuilder. Resulting BOC of this method can be passed into Solidity and C++ contracts as TvmCell type. * * @param {ParamsOfEncodeBoc} params * @returns ResultOfEncodeBoc */ encode_boc(params: ParamsOfEncodeBoc): Promise; /** * Returns the contract code's salt if it is present. * * @param {ParamsOfGetCodeSalt} params * @returns ResultOfGetCodeSalt */ get_code_salt(params: ParamsOfGetCodeSalt): Promise; /** * Sets new salt to contract code. * * @remarks * Returns the new contract code with salt. * * @param {ParamsOfSetCodeSalt} params * @returns ResultOfSetCodeSalt */ set_code_salt(params: ParamsOfSetCodeSalt): Promise; /** * Decodes tvc into code, data, libraries and special options. * * @param {ParamsOfDecodeTvc} params * @returns ResultOfDecodeTvc */ decode_tvc(params: ParamsOfDecodeTvc): Promise; /** * Encodes tvc from code, data, libraries ans special options (see input params) * * @param {ParamsOfEncodeTvc} params * @returns ResultOfEncodeTvc */ encode_tvc(params: ParamsOfEncodeTvc): Promise; /** * Encodes a message * * @remarks * Allows to encode any external inbound message. * * @param {ParamsOfEncodeExternalInMessage} params * @returns ResultOfEncodeExternalInMessage */ encode_external_in_message(params: ParamsOfEncodeExternalInMessage): Promise; /** * Returns the compiler version used to compile the code. * * @param {ParamsOfGetCompilerVersion} params * @returns ResultOfGetCompilerVersion */ get_compiler_version(params: ParamsOfGetCompilerVersion): Promise; } export declare enum ProcessingErrorCode { MessageAlreadyExpired = 501, MessageHasNotDestinationAddress = 502, CanNotBuildMessageCell = 503, FetchBlockFailed = 504, SendMessageFailed = 505, InvalidMessageBoc = 506, MessageExpired = 507, TransactionWaitTimeout = 508, InvalidBlockReceived = 509, CanNotCheckBlockShard = 510, BlockNotFound = 511, InvalidData = 512, ExternalSignerMustNotBeUsed = 513 } export declare type ProcessingEvent = { type: 'WillFetchFirstBlock'; } | { type: 'FetchFirstBlockFailed'; /** */ error: ClientError; } | { type: 'WillSend'; /** */ shard_block_id: string; /** */ message_id: string; /** */ message: string; } | { type: 'DidSend'; /** */ shard_block_id: string; /** */ message_id: string; /** */ message: string; } | { type: 'SendFailed'; /** */ shard_block_id: string; /** */ message_id: string; /** */ message: string; /** */ error: ClientError; } | { type: 'WillFetchNextBlock'; /** */ shard_block_id: string; /** */ message_id: string; /** */ message: string; } | { type: 'FetchNextBlockFailed'; /** */ shard_block_id: string; /** */ message_id: string; /** */ message: string; /** */ error: ClientError; } | { type: 'MessageExpired'; /** */ message_id: string; /** */ message: string; /** */ error: ClientError; }; export declare function processingEventWillFetchFirstBlock(): ProcessingEvent; export declare function processingEventFetchFirstBlockFailed(error: ClientError): ProcessingEvent; export declare function processingEventWillSend(shard_block_id: string, message_id: string, message: string): ProcessingEvent; export declare function processingEventDidSend(shard_block_id: string, message_id: string, message: string): ProcessingEvent; export declare function processingEventSendFailed(shard_block_id: string, message_id: string, message: string, error: ClientError): ProcessingEvent; export declare function processingEventWillFetchNextBlock(shard_block_id: string, message_id: string, message: string): ProcessingEvent; export declare function processingEventFetchNextBlockFailed(shard_block_id: string, message_id: string, message: string, error: ClientError): ProcessingEvent; export declare function processingEventMessageExpired(message_id: string, message: string, error: ClientError): ProcessingEvent; export declare type ResultOfProcessMessage = { /** * Parsed transaction. * * @remarks * In addition to the regular transaction fields there is a * `boc` field encoded with `base64` which contains source * transaction BOC. */ transaction: any; /** * List of output messages' BOCs. * * @remarks * Encoded as `base64` */ out_messages: string[]; /** * Optional decoded message bodies according to the optional `abi` parameter. */ decoded?: DecodedOutput; /** * Transaction fees */ fees: TransactionFees; }; export declare type DecodedOutput = { /** * Decoded bodies of the out messages. * * @remarks * If the message can't be decoded, then `None` will be stored in * the appropriate position. */ out_messages: DecodedMessageBody | null[]; /** * Decoded body of the function output message. */ output?: any; }; export declare type ParamsOfSendMessage = { /** * Message BOC. */ message: string; /** * Optional message ABI. * * @remarks * If this parameter is specified and the message has the * `expire` header then expiration time will be checked against * the current time to prevent unnecessary sending of already expired message. * * The `message already expired` error will be returned in this * case. * * Note, that specifying `abi` for ABI compliant contracts is * strongly recommended, so that proper processing strategy can be * chosen. */ abi?: Abi; /** * Flag for requesting events sending */ send_events: boolean; }; export declare type ResultOfSendMessage = { /** * The last generated shard block of the message destination account before the message was sent. * * @remarks * This block id must be used as a parameter of the * `wait_for_transaction`. */ shard_block_id: string; /** * The list of endpoints to which the message was sent. * * @remarks * This list id must be used as a parameter of the * `wait_for_transaction`. */ sending_endpoints: string[]; }; export declare type ParamsOfWaitForTransaction = { /** * Optional ABI for decoding the transaction result. * * @remarks * If it is specified, then the output messages' bodies will be * decoded according to this ABI. * * The `abi_decoded` result field will be filled out. */ abi?: Abi; /** * Message BOC. * * @remarks * Encoded with `base64`. */ message: string; /** * The last generated block id of the destination account shard before the message was sent. * * @remarks * You must provide the same value as the `send_message` has returned. */ shard_block_id: string; /** * Flag that enables/disables intermediate events */ send_events: boolean; /** * The list of endpoints to which the message was sent. * * @remarks * Use this field to get more informative errors. * Provide the same value as the `send_message` has returned. * If the message was not delivered (expired), SDK will log the endpoint URLs, used for its sending. */ sending_endpoints?: string[]; }; export declare type ParamsOfProcessMessage = { /** * Message encode parameters. */ message_encode_params: ParamsOfEncodeMessage; /** * Flag for requesting events sending */ send_events: boolean; }; /** * Message processing module. * * @remarks * This module incorporates functions related to complex message * processing scenarios. */ export declare class ProcessingModule { client: IClient; constructor(client: IClient); /** * Sends message to the network * * @remarks * Sends message to the network and returns the last generated shard block of the destination account * before the message was sent. It will be required later for message processing. * * @param {ParamsOfSendMessage} params * @returns ResultOfSendMessage */ send_message(params: ParamsOfSendMessage, responseHandler?: ResponseHandler): Promise; /** * Performs monitoring of the network for the result transaction of the external inbound message processing. * * @remarks * `send_events` enables intermediate events, such as `WillFetchNextBlock`, * `FetchNextBlockFailed` that may be useful for logging of new shard blocks creation * during message processing. * * Note, that presence of the `abi` parameter is critical for ABI * compliant contracts. Message processing uses drastically * different strategy for processing message for contracts which * ABI includes "expire" header. * * When the ABI header `expire` is present, the processing uses * `message expiration` strategy: * - The maximum block gen time is set to * `message_expiration_timeout + transaction_wait_timeout`. * - When maximum block gen time is reached, the processing will * be finished with `MessageExpired` error. * * When the ABI header `expire` isn't present or `abi` parameter * isn't specified, the processing uses `transaction waiting` * strategy: * - The maximum block gen time is set to * `now() + transaction_wait_timeout`. * * - If maximum block gen time is reached and no result transaction is found, * the processing will exit with an error. * * @param {ParamsOfWaitForTransaction} params * @returns ResultOfProcessMessage */ wait_for_transaction(params: ParamsOfWaitForTransaction, responseHandler?: ResponseHandler): Promise; /** * Creates message, sends it to the network and monitors its processing. * * @remarks * Creates ABI-compatible message, * sends it to the network and monitors for the result transaction. * Decodes the output messages' bodies. * * If contract's ABI includes "expire" header, then * SDK implements retries in case of unsuccessful message delivery within the expiration * timeout: SDK recreates the message, sends it and processes it again. * * The intermediate events, such as `WillFetchFirstBlock`, `WillSend`, `DidSend`, * `WillFetchNextBlock`, etc - are switched on/off by `send_events` flag * and logged into the supplied callback function. * * The retry configuration parameters are defined in the client's `NetworkConfig` and `AbiConfig`. * * If contract's ABI does not include "expire" header * then, if no transaction is found within the network timeout (see config parameter ), exits with error. * * @param {ParamsOfProcessMessage} params * @returns ResultOfProcessMessage */ process_message(params: ParamsOfProcessMessage, responseHandler?: ResponseHandler): Promise; } export declare type AddressStringFormat = { type: 'AccountId'; } | { type: 'Hex'; } | { type: 'Base64'; /** */ url: boolean; /** */ test: boolean; /** */ bounce: boolean; }; export declare function addressStringFormatAccountId(): AddressStringFormat; export declare function addressStringFormatHex(): AddressStringFormat; export declare function addressStringFormatBase64(url: boolean, test: boolean, bounce: boolean): AddressStringFormat; export declare enum AccountAddressType { AccountId = "AccountId", Hex = "Hex", Base64 = "Base64" } export declare type ParamsOfConvertAddress = { /** * Account address in any TON format. */ address: string; /** * Specify the format to convert to. */ output_format: AddressStringFormat; }; export declare type ResultOfConvertAddress = { /** * Address in the specified format */ address: string; }; export declare type ParamsOfGetAddressType = { /** * Account address in any TON format. */ address: string; }; export declare type ResultOfGetAddressType = { /** * Account address type. */ address_type: AccountAddressType; }; export declare type ParamsOfCalcStorageFee = { /** */ account: string; /** */ period: number; }; export declare type ResultOfCalcStorageFee = { /** */ fee: string; }; export declare type ParamsOfCompressZstd = { /** * Uncompressed data. * * @remarks * Must be encoded as base64. */ uncompressed: string; /** * Compression level, from 1 to 21. Where: 1 - lowest compression level (fastest compression); 21 - highest compression level (slowest compression). If level is omitted, the default compression level is used (currently `3`). */ level?: number; }; export declare type ResultOfCompressZstd = { /** * Compressed data. * * @remarks * Must be encoded as base64. */ compressed: string; }; export declare type ParamsOfDecompressZstd = { /** * Compressed data. * * @remarks * Must be encoded as base64. */ compressed: string; }; export declare type ResultOfDecompressZstd = { /** * Decompressed data. * * @remarks * Must be encoded as base64. */ decompressed: string; }; /** * Misc utility Functions. */ export declare class UtilsModule { client: IClient; constructor(client: IClient); /** * Converts address from any TON format to any TON format * * @param {ParamsOfConvertAddress} params * @returns ResultOfConvertAddress */ convert_address(params: ParamsOfConvertAddress): Promise; /** * Validates and returns the type of any TON address. * * @remarks * Address types are the following * * `0:919db8e740d50bf349df2eea03fa30c385d846b991ff5542e67098ee833fc7f7` - standard TON address most * commonly used in all cases. Also called as hex address * `919db8e740d50bf349df2eea03fa30c385d846b991ff5542e67098ee833fc7f7` - account ID. A part of full * address. Identifies account inside particular workchain * `EQCRnbjnQNUL80nfLuoD+jDDhdhGuZH/VULmcJjugz/H9wam` - base64 address. Also called "user-friendly". * Was used at the beginning of TON. Now it is supported for compatibility * * @param {ParamsOfGetAddressType} params * @returns ResultOfGetAddressType */ get_address_type(params: ParamsOfGetAddressType): Promise; /** * Calculates storage fee for an account over a specified time period * * @param {ParamsOfCalcStorageFee} params * @returns ResultOfCalcStorageFee */ calc_storage_fee(params: ParamsOfCalcStorageFee): Promise; /** * Compresses data using Zstandard algorithm * * @param {ParamsOfCompressZstd} params * @returns ResultOfCompressZstd */ compress_zstd(params: ParamsOfCompressZstd): Promise; /** * Decompresses data using Zstandard algorithm * * @param {ParamsOfDecompressZstd} params * @returns ResultOfDecompressZstd */ decompress_zstd(params: ParamsOfDecompressZstd): Promise; } export declare enum TvmErrorCode { CanNotReadTransaction = 401, CanNotReadBlockchainConfig = 402, TransactionAborted = 403, InternalError = 404, ActionPhaseFailed = 405, AccountCodeMissing = 406, LowBalance = 407, AccountFrozenOrDeleted = 408, AccountMissing = 409, UnknownExecutionError = 410, InvalidInputStack = 411, InvalidAccountBoc = 412, InvalidMessageType = 413, ContractExecutionError = 414 } export declare type ExecutionOptions = { /** * boc with config */ blockchain_config?: string; /** * time that is used as transaction time */ block_time?: number; /** * block logical time */ block_lt?: bigint; /** * transaction logical time */ transaction_lt?: bigint; }; export declare type AccountForExecutor = { type: 'None'; } | { type: 'Uninit'; } | { type: 'Account'; /** * Account BOC. * * @remarks * Encoded as base64. */ boc: string; /** * Flag for running account with the unlimited balance. * * @remarks * Can be used to calculate transaction fees without balance check */ unlimited_balance?: boolean; }; export declare function accountForExecutorNone(): AccountForExecutor; export declare function accountForExecutorUninit(): AccountForExecutor; export declare function accountForExecutorAccount(boc: string, unlimited_balance?: boolean): AccountForExecutor; export declare type TransactionFees = { /** */ in_msg_fwd_fee: bigint; /** */ storage_fee: bigint; /** */ gas_fee: bigint; /** */ out_msgs_fwd_fee: bigint; /** */ total_account_fees: bigint; /** */ total_output: bigint; }; export declare type ParamsOfRunExecutor = { /** * Input message BOC. * * @remarks * Must be encoded as base64. */ message: string; /** * Account to run on executor */ account: AccountForExecutor; /** * Execution options. */ execution_options?: ExecutionOptions; /** * Contract ABI for decoding output messages */ abi?: Abi; /** * Skip transaction check flag */ skip_transaction_check?: boolean; /** * Cache type to put the result. * * @remarks * The BOC itself returned if no cache type provided */ boc_cache?: BocCacheType; /** * Return updated account flag. * * @remarks * Empty string is returned if the flag is `false` */ return_updated_account?: boolean; }; export declare type ResultOfRunExecutor = { /** * Parsed transaction. * * @remarks * In addition to the regular transaction fields there is a * `boc` field encoded with `base64` which contains source * transaction BOC. */ transaction: any; /** * List of output messages' BOCs. * * @remarks * Encoded as `base64` */ out_messages: string[]; /** * Optional decoded message bodies according to the optional `abi` parameter. */ decoded?: DecodedOutput; /** * Updated account state BOC. * * @remarks * Encoded as `base64` */ account: string; /** * Transaction fees */ fees: TransactionFees; }; export declare type ParamsOfRunTvm = { /** * Input message BOC. * * @remarks * Must be encoded as base64. */ message: string; /** * Account BOC. * * @remarks * Must be encoded as base64. */ account: string; /** * Execution options. */ execution_options?: ExecutionOptions; /** * Contract ABI for decoding output messages */ abi?: Abi; /** * Cache type to put the result. * * @remarks * The BOC itself returned if no cache type provided */ boc_cache?: BocCacheType; /** * Return updated account flag. * * @remarks * Empty string is returned if the flag is `false` */ return_updated_account?: boolean; }; export declare type ResultOfRunTvm = { /** * List of output messages' BOCs. * * @remarks * Encoded as `base64` */ out_messages: string[]; /** * Optional decoded message bodies according to the optional `abi` parameter. */ decoded?: DecodedOutput; /** * Updated account state BOC. * * @remarks * Encoded as `base64`. Attention! Only `account_state.storage.state.data` part of the BOC is updated. */ account: string; }; export declare type ParamsOfRunGet = { /** * Account BOC in `base64` */ account: string; /** * Function name */ function_name: string; /** * Input parameters */ input?: any; /** * Execution options */ execution_options?: ExecutionOptions; /** * Convert lists based on nested tuples in the **result** into plain arrays. * * @remarks * Default is `false`. Input parameters may use any of lists representations * If you receive this error on Web: "Runtime error. Unreachable code should not be executed...", * set this flag to true. * This may happen, for example, when elector contract contains too many participants */ tuple_list_as_array?: boolean; }; export declare type ResultOfRunGet = { /** * Values returned by get-method on stack */ output: any; }; /** */ export declare class TvmModule { client: IClient; constructor(client: IClient); /** * Emulates all the phases of contract execution locally * * @remarks * Performs all the phases of contract execution on Transaction Executor - * the same component that is used on Validator Nodes. * * Can be used for contract debugging, to find out the reason why a message was not delivered successfully. * Validators throw away the failed external inbound messages (if they failed bedore `ACCEPT`) in the real network. * This is why these messages are impossible to debug in the real network. * With the help of run_executor you can do that. In fact, `process_message` function * performs local check with `run_executor` if there was no transaction as a result of processing * and returns the error, if there is one. * * Another use case to use `run_executor` is to estimate fees for message execution. * Set `AccountForExecutor::Account.unlimited_balance` * to `true` so that emulation will not depend on the actual balance. * This may be needed to calculate deploy fees for an account that does not exist yet. * JSON with fees is in `fees` field of the result. * * One more use case - you can produce the sequence of operations, * thus emulating the sequential contract calls locally. * And so on. * * Transaction executor requires account BOC (bag of cells) as a parameter. * To get the account BOC - use `net.query` method to download it from GraphQL API * (field `boc` of `account`) or generate it with `abi.encode_account` method. * * Also it requires message BOC. To get the message BOC - use `abi.encode_message` or `abi.encode_internal_message`. * * If you need this emulation to be as precise as possible (for instance - emulate transaction * with particular lt in particular block or use particular blockchain config, * downloaded from a particular key block - then specify `execution_options` parameter. * * If you need to see the aborted transaction as a result, not as an error, set `skip_transaction_check` to `true`. * * @param {ParamsOfRunExecutor} params * @returns ResultOfRunExecutor */ run_executor(params: ParamsOfRunExecutor): Promise; /** * Executes get-methods of ABI-compatible contracts * * @remarks * Performs only a part of compute phase of transaction execution * that is used to run get-methods of ABI-compatible contracts. * * If you try to run get-methods with `run_executor` you will get an error, because it checks ACCEPT and exits * if there is none, which is actually true for get-methods. * * To get the account BOC (bag of cells) - use `net.query` method to download it from GraphQL API * (field `boc` of `account`) or generate it with `abi.encode_account method`. * To get the message BOC - use `abi.encode_message` or prepare it any other way, for instance, with FIFT script. * * Attention! Updated account state is produces as well, but only * `account_state.storage.state.data` part of the BOC is updated. * * @param {ParamsOfRunTvm} params * @returns ResultOfRunTvm */ run_tvm(params: ParamsOfRunTvm): Promise; /** * Executes a get-method of FIFT contract * * @remarks * Executes a get-method of FIFT contract that fulfills the smc-guidelines https://test.ton.org/smc-guidelines.txt * and returns the result data from TVM's stack * * @param {ParamsOfRunGet} params * @returns ResultOfRunGet */ run_get(params: ParamsOfRunGet): Promise; } export declare enum NetErrorCode { QueryFailed = 601, SubscribeFailed = 602, WaitForFailed = 603, GetSubscriptionResultFailed = 604, InvalidServerResponse = 605, ClockOutOfSync = 606, WaitForTimeout = 607, GraphqlError = 608, NetworkModuleSuspended = 609, WebsocketDisconnected = 610, NotSupported = 611, NoEndpointsProvided = 612, GraphqlWebsocketInitError = 613, NetworkModuleResumed = 614 } export declare type OrderBy = { /** */ path: string; /** */ direction: SortDirection; }; export declare enum SortDirection { ASC = "ASC", DESC = "DESC" } export declare type ParamsOfQueryOperation = ({ type: 'QueryCollection'; } & ParamsOfQueryCollection) | ({ type: 'WaitForCollection'; } & ParamsOfWaitForCollection) | ({ type: 'AggregateCollection'; } & ParamsOfAggregateCollection) | ({ type: 'QueryCounterparties'; } & ParamsOfQueryCounterparties); export declare function paramsOfQueryOperationQueryCollection(params: ParamsOfQueryCollection): ParamsOfQueryOperation; export declare function paramsOfQueryOperationWaitForCollection(params: ParamsOfWaitForCollection): ParamsOfQueryOperation; export declare function paramsOfQueryOperationAggregateCollection(params: ParamsOfAggregateCollection): ParamsOfQueryOperation; export declare function paramsOfQueryOperationQueryCounterparties(params: ParamsOfQueryCounterparties): ParamsOfQueryOperation; export declare type FieldAggregation = { /** * Dot separated path to the field */ field: string; /** * Aggregation function that must be applied to field values */ fn: AggregationFn; }; export declare enum AggregationFn { COUNT = "COUNT", MIN = "MIN", MAX = "MAX", SUM = "SUM", AVERAGE = "AVERAGE" } export declare type TransactionNode = { /** * Transaction id. */ id: string; /** * In message id. */ in_msg: string; /** * Out message ids. */ out_msgs: string[]; /** * Account address. */ account_addr: string; /** * Transactions total fees. */ total_fees: string; /** * Aborted flag. */ aborted: boolean; /** * Compute phase exit code. */ exit_code?: number; }; export declare type MessageNode = { /** * Message id. */ id: string; /** * Source transaction id. * * @remarks * This field is missing for an external inbound messages. */ src_transaction_id?: string; /** * Destination transaction id. * * @remarks * This field is missing for an external outbound messages. */ dst_transaction_id?: string; /** * Source address. */ src?: string; /** * Destination address. */ dst?: string; /** * Transferred tokens value. */ value?: string; /** * Bounce flag. */ bounce: boolean; /** * Decoded body. * * @remarks * Library tries to decode message body using provided `params.abi_registry`. * This field will be missing if none of the provided abi can be used to decode. */ decoded_body?: DecodedMessageBody; }; export declare type ParamsOfQuery = { /** * GraphQL query text. */ query: string; /** * Variables used in query. * * @remarks * Must be a map with named values that can be used in query. */ variables?: any; }; export declare type ResultOfQuery = { /** * Result provided by DAppServer. */ result: any; }; export declare type ParamsOfBatchQuery = { /** * List of query operations that must be performed per single fetch. */ operations: ParamsOfQueryOperation[]; }; export declare type ResultOfBatchQuery = { /** * Result values for batched queries. * * @remarks * Returns an array of values. Each value corresponds to `queries` item. */ results: any[]; }; export declare type ParamsOfQueryCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ result: string; /** * Sorting order */ order?: OrderBy[]; /** * Number of documents to return */ limit?: number; }; export declare type ResultOfQueryCollection = { /** * Objects that match the provided criteria */ result: any[]; }; export declare type ParamsOfAggregateCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ fields?: FieldAggregation[]; }; export declare type ResultOfAggregateCollection = { /** * Values for requested fields. * * @remarks * Returns an array of strings. Each string refers to the corresponding `fields` item. * Numeric value is returned as a decimal string representations. */ values: any; }; export declare type ParamsOfWaitForCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ result: string; /** * Query timeout */ timeout?: number; }; export declare type ResultOfWaitForCollection = { /** * First found object that matches the provided criteria */ result: any; }; export declare type ResultOfSubscribeCollection = { /** * Subscription handle. * * @remarks * Must be closed with `unsubscribe` */ handle: number; }; export declare type ParamsOfSubscribeCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ result: string; }; export declare type ParamsOfSubscribe = { /** * GraphQL subscription text. */ subscription: string; /** * Variables used in subscription. * * @remarks * Must be a map with named values that can be used in query. */ variables?: any; }; export declare type ParamsOfFindLastShardBlock = { /** * Account address */ address: string; }; export declare type ResultOfFindLastShardBlock = { /** * Account shard last block ID */ block_id: string; }; export declare type EndpointsSet = { /** * List of endpoints provided by server */ endpoints: string[]; }; export declare type ResultOfGetEndpoints = { /** * Current query endpoint */ query: string; /** * List of all endpoints used by client */ endpoints: string[]; }; export declare type ParamsOfQueryCounterparties = { /** * Account address */ account: string; /** * Projection (result) string */ result: string; /** * Number of counterparties to return */ first?: number; /** * `cursor` field of the last received result */ after?: string; }; export declare type ParamsOfQueryTransactionTree = { /** * Input message id. */ in_msg: string; /** * List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry. */ abi_registry?: Abi[]; /** * Timeout used to limit waiting time for the missing messages and transaction. * * @remarks * If some of the following messages and transactions are missing yet * The maximum waiting time is regulated by this option. * * Default value is 60000 (1 min). */ timeout?: number; }; export declare type ResultOfQueryTransactionTree = { /** * Messages. */ messages: MessageNode[]; /** * Transactions. */ transactions: TransactionNode[]; }; export declare type ParamsOfCreateBlockIterator = { /** * Starting time to iterate from. * * @remarks * If the application specifies this parameter then the iteration * includes blocks with `gen_utime` >= `start_time`. * Otherwise the iteration starts from zero state. * * Must be specified in seconds. */ start_time?: number; /** * Optional end time to iterate for. * * @remarks * If the application specifies this parameter then the iteration * includes blocks with `gen_utime` < `end_time`. * Otherwise the iteration never stops. * * Must be specified in seconds. */ end_time?: number; /** * Shard prefix filter. * * @remarks * If the application specifies this parameter and it is not the empty array * then the iteration will include items related to accounts that belongs to * the specified shard prefixes. * Shard prefix must be represented as a string "workchain:prefix". * Where `workchain` is a signed integer and the `prefix` if a hexadecimal * representation if the 64-bit unsigned integer with tagged shard prefix. * For example: "0:3800000000000000". */ shard_filter?: string[]; /** * Projection (result) string. * * @remarks * List of the fields that must be returned for iterated items. * This field is the same as the `result` parameter of * the `query_collection` function. * Note that iterated items can contains additional fields that are * not requested in the `result`. */ result?: string; }; export declare type RegisteredIterator = { /** * Iterator handle. * * @remarks * Must be removed using `remove_iterator` * when it is no more needed for the application. */ handle: number; }; export declare type ParamsOfResumeBlockIterator = { /** * Iterator state from which to resume. * * @remarks * Same as value returned from `iterator_next`. */ resume_state: any; }; export declare type ParamsOfCreateTransactionIterator = { /** * Starting time to iterate from. * * @remarks * If the application specifies this parameter then the iteration * includes blocks with `gen_utime` >= `start_time`. * Otherwise the iteration starts from zero state. * * Must be specified in seconds. */ start_time?: number; /** * Optional end time to iterate for. * * @remarks * If the application specifies this parameter then the iteration * includes blocks with `gen_utime` < `end_time`. * Otherwise the iteration never stops. * * Must be specified in seconds. */ end_time?: number; /** * Shard prefix filters. * * @remarks * If the application specifies this parameter and it is not an empty array * then the iteration will include items related to accounts that belongs to * the specified shard prefixes. * Shard prefix must be represented as a string "workchain:prefix". * Where `workchain` is a signed integer and the `prefix` if a hexadecimal * representation if the 64-bit unsigned integer with tagged shard prefix. * For example: "0:3800000000000000". * Account address conforms to the shard filter if * it belongs to the filter workchain and the first bits of address match to * the shard prefix. Only transactions with suitable account addresses are iterated. */ shard_filter?: string[]; /** * Account address filter. * * @remarks * Application can specify the list of accounts for which * it wants to iterate transactions. * * If this parameter is missing or an empty list then the library iterates * transactions for all accounts that pass the shard filter. * * Note that the library doesn't detect conflicts between the account filter and the shard filter * if both are specified. * So it is an application responsibility to specify the correct filter combination. */ accounts_filter?: string[]; /** * Projection (result) string. * * @remarks * List of the fields that must be returned for iterated items. * This field is the same as the `result` parameter of * the `query_collection` function. * Note that iterated items can contain additional fields that are * not requested in the `result`. */ result?: string; /** * Include `transfers` field in iterated transactions. * * @remarks * If this parameter is `true` then each transaction contains field * `transfers` with list of transfer. See more about this structure in function description. */ include_transfers?: boolean; }; export declare type ParamsOfResumeTransactionIterator = { /** * Iterator state from which to resume. * * @remarks * Same as value returned from `iterator_next`. */ resume_state: any; /** * Account address filter. * * @remarks * Application can specify the list of accounts for which * it wants to iterate transactions. * * If this parameter is missing or an empty list then the library iterates * transactions for all accounts that passes the shard filter. * * Note that the library doesn't detect conflicts between the account filter and the shard filter * if both are specified. * So it is the application's responsibility to specify the correct filter combination. */ accounts_filter?: string[]; }; export declare type ParamsOfIteratorNext = { /** * Iterator handle */ iterator: number; /** * Maximum count of the returned items. * * @remarks * If value is missing or is less than 1 the library uses 1. */ limit?: number; /** * Indicates that function must return the iterator state that can be used for resuming iteration. */ return_resume_state?: boolean; }; export declare type ResultOfIteratorNext = { /** * Next available items. * * @remarks * Note that `iterator_next` can return an empty items and `has_more` equals to `true`. * In this case the application have to continue iteration. * Such situation can take place when there is no data yet but * the requested `end_time` is not reached. */ items: any[]; /** * Indicates that there are more available items in iterated range. */ has_more: boolean; /** * Optional iterator state that can be used for resuming iteration. * * @remarks * This field is returned only if the `return_resume_state` parameter * is specified. * * Note that `resume_state` corresponds to the iteration position * after the returned items. */ resume_state?: any; }; /** * Network access. */ export declare class NetModule { client: IClient; constructor(client: IClient); /** * Performs DAppServer GraphQL query. * * @param {ParamsOfQuery} params * @returns ResultOfQuery */ query(params: ParamsOfQuery): Promise; /** * Performs multiple queries per single fetch. * * @param {ParamsOfBatchQuery} params * @returns ResultOfBatchQuery */ batch_query(params: ParamsOfBatchQuery): Promise; /** * Queries collection data * * @remarks * Queries data that satisfies the `filter` conditions, * limits the number of returned records and orders them. * The projection fields are limited to `result` fields * * @param {ParamsOfQueryCollection} params * @returns ResultOfQueryCollection */ query_collection(params: ParamsOfQueryCollection): Promise; /** * Aggregates collection data. * * @remarks * Aggregates values from the specified `fields` for records * that satisfies the `filter` conditions, * * @param {ParamsOfAggregateCollection} params * @returns ResultOfAggregateCollection */ aggregate_collection(params: ParamsOfAggregateCollection): Promise; /** * Returns an object that fulfills the conditions or waits for its appearance * * @remarks * Triggers only once. * If object that satisfies the `filter` conditions * already exists - returns it immediately. * If not - waits for insert/update of data within the specified `timeout`, * and returns it. * The projection fields are limited to `result` fields * * @param {ParamsOfWaitForCollection} params * @returns ResultOfWaitForCollection */ wait_for_collection(params: ParamsOfWaitForCollection): Promise; /** * Cancels a subscription * * @remarks * Cancels a subscription specified by its handle. * * @param {ResultOfSubscribeCollection} params * @returns */ unsubscribe(params: ResultOfSubscribeCollection): Promise; /** * Creates a collection subscription * * @remarks * Triggers for each insert/update of data that satisfies * the `filter` conditions. * The projection fields are limited to `result` fields. * * The subscription is a persistent communication channel between * client and Free TON Network. * All changes in the blockchain will be reflected in realtime. * Changes means inserts and updates of the blockchain entities. * * ### Important Notes on Subscriptions * * Unfortunately sometimes the connection with the network brakes down. * In this situation the library attempts to reconnect to the network. * This reconnection sequence can take significant time. * All of this time the client is disconnected from the network. * * Bad news is that all blockchain changes that happened while * the client was disconnected are lost. * * Good news is that the client report errors to the callback when * it loses and resumes connection. * * So, if the lost changes are important to the application then * the application must handle these error reports. * * Library reports errors with `responseType` == 101 * and the error object passed via `params`. * * When the library has successfully reconnected * the application receives callback with * `responseType` == 101 and `params.code` == 614 (NetworkModuleResumed). * * Application can use several ways to handle this situation: * - If application monitors changes for the single blockchain * object (for example specific account): application * can perform a query for this object and handle actual data as a * regular data from the subscription. * - If application monitors sequence of some blockchain objects * (for example transactions of the specific account): application must * refresh all cached (or visible to user) lists where this sequences presents. * * @param {ParamsOfSubscribeCollection} params * @returns ResultOfSubscribeCollection */ subscribe_collection(params: ParamsOfSubscribeCollection, responseHandler?: ResponseHandler): Promise; /** * Creates a subscription * * @remarks * The subscription is a persistent communication channel between * client and Everscale Network. * * ### Important Notes on Subscriptions * * Unfortunately sometimes the connection with the network brakes down. * In this situation the library attempts to reconnect to the network. * This reconnection sequence can take significant time. * All of this time the client is disconnected from the network. * * Bad news is that all changes that happened while * the client was disconnected are lost. * * Good news is that the client report errors to the callback when * it loses and resumes connection. * * So, if the lost changes are important to the application then * the application must handle these error reports. * * Library reports errors with `responseType` == 101 * and the error object passed via `params`. * * When the library has successfully reconnected * the application receives callback with * `responseType` == 101 and `params.code` == 614 (NetworkModuleResumed). * * Application can use several ways to handle this situation: * - If application monitors changes for the single * object (for example specific account): application * can perform a query for this object and handle actual data as a * regular data from the subscription. * - If application monitors sequence of some objects * (for example transactions of the specific account): application must * refresh all cached (or visible to user) lists where this sequences presents. * * @param {ParamsOfSubscribe} params * @returns ResultOfSubscribeCollection */ subscribe(params: ParamsOfSubscribe, responseHandler?: ResponseHandler): Promise; /** * Suspends network module to stop any network activity * @returns */ suspend(): Promise; /** * Resumes network module to enable network activity * @returns */ resume(): Promise; /** * Returns ID of the last block in a specified account shard * * @param {ParamsOfFindLastShardBlock} params * @returns ResultOfFindLastShardBlock */ find_last_shard_block(params: ParamsOfFindLastShardBlock): Promise; /** * Requests the list of alternative endpoints from server * @returns EndpointsSet */ fetch_endpoints(): Promise; /** * Sets the list of endpoints to use on reinit * * @param {EndpointsSet} params * @returns */ set_endpoints(params: EndpointsSet): Promise; /** * Requests the list of alternative endpoints from server * @returns ResultOfGetEndpoints */ get_endpoints(): Promise; /** * Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts * * @remarks * *Attention* this query retrieves data from 'Counterparties' service which is not supported in * the opensource version of DApp Server (and will not be supported) as well as in TON OS SE (will be supported in SE in future), * but is always accessible via [TON OS Devnet/Mainnet Clouds](https://docs.ton.dev/86757ecb2/p/85c869-networks) * * @param {ParamsOfQueryCounterparties} params * @returns ResultOfQueryCollection */ query_counterparties(params: ParamsOfQueryCounterparties): Promise; /** * Returns a tree of transactions triggered by a specific message. * * @remarks * Performs recursive retrieval of a transactions tree produced by a specific message: * in_msg -> dst_transaction -> out_messages -> dst_transaction -> ... * If the chain of transactions execution is in progress while the function is running, * it will wait for the next transactions to appear until the full tree or more than 50 transactions * are received. * * All the retrieved messages and transactions are included * into `result.messages` and `result.transactions` respectively. * * Function reads transactions layer by layer, by pages of 20 transactions. * * The retrieval prosess goes like this: * Let's assume we have an infinite chain of transactions and each transaction generates 5 messages. * 1. Retrieve 1st message (input parameter) and corresponding transaction - put it into result. * It is the first level of the tree of transactions - its root. * Retrieve 5 out message ids from the transaction for next steps. * 2. Retrieve 5 messages and corresponding transactions on the 2nd layer. Put them into result. * Retrieve 5*5 out message ids from these transactions for next steps * 3. Retrieve 20 (size of the page) messages and transactions (3rd layer) and 20*5=100 message ids (4th layer). * 4. Retrieve the last 5 messages and 5 transactions on the 3rd layer + 15 messages and transactions (of 100) from the 4th layer * + 25 message ids of the 4th layer + 75 message ids of the 5th layer. * 5. Retrieve 20 more messages and 20 more transactions of the 4th layer + 100 more message ids of the 5th layer. * 6. Now we have 1+5+20+20+20 = 66 transactions, which is more than 50. Function exits with the tree of * 1m->1t->5m->5t->25m->25t->35m->35t. If we see any message ids in the last transactions out_msgs, which don't have * corresponding messages in the function result, it means that the full tree was not received and we need to continue iteration. * * To summarize, it is guaranteed that each message in `result.messages` has the corresponding transaction * in the `result.transactions`. * But there is no guarantee that all messages from transactions `out_msgs` are * presented in `result.messages`. * So the application has to continue retrieval for missing messages if it requires. * * @param {ParamsOfQueryTransactionTree} params * @returns ResultOfQueryTransactionTree */ query_transaction_tree(params: ParamsOfQueryTransactionTree): Promise; /** * Creates block iterator. * * @remarks * Block iterator uses robust iteration methods that guaranties that every * block in the specified range isn't missed or iterated twice. * * Iterated range can be reduced with some filters: * - `start_time` – the bottom time range. Only blocks with `gen_utime` * more or equal to this value is iterated. If this parameter is omitted then there is * no bottom time edge, so all blocks since zero state is iterated. * - `end_time` – the upper time range. Only blocks with `gen_utime` * less then this value is iterated. If this parameter is omitted then there is * no upper time edge, so iterator never finishes. * - `shard_filter` – workchains and shard prefixes that reduce the set of interesting * blocks. Block conforms to the shard filter if it belongs to the filter workchain * and the first bits of block's `shard` fields matches to the shard prefix. * Only blocks with suitable shard are iterated. * * Items iterated is a JSON objects with block data. The minimal set of returned * fields is: * ```text * id * gen_utime * workchain_id * shard * after_split * after_merge * prev_ref { * root_hash * } * prev_alt_ref { * root_hash * } * ``` * Application can request additional fields in the `result` parameter. * * Application should call the `remove_iterator` when iterator is no longer required. * * @param {ParamsOfCreateBlockIterator} params * @returns RegisteredIterator */ create_block_iterator(params: ParamsOfCreateBlockIterator): Promise; /** * Resumes block iterator. * * @remarks * The iterator stays exactly at the same position where the `resume_state` was catched. * * Application should call the `remove_iterator` when iterator is no longer required. * * @param {ParamsOfResumeBlockIterator} params * @returns RegisteredIterator */ resume_block_iterator(params: ParamsOfResumeBlockIterator): Promise; /** * Creates transaction iterator. * * @remarks * Transaction iterator uses robust iteration methods that guaranty that every * transaction in the specified range isn't missed or iterated twice. * * Iterated range can be reduced with some filters: * - `start_time` – the bottom time range. Only transactions with `now` * more or equal to this value are iterated. If this parameter is omitted then there is * no bottom time edge, so all the transactions since zero state are iterated. * - `end_time` – the upper time range. Only transactions with `now` * less then this value are iterated. If this parameter is omitted then there is * no upper time edge, so iterator never finishes. * - `shard_filter` – workchains and shard prefixes that reduce the set of interesting * accounts. Account address conforms to the shard filter if * it belongs to the filter workchain and the first bits of address match to * the shard prefix. Only transactions with suitable account addresses are iterated. * - `accounts_filter` – set of account addresses whose transactions must be iterated. * Note that accounts filter can conflict with shard filter so application must combine * these filters carefully. * * Iterated item is a JSON objects with transaction data. The minimal set of returned * fields is: * ```text * id * account_addr * now * balance_delta(format:DEC) * bounce { bounce_type } * in_message { * id * value(format:DEC) * msg_type * src * } * out_messages { * id * value(format:DEC) * msg_type * dst * } * ``` * Application can request an additional fields in the `result` parameter. * * Another parameter that affects on the returned fields is the `include_transfers`. * When this parameter is `true` the iterator computes and adds `transfer` field containing * list of the useful `TransactionTransfer` objects. * Each transfer is calculated from the particular message related to the transaction * and has the following structure: * - message – source message identifier. * - isBounced – indicates that the transaction is bounced, which means the value will be returned back to the sender. * - isDeposit – indicates that this transfer is the deposit (true) or withdraw (false). * - counterparty – account address of the transfer source or destination depending on `isDeposit`. * - value – amount of nano tokens transferred. The value is represented as a decimal string * because the actual value can be more precise than the JSON number can represent. Application * must use this string carefully – conversion to number can follow to loose of precision. * * Application should call the `remove_iterator` when iterator is no longer required. * * @param {ParamsOfCreateTransactionIterator} params * @returns RegisteredIterator */ create_transaction_iterator(params: ParamsOfCreateTransactionIterator): Promise; /** * Resumes transaction iterator. * * @remarks * The iterator stays exactly at the same position where the `resume_state` was caught. * Note that `resume_state` doesn't store the account filter. If the application requires * to use the same account filter as it was when the iterator was created then the application * must pass the account filter again in `accounts_filter` parameter. * * Application should call the `remove_iterator` when iterator is no longer required. * * @param {ParamsOfResumeTransactionIterator} params * @returns RegisteredIterator */ resume_transaction_iterator(params: ParamsOfResumeTransactionIterator): Promise; /** * Returns next available items. * * @remarks * In addition to available items this function returns the `has_more` flag * indicating that the iterator isn't reach the end of the iterated range yet. * * This function can return the empty list of available items but * indicates that there are more items is available. * This situation appears when the iterator doesn't reach iterated range * but database doesn't contains available items yet. * * If application requests resume state in `return_resume_state` parameter * then this function returns `resume_state` that can be used later to * resume the iteration from the position after returned items. * * The structure of the items returned depends on the iterator used. * See the description to the appropriated iterator creation function. * * @param {ParamsOfIteratorNext} params * @returns ResultOfIteratorNext */ iterator_next(params: ParamsOfIteratorNext): Promise; /** * Removes an iterator * * @remarks * Frees all resources allocated in library to serve iterator. * * Application always should call the `remove_iterator` when iterator * is no longer required. * * @param {RegisteredIterator} params * @returns */ remove_iterator(params: RegisteredIterator): Promise; } export declare enum DebotErrorCode { DebotStartFailed = 801, DebotFetchFailed = 802, DebotExecutionFailed = 803, DebotInvalidHandle = 804, DebotInvalidJsonParams = 805, DebotInvalidFunctionId = 806, DebotInvalidAbi = 807, DebotGetMethodFailed = 808, DebotInvalidMsg = 809, DebotExternalCallFailed = 810, DebotBrowserCallbackFailed = 811, DebotOperationRejected = 812, DebotNoCode = 813 } export declare type DebotHandle = number; export declare type DebotAction = { /** * A short action description. * * @remarks * Should be used by Debot Browser as name of menu item. */ description: string; /** * Depends on action type. * * @remarks * Can be a debot function name or a print string (for Print Action). */ name: string; /** * Action type. */ action_type: number; /** * ID of debot context to switch after action execution. */ to: number; /** * Action attributes. * * @remarks * In the form of "param=value,flag". attribute example: instant, args, fargs, sign. */ attributes: string; /** * Some internal action data. * * @remarks * Used by debot only. */ misc: string; }; export declare type DebotInfo = { /** * DeBot short name. */ name?: string; /** * DeBot semantic version. */ version?: string; /** * The name of DeBot deployer. */ publisher?: string; /** * Short info about DeBot. */ caption?: string; /** * The name of DeBot developer. */ author?: string; /** * TON address of author for questions and donations. */ support?: string; /** * String with the first messsage from DeBot. */ hello?: string; /** * String with DeBot interface language (ISO-639). */ language?: string; /** * String with DeBot ABI. */ dabi?: string; /** * DeBot icon. */ icon?: string; /** * Vector with IDs of DInterfaces used by DeBot. */ interfaces: string[]; /** * ABI version ("x.y") supported by DeBot */ dabiVersion: string; }; export declare type DebotActivity = { type: 'Transaction'; /** * External inbound message BOC. */ msg: string; /** * Target smart contract address. */ dst: string; /** * List of spendings as a result of transaction. */ out: Spending[]; /** * Transaction total fee. */ fee: bigint; /** * Indicates if target smart contract updates its code. */ setcode: boolean; /** * Public key from keypair that was used to sign external message. */ signkey: string; /** * Signing box handle used to sign external message. */ signing_box_handle: number; }; export declare function debotActivityTransaction(msg: string, dst: string, out: Spending[], fee: bigint, setcode: boolean, signkey: string, signing_box_handle: number): DebotActivity; export declare type Spending = { /** * Amount of nanotokens that will be sent to `dst` address. */ amount: bigint; /** * Destination address of recipient of funds. */ dst: string; }; export declare type ParamsOfInit = { /** * Debot smart contract address */ address: string; }; export declare type RegisteredDebot = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; /** * Debot abi as json string. */ debot_abi: string; /** * Debot metadata. */ info: DebotInfo; }; export declare type ParamsOfAppDebotBrowser = { type: 'Log'; /** * A string that must be printed to user. */ msg: string; } | { type: 'Switch'; /** * Debot context ID to which debot is switched. */ context_id: number; } | { type: 'SwitchCompleted'; } | { type: 'ShowAction'; /** * Debot action that must be shown to user as menu item. At least `description` property must be shown from [DebotAction] structure. */ action: DebotAction; } | { type: 'Input'; /** * A prompt string that must be printed to user before input request. */ prompt: string; } | { type: 'GetSigningBox'; } | { type: 'InvokeDebot'; /** * Address of debot in blockchain. */ debot_addr: string; /** * Debot action to execute. */ action: DebotAction; } | { type: 'Send'; /** * Internal message to DInterface address. * * @remarks * Message body contains interface function and parameters. */ message: string; } | { type: 'Approve'; /** * DeBot activity details. */ activity: DebotActivity; }; export declare function paramsOfAppDebotBrowserLog(msg: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSwitch(context_id: number): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSwitchCompleted(): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserShowAction(action: DebotAction): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserInput(prompt: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserGetSigningBox(): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserInvokeDebot(debot_addr: string, action: DebotAction): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSend(message: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserApprove(activity: DebotActivity): ParamsOfAppDebotBrowser; export declare type ResultOfAppDebotBrowser = { type: 'Input'; /** * String entered by user. */ value: string; } | { type: 'GetSigningBox'; /** * Signing box for signing data requested by debot engine. * * @remarks * Signing box is owned and disposed by debot engine */ signing_box: SigningBoxHandle; } | { type: 'InvokeDebot'; } | { type: 'Approve'; /** * Indicates whether the DeBot is allowed to perform the specified operation. */ approved: boolean; }; export declare function resultOfAppDebotBrowserInput(value: string): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserGetSigningBox(signing_box: SigningBoxHandle): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserInvokeDebot(): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserApprove(approved: boolean): ResultOfAppDebotBrowser; export declare type ParamsOfStart = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; }; export declare type ParamsOfFetch = { /** * Debot smart contract address. */ address: string; }; export declare type ResultOfFetch = { /** * Debot metadata. */ info: DebotInfo; }; export declare type ParamsOfExecute = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; /** * Debot Action that must be executed. */ action: DebotAction; }; export declare type ParamsOfSend = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; /** * BOC of internal message to debot encoded in base64 format. */ message: string; }; export declare type ParamsOfRemove = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; }; declare type ParamsOfAppDebotBrowserLog = { msg: string; }; declare type ParamsOfAppDebotBrowserSwitch = { context_id: number; }; declare type ParamsOfAppDebotBrowserShowAction = { action: DebotAction; }; declare type ParamsOfAppDebotBrowserInput = { prompt: string; }; declare type ResultOfAppDebotBrowserInput = { value: string; }; declare type ResultOfAppDebotBrowserGetSigningBox = { signing_box: SigningBoxHandle; }; declare type ParamsOfAppDebotBrowserInvokeDebot = { debot_addr: string; action: DebotAction; }; declare type ParamsOfAppDebotBrowserSend = { message: string; }; declare type ParamsOfAppDebotBrowserApprove = { activity: DebotActivity; }; declare type ResultOfAppDebotBrowserApprove = { approved: boolean; }; export interface AppDebotBrowser { log(params: ParamsOfAppDebotBrowserLog): void; switch(params: ParamsOfAppDebotBrowserSwitch): void; switch_completed(): void; show_action(params: ParamsOfAppDebotBrowserShowAction): void; input(params: ParamsOfAppDebotBrowserInput): Promise; get_signing_box(): Promise; invoke_debot(params: ParamsOfAppDebotBrowserInvokeDebot): Promise; send(params: ParamsOfAppDebotBrowserSend): void; approve(params: ParamsOfAppDebotBrowserApprove): Promise; } /** * [UNSTABLE](UNSTABLE.md) Module for working with debot. */ export declare class DebotModule { client: IClient; constructor(client: IClient); /** * [UNSTABLE](UNSTABLE.md) Creates and instance of DeBot. * * @remarks * Downloads debot smart contract (code and data) from blockchain and creates * an instance of Debot Engine for it. * * # Remarks * It does not switch debot to context 0. Browser Callbacks are not called. * * @param {ParamsOfInit} params * @returns RegisteredDebot */ init(params: ParamsOfInit, obj: AppDebotBrowser): Promise; /** * [UNSTABLE](UNSTABLE.md) Starts the DeBot. * * @remarks * Downloads debot smart contract from blockchain and switches it to * context zero. * * This function must be used by Debot Browser to start a dialog with debot. * While the function is executing, several Browser Callbacks can be called, * since the debot tries to display all actions from the context 0 to the user. * * When the debot starts SDK registers `BrowserCallbacks` AppObject. * Therefore when `debote.remove` is called the debot is being deleted and the callback is called * with `finish`=`true` which indicates that it will never be used again. * * @param {ParamsOfStart} params * @returns */ start(params: ParamsOfStart): Promise; /** * [UNSTABLE](UNSTABLE.md) Fetches DeBot metadata from blockchain. * * @remarks * Downloads DeBot from blockchain and creates and fetches its metadata. * * @param {ParamsOfFetch} params * @returns ResultOfFetch */ fetch(params: ParamsOfFetch): Promise; /** * [UNSTABLE](UNSTABLE.md) Executes debot action. * * @remarks * Calls debot engine referenced by debot handle to execute input action. * Calls Debot Browser Callbacks if needed. * * # Remarks * Chain of actions can be executed if input action generates a list of subactions. * * @param {ParamsOfExecute} params * @returns */ execute(params: ParamsOfExecute): Promise; /** * [UNSTABLE](UNSTABLE.md) Sends message to Debot. * * @remarks * Used by Debot Browser to send response on Dinterface call or from other Debots. * * @param {ParamsOfSend} params * @returns */ send(params: ParamsOfSend): Promise; /** * [UNSTABLE](UNSTABLE.md) Destroys debot handle. * * @remarks * Removes handle from Client Context and drops debot engine referenced by that handle. * * @param {ParamsOfRemove} params * @returns */ remove(params: ParamsOfRemove): Promise; } export declare enum ProofsErrorCode { InvalidData = 901, ProofCheckFailed = 902, InternalError = 903, DataDiffersFromProven = 904 } export declare type ParamsOfProofBlockData = { /** * Single block's data, retrieved from TONOS API, that needs proof. Required fields are `id` and/or top-level `boc` (for block identification), others are optional. */ block: any; }; export declare type ParamsOfProofTransactionData = { /** * Single transaction's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide `block_id` and `boc` of transaction. */ transaction: any; }; export declare type ParamsOfProofMessageData = { /** * Single message's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide at least `boc` of message and non-null `src_transaction.id` or `dst_transaction.id`. */ message: any; }; /** * [UNSTABLE](UNSTABLE.md) Module for proving data, retrieved from TONOS API. */ export declare class ProofsModule { client: IClient; constructor(client: IClient); /** * Proves that a given block's data, which is queried from TONOS API, can be trusted. * * @remarks * This function checks block proofs and compares given data with the proven. * If the given data differs from the proven, the exception will be thrown. * The input param is a single block's JSON object, which was queried from DApp server using * functions such as `net.query`, `net.query_collection` or `net.wait_for_collection`. * If block's BOC is not provided in the JSON, it will be queried from DApp server * (in this case it is required to provide at least `id` of block). * * Please note, that joins (like `signatures` in `Block`) are separated entities and not supported, * so function will throw an exception in a case if JSON being checked has such entities in it. * * If `cache_in_local_storage` in config is set to `true` (default), downloaded proofs and * master-chain BOCs are saved into the persistent local storage (e.g. file system for native * environments or browser's IndexedDB for the web); otherwise all the data is cached only in * memory in current client's context and will be lost after destruction of the client. * * **Why Proofs are needed** * * Proofs are needed to ensure that the data downloaded from a DApp server is real blockchain * data. Checking proofs can protect from the malicious DApp server which can potentially provide * fake data, or also from "Man in the Middle" attacks class. * * **What Proofs are** * * Simply, proof is a list of signatures of validators', which have signed this particular master- * block. * * The very first validator set's public keys are included in the zero-state. Whe know a root hash * of the zero-state, because it is stored in the network configuration file, it is our authority * root. For proving zero-state it is enough to calculate and compare its root hash. * * In each new validator cycle the validator set is changed. The new one is stored in a key-block, * which is signed by the validator set, which we already trust, the next validator set will be * stored to the new key-block and signed by the current validator set, and so on. * * In order to prove any block in the master-chain we need to check, that it has been signed by * a trusted validator set. So we need to check all key-blocks' proofs, started from the zero-state * and until the block, which we want to prove. But it can take a lot of time and traffic to * download and prove all key-blocks on a client. For solving this, special trusted blocks are used * in TON-SDK. * * The trusted block is the authority root, as well, as the zero-state. Each trusted block is the * `id` (e.g. `root_hash`) of the already proven key-block. There can be plenty of trusted * blocks, so there can be a lot of authority roots. The hashes of trusted blocks for MainNet * and DevNet are hardcoded in SDK in a separated binary file (trusted_key_blocks.bin) and can * be updated for each release. * In future SDK releases, one will also be able to provide their hashes of trusted blocks for * other networks, besides for MainNet and DevNet. * By using trusted key-blocks, in order to prove any block, we can prove chain of key-blocks to * the closest previous trusted key-block, not only to the zero-state. * * But shard-blocks don't have proofs on DApp server. In this case, in order to prove any shard- * block data, we search for a corresponding master-block, which contains the root hash of this * shard-block, or some shard block which is linked to that block in shard-chain. After proving * this master-block, we traverse through each link and calculate and compare hashes with links, * one-by-one. After that we can ensure that this shard-block has also been proven. * * @param {ParamsOfProofBlockData} params * @returns */ proof_block_data(params: ParamsOfProofBlockData): Promise; /** * Proves that a given transaction's data, which is queried from TONOS API, can be trusted. * * @remarks * This function requests the corresponding block, checks block proofs, ensures that given * transaction exists in the proven block and compares given data with the proven. * If the given data differs from the proven, the exception will be thrown. * The input parameter is a single transaction's JSON object (see params description), * which was queried from TONOS API using functions such as `net.query`, `net.query_collection` * or `net.wait_for_collection`. * * If transaction's BOC and/or `block_id` are not provided in the JSON, they will be queried from * TONOS API. * * Please note, that joins (like `account`, `in_message`, `out_messages`, etc. in `Transaction` * entity) are separated entities and not supported, so function will throw an exception in a case * if JSON being checked has such entities in it. * * For more information about proofs checking, see description of `proof_block_data` function. * * @param {ParamsOfProofTransactionData} params * @returns */ proof_transaction_data(params: ParamsOfProofTransactionData): Promise; /** * Proves that a given message's data, which is queried from TONOS API, can be trusted. * * @remarks * This function first proves the corresponding transaction, ensures that the proven transaction * refers to the given message and compares given data with the proven. * If the given data differs from the proven, the exception will be thrown. * The input parameter is a single message's JSON object (see params description), * which was queried from TONOS API using functions such as `net.query`, `net.query_collection` * or `net.wait_for_collection`. * * If message's BOC and/or non-null `src_transaction.id` or `dst_transaction.id` are not provided * in the JSON, they will be queried from TONOS API. * * Please note, that joins (like `block`, `dst_account`, `dst_transaction`, `src_account`, * `src_transaction`, etc. in `Message` entity) are separated entities and not supported, * so function will throw an exception in a case if JSON being checked has such entities in it. * * For more information about proofs checking, see description of `proof_block_data` function. * * @param {ParamsOfProofMessageData} params * @returns */ proof_message_data(params: ParamsOfProofMessageData): Promise; } export {}; //# sourceMappingURL=modules.d.ts.map