Skip to content

Latest commit

 

History

History
548 lines (372 loc) · 9.13 KB

mod_boc.md

File metadata and controls

548 lines (372 loc) · 9.13 KB

Module boc

BOC manipulation module.

Functions

parse_message – Parses message boc into a JSON

parse_transaction – Parses transaction boc into a JSON

parse_account – Parses account boc into a JSON

parse_block – Parses block boc into a JSON

parse_shardstate – Parses shardstate boc into a JSON

get_blockchain_config

get_boc_hash – Calculates BOC root hash

get_code_from_tvc – Extracts code from TVC contract image

cache_get – Get BOC from cache

cache_set – Save BOC into cache

cache_unpin – Unpin BOCs with specified pin.

Types

BocCacheType

BocErrorCode

ParamsOfParse

ResultOfParse

ParamsOfParseShardstate

ParamsOfGetBlockchainConfig

ResultOfGetBlockchainConfig

ParamsOfGetBocHash

ResultOfGetBocHash

ParamsOfGetCodeFromTvc

ResultOfGetCodeFromTvc

ParamsOfBocCacheGet

ResultOfBocCacheGet

ParamsOfBocCacheSet

ResultOfBocCacheSet

ParamsOfBocCacheUnpin

Functions

parse_message

Parses message boc into a JSON

JSON structure is compatible with GraphQL API message object

type ParamsOfParse = {
    boc: string
}

type ResultOfParse = {
    parsed: any
}

function parse_message(
    params: ParamsOfParse,
): Promise<ResultOfParse>;

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_transaction

Parses transaction boc into a JSON

JSON structure is compatible with GraphQL API transaction object

type ParamsOfParse = {
    boc: string
}

type ResultOfParse = {
    parsed: any
}

function parse_transaction(
    params: ParamsOfParse,
): Promise<ResultOfParse>;

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_account

Parses account boc into a JSON

JSON structure is compatible with GraphQL API account object

type ParamsOfParse = {
    boc: string
}

type ResultOfParse = {
    parsed: any
}

function parse_account(
    params: ParamsOfParse,
): Promise<ResultOfParse>;

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_block

Parses block boc into a JSON

JSON structure is compatible with GraphQL API block object

type ParamsOfParse = {
    boc: string
}

type ResultOfParse = {
    parsed: any
}

function parse_block(
    params: ParamsOfParse,
): Promise<ResultOfParse>;

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_shardstate

Parses shardstate boc into a JSON

JSON structure is compatible with GraphQL API shardstate object

type ParamsOfParseShardstate = {
    boc: string,
    id: string,
    workchain_id: number
}

type ResultOfParse = {
    parsed: any
}

function parse_shardstate(
    params: ParamsOfParseShardstate,
): Promise<ResultOfParse>;

Parameters

  • boc: string – BOC encoded as base64
  • id: string – Shardstate identificator
  • workchain_id: number – Workchain shardstate belongs to

Result

  • parsed: any – JSON containing parsed BOC

get_blockchain_config

type ParamsOfGetBlockchainConfig = {
    block_boc: string
}

type ResultOfGetBlockchainConfig = {
    config_boc: string
}

function get_blockchain_config(
    params: ParamsOfGetBlockchainConfig,
): Promise<ResultOfGetBlockchainConfig>;

Parameters

  • block_boc: string – Key block BOC encoded as base64

Result

  • config_boc: string – Blockchain config BOC encoded as base64

get_boc_hash

Calculates BOC root hash

type ParamsOfGetBocHash = {
    boc: string
}

type ResultOfGetBocHash = {
    hash: string
}

function get_boc_hash(
    params: ParamsOfGetBocHash,
): Promise<ResultOfGetBocHash>;

Parameters

  • boc: string – BOC encoded as base64

Result

  • hash: string – BOC root hash encoded with hex

get_code_from_tvc

Extracts code from TVC contract image

type ParamsOfGetCodeFromTvc = {
    tvc: string
}

type ResultOfGetCodeFromTvc = {
    code: string
}

function get_code_from_tvc(
    params: ParamsOfGetCodeFromTvc,
): Promise<ResultOfGetCodeFromTvc>;

Parameters

  • tvc: string – Contract TVC image encoded as base64

Result

  • code: string – Contract code encoded as base64

cache_get

Get BOC from cache

type ParamsOfBocCacheGet = {
    boc_ref: string
}

type ResultOfBocCacheGet = {
    boc?: string
}

