diff --git a/package-lock.json b/package-lock.json index 9c72f9b..696a0b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@minoru/react-dnd-treeview": "^3.4.1", "@monaco-editor/react": "^4.5.1", "@orbs-network/ton-access": "^2.3.0", - "@tact-lang/compiler": "^1.4.0", + "@tact-lang/compiler": "^1.4.2", "@ton-community/func-js": "^0.5.0", "@ton/core": "^0.56.3", "@ton/sandbox": "^0.16.0", @@ -464,6 +464,36 @@ "glob": "7.1.7" } }, + "node_modules/@next/swc-android-arm-eabi": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.7.tgz", + "integrity": "sha512-QTEamOK/LCwBf05GZ261rULMbZEpE3TYdjHlXfznV+nXwTztzkBNFXwP67gv2wW44BROzgi/vrR9H8oP+J5jxg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-android-arm64": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.7.tgz", + "integrity": "sha512-wcy2H0Tl9ME8vKy2GnJZ7Mybwys+43F/Eh2Pvph7mSDpMbYBJ6iA0zeY62iYYXxlZhnAID3+h79FUqUEakkClw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@next/swc-darwin-arm64": { "version": "13.0.7", "cpu": [ @@ -478,6 +508,156 @@ "node": ">= 10" } }, + "node_modules/@next/swc-darwin-x64": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.7.tgz", + "integrity": "sha512-636AuRQynCPnIPRVzcCk5B7OMq9XjaYam2T0HeWUCE6y7EqEO3kxiuZ4QmN81T7A6Ydb+JnivYrLelHXmgdj6A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-freebsd-x64": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.7.tgz", + "integrity": "sha512-92XAMzNgQazowZ9t7uZmHRA5VdBl/SwEdrf5UybdfRovsxB4r3+yJWEvFaqYpSEp0gwndbwLokJdpz7OwFdL3Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm-gnueabihf": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.7.tgz", + "integrity": "sha512-3r1CWl5P6I5n5Yxip8EXv/Rfu2Cp6wVmIOpvmczyUR82j+bcMkwPAcUjNkG/vMCagS4xV7NElrcdGb39iFmfLg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.7.tgz", + "integrity": "sha512-RXo8tt6ppiwyS6hpDw3JdAjKcdVewsefxnxk9xOH4mRhMyq9V2lQx0e24X/dRiZqkx3jnWReR2WRrUlgN1UkSQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.7.tgz", + "integrity": "sha512-RWpnW+bmfXyxyY7iARbueYDGuIF+BEp3etLeYh/RUNHb9PhOHLDgJOG8haGSykud3a6CcyBI8hEjqOhoObaDpw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.7.tgz", + "integrity": "sha512-/ygUIiMMTYnbKlFs5Ba9J5k/tNxFWy8eI1bBF8UuMTvV8QJHl/aLDiA5dwsei2kk99/cu3eay62JnJXkSk3RSQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.7.tgz", + "integrity": "sha512-dLzr6AL77USJN0ejgx5AS8O8SbFlbYTzs0XwAWag4oQpUG2p3ARvxwQgYQ0Z+6EP0zIRZ/XfLkN/mhsyi3m4PA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.7.tgz", + "integrity": "sha512-+vFIVa82AwqFkpFClKT+n73fGxrhAZ2u1u3mDYEBdxO6c9U4Pj3S5tZFsGFK9kLT/bFvf/eeVOICSLCC7MSgJQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.7.tgz", + "integrity": "sha512-RNLXIhp+assD39dQY9oHhDxw+/qSJRARKhOFsHfOtf8yEfCHqcKkn3X/L+ih60ntaEqK294y1WkMk6ylotsxwA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.7.tgz", + "integrity": "sha512-kvdnlLcrnEq72ZP0lqe2Z5NqvB9N5uSCvtXJ0PhKvNncWWd0fEG9Ec9erXgwCmVlM2ytw41k9/uuQ+SVw4Pihw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -665,12 +845,11 @@ } }, "node_modules/@tact-lang/compiler": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@tact-lang/compiler/-/compiler-1.4.0.tgz", - "integrity": "sha512-MUZ8ulTrIs0sgs1tdNww7yan6ozMGNO7xR6S0yKZc57E0EN9o72vRqKdQW7k3iS3+MvltKPt6RVbNamtuVJ1tQ==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@tact-lang/compiler/-/compiler-1.4.2.tgz", + "integrity": "sha512-vgXHCClLhedZ3BlrzEkX70QUWWcBjNyW3YBgfvOm0oj6g3WNrFv6W2z0hca/ZlCdwUqUwKz4lHuPCJdl201fgA==", "dependencies": { - "@ipld/dag-pb": "2.1.18", - "@tact-lang/opcode": "^0.0.14", + "@tact-lang/opcode": "^0.0.16", "@ton/core": "0.56.3", "@ton/crypto": "^3.2.0", "blockstore-core": "1.0.5", @@ -678,15 +857,13 @@ "ipfs-unixfs-importer": "9.0.10", "meow": "^13.2.0", "mkdirp": "^2.1.3", - "multiformats": "^13.1.0", "ohm-js": "^17.1.0", "path-normalize": "^6.0.13", "prando": "^6.0.1", - "qs": "^6.12.1", "zod": "^3.22.4" }, "bin": { - "tact": "bin/tact" + "tact": "bin/tact.js" } }, "node_modules/@tact-lang/compiler/node_modules/change-case": { @@ -707,15 +884,10 @@ "tslib": "^2.0.3" } }, - "node_modules/@tact-lang/compiler/node_modules/multiformats": { - "version": "13.2.2", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.2.2.tgz", - "integrity": "sha512-RWI+nyf0q64vyOxL8LbKtjJMki0sogRL/8axvklNtiTM0iFCVtHwME9w6+0P1/v4dQvsIg8A45oT3ka1t/M/+A==" - }, "node_modules/@tact-lang/opcode": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/@tact-lang/opcode/-/opcode-0.0.14.tgz", - "integrity": "sha512-8FKHK2jwvViRBReO2t40DCkHAP9KPTRWZof4kdsAUJFlyeWIC8SsRQSl9QkZxF+48WvjDduKNqN5Ltb80paufA==", + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/@tact-lang/opcode/-/opcode-0.0.16.tgz", + "integrity": "sha512-YJTUjoDOy+e+FHHppJiF+uWJ2IMjVknB9VQ5n78pknCE129DazCb/nFXnw0wVRDVcn8Tn59ky+pmjiQjQOjEbw==", "peerDependencies": { "@ton/core": ">=0.49.2", "@ton/crypto": "^3.2.0" @@ -6032,20 +6204,6 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "funding": [ @@ -8512,186 +8670,6 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } - }, - "node_modules/@next/swc-android-arm-eabi": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.7.tgz", - "integrity": "sha512-QTEamOK/LCwBf05GZ261rULMbZEpE3TYdjHlXfznV+nXwTztzkBNFXwP67gv2wW44BROzgi/vrR9H8oP+J5jxg==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-android-arm64": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.7.tgz", - "integrity": "sha512-wcy2H0Tl9ME8vKy2GnJZ7Mybwys+43F/Eh2Pvph7mSDpMbYBJ6iA0zeY62iYYXxlZhnAID3+h79FUqUEakkClw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.7.tgz", - "integrity": "sha512-636AuRQynCPnIPRVzcCk5B7OMq9XjaYam2T0HeWUCE6y7EqEO3kxiuZ4QmN81T7A6Ydb+JnivYrLelHXmgdj6A==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-freebsd-x64": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.7.tgz", - "integrity": "sha512-92XAMzNgQazowZ9t7uZmHRA5VdBl/SwEdrf5UybdfRovsxB4r3+yJWEvFaqYpSEp0gwndbwLokJdpz7OwFdL3Q==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm-gnueabihf": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.7.tgz", - "integrity": "sha512-3r1CWl5P6I5n5Yxip8EXv/Rfu2Cp6wVmIOpvmczyUR82j+bcMkwPAcUjNkG/vMCagS4xV7NElrcdGb39iFmfLg==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.7.tgz", - "integrity": "sha512-RXo8tt6ppiwyS6hpDw3JdAjKcdVewsefxnxk9xOH4mRhMyq9V2lQx0e24X/dRiZqkx3jnWReR2WRrUlgN1UkSQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.7.tgz", - "integrity": "sha512-RWpnW+bmfXyxyY7iARbueYDGuIF+BEp3etLeYh/RUNHb9PhOHLDgJOG8haGSykud3a6CcyBI8hEjqOhoObaDpw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.7.tgz", - "integrity": "sha512-/ygUIiMMTYnbKlFs5Ba9J5k/tNxFWy8eI1bBF8UuMTvV8QJHl/aLDiA5dwsei2kk99/cu3eay62JnJXkSk3RSQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.7.tgz", - "integrity": "sha512-dLzr6AL77USJN0ejgx5AS8O8SbFlbYTzs0XwAWag4oQpUG2p3ARvxwQgYQ0Z+6EP0zIRZ/XfLkN/mhsyi3m4PA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.7.tgz", - "integrity": "sha512-+vFIVa82AwqFkpFClKT+n73fGxrhAZ2u1u3mDYEBdxO6c9U4Pj3S5tZFsGFK9kLT/bFvf/eeVOICSLCC7MSgJQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.7.tgz", - "integrity": "sha512-RNLXIhp+assD39dQY9oHhDxw+/qSJRARKhOFsHfOtf8yEfCHqcKkn3X/L+ih60ntaEqK294y1WkMk6ylotsxwA==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.7.tgz", - "integrity": "sha512-kvdnlLcrnEq72ZP0lqe2Z5NqvB9N5uSCvtXJ0PhKvNncWWd0fEG9Ec9erXgwCmVlM2ytw41k9/uuQ+SVw4Pihw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } } } } diff --git a/package.json b/package.json index 332f2d4..82950fc 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@minoru/react-dnd-treeview": "^3.4.1", "@monaco-editor/react": "^4.5.1", "@orbs-network/ton-access": "^2.3.0", - "@tact-lang/compiler": "^1.4.0", + "@tact-lang/compiler": "^1.4.2", "@ton-community/func-js": "^0.5.0", "@ton/core": "^0.56.3", "@ton/sandbox": "^0.16.0", diff --git a/src/hooks/project.hooks.ts b/src/hooks/project.hooks.ts index ab7f7d7..a0b4c1f 100644 --- a/src/hooks/project.hooks.ts +++ b/src/hooks/project.hooks.ts @@ -12,6 +12,7 @@ import { OverwritableVirtualFileSystem } from '@/utility/OverwritableVirtualFile import { FileInterface } from '@/utility/fileSystem'; import { extractCompilerDiretive, parseGetters } from '@/utility/getterParser'; import { + LogLevel, build as buildTact, createVirtualFileSystem, } from '@tact-lang/compiler'; @@ -217,9 +218,9 @@ export function useProjectActions() { }, project: fs, stdlib: '@stdlib', - logger: TactLogger, + logger: new TactLogger(LogLevel.DEBUG), }); - if (!response) { + if (!response.ok) { throw new Error('Error while building'); } diff --git a/src/utility/abi.ts b/src/utility/abi.ts index 5593a03..6d43a1c 100644 --- a/src/utility/abi.ts +++ b/src/utility/abi.ts @@ -233,8 +233,8 @@ export function getContractInitParams( ) { const contactType = getType(ctx, contractName); - if (!contactType.init?.args) return []; - return contactType.init.args.map((item) => { + if (!contactType.init?.params) return []; + return contactType.init.params.map((item) => { let additionalProps = {}; switch (item.type.kind) { case 'ref': @@ -253,13 +253,13 @@ export function getContractInitParams( break; case 'void': additionalProps = { - name: item.name, + name: item.name.text, type: 'void', }; break; case 'null': additionalProps = { - name: item.name, + name: item.name.text, type: 'null', }; break; @@ -271,7 +271,7 @@ export function getContractInitParams( break; } return { - name: item.name, + name: item.name.text, type: { ...additionalProps, kind: item.type.kind === 'map' ? 'dict' : 'simple', diff --git a/src/utility/tactLogger.ts b/src/utility/tactLogger.ts index 5e600b6..cea2892 100644 --- a/src/utility/tactLogger.ts +++ b/src/utility/tactLogger.ts @@ -1,59 +1,42 @@ -// import { LogLevel, LogMethods, Logger } from '@tact-lang/compiler'; -import { TactLogger as TactLoggerType } from '@tact-lang/compiler'; +import { ILogger, Logger, LogLevel } from '@tact-lang/compiler'; import EventEmitter from './eventEmitter'; -// const logLevelToMethodName: { [key in LogLevel]: keyof LogMethods | null } = { -// [LogLevel.NONE]: null, -// [LogLevel.ERROR]: 'error', -// [LogLevel.WARN]: 'warn', -// [LogLevel.INFO]: 'info', -// [LogLevel.DEBUG]: 'debug', -// }; - -// function getLoggingMethod(level: LogLevel): keyof LogMethods | null { -// return logLevelToMethodName[level]; -// } - -// export default class TactLogger extends Logger { -// private levelLevel: LogLevel; -// constructor(level: LogLevel = LogLevel.INFO) { -// super(level); -// this.levelLevel = level; -// } -// protected log(level: LogLevel, message: string | Error): void { -// if (this.levelLevel === LogLevel.NONE) { -// return; -// } - -// message = message instanceof Error ? message.message : message; - -// if (level > this.levelLevel) return; -// const loggingMethod = getLoggingMethod(level); -// if (!loggingMethod) return; - -// EventEmitter.emit('LOG', { -// text: message, -// type: loggingMethod as Exclude, -// timestamp: new Date().toISOString(), -// }); -// } -// } - -const TactLogger: TactLoggerType = { - log: (message: string) => { - printLog(message, 'info'); - }, - error: (message: string) => { - printLog(message, 'error'); - }, -}; - -const printLog = (message: string, type: 'info' | 'error') => { - EventEmitter.emit('LOG', { - text: message, - type: type, - timestamp: new Date().toISOString(), - }); +const logLevelToMethodName: { [key in LogLevel]: keyof ILogger | null } = { + [LogLevel.NONE]: null, + [LogLevel.ERROR]: 'error', + [LogLevel.WARN]: 'warn', + [LogLevel.INFO]: 'info', + [LogLevel.DEBUG]: 'debug', }; -export default TactLogger; +function getLoggingMethod(level: LogLevel): keyof ILogger | null { + return logLevelToMethodName[level]; +} + +export default class TactLogger extends Logger { + private levelLevel: LogLevel; + constructor(level: LogLevel = LogLevel.INFO) { + super(level); + this.levelLevel = level; + } + protected log(level: LogLevel, message: string | Error): void { + if (this.levelLevel === LogLevel.NONE) { + return; + } + + message = message instanceof Error ? message.message : message; + + if (level > this.levelLevel) return; + const loggingMethod = getLoggingMethod(level); + if (!loggingMethod) return; + + EventEmitter.emit('LOG', { + text: message, + type: + loggingMethod === 'debug' + ? 'warning' + : (loggingMethod as Exclude), + timestamp: new Date().toISOString(), + }); + } +}