Skip to content

Commit

Permalink
chore: replace ton-core with @ton/core and rebuild tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thekiba committed Feb 11, 2024
1 parent 96d5848 commit 7e9495a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 124 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ generateCode('example.tlb', 'example.tlb.ts', "typescript")
```


## Integration with ton-core
## Integration with @ton/core

It is integrated with [ton-core](https://github.com/ton-org/ton-core/) in a way it uses several built-in types from there.
It is integrated with [@ton/core](https://github.com/ton-org/ton-core/) in a way it uses several built-in types from there.

Built-in types supported are:
- `Bool` -> `boolean` (loaded with `loadBoolean`, stored with `storeBit`)
Expand Down
126 changes: 32 additions & 94 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@ton/core": "^0.54.0",
"@ton-community/tlb-parser": "^0.1.2",
"@types/jest": "^29.5.11",
"crc-32": "^1.2.2",
"meow": "^9.0.0",
"ton": "^13.9.0",
"ts-jest": "^29.1.1"
}
}
2 changes: 1 addition & 1 deletion src/generators/typescript/complex_expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function bitlenFunctionDecl(): GenDeclaration {
tTypeParametersExpression([]),
null,
[tTypedIdentifier(id("n"), id("number"))],
[tExpressionStatement(id("return n.toString(2).length;"))]
[tExpressionStatement(id("return n.toString(2).length"))]
);
}
export function typedSlice() {
Expand Down
2 changes: 1 addition & 1 deletion src/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class TypescriptGenerator implements CodeGenerator {

addTonCoreClassUsage(name: string) {
this.jsCodeDeclarations.push(
tImportDeclaration(id(name), tStringLiteral("ton-core"))
tImportDeclaration(id(name), tStringLiteral("@ton/core"))
);
}
addBitLenFunction() {
Expand Down
20 changes: 10 additions & 10 deletions test/generated_files/generated_block.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Builder } from 'ton-core'
import { Slice } from 'ton-core'
import { beginCell } from 'ton-core'
import { BitString } from 'ton-core'
import { Cell } from 'ton-core'
import { Address } from 'ton-core'
import { ExternalAddress } from 'ton-core'
import { Dictionary } from 'ton-core'
import { DictionaryValue } from 'ton-core'
import { Builder } from '@ton/core'
import { Slice } from '@ton/core'
import { beginCell } from '@ton/core'
import { BitString } from '@ton/core'
import { Cell } from '@ton/core'
import { Address } from '@ton/core'
import { ExternalAddress } from '@ton/core'
import { Dictionary } from '@ton/core'
import { DictionaryValue } from '@ton/core'
export function bitLen(n: number) {
return n.toString(2).length;;
return n.toString(2).length;
}

// unit$_ = Unit;
Expand Down
20 changes: 10 additions & 10 deletions test/generated_files/generated_test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Builder } from 'ton-core'
import { Slice } from 'ton-core'
import { beginCell } from 'ton-core'
import { BitString } from 'ton-core'
import { Cell } from 'ton-core'
import { Address } from 'ton-core'
import { ExternalAddress } from 'ton-core'
import { Dictionary } from 'ton-core'
import { DictionaryValue } from 'ton-core'
import { Builder } from '@ton/core'
import { Slice } from '@ton/core'
import { beginCell } from '@ton/core'
import { BitString } from '@ton/core'
import { Cell } from '@ton/core'
import { Address } from '@ton/core'
import { ExternalAddress } from '@ton/core'
import { Dictionary } from '@ton/core'
import { DictionaryValue } from '@ton/core'
export function bitLen(n: number) {
return n.toString(2).length;;
return n.toString(2).length;
}

// tmpa$_ a:# b:# = Simple;
Expand Down
6 changes: 1 addition & 5 deletions test/tlbgen.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import path from 'path';

import { Address, BitString, Cell, Dictionary, DictionaryKeyTypes, ExternalAddress, Slice } from 'ton';

import { Address, BitString, Cell, Dictionary, ExternalAddress, Slice, beginCell } from '@ton/core';
import { describe, expect, test } from '@jest/globals';
import { beginCell } from 'ton';
import { loadBlock, storeBlock } from './generated_files/generated_block';
import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, FixedIntParam, GramsUser, HashmapAugEUser, HashmapEUser, HashmapExprKeyUser, HashmapOneCombUser, HashmapTPCell, HashmapVUIUser, HashmapVarKeyUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, OneComb, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, VarIntegerUser, VarUIntegerUser, loadAddressUser, loadAnonymousData, loadAnyAddressUser, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBitUser, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadExtAddressUser, loadFalseAnonField, loadGramsUser, loadHashmapAugEUser, loadHashmapEUser, loadHashmapExprKeyUser, loadHashmapOneCombUser, loadHashmapTPCell, loadHashmapVUIUser, loadHashmapVarKeyUser, loadImplicitCondition, loadIntBitsOutside, loadIntBitsParametrizedOutside, loadLessThan, loadLoadFromNegationOutsideExpr, loadManyComb, loadMathExprAsCombArg, loadMultipleEmptyConstructor, loadNegationFromImplicit, loadParamConst, loadParamDifNames, loadParamDifNamesUser, loadParamNamedArgInSecondConstr, loadRefCombinatorAny, loadRefCombinatorInRef, loadSharpConstructor, loadSharpTag, loadSimple, loadTrue, loadTupleCheck, loadTwoConstructors, loadTypedField, loadTypedParam, loadUnary, loadUnaryUserCheckOrder, loadVarIntegerUser, loadVarUIntegerUser, storeAddressUser, storeAnonymousData, storeAnyAddressUser, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBitUser, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeExtAddressUser, storeFalseAnonField, storeGramsUser, storeHashmapAugEUser, storeHashmapEUser, storeHashmapExprKeyUser, storeHashmapOneCombUser, storeHashmapTPCell, storeHashmapVUIUser, storeHashmapVarKeyUser, storeImplicitCondition, storeIntBitsOutside, storeIntBitsParametrizedOutside, storeLessThan, storeLoadFromNegationOutsideExpr, storeManyComb, storeMathExprAsCombArg, storeMultipleEmptyConstructor, storeNegationFromImplicit, storeParamConst, storeParamDifNames, storeParamDifNamesUser, storeParamNamedArgInSecondConstr, storeRefCombinatorAny, storeRefCombinatorInRef, storeSharpConstructor, storeSharpTag, storeSimple, storeTrue, storeTupleCheck, storeTwoConstructors, storeTypedField, storeTypedParam, storeUnary, storeUnaryUserCheckOrder, storeVarIntegerUser, storeVarUIntegerUser } from './generated_files/generated_test';

Expand Down

0 comments on commit 7e9495a

Please sign in to comment.