function cache_get(
    params: ParamsOfBocCacheGet,
): Promise<ResultOfBocCacheGet>;

Parameters

  • boc_ref: string – Reference to the cached BOC

Result

  • boc?: string – BOC encoded as base64.

cache_set

Save BOC into cache

type ParamsOfBocCacheSet = {
    boc: string,
    cache_type: BocCacheType
}

type ResultOfBocCacheSet = {
    boc_ref: string
}

function cache_set(
    params: ParamsOfBocCacheSet,
): Promise<ResultOfBocCacheSet>;

Parameters

  • boc: string – BOC encoded as base64 or BOC reference
  • cache_type: BocCacheType – Cache type

Result

  • boc_ref: string – Reference to the cached BOC

cache_unpin

Unpin BOCs with specified pin.

BOCs which don't have another pins will be removed from cache

type ParamsOfBocCacheUnpin = {
    pin: string,
    boc_ref?: string
}

function cache_unpin(
    params: ParamsOfBocCacheUnpin,
): Promise<void>;

Parameters

  • pin: string – Pinned name
  • boc_ref?: string – Reference to the cached BOC.
    If it is provided then only referenced BOC is unpinned

Result

Types

BocCacheType

type BocCacheType = {
    type: 'Pinned'
    pin: string
} | {
    type: 'Unpinned'
}

Depends on value of the type field.

When type is 'Pinned'

Pin the BOC with pin name.

Such BOC will not be removed from cache until it is unpinned

  • pin: string

When type is 'Unpinned'

BocErrorCode

enum BocErrorCode {
    InvalidBoc = 201,
    SerializationError = 202,
    InappropriateBlock = 203,
    MissingSourceBoc = 204,
    InsufficientCacheSize = 205,
    BocRefNotFound = 206,
    InvalidBocRef = 207
}

One of the following value:

  • InvalidBoc = 201
  • SerializationError = 202
  • InappropriateBlock = 203
  • MissingSourceBoc = 204
  • InsufficientCacheSize = 205
  • BocRefNotFound = 206
  • InvalidBocRef = 207

ParamsOfParse

type ParamsOfParse = {
    boc: string
}
  • boc: string – BOC encoded as base64

ResultOfParse

type ResultOfParse = {
    parsed: any
}
  • parsed: any – JSON containing parsed BOC

ParamsOfParseShardstate

type ParamsOfParseShardstate = {
    boc: string,
    id: string,
    workchain_id: number
}
  • boc: string – BOC encoded as base64
  • id: string – Shardstate identificator
  • workchain_id: number – Workchain shardstate belongs to

ParamsOfGetBlockchainConfig

type ParamsOfGetBlockchainConfig = {
    block_boc: string
}
  • block_boc: string – Key block BOC encoded as base64

ResultOfGetBlockchainConfig

type ResultOfGetBlockchainConfig = {
    config_boc: string
}
  • config_boc: string – Blockchain config BOC encoded as base64

ParamsOfGetBocHash

type ParamsOfGetBocHash = {
    boc: string
}
  • boc: string – BOC encoded as base64

ResultOfGetBocHash

type ResultOfGetBocHash = {
    hash: string
}
  • hash: string – BOC root hash encoded with hex

ParamsOfGetCodeFromTvc

type ParamsOfGetCodeFromTvc = {
    tvc: string
}
  • tvc: string – Contract TVC image encoded as base64

ResultOfGetCodeFromTvc

type ResultOfGetCodeFromTvc = {
    code: string
}
  • code: string – Contract code encoded as base64

ParamsOfBocCacheGet

type ParamsOfBocCacheGet = {
    boc_ref: string
}
  • boc_ref: string – Reference to the cached BOC

ResultOfBocCacheGet

type ResultOfBocCacheGet = {
    boc?: string
}
  • boc?: string – BOC encoded as base64.

ParamsOfBocCacheSet

type ParamsOfBocCacheSet = {
    boc: string,
    cache_type: BocCacheType
}
  • boc: string – BOC encoded as base64 or BOC reference
  • cache_type: BocCacheType – Cache type

ResultOfBocCacheSet

type ResultOfBocCacheSet = {
    boc_ref: string
}
  • boc_ref: string – Reference to the cached BOC

ParamsOfBocCacheUnpin

type ParamsOfBocCacheUnpin = {
    pin: string,
    boc_ref?: string
}
  • pin: string – Pinned name
  • boc_ref?: string – Reference to the cached BOC.
    If it is provided then only referenced BOC is unpinned