From 7e9495a332bd3fb0912d702d64266b4cddf3b6c2 Mon Sep 17 00:00:00 2001
From: thekiba
Date: Mon, 12 Feb 2024 02:03:55 +0400
Subject: [PATCH] chore: replace ton-core with @ton/core and rebuild tests
---
README.md | 4 +-
package-lock.json | 126 ++++++----------------
package.json | 2 +-
src/generators/typescript/complex_expr.ts | 2 +-
src/generators/typescript/generator.ts | 2 +-
test/generated_files/generated_block.ts | 20 ++--
test/generated_files/generated_test.ts | 20 ++--
test/tlbgen.spec.ts | 6 +-
8 files changed, 58 insertions(+), 124 deletions(-)
diff --git a/README.md b/README.md
index 4ef2912..87665b2 100644
--- a/README.md
+++ b/README.md
@@ -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`)
diff --git a/package-lock.json b/package-lock.json
index f6073dd..8dbc013 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,10 +10,10 @@
"license": "ISC",
"dependencies": {
"@ton-community/tlb-parser": "^0.1.2",
+ "@ton/core": "^0.54.0",
"@types/jest": "^29.5.11",
"crc-32": "^1.2.2",
"meow": "^9.0.0",
- "ton": "^13.9.0",
"ts-jest": "^29.1.1"
},
"bin": {
@@ -1019,6 +1019,37 @@
"tlb-parser": "dist/cli.js"
}
},
+ "node_modules/@ton/core": {
+ "version": "0.54.0",
+ "resolved": "https://registry.npmjs.org/@ton/core/-/core-0.54.0.tgz",
+ "integrity": "sha512-ry3sCDq3jdjZuo7+egZ827/Y0/ajPbtrozvJryNMefUGfZQ/zYLVCmw9zBtxVsY2EX2zW7QhHQUs76/3y6HCwQ==",
+ "dependencies": {
+ "symbol.inspect": "1.0.1"
+ },
+ "peerDependencies": {
+ "@ton/crypto": ">=3.2.0"
+ }
+ },
+ "node_modules/@ton/crypto": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/@ton/crypto/-/crypto-3.2.0.tgz",
+ "integrity": "sha512-50RkwReEuV2FkxSZ8ht/x9+n0ZGtwRKGsJ0ay4I/HFhkYVG/awIIBQeH0W4j8d5lADdO5h01UtX8PJ8AjiejjA==",
+ "peer": true,
+ "dependencies": {
+ "@ton/crypto-primitives": "2.0.0",
+ "jssha": "3.2.0",
+ "tweetnacl": "1.0.3"
+ }
+ },
+ "node_modules/@ton/crypto-primitives": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@ton/crypto-primitives/-/crypto-primitives-2.0.0.tgz",
+ "integrity": "sha512-wttiNClmGbI6Dfy/8oyNnsIV0b/qYkCJz4Gn4eP62lJZzMtVQ94Ko7nikDX1EfYHkLI1xpOitWpW+8ZuG6XtDg==",
+ "peer": true,
+ "dependencies": {
+ "jssha": "3.2.0"
+ }
+ },
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
@@ -1245,14 +1276,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/axios": {
- "version": "0.25.0",
- "resolved": "https://registry.npmjs.org/axios/-/axios-0.25.0.tgz",
- "integrity": "sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==",
- "dependencies": {
- "follow-redirects": "^1.14.7"
- }
- },
"node_modules/babel-jest": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz",
@@ -1630,11 +1653,6 @@
"node": ">= 8"
}
},
- "node_modules/dataloader": {
- "version": "2.2.2",
- "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.2.tgz",
- "integrity": "sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g=="
- },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -1866,25 +1884,6 @@
"node": ">=8"
}
},
- "node_modules/follow-redirects": {
- "version": "1.15.3",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
- "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
- "funding": [
- {
- "type": "individual",
- "url": "https://github.com/sponsors/RubenVerborgh"
- }
- ],
- "engines": {
- "node": ">=4.0"
- },
- "peerDependenciesMeta": {
- "debug": {
- "optional": true
- }
- }
- },
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -3725,11 +3724,6 @@
"resolved": "https://registry.npmjs.org/symbol.inspect/-/symbol.inspect-1.0.1.tgz",
"integrity": "sha512-YQSL4duoHmLhsTD1Pw8RW6TZ5MaTX5rXJnqacJottr2P2LZBF/Yvrc3ku4NUpMOm8aM0KOCqM+UAkMA5HWQCzQ=="
},
- "node_modules/teslabot": {
- "version": "1.5.0",
- "resolved": "https://registry.npmjs.org/teslabot/-/teslabot-1.5.0.tgz",
- "integrity": "sha512-e2MmELhCgrgZEGo7PQu/6bmYG36IDH+YrBI1iGm6jovXkeDIGa3pZ2WSqRjzkuw2vt1EqfkZoV5GpXgqL8QJVg=="
- },
"node_modules/test-exclude": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
@@ -3767,54 +3761,6 @@
"node": ">=8.0"
}
},
- "node_modules/ton": {
- "version": "13.9.0",
- "resolved": "https://registry.npmjs.org/ton/-/ton-13.9.0.tgz",
- "integrity": "sha512-IjZa4vFsyYHzQFY3kMSK/vw8T9b4zSJlSkZOgD8qeP4AFVxcD6pZ7TxfATwLJnA/4MCbaM9DY0V076oMjluDQg==",
- "dependencies": {
- "axios": "^0.25.0",
- "dataloader": "^2.0.0",
- "symbol.inspect": "1.0.1",
- "teslabot": "^1.3.0",
- "zod": "^3.21.4"
- },
- "peerDependencies": {
- "ton-core": ">=0.53.0",
- "ton-crypto": ">=3.2.0"
- }
- },
- "node_modules/ton-core": {
- "version": "0.53.0",
- "resolved": "https://registry.npmjs.org/ton-core/-/ton-core-0.53.0.tgz",
- "integrity": "sha512-uO/U1oVLdEliWWbwfNQQK+61C+KM0ehcTdHQ6cN0WSEH2UzGfdVFpC4Wb0ph+wUYe/5njl7TA0uL9nif9Q6qwA==",
- "peer": true,
- "dependencies": {
- "symbol.inspect": "1.0.1"
- },
- "peerDependencies": {
- "ton-crypto": ">=3.2.0"
- }
- },
- "node_modules/ton-crypto": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/ton-crypto/-/ton-crypto-3.2.0.tgz",
- "integrity": "sha512-fltdBNQ45gARMuGMEOjPZWPJ5eSql8p3CA0Dj7tPv5lhU5ziT8SxXLAzDraR9HJ8YpjBHLVvYyhMLRiEwxgtMQ==",
- "peer": true,
- "dependencies": {
- "jssha": "3.2.0",
- "ton-crypto-primitives": "2.0.0",
- "tweetnacl": "1.0.3"
- }
- },
- "node_modules/ton-crypto-primitives": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ton-crypto-primitives/-/ton-crypto-primitives-2.0.0.tgz",
- "integrity": "sha512-K+qKjpS0h9sPW6oExcpxnzuQ7nEgHEiDKwIqE/jWD25o8iFGe3FWj1gKxFNbKE9wwYKc5IV8FwrU+raF0KO5nQ==",
- "peer": true,
- "dependencies": {
- "jssha": "3.2.0"
- }
- },
"node_modules/trim-newlines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz",
@@ -4158,14 +4104,6 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
- },
- "node_modules/zod": {
- "version": "3.22.4",
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
- "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
}
}
}
diff --git a/package.json b/package.json
index e9dcc01..b48bd8e 100644
--- a/package.json
+++ b/package.json
@@ -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"
}
}
diff --git a/src/generators/typescript/complex_expr.ts b/src/generators/typescript/complex_expr.ts
index fd2d5bb..353b21c 100644
--- a/src/generators/typescript/complex_expr.ts
+++ b/src/generators/typescript/complex_expr.ts
@@ -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() {
diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts
index 4c3d6dc..6b62f2f 100644
--- a/src/generators/typescript/generator.ts
+++ b/src/generators/typescript/generator.ts
@@ -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() {
diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts
index afcad74..485ea58 100644
--- a/test/generated_files/generated_block.ts
+++ b/test/generated_files/generated_block.ts
@@ -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;
diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts
index e188afd..13d899e 100644
--- a/test/generated_files/generated_test.ts
+++ b/test/generated_files/generated_test.ts
@@ -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;
diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts
index bc66014..83ba38b 100644
--- a/test/tlbgen.spec.ts
+++ b/test/tlbgen.spec.ts
@@ -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';