Skip to content

Commit

Permalink
Add list support
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rich committed Jun 23, 2024
1 parent db72c8c commit 9e0c8e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/parser/parseTvmValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import type { TvmValue } from './types'
export function parseTvmValue(x: TvmValue): TupleItem {
const typeName = x['@type']
switch (typeName) {
// TODO: Check how list parsing works
case 'tvm.list':
return { type: 'tuple', items: x.elements.map(parseTvmValue) }
case 'tvm.stackEntryList':
return parseTvmValue(x.list)
case 'tvm.tuple':
return { type: 'tuple', items: x.elements.map(parseTvmValue) }
case 'tvm.stackEntryTuple':
return parseTvmValue(x.tuple)
case 'tvm.cell':
return { type: 'cell', cell: Cell.fromBoc(Buffer.from(x.bytes, 'base64'))[0] }
case 'tvm.stackEntryCell':
return parseTvmValue(x.cell)
case 'tvm.stackEntryTuple':
return parseTvmValue(x.tuple)
case 'tvm.stackEntryNumber':
return parseTvmValue(x.number)
case 'tvm.numberDecimal':
return { type: 'int', value: BigInt(x.number) }
case 'tvm.stackEntryNumber':
return parseTvmValue(x.number)
case 'tvm.slice':
return { type: 'slice', cell: Cell.fromBoc(Buffer.from(x.bytes, 'base64'))[0] }
case 'tvm.stackEntrySlice':
Expand Down
1 change: 0 additions & 1 deletion src/parser/types/tvmValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type TvmCell = { '@type': 'tvm.cell', bytes: string };
type TvmStackEntryCell = { '@type': 'tvm.stackEntryCell', cell: TvmCell };

// Structured types for TON Virtual Machine values
// TODO: Check how list parsing works
export type TvmList = { '@type': 'tvm.list', elements: TvmValue[] };
type TvmStackEntryList = { '@type': 'tvm.stackEntryList', list: TvmList };

Expand Down

0 comments on commit 9e0c8e4

Please sign in to comment.