Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slice type definition file #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions dist/types/boc/slice.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import BN from 'bn.js';
import { Address } from "../utils/address";

/**
* A partial view of a TVM cell, used for parsing data from Cells.
*/
declare class Slice {
array: Uint8Array;
length: number;
readCursor: number;
refs: Slice[];
refCursor: number;

/**
* @param array {Uint8Array}
* @param length {number} length in bits
* @param refs {Slice[]} child cells
*/
constructor(array: Uint8Array, length: number, refs: Slice[]);

/**
* @return {number}
*/
getFreeBits(): number;

/**
* @private
* @param n {number}
*/
private checkRange(n: number): void;

/**
* @private
* @param n {number}
* @return {boolean} bit value at position `n`
*/
private get(n: number): boolean;

/**
* @return {boolean} read bit
*/
loadBit(): boolean;

/**
* @param bitLength {number}
* @return {Uint8Array}
*/
loadBits(bitLength: number): Uint8Array;

/**
* Reads unsigned int
*
* @param {number} bitLength Size of uint in bits
* @returns {BN} number
*/
loadUint(bitLength: number): BN;

/**
* Reads signed int
*
* @param {number} bitLength Size of uint in bits
* @returns {BN} number
*/
loadInt(bitLength: number): BN;

/**
* @param bitLength {number}
* @return {BN}
*/
loadVarUint(bitLength: number): BN;

/**
* @return {BN}
*/
loadCoins(): BN;

/**
* @return {Address | null}
*/
loadAddress(): Address | null;

/**
* @return {Slice}
*/
loadRef(): Slice;
}

export { Slice };
2 changes: 2 additions & 0 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { formatTransferUrl, parseTransferUrl } from './utils/transfer-url';
export { ParsedTransferUrl } from './utils/transfer-url';
import { BitString } from './boc/bit-string';
import { Cell } from './boc/cell';
import { Slice } from './boc/slice';
import { Contract } from './contract/contract';
export { ContractMethods, ContractOptions, Method, Query, StateInit, } from './contract/contract';
import { Wallets } from './contract/wallet/wallets';
Expand Down Expand Up @@ -68,6 +69,7 @@ export default class TonWeb {
static boc: {
BitString: typeof BitString;
Cell: typeof Cell;
Slice: typeof Slice;
};
static HttpProvider: typeof HttpProvider;
static Contract: typeof Contract;
Expand Down