From c66e974e9fe1d7bee44955b026a4adbd5f3011c1 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Thu, 11 Jan 2024 13:06:08 -0500 Subject: [PATCH 01/28] Revert "remove all" This reverts commit 78e9a85c6e35ee8830cc5ccb480a7373fdad2143. --- .github/workflows/jest.yml | 16 + .gitignore | 67 + generate_all.ts | 24 + index.ts | 1 + jest.config.js | 5 + package-lock.json | 3774 ++++++ package.json | 25 + src/ast.ts | 179 + src/astbuilder/fill_constructors.ts | 578 + src/astbuilder/handle_field.ts | 134 + src/astbuilder/handle_type.ts | 284 + src/astbuilder/utils.ts | 264 + src/generators/CodeBuilder.ts | 64 + src/generators/generator.ts | 17 + src/generators/typescript/complex_expr.ts | 332 + src/generators/typescript/generator.ts | 969 ++ src/generators/typescript/tsgen.ts | 711 ++ src/generators/typescript/utils.ts | 228 + src/main.ts | 57 + src/utils.ts | 126 + test/generated_files/generated_block.ts | 13300 ++++++++++++++++++++ test/generated_files/generated_test.ts | 2562 ++++ test/tlb/block.tlb | 938 ++ test/tlb/test.tlb | 140 + test/tlbgen.spec.ts | 506 + tsconfig.json | 109 + 26 files changed, 25410 insertions(+) create mode 100644 .github/workflows/jest.yml create mode 100644 .gitignore create mode 100644 generate_all.ts create mode 100644 index.ts create mode 100644 jest.config.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/ast.ts create mode 100644 src/astbuilder/fill_constructors.ts create mode 100644 src/astbuilder/handle_field.ts create mode 100644 src/astbuilder/handle_type.ts create mode 100644 src/astbuilder/utils.ts create mode 100644 src/generators/CodeBuilder.ts create mode 100644 src/generators/generator.ts create mode 100644 src/generators/typescript/complex_expr.ts create mode 100644 src/generators/typescript/generator.ts create mode 100644 src/generators/typescript/tsgen.ts create mode 100644 src/generators/typescript/utils.ts create mode 100644 src/main.ts create mode 100644 src/utils.ts create mode 100644 test/generated_files/generated_block.ts create mode 100644 test/generated_files/generated_test.ts create mode 100644 test/tlb/block.tlb create mode 100644 test/tlb/test.tlb create mode 100644 test/tlbgen.spec.ts create mode 100644 tsconfig.json diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml new file mode 100644 index 0000000..5504883 --- /dev/null +++ b/.github/workflows/jest.yml @@ -0,0 +1,16 @@ +name: Typescript Generator Tests +run-name: ${{ github.actor }} is testing out tlbgenerator for typescript +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - run: npm install + - run: npm install -g ts-node + - run: sed -i 's/"+", "Type"/"#", "Type"/g' "node_modules/@igorivaniuk/tlb-parser/dist/ast/nodes.d.ts" + - run: ts-node generate_all.ts + - run: npm run test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0182f89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,67 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + + +## Custom +## ====== + +dist/ diff --git a/generate_all.ts b/generate_all.ts new file mode 100644 index 0000000..55bcc41 --- /dev/null +++ b/generate_all.ts @@ -0,0 +1,24 @@ +import fs from 'fs' +import path from 'path' +import util from 'util' + +import { parse, ast } from '@igorivaniuk/tlb-parser' +import { generate } from './src/main' + + +const fixturesDir = path.resolve(__dirname, 'test') + +function generateCode(filename: string) { + const input = fs.readFileSync( + path.resolve(fixturesDir, 'tlb', filename + '.tlb'), + 'utf-8', + ) + const parsed = parse(input) + + const tree = ast(input) + + fs.writeFile('test/generated_files/generated_' + filename + '.ts', generate(tree, input), () => { }); +} + +generateCode('block') +generateCode('test') diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..955ef64 --- /dev/null +++ b/index.ts @@ -0,0 +1 @@ +console.log("Hi") diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..b413e10 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..cdd8c61 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3774 @@ +{ + "name": "amy", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "amy", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@igorivaniuk/tlb-parser": "^0.1.0", + "@types/jest": "^29.5.11", + "crc-32": "^1.2.2", + "ton": "^13.9.0", + "ts-jest": "^29.1.1" + }, + "devDependencies": { + "@jest/globals": "^29.7.0", + "jest": "^29.7.0", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", + "dependencies": { + "@babel/highlight": "^7.23.4", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.5.tgz", + "integrity": "sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.23.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", + "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-compilation-targets": "^7.23.6", + "@babel/helper-module-transforms": "^7.23.3", + "@babel/helpers": "^7.23.7", + "@babel/parser": "^7.23.6", + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.23.7", + "@babel/types": "^7.23.6", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz", + "integrity": "sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==", + "dependencies": { + "@babel/types": "^7.23.6", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz", + "integrity": "sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ==", + "dependencies": { + "@babel/compat-data": "^7.23.5", + "@babel/helper-validator-option": "^7.23.5", + "browserslist": "^4.22.2", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", + "dependencies": { + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz", + "integrity": "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==", + "dependencies": { + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz", + "integrity": "sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==", + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-module-imports": "^7.22.15", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.20" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz", + "integrity": "sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.23.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.7.tgz", + "integrity": "sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ==", + "dependencies": { + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.23.7", + "@babel/types": "^7.23.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", + "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz", + "integrity": "sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz", + "integrity": "sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.23.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.7.tgz", + "integrity": "sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg==", + "dependencies": { + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", + "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", + "dependencies": { + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==" + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "devOptional": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@igorivaniuk/tlb-parser": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@igorivaniuk/tlb-parser/-/tlb-parser-0.1.0.tgz", + "integrity": "sha512-U7tNvwK3SL5BXujg5t3HZ0/aHnUkfT/acLG7E8J1R3CL6O/q6mfPcQnDfbIHPrnb6He+UMKhSsFjTbd4kKSvnw==", + "dependencies": { + "ohm-js": "^16.6.0" + } + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/reporters/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==" + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "devOptional": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "devOptional": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "devOptional": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "devOptional": true + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.4", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", + "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==" + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.11", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.11.tgz", + "integrity": "sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==", + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/node": { + "version": "20.10.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", + "integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" + }, + "node_modules/@types/yargs": { + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", + "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==" + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "devOptional": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", + "integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", + "devOptional": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "devOptional": true + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "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", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.22.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", + "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001565", + "electron-to-chromium": "^1.4.601", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001572", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001572.tgz", + "integrity": "sha512-1Pbh5FLmn5y4+QhNyJE9j3/7dK44dGB83/ZMjv/qJk86TvDbjk0LosiZo0i0WB0Vx607qMX9jYrn1VLHCkN4rw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==" + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==" + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" + }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "devOptional": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "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", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", + "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "devOptional": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.616", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.616.tgz", + "integrity": "sha512-1n7zWYh8eS0L9Uy+GskE0lkBUNK83cXTVJI0pU3mGprFsbfSdAc15VTFbo+A+Bq4pwstmL30AVcEU3Fo463lNg==" + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "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", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==" + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dependencies": { + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.1.tgz", + "integrity": "sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA==", + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jssha": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jssha/-/jssha-3.2.0.tgz", + "integrity": "sha512-QuruyBENDWdN4tZwJbQq7/eAK85FqrI4oDbXjy5IBhYD+2pTJyBUWZe8ctWaCkrV0gy6AaelgOZZBMeswEa/6Q==", + "peer": true, + "engines": { + "node": "*" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==" + }, + "node_modules/node-releases": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ohm-js": { + "version": "16.6.0", + "resolved": "https://registry.npmjs.org/ohm-js/-/ohm-js-16.6.0.tgz", + "integrity": "sha512-X9P4koSGa7swgVQ0gt71UCYtkAQGOjciJPJAz74kDxWt8nXbH5HrDOQG6qBDH7SR40ktNv4x61BwpTDE9q4lRA==", + "engines": { + "node": ">=0.12.1" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pure-rand": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz", + "integrity": "sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, + "node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/symbol.inspect": { + "version": "1.0.1", + "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", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==" + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "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/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "devOptional": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "peer": true + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "devOptional": true + }, + "node_modules/v8-to-istanbul": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "devOptional": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "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 new file mode 100644 index 0000000..c9aebc9 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "amy", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "jest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@jest/globals": "^29.7.0", + "jest": "^29.7.0", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" + }, + "dependencies": { + "@igorivaniuk/tlb-parser": "^0.1.0", + "@types/jest": "^29.5.11", + "crc-32": "^1.2.2", + "ton": "^13.9.0", + "ts-jest": "^29.1.1" + } +} diff --git a/src/ast.ts b/src/ast.ts new file mode 100644 index 0000000..d0fbede --- /dev/null +++ b/src/ast.ts @@ -0,0 +1,179 @@ +export class TLBBinaryOp { + constructor( + readonly left: TLBMathExpr, + readonly right: TLBMathExpr, + readonly operation: string, + readonly variables: Set = new Set([ + ...left.variables, + ...right.variables, + ]), + readonly hasNeg: boolean = left.hasNeg || right.hasNeg + ) {} +} + +export class TLBNumberExpr { + constructor( + readonly n: number, + readonly variables: Set = new Set(), + readonly hasNeg: boolean = false + ) {} +} + +export class TLBUnaryOp { + constructor( + readonly value: TLBMathExpr, + readonly operation: string, + readonly variables: Set = value.variables, + readonly hasNeg: boolean = value.hasNeg + ) {} +} + +export class TLBVarExpr { + constructor( + readonly x: string, + readonly variables: Set = new Set(), + readonly hasNeg: boolean = false + ) { + if (variables.size == 0) { + variables.add(x); + } + } +} + +export type TLBMathExpr = TLBBinaryOp | TLBNumberExpr | TLBVarExpr | TLBUnaryOp; + +export type TLBVariableType = "Type" | "#"; + +export class TLBVariable { + constructor( + readonly isConst: boolean, + readonly negated: boolean, + readonly type: TLBVariableType, + readonly name: string, + readonly isField: boolean, + readonly deriveExpr?: TLBMathExpr, + readonly initialExpr?: TLBMathExpr + ) {} +} + +export type TLBBitsType = { + kind: "TLBBitsType"; + bits: TLBMathExpr; +}; + +export type TLBNamedType = { + kind: "TLBNamedType"; + name: string; + arguments: TLBFieldType[]; +}; + +export type TLBMathExprType = { + kind: "TLBExprMathType"; + expr: TLBMathExpr; +}; + +export type TLBBoolType = { + kind: "TLBBoolType"; +}; + +export type TLBAddressType = { + kind: "TLBAddressType"; +}; + +export type TLBCellType = { + kind: "TLBCellType"; +}; + +export type TLBNumberType = { + kind: "TLBNumberType"; + bits: TLBMathExpr; + signed: boolean; + storeBits: TLBMathExpr; + maxBits: number | undefined; +}; + +export type TLBNegatedType = { + kind: "TLBNegatedType"; + variableName: string; +}; + +export type TLBCellInsideType = { + kind: "TLBCellInsideType"; + value: TLBFieldType; +}; + +export type TLBMultipleType = { + kind: "TLBMultipleType"; + value: TLBFieldType; + times: TLBMathExpr; +}; + +export type TLBCondType = { + kind: "TLBCondType"; + value: TLBFieldType; + condition: TLBMathExpr; +}; + +export type TLBExoticType = { + kind: "TLBExoticType"; +}; + +export type TLBFieldType = + | TLBNumberType + | TLBBitsType + | TLBNamedType + | TLBBoolType + | TLBAddressType + | TLBCellType + | TLBMathExprType + | TLBNegatedType + | TLBCellInsideType + | TLBMultipleType + | TLBCondType + | TLBExoticType; + +export type TLBField = { + name: string; + anonymous: boolean; + fieldType: TLBFieldType; + subFields: TLBField[]; +}; + +export class TLBParameter { + constructor( + readonly variable: TLBVariable, + readonly paramExpr: TLBMathExpr, + readonly argName?: string + ) {} +} + +export type TLBConstructorTag = { + bitLen: number; + binary: string; +}; + +export class TLBConstructor { + constructor( + readonly parameters: Array, + readonly variables: Array, + readonly variablesMap: Map, + readonly parametersMap: Map, + readonly name: string, + readonly fields: Array, + readonly tag: TLBConstructorTag, + readonly constraints: Array, + readonly declaration: string, + readonly tlbType: string + ) {} +} + +export class TLBType { + constructor( + readonly name: string, + readonly constructors: Array + ) {} +} + +export class TLBCode { + constructor(readonly types: Map) {} +} diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts new file mode 100644 index 0000000..b4fd67e --- /dev/null +++ b/src/astbuilder/fill_constructors.ts @@ -0,0 +1,578 @@ +import { + CompareExpr, + Declaration, + FieldBuiltinDef, + FieldCurlyExprDef, + FieldNamedDef, + MathExpr, + NameExpr, + NegateExpr, + NumberExpr, +} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import * as crc32 from "crc-32"; +import { + TLBBinaryOp, + TLBCode, + TLBConstructor, + TLBConstructorTag, + TLBField, + TLBMathExpr, + TLBNumberExpr, + TLBParameter, + TLBType, + TLBVarExpr, + TLBVariable, +} from "../ast"; +import { findNotReservedName } from "../utils"; +import { fillFields } from "./handle_field"; +import { + TLBCodeBuild, + TLBConstructorBuild, + TLBParameterBuild, + TLBTypeBuild, + TLBVariableBuild, + calculateVariable, + convertToMathExpr, + deriveMathExpression, + getNegatedVariable, + opCodeSetsEqual, + reorganizeExpression, +} from "./utils"; + +export function fillConstructors( + declarations: Declaration[], + tlbCode: TLBCodeBuild, + input: string[] +) { + let typeDeclarations = new Map< + String, + { declaration: Declaration; constructor: TLBConstructorBuild }[] + >(); + declarations.forEach((declaration) => { + let tlbType: TLBTypeBuild | undefined = tlbCode.types.get( + declaration.combinator.name + ); + if (tlbType == undefined) { + tlbType = { name: declaration.combinator.name, constructors: [] }; + } + let constructor = { + parameters: [], + parametersMap: new Map(), + name: declaration.constructorDef.name, + variables: new Array(), + variablesMap: new Map(), + tag: getConstructorTag(declaration, input), + constraints: [], + fields: [], + declaration: "", + tlbType: tlbType.name, + }; + tlbType.constructors.push(constructor); + tlbCode.types.set(tlbType.name, tlbType); + + let currentDecls = typeDeclarations.get(tlbType.name); + if (!currentDecls) { + currentDecls = []; + } + currentDecls.push({ declaration: declaration, constructor: constructor }); + typeDeclarations.set(tlbType.name, currentDecls); + }); + + tlbCode.types.forEach((tlbType: TLBTypeBuild) => { + typeDeclarations.get(tlbType.name)?.forEach((typeItem) => { + let declaration = typeItem.declaration; + let constructor = typeItem.constructor; + + declaration.fields.forEach((field) => { + if (field instanceof FieldBuiltinDef) { + constructor.variables.push({ + name: field.name, + isConst: false, + negated: false, + type: field.type, + calculated: false, + isField: false, + }); + } + if (field instanceof FieldNamedDef) { + constructor.variables.push({ + name: field.name, + isConst: false, + negated: false, + type: "#", + calculated: false, + isField: true, + }); + } + }); + constructor.variables.forEach((variable) => { + if (variable.name) { + constructor.variablesMap.set(variable.name, variable); + } + }); + let argumentIndex = -1; + declaration.combinator.args.forEach((element) => { + argumentIndex++; + let parameter: TLBParameterBuild | undefined = undefined; + if (element instanceof NameExpr) { + let variable = constructor.variablesMap.get(element.name); + if (variable) { + if (variable.type == "#") { + variable.deriveExpr = new TLBVarExpr(element.name); + variable.initialExpr = variable.deriveExpr; + } + parameter = { + variable: variable, + paramExpr: new TLBVarExpr(element.name), + }; + } else { + throw new Error( + "Field not known before using (should be tagged as implicit): " + + element + ); + } + } else if (element instanceof MathExpr) { + let derivedExpr = deriveMathExpression(element); + if (!derivedExpr.name) { + throw new Error(`Expression should contain variable ${element}`); + } + let variable = constructor.variablesMap.get(derivedExpr.name); + if (variable && variable.name) { + parameter = { variable: variable, paramExpr: derivedExpr.derived }; + parameter.argName = "arg" + argumentIndex; + parameter.variable.deriveExpr = reorganizeWithArg( + convertToMathExpr(element), + parameter.argName, + variable.name + ); + parameter.variable.initialExpr = new TLBVarExpr(variable.name); + } else { + throw new Error(`Variable should have name ${variable}`); + } + } else if ( + element instanceof NegateExpr && + (element.expr instanceof MathExpr || + element.expr instanceof NumberExpr || + element.expr instanceof NameExpr) + ) { + let derivedExpr = deriveMathExpression(element.expr); + let toBeConst = false; + if (element.expr instanceof NumberExpr) { + toBeConst = true; + } + + if (derivedExpr.name == undefined) { + if (toBeConst) { + parameter = { + variable: { + negated: true, + isConst: toBeConst, + type: "#", + name: undefined, + deriveExpr: derivedExpr.derived, + initialExpr: derivedExpr.derived, + calculated: false, + isField: false, + }, + paramExpr: derivedExpr.derived, + }; + } else { + throw new Error("Cannot identify combinator arg " + element); + } + } else { + let variable = constructor.variablesMap.get(derivedExpr.name); + if (variable) { + variable.negated = true; + variable.isConst = toBeConst; + variable.initialExpr = derivedExpr.derived; + parameter = { + variable: variable, + paramExpr: derivedExpr.derived, + }; + } else { + throw new Error("Cannot identify combinator arg " + element); + } + } + } else if (element instanceof NumberExpr) { + parameter = { + variable: { + negated: false, + isConst: true, + type: "#", + name: undefined, + deriveExpr: new TLBNumberExpr(element.num), + initialExpr: new TLBNumberExpr(element.num), + calculated: false, + isField: false, + }, + paramExpr: new TLBNumberExpr(element.num), + }; + } else { + throw new Error("Cannot identify combinator arg: " + element); + } + constructor.parameters.push(parameter); + if (parameter.variable.name != undefined) { + constructor.parametersMap.set(parameter.variable.name, parameter); + } + }); + constructor.declaration = getStringDeclaration(declaration, input); + fillConstraintsAndNegationVars(constructor, declaration); + fillFields(typeItem, tlbType); + calculateVariables(constructor); + }); + fillParameterNames(tlbType); + fillArgNames(tlbType); + findConstructorsNaming(tlbType); + tlbType.constructors.sort(compareConstructors); + }); + checkAndRemovePrimitives(tlbCode, input, typeDeclarations); + findAvailableVarNamesForCode(tlbCode); +} +function fillConstraintsAndNegationVars( + constructor: TLBConstructorBuild, + declaration: Declaration +) { + declaration.fields.forEach((field) => { + if ( + field instanceof FieldCurlyExprDef && + field.expr instanceof CompareExpr + ) { + if (field.expr.op == "=") { + let myMathExpr = convertToMathExpr(field.expr); + let negatedVariable = getNegatedVariable(myMathExpr); + if (negatedVariable) { + myMathExpr = reorganizeExpression(myMathExpr, negatedVariable); + if (myMathExpr instanceof TLBBinaryOp) { + myMathExpr = myMathExpr.right; + } + let variable = constructor.variablesMap.get(negatedVariable); + if (variable) { + variable.negated = true; + variable.deriveExpr = myMathExpr; + } else { + throw new Error(`Variable ${negatedVariable} not defined`); + } + } else { + constructor.constraints.push(myMathExpr); + } + } else { + constructor.constraints.push(convertToMathExpr(field.expr)); + } + } + }); +} +function fillParameterNames(tlbType: TLBTypeBuild) { + let parameterNames: (string | undefined)[] = []; + tlbType.constructors[0]?.parameters.forEach((element) => { + parameterNames.push(element.variable.name); + }); + tlbType.constructors.forEach((constructor) => { + for (let i = 0; i < constructor.parameters.length; i++) { + if (parameterNames[i] == undefined) { + let parameterName = constructor.parameters[i]?.variable.name; + if (parameterName != undefined) { + parameterNames[i] = parameterName; + } + } + } + }); + for (let i = 0; i < parameterNames.length; i++) { + if (parameterNames[i] == undefined) { + parameterNames[i] = "arg" + i; + } + } + tlbType.constructors.forEach((constructor) => { + for (let i = 0; i < constructor.parameters.length; i++) { + let parameterName = parameterNames[i]; + if ( + parameterName != undefined && + constructor.parameters[i]?.variable.name == undefined + ) { + constructor.parameters[i]!.variable.name = parameterName; + } + } + }); +} +function fillArgNames(tlbType: TLBTypeBuild) { + let argNames: (string | undefined)[] = []; + tlbType.constructors[0]?.parameters.forEach((element) => { + argNames.push(undefined); + }); + + tlbType.constructors.forEach((constructor) => { + for (let i = 0; i < constructor.parameters.length; i++) { + let argName = constructor.parameters[i]?.argName; + if (argName) { + argNames[i] = argName; + } + } + }); + tlbType.constructors.forEach((constructor) => { + for (let i = 0; i < constructor.parameters.length; i++) { + let argName = argNames[i]; + let parameter = constructor.parameters[i]; + if (argName != undefined && parameter != undefined) { + parameter.argName = argName; + if (parameter.paramExpr instanceof TLBVarExpr) { + parameter.variable.deriveExpr = new TLBVarExpr(parameter.argName); + parameter.paramExpr = parameter.variable.deriveExpr; + } + } + } + }); +} +function compareConstructors( + a: TLBConstructorBuild, + b: TLBConstructorBuild +): number { + let aPriority = constructorPriority(a); + let bPriority = constructorPriority(b); + if (aPriority < bPriority) { + return 1; + } + if (aPriority > bPriority) { + return -1; + } + return 0; +} +function constructorPriority(c: TLBConstructorBuild): number { + let result = 0; + if (c.tag.bitLen > 0) { + result++; + } + c.parameters.forEach((parameter) => { + if (parameter.variable.isConst) { + result++; + } + }); + return result; +} +function reorganizeWithArg( + mathExpr: TLBMathExpr, + argName: string, + varName: string +): TLBMathExpr { + let reorganized = reorganizeExpression( + new TLBBinaryOp( + new TLBVarExpr(argName), + mathExpr, + "=", + new Set(), + false + ), + varName + ); + if (reorganized instanceof TLBBinaryOp) { + return reorganized.right; + } + throw new Error(`Couldn't reorganize expression ${mathExpr}`); +} +function getConstructorTag( + declaration: Declaration, + input: string[] +): TLBConstructorTag { + let tag = declaration.constructorDef.tag; + if ( + (tag == null && declaration.constructorDef.name == "_") || + (tag && tag.length > 1 && tag[1] == "_") + ) { + return { + bitLen: 0, + binary: "", + }; + } + if (tag == null) { + let opCode = calculateOpcode(declaration, input); + return { + bitLen: 32, + binary: "0x" + opCode, + }; + } + if (tag[0] == "$") { + return { + bitLen: tag?.length - 1, + binary: "0b" + tag.slice(1), + }; + } + if (tag[0] == "#") { + return { + bitLen: (tag?.length - 1) * 4, + binary: "0x" + tag.slice(1), + }; + } + throw new Error("Unknown tag " + tag); +} +function findConstructorsNaming(tlbType: TLBTypeBuild) { + let constructorNames: Set = new Set(); + let constructorIndex = 0; + tlbType.constructors.forEach((current) => { + while (constructorNames.has(current.name)) { + current.name += constructorIndex.toString(); + } + constructorNames.add(current.name); + constructorIndex++; + }); +} +function checkAndRemovePrimitives( + tlbCode: TLBCodeBuild, + input: string[], + typeDeclarations: Map< + String, + { declaration: Declaration; constructor: TLBConstructorBuild }[] + > +) { + let toDelete: string[] = []; + + let typesToDelete = new Map(); + typesToDelete.set("Bool", ["4702fd23", "f0e8d7f"]); + typesToDelete.set("MsgAddressInt", ["d7b672a", "6d593e8a"]); + + typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { + let typeItems = typeDeclarations.get(typeName); + if (typeItems) { + let opCodesActual: string[] = []; + typeItems.forEach((typeItem) => { + opCodesActual.push(calculateOpcode(typeItem.declaration, input)); + }); + if (!opCodeSetsEqual(opCodesExpected, opCodesActual)) { + throw new Error("Bool primitive type is not correct in scheme"); + } + toDelete.push(typeName); + } + }); + + toDelete.forEach((name: string) => { + tlbCode.types.delete(name); + }); +} +function findAvailableVarNamesForCode(tlbCode: TLBCodeBuild) { + tlbCode.types.forEach((tlbType) => { + tlbType.constructors.forEach((constructor) => { + let variablesSet = new Set(); + findAvailableFieldsNames(constructor.fields, variablesSet); + }); + }); +} +function findAvailableFieldsNames( + fields: TLBField[], + variablesSet: Set +) { + fields.forEach((field) => { + if (field.subFields.length == 0) { + findAvailableFieldName(field, variablesSet); + } + findAvailableFieldsNames(field.subFields, variablesSet); + }); +} +function findAvailableFieldName(field: TLBField, variablesSet: Set) { + let index = 0; + field.name = findNotReservedName(field.name); + while (variablesSet.has(field.name)) { + field.name = findNotReservedName(field.name + "_" + index); + index++; + } + variablesSet.add(field.name); +} +export function convertCodeToReadonly(tlbCode: TLBCodeBuild): TLBCode { + let newTypes = new Map(); + tlbCode.types.forEach((value, key) => { + let newConstructors = new Array(); + value.constructors.forEach((value) => { + let newVariablesMap = new Map(); + value.variablesMap.forEach((value, key) => { + newVariablesMap.set(key, convertVariableToReadonly(value)); + }); + let newParametersMap = new Map(); + value.parametersMap.forEach((value, key) => { + newParametersMap.set(key, convertParameterToReadonly(value)); + }); + let newConstructor = new TLBConstructor( + value.parameters.map(convertParameterToReadonly), + value.variables.map(convertVariableToReadonly), + newVariablesMap, + newParametersMap, + value.name, + value.fields, + value.tag, + value.constraints, + value.declaration, + value.tlbType + ); + newConstructors.push(newConstructor); + }); + let newType = new TLBType(value.name, newConstructors); + newTypes.set(key, newType); + }); + return new TLBCode(newTypes); +} +function convertParameterToReadonly( + tlbParameter: TLBParameterBuild +): TLBParameter { + return new TLBParameter( + convertVariableToReadonly(tlbParameter.variable), + tlbParameter.paramExpr, + tlbParameter.argName + ); +} +function convertVariableToReadonly(tlbVariable: TLBVariableBuild): TLBVariable { + if (tlbVariable.name == undefined) { + throw new Error("Variable is undefined"); + } + return new TLBVariable( + tlbVariable.isConst, + tlbVariable.negated, + tlbVariable.type, + tlbVariable.name, + tlbVariable.isField, + tlbVariable.deriveExpr, + tlbVariable.initialExpr + ); +} +function calculateOpcode(declaration: Declaration, input: string[]): string { + let scheme = getStringDeclaration(declaration, input); + let constructor = scheme.substring(0, scheme.indexOf(" ")); + const rest = scheme.substring(scheme.indexOf(" ")); + if (constructor.includes("#")) { + constructor = constructor.substring(0, constructor.indexOf("#")); + } + scheme = + constructor + + " " + + rest + .replace(/\(/g, "") + .replace(/\)/g, "") + .replace(/\s+/g, " ") + .replace(/;/g, "") + .trim(); + return (BigInt(crc32.str(scheme)) & BigInt(2147483647)).toString(16); +} +function getStringDeclaration( + declaration: Declaration, + input: string[] +): string { + let result = ""; + let splittedInput = input; + let currentLine = declaration.locations.line - 1; + let currentColumn = 0; + while (!splittedInput[currentLine]?.includes(";")) { + result += splittedInput[currentLine]?.substring(currentColumn) + "\n"; + currentLine++; + currentColumn = 0; + } + let currentInput = splittedInput[currentLine]; + if (currentInput) { + result += currentInput.substring( + currentColumn, + currentInput.indexOf(";") + 1 + ); + } + return result; +} +function calculateVariables(constructor: TLBConstructorBuild) { + constructor.variables.forEach((variable) => { + calculateVariable(variable, constructor); + }); + constructor.parameters.forEach((parameter) => { + calculateVariable(parameter.variable, constructor); + }); +} diff --git a/src/astbuilder/handle_field.ts b/src/astbuilder/handle_field.ts new file mode 100644 index 0000000..0ac9119 --- /dev/null +++ b/src/astbuilder/handle_field.ts @@ -0,0 +1,134 @@ +import { + BuiltinOneArgExpr, + BuiltinZeroArgs, + CellRefExpr, + CombinatorExpr, + CondExpr, + Declaration, + FieldAnonymousDef, + FieldDefinition, + FieldExprDef, + FieldNamedDef, + MathExpr, + NameExpr, +} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import { TLBField } from "../ast"; +import { getType } from "./handle_type"; +import { TLBConstructorBuild, TLBTypeBuild } from "./utils"; + +function getField( + field: FieldDefinition, + constructor: TLBConstructorBuild, + fieldIndex: string +): TLBField | undefined { + if (field instanceof FieldAnonymousDef) { + let result: TLBField = { + name: "", + anonymous: true, + fieldType: { kind: "TLBBoolType" }, + subFields: [], + }; + let currentFieldIndex = 0; + field.fields.forEach((field) => { + let subField = getField( + field, + constructor, + fieldIndex + "_" + currentFieldIndex.toString() + ); + if (subField) { + result.subFields.push(subField); + } + currentFieldIndex++; + }); + return result; + } + + if (field instanceof FieldNamedDef || field instanceof FieldExprDef) { + let fieldName: string; + if (field instanceof FieldNamedDef) { + fieldName = field.name; + } else { + fieldName = "anon" + fieldIndex; + } + if ( + field instanceof FieldExprDef && + field.expr instanceof NameExpr && + field.expr.name == "_" + ) { + return undefined; + } + + if (field.expr instanceof CellRefExpr) { + if ( + field.expr.expr instanceof CombinatorExpr && + (field.expr.expr.name == "MERKLE_UPDATE" || + field.expr.expr.name == "MERKLE_ROOT") + ) { + return { + name: fieldName, + anonymous: true, + fieldType: { kind: "TLBExoticType" }, + subFields: [], + }; + } else { + let subField = getField( + new FieldNamedDef(fieldName, field.expr.expr), + constructor, + fieldIndex + "_" + "0" + ); + if (subField) { + let result: TLBField = { + name: fieldName, + anonymous: true, + fieldType: { kind: "TLBBoolType" }, + subFields: [subField], + }; + return result; + } + return subField; + } + } + + if ( + field.expr instanceof CombinatorExpr || + field.expr instanceof NameExpr || + field.expr instanceof BuiltinZeroArgs || + field.expr instanceof BuiltinOneArgExpr || + field.expr instanceof MathExpr || + field.expr instanceof CondExpr + ) { + let fieldTypeName: string; + if (field.expr instanceof MathExpr || field.expr instanceof CondExpr) { + fieldTypeName = ""; + } else { + fieldTypeName = field.expr.name; + } + let fieldInfo = getType(field.expr, constructor, fieldTypeName); + return { + name: fieldName, + anonymous: !(field instanceof FieldNamedDef), + fieldType: fieldInfo, + subFields: [], + }; + } + } + return undefined; +} + +export function fillFields( + typeItem: { declaration: Declaration; constructor: TLBConstructorBuild }, + tlbType: TLBTypeBuild +) { + let constructor = typeItem.constructor; + let declaration = typeItem.declaration; + + let fieldIndex = -1; + + declaration.fields.forEach((fieldDecl) => { + fieldIndex++; + let field = getField(fieldDecl, constructor, fieldIndex.toString()); + if (field != undefined) { + constructor.fields.push(field); + } + }); +} diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts new file mode 100644 index 0000000..0cb4415 --- /dev/null +++ b/src/astbuilder/handle_type.ts @@ -0,0 +1,284 @@ +import { + BuiltinOneArgExpr, + BuiltinZeroArgs, + CellRefExpr, + CombinatorExpr, + CondExpr, + MathExpr, + NameExpr, + NegateExpr, + NumberExpr, + Expression as ParserExpression, +} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import { + TLBBinaryOp, + TLBFieldType, + TLBMathExpr, + TLBNumberExpr, + TLBUnaryOp, + TLBVarExpr, +} from "../ast"; +import { + TLBConstructorBuild, + convertToMathExpr, + getCalculatedExpression, + splitForTypeValue, +} from "./utils"; + +export function getType( + expr: ParserExpression, + constructor: TLBConstructorBuild, + fieldTypeName: string +): TLBFieldType { + if (expr instanceof BuiltinZeroArgs) { + if (expr.name == "#") { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(32), + storeBits: new TLBNumberExpr(32), + signed: false, + maxBits: 32, + }; + } else { + throw new Error("Expression not supported" + expr); + } + } else if (expr instanceof BuiltinOneArgExpr) { + if (expr.name.toString() == "##" || expr.name.toString() == "(##)") { + if (expr.arg instanceof NumberExpr) { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(expr.arg.num), + storeBits: new TLBNumberExpr(expr.arg.num), + signed: false, + maxBits: expr.arg.num, + }; + } + if (expr.arg instanceof NameExpr) { + let parameter = constructor.parametersMap.get(expr.arg.name); + if ( + !parameter || + !parameter.variable.deriveExpr || + !parameter.variable.initialExpr + ) { + throw new Error(`Couldn't handle expression ${expr}`); + } + return { + kind: "TLBNumberType", + bits: getCalculatedExpression( + parameter.variable.deriveExpr, + constructor + ), + storeBits: parameter.variable.initialExpr, + signed: false, + maxBits: undefined, + }; + } else { + throw new Error(`Couldn't handle expression ${expr}`); + } + } else if (expr.name == "#<") { + if (expr.arg instanceof NumberExpr || expr.arg instanceof NameExpr) { + let bits = new TLBUnaryOp( + new TLBBinaryOp( + getCalculatedExpression(convertToMathExpr(expr.arg), constructor), + new TLBNumberExpr(1), + "-" + ), + "." + ); + return { + kind: "TLBNumberType", + bits: bits, + storeBits: bits, + signed: false, + maxBits: 32, + }; + } else { + throw new Error(`Couldn't handle expression ${expr}`); + } + } else if (expr.name == "#<=") { + if (expr.arg instanceof NumberExpr || expr.arg instanceof NameExpr) { + let bits = new TLBUnaryOp( + getCalculatedExpression(convertToMathExpr(expr.arg), constructor), + "." + ); + return { + kind: "TLBNumberType", + bits: bits, + storeBits: bits, + signed: false, + maxBits: 32, + }; + } else { + throw new Error(`Couldn't handle expression ${expr}`); + } + } + } else if (expr instanceof CombinatorExpr) { + if ( + expr.name == "int" && + expr.args.length == 1 && + (expr.args[0] instanceof MathExpr || + expr.args[0] instanceof NumberExpr || + expr.args[0] instanceof NameExpr) + ) { + return { + kind: "TLBNumberType", + bits: getCalculatedExpression( + convertToMathExpr(expr.args[0]), + constructor + ), + storeBits: convertToMathExpr(expr.args[0]), + signed: true, + maxBits: undefined, + }; + } else if ( + expr.name == "uint" && + expr.args.length == 1 && + (expr.args[0] instanceof MathExpr || + expr.args[0] instanceof NumberExpr || + expr.args[0] instanceof NameExpr) + ) { + return { + kind: "TLBNumberType", + bits: getCalculatedExpression( + convertToMathExpr(expr.args[0]), + constructor + ), + storeBits: convertToMathExpr(expr.args[0]), + signed: false, + maxBits: undefined, + }; + } else if ( + expr.name == "bits" && + expr.args.length == 1 && + (expr.args[0] instanceof MathExpr || + expr.args[0] instanceof NumberExpr || + expr.args[0] instanceof NameExpr) + ) { + return { + kind: "TLBBitsType", + bits: getCalculatedExpression( + convertToMathExpr(expr.args[0]), + constructor + ), + }; + } else { + let argumentTypes: TLBFieldType[] = []; + expr.args.forEach((arg) => { + let thefield = getType(arg, constructor, fieldTypeName); + argumentTypes.push(thefield); + }); + return { + kind: "TLBNamedType", + name: expr.name, + arguments: argumentTypes, + }; + } + } else if (expr instanceof NameExpr) { + let theNum; + if (expr.name == "Int") { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(257), + storeBits: new TLBNumberExpr(257), + signed: true, + maxBits: 257, + }; + } else if (expr.name == "Bits") { + return { kind: "TLBBitsType", bits: new TLBNumberExpr(1023) }; + } else if (expr.name == "Bit") { + return { kind: "TLBBitsType", bits: new TLBNumberExpr(1) }; + } else if (expr.name == "Uint") { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(257), + storeBits: new TLBNumberExpr(257), + signed: false, + maxBits: 257, + }; + } else if (expr.name == "Any" || expr.name == "Cell") { + return { kind: "TLBCellType" }; + } else if ((theNum = splitForTypeValue(expr.name, "int")) != undefined) { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(theNum), + storeBits: new TLBNumberExpr(theNum), + signed: true, + maxBits: theNum, + }; + } else if ((theNum = splitForTypeValue(expr.name, "uint")) != undefined) { + return { + kind: "TLBNumberType", + bits: new TLBNumberExpr(theNum), + storeBits: new TLBNumberExpr(theNum), + signed: false, + maxBits: theNum, + }; + } else if ((theNum = splitForTypeValue(expr.name, "bits")) != undefined) { + return { kind: "TLBBitsType", bits: new TLBNumberExpr(theNum) }; + } else if (expr.name == "Bool") { + return { kind: "TLBBoolType" }; + } else if (expr.name == "MsgAddressInt") { + return { kind: "TLBAddressType" }; + } else { + if (constructor.variablesMap.get(expr.name)?.type == "#") { + return { + kind: "TLBExprMathType", + expr: getCalculatedExpression(new TLBVarExpr(expr.name), constructor), + }; + } else { + return { kind: "TLBNamedType", name: expr.name, arguments: [] }; + } + } + } else if (expr instanceof NumberExpr) { + return { kind: "TLBExprMathType", expr: new TLBNumberExpr(expr.num) }; + } else if (expr instanceof NegateExpr && expr.expr instanceof NameExpr) { + return { kind: "TLBNegatedType", variableName: expr.expr.name }; + } else if (expr instanceof CellRefExpr) { + let subExprInfo = getType(expr.expr, constructor, fieldTypeName); + return { kind: "TLBCellInsideType", value: subExprInfo }; + } else if (expr instanceof MathExpr) { + if (fieldTypeName == "") { + if (expr.op == "*") { + let subExprInfo = getType(expr.right, constructor, fieldTypeName); + return { + kind: "TLBMultipleType", + times: getCalculatedExpression( + convertToMathExpr(expr.left), + constructor + ), + value: subExprInfo, + }; + } else { + throw new Error(`Couldn't handle expression ${expr}`); + } + } else { + return { + kind: "TLBExprMathType", + expr: getCalculatedExpression(convertToMathExpr(expr), constructor), + }; + } + } else if (expr instanceof CondExpr) { + let subExprInfo = getType(expr.condExpr, constructor, fieldTypeName); + if (expr.left instanceof NameExpr) { + let condition: TLBMathExpr = getCalculatedExpression( + convertToMathExpr(expr.left), + constructor + ); + if (expr.dotExpr != null) { + condition = new TLBBinaryOp( + condition, + new TLBBinaryOp( + new TLBNumberExpr(1), + new TLBNumberExpr(expr.dotExpr), + "<<" + ), + "&" + ); + } + return { kind: "TLBCondType", value: subExprInfo, condition: condition }; + } + } else { + throw new Error(`Couldn't handle expression ${expr}`); + } + throw new Error(`Couldn't handle expression ${expr}`); +} diff --git a/src/astbuilder/utils.ts b/src/astbuilder/utils.ts new file mode 100644 index 0000000..097e22d --- /dev/null +++ b/src/astbuilder/utils.ts @@ -0,0 +1,264 @@ +import { + CompareExpr, + MathExpr, + NameExpr, + NegateExpr, + NumberExpr, + SimpleExpr, +} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import { + TLBBinaryOp, + TLBConstructorTag, + TLBField, + TLBMathExpr, + TLBNumberExpr, + TLBVarExpr, + TLBVariableType, +} from "../ast"; + + +export type TLBVariableBuild = { + isConst: boolean; + negated: boolean; + type: TLBVariableType; + name: string | undefined; + deriveExpr?: TLBMathExpr; + initialExpr?: TLBMathExpr; + isField: boolean; + + calculated: boolean; +}; +export type TLBParameterBuild = { + variable: TLBVariableBuild; + paramExpr: TLBMathExpr; + argName?: string; +}; +export type TLBConstructorBuild = { + parameters: Array; + variables: Array; + variablesMap: Map; + parametersMap: Map; + name: string; + fields: Array; + tag: TLBConstructorTag; + constraints: Array; + declaration: string; + tlbType: string; +}; +export type TLBCodeBuild = { + types: Map; +}; +export type TLBTypeBuild = { + name: string; + constructors: Array; +}; +export function opCodeSetsEqual(a: string[], b: string[]) { + if (a === b) return true; + if (a == null || b == null) return false; + if (a.length !== b.length) return false; + + a = a.sort(); + b = b.sort(); + + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) return false; + } + return true; +} +export function calculateVariable( + variable: TLBVariableBuild, + constructor: TLBConstructorBuild +) { + if (variable.calculated) { + return; + } + if (!variable.deriveExpr) { + return; + } + variable.calculated = true; + variable.deriveExpr = getCalculatedExpression( + variable.deriveExpr, + constructor + ); +} +export function getCalculatedExpression( + expr: TLBMathExpr, + constructor: TLBConstructorBuild +): TLBMathExpr { + if (expr instanceof TLBVarExpr) { + let variable = constructor.variablesMap.get(expr.x); + if (variable) { + calculateVariable(variable, constructor); + if (variable.deriveExpr) { + return variable.deriveExpr; + } + } + } + if (expr instanceof TLBBinaryOp) { + let left = getCalculatedExpression(expr.left, constructor); + let right = getCalculatedExpression(expr.right, constructor); + return new TLBBinaryOp( + left, + right, + expr.operation, + expr.variables, + expr.hasNeg + ); + } + return expr; +} +export function splitForTypeValue(name: string, typeName: string) { + if (!name.startsWith(typeName)) { + return undefined; + } + let num = parseInt(name.slice(typeName.length)); + if (num == undefined) { + return undefined; + } + if (name != typeName + num.toString()) { + return undefined; + } + return num; +} +export function deriveMathExpression( + mathExpr: MathExpr | NameExpr | NumberExpr | CompareExpr +) { + let myMathExpr = convertToMathExpr(mathExpr); + return { + name: getVariableName(myMathExpr), + derived: myMathExpr, + }; +} +export function getVariableName(myMathExpr: TLBMathExpr): string | undefined { + if (myMathExpr instanceof TLBVarExpr) { + return myMathExpr.x; + } + if (myMathExpr instanceof TLBBinaryOp) { + if (myMathExpr.left.variables.size) { + return getVariableName(myMathExpr.left); + } else { + return getVariableName(myMathExpr.right); + } + } + return undefined; +} +export function reorganizeExpression( + mathExpr: TLBMathExpr, + variable: string +): TLBMathExpr { + if (mathExpr instanceof TLBBinaryOp && mathExpr.operation == "=") { + if (mathExpr.left.variables.has(variable)) { + mathExpr = new TLBBinaryOp( + mathExpr.right, + mathExpr.left, + "=", + mathExpr.variables, + mathExpr.hasNeg + ); + } + if (mathExpr.right instanceof TLBVarExpr) { + return new TLBBinaryOp( + mathExpr.right, + mathExpr.left, + "=", + mathExpr.variables, + mathExpr.hasNeg + ); + } + let rightSide = mathExpr.right; + if (rightSide instanceof TLBBinaryOp) { + let op = ""; + if (rightSide.operation == "*") { + op = "/"; + } else if (rightSide.operation == "+") { + op = "-"; + } else { + throw new Error("invalid operation"); + } + let withVariable = undefined; + let other = undefined; + if (rightSide.left.variables.has(variable)) { + withVariable = rightSide.left; + other = rightSide.right; + } else { + other = rightSide.left; + withVariable = rightSide.right; + } + let leftSide = new TLBBinaryOp(mathExpr.left, other, op); + mathExpr = new TLBBinaryOp( + leftSide, + withVariable, + "=", + new Set([...leftSide.variables, ...withVariable.variables]), + leftSide.hasNeg || rightSide.hasNeg + ); + return reorganizeExpression(mathExpr, variable); + } + } + throw new Error(`Couldn't reogranize expression: ${mathExpr}`); +} +export function getNegatedVariable(mathExpr: TLBMathExpr): string | undefined { + if (mathExpr.hasNeg) { + if (mathExpr instanceof TLBBinaryOp) { + if (mathExpr.left.hasNeg) { + return getNegatedVariable(mathExpr.left); + } + if (mathExpr.right.hasNeg) { + return getNegatedVariable(mathExpr.right); + } + } + if (mathExpr instanceof TLBVarExpr) { + return mathExpr.x; + } + } + return undefined; +} +export function convertToMathExpr( + mathExpr: SimpleExpr | NameExpr | NumberExpr | CompareExpr, + negated: boolean = false +): TLBMathExpr { + if (mathExpr instanceof NameExpr) { + let variables = new Set(); + variables.add(mathExpr.name); + return new TLBVarExpr(mathExpr.name, variables, negated); + } + if (mathExpr instanceof NumberExpr) { + return new TLBNumberExpr(mathExpr.num, new Set(), false); + } + if (mathExpr instanceof MathExpr) { + let left = convertToMathExpr(mathExpr.left, negated); + let right = convertToMathExpr(mathExpr.right, negated); + return new TLBBinaryOp(left, right, mathExpr.op); + } + if (mathExpr instanceof CompareExpr) { + let left = convertToMathExpr(mathExpr.left, negated); + let right = convertToMathExpr(mathExpr.right, negated); + let operation: string = mathExpr.op; + return new TLBBinaryOp(left, right, operation); + } + if (mathExpr instanceof NegateExpr) { + if ( + mathExpr.expr instanceof MathExpr || + mathExpr.expr instanceof NameExpr || + mathExpr.expr instanceof NumberExpr + ) { + let expression = convertToMathExpr(mathExpr.expr, true); + if (expression instanceof TLBBinaryOp) { + return new TLBBinaryOp( + expression.left, + expression.right, + expression.operation, + expression.variables, + true + ); + } + if (expression instanceof TLBVarExpr) { + return new TLBVarExpr(expression.x, expression.variables, true); + } + if (expression instanceof TLBNumberExpr) { + return new TLBNumberExpr(expression.n, expression.variables, true); + } + } + } + throw new Error(`Could not convert expression: ${mathExpr}`); +} diff --git a/src/generators/CodeBuilder.ts b/src/generators/CodeBuilder.ts new file mode 100644 index 0000000..c52ff16 --- /dev/null +++ b/src/generators/CodeBuilder.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) Whales Corp. + * All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export class CodeBuilder { + tabLevel = 0 + code = '' + + tab() { + this.tabLevel++ + } + + unTab() { + this.tabLevel-- + } + + inTab(callback: () => void) { + this.tab(); + callback() + this.unTab(); + } + + add(text?: string, moveLine = true) { + if (!text) { + this.code += '\n' + return + } + + let tab = ' '.repeat(this.tabLevel * 4) + this.code += tab + text + (moveLine ? '\n' : '') + } + + addMultiline(text: string, inline = false) { + let lines = text.split('\n') + let i = 0 + for (let line of lines) { + if (line === '\n' && lines.indexOf(line) === lines.length - 1) { + continue + } + if (inline && i === 0) { + this.code += line + '\n' + } else { + this.add(line) + } + i++ + } + } + + append(code: CodeBuilder) { + this.addMultiline(code.render()) + } + + appendInline(code: CodeBuilder) { + this.addMultiline(code.render(), true) + } + + render() { + return this.code + } +} \ No newline at end of file diff --git a/src/generators/generator.ts b/src/generators/generator.ts new file mode 100644 index 0000000..c9e29af --- /dev/null +++ b/src/generators/generator.ts @@ -0,0 +1,17 @@ +import { TLBCode, TLBType } from "../ast" +import { CodeBuilder } from "./CodeBuilder" +import { GenDeclaration as TSGenDeclaration, TheNode } from "./typescript/tsgen" + +export interface CodeGenerator { + jsCodeDeclarations: CommonGenDeclaration[] + jsCodeConstructorDeclarations: CommonGenDeclaration[] + jsCodeFunctionsDeclarations: CommonGenDeclaration[] + tlbCode: TLBCode + + addTonCoreClassUsage(name: string): void + addBitLenFunction(): void + addTlbType(tlbType: TLBType): void + toCode(node: TheNode, code: CodeBuilder): CodeBuilder +} + +export type CommonGenDeclaration = TSGenDeclaration; \ No newline at end of file diff --git a/src/generators/typescript/complex_expr.ts b/src/generators/typescript/complex_expr.ts new file mode 100644 index 0000000..7d6a08f --- /dev/null +++ b/src/generators/typescript/complex_expr.ts @@ -0,0 +1,332 @@ +import { TLBCode, TLBConstructorTag, TLBField } from "../../ast"; +import { findNotReservedName, firstLower, getCurrentSlice } from "../../utils"; +import { ConstructorContext } from "./generator"; +import { BinaryExpression, Expression, GenDeclaration, Identifier, Statement, TypeExpression, TypeParametersExpression, TypedIdentifier, id, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tDeclareVariable, tExpressionStatement, tForCycle, tFunctionCall, tFunctionDeclaration, tIfStatement, tMemberExpression, tMultiStatement, tNumericLiteral, tReturnStatement, tStringLiteral, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, toCode } from "./tsgen"; +import { ExprForParam, getNegationDerivationFunctionBody } from "./utils"; + +export function tEqualExpression(left: Expression, right: Expression) { + return tBinaryExpression(left, '==', right) +} +export function storeTagExpression(tag: TLBConstructorTag): Statement { + return tExpressionStatement( + tFunctionCall(tMemberExpression(id("builder"), id("storeUint")), [ + id(tag.binary), + tNumericLiteral(tag.bitLen), + ]) + ); +}export function storeFunctionStmt(statements: Statement[]): Statement { + return tReturnStatement( + tArrowFunctionExpression( + [tTypedIdentifier(id("builder"), id("Builder"))], + statements + ) + ); +} +export function checkKindStmt(variableCombinatorName: string, constructorTypeName: string, storeStatement: Statement): Statement { + return tIfStatement( + tEqualExpression( + tMemberExpression(id(variableCombinatorName), id("kind")), + tStringLiteral(constructorTypeName) + ), + [storeStatement] + ); +} +export function bitlenFunctionDecl(): GenDeclaration { + return tFunctionDeclaration( + id("bitLen"), + tTypeParametersExpression([]), + null, + [tTypedIdentifier(id("n"), id("number"))], + [tExpressionStatement(id("return n.toString(2).length;"))] + ); +} +export function typedSlice() { + return [tTypedIdentifier(id("slice"), id("Slice"))]; +} +export function sliceLoad(slicePrefix: number[], currentSlice: string) { + return tExpressionStatement( + tDeclareVariable( + id(getCurrentSlice(slicePrefix, "slice")), + tFunctionCall( + tMemberExpression( + tFunctionCall(tMemberExpression(id(currentSlice), id("loadRef")), []), + id("beginParse") + ), + [] + ) + ) + ); +} +export function simpleCycle(varName: string, finish: Expression): Statement { + return tForCycle( + tDeclareVariable(id(varName), tNumericLiteral(0)), + tBinaryExpression(id(varName), "<", finish), + tNumericLiteral(5), + [] + ); +} +export function storeFunctionParam(varName: string): TypedIdentifier { + return tTypedIdentifier( + id("store" + varName), + tArrowFunctionType( + [ + tTypedIdentifier( + id(firstLower(varName)), + id(varName) + ), + ], + tArrowFunctionType( + [tTypedIdentifier(id("builder"), id("Builder"))], + id("void") + ) + ) + ); +} +export function loadFunctionParam(varName: string): TypedIdentifier { + return tTypedIdentifier( + id("load" + varName), + tArrowFunctionType(typedSlice(), id(varName)) + ); +} +export function skipTagStmt(bitLen: number): Statement { + return tExpressionStatement( + tFunctionCall(tMemberExpression(id("slice"), id("loadUint")), [ + tNumericLiteral(bitLen), + ]) + ); +} +export function checkTagExpr(tag: TLBConstructorTag): BinaryExpression { + return tEqualExpression( + tFunctionCall(tMemberExpression(id("slice"), id("preloadUint")), [ + tNumericLiteral(tag.bitLen), + ]), + id(tag.binary) + ); +} +export function checkHasBitsForTag(bitLen: number): BinaryExpression { + return tBinaryExpression( + tMemberExpression(id("slice"), id("remainingBits")), + ">=", + tNumericLiteral(bitLen) + ); +} +export function storeFunctionExpr(typeParamExpr: TypeExpression, storeExpr2: Statement): Expression | undefined { + return tArrowFunctionExpression( + [tTypedIdentifier(id("arg"), typeParamExpr)], + [ + tReturnStatement( + tArrowFunctionExpression( + [tTypedIdentifier(id("builder"), id("Builder"))], + [storeExpr2] + ) + ), + ] + ); +} +export function coverFuncCall(loadExpr: Expression): Expression { + return loadExpr.type == "FunctionCall" ? tArrowFunctionExpression(typedSlice(), [ + tReturnStatement(loadExpr), + ]) : loadExpr; +} +export function storeExprForParam(theCell: string, exprForParam: ExprForParam, insideStoreParameters: Expression[]): Statement { + return tExpressionStatement( + tFunctionCall( + tMemberExpression( + id(theCell), + id("store" + exprForParam.fieldStoreSuffix) + ), + insideStoreParameters + ) + ); +} +export function returnSliceFunc(): Expression { + return tArrowFunctionExpression(typedSlice(), [ + tReturnStatement(id("slice")), + ]); +} +export function loadExprForParam(currentSlice: string, exprForParam: ExprForParam): Expression { + return tFunctionCall( + tMemberExpression( + id(currentSlice), + id("load" + exprForParam.fieldLoadSuffix) + ), + exprForParam.argLoadExpr ? [exprForParam.argLoadExpr] : [] + ); +} +export function storeCombinator( + typeName: string, + insideStoreParameters: Expression[], + storeFunctionsArray: Expression[], + currentTypeParameters: TypeParametersExpression, + theCell: string +): Statement { + return tExpressionStatement( + tFunctionCall( + tFunctionCall( + id("store" + typeName), + insideStoreParameters.concat(storeFunctionsArray), + currentTypeParameters + ), + [id(theCell)] + ) + ); +} +export function storeInNewCell(currentCell: string, storeExpr: Statement): Statement { + return tMultiStatement([ + tExpressionStatement( + tDeclareVariable(id(currentCell), tFunctionCall(id("beginCell"), [])) + ), + storeExpr, + tExpressionStatement( + tFunctionCall(tMemberExpression(id("builder"), id("storeRef")), [ + id(currentCell), + ]) + ), + ]); +} +export function loadFromNewSlice(loadExpr: Expression): Expression { + return tArrowFunctionExpression(typedSlice(), [ + sliceLoad([1, 0], "slice"), + tReturnStatement(loadExpr), + ]); +} +export function arrayedType(typeParamExpr: TypeExpression): TypeExpression { + return tTypeWithParameters( + id("Array"), + tTypeParametersExpression([typeParamExpr]) + ); +} +export function storeTupleStmt( + currentParam: Expression, + storeExpr: Statement, + typeParamExpr: TypeExpression +): Statement { + return tExpressionStatement( + tFunctionCall(tMemberExpression(currentParam, id("forEach")), [ + tArrowFunctionExpression( + [tTypedIdentifier(id("arg"), typeParamExpr)], + [storeExpr] + ), + ]) + ); +} +export function loadTupleExpr( + arrayLength: Expression, + loadExpr: Expression +): Expression { + return tFunctionCall( + tMemberExpression( + tFunctionCall(tMemberExpression(id("Array"), id("from")), [ + tFunctionCall( + tMemberExpression( + tFunctionCall(id("Array"), [arrayLength]), + id("keys") + ), + [] + ), + ]), + id("map") + ), + [ + tArrowFunctionExpression( + [tTypedIdentifier(id("arg"), id("number"))], + [tReturnStatement(loadExpr)] + ), + ] + ); +} +export function storeExprCond( + currentParam: Expression, + storeExpr: Statement +): Statement { + return tIfStatement(tBinaryExpression(currentParam, "!=", id("undefined")), [ + storeExpr, + ]); +} +export function storeExpressionNamedType( + typeName: string, + insideStoreParameters: Expression[], + currentCell: string +): Statement { + return tExpressionStatement( + tFunctionCall( + tFunctionCall(id("store" + typeName), insideStoreParameters), + [id(currentCell)] + ) + ); +} +export function storeRefObjectStmt( + currentCell: string, + ctx: ConstructorContext, + field: TLBField +): Statement { + return tExpressionStatement( + tFunctionCall(tMemberExpression(id(currentCell), id("storeRef")), [ + tMemberExpression(id(ctx.typeName), id(field.name)), + ]) + ); +} +export function loadRefStmt(slicePrefix: number[], currentSlice: string): Statement { + return tExpressionStatement( + tDeclareVariable( + id(getCurrentSlice(slicePrefix, "cell")), + tFunctionCall(tMemberExpression(id(currentSlice), id("loadRef")), []) + ) + ); +} +export function storeRefStmt(slicePrefix: number[], currentCell: string): Statement { + return tExpressionStatement( + tFunctionCall(tMemberExpression(id(currentCell), id("storeRef")), [ + id(getCurrentSlice(slicePrefix, "cell")), + ]) + ); +} +export function newCellStmt(slicePrefix: number[]): Statement { + return tExpressionStatement( + tDeclareVariable( + id(getCurrentSlice(slicePrefix, "cell")), + tFunctionCall(id("beginCell"), []) + ) + ); +} +export function checkConstraintStmt( + constraintAST: Expression, + exceptionCommentLastPart: string +): Statement { + return tIfStatement(tUnaryOpExpression("!", constraintAST), [ + tExpressionStatement( + id( + "throw new Error('Condition " + + toCode(constraintAST).code + + exceptionCommentLastPart + + "')" + ) + ), + ]); +} +export function inSeparateRef(slicePrefix: Array, callback: any) { + slicePrefix[slicePrefix.length - 1]++; + slicePrefix.push(0); + callback(); + slicePrefix.pop(); +} +export function negationDerivationFuncDecl( + tlbCode: TLBCode, + getParameterFunctionId: Identifier, + fieldName: string, + fieldTypeName: string, + argIndex: number +): GenDeclaration { + return tFunctionDeclaration( + getParameterFunctionId, + tTypeParametersExpression([]), + id("number"), + [tTypedIdentifier(id(findNotReservedName(fieldName)), id(fieldTypeName))], + getNegationDerivationFunctionBody( + tlbCode, + fieldTypeName, + argIndex, + fieldName + ) + ); +} diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts new file mode 100644 index 0000000..b8d0581 --- /dev/null +++ b/src/generators/typescript/generator.ts @@ -0,0 +1,969 @@ +import { + TLBCode, + TLBConstructor, + TLBField, + TLBFieldType, + TLBMathExpr, + TLBType, + TLBVariable, +} from "../../ast"; +import { + findNotReservedName, + firstLower, + getCurrentSlice, + getSubStructName, +} from "../../utils"; +import { CodeBuilder } from "../CodeBuilder"; +import { CodeGenerator } from "../generator"; +import { + arrayedType, + bitlenFunctionDecl, + checkConstraintStmt, + checkHasBitsForTag, + checkKindStmt, + checkTagExpr, + coverFuncCall, + inSeparateRef, + loadExprForParam, + loadFromNewSlice, + loadFunctionParam, + loadRefStmt, + loadTupleExpr, + negationDerivationFuncDecl, + newCellStmt, + returnSliceFunc, + skipTagStmt, + sliceLoad, + storeCombinator, + storeExprCond, + storeExprForParam, + storeExpressionNamedType, + storeFunctionExpr, + storeFunctionParam, + storeFunctionStmt, + storeInNewCell, + storeRefObjectStmt, + storeRefStmt, + storeTagExpression, + storeTupleStmt, + tEqualExpression, + typedSlice, +} from "./complex_expr"; +import { + BinaryExpression, + Expression, + GenDeclaration, + ObjectProperty, + Statement, + StructDeclaration, + TheNode, + TypeExpression, + TypeParametersExpression, + TypedIdentifier, + id, + tComment, + tExpressionStatement, + tFunctionCall, + tFunctionDeclaration, + tIfStatement, + tImportDeclaration, + tMemberExpression, + tObjectExpression, + tObjectProperty, + tReturnStatement, + tStringLiteral, + tStructDeclaration, + tTernaryExpression, + tTypeParametersExpression, + tTypeWithParameters, + tTypedIdentifier, + tUnionTypeDeclaration, + tUnionTypeExpression, + toCode, +} from "./tsgen"; +import { + ExprForParam, + FieldInfoType, + addLoadProperty, + convertToAST, + getCondition, + getParamVarExpr, + getTypeParametersExpression, + isBigInt, +} from "./utils"; + +/* + +Example for variables location in generated code: + +// bool_false$0 a:# b:(## 7) c:# = TwoConstructors; + +// bool_true$1 b:# = TwoConstructors; + + + +//---------------------------------------------------- + +//----------------------------------------- +export type TwoConstructors ------ = TwoConstructors_bool_false ------ | TwoConstructors_bool_true ------; + +//---------------------------- + +export interface TwoConstructors_bool_false ------ { + //--------------------------------------------------- + readonly kind: 'TwoConstructors_bool_false'; + readonly a: number; + readonly b: number; + readonly c: number; + //-------------------------------------------------- +} + +export interface TwoConstructors_bool_true ------ { + //--------------------------------------------------- + readonly kind: 'TwoConstructors_bool_true'; + readonly b: number; + //-------------------------------------------------- +} +//--------------------------- +//---------------------------------------- + +//------------------------------------------- +export function loadTwoConstructors(slice: Slice): TwoConstructors { + //---------------------------------- + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + //------------------------------------------- + slice.loadUint(1); + let a: number = slice.loadUint(32); + let b: number = slice.loadUint(7); + let c: number = slice.loadUint(32); + return { + //--------------------------------------- + kind: 'TwoConstructors_bool_false', + a: a, + b: b, + c: c, + //-------------------------------------- + } + //------------------------------------------ + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + //------------------------------------------- + slice.loadUint(1); + let b: number = slice.loadUint(32); + return { + //--------------------------------------- + kind: 'TwoConstructors_bool_true', + b: b, + //-------------------------------------- + + } + //------------------------------------------ + + + } + throw new Error('Expected one of "TwoConstructors_bool_false", "TwoConstructors_bool_true" in loading "TwoConstructors", but data does not satisfy any constructor'); + //--------------------------------- +} + + +export function storeTwoConstructors(twoConstructors: TwoConstructors): (builder: Builder) => void { + //--------------------------------- + if ((twoConstructors.kind == 'TwoConstructors_bool_false')) { + return ((builder: Builder) => { + //-------------------------------------- + builder.storeUint(0b0, 1); + builder.storeUint(twoConstructors.a, 32); + builder.storeUint(twoConstructors.b, 7); + builder.storeUint(twoConstructors.c, 32); + //------------------------------------- + }) + + } + if ((twoConstructors.kind == 'TwoConstructors_bool_true')) { + return ((builder: Builder) => { + //-------------------------------------- + builder.storeUint(0b1, 1); + builder.storeUint(twoConstructors.b, 32); + //------------------------------------- + }) + + } + throw new Error('Expected one of "TwoConstructors_bool_false", "TwoConstructors_bool_true" in loading "TwoConstructors", but data does not satisfy any constructor'); + //-------------------------------- +} + +//------------------------------------------ + +//--------------------------------------------------- + + +*/ + + + +export type ConstructorContext = { + constructor: TLBConstructor; + loadStatements: Statement[]; + storeStatements: Statement[]; + properties: TypedIdentifier[]; + loadProperties: ObjectProperty[]; + typeName: string; + name: string; +}; + +export class TypescriptGenerator implements CodeGenerator { + jsCodeDeclarations: GenDeclaration[] = []; + jsCodeConstructorDeclarations: GenDeclaration[] = []; + jsCodeFunctionsDeclarations: GenDeclaration[] = []; + tlbCode: TLBCode; + + constructor(tlbCode: TLBCode) { + this.tlbCode = tlbCode; + } + + addTonCoreClassUsage(name: string) { + this.jsCodeDeclarations.push( + tImportDeclaration(id(name), tStringLiteral("ton")) + ); + } + addBitLenFunction() { + this.jsCodeDeclarations.push(bitlenFunctionDecl()); + } + addTlbType(tlbType: TLBType): void { + let typeName = findNotReservedName( + firstLower(tlbType.name), + "0" + ); + let typeUnion: TypeExpression[] = []; + let constructorsDeclarations: StructDeclaration[] = []; + + let loadStatements: Statement[] = []; + let storeStatements: Statement[] = []; + + let structTypeParametersExpr: TypeParametersExpression = + tTypeParametersExpression([]); + + tlbType.constructors.forEach((constructor) => { + let constructorTypeName: string = getSubStructName(tlbType, constructor); + + let ctx: ConstructorContext = { + constructor: constructor, + name: findNotReservedName( + firstLower(constructorTypeName), + "_" + constructor.name + ), + typeName: typeName, + loadStatements: [], + loadProperties: [ + tObjectProperty(id("kind"), tStringLiteral(constructorTypeName)), + ], + properties: [ + tTypedIdentifier(id("kind"), tStringLiteral(constructorTypeName)), + ], + storeStatements: [], + }; + + structTypeParametersExpr = getTypeParametersExpression( + constructor.parameters + ); + + let slicePrefix: number[] = [0]; + + constructor.variables.forEach((variable) => { + this.addVarToConstructorLoadProperty(variable, ctx, constructor); + }); + + constructor.fields.forEach((field) => { + this.handleField(field, slicePrefix, ctx); + }); + + typeUnion.push( + tTypeWithParameters(id(constructorTypeName), structTypeParametersExpr) + ); + + let structX = tStructDeclaration( + id(constructorTypeName), + ctx.properties, + structTypeParametersExpr + ); + + constructor.constraints.forEach((constraint) => { + this.genCodeForConstraint( + constraint, + typeName, + tlbType, + ctx + ); + }); + + ctx.loadStatements.push( + tReturnStatement(tObjectExpression(ctx.loadProperties)) + ); + loadStatements = this.constructorStmtsToTypeStmts( + constructor, + tlbType, + ctx, + loadStatements + ); + + if (constructor.tag.bitLen != 0) { + ctx.storeStatements.splice( + 0, + 0, + storeTagExpression(constructor.tag) + ); + } + + let storeStatement: Statement = storeFunctionStmt( + ctx.storeStatements + ); + + if (tlbType.constructors.length > 1) { + storeStatement = checkKindStmt( + typeName, + constructorTypeName, + storeStatement + ); + } + storeStatements.push(storeStatement); + + constructorsDeclarations.push(structX); + + this.jsCodeFunctionsDeclarations.push(tComment(constructor.declaration)); + }); + + this.addExceptionStmts(tlbType, loadStatements, storeStatements); + + let loadFunctionParameters = typedSlice(); + const currentType = tTypeWithParameters( + id(tlbType.name), + structTypeParametersExpr + ); + let storeFunctionParameters = [ + tTypedIdentifier(id(typeName), currentType), + ]; + + this.addFunctionParameters( + tlbType, + loadFunctionParameters, + storeFunctionParameters + ); + + let loadFunction = tFunctionDeclaration( + id("load" + tlbType.name), + structTypeParametersExpr, + currentType, + loadFunctionParameters, + loadStatements + ); + + let storeFunction = tFunctionDeclaration( + id("store" + tlbType.name), + structTypeParametersExpr, + id("(builder: Builder) => void"), + storeFunctionParameters, + storeStatements + ); + + if (tlbType.constructors.length > 1) { + this.jsCodeConstructorDeclarations.push( + tUnionTypeDeclaration(currentType, tUnionTypeExpression(typeUnion)) + ); + } + constructorsDeclarations.forEach((element) => { + this.jsCodeConstructorDeclarations.push(element); + }); + + this.jsCodeFunctionsDeclarations.push(loadFunction); + this.jsCodeFunctionsDeclarations.push(storeFunction); + } + + private addFunctionParameters( + tlbType: TLBType, + loadFunctionParameters: TypedIdentifier[], + storeFunctionParameters: TypedIdentifier[] + ) { + let anyConstructor = tlbType.constructors[0]; + if (anyConstructor) { + anyConstructor.parameters.forEach((element) => { + if (element.variable.type == "Type") { + loadFunctionParameters.push(loadFunctionParam(element.variable.name)); + + storeFunctionParameters.push( + storeFunctionParam(element.variable.name) + ); + } + if (element.variable.type == "#" && !element.variable.negated) { + if (element.argName) { + loadFunctionParameters.push( + tTypedIdentifier(id(element.argName), id("number")) + ); + } else { + loadFunctionParameters.push( + tTypedIdentifier(id(element.variable.name), id("number")) + ); + } + } + }); + } else { + throw new Error( + `Type ${tlbType.name} should have at least one constructor` + ); + } + } + + private addExceptionStmts( + tlbType: TLBType, + loadStatements: Statement[], + storeStatements: Statement[] + ) { + let exceptionTypesComment = tlbType.constructors + .map((constructor) => { + return `"${getSubStructName(tlbType, constructor)}"`; + }) + .join(", "); + let exceptionComment = tExpressionStatement( + id( + "throw new Error('" + + `Expected one of ${exceptionTypesComment} in loading "${tlbType.name}", but data does not satisfy any constructor` + + "')" + ) + ); + if ( + tlbType.constructors.length > 1 || + tlbType.constructors.at(0)?.tag.bitLen != 0 + ) { + loadStatements.push(exceptionComment); + } + if (tlbType.constructors.length > 1) { + storeStatements.push(exceptionComment); + } + } + + private constructorStmtsToTypeStmts( + constructor: TLBConstructor, + tlbType: TLBType, + ctx: ConstructorContext, + loadStatements: Statement[] + ) { + if (constructor.tag.bitLen != 0 || tlbType.constructors.length > 1) { + let conditions: Array = []; + if (constructor.tag.bitLen != 0) { + conditions.push(checkHasBitsForTag(constructor.tag.bitLen)); + conditions.push(checkTagExpr(constructor.tag)); + let loadBitsStatement: Statement[] = [ + skipTagStmt(constructor.tag.bitLen), + ]; + ctx.loadStatements = loadBitsStatement.concat( + ctx.loadStatements + ); + } + constructor.parameters.forEach((param) => { + if (param.variable.isConst && !param.variable.negated) { + let argName = param.variable.name; + if (param.argName) { + argName = param.argName; + } + conditions.push( + tEqualExpression(id(argName), getParamVarExpr(param, constructor)) + ); + } + }); + loadStatements.push( + tIfStatement(getCondition(conditions), ctx.loadStatements) + ); + } else { + loadStatements = loadStatements.concat(ctx.loadStatements); + } + return loadStatements; + } + + private genCodeForConstraint( + constraint: TLBMathExpr, + variableCombinatorName: string, + tlbType: TLBType, + ctx: ConstructorContext + ) { + let loadConstraintAST = convertToAST(constraint, ctx.constructor); + let storeConstraintAST = convertToAST( + constraint, + ctx.constructor, + id(variableCombinatorName) + ); + let exceptionCommentLastPart = ` is not satisfied while loading "${getSubStructName( + tlbType, + ctx.constructor + )}" for type "${tlbType.name}"`; + ctx.loadStatements.push( + checkConstraintStmt(loadConstraintAST, exceptionCommentLastPart) + ); + ctx.storeStatements.push( + checkConstraintStmt(storeConstraintAST, exceptionCommentLastPart) + ); + } + + private addVarToConstructorLoadProperty( + variable: TLBVariable, + ctx: ConstructorContext, + constructor: TLBConstructor + ) { + let varExpr = undefined; + + if (variable.negated) { + if (variable.deriveExpr) { + varExpr = convertToAST(variable.deriveExpr, constructor); + } + } + + if (variable.type == "#" && !variable.isField) { + ctx.properties.push( + tTypedIdentifier(id(variable.name), id("number")) + ); + let parameter = constructor.parametersMap.get(variable.name); + if ( + parameter && + !parameter.variable.isConst && + !parameter.variable.negated + ) { + varExpr = getParamVarExpr(parameter, constructor); + } + } + + if (varExpr) { + ctx.loadProperties.push( + tObjectProperty(id(variable.name), varExpr) + ); + } + } + + toCode(node: TheNode, code: CodeBuilder = new CodeBuilder()): CodeBuilder { + return toCode(node, code); + } + + handleField( + field: TLBField, + slicePrefix: Array, + ctx: ConstructorContext + ) { + let currentSlice = getCurrentSlice(slicePrefix, "slice"); + let currentCell = getCurrentSlice(slicePrefix, "cell"); + + if (field.subFields.length > 0) { + inSeparateRef(slicePrefix, () => { + ctx.loadStatements.push( + sliceLoad(slicePrefix, currentSlice) + ); + ctx.storeStatements.push(newCellStmt(slicePrefix)); + + field.subFields.forEach((fieldDef) => { + this.handleField(fieldDef, slicePrefix, ctx); + }); + + ctx.storeStatements.push( + storeRefStmt(slicePrefix, currentCell) + ); + }); + } + + if (field.fieldType.kind == "TLBExoticType") { + inSeparateRef(slicePrefix, () => { + ctx.loadStatements.push( + loadRefStmt(slicePrefix, currentSlice) + ); + addLoadProperty( + field.name, + id(getCurrentSlice(slicePrefix, "cell")), + undefined, + ctx + ); + ctx.properties.push( + tTypedIdentifier(id(field.name), id("Cell")) + ); + ctx.storeStatements.push( + storeRefObjectStmt(currentCell, ctx, field) + ); + }); + } else if (field.subFields.length == 0) { + if (field == undefined) { + throw new Error(""); + } + let fieldInfo = this.handleType( + field, + field.fieldType, + true, + ctx, + slicePrefix, + 0 + ); + if (fieldInfo.loadExpr) { + addLoadProperty( + field.name, + fieldInfo.loadExpr, + fieldInfo.typeParamExpr, + ctx + ); + } + if (fieldInfo.typeParamExpr) { + ctx.properties.push( + tTypedIdentifier(id(field.name), fieldInfo.typeParamExpr) + ); + } + if (fieldInfo.storeStmtOutside) { + ctx.storeStatements.push(fieldInfo.storeStmtOutside); + } + fieldInfo.negatedVariablesLoads.forEach((element) => { + addLoadProperty(element.name, element.expression, undefined, ctx); + }); + } + } + + handleType( + field: TLBField, + fieldType: TLBFieldType, + isField: boolean, + ctx: ConstructorContext, + slicePrefix: Array, + argIndex: number + ): FieldInfoType { + let currentSlice = getCurrentSlice(slicePrefix, "slice"); + let currentCell = getCurrentSlice(slicePrefix, "cell"); + + let fieldName = field.name; + let theSlice = "slice"; + let theCell = "builder"; + if (isField) { + theSlice = currentSlice; + theCell = currentCell; + } + let result: FieldInfoType = { + typeParamExpr: undefined, + loadExpr: undefined, + loadFunctionExpr: undefined, + storeStmtOutside: undefined, + storeStmtInside: undefined, + storeFunctionExpr: undefined, + negatedVariablesLoads: [], + }; + + let exprForParam: ExprForParam | undefined; + + let storeParametersOutside: Expression[]; + + storeParametersOutside = [ + tMemberExpression(id(ctx.typeName), id(fieldName)), + ]; // TODO: use only field + let storeParametersInside: Expression[] = [id("arg")]; + + if (fieldType.kind == "TLBNumberType") { + exprForParam = { + argLoadExpr: convertToAST(fieldType.bits, ctx.constructor), + argStoreExpr: convertToAST( + fieldType.storeBits, + ctx.constructor, + id(ctx.typeName) + ), + paramType: "number", + fieldLoadSuffix: fieldType.signed ? "Int" : "Uint", + fieldStoreSuffix: fieldType.signed ? "Int" : "Uint", + }; + if (isBigInt(fieldType)) { + exprForParam.fieldLoadSuffix += "Big"; + exprForParam.paramType = "bigint"; + } + } else if (fieldType.kind == "TLBBitsType") { + exprForParam = { + argLoadExpr: convertToAST(fieldType.bits, ctx.constructor), + argStoreExpr: convertToAST( + fieldType.bits, + ctx.constructor, + id(ctx.name) + ), + paramType: "BitString", + fieldLoadSuffix: "Bits", + fieldStoreSuffix: "Bits", + }; + } else if (fieldType.kind == "TLBCellType") { + exprForParam = { + argLoadExpr: id(theSlice), + argStoreExpr: id(theSlice), + paramType: "Slice", + fieldLoadSuffix: "Slice", + fieldStoreSuffix: "Slice", + }; + } else if (fieldType.kind == "TLBBoolType") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "boolean", + fieldLoadSuffix: "Boolean", + fieldStoreSuffix: "Bit", + }; + } else if (fieldType.kind == "TLBAddressType") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "Address", + fieldLoadSuffix: "Address", + fieldStoreSuffix: "Address", + }; + } else if (fieldType.kind == "TLBExprMathType") { + result.loadExpr = convertToAST(fieldType.expr, ctx.constructor); + result.storeStmtOutside = tExpressionStatement(result.loadExpr); + } else if (fieldType.kind == "TLBNegatedType") { + let getParameterFunctionId = id( + ctx.name + "_get_" + fieldType.variableName + ); + if (field.fieldType.kind == "TLBNamedType") { + let fieldTypeName = field.fieldType.name; + this.jsCodeFunctionsDeclarations.push( + negationDerivationFuncDecl( + this.tlbCode, + getParameterFunctionId, + fieldName, + fieldTypeName, + argIndex + ) + ); + } + result.negatedVariablesLoads.push({ + name: fieldType.variableName, + expression: tFunctionCall(getParameterFunctionId, [id(fieldName)]), + }); + } else if ( + fieldType.kind == "TLBNamedType" && + fieldType.arguments.length == 0 + ) { + let typeName = fieldType.name; + result.typeParamExpr = id(typeName); + if (isField) { + result.loadExpr = tFunctionCall(id("load" + typeName), [id(theSlice)]); + result.storeStmtOutside = storeExpressionNamedType( + typeName, + storeParametersOutside, + currentCell + ); + result.storeStmtInside = storeExpressionNamedType( + typeName, + storeParametersInside, + currentCell + ); + } else { + result.loadExpr = id("load" + typeName); + result.storeStmtOutside = tExpressionStatement(id("store" + typeName)); + } + } else if (fieldType.kind == "TLBCondType") { + let subExprInfo: FieldInfoType; + let conditionExpr: Expression; + subExprInfo = this.handleType( + field, + fieldType.value, + true, + ctx, + slicePrefix, + argIndex + ); + conditionExpr = convertToAST(fieldType.condition, ctx.constructor); + if (subExprInfo.typeParamExpr) { + result.typeParamExpr = tUnionTypeExpression([ + subExprInfo.typeParamExpr, + id("undefined"), + ]); + } + if (subExprInfo.loadExpr) { + result.loadExpr = tTernaryExpression( + conditionExpr, + subExprInfo.loadExpr, + id("undefined") + ); + } + let currentParamOutside = storeParametersOutside[0]; + let currentParamInside = storeParametersInside[0]; + if (currentParamOutside && currentParamInside && subExprInfo.storeStmtOutside) { + result.storeStmtOutside = storeExprCond(currentParamOutside, subExprInfo.storeStmtOutside); + result.storeStmtInside = storeExprCond(currentParamInside, subExprInfo.storeStmtOutside); + } + } else if (fieldType.kind == "TLBMultipleType") { + let arrayLength: Expression; + let subExprInfo: FieldInfoType; + arrayLength = convertToAST(fieldType.times, ctx.constructor); + subExprInfo = this.handleType( + field, + fieldType.value, + false, + ctx, + slicePrefix, + argIndex + ); + let currentParamOutside = storeParametersOutside[0]; + let currentParamInside = storeParametersInside[0]; + if (subExprInfo.loadExpr) { + result.loadExpr = loadTupleExpr(arrayLength, subExprInfo.loadExpr); + } + if ( + currentParamOutside && + currentParamInside && + subExprInfo.typeParamExpr && + subExprInfo.storeStmtOutside + ) { + if (subExprInfo.storeFunctionExpr && subExprInfo.storeStmtInside) { + result.storeStmtOutside = storeTupleStmt( + currentParamOutside, + subExprInfo.storeStmtInside, + subExprInfo.typeParamExpr + ); + result.storeStmtInside = storeTupleStmt( + currentParamInside, + subExprInfo.storeStmtInside, + subExprInfo.typeParamExpr + ); + } + } + if (subExprInfo.typeParamExpr) { + result.typeParamExpr = arrayedType(subExprInfo.typeParamExpr); + } + } else if (fieldType.kind == "TLBCellInsideType") { + let currentCell = getCurrentSlice([1, 0], "cell"); + + let subExprInfo: FieldInfoType = this.handleType( + field, + fieldType.value, + true, + ctx, + [1, 0], + argIndex + ); + if (subExprInfo.loadExpr) { + result.typeParamExpr = subExprInfo.typeParamExpr; + result.storeStmtOutside = subExprInfo.storeStmtOutside; + result.negatedVariablesLoads = subExprInfo.negatedVariablesLoads; + result.loadFunctionExpr = loadFromNewSlice(subExprInfo.loadExpr); + result.loadExpr = tFunctionCall(result.loadFunctionExpr, [ + id(theSlice), + ]); + } + if (subExprInfo.storeStmtOutside) { + result.storeStmtOutside = storeInNewCell(currentCell, subExprInfo.storeStmtOutside); + } + if (subExprInfo.storeStmtInside) { + result.storeStmtInside = storeInNewCell(currentCell, subExprInfo.storeStmtInside); + } + } else if (fieldType.kind == "TLBNamedType" && fieldType.arguments.length) { + let typeName = fieldType.name; + + let typeExpression: TypeParametersExpression = tTypeParametersExpression( + [] + ); + let loadFunctionsArray: Array = []; + let storeFunctionsArray: Array = []; + let argIndex = -1; + fieldType.arguments.forEach((arg) => { + argIndex++; + let subExprInfo = this.handleType( + field, + arg, + false, + ctx, + slicePrefix, + argIndex + ); + if (subExprInfo.typeParamExpr) { + typeExpression.typeParameters.push(subExprInfo.typeParamExpr); + } + if (subExprInfo.loadFunctionExpr) { + loadFunctionsArray.push(subExprInfo.loadFunctionExpr); + } + if (subExprInfo.storeFunctionExpr) { + storeFunctionsArray.push(subExprInfo.storeFunctionExpr); + } + result.negatedVariablesLoads = result.negatedVariablesLoads.concat( + subExprInfo.negatedVariablesLoads + ); + }); + result.typeParamExpr = tTypeWithParameters(id(typeName), typeExpression); + + let currentTypeParameters = typeExpression; + + let insideLoadParameters: Array = [id(theSlice)]; + + result.loadExpr = tFunctionCall( + id("load" + typeName), + insideLoadParameters.concat(loadFunctionsArray), + currentTypeParameters + ); + result.storeStmtOutside = storeCombinator( + typeName, + storeParametersOutside, + storeFunctionsArray, + currentTypeParameters, + theCell + ); + result.storeStmtInside = storeCombinator( + typeName, + storeParametersInside, + storeFunctionsArray, + currentTypeParameters, + theCell + ); + if (exprForParam) { + result.typeParamExpr = id(exprForParam.paramType); + } + } + + if (exprForParam) { + if ( + exprForParam.paramType != "BitString" && + exprForParam.paramType != "Slice" + ) { + if (exprForParam.argStoreExpr) { + storeParametersOutside.push(exprForParam.argStoreExpr); + storeParametersInside.push(exprForParam.argStoreExpr); + } + } + result.loadExpr = loadExprForParam(currentSlice, exprForParam); + if (exprForParam.paramType == "Slice") { + result.loadExpr = id(currentSlice); + result.loadFunctionExpr = returnSliceFunc(); + } + result.typeParamExpr = id(exprForParam.paramType); + result.storeStmtOutside = storeExprForParam( + theCell, + exprForParam, + storeParametersOutside + ); + result.storeStmtInside = storeExprForParam( + theCell, + exprForParam, + storeParametersInside + ); + } + + if (result.loadExpr && !result.loadFunctionExpr) { + result.loadFunctionExpr = coverFuncCall(result.loadExpr); + } + if (result.storeStmtOutside && !result.storeFunctionExpr) { + if (!result.storeStmtInside) { + result.storeStmtInside = result.storeStmtOutside; + } + if (result.typeParamExpr) { + if ( + (result.storeStmtOutside.type == "ExpressionStatement" && + result.storeStmtOutside.expression.type == "FunctionCall") || + result.storeStmtOutside.type == "MultiStatement" + ) { + result.storeFunctionExpr = storeFunctionExpr( + result.typeParamExpr, + result.storeStmtInside + ); + } else { + if (result.storeStmtOutside.type == "ExpressionStatement") { + result.storeFunctionExpr = result.storeStmtOutside.expression; + } + } + } + } + + result.storeStmtInside = result.storeStmtInside; + return result; + } +} diff --git a/src/generators/typescript/tsgen.ts b/src/generators/typescript/tsgen.ts new file mode 100644 index 0000000..dd45e5c --- /dev/null +++ b/src/generators/typescript/tsgen.ts @@ -0,0 +1,711 @@ +import { CodeBuilder } from "../CodeBuilder"; + +export interface ASTNode { + type: TheNode["type"]; +} + +export interface Identifier extends ASTNode { + type: "Identifier"; + name: string; +} + +export interface TypeWithParameters extends ASTNode { + type: "TypeWithParameters"; + name: Identifier; + typeParameters: TypeParametersExpression; +} + +export interface NumericLiteral extends ASTNode { + type: "NumericLiteral"; + value: number; +} + +export interface BinaryNumericLiteral extends ASTNode { + type: "BinaryNumericLiteral"; + value: number; +} + +export interface StringLiteral extends ASTNode { + type: "StringLiteral"; + value: string; +} + +export interface ImportDeclaration extends ASTNode { + type: "ImportDeclaration"; + importValue: Identifier; + from: StringLiteral; +} + +export interface FunctionDeclaration extends ASTNode { + type: "FunctionDeclaration"; + name: Identifier; + typeParameters: TypeParametersExpression; + returnType: TypeExpression | null; + parameters: Array; + body: Array; +} + +export interface TypedIdentifier extends ASTNode { + type: "TypedIdentifier"; + name: Identifier; + typeId: TypeExpression | Literal; +} + +export interface TypeParametersExpression extends ASTNode { + type: "TypeParametersExpression"; + typeParameters: Array; +} + +export interface StructDeclaration extends ASTNode { + type: "StructDeclaration"; + name: Identifier; + fields: Array; + typeParametersExpression: TypeParametersExpression; +} + +export interface UnionTypeExpression extends ASTNode { + type: "UnionTypeExpression"; + unionMembers: Array; +} + +export interface UnionTypeDeclaration extends ASTNode { + type: "UnionTypeDeclaration"; + name: TypeExpression; + union: UnionTypeExpression; +} + +export interface ObjectProperty extends ASTNode { + type: "ObjectProperty"; + key: Expression; + value: Expression; +} + +export interface ObjectExpression extends ASTNode { + type: "ObjectExpression"; + objectValues: Array; +} + +export interface FunctionCall extends ASTNode { + type: "FunctionCall"; + functionId: Expression; + parameters: Array; + typeParameters: TypeParametersExpression | undefined; +} + +export interface MemberExpression extends ASTNode { + type: "MemberExpression"; + thisObject: Expression; + memberName: Identifier; +} + +export interface ArrowFunctionType extends ASTNode { + type: "ArrowFunctionType"; + parameters: Array; + returnType: TypeExpression | null; +} + +export interface ArrowFunctionExpression extends ASTNode { + type: "ArrowFunctionExpression"; + parameters: Array; + body: Array; +} + +export interface ReturnStatement extends ASTNode { + type: "ReturnStatement"; + returnValue: Expression; +} + +export interface ExpressionStatement extends ASTNode { + type: "ExpressionStatement"; + expression: Expression; +} + +export interface IfStatement extends ASTNode { + type: "IfStatement"; + condition: Expression; + body: Array; + elseBody: Array | undefined; +} + +export interface ForCycle extends ASTNode { + type: "ForCycle"; + init: Expression; + cond: Expression; + inc: Expression; + body: Array; +} + +export interface DeclareVariable extends ASTNode { + type: "DeclareVariable"; + name: Identifier; + init: Expression | undefined; + typeName: TypeExpression | undefined; +} + +export interface UnaryOpExpression extends ASTNode { + type: "UnaryOpExpression"; + unaryOperator: string; + expr: Expression; +} + +export interface BinaryExpression extends ASTNode { + type: "BinaryExpression"; + binarySign: string; + left: Expression; + right: Expression; +} + +export interface TernaryExpression extends ASTNode { + type: "TernaryExpression"; + condition: Expression; + body: Expression; + elseBody: Expression; +} + +export interface Comment extends ASTNode { + type: "Comment"; + value: string; +} + +export interface MultiStatement extends ASTNode { + type: "MultiStatement"; + statements: Array; +} + +export type TypeExpression = + | Identifier + | TypeWithParameters + | ArrowFunctionType + | UnionTypeExpression; +export type Statement = + | ReturnStatement + | ExpressionStatement + | IfStatement + | MultiStatement + | ForCycle; +export type Literal = NumericLiteral | BinaryNumericLiteral | StringLiteral; +export type Expression = + | Identifier + | TypeExpression + | Literal + | ObjectExpression + | FunctionCall + | MemberExpression + | ArrowFunctionExpression + | BinaryExpression + | ArrowFunctionType + | TypeParametersExpression + | DeclareVariable + | TernaryExpression + | UnaryOpExpression; +export type GenDeclaration = + | ImportDeclaration + | StructDeclaration + | UnionTypeDeclaration + | FunctionDeclaration + | Comment; + +export type TheNode = + | Identifier + | GenDeclaration + | TypedIdentifier + | Expression + | ObjectProperty + | Statement; + +export function tIdentifier(name: string): Identifier { + return { type: "Identifier", name: name }; +} + +export function tStringLiteral(value: string): StringLiteral { + return { type: "StringLiteral", value: value }; +} + +export function tImportDeclaration( + importValue: Identifier, + from: StringLiteral +): ImportDeclaration { + return { type: "ImportDeclaration", importValue: importValue, from: from }; +} + +export function tFunctionDeclaration( + name: Identifier, + typeParameters: TypeParametersExpression, + returnType: TypeExpression | null, + parameters: Array, + body: Array +): FunctionDeclaration { + return { + type: "FunctionDeclaration", + name: name, + typeParameters: typeParameters, + returnType: returnType, + parameters: parameters, + body: body, + }; +} + +export function tTypedIdentifier( + name: Identifier, + typeId: TypeExpression | StringLiteral +): TypedIdentifier { + return { type: "TypedIdentifier", name: name, typeId: typeId }; +} + +export function tTypeWithParameters( + name: Identifier, + typeParameters: TypeParametersExpression +): TypeWithParameters { + return { + type: "TypeWithParameters", + name: name, + typeParameters: typeParameters, + }; +} + +export function tStructDeclaration( + name: Identifier, + fields: Array, + typeParameters: TypeParametersExpression +): StructDeclaration { + return { + type: "StructDeclaration", + name: name, + fields: fields, + typeParametersExpression: typeParameters, + }; +} + +export function tObjectProperty( + key: Expression, + value: Expression +): ObjectProperty { + return { type: "ObjectProperty", key: key, value: value }; +} + +export function tForCycle( + init: Expression, + cond: Expression, + inc: Expression, + body: Array +): ForCycle { + return { type: "ForCycle", init: init, cond: cond, inc: inc, body: body }; +} + +export function tObjectExpression( + objectValues: Array +): ObjectExpression { + return { type: "ObjectExpression", objectValues: objectValues }; +} + +export function tReturnStatement(returnValue: Expression): ReturnStatement { + return { type: "ReturnStatement", returnValue: returnValue }; +} + +export function tFunctionCall( + functionId: Expression, + parameters: Array, + typeParameters?: TypeParametersExpression +): FunctionCall { + return { + type: "FunctionCall", + functionId: functionId, + parameters: parameters, + typeParameters: typeParameters, + }; +} + +export function tMemberExpression( + thisObject: Expression, + memberName: Identifier +): MemberExpression { + return { + type: "MemberExpression", + thisObject: thisObject, + memberName: memberName, + }; +} + +export function tNumericLiteral(value: number): NumericLiteral { + return { type: "NumericLiteral", value: value }; +} + +export function tBinaryNumericLiteral(value: number): BinaryNumericLiteral { + return { type: "BinaryNumericLiteral", value: value }; +} + +export function tTypeParametersExpression( + typeParameters: Array +): TypeParametersExpression { + return { type: "TypeParametersExpression", typeParameters: typeParameters }; +} + +export function tUnionTypeExpression( + unionMembers: Array +): UnionTypeExpression { + return { type: "UnionTypeExpression", unionMembers: unionMembers }; +} + +export function tArrowFunctionExpression( + parameters: Array, + body: Array +): ArrowFunctionExpression { + return { + type: "ArrowFunctionExpression", + parameters: parameters, + body: body, + }; +} + +export function tUnionTypeDeclaration( + name: TypeExpression, + union: UnionTypeExpression +): UnionTypeDeclaration { + return { type: "UnionTypeDeclaration", name: name, union: union }; +} + +export function tExpressionStatement( + expression: Expression +): ExpressionStatement { + return { type: "ExpressionStatement", expression: expression }; +} + +export function tIfStatement( + condition: Expression, + body: Array, + elseBody?: Array +): IfStatement { + return { + type: "IfStatement", + condition: condition, + body: body, + elseBody: elseBody, + }; +} + +export function tUnaryOpExpression( + unaryOperator: string, + expr: Expression +): UnaryOpExpression { + return { + type: "UnaryOpExpression", + unaryOperator: unaryOperator, + expr: expr, + }; +} + +export function tBinaryExpression( + left: Expression, + binarySign: string, + right: Expression +): BinaryExpression { + return { + type: "BinaryExpression", + binarySign: binarySign, + left: left, + right: right, + }; +} + +export function tArrowFunctionType( + parameters: Array, + returnType: TypeExpression +): ArrowFunctionType { + return { + type: "ArrowFunctionType", + parameters: parameters, + returnType: returnType, + }; +} + +export function tDeclareVariable( + name: Identifier, + init?: Expression, + typeName?: TypeExpression +): DeclareVariable { + return { + type: "DeclareVariable", + name: name, + init: init, + typeName: typeName, + }; +} + +export function tMultiStatement(statements: Array): MultiStatement { + return { type: "MultiStatement", statements: statements }; +} + +export function tComment(value: string): Comment { + return { type: "Comment", value: value }; +} + +export function tTernaryExpression( + condition: Expression, + body: Expression, + elseBody: Expression +): TernaryExpression { + return { + type: "TernaryExpression", + condition: condition, + body: body, + elseBody: elseBody, + }; +} + +function toCodeArray( + nodeArray: Array, + code: CodeBuilder, + delimeter: string +) { + for (let i = 0; i < nodeArray.length; i++) { + let currentParam = nodeArray[i]; + if (currentParam != undefined) { + toCode(currentParam, code); + } + if (i + 1 < nodeArray.length) { + code.add(delimeter, false); + } + } + return code; +} + +export function toCode( + node: TheNode, + code: CodeBuilder = new CodeBuilder() +): CodeBuilder { + if (node.type == "Identifier") { + code.add(node.name, false); + } + + if (node.type == "NumericLiteral") { + code.add(node.value.toString(), false); + } + + if (node.type == "ImportDeclaration") { + code.add( + `import { ${toCode(node.importValue).render()} } from ${toCode( + node.from + ).render()}`, + false + ); + } + + if (node.type == "FunctionDeclaration") { + code.add( + `export function ${toCode(node.name).render()}${toCode( + node.typeParameters + ).render()}(`, + false + ); + toCodeArray(node.parameters, code, ", "); + code.add( + `)${node.returnType ? ": " + toCode(node.returnType).render() : ""} {` + ); + code.inTab(() => { + node.body.forEach((statement) => { + code.append(toCode(statement)); + }); + }); + code.add("}"); + } + + if (node.type == "ArrowFunctionExpression") { + code.add(`((`, false); + toCodeArray(node.parameters, code, ", "); + code.add(`) => {`); + code.inTab(() => { + node.body.forEach((statement) => { + code.append(toCode(statement)); + }); + }); + code.add(`})`, false); + } + + if (node.type == "ArrowFunctionType") { + code.add( + `(${toCodeArray(node.parameters, new CodeBuilder(), ", ").render()}) => ${ + node.returnType ? toCode(node.returnType).render() : "" + }`, + false + ); + } + + if (node.type == "TypeWithParameters") { + code.add( + `${toCode(node.name).render()}${toCode(node.typeParameters).render()}`, + false + ); + } + + if (node.type == "TypedIdentifier") { + code.add( + toCode(node.name).render() + ": " + toCode(node.typeId).render(), + false + ); + } + + if (node.type == "ObjectProperty") { + code.add( + toCode(node.key).render() + ": " + toCode(node.value).render(), + false + ); + } + + if (node.type == "DeclareVariable") { + code.add( + `let ${toCode(node.name).render()}${ + node.typeName ? ": " + toCode(node.typeName).render() : "" + }`, + false + ); + if (node.init) { + code.add(" = ", false); + toCode(node.init, code); + } + } + + if (node.type == "ObjectExpression") { + code.add("{"); + code.inTab(() => { + node.objectValues.forEach((objectValue) => { + code.add(toCode(objectValue).render() + ","); + }); + }); + code.add("}", false); + } + + if (node.type == "MultiStatement") { + node.statements.forEach((statement) => { + code.append(toCode(statement)); + }); + } + + if (node.type == "ReturnStatement") { + code.add(`return `, false); + code.appendInline(toCode(node.returnValue)); + } + + if (node.type == "ExpressionStatement") { + code.add(toCode(node.expression).render() + ";", false); + } + + if (node.type == "TypeParametersExpression") { + if (node.typeParameters.length > 0) { + code.add("<", false); + toCodeArray(node.typeParameters, code, ", "); + code.add(">", false); + } + } + + if (node.type == "StructDeclaration") { + code.add( + `export interface ${toCode(node.name).render()}${toCode( + node.typeParametersExpression + ).render()} {` + ); + code.inTab(() => { + node.fields.forEach((field) => { + code.add(`readonly ${toCode(field).render()};`); + }); + }); + code.add("}"); + } + + if (node.type == "UnionTypeDeclaration") { + code.add( + `export type ${toCode(node.name).render()} = ${toCode( + node.union + ).render()};` + ); + } + + if (node.type == "UnionTypeExpression") { + toCodeArray(node.unionMembers, code, " | "); + } + + if (node.type == "FunctionCall") { + code.add( + `${toCode(node.functionId).render()}${ + node.typeParameters ? toCode(node.typeParameters).render() : "" + }(`, + false + ); + toCodeArray(node.parameters, code, ", "); + code.add(`)`, false); + } + + if (node.type == "StringLiteral") { + code.add(`'${node.value}'`, false); + } + + if (node.type == "MemberExpression") { + code.add( + toCode(node.thisObject).render() + "." + toCode(node.memberName).render(), + false + ); + } + + if (node.type == "IfStatement") { + code.add(`if (${toCode(node.condition).render()}) {`); + code.inTab(() => { + node.body.forEach((statement) => { + code.append(toCode(statement)); + }); + }); + code.add("}", false); + } + + if (node.type == "ForCycle") { + code.add( + `for (${toCode(node.init).render()};${toCode( + node.cond + ).render()};${toCode(node.inc).render()}) {` + ); + code.inTab(() => { + node.body.forEach((statement) => { + code.append(toCode(statement)); + }); + }); + code.add(`}`, false); + } + + if (node.type == "UnaryOpExpression") { + code.add(`(${node.unaryOperator}${toCode(node.expr).render()})`, false); + } + + if (node.type == "BinaryExpression") { + code.add( + `(${toCode(node.left).render()} ${node.binarySign} ${toCode( + node.right + ).render()})`, + false + ); + } + + if (node.type == "TernaryExpression") { + code.add( + `(${toCode(node.condition).render()} ? ${toCode( + node.body + ).render()} : ${toCode(node.elseBody).render()})`, + false + ); + } + + if (node.type == "Comment") { + let splittedComment = node.value.split("\n"); + if (splittedComment.length == 1) { + code.add(`// ${splittedComment[0]}`); + } else { + code.add(`/*`); + splittedComment.forEach((line) => { + code.add(line); + }); + code.add(`*/`); + } + } + + return code; +} + +export let id = tIdentifier; + diff --git a/src/generators/typescript/utils.ts b/src/generators/typescript/utils.ts new file mode 100644 index 0000000..16dfda8 --- /dev/null +++ b/src/generators/typescript/utils.ts @@ -0,0 +1,228 @@ +import { + TLBBinaryOp, + TLBCode, + TLBConstructor, + TLBMathExpr, + TLBNumberExpr, + TLBNumberType, + TLBParameter, + TLBType, + TLBUnaryOp, + TLBVarExpr, +} from "../../ast"; +import { getSubStructName } from "../../utils"; +import { tEqualExpression } from "./complex_expr"; +import { ConstructorContext } from "./generator"; +import { + BinaryExpression, + Expression, + Identifier, + ObjectProperty, + Statement, + TypeExpression, + tBinaryExpression, + tDeclareVariable, + tExpressionStatement, + tFunctionCall, + id, + tIfStatement, + tMemberExpression, + tNumericLiteral, + tObjectProperty, + tReturnStatement, + tStringLiteral, + tTypeParametersExpression, + tUnaryOpExpression, +} from "./tsgen"; + +export type FieldInfoType = { + typeParamExpr: TypeExpression | undefined; + loadExpr: Expression | undefined; + loadFunctionExpr: Expression | undefined; + storeStmtOutside: Statement | undefined; + storeStmtInside: Statement | undefined; + storeFunctionExpr: Expression | undefined; + negatedVariablesLoads: Array<{ name: string; expression: Expression }>; +}; +export type ExprForParam = { + argLoadExpr: Expression | undefined; + argStoreExpr: Expression | undefined; + paramType: string; + fieldLoadSuffix: string; + fieldStoreSuffix: string; +}; + +export function getParamVarExpr( + param: TLBParameter, + constructor: TLBConstructor +): Expression { + if (param.variable.deriveExpr) { + return convertToAST(param.variable.deriveExpr, constructor); + } else { + throw new Error( + `Could not get expression for param ${param.variable.name} for constructor ${constructor.name} of type ${constructor.tlbType}` + ); + } +} + +export function getVarExprByName( + name: string, + constructor: TLBConstructor +): Expression { + let variable = constructor.variablesMap.get(name); + if (variable?.deriveExpr) { + return convertToAST(variable.deriveExpr, constructor); + } + return id(name); +} + +export function getNegationDerivationFunctionBody( + tlbCode: TLBCode, + typeName: string, + parameterIndex: number, + parameterName: string +): Statement[] { + let result: Statement[] = []; + let tlbType: TLBType | undefined = tlbCode.types.get(typeName); + if (!tlbType) { + throw new Error(`Can not find type ${typeName}`); + } + tlbType.constructors.forEach((constructor) => { + let parameter = constructor.parameters[parameterIndex]; + if (parameter) { + let getExpression: Expression; + getExpression = convertToAST(parameter.paramExpr, constructor); + let statements = []; + if (!parameter.variable.isConst) { + statements.push( + tExpressionStatement( + tDeclareVariable( + id(parameter.variable.name), + tMemberExpression(id(parameterName), id(parameter.variable.name)) + ) + ) + ); + } + statements.push(tReturnStatement(getExpression)); + if (tlbType) { + result.push( + tIfStatement( + tEqualExpression( + tMemberExpression(id(parameterName), id("kind")), + tStringLiteral(getSubStructName(tlbType, constructor)) + ), + statements + ) + ); + } + } + }); + + let exceptionTypesComment = tlbType.constructors + .map((constructor) => { + return `"${tlbType ? getSubStructName(tlbType, constructor) : ""}"`; + }) + .join(", "); + let exceptionComment = tExpressionStatement( + id( + "throw new Error('" + + `Expected one of ${exceptionTypesComment} for type "${tlbType.name}" while getting "${parameterName}", but data does not satisfy any constructor` + + "')" + ) + ); + result.push(exceptionComment); + + return result; +} + +export function addLoadProperty( + name: string, + loadExpr: Expression, + typeExpr: TypeExpression | undefined, + ctx: ConstructorContext +) { + let nameId = id(name); + ctx.loadStatements.push( + tExpressionStatement(tDeclareVariable(nameId, loadExpr, typeExpr)) + ); + ctx.loadProperties.push(tObjectProperty(nameId, nameId)); +} + +export function convertToAST( + mathExpr: TLBMathExpr, + constructor: TLBConstructor, + objectId?: Identifier +): Expression { + if (mathExpr instanceof TLBVarExpr) { + let varName = mathExpr.x; + if (objectId != undefined) { + return tMemberExpression(objectId, id(varName)); + } + return id(varName); + } + if (mathExpr instanceof TLBNumberExpr) { + return tNumericLiteral(mathExpr.n); + } + if (mathExpr instanceof TLBBinaryOp) { + let operation: string = mathExpr.operation; + if (operation == "=") { + operation = "=="; + } + return tBinaryExpression( + convertToAST(mathExpr.left, constructor, objectId), + operation, + convertToAST(mathExpr.right, constructor, objectId) + ); + } + if (mathExpr instanceof TLBUnaryOp) { + if (mathExpr.operation == ".") { + return tFunctionCall(id("bitLen"), [ + convertToAST(mathExpr.value, constructor, objectId), + ]); + } + return tUnaryOpExpression( + mathExpr.operation, + convertToAST(mathExpr.value, constructor, objectId) + ); + } + throw new Error( + `Type ${constructor.tlbType}, constructor ${constructor.name}: couldn't convert to math expression: ${mathExpr}` + ); +} + +export function getTypeParametersExpression(parameters: Array) { + let structTypeParameters: Array = []; + parameters.forEach((element) => { + if (element.variable.type == "Type") { + structTypeParameters.push(id(element.variable.name)); + } + }); + let structTypeParametersExpr = + tTypeParametersExpression(structTypeParameters); + return structTypeParametersExpr; +} + +export function getCondition(conditions: Array): Expression { + let cnd = conditions[0]; + if (cnd) { + if (conditions.length > 1) { + return tBinaryExpression(cnd, "&&", getCondition(conditions.slice(1))); + } else { + return cnd; + } + } else { + return id("true"); + } +} + +export function isBigInt(fieldType: TLBNumberType) { + if (fieldType.bits instanceof TLBNumberExpr) { + if (fieldType.bits.n <= 64) { + return false; + } + } + if (fieldType.maxBits && fieldType.maxBits <= 64) { + return false; + } + return true; +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..7360cfe --- /dev/null +++ b/src/main.ts @@ -0,0 +1,57 @@ +import { Program } from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import { TLBCode, TLBType } from "./ast"; +import { + TLBCodeBuild, + TLBTypeBuild, +} from "./astbuilder/utils"; +import { convertCodeToReadonly } from "./astbuilder/fill_constructors"; +import { fillConstructors } from "./astbuilder/fill_constructors"; +import { CodeBuilder } from "./generators/CodeBuilder"; +import { CodeGenerator, CommonGenDeclaration } from "./generators/generator"; +import { TypescriptGenerator } from "./generators/typescript/generator"; + +export function generate(tree: Program, input: string) { + let oldTlbCode: TLBCodeBuild = { types: new Map() }; + + let splittedInput = input.split("\n"); + + fillConstructors(tree.declarations, oldTlbCode, splittedInput); + let tlbCode: TLBCode = convertCodeToReadonly(oldTlbCode); + + let codeGenerator: CodeGenerator = new TypescriptGenerator(tlbCode); + + codeGenerator.addTonCoreClassUsage("Builder"); + codeGenerator.addTonCoreClassUsage("Slice"); + codeGenerator.addTonCoreClassUsage("beginCell"); + codeGenerator.addTonCoreClassUsage("BitString"); + codeGenerator.addTonCoreClassUsage("Cell"); + codeGenerator.addTonCoreClassUsage("Address"); + + codeGenerator.addBitLenFunction(); + + let jsCodeDeclarations: CommonGenDeclaration[] = []; + codeGenerator.jsCodeDeclarations.forEach((declaration) => { + jsCodeDeclarations.push(declaration); + }); + + tlbCode.types.forEach((tlbType: TLBType) => { + codeGenerator.addTlbType(tlbType); + }); + + let generatedCode = ""; + + codeGenerator.jsCodeConstructorDeclarations.forEach((element) => { + jsCodeDeclarations.push(element); + }); + + codeGenerator.jsCodeFunctionsDeclarations.forEach((element) => { + jsCodeDeclarations.push(element); + }); + + jsCodeDeclarations.forEach((element) => { + generatedCode += + codeGenerator.toCode(element, new CodeBuilder()).render() + "\n"; + }); + + return generatedCode; +} diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..2c94ba4 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,126 @@ +import { TLBConstructor, TLBType } from "./ast"; +import { TLBConstructorBuild, TLBTypeBuild } from "./astbuilder/utils"; + +export function firstLower(structName: String) { + return structName.charAt(0).toLowerCase() + structName.slice(1); +} + +export function getCurrentSlice(slicePrefix: number[], name: string): string { + let result = name; + slicePrefix = slicePrefix.slice(0, slicePrefix.length - 1); + slicePrefix.forEach((element) => { + result += element.toString(); + }); + if (result == "cell") { + return "builder"; + } + return result; +} + +export function bitLen(n: number) { + return n.toString(2).length; +} + +export function isNameReserved(name: string): boolean { + let tsReserved = [ + "abstract", + "arguments", + "await", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "double", + "else", + "enum", + "eval", + "export", + "extends", + "false", + "final", + "finally", + "float", + "for", + "function", + "goto", + "if", + "implements", + "import", + "in", + "instanceof", + "int", + "interface", + "let", + "long", + "native", + "new", + "null", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "super", + "switch", + "synchronized", + "this", + "throw", + "throws", + "transient", + "true", + "try", + "typeof", + "var", + "void", + "volatile", + "while", + "with", + "yield", + ]; + if (tsReserved.includes(name)) { + return true; + } + if (name.startsWith("slice")) { + return true; + } + if (name.startsWith("cell")) { + return true; + } + if (name == "builder") { + return true; + } + return false; +} +export function findNotReservedName( + name: string, + possibleSuffix: string = "0" +): string { + if (name.startsWith("slice") || name.startsWith("cell")) { + name = "_" + name; + } + while (isNameReserved(name)) { + name += possibleSuffix; + } + return name; +} +export function getSubStructName( + tlbType: TLBType | TLBTypeBuild, + constructor: TLBConstructorBuild | TLBConstructor +): string { + if (tlbType.constructors.length > 1) { + return tlbType.name + "_" + constructor.name; + } else { + return tlbType.name; + } +} diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts new file mode 100644 index 0000000..5575016 --- /dev/null +++ b/test/generated_files/generated_block.ts @@ -0,0 +1,13300 @@ +import { Builder } from 'ton' +import { Slice } from 'ton' +import { beginCell } from 'ton' +import { BitString } from 'ton' +import { Cell } from 'ton' +import { Address } from 'ton' +export function bitLen(n: number) { + return n.toString(2).length;; +} + +export interface Unit { + readonly kind: 'Unit'; +} + +export interface True { + readonly kind: 'True'; +} + +export interface BoolFalse { + readonly kind: 'BoolFalse'; +} + +export interface BoolTrue { + readonly kind: 'BoolTrue'; +} + +export type Maybe = Maybe_nothing | Maybe_just; + +export interface Maybe_nothing { + readonly kind: 'Maybe_nothing'; +} + +export interface Maybe_just { + readonly kind: 'Maybe_just'; + readonly value: X; +} + +export type Either = Either_left | Either_right; + +export interface Either_left { + readonly kind: 'Either_left'; + readonly value: X; +} + +export interface Either_right { + readonly kind: 'Either_right'; + readonly value: Y; +} + +export interface Both { + readonly kind: 'Both'; + readonly first: X; + readonly second: Y; +} + +export interface Bit { + readonly kind: 'Bit'; + readonly anon0: number; +} + +export interface Hashmap { + readonly kind: 'Hashmap'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: HashmapNode; +} + +export type HashmapNode = HashmapNode_hmn_leaf | HashmapNode_hmn_fork; + +export interface HashmapNode_hmn_leaf { + readonly kind: 'HashmapNode_hmn_leaf'; + readonly value: X; +} + +export interface HashmapNode_hmn_fork { + readonly kind: 'HashmapNode_hmn_fork'; + readonly n: number; + readonly left: Hashmap; + readonly right: Hashmap; +} + +export type HmLabel = HmLabel_hml_short | HmLabel_hml_long | HmLabel_hml_same; + +export interface HmLabel_hml_short { + readonly kind: 'HmLabel_hml_short'; + readonly m: number; + readonly n: number; + readonly len: Unary; + readonly s: Array; +} + +export interface HmLabel_hml_long { + readonly kind: 'HmLabel_hml_long'; + readonly m: number; + readonly n: number; + readonly s: Array; +} + +export interface HmLabel_hml_same { + readonly kind: 'HmLabel_hml_same'; + readonly m: number; + readonly v: BitString; + readonly n: number; +} + +export type Unary = Unary_unary_zero | Unary_unary_succ; + +export interface Unary_unary_zero { + readonly kind: 'Unary_unary_zero'; +} + +export interface Unary_unary_succ { + readonly kind: 'Unary_unary_succ'; + readonly n: number; + readonly x: Unary; +} + +export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; + +export interface HashmapE_hme_empty { + readonly kind: 'HashmapE_hme_empty'; + readonly n: number; +} + +export interface HashmapE_hme_root { + readonly kind: 'HashmapE_hme_root'; + readonly n: number; + readonly root: Hashmap; +} + +export interface BitstringSet { + readonly kind: 'BitstringSet'; + readonly n: number; + readonly _: Hashmap; +} + +export interface HashmapAug { + readonly kind: 'HashmapAug'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: HashmapAugNode; +} + +export type HashmapAugNode = HashmapAugNode_ahmn_leaf | HashmapAugNode_ahmn_fork; + +export interface HashmapAugNode_ahmn_leaf { + readonly kind: 'HashmapAugNode_ahmn_leaf'; + readonly extra: Y; + readonly value: X; +} + +export interface HashmapAugNode_ahmn_fork { + readonly kind: 'HashmapAugNode_ahmn_fork'; + readonly n: number; + readonly left: HashmapAug; + readonly right: HashmapAug; + readonly extra: Y; +} + +export type HashmapAugE = HashmapAugE_ahme_empty | HashmapAugE_ahme_root; + +export interface HashmapAugE_ahme_empty { + readonly kind: 'HashmapAugE_ahme_empty'; + readonly n: number; + readonly extra: Y; +} + +export interface HashmapAugE_ahme_root { + readonly kind: 'HashmapAugE_ahme_root'; + readonly n: number; + readonly root: HashmapAug; + readonly extra: Y; +} + +export interface VarHashmap { + readonly kind: 'VarHashmap'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: VarHashmapNode; +} + +export type VarHashmapNode = VarHashmapNode_vhmn_leaf | VarHashmapNode_vhmn_fork | VarHashmapNode_vhmn_cont; + +export interface VarHashmapNode_vhmn_leaf { + readonly kind: 'VarHashmapNode_vhmn_leaf'; + readonly n: number; + readonly value: X; +} + +export interface VarHashmapNode_vhmn_fork { + readonly kind: 'VarHashmapNode_vhmn_fork'; + readonly n: number; + readonly left: VarHashmap; + readonly right: VarHashmap; + readonly value: Maybe; +} + +export interface VarHashmapNode_vhmn_cont { + readonly kind: 'VarHashmapNode_vhmn_cont'; + readonly n: number; + readonly branch: BitString; + readonly child: VarHashmap; + readonly value: X; +} + +export type VarHashmapE = VarHashmapE_vhme_empty | VarHashmapE_vhme_root; + +export interface VarHashmapE_vhme_empty { + readonly kind: 'VarHashmapE_vhme_empty'; + readonly n: number; +} + +export interface VarHashmapE_vhme_root { + readonly kind: 'VarHashmapE_vhme_root'; + readonly n: number; + readonly root: VarHashmap; +} + +export interface PfxHashmap { + readonly kind: 'PfxHashmap'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: PfxHashmapNode; +} + +export type PfxHashmapNode = PfxHashmapNode_phmn_leaf | PfxHashmapNode_phmn_fork; + +export interface PfxHashmapNode_phmn_leaf { + readonly kind: 'PfxHashmapNode_phmn_leaf'; + readonly n: number; + readonly value: X; +} + +export interface PfxHashmapNode_phmn_fork { + readonly kind: 'PfxHashmapNode_phmn_fork'; + readonly n: number; + readonly left: PfxHashmap; + readonly right: PfxHashmap; +} + +export type PfxHashmapE = PfxHashmapE_phme_empty | PfxHashmapE_phme_root; + +export interface PfxHashmapE_phme_empty { + readonly kind: 'PfxHashmapE_phme_empty'; + readonly n: number; +} + +export interface PfxHashmapE_phme_root { + readonly kind: 'PfxHashmapE_phme_root'; + readonly n: number; + readonly root: PfxHashmap; +} + +export type MsgAddressExt = MsgAddressExt_addr_none | MsgAddressExt_addr_extern; + +export interface MsgAddressExt_addr_none { + readonly kind: 'MsgAddressExt_addr_none'; +} + +export interface MsgAddressExt_addr_extern { + readonly kind: 'MsgAddressExt_addr_extern'; + readonly len: number; + readonly external_address: BitString; +} + +export interface Anycast { + readonly kind: 'Anycast'; + readonly depth: number; + readonly rewrite_pfx: BitString; +} + +export type MsgAddress = MsgAddress__ | MsgAddress__1; + +export interface MsgAddress__ { + readonly kind: 'MsgAddress__'; + readonly _: Address; +} + +export interface MsgAddress__1 { + readonly kind: 'MsgAddress__1'; + readonly _: MsgAddressExt; +} + +export interface VarUInteger { + readonly kind: 'VarUInteger'; + readonly n: number; + readonly len: number; + readonly value: bigint; +} + +export interface VarInteger { + readonly kind: 'VarInteger'; + readonly n: number; + readonly len: number; + readonly value: bigint; +} + +export interface Grams { + readonly kind: 'Grams'; + readonly amount: VarUInteger; +} + +export interface Coins { + readonly kind: 'Coins'; + readonly grams: Grams; +} + +export interface ExtraCurrencyCollection { + readonly kind: 'ExtraCurrencyCollection'; + readonly dict: HashmapE; +} + +export interface CurrencyCollection { + readonly kind: 'CurrencyCollection'; + readonly grams: Grams; + readonly other: ExtraCurrencyCollection; +} + +export type CommonMsgInfo = CommonMsgInfo_int_msg_info | CommonMsgInfo_ext_in_msg_info | CommonMsgInfo_ext_out_msg_info; + +export interface CommonMsgInfo_int_msg_info { + readonly kind: 'CommonMsgInfo_int_msg_info'; + readonly ihr_disabled: boolean; + readonly bounce: boolean; + readonly bounced: boolean; + readonly src: Address; + readonly dest: Address; + readonly value: CurrencyCollection; + readonly ihr_fee: Grams; + readonly fwd_fee: Grams; + readonly created_lt: number; + readonly created_at: number; +} + +export interface CommonMsgInfo_ext_in_msg_info { + readonly kind: 'CommonMsgInfo_ext_in_msg_info'; + readonly src: MsgAddressExt; + readonly dest: Address; + readonly import_fee: Grams; +} + +export interface CommonMsgInfo_ext_out_msg_info { + readonly kind: 'CommonMsgInfo_ext_out_msg_info'; + readonly src: Address; + readonly dest: MsgAddressExt; + readonly created_lt: number; + readonly created_at: number; +} + +export type CommonMsgInfoRelaxed = CommonMsgInfoRelaxed_int_msg_info | CommonMsgInfoRelaxed_ext_out_msg_info; + +export interface CommonMsgInfoRelaxed_int_msg_info { + readonly kind: 'CommonMsgInfoRelaxed_int_msg_info'; + readonly ihr_disabled: boolean; + readonly bounce: boolean; + readonly bounced: boolean; + readonly src: MsgAddress; + readonly dest: Address; + readonly value: CurrencyCollection; + readonly ihr_fee: Grams; + readonly fwd_fee: Grams; + readonly created_lt: number; + readonly created_at: number; +} + +export interface CommonMsgInfoRelaxed_ext_out_msg_info { + readonly kind: 'CommonMsgInfoRelaxed_ext_out_msg_info'; + readonly src: MsgAddress; + readonly dest: MsgAddressExt; + readonly created_lt: number; + readonly created_at: number; +} + +export interface TickTock { + readonly kind: 'TickTock'; + readonly tick: boolean; + readonly tock: boolean; +} + +export interface StateInit { + readonly kind: 'StateInit'; + readonly split_depth: Maybe; + readonly special: Maybe; + readonly code: Maybe; + readonly data: Maybe; + readonly library: Maybe; +} + +export interface StateInitWithLibs { + readonly kind: 'StateInitWithLibs'; + readonly split_depth: Maybe; + readonly special: Maybe; + readonly code: Maybe; + readonly data: Maybe; + readonly library: HashmapE; +} + +export interface SimpleLib { + readonly kind: 'SimpleLib'; + readonly public0: boolean; + readonly root: Slice; +} + +export interface Message { + readonly kind: 'Message'; + readonly info: CommonMsgInfo; + readonly init: Maybe>; + readonly body: Either; +} + +export interface MessageRelaxed { + readonly kind: 'MessageRelaxed'; + readonly info: CommonMsgInfoRelaxed; + readonly init: Maybe>; + readonly body: Either; +} + +export interface MessageAny { + readonly kind: 'MessageAny'; + readonly anon0: Message; +} + +export type IntermediateAddress = IntermediateAddress_interm_addr_regular | IntermediateAddress_interm_addr_simple | IntermediateAddress_interm_addr_ext; + +export interface IntermediateAddress_interm_addr_regular { + readonly kind: 'IntermediateAddress_interm_addr_regular'; + readonly use_dest_bits: number; +} + +export interface IntermediateAddress_interm_addr_simple { + readonly kind: 'IntermediateAddress_interm_addr_simple'; + readonly workchain_id: number; + readonly addr_pfx: number; +} + +export interface IntermediateAddress_interm_addr_ext { + readonly kind: 'IntermediateAddress_interm_addr_ext'; + readonly workchain_id: number; + readonly addr_pfx: number; +} + +export interface MsgEnvelope { + readonly kind: 'MsgEnvelope'; + readonly cur_addr: IntermediateAddress; + readonly next_addr: IntermediateAddress; + readonly fwd_fee_remaining: Grams; + readonly msg: Message; +} + +export type InMsg = InMsg_msg_import_ext | InMsg_msg_import_ihr | InMsg_msg_import_imm | InMsg_msg_import_fin | InMsg_msg_import_tr | InMsg_msg_discard_fin | InMsg_msg_discard_tr; + +export interface InMsg_msg_import_ext { + readonly kind: 'InMsg_msg_import_ext'; + readonly msg: Message; + readonly transaction: Transaction; +} + +export interface InMsg_msg_import_ihr { + readonly kind: 'InMsg_msg_import_ihr'; + readonly msg: Message; + readonly transaction: Transaction; + readonly ihr_fee: Grams; + readonly proof_created: Slice; +} + +export interface InMsg_msg_import_imm { + readonly kind: 'InMsg_msg_import_imm'; + readonly in_msg: MsgEnvelope; + readonly transaction: Transaction; + readonly fwd_fee: Grams; +} + +export interface InMsg_msg_import_fin { + readonly kind: 'InMsg_msg_import_fin'; + readonly in_msg: MsgEnvelope; + readonly transaction: Transaction; + readonly fwd_fee: Grams; +} + +export interface InMsg_msg_import_tr { + readonly kind: 'InMsg_msg_import_tr'; + readonly in_msg: MsgEnvelope; + readonly out_msg: MsgEnvelope; + readonly transit_fee: Grams; +} + +export interface InMsg_msg_discard_fin { + readonly kind: 'InMsg_msg_discard_fin'; + readonly in_msg: MsgEnvelope; + readonly transaction_id: number; + readonly fwd_fee: Grams; +} + +export interface InMsg_msg_discard_tr { + readonly kind: 'InMsg_msg_discard_tr'; + readonly in_msg: MsgEnvelope; + readonly transaction_id: number; + readonly fwd_fee: Grams; + readonly proof_delivered: Slice; +} + +export interface ImportFees { + readonly kind: 'ImportFees'; + readonly fees_collected: Grams; + readonly value_imported: CurrencyCollection; +} + +export interface InMsgDescr { + readonly kind: 'InMsgDescr'; + readonly anon0: HashmapAugE; +} + +export type OutMsg = OutMsg_msg_export_ext | OutMsg_msg_export_imm | OutMsg_msg_export_new | OutMsg_msg_export_tr | OutMsg_msg_export_deq | OutMsg_msg_export_deq_short | OutMsg_msg_export_tr_req | OutMsg_msg_export_deq_imm; + +export interface OutMsg_msg_export_ext { + readonly kind: 'OutMsg_msg_export_ext'; + readonly msg: Message; + readonly transaction: Transaction; +} + +export interface OutMsg_msg_export_imm { + readonly kind: 'OutMsg_msg_export_imm'; + readonly out_msg: MsgEnvelope; + readonly transaction: Transaction; + readonly reimport: InMsg; +} + +export interface OutMsg_msg_export_new { + readonly kind: 'OutMsg_msg_export_new'; + readonly out_msg: MsgEnvelope; + readonly transaction: Transaction; +} + +export interface OutMsg_msg_export_tr { + readonly kind: 'OutMsg_msg_export_tr'; + readonly out_msg: MsgEnvelope; + readonly imported: InMsg; +} + +export interface OutMsg_msg_export_deq { + readonly kind: 'OutMsg_msg_export_deq'; + readonly out_msg: MsgEnvelope; + readonly import_block_lt: number; +} + +export interface OutMsg_msg_export_deq_short { + readonly kind: 'OutMsg_msg_export_deq_short'; + readonly msg_env_hash: BitString; + readonly next_workchain: number; + readonly next_addr_pfx: number; + readonly import_block_lt: number; +} + +export interface OutMsg_msg_export_tr_req { + readonly kind: 'OutMsg_msg_export_tr_req'; + readonly out_msg: MsgEnvelope; + readonly imported: InMsg; +} + +export interface OutMsg_msg_export_deq_imm { + readonly kind: 'OutMsg_msg_export_deq_imm'; + readonly out_msg: MsgEnvelope; + readonly reimport: InMsg; +} + +export interface EnqueuedMsg { + readonly kind: 'EnqueuedMsg'; + readonly enqueued_lt: number; + readonly out_msg: MsgEnvelope; +} + +export interface OutMsgDescr { + readonly kind: 'OutMsgDescr'; + readonly anon0: HashmapAugE; +} + +export interface OutMsgQueue { + readonly kind: 'OutMsgQueue'; + readonly anon0: HashmapAugE; +} + +export interface ProcessedUpto { + readonly kind: 'ProcessedUpto'; + readonly last_msg_lt: number; + readonly last_msg_hash: BitString; +} + +export interface ProcessedInfo { + readonly kind: 'ProcessedInfo'; + readonly anon0: HashmapE; +} + +export interface IhrPendingSince { + readonly kind: 'IhrPendingSince'; + readonly import_lt: number; +} + +export interface IhrPendingInfo { + readonly kind: 'IhrPendingInfo'; + readonly anon0: HashmapE; +} + +export interface OutMsgQueueInfo { + readonly kind: 'OutMsgQueueInfo'; + readonly out_queue: OutMsgQueue; + readonly proc_info: ProcessedInfo; + readonly ihr_pending: IhrPendingInfo; +} + +export interface StorageUsed { + readonly kind: 'StorageUsed'; + readonly _cells: VarUInteger; + readonly bits: VarUInteger; + readonly public_cells: VarUInteger; +} + +export interface StorageUsedShort { + readonly kind: 'StorageUsedShort'; + readonly _cells: VarUInteger; + readonly bits: VarUInteger; +} + +export interface StorageInfo { + readonly kind: 'StorageInfo'; + readonly used: StorageUsed; + readonly last_paid: number; + readonly due_payment: Maybe; +} + +export type Account = Account_account_none | Account_account; + +export interface Account_account_none { + readonly kind: 'Account_account_none'; +} + +export interface Account_account { + readonly kind: 'Account_account'; + readonly addr: Address; + readonly storage_stat: StorageInfo; + readonly storage: AccountStorage; +} + +export interface AccountStorage { + readonly kind: 'AccountStorage'; + readonly last_trans_lt: number; + readonly balance: CurrencyCollection; + readonly state: AccountState; +} + +export type AccountState = AccountState_account_uninit | AccountState_account_active | AccountState_account_frozen; + +export interface AccountState_account_uninit { + readonly kind: 'AccountState_account_uninit'; +} + +export interface AccountState_account_active { + readonly kind: 'AccountState_account_active'; + readonly _: StateInit; +} + +export interface AccountState_account_frozen { + readonly kind: 'AccountState_account_frozen'; + readonly state_hash: BitString; +} + +export type AccountStatus = AccountStatus_acc_state_uninit | AccountStatus_acc_state_frozen | AccountStatus_acc_state_active | AccountStatus_acc_state_nonexist; + +export interface AccountStatus_acc_state_uninit { + readonly kind: 'AccountStatus_acc_state_uninit'; +} + +export interface AccountStatus_acc_state_frozen { + readonly kind: 'AccountStatus_acc_state_frozen'; +} + +export interface AccountStatus_acc_state_active { + readonly kind: 'AccountStatus_acc_state_active'; +} + +export interface AccountStatus_acc_state_nonexist { + readonly kind: 'AccountStatus_acc_state_nonexist'; +} + +export interface ShardAccount { + readonly kind: 'ShardAccount'; + readonly account: Account; + readonly last_trans_hash: BitString; + readonly last_trans_lt: number; +} + +export interface DepthBalanceInfo { + readonly kind: 'DepthBalanceInfo'; + readonly split_depth: number; + readonly balance: CurrencyCollection; +} + +export interface ShardAccounts { + readonly kind: 'ShardAccounts'; + readonly anon0: HashmapAugE; +} + +export interface Transaction { + readonly kind: 'Transaction'; + readonly account_addr: BitString; + readonly lt: number; + readonly prev_trans_hash: BitString; + readonly prev_trans_lt: number; + readonly now: number; + readonly outmsg_cnt: number; + readonly orig_status: AccountStatus; + readonly end_status: AccountStatus; + readonly in_msg: Maybe>; + readonly out_msgs: HashmapE>; + readonly total_fees: CurrencyCollection; + readonly state_update: HASH_UPDATE; + readonly description: TransactionDescr; +} + +export interface MERKLE_UPDATE { + readonly kind: 'MERKLE_UPDATE'; + readonly old_hash: BitString; + readonly new_hash: BitString; + readonly old: X; + readonly new0: X; +} + +export interface HASH_UPDATE { + readonly kind: 'HASH_UPDATE'; + readonly old_hash: BitString; + readonly new_hash: BitString; +} + +export interface MERKLE_PROOF { + readonly kind: 'MERKLE_PROOF'; + readonly virtual_hash: BitString; + readonly depth: number; + readonly virtual_root: X; +} + +export interface AccountBlock { + readonly kind: 'AccountBlock'; + readonly account_addr: BitString; + readonly transactions: HashmapAug; + readonly state_update: HASH_UPDATE; +} + +export interface ShardAccountBlocks { + readonly kind: 'ShardAccountBlocks'; + readonly anon0: HashmapAugE; +} + +export interface TrStoragePhase { + readonly kind: 'TrStoragePhase'; + readonly storage_fees_collected: Grams; + readonly storage_fees_due: Maybe; + readonly status_change: AccStatusChange; +} + +export type AccStatusChange = AccStatusChange_acst_unchanged | AccStatusChange_acst_frozen | AccStatusChange_acst_deleted; + +export interface AccStatusChange_acst_unchanged { + readonly kind: 'AccStatusChange_acst_unchanged'; +} + +export interface AccStatusChange_acst_frozen { + readonly kind: 'AccStatusChange_acst_frozen'; +} + +export interface AccStatusChange_acst_deleted { + readonly kind: 'AccStatusChange_acst_deleted'; +} + +export interface TrCreditPhase { + readonly kind: 'TrCreditPhase'; + readonly due_fees_collected: Maybe; + readonly credit: CurrencyCollection; +} + +export type TrComputePhase = TrComputePhase_tr_phase_compute_skipped | TrComputePhase_tr_phase_compute_vm; + +export interface TrComputePhase_tr_phase_compute_skipped { + readonly kind: 'TrComputePhase_tr_phase_compute_skipped'; + readonly reason: ComputeSkipReason; +} + +export interface TrComputePhase_tr_phase_compute_vm { + readonly kind: 'TrComputePhase_tr_phase_compute_vm'; + readonly success: boolean; + readonly msg_state_used: boolean; + readonly account_activated: boolean; + readonly gas_fees: Grams; + readonly gas_used: VarUInteger; + readonly gas_limit: VarUInteger; + readonly gas_credit: Maybe; + readonly mode: number; + readonly exit_code: number; + readonly exit_arg: Maybe; + readonly vm_steps: number; + readonly vm_init_state_hash: BitString; + readonly vm_final_state_hash: BitString; +} + +export type ComputeSkipReason = ComputeSkipReason_cskip_no_state | ComputeSkipReason_cskip_bad_state | ComputeSkipReason_cskip_no_gas | ComputeSkipReason_cskip_suspended; + +export interface ComputeSkipReason_cskip_no_state { + readonly kind: 'ComputeSkipReason_cskip_no_state'; +} + +export interface ComputeSkipReason_cskip_bad_state { + readonly kind: 'ComputeSkipReason_cskip_bad_state'; +} + +export interface ComputeSkipReason_cskip_no_gas { + readonly kind: 'ComputeSkipReason_cskip_no_gas'; +} + +export interface ComputeSkipReason_cskip_suspended { + readonly kind: 'ComputeSkipReason_cskip_suspended'; +} + +export interface TrActionPhase { + readonly kind: 'TrActionPhase'; + readonly success: boolean; + readonly valid: boolean; + readonly no_funds: boolean; + readonly status_change: AccStatusChange; + readonly total_fwd_fees: Maybe; + readonly total_action_fees: Maybe; + readonly result_code: number; + readonly result_arg: Maybe; + readonly tot_actions: number; + readonly spec_actions: number; + readonly skipped_actions: number; + readonly msgs_created: number; + readonly action_list_hash: BitString; + readonly tot_msg_size: StorageUsedShort; +} + +export type TrBouncePhase = TrBouncePhase_tr_phase_bounce_negfunds | TrBouncePhase_tr_phase_bounce_nofunds | TrBouncePhase_tr_phase_bounce_ok; + +export interface TrBouncePhase_tr_phase_bounce_negfunds { + readonly kind: 'TrBouncePhase_tr_phase_bounce_negfunds'; +} + +export interface TrBouncePhase_tr_phase_bounce_nofunds { + readonly kind: 'TrBouncePhase_tr_phase_bounce_nofunds'; + readonly msg_size: StorageUsedShort; + readonly req_fwd_fees: Grams; +} + +export interface TrBouncePhase_tr_phase_bounce_ok { + readonly kind: 'TrBouncePhase_tr_phase_bounce_ok'; + readonly msg_size: StorageUsedShort; + readonly msg_fees: Grams; + readonly fwd_fees: Grams; +} + +export type TransactionDescr = TransactionDescr_trans_ord | TransactionDescr_trans_storage | TransactionDescr_trans_tick_tock | TransactionDescr_trans_split_prepare | TransactionDescr_trans_split_install | TransactionDescr_trans_merge_prepare | TransactionDescr_trans_merge_install; + +export interface TransactionDescr_trans_ord { + readonly kind: 'TransactionDescr_trans_ord'; + readonly credit_first: boolean; + readonly storage_ph: Maybe; + readonly credit_ph: Maybe; + readonly compute_ph: TrComputePhase; + readonly action: Maybe; + readonly aborted: boolean; + readonly bounce: Maybe; + readonly destroyed: boolean; +} + +export interface TransactionDescr_trans_storage { + readonly kind: 'TransactionDescr_trans_storage'; + readonly storage_ph: TrStoragePhase; +} + +export interface TransactionDescr_trans_tick_tock { + readonly kind: 'TransactionDescr_trans_tick_tock'; + readonly is_tock: boolean; + readonly storage_ph: TrStoragePhase; + readonly compute_ph: TrComputePhase; + readonly action: Maybe; + readonly aborted: boolean; + readonly destroyed: boolean; +} + +export interface TransactionDescr_trans_split_prepare { + readonly kind: 'TransactionDescr_trans_split_prepare'; + readonly split_info: SplitMergeInfo; + readonly storage_ph: Maybe; + readonly compute_ph: TrComputePhase; + readonly action: Maybe; + readonly aborted: boolean; + readonly destroyed: boolean; +} + +export interface TransactionDescr_trans_split_install { + readonly kind: 'TransactionDescr_trans_split_install'; + readonly split_info: SplitMergeInfo; + readonly prepare_transaction: Transaction; + readonly installed: boolean; +} + +export interface TransactionDescr_trans_merge_prepare { + readonly kind: 'TransactionDescr_trans_merge_prepare'; + readonly split_info: SplitMergeInfo; + readonly storage_ph: TrStoragePhase; + readonly aborted: boolean; +} + +export interface TransactionDescr_trans_merge_install { + readonly kind: 'TransactionDescr_trans_merge_install'; + readonly split_info: SplitMergeInfo; + readonly prepare_transaction: Transaction; + readonly storage_ph: Maybe; + readonly credit_ph: Maybe; + readonly compute_ph: TrComputePhase; + readonly action: Maybe; + readonly aborted: boolean; + readonly destroyed: boolean; +} + +export interface SplitMergeInfo { + readonly kind: 'SplitMergeInfo'; + readonly cur_shard_pfx_len: number; + readonly acc_split_depth: number; + readonly this_addr: BitString; + readonly sibling_addr: BitString; +} + +export interface SmartContractInfo { + readonly kind: 'SmartContractInfo'; + readonly actions: number; + readonly msgs_sent: number; + readonly unixtime: number; + readonly block_lt: number; + readonly trans_lt: number; + readonly rand_seed: BitString; + readonly balance_remaining: CurrencyCollection; + readonly myself: Address; + readonly global_config: Maybe; +} + +export type OutList = OutList_out_list_empty | OutList_out_list; + +export interface OutList_out_list_empty { + readonly kind: 'OutList_out_list_empty'; +} + +export interface OutList_out_list { + readonly kind: 'OutList_out_list'; + readonly n: number; + readonly prev: OutList; + readonly action: OutAction; +} + +export type OutAction = OutAction_action_send_msg | OutAction_action_set_code | OutAction_action_reserve_currency | OutAction_action_change_library; + +export interface OutAction_action_send_msg { + readonly kind: 'OutAction_action_send_msg'; + readonly mode: number; + readonly out_msg: MessageRelaxed; +} + +export interface OutAction_action_set_code { + readonly kind: 'OutAction_action_set_code'; + readonly new_code: Slice; +} + +export interface OutAction_action_reserve_currency { + readonly kind: 'OutAction_action_reserve_currency'; + readonly mode: number; + readonly currency: CurrencyCollection; +} + +export interface OutAction_action_change_library { + readonly kind: 'OutAction_action_change_library'; + readonly mode: number; + readonly libref: LibRef; +} + +export type LibRef = LibRef_libref_hash | LibRef_libref_ref; + +export interface LibRef_libref_hash { + readonly kind: 'LibRef_libref_hash'; + readonly lib_hash: BitString; +} + +export interface LibRef_libref_ref { + readonly kind: 'LibRef_libref_ref'; + readonly library: Slice; +} + +export interface OutListNode { + readonly kind: 'OutListNode'; + readonly prev: Slice; + readonly action: OutAction; +} + +export interface ShardIdent { + readonly kind: 'ShardIdent'; + readonly shard_pfx_bits: number; + readonly workchain_id: number; + readonly shard_prefix: number; +} + +export interface ExtBlkRef { + readonly kind: 'ExtBlkRef'; + readonly end_lt: number; + readonly seq_no: number; + readonly root_hash: BitString; + readonly file_hash: BitString; +} + +export interface BlockIdExt { + readonly kind: 'BlockIdExt'; + readonly shard_id: ShardIdent; + readonly seq_no: number; + readonly root_hash: BitString; + readonly file_hash: BitString; +} + +export interface BlkMasterInfo { + readonly kind: 'BlkMasterInfo'; + readonly master: ExtBlkRef; +} + +export interface ShardStateUnsplit { + readonly kind: 'ShardStateUnsplit'; + readonly global_id: number; + readonly shard_id: ShardIdent; + readonly seq_no: number; + readonly vert_seq_no: number; + readonly gen_utime: number; + readonly gen_lt: number; + readonly min_ref_mc_seqno: number; + readonly out_msg_queue_info: OutMsgQueueInfo; + readonly before_split: number; + readonly accounts: ShardAccounts; + readonly overload_history: number; + readonly underload_history: number; + readonly total_balance: CurrencyCollection; + readonly total_validator_fees: CurrencyCollection; + readonly libraries: HashmapE; + readonly master_ref: Maybe; + readonly custom: Maybe; +} + +export type ShardState = ShardState_split_state | ShardState__; + +export interface ShardState_split_state { + readonly kind: 'ShardState_split_state'; + readonly left: ShardStateUnsplit; + readonly right: ShardStateUnsplit; +} + +export interface ShardState__ { + readonly kind: 'ShardState__'; + readonly anon0: ShardStateUnsplit; +} + +export interface LibDescr { + readonly kind: 'LibDescr'; + readonly lib: Slice; + readonly publishers: Hashmap; +} + +export interface BlockInfo { + readonly kind: 'BlockInfo'; + readonly prev_seq_no: number; + readonly version: number; + readonly not_master: number; + readonly after_merge: number; + readonly before_split: number; + readonly after_split: number; + readonly want_split: boolean; + readonly want_merge: boolean; + readonly key_block: boolean; + readonly vert_seqno_incr: number; + readonly flags: number; + readonly seq_no: number; + readonly vert_seq_no: number; + readonly shard: ShardIdent; + readonly gen_utime: number; + readonly start_lt: number; + readonly end_lt: number; + readonly gen_validator_list_hash_short: number; + readonly gen_catchain_seqno: number; + readonly min_ref_mc_seqno: number; + readonly prev_key_block_seqno: number; + readonly gen_software: GlobalVersion | undefined; + readonly master_ref: BlkMasterInfo | undefined; + readonly prev_ref: BlkPrevInfo; + readonly prev_vert_ref: BlkPrevInfo | undefined; +} + +export type BlkPrevInfo = BlkPrevInfo_prev_blk_info | BlkPrevInfo_prev_blks_info; + +export interface BlkPrevInfo_prev_blk_info { + readonly kind: 'BlkPrevInfo_prev_blk_info'; + readonly prev: ExtBlkRef; +} + +export interface BlkPrevInfo_prev_blks_info { + readonly kind: 'BlkPrevInfo_prev_blks_info'; + readonly prev1: ExtBlkRef; + readonly prev2: ExtBlkRef; +} + +export interface Block { + readonly kind: 'Block'; + readonly global_id: number; + readonly info: BlockInfo; + readonly value_flow: ValueFlow; + readonly state_update: Cell; + readonly extra: BlockExtra; +} + +export interface BlockExtra { + readonly kind: 'BlockExtra'; + readonly in_msg_descr: InMsgDescr; + readonly out_msg_descr: OutMsgDescr; + readonly account_blocks: ShardAccountBlocks; + readonly rand_seed: BitString; + readonly created_by: BitString; + readonly custom: Maybe; +} + +export type ValueFlow = ValueFlow_value_flow | ValueFlow_value_flow_v2; + +export interface ValueFlow_value_flow { + readonly kind: 'ValueFlow_value_flow'; + readonly from_prev_blk: CurrencyCollection; + readonly to_next_blk: CurrencyCollection; + readonly imported: CurrencyCollection; + readonly exported: CurrencyCollection; + readonly fees_collected: CurrencyCollection; + readonly fees_imported: CurrencyCollection; + readonly recovered: CurrencyCollection; + readonly created: CurrencyCollection; + readonly minted: CurrencyCollection; +} + +export interface ValueFlow_value_flow_v2 { + readonly kind: 'ValueFlow_value_flow_v2'; + readonly from_prev_blk: CurrencyCollection; + readonly to_next_blk: CurrencyCollection; + readonly imported: CurrencyCollection; + readonly exported: CurrencyCollection; + readonly fees_collected: CurrencyCollection; + readonly burned: CurrencyCollection; + readonly fees_imported: CurrencyCollection; + readonly recovered: CurrencyCollection; + readonly created: CurrencyCollection; + readonly minted: CurrencyCollection; +} + +export type BinTree = BinTree_bt_leaf | BinTree_bt_fork; + +export interface BinTree_bt_leaf { + readonly kind: 'BinTree_bt_leaf'; + readonly leaf: X; +} + +export interface BinTree_bt_fork { + readonly kind: 'BinTree_bt_fork'; + readonly left: BinTree; + readonly right: BinTree; +} + +export type FutureSplitMerge = FutureSplitMerge_fsm_none | FutureSplitMerge_fsm_split | FutureSplitMerge_fsm_merge; + +export interface FutureSplitMerge_fsm_none { + readonly kind: 'FutureSplitMerge_fsm_none'; +} + +export interface FutureSplitMerge_fsm_split { + readonly kind: 'FutureSplitMerge_fsm_split'; + readonly split_utime: number; + readonly interval: number; +} + +export interface FutureSplitMerge_fsm_merge { + readonly kind: 'FutureSplitMerge_fsm_merge'; + readonly merge_utime: number; + readonly interval: number; +} + +export type ShardDescr = ShardDescr_shard_descr | ShardDescr_shard_descr_new; + +export interface ShardDescr_shard_descr { + readonly kind: 'ShardDescr_shard_descr'; + readonly seq_no: number; + readonly reg_mc_seqno: number; + readonly start_lt: number; + readonly end_lt: number; + readonly root_hash: BitString; + readonly file_hash: BitString; + readonly before_split: boolean; + readonly before_merge: boolean; + readonly want_split: boolean; + readonly want_merge: boolean; + readonly nx_cc_updated: boolean; + readonly flags: number; + readonly next_catchain_seqno: number; + readonly next_validator_shard: number; + readonly min_ref_mc_seqno: number; + readonly gen_utime: number; + readonly split_merge_at: FutureSplitMerge; + readonly fees_collected: CurrencyCollection; + readonly funds_created: CurrencyCollection; +} + +export interface ShardDescr_shard_descr_new { + readonly kind: 'ShardDescr_shard_descr_new'; + readonly seq_no: number; + readonly reg_mc_seqno: number; + readonly start_lt: number; + readonly end_lt: number; + readonly root_hash: BitString; + readonly file_hash: BitString; + readonly before_split: boolean; + readonly before_merge: boolean; + readonly want_split: boolean; + readonly want_merge: boolean; + readonly nx_cc_updated: boolean; + readonly flags: number; + readonly next_catchain_seqno: number; + readonly next_validator_shard: number; + readonly min_ref_mc_seqno: number; + readonly gen_utime: number; + readonly split_merge_at: FutureSplitMerge; + readonly fees_collected: CurrencyCollection; + readonly funds_created: CurrencyCollection; +} + +export interface ShardHashes { + readonly kind: 'ShardHashes'; + readonly anon0: HashmapE>; +} + +export type BinTreeAug = BinTreeAug_bta_leaf | BinTreeAug_bta_fork; + +export interface BinTreeAug_bta_leaf { + readonly kind: 'BinTreeAug_bta_leaf'; + readonly extra: Y; + readonly leaf: X; +} + +export interface BinTreeAug_bta_fork { + readonly kind: 'BinTreeAug_bta_fork'; + readonly left: BinTreeAug; + readonly right: BinTreeAug; + readonly extra: Y; +} + +export interface ShardFeeCreated { + readonly kind: 'ShardFeeCreated'; + readonly fees: CurrencyCollection; + readonly create: CurrencyCollection; +} + +export interface ShardFees { + readonly kind: 'ShardFees'; + readonly anon0: HashmapAugE; +} + +export interface ConfigParams { + readonly kind: 'ConfigParams'; + readonly config_addr: BitString; + readonly config: Hashmap; +} + +export interface ValidatorInfo { + readonly kind: 'ValidatorInfo'; + readonly validator_list_hash_short: number; + readonly catchain_seqno: number; + readonly nx_cc_updated: boolean; +} + +export interface ValidatorBaseInfo { + readonly kind: 'ValidatorBaseInfo'; + readonly validator_list_hash_short: number; + readonly catchain_seqno: number; +} + +export interface KeyMaxLt { + readonly kind: 'KeyMaxLt'; + readonly key: boolean; + readonly max_end_lt: number; +} + +export interface KeyExtBlkRef { + readonly kind: 'KeyExtBlkRef'; + readonly key: boolean; + readonly blk_ref: ExtBlkRef; +} + +export interface OldMcBlocksInfo { + readonly kind: 'OldMcBlocksInfo'; + readonly anon0: HashmapAugE; +} + +export interface Counters { + readonly kind: 'Counters'; + readonly last_updated: number; + readonly total: number; + readonly cnt2048: number; + readonly cnt65536: number; +} + +export interface CreatorStats { + readonly kind: 'CreatorStats'; + readonly mc_blocks: Counters; + readonly shard_blocks: Counters; +} + +export type BlockCreateStats = BlockCreateStats_block_create_stats | BlockCreateStats_block_create_stats_ext; + +export interface BlockCreateStats_block_create_stats { + readonly kind: 'BlockCreateStats_block_create_stats'; + readonly counters: HashmapE; +} + +export interface BlockCreateStats_block_create_stats_ext { + readonly kind: 'BlockCreateStats_block_create_stats_ext'; + readonly counters: HashmapAugE; +} + +export interface McStateExtra { + readonly kind: 'McStateExtra'; + readonly shard_hashes: ShardHashes; + readonly config: ConfigParams; + readonly flags: number; + readonly validator_info: ValidatorInfo; + readonly prev_blocks: OldMcBlocksInfo; + readonly after_key_block: boolean; + readonly last_key_block: Maybe; + readonly block_create_stats: BlockCreateStats | undefined; + readonly global_balance: CurrencyCollection; +} + +export interface SigPubKey { + readonly kind: 'SigPubKey'; + readonly pubkey: BitString; +} + +export interface CryptoSignatureSimple { + readonly kind: 'CryptoSignatureSimple'; + readonly R: BitString; + readonly s: BitString; +} + +export type CryptoSignature = CryptoSignature_chained_signature | CryptoSignature__; + +export interface CryptoSignature_chained_signature { + readonly kind: 'CryptoSignature_chained_signature'; + readonly signed_cert: SignedCertificate; + readonly temp_key_signature: CryptoSignatureSimple; +} + +export interface CryptoSignature__ { + readonly kind: 'CryptoSignature__'; + readonly anon0: CryptoSignatureSimple; +} + +export interface CryptoSignaturePair { + readonly kind: 'CryptoSignaturePair'; + readonly node_id_short: BitString; + readonly sign: CryptoSignature; +} + +export interface Certificate { + readonly kind: 'Certificate'; + readonly temp_key: SigPubKey; + readonly valid_since: number; + readonly valid_until: number; +} + +export interface CertificateEnv { + readonly kind: 'CertificateEnv'; + readonly certificate: Certificate; +} + +export interface SignedCertificate { + readonly kind: 'SignedCertificate'; + readonly certificate: Certificate; + readonly certificate_signature: CryptoSignature; +} + +export interface McBlockExtra { + readonly kind: 'McBlockExtra'; + readonly key_block: number; + readonly shard_hashes: ShardHashes; + readonly shard_fees: ShardFees; + readonly prev_blk_signatures: HashmapE; + readonly recover_create_msg: Maybe; + readonly mint_msg: Maybe; + readonly config: ConfigParams | undefined; +} + +export type ValidatorDescr = ValidatorDescr_validator | ValidatorDescr_validator_addr; + +export interface ValidatorDescr_validator { + readonly kind: 'ValidatorDescr_validator'; + readonly public_key: SigPubKey; + readonly weight: number; +} + +export interface ValidatorDescr_validator_addr { + readonly kind: 'ValidatorDescr_validator_addr'; + readonly public_key: SigPubKey; + readonly weight: number; + readonly adnl_addr: BitString; +} + +export type ValidatorSet = ValidatorSet_validators | ValidatorSet_validators_ext; + +export interface ValidatorSet_validators { + readonly kind: 'ValidatorSet_validators'; + readonly utime_since: number; + readonly utime_until: number; + readonly total: number; + readonly main: number; + readonly list: Hashmap; +} + +export interface ValidatorSet_validators_ext { + readonly kind: 'ValidatorSet_validators_ext'; + readonly utime_since: number; + readonly utime_until: number; + readonly total: number; + readonly main: number; + readonly total_weight: number; + readonly list: HashmapE; +} + +export type ConfigParam = ConfigParam__ | ConfigParam__1 | ConfigParam__2 | ConfigParam__3 | ConfigParam__4 | ConfigParam__5 | ConfigParam__6 | ConfigParam__7 | ConfigParam__8 | ConfigParam__9 | ConfigParam__10 | ConfigParam__11 | ConfigParam__12 | ConfigParam__13 | ConfigParam__14 | ConfigParam__15 | ConfigParam__16 | ConfigParam__17 | ConfigParam__18 | ConfigParam__19 | ConfigParam_config_mc_gas_prices | ConfigParam_config_gas_prices | ConfigParam_config_mc_block_limits | ConfigParam_config_block_limits | ConfigParam_config_mc_fwd_prices | ConfigParam_config_fwd_prices | ConfigParam__26 | ConfigParam__27 | ConfigParam__28 | ConfigParam__29 | ConfigParam__30 | ConfigParam__31 | ConfigParam__32 | ConfigParam__33 | ConfigParam__34 | ConfigParam__35 | ConfigParam__36 | ConfigParam__37 | ConfigParam__38 | ConfigParam__39 | ConfigParam__40 | ConfigParam__41 | ConfigParam__42 | ConfigParam__43 | ConfigParam__44; + +export interface ConfigParam__ { + readonly kind: 'ConfigParam__'; + readonly config_addr: BitString; +} + +export interface ConfigParam__1 { + readonly kind: 'ConfigParam__1'; + readonly elector_addr: BitString; +} + +export interface ConfigParam__2 { + readonly kind: 'ConfigParam__2'; + readonly minter_addr: BitString; +} + +export interface ConfigParam__3 { + readonly kind: 'ConfigParam__3'; + readonly fee_collector_addr: BitString; +} + +export interface ConfigParam__4 { + readonly kind: 'ConfigParam__4'; + readonly dns_root_addr: BitString; +} + +export interface ConfigParam__5 { + readonly kind: 'ConfigParam__5'; + readonly anon0: BurningConfig; +} + +export interface ConfigParam__6 { + readonly kind: 'ConfigParam__6'; + readonly mint_new_price: Grams; + readonly mint_add_price: Grams; +} + +export interface ConfigParam__7 { + readonly kind: 'ConfigParam__7'; + readonly to_mint: ExtraCurrencyCollection; +} + +export interface ConfigParam__8 { + readonly kind: 'ConfigParam__8'; + readonly anon0: GlobalVersion; +} + +export interface ConfigParam__9 { + readonly kind: 'ConfigParam__9'; + readonly mandatory_params: Hashmap; +} + +export interface ConfigParam__10 { + readonly kind: 'ConfigParam__10'; + readonly critical_params: Hashmap; +} + +export interface ConfigParam__11 { + readonly kind: 'ConfigParam__11'; + readonly anon0: ConfigVotingSetup; +} + +export interface ConfigParam__12 { + readonly kind: 'ConfigParam__12'; + readonly workchains: HashmapE; +} + +export interface ConfigParam__13 { + readonly kind: 'ConfigParam__13'; + readonly anon0: ComplaintPricing; +} + +export interface ConfigParam__14 { + readonly kind: 'ConfigParam__14'; + readonly anon0: BlockCreateFees; +} + +export interface ConfigParam__15 { + readonly kind: 'ConfigParam__15'; + readonly validators_elected_for: number; + readonly elections_start_before: number; + readonly elections_end_before: number; + readonly stake_held_for: number; +} + +export interface ConfigParam__16 { + readonly kind: 'ConfigParam__16'; + readonly max_validators: number; + readonly max_main_validators: number; + readonly min_validators: number; +} + +export interface ConfigParam__17 { + readonly kind: 'ConfigParam__17'; + readonly min_stake: Grams; + readonly max_stake: Grams; + readonly min_total_stake: Grams; + readonly max_stake_factor: number; +} + +export interface ConfigParam__18 { + readonly kind: 'ConfigParam__18'; + readonly anon0: Hashmap; +} + +export interface ConfigParam__19 { + readonly kind: 'ConfigParam__19'; + readonly global_id: number; +} + +export interface ConfigParam_config_mc_gas_prices { + readonly kind: 'ConfigParam_config_mc_gas_prices'; + readonly anon0: GasLimitsPrices; +} + +export interface ConfigParam_config_gas_prices { + readonly kind: 'ConfigParam_config_gas_prices'; + readonly anon0: GasLimitsPrices; +} + +export interface ConfigParam_config_mc_block_limits { + readonly kind: 'ConfigParam_config_mc_block_limits'; + readonly anon0: BlockLimits; +} + +export interface ConfigParam_config_block_limits { + readonly kind: 'ConfigParam_config_block_limits'; + readonly anon0: BlockLimits; +} + +export interface ConfigParam_config_mc_fwd_prices { + readonly kind: 'ConfigParam_config_mc_fwd_prices'; + readonly anon0: MsgForwardPrices; +} + +export interface ConfigParam_config_fwd_prices { + readonly kind: 'ConfigParam_config_fwd_prices'; + readonly anon0: MsgForwardPrices; +} + +export interface ConfigParam__26 { + readonly kind: 'ConfigParam__26'; + readonly anon0: CatchainConfig; +} + +export interface ConfigParam__27 { + readonly kind: 'ConfigParam__27'; + readonly anon0: ConsensusConfig; +} + +export interface ConfigParam__28 { + readonly kind: 'ConfigParam__28'; + readonly fundamental_smc_addr: HashmapE; +} + +export interface ConfigParam__29 { + readonly kind: 'ConfigParam__29'; + readonly prev_validators: ValidatorSet; +} + +export interface ConfigParam__30 { + readonly kind: 'ConfigParam__30'; + readonly prev_temp_validators: ValidatorSet; +} + +export interface ConfigParam__31 { + readonly kind: 'ConfigParam__31'; + readonly cur_validators: ValidatorSet; +} + +export interface ConfigParam__32 { + readonly kind: 'ConfigParam__32'; + readonly cur_temp_validators: ValidatorSet; +} + +export interface ConfigParam__33 { + readonly kind: 'ConfigParam__33'; + readonly next_validators: ValidatorSet; +} + +export interface ConfigParam__34 { + readonly kind: 'ConfigParam__34'; + readonly next_temp_validators: ValidatorSet; +} + +export interface ConfigParam__35 { + readonly kind: 'ConfigParam__35'; + readonly anon0: HashmapE; +} + +export interface ConfigParam__36 { + readonly kind: 'ConfigParam__36'; + readonly anon0: MisbehaviourPunishmentConfig; +} + +export interface ConfigParam__37 { + readonly kind: 'ConfigParam__37'; + readonly anon0: SizeLimitsConfig; +} + +export interface ConfigParam__38 { + readonly kind: 'ConfigParam__38'; + readonly anon0: SuspendedAddressList; +} + +export interface ConfigParam__39 { + readonly kind: 'ConfigParam__39'; + readonly anon0: OracleBridgeParams; +} + +export interface ConfigParam__40 { + readonly kind: 'ConfigParam__40'; + readonly anon0: OracleBridgeParams; +} + +export interface ConfigParam__41 { + readonly kind: 'ConfigParam__41'; + readonly anon0: OracleBridgeParams; +} + +export interface ConfigParam__42 { + readonly kind: 'ConfigParam__42'; + readonly anon0: JettonBridgeParams; +} + +export interface ConfigParam__43 { + readonly kind: 'ConfigParam__43'; + readonly anon0: JettonBridgeParams; +} + +export interface ConfigParam__44 { + readonly kind: 'ConfigParam__44'; + readonly anon0: JettonBridgeParams; +} + +export interface BurningConfig { + readonly kind: 'BurningConfig'; + readonly blackhole_addr: Maybe; + readonly fee_burn_num: number; + readonly fee_burn_denom: number; +} + +export interface GlobalVersion { + readonly kind: 'GlobalVersion'; + readonly version: number; + readonly capabilities: number; +} + +export interface ConfigProposalSetup { + readonly kind: 'ConfigProposalSetup'; + readonly min_tot_rounds: number; + readonly max_tot_rounds: number; + readonly min_wins: number; + readonly max_losses: number; + readonly min_store_sec: number; + readonly max_store_sec: number; + readonly bit_price: number; + readonly _cell_price: number; +} + +export interface ConfigVotingSetup { + readonly kind: 'ConfigVotingSetup'; + readonly normal_params: ConfigProposalSetup; + readonly critical_params: ConfigProposalSetup; +} + +export interface ConfigProposal { + readonly kind: 'ConfigProposal'; + readonly param_id: number; + readonly param_value: Maybe; + readonly if_hash_equal: Maybe; +} + +export interface ConfigProposalStatus { + readonly kind: 'ConfigProposalStatus'; + readonly expires: number; + readonly proposal: ConfigProposal; + readonly is_critical: boolean; + readonly voters: HashmapE; + readonly remaining_weight: number; + readonly validator_set_id: bigint; + readonly rounds_remaining: number; + readonly wins: number; + readonly losses: number; +} + +export type WorkchainFormat = WorkchainFormat_wfmt_basic | WorkchainFormat_wfmt_ext; + +export interface WorkchainFormat_wfmt_basic { + readonly kind: 'WorkchainFormat_wfmt_basic'; + readonly vm_version: number; + readonly vm_mode: number; +} + +export interface WorkchainFormat_wfmt_ext { + readonly kind: 'WorkchainFormat_wfmt_ext'; + readonly min_addr_len: number; + readonly max_addr_len: number; + readonly addr_len_step: number; + readonly workchain_type_id: number; +} + +export interface WcSplitMergeTimings { + readonly kind: 'WcSplitMergeTimings'; + readonly split_merge_delay: number; + readonly split_merge_interval: number; + readonly min_split_merge_interval: number; + readonly max_split_merge_delay: number; +} + +export type WorkchainDescr = WorkchainDescr_workchain | WorkchainDescr_workchain_v2; + +export interface WorkchainDescr_workchain { + readonly kind: 'WorkchainDescr_workchain'; + readonly enabled_since: number; + readonly actual_min_split: number; + readonly min_split: number; + readonly max_split: number; + readonly basic: number; + readonly active: boolean; + readonly accept_msgs: boolean; + readonly flags: number; + readonly zerostate_root_hash: BitString; + readonly zerostate_file_hash: BitString; + readonly version: number; + readonly format: WorkchainFormat; +} + +export interface WorkchainDescr_workchain_v2 { + readonly kind: 'WorkchainDescr_workchain_v2'; + readonly enabled_since: number; + readonly actual_min_split: number; + readonly min_split: number; + readonly max_split: number; + readonly basic: number; + readonly active: boolean; + readonly accept_msgs: boolean; + readonly flags: number; + readonly zerostate_root_hash: BitString; + readonly zerostate_file_hash: BitString; + readonly version: number; + readonly format: WorkchainFormat; + readonly split_merge_timings: WcSplitMergeTimings; +} + +export interface ComplaintPricing { + readonly kind: 'ComplaintPricing'; + readonly deposit: Grams; + readonly bit_price: Grams; + readonly _cell_price: Grams; +} + +export interface BlockCreateFees { + readonly kind: 'BlockCreateFees'; + readonly masterchain_block_fee: Grams; + readonly basechain_block_fee: Grams; +} + +export interface StoragePrices { + readonly kind: 'StoragePrices'; + readonly utime_since: number; + readonly bit_price_ps: number; + readonly _cell_price_ps: number; + readonly mc_bit_price_ps: number; + readonly mc_cell_price_ps: number; +} + +export type GasLimitsPrices = GasLimitsPrices_gas_prices | GasLimitsPrices_gas_prices_ext | GasLimitsPrices_gas_flat_pfx; + +export interface GasLimitsPrices_gas_prices { + readonly kind: 'GasLimitsPrices_gas_prices'; + readonly gas_price: number; + readonly gas_limit: number; + readonly gas_credit: number; + readonly block_gas_limit: number; + readonly freeze_due_limit: number; + readonly delete_due_limit: number; +} + +export interface GasLimitsPrices_gas_prices_ext { + readonly kind: 'GasLimitsPrices_gas_prices_ext'; + readonly gas_price: number; + readonly gas_limit: number; + readonly special_gas_limit: number; + readonly gas_credit: number; + readonly block_gas_limit: number; + readonly freeze_due_limit: number; + readonly delete_due_limit: number; +} + +export interface GasLimitsPrices_gas_flat_pfx { + readonly kind: 'GasLimitsPrices_gas_flat_pfx'; + readonly flat_gas_limit: number; + readonly flat_gas_price: number; + readonly other: GasLimitsPrices; +} + +export interface ParamLimits { + readonly kind: 'ParamLimits'; + readonly underload: number; + readonly soft_limit: number; + readonly hard_limit: number; +} + +export interface BlockLimits { + readonly kind: 'BlockLimits'; + readonly bytes: ParamLimits; + readonly gas: ParamLimits; + readonly lt_delta: ParamLimits; +} + +export interface MsgForwardPrices { + readonly kind: 'MsgForwardPrices'; + readonly lump_price: number; + readonly bit_price: number; + readonly _cell_price: number; + readonly ihr_price_factor: number; + readonly first_frac: number; + readonly next_frac: number; +} + +export type CatchainConfig = CatchainConfig_catchain_config | CatchainConfig_catchain_config_new; + +export interface CatchainConfig_catchain_config { + readonly kind: 'CatchainConfig_catchain_config'; + readonly mc_catchain_lifetime: number; + readonly shard_catchain_lifetime: number; + readonly shard_validators_lifetime: number; + readonly shard_validators_num: number; +} + +export interface CatchainConfig_catchain_config_new { + readonly kind: 'CatchainConfig_catchain_config_new'; + readonly flags: number; + readonly shuffle_mc_validators: boolean; + readonly mc_catchain_lifetime: number; + readonly shard_catchain_lifetime: number; + readonly shard_validators_lifetime: number; + readonly shard_validators_num: number; +} + +export type ConsensusConfig = ConsensusConfig_consensus_config | ConsensusConfig_consensus_config_new | ConsensusConfig_consensus_config_v3 | ConsensusConfig_consensus_config_v4; + +export interface ConsensusConfig_consensus_config { + readonly kind: 'ConsensusConfig_consensus_config'; + readonly round_candidates: number; + readonly next_candidate_delay_ms: number; + readonly consensus_timeout_ms: number; + readonly fast_attempts: number; + readonly attempt_duration: number; + readonly catchain_max_deps: number; + readonly max_block_bytes: number; + readonly max_collated_bytes: number; +} + +export interface ConsensusConfig_consensus_config_new { + readonly kind: 'ConsensusConfig_consensus_config_new'; + readonly flags: number; + readonly new_catchain_ids: boolean; + readonly round_candidates: number; + readonly next_candidate_delay_ms: number; + readonly consensus_timeout_ms: number; + readonly fast_attempts: number; + readonly attempt_duration: number; + readonly catchain_max_deps: number; + readonly max_block_bytes: number; + readonly max_collated_bytes: number; +} + +export interface ConsensusConfig_consensus_config_v3 { + readonly kind: 'ConsensusConfig_consensus_config_v3'; + readonly flags: number; + readonly new_catchain_ids: boolean; + readonly round_candidates: number; + readonly next_candidate_delay_ms: number; + readonly consensus_timeout_ms: number; + readonly fast_attempts: number; + readonly attempt_duration: number; + readonly catchain_max_deps: number; + readonly max_block_bytes: number; + readonly max_collated_bytes: number; + readonly proto_version: number; +} + +export interface ConsensusConfig_consensus_config_v4 { + readonly kind: 'ConsensusConfig_consensus_config_v4'; + readonly flags: number; + readonly new_catchain_ids: boolean; + readonly round_candidates: number; + readonly next_candidate_delay_ms: number; + readonly consensus_timeout_ms: number; + readonly fast_attempts: number; + readonly attempt_duration: number; + readonly catchain_max_deps: number; + readonly max_block_bytes: number; + readonly max_collated_bytes: number; + readonly proto_version: number; + readonly catchain_max_blocks_coeff: number; +} + +export interface ValidatorTempKey { + readonly kind: 'ValidatorTempKey'; + readonly adnl_addr: BitString; + readonly temp_public_key: SigPubKey; + readonly seqno: number; + readonly valid_until: number; +} + +export interface ValidatorSignedTempKey { + readonly kind: 'ValidatorSignedTempKey'; + readonly key: ValidatorTempKey; + readonly signature: CryptoSignature; +} + +export interface MisbehaviourPunishmentConfig { + readonly kind: 'MisbehaviourPunishmentConfig'; + readonly default_flat_fine: Grams; + readonly default_proportional_fine: number; + readonly severity_flat_mult: number; + readonly severity_proportional_mult: number; + readonly unpunishable_interval: number; + readonly long_interval: number; + readonly long_flat_mult: number; + readonly long_proportional_mult: number; + readonly medium_interval: number; + readonly medium_flat_mult: number; + readonly medium_proportional_mult: number; +} + +export type SizeLimitsConfig = SizeLimitsConfig_size_limits_config | SizeLimitsConfig_size_limits_config_v2; + +export interface SizeLimitsConfig_size_limits_config { + readonly kind: 'SizeLimitsConfig_size_limits_config'; + readonly max_msg_bits: number; + readonly max_msg_cells: number; + readonly max_library_cells: number; + readonly max_vm_data_depth: number; + readonly max_ext_msg_size: number; + readonly max_ext_msg_depth: number; +} + +export interface SizeLimitsConfig_size_limits_config_v2 { + readonly kind: 'SizeLimitsConfig_size_limits_config_v2'; + readonly max_msg_bits: number; + readonly max_msg_cells: number; + readonly max_library_cells: number; + readonly max_vm_data_depth: number; + readonly max_ext_msg_size: number; + readonly max_ext_msg_depth: number; + readonly max_acc_state_cells: number; + readonly max_acc_state_bits: number; + readonly max_acc_public_libraries: number; +} + +export interface SuspendedAddressList { + readonly kind: 'SuspendedAddressList'; + readonly addresses: HashmapE; + readonly suspended_until: number; +} + +export interface OracleBridgeParams { + readonly kind: 'OracleBridgeParams'; + readonly bridge_address: BitString; + readonly oracle_mutlisig_address: BitString; + readonly oracles: HashmapE; + readonly external_chain_address: BitString; +} + +export interface JettonBridgePrices { + readonly kind: 'JettonBridgePrices'; + readonly bridge_burn_fee: Coins; + readonly bridge_mint_fee: Coins; + readonly wallet_min_tons_for_storage: Coins; + readonly wallet_gas_consumption: Coins; + readonly minter_min_tons_for_storage: Coins; + readonly discover_gas_consumption: Coins; +} + +export type JettonBridgeParams = JettonBridgeParams_jetton_bridge_params_v0 | JettonBridgeParams_jetton_bridge_params_v1; + +export interface JettonBridgeParams_jetton_bridge_params_v0 { + readonly kind: 'JettonBridgeParams_jetton_bridge_params_v0'; + readonly bridge_address: BitString; + readonly oracles_address: BitString; + readonly oracles: HashmapE; + readonly state_flags: number; + readonly burn_bridge_fee: Coins; +} + +export interface JettonBridgeParams_jetton_bridge_params_v1 { + readonly kind: 'JettonBridgeParams_jetton_bridge_params_v1'; + readonly bridge_address: BitString; + readonly oracles_address: BitString; + readonly oracles: HashmapE; + readonly state_flags: number; + readonly prices: JettonBridgePrices; + readonly external_chain_address: BitString; +} + +export interface BlockSignaturesPure { + readonly kind: 'BlockSignaturesPure'; + readonly sig_count: number; + readonly sig_weight: number; + readonly signatures: HashmapE; +} + +export interface BlockSignatures { + readonly kind: 'BlockSignatures'; + readonly validator_info: ValidatorBaseInfo; + readonly pure_signatures: BlockSignaturesPure; +} + +export interface BlockProof { + readonly kind: 'BlockProof'; + readonly proof_for: BlockIdExt; + readonly root: Slice; + readonly signatures: Maybe; +} + +export type ProofChain = ProofChain_chain_empty | ProofChain_chain_link; + +export interface ProofChain_chain_empty { + readonly kind: 'ProofChain_chain_empty'; +} + +export interface ProofChain_chain_link { + readonly kind: 'ProofChain_chain_link'; + readonly n: number; + readonly root: Slice; + readonly prev: ProofChain | undefined; +} + +export interface TopBlockDescr { + readonly kind: 'TopBlockDescr'; + readonly proof_for: BlockIdExt; + readonly signatures: Maybe; + readonly len: number; + readonly chain: ProofChain; +} + +export interface TopBlockDescrSet { + readonly kind: 'TopBlockDescrSet'; + readonly collection: HashmapE; +} + +export interface ProducerInfo { + readonly kind: 'ProducerInfo'; + readonly utime: number; + readonly mc_blk_ref: ExtBlkRef; + readonly state_proof: MERKLE_PROOF; + readonly prod_proof: MERKLE_PROOF; +} + +export type ComplaintDescr = ComplaintDescr_no_blk_gen | ComplaintDescr_no_blk_gen_diff; + +export interface ComplaintDescr_no_blk_gen { + readonly kind: 'ComplaintDescr_no_blk_gen'; + readonly from_utime: number; + readonly prod_info: ProducerInfo; +} + +export interface ComplaintDescr_no_blk_gen_diff { + readonly kind: 'ComplaintDescr_no_blk_gen_diff'; + readonly prod_info_old: ProducerInfo; + readonly prod_info_new: ProducerInfo; +} + +export interface ValidatorComplaint { + readonly kind: 'ValidatorComplaint'; + readonly validator_pubkey: BitString; + readonly description: ComplaintDescr; + readonly created_at: number; + readonly severity: number; + readonly reward_addr: bigint; + readonly paid: Grams; + readonly suggested_fine: Grams; + readonly suggested_fine_part: number; +} + +export interface ValidatorComplaintStatus { + readonly kind: 'ValidatorComplaintStatus'; + readonly complaint: ValidatorComplaint; + readonly voters: HashmapE; + readonly vset_id: bigint; + readonly weight_remaining: number; +} + +export type VmStackValue = VmStackValue_vm_stk_null | VmStackValue_vm_stk_tinyint | VmStackValue_vm_stk_int | VmStackValue_vm_stk_nan | VmStackValue_vm_stk_cell | VmStackValue_vm_stk_slice | VmStackValue_vm_stk_builder | VmStackValue_vm_stk_cont | VmStackValue_vm_stk_tuple; + +export interface VmStackValue_vm_stk_null { + readonly kind: 'VmStackValue_vm_stk_null'; +} + +export interface VmStackValue_vm_stk_tinyint { + readonly kind: 'VmStackValue_vm_stk_tinyint'; + readonly value: number; +} + +export interface VmStackValue_vm_stk_int { + readonly kind: 'VmStackValue_vm_stk_int'; + readonly value: bigint; +} + +export interface VmStackValue_vm_stk_nan { + readonly kind: 'VmStackValue_vm_stk_nan'; +} + +export interface VmStackValue_vm_stk_cell { + readonly kind: 'VmStackValue_vm_stk_cell'; + readonly _cell: Slice; +} + +export interface VmStackValue_vm_stk_slice { + readonly kind: 'VmStackValue_vm_stk_slice'; + readonly _: VmCellSlice; +} + +export interface VmStackValue_vm_stk_builder { + readonly kind: 'VmStackValue_vm_stk_builder'; + readonly _cell: Slice; +} + +export interface VmStackValue_vm_stk_cont { + readonly kind: 'VmStackValue_vm_stk_cont'; + readonly cont: VmCont; +} + +export interface VmStackValue_vm_stk_tuple { + readonly kind: 'VmStackValue_vm_stk_tuple'; + readonly len: number; + readonly data: VmTuple; +} + +export interface VmCellSlice { + readonly kind: 'VmCellSlice'; + readonly _cell: Slice; + readonly st_bits: number; + readonly end_bits: number; + readonly st_ref: number; + readonly end_ref: number; +} + +export type VmTupleRef = VmTupleRef_vm_tupref_nil | VmTupleRef_vm_tupref_single | VmTupleRef_vm_tupref_any; + +export interface VmTupleRef_vm_tupref_nil { + readonly kind: 'VmTupleRef_vm_tupref_nil'; +} + +export interface VmTupleRef_vm_tupref_single { + readonly kind: 'VmTupleRef_vm_tupref_single'; + readonly entry: VmStackValue; +} + +export interface VmTupleRef_vm_tupref_any { + readonly kind: 'VmTupleRef_vm_tupref_any'; + readonly n: number; + readonly ref: VmTuple; +} + +export type VmTuple = VmTuple_vm_tuple_nil | VmTuple_vm_tuple_tcons; + +export interface VmTuple_vm_tuple_nil { + readonly kind: 'VmTuple_vm_tuple_nil'; +} + +export interface VmTuple_vm_tuple_tcons { + readonly kind: 'VmTuple_vm_tuple_tcons'; + readonly n: number; + readonly head: VmTupleRef; + readonly tail: VmStackValue; +} + +export interface VmStack { + readonly kind: 'VmStack'; + readonly depth: number; + readonly stack: VmStackList; +} + +export type VmStackList = VmStackList_vm_stk_nil | VmStackList_vm_stk_cons; + +export interface VmStackList_vm_stk_nil { + readonly kind: 'VmStackList_vm_stk_nil'; +} + +export interface VmStackList_vm_stk_cons { + readonly kind: 'VmStackList_vm_stk_cons'; + readonly n: number; + readonly rest: VmStackList; + readonly tos: VmStackValue; +} + +export interface VmSaveList { + readonly kind: 'VmSaveList'; + readonly cregs: HashmapE; +} + +export interface VmGasLimits { + readonly kind: 'VmGasLimits'; + readonly remaining: number; + readonly max_limit: number; + readonly cur_limit: number; + readonly credit: number; +} + +export interface VmLibraries { + readonly kind: 'VmLibraries'; + readonly libraries: HashmapE; +} + +export interface VmControlData { + readonly kind: 'VmControlData'; + readonly nargs: Maybe; + readonly stack: Maybe; + readonly save: VmSaveList; + readonly cp: Maybe; +} + +export type VmCont = VmCont_vmc_std | VmCont_vmc_envelope | VmCont_vmc_quit | VmCont_vmc_quit_exc | VmCont_vmc_repeat | VmCont_vmc_until | VmCont_vmc_again | VmCont_vmc_while_cond | VmCont_vmc_while_body | VmCont_vmc_pushint; + +export interface VmCont_vmc_std { + readonly kind: 'VmCont_vmc_std'; + readonly cdata: VmControlData; + readonly code: VmCellSlice; +} + +export interface VmCont_vmc_envelope { + readonly kind: 'VmCont_vmc_envelope'; + readonly cdata: VmControlData; + readonly next: VmCont; +} + +export interface VmCont_vmc_quit { + readonly kind: 'VmCont_vmc_quit'; + readonly exit_code: number; +} + +export interface VmCont_vmc_quit_exc { + readonly kind: 'VmCont_vmc_quit_exc'; +} + +export interface VmCont_vmc_repeat { + readonly kind: 'VmCont_vmc_repeat'; + readonly count: number; + readonly body: VmCont; + readonly after: VmCont; +} + +export interface VmCont_vmc_until { + readonly kind: 'VmCont_vmc_until'; + readonly body: VmCont; + readonly after: VmCont; +} + +export interface VmCont_vmc_again { + readonly kind: 'VmCont_vmc_again'; + readonly body: VmCont; +} + +export interface VmCont_vmc_while_cond { + readonly kind: 'VmCont_vmc_while_cond'; + readonly cond: VmCont; + readonly body: VmCont; + readonly after: VmCont; +} + +export interface VmCont_vmc_while_body { + readonly kind: 'VmCont_vmc_while_body'; + readonly cond: VmCont; + readonly body: VmCont; + readonly after: VmCont; +} + +export interface VmCont_vmc_pushint { + readonly kind: 'VmCont_vmc_pushint'; + readonly value: number; + readonly next: VmCont; +} + +export interface DNS_RecordSet { + readonly kind: 'DNS_RecordSet'; + readonly anon0: HashmapE; +} + +export type TextChunkRef = TextChunkRef_chunk_ref_empty | TextChunkRef_chunk_ref; + +export interface TextChunkRef_chunk_ref_empty { + readonly kind: 'TextChunkRef_chunk_ref_empty'; +} + +export interface TextChunkRef_chunk_ref { + readonly kind: 'TextChunkRef_chunk_ref'; + readonly n: number; + readonly ref: TextChunks; +} + +export type TextChunks = TextChunks_text_chunk_empty | TextChunks_text_chunk; + +export interface TextChunks_text_chunk_empty { + readonly kind: 'TextChunks_text_chunk_empty'; +} + +export interface TextChunks_text_chunk { + readonly kind: 'TextChunks_text_chunk'; + readonly n: number; + readonly len: number; + readonly data: BitString; + readonly next: TextChunkRef; +} + +export interface Text { + readonly kind: 'Text'; + readonly chunks: number; + readonly rest: TextChunks; +} + +export type DNSRecord = DNSRecord_dns_text | DNSRecord_dns_next_resolver | DNSRecord_dns_adnl_address | DNSRecord_dns_smc_address | DNSRecord_dns_storage_address; + +export interface DNSRecord_dns_text { + readonly kind: 'DNSRecord_dns_text'; + readonly _: Text; +} + +export interface DNSRecord_dns_next_resolver { + readonly kind: 'DNSRecord_dns_next_resolver'; + readonly resolver: Address; +} + +export interface DNSRecord_dns_adnl_address { + readonly kind: 'DNSRecord_dns_adnl_address'; + readonly adnl_addr: BitString; + readonly flags: number; + readonly proto_list: ProtoList | undefined; +} + +export interface DNSRecord_dns_smc_address { + readonly kind: 'DNSRecord_dns_smc_address'; + readonly smc_addr: Address; + readonly flags: number; + readonly cap_list: SmcCapList | undefined; +} + +export interface DNSRecord_dns_storage_address { + readonly kind: 'DNSRecord_dns_storage_address'; + readonly bag_id: BitString; +} + +export type ProtoList = ProtoList_proto_list_nil | ProtoList_proto_list_next; + +export interface ProtoList_proto_list_nil { + readonly kind: 'ProtoList_proto_list_nil'; +} + +export interface ProtoList_proto_list_next { + readonly kind: 'ProtoList_proto_list_next'; + readonly head: Protocol; + readonly tail: ProtoList; +} + +export interface Protocol { + readonly kind: 'Protocol'; +} + +export type SmcCapList = SmcCapList_cap_list_nil | SmcCapList_cap_list_next; + +export interface SmcCapList_cap_list_nil { + readonly kind: 'SmcCapList_cap_list_nil'; +} + +export interface SmcCapList_cap_list_next { + readonly kind: 'SmcCapList_cap_list_next'; + readonly head: SmcCapability; + readonly tail: SmcCapList; +} + +export type SmcCapability = SmcCapability_cap_method_seqno | SmcCapability_cap_method_pubkey | SmcCapability_cap_is_wallet | SmcCapability_cap_name; + +export interface SmcCapability_cap_method_seqno { + readonly kind: 'SmcCapability_cap_method_seqno'; +} + +export interface SmcCapability_cap_method_pubkey { + readonly kind: 'SmcCapability_cap_method_pubkey'; +} + +export interface SmcCapability_cap_is_wallet { + readonly kind: 'SmcCapability_cap_is_wallet'; +} + +export interface SmcCapability_cap_name { + readonly kind: 'SmcCapability_cap_name'; + readonly name: Text; +} + +export interface ChanConfig { + readonly kind: 'ChanConfig'; + readonly init_timeout: number; + readonly close_timeout: number; + readonly a_key: BitString; + readonly b_key: BitString; + readonly a_addr: Address; + readonly b_addr: Address; + readonly channel_id: number; + readonly min_A_extra: Grams; +} + +export type ChanState = ChanState_chan_state_init | ChanState_chan_state_close | ChanState_chan_state_payout; + +export interface ChanState_chan_state_init { + readonly kind: 'ChanState_chan_state_init'; + readonly signed_A: boolean; + readonly signed_B: boolean; + readonly min_A: Grams; + readonly min_B: Grams; + readonly expire_at: number; + readonly A: Grams; + readonly B: Grams; +} + +export interface ChanState_chan_state_close { + readonly kind: 'ChanState_chan_state_close'; + readonly signed_A: boolean; + readonly signed_B: boolean; + readonly promise_A: Grams; + readonly promise_B: Grams; + readonly expire_at: number; + readonly A: Grams; + readonly B: Grams; +} + +export interface ChanState_chan_state_payout { + readonly kind: 'ChanState_chan_state_payout'; + readonly A: Grams; + readonly B: Grams; +} + +export interface ChanPromise { + readonly kind: 'ChanPromise'; + readonly channel_id: number; + readonly promise_A: Grams; + readonly promise_B: Grams; +} + +export interface ChanSignedPromise { + readonly kind: 'ChanSignedPromise'; + readonly sig: Maybe; + readonly promise: ChanPromise; +} + +export type ChanMsg = ChanMsg_chan_msg_init | ChanMsg_chan_msg_close | ChanMsg_chan_msg_timeout | ChanMsg_chan_msg_payout; + +export interface ChanMsg_chan_msg_init { + readonly kind: 'ChanMsg_chan_msg_init'; + readonly inc_A: Grams; + readonly inc_B: Grams; + readonly min_A: Grams; + readonly min_B: Grams; + readonly channel_id: number; +} + +export interface ChanMsg_chan_msg_close { + readonly kind: 'ChanMsg_chan_msg_close'; + readonly extra_A: Grams; + readonly extra_B: Grams; + readonly promise: ChanSignedPromise; +} + +export interface ChanMsg_chan_msg_timeout { + readonly kind: 'ChanMsg_chan_msg_timeout'; +} + +export interface ChanMsg_chan_msg_payout { + readonly kind: 'ChanMsg_chan_msg_payout'; +} + +export interface ChanSignedMsg { + readonly kind: 'ChanSignedMsg'; + readonly sig_A: Maybe; + readonly sig_B: Maybe; + readonly msg: ChanMsg; +} + +export interface ChanOp { + readonly kind: 'ChanOp'; + readonly msg: ChanSignedMsg; +} + +export interface ChanData { + readonly kind: 'ChanData'; + readonly config: ChanConfig; + readonly state: ChanState; +} + +// unit$_ = Unit; + +export function loadUnit(slice: Slice): Unit { + return { + kind: 'Unit', + } + +} + +export function storeUnit(unit: Unit): (builder: Builder) => void { + return ((builder: Builder) => { + }) + +} + +// true$_ = True; + +export function loadTrue(slice: Slice): True { + return { + kind: 'True', + } + +} + +export function storeTrue(true0: True): (builder: Builder) => void { + return ((builder: Builder) => { + }) + +} + +// bool_false$0 = BoolFalse; + +export function loadBoolFalse(slice: Slice): BoolFalse { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'BoolFalse', + } + + } + throw new Error('Expected one of "BoolFalse" in loading "BoolFalse", but data does not satisfy any constructor'); +} + +export function storeBoolFalse(boolFalse: BoolFalse): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + +} + +// bool_true$1 = BoolTrue; + +export function loadBoolTrue(slice: Slice): BoolTrue { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + return { + kind: 'BoolTrue', + } + + } + throw new Error('Expected one of "BoolTrue" in loading "BoolTrue", but data does not satisfy any constructor'); +} + +export function storeBoolTrue(boolTrue: BoolTrue): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + }) + +} + +// nothing$0 {X:Type} = Maybe X; + +// just$1 {X:Type} value:X = Maybe X; + +export function loadMaybe(slice: Slice, loadX: (slice: Slice) => X): Maybe { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'Maybe_nothing', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let value: X = loadX(slice); + return { + kind: 'Maybe_just', + value: value, + } + + } + throw new Error('Expected one of "Maybe_nothing", "Maybe_just" in loading "Maybe", but data does not satisfy any constructor'); +} + +export function storeMaybe(maybe: Maybe, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((maybe.kind == 'Maybe_nothing')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((maybe.kind == 'Maybe_just')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeX(maybe.value)(builder); + }) + + } + throw new Error('Expected one of "Maybe_nothing", "Maybe_just" in loading "Maybe", but data does not satisfy any constructor'); +} + +// left$0 {X:Type} {Y:Type} value:X = Either X Y; + +// right$1 {X:Type} {Y:Type} value:Y = Either X Y; + +export function loadEither(slice: Slice, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): Either { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let value: X = loadX(slice); + return { + kind: 'Either_left', + value: value, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let value: Y = loadY(slice); + return { + kind: 'Either_right', + value: value, + } + + } + throw new Error('Expected one of "Either_left", "Either_right" in loading "Either", but data does not satisfy any constructor'); +} + +export function storeEither(either: Either, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((either.kind == 'Either_left')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeX(either.value)(builder); + }) + + } + if ((either.kind == 'Either_right')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeY(either.value)(builder); + }) + + } + throw new Error('Expected one of "Either_left", "Either_right" in loading "Either", but data does not satisfy any constructor'); +} + +// pair$_ {X:Type} {Y:Type} first:X second:Y = Both X Y; + +export function loadBoth(slice: Slice, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): Both { + let first: X = loadX(slice); + let second: Y = loadY(slice); + return { + kind: 'Both', + first: first, + second: second, + } + +} + +export function storeBoth(both: Both, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeX(both.first)(builder); + storeY(both.second)(builder); + }) + +} + +// bit$_ (## 1) = Bit; + +export function loadBit(slice: Slice): Bit { + let anon0: number = slice.loadUint(1); + return { + kind: 'Bit', + anon0: anon0, + } + +} + +export function storeBit(bit: Bit): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(bit.anon0, 1); + }) + +} + +export function hashmap_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; +*/ + +export function loadHashmap(slice: Slice, n: number, loadX: (slice: Slice) => X): Hashmap { + let label: HmLabel = loadHmLabel(slice, n); + let l = hashmap_get_l(label); + let node: HashmapNode = loadHashmapNode(slice, (n - l), loadX); + return { + kind: 'Hashmap', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storeHashmap(hashmap: Hashmap, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(hashmap.label)(builder); + storeHashmapNode(hashmap.node, storeX)(builder); + }) + +} + +// hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; + +/* +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; +*/ + +export function loadHashmapNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X): HashmapNode { + if ((arg0 == 0)) { + let value: X = loadX(slice); + return { + kind: 'HashmapNode_hmn_leaf', + value: value, + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let left: Hashmap = loadHashmap(slice1, (arg0 - 1), loadX); + let slice2 = slice.loadRef().beginParse(); + let right: Hashmap = loadHashmap(slice2, (arg0 - 1), loadX); + return { + kind: 'HashmapNode_hmn_fork', + n: (arg0 - 1), + left: left, + right: right, + } + + } + throw new Error('Expected one of "HashmapNode_hmn_leaf", "HashmapNode_hmn_fork" in loading "HashmapNode", but data does not satisfy any constructor'); +} + +export function storeHashmapNode(hashmapNode: HashmapNode, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapNode.kind == 'HashmapNode_hmn_leaf')) { + return ((builder: Builder) => { + storeX(hashmapNode.value)(builder); + }) + + } + if ((hashmapNode.kind == 'HashmapNode_hmn_fork')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeHashmap(hashmapNode.left, storeX)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeHashmap(hashmapNode.right, storeX)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "HashmapNode_hmn_leaf", "HashmapNode_hmn_fork" in loading "HashmapNode", but data does not satisfy any constructor'); +} + +export function hmLabel_hml_short_get_n(len: Unary): number { + if ((len.kind == 'Unary_unary_zero')) { + return 0 + + } + if ((len.kind == 'Unary_unary_succ')) { + let n = len.n; + return (n + 1) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" for type "Unary" while getting "len", but data does not satisfy any constructor'); +} + +// hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + +// hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + +// hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + +export function loadHmLabel(slice: Slice, m: number): HmLabel { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let len: Unary = loadUnary(slice); + let n = hmLabel_hml_short_get_n(len); + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBits(1) + + })); + if ((!(n <= m))) { + throw new Error('Condition (n <= m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); + } + return { + kind: 'HmLabel_hml_short', + m: m, + len: len, + n: n, + s: s, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + let n: number = slice.loadUint(bitLen(m)); + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBits(1) + + })); + return { + kind: 'HmLabel_hml_long', + m: m, + n: n, + s: s, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let v: BitString = slice.loadBits(1); + let n: number = slice.loadUint(bitLen(m)); + return { + kind: 'HmLabel_hml_same', + m: m, + v: v, + n: n, + } + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" in loading "HmLabel", but data does not satisfy any constructor'); +} + +export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { + if ((hmLabel.kind == 'HmLabel_hml_short')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeUnary(hmLabel.len)(builder); + hmLabel.s.forEach(((arg: BitString) => { + builder.storeBits(arg); + })); + if ((!(hmLabel.n <= hmLabel.m))) { + throw new Error('Condition (hmLabel.n <= hmLabel.m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); + } + }) + + } + if ((hmLabel.kind == 'HmLabel_hml_long')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); + hmLabel.s.forEach(((arg: BitString) => { + builder.storeBits(arg); + })); + }) + + } + if ((hmLabel.kind == 'HmLabel_hml_same')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + builder.storeBits(hmLabel.v); + builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); + }) + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" in loading "HmLabel", but data does not satisfy any constructor'); +} + +// unary_zero$0 = Unary ~0; + +export function unary_unary_succ_get_n(x: Unary): number { + if ((x.kind == 'Unary_unary_zero')) { + return 0 + + } + if ((x.kind == 'Unary_unary_succ')) { + let n = x.n; + return (n + 1) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" for type "Unary" while getting "x", but data does not satisfy any constructor'); +} + +// unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + +export function loadUnary(slice: Slice): Unary { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'Unary_unary_zero', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let x: Unary = loadUnary(slice); + let n = unary_unary_succ_get_n(x); + return { + kind: 'Unary_unary_succ', + x: x, + n: n, + } + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" in loading "Unary", but data does not satisfy any constructor'); +} + +export function storeUnary(unary: Unary): (builder: Builder) => void { + if ((unary.kind == 'Unary_unary_zero')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((unary.kind == 'Unary_unary_succ')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeUnary(unary.x)(builder); + }) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" in loading "Unary", but data does not satisfy any constructor'); +} + +// hme_empty$0 {n:#} {X:Type} = HashmapE n X; + +// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + +export function loadHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): HashmapE { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'HashmapE_hme_empty', + n: n, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let root: Hashmap = loadHashmap(slice1, n, loadX); + return { + kind: 'HashmapE_hme_root', + n: n, + root: root, + } + + } + throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); +} + +export function storeHashmapE(hashmapE: HashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapE.kind == 'HashmapE_hme_empty')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((hashmapE.kind == 'HashmapE_hme_root')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeHashmap(hashmapE.root, storeX)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); +} + +// _ {n:#} _:(Hashmap n True) = BitstringSet n; + +export function loadBitstringSet(slice: Slice, n: number): BitstringSet { + let _: Hashmap = loadHashmap(slice, n, loadTrue); + return { + kind: 'BitstringSet', + n: n, + _: _, + } + +} + +export function storeBitstringSet(bitstringSet: BitstringSet): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmap(bitstringSet._, storeTrue)(builder); + }) + +} + +export function hashmapAug_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +*/ + +export function loadHashmapAug(slice: Slice, n: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAug { + let label: HmLabel = loadHmLabel(slice, n); + let l = hashmapAug_get_l(label); + let node: HashmapAugNode = loadHashmapAugNode(slice, (n - l), loadX, loadY); + return { + kind: 'HashmapAug', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storeHashmapAug(hashmapAug: HashmapAug, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(hashmapAug.label)(builder); + storeHashmapAugNode(hashmapAug.node, storeX, storeY)(builder); + }) + +} + +// ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; + +/* +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; +*/ + +export function loadHashmapAugNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAugNode { + if ((arg0 == 0)) { + let extra: Y = loadY(slice); + let value: X = loadX(slice); + return { + kind: 'HashmapAugNode_ahmn_leaf', + extra: extra, + value: value, + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let left: HashmapAug = loadHashmapAug(slice1, (arg0 - 1), loadX, loadY); + let slice2 = slice.loadRef().beginParse(); + let right: HashmapAug = loadHashmapAug(slice2, (arg0 - 1), loadX, loadY); + let extra: Y = loadY(slice); + return { + kind: 'HashmapAugNode_ahmn_fork', + n: (arg0 - 1), + left: left, + right: right, + extra: extra, + } + + } + throw new Error('Expected one of "HashmapAugNode_ahmn_leaf", "HashmapAugNode_ahmn_fork" in loading "HashmapAugNode", but data does not satisfy any constructor'); +} + +export function storeHashmapAugNode(hashmapAugNode: HashmapAugNode, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapAugNode.kind == 'HashmapAugNode_ahmn_leaf')) { + return ((builder: Builder) => { + storeY(hashmapAugNode.extra)(builder); + storeX(hashmapAugNode.value)(builder); + }) + + } + if ((hashmapAugNode.kind == 'HashmapAugNode_ahmn_fork')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeHashmapAug(hashmapAugNode.left, storeX, storeY)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeHashmapAug(hashmapAugNode.right, storeX, storeY)(cell2); + builder.storeRef(cell2); + storeY(hashmapAugNode.extra)(builder); + }) + + } + throw new Error('Expected one of "HashmapAugNode_ahmn_leaf", "HashmapAugNode_ahmn_fork" in loading "HashmapAugNode", but data does not satisfy any constructor'); +} + +/* +ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y + = HashmapAugE n X Y; +*/ + +/* +ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) + extra:Y = HashmapAugE n X Y; +*/ + +export function loadHashmapAugE(slice: Slice, n: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAugE { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let extra: Y = loadY(slice); + return { + kind: 'HashmapAugE_ahme_empty', + n: n, + extra: extra, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let root: HashmapAug = loadHashmapAug(slice1, n, loadX, loadY); + let extra: Y = loadY(slice); + return { + kind: 'HashmapAugE_ahme_root', + n: n, + root: root, + extra: extra, + } + + } + throw new Error('Expected one of "HashmapAugE_ahme_empty", "HashmapAugE_ahme_root" in loading "HashmapAugE", but data does not satisfy any constructor'); +} + +export function storeHashmapAugE(hashmapAugE: HashmapAugE, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapAugE.kind == 'HashmapAugE_ahme_empty')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeY(hashmapAugE.extra)(builder); + }) + + } + if ((hashmapAugE.kind == 'HashmapAugE_ahme_root')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeHashmapAug(hashmapAugE.root, storeX, storeY)(cell1); + builder.storeRef(cell1); + storeY(hashmapAugE.extra)(builder); + }) + + } + throw new Error('Expected one of "HashmapAugE_ahme_empty", "HashmapAugE_ahme_root" in loading "HashmapAugE", but data does not satisfy any constructor'); +} + +export function varHashmap_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +vhm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(VarHashmapNode m X) + = VarHashmap n X; +*/ + +export function loadVarHashmap(slice: Slice, n: number, loadX: (slice: Slice) => X): VarHashmap { + let label: HmLabel = loadHmLabel(slice, n); + let l = varHashmap_get_l(label); + let node: VarHashmapNode = loadVarHashmapNode(slice, (n - l), loadX); + return { + kind: 'VarHashmap', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storeVarHashmap(varHashmap: VarHashmap, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(varHashmap.label)(builder); + storeVarHashmapNode(varHashmap.node, storeX)(builder); + }) + +} + +// vhmn_leaf$00 {n:#} {X:Type} value:X = VarHashmapNode n X; + +/* +vhmn_fork$01 {n:#} {X:Type} left:^(VarHashmap n X) + right:^(VarHashmap n X) value:(Maybe X) + = VarHashmapNode (n + 1) X; +*/ + +/* +vhmn_cont$1 {n:#} {X:Type} branch:Bit child:^(VarHashmap n X) + value:X = VarHashmapNode (n + 1) X; +*/ + +export function loadVarHashmapNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X): VarHashmapNode { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + let value: X = loadX(slice); + return { + kind: 'VarHashmapNode_vhmn_leaf', + n: arg0, + value: value, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + let slice1 = slice.loadRef().beginParse(); + let left: VarHashmap = loadVarHashmap(slice1, (arg0 - 1), loadX); + let slice2 = slice.loadRef().beginParse(); + let right: VarHashmap = loadVarHashmap(slice2, (arg0 - 1), loadX); + let value: Maybe = loadMaybe(slice, loadX); + return { + kind: 'VarHashmapNode_vhmn_fork', + n: (arg0 - 1), + left: left, + right: right, + value: value, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let branch: BitString = slice.loadBits(1); + let slice1 = slice.loadRef().beginParse(); + let child: VarHashmap = loadVarHashmap(slice1, (arg0 - 1), loadX); + let value: X = loadX(slice); + return { + kind: 'VarHashmapNode_vhmn_cont', + n: (arg0 - 1), + branch: branch, + child: child, + value: value, + } + + } + throw new Error('Expected one of "VarHashmapNode_vhmn_leaf", "VarHashmapNode_vhmn_fork", "VarHashmapNode_vhmn_cont" in loading "VarHashmapNode", but data does not satisfy any constructor'); +} + +export function storeVarHashmapNode(varHashmapNode: VarHashmapNode, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((varHashmapNode.kind == 'VarHashmapNode_vhmn_leaf')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + storeX(varHashmapNode.value)(builder); + }) + + } + if ((varHashmapNode.kind == 'VarHashmapNode_vhmn_fork')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + let cell1 = beginCell(); + storeVarHashmap(varHashmapNode.left, storeX)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeVarHashmap(varHashmapNode.right, storeX)(cell2); + builder.storeRef(cell2); + storeMaybe(varHashmapNode.value, storeX)(builder); + }) + + } + if ((varHashmapNode.kind == 'VarHashmapNode_vhmn_cont')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + builder.storeBits(varHashmapNode.branch); + let cell1 = beginCell(); + storeVarHashmap(varHashmapNode.child, storeX)(cell1); + builder.storeRef(cell1); + storeX(varHashmapNode.value)(builder); + }) + + } + throw new Error('Expected one of "VarHashmapNode_vhmn_leaf", "VarHashmapNode_vhmn_fork", "VarHashmapNode_vhmn_cont" in loading "VarHashmapNode", but data does not satisfy any constructor'); +} + +// vhme_empty$0 {n:#} {X:Type} = VarHashmapE n X; + +/* +vhme_root$1 {n:#} {X:Type} root:^(VarHashmap n X) + = VarHashmapE n X; +*/ + +export function loadVarHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): VarHashmapE { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'VarHashmapE_vhme_empty', + n: n, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let root: VarHashmap = loadVarHashmap(slice1, n, loadX); + return { + kind: 'VarHashmapE_vhme_root', + n: n, + root: root, + } + + } + throw new Error('Expected one of "VarHashmapE_vhme_empty", "VarHashmapE_vhme_root" in loading "VarHashmapE", but data does not satisfy any constructor'); +} + +export function storeVarHashmapE(varHashmapE: VarHashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((varHashmapE.kind == 'VarHashmapE_vhme_empty')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((varHashmapE.kind == 'VarHashmapE_vhme_root')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeVarHashmap(varHashmapE.root, storeX)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "VarHashmapE_vhme_empty", "VarHashmapE_vhme_root" in loading "VarHashmapE", but data does not satisfy any constructor'); +} + +export function pfxHashmap_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +phm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(PfxHashmapNode m X) + = PfxHashmap n X; +*/ + +export function loadPfxHashmap(slice: Slice, n: number, loadX: (slice: Slice) => X): PfxHashmap { + let label: HmLabel = loadHmLabel(slice, n); + let l = pfxHashmap_get_l(label); + let node: PfxHashmapNode = loadPfxHashmapNode(slice, (n - l), loadX); + return { + kind: 'PfxHashmap', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storePfxHashmap(pfxHashmap: PfxHashmap, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(pfxHashmap.label)(builder); + storePfxHashmapNode(pfxHashmap.node, storeX)(builder); + }) + +} + +// phmn_leaf$0 {n:#} {X:Type} value:X = PfxHashmapNode n X; + +/* +phmn_fork$1 {n:#} {X:Type} left:^(PfxHashmap n X) + right:^(PfxHashmap n X) = PfxHashmapNode (n + 1) X; +*/ + +export function loadPfxHashmapNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X): PfxHashmapNode { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let value: X = loadX(slice); + return { + kind: 'PfxHashmapNode_phmn_leaf', + n: arg0, + value: value, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let left: PfxHashmap = loadPfxHashmap(slice1, (arg0 - 1), loadX); + let slice2 = slice.loadRef().beginParse(); + let right: PfxHashmap = loadPfxHashmap(slice2, (arg0 - 1), loadX); + return { + kind: 'PfxHashmapNode_phmn_fork', + n: (arg0 - 1), + left: left, + right: right, + } + + } + throw new Error('Expected one of "PfxHashmapNode_phmn_leaf", "PfxHashmapNode_phmn_fork" in loading "PfxHashmapNode", but data does not satisfy any constructor'); +} + +export function storePfxHashmapNode(pfxHashmapNode: PfxHashmapNode, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((pfxHashmapNode.kind == 'PfxHashmapNode_phmn_leaf')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeX(pfxHashmapNode.value)(builder); + }) + + } + if ((pfxHashmapNode.kind == 'PfxHashmapNode_phmn_fork')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storePfxHashmap(pfxHashmapNode.left, storeX)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storePfxHashmap(pfxHashmapNode.right, storeX)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "PfxHashmapNode_phmn_leaf", "PfxHashmapNode_phmn_fork" in loading "PfxHashmapNode", but data does not satisfy any constructor'); +} + +// phme_empty$0 {n:#} {X:Type} = PfxHashmapE n X; + +/* +phme_root$1 {n:#} {X:Type} root:^(PfxHashmap n X) + = PfxHashmapE n X; +*/ + +export function loadPfxHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): PfxHashmapE { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'PfxHashmapE_phme_empty', + n: n, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let root: PfxHashmap = loadPfxHashmap(slice1, n, loadX); + return { + kind: 'PfxHashmapE_phme_root', + n: n, + root: root, + } + + } + throw new Error('Expected one of "PfxHashmapE_phme_empty", "PfxHashmapE_phme_root" in loading "PfxHashmapE", but data does not satisfy any constructor'); +} + +export function storePfxHashmapE(pfxHashmapE: PfxHashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((pfxHashmapE.kind == 'PfxHashmapE_phme_empty')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((pfxHashmapE.kind == 'PfxHashmapE_phme_root')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storePfxHashmap(pfxHashmapE.root, storeX)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "PfxHashmapE_phme_empty", "PfxHashmapE_phme_root" in loading "PfxHashmapE", but data does not satisfy any constructor'); +} + +// addr_none$00 = MsgAddressExt; + +/* +addr_extern$01 len:(## 9) external_address:(bits len) + = MsgAddressExt; +*/ + +export function loadMsgAddressExt(slice: Slice): MsgAddressExt { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + return { + kind: 'MsgAddressExt_addr_none', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + let len: number = slice.loadUint(9); + let external_address: BitString = slice.loadBits(len); + return { + kind: 'MsgAddressExt_addr_extern', + len: len, + external_address: external_address, + } + + } + throw new Error('Expected one of "MsgAddressExt_addr_none", "MsgAddressExt_addr_extern" in loading "MsgAddressExt", but data does not satisfy any constructor'); +} + +export function storeMsgAddressExt(msgAddressExt: MsgAddressExt): (builder: Builder) => void { + if ((msgAddressExt.kind == 'MsgAddressExt_addr_none')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + }) + + } + if ((msgAddressExt.kind == 'MsgAddressExt_addr_extern')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + builder.storeUint(msgAddressExt.len, 9); + builder.storeBits(msgAddressExt.external_address); + }) + + } + throw new Error('Expected one of "MsgAddressExt_addr_none", "MsgAddressExt_addr_extern" in loading "MsgAddressExt", but data does not satisfy any constructor'); +} + +/* +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +*/ + +export function loadAnycast(slice: Slice): Anycast { + let depth: number = slice.loadUint(bitLen(30)); + let rewrite_pfx: BitString = slice.loadBits(depth); + if ((!(depth >= 1))) { + throw new Error('Condition (depth >= 1) is not satisfied while loading "Anycast" for type "Anycast"'); + } + return { + kind: 'Anycast', + depth: depth, + rewrite_pfx: rewrite_pfx, + } + +} + +export function storeAnycast(anycast: Anycast): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(anycast.depth, bitLen(30)); + builder.storeBits(anycast.rewrite_pfx); + if ((!(anycast.depth >= 1))) { + throw new Error('Condition (anycast.depth >= 1) is not satisfied while loading "Anycast" for type "Anycast"'); + } + }) + +} + +// _ _:MsgAddressInt = MsgAddress; + +// _ _:MsgAddressExt = MsgAddress; + +export function loadMsgAddress(slice: Slice): MsgAddress { + if (true) { + let _: Address = slice.loadAddress(); + return { + kind: 'MsgAddress__', + _: _, + } + + } + if (true) { + let _: MsgAddressExt = loadMsgAddressExt(slice); + return { + kind: 'MsgAddress__1', + _: _, + } + + } + throw new Error('Expected one of "MsgAddress__", "MsgAddress__1" in loading "MsgAddress", but data does not satisfy any constructor'); +} + +export function storeMsgAddress(msgAddress: MsgAddress): (builder: Builder) => void { + if ((msgAddress.kind == 'MsgAddress__')) { + return ((builder: Builder) => { + builder.storeAddress(msgAddress._); + }) + + } + if ((msgAddress.kind == 'MsgAddress__1')) { + return ((builder: Builder) => { + storeMsgAddressExt(msgAddress._)(builder); + }) + + } + throw new Error('Expected one of "MsgAddress__", "MsgAddress__1" in loading "MsgAddress", but data does not satisfy any constructor'); +} + +/* +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; +*/ + +export function loadVarUInteger(slice: Slice, n: number): VarUInteger { + let len: number = slice.loadUint(bitLen((n - 1))); + let value: bigint = slice.loadUintBig((len * 8)); + return { + kind: 'VarUInteger', + n: n, + len: len, + value: value, + } + +} + +export function storeVarUInteger(varUInteger: VarUInteger): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(varUInteger.len, bitLen((varUInteger.n - 1))); + builder.storeUint(varUInteger.value, (varUInteger.len * 8)); + }) + +} + +/* +var_int$_ {n:#} len:(#< n) value:(int (len * 8)) + = VarInteger n; +*/ + +export function loadVarInteger(slice: Slice, n: number): VarInteger { + let len: number = slice.loadUint(bitLen((n - 1))); + let value: bigint = slice.loadIntBig((len * 8)); + return { + kind: 'VarInteger', + n: n, + len: len, + value: value, + } + +} + +export function storeVarInteger(varInteger: VarInteger): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(varInteger.len, bitLen((varInteger.n - 1))); + builder.storeInt(varInteger.value, (varInteger.len * 8)); + }) + +} + +// nanograms$_ amount:(VarUInteger 16) = Grams; + +export function loadGrams(slice: Slice): Grams { + let amount: VarUInteger = loadVarUInteger(slice, 16); + return { + kind: 'Grams', + amount: amount, + } + +} + +export function storeGrams(grams: Grams): (builder: Builder) => void { + return ((builder: Builder) => { + storeVarUInteger(grams.amount)(builder); + }) + +} + +// _ grams:Grams = Coins; + +export function loadCoins(slice: Slice): Coins { + let grams: Grams = loadGrams(slice); + return { + kind: 'Coins', + grams: grams, + } + +} + +export function storeCoins(coins: Coins): (builder: Builder) => void { + return ((builder: Builder) => { + storeGrams(coins.grams)(builder); + }) + +} + +/* +extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) + = ExtraCurrencyCollection; +*/ + +export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollection { + let dict: HashmapE = loadHashmapE(slice, 32, ((slice: Slice) => { + return loadVarUInteger(slice, 32) + + })); + return { + kind: 'ExtraCurrencyCollection', + dict: dict, + } + +} + +export function storeExtraCurrencyCollection(extraCurrencyCollection: ExtraCurrencyCollection): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(extraCurrencyCollection.dict, ((arg: VarUInteger) => { + return ((builder: Builder) => { + storeVarUInteger(arg)(builder); + }) + + }))(builder); + }) + +} + +/* +currencies$_ grams:Grams other:ExtraCurrencyCollection + = CurrencyCollection; +*/ + +export function loadCurrencyCollection(slice: Slice): CurrencyCollection { + let grams: Grams = loadGrams(slice); + let other: ExtraCurrencyCollection = loadExtraCurrencyCollection(slice); + return { + kind: 'CurrencyCollection', + grams: grams, + other: other, + } + +} + +export function storeCurrencyCollection(currencyCollection: CurrencyCollection): (builder: Builder) => void { + return ((builder: Builder) => { + storeGrams(currencyCollection.grams)(builder); + storeExtraCurrencyCollection(currencyCollection.other)(builder); + }) + +} + +/* +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddressInt dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfo; +*/ + +/* +ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt + import_fee:Grams = CommonMsgInfo; +*/ + +/* +ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfo; +*/ + +export function loadCommonMsgInfo(slice: Slice): CommonMsgInfo { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let ihr_disabled: boolean = slice.loadBoolean(); + let bounce: boolean = slice.loadBoolean(); + let bounced: boolean = slice.loadBoolean(); + let src: Address = slice.loadAddress(); + let dest: Address = slice.loadAddress(); + let value: CurrencyCollection = loadCurrencyCollection(slice); + let ihr_fee: Grams = loadGrams(slice); + let fwd_fee: Grams = loadGrams(slice); + let created_lt: number = slice.loadUint(64); + let created_at: number = slice.loadUint(32); + return { + kind: 'CommonMsgInfo_int_msg_info', + ihr_disabled: ihr_disabled, + bounce: bounce, + bounced: bounced, + src: src, + dest: dest, + value: value, + ihr_fee: ihr_fee, + fwd_fee: fwd_fee, + created_lt: created_lt, + created_at: created_at, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + let src: MsgAddressExt = loadMsgAddressExt(slice); + let dest: Address = slice.loadAddress(); + let import_fee: Grams = loadGrams(slice); + return { + kind: 'CommonMsgInfo_ext_in_msg_info', + src: src, + dest: dest, + import_fee: import_fee, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let src: Address = slice.loadAddress(); + let dest: MsgAddressExt = loadMsgAddressExt(slice); + let created_lt: number = slice.loadUint(64); + let created_at: number = slice.loadUint(32); + return { + kind: 'CommonMsgInfo_ext_out_msg_info', + src: src, + dest: dest, + created_lt: created_lt, + created_at: created_at, + } + + } + throw new Error('Expected one of "CommonMsgInfo_int_msg_info", "CommonMsgInfo_ext_in_msg_info", "CommonMsgInfo_ext_out_msg_info" in loading "CommonMsgInfo", but data does not satisfy any constructor'); +} + +export function storeCommonMsgInfo(commonMsgInfo: CommonMsgInfo): (builder: Builder) => void { + if ((commonMsgInfo.kind == 'CommonMsgInfo_int_msg_info')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + builder.storeBit(commonMsgInfo.ihr_disabled); + builder.storeBit(commonMsgInfo.bounce); + builder.storeBit(commonMsgInfo.bounced); + builder.storeAddress(commonMsgInfo.src); + builder.storeAddress(commonMsgInfo.dest); + storeCurrencyCollection(commonMsgInfo.value)(builder); + storeGrams(commonMsgInfo.ihr_fee)(builder); + storeGrams(commonMsgInfo.fwd_fee)(builder); + builder.storeUint(commonMsgInfo.created_lt, 64); + builder.storeUint(commonMsgInfo.created_at, 32); + }) + + } + if ((commonMsgInfo.kind == 'CommonMsgInfo_ext_in_msg_info')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + storeMsgAddressExt(commonMsgInfo.src)(builder); + builder.storeAddress(commonMsgInfo.dest); + storeGrams(commonMsgInfo.import_fee)(builder); + }) + + } + if ((commonMsgInfo.kind == 'CommonMsgInfo_ext_out_msg_info')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + builder.storeAddress(commonMsgInfo.src); + storeMsgAddressExt(commonMsgInfo.dest)(builder); + builder.storeUint(commonMsgInfo.created_lt, 64); + builder.storeUint(commonMsgInfo.created_at, 32); + }) + + } + throw new Error('Expected one of "CommonMsgInfo_int_msg_info", "CommonMsgInfo_ext_in_msg_info", "CommonMsgInfo_ext_out_msg_info" in loading "CommonMsgInfo", but data does not satisfy any constructor'); +} + +/* +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddress dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; +*/ + +/* +ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; +*/ + +export function loadCommonMsgInfoRelaxed(slice: Slice): CommonMsgInfoRelaxed { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let ihr_disabled: boolean = slice.loadBoolean(); + let bounce: boolean = slice.loadBoolean(); + let bounced: boolean = slice.loadBoolean(); + let src: MsgAddress = loadMsgAddress(slice); + let dest: Address = slice.loadAddress(); + let value: CurrencyCollection = loadCurrencyCollection(slice); + let ihr_fee: Grams = loadGrams(slice); + let fwd_fee: Grams = loadGrams(slice); + let created_lt: number = slice.loadUint(64); + let created_at: number = slice.loadUint(32); + return { + kind: 'CommonMsgInfoRelaxed_int_msg_info', + ihr_disabled: ihr_disabled, + bounce: bounce, + bounced: bounced, + src: src, + dest: dest, + value: value, + ihr_fee: ihr_fee, + fwd_fee: fwd_fee, + created_lt: created_lt, + created_at: created_at, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let src: MsgAddress = loadMsgAddress(slice); + let dest: MsgAddressExt = loadMsgAddressExt(slice); + let created_lt: number = slice.loadUint(64); + let created_at: number = slice.loadUint(32); + return { + kind: 'CommonMsgInfoRelaxed_ext_out_msg_info', + src: src, + dest: dest, + created_lt: created_lt, + created_at: created_at, + } + + } + throw new Error('Expected one of "CommonMsgInfoRelaxed_int_msg_info", "CommonMsgInfoRelaxed_ext_out_msg_info" in loading "CommonMsgInfoRelaxed", but data does not satisfy any constructor'); +} + +export function storeCommonMsgInfoRelaxed(commonMsgInfoRelaxed: CommonMsgInfoRelaxed): (builder: Builder) => void { + if ((commonMsgInfoRelaxed.kind == 'CommonMsgInfoRelaxed_int_msg_info')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + builder.storeBit(commonMsgInfoRelaxed.ihr_disabled); + builder.storeBit(commonMsgInfoRelaxed.bounce); + builder.storeBit(commonMsgInfoRelaxed.bounced); + storeMsgAddress(commonMsgInfoRelaxed.src)(builder); + builder.storeAddress(commonMsgInfoRelaxed.dest); + storeCurrencyCollection(commonMsgInfoRelaxed.value)(builder); + storeGrams(commonMsgInfoRelaxed.ihr_fee)(builder); + storeGrams(commonMsgInfoRelaxed.fwd_fee)(builder); + builder.storeUint(commonMsgInfoRelaxed.created_lt, 64); + builder.storeUint(commonMsgInfoRelaxed.created_at, 32); + }) + + } + if ((commonMsgInfoRelaxed.kind == 'CommonMsgInfoRelaxed_ext_out_msg_info')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + storeMsgAddress(commonMsgInfoRelaxed.src)(builder); + storeMsgAddressExt(commonMsgInfoRelaxed.dest)(builder); + builder.storeUint(commonMsgInfoRelaxed.created_lt, 64); + builder.storeUint(commonMsgInfoRelaxed.created_at, 32); + }) + + } + throw new Error('Expected one of "CommonMsgInfoRelaxed_int_msg_info", "CommonMsgInfoRelaxed_ext_out_msg_info" in loading "CommonMsgInfoRelaxed", but data does not satisfy any constructor'); +} + +// tick_tock$_ tick:Bool tock:Bool = TickTock; + +export function loadTickTock(slice: Slice): TickTock { + let tick: boolean = slice.loadBoolean(); + let tock: boolean = slice.loadBoolean(); + return { + kind: 'TickTock', + tick: tick, + tock: tock, + } + +} + +export function storeTickTock(tickTock: TickTock): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(tickTock.tick); + builder.storeBit(tickTock.tock); + }) + +} + +/* +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(Maybe ^Cell) = StateInit; +*/ + +export function loadStateInit(slice: Slice): StateInit { + let split_depth: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadUint(5) + + })); + let special: Maybe = loadMaybe(slice, loadTickTock); + let code: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + let data: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + let library: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + return { + kind: 'StateInit', + split_depth: split_depth, + special: special, + code: code, + data: data, + library: library, + } + +} + +export function storeStateInit(stateInit: StateInit): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(stateInit.split_depth, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 5); + }) + + }))(builder); + storeMaybe(stateInit.special, storeTickTock)(builder); + storeMaybe(stateInit.code, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeMaybe(stateInit.data, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeMaybe(stateInit.library, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +/* +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(HashmapE 256 SimpleLib) = StateInitWithLibs; +*/ + +export function loadStateInitWithLibs(slice: Slice): StateInitWithLibs { + let split_depth: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadUint(5) + + })); + let special: Maybe = loadMaybe(slice, loadTickTock); + let code: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + let data: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + let library: HashmapE = loadHashmapE(slice, 256, loadSimpleLib); + return { + kind: 'StateInitWithLibs', + split_depth: split_depth, + special: special, + code: code, + data: data, + library: library, + } + +} + +export function storeStateInitWithLibs(stateInitWithLibs: StateInitWithLibs): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(stateInitWithLibs.split_depth, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 5); + }) + + }))(builder); + storeMaybe(stateInitWithLibs.special, storeTickTock)(builder); + storeMaybe(stateInitWithLibs.code, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeMaybe(stateInitWithLibs.data, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeHashmapE(stateInitWithLibs.library, storeSimpleLib)(builder); + }) + +} + +// simple_lib$_ public:Bool root:^Cell = SimpleLib; + +export function loadSimpleLib(slice: Slice): SimpleLib { + let public0: boolean = slice.loadBoolean(); + let slice1 = slice.loadRef().beginParse(); + let root: Slice = slice1; + return { + kind: 'SimpleLib', + public0: public0, + root: root, + } + +} + +export function storeSimpleLib(simpleLib: SimpleLib): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(simpleLib.public0); + let cell1 = beginCell(); + cell1.storeSlice(simpleLib.root); + builder.storeRef(cell1); + }) + +} + +/* +message$_ {X:Type} info:CommonMsgInfo + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = Message X; +*/ + +export function loadMessage(slice: Slice, loadX: (slice: Slice) => X): Message { + let info: CommonMsgInfo = loadCommonMsgInfo(slice); + let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { + return loadEither(slice, loadStateInit, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadStateInit(slice1) + + })) + + })); + let body: Either = loadEither(slice, loadX, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadX(slice1) + + })); + return { + kind: 'Message', + info: info, + init: init, + body: body, + } + +} + +export function storeMessage(message: Message, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeCommonMsgInfo(message.info)(builder); + storeMaybe>(message.init, ((arg: Either) => { + return ((builder: Builder) => { + storeEither(arg, storeStateInit, ((arg: StateInit) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeStateInit(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + + }))(builder); + storeEither(message.body, storeX, ((arg: X) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeX(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +/* +message$_ {X:Type} info:CommonMsgInfoRelaxed + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = MessageRelaxed X; +*/ + +export function loadMessageRelaxed(slice: Slice, loadX: (slice: Slice) => X): MessageRelaxed { + let info: CommonMsgInfoRelaxed = loadCommonMsgInfoRelaxed(slice); + let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { + return loadEither(slice, loadStateInit, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadStateInit(slice1) + + })) + + })); + let body: Either = loadEither(slice, loadX, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadX(slice1) + + })); + return { + kind: 'MessageRelaxed', + info: info, + init: init, + body: body, + } + +} + +export function storeMessageRelaxed(messageRelaxed: MessageRelaxed, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeCommonMsgInfoRelaxed(messageRelaxed.info)(builder); + storeMaybe>(messageRelaxed.init, ((arg: Either) => { + return ((builder: Builder) => { + storeEither(arg, storeStateInit, ((arg: StateInit) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeStateInit(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + + }))(builder); + storeEither(messageRelaxed.body, storeX, ((arg: X) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeX(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// _ (Message Any) = MessageAny; + +export function loadMessageAny(slice: Slice): MessageAny { + let anon0: Message = loadMessage(slice, ((slice: Slice) => { + return slice + + })); + return { + kind: 'MessageAny', + anon0: anon0, + } + +} + +export function storeMessageAny(messageAny: MessageAny): (builder: Builder) => void { + return ((builder: Builder) => { + storeMessage(messageAny.anon0, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(builder); + }) + +} + +/* +interm_addr_regular$0 use_dest_bits:(#<= 96) + = IntermediateAddress; +*/ + +/* +interm_addr_simple$10 workchain_id:int8 addr_pfx:uint64 + = IntermediateAddress; +*/ + +/* +interm_addr_ext$11 workchain_id:int32 addr_pfx:uint64 + = IntermediateAddress; +*/ + +export function loadIntermediateAddress(slice: Slice): IntermediateAddress { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let use_dest_bits: number = slice.loadUint(bitLen(96)); + return { + kind: 'IntermediateAddress_interm_addr_regular', + use_dest_bits: use_dest_bits, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + let workchain_id: number = slice.loadInt(8); + let addr_pfx: number = slice.loadUint(64); + return { + kind: 'IntermediateAddress_interm_addr_simple', + workchain_id: workchain_id, + addr_pfx: addr_pfx, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let workchain_id: number = slice.loadInt(32); + let addr_pfx: number = slice.loadUint(64); + return { + kind: 'IntermediateAddress_interm_addr_ext', + workchain_id: workchain_id, + addr_pfx: addr_pfx, + } + + } + throw new Error('Expected one of "IntermediateAddress_interm_addr_regular", "IntermediateAddress_interm_addr_simple", "IntermediateAddress_interm_addr_ext" in loading "IntermediateAddress", but data does not satisfy any constructor'); +} + +export function storeIntermediateAddress(intermediateAddress: IntermediateAddress): (builder: Builder) => void { + if ((intermediateAddress.kind == 'IntermediateAddress_interm_addr_regular')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + builder.storeUint(intermediateAddress.use_dest_bits, bitLen(96)); + }) + + } + if ((intermediateAddress.kind == 'IntermediateAddress_interm_addr_simple')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + builder.storeInt(intermediateAddress.workchain_id, 8); + builder.storeUint(intermediateAddress.addr_pfx, 64); + }) + + } + if ((intermediateAddress.kind == 'IntermediateAddress_interm_addr_ext')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + builder.storeInt(intermediateAddress.workchain_id, 32); + builder.storeUint(intermediateAddress.addr_pfx, 64); + }) + + } + throw new Error('Expected one of "IntermediateAddress_interm_addr_regular", "IntermediateAddress_interm_addr_simple", "IntermediateAddress_interm_addr_ext" in loading "IntermediateAddress", but data does not satisfy any constructor'); +} + +/* +msg_envelope#4 cur_addr:IntermediateAddress + next_addr:IntermediateAddress fwd_fee_remaining:Grams + msg:^(Message Any) = MsgEnvelope; +*/ + +export function loadMsgEnvelope(slice: Slice): MsgEnvelope { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x4))) { + slice.loadUint(4); + let cur_addr: IntermediateAddress = loadIntermediateAddress(slice); + let next_addr: IntermediateAddress = loadIntermediateAddress(slice); + let fwd_fee_remaining: Grams = loadGrams(slice); + let slice1 = slice.loadRef().beginParse(); + let msg: Message = loadMessage(slice1, ((slice: Slice) => { + return slice + + })); + return { + kind: 'MsgEnvelope', + cur_addr: cur_addr, + next_addr: next_addr, + fwd_fee_remaining: fwd_fee_remaining, + msg: msg, + } + + } + throw new Error('Expected one of "MsgEnvelope" in loading "MsgEnvelope", but data does not satisfy any constructor'); +} + +export function storeMsgEnvelope(msgEnvelope: MsgEnvelope): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4, 4); + storeIntermediateAddress(msgEnvelope.cur_addr)(builder); + storeIntermediateAddress(msgEnvelope.next_addr)(builder); + storeGrams(msgEnvelope.fwd_fee_remaining)(builder); + let cell1 = beginCell(); + storeMessage(msgEnvelope.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + }) + +} + +/* +msg_import_ext$000 msg:^(Message Any) transaction:^Transaction + = InMsg; +*/ + +/* +msg_import_ihr$010 msg:^(Message Any) transaction:^Transaction + ihr_fee:Grams proof_created:^Cell = InMsg; +*/ + +/* +msg_import_imm$011 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +*/ + +/* +msg_import_fin$100 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +*/ + +/* +msg_import_tr$101 in_msg:^MsgEnvelope out_msg:^MsgEnvelope + transit_fee:Grams = InMsg; +*/ + +/* +msg_discard_fin$110 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams = InMsg; +*/ + +/* +msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams proof_delivered:^Cell = InMsg; +*/ + +export function loadInMsg(slice: Slice): InMsg { + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b000))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let msg: Message = loadMessage(slice1, ((slice: Slice) => { + return slice + + })); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + return { + kind: 'InMsg_msg_import_ext', + msg: msg, + transaction: transaction, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let msg: Message = loadMessage(slice1, ((slice: Slice) => { + return slice + + })); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + let ihr_fee: Grams = loadGrams(slice); + let slice3 = slice.loadRef().beginParse(); + let proof_created: Slice = slice3; + return { + kind: 'InMsg_msg_import_ihr', + msg: msg, + transaction: transaction, + ihr_fee: ihr_fee, + proof_created: proof_created, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b011))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + let fwd_fee: Grams = loadGrams(slice); + return { + kind: 'InMsg_msg_import_imm', + in_msg: in_msg, + transaction: transaction, + fwd_fee: fwd_fee, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b100))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + let fwd_fee: Grams = loadGrams(slice); + return { + kind: 'InMsg_msg_import_fin', + in_msg: in_msg, + transaction: transaction, + fwd_fee: fwd_fee, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b101))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice2); + let transit_fee: Grams = loadGrams(slice); + return { + kind: 'InMsg_msg_import_tr', + in_msg: in_msg, + out_msg: out_msg, + transit_fee: transit_fee, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b110))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let transaction_id: number = slice.loadUint(64); + let fwd_fee: Grams = loadGrams(slice); + return { + kind: 'InMsg_msg_discard_fin', + in_msg: in_msg, + transaction_id: transaction_id, + fwd_fee: fwd_fee, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b111))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let transaction_id: number = slice.loadUint(64); + let fwd_fee: Grams = loadGrams(slice); + let slice2 = slice.loadRef().beginParse(); + let proof_delivered: Slice = slice2; + return { + kind: 'InMsg_msg_discard_tr', + in_msg: in_msg, + transaction_id: transaction_id, + fwd_fee: fwd_fee, + proof_delivered: proof_delivered, + } + + } + throw new Error('Expected one of "InMsg_msg_import_ext", "InMsg_msg_import_ihr", "InMsg_msg_import_imm", "InMsg_msg_import_fin", "InMsg_msg_import_tr", "InMsg_msg_discard_fin", "InMsg_msg_discard_tr" in loading "InMsg", but data does not satisfy any constructor'); +} + +export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { + if ((inMsg.kind == 'InMsg_msg_import_ext')) { + return ((builder: Builder) => { + builder.storeUint(0b000, 3); + let cell1 = beginCell(); + storeMessage(inMsg.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(inMsg.transaction)(cell2); + builder.storeRef(cell2); + }) + + } + if ((inMsg.kind == 'InMsg_msg_import_ihr')) { + return ((builder: Builder) => { + builder.storeUint(0b010, 3); + let cell1 = beginCell(); + storeMessage(inMsg.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(inMsg.transaction)(cell2); + builder.storeRef(cell2); + storeGrams(inMsg.ihr_fee)(builder); + let cell3 = beginCell(); + cell3.storeSlice(inMsg.proof_created); + builder.storeRef(cell3); + }) + + } + if ((inMsg.kind == 'InMsg_msg_import_imm')) { + return ((builder: Builder) => { + builder.storeUint(0b011, 3); + let cell1 = beginCell(); + storeMsgEnvelope(inMsg.in_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(inMsg.transaction)(cell2); + builder.storeRef(cell2); + storeGrams(inMsg.fwd_fee)(builder); + }) + + } + if ((inMsg.kind == 'InMsg_msg_import_fin')) { + return ((builder: Builder) => { + builder.storeUint(0b100, 3); + let cell1 = beginCell(); + storeMsgEnvelope(inMsg.in_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(inMsg.transaction)(cell2); + builder.storeRef(cell2); + storeGrams(inMsg.fwd_fee)(builder); + }) + + } + if ((inMsg.kind == 'InMsg_msg_import_tr')) { + return ((builder: Builder) => { + builder.storeUint(0b101, 3); + let cell1 = beginCell(); + storeMsgEnvelope(inMsg.in_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeMsgEnvelope(inMsg.out_msg)(cell2); + builder.storeRef(cell2); + storeGrams(inMsg.transit_fee)(builder); + }) + + } + if ((inMsg.kind == 'InMsg_msg_discard_fin')) { + return ((builder: Builder) => { + builder.storeUint(0b110, 3); + let cell1 = beginCell(); + storeMsgEnvelope(inMsg.in_msg)(cell1); + builder.storeRef(cell1); + builder.storeUint(inMsg.transaction_id, 64); + storeGrams(inMsg.fwd_fee)(builder); + }) + + } + if ((inMsg.kind == 'InMsg_msg_discard_tr')) { + return ((builder: Builder) => { + builder.storeUint(0b111, 3); + let cell1 = beginCell(); + storeMsgEnvelope(inMsg.in_msg)(cell1); + builder.storeRef(cell1); + builder.storeUint(inMsg.transaction_id, 64); + storeGrams(inMsg.fwd_fee)(builder); + let cell2 = beginCell(); + cell2.storeSlice(inMsg.proof_delivered); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "InMsg_msg_import_ext", "InMsg_msg_import_ihr", "InMsg_msg_import_imm", "InMsg_msg_import_fin", "InMsg_msg_import_tr", "InMsg_msg_discard_fin", "InMsg_msg_discard_tr" in loading "InMsg", but data does not satisfy any constructor'); +} + +/* +import_fees$_ fees_collected:Grams + value_imported:CurrencyCollection = ImportFees; +*/ + +export function loadImportFees(slice: Slice): ImportFees { + let fees_collected: Grams = loadGrams(slice); + let value_imported: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'ImportFees', + fees_collected: fees_collected, + value_imported: value_imported, + } + +} + +export function storeImportFees(importFees: ImportFees): (builder: Builder) => void { + return ((builder: Builder) => { + storeGrams(importFees.fees_collected)(builder); + storeCurrencyCollection(importFees.value_imported)(builder); + }) + +} + +// _ (HashmapAugE 256 InMsg ImportFees) = InMsgDescr; + +export function loadInMsgDescr(slice: Slice): InMsgDescr { + let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadInMsg, loadImportFees); + return { + kind: 'InMsgDescr', + anon0: anon0, + } + +} + +export function storeInMsgDescr(inMsgDescr: InMsgDescr): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(inMsgDescr.anon0, storeInMsg, storeImportFees)(builder); + }) + +} + +/* +msg_export_ext$000 msg:^(Message Any) + transaction:^Transaction = OutMsg; +*/ + +/* +msg_export_imm$010 out_msg:^MsgEnvelope + transaction:^Transaction reimport:^InMsg = OutMsg; +*/ + +/* +msg_export_new$001 out_msg:^MsgEnvelope + transaction:^Transaction = OutMsg; +*/ + +/* +msg_export_tr$011 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +*/ + +/* +msg_export_deq$1100 out_msg:^MsgEnvelope + import_block_lt:uint63 = OutMsg; +*/ + +/* +msg_export_deq_short$1101 msg_env_hash:bits256 + next_workchain:int32 next_addr_pfx:uint64 + import_block_lt:uint64 = OutMsg; +*/ + +/* +msg_export_tr_req$111 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +*/ + +/* +msg_export_deq_imm$100 out_msg:^MsgEnvelope + reimport:^InMsg = OutMsg; +*/ + +export function loadOutMsg(slice: Slice): OutMsg { + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b000))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let msg: Message = loadMessage(slice1, ((slice: Slice) => { + return slice + + })); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + return { + kind: 'OutMsg_msg_export_ext', + msg: msg, + transaction: transaction, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + let slice3 = slice.loadRef().beginParse(); + let reimport: InMsg = loadInMsg(slice3); + return { + kind: 'OutMsg_msg_export_imm', + out_msg: out_msg, + transaction: transaction, + reimport: reimport, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b001))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let transaction: Transaction = loadTransaction(slice2); + return { + kind: 'OutMsg_msg_export_new', + out_msg: out_msg, + transaction: transaction, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b011))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let imported: InMsg = loadInMsg(slice2); + return { + kind: 'OutMsg_msg_export_tr', + out_msg: out_msg, + imported: imported, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1100))) { + slice.loadUint(4); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let import_block_lt: number = slice.loadUint(63); + return { + kind: 'OutMsg_msg_export_deq', + out_msg: out_msg, + import_block_lt: import_block_lt, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1101))) { + slice.loadUint(4); + let msg_env_hash: BitString = slice.loadBits(256); + let next_workchain: number = slice.loadInt(32); + let next_addr_pfx: number = slice.loadUint(64); + let import_block_lt: number = slice.loadUint(64); + return { + kind: 'OutMsg_msg_export_deq_short', + msg_env_hash: msg_env_hash, + next_workchain: next_workchain, + next_addr_pfx: next_addr_pfx, + import_block_lt: import_block_lt, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b111))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let imported: InMsg = loadInMsg(slice2); + return { + kind: 'OutMsg_msg_export_tr_req', + out_msg: out_msg, + imported: imported, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b100))) { + slice.loadUint(3); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + let slice2 = slice.loadRef().beginParse(); + let reimport: InMsg = loadInMsg(slice2); + return { + kind: 'OutMsg_msg_export_deq_imm', + out_msg: out_msg, + reimport: reimport, + } + + } + throw new Error('Expected one of "OutMsg_msg_export_ext", "OutMsg_msg_export_imm", "OutMsg_msg_export_new", "OutMsg_msg_export_tr", "OutMsg_msg_export_deq", "OutMsg_msg_export_deq_short", "OutMsg_msg_export_tr_req", "OutMsg_msg_export_deq_imm" in loading "OutMsg", but data does not satisfy any constructor'); +} + +export function storeOutMsg(outMsg: OutMsg): (builder: Builder) => void { + if ((outMsg.kind == 'OutMsg_msg_export_ext')) { + return ((builder: Builder) => { + builder.storeUint(0b000, 3); + let cell1 = beginCell(); + storeMessage(outMsg.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(outMsg.transaction)(cell2); + builder.storeRef(cell2); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_imm')) { + return ((builder: Builder) => { + builder.storeUint(0b010, 3); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(outMsg.transaction)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + storeInMsg(outMsg.reimport)(cell3); + builder.storeRef(cell3); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_new')) { + return ((builder: Builder) => { + builder.storeUint(0b001, 3); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeTransaction(outMsg.transaction)(cell2); + builder.storeRef(cell2); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_tr')) { + return ((builder: Builder) => { + builder.storeUint(0b011, 3); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeInMsg(outMsg.imported)(cell2); + builder.storeRef(cell2); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_deq')) { + return ((builder: Builder) => { + builder.storeUint(0b1100, 4); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + builder.storeUint(outMsg.import_block_lt, 63); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_deq_short')) { + return ((builder: Builder) => { + builder.storeUint(0b1101, 4); + builder.storeBits(outMsg.msg_env_hash); + builder.storeInt(outMsg.next_workchain, 32); + builder.storeUint(outMsg.next_addr_pfx, 64); + builder.storeUint(outMsg.import_block_lt, 64); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_tr_req')) { + return ((builder: Builder) => { + builder.storeUint(0b111, 3); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeInMsg(outMsg.imported)(cell2); + builder.storeRef(cell2); + }) + + } + if ((outMsg.kind == 'OutMsg_msg_export_deq_imm')) { + return ((builder: Builder) => { + builder.storeUint(0b100, 3); + let cell1 = beginCell(); + storeMsgEnvelope(outMsg.out_msg)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeInMsg(outMsg.reimport)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "OutMsg_msg_export_ext", "OutMsg_msg_export_imm", "OutMsg_msg_export_new", "OutMsg_msg_export_tr", "OutMsg_msg_export_deq", "OutMsg_msg_export_deq_short", "OutMsg_msg_export_tr_req", "OutMsg_msg_export_deq_imm" in loading "OutMsg", but data does not satisfy any constructor'); +} + +// _ enqueued_lt:uint64 out_msg:^MsgEnvelope = EnqueuedMsg; + +export function loadEnqueuedMsg(slice: Slice): EnqueuedMsg { + let enqueued_lt: number = slice.loadUint(64); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); + return { + kind: 'EnqueuedMsg', + enqueued_lt: enqueued_lt, + out_msg: out_msg, + } + +} + +export function storeEnqueuedMsg(enqueuedMsg: EnqueuedMsg): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(enqueuedMsg.enqueued_lt, 64); + let cell1 = beginCell(); + storeMsgEnvelope(enqueuedMsg.out_msg)(cell1); + builder.storeRef(cell1); + }) + +} + +// _ (HashmapAugE 256 OutMsg CurrencyCollection) = OutMsgDescr; + +export function loadOutMsgDescr(slice: Slice): OutMsgDescr { + let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadOutMsg, loadCurrencyCollection); + return { + kind: 'OutMsgDescr', + anon0: anon0, + } + +} + +export function storeOutMsgDescr(outMsgDescr: OutMsgDescr): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(outMsgDescr.anon0, storeOutMsg, storeCurrencyCollection)(builder); + }) + +} + +// _ (HashmapAugE 352 EnqueuedMsg uint64) = OutMsgQueue; + +export function loadOutMsgQueue(slice: Slice): OutMsgQueue { + let anon0: HashmapAugE = loadHashmapAugE(slice, 352, loadEnqueuedMsg, ((slice: Slice) => { + return slice.loadUint(64) + + })); + return { + kind: 'OutMsgQueue', + anon0: anon0, + } + +} + +export function storeOutMsgQueue(outMsgQueue: OutMsgQueue): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(outMsgQueue.anon0, storeEnqueuedMsg, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 64); + }) + + }))(builder); + }) + +} + +// processed_upto$_ last_msg_lt:uint64 last_msg_hash:bits256 = ProcessedUpto; + +export function loadProcessedUpto(slice: Slice): ProcessedUpto { + let last_msg_lt: number = slice.loadUint(64); + let last_msg_hash: BitString = slice.loadBits(256); + return { + kind: 'ProcessedUpto', + last_msg_lt: last_msg_lt, + last_msg_hash: last_msg_hash, + } + +} + +export function storeProcessedUpto(processedUpto: ProcessedUpto): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(processedUpto.last_msg_lt, 64); + builder.storeBits(processedUpto.last_msg_hash); + }) + +} + +// _ (HashmapE 96 ProcessedUpto) = ProcessedInfo; + +export function loadProcessedInfo(slice: Slice): ProcessedInfo { + let anon0: HashmapE = loadHashmapE(slice, 96, loadProcessedUpto); + return { + kind: 'ProcessedInfo', + anon0: anon0, + } + +} + +export function storeProcessedInfo(processedInfo: ProcessedInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(processedInfo.anon0, storeProcessedUpto)(builder); + }) + +} + +// ihr_pending$_ import_lt:uint64 = IhrPendingSince; + +export function loadIhrPendingSince(slice: Slice): IhrPendingSince { + let import_lt: number = slice.loadUint(64); + return { + kind: 'IhrPendingSince', + import_lt: import_lt, + } + +} + +export function storeIhrPendingSince(ihrPendingSince: IhrPendingSince): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(ihrPendingSince.import_lt, 64); + }) + +} + +// _ (HashmapE 320 IhrPendingSince) = IhrPendingInfo; + +export function loadIhrPendingInfo(slice: Slice): IhrPendingInfo { + let anon0: HashmapE = loadHashmapE(slice, 320, loadIhrPendingSince); + return { + kind: 'IhrPendingInfo', + anon0: anon0, + } + +} + +export function storeIhrPendingInfo(ihrPendingInfo: IhrPendingInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(ihrPendingInfo.anon0, storeIhrPendingSince)(builder); + }) + +} + +/* +_ out_queue:OutMsgQueue proc_info:ProcessedInfo + ihr_pending:IhrPendingInfo = OutMsgQueueInfo; +*/ + +export function loadOutMsgQueueInfo(slice: Slice): OutMsgQueueInfo { + let out_queue: OutMsgQueue = loadOutMsgQueue(slice); + let proc_info: ProcessedInfo = loadProcessedInfo(slice); + let ihr_pending: IhrPendingInfo = loadIhrPendingInfo(slice); + return { + kind: 'OutMsgQueueInfo', + out_queue: out_queue, + proc_info: proc_info, + ihr_pending: ihr_pending, + } + +} + +export function storeOutMsgQueueInfo(outMsgQueueInfo: OutMsgQueueInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeOutMsgQueue(outMsgQueueInfo.out_queue)(builder); + storeProcessedInfo(outMsgQueueInfo.proc_info)(builder); + storeIhrPendingInfo(outMsgQueueInfo.ihr_pending)(builder); + }) + +} + +/* +storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7) + public_cells:(VarUInteger 7) = StorageUsed; +*/ + +export function loadStorageUsed(slice: Slice): StorageUsed { + let _cells: VarUInteger = loadVarUInteger(slice, 7); + let bits: VarUInteger = loadVarUInteger(slice, 7); + let public_cells: VarUInteger = loadVarUInteger(slice, 7); + return { + kind: 'StorageUsed', + _cells: _cells, + bits: bits, + public_cells: public_cells, + } + +} + +export function storeStorageUsed(storageUsed: StorageUsed): (builder: Builder) => void { + return ((builder: Builder) => { + storeVarUInteger(storageUsed._cells)(builder); + storeVarUInteger(storageUsed.bits)(builder); + storeVarUInteger(storageUsed.public_cells)(builder); + }) + +} + +/* +storage_used_short$_ cells:(VarUInteger 7) + bits:(VarUInteger 7) = StorageUsedShort; +*/ + +export function loadStorageUsedShort(slice: Slice): StorageUsedShort { + let _cells: VarUInteger = loadVarUInteger(slice, 7); + let bits: VarUInteger = loadVarUInteger(slice, 7); + return { + kind: 'StorageUsedShort', + _cells: _cells, + bits: bits, + } + +} + +export function storeStorageUsedShort(storageUsedShort: StorageUsedShort): (builder: Builder) => void { + return ((builder: Builder) => { + storeVarUInteger(storageUsedShort._cells)(builder); + storeVarUInteger(storageUsedShort.bits)(builder); + }) + +} + +/* +storage_info$_ used:StorageUsed last_paid:uint32 + due_payment:(Maybe Grams) = StorageInfo; +*/ + +export function loadStorageInfo(slice: Slice): StorageInfo { + let used: StorageUsed = loadStorageUsed(slice); + let last_paid: number = slice.loadUint(32); + let due_payment: Maybe = loadMaybe(slice, loadGrams); + return { + kind: 'StorageInfo', + used: used, + last_paid: last_paid, + due_payment: due_payment, + } + +} + +export function storeStorageInfo(storageInfo: StorageInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeStorageUsed(storageInfo.used)(builder); + builder.storeUint(storageInfo.last_paid, 32); + storeMaybe(storageInfo.due_payment, storeGrams)(builder); + }) + +} + +// account_none$0 = Account; + +/* +account$1 addr:MsgAddressInt storage_stat:StorageInfo + storage:AccountStorage = Account; +*/ + +export function loadAccount(slice: Slice): Account { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'Account_account_none', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let addr: Address = slice.loadAddress(); + let storage_stat: StorageInfo = loadStorageInfo(slice); + let storage: AccountStorage = loadAccountStorage(slice); + return { + kind: 'Account_account', + addr: addr, + storage_stat: storage_stat, + storage: storage, + } + + } + throw new Error('Expected one of "Account_account_none", "Account_account" in loading "Account", but data does not satisfy any constructor'); +} + +export function storeAccount(account: Account): (builder: Builder) => void { + if ((account.kind == 'Account_account_none')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((account.kind == 'Account_account')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + builder.storeAddress(account.addr); + storeStorageInfo(account.storage_stat)(builder); + storeAccountStorage(account.storage)(builder); + }) + + } + throw new Error('Expected one of "Account_account_none", "Account_account" in loading "Account", but data does not satisfy any constructor'); +} + +/* +account_storage$_ last_trans_lt:uint64 + balance:CurrencyCollection state:AccountState + = AccountStorage; +*/ + +export function loadAccountStorage(slice: Slice): AccountStorage { + let last_trans_lt: number = slice.loadUint(64); + let balance: CurrencyCollection = loadCurrencyCollection(slice); + let state: AccountState = loadAccountState(slice); + return { + kind: 'AccountStorage', + last_trans_lt: last_trans_lt, + balance: balance, + state: state, + } + +} + +export function storeAccountStorage(accountStorage: AccountStorage): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(accountStorage.last_trans_lt, 64); + storeCurrencyCollection(accountStorage.balance)(builder); + storeAccountState(accountStorage.state)(builder); + }) + +} + +// account_uninit$00 = AccountState; + +// account_active$1 _:StateInit = AccountState; + +// account_frozen$01 state_hash:bits256 = AccountState; + +export function loadAccountState(slice: Slice): AccountState { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + return { + kind: 'AccountState_account_uninit', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let _: StateInit = loadStateInit(slice); + return { + kind: 'AccountState_account_active', + _: _, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + let state_hash: BitString = slice.loadBits(256); + return { + kind: 'AccountState_account_frozen', + state_hash: state_hash, + } + + } + throw new Error('Expected one of "AccountState_account_uninit", "AccountState_account_active", "AccountState_account_frozen" in loading "AccountState", but data does not satisfy any constructor'); +} + +export function storeAccountState(accountState: AccountState): (builder: Builder) => void { + if ((accountState.kind == 'AccountState_account_uninit')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + }) + + } + if ((accountState.kind == 'AccountState_account_active')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeStateInit(accountState._)(builder); + }) + + } + if ((accountState.kind == 'AccountState_account_frozen')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + builder.storeBits(accountState.state_hash); + }) + + } + throw new Error('Expected one of "AccountState_account_uninit", "AccountState_account_active", "AccountState_account_frozen" in loading "AccountState", but data does not satisfy any constructor'); +} + +// acc_state_uninit$00 = AccountStatus; + +// acc_state_frozen$01 = AccountStatus; + +// acc_state_active$10 = AccountStatus; + +// acc_state_nonexist$11 = AccountStatus; + +export function loadAccountStatus(slice: Slice): AccountStatus { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + return { + kind: 'AccountStatus_acc_state_uninit', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + return { + kind: 'AccountStatus_acc_state_frozen', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + return { + kind: 'AccountStatus_acc_state_active', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + return { + kind: 'AccountStatus_acc_state_nonexist', + } + + } + throw new Error('Expected one of "AccountStatus_acc_state_uninit", "AccountStatus_acc_state_frozen", "AccountStatus_acc_state_active", "AccountStatus_acc_state_nonexist" in loading "AccountStatus", but data does not satisfy any constructor'); +} + +export function storeAccountStatus(accountStatus: AccountStatus): (builder: Builder) => void { + if ((accountStatus.kind == 'AccountStatus_acc_state_uninit')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + }) + + } + if ((accountStatus.kind == 'AccountStatus_acc_state_frozen')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + }) + + } + if ((accountStatus.kind == 'AccountStatus_acc_state_active')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + }) + + } + if ((accountStatus.kind == 'AccountStatus_acc_state_nonexist')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + }) + + } + throw new Error('Expected one of "AccountStatus_acc_state_uninit", "AccountStatus_acc_state_frozen", "AccountStatus_acc_state_active", "AccountStatus_acc_state_nonexist" in loading "AccountStatus", but data does not satisfy any constructor'); +} + +/* +account_descr$_ account:^Account last_trans_hash:bits256 + last_trans_lt:uint64 = ShardAccount; +*/ + +export function loadShardAccount(slice: Slice): ShardAccount { + let slice1 = slice.loadRef().beginParse(); + let account: Account = loadAccount(slice1); + let last_trans_hash: BitString = slice.loadBits(256); + let last_trans_lt: number = slice.loadUint(64); + return { + kind: 'ShardAccount', + account: account, + last_trans_hash: last_trans_hash, + last_trans_lt: last_trans_lt, + } + +} + +export function storeShardAccount(shardAccount: ShardAccount): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeAccount(shardAccount.account)(cell1); + builder.storeRef(cell1); + builder.storeBits(shardAccount.last_trans_hash); + builder.storeUint(shardAccount.last_trans_lt, 64); + }) + +} + +// depth_balance$_ split_depth:(#<= 30) balance:CurrencyCollection = DepthBalanceInfo; + +export function loadDepthBalanceInfo(slice: Slice): DepthBalanceInfo { + let split_depth: number = slice.loadUint(bitLen(30)); + let balance: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'DepthBalanceInfo', + split_depth: split_depth, + balance: balance, + } + +} + +export function storeDepthBalanceInfo(depthBalanceInfo: DepthBalanceInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(depthBalanceInfo.split_depth, bitLen(30)); + storeCurrencyCollection(depthBalanceInfo.balance)(builder); + }) + +} + +// _ (HashmapAugE 256 ShardAccount DepthBalanceInfo) = ShardAccounts; + +export function loadShardAccounts(slice: Slice): ShardAccounts { + let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadShardAccount, loadDepthBalanceInfo); + return { + kind: 'ShardAccounts', + anon0: anon0, + } + +} + +export function storeShardAccounts(shardAccounts: ShardAccounts): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(shardAccounts.anon0, storeShardAccount, storeDepthBalanceInfo)(builder); + }) + +} + +/* +transaction$0111 account_addr:bits256 lt:uint64 + prev_trans_hash:bits256 prev_trans_lt:uint64 now:uint32 + outmsg_cnt:uint15 + orig_status:AccountStatus end_status:AccountStatus + ^[ in_msg:(Maybe ^(Message Any)) out_msgs:(HashmapE 15 ^(Message Any)) ] + total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account) + description:^TransactionDescr = Transaction; +*/ + +export function loadTransaction(slice: Slice): Transaction { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0111))) { + slice.loadUint(4); + let account_addr: BitString = slice.loadBits(256); + let lt: number = slice.loadUint(64); + let prev_trans_hash: BitString = slice.loadBits(256); + let prev_trans_lt: number = slice.loadUint(64); + let now: number = slice.loadUint(32); + let outmsg_cnt: number = slice.loadUint(15); + let orig_status: AccountStatus = loadAccountStatus(slice); + let end_status: AccountStatus = loadAccountStatus(slice); + let slice1 = slice.loadRef().beginParse(); + let in_msg: Maybe> = loadMaybe>(slice1, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadMessage(slice1, ((slice: Slice) => { + return slice + + })) + + })); + let out_msgs: HashmapE> = loadHashmapE>(slice1, 15, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadMessage(slice1, ((slice: Slice) => { + return slice + + })) + + })); + let total_fees: CurrencyCollection = loadCurrencyCollection(slice); + let slice2 = slice.loadRef().beginParse(); + let state_update: HASH_UPDATE = loadHASH_UPDATE(slice2, loadAccount); + let slice3 = slice.loadRef().beginParse(); + let description: TransactionDescr = loadTransactionDescr(slice3); + return { + kind: 'Transaction', + account_addr: account_addr, + lt: lt, + prev_trans_hash: prev_trans_hash, + prev_trans_lt: prev_trans_lt, + now: now, + outmsg_cnt: outmsg_cnt, + orig_status: orig_status, + end_status: end_status, + in_msg: in_msg, + out_msgs: out_msgs, + total_fees: total_fees, + state_update: state_update, + description: description, + } + + } + throw new Error('Expected one of "Transaction" in loading "Transaction", but data does not satisfy any constructor'); +} + +export function storeTransaction(transaction: Transaction): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b0111, 4); + builder.storeBits(transaction.account_addr); + builder.storeUint(transaction.lt, 64); + builder.storeBits(transaction.prev_trans_hash); + builder.storeUint(transaction.prev_trans_lt, 64); + builder.storeUint(transaction.now, 32); + builder.storeUint(transaction.outmsg_cnt, 15); + storeAccountStatus(transaction.orig_status)(builder); + storeAccountStatus(transaction.end_status)(builder); + let cell1 = beginCell(); + storeMaybe>(transaction.in_msg, ((arg: Message) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMessage(arg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + + }) + + }))(cell1); + storeHashmapE>(transaction.out_msgs, ((arg: Message) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMessage(arg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + + }) + + }))(cell1); + builder.storeRef(cell1); + storeCurrencyCollection(transaction.total_fees)(builder); + let cell2 = beginCell(); + storeHASH_UPDATE(transaction.state_update, storeAccount)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + storeTransactionDescr(transaction.description)(cell3); + builder.storeRef(cell3); + }) + +} + +/* +merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 + old:^X new:^X = MERKLE_UPDATE X; +*/ + +export function loadMERKLE_UPDATE(slice: Slice, loadX: (slice: Slice) => X): MERKLE_UPDATE { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x02))) { + slice.loadUint(8); + let old_hash: BitString = slice.loadBits(256); + let new_hash: BitString = slice.loadBits(256); + let slice1 = slice.loadRef().beginParse(); + let old: X = loadX(slice1); + let slice2 = slice.loadRef().beginParse(); + let new0: X = loadX(slice2); + return { + kind: 'MERKLE_UPDATE', + old_hash: old_hash, + new_hash: new_hash, + old: old, + new0: new0, + } + + } + throw new Error('Expected one of "MERKLE_UPDATE" in loading "MERKLE_UPDATE", but data does not satisfy any constructor'); +} + +export function storeMERKLE_UPDATE(mERKLE_UPDATE: MERKLE_UPDATE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x02, 8); + builder.storeBits(mERKLE_UPDATE.old_hash); + builder.storeBits(mERKLE_UPDATE.new_hash); + let cell1 = beginCell(); + storeX(mERKLE_UPDATE.old)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeX(mERKLE_UPDATE.new0)(cell2); + builder.storeRef(cell2); + }) + +} + +/* +update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256 + = HASH_UPDATE X; +*/ + +export function loadHASH_UPDATE(slice: Slice, loadX: (slice: Slice) => X): HASH_UPDATE { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x72))) { + slice.loadUint(8); + let old_hash: BitString = slice.loadBits(256); + let new_hash: BitString = slice.loadBits(256); + return { + kind: 'HASH_UPDATE', + old_hash: old_hash, + new_hash: new_hash, + } + + } + throw new Error('Expected one of "HASH_UPDATE" in loading "HASH_UPDATE", but data does not satisfy any constructor'); +} + +export function storeHASH_UPDATE(hASH_UPDATE: HASH_UPDATE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x72, 8); + builder.storeBits(hASH_UPDATE.old_hash); + builder.storeBits(hASH_UPDATE.new_hash); + }) + +} + +// merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; + +export function loadMERKLE_PROOF(slice: Slice, loadX: (slice: Slice) => X): MERKLE_PROOF { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x03))) { + slice.loadUint(8); + let virtual_hash: BitString = slice.loadBits(256); + let depth: number = slice.loadUint(16); + let slice1 = slice.loadRef().beginParse(); + let virtual_root: X = loadX(slice1); + return { + kind: 'MERKLE_PROOF', + virtual_hash: virtual_hash, + depth: depth, + virtual_root: virtual_root, + } + + } + throw new Error('Expected one of "MERKLE_PROOF" in loading "MERKLE_PROOF", but data does not satisfy any constructor'); +} + +export function storeMERKLE_PROOF(mERKLE_PROOF: MERKLE_PROOF, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x03, 8); + builder.storeBits(mERKLE_PROOF.virtual_hash); + builder.storeUint(mERKLE_PROOF.depth, 16); + let cell1 = beginCell(); + storeX(mERKLE_PROOF.virtual_root)(cell1); + builder.storeRef(cell1); + }) + +} + +/* +acc_trans#5 account_addr:bits256 + transactions:(HashmapAug 64 ^Transaction CurrencyCollection) + state_update:^(HASH_UPDATE Account) + = AccountBlock; +*/ + +export function loadAccountBlock(slice: Slice): AccountBlock { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x5))) { + slice.loadUint(4); + let account_addr: BitString = slice.loadBits(256); + let transactions: HashmapAug = loadHashmapAug(slice, 64, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTransaction(slice1) + + }), loadCurrencyCollection); + let slice1 = slice.loadRef().beginParse(); + let state_update: HASH_UPDATE = loadHASH_UPDATE(slice1, loadAccount); + return { + kind: 'AccountBlock', + account_addr: account_addr, + transactions: transactions, + state_update: state_update, + } + + } + throw new Error('Expected one of "AccountBlock" in loading "AccountBlock", but data does not satisfy any constructor'); +} + +export function storeAccountBlock(accountBlock: AccountBlock): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x5, 4); + builder.storeBits(accountBlock.account_addr); + storeHashmapAug(accountBlock.transactions, ((arg: Transaction) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTransaction(arg)(cell1); + builder.storeRef(cell1); + + }) + + }), storeCurrencyCollection)(builder); + let cell1 = beginCell(); + storeHASH_UPDATE(accountBlock.state_update, storeAccount)(cell1); + builder.storeRef(cell1); + }) + +} + +// _ (HashmapAugE 256 AccountBlock CurrencyCollection) = ShardAccountBlocks; + +export function loadShardAccountBlocks(slice: Slice): ShardAccountBlocks { + let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadAccountBlock, loadCurrencyCollection); + return { + kind: 'ShardAccountBlocks', + anon0: anon0, + } + +} + +export function storeShardAccountBlocks(shardAccountBlocks: ShardAccountBlocks): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(shardAccountBlocks.anon0, storeAccountBlock, storeCurrencyCollection)(builder); + }) + +} + +/* +tr_phase_storage$_ storage_fees_collected:Grams + storage_fees_due:(Maybe Grams) + status_change:AccStatusChange + = TrStoragePhase; +*/ + +export function loadTrStoragePhase(slice: Slice): TrStoragePhase { + let storage_fees_collected: Grams = loadGrams(slice); + let storage_fees_due: Maybe = loadMaybe(slice, loadGrams); + let status_change: AccStatusChange = loadAccStatusChange(slice); + return { + kind: 'TrStoragePhase', + storage_fees_collected: storage_fees_collected, + storage_fees_due: storage_fees_due, + status_change: status_change, + } + +} + +export function storeTrStoragePhase(trStoragePhase: TrStoragePhase): (builder: Builder) => void { + return ((builder: Builder) => { + storeGrams(trStoragePhase.storage_fees_collected)(builder); + storeMaybe(trStoragePhase.storage_fees_due, storeGrams)(builder); + storeAccStatusChange(trStoragePhase.status_change)(builder); + }) + +} + +// acst_unchanged$0 = AccStatusChange; + +// acst_frozen$10 = AccStatusChange; + +// acst_deleted$11 = AccStatusChange; + +export function loadAccStatusChange(slice: Slice): AccStatusChange { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'AccStatusChange_acst_unchanged', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + return { + kind: 'AccStatusChange_acst_frozen', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + return { + kind: 'AccStatusChange_acst_deleted', + } + + } + throw new Error('Expected one of "AccStatusChange_acst_unchanged", "AccStatusChange_acst_frozen", "AccStatusChange_acst_deleted" in loading "AccStatusChange", but data does not satisfy any constructor'); +} + +export function storeAccStatusChange(accStatusChange: AccStatusChange): (builder: Builder) => void { + if ((accStatusChange.kind == 'AccStatusChange_acst_unchanged')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((accStatusChange.kind == 'AccStatusChange_acst_frozen')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + }) + + } + if ((accStatusChange.kind == 'AccStatusChange_acst_deleted')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + }) + + } + throw new Error('Expected one of "AccStatusChange_acst_unchanged", "AccStatusChange_acst_frozen", "AccStatusChange_acst_deleted" in loading "AccStatusChange", but data does not satisfy any constructor'); +} + +/* +tr_phase_credit$_ due_fees_collected:(Maybe Grams) + credit:CurrencyCollection = TrCreditPhase; +*/ + +export function loadTrCreditPhase(slice: Slice): TrCreditPhase { + let due_fees_collected: Maybe = loadMaybe(slice, loadGrams); + let credit: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'TrCreditPhase', + due_fees_collected: due_fees_collected, + credit: credit, + } + +} + +export function storeTrCreditPhase(trCreditPhase: TrCreditPhase): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(trCreditPhase.due_fees_collected, storeGrams)(builder); + storeCurrencyCollection(trCreditPhase.credit)(builder); + }) + +} + +/* +tr_phase_compute_skipped$0 reason:ComputeSkipReason + = TrComputePhase; +*/ + +/* +tr_phase_compute_vm$1 success:Bool msg_state_used:Bool + account_activated:Bool gas_fees:Grams + ^[ gas_used:(VarUInteger 7) + gas_limit:(VarUInteger 7) gas_credit:(Maybe (VarUInteger 3)) + mode:int8 exit_code:int32 exit_arg:(Maybe int32) + vm_steps:uint32 + vm_init_state_hash:bits256 vm_final_state_hash:bits256 ] + = TrComputePhase; +*/ + +export function loadTrComputePhase(slice: Slice): TrComputePhase { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let reason: ComputeSkipReason = loadComputeSkipReason(slice); + return { + kind: 'TrComputePhase_tr_phase_compute_skipped', + reason: reason, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let success: boolean = slice.loadBoolean(); + let msg_state_used: boolean = slice.loadBoolean(); + let account_activated: boolean = slice.loadBoolean(); + let gas_fees: Grams = loadGrams(slice); + let slice1 = slice.loadRef().beginParse(); + let gas_used: VarUInteger = loadVarUInteger(slice1, 7); + let gas_limit: VarUInteger = loadVarUInteger(slice1, 7); + let gas_credit: Maybe = loadMaybe(slice1, ((slice: Slice) => { + return loadVarUInteger(slice, 3) + + })); + let mode: number = slice1.loadInt(8); + let exit_code: number = slice1.loadInt(32); + let exit_arg: Maybe = loadMaybe(slice1, ((slice: Slice) => { + return slice1.loadInt(32) + + })); + let vm_steps: number = slice1.loadUint(32); + let vm_init_state_hash: BitString = slice1.loadBits(256); + let vm_final_state_hash: BitString = slice1.loadBits(256); + return { + kind: 'TrComputePhase_tr_phase_compute_vm', + success: success, + msg_state_used: msg_state_used, + account_activated: account_activated, + gas_fees: gas_fees, + gas_used: gas_used, + gas_limit: gas_limit, + gas_credit: gas_credit, + mode: mode, + exit_code: exit_code, + exit_arg: exit_arg, + vm_steps: vm_steps, + vm_init_state_hash: vm_init_state_hash, + vm_final_state_hash: vm_final_state_hash, + } + + } + throw new Error('Expected one of "TrComputePhase_tr_phase_compute_skipped", "TrComputePhase_tr_phase_compute_vm" in loading "TrComputePhase", but data does not satisfy any constructor'); +} + +export function storeTrComputePhase(trComputePhase: TrComputePhase): (builder: Builder) => void { + if ((trComputePhase.kind == 'TrComputePhase_tr_phase_compute_skipped')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeComputeSkipReason(trComputePhase.reason)(builder); + }) + + } + if ((trComputePhase.kind == 'TrComputePhase_tr_phase_compute_vm')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + builder.storeBit(trComputePhase.success); + builder.storeBit(trComputePhase.msg_state_used); + builder.storeBit(trComputePhase.account_activated); + storeGrams(trComputePhase.gas_fees)(builder); + let cell1 = beginCell(); + storeVarUInteger(trComputePhase.gas_used)(cell1); + storeVarUInteger(trComputePhase.gas_limit)(cell1); + storeMaybe(trComputePhase.gas_credit, ((arg: VarUInteger) => { + return ((builder: Builder) => { + storeVarUInteger(arg)(builder); + }) + + }))(cell1); + cell1.storeInt(trComputePhase.mode, 8); + cell1.storeInt(trComputePhase.exit_code, 32); + storeMaybe(trComputePhase.exit_arg, ((arg: number) => { + return ((builder: Builder) => { + builder.storeInt(arg, 32); + }) + + }))(cell1); + cell1.storeUint(trComputePhase.vm_steps, 32); + cell1.storeBits(trComputePhase.vm_init_state_hash); + cell1.storeBits(trComputePhase.vm_final_state_hash); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "TrComputePhase_tr_phase_compute_skipped", "TrComputePhase_tr_phase_compute_vm" in loading "TrComputePhase", but data does not satisfy any constructor'); +} + +// cskip_no_state$00 = ComputeSkipReason; + +// cskip_bad_state$01 = ComputeSkipReason; + +// cskip_no_gas$10 = ComputeSkipReason; + +// cskip_suspended$110 = ComputeSkipReason; + +export function loadComputeSkipReason(slice: Slice): ComputeSkipReason { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + return { + kind: 'ComputeSkipReason_cskip_no_state', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + return { + kind: 'ComputeSkipReason_cskip_bad_state', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + return { + kind: 'ComputeSkipReason_cskip_no_gas', + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b110))) { + slice.loadUint(3); + return { + kind: 'ComputeSkipReason_cskip_suspended', + } + + } + throw new Error('Expected one of "ComputeSkipReason_cskip_no_state", "ComputeSkipReason_cskip_bad_state", "ComputeSkipReason_cskip_no_gas", "ComputeSkipReason_cskip_suspended" in loading "ComputeSkipReason", but data does not satisfy any constructor'); +} + +export function storeComputeSkipReason(computeSkipReason: ComputeSkipReason): (builder: Builder) => void { + if ((computeSkipReason.kind == 'ComputeSkipReason_cskip_no_state')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + }) + + } + if ((computeSkipReason.kind == 'ComputeSkipReason_cskip_bad_state')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + }) + + } + if ((computeSkipReason.kind == 'ComputeSkipReason_cskip_no_gas')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + }) + + } + if ((computeSkipReason.kind == 'ComputeSkipReason_cskip_suspended')) { + return ((builder: Builder) => { + builder.storeUint(0b110, 3); + }) + + } + throw new Error('Expected one of "ComputeSkipReason_cskip_no_state", "ComputeSkipReason_cskip_bad_state", "ComputeSkipReason_cskip_no_gas", "ComputeSkipReason_cskip_suspended" in loading "ComputeSkipReason", but data does not satisfy any constructor'); +} + +/* +tr_phase_action$_ success:Bool valid:Bool no_funds:Bool + status_change:AccStatusChange + total_fwd_fees:(Maybe Grams) total_action_fees:(Maybe Grams) + result_code:int32 result_arg:(Maybe int32) tot_actions:uint16 + spec_actions:uint16 skipped_actions:uint16 msgs_created:uint16 + action_list_hash:bits256 tot_msg_size:StorageUsedShort + = TrActionPhase; +*/ + +export function loadTrActionPhase(slice: Slice): TrActionPhase { + let success: boolean = slice.loadBoolean(); + let valid: boolean = slice.loadBoolean(); + let no_funds: boolean = slice.loadBoolean(); + let status_change: AccStatusChange = loadAccStatusChange(slice); + let total_fwd_fees: Maybe = loadMaybe(slice, loadGrams); + let total_action_fees: Maybe = loadMaybe(slice, loadGrams); + let result_code: number = slice.loadInt(32); + let result_arg: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadInt(32) + + })); + let tot_actions: number = slice.loadUint(16); + let spec_actions: number = slice.loadUint(16); + let skipped_actions: number = slice.loadUint(16); + let msgs_created: number = slice.loadUint(16); + let action_list_hash: BitString = slice.loadBits(256); + let tot_msg_size: StorageUsedShort = loadStorageUsedShort(slice); + return { + kind: 'TrActionPhase', + success: success, + valid: valid, + no_funds: no_funds, + status_change: status_change, + total_fwd_fees: total_fwd_fees, + total_action_fees: total_action_fees, + result_code: result_code, + result_arg: result_arg, + tot_actions: tot_actions, + spec_actions: spec_actions, + skipped_actions: skipped_actions, + msgs_created: msgs_created, + action_list_hash: action_list_hash, + tot_msg_size: tot_msg_size, + } + +} + +export function storeTrActionPhase(trActionPhase: TrActionPhase): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(trActionPhase.success); + builder.storeBit(trActionPhase.valid); + builder.storeBit(trActionPhase.no_funds); + storeAccStatusChange(trActionPhase.status_change)(builder); + storeMaybe(trActionPhase.total_fwd_fees, storeGrams)(builder); + storeMaybe(trActionPhase.total_action_fees, storeGrams)(builder); + builder.storeInt(trActionPhase.result_code, 32); + storeMaybe(trActionPhase.result_arg, ((arg: number) => { + return ((builder: Builder) => { + builder.storeInt(arg, 32); + }) + + }))(builder); + builder.storeUint(trActionPhase.tot_actions, 16); + builder.storeUint(trActionPhase.spec_actions, 16); + builder.storeUint(trActionPhase.skipped_actions, 16); + builder.storeUint(trActionPhase.msgs_created, 16); + builder.storeBits(trActionPhase.action_list_hash); + storeStorageUsedShort(trActionPhase.tot_msg_size)(builder); + }) + +} + +// tr_phase_bounce_negfunds$00 = TrBouncePhase; + +/* +tr_phase_bounce_nofunds$01 msg_size:StorageUsedShort + req_fwd_fees:Grams = TrBouncePhase; +*/ + +/* +tr_phase_bounce_ok$1 msg_size:StorageUsedShort + msg_fees:Grams fwd_fees:Grams = TrBouncePhase; +*/ + +export function loadTrBouncePhase(slice: Slice): TrBouncePhase { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + return { + kind: 'TrBouncePhase_tr_phase_bounce_negfunds', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + let msg_size: StorageUsedShort = loadStorageUsedShort(slice); + let req_fwd_fees: Grams = loadGrams(slice); + return { + kind: 'TrBouncePhase_tr_phase_bounce_nofunds', + msg_size: msg_size, + req_fwd_fees: req_fwd_fees, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let msg_size: StorageUsedShort = loadStorageUsedShort(slice); + let msg_fees: Grams = loadGrams(slice); + let fwd_fees: Grams = loadGrams(slice); + return { + kind: 'TrBouncePhase_tr_phase_bounce_ok', + msg_size: msg_size, + msg_fees: msg_fees, + fwd_fees: fwd_fees, + } + + } + throw new Error('Expected one of "TrBouncePhase_tr_phase_bounce_negfunds", "TrBouncePhase_tr_phase_bounce_nofunds", "TrBouncePhase_tr_phase_bounce_ok" in loading "TrBouncePhase", but data does not satisfy any constructor'); +} + +export function storeTrBouncePhase(trBouncePhase: TrBouncePhase): (builder: Builder) => void { + if ((trBouncePhase.kind == 'TrBouncePhase_tr_phase_bounce_negfunds')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + }) + + } + if ((trBouncePhase.kind == 'TrBouncePhase_tr_phase_bounce_nofunds')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + storeStorageUsedShort(trBouncePhase.msg_size)(builder); + storeGrams(trBouncePhase.req_fwd_fees)(builder); + }) + + } + if ((trBouncePhase.kind == 'TrBouncePhase_tr_phase_bounce_ok')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeStorageUsedShort(trBouncePhase.msg_size)(builder); + storeGrams(trBouncePhase.msg_fees)(builder); + storeGrams(trBouncePhase.fwd_fees)(builder); + }) + + } + throw new Error('Expected one of "TrBouncePhase_tr_phase_bounce_negfunds", "TrBouncePhase_tr_phase_bounce_nofunds", "TrBouncePhase_tr_phase_bounce_ok" in loading "TrBouncePhase", but data does not satisfy any constructor'); +} + +/* +trans_ord$0000 credit_first:Bool + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool bounce:(Maybe TrBouncePhase) + destroyed:Bool + = TransactionDescr; +*/ + +/* +trans_storage$0001 storage_ph:TrStoragePhase + = TransactionDescr; +*/ + +/* +trans_tick_tock$001 is_tock:Bool storage_ph:TrStoragePhase + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool = TransactionDescr; +*/ + +/* +trans_split_prepare$0100 split_info:SplitMergeInfo + storage_ph:(Maybe TrStoragePhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; +*/ + +/* +trans_split_install$0101 split_info:SplitMergeInfo + prepare_transaction:^Transaction + installed:Bool = TransactionDescr; +*/ + +/* +trans_merge_prepare$0110 split_info:SplitMergeInfo + storage_ph:TrStoragePhase aborted:Bool + = TransactionDescr; +*/ + +/* +trans_merge_install$0111 split_info:SplitMergeInfo + prepare_transaction:^Transaction + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; +*/ + +export function loadTransactionDescr(slice: Slice): TransactionDescr { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0000))) { + slice.loadUint(4); + let credit_first: boolean = slice.loadBoolean(); + let storage_ph: Maybe = loadMaybe(slice, loadTrStoragePhase); + let credit_ph: Maybe = loadMaybe(slice, loadTrCreditPhase); + let compute_ph: TrComputePhase = loadTrComputePhase(slice); + let action: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTrActionPhase(slice1) + + })); + let aborted: boolean = slice.loadBoolean(); + let bounce: Maybe = loadMaybe(slice, loadTrBouncePhase); + let destroyed: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_ord', + credit_first: credit_first, + storage_ph: storage_ph, + credit_ph: credit_ph, + compute_ph: compute_ph, + action: action, + aborted: aborted, + bounce: bounce, + destroyed: destroyed, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0001))) { + slice.loadUint(4); + let storage_ph: TrStoragePhase = loadTrStoragePhase(slice); + return { + kind: 'TransactionDescr_trans_storage', + storage_ph: storage_ph, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b001))) { + slice.loadUint(3); + let is_tock: boolean = slice.loadBoolean(); + let storage_ph: TrStoragePhase = loadTrStoragePhase(slice); + let compute_ph: TrComputePhase = loadTrComputePhase(slice); + let action: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTrActionPhase(slice1) + + })); + let aborted: boolean = slice.loadBoolean(); + let destroyed: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_tick_tock', + is_tock: is_tock, + storage_ph: storage_ph, + compute_ph: compute_ph, + action: action, + aborted: aborted, + destroyed: destroyed, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0100))) { + slice.loadUint(4); + let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); + let storage_ph: Maybe = loadMaybe(slice, loadTrStoragePhase); + let compute_ph: TrComputePhase = loadTrComputePhase(slice); + let action: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTrActionPhase(slice1) + + })); + let aborted: boolean = slice.loadBoolean(); + let destroyed: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_split_prepare', + split_info: split_info, + storage_ph: storage_ph, + compute_ph: compute_ph, + action: action, + aborted: aborted, + destroyed: destroyed, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0101))) { + slice.loadUint(4); + let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); + let slice1 = slice.loadRef().beginParse(); + let prepare_transaction: Transaction = loadTransaction(slice1); + let installed: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_split_install', + split_info: split_info, + prepare_transaction: prepare_transaction, + installed: installed, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0110))) { + slice.loadUint(4); + let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); + let storage_ph: TrStoragePhase = loadTrStoragePhase(slice); + let aborted: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_merge_prepare', + split_info: split_info, + storage_ph: storage_ph, + aborted: aborted, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0111))) { + slice.loadUint(4); + let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); + let slice1 = slice.loadRef().beginParse(); + let prepare_transaction: Transaction = loadTransaction(slice1); + let storage_ph: Maybe = loadMaybe(slice, loadTrStoragePhase); + let credit_ph: Maybe = loadMaybe(slice, loadTrCreditPhase); + let compute_ph: TrComputePhase = loadTrComputePhase(slice); + let action: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTrActionPhase(slice1) + + })); + let aborted: boolean = slice.loadBoolean(); + let destroyed: boolean = slice.loadBoolean(); + return { + kind: 'TransactionDescr_trans_merge_install', + split_info: split_info, + prepare_transaction: prepare_transaction, + storage_ph: storage_ph, + credit_ph: credit_ph, + compute_ph: compute_ph, + action: action, + aborted: aborted, + destroyed: destroyed, + } + + } + throw new Error('Expected one of "TransactionDescr_trans_ord", "TransactionDescr_trans_storage", "TransactionDescr_trans_tick_tock", "TransactionDescr_trans_split_prepare", "TransactionDescr_trans_split_install", "TransactionDescr_trans_merge_prepare", "TransactionDescr_trans_merge_install" in loading "TransactionDescr", but data does not satisfy any constructor'); +} + +export function storeTransactionDescr(transactionDescr: TransactionDescr): (builder: Builder) => void { + if ((transactionDescr.kind == 'TransactionDescr_trans_ord')) { + return ((builder: Builder) => { + builder.storeUint(0b0000, 4); + builder.storeBit(transactionDescr.credit_first); + storeMaybe(transactionDescr.storage_ph, storeTrStoragePhase)(builder); + storeMaybe(transactionDescr.credit_ph, storeTrCreditPhase)(builder); + storeTrComputePhase(transactionDescr.compute_ph)(builder); + storeMaybe(transactionDescr.action, ((arg: TrActionPhase) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTrActionPhase(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + builder.storeBit(transactionDescr.aborted); + storeMaybe(transactionDescr.bounce, storeTrBouncePhase)(builder); + builder.storeBit(transactionDescr.destroyed); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_storage')) { + return ((builder: Builder) => { + builder.storeUint(0b0001, 4); + storeTrStoragePhase(transactionDescr.storage_ph)(builder); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_tick_tock')) { + return ((builder: Builder) => { + builder.storeUint(0b001, 3); + builder.storeBit(transactionDescr.is_tock); + storeTrStoragePhase(transactionDescr.storage_ph)(builder); + storeTrComputePhase(transactionDescr.compute_ph)(builder); + storeMaybe(transactionDescr.action, ((arg: TrActionPhase) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTrActionPhase(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + builder.storeBit(transactionDescr.aborted); + builder.storeBit(transactionDescr.destroyed); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_split_prepare')) { + return ((builder: Builder) => { + builder.storeUint(0b0100, 4); + storeSplitMergeInfo(transactionDescr.split_info)(builder); + storeMaybe(transactionDescr.storage_ph, storeTrStoragePhase)(builder); + storeTrComputePhase(transactionDescr.compute_ph)(builder); + storeMaybe(transactionDescr.action, ((arg: TrActionPhase) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTrActionPhase(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + builder.storeBit(transactionDescr.aborted); + builder.storeBit(transactionDescr.destroyed); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_split_install')) { + return ((builder: Builder) => { + builder.storeUint(0b0101, 4); + storeSplitMergeInfo(transactionDescr.split_info)(builder); + let cell1 = beginCell(); + storeTransaction(transactionDescr.prepare_transaction)(cell1); + builder.storeRef(cell1); + builder.storeBit(transactionDescr.installed); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_merge_prepare')) { + return ((builder: Builder) => { + builder.storeUint(0b0110, 4); + storeSplitMergeInfo(transactionDescr.split_info)(builder); + storeTrStoragePhase(transactionDescr.storage_ph)(builder); + builder.storeBit(transactionDescr.aborted); + }) + + } + if ((transactionDescr.kind == 'TransactionDescr_trans_merge_install')) { + return ((builder: Builder) => { + builder.storeUint(0b0111, 4); + storeSplitMergeInfo(transactionDescr.split_info)(builder); + let cell1 = beginCell(); + storeTransaction(transactionDescr.prepare_transaction)(cell1); + builder.storeRef(cell1); + storeMaybe(transactionDescr.storage_ph, storeTrStoragePhase)(builder); + storeMaybe(transactionDescr.credit_ph, storeTrCreditPhase)(builder); + storeTrComputePhase(transactionDescr.compute_ph)(builder); + storeMaybe(transactionDescr.action, ((arg: TrActionPhase) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTrActionPhase(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + builder.storeBit(transactionDescr.aborted); + builder.storeBit(transactionDescr.destroyed); + }) + + } + throw new Error('Expected one of "TransactionDescr_trans_ord", "TransactionDescr_trans_storage", "TransactionDescr_trans_tick_tock", "TransactionDescr_trans_split_prepare", "TransactionDescr_trans_split_install", "TransactionDescr_trans_merge_prepare", "TransactionDescr_trans_merge_install" in loading "TransactionDescr", but data does not satisfy any constructor'); +} + +/* +split_merge_info$_ cur_shard_pfx_len:(## 6) + acc_split_depth:(## 6) this_addr:bits256 sibling_addr:bits256 + = SplitMergeInfo; +*/ + +export function loadSplitMergeInfo(slice: Slice): SplitMergeInfo { + let cur_shard_pfx_len: number = slice.loadUint(6); + let acc_split_depth: number = slice.loadUint(6); + let this_addr: BitString = slice.loadBits(256); + let sibling_addr: BitString = slice.loadBits(256); + return { + kind: 'SplitMergeInfo', + cur_shard_pfx_len: cur_shard_pfx_len, + acc_split_depth: acc_split_depth, + this_addr: this_addr, + sibling_addr: sibling_addr, + } + +} + +export function storeSplitMergeInfo(splitMergeInfo: SplitMergeInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(splitMergeInfo.cur_shard_pfx_len, 6); + builder.storeUint(splitMergeInfo.acc_split_depth, 6); + builder.storeBits(splitMergeInfo.this_addr); + builder.storeBits(splitMergeInfo.sibling_addr); + }) + +} + +/* +smc_info#076ef1ea actions:uint16 msgs_sent:uint16 + unixtime:uint32 block_lt:uint64 trans_lt:uint64 + rand_seed:bits256 balance_remaining:CurrencyCollection + myself:MsgAddressInt global_config:(Maybe Cell) = SmartContractInfo; +*/ + +export function loadSmartContractInfo(slice: Slice): SmartContractInfo { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x076ef1ea))) { + slice.loadUint(32); + let actions: number = slice.loadUint(16); + let msgs_sent: number = slice.loadUint(16); + let unixtime: number = slice.loadUint(32); + let block_lt: number = slice.loadUint(64); + let trans_lt: number = slice.loadUint(64); + let rand_seed: BitString = slice.loadBits(256); + let balance_remaining: CurrencyCollection = loadCurrencyCollection(slice); + let myself: Address = slice.loadAddress(); + let global_config: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice + + })); + return { + kind: 'SmartContractInfo', + actions: actions, + msgs_sent: msgs_sent, + unixtime: unixtime, + block_lt: block_lt, + trans_lt: trans_lt, + rand_seed: rand_seed, + balance_remaining: balance_remaining, + myself: myself, + global_config: global_config, + } + + } + throw new Error('Expected one of "SmartContractInfo" in loading "SmartContractInfo", but data does not satisfy any constructor'); +} + +export function storeSmartContractInfo(smartContractInfo: SmartContractInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x076ef1ea, 32); + builder.storeUint(smartContractInfo.actions, 16); + builder.storeUint(smartContractInfo.msgs_sent, 16); + builder.storeUint(smartContractInfo.unixtime, 32); + builder.storeUint(smartContractInfo.block_lt, 64); + builder.storeUint(smartContractInfo.trans_lt, 64); + builder.storeBits(smartContractInfo.rand_seed); + storeCurrencyCollection(smartContractInfo.balance_remaining)(builder); + builder.storeAddress(smartContractInfo.myself); + storeMaybe(smartContractInfo.global_config, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(builder); + }) + +} + +// out_list_empty$_ = OutList 0; + +/* +out_list$_ {n:#} prev:^(OutList n) action:OutAction + = OutList (n + 1); +*/ + +export function loadOutList(slice: Slice, arg0: number): OutList { + if ((arg0 == 0)) { + return { + kind: 'OutList_out_list_empty', + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let prev: OutList = loadOutList(slice1, (arg0 - 1)); + let action: OutAction = loadOutAction(slice); + return { + kind: 'OutList_out_list', + n: (arg0 - 1), + prev: prev, + action: action, + } + + } + throw new Error('Expected one of "OutList_out_list_empty", "OutList_out_list" in loading "OutList", but data does not satisfy any constructor'); +} + +export function storeOutList(outList: OutList): (builder: Builder) => void { + if ((outList.kind == 'OutList_out_list_empty')) { + return ((builder: Builder) => { + }) + + } + if ((outList.kind == 'OutList_out_list')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeOutList(outList.prev)(cell1); + builder.storeRef(cell1); + storeOutAction(outList.action)(builder); + }) + + } + throw new Error('Expected one of "OutList_out_list_empty", "OutList_out_list" in loading "OutList", but data does not satisfy any constructor'); +} + +/* +action_send_msg#0ec3c86d mode:(## 8) + out_msg:^(MessageRelaxed Any) = OutAction; +*/ + +// action_set_code#ad4de08e new_code:^Cell = OutAction; + +/* +action_reserve_currency#36e6b809 mode:(## 8) + currency:CurrencyCollection = OutAction; +*/ + +/* +action_change_library#26fa1dd4 mode:(## 7) + libref:LibRef = OutAction; +*/ + +export function loadOutAction(slice: Slice): OutAction { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x0ec3c86d))) { + slice.loadUint(32); + let mode: number = slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let out_msg: MessageRelaxed = loadMessageRelaxed(slice1, ((slice: Slice) => { + return slice + + })); + return { + kind: 'OutAction_action_send_msg', + mode: mode, + out_msg: out_msg, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xad4de08e))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let new_code: Slice = slice1; + return { + kind: 'OutAction_action_set_code', + new_code: new_code, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x36e6b809))) { + slice.loadUint(32); + let mode: number = slice.loadUint(8); + let currency: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'OutAction_action_reserve_currency', + mode: mode, + currency: currency, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x26fa1dd4))) { + slice.loadUint(32); + let mode: number = slice.loadUint(7); + let libref: LibRef = loadLibRef(slice); + return { + kind: 'OutAction_action_change_library', + mode: mode, + libref: libref, + } + + } + throw new Error('Expected one of "OutAction_action_send_msg", "OutAction_action_set_code", "OutAction_action_reserve_currency", "OutAction_action_change_library" in loading "OutAction", but data does not satisfy any constructor'); +} + +export function storeOutAction(outAction: OutAction): (builder: Builder) => void { + if ((outAction.kind == 'OutAction_action_send_msg')) { + return ((builder: Builder) => { + builder.storeUint(0x0ec3c86d, 32); + builder.storeUint(outAction.mode, 8); + let cell1 = beginCell(); + storeMessageRelaxed(outAction.out_msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + }) + + } + if ((outAction.kind == 'OutAction_action_set_code')) { + return ((builder: Builder) => { + builder.storeUint(0xad4de08e, 32); + let cell1 = beginCell(); + cell1.storeSlice(outAction.new_code); + builder.storeRef(cell1); + }) + + } + if ((outAction.kind == 'OutAction_action_reserve_currency')) { + return ((builder: Builder) => { + builder.storeUint(0x36e6b809, 32); + builder.storeUint(outAction.mode, 8); + storeCurrencyCollection(outAction.currency)(builder); + }) + + } + if ((outAction.kind == 'OutAction_action_change_library')) { + return ((builder: Builder) => { + builder.storeUint(0x26fa1dd4, 32); + builder.storeUint(outAction.mode, 7); + storeLibRef(outAction.libref)(builder); + }) + + } + throw new Error('Expected one of "OutAction_action_send_msg", "OutAction_action_set_code", "OutAction_action_reserve_currency", "OutAction_action_change_library" in loading "OutAction", but data does not satisfy any constructor'); +} + +// libref_hash$0 lib_hash:bits256 = LibRef; + +// libref_ref$1 library:^Cell = LibRef; + +export function loadLibRef(slice: Slice): LibRef { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let lib_hash: BitString = slice.loadBits(256); + return { + kind: 'LibRef_libref_hash', + lib_hash: lib_hash, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let library: Slice = slice1; + return { + kind: 'LibRef_libref_ref', + library: library, + } + + } + throw new Error('Expected one of "LibRef_libref_hash", "LibRef_libref_ref" in loading "LibRef", but data does not satisfy any constructor'); +} + +export function storeLibRef(libRef: LibRef): (builder: Builder) => void { + if ((libRef.kind == 'LibRef_libref_hash')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + builder.storeBits(libRef.lib_hash); + }) + + } + if ((libRef.kind == 'LibRef_libref_ref')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + cell1.storeSlice(libRef.library); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "LibRef_libref_hash", "LibRef_libref_ref" in loading "LibRef", but data does not satisfy any constructor'); +} + +// out_list_node$_ prev:^Cell action:OutAction = OutListNode; + +export function loadOutListNode(slice: Slice): OutListNode { + let slice1 = slice.loadRef().beginParse(); + let prev: Slice = slice1; + let action: OutAction = loadOutAction(slice); + return { + kind: 'OutListNode', + prev: prev, + action: action, + } + +} + +export function storeOutListNode(outListNode: OutListNode): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(outListNode.prev); + builder.storeRef(cell1); + storeOutAction(outListNode.action)(builder); + }) + +} + +/* +shard_ident$00 shard_pfx_bits:(#<= 60) + workchain_id:int32 shard_prefix:uint64 = ShardIdent; +*/ + +export function loadShardIdent(slice: Slice): ShardIdent { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + let shard_pfx_bits: number = slice.loadUint(bitLen(60)); + let workchain_id: number = slice.loadInt(32); + let shard_prefix: number = slice.loadUint(64); + return { + kind: 'ShardIdent', + shard_pfx_bits: shard_pfx_bits, + workchain_id: workchain_id, + shard_prefix: shard_prefix, + } + + } + throw new Error('Expected one of "ShardIdent" in loading "ShardIdent", but data does not satisfy any constructor'); +} + +export function storeShardIdent(shardIdent: ShardIdent): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + builder.storeUint(shardIdent.shard_pfx_bits, bitLen(60)); + builder.storeInt(shardIdent.workchain_id, 32); + builder.storeUint(shardIdent.shard_prefix, 64); + }) + +} + +/* +ext_blk_ref$_ end_lt:uint64 + seq_no:uint32 root_hash:bits256 file_hash:bits256 + = ExtBlkRef; +*/ + +export function loadExtBlkRef(slice: Slice): ExtBlkRef { + let end_lt: number = slice.loadUint(64); + let seq_no: number = slice.loadUint(32); + let root_hash: BitString = slice.loadBits(256); + let file_hash: BitString = slice.loadBits(256); + return { + kind: 'ExtBlkRef', + end_lt: end_lt, + seq_no: seq_no, + root_hash: root_hash, + file_hash: file_hash, + } + +} + +export function storeExtBlkRef(extBlkRef: ExtBlkRef): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(extBlkRef.end_lt, 64); + builder.storeUint(extBlkRef.seq_no, 32); + builder.storeBits(extBlkRef.root_hash); + builder.storeBits(extBlkRef.file_hash); + }) + +} + +/* +block_id_ext$_ shard_id:ShardIdent seq_no:uint32 + root_hash:bits256 file_hash:bits256 = BlockIdExt; +*/ + +export function loadBlockIdExt(slice: Slice): BlockIdExt { + let shard_id: ShardIdent = loadShardIdent(slice); + let seq_no: number = slice.loadUint(32); + let root_hash: BitString = slice.loadBits(256); + let file_hash: BitString = slice.loadBits(256); + return { + kind: 'BlockIdExt', + shard_id: shard_id, + seq_no: seq_no, + root_hash: root_hash, + file_hash: file_hash, + } + +} + +export function storeBlockIdExt(blockIdExt: BlockIdExt): (builder: Builder) => void { + return ((builder: Builder) => { + storeShardIdent(blockIdExt.shard_id)(builder); + builder.storeUint(blockIdExt.seq_no, 32); + builder.storeBits(blockIdExt.root_hash); + builder.storeBits(blockIdExt.file_hash); + }) + +} + +// master_info$_ master:ExtBlkRef = BlkMasterInfo; + +export function loadBlkMasterInfo(slice: Slice): BlkMasterInfo { + let master: ExtBlkRef = loadExtBlkRef(slice); + return { + kind: 'BlkMasterInfo', + master: master, + } + +} + +export function storeBlkMasterInfo(blkMasterInfo: BlkMasterInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeExtBlkRef(blkMasterInfo.master)(builder); + }) + +} + +/* +shard_state#9023afe2 global_id:int32 + shard_id:ShardIdent + seq_no:uint32 vert_seq_no:# + gen_utime:uint32 gen_lt:uint64 + min_ref_mc_seqno:uint32 + out_msg_queue_info:^OutMsgQueueInfo + before_split:(## 1) + accounts:^ShardAccounts + ^[ overload_history:uint64 underload_history:uint64 + total_balance:CurrencyCollection + total_validator_fees:CurrencyCollection + libraries:(HashmapE 256 LibDescr) + master_ref:(Maybe BlkMasterInfo) ] + custom:(Maybe ^McStateExtra) + = ShardStateUnsplit; +*/ + +export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x9023afe2))) { + slice.loadUint(32); + let global_id: number = slice.loadInt(32); + let shard_id: ShardIdent = loadShardIdent(slice); + let seq_no: number = slice.loadUint(32); + let vert_seq_no: number = slice.loadUint(32); + let gen_utime: number = slice.loadUint(32); + let gen_lt: number = slice.loadUint(64); + let min_ref_mc_seqno: number = slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let out_msg_queue_info: OutMsgQueueInfo = loadOutMsgQueueInfo(slice1); + let before_split: number = slice.loadUint(1); + let slice2 = slice.loadRef().beginParse(); + let accounts: ShardAccounts = loadShardAccounts(slice2); + let slice3 = slice.loadRef().beginParse(); + let overload_history: number = slice3.loadUint(64); + let underload_history: number = slice3.loadUint(64); + let total_balance: CurrencyCollection = loadCurrencyCollection(slice3); + let total_validator_fees: CurrencyCollection = loadCurrencyCollection(slice3); + let libraries: HashmapE = loadHashmapE(slice3, 256, loadLibDescr); + let master_ref: Maybe = loadMaybe(slice3, loadBlkMasterInfo); + let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadMcStateExtra(slice1) + + })); + return { + kind: 'ShardStateUnsplit', + global_id: global_id, + shard_id: shard_id, + seq_no: seq_no, + vert_seq_no: vert_seq_no, + gen_utime: gen_utime, + gen_lt: gen_lt, + min_ref_mc_seqno: min_ref_mc_seqno, + out_msg_queue_info: out_msg_queue_info, + before_split: before_split, + accounts: accounts, + overload_history: overload_history, + underload_history: underload_history, + total_balance: total_balance, + total_validator_fees: total_validator_fees, + libraries: libraries, + master_ref: master_ref, + custom: custom, + } + + } + throw new Error('Expected one of "ShardStateUnsplit" in loading "ShardStateUnsplit", but data does not satisfy any constructor'); +} + +export function storeShardStateUnsplit(shardStateUnsplit: ShardStateUnsplit): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x9023afe2, 32); + builder.storeInt(shardStateUnsplit.global_id, 32); + storeShardIdent(shardStateUnsplit.shard_id)(builder); + builder.storeUint(shardStateUnsplit.seq_no, 32); + builder.storeUint(shardStateUnsplit.vert_seq_no, 32); + builder.storeUint(shardStateUnsplit.gen_utime, 32); + builder.storeUint(shardStateUnsplit.gen_lt, 64); + builder.storeUint(shardStateUnsplit.min_ref_mc_seqno, 32); + let cell1 = beginCell(); + storeOutMsgQueueInfo(shardStateUnsplit.out_msg_queue_info)(cell1); + builder.storeRef(cell1); + builder.storeUint(shardStateUnsplit.before_split, 1); + let cell2 = beginCell(); + storeShardAccounts(shardStateUnsplit.accounts)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + cell3.storeUint(shardStateUnsplit.overload_history, 64); + cell3.storeUint(shardStateUnsplit.underload_history, 64); + storeCurrencyCollection(shardStateUnsplit.total_balance)(cell3); + storeCurrencyCollection(shardStateUnsplit.total_validator_fees)(cell3); + storeHashmapE(shardStateUnsplit.libraries, storeLibDescr)(cell3); + storeMaybe(shardStateUnsplit.master_ref, storeBlkMasterInfo)(cell3); + builder.storeRef(cell3); + storeMaybe(shardStateUnsplit.custom, ((arg: McStateExtra) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMcStateExtra(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// split_state#5f327da5 left:^ShardStateUnsplit right:^ShardStateUnsplit = ShardState; + +// _ ShardStateUnsplit = ShardState; + +export function loadShardState(slice: Slice): ShardState { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x5f327da5))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let left: ShardStateUnsplit = loadShardStateUnsplit(slice1); + let slice2 = slice.loadRef().beginParse(); + let right: ShardStateUnsplit = loadShardStateUnsplit(slice2); + return { + kind: 'ShardState_split_state', + left: left, + right: right, + } + + } + if (true) { + let anon0: ShardStateUnsplit = loadShardStateUnsplit(slice); + return { + kind: 'ShardState__', + anon0: anon0, + } + + } + throw new Error('Expected one of "ShardState_split_state", "ShardState__" in loading "ShardState", but data does not satisfy any constructor'); +} + +export function storeShardState(shardState: ShardState): (builder: Builder) => void { + if ((shardState.kind == 'ShardState_split_state')) { + return ((builder: Builder) => { + builder.storeUint(0x5f327da5, 32); + let cell1 = beginCell(); + storeShardStateUnsplit(shardState.left)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeShardStateUnsplit(shardState.right)(cell2); + builder.storeRef(cell2); + }) + + } + if ((shardState.kind == 'ShardState__')) { + return ((builder: Builder) => { + storeShardStateUnsplit(shardState.anon0)(builder); + }) + + } + throw new Error('Expected one of "ShardState_split_state", "ShardState__" in loading "ShardState", but data does not satisfy any constructor'); +} + +/* +shared_lib_descr$00 lib:^Cell publishers:(Hashmap 256 True) + = LibDescr; +*/ + +export function loadLibDescr(slice: Slice): LibDescr { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + let slice1 = slice.loadRef().beginParse(); + let lib: Slice = slice1; + let publishers: Hashmap = loadHashmap(slice, 256, loadTrue); + return { + kind: 'LibDescr', + lib: lib, + publishers: publishers, + } + + } + throw new Error('Expected one of "LibDescr" in loading "LibDescr", but data does not satisfy any constructor'); +} + +export function storeLibDescr(libDescr: LibDescr): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + let cell1 = beginCell(); + cell1.storeSlice(libDescr.lib); + builder.storeRef(cell1); + storeHashmap(libDescr.publishers, storeTrue)(builder); + }) + +} + +/* +block_info#9bc7a987 version:uint32 + not_master:(## 1) + after_merge:(## 1) before_split:(## 1) + after_split:(## 1) + want_split:Bool want_merge:Bool + key_block:Bool vert_seqno_incr:(## 1) + flags:(## 8) { flags <= 1 } + seq_no:# vert_seq_no:# { vert_seq_no >= vert_seqno_incr } + { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } + shard:ShardIdent gen_utime:uint32 + start_lt:uint64 end_lt:uint64 + gen_validator_list_hash_short:uint32 + gen_catchain_seqno:uint32 + min_ref_mc_seqno:uint32 + prev_key_block_seqno:uint32 + gen_software:flags . 0?GlobalVersion + master_ref:not_master?^BlkMasterInfo + prev_ref:^(BlkPrevInfo after_merge) + prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0) + = BlockInfo; +*/ + +export function loadBlockInfo(slice: Slice): BlockInfo { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x9bc7a987))) { + slice.loadUint(32); + let version: number = slice.loadUint(32); + let not_master: number = slice.loadUint(1); + let after_merge: number = slice.loadUint(1); + let before_split: number = slice.loadUint(1); + let after_split: number = slice.loadUint(1); + let want_split: boolean = slice.loadBoolean(); + let want_merge: boolean = slice.loadBoolean(); + let key_block: boolean = slice.loadBoolean(); + let vert_seqno_incr: number = slice.loadUint(1); + let flags: number = slice.loadUint(8); + let seq_no: number = slice.loadUint(32); + let vert_seq_no: number = slice.loadUint(32); + let shard: ShardIdent = loadShardIdent(slice); + let gen_utime: number = slice.loadUint(32); + let start_lt: number = slice.loadUint(64); + let end_lt: number = slice.loadUint(64); + let gen_validator_list_hash_short: number = slice.loadUint(32); + let gen_catchain_seqno: number = slice.loadUint(32); + let min_ref_mc_seqno: number = slice.loadUint(32); + let prev_key_block_seqno: number = slice.loadUint(32); + let gen_software: GlobalVersion | undefined = ((flags & (1 << 0)) ? loadGlobalVersion(slice) : undefined); + let master_ref: BlkMasterInfo | undefined = (not_master ? ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadBlkMasterInfo(slice1) + + })(slice) : undefined); + let slice1 = slice.loadRef().beginParse(); + let prev_ref: BlkPrevInfo = loadBlkPrevInfo(slice1, after_merge); + let prev_vert_ref: BlkPrevInfo | undefined = (vert_seqno_incr ? ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadBlkPrevInfo(slice1, 0) + + })(slice) : undefined); + if ((!(flags <= 1))) { + throw new Error('Condition (flags <= 1) is not satisfied while loading "BlockInfo" for type "BlockInfo"'); + } + if ((!(vert_seq_no >= vert_seqno_incr))) { + throw new Error('Condition (vert_seq_no >= vert_seqno_incr) is not satisfied while loading "BlockInfo" for type "BlockInfo"'); + } + return { + kind: 'BlockInfo', + prev_seq_no: (seq_no - 1), + version: version, + not_master: not_master, + after_merge: after_merge, + before_split: before_split, + after_split: after_split, + want_split: want_split, + want_merge: want_merge, + key_block: key_block, + vert_seqno_incr: vert_seqno_incr, + flags: flags, + seq_no: seq_no, + vert_seq_no: vert_seq_no, + shard: shard, + gen_utime: gen_utime, + start_lt: start_lt, + end_lt: end_lt, + gen_validator_list_hash_short: gen_validator_list_hash_short, + gen_catchain_seqno: gen_catchain_seqno, + min_ref_mc_seqno: min_ref_mc_seqno, + prev_key_block_seqno: prev_key_block_seqno, + gen_software: gen_software, + master_ref: master_ref, + prev_ref: prev_ref, + prev_vert_ref: prev_vert_ref, + } + + } + throw new Error('Expected one of "BlockInfo" in loading "BlockInfo", but data does not satisfy any constructor'); +} + +export function storeBlockInfo(blockInfo: BlockInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x9bc7a987, 32); + builder.storeUint(blockInfo.version, 32); + builder.storeUint(blockInfo.not_master, 1); + builder.storeUint(blockInfo.after_merge, 1); + builder.storeUint(blockInfo.before_split, 1); + builder.storeUint(blockInfo.after_split, 1); + builder.storeBit(blockInfo.want_split); + builder.storeBit(blockInfo.want_merge); + builder.storeBit(blockInfo.key_block); + builder.storeUint(blockInfo.vert_seqno_incr, 1); + builder.storeUint(blockInfo.flags, 8); + builder.storeUint(blockInfo.seq_no, 32); + builder.storeUint(blockInfo.vert_seq_no, 32); + storeShardIdent(blockInfo.shard)(builder); + builder.storeUint(blockInfo.gen_utime, 32); + builder.storeUint(blockInfo.start_lt, 64); + builder.storeUint(blockInfo.end_lt, 64); + builder.storeUint(blockInfo.gen_validator_list_hash_short, 32); + builder.storeUint(blockInfo.gen_catchain_seqno, 32); + builder.storeUint(blockInfo.min_ref_mc_seqno, 32); + builder.storeUint(blockInfo.prev_key_block_seqno, 32); + if ((blockInfo.gen_software != undefined)) { + storeGlobalVersion(blockInfo.gen_software)(builder); + } + if ((blockInfo.master_ref != undefined)) { + let cell1 = beginCell(); + storeBlkMasterInfo(blockInfo.master_ref)(cell1); + builder.storeRef(cell1); + + } + let cell1 = beginCell(); + storeBlkPrevInfo(blockInfo.prev_ref)(cell1); + builder.storeRef(cell1); + if ((blockInfo.prev_vert_ref != undefined)) { + let cell1 = beginCell(); + storeBlkPrevInfo(blockInfo.prev_vert_ref)(cell1); + builder.storeRef(cell1); + + } + if ((!(blockInfo.flags <= 1))) { + throw new Error('Condition (blockInfo.flags <= 1) is not satisfied while loading "BlockInfo" for type "BlockInfo"'); + } + if ((!(blockInfo.vert_seq_no >= blockInfo.vert_seqno_incr))) { + throw new Error('Condition (blockInfo.vert_seq_no >= blockInfo.vert_seqno_incr) is not satisfied while loading "BlockInfo" for type "BlockInfo"'); + } + }) + +} + +// prev_blk_info$_ prev:ExtBlkRef = BlkPrevInfo 0; + +// prev_blks_info$_ prev1:^ExtBlkRef prev2:^ExtBlkRef = BlkPrevInfo 1; + +export function loadBlkPrevInfo(slice: Slice, arg0: number): BlkPrevInfo { + if ((arg0 == 0)) { + let prev: ExtBlkRef = loadExtBlkRef(slice); + return { + kind: 'BlkPrevInfo_prev_blk_info', + prev: prev, + } + + } + if ((arg0 == 1)) { + let slice1 = slice.loadRef().beginParse(); + let prev1: ExtBlkRef = loadExtBlkRef(slice1); + let slice2 = slice.loadRef().beginParse(); + let prev2: ExtBlkRef = loadExtBlkRef(slice2); + return { + kind: 'BlkPrevInfo_prev_blks_info', + prev1: prev1, + prev2: prev2, + } + + } + throw new Error('Expected one of "BlkPrevInfo_prev_blk_info", "BlkPrevInfo_prev_blks_info" in loading "BlkPrevInfo", but data does not satisfy any constructor'); +} + +export function storeBlkPrevInfo(blkPrevInfo: BlkPrevInfo): (builder: Builder) => void { + if ((blkPrevInfo.kind == 'BlkPrevInfo_prev_blk_info')) { + return ((builder: Builder) => { + storeExtBlkRef(blkPrevInfo.prev)(builder); + }) + + } + if ((blkPrevInfo.kind == 'BlkPrevInfo_prev_blks_info')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeExtBlkRef(blkPrevInfo.prev1)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeExtBlkRef(blkPrevInfo.prev2)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "BlkPrevInfo_prev_blk_info", "BlkPrevInfo_prev_blks_info" in loading "BlkPrevInfo", but data does not satisfy any constructor'); +} + +/* +block#11ef55aa global_id:int32 + info:^BlockInfo value_flow:^ValueFlow + state_update:^(MERKLE_UPDATE ShardState) + extra:^BlockExtra = Block; +*/ + +export function loadBlock(slice: Slice): Block { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x11ef55aa))) { + slice.loadUint(32); + let global_id: number = slice.loadInt(32); + let slice1 = slice.loadRef().beginParse(); + let info: BlockInfo = loadBlockInfo(slice1); + let slice2 = slice.loadRef().beginParse(); + let value_flow: ValueFlow = loadValueFlow(slice2); + let cell3 = slice.loadRef(); + let state_update = cell3; + let slice4 = slice.loadRef().beginParse(); + let extra: BlockExtra = loadBlockExtra(slice4); + return { + kind: 'Block', + global_id: global_id, + info: info, + value_flow: value_flow, + state_update: state_update, + extra: extra, + } + + } + throw new Error('Expected one of "Block" in loading "Block", but data does not satisfy any constructor'); +} + +export function storeBlock(block: Block): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x11ef55aa, 32); + builder.storeInt(block.global_id, 32); + let cell1 = beginCell(); + storeBlockInfo(block.info)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeValueFlow(block.value_flow)(cell2); + builder.storeRef(cell2); + builder.storeRef(block.state_update); + let cell4 = beginCell(); + storeBlockExtra(block.extra)(cell4); + builder.storeRef(cell4); + }) + +} + +/* +block_extra in_msg_descr:^InMsgDescr + out_msg_descr:^OutMsgDescr + account_blocks:^ShardAccountBlocks + rand_seed:bits256 + created_by:bits256 + custom:(Maybe ^McBlockExtra) = BlockExtra; +*/ + +export function loadBlockExtra(slice: Slice): BlockExtra { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4a33f6fd))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let in_msg_descr: InMsgDescr = loadInMsgDescr(slice1); + let slice2 = slice.loadRef().beginParse(); + let out_msg_descr: OutMsgDescr = loadOutMsgDescr(slice2); + let slice3 = slice.loadRef().beginParse(); + let account_blocks: ShardAccountBlocks = loadShardAccountBlocks(slice3); + let rand_seed: BitString = slice.loadBits(256); + let created_by: BitString = slice.loadBits(256); + let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadMcBlockExtra(slice1) + + })); + return { + kind: 'BlockExtra', + in_msg_descr: in_msg_descr, + out_msg_descr: out_msg_descr, + account_blocks: account_blocks, + rand_seed: rand_seed, + created_by: created_by, + custom: custom, + } + + } + throw new Error('Expected one of "BlockExtra" in loading "BlockExtra", but data does not satisfy any constructor'); +} + +export function storeBlockExtra(blockExtra: BlockExtra): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4a33f6fd, 32); + let cell1 = beginCell(); + storeInMsgDescr(blockExtra.in_msg_descr)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeOutMsgDescr(blockExtra.out_msg_descr)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + storeShardAccountBlocks(blockExtra.account_blocks)(cell3); + builder.storeRef(cell3); + builder.storeBits(blockExtra.rand_seed); + builder.storeBits(blockExtra.created_by); + storeMaybe(blockExtra.custom, ((arg: McBlockExtra) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMcBlockExtra(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +/* +value_flow#b8e48dfb ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; +*/ + +/* +value_flow_v2#3ebf98b7 ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + burned:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; +*/ + +export function loadValueFlow(slice: Slice): ValueFlow { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xb8e48dfb))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let from_prev_blk: CurrencyCollection = loadCurrencyCollection(slice1); + let to_next_blk: CurrencyCollection = loadCurrencyCollection(slice1); + let imported: CurrencyCollection = loadCurrencyCollection(slice1); + let exported: CurrencyCollection = loadCurrencyCollection(slice1); + let fees_collected: CurrencyCollection = loadCurrencyCollection(slice); + let slice2 = slice.loadRef().beginParse(); + let fees_imported: CurrencyCollection = loadCurrencyCollection(slice2); + let recovered: CurrencyCollection = loadCurrencyCollection(slice2); + let created: CurrencyCollection = loadCurrencyCollection(slice2); + let minted: CurrencyCollection = loadCurrencyCollection(slice2); + return { + kind: 'ValueFlow_value_flow', + from_prev_blk: from_prev_blk, + to_next_blk: to_next_blk, + imported: imported, + exported: exported, + fees_collected: fees_collected, + fees_imported: fees_imported, + recovered: recovered, + created: created, + minted: minted, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x3ebf98b7))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let from_prev_blk: CurrencyCollection = loadCurrencyCollection(slice1); + let to_next_blk: CurrencyCollection = loadCurrencyCollection(slice1); + let imported: CurrencyCollection = loadCurrencyCollection(slice1); + let exported: CurrencyCollection = loadCurrencyCollection(slice1); + let fees_collected: CurrencyCollection = loadCurrencyCollection(slice); + let burned: CurrencyCollection = loadCurrencyCollection(slice); + let slice2 = slice.loadRef().beginParse(); + let fees_imported: CurrencyCollection = loadCurrencyCollection(slice2); + let recovered: CurrencyCollection = loadCurrencyCollection(slice2); + let created: CurrencyCollection = loadCurrencyCollection(slice2); + let minted: CurrencyCollection = loadCurrencyCollection(slice2); + return { + kind: 'ValueFlow_value_flow_v2', + from_prev_blk: from_prev_blk, + to_next_blk: to_next_blk, + imported: imported, + exported: exported, + fees_collected: fees_collected, + burned: burned, + fees_imported: fees_imported, + recovered: recovered, + created: created, + minted: minted, + } + + } + throw new Error('Expected one of "ValueFlow_value_flow", "ValueFlow_value_flow_v2" in loading "ValueFlow", but data does not satisfy any constructor'); +} + +export function storeValueFlow(valueFlow: ValueFlow): (builder: Builder) => void { + if ((valueFlow.kind == 'ValueFlow_value_flow')) { + return ((builder: Builder) => { + builder.storeUint(0xb8e48dfb, 32); + let cell1 = beginCell(); + storeCurrencyCollection(valueFlow.from_prev_blk)(cell1); + storeCurrencyCollection(valueFlow.to_next_blk)(cell1); + storeCurrencyCollection(valueFlow.imported)(cell1); + storeCurrencyCollection(valueFlow.exported)(cell1); + builder.storeRef(cell1); + storeCurrencyCollection(valueFlow.fees_collected)(builder); + let cell2 = beginCell(); + storeCurrencyCollection(valueFlow.fees_imported)(cell2); + storeCurrencyCollection(valueFlow.recovered)(cell2); + storeCurrencyCollection(valueFlow.created)(cell2); + storeCurrencyCollection(valueFlow.minted)(cell2); + builder.storeRef(cell2); + }) + + } + if ((valueFlow.kind == 'ValueFlow_value_flow_v2')) { + return ((builder: Builder) => { + builder.storeUint(0x3ebf98b7, 32); + let cell1 = beginCell(); + storeCurrencyCollection(valueFlow.from_prev_blk)(cell1); + storeCurrencyCollection(valueFlow.to_next_blk)(cell1); + storeCurrencyCollection(valueFlow.imported)(cell1); + storeCurrencyCollection(valueFlow.exported)(cell1); + builder.storeRef(cell1); + storeCurrencyCollection(valueFlow.fees_collected)(builder); + storeCurrencyCollection(valueFlow.burned)(builder); + let cell2 = beginCell(); + storeCurrencyCollection(valueFlow.fees_imported)(cell2); + storeCurrencyCollection(valueFlow.recovered)(cell2); + storeCurrencyCollection(valueFlow.created)(cell2); + storeCurrencyCollection(valueFlow.minted)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "ValueFlow_value_flow", "ValueFlow_value_flow_v2" in loading "ValueFlow", but data does not satisfy any constructor'); +} + +// bt_leaf$0 {X:Type} leaf:X = BinTree X; + +/* +bt_fork$1 {X:Type} left:^(BinTree X) right:^(BinTree X) + = BinTree X; +*/ + +export function loadBinTree(slice: Slice, loadX: (slice: Slice) => X): BinTree { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let leaf: X = loadX(slice); + return { + kind: 'BinTree_bt_leaf', + leaf: leaf, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let left: BinTree = loadBinTree(slice1, loadX); + let slice2 = slice.loadRef().beginParse(); + let right: BinTree = loadBinTree(slice2, loadX); + return { + kind: 'BinTree_bt_fork', + left: left, + right: right, + } + + } + throw new Error('Expected one of "BinTree_bt_leaf", "BinTree_bt_fork" in loading "BinTree", but data does not satisfy any constructor'); +} + +export function storeBinTree(binTree: BinTree, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((binTree.kind == 'BinTree_bt_leaf')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeX(binTree.leaf)(builder); + }) + + } + if ((binTree.kind == 'BinTree_bt_fork')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeBinTree(binTree.left, storeX)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeBinTree(binTree.right, storeX)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "BinTree_bt_leaf", "BinTree_bt_fork" in loading "BinTree", but data does not satisfy any constructor'); +} + +// fsm_none$0 = FutureSplitMerge; + +// fsm_split$10 split_utime:uint32 interval:uint32 = FutureSplitMerge; + +// fsm_merge$11 merge_utime:uint32 interval:uint32 = FutureSplitMerge; + +export function loadFutureSplitMerge(slice: Slice): FutureSplitMerge { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'FutureSplitMerge_fsm_none', + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + let split_utime: number = slice.loadUint(32); + let interval: number = slice.loadUint(32); + return { + kind: 'FutureSplitMerge_fsm_split', + split_utime: split_utime, + interval: interval, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let merge_utime: number = slice.loadUint(32); + let interval: number = slice.loadUint(32); + return { + kind: 'FutureSplitMerge_fsm_merge', + merge_utime: merge_utime, + interval: interval, + } + + } + throw new Error('Expected one of "FutureSplitMerge_fsm_none", "FutureSplitMerge_fsm_split", "FutureSplitMerge_fsm_merge" in loading "FutureSplitMerge", but data does not satisfy any constructor'); +} + +export function storeFutureSplitMerge(futureSplitMerge: FutureSplitMerge): (builder: Builder) => void { + if ((futureSplitMerge.kind == 'FutureSplitMerge_fsm_none')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((futureSplitMerge.kind == 'FutureSplitMerge_fsm_split')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + builder.storeUint(futureSplitMerge.split_utime, 32); + builder.storeUint(futureSplitMerge.interval, 32); + }) + + } + if ((futureSplitMerge.kind == 'FutureSplitMerge_fsm_merge')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + builder.storeUint(futureSplitMerge.merge_utime, 32); + builder.storeUint(futureSplitMerge.interval, 32); + }) + + } + throw new Error('Expected one of "FutureSplitMerge_fsm_none", "FutureSplitMerge_fsm_split", "FutureSplitMerge_fsm_merge" in loading "FutureSplitMerge", but data does not satisfy any constructor'); +} + +/* +shard_descr#b seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + fees_collected:CurrencyCollection + funds_created:CurrencyCollection = ShardDescr; +*/ + +/* +shard_descr_new#a seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + ^[ fees_collected:CurrencyCollection + funds_created:CurrencyCollection ] = ShardDescr; +*/ + +export function loadShardDescr(slice: Slice): ShardDescr { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0xb))) { + slice.loadUint(4); + let seq_no: number = slice.loadUint(32); + let reg_mc_seqno: number = slice.loadUint(32); + let start_lt: number = slice.loadUint(64); + let end_lt: number = slice.loadUint(64); + let root_hash: BitString = slice.loadBits(256); + let file_hash: BitString = slice.loadBits(256); + let before_split: boolean = slice.loadBoolean(); + let before_merge: boolean = slice.loadBoolean(); + let want_split: boolean = slice.loadBoolean(); + let want_merge: boolean = slice.loadBoolean(); + let nx_cc_updated: boolean = slice.loadBoolean(); + let flags: number = slice.loadUint(3); + let next_catchain_seqno: number = slice.loadUint(32); + let next_validator_shard: number = slice.loadUint(64); + let min_ref_mc_seqno: number = slice.loadUint(32); + let gen_utime: number = slice.loadUint(32); + let split_merge_at: FutureSplitMerge = loadFutureSplitMerge(slice); + let fees_collected: CurrencyCollection = loadCurrencyCollection(slice); + let funds_created: CurrencyCollection = loadCurrencyCollection(slice); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "ShardDescr_shard_descr" for type "ShardDescr"'); + } + return { + kind: 'ShardDescr_shard_descr', + seq_no: seq_no, + reg_mc_seqno: reg_mc_seqno, + start_lt: start_lt, + end_lt: end_lt, + root_hash: root_hash, + file_hash: file_hash, + before_split: before_split, + before_merge: before_merge, + want_split: want_split, + want_merge: want_merge, + nx_cc_updated: nx_cc_updated, + flags: flags, + next_catchain_seqno: next_catchain_seqno, + next_validator_shard: next_validator_shard, + min_ref_mc_seqno: min_ref_mc_seqno, + gen_utime: gen_utime, + split_merge_at: split_merge_at, + fees_collected: fees_collected, + funds_created: funds_created, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0xa))) { + slice.loadUint(4); + let seq_no: number = slice.loadUint(32); + let reg_mc_seqno: number = slice.loadUint(32); + let start_lt: number = slice.loadUint(64); + let end_lt: number = slice.loadUint(64); + let root_hash: BitString = slice.loadBits(256); + let file_hash: BitString = slice.loadBits(256); + let before_split: boolean = slice.loadBoolean(); + let before_merge: boolean = slice.loadBoolean(); + let want_split: boolean = slice.loadBoolean(); + let want_merge: boolean = slice.loadBoolean(); + let nx_cc_updated: boolean = slice.loadBoolean(); + let flags: number = slice.loadUint(3); + let next_catchain_seqno: number = slice.loadUint(32); + let next_validator_shard: number = slice.loadUint(64); + let min_ref_mc_seqno: number = slice.loadUint(32); + let gen_utime: number = slice.loadUint(32); + let split_merge_at: FutureSplitMerge = loadFutureSplitMerge(slice); + let slice1 = slice.loadRef().beginParse(); + let fees_collected: CurrencyCollection = loadCurrencyCollection(slice1); + let funds_created: CurrencyCollection = loadCurrencyCollection(slice1); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "ShardDescr_shard_descr_new" for type "ShardDescr"'); + } + return { + kind: 'ShardDescr_shard_descr_new', + seq_no: seq_no, + reg_mc_seqno: reg_mc_seqno, + start_lt: start_lt, + end_lt: end_lt, + root_hash: root_hash, + file_hash: file_hash, + before_split: before_split, + before_merge: before_merge, + want_split: want_split, + want_merge: want_merge, + nx_cc_updated: nx_cc_updated, + flags: flags, + next_catchain_seqno: next_catchain_seqno, + next_validator_shard: next_validator_shard, + min_ref_mc_seqno: min_ref_mc_seqno, + gen_utime: gen_utime, + split_merge_at: split_merge_at, + fees_collected: fees_collected, + funds_created: funds_created, + } + + } + throw new Error('Expected one of "ShardDescr_shard_descr", "ShardDescr_shard_descr_new" in loading "ShardDescr", but data does not satisfy any constructor'); +} + +export function storeShardDescr(shardDescr: ShardDescr): (builder: Builder) => void { + if ((shardDescr.kind == 'ShardDescr_shard_descr')) { + return ((builder: Builder) => { + builder.storeUint(0xb, 4); + builder.storeUint(shardDescr.seq_no, 32); + builder.storeUint(shardDescr.reg_mc_seqno, 32); + builder.storeUint(shardDescr.start_lt, 64); + builder.storeUint(shardDescr.end_lt, 64); + builder.storeBits(shardDescr.root_hash); + builder.storeBits(shardDescr.file_hash); + builder.storeBit(shardDescr.before_split); + builder.storeBit(shardDescr.before_merge); + builder.storeBit(shardDescr.want_split); + builder.storeBit(shardDescr.want_merge); + builder.storeBit(shardDescr.nx_cc_updated); + builder.storeUint(shardDescr.flags, 3); + builder.storeUint(shardDescr.next_catchain_seqno, 32); + builder.storeUint(shardDescr.next_validator_shard, 64); + builder.storeUint(shardDescr.min_ref_mc_seqno, 32); + builder.storeUint(shardDescr.gen_utime, 32); + storeFutureSplitMerge(shardDescr.split_merge_at)(builder); + storeCurrencyCollection(shardDescr.fees_collected)(builder); + storeCurrencyCollection(shardDescr.funds_created)(builder); + if ((!(shardDescr.flags == 0))) { + throw new Error('Condition (shardDescr.flags == 0) is not satisfied while loading "ShardDescr_shard_descr" for type "ShardDescr"'); + } + }) + + } + if ((shardDescr.kind == 'ShardDescr_shard_descr_new')) { + return ((builder: Builder) => { + builder.storeUint(0xa, 4); + builder.storeUint(shardDescr.seq_no, 32); + builder.storeUint(shardDescr.reg_mc_seqno, 32); + builder.storeUint(shardDescr.start_lt, 64); + builder.storeUint(shardDescr.end_lt, 64); + builder.storeBits(shardDescr.root_hash); + builder.storeBits(shardDescr.file_hash); + builder.storeBit(shardDescr.before_split); + builder.storeBit(shardDescr.before_merge); + builder.storeBit(shardDescr.want_split); + builder.storeBit(shardDescr.want_merge); + builder.storeBit(shardDescr.nx_cc_updated); + builder.storeUint(shardDescr.flags, 3); + builder.storeUint(shardDescr.next_catchain_seqno, 32); + builder.storeUint(shardDescr.next_validator_shard, 64); + builder.storeUint(shardDescr.min_ref_mc_seqno, 32); + builder.storeUint(shardDescr.gen_utime, 32); + storeFutureSplitMerge(shardDescr.split_merge_at)(builder); + let cell1 = beginCell(); + storeCurrencyCollection(shardDescr.fees_collected)(cell1); + storeCurrencyCollection(shardDescr.funds_created)(cell1); + builder.storeRef(cell1); + if ((!(shardDescr.flags == 0))) { + throw new Error('Condition (shardDescr.flags == 0) is not satisfied while loading "ShardDescr_shard_descr_new" for type "ShardDescr"'); + } + }) + + } + throw new Error('Expected one of "ShardDescr_shard_descr", "ShardDescr_shard_descr_new" in loading "ShardDescr", but data does not satisfy any constructor'); +} + +// _ (HashmapE 32 ^(BinTree ShardDescr)) = ShardHashes; + +export function loadShardHashes(slice: Slice): ShardHashes { + let anon0: HashmapE> = loadHashmapE>(slice, 32, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadBinTree(slice1, loadShardDescr) + + })); + return { + kind: 'ShardHashes', + anon0: anon0, + } + +} + +export function storeShardHashes(shardHashes: ShardHashes): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE>(shardHashes.anon0, ((arg: BinTree) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeBinTree(arg, storeShardDescr)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// bta_leaf$0 {X:Type} {Y:Type} extra:Y leaf:X = BinTreeAug X Y; + +/* +bta_fork$1 {X:Type} {Y:Type} left:^(BinTreeAug X Y) + right:^(BinTreeAug X Y) extra:Y = BinTreeAug X Y; +*/ + +export function loadBinTreeAug(slice: Slice, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): BinTreeAug { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let extra: Y = loadY(slice); + let leaf: X = loadX(slice); + return { + kind: 'BinTreeAug_bta_leaf', + extra: extra, + leaf: leaf, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let left: BinTreeAug = loadBinTreeAug(slice1, loadX, loadY); + let slice2 = slice.loadRef().beginParse(); + let right: BinTreeAug = loadBinTreeAug(slice2, loadX, loadY); + let extra: Y = loadY(slice); + return { + kind: 'BinTreeAug_bta_fork', + left: left, + right: right, + extra: extra, + } + + } + throw new Error('Expected one of "BinTreeAug_bta_leaf", "BinTreeAug_bta_fork" in loading "BinTreeAug", but data does not satisfy any constructor'); +} + +export function storeBinTreeAug(binTreeAug: BinTreeAug, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((binTreeAug.kind == 'BinTreeAug_bta_leaf')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeY(binTreeAug.extra)(builder); + storeX(binTreeAug.leaf)(builder); + }) + + } + if ((binTreeAug.kind == 'BinTreeAug_bta_fork')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeBinTreeAug(binTreeAug.left, storeX, storeY)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeBinTreeAug(binTreeAug.right, storeX, storeY)(cell2); + builder.storeRef(cell2); + storeY(binTreeAug.extra)(builder); + }) + + } + throw new Error('Expected one of "BinTreeAug_bta_leaf", "BinTreeAug_bta_fork" in loading "BinTreeAug", but data does not satisfy any constructor'); +} + +// _ fees:CurrencyCollection create:CurrencyCollection = ShardFeeCreated; + +export function loadShardFeeCreated(slice: Slice): ShardFeeCreated { + let fees: CurrencyCollection = loadCurrencyCollection(slice); + let create: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'ShardFeeCreated', + fees: fees, + create: create, + } + +} + +export function storeShardFeeCreated(shardFeeCreated: ShardFeeCreated): (builder: Builder) => void { + return ((builder: Builder) => { + storeCurrencyCollection(shardFeeCreated.fees)(builder); + storeCurrencyCollection(shardFeeCreated.create)(builder); + }) + +} + +// _ (HashmapAugE 96 ShardFeeCreated ShardFeeCreated) = ShardFees; + +export function loadShardFees(slice: Slice): ShardFees { + let anon0: HashmapAugE = loadHashmapAugE(slice, 96, loadShardFeeCreated, loadShardFeeCreated); + return { + kind: 'ShardFees', + anon0: anon0, + } + +} + +export function storeShardFees(shardFees: ShardFees): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(shardFees.anon0, storeShardFeeCreated, storeShardFeeCreated)(builder); + }) + +} + +/* +_ config_addr:bits256 config:^(Hashmap 32 ^Cell) + = ConfigParams; +*/ + +export function loadConfigParams(slice: Slice): ConfigParams { + let config_addr: BitString = slice.loadBits(256); + let slice1 = slice.loadRef().beginParse(); + let config: Hashmap = loadHashmap(slice1, 32, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + return { + kind: 'ConfigParams', + config_addr: config_addr, + config: config, + } + +} + +export function storeConfigParams(configParams: ConfigParams): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBits(configParams.config_addr); + let cell1 = beginCell(); + storeHashmap(configParams.config, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(cell1); + builder.storeRef(cell1); + }) + +} + +/* +validator_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 + nx_cc_updated:Bool += ValidatorInfo; +*/ + +export function loadValidatorInfo(slice: Slice): ValidatorInfo { + let validator_list_hash_short: number = slice.loadUint(32); + let catchain_seqno: number = slice.loadUint(32); + let nx_cc_updated: boolean = slice.loadBoolean(); + return { + kind: 'ValidatorInfo', + validator_list_hash_short: validator_list_hash_short, + catchain_seqno: catchain_seqno, + nx_cc_updated: nx_cc_updated, + } + +} + +export function storeValidatorInfo(validatorInfo: ValidatorInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(validatorInfo.validator_list_hash_short, 32); + builder.storeUint(validatorInfo.catchain_seqno, 32); + builder.storeBit(validatorInfo.nx_cc_updated); + }) + +} + +/* +validator_base_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 += ValidatorBaseInfo; +*/ + +export function loadValidatorBaseInfo(slice: Slice): ValidatorBaseInfo { + let validator_list_hash_short: number = slice.loadUint(32); + let catchain_seqno: number = slice.loadUint(32); + return { + kind: 'ValidatorBaseInfo', + validator_list_hash_short: validator_list_hash_short, + catchain_seqno: catchain_seqno, + } + +} + +export function storeValidatorBaseInfo(validatorBaseInfo: ValidatorBaseInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(validatorBaseInfo.validator_list_hash_short, 32); + builder.storeUint(validatorBaseInfo.catchain_seqno, 32); + }) + +} + +// _ key:Bool max_end_lt:uint64 = KeyMaxLt; + +export function loadKeyMaxLt(slice: Slice): KeyMaxLt { + let key: boolean = slice.loadBoolean(); + let max_end_lt: number = slice.loadUint(64); + return { + kind: 'KeyMaxLt', + key: key, + max_end_lt: max_end_lt, + } + +} + +export function storeKeyMaxLt(keyMaxLt: KeyMaxLt): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(keyMaxLt.key); + builder.storeUint(keyMaxLt.max_end_lt, 64); + }) + +} + +// _ key:Bool blk_ref:ExtBlkRef = KeyExtBlkRef; + +export function loadKeyExtBlkRef(slice: Slice): KeyExtBlkRef { + let key: boolean = slice.loadBoolean(); + let blk_ref: ExtBlkRef = loadExtBlkRef(slice); + return { + kind: 'KeyExtBlkRef', + key: key, + blk_ref: blk_ref, + } + +} + +export function storeKeyExtBlkRef(keyExtBlkRef: KeyExtBlkRef): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(keyExtBlkRef.key); + storeExtBlkRef(keyExtBlkRef.blk_ref)(builder); + }) + +} + +// _ (HashmapAugE 32 KeyExtBlkRef KeyMaxLt) = OldMcBlocksInfo; + +export function loadOldMcBlocksInfo(slice: Slice): OldMcBlocksInfo { + let anon0: HashmapAugE = loadHashmapAugE(slice, 32, loadKeyExtBlkRef, loadKeyMaxLt); + return { + kind: 'OldMcBlocksInfo', + anon0: anon0, + } + +} + +export function storeOldMcBlocksInfo(oldMcBlocksInfo: OldMcBlocksInfo): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapAugE(oldMcBlocksInfo.anon0, storeKeyExtBlkRef, storeKeyMaxLt)(builder); + }) + +} + +// counters#_ last_updated:uint32 total:uint64 cnt2048:uint64 cnt65536:uint64 = Counters; + +export function loadCounters(slice: Slice): Counters { + let last_updated: number = slice.loadUint(32); + let total: number = slice.loadUint(64); + let cnt2048: number = slice.loadUint(64); + let cnt65536: number = slice.loadUint(64); + return { + kind: 'Counters', + last_updated: last_updated, + total: total, + cnt2048: cnt2048, + cnt65536: cnt65536, + } + +} + +export function storeCounters(counters: Counters): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(counters.last_updated, 32); + builder.storeUint(counters.total, 64); + builder.storeUint(counters.cnt2048, 64); + builder.storeUint(counters.cnt65536, 64); + }) + +} + +// creator_info#4 mc_blocks:Counters shard_blocks:Counters = CreatorStats; + +export function loadCreatorStats(slice: Slice): CreatorStats { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x4))) { + slice.loadUint(4); + let mc_blocks: Counters = loadCounters(slice); + let shard_blocks: Counters = loadCounters(slice); + return { + kind: 'CreatorStats', + mc_blocks: mc_blocks, + shard_blocks: shard_blocks, + } + + } + throw new Error('Expected one of "CreatorStats" in loading "CreatorStats", but data does not satisfy any constructor'); +} + +export function storeCreatorStats(creatorStats: CreatorStats): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4, 4); + storeCounters(creatorStats.mc_blocks)(builder); + storeCounters(creatorStats.shard_blocks)(builder); + }) + +} + +// block_create_stats#17 counters:(HashmapE 256 CreatorStats) = BlockCreateStats; + +// block_create_stats_ext#34 counters:(HashmapAugE 256 CreatorStats uint32) = BlockCreateStats; + +export function loadBlockCreateStats(slice: Slice): BlockCreateStats { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x17))) { + slice.loadUint(8); + let counters: HashmapE = loadHashmapE(slice, 256, loadCreatorStats); + return { + kind: 'BlockCreateStats_block_create_stats', + counters: counters, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x34))) { + slice.loadUint(8); + let counters: HashmapAugE = loadHashmapAugE(slice, 256, loadCreatorStats, ((slice: Slice) => { + return slice.loadUint(32) + + })); + return { + kind: 'BlockCreateStats_block_create_stats_ext', + counters: counters, + } + + } + throw new Error('Expected one of "BlockCreateStats_block_create_stats", "BlockCreateStats_block_create_stats_ext" in loading "BlockCreateStats", but data does not satisfy any constructor'); +} + +export function storeBlockCreateStats(blockCreateStats: BlockCreateStats): (builder: Builder) => void { + if ((blockCreateStats.kind == 'BlockCreateStats_block_create_stats')) { + return ((builder: Builder) => { + builder.storeUint(0x17, 8); + storeHashmapE(blockCreateStats.counters, storeCreatorStats)(builder); + }) + + } + if ((blockCreateStats.kind == 'BlockCreateStats_block_create_stats_ext')) { + return ((builder: Builder) => { + builder.storeUint(0x34, 8); + storeHashmapAugE(blockCreateStats.counters, storeCreatorStats, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 32); + }) + + }))(builder); + }) + + } + throw new Error('Expected one of "BlockCreateStats_block_create_stats", "BlockCreateStats_block_create_stats_ext" in loading "BlockCreateStats", but data does not satisfy any constructor'); +} + +/* +masterchain_state_extra#cc26 + shard_hashes:ShardHashes + config:ConfigParams + ^[ flags:(## 16) { flags <= 1 } + validator_info:ValidatorInfo + prev_blocks:OldMcBlocksInfo + after_key_block:Bool + last_key_block:(Maybe ExtBlkRef) + block_create_stats:(flags . 0)?BlockCreateStats ] + global_balance:CurrencyCollection += McStateExtra; +*/ + +export function loadMcStateExtra(slice: Slice): McStateExtra { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0xcc26))) { + slice.loadUint(16); + let shard_hashes: ShardHashes = loadShardHashes(slice); + let config: ConfigParams = loadConfigParams(slice); + let slice1 = slice.loadRef().beginParse(); + let flags: number = slice1.loadUint(16); + let validator_info: ValidatorInfo = loadValidatorInfo(slice1); + let prev_blocks: OldMcBlocksInfo = loadOldMcBlocksInfo(slice1); + let after_key_block: boolean = slice1.loadBoolean(); + let last_key_block: Maybe = loadMaybe(slice1, loadExtBlkRef); + let block_create_stats: BlockCreateStats | undefined = ((flags & (1 << 0)) ? loadBlockCreateStats(slice1) : undefined); + let global_balance: CurrencyCollection = loadCurrencyCollection(slice); + return { + kind: 'McStateExtra', + shard_hashes: shard_hashes, + config: config, + flags: flags, + validator_info: validator_info, + prev_blocks: prev_blocks, + after_key_block: after_key_block, + last_key_block: last_key_block, + block_create_stats: block_create_stats, + global_balance: global_balance, + } + + } + throw new Error('Expected one of "McStateExtra" in loading "McStateExtra", but data does not satisfy any constructor'); +} + +export function storeMcStateExtra(mcStateExtra: McStateExtra): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xcc26, 16); + storeShardHashes(mcStateExtra.shard_hashes)(builder); + storeConfigParams(mcStateExtra.config)(builder); + let cell1 = beginCell(); + cell1.storeUint(mcStateExtra.flags, 16); + storeValidatorInfo(mcStateExtra.validator_info)(cell1); + storeOldMcBlocksInfo(mcStateExtra.prev_blocks)(cell1); + cell1.storeBit(mcStateExtra.after_key_block); + storeMaybe(mcStateExtra.last_key_block, storeExtBlkRef)(cell1); + if ((mcStateExtra.block_create_stats != undefined)) { + storeBlockCreateStats(mcStateExtra.block_create_stats)(cell1); + } + builder.storeRef(cell1); + storeCurrencyCollection(mcStateExtra.global_balance)(builder); + }) + +} + +// ed25519_pubkey#8e81278a pubkey:bits256 = SigPubKey; + +export function loadSigPubKey(slice: Slice): SigPubKey { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x8e81278a))) { + slice.loadUint(32); + let pubkey: BitString = slice.loadBits(256); + return { + kind: 'SigPubKey', + pubkey: pubkey, + } + + } + throw new Error('Expected one of "SigPubKey" in loading "SigPubKey", but data does not satisfy any constructor'); +} + +export function storeSigPubKey(sigPubKey: SigPubKey): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x8e81278a, 32); + builder.storeBits(sigPubKey.pubkey); + }) + +} + +// ed25519_signature#5 R:bits256 s:bits256 = CryptoSignatureSimple; + +export function loadCryptoSignatureSimple(slice: Slice): CryptoSignatureSimple { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x5))) { + slice.loadUint(4); + let R: BitString = slice.loadBits(256); + let s: BitString = slice.loadBits(256); + return { + kind: 'CryptoSignatureSimple', + R: R, + s: s, + } + + } + throw new Error('Expected one of "CryptoSignatureSimple" in loading "CryptoSignatureSimple", but data does not satisfy any constructor'); +} + +export function storeCryptoSignatureSimple(cryptoSignatureSimple: CryptoSignatureSimple): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x5, 4); + builder.storeBits(cryptoSignatureSimple.R); + builder.storeBits(cryptoSignatureSimple.s); + }) + +} + +/* +chained_signature#f signed_cert:^SignedCertificate temp_key_signature:CryptoSignatureSimple + = CryptoSignature; +*/ + +// _ CryptoSignatureSimple = CryptoSignature; + +export function loadCryptoSignature(slice: Slice): CryptoSignature { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0xf))) { + slice.loadUint(4); + let slice1 = slice.loadRef().beginParse(); + let signed_cert: SignedCertificate = loadSignedCertificate(slice1); + let temp_key_signature: CryptoSignatureSimple = loadCryptoSignatureSimple(slice); + return { + kind: 'CryptoSignature_chained_signature', + signed_cert: signed_cert, + temp_key_signature: temp_key_signature, + } + + } + if (true) { + let anon0: CryptoSignatureSimple = loadCryptoSignatureSimple(slice); + return { + kind: 'CryptoSignature__', + anon0: anon0, + } + + } + throw new Error('Expected one of "CryptoSignature_chained_signature", "CryptoSignature__" in loading "CryptoSignature", but data does not satisfy any constructor'); +} + +export function storeCryptoSignature(cryptoSignature: CryptoSignature): (builder: Builder) => void { + if ((cryptoSignature.kind == 'CryptoSignature_chained_signature')) { + return ((builder: Builder) => { + builder.storeUint(0xf, 4); + let cell1 = beginCell(); + storeSignedCertificate(cryptoSignature.signed_cert)(cell1); + builder.storeRef(cell1); + storeCryptoSignatureSimple(cryptoSignature.temp_key_signature)(builder); + }) + + } + if ((cryptoSignature.kind == 'CryptoSignature__')) { + return ((builder: Builder) => { + storeCryptoSignatureSimple(cryptoSignature.anon0)(builder); + }) + + } + throw new Error('Expected one of "CryptoSignature_chained_signature", "CryptoSignature__" in loading "CryptoSignature", but data does not satisfy any constructor'); +} + +// sig_pair$_ node_id_short:bits256 sign:CryptoSignature = CryptoSignaturePair; + +export function loadCryptoSignaturePair(slice: Slice): CryptoSignaturePair { + let node_id_short: BitString = slice.loadBits(256); + let sign: CryptoSignature = loadCryptoSignature(slice); + return { + kind: 'CryptoSignaturePair', + node_id_short: node_id_short, + sign: sign, + } + +} + +export function storeCryptoSignaturePair(cryptoSignaturePair: CryptoSignaturePair): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBits(cryptoSignaturePair.node_id_short); + storeCryptoSignature(cryptoSignaturePair.sign)(builder); + }) + +} + +// certificate#4 temp_key:SigPubKey valid_since:uint32 valid_until:uint32 = Certificate; + +export function loadCertificate(slice: Slice): Certificate { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x4))) { + slice.loadUint(4); + let temp_key: SigPubKey = loadSigPubKey(slice); + let valid_since: number = slice.loadUint(32); + let valid_until: number = slice.loadUint(32); + return { + kind: 'Certificate', + temp_key: temp_key, + valid_since: valid_since, + valid_until: valid_until, + } + + } + throw new Error('Expected one of "Certificate" in loading "Certificate", but data does not satisfy any constructor'); +} + +export function storeCertificate(certificate: Certificate): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4, 4); + storeSigPubKey(certificate.temp_key)(builder); + builder.storeUint(certificate.valid_since, 32); + builder.storeUint(certificate.valid_until, 32); + }) + +} + +// certificate_env#a419b7d certificate:Certificate = CertificateEnv; + +export function loadCertificateEnv(slice: Slice): CertificateEnv { + if (((slice.remainingBits >= 28) && (slice.preloadUint(28) == 0xa419b7d))) { + slice.loadUint(28); + let certificate: Certificate = loadCertificate(slice); + return { + kind: 'CertificateEnv', + certificate: certificate, + } + + } + throw new Error('Expected one of "CertificateEnv" in loading "CertificateEnv", but data does not satisfy any constructor'); +} + +export function storeCertificateEnv(certificateEnv: CertificateEnv): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xa419b7d, 28); + storeCertificate(certificateEnv.certificate)(builder); + }) + +} + +/* +signed_certificate$_ certificate:Certificate certificate_signature:CryptoSignature + = SignedCertificate; +*/ + +export function loadSignedCertificate(slice: Slice): SignedCertificate { + let certificate: Certificate = loadCertificate(slice); + let certificate_signature: CryptoSignature = loadCryptoSignature(slice); + return { + kind: 'SignedCertificate', + certificate: certificate, + certificate_signature: certificate_signature, + } + +} + +export function storeSignedCertificate(signedCertificate: SignedCertificate): (builder: Builder) => void { + return ((builder: Builder) => { + storeCertificate(signedCertificate.certificate)(builder); + storeCryptoSignature(signedCertificate.certificate_signature)(builder); + }) + +} + +/* +masterchain_block_extra#cca5 + key_block:(## 1) + shard_hashes:ShardHashes + shard_fees:ShardFees + ^[ prev_blk_signatures:(HashmapE 16 CryptoSignaturePair) + recover_create_msg:(Maybe ^InMsg) + mint_msg:(Maybe ^InMsg) ] + config:key_block?ConfigParams += McBlockExtra; +*/ + +export function loadMcBlockExtra(slice: Slice): McBlockExtra { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0xcca5))) { + slice.loadUint(16); + let key_block: number = slice.loadUint(1); + let shard_hashes: ShardHashes = loadShardHashes(slice); + let shard_fees: ShardFees = loadShardFees(slice); + let slice1 = slice.loadRef().beginParse(); + let prev_blk_signatures: HashmapE = loadHashmapE(slice1, 16, loadCryptoSignaturePair); + let recover_create_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadInMsg(slice1) + + })); + let mint_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadInMsg(slice1) + + })); + let config: ConfigParams | undefined = (key_block ? loadConfigParams(slice) : undefined); + return { + kind: 'McBlockExtra', + key_block: key_block, + shard_hashes: shard_hashes, + shard_fees: shard_fees, + prev_blk_signatures: prev_blk_signatures, + recover_create_msg: recover_create_msg, + mint_msg: mint_msg, + config: config, + } + + } + throw new Error('Expected one of "McBlockExtra" in loading "McBlockExtra", but data does not satisfy any constructor'); +} + +export function storeMcBlockExtra(mcBlockExtra: McBlockExtra): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xcca5, 16); + builder.storeUint(mcBlockExtra.key_block, 1); + storeShardHashes(mcBlockExtra.shard_hashes)(builder); + storeShardFees(mcBlockExtra.shard_fees)(builder); + let cell1 = beginCell(); + storeHashmapE(mcBlockExtra.prev_blk_signatures, storeCryptoSignaturePair)(cell1); + storeMaybe(mcBlockExtra.recover_create_msg, ((arg: InMsg) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeInMsg(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(cell1); + storeMaybe(mcBlockExtra.mint_msg, ((arg: InMsg) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeInMsg(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(cell1); + builder.storeRef(cell1); + if ((mcBlockExtra.config != undefined)) { + storeConfigParams(mcBlockExtra.config)(builder); + } + }) + +} + +// validator#53 public_key:SigPubKey weight:uint64 = ValidatorDescr; + +// validator_addr#73 public_key:SigPubKey weight:uint64 adnl_addr:bits256 = ValidatorDescr; + +export function loadValidatorDescr(slice: Slice): ValidatorDescr { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x53))) { + slice.loadUint(8); + let public_key: SigPubKey = loadSigPubKey(slice); + let weight: number = slice.loadUint(64); + return { + kind: 'ValidatorDescr_validator', + public_key: public_key, + weight: weight, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x73))) { + slice.loadUint(8); + let public_key: SigPubKey = loadSigPubKey(slice); + let weight: number = slice.loadUint(64); + let adnl_addr: BitString = slice.loadBits(256); + return { + kind: 'ValidatorDescr_validator_addr', + public_key: public_key, + weight: weight, + adnl_addr: adnl_addr, + } + + } + throw new Error('Expected one of "ValidatorDescr_validator", "ValidatorDescr_validator_addr" in loading "ValidatorDescr", but data does not satisfy any constructor'); +} + +export function storeValidatorDescr(validatorDescr: ValidatorDescr): (builder: Builder) => void { + if ((validatorDescr.kind == 'ValidatorDescr_validator')) { + return ((builder: Builder) => { + builder.storeUint(0x53, 8); + storeSigPubKey(validatorDescr.public_key)(builder); + builder.storeUint(validatorDescr.weight, 64); + }) + + } + if ((validatorDescr.kind == 'ValidatorDescr_validator_addr')) { + return ((builder: Builder) => { + builder.storeUint(0x73, 8); + storeSigPubKey(validatorDescr.public_key)(builder); + builder.storeUint(validatorDescr.weight, 64); + builder.storeBits(validatorDescr.adnl_addr); + }) + + } + throw new Error('Expected one of "ValidatorDescr_validator", "ValidatorDescr_validator_addr" in loading "ValidatorDescr", but data does not satisfy any constructor'); +} + +/* +validators#11 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + list:(Hashmap 16 ValidatorDescr) = ValidatorSet; +*/ + +/* +validators_ext#12 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + total_weight:uint64 list:(HashmapE 16 ValidatorDescr) = ValidatorSet; +*/ + +export function loadValidatorSet(slice: Slice): ValidatorSet { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x11))) { + slice.loadUint(8); + let utime_since: number = slice.loadUint(32); + let utime_until: number = slice.loadUint(32); + let total: number = slice.loadUint(16); + let main: number = slice.loadUint(16); + let list: Hashmap = loadHashmap(slice, 16, loadValidatorDescr); + if ((!(main <= total))) { + throw new Error('Condition (main <= total) is not satisfied while loading "ValidatorSet_validators" for type "ValidatorSet"'); + } + if ((!(main >= 1))) { + throw new Error('Condition (main >= 1) is not satisfied while loading "ValidatorSet_validators" for type "ValidatorSet"'); + } + return { + kind: 'ValidatorSet_validators', + utime_since: utime_since, + utime_until: utime_until, + total: total, + main: main, + list: list, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x12))) { + slice.loadUint(8); + let utime_since: number = slice.loadUint(32); + let utime_until: number = slice.loadUint(32); + let total: number = slice.loadUint(16); + let main: number = slice.loadUint(16); + let total_weight: number = slice.loadUint(64); + let list: HashmapE = loadHashmapE(slice, 16, loadValidatorDescr); + if ((!(main <= total))) { + throw new Error('Condition (main <= total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); + } + if ((!(main >= 1))) { + throw new Error('Condition (main >= 1) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); + } + return { + kind: 'ValidatorSet_validators_ext', + utime_since: utime_since, + utime_until: utime_until, + total: total, + main: main, + total_weight: total_weight, + list: list, + } + + } + throw new Error('Expected one of "ValidatorSet_validators", "ValidatorSet_validators_ext" in loading "ValidatorSet", but data does not satisfy any constructor'); +} + +export function storeValidatorSet(validatorSet: ValidatorSet): (builder: Builder) => void { + if ((validatorSet.kind == 'ValidatorSet_validators')) { + return ((builder: Builder) => { + builder.storeUint(0x11, 8); + builder.storeUint(validatorSet.utime_since, 32); + builder.storeUint(validatorSet.utime_until, 32); + builder.storeUint(validatorSet.total, 16); + builder.storeUint(validatorSet.main, 16); + storeHashmap(validatorSet.list, storeValidatorDescr)(builder); + if ((!(validatorSet.main <= validatorSet.total))) { + throw new Error('Condition (validatorSet.main <= validatorSet.total) is not satisfied while loading "ValidatorSet_validators" for type "ValidatorSet"'); + } + if ((!(validatorSet.main >= 1))) { + throw new Error('Condition (validatorSet.main >= 1) is not satisfied while loading "ValidatorSet_validators" for type "ValidatorSet"'); + } + }) + + } + if ((validatorSet.kind == 'ValidatorSet_validators_ext')) { + return ((builder: Builder) => { + builder.storeUint(0x12, 8); + builder.storeUint(validatorSet.utime_since, 32); + builder.storeUint(validatorSet.utime_until, 32); + builder.storeUint(validatorSet.total, 16); + builder.storeUint(validatorSet.main, 16); + builder.storeUint(validatorSet.total_weight, 64); + storeHashmapE(validatorSet.list, storeValidatorDescr)(builder); + if ((!(validatorSet.main <= validatorSet.total))) { + throw new Error('Condition (validatorSet.main <= validatorSet.total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); + } + if ((!(validatorSet.main >= 1))) { + throw new Error('Condition (validatorSet.main >= 1) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); + } + }) + + } + throw new Error('Expected one of "ValidatorSet_validators", "ValidatorSet_validators_ext" in loading "ValidatorSet", but data does not satisfy any constructor'); +} + +// _ config_addr:bits256 = ConfigParam 0; + +// _ elector_addr:bits256 = ConfigParam 1; + +// _ minter_addr:bits256 = ConfigParam 2; + +// _ fee_collector_addr:bits256 = ConfigParam 3; + +// _ dns_root_addr:bits256 = ConfigParam 4; + +// _ BurningConfig = ConfigParam 5; + +// _ mint_new_price:Grams mint_add_price:Grams = ConfigParam 6; + +// _ to_mint:ExtraCurrencyCollection = ConfigParam 7; + +// _ GlobalVersion = ConfigParam 8; + +// _ mandatory_params:(Hashmap 32 True) = ConfigParam 9; + +// _ critical_params:(Hashmap 32 True) = ConfigParam 10; + +// _ ConfigVotingSetup = ConfigParam 11; + +// _ workchains:(HashmapE 32 WorkchainDescr) = ConfigParam 12; + +// _ ComplaintPricing = ConfigParam 13; + +// _ BlockCreateFees = ConfigParam 14; + +/* +_ validators_elected_for:uint32 elections_start_before:uint32 + elections_end_before:uint32 stake_held_for:uint32 + = ConfigParam 15; +*/ + +/* +_ max_validators:(## 16) max_main_validators:(## 16) min_validators:(## 16) + { max_validators >= max_main_validators } + { max_main_validators >= min_validators } + { min_validators >= 1 } + = ConfigParam 16; +*/ + +// _ min_stake:Grams max_stake:Grams min_total_stake:Grams max_stake_factor:uint32 = ConfigParam 17; + +// _ (Hashmap 32 StoragePrices) = ConfigParam 18; + +// _ global_id:int32 = ConfigParam 19; + +// config_mc_gas_prices#_ GasLimitsPrices = ConfigParam 20; + +// config_gas_prices#_ GasLimitsPrices = ConfigParam 21; + +// config_mc_block_limits#_ BlockLimits = ConfigParam 22; + +// config_block_limits#_ BlockLimits = ConfigParam 23; + +// config_mc_fwd_prices#_ MsgForwardPrices = ConfigParam 24; + +// config_fwd_prices#_ MsgForwardPrices = ConfigParam 25; + +// _ CatchainConfig = ConfigParam 28; + +// _ ConsensusConfig = ConfigParam 29; + +// _ fundamental_smc_addr:(HashmapE 256 True) = ConfigParam 31; + +// _ prev_validators:ValidatorSet = ConfigParam 32; + +// _ prev_temp_validators:ValidatorSet = ConfigParam 33; + +// _ cur_validators:ValidatorSet = ConfigParam 34; + +// _ cur_temp_validators:ValidatorSet = ConfigParam 35; + +// _ next_validators:ValidatorSet = ConfigParam 36; + +// _ next_temp_validators:ValidatorSet = ConfigParam 37; + +// _ (HashmapE 256 ValidatorSignedTempKey) = ConfigParam 39; + +// _ MisbehaviourPunishmentConfig = ConfigParam 40; + +// _ SizeLimitsConfig = ConfigParam 43; + +// _ SuspendedAddressList = ConfigParam 44; + +// _ OracleBridgeParams = ConfigParam 71; + +// _ OracleBridgeParams = ConfigParam 72; + +// _ OracleBridgeParams = ConfigParam 73; + +// _ JettonBridgeParams = ConfigParam 79; + +// _ JettonBridgeParams = ConfigParam 81; + +// _ JettonBridgeParams = ConfigParam 82; + +export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { + if ((arg0 == 0)) { + let config_addr: BitString = slice.loadBits(256); + return { + kind: 'ConfigParam__', + config_addr: config_addr, + } + + } + if ((arg0 == 1)) { + let elector_addr: BitString = slice.loadBits(256); + return { + kind: 'ConfigParam__1', + elector_addr: elector_addr, + } + + } + if ((arg0 == 2)) { + let minter_addr: BitString = slice.loadBits(256); + return { + kind: 'ConfigParam__2', + minter_addr: minter_addr, + } + + } + if ((arg0 == 3)) { + let fee_collector_addr: BitString = slice.loadBits(256); + return { + kind: 'ConfigParam__3', + fee_collector_addr: fee_collector_addr, + } + + } + if ((arg0 == 4)) { + let dns_root_addr: BitString = slice.loadBits(256); + return { + kind: 'ConfigParam__4', + dns_root_addr: dns_root_addr, + } + + } + if ((arg0 == 5)) { + let anon0: BurningConfig = loadBurningConfig(slice); + return { + kind: 'ConfigParam__5', + anon0: anon0, + } + + } + if ((arg0 == 6)) { + let mint_new_price: Grams = loadGrams(slice); + let mint_add_price: Grams = loadGrams(slice); + return { + kind: 'ConfigParam__6', + mint_new_price: mint_new_price, + mint_add_price: mint_add_price, + } + + } + if ((arg0 == 7)) { + let to_mint: ExtraCurrencyCollection = loadExtraCurrencyCollection(slice); + return { + kind: 'ConfigParam__7', + to_mint: to_mint, + } + + } + if ((arg0 == 8)) { + let anon0: GlobalVersion = loadGlobalVersion(slice); + return { + kind: 'ConfigParam__8', + anon0: anon0, + } + + } + if ((arg0 == 9)) { + let mandatory_params: Hashmap = loadHashmap(slice, 32, loadTrue); + return { + kind: 'ConfigParam__9', + mandatory_params: mandatory_params, + } + + } + if ((arg0 == 10)) { + let critical_params: Hashmap = loadHashmap(slice, 32, loadTrue); + return { + kind: 'ConfigParam__10', + critical_params: critical_params, + } + + } + if ((arg0 == 11)) { + let anon0: ConfigVotingSetup = loadConfigVotingSetup(slice); + return { + kind: 'ConfigParam__11', + anon0: anon0, + } + + } + if ((arg0 == 12)) { + let workchains: HashmapE = loadHashmapE(slice, 32, loadWorkchainDescr); + return { + kind: 'ConfigParam__12', + workchains: workchains, + } + + } + if ((arg0 == 13)) { + let anon0: ComplaintPricing = loadComplaintPricing(slice); + return { + kind: 'ConfigParam__13', + anon0: anon0, + } + + } + if ((arg0 == 14)) { + let anon0: BlockCreateFees = loadBlockCreateFees(slice); + return { + kind: 'ConfigParam__14', + anon0: anon0, + } + + } + if ((arg0 == 15)) { + let validators_elected_for: number = slice.loadUint(32); + let elections_start_before: number = slice.loadUint(32); + let elections_end_before: number = slice.loadUint(32); + let stake_held_for: number = slice.loadUint(32); + return { + kind: 'ConfigParam__15', + validators_elected_for: validators_elected_for, + elections_start_before: elections_start_before, + elections_end_before: elections_end_before, + stake_held_for: stake_held_for, + } + + } + if ((arg0 == 16)) { + let max_validators: number = slice.loadUint(16); + let max_main_validators: number = slice.loadUint(16); + let min_validators: number = slice.loadUint(16); + if ((!(max_validators >= max_main_validators))) { + throw new Error('Condition (max_validators >= max_main_validators) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + if ((!(max_main_validators >= min_validators))) { + throw new Error('Condition (max_main_validators >= min_validators) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + if ((!(min_validators >= 1))) { + throw new Error('Condition (min_validators >= 1) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + return { + kind: 'ConfigParam__16', + max_validators: max_validators, + max_main_validators: max_main_validators, + min_validators: min_validators, + } + + } + if ((arg0 == 17)) { + let min_stake: Grams = loadGrams(slice); + let max_stake: Grams = loadGrams(slice); + let min_total_stake: Grams = loadGrams(slice); + let max_stake_factor: number = slice.loadUint(32); + return { + kind: 'ConfigParam__17', + min_stake: min_stake, + max_stake: max_stake, + min_total_stake: min_total_stake, + max_stake_factor: max_stake_factor, + } + + } + if ((arg0 == 18)) { + let anon0: Hashmap = loadHashmap(slice, 32, loadStoragePrices); + return { + kind: 'ConfigParam__18', + anon0: anon0, + } + + } + if ((arg0 == 19)) { + let global_id: number = slice.loadInt(32); + return { + kind: 'ConfigParam__19', + global_id: global_id, + } + + } + if ((arg0 == 20)) { + let anon0: GasLimitsPrices = loadGasLimitsPrices(slice); + return { + kind: 'ConfigParam_config_mc_gas_prices', + anon0: anon0, + } + + } + if ((arg0 == 21)) { + let anon0: GasLimitsPrices = loadGasLimitsPrices(slice); + return { + kind: 'ConfigParam_config_gas_prices', + anon0: anon0, + } + + } + if ((arg0 == 22)) { + let anon0: BlockLimits = loadBlockLimits(slice); + return { + kind: 'ConfigParam_config_mc_block_limits', + anon0: anon0, + } + + } + if ((arg0 == 23)) { + let anon0: BlockLimits = loadBlockLimits(slice); + return { + kind: 'ConfigParam_config_block_limits', + anon0: anon0, + } + + } + if ((arg0 == 24)) { + let anon0: MsgForwardPrices = loadMsgForwardPrices(slice); + return { + kind: 'ConfigParam_config_mc_fwd_prices', + anon0: anon0, + } + + } + if ((arg0 == 25)) { + let anon0: MsgForwardPrices = loadMsgForwardPrices(slice); + return { + kind: 'ConfigParam_config_fwd_prices', + anon0: anon0, + } + + } + if ((arg0 == 28)) { + let anon0: CatchainConfig = loadCatchainConfig(slice); + return { + kind: 'ConfigParam__26', + anon0: anon0, + } + + } + if ((arg0 == 29)) { + let anon0: ConsensusConfig = loadConsensusConfig(slice); + return { + kind: 'ConfigParam__27', + anon0: anon0, + } + + } + if ((arg0 == 31)) { + let fundamental_smc_addr: HashmapE = loadHashmapE(slice, 256, loadTrue); + return { + kind: 'ConfigParam__28', + fundamental_smc_addr: fundamental_smc_addr, + } + + } + if ((arg0 == 32)) { + let prev_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__29', + prev_validators: prev_validators, + } + + } + if ((arg0 == 33)) { + let prev_temp_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__30', + prev_temp_validators: prev_temp_validators, + } + + } + if ((arg0 == 34)) { + let cur_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__31', + cur_validators: cur_validators, + } + + } + if ((arg0 == 35)) { + let cur_temp_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__32', + cur_temp_validators: cur_temp_validators, + } + + } + if ((arg0 == 36)) { + let next_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__33', + next_validators: next_validators, + } + + } + if ((arg0 == 37)) { + let next_temp_validators: ValidatorSet = loadValidatorSet(slice); + return { + kind: 'ConfigParam__34', + next_temp_validators: next_temp_validators, + } + + } + if ((arg0 == 39)) { + let anon0: HashmapE = loadHashmapE(slice, 256, loadValidatorSignedTempKey); + return { + kind: 'ConfigParam__35', + anon0: anon0, + } + + } + if ((arg0 == 40)) { + let anon0: MisbehaviourPunishmentConfig = loadMisbehaviourPunishmentConfig(slice); + return { + kind: 'ConfigParam__36', + anon0: anon0, + } + + } + if ((arg0 == 43)) { + let anon0: SizeLimitsConfig = loadSizeLimitsConfig(slice); + return { + kind: 'ConfigParam__37', + anon0: anon0, + } + + } + if ((arg0 == 44)) { + let anon0: SuspendedAddressList = loadSuspendedAddressList(slice); + return { + kind: 'ConfigParam__38', + anon0: anon0, + } + + } + if ((arg0 == 71)) { + let anon0: OracleBridgeParams = loadOracleBridgeParams(slice); + return { + kind: 'ConfigParam__39', + anon0: anon0, + } + + } + if ((arg0 == 72)) { + let anon0: OracleBridgeParams = loadOracleBridgeParams(slice); + return { + kind: 'ConfigParam__40', + anon0: anon0, + } + + } + if ((arg0 == 73)) { + let anon0: OracleBridgeParams = loadOracleBridgeParams(slice); + return { + kind: 'ConfigParam__41', + anon0: anon0, + } + + } + if ((arg0 == 79)) { + let anon0: JettonBridgeParams = loadJettonBridgeParams(slice); + return { + kind: 'ConfigParam__42', + anon0: anon0, + } + + } + if ((arg0 == 81)) { + let anon0: JettonBridgeParams = loadJettonBridgeParams(slice); + return { + kind: 'ConfigParam__43', + anon0: anon0, + } + + } + if ((arg0 == 82)) { + let anon0: JettonBridgeParams = loadJettonBridgeParams(slice); + return { + kind: 'ConfigParam__44', + anon0: anon0, + } + + } + throw new Error('Expected one of "ConfigParam__", "ConfigParam__1", "ConfigParam__2", "ConfigParam__3", "ConfigParam__4", "ConfigParam__5", "ConfigParam__6", "ConfigParam__7", "ConfigParam__8", "ConfigParam__9", "ConfigParam__10", "ConfigParam__11", "ConfigParam__12", "ConfigParam__13", "ConfigParam__14", "ConfigParam__15", "ConfigParam__16", "ConfigParam__17", "ConfigParam__18", "ConfigParam__19", "ConfigParam_config_mc_gas_prices", "ConfigParam_config_gas_prices", "ConfigParam_config_mc_block_limits", "ConfigParam_config_block_limits", "ConfigParam_config_mc_fwd_prices", "ConfigParam_config_fwd_prices", "ConfigParam__26", "ConfigParam__27", "ConfigParam__28", "ConfigParam__29", "ConfigParam__30", "ConfigParam__31", "ConfigParam__32", "ConfigParam__33", "ConfigParam__34", "ConfigParam__35", "ConfigParam__36", "ConfigParam__37", "ConfigParam__38", "ConfigParam__39", "ConfigParam__40", "ConfigParam__41", "ConfigParam__42", "ConfigParam__43", "ConfigParam__44" in loading "ConfigParam", but data does not satisfy any constructor'); +} + +export function storeConfigParam(configParam: ConfigParam): (builder: Builder) => void { + if ((configParam.kind == 'ConfigParam__')) { + return ((builder: Builder) => { + builder.storeBits(configParam.config_addr); + }) + + } + if ((configParam.kind == 'ConfigParam__1')) { + return ((builder: Builder) => { + builder.storeBits(configParam.elector_addr); + }) + + } + if ((configParam.kind == 'ConfigParam__2')) { + return ((builder: Builder) => { + builder.storeBits(configParam.minter_addr); + }) + + } + if ((configParam.kind == 'ConfigParam__3')) { + return ((builder: Builder) => { + builder.storeBits(configParam.fee_collector_addr); + }) + + } + if ((configParam.kind == 'ConfigParam__4')) { + return ((builder: Builder) => { + builder.storeBits(configParam.dns_root_addr); + }) + + } + if ((configParam.kind == 'ConfigParam__5')) { + return ((builder: Builder) => { + storeBurningConfig(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__6')) { + return ((builder: Builder) => { + storeGrams(configParam.mint_new_price)(builder); + storeGrams(configParam.mint_add_price)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__7')) { + return ((builder: Builder) => { + storeExtraCurrencyCollection(configParam.to_mint)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__8')) { + return ((builder: Builder) => { + storeGlobalVersion(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__9')) { + return ((builder: Builder) => { + storeHashmap(configParam.mandatory_params, storeTrue)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__10')) { + return ((builder: Builder) => { + storeHashmap(configParam.critical_params, storeTrue)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__11')) { + return ((builder: Builder) => { + storeConfigVotingSetup(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__12')) { + return ((builder: Builder) => { + storeHashmapE(configParam.workchains, storeWorkchainDescr)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__13')) { + return ((builder: Builder) => { + storeComplaintPricing(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__14')) { + return ((builder: Builder) => { + storeBlockCreateFees(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__15')) { + return ((builder: Builder) => { + builder.storeUint(configParam.validators_elected_for, 32); + builder.storeUint(configParam.elections_start_before, 32); + builder.storeUint(configParam.elections_end_before, 32); + builder.storeUint(configParam.stake_held_for, 32); + }) + + } + if ((configParam.kind == 'ConfigParam__16')) { + return ((builder: Builder) => { + builder.storeUint(configParam.max_validators, 16); + builder.storeUint(configParam.max_main_validators, 16); + builder.storeUint(configParam.min_validators, 16); + if ((!(configParam.max_validators >= configParam.max_main_validators))) { + throw new Error('Condition (configParam.max_validators >= configParam.max_main_validators) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + if ((!(configParam.max_main_validators >= configParam.min_validators))) { + throw new Error('Condition (configParam.max_main_validators >= configParam.min_validators) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + if ((!(configParam.min_validators >= 1))) { + throw new Error('Condition (configParam.min_validators >= 1) is not satisfied while loading "ConfigParam__16" for type "ConfigParam"'); + } + }) + + } + if ((configParam.kind == 'ConfigParam__17')) { + return ((builder: Builder) => { + storeGrams(configParam.min_stake)(builder); + storeGrams(configParam.max_stake)(builder); + storeGrams(configParam.min_total_stake)(builder); + builder.storeUint(configParam.max_stake_factor, 32); + }) + + } + if ((configParam.kind == 'ConfigParam__18')) { + return ((builder: Builder) => { + storeHashmap(configParam.anon0, storeStoragePrices)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__19')) { + return ((builder: Builder) => { + builder.storeInt(configParam.global_id, 32); + }) + + } + if ((configParam.kind == 'ConfigParam_config_mc_gas_prices')) { + return ((builder: Builder) => { + storeGasLimitsPrices(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam_config_gas_prices')) { + return ((builder: Builder) => { + storeGasLimitsPrices(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam_config_mc_block_limits')) { + return ((builder: Builder) => { + storeBlockLimits(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam_config_block_limits')) { + return ((builder: Builder) => { + storeBlockLimits(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam_config_mc_fwd_prices')) { + return ((builder: Builder) => { + storeMsgForwardPrices(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam_config_fwd_prices')) { + return ((builder: Builder) => { + storeMsgForwardPrices(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__26')) { + return ((builder: Builder) => { + storeCatchainConfig(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__27')) { + return ((builder: Builder) => { + storeConsensusConfig(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__28')) { + return ((builder: Builder) => { + storeHashmapE(configParam.fundamental_smc_addr, storeTrue)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__29')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.prev_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__30')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.prev_temp_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__31')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.cur_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__32')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.cur_temp_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__33')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.next_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__34')) { + return ((builder: Builder) => { + storeValidatorSet(configParam.next_temp_validators)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__35')) { + return ((builder: Builder) => { + storeHashmapE(configParam.anon0, storeValidatorSignedTempKey)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__36')) { + return ((builder: Builder) => { + storeMisbehaviourPunishmentConfig(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__37')) { + return ((builder: Builder) => { + storeSizeLimitsConfig(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__38')) { + return ((builder: Builder) => { + storeSuspendedAddressList(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__39')) { + return ((builder: Builder) => { + storeOracleBridgeParams(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__40')) { + return ((builder: Builder) => { + storeOracleBridgeParams(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__41')) { + return ((builder: Builder) => { + storeOracleBridgeParams(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__42')) { + return ((builder: Builder) => { + storeJettonBridgeParams(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__43')) { + return ((builder: Builder) => { + storeJettonBridgeParams(configParam.anon0)(builder); + }) + + } + if ((configParam.kind == 'ConfigParam__44')) { + return ((builder: Builder) => { + storeJettonBridgeParams(configParam.anon0)(builder); + }) + + } + throw new Error('Expected one of "ConfigParam__", "ConfigParam__1", "ConfigParam__2", "ConfigParam__3", "ConfigParam__4", "ConfigParam__5", "ConfigParam__6", "ConfigParam__7", "ConfigParam__8", "ConfigParam__9", "ConfigParam__10", "ConfigParam__11", "ConfigParam__12", "ConfigParam__13", "ConfigParam__14", "ConfigParam__15", "ConfigParam__16", "ConfigParam__17", "ConfigParam__18", "ConfigParam__19", "ConfigParam_config_mc_gas_prices", "ConfigParam_config_gas_prices", "ConfigParam_config_mc_block_limits", "ConfigParam_config_block_limits", "ConfigParam_config_mc_fwd_prices", "ConfigParam_config_fwd_prices", "ConfigParam__26", "ConfigParam__27", "ConfigParam__28", "ConfigParam__29", "ConfigParam__30", "ConfigParam__31", "ConfigParam__32", "ConfigParam__33", "ConfigParam__34", "ConfigParam__35", "ConfigParam__36", "ConfigParam__37", "ConfigParam__38", "ConfigParam__39", "ConfigParam__40", "ConfigParam__41", "ConfigParam__42", "ConfigParam__43", "ConfigParam__44" in loading "ConfigParam", but data does not satisfy any constructor'); +} + +/* +burning_config#01 + blackhole_addr:(Maybe bits256) + fee_burn_num:# fee_burn_denom:# { fee_burn_num <= fee_burn_denom } { fee_burn_denom >= 1 } = BurningConfig; +*/ + +export function loadBurningConfig(slice: Slice): BurningConfig { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { + slice.loadUint(8); + let blackhole_addr: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadBits(256) + + })); + let fee_burn_num: number = slice.loadUint(32); + let fee_burn_denom: number = slice.loadUint(32); + if ((!(fee_burn_num <= fee_burn_denom))) { + throw new Error('Condition (fee_burn_num <= fee_burn_denom) is not satisfied while loading "BurningConfig" for type "BurningConfig"'); + } + if ((!(fee_burn_denom >= 1))) { + throw new Error('Condition (fee_burn_denom >= 1) is not satisfied while loading "BurningConfig" for type "BurningConfig"'); + } + return { + kind: 'BurningConfig', + blackhole_addr: blackhole_addr, + fee_burn_num: fee_burn_num, + fee_burn_denom: fee_burn_denom, + } + + } + throw new Error('Expected one of "BurningConfig" in loading "BurningConfig", but data does not satisfy any constructor'); +} + +export function storeBurningConfig(burningConfig: BurningConfig): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x01, 8); + storeMaybe(burningConfig.blackhole_addr, ((arg: BitString) => { + return ((builder: Builder) => { + builder.storeBits(arg); + }) + + }))(builder); + builder.storeUint(burningConfig.fee_burn_num, 32); + builder.storeUint(burningConfig.fee_burn_denom, 32); + if ((!(burningConfig.fee_burn_num <= burningConfig.fee_burn_denom))) { + throw new Error('Condition (burningConfig.fee_burn_num <= burningConfig.fee_burn_denom) is not satisfied while loading "BurningConfig" for type "BurningConfig"'); + } + if ((!(burningConfig.fee_burn_denom >= 1))) { + throw new Error('Condition (burningConfig.fee_burn_denom >= 1) is not satisfied while loading "BurningConfig" for type "BurningConfig"'); + } + }) + +} + +// capabilities#c4 version:uint32 capabilities:uint64 = GlobalVersion; + +export function loadGlobalVersion(slice: Slice): GlobalVersion { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc4))) { + slice.loadUint(8); + let version: number = slice.loadUint(32); + let capabilities: number = slice.loadUint(64); + return { + kind: 'GlobalVersion', + version: version, + capabilities: capabilities, + } + + } + throw new Error('Expected one of "GlobalVersion" in loading "GlobalVersion", but data does not satisfy any constructor'); +} + +export function storeGlobalVersion(globalVersion: GlobalVersion): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xc4, 8); + builder.storeUint(globalVersion.version, 32); + builder.storeUint(globalVersion.capabilities, 64); + }) + +} + +// cfg_vote_cfg#36 min_tot_rounds:uint8 max_tot_rounds:uint8 min_wins:uint8 max_losses:uint8 min_store_sec:uint32 max_store_sec:uint32 bit_price:uint32 cell_price:uint32 = ConfigProposalSetup; + +export function loadConfigProposalSetup(slice: Slice): ConfigProposalSetup { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x36))) { + slice.loadUint(8); + let min_tot_rounds: number = slice.loadUint(8); + let max_tot_rounds: number = slice.loadUint(8); + let min_wins: number = slice.loadUint(8); + let max_losses: number = slice.loadUint(8); + let min_store_sec: number = slice.loadUint(32); + let max_store_sec: number = slice.loadUint(32); + let bit_price: number = slice.loadUint(32); + let _cell_price: number = slice.loadUint(32); + return { + kind: 'ConfigProposalSetup', + min_tot_rounds: min_tot_rounds, + max_tot_rounds: max_tot_rounds, + min_wins: min_wins, + max_losses: max_losses, + min_store_sec: min_store_sec, + max_store_sec: max_store_sec, + bit_price: bit_price, + _cell_price: _cell_price, + } + + } + throw new Error('Expected one of "ConfigProposalSetup" in loading "ConfigProposalSetup", but data does not satisfy any constructor'); +} + +export function storeConfigProposalSetup(configProposalSetup: ConfigProposalSetup): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x36, 8); + builder.storeUint(configProposalSetup.min_tot_rounds, 8); + builder.storeUint(configProposalSetup.max_tot_rounds, 8); + builder.storeUint(configProposalSetup.min_wins, 8); + builder.storeUint(configProposalSetup.max_losses, 8); + builder.storeUint(configProposalSetup.min_store_sec, 32); + builder.storeUint(configProposalSetup.max_store_sec, 32); + builder.storeUint(configProposalSetup.bit_price, 32); + builder.storeUint(configProposalSetup._cell_price, 32); + }) + +} + +// cfg_vote_setup#91 normal_params:^ConfigProposalSetup critical_params:^ConfigProposalSetup = ConfigVotingSetup; + +export function loadConfigVotingSetup(slice: Slice): ConfigVotingSetup { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x91))) { + slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let normal_params: ConfigProposalSetup = loadConfigProposalSetup(slice1); + let slice2 = slice.loadRef().beginParse(); + let critical_params: ConfigProposalSetup = loadConfigProposalSetup(slice2); + return { + kind: 'ConfigVotingSetup', + normal_params: normal_params, + critical_params: critical_params, + } + + } + throw new Error('Expected one of "ConfigVotingSetup" in loading "ConfigVotingSetup", but data does not satisfy any constructor'); +} + +export function storeConfigVotingSetup(configVotingSetup: ConfigVotingSetup): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x91, 8); + let cell1 = beginCell(); + storeConfigProposalSetup(configVotingSetup.normal_params)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeConfigProposalSetup(configVotingSetup.critical_params)(cell2); + builder.storeRef(cell2); + }) + +} + +/* +cfg_proposal#f3 param_id:int32 param_value:(Maybe ^Cell) if_hash_equal:(Maybe uint256) + = ConfigProposal; +*/ + +export function loadConfigProposal(slice: Slice): ConfigProposal { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xf3))) { + slice.loadUint(8); + let param_id: number = slice.loadInt(32); + let param_value: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + let if_hash_equal: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadUintBig(256) + + })); + return { + kind: 'ConfigProposal', + param_id: param_id, + param_value: param_value, + if_hash_equal: if_hash_equal, + } + + } + throw new Error('Expected one of "ConfigProposal" in loading "ConfigProposal", but data does not satisfy any constructor'); +} + +export function storeConfigProposal(configProposal: ConfigProposal): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xf3, 8); + builder.storeInt(configProposal.param_id, 32); + storeMaybe(configProposal.param_value, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeMaybe(configProposal.if_hash_equal, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) + + }))(builder); + }) + +} + +/* +cfg_proposal_status#ce expires:uint32 proposal:^ConfigProposal is_critical:Bool + voters:(HashmapE 16 True) remaining_weight:int64 validator_set_id:uint256 + rounds_remaining:uint8 wins:uint8 losses:uint8 = ConfigProposalStatus; +*/ + +export function loadConfigProposalStatus(slice: Slice): ConfigProposalStatus { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xce))) { + slice.loadUint(8); + let expires: number = slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let proposal: ConfigProposal = loadConfigProposal(slice1); + let is_critical: boolean = slice.loadBoolean(); + let voters: HashmapE = loadHashmapE(slice, 16, loadTrue); + let remaining_weight: number = slice.loadInt(64); + let validator_set_id: bigint = slice.loadUintBig(256); + let rounds_remaining: number = slice.loadUint(8); + let wins: number = slice.loadUint(8); + let losses: number = slice.loadUint(8); + return { + kind: 'ConfigProposalStatus', + expires: expires, + proposal: proposal, + is_critical: is_critical, + voters: voters, + remaining_weight: remaining_weight, + validator_set_id: validator_set_id, + rounds_remaining: rounds_remaining, + wins: wins, + losses: losses, + } + + } + throw new Error('Expected one of "ConfigProposalStatus" in loading "ConfigProposalStatus", but data does not satisfy any constructor'); +} + +export function storeConfigProposalStatus(configProposalStatus: ConfigProposalStatus): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xce, 8); + builder.storeUint(configProposalStatus.expires, 32); + let cell1 = beginCell(); + storeConfigProposal(configProposalStatus.proposal)(cell1); + builder.storeRef(cell1); + builder.storeBit(configProposalStatus.is_critical); + storeHashmapE(configProposalStatus.voters, storeTrue)(builder); + builder.storeInt(configProposalStatus.remaining_weight, 64); + builder.storeUint(configProposalStatus.validator_set_id, 256); + builder.storeUint(configProposalStatus.rounds_remaining, 8); + builder.storeUint(configProposalStatus.wins, 8); + builder.storeUint(configProposalStatus.losses, 8); + }) + +} + +// wfmt_basic#1 vm_version:int32 vm_mode:uint64 = WorkchainFormat 1; + +/* +wfmt_ext#0 min_addr_len:(## 12) max_addr_len:(## 12) addr_len_step:(## 12) + { min_addr_len >= 64 } { min_addr_len <= max_addr_len } + { max_addr_len <= 1023 } { addr_len_step <= 1023 } + workchain_type_id:(## 32) { workchain_type_id >= 1 } + = WorkchainFormat 0; +*/ + +export function loadWorkchainFormat(slice: Slice, arg0: number): WorkchainFormat { + if (((slice.remainingBits >= 4) && ((slice.preloadUint(4) == 0x1) && (arg0 == 1)))) { + slice.loadUint(4); + let vm_version: number = slice.loadInt(32); + let vm_mode: number = slice.loadUint(64); + return { + kind: 'WorkchainFormat_wfmt_basic', + vm_version: vm_version, + vm_mode: vm_mode, + } + + } + if (((slice.remainingBits >= 4) && ((slice.preloadUint(4) == 0x0) && (arg0 == 0)))) { + slice.loadUint(4); + let min_addr_len: number = slice.loadUint(12); + let max_addr_len: number = slice.loadUint(12); + let addr_len_step: number = slice.loadUint(12); + let workchain_type_id: number = slice.loadUint(32); + if ((!(min_addr_len >= 64))) { + throw new Error('Condition (min_addr_len >= 64) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(min_addr_len <= max_addr_len))) { + throw new Error('Condition (min_addr_len <= max_addr_len) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(max_addr_len <= 1023))) { + throw new Error('Condition (max_addr_len <= 1023) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(addr_len_step <= 1023))) { + throw new Error('Condition (addr_len_step <= 1023) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(workchain_type_id >= 1))) { + throw new Error('Condition (workchain_type_id >= 1) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + return { + kind: 'WorkchainFormat_wfmt_ext', + min_addr_len: min_addr_len, + max_addr_len: max_addr_len, + addr_len_step: addr_len_step, + workchain_type_id: workchain_type_id, + } + + } + throw new Error('Expected one of "WorkchainFormat_wfmt_basic", "WorkchainFormat_wfmt_ext" in loading "WorkchainFormat", but data does not satisfy any constructor'); +} + +export function storeWorkchainFormat(workchainFormat: WorkchainFormat): (builder: Builder) => void { + if ((workchainFormat.kind == 'WorkchainFormat_wfmt_basic')) { + return ((builder: Builder) => { + builder.storeUint(0x1, 4); + builder.storeInt(workchainFormat.vm_version, 32); + builder.storeUint(workchainFormat.vm_mode, 64); + }) + + } + if ((workchainFormat.kind == 'WorkchainFormat_wfmt_ext')) { + return ((builder: Builder) => { + builder.storeUint(0x0, 4); + builder.storeUint(workchainFormat.min_addr_len, 12); + builder.storeUint(workchainFormat.max_addr_len, 12); + builder.storeUint(workchainFormat.addr_len_step, 12); + builder.storeUint(workchainFormat.workchain_type_id, 32); + if ((!(workchainFormat.min_addr_len >= 64))) { + throw new Error('Condition (workchainFormat.min_addr_len >= 64) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(workchainFormat.min_addr_len <= workchainFormat.max_addr_len))) { + throw new Error('Condition (workchainFormat.min_addr_len <= workchainFormat.max_addr_len) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(workchainFormat.max_addr_len <= 1023))) { + throw new Error('Condition (workchainFormat.max_addr_len <= 1023) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(workchainFormat.addr_len_step <= 1023))) { + throw new Error('Condition (workchainFormat.addr_len_step <= 1023) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + if ((!(workchainFormat.workchain_type_id >= 1))) { + throw new Error('Condition (workchainFormat.workchain_type_id >= 1) is not satisfied while loading "WorkchainFormat_wfmt_ext" for type "WorkchainFormat"'); + } + }) + + } + throw new Error('Expected one of "WorkchainFormat_wfmt_basic", "WorkchainFormat_wfmt_ext" in loading "WorkchainFormat", but data does not satisfy any constructor'); +} + +/* +wc_split_merge_timings#0 + split_merge_delay:uint32 split_merge_interval:uint32 + min_split_merge_interval:uint32 max_split_merge_delay:uint32 + = WcSplitMergeTimings; +*/ + +export function loadWcSplitMergeTimings(slice: Slice): WcSplitMergeTimings { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x0))) { + slice.loadUint(4); + let split_merge_delay: number = slice.loadUint(32); + let split_merge_interval: number = slice.loadUint(32); + let min_split_merge_interval: number = slice.loadUint(32); + let max_split_merge_delay: number = slice.loadUint(32); + return { + kind: 'WcSplitMergeTimings', + split_merge_delay: split_merge_delay, + split_merge_interval: split_merge_interval, + min_split_merge_interval: min_split_merge_interval, + max_split_merge_delay: max_split_merge_delay, + } + + } + throw new Error('Expected one of "WcSplitMergeTimings" in loading "WcSplitMergeTimings", but data does not satisfy any constructor'); +} + +export function storeWcSplitMergeTimings(wcSplitMergeTimings: WcSplitMergeTimings): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x0, 4); + builder.storeUint(wcSplitMergeTimings.split_merge_delay, 32); + builder.storeUint(wcSplitMergeTimings.split_merge_interval, 32); + builder.storeUint(wcSplitMergeTimings.min_split_merge_interval, 32); + builder.storeUint(wcSplitMergeTimings.max_split_merge_delay, 32); + }) + +} + +/* +workchain#a6 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + = WorkchainDescr; +*/ + +/* +workchain_v2#a7 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + split_merge_timings:WcSplitMergeTimings + = WorkchainDescr; +*/ + +export function loadWorkchainDescr(slice: Slice): WorkchainDescr { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xa6))) { + slice.loadUint(8); + let enabled_since: number = slice.loadUint(32); + let actual_min_split: number = slice.loadUint(8); + let min_split: number = slice.loadUint(8); + let max_split: number = slice.loadUint(8); + let basic: number = slice.loadUint(1); + let active: boolean = slice.loadBoolean(); + let accept_msgs: boolean = slice.loadBoolean(); + let flags: number = slice.loadUint(13); + let zerostate_root_hash: BitString = slice.loadBits(256); + let zerostate_file_hash: BitString = slice.loadBits(256); + let version: number = slice.loadUint(32); + let format: WorkchainFormat = loadWorkchainFormat(slice, basic); + if ((!(actual_min_split <= min_split))) { + throw new Error('Condition (actual_min_split <= min_split) is not satisfied while loading "WorkchainDescr_workchain" for type "WorkchainDescr"'); + } + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "WorkchainDescr_workchain" for type "WorkchainDescr"'); + } + return { + kind: 'WorkchainDescr_workchain', + enabled_since: enabled_since, + actual_min_split: actual_min_split, + min_split: min_split, + max_split: max_split, + basic: basic, + active: active, + accept_msgs: accept_msgs, + flags: flags, + zerostate_root_hash: zerostate_root_hash, + zerostate_file_hash: zerostate_file_hash, + version: version, + format: format, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xa7))) { + slice.loadUint(8); + let enabled_since: number = slice.loadUint(32); + let actual_min_split: number = slice.loadUint(8); + let min_split: number = slice.loadUint(8); + let max_split: number = slice.loadUint(8); + let basic: number = slice.loadUint(1); + let active: boolean = slice.loadBoolean(); + let accept_msgs: boolean = slice.loadBoolean(); + let flags: number = slice.loadUint(13); + let zerostate_root_hash: BitString = slice.loadBits(256); + let zerostate_file_hash: BitString = slice.loadBits(256); + let version: number = slice.loadUint(32); + let format: WorkchainFormat = loadWorkchainFormat(slice, basic); + let split_merge_timings: WcSplitMergeTimings = loadWcSplitMergeTimings(slice); + if ((!(actual_min_split <= min_split))) { + throw new Error('Condition (actual_min_split <= min_split) is not satisfied while loading "WorkchainDescr_workchain_v2" for type "WorkchainDescr"'); + } + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "WorkchainDescr_workchain_v2" for type "WorkchainDescr"'); + } + return { + kind: 'WorkchainDescr_workchain_v2', + enabled_since: enabled_since, + actual_min_split: actual_min_split, + min_split: min_split, + max_split: max_split, + basic: basic, + active: active, + accept_msgs: accept_msgs, + flags: flags, + zerostate_root_hash: zerostate_root_hash, + zerostate_file_hash: zerostate_file_hash, + version: version, + format: format, + split_merge_timings: split_merge_timings, + } + + } + throw new Error('Expected one of "WorkchainDescr_workchain", "WorkchainDescr_workchain_v2" in loading "WorkchainDescr", but data does not satisfy any constructor'); +} + +export function storeWorkchainDescr(workchainDescr: WorkchainDescr): (builder: Builder) => void { + if ((workchainDescr.kind == 'WorkchainDescr_workchain')) { + return ((builder: Builder) => { + builder.storeUint(0xa6, 8); + builder.storeUint(workchainDescr.enabled_since, 32); + builder.storeUint(workchainDescr.actual_min_split, 8); + builder.storeUint(workchainDescr.min_split, 8); + builder.storeUint(workchainDescr.max_split, 8); + builder.storeUint(workchainDescr.basic, 1); + builder.storeBit(workchainDescr.active); + builder.storeBit(workchainDescr.accept_msgs); + builder.storeUint(workchainDescr.flags, 13); + builder.storeBits(workchainDescr.zerostate_root_hash); + builder.storeBits(workchainDescr.zerostate_file_hash); + builder.storeUint(workchainDescr.version, 32); + storeWorkchainFormat(workchainDescr.format)(builder); + if ((!(workchainDescr.actual_min_split <= workchainDescr.min_split))) { + throw new Error('Condition (workchainDescr.actual_min_split <= workchainDescr.min_split) is not satisfied while loading "WorkchainDescr_workchain" for type "WorkchainDescr"'); + } + if ((!(workchainDescr.flags == 0))) { + throw new Error('Condition (workchainDescr.flags == 0) is not satisfied while loading "WorkchainDescr_workchain" for type "WorkchainDescr"'); + } + }) + + } + if ((workchainDescr.kind == 'WorkchainDescr_workchain_v2')) { + return ((builder: Builder) => { + builder.storeUint(0xa7, 8); + builder.storeUint(workchainDescr.enabled_since, 32); + builder.storeUint(workchainDescr.actual_min_split, 8); + builder.storeUint(workchainDescr.min_split, 8); + builder.storeUint(workchainDescr.max_split, 8); + builder.storeUint(workchainDescr.basic, 1); + builder.storeBit(workchainDescr.active); + builder.storeBit(workchainDescr.accept_msgs); + builder.storeUint(workchainDescr.flags, 13); + builder.storeBits(workchainDescr.zerostate_root_hash); + builder.storeBits(workchainDescr.zerostate_file_hash); + builder.storeUint(workchainDescr.version, 32); + storeWorkchainFormat(workchainDescr.format)(builder); + storeWcSplitMergeTimings(workchainDescr.split_merge_timings)(builder); + if ((!(workchainDescr.actual_min_split <= workchainDescr.min_split))) { + throw new Error('Condition (workchainDescr.actual_min_split <= workchainDescr.min_split) is not satisfied while loading "WorkchainDescr_workchain_v2" for type "WorkchainDescr"'); + } + if ((!(workchainDescr.flags == 0))) { + throw new Error('Condition (workchainDescr.flags == 0) is not satisfied while loading "WorkchainDescr_workchain_v2" for type "WorkchainDescr"'); + } + }) + + } + throw new Error('Expected one of "WorkchainDescr_workchain", "WorkchainDescr_workchain_v2" in loading "WorkchainDescr", but data does not satisfy any constructor'); +} + +// complaint_prices#1a deposit:Grams bit_price:Grams cell_price:Grams = ComplaintPricing; + +export function loadComplaintPricing(slice: Slice): ComplaintPricing { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x1a))) { + slice.loadUint(8); + let deposit: Grams = loadGrams(slice); + let bit_price: Grams = loadGrams(slice); + let _cell_price: Grams = loadGrams(slice); + return { + kind: 'ComplaintPricing', + deposit: deposit, + bit_price: bit_price, + _cell_price: _cell_price, + } + + } + throw new Error('Expected one of "ComplaintPricing" in loading "ComplaintPricing", but data does not satisfy any constructor'); +} + +export function storeComplaintPricing(complaintPricing: ComplaintPricing): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x1a, 8); + storeGrams(complaintPricing.deposit)(builder); + storeGrams(complaintPricing.bit_price)(builder); + storeGrams(complaintPricing._cell_price)(builder); + }) + +} + +/* +block_grams_created#6b masterchain_block_fee:Grams basechain_block_fee:Grams + = BlockCreateFees; +*/ + +export function loadBlockCreateFees(slice: Slice): BlockCreateFees { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x6b))) { + slice.loadUint(8); + let masterchain_block_fee: Grams = loadGrams(slice); + let basechain_block_fee: Grams = loadGrams(slice); + return { + kind: 'BlockCreateFees', + masterchain_block_fee: masterchain_block_fee, + basechain_block_fee: basechain_block_fee, + } + + } + throw new Error('Expected one of "BlockCreateFees" in loading "BlockCreateFees", but data does not satisfy any constructor'); +} + +export function storeBlockCreateFees(blockCreateFees: BlockCreateFees): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x6b, 8); + storeGrams(blockCreateFees.masterchain_block_fee)(builder); + storeGrams(blockCreateFees.basechain_block_fee)(builder); + }) + +} + +/* +_#cc utime_since:uint32 bit_price_ps:uint64 cell_price_ps:uint64 + mc_bit_price_ps:uint64 mc_cell_price_ps:uint64 = StoragePrices; +*/ + +export function loadStoragePrices(slice: Slice): StoragePrices { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xcc))) { + slice.loadUint(8); + let utime_since: number = slice.loadUint(32); + let bit_price_ps: number = slice.loadUint(64); + let _cell_price_ps: number = slice.loadUint(64); + let mc_bit_price_ps: number = slice.loadUint(64); + let mc_cell_price_ps: number = slice.loadUint(64); + return { + kind: 'StoragePrices', + utime_since: utime_since, + bit_price_ps: bit_price_ps, + _cell_price_ps: _cell_price_ps, + mc_bit_price_ps: mc_bit_price_ps, + mc_cell_price_ps: mc_cell_price_ps, + } + + } + throw new Error('Expected one of "StoragePrices" in loading "StoragePrices", but data does not satisfy any constructor'); +} + +export function storeStoragePrices(storagePrices: StoragePrices): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xcc, 8); + builder.storeUint(storagePrices.utime_since, 32); + builder.storeUint(storagePrices.bit_price_ps, 64); + builder.storeUint(storagePrices._cell_price_ps, 64); + builder.storeUint(storagePrices.mc_bit_price_ps, 64); + builder.storeUint(storagePrices.mc_cell_price_ps, 64); + }) + +} + +/* +gas_prices#dd gas_price:uint64 gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; +*/ + +/* +gas_prices_ext#de gas_price:uint64 gas_limit:uint64 special_gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; +*/ + +/* +gas_flat_pfx#d1 flat_gas_limit:uint64 flat_gas_price:uint64 other:GasLimitsPrices + = GasLimitsPrices; +*/ + +export function loadGasLimitsPrices(slice: Slice): GasLimitsPrices { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xdd))) { + slice.loadUint(8); + let gas_price: number = slice.loadUint(64); + let gas_limit: number = slice.loadUint(64); + let gas_credit: number = slice.loadUint(64); + let block_gas_limit: number = slice.loadUint(64); + let freeze_due_limit: number = slice.loadUint(64); + let delete_due_limit: number = slice.loadUint(64); + return { + kind: 'GasLimitsPrices_gas_prices', + gas_price: gas_price, + gas_limit: gas_limit, + gas_credit: gas_credit, + block_gas_limit: block_gas_limit, + freeze_due_limit: freeze_due_limit, + delete_due_limit: delete_due_limit, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xde))) { + slice.loadUint(8); + let gas_price: number = slice.loadUint(64); + let gas_limit: number = slice.loadUint(64); + let special_gas_limit: number = slice.loadUint(64); + let gas_credit: number = slice.loadUint(64); + let block_gas_limit: number = slice.loadUint(64); + let freeze_due_limit: number = slice.loadUint(64); + let delete_due_limit: number = slice.loadUint(64); + return { + kind: 'GasLimitsPrices_gas_prices_ext', + gas_price: gas_price, + gas_limit: gas_limit, + special_gas_limit: special_gas_limit, + gas_credit: gas_credit, + block_gas_limit: block_gas_limit, + freeze_due_limit: freeze_due_limit, + delete_due_limit: delete_due_limit, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd1))) { + slice.loadUint(8); + let flat_gas_limit: number = slice.loadUint(64); + let flat_gas_price: number = slice.loadUint(64); + let other: GasLimitsPrices = loadGasLimitsPrices(slice); + return { + kind: 'GasLimitsPrices_gas_flat_pfx', + flat_gas_limit: flat_gas_limit, + flat_gas_price: flat_gas_price, + other: other, + } + + } + throw new Error('Expected one of "GasLimitsPrices_gas_prices", "GasLimitsPrices_gas_prices_ext", "GasLimitsPrices_gas_flat_pfx" in loading "GasLimitsPrices", but data does not satisfy any constructor'); +} + +export function storeGasLimitsPrices(gasLimitsPrices: GasLimitsPrices): (builder: Builder) => void { + if ((gasLimitsPrices.kind == 'GasLimitsPrices_gas_prices')) { + return ((builder: Builder) => { + builder.storeUint(0xdd, 8); + builder.storeUint(gasLimitsPrices.gas_price, 64); + builder.storeUint(gasLimitsPrices.gas_limit, 64); + builder.storeUint(gasLimitsPrices.gas_credit, 64); + builder.storeUint(gasLimitsPrices.block_gas_limit, 64); + builder.storeUint(gasLimitsPrices.freeze_due_limit, 64); + builder.storeUint(gasLimitsPrices.delete_due_limit, 64); + }) + + } + if ((gasLimitsPrices.kind == 'GasLimitsPrices_gas_prices_ext')) { + return ((builder: Builder) => { + builder.storeUint(0xde, 8); + builder.storeUint(gasLimitsPrices.gas_price, 64); + builder.storeUint(gasLimitsPrices.gas_limit, 64); + builder.storeUint(gasLimitsPrices.special_gas_limit, 64); + builder.storeUint(gasLimitsPrices.gas_credit, 64); + builder.storeUint(gasLimitsPrices.block_gas_limit, 64); + builder.storeUint(gasLimitsPrices.freeze_due_limit, 64); + builder.storeUint(gasLimitsPrices.delete_due_limit, 64); + }) + + } + if ((gasLimitsPrices.kind == 'GasLimitsPrices_gas_flat_pfx')) { + return ((builder: Builder) => { + builder.storeUint(0xd1, 8); + builder.storeUint(gasLimitsPrices.flat_gas_limit, 64); + builder.storeUint(gasLimitsPrices.flat_gas_price, 64); + storeGasLimitsPrices(gasLimitsPrices.other)(builder); + }) + + } + throw new Error('Expected one of "GasLimitsPrices_gas_prices", "GasLimitsPrices_gas_prices_ext", "GasLimitsPrices_gas_flat_pfx" in loading "GasLimitsPrices", but data does not satisfy any constructor'); +} + +/* +param_limits#c3 underload:# soft_limit:# { underload <= soft_limit } + hard_limit:# { soft_limit <= hard_limit } = ParamLimits; +*/ + +export function loadParamLimits(slice: Slice): ParamLimits { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc3))) { + slice.loadUint(8); + let underload: number = slice.loadUint(32); + let soft_limit: number = slice.loadUint(32); + let hard_limit: number = slice.loadUint(32); + if ((!(underload <= soft_limit))) { + throw new Error('Condition (underload <= soft_limit) is not satisfied while loading "ParamLimits" for type "ParamLimits"'); + } + if ((!(soft_limit <= hard_limit))) { + throw new Error('Condition (soft_limit <= hard_limit) is not satisfied while loading "ParamLimits" for type "ParamLimits"'); + } + return { + kind: 'ParamLimits', + underload: underload, + soft_limit: soft_limit, + hard_limit: hard_limit, + } + + } + throw new Error('Expected one of "ParamLimits" in loading "ParamLimits", but data does not satisfy any constructor'); +} + +export function storeParamLimits(paramLimits: ParamLimits): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xc3, 8); + builder.storeUint(paramLimits.underload, 32); + builder.storeUint(paramLimits.soft_limit, 32); + builder.storeUint(paramLimits.hard_limit, 32); + if ((!(paramLimits.underload <= paramLimits.soft_limit))) { + throw new Error('Condition (paramLimits.underload <= paramLimits.soft_limit) is not satisfied while loading "ParamLimits" for type "ParamLimits"'); + } + if ((!(paramLimits.soft_limit <= paramLimits.hard_limit))) { + throw new Error('Condition (paramLimits.soft_limit <= paramLimits.hard_limit) is not satisfied while loading "ParamLimits" for type "ParamLimits"'); + } + }) + +} + +/* +block_limits#5d bytes:ParamLimits gas:ParamLimits lt_delta:ParamLimits + = BlockLimits; +*/ + +export function loadBlockLimits(slice: Slice): BlockLimits { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x5d))) { + slice.loadUint(8); + let bytes: ParamLimits = loadParamLimits(slice); + let gas: ParamLimits = loadParamLimits(slice); + let lt_delta: ParamLimits = loadParamLimits(slice); + return { + kind: 'BlockLimits', + bytes: bytes, + gas: gas, + lt_delta: lt_delta, + } + + } + throw new Error('Expected one of "BlockLimits" in loading "BlockLimits", but data does not satisfy any constructor'); +} + +export function storeBlockLimits(blockLimits: BlockLimits): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x5d, 8); + storeParamLimits(blockLimits.bytes)(builder); + storeParamLimits(blockLimits.gas)(builder); + storeParamLimits(blockLimits.lt_delta)(builder); + }) + +} + +/* +msg_forward_prices#ea lump_price:uint64 bit_price:uint64 cell_price:uint64 + ihr_price_factor:uint32 first_frac:uint16 next_frac:uint16 = MsgForwardPrices; +*/ + +export function loadMsgForwardPrices(slice: Slice): MsgForwardPrices { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xea))) { + slice.loadUint(8); + let lump_price: number = slice.loadUint(64); + let bit_price: number = slice.loadUint(64); + let _cell_price: number = slice.loadUint(64); + let ihr_price_factor: number = slice.loadUint(32); + let first_frac: number = slice.loadUint(16); + let next_frac: number = slice.loadUint(16); + return { + kind: 'MsgForwardPrices', + lump_price: lump_price, + bit_price: bit_price, + _cell_price: _cell_price, + ihr_price_factor: ihr_price_factor, + first_frac: first_frac, + next_frac: next_frac, + } + + } + throw new Error('Expected one of "MsgForwardPrices" in loading "MsgForwardPrices", but data does not satisfy any constructor'); +} + +export function storeMsgForwardPrices(msgForwardPrices: MsgForwardPrices): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xea, 8); + builder.storeUint(msgForwardPrices.lump_price, 64); + builder.storeUint(msgForwardPrices.bit_price, 64); + builder.storeUint(msgForwardPrices._cell_price, 64); + builder.storeUint(msgForwardPrices.ihr_price_factor, 32); + builder.storeUint(msgForwardPrices.first_frac, 16); + builder.storeUint(msgForwardPrices.next_frac, 16); + }) + +} + +/* +catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; +*/ + +/* +catchain_config_new#c2 flags:(## 7) { flags = 0 } shuffle_mc_validators:Bool + mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; +*/ + +export function loadCatchainConfig(slice: Slice): CatchainConfig { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc1))) { + slice.loadUint(8); + let mc_catchain_lifetime: number = slice.loadUint(32); + let shard_catchain_lifetime: number = slice.loadUint(32); + let shard_validators_lifetime: number = slice.loadUint(32); + let shard_validators_num: number = slice.loadUint(32); + return { + kind: 'CatchainConfig_catchain_config', + mc_catchain_lifetime: mc_catchain_lifetime, + shard_catchain_lifetime: shard_catchain_lifetime, + shard_validators_lifetime: shard_validators_lifetime, + shard_validators_num: shard_validators_num, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc2))) { + slice.loadUint(8); + let flags: number = slice.loadUint(7); + let shuffle_mc_validators: boolean = slice.loadBoolean(); + let mc_catchain_lifetime: number = slice.loadUint(32); + let shard_catchain_lifetime: number = slice.loadUint(32); + let shard_validators_lifetime: number = slice.loadUint(32); + let shard_validators_num: number = slice.loadUint(32); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "CatchainConfig_catchain_config_new" for type "CatchainConfig"'); + } + return { + kind: 'CatchainConfig_catchain_config_new', + flags: flags, + shuffle_mc_validators: shuffle_mc_validators, + mc_catchain_lifetime: mc_catchain_lifetime, + shard_catchain_lifetime: shard_catchain_lifetime, + shard_validators_lifetime: shard_validators_lifetime, + shard_validators_num: shard_validators_num, + } + + } + throw new Error('Expected one of "CatchainConfig_catchain_config", "CatchainConfig_catchain_config_new" in loading "CatchainConfig", but data does not satisfy any constructor'); +} + +export function storeCatchainConfig(catchainConfig: CatchainConfig): (builder: Builder) => void { + if ((catchainConfig.kind == 'CatchainConfig_catchain_config')) { + return ((builder: Builder) => { + builder.storeUint(0xc1, 8); + builder.storeUint(catchainConfig.mc_catchain_lifetime, 32); + builder.storeUint(catchainConfig.shard_catchain_lifetime, 32); + builder.storeUint(catchainConfig.shard_validators_lifetime, 32); + builder.storeUint(catchainConfig.shard_validators_num, 32); + }) + + } + if ((catchainConfig.kind == 'CatchainConfig_catchain_config_new')) { + return ((builder: Builder) => { + builder.storeUint(0xc2, 8); + builder.storeUint(catchainConfig.flags, 7); + builder.storeBit(catchainConfig.shuffle_mc_validators); + builder.storeUint(catchainConfig.mc_catchain_lifetime, 32); + builder.storeUint(catchainConfig.shard_catchain_lifetime, 32); + builder.storeUint(catchainConfig.shard_validators_lifetime, 32); + builder.storeUint(catchainConfig.shard_validators_num, 32); + if ((!(catchainConfig.flags == 0))) { + throw new Error('Condition (catchainConfig.flags == 0) is not satisfied while loading "CatchainConfig_catchain_config_new" for type "CatchainConfig"'); + } + }) + + } + throw new Error('Expected one of "CatchainConfig_catchain_config", "CatchainConfig_catchain_config_new" in loading "CatchainConfig", but data does not satisfy any constructor'); +} + +/* +consensus_config#d6 round_candidates:# { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; +*/ + +/* +consensus_config_new#d7 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; +*/ + +/* +consensus_config_v3#d8 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 = ConsensusConfig; +*/ + +/* +consensus_config_v4#d9 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 catchain_max_blocks_coeff:uint32 = ConsensusConfig; +*/ + +export function loadConsensusConfig(slice: Slice): ConsensusConfig { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd6))) { + slice.loadUint(8); + let round_candidates: number = slice.loadUint(32); + let next_candidate_delay_ms: number = slice.loadUint(32); + let consensus_timeout_ms: number = slice.loadUint(32); + let fast_attempts: number = slice.loadUint(32); + let attempt_duration: number = slice.loadUint(32); + let catchain_max_deps: number = slice.loadUint(32); + let max_block_bytes: number = slice.loadUint(32); + let max_collated_bytes: number = slice.loadUint(32); + if ((!(round_candidates >= 1))) { + throw new Error('Condition (round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config" for type "ConsensusConfig"'); + } + return { + kind: 'ConsensusConfig_consensus_config', + round_candidates: round_candidates, + next_candidate_delay_ms: next_candidate_delay_ms, + consensus_timeout_ms: consensus_timeout_ms, + fast_attempts: fast_attempts, + attempt_duration: attempt_duration, + catchain_max_deps: catchain_max_deps, + max_block_bytes: max_block_bytes, + max_collated_bytes: max_collated_bytes, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd7))) { + slice.loadUint(8); + let flags: number = slice.loadUint(7); + let new_catchain_ids: boolean = slice.loadBoolean(); + let round_candidates: number = slice.loadUint(8); + let next_candidate_delay_ms: number = slice.loadUint(32); + let consensus_timeout_ms: number = slice.loadUint(32); + let fast_attempts: number = slice.loadUint(32); + let attempt_duration: number = slice.loadUint(32); + let catchain_max_deps: number = slice.loadUint(32); + let max_block_bytes: number = slice.loadUint(32); + let max_collated_bytes: number = slice.loadUint(32); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_new" for type "ConsensusConfig"'); + } + if ((!(round_candidates >= 1))) { + throw new Error('Condition (round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_new" for type "ConsensusConfig"'); + } + return { + kind: 'ConsensusConfig_consensus_config_new', + flags: flags, + new_catchain_ids: new_catchain_ids, + round_candidates: round_candidates, + next_candidate_delay_ms: next_candidate_delay_ms, + consensus_timeout_ms: consensus_timeout_ms, + fast_attempts: fast_attempts, + attempt_duration: attempt_duration, + catchain_max_deps: catchain_max_deps, + max_block_bytes: max_block_bytes, + max_collated_bytes: max_collated_bytes, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd8))) { + slice.loadUint(8); + let flags: number = slice.loadUint(7); + let new_catchain_ids: boolean = slice.loadBoolean(); + let round_candidates: number = slice.loadUint(8); + let next_candidate_delay_ms: number = slice.loadUint(32); + let consensus_timeout_ms: number = slice.loadUint(32); + let fast_attempts: number = slice.loadUint(32); + let attempt_duration: number = slice.loadUint(32); + let catchain_max_deps: number = slice.loadUint(32); + let max_block_bytes: number = slice.loadUint(32); + let max_collated_bytes: number = slice.loadUint(32); + let proto_version: number = slice.loadUint(16); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_v3" for type "ConsensusConfig"'); + } + if ((!(round_candidates >= 1))) { + throw new Error('Condition (round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_v3" for type "ConsensusConfig"'); + } + return { + kind: 'ConsensusConfig_consensus_config_v3', + flags: flags, + new_catchain_ids: new_catchain_ids, + round_candidates: round_candidates, + next_candidate_delay_ms: next_candidate_delay_ms, + consensus_timeout_ms: consensus_timeout_ms, + fast_attempts: fast_attempts, + attempt_duration: attempt_duration, + catchain_max_deps: catchain_max_deps, + max_block_bytes: max_block_bytes, + max_collated_bytes: max_collated_bytes, + proto_version: proto_version, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd9))) { + slice.loadUint(8); + let flags: number = slice.loadUint(7); + let new_catchain_ids: boolean = slice.loadBoolean(); + let round_candidates: number = slice.loadUint(8); + let next_candidate_delay_ms: number = slice.loadUint(32); + let consensus_timeout_ms: number = slice.loadUint(32); + let fast_attempts: number = slice.loadUint(32); + let attempt_duration: number = slice.loadUint(32); + let catchain_max_deps: number = slice.loadUint(32); + let max_block_bytes: number = slice.loadUint(32); + let max_collated_bytes: number = slice.loadUint(32); + let proto_version: number = slice.loadUint(16); + let catchain_max_blocks_coeff: number = slice.loadUint(32); + if ((!(flags == 0))) { + throw new Error('Condition (flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_v4" for type "ConsensusConfig"'); + } + if ((!(round_candidates >= 1))) { + throw new Error('Condition (round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_v4" for type "ConsensusConfig"'); + } + return { + kind: 'ConsensusConfig_consensus_config_v4', + flags: flags, + new_catchain_ids: new_catchain_ids, + round_candidates: round_candidates, + next_candidate_delay_ms: next_candidate_delay_ms, + consensus_timeout_ms: consensus_timeout_ms, + fast_attempts: fast_attempts, + attempt_duration: attempt_duration, + catchain_max_deps: catchain_max_deps, + max_block_bytes: max_block_bytes, + max_collated_bytes: max_collated_bytes, + proto_version: proto_version, + catchain_max_blocks_coeff: catchain_max_blocks_coeff, + } + + } + throw new Error('Expected one of "ConsensusConfig_consensus_config", "ConsensusConfig_consensus_config_new", "ConsensusConfig_consensus_config_v3", "ConsensusConfig_consensus_config_v4" in loading "ConsensusConfig", but data does not satisfy any constructor'); +} + +export function storeConsensusConfig(consensusConfig: ConsensusConfig): (builder: Builder) => void { + if ((consensusConfig.kind == 'ConsensusConfig_consensus_config')) { + return ((builder: Builder) => { + builder.storeUint(0xd6, 8); + builder.storeUint(consensusConfig.round_candidates, 32); + builder.storeUint(consensusConfig.next_candidate_delay_ms, 32); + builder.storeUint(consensusConfig.consensus_timeout_ms, 32); + builder.storeUint(consensusConfig.fast_attempts, 32); + builder.storeUint(consensusConfig.attempt_duration, 32); + builder.storeUint(consensusConfig.catchain_max_deps, 32); + builder.storeUint(consensusConfig.max_block_bytes, 32); + builder.storeUint(consensusConfig.max_collated_bytes, 32); + if ((!(consensusConfig.round_candidates >= 1))) { + throw new Error('Condition (consensusConfig.round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config" for type "ConsensusConfig"'); + } + }) + + } + if ((consensusConfig.kind == 'ConsensusConfig_consensus_config_new')) { + return ((builder: Builder) => { + builder.storeUint(0xd7, 8); + builder.storeUint(consensusConfig.flags, 7); + builder.storeBit(consensusConfig.new_catchain_ids); + builder.storeUint(consensusConfig.round_candidates, 8); + builder.storeUint(consensusConfig.next_candidate_delay_ms, 32); + builder.storeUint(consensusConfig.consensus_timeout_ms, 32); + builder.storeUint(consensusConfig.fast_attempts, 32); + builder.storeUint(consensusConfig.attempt_duration, 32); + builder.storeUint(consensusConfig.catchain_max_deps, 32); + builder.storeUint(consensusConfig.max_block_bytes, 32); + builder.storeUint(consensusConfig.max_collated_bytes, 32); + if ((!(consensusConfig.flags == 0))) { + throw new Error('Condition (consensusConfig.flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_new" for type "ConsensusConfig"'); + } + if ((!(consensusConfig.round_candidates >= 1))) { + throw new Error('Condition (consensusConfig.round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_new" for type "ConsensusConfig"'); + } + }) + + } + if ((consensusConfig.kind == 'ConsensusConfig_consensus_config_v3')) { + return ((builder: Builder) => { + builder.storeUint(0xd8, 8); + builder.storeUint(consensusConfig.flags, 7); + builder.storeBit(consensusConfig.new_catchain_ids); + builder.storeUint(consensusConfig.round_candidates, 8); + builder.storeUint(consensusConfig.next_candidate_delay_ms, 32); + builder.storeUint(consensusConfig.consensus_timeout_ms, 32); + builder.storeUint(consensusConfig.fast_attempts, 32); + builder.storeUint(consensusConfig.attempt_duration, 32); + builder.storeUint(consensusConfig.catchain_max_deps, 32); + builder.storeUint(consensusConfig.max_block_bytes, 32); + builder.storeUint(consensusConfig.max_collated_bytes, 32); + builder.storeUint(consensusConfig.proto_version, 16); + if ((!(consensusConfig.flags == 0))) { + throw new Error('Condition (consensusConfig.flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_v3" for type "ConsensusConfig"'); + } + if ((!(consensusConfig.round_candidates >= 1))) { + throw new Error('Condition (consensusConfig.round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_v3" for type "ConsensusConfig"'); + } + }) + + } + if ((consensusConfig.kind == 'ConsensusConfig_consensus_config_v4')) { + return ((builder: Builder) => { + builder.storeUint(0xd9, 8); + builder.storeUint(consensusConfig.flags, 7); + builder.storeBit(consensusConfig.new_catchain_ids); + builder.storeUint(consensusConfig.round_candidates, 8); + builder.storeUint(consensusConfig.next_candidate_delay_ms, 32); + builder.storeUint(consensusConfig.consensus_timeout_ms, 32); + builder.storeUint(consensusConfig.fast_attempts, 32); + builder.storeUint(consensusConfig.attempt_duration, 32); + builder.storeUint(consensusConfig.catchain_max_deps, 32); + builder.storeUint(consensusConfig.max_block_bytes, 32); + builder.storeUint(consensusConfig.max_collated_bytes, 32); + builder.storeUint(consensusConfig.proto_version, 16); + builder.storeUint(consensusConfig.catchain_max_blocks_coeff, 32); + if ((!(consensusConfig.flags == 0))) { + throw new Error('Condition (consensusConfig.flags == 0) is not satisfied while loading "ConsensusConfig_consensus_config_v4" for type "ConsensusConfig"'); + } + if ((!(consensusConfig.round_candidates >= 1))) { + throw new Error('Condition (consensusConfig.round_candidates >= 1) is not satisfied while loading "ConsensusConfig_consensus_config_v4" for type "ConsensusConfig"'); + } + }) + + } + throw new Error('Expected one of "ConsensusConfig_consensus_config", "ConsensusConfig_consensus_config_new", "ConsensusConfig_consensus_config_v3", "ConsensusConfig_consensus_config_v4" in loading "ConsensusConfig", but data does not satisfy any constructor'); +} + +// validator_temp_key#3 adnl_addr:bits256 temp_public_key:SigPubKey seqno:# valid_until:uint32 = ValidatorTempKey; + +export function loadValidatorTempKey(slice: Slice): ValidatorTempKey { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x3))) { + slice.loadUint(4); + let adnl_addr: BitString = slice.loadBits(256); + let temp_public_key: SigPubKey = loadSigPubKey(slice); + let seqno: number = slice.loadUint(32); + let valid_until: number = slice.loadUint(32); + return { + kind: 'ValidatorTempKey', + adnl_addr: adnl_addr, + temp_public_key: temp_public_key, + seqno: seqno, + valid_until: valid_until, + } + + } + throw new Error('Expected one of "ValidatorTempKey" in loading "ValidatorTempKey", but data does not satisfy any constructor'); +} + +export function storeValidatorTempKey(validatorTempKey: ValidatorTempKey): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x3, 4); + builder.storeBits(validatorTempKey.adnl_addr); + storeSigPubKey(validatorTempKey.temp_public_key)(builder); + builder.storeUint(validatorTempKey.seqno, 32); + builder.storeUint(validatorTempKey.valid_until, 32); + }) + +} + +// signed_temp_key#4 key:^ValidatorTempKey signature:CryptoSignature = ValidatorSignedTempKey; + +export function loadValidatorSignedTempKey(slice: Slice): ValidatorSignedTempKey { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x4))) { + slice.loadUint(4); + let slice1 = slice.loadRef().beginParse(); + let key: ValidatorTempKey = loadValidatorTempKey(slice1); + let signature: CryptoSignature = loadCryptoSignature(slice); + return { + kind: 'ValidatorSignedTempKey', + key: key, + signature: signature, + } + + } + throw new Error('Expected one of "ValidatorSignedTempKey" in loading "ValidatorSignedTempKey", but data does not satisfy any constructor'); +} + +export function storeValidatorSignedTempKey(validatorSignedTempKey: ValidatorSignedTempKey): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4, 4); + let cell1 = beginCell(); + storeValidatorTempKey(validatorSignedTempKey.key)(cell1); + builder.storeRef(cell1); + storeCryptoSignature(validatorSignedTempKey.signature)(builder); + }) + +} + +/* +misbehaviour_punishment_config_v1#01 + default_flat_fine:Grams default_proportional_fine:uint32 + severity_flat_mult:uint16 severity_proportional_mult:uint16 + unpunishable_interval:uint16 + long_interval:uint16 long_flat_mult:uint16 long_proportional_mult:uint16 + medium_interval:uint16 medium_flat_mult:uint16 medium_proportional_mult:uint16 + = MisbehaviourPunishmentConfig; +*/ + +export function loadMisbehaviourPunishmentConfig(slice: Slice): MisbehaviourPunishmentConfig { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { + slice.loadUint(8); + let default_flat_fine: Grams = loadGrams(slice); + let default_proportional_fine: number = slice.loadUint(32); + let severity_flat_mult: number = slice.loadUint(16); + let severity_proportional_mult: number = slice.loadUint(16); + let unpunishable_interval: number = slice.loadUint(16); + let long_interval: number = slice.loadUint(16); + let long_flat_mult: number = slice.loadUint(16); + let long_proportional_mult: number = slice.loadUint(16); + let medium_interval: number = slice.loadUint(16); + let medium_flat_mult: number = slice.loadUint(16); + let medium_proportional_mult: number = slice.loadUint(16); + return { + kind: 'MisbehaviourPunishmentConfig', + default_flat_fine: default_flat_fine, + default_proportional_fine: default_proportional_fine, + severity_flat_mult: severity_flat_mult, + severity_proportional_mult: severity_proportional_mult, + unpunishable_interval: unpunishable_interval, + long_interval: long_interval, + long_flat_mult: long_flat_mult, + long_proportional_mult: long_proportional_mult, + medium_interval: medium_interval, + medium_flat_mult: medium_flat_mult, + medium_proportional_mult: medium_proportional_mult, + } + + } + throw new Error('Expected one of "MisbehaviourPunishmentConfig" in loading "MisbehaviourPunishmentConfig", but data does not satisfy any constructor'); +} + +export function storeMisbehaviourPunishmentConfig(misbehaviourPunishmentConfig: MisbehaviourPunishmentConfig): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x01, 8); + storeGrams(misbehaviourPunishmentConfig.default_flat_fine)(builder); + builder.storeUint(misbehaviourPunishmentConfig.default_proportional_fine, 32); + builder.storeUint(misbehaviourPunishmentConfig.severity_flat_mult, 16); + builder.storeUint(misbehaviourPunishmentConfig.severity_proportional_mult, 16); + builder.storeUint(misbehaviourPunishmentConfig.unpunishable_interval, 16); + builder.storeUint(misbehaviourPunishmentConfig.long_interval, 16); + builder.storeUint(misbehaviourPunishmentConfig.long_flat_mult, 16); + builder.storeUint(misbehaviourPunishmentConfig.long_proportional_mult, 16); + builder.storeUint(misbehaviourPunishmentConfig.medium_interval, 16); + builder.storeUint(misbehaviourPunishmentConfig.medium_flat_mult, 16); + builder.storeUint(misbehaviourPunishmentConfig.medium_proportional_mult, 16); + }) + +} + +/* +size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig; +*/ + +/* +size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32 + max_acc_public_libraries:uint32 = SizeLimitsConfig; +*/ + +export function loadSizeLimitsConfig(slice: Slice): SizeLimitsConfig { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { + slice.loadUint(8); + let max_msg_bits: number = slice.loadUint(32); + let max_msg_cells: number = slice.loadUint(32); + let max_library_cells: number = slice.loadUint(32); + let max_vm_data_depth: number = slice.loadUint(16); + let max_ext_msg_size: number = slice.loadUint(32); + let max_ext_msg_depth: number = slice.loadUint(16); + return { + kind: 'SizeLimitsConfig_size_limits_config', + max_msg_bits: max_msg_bits, + max_msg_cells: max_msg_cells, + max_library_cells: max_library_cells, + max_vm_data_depth: max_vm_data_depth, + max_ext_msg_size: max_ext_msg_size, + max_ext_msg_depth: max_ext_msg_depth, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x02))) { + slice.loadUint(8); + let max_msg_bits: number = slice.loadUint(32); + let max_msg_cells: number = slice.loadUint(32); + let max_library_cells: number = slice.loadUint(32); + let max_vm_data_depth: number = slice.loadUint(16); + let max_ext_msg_size: number = slice.loadUint(32); + let max_ext_msg_depth: number = slice.loadUint(16); + let max_acc_state_cells: number = slice.loadUint(32); + let max_acc_state_bits: number = slice.loadUint(32); + let max_acc_public_libraries: number = slice.loadUint(32); + return { + kind: 'SizeLimitsConfig_size_limits_config_v2', + max_msg_bits: max_msg_bits, + max_msg_cells: max_msg_cells, + max_library_cells: max_library_cells, + max_vm_data_depth: max_vm_data_depth, + max_ext_msg_size: max_ext_msg_size, + max_ext_msg_depth: max_ext_msg_depth, + max_acc_state_cells: max_acc_state_cells, + max_acc_state_bits: max_acc_state_bits, + max_acc_public_libraries: max_acc_public_libraries, + } + + } + throw new Error('Expected one of "SizeLimitsConfig_size_limits_config", "SizeLimitsConfig_size_limits_config_v2" in loading "SizeLimitsConfig", but data does not satisfy any constructor'); +} + +export function storeSizeLimitsConfig(sizeLimitsConfig: SizeLimitsConfig): (builder: Builder) => void { + if ((sizeLimitsConfig.kind == 'SizeLimitsConfig_size_limits_config')) { + return ((builder: Builder) => { + builder.storeUint(0x01, 8); + builder.storeUint(sizeLimitsConfig.max_msg_bits, 32); + builder.storeUint(sizeLimitsConfig.max_msg_cells, 32); + builder.storeUint(sizeLimitsConfig.max_library_cells, 32); + builder.storeUint(sizeLimitsConfig.max_vm_data_depth, 16); + builder.storeUint(sizeLimitsConfig.max_ext_msg_size, 32); + builder.storeUint(sizeLimitsConfig.max_ext_msg_depth, 16); + }) + + } + if ((sizeLimitsConfig.kind == 'SizeLimitsConfig_size_limits_config_v2')) { + return ((builder: Builder) => { + builder.storeUint(0x02, 8); + builder.storeUint(sizeLimitsConfig.max_msg_bits, 32); + builder.storeUint(sizeLimitsConfig.max_msg_cells, 32); + builder.storeUint(sizeLimitsConfig.max_library_cells, 32); + builder.storeUint(sizeLimitsConfig.max_vm_data_depth, 16); + builder.storeUint(sizeLimitsConfig.max_ext_msg_size, 32); + builder.storeUint(sizeLimitsConfig.max_ext_msg_depth, 16); + builder.storeUint(sizeLimitsConfig.max_acc_state_cells, 32); + builder.storeUint(sizeLimitsConfig.max_acc_state_bits, 32); + builder.storeUint(sizeLimitsConfig.max_acc_public_libraries, 32); + }) + + } + throw new Error('Expected one of "SizeLimitsConfig_size_limits_config", "SizeLimitsConfig_size_limits_config_v2" in loading "SizeLimitsConfig", but data does not satisfy any constructor'); +} + +// suspended_address_list#00 addresses:(HashmapE 288 Unit) suspended_until:uint32 = SuspendedAddressList; + +export function loadSuspendedAddressList(slice: Slice): SuspendedAddressList { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x00))) { + slice.loadUint(8); + let addresses: HashmapE = loadHashmapE(slice, 288, loadUnit); + let suspended_until: number = slice.loadUint(32); + return { + kind: 'SuspendedAddressList', + addresses: addresses, + suspended_until: suspended_until, + } + + } + throw new Error('Expected one of "SuspendedAddressList" in loading "SuspendedAddressList", but data does not satisfy any constructor'); +} + +export function storeSuspendedAddressList(suspendedAddressList: SuspendedAddressList): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x00, 8); + storeHashmapE(suspendedAddressList.addresses, storeUnit)(builder); + builder.storeUint(suspendedAddressList.suspended_until, 32); + }) + +} + +// oracle_bridge_params#_ bridge_address:bits256 oracle_mutlisig_address:bits256 oracles:(HashmapE 256 uint256) external_chain_address:bits256 = OracleBridgeParams; + +export function loadOracleBridgeParams(slice: Slice): OracleBridgeParams { + let bridge_address: BitString = slice.loadBits(256); + let oracle_mutlisig_address: BitString = slice.loadBits(256); + let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + return slice.loadUintBig(256) + + })); + let external_chain_address: BitString = slice.loadBits(256); + return { + kind: 'OracleBridgeParams', + bridge_address: bridge_address, + oracle_mutlisig_address: oracle_mutlisig_address, + oracles: oracles, + external_chain_address: external_chain_address, + } + +} + +export function storeOracleBridgeParams(oracleBridgeParams: OracleBridgeParams): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBits(oracleBridgeParams.bridge_address); + builder.storeBits(oracleBridgeParams.oracle_mutlisig_address); + storeHashmapE(oracleBridgeParams.oracles, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) + + }))(builder); + builder.storeBits(oracleBridgeParams.external_chain_address); + }) + +} + +/* +jetton_bridge_prices#_ bridge_burn_fee:Coins bridge_mint_fee:Coins + wallet_min_tons_for_storage:Coins + wallet_gas_consumption:Coins + minter_min_tons_for_storage:Coins + discover_gas_consumption:Coins = JettonBridgePrices; +*/ + +export function loadJettonBridgePrices(slice: Slice): JettonBridgePrices { + let bridge_burn_fee: Coins = loadCoins(slice); + let bridge_mint_fee: Coins = loadCoins(slice); + let wallet_min_tons_for_storage: Coins = loadCoins(slice); + let wallet_gas_consumption: Coins = loadCoins(slice); + let minter_min_tons_for_storage: Coins = loadCoins(slice); + let discover_gas_consumption: Coins = loadCoins(slice); + return { + kind: 'JettonBridgePrices', + bridge_burn_fee: bridge_burn_fee, + bridge_mint_fee: bridge_mint_fee, + wallet_min_tons_for_storage: wallet_min_tons_for_storage, + wallet_gas_consumption: wallet_gas_consumption, + minter_min_tons_for_storage: minter_min_tons_for_storage, + discover_gas_consumption: discover_gas_consumption, + } + +} + +export function storeJettonBridgePrices(jettonBridgePrices: JettonBridgePrices): (builder: Builder) => void { + return ((builder: Builder) => { + storeCoins(jettonBridgePrices.bridge_burn_fee)(builder); + storeCoins(jettonBridgePrices.bridge_mint_fee)(builder); + storeCoins(jettonBridgePrices.wallet_min_tons_for_storage)(builder); + storeCoins(jettonBridgePrices.wallet_gas_consumption)(builder); + storeCoins(jettonBridgePrices.minter_min_tons_for_storage)(builder); + storeCoins(jettonBridgePrices.discover_gas_consumption)(builder); + }) + +} + +// jetton_bridge_params_v0#00 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 burn_bridge_fee:Coins = JettonBridgeParams; + +// jetton_bridge_params_v1#01 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 prices:^JettonBridgePrices external_chain_address:bits256 = JettonBridgeParams; + +export function loadJettonBridgeParams(slice: Slice): JettonBridgeParams { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x00))) { + slice.loadUint(8); + let bridge_address: BitString = slice.loadBits(256); + let oracles_address: BitString = slice.loadBits(256); + let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + return slice.loadUintBig(256) + + })); + let state_flags: number = slice.loadUint(8); + let burn_bridge_fee: Coins = loadCoins(slice); + return { + kind: 'JettonBridgeParams_jetton_bridge_params_v0', + bridge_address: bridge_address, + oracles_address: oracles_address, + oracles: oracles, + state_flags: state_flags, + burn_bridge_fee: burn_bridge_fee, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { + slice.loadUint(8); + let bridge_address: BitString = slice.loadBits(256); + let oracles_address: BitString = slice.loadBits(256); + let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + return slice.loadUintBig(256) + + })); + let state_flags: number = slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let prices: JettonBridgePrices = loadJettonBridgePrices(slice1); + let external_chain_address: BitString = slice.loadBits(256); + return { + kind: 'JettonBridgeParams_jetton_bridge_params_v1', + bridge_address: bridge_address, + oracles_address: oracles_address, + oracles: oracles, + state_flags: state_flags, + prices: prices, + external_chain_address: external_chain_address, + } + + } + throw new Error('Expected one of "JettonBridgeParams_jetton_bridge_params_v0", "JettonBridgeParams_jetton_bridge_params_v1" in loading "JettonBridgeParams", but data does not satisfy any constructor'); +} + +export function storeJettonBridgeParams(jettonBridgeParams: JettonBridgeParams): (builder: Builder) => void { + if ((jettonBridgeParams.kind == 'JettonBridgeParams_jetton_bridge_params_v0')) { + return ((builder: Builder) => { + builder.storeUint(0x00, 8); + builder.storeBits(jettonBridgeParams.bridge_address); + builder.storeBits(jettonBridgeParams.oracles_address); + storeHashmapE(jettonBridgeParams.oracles, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) + + }))(builder); + builder.storeUint(jettonBridgeParams.state_flags, 8); + storeCoins(jettonBridgeParams.burn_bridge_fee)(builder); + }) + + } + if ((jettonBridgeParams.kind == 'JettonBridgeParams_jetton_bridge_params_v1')) { + return ((builder: Builder) => { + builder.storeUint(0x01, 8); + builder.storeBits(jettonBridgeParams.bridge_address); + builder.storeBits(jettonBridgeParams.oracles_address); + storeHashmapE(jettonBridgeParams.oracles, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) + + }))(builder); + builder.storeUint(jettonBridgeParams.state_flags, 8); + let cell1 = beginCell(); + storeJettonBridgePrices(jettonBridgeParams.prices)(cell1); + builder.storeRef(cell1); + builder.storeBits(jettonBridgeParams.external_chain_address); + }) + + } + throw new Error('Expected one of "JettonBridgeParams_jetton_bridge_params_v0", "JettonBridgeParams_jetton_bridge_params_v1" in loading "JettonBridgeParams", but data does not satisfy any constructor'); +} + +/* +block_signatures_pure#_ sig_count:uint32 sig_weight:uint64 + signatures:(HashmapE 16 CryptoSignaturePair) = BlockSignaturesPure; +*/ + +export function loadBlockSignaturesPure(slice: Slice): BlockSignaturesPure { + let sig_count: number = slice.loadUint(32); + let sig_weight: number = slice.loadUint(64); + let signatures: HashmapE = loadHashmapE(slice, 16, loadCryptoSignaturePair); + return { + kind: 'BlockSignaturesPure', + sig_count: sig_count, + sig_weight: sig_weight, + signatures: signatures, + } + +} + +export function storeBlockSignaturesPure(blockSignaturesPure: BlockSignaturesPure): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(blockSignaturesPure.sig_count, 32); + builder.storeUint(blockSignaturesPure.sig_weight, 64); + storeHashmapE(blockSignaturesPure.signatures, storeCryptoSignaturePair)(builder); + }) + +} + +// block_signatures#11 validator_info:ValidatorBaseInfo pure_signatures:BlockSignaturesPure = BlockSignatures; + +export function loadBlockSignatures(slice: Slice): BlockSignatures { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x11))) { + slice.loadUint(8); + let validator_info: ValidatorBaseInfo = loadValidatorBaseInfo(slice); + let pure_signatures: BlockSignaturesPure = loadBlockSignaturesPure(slice); + return { + kind: 'BlockSignatures', + validator_info: validator_info, + pure_signatures: pure_signatures, + } + + } + throw new Error('Expected one of "BlockSignatures" in loading "BlockSignatures", but data does not satisfy any constructor'); +} + +export function storeBlockSignatures(blockSignatures: BlockSignatures): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x11, 8); + storeValidatorBaseInfo(blockSignatures.validator_info)(builder); + storeBlockSignaturesPure(blockSignatures.pure_signatures)(builder); + }) + +} + +// block_proof#c3 proof_for:BlockIdExt root:^Cell signatures:(Maybe ^BlockSignatures) = BlockProof; + +export function loadBlockProof(slice: Slice): BlockProof { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc3))) { + slice.loadUint(8); + let proof_for: BlockIdExt = loadBlockIdExt(slice); + let slice1 = slice.loadRef().beginParse(); + let root: Slice = slice1; + let signatures: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadBlockSignatures(slice1) + + })); + return { + kind: 'BlockProof', + proof_for: proof_for, + root: root, + signatures: signatures, + } + + } + throw new Error('Expected one of "BlockProof" in loading "BlockProof", but data does not satisfy any constructor'); +} + +export function storeBlockProof(blockProof: BlockProof): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xc3, 8); + storeBlockIdExt(blockProof.proof_for)(builder); + let cell1 = beginCell(); + cell1.storeSlice(blockProof.root); + builder.storeRef(cell1); + storeMaybe(blockProof.signatures, ((arg: BlockSignatures) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeBlockSignatures(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// chain_empty$_ = ProofChain 0; + +// chain_link$_ {n:#} root:^Cell prev:n?^(ProofChain n) = ProofChain (n + 1); + +export function loadProofChain(slice: Slice, arg0: number): ProofChain { + if ((arg0 == 0)) { + return { + kind: 'ProofChain_chain_empty', + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let root: Slice = slice1; + let prev: ProofChain | undefined = ((arg0 - 1) ? ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadProofChain(slice1, (arg0 - 1)) + + })(slice) : undefined); + return { + kind: 'ProofChain_chain_link', + n: (arg0 - 1), + root: root, + prev: prev, + } + + } + throw new Error('Expected one of "ProofChain_chain_empty", "ProofChain_chain_link" in loading "ProofChain", but data does not satisfy any constructor'); +} + +export function storeProofChain(proofChain: ProofChain): (builder: Builder) => void { + if ((proofChain.kind == 'ProofChain_chain_empty')) { + return ((builder: Builder) => { + }) + + } + if ((proofChain.kind == 'ProofChain_chain_link')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(proofChain.root); + builder.storeRef(cell1); + if ((proofChain.prev != undefined)) { + let cell1 = beginCell(); + storeProofChain(proofChain.prev)(cell1); + builder.storeRef(cell1); + + } + }) + + } + throw new Error('Expected one of "ProofChain_chain_empty", "ProofChain_chain_link" in loading "ProofChain", but data does not satisfy any constructor'); +} + +/* +top_block_descr#d5 proof_for:BlockIdExt signatures:(Maybe ^BlockSignatures) + len:(## 8) { len >= 1 } { len <= 8 } chain:(ProofChain len) = TopBlockDescr; +*/ + +export function loadTopBlockDescr(slice: Slice): TopBlockDescr { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xd5))) { + slice.loadUint(8); + let proof_for: BlockIdExt = loadBlockIdExt(slice); + let signatures: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadBlockSignatures(slice1) + + })); + let len: number = slice.loadUint(8); + let chain: ProofChain = loadProofChain(slice, len); + if ((!(len >= 1))) { + throw new Error('Condition (len >= 1) is not satisfied while loading "TopBlockDescr" for type "TopBlockDescr"'); + } + if ((!(len <= 8))) { + throw new Error('Condition (len <= 8) is not satisfied while loading "TopBlockDescr" for type "TopBlockDescr"'); + } + return { + kind: 'TopBlockDescr', + proof_for: proof_for, + signatures: signatures, + len: len, + chain: chain, + } + + } + throw new Error('Expected one of "TopBlockDescr" in loading "TopBlockDescr", but data does not satisfy any constructor'); +} + +export function storeTopBlockDescr(topBlockDescr: TopBlockDescr): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xd5, 8); + storeBlockIdExt(topBlockDescr.proof_for)(builder); + storeMaybe(topBlockDescr.signatures, ((arg: BlockSignatures) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeBlockSignatures(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + builder.storeUint(topBlockDescr.len, 8); + storeProofChain(topBlockDescr.chain)(builder); + if ((!(topBlockDescr.len >= 1))) { + throw new Error('Condition (topBlockDescr.len >= 1) is not satisfied while loading "TopBlockDescr" for type "TopBlockDescr"'); + } + if ((!(topBlockDescr.len <= 8))) { + throw new Error('Condition (topBlockDescr.len <= 8) is not satisfied while loading "TopBlockDescr" for type "TopBlockDescr"'); + } + }) + +} + +// top_block_descr_set#4ac789f3 collection:(HashmapE 96 ^TopBlockDescr) = TopBlockDescrSet; + +export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4ac789f3))) { + slice.loadUint(32); + let collection: HashmapE = loadHashmapE(slice, 96, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTopBlockDescr(slice1) + + })); + return { + kind: 'TopBlockDescrSet', + collection: collection, + } + + } + throw new Error('Expected one of "TopBlockDescrSet" in loading "TopBlockDescrSet", but data does not satisfy any constructor'); +} + +export function storeTopBlockDescrSet(topBlockDescrSet: TopBlockDescrSet): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4ac789f3, 32); + storeHashmapE(topBlockDescrSet.collection, ((arg: TopBlockDescr) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTopBlockDescr(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +/* +prod_info#34 utime:uint32 mc_blk_ref:ExtBlkRef state_proof:^(MERKLE_PROOF Block) + prod_proof:^(MERKLE_PROOF ShardState) = ProducerInfo; +*/ + +export function loadProducerInfo(slice: Slice): ProducerInfo { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x34))) { + slice.loadUint(8); + let utime: number = slice.loadUint(32); + let mc_blk_ref: ExtBlkRef = loadExtBlkRef(slice); + let slice1 = slice.loadRef().beginParse(); + let state_proof: MERKLE_PROOF = loadMERKLE_PROOF(slice1, loadBlock); + let slice2 = slice.loadRef().beginParse(); + let prod_proof: MERKLE_PROOF = loadMERKLE_PROOF(slice2, loadShardState); + return { + kind: 'ProducerInfo', + utime: utime, + mc_blk_ref: mc_blk_ref, + state_proof: state_proof, + prod_proof: prod_proof, + } + + } + throw new Error('Expected one of "ProducerInfo" in loading "ProducerInfo", but data does not satisfy any constructor'); +} + +export function storeProducerInfo(producerInfo: ProducerInfo): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x34, 8); + builder.storeUint(producerInfo.utime, 32); + storeExtBlkRef(producerInfo.mc_blk_ref)(builder); + let cell1 = beginCell(); + storeMERKLE_PROOF(producerInfo.state_proof, storeBlock)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeMERKLE_PROOF(producerInfo.prod_proof, storeShardState)(cell2); + builder.storeRef(cell2); + }) + +} + +// no_blk_gen from_utime:uint32 prod_info:^ProducerInfo = ComplaintDescr; + +// no_blk_gen_diff prod_info_old:^ProducerInfo prod_info_new:^ProducerInfo = ComplaintDescr; + +export function loadComplaintDescr(slice: Slice): ComplaintDescr { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x450e8bd9))) { + slice.loadUint(32); + let from_utime: number = slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let prod_info: ProducerInfo = loadProducerInfo(slice1); + return { + kind: 'ComplaintDescr_no_blk_gen', + from_utime: from_utime, + prod_info: prod_info, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4737b0ca))) { + slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let prod_info_old: ProducerInfo = loadProducerInfo(slice1); + let slice2 = slice.loadRef().beginParse(); + let prod_info_new: ProducerInfo = loadProducerInfo(slice2); + return { + kind: 'ComplaintDescr_no_blk_gen_diff', + prod_info_old: prod_info_old, + prod_info_new: prod_info_new, + } + + } + throw new Error('Expected one of "ComplaintDescr_no_blk_gen", "ComplaintDescr_no_blk_gen_diff" in loading "ComplaintDescr", but data does not satisfy any constructor'); +} + +export function storeComplaintDescr(complaintDescr: ComplaintDescr): (builder: Builder) => void { + if ((complaintDescr.kind == 'ComplaintDescr_no_blk_gen')) { + return ((builder: Builder) => { + builder.storeUint(0x450e8bd9, 32); + builder.storeUint(complaintDescr.from_utime, 32); + let cell1 = beginCell(); + storeProducerInfo(complaintDescr.prod_info)(cell1); + builder.storeRef(cell1); + }) + + } + if ((complaintDescr.kind == 'ComplaintDescr_no_blk_gen_diff')) { + return ((builder: Builder) => { + builder.storeUint(0x4737b0ca, 32); + let cell1 = beginCell(); + storeProducerInfo(complaintDescr.prod_info_old)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeProducerInfo(complaintDescr.prod_info_new)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "ComplaintDescr_no_blk_gen", "ComplaintDescr_no_blk_gen_diff" in loading "ComplaintDescr", but data does not satisfy any constructor'); +} + +// validator_complaint#bc validator_pubkey:bits256 description:^ComplaintDescr created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint; + +export function loadValidatorComplaint(slice: Slice): ValidatorComplaint { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xbc))) { + slice.loadUint(8); + let validator_pubkey: BitString = slice.loadBits(256); + let slice1 = slice.loadRef().beginParse(); + let description: ComplaintDescr = loadComplaintDescr(slice1); + let created_at: number = slice.loadUint(32); + let severity: number = slice.loadUint(8); + let reward_addr: bigint = slice.loadUintBig(256); + let paid: Grams = loadGrams(slice); + let suggested_fine: Grams = loadGrams(slice); + let suggested_fine_part: number = slice.loadUint(32); + return { + kind: 'ValidatorComplaint', + validator_pubkey: validator_pubkey, + description: description, + created_at: created_at, + severity: severity, + reward_addr: reward_addr, + paid: paid, + suggested_fine: suggested_fine, + suggested_fine_part: suggested_fine_part, + } + + } + throw new Error('Expected one of "ValidatorComplaint" in loading "ValidatorComplaint", but data does not satisfy any constructor'); +} + +export function storeValidatorComplaint(validatorComplaint: ValidatorComplaint): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xbc, 8); + builder.storeBits(validatorComplaint.validator_pubkey); + let cell1 = beginCell(); + storeComplaintDescr(validatorComplaint.description)(cell1); + builder.storeRef(cell1); + builder.storeUint(validatorComplaint.created_at, 32); + builder.storeUint(validatorComplaint.severity, 8); + builder.storeUint(validatorComplaint.reward_addr, 256); + storeGrams(validatorComplaint.paid)(builder); + storeGrams(validatorComplaint.suggested_fine)(builder); + builder.storeUint(validatorComplaint.suggested_fine_part, 32); + }) + +} + +// complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus; + +export function loadValidatorComplaintStatus(slice: Slice): ValidatorComplaintStatus { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x2d))) { + slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let complaint: ValidatorComplaint = loadValidatorComplaint(slice1); + let voters: HashmapE = loadHashmapE(slice, 16, loadTrue); + let vset_id: bigint = slice.loadUintBig(256); + let weight_remaining: number = slice.loadInt(64); + return { + kind: 'ValidatorComplaintStatus', + complaint: complaint, + voters: voters, + vset_id: vset_id, + weight_remaining: weight_remaining, + } + + } + throw new Error('Expected one of "ValidatorComplaintStatus" in loading "ValidatorComplaintStatus", but data does not satisfy any constructor'); +} + +export function storeValidatorComplaintStatus(validatorComplaintStatus: ValidatorComplaintStatus): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x2d, 8); + let cell1 = beginCell(); + storeValidatorComplaint(validatorComplaintStatus.complaint)(cell1); + builder.storeRef(cell1); + storeHashmapE(validatorComplaintStatus.voters, storeTrue)(builder); + builder.storeUint(validatorComplaintStatus.vset_id, 256); + builder.storeInt(validatorComplaintStatus.weight_remaining, 64); + }) + +} + +// vm_stk_null#00 = VmStackValue; + +// vm_stk_tinyint#01 value:int64 = VmStackValue; + +// vm_stk_int#0201_ value:int257 = VmStackValue; + +// vm_stk_nan#02ff = VmStackValue; + +// vm_stk_cell#03 cell:^Cell = VmStackValue; + +// vm_stk_slice#04 _:VmCellSlice = VmStackValue; + +// vm_stk_builder#05 cell:^Cell = VmStackValue; + +// vm_stk_cont#06 cont:VmCont = VmStackValue; + +// vm_stk_tuple#07 len:(## 16) data:(VmTuple len) = VmStackValue; + +export function loadVmStackValue(slice: Slice): VmStackValue { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x00))) { + slice.loadUint(8); + return { + kind: 'VmStackValue_vm_stk_null', + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { + slice.loadUint(8); + let value: number = slice.loadInt(64); + return { + kind: 'VmStackValue_vm_stk_tinyint', + value: value, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x0201))) { + slice.loadUint(16); + let value: bigint = slice.loadIntBig(257); + return { + kind: 'VmStackValue_vm_stk_int', + value: value, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x02ff))) { + slice.loadUint(16); + return { + kind: 'VmStackValue_vm_stk_nan', + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x03))) { + slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let _cell: Slice = slice1; + return { + kind: 'VmStackValue_vm_stk_cell', + _cell: _cell, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x04))) { + slice.loadUint(8); + let _: VmCellSlice = loadVmCellSlice(slice); + return { + kind: 'VmStackValue_vm_stk_slice', + _: _, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x05))) { + slice.loadUint(8); + let slice1 = slice.loadRef().beginParse(); + let _cell: Slice = slice1; + return { + kind: 'VmStackValue_vm_stk_builder', + _cell: _cell, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x06))) { + slice.loadUint(8); + let cont: VmCont = loadVmCont(slice); + return { + kind: 'VmStackValue_vm_stk_cont', + cont: cont, + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x07))) { + slice.loadUint(8); + let len: number = slice.loadUint(16); + let data: VmTuple = loadVmTuple(slice, len); + return { + kind: 'VmStackValue_vm_stk_tuple', + len: len, + data: data, + } + + } + throw new Error('Expected one of "VmStackValue_vm_stk_null", "VmStackValue_vm_stk_tinyint", "VmStackValue_vm_stk_int", "VmStackValue_vm_stk_nan", "VmStackValue_vm_stk_cell", "VmStackValue_vm_stk_slice", "VmStackValue_vm_stk_builder", "VmStackValue_vm_stk_cont", "VmStackValue_vm_stk_tuple" in loading "VmStackValue", but data does not satisfy any constructor'); +} + +export function storeVmStackValue(vmStackValue: VmStackValue): (builder: Builder) => void { + if ((vmStackValue.kind == 'VmStackValue_vm_stk_null')) { + return ((builder: Builder) => { + builder.storeUint(0x00, 8); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_tinyint')) { + return ((builder: Builder) => { + builder.storeUint(0x01, 8); + builder.storeInt(vmStackValue.value, 64); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_int')) { + return ((builder: Builder) => { + builder.storeUint(0x0201, 16); + builder.storeInt(vmStackValue.value, 257); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_nan')) { + return ((builder: Builder) => { + builder.storeUint(0x02ff, 16); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_cell')) { + return ((builder: Builder) => { + builder.storeUint(0x03, 8); + let cell1 = beginCell(); + cell1.storeSlice(vmStackValue._cell); + builder.storeRef(cell1); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_slice')) { + return ((builder: Builder) => { + builder.storeUint(0x04, 8); + storeVmCellSlice(vmStackValue._)(builder); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_builder')) { + return ((builder: Builder) => { + builder.storeUint(0x05, 8); + let cell1 = beginCell(); + cell1.storeSlice(vmStackValue._cell); + builder.storeRef(cell1); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_cont')) { + return ((builder: Builder) => { + builder.storeUint(0x06, 8); + storeVmCont(vmStackValue.cont)(builder); + }) + + } + if ((vmStackValue.kind == 'VmStackValue_vm_stk_tuple')) { + return ((builder: Builder) => { + builder.storeUint(0x07, 8); + builder.storeUint(vmStackValue.len, 16); + storeVmTuple(vmStackValue.data)(builder); + }) + + } + throw new Error('Expected one of "VmStackValue_vm_stk_null", "VmStackValue_vm_stk_tinyint", "VmStackValue_vm_stk_int", "VmStackValue_vm_stk_nan", "VmStackValue_vm_stk_cell", "VmStackValue_vm_stk_slice", "VmStackValue_vm_stk_builder", "VmStackValue_vm_stk_cont", "VmStackValue_vm_stk_tuple" in loading "VmStackValue", but data does not satisfy any constructor'); +} + +/* +_ cell:^Cell st_bits:(## 10) end_bits:(## 10) { st_bits <= end_bits } + st_ref:(#<= 4) end_ref:(#<= 4) { st_ref <= end_ref } = VmCellSlice; +*/ + +export function loadVmCellSlice(slice: Slice): VmCellSlice { + let slice1 = slice.loadRef().beginParse(); + let _cell: Slice = slice1; + let st_bits: number = slice.loadUint(10); + let end_bits: number = slice.loadUint(10); + let st_ref: number = slice.loadUint(bitLen(4)); + let end_ref: number = slice.loadUint(bitLen(4)); + if ((!(st_bits <= end_bits))) { + throw new Error('Condition (st_bits <= end_bits) is not satisfied while loading "VmCellSlice" for type "VmCellSlice"'); + } + if ((!(st_ref <= end_ref))) { + throw new Error('Condition (st_ref <= end_ref) is not satisfied while loading "VmCellSlice" for type "VmCellSlice"'); + } + return { + kind: 'VmCellSlice', + _cell: _cell, + st_bits: st_bits, + end_bits: end_bits, + st_ref: st_ref, + end_ref: end_ref, + } + +} + +export function storeVmCellSlice(vmCellSlice: VmCellSlice): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(vmCellSlice._cell); + builder.storeRef(cell1); + builder.storeUint(vmCellSlice.st_bits, 10); + builder.storeUint(vmCellSlice.end_bits, 10); + builder.storeUint(vmCellSlice.st_ref, bitLen(4)); + builder.storeUint(vmCellSlice.end_ref, bitLen(4)); + if ((!(vmCellSlice.st_bits <= vmCellSlice.end_bits))) { + throw new Error('Condition (vmCellSlice.st_bits <= vmCellSlice.end_bits) is not satisfied while loading "VmCellSlice" for type "VmCellSlice"'); + } + if ((!(vmCellSlice.st_ref <= vmCellSlice.end_ref))) { + throw new Error('Condition (vmCellSlice.st_ref <= vmCellSlice.end_ref) is not satisfied while loading "VmCellSlice" for type "VmCellSlice"'); + } + }) + +} + +// vm_tupref_nil$_ = VmTupleRef 0; + +// vm_tupref_single$_ entry:^VmStackValue = VmTupleRef 1; + +// vm_tupref_any$_ {n:#} ref:^(VmTuple (n + 2)) = VmTupleRef (n + 2); + +export function loadVmTupleRef(slice: Slice, arg0: number): VmTupleRef { + if ((arg0 == 0)) { + return { + kind: 'VmTupleRef_vm_tupref_nil', + } + + } + if ((arg0 == 1)) { + let slice1 = slice.loadRef().beginParse(); + let entry: VmStackValue = loadVmStackValue(slice1); + return { + kind: 'VmTupleRef_vm_tupref_single', + entry: entry, + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let ref: VmTuple = loadVmTuple(slice1, ((arg0 - 2) + 2)); + return { + kind: 'VmTupleRef_vm_tupref_any', + n: (arg0 - 2), + ref: ref, + } + + } + throw new Error('Expected one of "VmTupleRef_vm_tupref_nil", "VmTupleRef_vm_tupref_single", "VmTupleRef_vm_tupref_any" in loading "VmTupleRef", but data does not satisfy any constructor'); +} + +export function storeVmTupleRef(vmTupleRef: VmTupleRef): (builder: Builder) => void { + if ((vmTupleRef.kind == 'VmTupleRef_vm_tupref_nil')) { + return ((builder: Builder) => { + }) + + } + if ((vmTupleRef.kind == 'VmTupleRef_vm_tupref_single')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeVmStackValue(vmTupleRef.entry)(cell1); + builder.storeRef(cell1); + }) + + } + if ((vmTupleRef.kind == 'VmTupleRef_vm_tupref_any')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeVmTuple(vmTupleRef.ref)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "VmTupleRef_vm_tupref_nil", "VmTupleRef_vm_tupref_single", "VmTupleRef_vm_tupref_any" in loading "VmTupleRef", but data does not satisfy any constructor'); +} + +// vm_tuple_nil$_ = VmTuple 0; + +// vm_tuple_tcons$_ {n:#} head:(VmTupleRef n) tail:^VmStackValue = VmTuple (n + 1); + +export function loadVmTuple(slice: Slice, arg0: number): VmTuple { + if ((arg0 == 0)) { + return { + kind: 'VmTuple_vm_tuple_nil', + } + + } + if (true) { + let head: VmTupleRef = loadVmTupleRef(slice, (arg0 - 1)); + let slice1 = slice.loadRef().beginParse(); + let tail: VmStackValue = loadVmStackValue(slice1); + return { + kind: 'VmTuple_vm_tuple_tcons', + n: (arg0 - 1), + head: head, + tail: tail, + } + + } + throw new Error('Expected one of "VmTuple_vm_tuple_nil", "VmTuple_vm_tuple_tcons" in loading "VmTuple", but data does not satisfy any constructor'); +} + +export function storeVmTuple(vmTuple: VmTuple): (builder: Builder) => void { + if ((vmTuple.kind == 'VmTuple_vm_tuple_nil')) { + return ((builder: Builder) => { + }) + + } + if ((vmTuple.kind == 'VmTuple_vm_tuple_tcons')) { + return ((builder: Builder) => { + storeVmTupleRef(vmTuple.head)(builder); + let cell1 = beginCell(); + storeVmStackValue(vmTuple.tail)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "VmTuple_vm_tuple_nil", "VmTuple_vm_tuple_tcons" in loading "VmTuple", but data does not satisfy any constructor'); +} + +// vm_stack#_ depth:(## 24) stack:(VmStackList depth) = VmStack; + +export function loadVmStack(slice: Slice): VmStack { + let depth: number = slice.loadUint(24); + let stack: VmStackList = loadVmStackList(slice, depth); + return { + kind: 'VmStack', + depth: depth, + stack: stack, + } + +} + +export function storeVmStack(vmStack: VmStack): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(vmStack.depth, 24); + storeVmStackList(vmStack.stack)(builder); + }) + +} + +// vm_stk_nil#_ = VmStackList 0; + +// vm_stk_cons#_ {n:#} rest:^(VmStackList n) tos:VmStackValue = VmStackList (n + 1); + +export function loadVmStackList(slice: Slice, arg0: number): VmStackList { + if ((arg0 == 0)) { + return { + kind: 'VmStackList_vm_stk_nil', + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let rest: VmStackList = loadVmStackList(slice1, (arg0 - 1)); + let tos: VmStackValue = loadVmStackValue(slice); + return { + kind: 'VmStackList_vm_stk_cons', + n: (arg0 - 1), + rest: rest, + tos: tos, + } + + } + throw new Error('Expected one of "VmStackList_vm_stk_nil", "VmStackList_vm_stk_cons" in loading "VmStackList", but data does not satisfy any constructor'); +} + +export function storeVmStackList(vmStackList: VmStackList): (builder: Builder) => void { + if ((vmStackList.kind == 'VmStackList_vm_stk_nil')) { + return ((builder: Builder) => { + }) + + } + if ((vmStackList.kind == 'VmStackList_vm_stk_cons')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeVmStackList(vmStackList.rest)(cell1); + builder.storeRef(cell1); + storeVmStackValue(vmStackList.tos)(builder); + }) + + } + throw new Error('Expected one of "VmStackList_vm_stk_nil", "VmStackList_vm_stk_cons" in loading "VmStackList", but data does not satisfy any constructor'); +} + +// _ cregs:(HashmapE 4 VmStackValue) = VmSaveList; + +export function loadVmSaveList(slice: Slice): VmSaveList { + let cregs: HashmapE = loadHashmapE(slice, 4, loadVmStackValue); + return { + kind: 'VmSaveList', + cregs: cregs, + } + +} + +export function storeVmSaveList(vmSaveList: VmSaveList): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(vmSaveList.cregs, storeVmStackValue)(builder); + }) + +} + +/* +gas_limits#_ remaining:int64 _:^[ max_limit:int64 cur_limit:int64 credit:int64 ] + = VmGasLimits; +*/ + +export function loadVmGasLimits(slice: Slice): VmGasLimits { + let remaining: number = slice.loadInt(64); + let slice1 = slice.loadRef().beginParse(); + let max_limit: number = slice1.loadInt(64); + let cur_limit: number = slice1.loadInt(64); + let credit: number = slice1.loadInt(64); + return { + kind: 'VmGasLimits', + remaining: remaining, + max_limit: max_limit, + cur_limit: cur_limit, + credit: credit, + } + +} + +export function storeVmGasLimits(vmGasLimits: VmGasLimits): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeInt(vmGasLimits.remaining, 64); + let cell1 = beginCell(); + cell1.storeInt(vmGasLimits.max_limit, 64); + cell1.storeInt(vmGasLimits.cur_limit, 64); + cell1.storeInt(vmGasLimits.credit, 64); + builder.storeRef(cell1); + }) + +} + +// _ libraries:(HashmapE 256 ^Cell) = VmLibraries; + +export function loadVmLibraries(slice: Slice): VmLibraries { + let libraries: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1 + + })); + return { + kind: 'VmLibraries', + libraries: libraries, + } + +} + +export function storeVmLibraries(vmLibraries: VmLibraries): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(vmLibraries.libraries, ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +/* +vm_ctl_data$_ nargs:(Maybe uint13) stack:(Maybe VmStack) save:VmSaveList +cp:(Maybe int16) = VmControlData; +*/ + +export function loadVmControlData(slice: Slice): VmControlData { + let nargs: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadUint(13) + + })); + let stack: Maybe = loadMaybe(slice, loadVmStack); + let save: VmSaveList = loadVmSaveList(slice); + let cp: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadInt(16) + + })); + return { + kind: 'VmControlData', + nargs: nargs, + stack: stack, + save: save, + cp: cp, + } + +} + +export function storeVmControlData(vmControlData: VmControlData): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(vmControlData.nargs, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 13); + }) + + }))(builder); + storeMaybe(vmControlData.stack, storeVmStack)(builder); + storeVmSaveList(vmControlData.save)(builder); + storeMaybe(vmControlData.cp, ((arg: number) => { + return ((builder: Builder) => { + builder.storeInt(arg, 16); + }) + + }))(builder); + }) + +} + +// vmc_std$00 cdata:VmControlData code:VmCellSlice = VmCont; + +// vmc_envelope$01 cdata:VmControlData next:^VmCont = VmCont; + +// vmc_quit$1000 exit_code:int32 = VmCont; + +// vmc_quit_exc$1001 = VmCont; + +// vmc_repeat$10100 count:uint63 body:^VmCont after:^VmCont = VmCont; + +// vmc_until$110000 body:^VmCont after:^VmCont = VmCont; + +// vmc_again$110001 body:^VmCont = VmCont; + +/* +vmc_while_cond$110010 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +*/ + +/* +vmc_while_body$110011 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +*/ + +// vmc_pushint$1111 value:int32 next:^VmCont = VmCont; + +export function loadVmCont(slice: Slice): VmCont { + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { + slice.loadUint(2); + let cdata: VmControlData = loadVmControlData(slice); + let code: VmCellSlice = loadVmCellSlice(slice); + return { + kind: 'VmCont_vmc_std', + cdata: cdata, + code: code, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { + slice.loadUint(2); + let cdata: VmControlData = loadVmControlData(slice); + let slice1 = slice.loadRef().beginParse(); + let next: VmCont = loadVmCont(slice1); + return { + kind: 'VmCont_vmc_envelope', + cdata: cdata, + next: next, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1000))) { + slice.loadUint(4); + let exit_code: number = slice.loadInt(32); + return { + kind: 'VmCont_vmc_quit', + exit_code: exit_code, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1001))) { + slice.loadUint(4); + return { + kind: 'VmCont_vmc_quit_exc', + } + + } + if (((slice.remainingBits >= 5) && (slice.preloadUint(5) == 0b10100))) { + slice.loadUint(5); + let count: number = slice.loadUint(63); + let slice1 = slice.loadRef().beginParse(); + let body: VmCont = loadVmCont(slice1); + let slice2 = slice.loadRef().beginParse(); + let after: VmCont = loadVmCont(slice2); + return { + kind: 'VmCont_vmc_repeat', + count: count, + body: body, + after: after, + } + + } + if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110000))) { + slice.loadUint(6); + let slice1 = slice.loadRef().beginParse(); + let body: VmCont = loadVmCont(slice1); + let slice2 = slice.loadRef().beginParse(); + let after: VmCont = loadVmCont(slice2); + return { + kind: 'VmCont_vmc_until', + body: body, + after: after, + } + + } + if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110001))) { + slice.loadUint(6); + let slice1 = slice.loadRef().beginParse(); + let body: VmCont = loadVmCont(slice1); + return { + kind: 'VmCont_vmc_again', + body: body, + } + + } + if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110010))) { + slice.loadUint(6); + let slice1 = slice.loadRef().beginParse(); + let cond: VmCont = loadVmCont(slice1); + let slice2 = slice.loadRef().beginParse(); + let body: VmCont = loadVmCont(slice2); + let slice3 = slice.loadRef().beginParse(); + let after: VmCont = loadVmCont(slice3); + return { + kind: 'VmCont_vmc_while_cond', + cond: cond, + body: body, + after: after, + } + + } + if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110011))) { + slice.loadUint(6); + let slice1 = slice.loadRef().beginParse(); + let cond: VmCont = loadVmCont(slice1); + let slice2 = slice.loadRef().beginParse(); + let body: VmCont = loadVmCont(slice2); + let slice3 = slice.loadRef().beginParse(); + let after: VmCont = loadVmCont(slice3); + return { + kind: 'VmCont_vmc_while_body', + cond: cond, + body: body, + after: after, + } + + } + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1111))) { + slice.loadUint(4); + let value: number = slice.loadInt(32); + let slice1 = slice.loadRef().beginParse(); + let next: VmCont = loadVmCont(slice1); + return { + kind: 'VmCont_vmc_pushint', + value: value, + next: next, + } + + } + throw new Error('Expected one of "VmCont_vmc_std", "VmCont_vmc_envelope", "VmCont_vmc_quit", "VmCont_vmc_quit_exc", "VmCont_vmc_repeat", "VmCont_vmc_until", "VmCont_vmc_again", "VmCont_vmc_while_cond", "VmCont_vmc_while_body", "VmCont_vmc_pushint" in loading "VmCont", but data does not satisfy any constructor'); +} + +export function storeVmCont(vmCont: VmCont): (builder: Builder) => void { + if ((vmCont.kind == 'VmCont_vmc_std')) { + return ((builder: Builder) => { + builder.storeUint(0b00, 2); + storeVmControlData(vmCont.cdata)(builder); + storeVmCellSlice(vmCont.code)(builder); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_envelope')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + storeVmControlData(vmCont.cdata)(builder); + let cell1 = beginCell(); + storeVmCont(vmCont.next)(cell1); + builder.storeRef(cell1); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_quit')) { + return ((builder: Builder) => { + builder.storeUint(0b1000, 4); + builder.storeInt(vmCont.exit_code, 32); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_quit_exc')) { + return ((builder: Builder) => { + builder.storeUint(0b1001, 4); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_repeat')) { + return ((builder: Builder) => { + builder.storeUint(0b10100, 5); + builder.storeUint(vmCont.count, 63); + let cell1 = beginCell(); + storeVmCont(vmCont.body)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeVmCont(vmCont.after)(cell2); + builder.storeRef(cell2); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_until')) { + return ((builder: Builder) => { + builder.storeUint(0b110000, 6); + let cell1 = beginCell(); + storeVmCont(vmCont.body)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeVmCont(vmCont.after)(cell2); + builder.storeRef(cell2); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_again')) { + return ((builder: Builder) => { + builder.storeUint(0b110001, 6); + let cell1 = beginCell(); + storeVmCont(vmCont.body)(cell1); + builder.storeRef(cell1); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_while_cond')) { + return ((builder: Builder) => { + builder.storeUint(0b110010, 6); + let cell1 = beginCell(); + storeVmCont(vmCont.cond)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeVmCont(vmCont.body)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + storeVmCont(vmCont.after)(cell3); + builder.storeRef(cell3); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_while_body')) { + return ((builder: Builder) => { + builder.storeUint(0b110011, 6); + let cell1 = beginCell(); + storeVmCont(vmCont.cond)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeVmCont(vmCont.body)(cell2); + builder.storeRef(cell2); + let cell3 = beginCell(); + storeVmCont(vmCont.after)(cell3); + builder.storeRef(cell3); + }) + + } + if ((vmCont.kind == 'VmCont_vmc_pushint')) { + return ((builder: Builder) => { + builder.storeUint(0b1111, 4); + builder.storeInt(vmCont.value, 32); + let cell1 = beginCell(); + storeVmCont(vmCont.next)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "VmCont_vmc_std", "VmCont_vmc_envelope", "VmCont_vmc_quit", "VmCont_vmc_quit_exc", "VmCont_vmc_repeat", "VmCont_vmc_until", "VmCont_vmc_again", "VmCont_vmc_while_cond", "VmCont_vmc_while_body", "VmCont_vmc_pushint" in loading "VmCont", but data does not satisfy any constructor'); +} + +// _ (HashmapE 256 ^DNSRecord) = DNS_RecordSet; + +export function loadDNS_RecordSet(slice: Slice): DNS_RecordSet { + let anon0: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadDNSRecord(slice1) + + })); + return { + kind: 'DNS_RecordSet', + anon0: anon0, + } + +} + +export function storeDNS_RecordSet(dNS_RecordSet: DNS_RecordSet): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(dNS_RecordSet.anon0, ((arg: DNSRecord) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeDNSRecord(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// chunk_ref_empty$_ = TextChunkRef 0; + +// chunk_ref$_ {n:#} ref:^(TextChunks (n + 1)) = TextChunkRef (n + 1); + +export function loadTextChunkRef(slice: Slice, arg0: number): TextChunkRef { + if ((arg0 == 0)) { + return { + kind: 'TextChunkRef_chunk_ref_empty', + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let ref: TextChunks = loadTextChunks(slice1, ((arg0 - 1) + 1)); + return { + kind: 'TextChunkRef_chunk_ref', + n: (arg0 - 1), + ref: ref, + } + + } + throw new Error('Expected one of "TextChunkRef_chunk_ref_empty", "TextChunkRef_chunk_ref" in loading "TextChunkRef", but data does not satisfy any constructor'); +} + +export function storeTextChunkRef(textChunkRef: TextChunkRef): (builder: Builder) => void { + if ((textChunkRef.kind == 'TextChunkRef_chunk_ref_empty')) { + return ((builder: Builder) => { + }) + + } + if ((textChunkRef.kind == 'TextChunkRef_chunk_ref')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTextChunks(textChunkRef.ref)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "TextChunkRef_chunk_ref_empty", "TextChunkRef_chunk_ref" in loading "TextChunkRef", but data does not satisfy any constructor'); +} + +// text_chunk_empty$_ = TextChunks 0; + +// text_chunk$_ {n:#} len:(## 8) data:(bits (len * 8)) next:(TextChunkRef n) = TextChunks (n + 1); + +export function loadTextChunks(slice: Slice, arg0: number): TextChunks { + if ((arg0 == 0)) { + return { + kind: 'TextChunks_text_chunk_empty', + } + + } + if (true) { + let len: number = slice.loadUint(8); + let data: BitString = slice.loadBits((len * 8)); + let next: TextChunkRef = loadTextChunkRef(slice, (arg0 - 1)); + return { + kind: 'TextChunks_text_chunk', + n: (arg0 - 1), + len: len, + data: data, + next: next, + } + + } + throw new Error('Expected one of "TextChunks_text_chunk_empty", "TextChunks_text_chunk" in loading "TextChunks", but data does not satisfy any constructor'); +} + +export function storeTextChunks(textChunks: TextChunks): (builder: Builder) => void { + if ((textChunks.kind == 'TextChunks_text_chunk_empty')) { + return ((builder: Builder) => { + }) + + } + if ((textChunks.kind == 'TextChunks_text_chunk')) { + return ((builder: Builder) => { + builder.storeUint(textChunks.len, 8); + builder.storeBits(textChunks.data); + storeTextChunkRef(textChunks.next)(builder); + }) + + } + throw new Error('Expected one of "TextChunks_text_chunk_empty", "TextChunks_text_chunk" in loading "TextChunks", but data does not satisfy any constructor'); +} + +// text$_ chunks:(## 8) rest:(TextChunks chunks) = Text; + +export function loadText(slice: Slice): Text { + let chunks: number = slice.loadUint(8); + let rest: TextChunks = loadTextChunks(slice, chunks); + return { + kind: 'Text', + chunks: chunks, + rest: rest, + } + +} + +export function storeText(text: Text): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(text.chunks, 8); + storeTextChunks(text.rest)(builder); + }) + +} + +// dns_text#1eda _:Text = DNSRecord; + +// dns_next_resolver#ba93 resolver:MsgAddressInt = DNSRecord; + +/* +dns_adnl_address#ad01 adnl_addr:bits256 flags:(## 8) { flags <= 1 } + proto_list:flags . 0?ProtoList = DNSRecord; +*/ + +/* +dns_smc_address#9fd3 smc_addr:MsgAddressInt flags:(## 8) { flags <= 1 } + cap_list:flags . 0?SmcCapList = DNSRecord; +*/ + +// dns_storage_address#7473 bag_id:bits256 = DNSRecord; + +export function loadDNSRecord(slice: Slice): DNSRecord { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x1eda))) { + slice.loadUint(16); + let _: Text = loadText(slice); + return { + kind: 'DNSRecord_dns_text', + _: _, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0xba93))) { + slice.loadUint(16); + let resolver: Address = slice.loadAddress(); + return { + kind: 'DNSRecord_dns_next_resolver', + resolver: resolver, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0xad01))) { + slice.loadUint(16); + let adnl_addr: BitString = slice.loadBits(256); + let flags: number = slice.loadUint(8); + let proto_list: ProtoList | undefined = ((flags & (1 << 0)) ? loadProtoList(slice) : undefined); + if ((!(flags <= 1))) { + throw new Error('Condition (flags <= 1) is not satisfied while loading "DNSRecord_dns_adnl_address" for type "DNSRecord"'); + } + return { + kind: 'DNSRecord_dns_adnl_address', + adnl_addr: adnl_addr, + flags: flags, + proto_list: proto_list, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x9fd3))) { + slice.loadUint(16); + let smc_addr: Address = slice.loadAddress(); + let flags: number = slice.loadUint(8); + let cap_list: SmcCapList | undefined = ((flags & (1 << 0)) ? loadSmcCapList(slice) : undefined); + if ((!(flags <= 1))) { + throw new Error('Condition (flags <= 1) is not satisfied while loading "DNSRecord_dns_smc_address" for type "DNSRecord"'); + } + return { + kind: 'DNSRecord_dns_smc_address', + smc_addr: smc_addr, + flags: flags, + cap_list: cap_list, + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x7473))) { + slice.loadUint(16); + let bag_id: BitString = slice.loadBits(256); + return { + kind: 'DNSRecord_dns_storage_address', + bag_id: bag_id, + } + + } + throw new Error('Expected one of "DNSRecord_dns_text", "DNSRecord_dns_next_resolver", "DNSRecord_dns_adnl_address", "DNSRecord_dns_smc_address", "DNSRecord_dns_storage_address" in loading "DNSRecord", but data does not satisfy any constructor'); +} + +export function storeDNSRecord(dNSRecord: DNSRecord): (builder: Builder) => void { + if ((dNSRecord.kind == 'DNSRecord_dns_text')) { + return ((builder: Builder) => { + builder.storeUint(0x1eda, 16); + storeText(dNSRecord._)(builder); + }) + + } + if ((dNSRecord.kind == 'DNSRecord_dns_next_resolver')) { + return ((builder: Builder) => { + builder.storeUint(0xba93, 16); + builder.storeAddress(dNSRecord.resolver); + }) + + } + if ((dNSRecord.kind == 'DNSRecord_dns_adnl_address')) { + return ((builder: Builder) => { + builder.storeUint(0xad01, 16); + builder.storeBits(dNSRecord.adnl_addr); + builder.storeUint(dNSRecord.flags, 8); + if ((dNSRecord.proto_list != undefined)) { + storeProtoList(dNSRecord.proto_list)(builder); + } + if ((!(dNSRecord.flags <= 1))) { + throw new Error('Condition (dNSRecord.flags <= 1) is not satisfied while loading "DNSRecord_dns_adnl_address" for type "DNSRecord"'); + } + }) + + } + if ((dNSRecord.kind == 'DNSRecord_dns_smc_address')) { + return ((builder: Builder) => { + builder.storeUint(0x9fd3, 16); + builder.storeAddress(dNSRecord.smc_addr); + builder.storeUint(dNSRecord.flags, 8); + if ((dNSRecord.cap_list != undefined)) { + storeSmcCapList(dNSRecord.cap_list)(builder); + } + if ((!(dNSRecord.flags <= 1))) { + throw new Error('Condition (dNSRecord.flags <= 1) is not satisfied while loading "DNSRecord_dns_smc_address" for type "DNSRecord"'); + } + }) + + } + if ((dNSRecord.kind == 'DNSRecord_dns_storage_address')) { + return ((builder: Builder) => { + builder.storeUint(0x7473, 16); + builder.storeBits(dNSRecord.bag_id); + }) + + } + throw new Error('Expected one of "DNSRecord_dns_text", "DNSRecord_dns_next_resolver", "DNSRecord_dns_adnl_address", "DNSRecord_dns_smc_address", "DNSRecord_dns_storage_address" in loading "DNSRecord", but data does not satisfy any constructor'); +} + +// proto_list_nil$0 = ProtoList; + +// proto_list_next$1 head:Protocol tail:ProtoList = ProtoList; + +export function loadProtoList(slice: Slice): ProtoList { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'ProtoList_proto_list_nil', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let head: Protocol = loadProtocol(slice); + let tail: ProtoList = loadProtoList(slice); + return { + kind: 'ProtoList_proto_list_next', + head: head, + tail: tail, + } + + } + throw new Error('Expected one of "ProtoList_proto_list_nil", "ProtoList_proto_list_next" in loading "ProtoList", but data does not satisfy any constructor'); +} + +export function storeProtoList(protoList: ProtoList): (builder: Builder) => void { + if ((protoList.kind == 'ProtoList_proto_list_nil')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((protoList.kind == 'ProtoList_proto_list_next')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeProtocol(protoList.head)(builder); + storeProtoList(protoList.tail)(builder); + }) + + } + throw new Error('Expected one of "ProtoList_proto_list_nil", "ProtoList_proto_list_next" in loading "ProtoList", but data does not satisfy any constructor'); +} + +// proto_http#4854 = Protocol; + +export function loadProtocol(slice: Slice): Protocol { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x4854))) { + slice.loadUint(16); + return { + kind: 'Protocol', + } + + } + throw new Error('Expected one of "Protocol" in loading "Protocol", but data does not satisfy any constructor'); +} + +export function storeProtocol(protocol: Protocol): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x4854, 16); + }) + +} + +// cap_list_nil$0 = SmcCapList; + +// cap_list_next$1 head:SmcCapability tail:SmcCapList = SmcCapList; + +export function loadSmcCapList(slice: Slice): SmcCapList { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'SmcCapList_cap_list_nil', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let head: SmcCapability = loadSmcCapability(slice); + let tail: SmcCapList = loadSmcCapList(slice); + return { + kind: 'SmcCapList_cap_list_next', + head: head, + tail: tail, + } + + } + throw new Error('Expected one of "SmcCapList_cap_list_nil", "SmcCapList_cap_list_next" in loading "SmcCapList", but data does not satisfy any constructor'); +} + +export function storeSmcCapList(smcCapList: SmcCapList): (builder: Builder) => void { + if ((smcCapList.kind == 'SmcCapList_cap_list_nil')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((smcCapList.kind == 'SmcCapList_cap_list_next')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeSmcCapability(smcCapList.head)(builder); + storeSmcCapList(smcCapList.tail)(builder); + }) + + } + throw new Error('Expected one of "SmcCapList_cap_list_nil", "SmcCapList_cap_list_next" in loading "SmcCapList", but data does not satisfy any constructor'); +} + +// cap_method_seqno#5371 = SmcCapability; + +// cap_method_pubkey#71f4 = SmcCapability; + +// cap_is_wallet#2177 = SmcCapability; + +// cap_name#ff name:Text = SmcCapability; + +export function loadSmcCapability(slice: Slice): SmcCapability { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x5371))) { + slice.loadUint(16); + return { + kind: 'SmcCapability_cap_method_seqno', + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x71f4))) { + slice.loadUint(16); + return { + kind: 'SmcCapability_cap_method_pubkey', + } + + } + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x2177))) { + slice.loadUint(16); + return { + kind: 'SmcCapability_cap_is_wallet', + } + + } + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xff))) { + slice.loadUint(8); + let name: Text = loadText(slice); + return { + kind: 'SmcCapability_cap_name', + name: name, + } + + } + throw new Error('Expected one of "SmcCapability_cap_method_seqno", "SmcCapability_cap_method_pubkey", "SmcCapability_cap_is_wallet", "SmcCapability_cap_name" in loading "SmcCapability", but data does not satisfy any constructor'); +} + +export function storeSmcCapability(smcCapability: SmcCapability): (builder: Builder) => void { + if ((smcCapability.kind == 'SmcCapability_cap_method_seqno')) { + return ((builder: Builder) => { + builder.storeUint(0x5371, 16); + }) + + } + if ((smcCapability.kind == 'SmcCapability_cap_method_pubkey')) { + return ((builder: Builder) => { + builder.storeUint(0x71f4, 16); + }) + + } + if ((smcCapability.kind == 'SmcCapability_cap_is_wallet')) { + return ((builder: Builder) => { + builder.storeUint(0x2177, 16); + }) + + } + if ((smcCapability.kind == 'SmcCapability_cap_name')) { + return ((builder: Builder) => { + builder.storeUint(0xff, 8); + storeText(smcCapability.name)(builder); + }) + + } + throw new Error('Expected one of "SmcCapability_cap_method_seqno", "SmcCapability_cap_method_pubkey", "SmcCapability_cap_is_wallet", "SmcCapability_cap_name" in loading "SmcCapability", but data does not satisfy any constructor'); +} + +/* +chan_config$_ init_timeout:uint32 close_timeout:uint32 a_key:bits256 b_key:bits256 + a_addr:^MsgAddressInt b_addr:^MsgAddressInt channel_id:uint64 min_A_extra:Grams = ChanConfig; +*/ + +export function loadChanConfig(slice: Slice): ChanConfig { + let init_timeout: number = slice.loadUint(32); + let close_timeout: number = slice.loadUint(32); + let a_key: BitString = slice.loadBits(256); + let b_key: BitString = slice.loadBits(256); + let slice1 = slice.loadRef().beginParse(); + let a_addr: Address = slice1.loadAddress(); + let slice2 = slice.loadRef().beginParse(); + let b_addr: Address = slice2.loadAddress(); + let channel_id: number = slice.loadUint(64); + let min_A_extra: Grams = loadGrams(slice); + return { + kind: 'ChanConfig', + init_timeout: init_timeout, + close_timeout: close_timeout, + a_key: a_key, + b_key: b_key, + a_addr: a_addr, + b_addr: b_addr, + channel_id: channel_id, + min_A_extra: min_A_extra, + } + +} + +export function storeChanConfig(chanConfig: ChanConfig): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(chanConfig.init_timeout, 32); + builder.storeUint(chanConfig.close_timeout, 32); + builder.storeBits(chanConfig.a_key); + builder.storeBits(chanConfig.b_key); + let cell1 = beginCell(); + cell1.storeAddress(chanConfig.a_addr); + builder.storeRef(cell1); + let cell2 = beginCell(); + cell2.storeAddress(chanConfig.b_addr); + builder.storeRef(cell2); + builder.storeUint(chanConfig.channel_id, 64); + storeGrams(chanConfig.min_A_extra)(builder); + }) + +} + +// chan_state_init$000 signed_A:Bool signed_B:Bool min_A:Grams min_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; + +// chan_state_close$001 signed_A:Bool signed_B:Bool promise_A:Grams promise_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; + +// chan_state_payout$010 A:Grams B:Grams = ChanState; + +export function loadChanState(slice: Slice): ChanState { + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b000))) { + slice.loadUint(3); + let signed_A: boolean = slice.loadBoolean(); + let signed_B: boolean = slice.loadBoolean(); + let min_A: Grams = loadGrams(slice); + let min_B: Grams = loadGrams(slice); + let expire_at: number = slice.loadUint(32); + let A: Grams = loadGrams(slice); + let B: Grams = loadGrams(slice); + return { + kind: 'ChanState_chan_state_init', + signed_A: signed_A, + signed_B: signed_B, + min_A: min_A, + min_B: min_B, + expire_at: expire_at, + A: A, + B: B, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b001))) { + slice.loadUint(3); + let signed_A: boolean = slice.loadBoolean(); + let signed_B: boolean = slice.loadBoolean(); + let promise_A: Grams = loadGrams(slice); + let promise_B: Grams = loadGrams(slice); + let expire_at: number = slice.loadUint(32); + let A: Grams = loadGrams(slice); + let B: Grams = loadGrams(slice); + return { + kind: 'ChanState_chan_state_close', + signed_A: signed_A, + signed_B: signed_B, + promise_A: promise_A, + promise_B: promise_B, + expire_at: expire_at, + A: A, + B: B, + } + + } + if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { + slice.loadUint(3); + let A: Grams = loadGrams(slice); + let B: Grams = loadGrams(slice); + return { + kind: 'ChanState_chan_state_payout', + A: A, + B: B, + } + + } + throw new Error('Expected one of "ChanState_chan_state_init", "ChanState_chan_state_close", "ChanState_chan_state_payout" in loading "ChanState", but data does not satisfy any constructor'); +} + +export function storeChanState(chanState: ChanState): (builder: Builder) => void { + if ((chanState.kind == 'ChanState_chan_state_init')) { + return ((builder: Builder) => { + builder.storeUint(0b000, 3); + builder.storeBit(chanState.signed_A); + builder.storeBit(chanState.signed_B); + storeGrams(chanState.min_A)(builder); + storeGrams(chanState.min_B)(builder); + builder.storeUint(chanState.expire_at, 32); + storeGrams(chanState.A)(builder); + storeGrams(chanState.B)(builder); + }) + + } + if ((chanState.kind == 'ChanState_chan_state_close')) { + return ((builder: Builder) => { + builder.storeUint(0b001, 3); + builder.storeBit(chanState.signed_A); + builder.storeBit(chanState.signed_B); + storeGrams(chanState.promise_A)(builder); + storeGrams(chanState.promise_B)(builder); + builder.storeUint(chanState.expire_at, 32); + storeGrams(chanState.A)(builder); + storeGrams(chanState.B)(builder); + }) + + } + if ((chanState.kind == 'ChanState_chan_state_payout')) { + return ((builder: Builder) => { + builder.storeUint(0b010, 3); + storeGrams(chanState.A)(builder); + storeGrams(chanState.B)(builder); + }) + + } + throw new Error('Expected one of "ChanState_chan_state_init", "ChanState_chan_state_close", "ChanState_chan_state_payout" in loading "ChanState", but data does not satisfy any constructor'); +} + +// chan_promise$_ channel_id:uint64 promise_A:Grams promise_B:Grams = ChanPromise; + +export function loadChanPromise(slice: Slice): ChanPromise { + let channel_id: number = slice.loadUint(64); + let promise_A: Grams = loadGrams(slice); + let promise_B: Grams = loadGrams(slice); + return { + kind: 'ChanPromise', + channel_id: channel_id, + promise_A: promise_A, + promise_B: promise_B, + } + +} + +export function storeChanPromise(chanPromise: ChanPromise): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(chanPromise.channel_id, 64); + storeGrams(chanPromise.promise_A)(builder); + storeGrams(chanPromise.promise_B)(builder); + }) + +} + +// chan_signed_promise#_ sig:(Maybe ^bits512) promise:ChanPromise = ChanSignedPromise; + +export function loadChanSignedPromise(slice: Slice): ChanSignedPromise { + let sig: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1.loadBits(512) + + })); + let promise: ChanPromise = loadChanPromise(slice); + return { + kind: 'ChanSignedPromise', + sig: sig, + promise: promise, + } + +} + +export function storeChanSignedPromise(chanSignedPromise: ChanSignedPromise): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(chanSignedPromise.sig, ((arg: BitString) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeBits(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeChanPromise(chanSignedPromise.promise)(builder); + }) + +} + +// chan_msg_init#27317822 inc_A:Grams inc_B:Grams min_A:Grams min_B:Grams channel_id:uint64 = ChanMsg; + +// chan_msg_close#f28ae183 extra_A:Grams extra_B:Grams promise:ChanSignedPromise = ChanMsg; + +// chan_msg_timeout#43278a28 = ChanMsg; + +// chan_msg_payout#37fe7810 = ChanMsg; + +export function loadChanMsg(slice: Slice): ChanMsg { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x27317822))) { + slice.loadUint(32); + let inc_A: Grams = loadGrams(slice); + let inc_B: Grams = loadGrams(slice); + let min_A: Grams = loadGrams(slice); + let min_B: Grams = loadGrams(slice); + let channel_id: number = slice.loadUint(64); + return { + kind: 'ChanMsg_chan_msg_init', + inc_A: inc_A, + inc_B: inc_B, + min_A: min_A, + min_B: min_B, + channel_id: channel_id, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xf28ae183))) { + slice.loadUint(32); + let extra_A: Grams = loadGrams(slice); + let extra_B: Grams = loadGrams(slice); + let promise: ChanSignedPromise = loadChanSignedPromise(slice); + return { + kind: 'ChanMsg_chan_msg_close', + extra_A: extra_A, + extra_B: extra_B, + promise: promise, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x43278a28))) { + slice.loadUint(32); + return { + kind: 'ChanMsg_chan_msg_timeout', + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x37fe7810))) { + slice.loadUint(32); + return { + kind: 'ChanMsg_chan_msg_payout', + } + + } + throw new Error('Expected one of "ChanMsg_chan_msg_init", "ChanMsg_chan_msg_close", "ChanMsg_chan_msg_timeout", "ChanMsg_chan_msg_payout" in loading "ChanMsg", but data does not satisfy any constructor'); +} + +export function storeChanMsg(chanMsg: ChanMsg): (builder: Builder) => void { + if ((chanMsg.kind == 'ChanMsg_chan_msg_init')) { + return ((builder: Builder) => { + builder.storeUint(0x27317822, 32); + storeGrams(chanMsg.inc_A)(builder); + storeGrams(chanMsg.inc_B)(builder); + storeGrams(chanMsg.min_A)(builder); + storeGrams(chanMsg.min_B)(builder); + builder.storeUint(chanMsg.channel_id, 64); + }) + + } + if ((chanMsg.kind == 'ChanMsg_chan_msg_close')) { + return ((builder: Builder) => { + builder.storeUint(0xf28ae183, 32); + storeGrams(chanMsg.extra_A)(builder); + storeGrams(chanMsg.extra_B)(builder); + storeChanSignedPromise(chanMsg.promise)(builder); + }) + + } + if ((chanMsg.kind == 'ChanMsg_chan_msg_timeout')) { + return ((builder: Builder) => { + builder.storeUint(0x43278a28, 32); + }) + + } + if ((chanMsg.kind == 'ChanMsg_chan_msg_payout')) { + return ((builder: Builder) => { + builder.storeUint(0x37fe7810, 32); + }) + + } + throw new Error('Expected one of "ChanMsg_chan_msg_init", "ChanMsg_chan_msg_close", "ChanMsg_chan_msg_timeout", "ChanMsg_chan_msg_payout" in loading "ChanMsg", but data does not satisfy any constructor'); +} + +// chan_signed_msg$_ sig_A:(Maybe ^bits512) sig_B:(Maybe ^bits512) msg:ChanMsg = ChanSignedMsg; + +export function loadChanSignedMsg(slice: Slice): ChanSignedMsg { + let sig_A: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1.loadBits(512) + + })); + let sig_B: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1.loadBits(512) + + })); + let msg: ChanMsg = loadChanMsg(slice); + return { + kind: 'ChanSignedMsg', + sig_A: sig_A, + sig_B: sig_B, + msg: msg, + } + +} + +export function storeChanSignedMsg(chanSignedMsg: ChanSignedMsg): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(chanSignedMsg.sig_A, ((arg: BitString) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeBits(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeMaybe(chanSignedMsg.sig_B, ((arg: BitString) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeBits(arg); + builder.storeRef(cell1); + + }) + + }))(builder); + storeChanMsg(chanSignedMsg.msg)(builder); + }) + +} + +// chan_op_cmd#912838d1 msg:ChanSignedMsg = ChanOp; + +export function loadChanOp(slice: Slice): ChanOp { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x912838d1))) { + slice.loadUint(32); + let msg: ChanSignedMsg = loadChanSignedMsg(slice); + return { + kind: 'ChanOp', + msg: msg, + } + + } + throw new Error('Expected one of "ChanOp" in loading "ChanOp", but data does not satisfy any constructor'); +} + +export function storeChanOp(chanOp: ChanOp): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x912838d1, 32); + storeChanSignedMsg(chanOp.msg)(builder); + }) + +} + +// chan_data$_ config:^ChanConfig state:^ChanState = ChanData; + +export function loadChanData(slice: Slice): ChanData { + let slice1 = slice.loadRef().beginParse(); + let config: ChanConfig = loadChanConfig(slice1); + let slice2 = slice.loadRef().beginParse(); + let state: ChanState = loadChanState(slice2); + return { + kind: 'ChanData', + config: config, + state: state, + } + +} + +export function storeChanData(chanData: ChanData): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeChanConfig(chanData.config)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeChanState(chanData.state)(cell2); + builder.storeRef(cell2); + }) + +} + diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts new file mode 100644 index 0000000..fcee5bb --- /dev/null +++ b/test/generated_files/generated_test.ts @@ -0,0 +1,2562 @@ +import { Builder } from 'ton' +import { Slice } from 'ton' +import { beginCell } from 'ton' +import { BitString } from 'ton' +import { Cell } from 'ton' +import { Address } from 'ton' +export function bitLen(n: number) { + return n.toString(2).length;; +} + +export interface Simple { + readonly kind: 'Simple'; + readonly a: number; + readonly b: number; +} + +export type TwoConstructors = TwoConstructors_bool_false | TwoConstructors_bool_true; + +export interface TwoConstructors_bool_false { + readonly kind: 'TwoConstructors_bool_false'; + readonly a: number; + readonly b: number; + readonly c: number; +} + +export interface TwoConstructors_bool_true { + readonly kind: 'TwoConstructors_bool_true'; + readonly b: number; +} + +export interface FixedIntParam { + readonly kind: 'FixedIntParam'; + readonly y: number; +} + +export interface TypedField { + readonly kind: 'TypedField'; + readonly y: FixedIntParam; + readonly c: number; +} + +export interface SharpConstructor { + readonly kind: 'SharpConstructor'; + readonly y: FixedIntParam; + readonly c: number; +} + +export type Maybe = Maybe_nothing | Maybe_just; + +export interface Maybe_nothing { + readonly kind: 'Maybe_nothing'; +} + +export interface Maybe_just { + readonly kind: 'Maybe_just'; + readonly value: TheType; +} + +export interface TypedParam { + readonly kind: 'TypedParam'; + readonly x: Maybe; +} + +export type Either = Either_left | Either_right; + +export interface Either_left { + readonly kind: 'Either_left'; + readonly value: X; +} + +export interface Either_right { + readonly kind: 'Either_right'; + readonly value: Y; +} + +export interface BitLenArg { + readonly kind: 'BitLenArg'; + readonly x: number; + readonly value: bigint; +} + +export interface BitLenArgUser { + readonly kind: 'BitLenArgUser'; + readonly t: BitLenArg; +} + +export interface ExprArg { + readonly kind: 'ExprArg'; + readonly x: number; + readonly value: bigint; +} + +export interface ExprArgUser { + readonly kind: 'ExprArgUser'; + readonly t: ExprArg; +} + +export interface ComplexTypedField { + readonly kind: 'ComplexTypedField'; + readonly a: ExprArgUser; +} + +export interface CellTypedField { + readonly kind: 'CellTypedField'; + readonly a: ExprArgUser; +} + +export interface CellsSimple { + readonly kind: 'CellsSimple'; + readonly t: number; + readonly q: number; + readonly a: number; + readonly e: number; + readonly b: number; + readonly d: number; + readonly c: number; +} + +export interface IntBits { + readonly kind: 'IntBits'; + readonly d: number; + readonly g: BitString; + readonly arg: Arg; + readonly x: Slice; +} + +export interface IntBitsInside { + readonly kind: 'IntBitsInside'; + readonly x: number; + readonly a: IntBits; +} + +export interface IntBitsOutside { + readonly kind: 'IntBitsOutside'; + readonly x: IntBitsInside; +} + +export interface IntBitsParametrized { + readonly kind: 'IntBitsParametrized'; + readonly e: number; + readonly h: bigint; + readonly f: bigint; + readonly i: BitString; + readonly j: number; + readonly k: bigint; + readonly tc: Slice; +} + +export interface IntBitsParametrizedInside { + readonly kind: 'IntBitsParametrizedInside'; + readonly x: number; + readonly a: IntBitsParametrized; +} + +export interface IntBitsParametrizedOutside { + readonly kind: 'IntBitsParametrizedOutside'; + readonly x: IntBitsParametrizedInside; +} + +export interface LessThan { + readonly kind: 'LessThan'; + readonly x: number; + readonly y: number; +} + +export interface OneComb { + readonly kind: 'OneComb'; + readonly t: number; + readonly x: A; +} + +export interface ManyComb { + readonly kind: 'ManyComb'; + readonly y: OneComb>>; +} + +export type Unary = Unary_unary_zero | Unary_unary_succ; + +export interface Unary_unary_zero { + readonly kind: 'Unary_unary_zero'; +} + +export interface Unary_unary_succ { + readonly kind: 'Unary_unary_succ'; + readonly n: number; + readonly x: Unary; +} + +export type ParamConst = ParamConst_b | ParamConst_c | ParamConst_a | ParamConst_d; + +export interface ParamConst_b { + readonly kind: 'ParamConst_b'; + readonly m: number; + readonly k: number; +} + +export interface ParamConst_c { + readonly kind: 'ParamConst_c'; + readonly n: number; + readonly m: number; + readonly k: number; +} + +export interface ParamConst_a { + readonly kind: 'ParamConst_a'; + readonly n: number; +} + +export interface ParamConst_d { + readonly kind: 'ParamConst_d'; + readonly n: number; + readonly m: number; + readonly k: number; + readonly l: number; +} + +export type ParamDifNames = ParamDifNames_a | ParamDifNames_b | ParamDifNames_c | ParamDifNames_d; + +export interface ParamDifNames_a { + readonly kind: 'ParamDifNames_a'; +} + +export interface ParamDifNames_b { + readonly kind: 'ParamDifNames_b'; +} + +export interface ParamDifNames_c { + readonly kind: 'ParamDifNames_c'; + readonly n: number; + readonly x: ParamDifNames; +} + +export interface ParamDifNames_d { + readonly kind: 'ParamDifNames_d'; + readonly m: number; + readonly x: ParamDifNames; +} + +export interface ParamDifNamesUser { + readonly kind: 'ParamDifNamesUser'; + readonly k: number; + readonly x: ParamDifNames; +} + +export interface NegationFromImplicit { + readonly kind: 'NegationFromImplicit'; + readonly y: number; + readonly t: number; + readonly z: number; +} + +export interface UnaryUserCheckOrder { + readonly kind: 'UnaryUserCheckOrder'; + readonly l: number; + readonly m: number; + readonly label: Unary; +} + +export interface CombArgCellRef { + readonly kind: 'CombArgCellRef'; + readonly info: number; + readonly init: Maybe>; + readonly other: Either>; + readonly body: Either; +} + +export interface CombArgCellRefUser { + readonly kind: 'CombArgCellRefUser'; + readonly x: CombArgCellRef; +} + +export interface MathExprAsCombArg { + readonly kind: 'MathExprAsCombArg'; + readonly n: number; + readonly ref: BitLenArg; +} + +export interface EmptyTag { + readonly kind: 'EmptyTag'; + readonly a: number; +} + +export interface SharpTag { + readonly kind: 'SharpTag'; + readonly x: number; +} + +export interface DollarTag { + readonly kind: 'DollarTag'; + readonly x: number; +} + +export interface TupleCheck { + readonly kind: 'TupleCheck'; + readonly s: Array; +} + +export interface Hashmap { + readonly kind: 'Hashmap'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: HashmapNode; +} + +export type HashmapNode = HashmapNode_hmn_leaf | HashmapNode_hmn_fork; + +export interface HashmapNode_hmn_leaf { + readonly kind: 'HashmapNode_hmn_leaf'; + readonly value: X; +} + +export interface HashmapNode_hmn_fork { + readonly kind: 'HashmapNode_hmn_fork'; + readonly n: number; + readonly left: Hashmap; + readonly right: Hashmap; +} + +export type HmLabel = HmLabel_hml_short | HmLabel_hml_long | HmLabel_hml_same; + +export interface HmLabel_hml_short { + readonly kind: 'HmLabel_hml_short'; + readonly m: number; + readonly n: number; + readonly len: Unary; + readonly s: Array; +} + +export interface HmLabel_hml_long { + readonly kind: 'HmLabel_hml_long'; + readonly m: number; + readonly n: number; + readonly s: Array; +} + +export interface HmLabel_hml_same { + readonly kind: 'HmLabel_hml_same'; + readonly m: number; + readonly v: BitString; + readonly n: number; +} + +export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; + +export interface HashmapE_hme_empty { + readonly kind: 'HashmapE_hme_empty'; + readonly n: number; +} + +export interface HashmapE_hme_root { + readonly kind: 'HashmapE_hme_root'; + readonly n: number; + readonly root: Hashmap; +} + +export interface HashmapEUser { + readonly kind: 'HashmapEUser'; + readonly x: HashmapE; +} + +export interface ConditionalField { + readonly kind: 'ConditionalField'; + readonly a: number; + readonly b: number | undefined; +} + +export interface BitSelection { + readonly kind: 'BitSelection'; + readonly a: number; + readonly b: number | undefined; +} + +export interface ImplicitCondition { + readonly kind: 'ImplicitCondition'; + readonly flags: number; +} + +export type MultipleEmptyConstructor = MultipleEmptyConstructor__ | MultipleEmptyConstructor__1 | MultipleEmptyConstructor_a; + +export interface MultipleEmptyConstructor__ { + readonly kind: 'MultipleEmptyConstructor__'; + readonly a: number; +} + +export interface MultipleEmptyConstructor__1 { + readonly kind: 'MultipleEmptyConstructor__1'; + readonly b: number; +} + +export interface MultipleEmptyConstructor_a { + readonly kind: 'MultipleEmptyConstructor_a'; + readonly x: number; +} + +export interface True { + readonly kind: 'True'; +} + +export type ParamNamedArgInSecondConstr = ParamNamedArgInSecondConstr_a | ParamNamedArgInSecondConstr_b; + +export interface ParamNamedArgInSecondConstr_a { + readonly kind: 'ParamNamedArgInSecondConstr_a'; + readonly n: number; +} + +export interface ParamNamedArgInSecondConstr_b { + readonly kind: 'ParamNamedArgInSecondConstr_b'; + readonly n: number; +} + +export interface RefCombinatorAny { + readonly kind: 'RefCombinatorAny'; + readonly msg: Maybe; +} + +export interface EqualityExpression { + readonly kind: 'EqualityExpression'; + readonly n: number; +} + +export interface ConditionalRef { + readonly kind: 'ConditionalRef'; + readonly x: number; + readonly y: Simple | undefined; +} + +export interface LoadFromNegationOutsideExpr { + readonly kind: 'LoadFromNegationOutsideExpr'; + readonly prev_seq_no: number; + readonly seq_no: number; +} + +export interface AnonymousData { + readonly kind: 'AnonymousData'; + readonly anon0: number; + readonly anon0_0: number; +} + +export interface FalseAnonField { + readonly kind: 'FalseAnonField'; + readonly value: bigint; +} + +export type ConstructorOrder = ConstructorOrder_a | ConstructorOrder__; + +export interface ConstructorOrder_a { + readonly kind: 'ConstructorOrder_a'; + readonly a: Simple; +} + +export interface ConstructorOrder__ { + readonly kind: 'ConstructorOrder__'; + readonly anon0: Simple; +} + +export type CheckCrc32 = CheckCrc32_a | CheckCrc32_b; + +export interface CheckCrc32_a { + readonly kind: 'CheckCrc32_a'; + readonly a: number; +} + +export interface CheckCrc32_b { + readonly kind: 'CheckCrc32_b'; + readonly b: number; + readonly c: number; +} + +export interface CheckKeyword { + readonly kind: 'CheckKeyword'; + readonly const0: number; +} + +export interface RefCombinatorInRefHelper { + readonly kind: 'RefCombinatorInRefHelper'; + readonly t: number; + readonly y: Maybe; +} + +export interface RefCombinatorInRef { + readonly kind: 'RefCombinatorInRef'; + readonly msg: RefCombinatorInRefHelper; +} + +export interface BoolUser { + readonly kind: 'BoolUser'; + readonly a: boolean; +} + +export interface Anycast { + readonly kind: 'Anycast'; + readonly depth: number; + readonly rewrite_pfx: BitString; +} + +export interface AddressUser { + readonly kind: 'AddressUser'; + readonly src: Address; +} + +// tmpa$_ a:# b:# = Simple; + +export function loadSimple(slice: Slice): Simple { + let a: number = slice.loadUint(32); + let b: number = slice.loadUint(32); + return { + kind: 'Simple', + a: a, + b: b, + } + +} + +export function storeSimple(simple: Simple): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(simple.a, 32); + builder.storeUint(simple.b, 32); + }) + +} + +// bool_false$0 a:# b:(## 7) c:# = TwoConstructors; + +// bool_true$1 b:# = TwoConstructors; + +export function loadTwoConstructors(slice: Slice): TwoConstructors { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let a: number = slice.loadUint(32); + let b: number = slice.loadUint(7); + let c: number = slice.loadUint(32); + return { + kind: 'TwoConstructors_bool_false', + a: a, + b: b, + c: c, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let b: number = slice.loadUint(32); + return { + kind: 'TwoConstructors_bool_true', + b: b, + } + + } + throw new Error('Expected one of "TwoConstructors_bool_false", "TwoConstructors_bool_true" in loading "TwoConstructors", but data does not satisfy any constructor'); +} + +export function storeTwoConstructors(twoConstructors: TwoConstructors): (builder: Builder) => void { + if ((twoConstructors.kind == 'TwoConstructors_bool_false')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + builder.storeUint(twoConstructors.a, 32); + builder.storeUint(twoConstructors.b, 7); + builder.storeUint(twoConstructors.c, 32); + }) + + } + if ((twoConstructors.kind == 'TwoConstructors_bool_true')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + builder.storeUint(twoConstructors.b, 32); + }) + + } + throw new Error('Expected one of "TwoConstructors_bool_false", "TwoConstructors_bool_true" in loading "TwoConstructors", but data does not satisfy any constructor'); +} + +// tmpb$_ y:(## 5) = FixedIntParam; + +export function loadFixedIntParam(slice: Slice): FixedIntParam { + let y: number = slice.loadUint(5); + return { + kind: 'FixedIntParam', + y: y, + } + +} + +export function storeFixedIntParam(fixedIntParam: FixedIntParam): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(fixedIntParam.y, 5); + }) + +} + +// tmpc$_ y:FixedIntParam c:# = TypedField; + +export function loadTypedField(slice: Slice): TypedField { + let y: FixedIntParam = loadFixedIntParam(slice); + let c: number = slice.loadUint(32); + return { + kind: 'TypedField', + y: y, + c: c, + } + +} + +export function storeTypedField(typedField: TypedField): (builder: Builder) => void { + return ((builder: Builder) => { + storeFixedIntParam(typedField.y)(builder); + builder.storeUint(typedField.c, 32); + }) + +} + +// tmpd#_ y:FixedIntParam c:# = SharpConstructor; + +export function loadSharpConstructor(slice: Slice): SharpConstructor { + let y: FixedIntParam = loadFixedIntParam(slice); + let c: number = slice.loadUint(32); + return { + kind: 'SharpConstructor', + y: y, + c: c, + } + +} + +export function storeSharpConstructor(sharpConstructor: SharpConstructor): (builder: Builder) => void { + return ((builder: Builder) => { + storeFixedIntParam(sharpConstructor.y)(builder); + builder.storeUint(sharpConstructor.c, 32); + }) + +} + +// nothing$0 {TheType:Type} = Maybe TheType; + +// just$1 {TheType:Type} value:TheType = Maybe TheType; + +export function loadMaybe(slice: Slice, loadTheType: (slice: Slice) => TheType): Maybe { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'Maybe_nothing', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let value: TheType = loadTheType(slice); + return { + kind: 'Maybe_just', + value: value, + } + + } + throw new Error('Expected one of "Maybe_nothing", "Maybe_just" in loading "Maybe", but data does not satisfy any constructor'); +} + +export function storeMaybe(maybe: Maybe, storeTheType: (theType: TheType) => (builder: Builder) => void): (builder: Builder) => void { + if ((maybe.kind == 'Maybe_nothing')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((maybe.kind == 'Maybe_just')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeTheType(maybe.value)(builder); + }) + + } + throw new Error('Expected one of "Maybe_nothing", "Maybe_just" in loading "Maybe", but data does not satisfy any constructor'); +} + +// thejust$_ x:(Maybe SharpConstructor) = TypedParam; + +export function loadTypedParam(slice: Slice): TypedParam { + let x: Maybe = loadMaybe(slice, loadSharpConstructor); + return { + kind: 'TypedParam', + x: x, + } + +} + +export function storeTypedParam(typedParam: TypedParam): (builder: Builder) => void { + return ((builder: Builder) => { + storeMaybe(typedParam.x, storeSharpConstructor)(builder); + }) + +} + +// left$0 {X:Type} {Y:Type} value:X = Either X Y; + +// right$1 {X:Type} {Y:Type} value:Y = Either X Y; + +export function loadEither(slice: Slice, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): Either { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let value: X = loadX(slice); + return { + kind: 'Either_left', + value: value, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let value: Y = loadY(slice); + return { + kind: 'Either_right', + value: value, + } + + } + throw new Error('Expected one of "Either_left", "Either_right" in loading "Either", but data does not satisfy any constructor'); +} + +export function storeEither(either: Either, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((either.kind == 'Either_left')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeX(either.value)(builder); + }) + + } + if ((either.kind == 'Either_right')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeY(either.value)(builder); + }) + + } + throw new Error('Expected one of "Either_left", "Either_right" in loading "Either", but data does not satisfy any constructor'); +} + +// a$_ {x:#} value:(## x) = BitLenArg x; + +export function loadBitLenArg(slice: Slice, x: number): BitLenArg { + let value: bigint = slice.loadUintBig(x); + return { + kind: 'BitLenArg', + x: x, + value: value, + } + +} + +export function storeBitLenArg(bitLenArg: BitLenArg): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(bitLenArg.value, bitLenArg.x); + }) + +} + +// a$_ t:(BitLenArg 4) = BitLenArgUser; + +export function loadBitLenArgUser(slice: Slice): BitLenArgUser { + let t: BitLenArg = loadBitLenArg(slice, 4); + return { + kind: 'BitLenArgUser', + t: t, + } + +} + +export function storeBitLenArgUser(bitLenArgUser: BitLenArgUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeBitLenArg(bitLenArgUser.t)(builder); + }) + +} + +// a$_ {x:#} value:(## x) = ExprArg (2 + x); + +export function loadExprArg(slice: Slice, arg0: number): ExprArg { + let value: bigint = slice.loadUintBig((arg0 - 2)); + return { + kind: 'ExprArg', + x: (arg0 - 2), + value: value, + } + +} + +export function storeExprArg(exprArg: ExprArg): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(exprArg.value, exprArg.x); + }) + +} + +// a$_ t:(ExprArg 6) = ExprArgUser; + +export function loadExprArgUser(slice: Slice): ExprArgUser { + let t: ExprArg = loadExprArg(slice, 6); + return { + kind: 'ExprArgUser', + t: t, + } + +} + +export function storeExprArgUser(exprArgUser: ExprArgUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeExprArg(exprArgUser.t)(builder); + }) + +} + +// a$_ a:ExprArgUser = ComplexTypedField; + +export function loadComplexTypedField(slice: Slice): ComplexTypedField { + let a: ExprArgUser = loadExprArgUser(slice); + return { + kind: 'ComplexTypedField', + a: a, + } + +} + +export function storeComplexTypedField(complexTypedField: ComplexTypedField): (builder: Builder) => void { + return ((builder: Builder) => { + storeExprArgUser(complexTypedField.a)(builder); + }) + +} + +// a$_ a:^ExprArgUser = CellTypedField; + +export function loadCellTypedField(slice: Slice): CellTypedField { + let slice1 = slice.loadRef().beginParse(); + let a: ExprArgUser = loadExprArgUser(slice1); + return { + kind: 'CellTypedField', + a: a, + } + +} + +export function storeCellTypedField(_cellTypedField: CellTypedField): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeExprArgUser(_cellTypedField.a)(cell1); + builder.storeRef(cell1); + }) + +} + +// a$_ t:# ^[ q:# ] ^[ a:(## 32) ^[ e:# ] ^[ b:(## 32) d:# ^[ c:(## 32) ] ] ] = CellsSimple; + +export function loadCellsSimple(slice: Slice): CellsSimple { + let t: number = slice.loadUint(32); + let slice1 = slice.loadRef().beginParse(); + let q: number = slice1.loadUint(32); + let slice2 = slice.loadRef().beginParse(); + let a: number = slice2.loadUint(32); + let slice21 = slice2.loadRef().beginParse(); + let e: number = slice21.loadUint(32); + let slice22 = slice2.loadRef().beginParse(); + let b: number = slice22.loadUint(32); + let d: number = slice22.loadUint(32); + let slice221 = slice22.loadRef().beginParse(); + let c: number = slice221.loadUint(32); + return { + kind: 'CellsSimple', + t: t, + q: q, + a: a, + e: e, + b: b, + d: d, + c: c, + } + +} + +export function storeCellsSimple(_cellsSimple: CellsSimple): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(_cellsSimple.t, 32); + let cell1 = beginCell(); + cell1.storeUint(_cellsSimple.q, 32); + builder.storeRef(cell1); + let cell2 = beginCell(); + cell2.storeUint(_cellsSimple.a, 32); + let cell21 = beginCell(); + cell21.storeUint(_cellsSimple.e, 32); + cell2.storeRef(cell21); + let cell22 = beginCell(); + cell22.storeUint(_cellsSimple.b, 32); + cell22.storeUint(_cellsSimple.d, 32); + let cell221 = beginCell(); + cell221.storeUint(_cellsSimple.c, 32); + cell22.storeRef(cell221); + cell2.storeRef(cell22); + builder.storeRef(cell2); + }) + +} + +// b$_ d:int11 g:bits2 {Arg:Type} arg:Arg x:Any = IntBits Arg; + +export function loadIntBits(slice: Slice, loadArg: (slice: Slice) => Arg): IntBits { + let d: number = slice.loadInt(11); + let g: BitString = slice.loadBits(2); + let arg: Arg = loadArg(slice); + let x: Slice = slice; + return { + kind: 'IntBits', + d: d, + g: g, + arg: arg, + x: x, + } + +} + +export function storeIntBits(intBits: IntBits, storeArg: (arg: Arg) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeInt(intBits.d, 11); + builder.storeBits(intBits.g); + storeArg(intBits.arg)(builder); + builder.storeSlice(intBits.x); + }) + +} + +// a$_ {x:#} a:(IntBits (int (1 + x))) = IntBitsInside (x * 2); + +export function loadIntBitsInside(slice: Slice, arg0: number): IntBitsInside { + let a: IntBits = loadIntBits(slice, ((slice: Slice) => { + return slice.loadIntBig((1 + (arg0 / 2))) + + })); + return { + kind: 'IntBitsInside', + x: (arg0 / 2), + a: a, + } + +} + +export function storeIntBitsInside(intBitsInside: IntBitsInside): (builder: Builder) => void { + return ((builder: Builder) => { + storeIntBits(intBitsInside.a, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeInt(arg, (1 + intBitsInside.x)); + }) + + }))(builder); + }) + +} + +// a$_ x:(IntBitsInside 6) = IntBitsOutside; + +export function loadIntBitsOutside(slice: Slice): IntBitsOutside { + let x: IntBitsInside = loadIntBitsInside(slice, 6); + return { + kind: 'IntBitsOutside', + x: x, + } + +} + +export function storeIntBitsOutside(intBitsOutside: IntBitsOutside): (builder: Builder) => void { + return ((builder: Builder) => { + storeIntBitsInside(intBitsOutside.x)(builder); + }) + +} + +// a$_ {e:#} h:(int (e * 8)) f:(uint (7 * e)) i:(bits (5 + e)) j:(int 5) k:(uint e) tc:Cell = IntBitsParametrized e; + +export function loadIntBitsParametrized(slice: Slice, e: number): IntBitsParametrized { + let h: bigint = slice.loadIntBig((e * 8)); + let f: bigint = slice.loadUintBig((7 * e)); + let i: BitString = slice.loadBits((5 + e)); + let j: number = slice.loadInt(5); + let k: bigint = slice.loadUintBig(e); + let tc: Slice = slice; + return { + kind: 'IntBitsParametrized', + e: e, + h: h, + f: f, + i: i, + j: j, + k: k, + tc: tc, + } + +} + +export function storeIntBitsParametrized(intBitsParametrized: IntBitsParametrized): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeInt(intBitsParametrized.h, (intBitsParametrized.e * 8)); + builder.storeUint(intBitsParametrized.f, (7 * intBitsParametrized.e)); + builder.storeBits(intBitsParametrized.i); + builder.storeInt(intBitsParametrized.j, 5); + builder.storeUint(intBitsParametrized.k, intBitsParametrized.e); + builder.storeSlice(intBitsParametrized.tc); + }) + +} + +// a$_ {x:#} a:(IntBitsParametrized x) = IntBitsParametrizedInside x; + +export function loadIntBitsParametrizedInside(slice: Slice, x: number): IntBitsParametrizedInside { + let a: IntBitsParametrized = loadIntBitsParametrized(slice, x); + return { + kind: 'IntBitsParametrizedInside', + x: x, + a: a, + } + +} + +export function storeIntBitsParametrizedInside(intBitsParametrizedInside: IntBitsParametrizedInside): (builder: Builder) => void { + return ((builder: Builder) => { + storeIntBitsParametrized(intBitsParametrizedInside.a)(builder); + }) + +} + +// a$_ x:(IntBitsParametrizedInside 5) = IntBitsParametrizedOutside; + +export function loadIntBitsParametrizedOutside(slice: Slice): IntBitsParametrizedOutside { + let x: IntBitsParametrizedInside = loadIntBitsParametrizedInside(slice, 5); + return { + kind: 'IntBitsParametrizedOutside', + x: x, + } + +} + +export function storeIntBitsParametrizedOutside(intBitsParametrizedOutside: IntBitsParametrizedOutside): (builder: Builder) => void { + return ((builder: Builder) => { + storeIntBitsParametrizedInside(intBitsParametrizedOutside.x)(builder); + }) + +} + +// a$_ x:(#< 4) y:(#<= 4) = LessThan; + +export function loadLessThan(slice: Slice): LessThan { + let x: number = slice.loadUint(bitLen((4 - 1))); + let y: number = slice.loadUint(bitLen(4)); + return { + kind: 'LessThan', + x: x, + y: y, + } + +} + +export function storeLessThan(lessThan: LessThan): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(lessThan.x, bitLen((4 - 1))); + builder.storeUint(lessThan.y, bitLen(4)); + }) + +} + +// a$_ {A:Type} t:# x:A = OneComb A; + +export function loadOneComb(slice: Slice, loadA: (slice: Slice) => A): OneComb { + let t: number = slice.loadUint(32); + let x: A = loadA(slice); + return { + kind: 'OneComb', + t: t, + x: x, + } + +} + +export function storeOneComb(oneComb: OneComb, storeA: (a: A) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(oneComb.t, 32); + storeA(oneComb.x)(builder); + }) + +} + +// a$_ y:(OneComb(OneComb(OneComb int3))) = ManyComb; + +export function loadManyComb(slice: Slice): ManyComb { + let y: OneComb>> = loadOneComb>>(slice, ((slice: Slice) => { + return loadOneComb>(slice, ((slice: Slice) => { + return loadOneComb(slice, ((slice: Slice) => { + return slice.loadInt(3) + + })) + + })) + + })); + return { + kind: 'ManyComb', + y: y, + } + +} + +export function storeManyComb(manyComb: ManyComb): (builder: Builder) => void { + return ((builder: Builder) => { + storeOneComb>>(manyComb.y, ((arg: OneComb>) => { + return ((builder: Builder) => { + storeOneComb>(arg, ((arg: OneComb) => { + return ((builder: Builder) => { + storeOneComb(arg, ((arg: number) => { + return ((builder: Builder) => { + builder.storeInt(arg, 3); + }) + + }))(builder); + }) + + }))(builder); + }) + + }))(builder); + }) + +} + +// unary_zero$0 = Unary ~0; + +export function unary_unary_succ_get_n(x: Unary): number { + if ((x.kind == 'Unary_unary_zero')) { + return 0 + + } + if ((x.kind == 'Unary_unary_succ')) { + let n = x.n; + return (n + 1) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" for type "Unary" while getting "x", but data does not satisfy any constructor'); +} + +// unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + +export function loadUnary(slice: Slice): Unary { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'Unary_unary_zero', + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let x: Unary = loadUnary(slice); + let n = unary_unary_succ_get_n(x); + return { + kind: 'Unary_unary_succ', + x: x, + n: n, + } + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" in loading "Unary", but data does not satisfy any constructor'); +} + +export function storeUnary(unary: Unary): (builder: Builder) => void { + if ((unary.kind == 'Unary_unary_zero')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((unary.kind == 'Unary_unary_succ')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeUnary(unary.x)(builder); + }) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" in loading "Unary", but data does not satisfy any constructor'); +} + +// b$01 m:# k:# = ParamConst 2 1; + +// c$01 n:# m:# k:# = ParamConst 3 3; + +// a$_ n:# = ParamConst 1 1; + +// d$_ n:# m:# k:# l:# = ParamConst 4 2; + +export function loadParamConst(slice: Slice, arg0: number, arg1: number): ParamConst { + if (((slice.remainingBits >= 2) && ((slice.preloadUint(2) == 0b01) && ((arg0 == 2) && (arg1 == 1))))) { + slice.loadUint(2); + let m: number = slice.loadUint(32); + let k: number = slice.loadUint(32); + return { + kind: 'ParamConst_b', + m: m, + k: k, + } + + } + if (((slice.remainingBits >= 2) && ((slice.preloadUint(2) == 0b01) && ((arg0 == 3) && (arg1 == 3))))) { + slice.loadUint(2); + let n: number = slice.loadUint(32); + let m: number = slice.loadUint(32); + let k: number = slice.loadUint(32); + return { + kind: 'ParamConst_c', + n: n, + m: m, + k: k, + } + + } + if (((arg0 == 1) && (arg1 == 1))) { + let n: number = slice.loadUint(32); + return { + kind: 'ParamConst_a', + n: n, + } + + } + if (((arg0 == 4) && (arg1 == 2))) { + let n: number = slice.loadUint(32); + let m: number = slice.loadUint(32); + let k: number = slice.loadUint(32); + let l: number = slice.loadUint(32); + return { + kind: 'ParamConst_d', + n: n, + m: m, + k: k, + l: l, + } + + } + throw new Error('Expected one of "ParamConst_b", "ParamConst_c", "ParamConst_a", "ParamConst_d" in loading "ParamConst", but data does not satisfy any constructor'); +} + +export function storeParamConst(paramConst: ParamConst): (builder: Builder) => void { + if ((paramConst.kind == 'ParamConst_b')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + builder.storeUint(paramConst.m, 32); + builder.storeUint(paramConst.k, 32); + }) + + } + if ((paramConst.kind == 'ParamConst_c')) { + return ((builder: Builder) => { + builder.storeUint(0b01, 2); + builder.storeUint(paramConst.n, 32); + builder.storeUint(paramConst.m, 32); + builder.storeUint(paramConst.k, 32); + }) + + } + if ((paramConst.kind == 'ParamConst_a')) { + return ((builder: Builder) => { + builder.storeUint(paramConst.n, 32); + }) + + } + if ((paramConst.kind == 'ParamConst_d')) { + return ((builder: Builder) => { + builder.storeUint(paramConst.n, 32); + builder.storeUint(paramConst.m, 32); + builder.storeUint(paramConst.k, 32); + builder.storeUint(paramConst.l, 32); + }) + + } + throw new Error('Expected one of "ParamConst_b", "ParamConst_c", "ParamConst_a", "ParamConst_d" in loading "ParamConst", but data does not satisfy any constructor'); +} + +// a$0 = ParamDifNames 2 ~1; + +// b$1 = ParamDifNames 3 ~1; + +export function paramDifNames_c_get_n(x: ParamDifNames): number { + if ((x.kind == 'ParamDifNames_a')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_b')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_c')) { + let n = x.n; + return (n + 1) + + } + if ((x.kind == 'ParamDifNames_d')) { + let m = x.m; + return (m * 2) + + } + throw new Error('Expected one of "ParamDifNames_a", "ParamDifNames_b", "ParamDifNames_c", "ParamDifNames_d" for type "ParamDifNames" while getting "x", but data does not satisfy any constructor'); +} + +// c$1 {n:#} x:(ParamDifNames 2 ~n) = ParamDifNames 2 ~(n + 1); + +export function paramDifNames_d_get_m(x: ParamDifNames): number { + if ((x.kind == 'ParamDifNames_a')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_b')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_c')) { + let n = x.n; + return (n + 1) + + } + if ((x.kind == 'ParamDifNames_d')) { + let m = x.m; + return (m * 2) + + } + throw new Error('Expected one of "ParamDifNames_a", "ParamDifNames_b", "ParamDifNames_c", "ParamDifNames_d" for type "ParamDifNames" while getting "x", but data does not satisfy any constructor'); +} + +// d$0 {m:#} x:(ParamDifNames 3 ~m) = ParamDifNames 3 ~(m * 2); + +export function loadParamDifNames(slice: Slice, arg0: number): ParamDifNames { + if (((slice.remainingBits >= 1) && ((slice.preloadUint(1) == 0b0) && (arg0 == 2)))) { + slice.loadUint(1); + return { + kind: 'ParamDifNames_a', + } + + } + if (((slice.remainingBits >= 1) && ((slice.preloadUint(1) == 0b1) && (arg0 == 3)))) { + slice.loadUint(1); + return { + kind: 'ParamDifNames_b', + } + + } + if (((slice.remainingBits >= 1) && ((slice.preloadUint(1) == 0b1) && (arg0 == 2)))) { + slice.loadUint(1); + let x: ParamDifNames = loadParamDifNames(slice, 2); + let n = paramDifNames_c_get_n(x); + return { + kind: 'ParamDifNames_c', + x: x, + n: n, + } + + } + if (((slice.remainingBits >= 1) && ((slice.preloadUint(1) == 0b0) && (arg0 == 3)))) { + slice.loadUint(1); + let x: ParamDifNames = loadParamDifNames(slice, 3); + let m = paramDifNames_d_get_m(x); + return { + kind: 'ParamDifNames_d', + x: x, + m: m, + } + + } + throw new Error('Expected one of "ParamDifNames_a", "ParamDifNames_b", "ParamDifNames_c", "ParamDifNames_d" in loading "ParamDifNames", but data does not satisfy any constructor'); +} + +export function storeParamDifNames(paramDifNames: ParamDifNames): (builder: Builder) => void { + if ((paramDifNames.kind == 'ParamDifNames_a')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((paramDifNames.kind == 'ParamDifNames_b')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + }) + + } + if ((paramDifNames.kind == 'ParamDifNames_c')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + storeParamDifNames(paramDifNames.x)(builder); + }) + + } + if ((paramDifNames.kind == 'ParamDifNames_d')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeParamDifNames(paramDifNames.x)(builder); + }) + + } + throw new Error('Expected one of "ParamDifNames_a", "ParamDifNames_b", "ParamDifNames_c", "ParamDifNames_d" in loading "ParamDifNames", but data does not satisfy any constructor'); +} + +export function paramDifNamesUser_get_k(x: ParamDifNames): number { + if ((x.kind == 'ParamDifNames_a')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_b')) { + return 1 + + } + if ((x.kind == 'ParamDifNames_c')) { + let n = x.n; + return (n + 1) + + } + if ((x.kind == 'ParamDifNames_d')) { + let m = x.m; + return (m * 2) + + } + throw new Error('Expected one of "ParamDifNames_a", "ParamDifNames_b", "ParamDifNames_c", "ParamDifNames_d" for type "ParamDifNames" while getting "x", but data does not satisfy any constructor'); +} + +// e$0 {k:#} x:(ParamDifNames 2 ~k) = ParamDifNamesUser; + +export function loadParamDifNamesUser(slice: Slice): ParamDifNamesUser { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let x: ParamDifNames = loadParamDifNames(slice, 2); + let k = paramDifNamesUser_get_k(x); + return { + kind: 'ParamDifNamesUser', + x: x, + k: k, + } + + } + throw new Error('Expected one of "ParamDifNamesUser" in loading "ParamDifNamesUser", but data does not satisfy any constructor'); +} + +export function storeParamDifNamesUser(paramDifNamesUser: ParamDifNamesUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeParamDifNames(paramDifNamesUser.x)(builder); + }) + +} + +// b$1 {y:#} t:# z:# { t = (~y) * 2} = NegationFromImplicit ~(y + 1); + +export function loadNegationFromImplicit(slice: Slice): NegationFromImplicit { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let t: number = slice.loadUint(32); + let z: number = slice.loadUint(32); + return { + kind: 'NegationFromImplicit', + y: (t / 2), + t: t, + z: z, + } + + } + throw new Error('Expected one of "NegationFromImplicit" in loading "NegationFromImplicit", but data does not satisfy any constructor'); +} + +export function storeNegationFromImplicit(negationFromImplicit: NegationFromImplicit): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + builder.storeUint(negationFromImplicit.t, 32); + builder.storeUint(negationFromImplicit.z, 32); + }) + +} + +export function unaryUserCheckOrder_get_l(label: Unary): number { + if ((label.kind == 'Unary_unary_zero')) { + return 0 + + } + if ((label.kind == 'Unary_unary_succ')) { + let n = label.n; + return (n + 1) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" for type "Unary" while getting "label", but data does not satisfy any constructor'); +} + +// hm_edge#_ {l:#} {m:#} label:(Unary ~l) {7 = (~m) + l} = UnaryUserCheckOrder; + +export function loadUnaryUserCheckOrder(slice: Slice): UnaryUserCheckOrder { + let label: Unary = loadUnary(slice); + let l = unaryUserCheckOrder_get_l(label); + return { + kind: 'UnaryUserCheckOrder', + m: (7 - l), + label: label, + l: l, + } + +} + +export function storeUnaryUserCheckOrder(unaryUserCheckOrder: UnaryUserCheckOrder): (builder: Builder) => void { + return ((builder: Builder) => { + storeUnary(unaryUserCheckOrder.label)(builder); + }) + +} + +/* +a$_ {X:Type} info:int32 + init:(Maybe (Either X ^int22)) + other:(Either X ^(OneComb X)) + body:(Either X ^X) = CombArgCellRef X; +*/ + +export function loadCombArgCellRef(slice: Slice, loadX: (slice: Slice) => X): CombArgCellRef { + let info: number = slice.loadInt(32); + let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { + return loadEither(slice, loadX, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return slice1.loadInt(22) + + })) + + })); + let other: Either> = loadEither>(slice, loadX, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadOneComb(slice1, loadX) + + })); + let body: Either = loadEither(slice, loadX, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadX(slice1) + + })); + return { + kind: 'CombArgCellRef', + info: info, + init: init, + other: other, + body: body, + } + +} + +export function storeCombArgCellRef(combArgCellRef: CombArgCellRef, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeInt(combArgCellRef.info, 32); + storeMaybe>(combArgCellRef.init, ((arg: Either) => { + return ((builder: Builder) => { + storeEither(arg, storeX, ((arg: number) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeInt(arg, 22); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + + }))(builder); + storeEither>(combArgCellRef.other, storeX, ((arg: OneComb) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeOneComb(arg, storeX)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + storeEither(combArgCellRef.body, storeX, ((arg: X) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeX(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// a$_ x:(CombArgCellRef int12) = CombArgCellRefUser; + +export function loadCombArgCellRefUser(slice: Slice): CombArgCellRefUser { + let x: CombArgCellRef = loadCombArgCellRef(slice, ((slice: Slice) => { + return slice.loadInt(12) + + })); + return { + kind: 'CombArgCellRefUser', + x: x, + } + +} + +export function storeCombArgCellRefUser(combArgCellRefUser: CombArgCellRefUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeCombArgCellRef(combArgCellRefUser.x, ((arg: number) => { + return ((builder: Builder) => { + builder.storeInt(arg, 12); + }) + + }))(builder); + }) + +} + +// a$_ {n:#} ref:^(BitLenArg (n + 2)) = MathExprAsCombArg (n + 2); + +export function loadMathExprAsCombArg(slice: Slice, arg0: number): MathExprAsCombArg { + let slice1 = slice.loadRef().beginParse(); + let ref: BitLenArg = loadBitLenArg(slice1, ((arg0 - 2) + 2)); + return { + kind: 'MathExprAsCombArg', + n: (arg0 - 2), + ref: ref, + } + +} + +export function storeMathExprAsCombArg(mathExprAsCombArg: MathExprAsCombArg): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeBitLenArg(mathExprAsCombArg.ref)(cell1); + builder.storeRef(cell1); + }) + +} + +// _ a:# = EmptyTag; + +export function loadEmptyTag(slice: Slice): EmptyTag { + let a: number = slice.loadUint(32); + return { + kind: 'EmptyTag', + a: a, + } + +} + +export function storeEmptyTag(emptyTag: EmptyTag): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(emptyTag.a, 32); + }) + +} + +// a#f4 x:# = SharpTag; + +export function loadSharpTag(slice: Slice): SharpTag { + if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xf4))) { + slice.loadUint(8); + let x: number = slice.loadUint(32); + return { + kind: 'SharpTag', + x: x, + } + + } + throw new Error('Expected one of "SharpTag" in loading "SharpTag", but data does not satisfy any constructor'); +} + +export function storeSharpTag(sharpTag: SharpTag): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0xf4, 8); + builder.storeUint(sharpTag.x, 32); + }) + +} + +// a$1011 x:# = DollarTag; + +export function loadDollarTag(slice: Slice): DollarTag { + if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1011))) { + slice.loadUint(4); + let x: number = slice.loadUint(32); + return { + kind: 'DollarTag', + x: x, + } + + } + throw new Error('Expected one of "DollarTag" in loading "DollarTag", but data does not satisfy any constructor'); +} + +export function storeDollarTag(dollarTag: DollarTag): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0b1011, 4); + builder.storeUint(dollarTag.x, 32); + }) + +} + +// a$_ s:(3 * int5) = TupleCheck; + +export function loadTupleCheck(slice: Slice): TupleCheck { + let s: Array = Array.from(Array(3).keys()).map(((arg: number) => { + return slice.loadInt(5) + + })); + return { + kind: 'TupleCheck', + s: s, + } + +} + +export function storeTupleCheck(tupleCheck: TupleCheck): (builder: Builder) => void { + return ((builder: Builder) => { + tupleCheck.s.forEach(((arg: number) => { + builder.storeInt(arg, 5); + })); + }) + +} + +export function hashmap_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; +*/ + +export function loadHashmap(slice: Slice, n: number, loadX: (slice: Slice) => X): Hashmap { + let label: HmLabel = loadHmLabel(slice, n); + let l = hashmap_get_l(label); + let node: HashmapNode = loadHashmapNode(slice, (n - l), loadX); + return { + kind: 'Hashmap', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storeHashmap(hashmap: Hashmap, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(hashmap.label)(builder); + storeHashmapNode(hashmap.node, storeX)(builder); + }) + +} + +// hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; + +/* +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; +*/ + +export function loadHashmapNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X): HashmapNode { + if ((arg0 == 0)) { + let value: X = loadX(slice); + return { + kind: 'HashmapNode_hmn_leaf', + value: value, + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let left: Hashmap = loadHashmap(slice1, (arg0 - 1), loadX); + let slice2 = slice.loadRef().beginParse(); + let right: Hashmap = loadHashmap(slice2, (arg0 - 1), loadX); + return { + kind: 'HashmapNode_hmn_fork', + n: (arg0 - 1), + left: left, + right: right, + } + + } + throw new Error('Expected one of "HashmapNode_hmn_leaf", "HashmapNode_hmn_fork" in loading "HashmapNode", but data does not satisfy any constructor'); +} + +export function storeHashmapNode(hashmapNode: HashmapNode, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapNode.kind == 'HashmapNode_hmn_leaf')) { + return ((builder: Builder) => { + storeX(hashmapNode.value)(builder); + }) + + } + if ((hashmapNode.kind == 'HashmapNode_hmn_fork')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeHashmap(hashmapNode.left, storeX)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeHashmap(hashmapNode.right, storeX)(cell2); + builder.storeRef(cell2); + }) + + } + throw new Error('Expected one of "HashmapNode_hmn_leaf", "HashmapNode_hmn_fork" in loading "HashmapNode", but data does not satisfy any constructor'); +} + +export function hmLabel_hml_short_get_n(len: Unary): number { + if ((len.kind == 'Unary_unary_zero')) { + return 0 + + } + if ((len.kind == 'Unary_unary_succ')) { + let n = len.n; + return (n + 1) + + } + throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" for type "Unary" while getting "len", but data does not satisfy any constructor'); +} + +// hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + +// hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + +// hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + +export function loadHmLabel(slice: Slice, m: number): HmLabel { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let len: Unary = loadUnary(slice); + let n = hmLabel_hml_short_get_n(len); + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBits(1) + + })); + if ((!(n <= m))) { + throw new Error('Condition (n <= m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); + } + return { + kind: 'HmLabel_hml_short', + m: m, + len: len, + n: n, + s: s, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { + slice.loadUint(2); + let n: number = slice.loadUint(bitLen(m)); + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBits(1) + + })); + return { + kind: 'HmLabel_hml_long', + m: m, + n: n, + s: s, + } + + } + if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { + slice.loadUint(2); + let v: BitString = slice.loadBits(1); + let n: number = slice.loadUint(bitLen(m)); + return { + kind: 'HmLabel_hml_same', + m: m, + v: v, + n: n, + } + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" in loading "HmLabel", but data does not satisfy any constructor'); +} + +export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { + if ((hmLabel.kind == 'HmLabel_hml_short')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeUnary(hmLabel.len)(builder); + hmLabel.s.forEach(((arg: BitString) => { + builder.storeBits(arg); + })); + if ((!(hmLabel.n <= hmLabel.m))) { + throw new Error('Condition (hmLabel.n <= hmLabel.m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); + } + }) + + } + if ((hmLabel.kind == 'HmLabel_hml_long')) { + return ((builder: Builder) => { + builder.storeUint(0b10, 2); + builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); + hmLabel.s.forEach(((arg: BitString) => { + builder.storeBits(arg); + })); + }) + + } + if ((hmLabel.kind == 'HmLabel_hml_same')) { + return ((builder: Builder) => { + builder.storeUint(0b11, 2); + builder.storeBits(hmLabel.v); + builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); + }) + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" in loading "HmLabel", but data does not satisfy any constructor'); +} + +// hme_empty$0 {n:#} {X:Type} = HashmapE n X; + +// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + +export function loadHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): HashmapE { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'HashmapE_hme_empty', + n: n, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + let slice1 = slice.loadRef().beginParse(); + let root: Hashmap = loadHashmap(slice1, n, loadX); + return { + kind: 'HashmapE_hme_root', + n: n, + root: root, + } + + } + throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); +} + +export function storeHashmapE(hashmapE: HashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapE.kind == 'HashmapE_hme_empty')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((hashmapE.kind == 'HashmapE_hme_root')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + let cell1 = beginCell(); + storeHashmap(hashmapE.root, storeX)(cell1); + builder.storeRef(cell1); + }) + + } + throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); +} + +// a$_ x:(HashmapE 8 uint16) = HashmapEUser; + +export function loadHashmapEUser(slice: Slice): HashmapEUser { + let x: HashmapE = loadHashmapE(slice, 8, ((slice: Slice) => { + return slice.loadUint(16) + + })); + return { + kind: 'HashmapEUser', + x: x, + } + +} + +export function storeHashmapEUser(hashmapEUser: HashmapEUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapE(hashmapEUser.x, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 16); + }) + + }))(builder); + }) + +} + +// _ a:(## 1) b:a?(## 32) = ConditionalField; + +export function loadConditionalField(slice: Slice): ConditionalField { + let a: number = slice.loadUint(1); + let b: number | undefined = (a ? slice.loadUint(32) : undefined); + return { + kind: 'ConditionalField', + a: a, + b: b, + } + +} + +export function storeConditionalField(conditionalField: ConditionalField): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(conditionalField.a, 1); + if ((conditionalField.b != undefined)) { + builder.storeUint(conditionalField.b, 32); + } + }) + +} + +// _ a:(## 6) b:(a . 2)?(## 32) = BitSelection; + +export function loadBitSelection(slice: Slice): BitSelection { + let a: number = slice.loadUint(6); + let b: number | undefined = ((a & (1 << 2)) ? slice.loadUint(32) : undefined); + return { + kind: 'BitSelection', + a: a, + b: b, + } + +} + +export function storeBitSelection(bitSelection: BitSelection): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(bitSelection.a, 6); + if ((bitSelection.b != undefined)) { + builder.storeUint(bitSelection.b, 32); + } + }) + +} + +// _ flags:(## 10) { flags <= 100 } = ImplicitCondition; + +export function loadImplicitCondition(slice: Slice): ImplicitCondition { + let flags: number = slice.loadUint(10); + if ((!(flags <= 100))) { + throw new Error('Condition (flags <= 100) is not satisfied while loading "ImplicitCondition" for type "ImplicitCondition"'); + } + return { + kind: 'ImplicitCondition', + flags: flags, + } + +} + +export function storeImplicitCondition(implicitCondition: ImplicitCondition): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(implicitCondition.flags, 10); + if ((!(implicitCondition.flags <= 100))) { + throw new Error('Condition (implicitCondition.flags <= 100) is not satisfied while loading "ImplicitCondition" for type "ImplicitCondition"'); + } + }) + +} + +// _ a:# = MultipleEmptyConstructor 0; + +// _ b:(## 5) = MultipleEmptyConstructor 1; + +// a$_ x:(## 6) = MultipleEmptyConstructor 2; + +export function loadMultipleEmptyConstructor(slice: Slice, arg0: number): MultipleEmptyConstructor { + if ((arg0 == 0)) { + let a: number = slice.loadUint(32); + return { + kind: 'MultipleEmptyConstructor__', + a: a, + } + + } + if ((arg0 == 1)) { + let b: number = slice.loadUint(5); + return { + kind: 'MultipleEmptyConstructor__1', + b: b, + } + + } + if ((arg0 == 2)) { + let x: number = slice.loadUint(6); + return { + kind: 'MultipleEmptyConstructor_a', + x: x, + } + + } + throw new Error('Expected one of "MultipleEmptyConstructor__", "MultipleEmptyConstructor__1", "MultipleEmptyConstructor_a" in loading "MultipleEmptyConstructor", but data does not satisfy any constructor'); +} + +export function storeMultipleEmptyConstructor(multipleEmptyConstructor: MultipleEmptyConstructor): (builder: Builder) => void { + if ((multipleEmptyConstructor.kind == 'MultipleEmptyConstructor__')) { + return ((builder: Builder) => { + builder.storeUint(multipleEmptyConstructor.a, 32); + }) + + } + if ((multipleEmptyConstructor.kind == 'MultipleEmptyConstructor__1')) { + return ((builder: Builder) => { + builder.storeUint(multipleEmptyConstructor.b, 5); + }) + + } + if ((multipleEmptyConstructor.kind == 'MultipleEmptyConstructor_a')) { + return ((builder: Builder) => { + builder.storeUint(multipleEmptyConstructor.x, 6); + }) + + } + throw new Error('Expected one of "MultipleEmptyConstructor__", "MultipleEmptyConstructor__1", "MultipleEmptyConstructor_a" in loading "MultipleEmptyConstructor", but data does not satisfy any constructor'); +} + +// true$_ = True; + +export function loadTrue(slice: Slice): True { + return { + kind: 'True', + } + +} + +export function storeTrue(true0: True): (builder: Builder) => void { + return ((builder: Builder) => { + }) + +} + +// a$0 {n:#} = ParamNamedArgInSecondConstr n; + +// b$1 {n:#} = ParamNamedArgInSecondConstr (n + 1); + +export function loadParamNamedArgInSecondConstr(slice: Slice, arg0: number): ParamNamedArgInSecondConstr { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + return { + kind: 'ParamNamedArgInSecondConstr_a', + n: arg0, + } + + } + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { + slice.loadUint(1); + return { + kind: 'ParamNamedArgInSecondConstr_b', + n: (arg0 - 1), + } + + } + throw new Error('Expected one of "ParamNamedArgInSecondConstr_a", "ParamNamedArgInSecondConstr_b" in loading "ParamNamedArgInSecondConstr", but data does not satisfy any constructor'); +} + +export function storeParamNamedArgInSecondConstr(paramNamedArgInSecondConstr: ParamNamedArgInSecondConstr): (builder: Builder) => void { + if ((paramNamedArgInSecondConstr.kind == 'ParamNamedArgInSecondConstr_a')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + }) + + } + if ((paramNamedArgInSecondConstr.kind == 'ParamNamedArgInSecondConstr_b')) { + return ((builder: Builder) => { + builder.storeUint(0b1, 1); + }) + + } + throw new Error('Expected one of "ParamNamedArgInSecondConstr_a", "ParamNamedArgInSecondConstr_b" in loading "ParamNamedArgInSecondConstr", but data does not satisfy any constructor'); +} + +// a$_ msg:^(Maybe Any) = RefCombinatorAny; + +export function loadRefCombinatorAny(slice: Slice): RefCombinatorAny { + let slice1 = slice.loadRef().beginParse(); + let msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { + return slice + + })); + return { + kind: 'RefCombinatorAny', + msg: msg, + } + +} + +export function storeRefCombinatorAny(refCombinatorAny: RefCombinatorAny): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMaybe(refCombinatorAny.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + }) + +} + +// a$_ n:# { 5 + n = 7 } = EqualityExpression; + +export function loadEqualityExpression(slice: Slice): EqualityExpression { + let n: number = slice.loadUint(32); + if ((!((5 + n) == 7))) { + throw new Error('Condition ((5 + n) == 7) is not satisfied while loading "EqualityExpression" for type "EqualityExpression"'); + } + return { + kind: 'EqualityExpression', + n: n, + } + +} + +export function storeEqualityExpression(equalityExpression: EqualityExpression): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(equalityExpression.n, 32); + if ((!((5 + equalityExpression.n) == 7))) { + throw new Error('Condition ((5 + equalityExpression.n) == 7) is not satisfied while loading "EqualityExpression" for type "EqualityExpression"'); + } + }) + +} + +// a$_ x:(## 1) y:x?^Simple = ConditionalRef; + +export function loadConditionalRef(slice: Slice): ConditionalRef { + let x: number = slice.loadUint(1); + let y: Simple | undefined = (x ? ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadSimple(slice1) + + })(slice) : undefined); + return { + kind: 'ConditionalRef', + x: x, + y: y, + } + +} + +export function storeConditionalRef(conditionalRef: ConditionalRef): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(conditionalRef.x, 1); + if ((conditionalRef.y != undefined)) { + let cell1 = beginCell(); + storeSimple(conditionalRef.y)(cell1); + builder.storeRef(cell1); + + } + }) + +} + +// block_info#9bc7a987 seq_no:# { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } = LoadFromNegationOutsideExpr; + +export function loadLoadFromNegationOutsideExpr(slice: Slice): LoadFromNegationOutsideExpr { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x9bc7a987))) { + slice.loadUint(32); + let seq_no: number = slice.loadUint(32); + return { + kind: 'LoadFromNegationOutsideExpr', + prev_seq_no: (seq_no - 1), + seq_no: seq_no, + } + + } + throw new Error('Expected one of "LoadFromNegationOutsideExpr" in loading "LoadFromNegationOutsideExpr", but data does not satisfy any constructor'); +} + +export function storeLoadFromNegationOutsideExpr(loadFromNegationOutsideExpr: LoadFromNegationOutsideExpr): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x9bc7a987, 32); + builder.storeUint(loadFromNegationOutsideExpr.seq_no, 32); + }) + +} + +// bit$_ (## 1) anon0:# = AnonymousData; + +export function loadAnonymousData(slice: Slice): AnonymousData { + let anon0: number = slice.loadUint(1); + let anon0_0: number = slice.loadUint(32); + return { + kind: 'AnonymousData', + anon0: anon0, + anon0_0: anon0_0, + } + +} + +export function storeAnonymousData(anonymousData: AnonymousData): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(anonymousData.anon0, 1); + builder.storeUint(anonymousData.anon0_0, 32); + }) + +} + +// vm_stk_int#0201_ value:int257 = FalseAnonField; + +export function loadFalseAnonField(slice: Slice): FalseAnonField { + if (((slice.remainingBits >= 16) && (slice.preloadUint(16) == 0x0201))) { + slice.loadUint(16); + let value: bigint = slice.loadIntBig(257); + return { + kind: 'FalseAnonField', + value: value, + } + + } + throw new Error('Expected one of "FalseAnonField" in loading "FalseAnonField", but data does not satisfy any constructor'); +} + +export function storeFalseAnonField(falseAnonField: FalseAnonField): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(0x0201, 16); + builder.storeInt(falseAnonField.value, 257); + }) + +} + +// a$0 a:Simple = ConstructorOrder; + +// _ Simple = ConstructorOrder; + +export function loadConstructorOrder(slice: Slice): ConstructorOrder { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let a: Simple = loadSimple(slice); + return { + kind: 'ConstructorOrder_a', + a: a, + } + + } + if (true) { + let anon0: Simple = loadSimple(slice); + return { + kind: 'ConstructorOrder__', + anon0: anon0, + } + + } + throw new Error('Expected one of "ConstructorOrder_a", "ConstructorOrder__" in loading "ConstructorOrder", but data does not satisfy any constructor'); +} + +export function storeConstructorOrder(constructorOrder: ConstructorOrder): (builder: Builder) => void { + if ((constructorOrder.kind == 'ConstructorOrder_a')) { + return ((builder: Builder) => { + builder.storeUint(0b0, 1); + storeSimple(constructorOrder.a)(builder); + }) + + } + if ((constructorOrder.kind == 'ConstructorOrder__')) { + return ((builder: Builder) => { + storeSimple(constructorOrder.anon0)(builder); + }) + + } + throw new Error('Expected one of "ConstructorOrder_a", "ConstructorOrder__" in loading "ConstructorOrder", but data does not satisfy any constructor'); +} + +// a a:# = CheckCrc32; + +// b b:# c:# = CheckCrc32; + +export function loadCheckCrc32(slice: Slice): CheckCrc32 { + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x9d97e7a))) { + slice.loadUint(32); + let a: number = slice.loadUint(32); + return { + kind: 'CheckCrc32_a', + a: a, + } + + } + if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x2842b3f0))) { + slice.loadUint(32); + let b: number = slice.loadUint(32); + let c: number = slice.loadUint(32); + return { + kind: 'CheckCrc32_b', + b: b, + c: c, + } + + } + throw new Error('Expected one of "CheckCrc32_a", "CheckCrc32_b" in loading "CheckCrc32", but data does not satisfy any constructor'); +} + +export function storeCheckCrc32(checkCrc32: CheckCrc32): (builder: Builder) => void { + if ((checkCrc32.kind == 'CheckCrc32_a')) { + return ((builder: Builder) => { + builder.storeUint(0x9d97e7a, 32); + builder.storeUint(checkCrc32.a, 32); + }) + + } + if ((checkCrc32.kind == 'CheckCrc32_b')) { + return ((builder: Builder) => { + builder.storeUint(0x2842b3f0, 32); + builder.storeUint(checkCrc32.b, 32); + builder.storeUint(checkCrc32.c, 32); + }) + + } + throw new Error('Expected one of "CheckCrc32_a", "CheckCrc32_b" in loading "CheckCrc32", but data does not satisfy any constructor'); +} + +// a$_ const:# = CheckKeyword; + +export function loadCheckKeyword(slice: Slice): CheckKeyword { + let const0: number = slice.loadUint(32); + return { + kind: 'CheckKeyword', + const0: const0, + } + +} + +export function storeCheckKeyword(checkKeyword: CheckKeyword): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(checkKeyword.const0, 32); + }) + +} + +// a$_ {X:Type} t:# y:(Maybe ^X) = RefCombinatorInRefHelper X; + +export function loadRefCombinatorInRefHelper(slice: Slice, loadX: (slice: Slice) => X): RefCombinatorInRefHelper { + let t: number = slice.loadUint(32); + let y: Maybe = loadMaybe(slice, ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadX(slice1) + + })); + return { + kind: 'RefCombinatorInRefHelper', + t: t, + y: y, + } + +} + +export function storeRefCombinatorInRefHelper(refCombinatorInRefHelper: RefCombinatorInRefHelper, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(refCombinatorInRefHelper.t, 32); + storeMaybe(refCombinatorInRefHelper.y, ((arg: X) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeX(arg)(cell1); + builder.storeRef(cell1); + + }) + + }))(builder); + }) + +} + +// a$_ msg:^(RefCombinatorInRefHelper Any) = RefCombinatorInRef; + +export function loadRefCombinatorInRef(slice: Slice): RefCombinatorInRef { + let slice1 = slice.loadRef().beginParse(); + let msg: RefCombinatorInRefHelper = loadRefCombinatorInRefHelper(slice1, ((slice: Slice) => { + return slice + + })); + return { + kind: 'RefCombinatorInRef', + msg: msg, + } + +} + +export function storeRefCombinatorInRef(refCombinatorInRef: RefCombinatorInRef): (builder: Builder) => void { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeRefCombinatorInRefHelper(refCombinatorInRef.msg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) + + }))(cell1); + builder.storeRef(cell1); + }) + +} + +// _ a:Bool = BoolUser; + +export function loadBoolUser(slice: Slice): BoolUser { + let a: boolean = slice.loadBoolean(); + return { + kind: 'BoolUser', + a: a, + } + +} + +export function storeBoolUser(boolUser: BoolUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(boolUser.a); + }) + +} + +/* +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +*/ + +export function loadAnycast(slice: Slice): Anycast { + let depth: number = slice.loadUint(bitLen(30)); + let rewrite_pfx: BitString = slice.loadBits(depth); + if ((!(depth >= 1))) { + throw new Error('Condition (depth >= 1) is not satisfied while loading "Anycast" for type "Anycast"'); + } + return { + kind: 'Anycast', + depth: depth, + rewrite_pfx: rewrite_pfx, + } + +} + +export function storeAnycast(anycast: Anycast): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(anycast.depth, bitLen(30)); + builder.storeBits(anycast.rewrite_pfx); + if ((!(anycast.depth >= 1))) { + throw new Error('Condition (anycast.depth >= 1) is not satisfied while loading "Anycast" for type "Anycast"'); + } + }) + +} + +// _ src:MsgAddressInt = AddressUser; + +export function loadAddressUser(slice: Slice): AddressUser { + let src: Address = slice.loadAddress(); + return { + kind: 'AddressUser', + src: src, + } + +} + +export function storeAddressUser(addressUser: AddressUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeAddress(addressUser.src); + }) + +} + diff --git a/test/tlb/block.tlb b/test/tlb/block.tlb new file mode 100644 index 0000000..5e6c602 --- /dev/null +++ b/test/tlb/block.tlb @@ -0,0 +1,938 @@ +unit$_ = Unit; +true$_ = True; +// EMPTY False; +bool_false$0 = Bool; +bool_true$1 = Bool; +bool_false$0 = BoolFalse; +bool_true$1 = BoolTrue; +nothing$0 {X:Type} = Maybe X; +just$1 {X:Type} value:X = Maybe X; +left$0 {X:Type} {Y:Type} value:X = Either X Y; +right$1 {X:Type} {Y:Type} value:Y = Either X Y; +pair$_ {X:Type} {Y:Type} first:X second:Y = Both X Y; + +bit$_ (## 1) = Bit; +/* + * + * FROM hashmap.tlb + * + */ +// ordinary Hashmap / HashmapE, with fixed length keys +// +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; + +hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; + +hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; +hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; +hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + +unary_zero$0 = Unary ~0; +unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + +hme_empty$0 {n:#} {X:Type} = HashmapE n X; +hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + +// true#_ = True; +_ {n:#} _:(Hashmap n True) = BitstringSet n; + +// HashmapAug, hashmap with an extra value +// (augmentation) of type Y at every node +// +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; + +ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y + = HashmapAugE n X Y; +ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) + extra:Y = HashmapAugE n X Y; + +// VarHashmap / VarHashmapE, with variable-length keys +// +vhm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(VarHashmapNode m X) + = VarHashmap n X; +vhmn_leaf$00 {n:#} {X:Type} value:X = VarHashmapNode n X; +vhmn_fork$01 {n:#} {X:Type} left:^(VarHashmap n X) + right:^(VarHashmap n X) value:(Maybe X) + = VarHashmapNode (n + 1) X; +vhmn_cont$1 {n:#} {X:Type} branch:Bit child:^(VarHashmap n X) + value:X = VarHashmapNode (n + 1) X; + +// nothing$0 {X:Type} = Maybe X; +// just$1 {X:Type} value:X = Maybe X; + +vhme_empty$0 {n:#} {X:Type} = VarHashmapE n X; +vhme_root$1 {n:#} {X:Type} root:^(VarHashmap n X) + = VarHashmapE n X; + +// +// PfxHashmap / PfxHashmapE, with variable-length keys +// constituting a prefix code +// + +phm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(PfxHashmapNode m X) + = PfxHashmap n X; + +phmn_leaf$0 {n:#} {X:Type} value:X = PfxHashmapNode n X; +phmn_fork$1 {n:#} {X:Type} left:^(PfxHashmap n X) + right:^(PfxHashmap n X) = PfxHashmapNode (n + 1) X; + +phme_empty$0 {n:#} {X:Type} = PfxHashmapE n X; +phme_root$1 {n:#} {X:Type} root:^(PfxHashmap n X) + = PfxHashmapE n X; +/* + * + * END hashmap.tlb + * + */ +// +// TON BLOCK LAYOUT +// +addr_none$00 = MsgAddressExt; +addr_extern$01 len:(## 9) external_address:(bits len) + = MsgAddressExt; +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +addr_std$10 anycast:(Maybe Anycast) + workchain_id:int8 address:bits256 = MsgAddressInt; +addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) + workchain_id:int32 address:(bits addr_len) = MsgAddressInt; +_ _:MsgAddressInt = MsgAddress; +_ _:MsgAddressExt = MsgAddress; +// +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; +var_int$_ {n:#} len:(#< n) value:(int (len * 8)) + = VarInteger n; +nanograms$_ amount:(VarUInteger 16) = Grams; + +_ grams:Grams = Coins; + +// +extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) + = ExtraCurrencyCollection; +currencies$_ grams:Grams other:ExtraCurrencyCollection + = CurrencyCollection; +// +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddressInt dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfo; +ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt + import_fee:Grams = CommonMsgInfo; +ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfo; + +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddress dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; +ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; + +tick_tock$_ tick:Bool tock:Bool = TickTock; + +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(Maybe ^Cell) = StateInit; + +// StateInitWithLibs is used to validate sent and received messages +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(HashmapE 256 SimpleLib) = StateInitWithLibs; + +simple_lib$_ public:Bool root:^Cell = SimpleLib; + +message$_ {X:Type} info:CommonMsgInfo + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = Message X; + +message$_ {X:Type} info:CommonMsgInfoRelaxed + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = MessageRelaxed X; + +_ (Message Any) = MessageAny; + +// +interm_addr_regular$0 use_dest_bits:(#<= 96) + = IntermediateAddress; +interm_addr_simple$10 workchain_id:int8 addr_pfx:uint64 + = IntermediateAddress; +interm_addr_ext$11 workchain_id:int32 addr_pfx:uint64 + = IntermediateAddress; +msg_envelope#4 cur_addr:IntermediateAddress + next_addr:IntermediateAddress fwd_fee_remaining:Grams + msg:^(Message Any) = MsgEnvelope; +// +msg_import_ext$000 msg:^(Message Any) transaction:^Transaction + = InMsg; +msg_import_ihr$010 msg:^(Message Any) transaction:^Transaction + ihr_fee:Grams proof_created:^Cell = InMsg; +msg_import_imm$011 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +msg_import_fin$100 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +msg_import_tr$101 in_msg:^MsgEnvelope out_msg:^MsgEnvelope + transit_fee:Grams = InMsg; +msg_discard_fin$110 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams = InMsg; +msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams proof_delivered:^Cell = InMsg; +// +import_fees$_ fees_collected:Grams + value_imported:CurrencyCollection = ImportFees; + +_ (HashmapAugE 256 InMsg ImportFees) = InMsgDescr; + +msg_export_ext$000 msg:^(Message Any) + transaction:^Transaction = OutMsg; +msg_export_imm$010 out_msg:^MsgEnvelope + transaction:^Transaction reimport:^InMsg = OutMsg; +msg_export_new$001 out_msg:^MsgEnvelope + transaction:^Transaction = OutMsg; +msg_export_tr$011 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +msg_export_deq$1100 out_msg:^MsgEnvelope + import_block_lt:uint63 = OutMsg; +msg_export_deq_short$1101 msg_env_hash:bits256 + next_workchain:int32 next_addr_pfx:uint64 + import_block_lt:uint64 = OutMsg; +msg_export_tr_req$111 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +msg_export_deq_imm$100 out_msg:^MsgEnvelope + reimport:^InMsg = OutMsg; + +_ enqueued_lt:uint64 out_msg:^MsgEnvelope = EnqueuedMsg; + +_ (HashmapAugE 256 OutMsg CurrencyCollection) = OutMsgDescr; + +_ (HashmapAugE 352 EnqueuedMsg uint64) = OutMsgQueue; + +processed_upto$_ last_msg_lt:uint64 last_msg_hash:bits256 = ProcessedUpto; +// key is [ shard:uint64 mc_seqno:uint32 ] +_ (HashmapE 96 ProcessedUpto) = ProcessedInfo; + +ihr_pending$_ import_lt:uint64 = IhrPendingSince; +_ (HashmapE 320 IhrPendingSince) = IhrPendingInfo; + +_ out_queue:OutMsgQueue proc_info:ProcessedInfo + ihr_pending:IhrPendingInfo = OutMsgQueueInfo; +// +storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7) + public_cells:(VarUInteger 7) = StorageUsed; + +storage_used_short$_ cells:(VarUInteger 7) + bits:(VarUInteger 7) = StorageUsedShort; + +storage_info$_ used:StorageUsed last_paid:uint32 + due_payment:(Maybe Grams) = StorageInfo; + +account_none$0 = Account; +account$1 addr:MsgAddressInt storage_stat:StorageInfo + storage:AccountStorage = Account; + +account_storage$_ last_trans_lt:uint64 + balance:CurrencyCollection state:AccountState + = AccountStorage; + +account_uninit$00 = AccountState; +account_active$1 _:StateInit = AccountState; +account_frozen$01 state_hash:bits256 = AccountState; + +acc_state_uninit$00 = AccountStatus; +acc_state_frozen$01 = AccountStatus; +acc_state_active$10 = AccountStatus; +acc_state_nonexist$11 = AccountStatus; + +/* duplicates +tick_tock$_ tick:Bool tock:Bool = TickTock; + +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(Maybe ^Cell) = StateInit; +*/ + +account_descr$_ account:^Account last_trans_hash:bits256 + last_trans_lt:uint64 = ShardAccount; + +depth_balance$_ split_depth:(#<= 30) balance:CurrencyCollection = DepthBalanceInfo; + +_ (HashmapAugE 256 ShardAccount DepthBalanceInfo) = ShardAccounts; + +transaction$0111 account_addr:bits256 lt:uint64 + prev_trans_hash:bits256 prev_trans_lt:uint64 now:uint32 + outmsg_cnt:uint15 + orig_status:AccountStatus end_status:AccountStatus + ^[ in_msg:(Maybe ^(Message Any)) out_msgs:(HashmapE 15 ^(Message Any)) ] + total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account) + description:^TransactionDescr = Transaction; + +merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 + old:^X new:^X = MERKLE_UPDATE X; +update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256 + = HASH_UPDATE X; +merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; + +acc_trans#5 account_addr:bits256 + transactions:(HashmapAug 64 ^Transaction CurrencyCollection) + state_update:^(HASH_UPDATE Account) + = AccountBlock; + +_ (HashmapAugE 256 AccountBlock CurrencyCollection) = ShardAccountBlocks; +// +tr_phase_storage$_ storage_fees_collected:Grams + storage_fees_due:(Maybe Grams) + status_change:AccStatusChange + = TrStoragePhase; + +acst_unchanged$0 = AccStatusChange; // x -> x +acst_frozen$10 = AccStatusChange; // init -> frozen +acst_deleted$11 = AccStatusChange; // frozen -> deleted + +tr_phase_credit$_ due_fees_collected:(Maybe Grams) + credit:CurrencyCollection = TrCreditPhase; + +tr_phase_compute_skipped$0 reason:ComputeSkipReason + = TrComputePhase; +tr_phase_compute_vm$1 success:Bool msg_state_used:Bool + account_activated:Bool gas_fees:Grams + ^[ gas_used:(VarUInteger 7) + gas_limit:(VarUInteger 7) gas_credit:(Maybe (VarUInteger 3)) + mode:int8 exit_code:int32 exit_arg:(Maybe int32) + vm_steps:uint32 + vm_init_state_hash:bits256 vm_final_state_hash:bits256 ] + = TrComputePhase; +cskip_no_state$00 = ComputeSkipReason; +cskip_bad_state$01 = ComputeSkipReason; +cskip_no_gas$10 = ComputeSkipReason; +cskip_suspended$110 = ComputeSkipReason; + +tr_phase_action$_ success:Bool valid:Bool no_funds:Bool + status_change:AccStatusChange + total_fwd_fees:(Maybe Grams) total_action_fees:(Maybe Grams) + result_code:int32 result_arg:(Maybe int32) tot_actions:uint16 + spec_actions:uint16 skipped_actions:uint16 msgs_created:uint16 + action_list_hash:bits256 tot_msg_size:StorageUsedShort + = TrActionPhase; + +tr_phase_bounce_negfunds$00 = TrBouncePhase; +tr_phase_bounce_nofunds$01 msg_size:StorageUsedShort + req_fwd_fees:Grams = TrBouncePhase; +tr_phase_bounce_ok$1 msg_size:StorageUsedShort + msg_fees:Grams fwd_fees:Grams = TrBouncePhase; +// +trans_ord$0000 credit_first:Bool + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool bounce:(Maybe TrBouncePhase) + destroyed:Bool + = TransactionDescr; + +trans_storage$0001 storage_ph:TrStoragePhase + = TransactionDescr; + +trans_tick_tock$001 is_tock:Bool storage_ph:TrStoragePhase + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool = TransactionDescr; +// +split_merge_info$_ cur_shard_pfx_len:(## 6) + acc_split_depth:(## 6) this_addr:bits256 sibling_addr:bits256 + = SplitMergeInfo; +trans_split_prepare$0100 split_info:SplitMergeInfo + storage_ph:(Maybe TrStoragePhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; +trans_split_install$0101 split_info:SplitMergeInfo + prepare_transaction:^Transaction + installed:Bool = TransactionDescr; + +trans_merge_prepare$0110 split_info:SplitMergeInfo + storage_ph:TrStoragePhase aborted:Bool + = TransactionDescr; +trans_merge_install$0111 split_info:SplitMergeInfo + prepare_transaction:^Transaction + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; + +smc_info#076ef1ea actions:uint16 msgs_sent:uint16 + unixtime:uint32 block_lt:uint64 trans_lt:uint64 + rand_seed:bits256 balance_remaining:CurrencyCollection + myself:MsgAddressInt global_config:(Maybe Cell) = SmartContractInfo; +// +// +out_list_empty$_ = OutList 0; +out_list$_ {n:#} prev:^(OutList n) action:OutAction + = OutList (n + 1); +action_send_msg#0ec3c86d mode:(## 8) + out_msg:^(MessageRelaxed Any) = OutAction; +action_set_code#ad4de08e new_code:^Cell = OutAction; +action_reserve_currency#36e6b809 mode:(## 8) + currency:CurrencyCollection = OutAction; +libref_hash$0 lib_hash:bits256 = LibRef; +libref_ref$1 library:^Cell = LibRef; +action_change_library#26fa1dd4 mode:(## 7) + libref:LibRef = OutAction; + +out_list_node$_ prev:^Cell action:OutAction = OutListNode; +// +// +shard_ident$00 shard_pfx_bits:(#<= 60) + workchain_id:int32 shard_prefix:uint64 = ShardIdent; + +ext_blk_ref$_ end_lt:uint64 + seq_no:uint32 root_hash:bits256 file_hash:bits256 + = ExtBlkRef; + +block_id_ext$_ shard_id:ShardIdent seq_no:uint32 + root_hash:bits256 file_hash:bits256 = BlockIdExt; + +master_info$_ master:ExtBlkRef = BlkMasterInfo; + +shard_state#9023afe2 global_id:int32 + shard_id:ShardIdent + seq_no:uint32 vert_seq_no:# + gen_utime:uint32 gen_lt:uint64 + min_ref_mc_seqno:uint32 + out_msg_queue_info:^OutMsgQueueInfo + before_split:(## 1) + accounts:^ShardAccounts + ^[ overload_history:uint64 underload_history:uint64 + total_balance:CurrencyCollection + total_validator_fees:CurrencyCollection + libraries:(HashmapE 256 LibDescr) + master_ref:(Maybe BlkMasterInfo) ] + custom:(Maybe ^McStateExtra) + = ShardStateUnsplit; + +_ ShardStateUnsplit = ShardState; +split_state#5f327da5 left:^ShardStateUnsplit right:^ShardStateUnsplit = ShardState; + +shared_lib_descr$00 lib:^Cell publishers:(Hashmap 256 True) + = LibDescr; + +block_info#9bc7a987 version:uint32 + not_master:(## 1) + after_merge:(## 1) before_split:(## 1) + after_split:(## 1) + want_split:Bool want_merge:Bool + key_block:Bool vert_seqno_incr:(## 1) + flags:(## 8) { flags <= 1 } + seq_no:# vert_seq_no:# { vert_seq_no >= vert_seqno_incr } + { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } + shard:ShardIdent gen_utime:uint32 + start_lt:uint64 end_lt:uint64 + gen_validator_list_hash_short:uint32 + gen_catchain_seqno:uint32 + min_ref_mc_seqno:uint32 + prev_key_block_seqno:uint32 + gen_software:flags . 0?GlobalVersion + master_ref:not_master?^BlkMasterInfo + prev_ref:^(BlkPrevInfo after_merge) + prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0) + = BlockInfo; + +prev_blk_info$_ prev:ExtBlkRef = BlkPrevInfo 0; +prev_blks_info$_ prev1:^ExtBlkRef prev2:^ExtBlkRef = BlkPrevInfo 1; + +block#11ef55aa global_id:int32 + info:^BlockInfo value_flow:^ValueFlow + state_update:^(MERKLE_UPDATE ShardState) + extra:^BlockExtra = Block; + +block_extra in_msg_descr:^InMsgDescr + out_msg_descr:^OutMsgDescr + account_blocks:^ShardAccountBlocks + rand_seed:bits256 + created_by:bits256 + custom:(Maybe ^McBlockExtra) = BlockExtra; +// +value_flow#b8e48dfb ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; + +value_flow_v2#3ebf98b7 ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + burned:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; + +// +// +bt_leaf$0 {X:Type} leaf:X = BinTree X; +bt_fork$1 {X:Type} left:^(BinTree X) right:^(BinTree X) + = BinTree X; + +fsm_none$0 = FutureSplitMerge; +fsm_split$10 split_utime:uint32 interval:uint32 = FutureSplitMerge; +fsm_merge$11 merge_utime:uint32 interval:uint32 = FutureSplitMerge; + +shard_descr#b seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + fees_collected:CurrencyCollection + funds_created:CurrencyCollection = ShardDescr; + +shard_descr_new#a seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + ^[ fees_collected:CurrencyCollection + funds_created:CurrencyCollection ] = ShardDescr; + +_ (HashmapE 32 ^(BinTree ShardDescr)) = ShardHashes; + +bta_leaf$0 {X:Type} {Y:Type} extra:Y leaf:X = BinTreeAug X Y; +bta_fork$1 {X:Type} {Y:Type} left:^(BinTreeAug X Y) + right:^(BinTreeAug X Y) extra:Y = BinTreeAug X Y; + +_ fees:CurrencyCollection create:CurrencyCollection = ShardFeeCreated; +_ (HashmapAugE 96 ShardFeeCreated ShardFeeCreated) = ShardFees; + +_ config_addr:bits256 config:^(Hashmap 32 ^Cell) + = ConfigParams; + +validator_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 + nx_cc_updated:Bool += ValidatorInfo; + +validator_base_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 += ValidatorBaseInfo; + +_ key:Bool max_end_lt:uint64 = KeyMaxLt; +_ key:Bool blk_ref:ExtBlkRef = KeyExtBlkRef; + +_ (HashmapAugE 32 KeyExtBlkRef KeyMaxLt) = OldMcBlocksInfo; + + +counters#_ last_updated:uint32 total:uint64 cnt2048:uint64 cnt65536:uint64 = Counters; +creator_info#4 mc_blocks:Counters shard_blocks:Counters = CreatorStats; +block_create_stats#17 counters:(HashmapE 256 CreatorStats) = BlockCreateStats; +block_create_stats_ext#34 counters:(HashmapAugE 256 CreatorStats uint32) = BlockCreateStats; + +masterchain_state_extra#cc26 + shard_hashes:ShardHashes + config:ConfigParams + ^[ flags:(## 16) { flags <= 1 } + validator_info:ValidatorInfo + prev_blocks:OldMcBlocksInfo + after_key_block:Bool + last_key_block:(Maybe ExtBlkRef) + block_create_stats:(flags . 0)?BlockCreateStats ] + global_balance:CurrencyCollection += McStateExtra; + +ed25519_pubkey#8e81278a pubkey:bits256 = SigPubKey; // 288 bits +ed25519_signature#5 R:bits256 s:bits256 = CryptoSignatureSimple; // 516 bits +_ CryptoSignatureSimple = CryptoSignature; +sig_pair$_ node_id_short:bits256 sign:CryptoSignature = CryptoSignaturePair; // 256+x ~ 772 bits + +certificate#4 temp_key:SigPubKey valid_since:uint32 valid_until:uint32 = Certificate; // 356 bits +certificate_env#a419b7d certificate:Certificate = CertificateEnv; // 384 bits +signed_certificate$_ certificate:Certificate certificate_signature:CryptoSignature + = SignedCertificate; // 356+516 = 872 bits +// certificate_signature is the signature of CertificateEnv (with embedded certificate) with persistent key +chained_signature#f signed_cert:^SignedCertificate temp_key_signature:CryptoSignatureSimple + = CryptoSignature; // 4+(356+516)+516 = 520 bits+ref (1392 bits total) +// temp_key_signature is the signature of whatever was originally intended to be signed with temp_key from certificate + +masterchain_block_extra#cca5 + key_block:(## 1) + shard_hashes:ShardHashes + shard_fees:ShardFees + ^[ prev_blk_signatures:(HashmapE 16 CryptoSignaturePair) + recover_create_msg:(Maybe ^InMsg) + mint_msg:(Maybe ^InMsg) ] + config:key_block?ConfigParams += McBlockExtra; + +// +// CONFIGURATION PARAMETERS +// + +validator#53 public_key:SigPubKey weight:uint64 = ValidatorDescr; +validator_addr#73 public_key:SigPubKey weight:uint64 adnl_addr:bits256 = ValidatorDescr; +validators#11 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + list:(Hashmap 16 ValidatorDescr) = ValidatorSet; +validators_ext#12 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + total_weight:uint64 list:(HashmapE 16 ValidatorDescr) = ValidatorSet; + +_ config_addr:bits256 = ConfigParam 0; +_ elector_addr:bits256 = ConfigParam 1; +_ minter_addr:bits256 = ConfigParam 2; // ConfigParam 0 is used if absent +_ fee_collector_addr:bits256 = ConfigParam 3; // ConfigParam 1 is used if absent +_ dns_root_addr:bits256 = ConfigParam 4; // root TON DNS resolver + +burning_config#01 + blackhole_addr:(Maybe bits256) + fee_burn_num:# fee_burn_denom:# { fee_burn_num <= fee_burn_denom } { fee_burn_denom >= 1 } = BurningConfig; +_ BurningConfig = ConfigParam 5; + +_ mint_new_price:Grams mint_add_price:Grams = ConfigParam 6; +_ to_mint:ExtraCurrencyCollection = ConfigParam 7; + +capabilities#c4 version:uint32 capabilities:uint64 = GlobalVersion; +_ GlobalVersion = ConfigParam 8; // all zero if absent +_ mandatory_params:(Hashmap 32 True) = ConfigParam 9; +_ critical_params:(Hashmap 32 True) = ConfigParam 10; + +cfg_vote_cfg#36 min_tot_rounds:uint8 max_tot_rounds:uint8 min_wins:uint8 max_losses:uint8 min_store_sec:uint32 max_store_sec:uint32 bit_price:uint32 cell_price:uint32 = ConfigProposalSetup; +cfg_vote_setup#91 normal_params:^ConfigProposalSetup critical_params:^ConfigProposalSetup = ConfigVotingSetup; +_ ConfigVotingSetup = ConfigParam 11; + +cfg_proposal#f3 param_id:int32 param_value:(Maybe ^Cell) if_hash_equal:(Maybe uint256) + = ConfigProposal; +cfg_proposal_status#ce expires:uint32 proposal:^ConfigProposal is_critical:Bool + voters:(HashmapE 16 True) remaining_weight:int64 validator_set_id:uint256 + rounds_remaining:uint8 wins:uint8 losses:uint8 = ConfigProposalStatus; + +wfmt_basic#1 vm_version:int32 vm_mode:uint64 = WorkchainFormat 1; +wfmt_ext#0 min_addr_len:(## 12) max_addr_len:(## 12) addr_len_step:(## 12) + { min_addr_len >= 64 } { min_addr_len <= max_addr_len } + { max_addr_len <= 1023 } { addr_len_step <= 1023 } + workchain_type_id:(## 32) { workchain_type_id >= 1 } + = WorkchainFormat 0; + +wc_split_merge_timings#0 + split_merge_delay:uint32 split_merge_interval:uint32 + min_split_merge_interval:uint32 max_split_merge_delay:uint32 + = WcSplitMergeTimings; + +//workchain#a5 enabled_since:uint32 min_split:(## 8) max_split:(## 8) +// { min_split <= max_split } { max_split <= 60 } + +workchain#a6 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + = WorkchainDescr; + +workchain_v2#a7 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + split_merge_timings:WcSplitMergeTimings + = WorkchainDescr; + +_ workchains:(HashmapE 32 WorkchainDescr) = ConfigParam 12; + +complaint_prices#1a deposit:Grams bit_price:Grams cell_price:Grams = ComplaintPricing; +_ ComplaintPricing = ConfigParam 13; + +block_grams_created#6b masterchain_block_fee:Grams basechain_block_fee:Grams + = BlockCreateFees; +_ BlockCreateFees = ConfigParam 14; + +_ validators_elected_for:uint32 elections_start_before:uint32 + elections_end_before:uint32 stake_held_for:uint32 + = ConfigParam 15; + +_ max_validators:(## 16) max_main_validators:(## 16) min_validators:(## 16) + { max_validators >= max_main_validators } + { max_main_validators >= min_validators } + { min_validators >= 1 } + = ConfigParam 16; + +_ min_stake:Grams max_stake:Grams min_total_stake:Grams max_stake_factor:uint32 = ConfigParam 17; + +_#cc utime_since:uint32 bit_price_ps:uint64 cell_price_ps:uint64 + mc_bit_price_ps:uint64 mc_cell_price_ps:uint64 = StoragePrices; +_ (Hashmap 32 StoragePrices) = ConfigParam 18; + +_ global_id:int32 = ConfigParam 19; + +gas_prices#dd gas_price:uint64 gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; + +gas_prices_ext#de gas_price:uint64 gas_limit:uint64 special_gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; + +gas_flat_pfx#d1 flat_gas_limit:uint64 flat_gas_price:uint64 other:GasLimitsPrices + = GasLimitsPrices; + +config_mc_gas_prices#_ GasLimitsPrices = ConfigParam 20; +config_gas_prices#_ GasLimitsPrices = ConfigParam 21; + +param_limits#c3 underload:# soft_limit:# { underload <= soft_limit } + hard_limit:# { soft_limit <= hard_limit } = ParamLimits; +block_limits#5d bytes:ParamLimits gas:ParamLimits lt_delta:ParamLimits + = BlockLimits; + +config_mc_block_limits#_ BlockLimits = ConfigParam 22; +config_block_limits#_ BlockLimits = ConfigParam 23; + +// msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16)) nanograms +// ihr_fwd_fees = ceil((msg_fwd_fees * ihr_price_factor)/2^16) nanograms +// bits in the root cell of a message are not included in msg.bits (lump_price pays for them) +msg_forward_prices#ea lump_price:uint64 bit_price:uint64 cell_price:uint64 + ihr_price_factor:uint32 first_frac:uint16 next_frac:uint16 = MsgForwardPrices; + +// used for messages to/from masterchain +config_mc_fwd_prices#_ MsgForwardPrices = ConfigParam 24; +// used for all other messages +config_fwd_prices#_ MsgForwardPrices = ConfigParam 25; + +catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; + +catchain_config_new#c2 flags:(## 7) { flags = 0 } shuffle_mc_validators:Bool + mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; + +consensus_config#d6 round_candidates:# { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; + +consensus_config_new#d7 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; + +consensus_config_v3#d8 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 = ConsensusConfig; + +consensus_config_v4#d9 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 catchain_max_blocks_coeff:uint32 = ConsensusConfig; + +_ CatchainConfig = ConfigParam 28; +_ ConsensusConfig = ConfigParam 29; + +_ fundamental_smc_addr:(HashmapE 256 True) = ConfigParam 31; +_ prev_validators:ValidatorSet = ConfigParam 32; +_ prev_temp_validators:ValidatorSet = ConfigParam 33; +_ cur_validators:ValidatorSet = ConfigParam 34; +_ cur_temp_validators:ValidatorSet = ConfigParam 35; +_ next_validators:ValidatorSet = ConfigParam 36; +_ next_temp_validators:ValidatorSet = ConfigParam 37; + +validator_temp_key#3 adnl_addr:bits256 temp_public_key:SigPubKey seqno:# valid_until:uint32 = ValidatorTempKey; +signed_temp_key#4 key:^ValidatorTempKey signature:CryptoSignature = ValidatorSignedTempKey; +_ (HashmapE 256 ValidatorSignedTempKey) = ConfigParam 39; + +misbehaviour_punishment_config_v1#01 + default_flat_fine:Grams default_proportional_fine:uint32 + severity_flat_mult:uint16 severity_proportional_mult:uint16 + unpunishable_interval:uint16 + long_interval:uint16 long_flat_mult:uint16 long_proportional_mult:uint16 + medium_interval:uint16 medium_flat_mult:uint16 medium_proportional_mult:uint16 + = MisbehaviourPunishmentConfig; +_ MisbehaviourPunishmentConfig = ConfigParam 40; + +size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig; +size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32 + max_acc_public_libraries:uint32 = SizeLimitsConfig; +_ SizeLimitsConfig = ConfigParam 43; + +// key is [ wc:int32 addr:uint256 ] +suspended_address_list#00 addresses:(HashmapE 288 Unit) suspended_until:uint32 = SuspendedAddressList; +_ SuspendedAddressList = ConfigParam 44; + +oracle_bridge_params#_ bridge_address:bits256 oracle_mutlisig_address:bits256 oracles:(HashmapE 256 uint256) external_chain_address:bits256 = OracleBridgeParams; +_ OracleBridgeParams = ConfigParam 71; // Ethereum bridge +_ OracleBridgeParams = ConfigParam 72; // Binance Smart Chain bridge +_ OracleBridgeParams = ConfigParam 73; // Polygon bridge + +// Note that chains in which bridge, minter and jetton-wallet operate are fixated +jetton_bridge_prices#_ bridge_burn_fee:Coins bridge_mint_fee:Coins + wallet_min_tons_for_storage:Coins + wallet_gas_consumption:Coins + minter_min_tons_for_storage:Coins + discover_gas_consumption:Coins = JettonBridgePrices; + +jetton_bridge_params_v0#00 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 burn_bridge_fee:Coins = JettonBridgeParams; +jetton_bridge_params_v1#01 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 prices:^JettonBridgePrices external_chain_address:bits256 = JettonBridgeParams; + +_ JettonBridgeParams = ConfigParam 79; // ETH->TON token bridge +_ JettonBridgeParams = ConfigParam 81; // BNB->TON token bridge +_ JettonBridgeParams = ConfigParam 82; // Polygon->TON token bridge + + +// +// PROOFS +// +block_signatures_pure#_ sig_count:uint32 sig_weight:uint64 + signatures:(HashmapE 16 CryptoSignaturePair) = BlockSignaturesPure; +block_signatures#11 validator_info:ValidatorBaseInfo pure_signatures:BlockSignaturesPure = BlockSignatures; +block_proof#c3 proof_for:BlockIdExt root:^Cell signatures:(Maybe ^BlockSignatures) = BlockProof; + +chain_empty$_ = ProofChain 0; +chain_link$_ {n:#} root:^Cell prev:n?^(ProofChain n) = ProofChain (n + 1); +top_block_descr#d5 proof_for:BlockIdExt signatures:(Maybe ^BlockSignatures) + len:(## 8) { len >= 1 } { len <= 8 } chain:(ProofChain len) = TopBlockDescr; + +// +// COLLATED DATA +// +top_block_descr_set#4ac789f3 collection:(HashmapE 96 ^TopBlockDescr) = TopBlockDescrSet; + +// +// VALIDATOR MISBEHAVIOR COMPLAINTS +// +prod_info#34 utime:uint32 mc_blk_ref:ExtBlkRef state_proof:^(MERKLE_PROOF Block) + prod_proof:^(MERKLE_PROOF ShardState) = ProducerInfo; +no_blk_gen from_utime:uint32 prod_info:^ProducerInfo = ComplaintDescr; +no_blk_gen_diff prod_info_old:^ProducerInfo prod_info_new:^ProducerInfo = ComplaintDescr; +validator_complaint#bc validator_pubkey:bits256 description:^ComplaintDescr created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint; +complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus; + +// +// TVM REFLECTION +// +vm_stk_null#00 = VmStackValue; +vm_stk_tinyint#01 value:int64 = VmStackValue; +vm_stk_int#0201_ value:int257 = VmStackValue; +vm_stk_nan#02ff = VmStackValue; +vm_stk_cell#03 cell:^Cell = VmStackValue; +_ cell:^Cell st_bits:(## 10) end_bits:(## 10) { st_bits <= end_bits } + st_ref:(#<= 4) end_ref:(#<= 4) { st_ref <= end_ref } = VmCellSlice; +vm_stk_slice#04 _:VmCellSlice = VmStackValue; +vm_stk_builder#05 cell:^Cell = VmStackValue; +vm_stk_cont#06 cont:VmCont = VmStackValue; +vm_tupref_nil$_ = VmTupleRef 0; +vm_tupref_single$_ entry:^VmStackValue = VmTupleRef 1; +vm_tupref_any$_ {n:#} ref:^(VmTuple (n + 2)) = VmTupleRef (n + 2); +vm_tuple_nil$_ = VmTuple 0; +vm_tuple_tcons$_ {n:#} head:(VmTupleRef n) tail:^VmStackValue = VmTuple (n + 1); +vm_stk_tuple#07 len:(## 16) data:(VmTuple len) = VmStackValue; + +vm_stack#_ depth:(## 24) stack:(VmStackList depth) = VmStack; +vm_stk_cons#_ {n:#} rest:^(VmStackList n) tos:VmStackValue = VmStackList (n + 1); +vm_stk_nil#_ = VmStackList 0; + +_ cregs:(HashmapE 4 VmStackValue) = VmSaveList; +gas_limits#_ remaining:int64 _:^[ max_limit:int64 cur_limit:int64 credit:int64 ] + = VmGasLimits; +_ libraries:(HashmapE 256 ^Cell) = VmLibraries; + +vm_ctl_data$_ nargs:(Maybe uint13) stack:(Maybe VmStack) save:VmSaveList +cp:(Maybe int16) = VmControlData; +vmc_std$00 cdata:VmControlData code:VmCellSlice = VmCont; +vmc_envelope$01 cdata:VmControlData next:^VmCont = VmCont; +vmc_quit$1000 exit_code:int32 = VmCont; +vmc_quit_exc$1001 = VmCont; +vmc_repeat$10100 count:uint63 body:^VmCont after:^VmCont = VmCont; +vmc_until$110000 body:^VmCont after:^VmCont = VmCont; +vmc_again$110001 body:^VmCont = VmCont; +vmc_while_cond$110010 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +vmc_while_body$110011 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +vmc_pushint$1111 value:int32 next:^VmCont = VmCont; + +// +// DNS RECORDS +// +_ (HashmapE 256 ^DNSRecord) = DNS_RecordSet; + +chunk_ref$_ {n:#} ref:^(TextChunks (n + 1)) = TextChunkRef (n + 1); +chunk_ref_empty$_ = TextChunkRef 0; +text_chunk$_ {n:#} len:(## 8) data:(bits (len * 8)) next:(TextChunkRef n) = TextChunks (n + 1); +text_chunk_empty$_ = TextChunks 0; +text$_ chunks:(## 8) rest:(TextChunks chunks) = Text; +dns_text#1eda _:Text = DNSRecord; + +dns_next_resolver#ba93 resolver:MsgAddressInt = DNSRecord; // usually in record #-1 + +dns_adnl_address#ad01 adnl_addr:bits256 flags:(## 8) { flags <= 1 } + proto_list:flags . 0?ProtoList = DNSRecord; // often in record #2 +proto_list_nil$0 = ProtoList; +proto_list_next$1 head:Protocol tail:ProtoList = ProtoList; +proto_http#4854 = Protocol; + +dns_smc_address#9fd3 smc_addr:MsgAddressInt flags:(## 8) { flags <= 1 } + cap_list:flags . 0?SmcCapList = DNSRecord; // often in record #1 +cap_list_nil$0 = SmcCapList; +cap_list_next$1 head:SmcCapability tail:SmcCapList = SmcCapList; +cap_method_seqno#5371 = SmcCapability; +cap_method_pubkey#71f4 = SmcCapability; +cap_is_wallet#2177 = SmcCapability; +cap_name#ff name:Text = SmcCapability; + +dns_storage_address#7473 bag_id:bits256 = DNSRecord; + +// +// PAYMENT CHANNELS +// + +chan_config$_ init_timeout:uint32 close_timeout:uint32 a_key:bits256 b_key:bits256 + a_addr:^MsgAddressInt b_addr:^MsgAddressInt channel_id:uint64 min_A_extra:Grams = ChanConfig; + +chan_state_init$000 signed_A:Bool signed_B:Bool min_A:Grams min_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; +chan_state_close$001 signed_A:Bool signed_B:Bool promise_A:Grams promise_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; +chan_state_payout$010 A:Grams B:Grams = ChanState; + +chan_promise$_ channel_id:uint64 promise_A:Grams promise_B:Grams = ChanPromise; +chan_signed_promise#_ sig:(Maybe ^bits512) promise:ChanPromise = ChanSignedPromise; + +chan_msg_init#27317822 inc_A:Grams inc_B:Grams min_A:Grams min_B:Grams channel_id:uint64 = ChanMsg; +chan_msg_close#f28ae183 extra_A:Grams extra_B:Grams promise:ChanSignedPromise = ChanMsg; +chan_msg_timeout#43278a28 = ChanMsg; +chan_msg_payout#37fe7810 = ChanMsg; + +chan_signed_msg$_ sig_A:(Maybe ^bits512) sig_B:(Maybe ^bits512) msg:ChanMsg = ChanSignedMsg; + +chan_op_cmd#912838d1 msg:ChanSignedMsg = ChanOp; + + +chan_data$_ config:^ChanConfig state:^ChanState = ChanData; \ No newline at end of file diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb new file mode 100644 index 0000000..60cf64f --- /dev/null +++ b/test/tlb/test.tlb @@ -0,0 +1,140 @@ +tmpa$_ a:# b:# = Simple; + +bool_false$0 a:# b:(## 7) c:# = TwoConstructors; +bool_true$1 b:# = TwoConstructors; + +tmpb$_ y:(## 5) = FixedIntParam; +tmpc$_ y:FixedIntParam c:# = TypedField; +tmpd#_ y:FixedIntParam c:# = SharpConstructor; + +nothing$0 {TheType:Type} = Maybe TheType; +just$1 {TheType:Type} value:TheType = Maybe TheType; +thejust$_ x:(Maybe SharpConstructor) = TypedParam; + +left$0 {X:Type} {Y:Type} value:X = Either X Y; +right$1 {X:Type} {Y:Type} value:Y = Either X Y; + +a$_ {x:#} value:(## x) = BitLenArg x; +a$_ t:(BitLenArg 4) = BitLenArgUser; + +a$_ {x:#} value:(## x) = ExprArg (2 + x); +a$_ t:(ExprArg 6) = ExprArgUser; + +a$_ a:ExprArgUser = ComplexTypedField; +a$_ a:^ExprArgUser = CellTypedField; + +a$_ t:# ^[ q:# ] ^[ a:(## 32) ^[ e:# ] ^[ b:(## 32) d:# ^[ c:(## 32) ] ] ] = CellsSimple; + +b$_ d:int11 g:bits2 {Arg:Type} arg:Arg x:Any = IntBits Arg; +a$_ {x:#} a:(IntBits (int (1 + x))) = IntBitsInside (x * 2); +a$_ x:(IntBitsInside 6) = IntBitsOutside; + +a$_ {e:#} h:(int (e * 8)) f:(uint (7 * e)) i:(bits (5 + e)) j:(int 5) k:(uint e) tc:Cell = IntBitsParametrized e; +a$_ {x:#} a:(IntBitsParametrized x) = IntBitsParametrizedInside x; +a$_ x:(IntBitsParametrizedInside 5) = IntBitsParametrizedOutside; + +a$_ x:(#< 4) y:(#<= 4) = LessThan; + +a$_ {A:Type} t:# x:A = OneComb A; +a$_ y:(OneComb(OneComb(OneComb int3))) = ManyComb; + +unary_zero$0 = Unary ~0; +unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + +a$_ n:# = ParamConst 1 1; +b$01 m:# k:# = ParamConst 2 1; +c$01 n:# m:# k:# = ParamConst 3 3; +d$_ n:# m:# k:# l:# = ParamConst 4 2; + +a$0 = ParamDifNames 2 ~1; +b$1 = ParamDifNames 3 ~1; +c$1 {n:#} x:(ParamDifNames 2 ~n) = ParamDifNames 2 ~(n + 1); +d$0 {m:#} x:(ParamDifNames 3 ~m) = ParamDifNames 3 ~(m * 2); +e$0 {k:#} x:(ParamDifNames 2 ~k) = ParamDifNamesUser; + +b$1 {y:#} t:# z:# { t = (~y) * 2} = NegationFromImplicit ~(y + 1); + +hm_edge#_ {l:#} {m:#} label:(Unary ~l) {7 = (~m) + l} = UnaryUserCheckOrder; + +a$_ {X:Type} info:int32 + init:(Maybe (Either X ^int22)) + other:(Either X ^(OneComb X)) + body:(Either X ^X) = CombArgCellRef X; +a$_ x:(CombArgCellRef int12) = CombArgCellRefUser; + +a$_ {n:#} ref:^(BitLenArg (n + 2)) = MathExprAsCombArg (n + 2); + +_ a:# = EmptyTag; + +a#f4 x:# = SharpTag; +a$1011 x:# = DollarTag; + +a$_ s:(3 * int5) = TupleCheck; + +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; + +hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; + +hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; +hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; +hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + +hme_empty$0 {n:#} {X:Type} = HashmapE n X; +hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + +a$_ x:(HashmapE 8 uint16) = HashmapEUser; + +_ a:(## 1) b:a?(## 32) = ConditionalField; + +_ a:(## 6) b:(a . 2)?(## 32) = BitSelection; + +_ flags:(## 10) { flags <= 100 } = ImplicitCondition; + +_ a:# = MultipleEmptyConstructor 0; +_ b:(## 5) = MultipleEmptyConstructor 1; +a$_ x:(## 6) = MultipleEmptyConstructor 2; + +true$_ = True; + +a$0 {n:#} = ParamNamedArgInSecondConstr n; +b$1 {n:#} = ParamNamedArgInSecondConstr (n + 1); + +a$_ msg:^(Maybe Any) = RefCombinatorAny; + +a$_ n:# { 5 + n = 7 } = EqualityExpression; + +a$_ x:(## 1) y:x?^Simple = ConditionalRef; + +block_info#9bc7a987 seq_no:# { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } = LoadFromNegationOutsideExpr; + +bit$_ (## 1) anon0:# = AnonymousData; + +vm_stk_int#0201_ value:int257 = FalseAnonField; + +_ Simple = ConstructorOrder; +a$0 a:Simple = ConstructorOrder; + +a a:# = CheckCrc32; +b b:# c:# = CheckCrc32; + +a$_ const:# = CheckKeyword; + +a$_ {X:Type} t:# y:(Maybe ^X) = RefCombinatorInRefHelper X; +a$_ msg:^(RefCombinatorInRefHelper Any) = RefCombinatorInRef; + +bool_false$0 = Bool; +bool_true$1 = Bool; + +_ a:Bool = BoolUser; + +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +addr_std$10 anycast:(Maybe Anycast) + workchain_id:int8 address:bits256 = MsgAddressInt; +addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) + workchain_id:int32 address:(bits addr_len) = MsgAddressInt; + +_ src:MsgAddressInt = AddressUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts new file mode 100644 index 0000000..5b6f21b --- /dev/null +++ b/test/tlbgen.spec.ts @@ -0,0 +1,506 @@ +import path from 'path'; + +import { Address, BitString, Cell, Slice } from 'ton'; + +import { describe, expect, test } from '@jest/globals'; +import { beginCell } from 'ton'; +import { loadBlock, storeBlock } from './generated_files/generated_block'; +import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeHashmapEUser, 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 } from './generated_files/generated_test'; + +const fixturesDir = path.resolve(__dirname, 'fixtures'); + +function deepEqual(object1: any, object2: any) { + if (object1 instanceof BitString && object2 instanceof BitString) { + return object1.equals(object2); + } + if (object1 instanceof Slice && object2 instanceof Slice) { + return object1.toString() == object2.toString(); + } + if (object1 instanceof Address && object2 instanceof Address) { + return object1.equals(object2); + } + + const keys1 = Object.keys(object1); + const keys2 = Object.keys(object2); + + if (keys1.length !== keys2.length) { + return false; + } + + for (const key of keys1) { + const val1 = object1[key]; + const val2 = object2[key]; + const areObjects = isObject(val1) && isObject(val2); + if ( + areObjects && !deepEqual(val1, val2) || + !areObjects && val1 !== val2 + ) { + return false; + } + } + + return true; +} + +function isObject(object: any) { + return object != null && typeof object === 'object'; +} + +function checkSameOnStoreLoad(expected: any, load: any, store: any, expectCell?: any) { + let cell = beginCell(); + store(expected)(cell); + let slice = cell.endCell().beginParse(); + if (expectCell) { + expectCell(slice) + } + let actual = load(slice) + expect(deepEqual(expected, actual)).toBeTruthy() +} + +function checkDifferOnStoreLoad(expected: any, load: any, store: any) { + let cell = beginCell(); + store(expected)(cell); + let actual = load(cell.endCell().beginParse()) + expect(deepEqual(expected, actual)).toBeFalsy() +} + +function getBitStringOne(bit: boolean): BitString { + return beginCell().storeBit(bit).endCell().beginParse().loadBits(1); +} + +function getBitStringArray(bitString: string) { + let result: BitString[] = []; + for (let i = 0; i < bitString.length; i++) { + result.push(getBitStringOne(bitString[i] == '0')) + } + return result; +} + +function checkThrowOnStoreLoad(expected: any, load: any, store: any, expectCell?: any) { + const t = () => { + let cell = beginCell(); + store(expected)(cell); + let slice = cell.endCell().beginParse(); + if (expectCell) { + expectCell(slice) + } + let actual = load(slice) + return actual; + } + expect(t).toThrow(Error); +} + +export type TLFunction = { + decode: any + encode: any +}; + +describe('Generating tlb code', () => { + test('Basic types', () => { + expect.hasAssertions() + + let simple: Simple = { kind: 'Simple', a: 827, b: 387 } + checkSameOnStoreLoad(simple, loadSimple, storeSimple); + let tcFalse: TwoConstructors = { 'kind': 'TwoConstructors_bool_false', a: 1000, b: 10, c: 1000 } + checkSameOnStoreLoad(tcFalse, loadTwoConstructors, storeTwoConstructors) + let tcTooBigNumberB: TwoConstructors = { 'kind': 'TwoConstructors_bool_false', a: 1000, b: 128, c: 1000 } + checkThrowOnStoreLoad(tcTooBigNumberB, loadTwoConstructors, storeTwoConstructors) + let tcTrue: TwoConstructors = { 'kind': 'TwoConstructors_bool_true', b: 1000 } + checkSameOnStoreLoad(tcTrue, loadTwoConstructors, storeTwoConstructors) + let typedConstructor: TypedField = { 'kind': 'TypedField', c: 5, y: { 'kind': 'FixedIntParam', y: 10 } } + checkSameOnStoreLoad(typedConstructor, loadTypedField, storeTypedField); + let typedParamValue: TypedParam = { 'kind': 'TypedParam', x: { 'kind': 'Maybe_just', value: { 'kind': 'SharpConstructor', c: 5, y: { 'kind': 'FixedIntParam', y: 6 } } } } + checkSameOnStoreLoad(typedParamValue, loadTypedParam, storeTypedParam); + let typedParamNothing: TypedParam = { 'kind': 'TypedParam', x: { 'kind': 'Maybe_nothing' } } + checkSameOnStoreLoad(typedParamNothing, loadTypedParam, storeTypedParam); + let bitlenArgUser: BitLenArgUser = { 'kind': 'BitLenArgUser', t: { 'kind': 'BitLenArg', x: 4, value: BigInt(10) } } + checkSameOnStoreLoad(bitlenArgUser, loadBitLenArgUser, storeBitLenArgUser); + let bitlenArgUserIncorrect: BitLenArgUser = { 'kind': 'BitLenArgUser', t: { 'kind': 'BitLenArg', x: 3, value: BigInt(10) } } + checkThrowOnStoreLoad(bitlenArgUserIncorrect, loadBitLenArgUser, storeBitLenArgUser); + let exprArgUser: ExprArgUser = { 'kind': 'ExprArgUser', t: { 'kind': 'ExprArg', x: 4, value: BigInt(10) } } + checkSameOnStoreLoad(exprArgUser, loadExprArgUser, storeExprArgUser); + let exprArgUserIncorrect: ExprArgUser = { 'kind': 'ExprArgUser', t: { 'kind': 'ExprArg', x: 5, value: BigInt(10) } } + checkDifferOnStoreLoad(exprArgUserIncorrect, loadExprArgUser, storeExprArgUser); + let complexTypedField: ComplexTypedField = { 'kind': 'ComplexTypedField', a: { 'kind': 'ExprArgUser', t: { 'kind': 'ExprArg', x: 4, value: BigInt(10) } } } + checkSameOnStoreLoad(complexTypedField, loadComplexTypedField, storeComplexTypedField); + let cellTypedField: CellTypedField = { 'kind': 'CellTypedField', a: { 'kind': 'ExprArgUser', t: { 'kind': 'ExprArg', x: 4, value: BigInt(10) } } } + checkSameOnStoreLoad(cellTypedField, loadCellTypedField, storeCellTypedField); + let lessThan: LessThan = { kind: 'LessThan', x: 3, y: 7 } + checkSameOnStoreLoad(lessThan, loadLessThan, storeLessThan); + let lessThanIncorrectX: LessThan = { kind: 'LessThan', x: 4, y: 7 } + checkThrowOnStoreLoad(lessThanIncorrectX, loadLessThan, storeLessThan); + let lessThanIncorrectY: LessThan = { kind: 'LessThan', x: 3, y: 8 } + checkThrowOnStoreLoad(lessThanIncorrectY, loadLessThan, storeLessThan); + let paramNamedArgInSecondConstr: ParamNamedArgInSecondConstr = { kind: 'ParamNamedArgInSecondConstr_a', n: 3 } + checkSameOnStoreLoad(paramNamedArgInSecondConstr, (slice: Slice) => { return loadParamNamedArgInSecondConstr(slice, 3) }, storeParamNamedArgInSecondConstr); + let anonymousData: AnonymousData = { kind: 'AnonymousData', anon0: 1, anon0_0: 3 } + checkSameOnStoreLoad(anonymousData, loadAnonymousData, storeAnonymousData); + let falseAnonField: FalseAnonField = { kind: 'FalseAnonField', value: BigInt(3) } + checkSameOnStoreLoad(falseAnonField, loadFalseAnonField, storeFalseAnonField) + let checkKeyword: CheckKeyword = { kind: 'CheckKeyword', const0: 3 } + checkSameOnStoreLoad(checkKeyword, loadCheckKeyword, storeCheckKeyword); + + let checkBigInt: BitLenArg = { kind: 'BitLenArg', x: 100, value: BigInt(2709958555) * BigInt(1e9) + BigInt(228628813) } + checkSameOnStoreLoad(checkBigInt, (slice: Slice) => { return loadBitLenArg(slice, checkBigInt.x) }, storeBitLenArg) + }) + + test('Primitives', () => { + expect.hasAssertions() + + let boolUserTrue: BoolUser = { kind: 'BoolUser', a: true } + checkSameOnStoreLoad(boolUserTrue, loadBoolUser, storeBoolUser); + let boolUserFalse: BoolUser = { kind: 'BoolUser', a: false } + checkSameOnStoreLoad(boolUserFalse, loadBoolUser, storeBoolUser); + + let expectedAddressUser: AddressUser = { kind: 'AddressUser', src: Address.parseFriendly('EQBmzW4wYlFW0tiBgj5sP1CgSlLdYs-VpjPWM7oPYPYWQEdT').address } + checkSameOnStoreLoad(expectedAddressUser, loadAddressUser, storeAddressUser) + }) + + test('Combinators', () => { + expect.hasAssertions() + let manyComb: ManyComb = { kind: 'ManyComb', y: { kind: 'OneComb', t: 5, x: { kind: 'OneComb', t: 6, x: { kind: 'OneComb', t: 7, x: 3 } } } }; + checkSameOnStoreLoad(manyComb, loadManyComb, storeManyComb); + let manyCombIncorrect: ManyComb = { kind: 'ManyComb', y: { kind: 'OneComb', t: 5, x: { kind: 'OneComb', t: 8, x: { kind: 'OneComb', t: 7, x: 8 } } } }; + checkThrowOnStoreLoad(manyCombIncorrect, loadManyComb, storeManyComb); + let combArgCellRefUser: CombArgCellRefUser = { kind: 'CombArgCellRefUser', x: { kind: 'CombArgCellRef', body: { 'kind': 'Either_right', value: 3 }, info: 4, other: { kind: 'Either_right', value: { kind: 'OneComb', t: 5, x: 5 } }, init: { kind: 'Maybe_just', value: { kind: 'Either_right', value: 4 } } } } + checkSameOnStoreLoad(combArgCellRefUser, loadCombArgCellRefUser, storeCombArgCellRefUser); + let mathExprAsCombArg: MathExprAsCombArg = { kind: 'MathExprAsCombArg', n: 8, ref: { kind: 'BitLenArg', x: 10, value: BigInt(1000) } } + checkSameOnStoreLoad(mathExprAsCombArg, (slice: Slice) => { return loadMathExprAsCombArg(slice, mathExprAsCombArg.n + 2) }, storeMathExprAsCombArg); + + let refCombinatorAny: RefCombinatorAny = { + kind: 'RefCombinatorAny', + msg: { kind: 'Maybe_just', value: beginCell().storeUint(676, 10).endCell().beginParse() } + } + checkSameOnStoreLoad(refCombinatorAny, loadRefCombinatorAny, storeRefCombinatorAny); + + let msgEnvelope: RefCombinatorInRef = { kind: 'RefCombinatorInRef', msg: { kind: 'RefCombinatorInRefHelper', t: 3, y: { kind: 'Maybe_just', value: beginCell().storeUint(3, 32).endCell().beginParse() } } } + checkSameOnStoreLoad(msgEnvelope, loadRefCombinatorInRef, storeRefCombinatorInRef); + }); + + test('Naming', () => { + expect.hasAssertions() + + let multipleEmptyConstructor: MultipleEmptyConstructor = { kind: 'MultipleEmptyConstructor__', a: 5 } + checkSameOnStoreLoad(multipleEmptyConstructor, (slice: Slice) => { return loadMultipleEmptyConstructor(slice, 0); }, storeMultipleEmptyConstructor); + let multipleEmptyConstructor1: MultipleEmptyConstructor = { kind: 'MultipleEmptyConstructor__1', b: 6 } + checkSameOnStoreLoad(multipleEmptyConstructor1, (slice: Slice) => { return loadMultipleEmptyConstructor(slice, 1); }, storeMultipleEmptyConstructor); + let multipleEmptyConstructor2: MultipleEmptyConstructor = { kind: 'MultipleEmptyConstructor_a', x: 5 } + checkSameOnStoreLoad(multipleEmptyConstructor2, (slice: Slice) => { return loadMultipleEmptyConstructor(slice, 2); }, storeMultipleEmptyConstructor); + + let trueCheck: True = { kind: 'True' } + checkSameOnStoreLoad(trueCheck, loadTrue, storeTrue); + }) + + test('Complex Expressions', () => { + expect.hasAssertions() + + let tupleCheck: TupleCheck = { kind: 'TupleCheck', s: [5, 6, 7] } + checkSameOnStoreLoad(tupleCheck, loadTupleCheck, storeTupleCheck); + + let conditionalField: ConditionalField = { kind: 'ConditionalField', a: 1, b: 5 } + checkSameOnStoreLoad(conditionalField, loadConditionalField, storeConditionalField); + + let conditionalFieldIncorrect: ConditionalField = { kind: 'ConditionalField', a: 0, b: 5 } + checkDifferOnStoreLoad(conditionalFieldIncorrect, loadConditionalField, storeConditionalField); + + let conditionalFieldBUndef: ConditionalField = { kind: 'ConditionalField', a: 0, b: undefined } + checkSameOnStoreLoad(conditionalFieldBUndef, loadConditionalField, storeConditionalField); + + let bitSelection: BitSelection = { kind: 'BitSelection', a: 5, b: 5 } + checkSameOnStoreLoad(bitSelection, loadBitSelection, storeBitSelection); + + let bitSelectionIncorrect: BitSelection = { kind: 'BitSelection', a: 8, b: 5 } + checkDifferOnStoreLoad(bitSelectionIncorrect, loadBitSelection, storeBitSelection); + + let conditionalRef: ConditionalRef = { kind: 'ConditionalRef', x: 1, y: { kind: 'Simple', a: 3, b: 4 } } + checkSameOnStoreLoad(conditionalRef, loadConditionalRef, storeConditionalRef); + + let conditionalRefUndefined: ConditionalRef = { kind: 'ConditionalRef', x: 0, y: undefined } + checkSameOnStoreLoad(conditionalRefUndefined, loadConditionalRef, storeConditionalRef); + }) + + test('Exceptions', () => { + expect.hasAssertions() + + let implicitConditionIncorrect: ImplicitCondition = { kind: 'ImplicitCondition', flags: 200 } + checkThrowOnStoreLoad(implicitConditionIncorrect, loadImplicitCondition, storeImplicitCondition); + + let implicitCondition: ImplicitCondition = { kind: 'ImplicitCondition', flags: 100 } + checkSameOnStoreLoad(implicitCondition, loadImplicitCondition, storeImplicitCondition); + + let implicitConditionIncorrectCell = beginCell().storeUint(200, 10).endCell().beginParse(); + expect(() => { + loadImplicitCondition(implicitConditionIncorrectCell) + }).toThrow(Error); + + let implicitConditionCell = beginCell().storeUint(100, 10).endCell().beginParse(); + expect(loadImplicitCondition(implicitConditionCell).flags == 100).toBeTruthy() + + let equalityExpression: EqualityExpression = { kind: 'EqualityExpression', n: 2 } + checkSameOnStoreLoad(equalityExpression, loadEqualityExpression, storeEqualityExpression); + + let equalityExpressionIncorrect: EqualityExpression = { kind: 'EqualityExpression', n: 3 } + checkThrowOnStoreLoad(equalityExpressionIncorrect, loadEqualityExpression, storeEqualityExpression); + }) + + test('Hashmap', () => { + expect.hasAssertions() + + let hashmapEUser: HashmapEUser = { + kind: 'HashmapEUser', + x: { + kind: 'HashmapE_hme_root', + n: 8, + root: { + kind: 'Hashmap', + l: 0, m: 8, n: 8, + label: { + kind: 'HmLabel_hml_short', + n: 0, m: 8, + len: { kind: 'Unary_unary_zero' }, + s: [] + }, + node: { + kind: 'HashmapNode_hmn_fork', + n: 7, + left: { + kind: 'Hashmap', + n: 7, + m: 5, + l: 2, + label: { + kind: 'HmLabel_hml_long', + m: 7, + n: 2, + s: getBitStringArray('00') + }, + node: { + kind: 'HashmapNode_hmn_fork', + n: 4, + left: { + kind: 'Hashmap', + n: 4, + m: 0, + l: 4, + label: { + kind: 'HmLabel_hml_long', + m: 4, + n: 4, + s: getBitStringArray('0001') + }, + node: { + kind: 'HashmapNode_hmn_leaf', + value: 777 + } + }, + right: { + kind: 'Hashmap', + n: 4, + m: 0, + l: 4, + label: { + kind: 'HmLabel_hml_long', + m: 4, + n: 4, + s: getBitStringArray('0001') + }, + node: { + kind: 'HashmapNode_hmn_leaf', + value: 111 + } + } + } + }, + right: { + kind: 'Hashmap', + n: 7, + m: 0, + l: 7, + label: { + kind: 'HmLabel_hml_long', + m: 7, + n: 7, + s: getBitStringArray('0000000') + }, + node: { + kind: 'HashmapNode_hmn_leaf', + value: 777 + } + } + } + } + } + } + checkSameOnStoreLoad(hashmapEUser, loadHashmapEUser, storeHashmapEUser); + }) + + test('Constructor Tags', () => { + expect.hasAssertions() + + let sharpConstructor: SharpConstructor = { kind: 'SharpConstructor', c: 5, y: { 'kind': 'FixedIntParam', y: 6 } } + checkSameOnStoreLoad(sharpConstructor, loadSharpConstructor, storeSharpConstructor); + + let emptyTag: EmptyTag = { kind: 'EmptyTag', a: 3 } + checkSameOnStoreLoad(emptyTag, loadEmptyTag, storeEmptyTag); + let emptyTagCell = beginCell(); + storeEmptyTag(emptyTag)(emptyTagCell); + expect(emptyTagCell.endCell().beginParse().remainingBits == 32).toBeTruthy(); + + let sharpTag: SharpTag = { kind: 'SharpTag', x: 3 } + checkSameOnStoreLoad(sharpTag, loadSharpTag, storeSharpTag); + let sharpTagCell = beginCell(); + storeSharpTag(sharpTag)(sharpTagCell); + let sharpTagSlice = sharpTagCell.endCell().beginParse() + expect(sharpTagSlice.loadUint(8) == 0xf4).toBeTruthy(); + expect(sharpTagSlice.remainingBits == 32).toBeTruthy(); + + let dollarTag: DollarTag = { kind: 'DollarTag', x: 3 } + checkSameOnStoreLoad(dollarTag, loadDollarTag, storeDollarTag); + let dollarTagCell = beginCell(); + storeDollarTag(dollarTag)(dollarTagCell); + let dollarTagSlice = dollarTagCell.endCell().beginParse() + expect(dollarTagSlice.loadUint(4) == 0b1011).toBeTruthy(); + expect(dollarTagSlice.remainingBits == 32).toBeTruthy(); + + let constructorOrder: ConstructorOrder = { kind: 'ConstructorOrder_a', a: { kind: 'Simple', a: 2, b: 3 } } + checkSameOnStoreLoad(constructorOrder, loadConstructorOrder, storeConstructorOrder); + + let checkCrc32A: CheckCrc32 = { kind: 'CheckCrc32_a', a: 3 } + checkSameOnStoreLoad(checkCrc32A, loadCheckCrc32, storeCheckCrc32); + + let checkCrc32B: CheckCrc32 = { kind: 'CheckCrc32_b', b: 4, c: 5 } + checkSameOnStoreLoad(checkCrc32B, loadCheckCrc32, storeCheckCrc32); + + let checkCrc32AOpCode = beginCell().storeUint(0x9d97e7a, 32).storeUint(76, 32).endCell().beginParse(); + loadCheckCrc32(checkCrc32AOpCode); + }) + + test('Advanced types', () => { + expect.hasAssertions() + + let unary: Unary = { kind: 'Unary_unary_succ', n: 2, x: { kind: 'Unary_unary_succ', n: 1, x: { kind: 'Unary_unary_succ', n: 0, x: { kind: 'Unary_unary_zero' } } } } + checkSameOnStoreLoad(unary, loadUnary, storeUnary); + let unaryIncorrectOne: Unary = { kind: 'Unary_unary_succ', n: 3, x: { kind: 'Unary_unary_succ', n: 1, x: { kind: 'Unary_unary_succ', n: 0, x: { kind: 'Unary_unary_zero' } } } } + checkDifferOnStoreLoad(unaryIncorrectOne, loadUnary, storeUnary); + let unaryIncorrectAll: Unary = { kind: 'Unary_unary_succ', n: 3, x: { kind: 'Unary_unary_succ', n: 2, x: { kind: 'Unary_unary_succ', n: 1, x: { kind: 'Unary_unary_zero' } } } } + checkDifferOnStoreLoad(unaryIncorrectAll, loadUnary, storeUnary); + let unaryIncorrectSuccZero: Unary = { kind: 'Unary_unary_succ', n: 3, x: { kind: 'Unary_unary_zero' } } + checkDifferOnStoreLoad(unaryIncorrectSuccZero, loadUnary, storeUnary); + + let paramConstD: ParamConst = { kind: 'ParamConst_d', n: 1, k: 2, l: 3, m: 4 } + checkDifferOnStoreLoad(paramConstD, (slice: Slice) => loadParamConst(slice, 1, 1), storeParamConst); + checkThrowOnStoreLoad(paramConstD, (slice: Slice) => loadParamConst(slice, 1, 2), storeParamConst) + checkSameOnStoreLoad(paramConstD, (slice: Slice) => loadParamConst(slice, 4, 2), storeParamConst) + let paramConstB: ParamConst = { kind: 'ParamConst_b', k: 2, m: 4 } + checkSameOnStoreLoad(paramConstB, (slice: Slice) => loadParamConst(slice, 2, 1), storeParamConst); + let paramConstC: ParamConst = { kind: 'ParamConst_c', k: 2, m: 4, n: 3 } + checkSameOnStoreLoad(paramConstC, (slice: Slice) => loadParamConst(slice, 3, 3), storeParamConst); + + let paramDifNamesC: ParamDifNames = { kind: 'ParamDifNames_c', n: 3, x: { kind: 'ParamDifNames_c', n: 2, x: { kind: 'ParamDifNames_c', n: 1, x: { kind: 'ParamDifNames_a' } } } } + checkSameOnStoreLoad(paramDifNamesC, (slice: Slice) => loadParamDifNames(slice, 2), storeParamDifNames); + let paramDifNamesD: ParamDifNames = { kind: 'ParamDifNames_d', m: 4, x: { kind: 'ParamDifNames_d', m: 2, x: { kind: 'ParamDifNames_d', m: 1, x: { kind: 'ParamDifNames_b' } } } } + checkSameOnStoreLoad(paramDifNamesD, (slice: Slice) => loadParamDifNames(slice, 3), storeParamDifNames); + + let paramDifNamesUser: ParamDifNamesUser = { kind: 'ParamDifNamesUser', k: 4, x: { kind: 'ParamDifNames_c', n: 3, x: { kind: 'ParamDifNames_c', n: 2, x: { kind: 'ParamDifNames_c', n: 1, x: { kind: 'ParamDifNames_a' } } } } } + checkSameOnStoreLoad(paramDifNamesUser, loadParamDifNamesUser, storeParamDifNamesUser); + let paramDifNamesUserIncorrect: ParamDifNamesUser = { kind: 'ParamDifNamesUser', k: 5, x: { kind: 'ParamDifNames_c', n: 3, x: { kind: 'ParamDifNames_c', n: 2, x: { kind: 'ParamDifNames_c', n: 1, x: { kind: 'ParamDifNames_a' } } } } } + checkDifferOnStoreLoad(paramDifNamesUserIncorrect, loadParamDifNamesUser, storeParamDifNamesUser); + + let negationFromImplicit: NegationFromImplicit = { kind: 'NegationFromImplicit', t: 4, y: 2, z: 7 } + checkSameOnStoreLoad(negationFromImplicit, loadNegationFromImplicit, storeNegationFromImplicit) + let negationFromImplicitIncorrect: NegationFromImplicit = { kind: 'NegationFromImplicit', t: 4, y: 3, z: 7 } + checkDifferOnStoreLoad(negationFromImplicitIncorrect, loadNegationFromImplicit, storeNegationFromImplicit) + + let unaryUserCheckOrder: UnaryUserCheckOrder = { kind: 'UnaryUserCheckOrder', l: 2, m: 5, label: { kind: 'Unary_unary_succ', n: 1, x: { kind: 'Unary_unary_succ', n: 0, x: { kind: 'Unary_unary_zero' } } } } + checkSameOnStoreLoad(unaryUserCheckOrder, loadUnaryUserCheckOrder, storeUnaryUserCheckOrder) + + let loadFromNegationOutsideExpr: LoadFromNegationOutsideExpr = { kind: 'LoadFromNegationOutsideExpr', prev_seq_no: 3, seq_no: 4 } + checkSameOnStoreLoad(loadFromNegationOutsideExpr, loadLoadFromNegationOutsideExpr, storeLoadFromNegationOutsideExpr) + + }) + + test('Slices', () => { + expect.hasAssertions() + + let cellsSimple: CellsSimple = { 'kind': 'CellsSimple', a: 5, b: 3, c: 4, d: 100, e: 4, q: 1, t: 3 } + checkSameOnStoreLoad(cellsSimple, loadCellsSimple, storeCellsSimple, (slice: Slice) => { + slice = slice.clone() + slice.loadRef(); + let slice2 = slice.loadRef().beginParse(); + slice2.loadRef(); + let slice22 = slice2.loadRef().beginParse(); + let slice221 = slice22.loadRef(); + }); + checkThrowOnStoreLoad(cellsSimple, loadCellsSimple, storeCellsSimple, (slice: Slice) => { + slice = slice.clone() + slice.loadRef(); + let slice2 = slice.loadRef().beginParse(); + slice2.loadRef(); + let slice22 = slice2.loadRef().beginParse(); + let slice221 = slice22.loadRef(); + let slice2211 = slice221.beginParse().loadRef(); + }); + checkThrowOnStoreLoad(cellsSimple, loadCellsSimple, storeCellsSimple, (slice: Slice) => { + slice.loadRef(); + }); + checkThrowOnStoreLoad(cellsSimple, loadCellsSimple, storeCellsSimple, (slice: Slice) => { + slice.preloadRef().beginParse().preloadRef(); + }); + checkSameOnStoreLoad(cellsSimple, loadCellsSimple, storeCellsSimple, (slice: Slice) => { + slice.preloadRef().beginParse(); + }); + + let intBitsOutside: IntBitsOutside = { + 'kind': 'IntBitsOutside', + x: { + 'kind': 'IntBitsInside', + a: { + 'kind': 'IntBits', arg: BigInt(3), d: 5, + g: beginCell().storeUint(3, 2).endCell().beginParse().loadBits(2), + x: beginCell().storeUint(76, 10).endCell().beginParse() + }, + x: 3 + } + } + checkSameOnStoreLoad(intBitsOutside, loadIntBitsOutside, storeIntBitsOutside); + + let intBitsParametrizedOutside: IntBitsParametrizedOutside = { + kind: 'IntBitsParametrizedOutside', + x: { + kind: 'IntBitsParametrizedInside', + a: { + kind: 'IntBitsParametrized', e: 5, f: BigInt(3), h: BigInt(7), j: 9, k: BigInt(10), + i: beginCell().storeUint(676, 10).endCell().beginParse().loadBits(10), + tc: beginCell().storeUint(76, 10).endCell().beginParse() + }, + x: 5 + } + } + checkSameOnStoreLoad(intBitsParametrizedOutside, loadIntBitsParametrizedOutside, storeIntBitsParametrizedOutside); + + let intBitsParametrizedOutsideIncorrect: IntBitsParametrizedOutside = { + kind: 'IntBitsParametrizedOutside', + x: { + kind: 'IntBitsParametrizedInside', + a: { + kind: 'IntBitsParametrized', e: 6, f: BigInt(3), h: BigInt(7), j: 9, k: BigInt(10), + i: beginCell().storeUint(676, 10).endCell().beginParse().loadBits(10), + tc: beginCell().storeUint(76, 10).endCell().beginParse() + }, + x: 5 + } + } + checkDifferOnStoreLoad(intBitsParametrizedOutsideIncorrect, loadIntBitsParametrizedOutside, storeIntBitsParametrizedOutside); + }) + + test('block tlb tests', () => { + const state = 'te6cckEC0QEAF4EABBAR71Wq////EQ4LARoKigRFBc22uwt5FAe5LkwV9/aUCMG3DMEFmhpBL/V+tBDI/gV3bfbEh9X1jahPoZpMXpC6TwToe2oBAiKcJCMWgMzjAhkCGSUCI1uQI6/i////EQAAAAAAAAAAAAAAAAACCJygAAAAAWQpXggAACE4Ni/9xAGyx8EgCgQDAdkAAAAAAAAAAP//////////glm7Tyr7ph7bvcoliLx6hZAAAhODYReUQBssfBAKstMwDM/+WPxY9XNFdU/4cu5AdlJJxlQd/rujBrVRmS8DPQgPzqUD9KMX8as2Dwctu9c04+8yNoUKVi2nVyoIECITgglm7Tyr7ph7cAUQIxMBBLN2nlX3TD24GAYQIxMBAZDm24nj3jYYBywVIxMBAQHXwZPFZ1f4SRIIAgEgoQkAE7////+8hct+TjABEQAAAAAAAAAAUKICEbjkjftDxPT2BA0MAA0AEO5rKAAIAiWCWbtPKwbudNwSzdp5V90w9sAIEBACoJvHqYcAAAAAhAECCJygAAAAAQAAAAAAAAAAAAAAAABkKV4IAAAhODYv/cAAACE4Ni/9xGSeizgABnF2AbLHwQGyxDjEAAAAAwAAAAAAAAAuRg8AmAAAITg2ILuBAgicn5OTTn6kV5z6E216F7w1p7ywI+Wsbfm4l7+fH+PH3tbaRLtCQmSNinuI8RM1X14LJBOd+k8nDROIBcr5XT35BMwCASARFgATvgAAA7yRYnrqkCMTAQCVZm3cySLJmM8TJCITAQBXbLG1sxxLaBSmIhEA7TNAkoCvNMhLqAIBIBcWABO/////vIuW/JxQABO+AAADvJFVjgoQIxMBAyKPwswTbge4RG8ZABGgAAAA7xs7OCQDiUoz9v0AAAAAMhjte0ADZ9Ue4JasekQN2qxAbkcpsPnm3xb+QdycBRLKp6O4P7y5zuVClQ61W4lQ2IB7RVnlRQ3Zf7ntQCAfGwEHnTCbchwCBw6YTbkeHQKkv9hmS6t5x389cc3WraAW8v9u/tHNgS00XoIS5/rCIFutGIBUYWwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WqAAABCcGxf+4ZiAVGF9jAqS/8DbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY4csEcRWBtqDZepDMCpWf6e4TGBEQr1oVdFBVra1hoWmBM4PscoAAAEJwbF/7gnLBHEZWkBAYJdAQmYc4+QICECCQw5x8gQIyICU7/tv+KF5I5D4kmpP2G9Ole4W7PrWAo836gCz/UsR488Shhzj5AZhzj5QHFfAkW/+10YVX8suGLI/VWnKzNQacHbz88tvbzdIeyzKUTUvL6ABGxlABGgAAAA7xhMWuQjW5Ajr+L///8RAAAAAAAAAAAAAAAAAAIInJ8AAAABZCleBQAAITg2ILuBAbLHvyBFJyYoSAEBpRWq+4O2768Q6YgNNGQjmj0oa8zM5VMgwFF0+iWqUqkAAiITgglm7TysG7nTcCgpIxMBBLN2nlYN3Om4LSopKEgBAbPpZJ0QzLN5No6Bo6fo5JyOtT9qzGmwui/6gAgvcO45AAEjEwEBkOba1PLVX/hHLCsoSAEBuwbzUGdFxfamI50TKnCzhDnLYP+V9i5FJhuhLoROiJsAAShIAQFdcwvHm2Gi3vzR5QK6MzZpJ2XoxG6s9cU5A+NecaY2ZQBnIxMBAyKPw4EbB4nYRC8uKEgBAW8xXyW0o5rBLIX+pOz+eoPl5Z0fBZeD+gw+8nlzCIBhAAAjEwEBQHDBzHvk29hwMEojEwEAUApu/uIBspgxd0ojEQD9ZwkwKFUL2DJ5MyMRAPxRfpdfYWL4NHwzKEgBAdesu2AjOMhtYQ81z7Ni/Xb8GLGBJHa2/KmaBnjmZfz1AAAiEQDjkp2cjH78iDXQIhEA4qsjFN6mokg2fyIRAOKYHdmYGycIN4EiEQDh3QxQfyu5CJ04Ig8AxgUbDbsGSJw5Ig8AxR33sLE3CDqFIg8AxHL6Yno2qJs7Ig8AxC6kdAuZaJo8Ig8AxCi4DqgjyD2JIg8AxCCrNzFaaJk+Ig8AxCBpdu+8CJg/Ig8AxB7y0orbaECNIg8AxB7qPeidiJdBIg8AxB7pSOPSiEKQIg9QMQaGMcp2EkOSIZu6g2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HAMQaGHhPJk8fJ/pSBwkG9iigbeI6u0UIcOptjngRxq8d+vVLS6LY0AACE4BYzRwaeKEgBAT3wohgPv4MQ4+vz7gM349tPPFYHsqlZSMuevDm3t4EBAhUoSAEBOxcU0HjSRdQVv8jz/2RdmNPXidHJrEXKTEh77ypybKAAAgCYAAAhODYReUQBssfBAKstMwDM/+WPxY9XNFdU/4cu5AdlJJxlQd/rujBrVRmS8DPQgPzqUD9KMX8as2Dwctu9c04+8yNoUKVi2nVyoCMTAQEB18De1F6B2EmjSChIAQHskKRO7gK+2EDBDog1EWPunjYT652+jadgeD2kSXFOKAABKEgBAeK+z0GLoJJXqHmcgiUmFab+cGE3G05kIzFL1fGvx+7yAGcoSAEB7X4mvTbvptXZtPaqq5gTrwdCqEJEl390/UB0ycmJCL4AACIRAOfckED3AmmoTKoiEQDgKvnhz8sqaE2sIg8AzWFSJqtV6M5OIg8AxY+VQnVA6M1PIg8Aw4VN2Uwz6FCwIg8AwmgbZ7zyCFGyIg8AwLPaWJdUqMxSIg8AwEW+c768iMtTIg8AwCGKXAQqSFS2Ig8AwCAp2uw86FW4Ig0Avii23INoylYiDQCg9iRqgQhXuyINAKD0o/xyaFi9Ig0AoNeOM7+oyVkiDQCg1z9eQuhawCINAKDWv15C6MhbIg0AoNIwddNIx1whmbpq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60BQaOLJc2OxZkrdV5VNejNdZYocwulM6KlsjAputOLtERFZ6SV/oAABCcGxf+4cdANFoBtv+KF5I5D4kmpP2G9Ole4W7PrWAo836gCz/UsR488SgFBxZV4CB2Yc4+VxXwO1ewzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WgAAITg2L/3DbOLcUyYI0cPzAxVFzkG6J7zghhDc9bLr92Oh7WOzkVkAACEogQULwWQpXggAAUYgFRiGRjYAIbDLrdCUFp5hRPWGHj4xFiYQBbwAAAAAAAAAAAAAAAAS1FLaRJ5QuM990nhh8UYSKv4bVGu4tw/IIW8MYUE5+OBACeQHvsPQkAAAAAAAAAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCcqwgKOzuSym5usTshSpMpCr16O7s5bepH1izbp7Xp2Czizf8kNDqAW3uBWuovIThZFt6VZVorL4SzhvSsRKnI0wBAaByA7V2BtqDZepDMCpWf6e4TGBEQr1oVdFBVra1hoWmBM4PscAAAhODYv/cHx8n+lIHCQb2KKBt4jq7RQhw6m2OeBHGrx369UtLotjQAAITgFjNHBZCleCAADRywRxIamlmAhEMgFcGG4cyxEBoZwBvyYrVcEwc47gAAAAAAAIAAAAAAAJGZSaqgI5ubq7EBkS9iYCyLImlfsoM+uTwXHcA6Ll23kCQIEwAnUOc4xOIAAAAAAAAAAAhgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAgnLsg1gBXx7Xxc8sPHDKhgW6z7UHcU5ZMO7TJUYI4hsdeNd1bVzcsM9RXJH+4PoemNCiNrt5WeZxeO791T0M+08OAgHgbGsBAd9yAd2IAMDbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY4BE2TDQHoAPruZj44qfgANmByqblxPjLe/6PijbrlfomSpMKoT4olv46Ec0Oyon/E9itWsVVbgoHiSurUO1mI0HAAAAALIUryEP2V8t5tAQTQA24AukIAWGZLq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60oLTzCiegAAAAAAAAAAAAAAAAAAAAAADk0YjFlMzVkLWYyMGUtNDJkYS04MGU2LWNiM2ZkYWY2YjcwNCMTAQFAcMEXdEtZuHB1dihIAQEzX6VT6kvKa9205IdZXLH1EnzQYt5IxkFRCl98L8aoHQBhAQxGBgMOcfJyAbNIAMDbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY5ACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WlBaeYUT0Bhzj5AAAQnBsX/uEyFK8EMBzAFAAAAAAOTRiMWUzNWQtZjIwZS00MmRhLTgwZTYtY2IzZmRhZjZiNzA0InHACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WiLIWQQyFK8EAAAITg2L/3EUGjiyXNk0DGxSMTAQBQCm5J2mgweHh3dgARoAAAAO8ZEcTMKEgBAStT6er4RaQYeNe/8rQVgaM+C5Ec6gMxWKLQBM/s3OP9ADojEQD9Zwh7ILuJuHp5eyhIAQHGJBxyRx2nxj5LaPE51bQZCvSffkDzMhCsMKvaDnBwrgBfIxEA/FF94lfH4Nh9fHsAEaAAAADvGKfJJChIAQHF0rr8QO139Iq41hqZKErCW8ACJrijYIM1RHpJjqtT8gA4IhEA45Kc54Tlemh+0CIRAOKrIl/XDSAogH8oSAEBT02ni3tLW5UgUljEDbLdnR8ffMmUf/QmI5hnM/54gr0AJSIRAOKYHSSQgaTogoEoSAEBM68Z6oNiYqIE/xCVIXNCO5DHgBCH0v6D8o0IlWLSbt8AJiIRAOHdC5t3kjbonYMiDwDGBGYGIYQonIQiDwDFHUKpF7TohoUoSAEBNB3OA0eOfDTx/kErEufcekh6AE8/s2emeGEsVZlHOG8AGCIPAMRyRVrgtIibhyIPAMQt72xyF0iaiCIPAMQoAwcOoaiKiShIAQGiHAzPwfwORsBp02k9WV3cjFaEUdSQ36sRel1jRCTNJAAUIg8AxB/2L5fYSJmLIg8AxB+0b1Y56JiMIg8AxB49yvFZSI6NKEgBAUZtH4yDm+D0wHPn5Yce9BEfDbMoaajlB1Ud1mN/OtlWAA0iDwDEHjU2Txtol48iDwDEHjRBSlBokZAoSAEBdZZPFv97JSIbVQ4JyJgoDuTkm83nC6jEYDVcwGxoNjIACyIPUDEGWO/kFYqTkihIAQEM+/iVpCeSGVQ7v7SwKOqMLsAP7eS6EZo6dUA/pfUPEAAIIZu6g2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HAMQZY3C1pCVzFHjnW5pCIDMke2Eo0dBFsj0nDOu0KHDzAnsVol79cAACE4Ni/9waUInPABgbag2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HCGIIZwyFK8EAAAITg2L/3DYgyxuFrSFNAoJUBWQAAAAFkKVNZDx4g+gWglbhB38WtcZ5x5JAn5jqXB4f3jyt4GZK2irpzvcQAwJYAE6AyFK8hD9lfLcAoSAEBHgrDQCiPcdY0HrD7MU6zKEzVsG2o7h+uS9pWs8wbnJ8ADChIAQHKxBWQY1y/aOvinbyMXBGKE2NY8M7FwIMOajGn3/DSHAAQKEgBAecXqSOr4K1n8v+a4nkWws/qYIhRZOoeR+i9A/Iu/Zz+ABQoSAEBwLwm5Uey6iIGJ9PifbSXU8cHk7HL4jPeZbCRWeuPvHIAFShIAQGqWL/ZPmD9wOC1butJ0zbkCcW4NbO4mCXgMZLGpgeq5QAXKEgBAVtS27/eOLwtYVWxS0d8zkZ94CVGNHFHaFvO6Zn5UDJUABkoSAEBOCsW8AxTELrth9Wtfx0GfnCzwOhxw7/npgcWWP0PicAAHCJzwAYG2oNl6kMwKlZ/p7hMYERCvWhV0UFWtrWGhaYEzg+xwhiCGcMhSpj4AACE4BYzRw2INDDwnkyTQKCfKEgBATSTTv6zIMNhS6ljIyo9l6Dw2TQ6QRE+qW2FK+Hj3iFKAAEoSAEBlJTRzI7fEvBWcaGpugmSEJbrUIEeGSTsZcPGKfu4CBIABAATvgAAA7yE+MJA0ABrsEAAAAAAAAAAANlj4IAAEJwbF/7hbb/iheSOQ+JJqT9hvTpXuFuz61gKPN+oAs/1LEePPEpAIxMBAJVmbSfYGfN4z6WkKEgBAT6FZvX18rkB8AC7g6PivCJByqd21885qflpQfuAgXmcAAAiEwEAV2yxAMITdUinpihIAQGggxo341fgvkQKy3tnb2FOymbihPqgx8XXa1uwuk/xdgBeIhEA7TM/3Y+mXqipqChIAQHekhfgIk36qC9gwNk/4lpJwJJlrZ+6mgm0xNEwIMuhxAAqIhEA59yPjAX5k4irqihIAQHLtFsOh+u3y+guD+3i0xwpF5AAgcz8NYv3QPwJ8GZ+XAAsIhEA4Cr5LN7CVEitrChIAQHIF3gFICgSZ5FN5CQLsqXEHdeKjdl2VTk72mko9KkK5gAeIg8AzWCdNaJ/yM6uIg8AxY7gUWxqyM2vIg8Aw4SY6ENdyLGwKEgBAcNf5HCvff88cYOGfq4hMLsZQ4rpmN3p5TESjIZeHYfdABoiDwDCZ2Z2tBvos7IoSAEBzB2qFVwzmJ0RM8aZixilBpPTlGx0GtCUi57FA+izvrAAGyIPAMCzJWeOfojMtCIPAMBFCYK15mjLtSIPAMAg1Wr7VCi3tihIAQFwNwR3atIjdJf2/elobh7DuB75ni/SufuFCxxWOBzdhwAUIg0Av3Tp42bIubgoSAEBRX2kAc8o5m/8t/t3sEEMmGqq5/W7d7/F9FIduN6duNkADyINAL1zxdOtSMq6Ig0AoEEzYarovLsoSAEB6XW8yt4T58ElUyuuyJ54dMGtFU0CexVUycIVI3a8c2YADSINAKA/svOcSL69KEgBAUK7MUSjrXWVXuZBYUKlHUKrroQGX+yfWhtNhz7lN8n6AAsiDQCgIp0q6YjJvyINAKAiTlVsyMHAKEgBAXxNBe3bbHX79cjVPvcm8cvZKtPEGQqLP9IzrRkbIfjWAAkiDQCgIc5VbMjIwiILAJ0/bP0ox8Mhl7pq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60BOakUIU2cW4pkwRo4fmBiqLnIN0T3nBDCG562XX7sdD2sdnIrIAAEJRAgoXgzEIm/ACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WiLIWOQyEuC4AAAISiBBQvDTmpFCFTQMbFAFEAAAAHKamjF34U6KK3xtVYfJKAXDfvq96k6gufJtm4qCqODWvc6mJQQChIAQH+tf9oIOL/DZSD5+DWLIF9hGeJ+0rlgMh4hm2VnavVwAAHKEgBAUgdtUNfI6DNuGnT4LxXs0enI/3ZDm/o4GHoKSGDln4+AAkoSAEBPGpn9ZfihdTNKNHBnuCU+UJCqd2zuEnF8cCnicSLziUACChIAQGMKLC8jkc1VDLelznZZQAbKi948QotANztzp+kaw4W7QAIKEgBAVMWIkIDHF47BX2a46BlCEEASbT5onV/U/84xeSJyavbABIoSAEBjEEiz61R0H6dN/31qP+jdNbMpw2LOYRARFnHgWqSWNQAFihIAQH7oZuYMFt25/R/rDYjGn6YHeVcFBL0C+pwhZCqt/bUbQAYKEgBAejgWpiIE/DT5RzO8P3ny8oYPEHblFq5UlxWkXAW5QQUAB0oSAEBHEzwo1WeCo4ej1Vob5/vEp/iY9isaWQiUjPKLXSa2F0AJyhIAQG6AR8M/S/UB23zXmBMm80bjwEVWFYt7N0B/gicRJjr1wBlKEgBAZAkBO+kH7fhtV/nPdXl/YhX9N1x4bZfgSrpmy1eIH/CACQY+N7F'; + const cs = Cell.fromBase64(state); + + let blk = loadBlock(cs.beginParse()); + let builder = beginCell(); + storeBlock(blk)(builder); + + expect(deepEqual(cs.hash(), builder.endCell().hash())).toBeTruthy() + }) +}) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e075f97 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} From cc4dd290d92dcc4d1e0ea477c13f355618d50432 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Thu, 11 Jan 2024 20:00:44 -0500 Subject: [PATCH 02/28] add bit type --- src/astbuilder/fill_constructors.ts | 1 + src/astbuilder/handle_type.ts | 2 + src/generators/typescript/generator.ts | 34 ++++++++++----- test/generated_files/generated_block.ts | 55 +++++++------------------ test/generated_files/generated_test.ts | 49 ++++++++++++++++------ test/tlb/test.tlb | 6 ++- test/tlbgen.spec.ts | 23 ++++++++--- 7 files changed, 100 insertions(+), 70 deletions(-) diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index b4fd67e..fd44f61 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -426,6 +426,7 @@ function checkAndRemovePrimitives( let typesToDelete = new Map(); typesToDelete.set("Bool", ["4702fd23", "f0e8d7f"]); typesToDelete.set("MsgAddressInt", ["d7b672a", "6d593e8a"]); + typesToDelete.set("Bit", ["2873c6f5"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 0cb4415..7a7bec0 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -219,6 +219,8 @@ export function getType( return { kind: "TLBBoolType" }; } else if (expr.name == "MsgAddressInt") { return { kind: "TLBAddressType" }; + } else if (expr.name == "Bit") { + return { kind:"TLBBitsType", bits: new TLBNumberExpr(1) } } else { if (constructor.variablesMap.get(expr.name)?.type == "#") { return { diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index b8d0581..f240d04 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -4,6 +4,7 @@ import { TLBField, TLBFieldType, TLBMathExpr, + TLBNumberExpr, TLBType, TLBVariable, } from "../../ast"; @@ -68,6 +69,7 @@ import { tIfStatement, tImportDeclaration, tMemberExpression, + tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, @@ -672,17 +674,27 @@ export class TypescriptGenerator implements CodeGenerator { exprForParam.paramType = "bigint"; } } else if (fieldType.kind == "TLBBitsType") { - exprForParam = { - argLoadExpr: convertToAST(fieldType.bits, ctx.constructor), - argStoreExpr: convertToAST( - fieldType.bits, - ctx.constructor, - id(ctx.name) - ), - paramType: "BitString", - fieldLoadSuffix: "Bits", - fieldStoreSuffix: "Bits", - }; + if (fieldType.bits instanceof TLBNumberExpr && fieldType.bits.n == 1) { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "boolean", + fieldLoadSuffix: "Bit", + fieldStoreSuffix: "Bit" + } + } else { + exprForParam = { + argLoadExpr: convertToAST(fieldType.bits, ctx.constructor), + argStoreExpr: convertToAST( + fieldType.bits, + ctx.constructor, + id(ctx.name) + ), + paramType: "BitString", + fieldLoadSuffix: "Bits", + fieldStoreSuffix: "Bits", + }; + } } else if (fieldType.kind == "TLBCellType") { exprForParam = { argLoadExpr: id(theSlice), diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 5575016..57e0d85 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -53,11 +53,6 @@ export interface Both { readonly second: Y; } -export interface Bit { - readonly kind: 'Bit'; - readonly anon0: number; -} - export interface Hashmap { readonly kind: 'Hashmap'; readonly n: number; @@ -88,20 +83,20 @@ export interface HmLabel_hml_short { readonly m: number; readonly n: number; readonly len: Unary; - readonly s: Array; + readonly s: Array; } export interface HmLabel_hml_long { readonly kind: 'HmLabel_hml_long'; readonly m: number; readonly n: number; - readonly s: Array; + readonly s: Array; } export interface HmLabel_hml_same { readonly kind: 'HmLabel_hml_same'; readonly m: number; - readonly v: BitString; + readonly v: boolean; readonly n: number; } @@ -204,7 +199,7 @@ export interface VarHashmapNode_vhmn_fork { export interface VarHashmapNode_vhmn_cont { readonly kind: 'VarHashmapNode_vhmn_cont'; readonly n: number; - readonly branch: BitString; + readonly branch: boolean; readonly child: VarHashmap; readonly value: X; } @@ -2712,24 +2707,6 @@ export function storeBoth(both: Both, storeX: (x: X) => (builder: Bu } -// bit$_ (## 1) = Bit; - -export function loadBit(slice: Slice): Bit { - let anon0: number = slice.loadUint(1); - return { - kind: 'Bit', - anon0: anon0, - } - -} - -export function storeBit(bit: Bit): (builder: Builder) => void { - return ((builder: Builder) => { - builder.storeUint(bit.anon0, 1); - }) - -} - export function hashmap_get_l(label: HmLabel): number { if ((label.kind == 'HmLabel_hml_short')) { let n = label.n; @@ -2854,8 +2831,8 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { slice.loadUint(1); let len: Unary = loadUnary(slice); let n = hmLabel_hml_short_get_n(len); - let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { - return slice.loadBits(1) + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBit() })); if ((!(n <= m))) { @@ -2873,8 +2850,8 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { slice.loadUint(2); let n: number = slice.loadUint(bitLen(m)); - let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { - return slice.loadBits(1) + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBit() })); return { @@ -2887,7 +2864,7 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { } if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { slice.loadUint(2); - let v: BitString = slice.loadBits(1); + let v: boolean = slice.loadBit(); let n: number = slice.loadUint(bitLen(m)); return { kind: 'HmLabel_hml_same', @@ -2905,8 +2882,8 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0b0, 1); storeUnary(hmLabel.len)(builder); - hmLabel.s.forEach(((arg: BitString) => { - builder.storeBits(arg); + hmLabel.s.forEach(((arg: boolean) => { + builder.storeBit(arg); })); if ((!(hmLabel.n <= hmLabel.m))) { throw new Error('Condition (hmLabel.n <= hmLabel.m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); @@ -2918,8 +2895,8 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0b10, 2); builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); - hmLabel.s.forEach(((arg: BitString) => { - builder.storeBits(arg); + hmLabel.s.forEach(((arg: boolean) => { + builder.storeBit(arg); })); }) @@ -2927,7 +2904,7 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { if ((hmLabel.kind == 'HmLabel_hml_same')) { return ((builder: Builder) => { builder.storeUint(0b11, 2); - builder.storeBits(hmLabel.v); + builder.storeBit(hmLabel.v); builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); }) @@ -3311,7 +3288,7 @@ export function loadVarHashmapNode(slice: Slice, arg0: number, loadX: (slice: } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let branch: BitString = slice.loadBits(1); + let branch: boolean = slice.loadBit(); let slice1 = slice.loadRef().beginParse(); let child: VarHashmap = loadVarHashmap(slice1, (arg0 - 1), loadX); let value: X = loadX(slice); @@ -3351,7 +3328,7 @@ export function storeVarHashmapNode(varHashmapNode: VarHashmapNode, storeX if ((varHashmapNode.kind == 'VarHashmapNode_vhmn_cont')) { return ((builder: Builder) => { builder.storeUint(0b1, 1); - builder.storeBits(varHashmapNode.branch); + builder.storeBit(varHashmapNode.branch); let cell1 = beginCell(); storeVarHashmap(varHashmapNode.child, storeX)(cell1); builder.storeRef(cell1); diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index fcee5bb..3937dc8 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -325,20 +325,20 @@ export interface HmLabel_hml_short { readonly m: number; readonly n: number; readonly len: Unary; - readonly s: Array; + readonly s: Array; } export interface HmLabel_hml_long { readonly kind: 'HmLabel_hml_long'; readonly m: number; readonly n: number; - readonly s: Array; + readonly s: Array; } export interface HmLabel_hml_same { readonly kind: 'HmLabel_hml_same'; readonly m: number; - readonly v: BitString; + readonly v: boolean; readonly n: number; } @@ -500,6 +500,11 @@ export interface AddressUser { readonly src: Address; } +export interface BitUser { + readonly kind: 'BitUser'; + readonly b: boolean; +} + // tmpa$_ a:# b:# = Simple; export function loadSimple(slice: Slice): Simple { @@ -1840,8 +1845,8 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { slice.loadUint(1); let len: Unary = loadUnary(slice); let n = hmLabel_hml_short_get_n(len); - let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { - return slice.loadBits(1) + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBit() })); if ((!(n <= m))) { @@ -1859,8 +1864,8 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { slice.loadUint(2); let n: number = slice.loadUint(bitLen(m)); - let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { - return slice.loadBits(1) + let s: Array = Array.from(Array(n).keys()).map(((arg: number) => { + return slice.loadBit() })); return { @@ -1873,7 +1878,7 @@ export function loadHmLabel(slice: Slice, m: number): HmLabel { } if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { slice.loadUint(2); - let v: BitString = slice.loadBits(1); + let v: boolean = slice.loadBit(); let n: number = slice.loadUint(bitLen(m)); return { kind: 'HmLabel_hml_same', @@ -1891,8 +1896,8 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0b0, 1); storeUnary(hmLabel.len)(builder); - hmLabel.s.forEach(((arg: BitString) => { - builder.storeBits(arg); + hmLabel.s.forEach(((arg: boolean) => { + builder.storeBit(arg); })); if ((!(hmLabel.n <= hmLabel.m))) { throw new Error('Condition (hmLabel.n <= hmLabel.m) is not satisfied while loading "HmLabel_hml_short" for type "HmLabel"'); @@ -1904,8 +1909,8 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0b10, 2); builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); - hmLabel.s.forEach(((arg: BitString) => { - builder.storeBits(arg); + hmLabel.s.forEach(((arg: boolean) => { + builder.storeBit(arg); })); }) @@ -1913,7 +1918,7 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { if ((hmLabel.kind == 'HmLabel_hml_same')) { return ((builder: Builder) => { builder.storeUint(0b11, 2); - builder.storeBits(hmLabel.v); + builder.storeBit(hmLabel.v); builder.storeUint(hmLabel.n, bitLen(hmLabel.m)); }) @@ -2560,3 +2565,21 @@ export function storeAddressUser(addressUser: AddressUser): (builder: Builder) = } +// a$_ b:Bit = BitUser; + +export function loadBitUser(slice: Slice): BitUser { + let b: boolean = slice.loadBit(); + return { + kind: 'BitUser', + b: b, + } + +} + +export function storeBitUser(bitUser: BitUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeBit(bitUser.b); + }) + +} + diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index 60cf64f..755f48d 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -137,4 +137,8 @@ addr_std$10 anycast:(Maybe Anycast) addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) workchain_id:int32 address:(bits addr_len) = MsgAddressInt; -_ src:MsgAddressInt = AddressUser; \ No newline at end of file +_ src:MsgAddressInt = AddressUser; + +bit$_ (## 1) = Bit; + +a$_ b:Bit = BitUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 5b6f21b..62fb020 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -71,7 +71,15 @@ function getBitStringOne(bit: boolean): BitString { function getBitStringArray(bitString: string) { let result: BitString[] = []; for (let i = 0; i < bitString.length; i++) { - result.push(getBitStringOne(bitString[i] == '0')) + result.push(getBitStringOne(bitString[i] == '1')) + } + return result; +} + +function getBooleanArray(bitString: string) { + let result: boolean[] = []; + for (let i = 0; i < bitString.length; i++) { + result.push(bitString[i] == '1') } return result; } @@ -243,9 +251,12 @@ describe('Generating tlb code', () => { checkThrowOnStoreLoad(equalityExpressionIncorrect, loadEqualityExpression, storeEqualityExpression); }) - test('Hashmap', () => { + test('Builtins', () => { expect.hasAssertions() + let boolUser: BoolUser = { kind: 'BoolUser', a: true } + checkSameOnStoreLoad(boolUser, loadBoolUser, storeBoolUser); + let hashmapEUser: HashmapEUser = { kind: 'HashmapEUser', x: { @@ -272,7 +283,7 @@ describe('Generating tlb code', () => { kind: 'HmLabel_hml_long', m: 7, n: 2, - s: getBitStringArray('00') + s: getBooleanArray('00') }, node: { kind: 'HashmapNode_hmn_fork', @@ -286,7 +297,7 @@ describe('Generating tlb code', () => { kind: 'HmLabel_hml_long', m: 4, n: 4, - s: getBitStringArray('0001') + s: getBooleanArray('0001') }, node: { kind: 'HashmapNode_hmn_leaf', @@ -302,7 +313,7 @@ describe('Generating tlb code', () => { kind: 'HmLabel_hml_long', m: 4, n: 4, - s: getBitStringArray('0001') + s: getBooleanArray('0001') }, node: { kind: 'HashmapNode_hmn_leaf', @@ -320,7 +331,7 @@ describe('Generating tlb code', () => { kind: 'HmLabel_hml_long', m: 7, n: 7, - s: getBitStringArray('0000000') + s: getBooleanArray('0000000') }, node: { kind: 'HashmapNode_hmn_leaf', From 124cf03a46c19d60065f23c52d45d27297feeda3 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Thu, 11 Jan 2024 20:20:50 -0500 Subject: [PATCH 03/28] add grams builtin --- src/ast.ts | 5 + src/astbuilder/fill_constructors.ts | 1 + src/astbuilder/handle_type.ts | 2 + src/generators/typescript/generator.ts | 8 + test/generated_files/generated_block.ts | 405 ++++++++++++------------ test/generated_files/generated_test.ts | 23 ++ test/tlb/test.tlb | 4 +- test/tlbgen.spec.ts | 5 +- 8 files changed, 257 insertions(+), 196 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index d0fbede..629abe4 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -76,6 +76,10 @@ export type TLBBoolType = { kind: "TLBBoolType"; }; +export type TLBCoinsType = { + kind: "TLBCoinsType"; +} + export type TLBAddressType = { kind: "TLBAddressType"; }; @@ -123,6 +127,7 @@ export type TLBFieldType = | TLBBitsType | TLBNamedType | TLBBoolType + | TLBCoinsType | TLBAddressType | TLBCellType | TLBMathExprType diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index fd44f61..d5ec7af 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -427,6 +427,7 @@ function checkAndRemovePrimitives( typesToDelete.set("Bool", ["4702fd23", "f0e8d7f"]); typesToDelete.set("MsgAddressInt", ["d7b672a", "6d593e8a"]); typesToDelete.set("Bit", ["2873c6f5"]) + typesToDelete.set("Grams", ["2f73160b"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 7a7bec0..e6d0c6b 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -221,6 +221,8 @@ export function getType( return { kind: "TLBAddressType" }; } else if (expr.name == "Bit") { return { kind:"TLBBitsType", bits: new TLBNumberExpr(1) } + } else if (expr.name == "Grams") { + return { kind:"TLBCoinsType"} } else { if (constructor.variablesMap.get(expr.name)?.type == "#") { return { diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index f240d04..21b0b78 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -711,6 +711,14 @@ export class TypescriptGenerator implements CodeGenerator { fieldLoadSuffix: "Boolean", fieldStoreSuffix: "Bit", }; + } else if (fieldType.kind == "TLBCoinsType") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "bigint", + fieldLoadSuffix: "Coins", + fieldStoreSuffix: "Coins", + }; } else if (fieldType.kind == "TLBAddressType") { exprForParam = { argLoadExpr: undefined, diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 57e0d85..1772f30 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -298,14 +298,9 @@ export interface VarInteger { readonly value: bigint; } -export interface Grams { - readonly kind: 'Grams'; - readonly amount: VarUInteger; -} - export interface Coins { readonly kind: 'Coins'; - readonly grams: Grams; + readonly grams: bigint; } export interface ExtraCurrencyCollection { @@ -315,7 +310,7 @@ export interface ExtraCurrencyCollection { export interface CurrencyCollection { readonly kind: 'CurrencyCollection'; - readonly grams: Grams; + readonly grams: bigint; readonly other: ExtraCurrencyCollection; } @@ -329,8 +324,8 @@ export interface CommonMsgInfo_int_msg_info { readonly src: Address; readonly dest: Address; readonly value: CurrencyCollection; - readonly ihr_fee: Grams; - readonly fwd_fee: Grams; + readonly ihr_fee: bigint; + readonly fwd_fee: bigint; readonly created_lt: number; readonly created_at: number; } @@ -339,7 +334,7 @@ export interface CommonMsgInfo_ext_in_msg_info { readonly kind: 'CommonMsgInfo_ext_in_msg_info'; readonly src: MsgAddressExt; readonly dest: Address; - readonly import_fee: Grams; + readonly import_fee: bigint; } export interface CommonMsgInfo_ext_out_msg_info { @@ -360,8 +355,8 @@ export interface CommonMsgInfoRelaxed_int_msg_info { readonly src: MsgAddress; readonly dest: Address; readonly value: CurrencyCollection; - readonly ihr_fee: Grams; - readonly fwd_fee: Grams; + readonly ihr_fee: bigint; + readonly fwd_fee: bigint; readonly created_lt: number; readonly created_at: number; } @@ -446,7 +441,7 @@ export interface MsgEnvelope { readonly kind: 'MsgEnvelope'; readonly cur_addr: IntermediateAddress; readonly next_addr: IntermediateAddress; - readonly fwd_fee_remaining: Grams; + readonly fwd_fee_remaining: bigint; readonly msg: Message; } @@ -462,7 +457,7 @@ export interface InMsg_msg_import_ihr { readonly kind: 'InMsg_msg_import_ihr'; readonly msg: Message; readonly transaction: Transaction; - readonly ihr_fee: Grams; + readonly ihr_fee: bigint; readonly proof_created: Slice; } @@ -470,41 +465,41 @@ export interface InMsg_msg_import_imm { readonly kind: 'InMsg_msg_import_imm'; readonly in_msg: MsgEnvelope; readonly transaction: Transaction; - readonly fwd_fee: Grams; + readonly fwd_fee: bigint; } export interface InMsg_msg_import_fin { readonly kind: 'InMsg_msg_import_fin'; readonly in_msg: MsgEnvelope; readonly transaction: Transaction; - readonly fwd_fee: Grams; + readonly fwd_fee: bigint; } export interface InMsg_msg_import_tr { readonly kind: 'InMsg_msg_import_tr'; readonly in_msg: MsgEnvelope; readonly out_msg: MsgEnvelope; - readonly transit_fee: Grams; + readonly transit_fee: bigint; } export interface InMsg_msg_discard_fin { readonly kind: 'InMsg_msg_discard_fin'; readonly in_msg: MsgEnvelope; readonly transaction_id: number; - readonly fwd_fee: Grams; + readonly fwd_fee: bigint; } export interface InMsg_msg_discard_tr { readonly kind: 'InMsg_msg_discard_tr'; readonly in_msg: MsgEnvelope; readonly transaction_id: number; - readonly fwd_fee: Grams; + readonly fwd_fee: bigint; readonly proof_delivered: Slice; } export interface ImportFees { readonly kind: 'ImportFees'; - readonly fees_collected: Grams; + readonly fees_collected: bigint; readonly value_imported: CurrencyCollection; } @@ -627,7 +622,7 @@ export interface StorageInfo { readonly kind: 'StorageInfo'; readonly used: StorageUsed; readonly last_paid: number; - readonly due_payment: Maybe; + readonly due_payment: Maybe; } export type Account = Account_account_none | Account_account; @@ -754,8 +749,8 @@ export interface ShardAccountBlocks { export interface TrStoragePhase { readonly kind: 'TrStoragePhase'; - readonly storage_fees_collected: Grams; - readonly storage_fees_due: Maybe; + readonly storage_fees_collected: bigint; + readonly storage_fees_due: Maybe; readonly status_change: AccStatusChange; } @@ -775,7 +770,7 @@ export interface AccStatusChange_acst_deleted { export interface TrCreditPhase { readonly kind: 'TrCreditPhase'; - readonly due_fees_collected: Maybe; + readonly due_fees_collected: Maybe; readonly credit: CurrencyCollection; } @@ -791,7 +786,7 @@ export interface TrComputePhase_tr_phase_compute_vm { readonly success: boolean; readonly msg_state_used: boolean; readonly account_activated: boolean; - readonly gas_fees: Grams; + readonly gas_fees: bigint; readonly gas_used: VarUInteger; readonly gas_limit: VarUInteger; readonly gas_credit: Maybe; @@ -827,8 +822,8 @@ export interface TrActionPhase { readonly valid: boolean; readonly no_funds: boolean; readonly status_change: AccStatusChange; - readonly total_fwd_fees: Maybe; - readonly total_action_fees: Maybe; + readonly total_fwd_fees: Maybe; + readonly total_action_fees: Maybe; readonly result_code: number; readonly result_arg: Maybe; readonly tot_actions: number; @@ -848,14 +843,14 @@ export interface TrBouncePhase_tr_phase_bounce_negfunds { export interface TrBouncePhase_tr_phase_bounce_nofunds { readonly kind: 'TrBouncePhase_tr_phase_bounce_nofunds'; readonly msg_size: StorageUsedShort; - readonly req_fwd_fees: Grams; + readonly req_fwd_fees: bigint; } export interface TrBouncePhase_tr_phase_bounce_ok { readonly kind: 'TrBouncePhase_tr_phase_bounce_ok'; readonly msg_size: StorageUsedShort; - readonly msg_fees: Grams; - readonly fwd_fees: Grams; + readonly msg_fees: bigint; + readonly fwd_fees: bigint; } export type TransactionDescr = TransactionDescr_trans_ord | TransactionDescr_trans_storage | TransactionDescr_trans_tick_tock | TransactionDescr_trans_split_prepare | TransactionDescr_trans_split_install | TransactionDescr_trans_merge_prepare | TransactionDescr_trans_merge_install; @@ -1472,8 +1467,8 @@ export interface ConfigParam__5 { export interface ConfigParam__6 { readonly kind: 'ConfigParam__6'; - readonly mint_new_price: Grams; - readonly mint_add_price: Grams; + readonly mint_new_price: bigint; + readonly mint_add_price: bigint; } export interface ConfigParam__7 { @@ -1533,9 +1528,9 @@ export interface ConfigParam__16 { export interface ConfigParam__17 { readonly kind: 'ConfigParam__17'; - readonly min_stake: Grams; - readonly max_stake: Grams; - readonly min_total_stake: Grams; + readonly min_stake: bigint; + readonly max_stake: bigint; + readonly min_total_stake: bigint; readonly max_stake_factor: number; } @@ -1786,15 +1781,15 @@ export interface WorkchainDescr_workchain_v2 { export interface ComplaintPricing { readonly kind: 'ComplaintPricing'; - readonly deposit: Grams; - readonly bit_price: Grams; - readonly _cell_price: Grams; + readonly deposit: bigint; + readonly bit_price: bigint; + readonly _cell_price: bigint; } export interface BlockCreateFees { readonly kind: 'BlockCreateFees'; - readonly masterchain_block_fee: Grams; - readonly basechain_block_fee: Grams; + readonly masterchain_block_fee: bigint; + readonly basechain_block_fee: bigint; } export interface StoragePrices { @@ -1955,7 +1950,7 @@ export interface ValidatorSignedTempKey { export interface MisbehaviourPunishmentConfig { readonly kind: 'MisbehaviourPunishmentConfig'; - readonly default_flat_fine: Grams; + readonly default_flat_fine: bigint; readonly default_proportional_fine: number; readonly severity_flat_mult: number; readonly severity_proportional_mult: number; @@ -2113,8 +2108,8 @@ export interface ValidatorComplaint { readonly created_at: number; readonly severity: number; readonly reward_addr: bigint; - readonly paid: Grams; - readonly suggested_fine: Grams; + readonly paid: bigint; + readonly suggested_fine: bigint; readonly suggested_fine_part: number; } @@ -2441,7 +2436,7 @@ export interface ChanConfig { readonly a_addr: Address; readonly b_addr: Address; readonly channel_id: number; - readonly min_A_extra: Grams; + readonly min_A_extra: bigint; } export type ChanState = ChanState_chan_state_init | ChanState_chan_state_close | ChanState_chan_state_payout; @@ -2450,35 +2445,35 @@ export interface ChanState_chan_state_init { readonly kind: 'ChanState_chan_state_init'; readonly signed_A: boolean; readonly signed_B: boolean; - readonly min_A: Grams; - readonly min_B: Grams; + readonly min_A: bigint; + readonly min_B: bigint; readonly expire_at: number; - readonly A: Grams; - readonly B: Grams; + readonly A: bigint; + readonly B: bigint; } export interface ChanState_chan_state_close { readonly kind: 'ChanState_chan_state_close'; readonly signed_A: boolean; readonly signed_B: boolean; - readonly promise_A: Grams; - readonly promise_B: Grams; + readonly promise_A: bigint; + readonly promise_B: bigint; readonly expire_at: number; - readonly A: Grams; - readonly B: Grams; + readonly A: bigint; + readonly B: bigint; } export interface ChanState_chan_state_payout { readonly kind: 'ChanState_chan_state_payout'; - readonly A: Grams; - readonly B: Grams; + readonly A: bigint; + readonly B: bigint; } export interface ChanPromise { readonly kind: 'ChanPromise'; readonly channel_id: number; - readonly promise_A: Grams; - readonly promise_B: Grams; + readonly promise_A: bigint; + readonly promise_B: bigint; } export interface ChanSignedPromise { @@ -2491,17 +2486,17 @@ export type ChanMsg = ChanMsg_chan_msg_init | ChanMsg_chan_msg_close | ChanMsg_c export interface ChanMsg_chan_msg_init { readonly kind: 'ChanMsg_chan_msg_init'; - readonly inc_A: Grams; - readonly inc_B: Grams; - readonly min_A: Grams; - readonly min_B: Grams; + readonly inc_A: bigint; + readonly inc_B: bigint; + readonly min_A: bigint; + readonly min_B: bigint; readonly channel_id: number; } export interface ChanMsg_chan_msg_close { readonly kind: 'ChanMsg_chan_msg_close'; - readonly extra_A: Grams; - readonly extra_B: Grams; + readonly extra_A: bigint; + readonly extra_B: bigint; readonly promise: ChanSignedPromise; } @@ -3710,28 +3705,10 @@ export function storeVarInteger(varInteger: VarInteger): (builder: Builder) => v } -// nanograms$_ amount:(VarUInteger 16) = Grams; - -export function loadGrams(slice: Slice): Grams { - let amount: VarUInteger = loadVarUInteger(slice, 16); - return { - kind: 'Grams', - amount: amount, - } - -} - -export function storeGrams(grams: Grams): (builder: Builder) => void { - return ((builder: Builder) => { - storeVarUInteger(grams.amount)(builder); - }) - -} - // _ grams:Grams = Coins; export function loadCoins(slice: Slice): Coins { - let grams: Grams = loadGrams(slice); + let grams: bigint = slice.loadCoins(); return { kind: 'Coins', grams: grams, @@ -3741,7 +3718,7 @@ export function loadCoins(slice: Slice): Coins { export function storeCoins(coins: Coins): (builder: Builder) => void { return ((builder: Builder) => { - storeGrams(coins.grams)(builder); + builder.storeCoins(coins.grams); }) } @@ -3781,7 +3758,7 @@ currencies$_ grams:Grams other:ExtraCurrencyCollection */ export function loadCurrencyCollection(slice: Slice): CurrencyCollection { - let grams: Grams = loadGrams(slice); + let grams: bigint = slice.loadCoins(); let other: ExtraCurrencyCollection = loadExtraCurrencyCollection(slice); return { kind: 'CurrencyCollection', @@ -3793,7 +3770,7 @@ export function loadCurrencyCollection(slice: Slice): CurrencyCollection { export function storeCurrencyCollection(currencyCollection: CurrencyCollection): (builder: Builder) => void { return ((builder: Builder) => { - storeGrams(currencyCollection.grams)(builder); + builder.storeCoins(currencyCollection.grams); storeExtraCurrencyCollection(currencyCollection.other)(builder); }) @@ -3825,8 +3802,8 @@ export function loadCommonMsgInfo(slice: Slice): CommonMsgInfo { let src: Address = slice.loadAddress(); let dest: Address = slice.loadAddress(); let value: CurrencyCollection = loadCurrencyCollection(slice); - let ihr_fee: Grams = loadGrams(slice); - let fwd_fee: Grams = loadGrams(slice); + let ihr_fee: bigint = slice.loadCoins(); + let fwd_fee: bigint = slice.loadCoins(); let created_lt: number = slice.loadUint(64); let created_at: number = slice.loadUint(32); return { @@ -3848,7 +3825,7 @@ export function loadCommonMsgInfo(slice: Slice): CommonMsgInfo { slice.loadUint(2); let src: MsgAddressExt = loadMsgAddressExt(slice); let dest: Address = slice.loadAddress(); - let import_fee: Grams = loadGrams(slice); + let import_fee: bigint = slice.loadCoins(); return { kind: 'CommonMsgInfo_ext_in_msg_info', src: src, @@ -3885,8 +3862,8 @@ export function storeCommonMsgInfo(commonMsgInfo: CommonMsgInfo): (builder: Buil builder.storeAddress(commonMsgInfo.src); builder.storeAddress(commonMsgInfo.dest); storeCurrencyCollection(commonMsgInfo.value)(builder); - storeGrams(commonMsgInfo.ihr_fee)(builder); - storeGrams(commonMsgInfo.fwd_fee)(builder); + builder.storeCoins(commonMsgInfo.ihr_fee); + builder.storeCoins(commonMsgInfo.fwd_fee); builder.storeUint(commonMsgInfo.created_lt, 64); builder.storeUint(commonMsgInfo.created_at, 32); }) @@ -3897,7 +3874,7 @@ export function storeCommonMsgInfo(commonMsgInfo: CommonMsgInfo): (builder: Buil builder.storeUint(0b10, 2); storeMsgAddressExt(commonMsgInfo.src)(builder); builder.storeAddress(commonMsgInfo.dest); - storeGrams(commonMsgInfo.import_fee)(builder); + builder.storeCoins(commonMsgInfo.import_fee); }) } @@ -3935,8 +3912,8 @@ export function loadCommonMsgInfoRelaxed(slice: Slice): CommonMsgInfoRelaxed { let src: MsgAddress = loadMsgAddress(slice); let dest: Address = slice.loadAddress(); let value: CurrencyCollection = loadCurrencyCollection(slice); - let ihr_fee: Grams = loadGrams(slice); - let fwd_fee: Grams = loadGrams(slice); + let ihr_fee: bigint = slice.loadCoins(); + let fwd_fee: bigint = slice.loadCoins(); let created_lt: number = slice.loadUint(64); let created_at: number = slice.loadUint(32); return { @@ -3982,8 +3959,8 @@ export function storeCommonMsgInfoRelaxed(commonMsgInfoRelaxed: CommonMsgInfoRel storeMsgAddress(commonMsgInfoRelaxed.src)(builder); builder.storeAddress(commonMsgInfoRelaxed.dest); storeCurrencyCollection(commonMsgInfoRelaxed.value)(builder); - storeGrams(commonMsgInfoRelaxed.ihr_fee)(builder); - storeGrams(commonMsgInfoRelaxed.fwd_fee)(builder); + builder.storeCoins(commonMsgInfoRelaxed.ihr_fee); + builder.storeCoins(commonMsgInfoRelaxed.fwd_fee); builder.storeUint(commonMsgInfoRelaxed.created_lt, 64); builder.storeUint(commonMsgInfoRelaxed.created_at, 32); }) @@ -4425,7 +4402,7 @@ export function loadMsgEnvelope(slice: Slice): MsgEnvelope { slice.loadUint(4); let cur_addr: IntermediateAddress = loadIntermediateAddress(slice); let next_addr: IntermediateAddress = loadIntermediateAddress(slice); - let fwd_fee_remaining: Grams = loadGrams(slice); + let fwd_fee_remaining: bigint = slice.loadCoins(); let slice1 = slice.loadRef().beginParse(); let msg: Message = loadMessage(slice1, ((slice: Slice) => { return slice @@ -4448,7 +4425,7 @@ export function storeMsgEnvelope(msgEnvelope: MsgEnvelope): (builder: Builder) = builder.storeUint(0x4, 4); storeIntermediateAddress(msgEnvelope.cur_addr)(builder); storeIntermediateAddress(msgEnvelope.next_addr)(builder); - storeGrams(msgEnvelope.fwd_fee_remaining)(builder); + builder.storeCoins(msgEnvelope.fwd_fee_remaining); let cell1 = beginCell(); storeMessage(msgEnvelope.msg, ((arg: Slice) => { return ((builder: Builder) => { @@ -4522,7 +4499,7 @@ export function loadInMsg(slice: Slice): InMsg { })); let slice2 = slice.loadRef().beginParse(); let transaction: Transaction = loadTransaction(slice2); - let ihr_fee: Grams = loadGrams(slice); + let ihr_fee: bigint = slice.loadCoins(); let slice3 = slice.loadRef().beginParse(); let proof_created: Slice = slice3; return { @@ -4540,7 +4517,7 @@ export function loadInMsg(slice: Slice): InMsg { let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let slice2 = slice.loadRef().beginParse(); let transaction: Transaction = loadTransaction(slice2); - let fwd_fee: Grams = loadGrams(slice); + let fwd_fee: bigint = slice.loadCoins(); return { kind: 'InMsg_msg_import_imm', in_msg: in_msg, @@ -4555,7 +4532,7 @@ export function loadInMsg(slice: Slice): InMsg { let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let slice2 = slice.loadRef().beginParse(); let transaction: Transaction = loadTransaction(slice2); - let fwd_fee: Grams = loadGrams(slice); + let fwd_fee: bigint = slice.loadCoins(); return { kind: 'InMsg_msg_import_fin', in_msg: in_msg, @@ -4570,7 +4547,7 @@ export function loadInMsg(slice: Slice): InMsg { let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let slice2 = slice.loadRef().beginParse(); let out_msg: MsgEnvelope = loadMsgEnvelope(slice2); - let transit_fee: Grams = loadGrams(slice); + let transit_fee: bigint = slice.loadCoins(); return { kind: 'InMsg_msg_import_tr', in_msg: in_msg, @@ -4584,7 +4561,7 @@ export function loadInMsg(slice: Slice): InMsg { let slice1 = slice.loadRef().beginParse(); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let transaction_id: number = slice.loadUint(64); - let fwd_fee: Grams = loadGrams(slice); + let fwd_fee: bigint = slice.loadCoins(); return { kind: 'InMsg_msg_discard_fin', in_msg: in_msg, @@ -4598,7 +4575,7 @@ export function loadInMsg(slice: Slice): InMsg { let slice1 = slice.loadRef().beginParse(); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let transaction_id: number = slice.loadUint(64); - let fwd_fee: Grams = loadGrams(slice); + let fwd_fee: bigint = slice.loadCoins(); let slice2 = slice.loadRef().beginParse(); let proof_delivered: Slice = slice2; return { @@ -4645,7 +4622,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { let cell2 = beginCell(); storeTransaction(inMsg.transaction)(cell2); builder.storeRef(cell2); - storeGrams(inMsg.ihr_fee)(builder); + builder.storeCoins(inMsg.ihr_fee); let cell3 = beginCell(); cell3.storeSlice(inMsg.proof_created); builder.storeRef(cell3); @@ -4661,7 +4638,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { let cell2 = beginCell(); storeTransaction(inMsg.transaction)(cell2); builder.storeRef(cell2); - storeGrams(inMsg.fwd_fee)(builder); + builder.storeCoins(inMsg.fwd_fee); }) } @@ -4674,7 +4651,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { let cell2 = beginCell(); storeTransaction(inMsg.transaction)(cell2); builder.storeRef(cell2); - storeGrams(inMsg.fwd_fee)(builder); + builder.storeCoins(inMsg.fwd_fee); }) } @@ -4687,7 +4664,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { let cell2 = beginCell(); storeMsgEnvelope(inMsg.out_msg)(cell2); builder.storeRef(cell2); - storeGrams(inMsg.transit_fee)(builder); + builder.storeCoins(inMsg.transit_fee); }) } @@ -4698,7 +4675,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { storeMsgEnvelope(inMsg.in_msg)(cell1); builder.storeRef(cell1); builder.storeUint(inMsg.transaction_id, 64); - storeGrams(inMsg.fwd_fee)(builder); + builder.storeCoins(inMsg.fwd_fee); }) } @@ -4709,7 +4686,7 @@ export function storeInMsg(inMsg: InMsg): (builder: Builder) => void { storeMsgEnvelope(inMsg.in_msg)(cell1); builder.storeRef(cell1); builder.storeUint(inMsg.transaction_id, 64); - storeGrams(inMsg.fwd_fee)(builder); + builder.storeCoins(inMsg.fwd_fee); let cell2 = beginCell(); cell2.storeSlice(inMsg.proof_delivered); builder.storeRef(cell2); @@ -4725,7 +4702,7 @@ import_fees$_ fees_collected:Grams */ export function loadImportFees(slice: Slice): ImportFees { - let fees_collected: Grams = loadGrams(slice); + let fees_collected: bigint = slice.loadCoins(); let value_imported: CurrencyCollection = loadCurrencyCollection(slice); return { kind: 'ImportFees', @@ -4737,7 +4714,7 @@ export function loadImportFees(slice: Slice): ImportFees { export function storeImportFees(importFees: ImportFees): (builder: Builder) => void { return ((builder: Builder) => { - storeGrams(importFees.fees_collected)(builder); + builder.storeCoins(importFees.fees_collected); storeCurrencyCollection(importFees.value_imported)(builder); }) @@ -5250,7 +5227,10 @@ storage_info$_ used:StorageUsed last_paid:uint32 export function loadStorageInfo(slice: Slice): StorageInfo { let used: StorageUsed = loadStorageUsed(slice); let last_paid: number = slice.loadUint(32); - let due_payment: Maybe = loadMaybe(slice, loadGrams); + let due_payment: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadCoins() + + })); return { kind: 'StorageInfo', used: used, @@ -5264,7 +5244,12 @@ export function storeStorageInfo(storageInfo: StorageInfo): (builder: Builder) = return ((builder: Builder) => { storeStorageUsed(storageInfo.used)(builder); builder.storeUint(storageInfo.last_paid, 32); - storeMaybe(storageInfo.due_payment, storeGrams)(builder); + storeMaybe(storageInfo.due_payment, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + }))(builder); }) } @@ -5836,8 +5821,11 @@ tr_phase_storage$_ storage_fees_collected:Grams */ export function loadTrStoragePhase(slice: Slice): TrStoragePhase { - let storage_fees_collected: Grams = loadGrams(slice); - let storage_fees_due: Maybe = loadMaybe(slice, loadGrams); + let storage_fees_collected: bigint = slice.loadCoins(); + let storage_fees_due: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadCoins() + + })); let status_change: AccStatusChange = loadAccStatusChange(slice); return { kind: 'TrStoragePhase', @@ -5850,8 +5838,13 @@ export function loadTrStoragePhase(slice: Slice): TrStoragePhase { export function storeTrStoragePhase(trStoragePhase: TrStoragePhase): (builder: Builder) => void { return ((builder: Builder) => { - storeGrams(trStoragePhase.storage_fees_collected)(builder); - storeMaybe(trStoragePhase.storage_fees_due, storeGrams)(builder); + builder.storeCoins(trStoragePhase.storage_fees_collected); + storeMaybe(trStoragePhase.storage_fees_due, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + }))(builder); storeAccStatusChange(trStoragePhase.status_change)(builder); }) @@ -5916,7 +5909,10 @@ tr_phase_credit$_ due_fees_collected:(Maybe Grams) */ export function loadTrCreditPhase(slice: Slice): TrCreditPhase { - let due_fees_collected: Maybe = loadMaybe(slice, loadGrams); + let due_fees_collected: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadCoins() + + })); let credit: CurrencyCollection = loadCurrencyCollection(slice); return { kind: 'TrCreditPhase', @@ -5928,7 +5924,12 @@ export function loadTrCreditPhase(slice: Slice): TrCreditPhase { export function storeTrCreditPhase(trCreditPhase: TrCreditPhase): (builder: Builder) => void { return ((builder: Builder) => { - storeMaybe(trCreditPhase.due_fees_collected, storeGrams)(builder); + storeMaybe(trCreditPhase.due_fees_collected, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + }))(builder); storeCurrencyCollection(trCreditPhase.credit)(builder); }) @@ -5965,7 +5966,7 @@ export function loadTrComputePhase(slice: Slice): TrComputePhase { let success: boolean = slice.loadBoolean(); let msg_state_used: boolean = slice.loadBoolean(); let account_activated: boolean = slice.loadBoolean(); - let gas_fees: Grams = loadGrams(slice); + let gas_fees: bigint = slice.loadCoins(); let slice1 = slice.loadRef().beginParse(); let gas_used: VarUInteger = loadVarUInteger(slice1, 7); let gas_limit: VarUInteger = loadVarUInteger(slice1, 7); @@ -6017,7 +6018,7 @@ export function storeTrComputePhase(trComputePhase: TrComputePhase): (builder: B builder.storeBit(trComputePhase.success); builder.storeBit(trComputePhase.msg_state_used); builder.storeBit(trComputePhase.account_activated); - storeGrams(trComputePhase.gas_fees)(builder); + builder.storeCoins(trComputePhase.gas_fees); let cell1 = beginCell(); storeVarUInteger(trComputePhase.gas_used)(cell1); storeVarUInteger(trComputePhase.gas_limit)(cell1); @@ -6128,8 +6129,14 @@ export function loadTrActionPhase(slice: Slice): TrActionPhase { let valid: boolean = slice.loadBoolean(); let no_funds: boolean = slice.loadBoolean(); let status_change: AccStatusChange = loadAccStatusChange(slice); - let total_fwd_fees: Maybe = loadMaybe(slice, loadGrams); - let total_action_fees: Maybe = loadMaybe(slice, loadGrams); + let total_fwd_fees: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadCoins() + + })); + let total_action_fees: Maybe = loadMaybe(slice, ((slice: Slice) => { + return slice.loadCoins() + + })); let result_code: number = slice.loadInt(32); let result_arg: Maybe = loadMaybe(slice, ((slice: Slice) => { return slice.loadInt(32) @@ -6167,8 +6174,18 @@ export function storeTrActionPhase(trActionPhase: TrActionPhase): (builder: Buil builder.storeBit(trActionPhase.valid); builder.storeBit(trActionPhase.no_funds); storeAccStatusChange(trActionPhase.status_change)(builder); - storeMaybe(trActionPhase.total_fwd_fees, storeGrams)(builder); - storeMaybe(trActionPhase.total_action_fees, storeGrams)(builder); + storeMaybe(trActionPhase.total_fwd_fees, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + }))(builder); + storeMaybe(trActionPhase.total_action_fees, ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + }))(builder); builder.storeInt(trActionPhase.result_code, 32); storeMaybe(trActionPhase.result_arg, ((arg: number) => { return ((builder: Builder) => { @@ -6209,7 +6226,7 @@ export function loadTrBouncePhase(slice: Slice): TrBouncePhase { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { slice.loadUint(2); let msg_size: StorageUsedShort = loadStorageUsedShort(slice); - let req_fwd_fees: Grams = loadGrams(slice); + let req_fwd_fees: bigint = slice.loadCoins(); return { kind: 'TrBouncePhase_tr_phase_bounce_nofunds', msg_size: msg_size, @@ -6220,8 +6237,8 @@ export function loadTrBouncePhase(slice: Slice): TrBouncePhase { if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); let msg_size: StorageUsedShort = loadStorageUsedShort(slice); - let msg_fees: Grams = loadGrams(slice); - let fwd_fees: Grams = loadGrams(slice); + let msg_fees: bigint = slice.loadCoins(); + let fwd_fees: bigint = slice.loadCoins(); return { kind: 'TrBouncePhase_tr_phase_bounce_ok', msg_size: msg_size, @@ -6244,7 +6261,7 @@ export function storeTrBouncePhase(trBouncePhase: TrBouncePhase): (builder: Buil return ((builder: Builder) => { builder.storeUint(0b01, 2); storeStorageUsedShort(trBouncePhase.msg_size)(builder); - storeGrams(trBouncePhase.req_fwd_fees)(builder); + builder.storeCoins(trBouncePhase.req_fwd_fees); }) } @@ -6252,8 +6269,8 @@ export function storeTrBouncePhase(trBouncePhase: TrBouncePhase): (builder: Buil return ((builder: Builder) => { builder.storeUint(0b1, 1); storeStorageUsedShort(trBouncePhase.msg_size)(builder); - storeGrams(trBouncePhase.msg_fees)(builder); - storeGrams(trBouncePhase.fwd_fees)(builder); + builder.storeCoins(trBouncePhase.msg_fees); + builder.storeCoins(trBouncePhase.fwd_fees); }) } @@ -8988,8 +9005,8 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 6)) { - let mint_new_price: Grams = loadGrams(slice); - let mint_add_price: Grams = loadGrams(slice); + let mint_new_price: bigint = slice.loadCoins(); + let mint_add_price: bigint = slice.loadCoins(); return { kind: 'ConfigParam__6', mint_new_price: mint_new_price, @@ -9097,9 +9114,9 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 17)) { - let min_stake: Grams = loadGrams(slice); - let max_stake: Grams = loadGrams(slice); - let min_total_stake: Grams = loadGrams(slice); + let min_stake: bigint = slice.loadCoins(); + let max_stake: bigint = slice.loadCoins(); + let min_total_stake: bigint = slice.loadCoins(); let max_stake_factor: number = slice.loadUint(32); return { kind: 'ConfigParam__17', @@ -9368,8 +9385,8 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__6')) { return ((builder: Builder) => { - storeGrams(configParam.mint_new_price)(builder); - storeGrams(configParam.mint_add_price)(builder); + builder.storeCoins(configParam.mint_new_price); + builder.storeCoins(configParam.mint_add_price); }) } @@ -9449,9 +9466,9 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__17')) { return ((builder: Builder) => { - storeGrams(configParam.min_stake)(builder); - storeGrams(configParam.max_stake)(builder); - storeGrams(configParam.min_total_stake)(builder); + builder.storeCoins(configParam.min_stake); + builder.storeCoins(configParam.max_stake); + builder.storeCoins(configParam.min_total_stake); builder.storeUint(configParam.max_stake_factor, 32); }) @@ -10168,9 +10185,9 @@ export function storeWorkchainDescr(workchainDescr: WorkchainDescr): (builder: B export function loadComplaintPricing(slice: Slice): ComplaintPricing { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x1a))) { slice.loadUint(8); - let deposit: Grams = loadGrams(slice); - let bit_price: Grams = loadGrams(slice); - let _cell_price: Grams = loadGrams(slice); + let deposit: bigint = slice.loadCoins(); + let bit_price: bigint = slice.loadCoins(); + let _cell_price: bigint = slice.loadCoins(); return { kind: 'ComplaintPricing', deposit: deposit, @@ -10185,9 +10202,9 @@ export function loadComplaintPricing(slice: Slice): ComplaintPricing { export function storeComplaintPricing(complaintPricing: ComplaintPricing): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x1a, 8); - storeGrams(complaintPricing.deposit)(builder); - storeGrams(complaintPricing.bit_price)(builder); - storeGrams(complaintPricing._cell_price)(builder); + builder.storeCoins(complaintPricing.deposit); + builder.storeCoins(complaintPricing.bit_price); + builder.storeCoins(complaintPricing._cell_price); }) } @@ -10200,8 +10217,8 @@ block_grams_created#6b masterchain_block_fee:Grams basechain_block_fee:Grams export function loadBlockCreateFees(slice: Slice): BlockCreateFees { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x6b))) { slice.loadUint(8); - let masterchain_block_fee: Grams = loadGrams(slice); - let basechain_block_fee: Grams = loadGrams(slice); + let masterchain_block_fee: bigint = slice.loadCoins(); + let basechain_block_fee: bigint = slice.loadCoins(); return { kind: 'BlockCreateFees', masterchain_block_fee: masterchain_block_fee, @@ -10215,8 +10232,8 @@ export function loadBlockCreateFees(slice: Slice): BlockCreateFees { export function storeBlockCreateFees(blockCreateFees: BlockCreateFees): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x6b, 8); - storeGrams(blockCreateFees.masterchain_block_fee)(builder); - storeGrams(blockCreateFees.basechain_block_fee)(builder); + builder.storeCoins(blockCreateFees.masterchain_block_fee); + builder.storeCoins(blockCreateFees.basechain_block_fee); }) } @@ -10901,7 +10918,7 @@ misbehaviour_punishment_config_v1#01 export function loadMisbehaviourPunishmentConfig(slice: Slice): MisbehaviourPunishmentConfig { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x01))) { slice.loadUint(8); - let default_flat_fine: Grams = loadGrams(slice); + let default_flat_fine: bigint = slice.loadCoins(); let default_proportional_fine: number = slice.loadUint(32); let severity_flat_mult: number = slice.loadUint(16); let severity_proportional_mult: number = slice.loadUint(16); @@ -10934,7 +10951,7 @@ export function loadMisbehaviourPunishmentConfig(slice: Slice): MisbehaviourPuni export function storeMisbehaviourPunishmentConfig(misbehaviourPunishmentConfig: MisbehaviourPunishmentConfig): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x01, 8); - storeGrams(misbehaviourPunishmentConfig.default_flat_fine)(builder); + builder.storeCoins(misbehaviourPunishmentConfig.default_flat_fine); builder.storeUint(misbehaviourPunishmentConfig.default_proportional_fine, 32); builder.storeUint(misbehaviourPunishmentConfig.severity_flat_mult, 16); builder.storeUint(misbehaviourPunishmentConfig.severity_proportional_mult, 16); @@ -11584,8 +11601,8 @@ export function loadValidatorComplaint(slice: Slice): ValidatorComplaint { let created_at: number = slice.loadUint(32); let severity: number = slice.loadUint(8); let reward_addr: bigint = slice.loadUintBig(256); - let paid: Grams = loadGrams(slice); - let suggested_fine: Grams = loadGrams(slice); + let paid: bigint = slice.loadCoins(); + let suggested_fine: bigint = slice.loadCoins(); let suggested_fine_part: number = slice.loadUint(32); return { kind: 'ValidatorComplaint', @@ -11613,8 +11630,8 @@ export function storeValidatorComplaint(validatorComplaint: ValidatorComplaint): builder.storeUint(validatorComplaint.created_at, 32); builder.storeUint(validatorComplaint.severity, 8); builder.storeUint(validatorComplaint.reward_addr, 256); - storeGrams(validatorComplaint.paid)(builder); - storeGrams(validatorComplaint.suggested_fine)(builder); + builder.storeCoins(validatorComplaint.paid); + builder.storeCoins(validatorComplaint.suggested_fine); builder.storeUint(validatorComplaint.suggested_fine_part, 32); }) @@ -12894,7 +12911,7 @@ export function loadChanConfig(slice: Slice): ChanConfig { let slice2 = slice.loadRef().beginParse(); let b_addr: Address = slice2.loadAddress(); let channel_id: number = slice.loadUint(64); - let min_A_extra: Grams = loadGrams(slice); + let min_A_extra: bigint = slice.loadCoins(); return { kind: 'ChanConfig', init_timeout: init_timeout, @@ -12922,7 +12939,7 @@ export function storeChanConfig(chanConfig: ChanConfig): (builder: Builder) => v cell2.storeAddress(chanConfig.b_addr); builder.storeRef(cell2); builder.storeUint(chanConfig.channel_id, 64); - storeGrams(chanConfig.min_A_extra)(builder); + builder.storeCoins(chanConfig.min_A_extra); }) } @@ -12938,11 +12955,11 @@ export function loadChanState(slice: Slice): ChanState { slice.loadUint(3); let signed_A: boolean = slice.loadBoolean(); let signed_B: boolean = slice.loadBoolean(); - let min_A: Grams = loadGrams(slice); - let min_B: Grams = loadGrams(slice); + let min_A: bigint = slice.loadCoins(); + let min_B: bigint = slice.loadCoins(); let expire_at: number = slice.loadUint(32); - let A: Grams = loadGrams(slice); - let B: Grams = loadGrams(slice); + let A: bigint = slice.loadCoins(); + let B: bigint = slice.loadCoins(); return { kind: 'ChanState_chan_state_init', signed_A: signed_A, @@ -12959,11 +12976,11 @@ export function loadChanState(slice: Slice): ChanState { slice.loadUint(3); let signed_A: boolean = slice.loadBoolean(); let signed_B: boolean = slice.loadBoolean(); - let promise_A: Grams = loadGrams(slice); - let promise_B: Grams = loadGrams(slice); + let promise_A: bigint = slice.loadCoins(); + let promise_B: bigint = slice.loadCoins(); let expire_at: number = slice.loadUint(32); - let A: Grams = loadGrams(slice); - let B: Grams = loadGrams(slice); + let A: bigint = slice.loadCoins(); + let B: bigint = slice.loadCoins(); return { kind: 'ChanState_chan_state_close', signed_A: signed_A, @@ -12978,8 +12995,8 @@ export function loadChanState(slice: Slice): ChanState { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { slice.loadUint(3); - let A: Grams = loadGrams(slice); - let B: Grams = loadGrams(slice); + let A: bigint = slice.loadCoins(); + let B: bigint = slice.loadCoins(); return { kind: 'ChanState_chan_state_payout', A: A, @@ -12996,11 +13013,11 @@ export function storeChanState(chanState: ChanState): (builder: Builder) => void builder.storeUint(0b000, 3); builder.storeBit(chanState.signed_A); builder.storeBit(chanState.signed_B); - storeGrams(chanState.min_A)(builder); - storeGrams(chanState.min_B)(builder); + builder.storeCoins(chanState.min_A); + builder.storeCoins(chanState.min_B); builder.storeUint(chanState.expire_at, 32); - storeGrams(chanState.A)(builder); - storeGrams(chanState.B)(builder); + builder.storeCoins(chanState.A); + builder.storeCoins(chanState.B); }) } @@ -13009,19 +13026,19 @@ export function storeChanState(chanState: ChanState): (builder: Builder) => void builder.storeUint(0b001, 3); builder.storeBit(chanState.signed_A); builder.storeBit(chanState.signed_B); - storeGrams(chanState.promise_A)(builder); - storeGrams(chanState.promise_B)(builder); + builder.storeCoins(chanState.promise_A); + builder.storeCoins(chanState.promise_B); builder.storeUint(chanState.expire_at, 32); - storeGrams(chanState.A)(builder); - storeGrams(chanState.B)(builder); + builder.storeCoins(chanState.A); + builder.storeCoins(chanState.B); }) } if ((chanState.kind == 'ChanState_chan_state_payout')) { return ((builder: Builder) => { builder.storeUint(0b010, 3); - storeGrams(chanState.A)(builder); - storeGrams(chanState.B)(builder); + builder.storeCoins(chanState.A); + builder.storeCoins(chanState.B); }) } @@ -13032,8 +13049,8 @@ export function storeChanState(chanState: ChanState): (builder: Builder) => void export function loadChanPromise(slice: Slice): ChanPromise { let channel_id: number = slice.loadUint(64); - let promise_A: Grams = loadGrams(slice); - let promise_B: Grams = loadGrams(slice); + let promise_A: bigint = slice.loadCoins(); + let promise_B: bigint = slice.loadCoins(); return { kind: 'ChanPromise', channel_id: channel_id, @@ -13046,8 +13063,8 @@ export function loadChanPromise(slice: Slice): ChanPromise { export function storeChanPromise(chanPromise: ChanPromise): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(chanPromise.channel_id, 64); - storeGrams(chanPromise.promise_A)(builder); - storeGrams(chanPromise.promise_B)(builder); + builder.storeCoins(chanPromise.promise_A); + builder.storeCoins(chanPromise.promise_B); }) } @@ -13096,10 +13113,10 @@ export function storeChanSignedPromise(chanSignedPromise: ChanSignedPromise): (b export function loadChanMsg(slice: Slice): ChanMsg { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x27317822))) { slice.loadUint(32); - let inc_A: Grams = loadGrams(slice); - let inc_B: Grams = loadGrams(slice); - let min_A: Grams = loadGrams(slice); - let min_B: Grams = loadGrams(slice); + let inc_A: bigint = slice.loadCoins(); + let inc_B: bigint = slice.loadCoins(); + let min_A: bigint = slice.loadCoins(); + let min_B: bigint = slice.loadCoins(); let channel_id: number = slice.loadUint(64); return { kind: 'ChanMsg_chan_msg_init', @@ -13113,8 +13130,8 @@ export function loadChanMsg(slice: Slice): ChanMsg { } if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xf28ae183))) { slice.loadUint(32); - let extra_A: Grams = loadGrams(slice); - let extra_B: Grams = loadGrams(slice); + let extra_A: bigint = slice.loadCoins(); + let extra_B: bigint = slice.loadCoins(); let promise: ChanSignedPromise = loadChanSignedPromise(slice); return { kind: 'ChanMsg_chan_msg_close', @@ -13145,10 +13162,10 @@ export function storeChanMsg(chanMsg: ChanMsg): (builder: Builder) => void { if ((chanMsg.kind == 'ChanMsg_chan_msg_init')) { return ((builder: Builder) => { builder.storeUint(0x27317822, 32); - storeGrams(chanMsg.inc_A)(builder); - storeGrams(chanMsg.inc_B)(builder); - storeGrams(chanMsg.min_A)(builder); - storeGrams(chanMsg.min_B)(builder); + builder.storeCoins(chanMsg.inc_A); + builder.storeCoins(chanMsg.inc_B); + builder.storeCoins(chanMsg.min_A); + builder.storeCoins(chanMsg.min_B); builder.storeUint(chanMsg.channel_id, 64); }) @@ -13156,8 +13173,8 @@ export function storeChanMsg(chanMsg: ChanMsg): (builder: Builder) => void { if ((chanMsg.kind == 'ChanMsg_chan_msg_close')) { return ((builder: Builder) => { builder.storeUint(0xf28ae183, 32); - storeGrams(chanMsg.extra_A)(builder); - storeGrams(chanMsg.extra_B)(builder); + builder.storeCoins(chanMsg.extra_A); + builder.storeCoins(chanMsg.extra_B); storeChanSignedPromise(chanMsg.promise)(builder); }) diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index 3937dc8..954ac49 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -505,6 +505,11 @@ export interface BitUser { readonly b: boolean; } +export interface GramsUser { + readonly kind: 'GramsUser'; + readonly g: bigint; +} + // tmpa$_ a:# b:# = Simple; export function loadSimple(slice: Slice): Simple { @@ -2583,3 +2588,21 @@ export function storeBitUser(bitUser: BitUser): (builder: Builder) => void { } +// a$_ g:Grams = GramsUser; + +export function loadGramsUser(slice: Slice): GramsUser { + let g: bigint = slice.loadCoins(); + return { + kind: 'GramsUser', + g: g, + } + +} + +export function storeGramsUser(gramsUser: GramsUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeCoins(gramsUser.g); + }) + +} + diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index 755f48d..f39abdd 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -140,5 +140,7 @@ addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) _ src:MsgAddressInt = AddressUser; bit$_ (## 1) = Bit; +a$_ b:Bit = BitUser; -a$_ b:Bit = BitUser; \ No newline at end of file +nanograms$_ amount:(VarUInteger 16) = Grams; +a$_ g:Grams = GramsUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 62fb020..f0c8056 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -5,7 +5,7 @@ import { Address, BitString, Cell, Slice } from 'ton'; import { describe, expect, test } from '@jest/globals'; import { beginCell } from 'ton'; import { loadBlock, storeBlock } from './generated_files/generated_block'; -import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeHashmapEUser, 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 } from './generated_files/generated_test'; +import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, 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 } from './generated_files/generated_test'; const fixturesDir = path.resolve(__dirname, 'fixtures'); @@ -257,6 +257,9 @@ describe('Generating tlb code', () => { let boolUser: BoolUser = { kind: 'BoolUser', a: true } checkSameOnStoreLoad(boolUser, loadBoolUser, storeBoolUser); + let gramsUser: GramsUser = { kind: 'GramsUser', g: BigInt(100000) } + checkSameOnStoreLoad(gramsUser, loadGramsUser, storeGramsUser) + let hashmapEUser: HashmapEUser = { kind: 'HashmapEUser', x: { From 8d780291e9f88e3e7a19d5027e95abf1abf36ea4 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Fri, 12 Jan 2024 01:30:37 -0500 Subject: [PATCH 04/28] address --- src/ast.ts | 1 + src/astbuilder/fill_constructors.ts | 2 + src/astbuilder/handle_type.ts | 10 +- src/generators/typescript/generator.ts | 35 ++++-- src/main.ts | 1 + test/generated_files/generated_block.ts | 142 +++------------------ test/generated_files/generated_test.ts | 159 ++++++++++++++++++++---- test/tlb/test.tlb | 14 ++- test/tlbgen.spec.ts | 32 +++-- 9 files changed, 228 insertions(+), 168 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index 629abe4..6bbbf30 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -82,6 +82,7 @@ export type TLBCoinsType = { export type TLBAddressType = { kind: "TLBAddressType"; + addrType: "Internal" | "External" | "Any" }; export type TLBCellType = { diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index d5ec7af..ce1fca6 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -428,6 +428,8 @@ function checkAndRemovePrimitives( typesToDelete.set("MsgAddressInt", ["d7b672a", "6d593e8a"]); typesToDelete.set("Bit", ["2873c6f5"]) typesToDelete.set("Grams", ["2f73160b"]) + typesToDelete.set("MsgAddressExt", ["44163e94", "2e933043"]) + typesToDelete.set("MsgAddress", ["606aa05e", "21d0382b"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index e6d0c6b..633b166 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -218,11 +218,15 @@ export function getType( } else if (expr.name == "Bool") { return { kind: "TLBBoolType" }; } else if (expr.name == "MsgAddressInt") { - return { kind: "TLBAddressType" }; + return { kind: "TLBAddressType", addrType: "Internal" }; + } else if (expr.name == "MsgAddressExt") { + return { kind: "TLBAddressType", addrType: "External" }; + } else if (expr.name == "MsgAddress") { + return { kind: "TLBAddressType", addrType: "Any" }; } else if (expr.name == "Bit") { - return { kind:"TLBBitsType", bits: new TLBNumberExpr(1) } + return { kind: "TLBBitsType", bits: new TLBNumberExpr(1) } } else if (expr.name == "Grams") { - return { kind:"TLBCoinsType"} + return { kind: "TLBCoinsType"} } else { if (constructor.variablesMap.get(expr.name)?.type == "#") { return { diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index 21b0b78..891d611 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -62,6 +62,7 @@ import { TypeParametersExpression, TypedIdentifier, id, + tArrowFunctionExpression, tComment, tExpressionStatement, tFunctionCall, @@ -720,13 +721,33 @@ export class TypescriptGenerator implements CodeGenerator { fieldStoreSuffix: "Coins", }; } else if (fieldType.kind == "TLBAddressType") { - exprForParam = { - argLoadExpr: undefined, - argStoreExpr: undefined, - paramType: "Address", - fieldLoadSuffix: "Address", - fieldStoreSuffix: "Address", - }; + if (fieldType.addrType == "Internal") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "Address", + fieldLoadSuffix: "Address", + fieldStoreSuffix: "Address", + }; + } else if (fieldType.addrType == "External") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "ExternalAddress | null", + fieldLoadSuffix: "MaybeExternalAddress", + fieldStoreSuffix: "Address", + }; + } else if (fieldType.addrType == "Any") { + exprForParam = { + argLoadExpr: undefined, + argStoreExpr: undefined, + paramType: "Address | ExternalAddress | null", + fieldLoadSuffix: "AddressAny", + fieldStoreSuffix: "Address" + } + } else { + throw new Error("Address has type other than ['Internal', 'External', 'Any']") + } } else if (fieldType.kind == "TLBExprMathType") { result.loadExpr = convertToAST(fieldType.expr, ctx.constructor); result.storeStmtOutside = tExpressionStatement(result.loadExpr); diff --git a/src/main.ts b/src/main.ts index 7360cfe..86112f4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,6 +26,7 @@ export function generate(tree: Program, input: string) { codeGenerator.addTonCoreClassUsage("BitString"); codeGenerator.addTonCoreClassUsage("Cell"); codeGenerator.addTonCoreClassUsage("Address"); + codeGenerator.addTonCoreClassUsage("ExternalAddress"); codeGenerator.addBitLenFunction(); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 1772f30..bc8d3f7 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -4,6 +4,7 @@ import { beginCell } from 'ton' import { BitString } from 'ton' import { Cell } from 'ton' import { Address } from 'ton' +import { ExternalAddress } from 'ton' export function bitLen(n: number) { return n.toString(2).length;; } @@ -254,36 +255,12 @@ export interface PfxHashmapE_phme_root { readonly root: PfxHashmap; } -export type MsgAddressExt = MsgAddressExt_addr_none | MsgAddressExt_addr_extern; - -export interface MsgAddressExt_addr_none { - readonly kind: 'MsgAddressExt_addr_none'; -} - -export interface MsgAddressExt_addr_extern { - readonly kind: 'MsgAddressExt_addr_extern'; - readonly len: number; - readonly external_address: BitString; -} - export interface Anycast { readonly kind: 'Anycast'; readonly depth: number; readonly rewrite_pfx: BitString; } -export type MsgAddress = MsgAddress__ | MsgAddress__1; - -export interface MsgAddress__ { - readonly kind: 'MsgAddress__'; - readonly _: Address; -} - -export interface MsgAddress__1 { - readonly kind: 'MsgAddress__1'; - readonly _: MsgAddressExt; -} - export interface VarUInteger { readonly kind: 'VarUInteger'; readonly n: number; @@ -332,7 +309,7 @@ export interface CommonMsgInfo_int_msg_info { export interface CommonMsgInfo_ext_in_msg_info { readonly kind: 'CommonMsgInfo_ext_in_msg_info'; - readonly src: MsgAddressExt; + readonly src: ExternalAddress | null; readonly dest: Address; readonly import_fee: bigint; } @@ -340,7 +317,7 @@ export interface CommonMsgInfo_ext_in_msg_info { export interface CommonMsgInfo_ext_out_msg_info { readonly kind: 'CommonMsgInfo_ext_out_msg_info'; readonly src: Address; - readonly dest: MsgAddressExt; + readonly dest: ExternalAddress | null; readonly created_lt: number; readonly created_at: number; } @@ -352,7 +329,7 @@ export interface CommonMsgInfoRelaxed_int_msg_info { readonly ihr_disabled: boolean; readonly bounce: boolean; readonly bounced: boolean; - readonly src: MsgAddress; + readonly src: Address | ExternalAddress | null; readonly dest: Address; readonly value: CurrencyCollection; readonly ihr_fee: bigint; @@ -363,8 +340,8 @@ export interface CommonMsgInfoRelaxed_int_msg_info { export interface CommonMsgInfoRelaxed_ext_out_msg_info { readonly kind: 'CommonMsgInfoRelaxed_ext_out_msg_info'; - readonly src: MsgAddress; - readonly dest: MsgAddressExt; + readonly src: Address | ExternalAddress | null; + readonly dest: ExternalAddress | null; readonly created_lt: number; readonly created_at: number; } @@ -3538,53 +3515,6 @@ export function storePfxHashmapE(pfxHashmapE: PfxHashmapE, storeX: (x: X) throw new Error('Expected one of "PfxHashmapE_phme_empty", "PfxHashmapE_phme_root" in loading "PfxHashmapE", but data does not satisfy any constructor'); } -// addr_none$00 = MsgAddressExt; - -/* -addr_extern$01 len:(## 9) external_address:(bits len) - = MsgAddressExt; -*/ - -export function loadMsgAddressExt(slice: Slice): MsgAddressExt { - if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { - slice.loadUint(2); - return { - kind: 'MsgAddressExt_addr_none', - } - - } - if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { - slice.loadUint(2); - let len: number = slice.loadUint(9); - let external_address: BitString = slice.loadBits(len); - return { - kind: 'MsgAddressExt_addr_extern', - len: len, - external_address: external_address, - } - - } - throw new Error('Expected one of "MsgAddressExt_addr_none", "MsgAddressExt_addr_extern" in loading "MsgAddressExt", but data does not satisfy any constructor'); -} - -export function storeMsgAddressExt(msgAddressExt: MsgAddressExt): (builder: Builder) => void { - if ((msgAddressExt.kind == 'MsgAddressExt_addr_none')) { - return ((builder: Builder) => { - builder.storeUint(0b00, 2); - }) - - } - if ((msgAddressExt.kind == 'MsgAddressExt_addr_extern')) { - return ((builder: Builder) => { - builder.storeUint(0b01, 2); - builder.storeUint(msgAddressExt.len, 9); - builder.storeBits(msgAddressExt.external_address); - }) - - } - throw new Error('Expected one of "MsgAddressExt_addr_none", "MsgAddressExt_addr_extern" in loading "MsgAddressExt", but data does not satisfy any constructor'); -} - /* anycast_info$_ depth:(#<= 30) { depth >= 1 } rewrite_pfx:(bits depth) = Anycast; @@ -3615,46 +3545,6 @@ export function storeAnycast(anycast: Anycast): (builder: Builder) => void { } -// _ _:MsgAddressInt = MsgAddress; - -// _ _:MsgAddressExt = MsgAddress; - -export function loadMsgAddress(slice: Slice): MsgAddress { - if (true) { - let _: Address = slice.loadAddress(); - return { - kind: 'MsgAddress__', - _: _, - } - - } - if (true) { - let _: MsgAddressExt = loadMsgAddressExt(slice); - return { - kind: 'MsgAddress__1', - _: _, - } - - } - throw new Error('Expected one of "MsgAddress__", "MsgAddress__1" in loading "MsgAddress", but data does not satisfy any constructor'); -} - -export function storeMsgAddress(msgAddress: MsgAddress): (builder: Builder) => void { - if ((msgAddress.kind == 'MsgAddress__')) { - return ((builder: Builder) => { - builder.storeAddress(msgAddress._); - }) - - } - if ((msgAddress.kind == 'MsgAddress__1')) { - return ((builder: Builder) => { - storeMsgAddressExt(msgAddress._)(builder); - }) - - } - throw new Error('Expected one of "MsgAddress__", "MsgAddress__1" in loading "MsgAddress", but data does not satisfy any constructor'); -} - /* var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) = VarUInteger n; @@ -3823,7 +3713,7 @@ export function loadCommonMsgInfo(slice: Slice): CommonMsgInfo { } if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b10))) { slice.loadUint(2); - let src: MsgAddressExt = loadMsgAddressExt(slice); + let src: ExternalAddress | null = slice.loadMaybeExternalAddress(); let dest: Address = slice.loadAddress(); let import_fee: bigint = slice.loadCoins(); return { @@ -3837,7 +3727,7 @@ export function loadCommonMsgInfo(slice: Slice): CommonMsgInfo { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { slice.loadUint(2); let src: Address = slice.loadAddress(); - let dest: MsgAddressExt = loadMsgAddressExt(slice); + let dest: ExternalAddress | null = slice.loadMaybeExternalAddress(); let created_lt: number = slice.loadUint(64); let created_at: number = slice.loadUint(32); return { @@ -3872,7 +3762,7 @@ export function storeCommonMsgInfo(commonMsgInfo: CommonMsgInfo): (builder: Buil if ((commonMsgInfo.kind == 'CommonMsgInfo_ext_in_msg_info')) { return ((builder: Builder) => { builder.storeUint(0b10, 2); - storeMsgAddressExt(commonMsgInfo.src)(builder); + builder.storeAddress(commonMsgInfo.src); builder.storeAddress(commonMsgInfo.dest); builder.storeCoins(commonMsgInfo.import_fee); }) @@ -3882,7 +3772,7 @@ export function storeCommonMsgInfo(commonMsgInfo: CommonMsgInfo): (builder: Buil return ((builder: Builder) => { builder.storeUint(0b11, 2); builder.storeAddress(commonMsgInfo.src); - storeMsgAddressExt(commonMsgInfo.dest)(builder); + builder.storeAddress(commonMsgInfo.dest); builder.storeUint(commonMsgInfo.created_lt, 64); builder.storeUint(commonMsgInfo.created_at, 32); }) @@ -3909,7 +3799,7 @@ export function loadCommonMsgInfoRelaxed(slice: Slice): CommonMsgInfoRelaxed { let ihr_disabled: boolean = slice.loadBoolean(); let bounce: boolean = slice.loadBoolean(); let bounced: boolean = slice.loadBoolean(); - let src: MsgAddress = loadMsgAddress(slice); + let src: Address | ExternalAddress | null = slice.loadAddressAny(); let dest: Address = slice.loadAddress(); let value: CurrencyCollection = loadCurrencyCollection(slice); let ihr_fee: bigint = slice.loadCoins(); @@ -3933,8 +3823,8 @@ export function loadCommonMsgInfoRelaxed(slice: Slice): CommonMsgInfoRelaxed { } if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b11))) { slice.loadUint(2); - let src: MsgAddress = loadMsgAddress(slice); - let dest: MsgAddressExt = loadMsgAddressExt(slice); + let src: Address | ExternalAddress | null = slice.loadAddressAny(); + let dest: ExternalAddress | null = slice.loadMaybeExternalAddress(); let created_lt: number = slice.loadUint(64); let created_at: number = slice.loadUint(32); return { @@ -3956,7 +3846,7 @@ export function storeCommonMsgInfoRelaxed(commonMsgInfoRelaxed: CommonMsgInfoRel builder.storeBit(commonMsgInfoRelaxed.ihr_disabled); builder.storeBit(commonMsgInfoRelaxed.bounce); builder.storeBit(commonMsgInfoRelaxed.bounced); - storeMsgAddress(commonMsgInfoRelaxed.src)(builder); + builder.storeAddress(commonMsgInfoRelaxed.src); builder.storeAddress(commonMsgInfoRelaxed.dest); storeCurrencyCollection(commonMsgInfoRelaxed.value)(builder); builder.storeCoins(commonMsgInfoRelaxed.ihr_fee); @@ -3969,8 +3859,8 @@ export function storeCommonMsgInfoRelaxed(commonMsgInfoRelaxed: CommonMsgInfoRel if ((commonMsgInfoRelaxed.kind == 'CommonMsgInfoRelaxed_ext_out_msg_info')) { return ((builder: Builder) => { builder.storeUint(0b11, 2); - storeMsgAddress(commonMsgInfoRelaxed.src)(builder); - storeMsgAddressExt(commonMsgInfoRelaxed.dest)(builder); + builder.storeAddress(commonMsgInfoRelaxed.src); + builder.storeAddress(commonMsgInfoRelaxed.dest); builder.storeUint(commonMsgInfoRelaxed.created_lt, 64); builder.storeUint(commonMsgInfoRelaxed.created_at, 32); }) diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index 954ac49..5fc99e0 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -4,6 +4,7 @@ import { beginCell } from 'ton' import { BitString } from 'ton' import { Cell } from 'ton' import { Address } from 'ton' +import { ExternalAddress } from 'ton' export function bitLen(n: number) { return n.toString(2).length;; } @@ -443,18 +444,18 @@ export interface FalseAnonField { readonly value: bigint; } -export type ConstructorOrder = ConstructorOrder_a | ConstructorOrder__; +export type ConstructorOrder = ConstructorOrder_b | ConstructorOrder_a; + +export interface ConstructorOrder_b { + readonly kind: 'ConstructorOrder_b'; + readonly anon0: Simple; +} export interface ConstructorOrder_a { readonly kind: 'ConstructorOrder_a'; readonly a: Simple; } -export interface ConstructorOrder__ { - readonly kind: 'ConstructorOrder__'; - readonly anon0: Simple; -} - export type CheckCrc32 = CheckCrc32_a | CheckCrc32_b; export interface CheckCrc32_a { @@ -500,11 +501,35 @@ export interface AddressUser { readonly src: Address; } +export interface ExtAddressUser { + readonly kind: 'ExtAddressUser'; + readonly src: ExternalAddress | null; +} + +export interface AnyAddressUser { + readonly kind: 'AnyAddressUser'; + readonly src: Address | ExternalAddress | null; +} + export interface BitUser { readonly kind: 'BitUser'; readonly b: boolean; } +export interface VarUInteger { + readonly kind: 'VarUInteger'; + readonly n: number; + readonly len: number; + readonly value: bigint; +} + +export interface VarInteger { + readonly kind: 'VarInteger'; + readonly n: number; + readonly len: number; + readonly value: bigint; +} + export interface GramsUser { readonly kind: 'GramsUser'; readonly g: bigint; @@ -2335,46 +2360,48 @@ export function storeFalseAnonField(falseAnonField: FalseAnonField): (builder: B } -// a$0 a:Simple = ConstructorOrder; +// b$1 Simple = ConstructorOrder; -// _ Simple = ConstructorOrder; +// a$0 a:Simple = ConstructorOrder; export function loadConstructorOrder(slice: Slice): ConstructorOrder { - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let a: Simple = loadSimple(slice); + let anon0: Simple = loadSimple(slice); return { - kind: 'ConstructorOrder_a', - a: a, + kind: 'ConstructorOrder_b', + anon0: anon0, } } - if (true) { - let anon0: Simple = loadSimple(slice); + if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { + slice.loadUint(1); + let a: Simple = loadSimple(slice); return { - kind: 'ConstructorOrder__', - anon0: anon0, + kind: 'ConstructorOrder_a', + a: a, } } - throw new Error('Expected one of "ConstructorOrder_a", "ConstructorOrder__" in loading "ConstructorOrder", but data does not satisfy any constructor'); + throw new Error('Expected one of "ConstructorOrder_b", "ConstructorOrder_a" in loading "ConstructorOrder", but data does not satisfy any constructor'); } export function storeConstructorOrder(constructorOrder: ConstructorOrder): (builder: Builder) => void { - if ((constructorOrder.kind == 'ConstructorOrder_a')) { + if ((constructorOrder.kind == 'ConstructorOrder_b')) { return ((builder: Builder) => { - builder.storeUint(0b0, 1); - storeSimple(constructorOrder.a)(builder); + builder.storeUint(0b1, 1); + storeSimple(constructorOrder.anon0)(builder); }) } - if ((constructorOrder.kind == 'ConstructorOrder__')) { + if ((constructorOrder.kind == 'ConstructorOrder_a')) { return ((builder: Builder) => { - storeSimple(constructorOrder.anon0)(builder); + builder.storeUint(0b0, 1); + storeSimple(constructorOrder.a)(builder); }) } - throw new Error('Expected one of "ConstructorOrder_a", "ConstructorOrder__" in loading "ConstructorOrder", but data does not satisfy any constructor'); + throw new Error('Expected one of "ConstructorOrder_b", "ConstructorOrder_a" in loading "ConstructorOrder", but data does not satisfy any constructor'); } // a a:# = CheckCrc32; @@ -2570,6 +2597,42 @@ export function storeAddressUser(addressUser: AddressUser): (builder: Builder) = } +// _ src:MsgAddressExt = ExtAddressUser; + +export function loadExtAddressUser(slice: Slice): ExtAddressUser { + let src: ExternalAddress | null = slice.loadMaybeExternalAddress(); + return { + kind: 'ExtAddressUser', + src: src, + } + +} + +export function storeExtAddressUser(extAddressUser: ExtAddressUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeAddress(extAddressUser.src); + }) + +} + +// _ src:MsgAddress = AnyAddressUser; + +export function loadAnyAddressUser(slice: Slice): AnyAddressUser { + let src: Address | ExternalAddress | null = slice.loadAddressAny(); + return { + kind: 'AnyAddressUser', + src: src, + } + +} + +export function storeAnyAddressUser(anyAddressUser: AnyAddressUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeAddress(anyAddressUser.src); + }) + +} + // a$_ b:Bit = BitUser; export function loadBitUser(slice: Slice): BitUser { @@ -2588,6 +2651,56 @@ export function storeBitUser(bitUser: BitUser): (builder: Builder) => void { } +/* +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; +*/ + +export function loadVarUInteger(slice: Slice, n: number): VarUInteger { + let len: number = slice.loadUint(bitLen((n - 1))); + let value: bigint = slice.loadUintBig((len * 8)); + return { + kind: 'VarUInteger', + n: n, + len: len, + value: value, + } + +} + +export function storeVarUInteger(varUInteger: VarUInteger): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(varUInteger.len, bitLen((varUInteger.n - 1))); + builder.storeUint(varUInteger.value, (varUInteger.len * 8)); + }) + +} + +/* +var_int$_ {n:#} len:(#< n) value:(int (len * 8)) + = VarInteger n; +*/ + +export function loadVarInteger(slice: Slice, n: number): VarInteger { + let len: number = slice.loadUint(bitLen((n - 1))); + let value: bigint = slice.loadIntBig((len * 8)); + return { + kind: 'VarInteger', + n: n, + len: len, + value: value, + } + +} + +export function storeVarInteger(varInteger: VarInteger): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(varInteger.len, bitLen((varInteger.n - 1))); + builder.storeInt(varInteger.value, (varInteger.len * 8)); + }) + +} + // a$_ g:Grams = GramsUser; export function loadGramsUser(slice: Slice): GramsUser { diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index f39abdd..261e5cd 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -114,7 +114,7 @@ bit$_ (## 1) anon0:# = AnonymousData; vm_stk_int#0201_ value:int257 = FalseAnonField; -_ Simple = ConstructorOrder; +b$1 Simple = ConstructorOrder; a$0 a:Simple = ConstructorOrder; a a:# = CheckCrc32; @@ -136,11 +136,23 @@ addr_std$10 anycast:(Maybe Anycast) workchain_id:int8 address:bits256 = MsgAddressInt; addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) workchain_id:int32 address:(bits addr_len) = MsgAddressInt; +addr_none$00 = MsgAddressExt; +addr_extern$01 len:(## 9) external_address:(bits len) + = MsgAddressExt; +_ _:MsgAddressInt = MsgAddress; +_ _:MsgAddressExt = MsgAddress; _ src:MsgAddressInt = AddressUser; +_ src:MsgAddressExt = ExtAddressUser; +_ src:MsgAddress = AnyAddressUser; bit$_ (## 1) = Bit; a$_ b:Bit = BitUser; +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; +var_int$_ {n:#} len:(#< n) value:(int (len * 8)) + = VarInteger n; + nanograms$_ amount:(VarUInteger 16) = Grams; a$_ g:Grams = GramsUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index f0c8056..1826ab8 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -1,11 +1,12 @@ import path from 'path'; -import { Address, BitString, Cell, Slice } from 'ton'; +import { Address, BitString, Cell, ExternalAddress, Slice } from 'ton'; import { describe, expect, test } from '@jest/globals'; import { beginCell } from 'ton'; import { loadBlock, storeBlock } from './generated_files/generated_block'; -import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, 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 } from './generated_files/generated_test'; +import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadAnyAddressUser, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBitUser, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadExtAddressUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeAnyAddressUser, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBitUser, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeExtAddressUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, 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 } from './generated_files/generated_test'; +import { randomInt } from 'crypto'; const fixturesDir = path.resolve(__dirname, 'fixtures'); @@ -162,6 +163,27 @@ describe('Generating tlb code', () => { let expectedAddressUser: AddressUser = { kind: 'AddressUser', src: Address.parseFriendly('EQBmzW4wYlFW0tiBgj5sP1CgSlLdYs-VpjPWM7oPYPYWQEdT').address } checkSameOnStoreLoad(expectedAddressUser, loadAddressUser, storeAddressUser) + + let bitUser: BitUser = { kind: 'BitUser', b: false } + checkSameOnStoreLoad(bitUser, loadBitUser, storeBitUser); + + let gramsUser: GramsUser = { kind: 'GramsUser', g: BigInt(100000) } + checkSameOnStoreLoad(gramsUser, loadGramsUser, storeGramsUser) + + let extAddressUser: ExtAddressUser = { kind: 'ExtAddressUser', src: new ExternalAddress(BigInt(5623048054), 48) } + checkSameOnStoreLoad(extAddressUser, loadExtAddressUser, storeExtAddressUser) + + let extAddressUserNull: ExtAddressUser = { kind: 'ExtAddressUser', src: null } + checkSameOnStoreLoad(extAddressUserNull, loadExtAddressUser, storeExtAddressUser) + + let anyAddressUserInt: AnyAddressUser = { kind: 'AnyAddressUser', src: Address.parseFriendly('EQBmzW4wYlFW0tiBgj5sP1CgSlLdYs-VpjPWM7oPYPYWQEdT').address } + checkSameOnStoreLoad(anyAddressUserInt, loadAnyAddressUser, storeAnyAddressUser) + + let anyAddressUserExt: AnyAddressUser = { kind: 'AnyAddressUser', src: new ExternalAddress(BigInt(5623048054), 48) } + checkSameOnStoreLoad(anyAddressUserExt, loadAnyAddressUser, storeAnyAddressUser) + + let anyAddressUserNull: AnyAddressUser = { kind: 'AnyAddressUser', src: null } + checkSameOnStoreLoad(anyAddressUserNull, loadAnyAddressUser, storeAnyAddressUser) }) test('Combinators', () => { @@ -254,12 +276,6 @@ describe('Generating tlb code', () => { test('Builtins', () => { expect.hasAssertions() - let boolUser: BoolUser = { kind: 'BoolUser', a: true } - checkSameOnStoreLoad(boolUser, loadBoolUser, storeBoolUser); - - let gramsUser: GramsUser = { kind: 'GramsUser', g: BigInt(100000) } - checkSameOnStoreLoad(gramsUser, loadGramsUser, storeGramsUser) - let hashmapEUser: HashmapEUser = { kind: 'HashmapEUser', x: { From 1546ee574af1f4e75eebfce0d9d37c9e20b48f91 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Fri, 12 Jan 2024 03:01:07 -0500 Subject: [PATCH 05/28] varinteger --- src/ast.ts | 7 ++ src/astbuilder/fill_constructors.ts | 2 + src/astbuilder/handle_type.ts | 29 +++++- src/generators/typescript/generator.ts | 12 +++ test/generated_files/generated_block.ts | 126 ++++++------------------ test/generated_files/generated_test.ts | 58 ++++------- test/tlb/test.tlb | 3 + test/tlbgen.spec.ts | 8 +- 8 files changed, 109 insertions(+), 136 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index 6bbbf30..e8aae94 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -85,6 +85,12 @@ export type TLBAddressType = { addrType: "Internal" | "External" | "Any" }; +export type TLBVarIntegerType = { + kind: "TLBVarIntegerType"; + signed: boolean; + n: TLBMathExpr; +} + export type TLBCellType = { kind: "TLBCellType"; }; @@ -130,6 +136,7 @@ export type TLBFieldType = | TLBBoolType | TLBCoinsType | TLBAddressType + | TLBVarIntegerType | TLBCellType | TLBMathExprType | TLBNegatedType diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index ce1fca6..b20dc80 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -430,6 +430,8 @@ function checkAndRemovePrimitives( typesToDelete.set("Grams", ["2f73160b"]) typesToDelete.set("MsgAddressExt", ["44163e94", "2e933043"]) typesToDelete.set("MsgAddress", ["606aa05e", "21d0382b"]) + typesToDelete.set("VarUInteger", ["11d56c2e"]) + typesToDelete.set("VarInteger", ["d466ed5"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 633b166..5c4fdc3 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -161,6 +161,31 @@ export function getType( constructor ), }; + } else if ( + expr.name == "VarUInteger" && + (expr.args[0] instanceof MathExpr || + expr.args[0] instanceof NumberExpr || + expr.args[0] instanceof NameExpr) + ) { + return { + kind: "TLBVarIntegerType", + n: new TLBUnaryOp( + new TLBBinaryOp(convertToMathExpr(expr.args[0]), new TLBNumberExpr(1), '-'), + "." + ), + signed: false, + }; + } else if ( + expr.name == "VarInteger" && + (expr.args[0] instanceof MathExpr || + expr.args[0] instanceof NumberExpr || + expr.args[0] instanceof NameExpr) + ) { + return { + kind: "TLBVarIntegerType", + n: convertToMathExpr(expr.args[0]), + signed: true, + }; } else { let argumentTypes: TLBFieldType[] = []; expr.args.forEach((arg) => { @@ -224,9 +249,9 @@ export function getType( } else if (expr.name == "MsgAddress") { return { kind: "TLBAddressType", addrType: "Any" }; } else if (expr.name == "Bit") { - return { kind: "TLBBitsType", bits: new TLBNumberExpr(1) } + return { kind: "TLBBitsType", bits: new TLBNumberExpr(1) }; } else if (expr.name == "Grams") { - return { kind: "TLBCoinsType"} + return { kind: "TLBCoinsType" }; } else { if (constructor.variablesMap.get(expr.name)?.type == "#") { return { diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index 891d611..a91841c 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -720,6 +720,18 @@ export class TypescriptGenerator implements CodeGenerator { fieldLoadSuffix: "Coins", fieldStoreSuffix: "Coins", }; + } else if (fieldType.kind == "TLBVarIntegerType") { + exprForParam = { + argLoadExpr: convertToAST(fieldType.n, ctx.constructor), + argStoreExpr: convertToAST( + fieldType.n, + ctx.constructor, + id(ctx.name) + ), + paramType: "bigint", + fieldLoadSuffix: fieldType.signed ? "VarIntBig" : "VarUintBig", + fieldStoreSuffix: fieldType.signed ? "VarInt" : "VarUint" + } } else if (fieldType.kind == "TLBAddressType") { if (fieldType.addrType == "Internal") { exprForParam = { diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index bc8d3f7..703602a 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -261,20 +261,6 @@ export interface Anycast { readonly rewrite_pfx: BitString; } -export interface VarUInteger { - readonly kind: 'VarUInteger'; - readonly n: number; - readonly len: number; - readonly value: bigint; -} - -export interface VarInteger { - readonly kind: 'VarInteger'; - readonly n: number; - readonly len: number; - readonly value: bigint; -} - export interface Coins { readonly kind: 'Coins'; readonly grams: bigint; @@ -282,7 +268,7 @@ export interface Coins { export interface ExtraCurrencyCollection { readonly kind: 'ExtraCurrencyCollection'; - readonly dict: HashmapE; + readonly dict: HashmapE; } export interface CurrencyCollection { @@ -584,15 +570,15 @@ export interface OutMsgQueueInfo { export interface StorageUsed { readonly kind: 'StorageUsed'; - readonly _cells: VarUInteger; - readonly bits: VarUInteger; - readonly public_cells: VarUInteger; + readonly _cells: bigint; + readonly bits: bigint; + readonly public_cells: bigint; } export interface StorageUsedShort { readonly kind: 'StorageUsedShort'; - readonly _cells: VarUInteger; - readonly bits: VarUInteger; + readonly _cells: bigint; + readonly bits: bigint; } export interface StorageInfo { @@ -764,9 +750,9 @@ export interface TrComputePhase_tr_phase_compute_vm { readonly msg_state_used: boolean; readonly account_activated: boolean; readonly gas_fees: bigint; - readonly gas_used: VarUInteger; - readonly gas_limit: VarUInteger; - readonly gas_credit: Maybe; + readonly gas_used: bigint; + readonly gas_limit: bigint; + readonly gas_credit: Maybe; readonly mode: number; readonly exit_code: number; readonly exit_arg: Maybe; @@ -3545,56 +3531,6 @@ export function storeAnycast(anycast: Anycast): (builder: Builder) => void { } -/* -var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) - = VarUInteger n; -*/ - -export function loadVarUInteger(slice: Slice, n: number): VarUInteger { - let len: number = slice.loadUint(bitLen((n - 1))); - let value: bigint = slice.loadUintBig((len * 8)); - return { - kind: 'VarUInteger', - n: n, - len: len, - value: value, - } - -} - -export function storeVarUInteger(varUInteger: VarUInteger): (builder: Builder) => void { - return ((builder: Builder) => { - builder.storeUint(varUInteger.len, bitLen((varUInteger.n - 1))); - builder.storeUint(varUInteger.value, (varUInteger.len * 8)); - }) - -} - -/* -var_int$_ {n:#} len:(#< n) value:(int (len * 8)) - = VarInteger n; -*/ - -export function loadVarInteger(slice: Slice, n: number): VarInteger { - let len: number = slice.loadUint(bitLen((n - 1))); - let value: bigint = slice.loadIntBig((len * 8)); - return { - kind: 'VarInteger', - n: n, - len: len, - value: value, - } - -} - -export function storeVarInteger(varInteger: VarInteger): (builder: Builder) => void { - return ((builder: Builder) => { - builder.storeUint(varInteger.len, bitLen((varInteger.n - 1))); - builder.storeInt(varInteger.value, (varInteger.len * 8)); - }) - -} - // _ grams:Grams = Coins; export function loadCoins(slice: Slice): Coins { @@ -3619,8 +3555,8 @@ extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) */ export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollection { - let dict: HashmapE = loadHashmapE(slice, 32, ((slice: Slice) => { - return loadVarUInteger(slice, 32) + let dict: HashmapE = loadHashmapE(slice, 32, ((slice: Slice) => { + return slice.loadVarUintBig(bitLen((32 - 1))) })); return { @@ -3632,9 +3568,9 @@ export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollecti export function storeExtraCurrencyCollection(extraCurrencyCollection: ExtraCurrencyCollection): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(extraCurrencyCollection.dict, ((arg: VarUInteger) => { + storeHashmapE(extraCurrencyCollection.dict, ((arg: bigint) => { return ((builder: Builder) => { - storeVarUInteger(arg)(builder); + builder.storeVarUint(arg, bitLen((32 - 1))); }) }))(builder); @@ -5064,9 +5000,9 @@ storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7) */ export function loadStorageUsed(slice: Slice): StorageUsed { - let _cells: VarUInteger = loadVarUInteger(slice, 7); - let bits: VarUInteger = loadVarUInteger(slice, 7); - let public_cells: VarUInteger = loadVarUInteger(slice, 7); + let _cells: bigint = slice.loadVarUintBig(bitLen((7 - 1))); + let bits: bigint = slice.loadVarUintBig(bitLen((7 - 1))); + let public_cells: bigint = slice.loadVarUintBig(bitLen((7 - 1))); return { kind: 'StorageUsed', _cells: _cells, @@ -5078,9 +5014,9 @@ export function loadStorageUsed(slice: Slice): StorageUsed { export function storeStorageUsed(storageUsed: StorageUsed): (builder: Builder) => void { return ((builder: Builder) => { - storeVarUInteger(storageUsed._cells)(builder); - storeVarUInteger(storageUsed.bits)(builder); - storeVarUInteger(storageUsed.public_cells)(builder); + builder.storeVarUint(storageUsed._cells, bitLen((7 - 1))); + builder.storeVarUint(storageUsed.bits, bitLen((7 - 1))); + builder.storeVarUint(storageUsed.public_cells, bitLen((7 - 1))); }) } @@ -5091,8 +5027,8 @@ storage_used_short$_ cells:(VarUInteger 7) */ export function loadStorageUsedShort(slice: Slice): StorageUsedShort { - let _cells: VarUInteger = loadVarUInteger(slice, 7); - let bits: VarUInteger = loadVarUInteger(slice, 7); + let _cells: bigint = slice.loadVarUintBig(bitLen((7 - 1))); + let bits: bigint = slice.loadVarUintBig(bitLen((7 - 1))); return { kind: 'StorageUsedShort', _cells: _cells, @@ -5103,8 +5039,8 @@ export function loadStorageUsedShort(slice: Slice): StorageUsedShort { export function storeStorageUsedShort(storageUsedShort: StorageUsedShort): (builder: Builder) => void { return ((builder: Builder) => { - storeVarUInteger(storageUsedShort._cells)(builder); - storeVarUInteger(storageUsedShort.bits)(builder); + builder.storeVarUint(storageUsedShort._cells, bitLen((7 - 1))); + builder.storeVarUint(storageUsedShort.bits, bitLen((7 - 1))); }) } @@ -5858,10 +5794,10 @@ export function loadTrComputePhase(slice: Slice): TrComputePhase { let account_activated: boolean = slice.loadBoolean(); let gas_fees: bigint = slice.loadCoins(); let slice1 = slice.loadRef().beginParse(); - let gas_used: VarUInteger = loadVarUInteger(slice1, 7); - let gas_limit: VarUInteger = loadVarUInteger(slice1, 7); - let gas_credit: Maybe = loadMaybe(slice1, ((slice: Slice) => { - return loadVarUInteger(slice, 3) + let gas_used: bigint = slice1.loadVarUintBig(bitLen((7 - 1))); + let gas_limit: bigint = slice1.loadVarUintBig(bitLen((7 - 1))); + let gas_credit: Maybe = loadMaybe(slice1, ((slice: Slice) => { + return slice1.loadVarUintBig(bitLen((3 - 1))) })); let mode: number = slice1.loadInt(8); @@ -5910,11 +5846,11 @@ export function storeTrComputePhase(trComputePhase: TrComputePhase): (builder: B builder.storeBit(trComputePhase.account_activated); builder.storeCoins(trComputePhase.gas_fees); let cell1 = beginCell(); - storeVarUInteger(trComputePhase.gas_used)(cell1); - storeVarUInteger(trComputePhase.gas_limit)(cell1); - storeMaybe(trComputePhase.gas_credit, ((arg: VarUInteger) => { + cell1.storeVarUint(trComputePhase.gas_used, bitLen((7 - 1))); + cell1.storeVarUint(trComputePhase.gas_limit, bitLen((7 - 1))); + storeMaybe(trComputePhase.gas_credit, ((arg: bigint) => { return ((builder: Builder) => { - storeVarUInteger(arg)(builder); + builder.storeVarUint(arg, bitLen((3 - 1))); }) }))(cell1); diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index 5fc99e0..fcfc73c 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -516,18 +516,14 @@ export interface BitUser { readonly b: boolean; } -export interface VarUInteger { - readonly kind: 'VarUInteger'; - readonly n: number; - readonly len: number; - readonly value: bigint; +export interface VarUIntegerUser { + readonly kind: 'VarUIntegerUser'; + readonly v: bigint; } -export interface VarInteger { - readonly kind: 'VarInteger'; - readonly n: number; - readonly len: number; - readonly value: bigint; +export interface VarIntegerUser { + readonly kind: 'VarIntegerUser'; + readonly v: bigint; } export interface GramsUser { @@ -2651,52 +2647,38 @@ export function storeBitUser(bitUser: BitUser): (builder: Builder) => void { } -/* -var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) - = VarUInteger n; -*/ +// a$_ v:(VarUInteger 5) = VarUIntegerUser; -export function loadVarUInteger(slice: Slice, n: number): VarUInteger { - let len: number = slice.loadUint(bitLen((n - 1))); - let value: bigint = slice.loadUintBig((len * 8)); +export function loadVarUIntegerUser(slice: Slice): VarUIntegerUser { + let v: bigint = slice.loadVarUintBig(bitLen((5 - 1))); return { - kind: 'VarUInteger', - n: n, - len: len, - value: value, + kind: 'VarUIntegerUser', + v: v, } } -export function storeVarUInteger(varUInteger: VarUInteger): (builder: Builder) => void { +export function storeVarUIntegerUser(varUIntegerUser: VarUIntegerUser): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeUint(varUInteger.len, bitLen((varUInteger.n - 1))); - builder.storeUint(varUInteger.value, (varUInteger.len * 8)); + builder.storeVarUint(varUIntegerUser.v, bitLen((5 - 1))); }) } -/* -var_int$_ {n:#} len:(#< n) value:(int (len * 8)) - = VarInteger n; -*/ +// a$_ v:(VarInteger 5) = VarIntegerUser; -export function loadVarInteger(slice: Slice, n: number): VarInteger { - let len: number = slice.loadUint(bitLen((n - 1))); - let value: bigint = slice.loadIntBig((len * 8)); +export function loadVarIntegerUser(slice: Slice): VarIntegerUser { + let v: bigint = slice.loadVarIntBig(5); return { - kind: 'VarInteger', - n: n, - len: len, - value: value, + kind: 'VarIntegerUser', + v: v, } } -export function storeVarInteger(varInteger: VarInteger): (builder: Builder) => void { +export function storeVarIntegerUser(varIntegerUser: VarIntegerUser): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeUint(varInteger.len, bitLen((varInteger.n - 1))); - builder.storeInt(varInteger.value, (varInteger.len * 8)); + builder.storeVarInt(varIntegerUser.v, 5); }) } diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index 261e5cd..f5707eb 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -154,5 +154,8 @@ var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) var_int$_ {n:#} len:(#< n) value:(int (len * 8)) = VarInteger n; +a$_ v:(VarUInteger 5) = VarUIntegerUser; +a$_ v:(VarInteger 5) = VarIntegerUser; + nanograms$_ amount:(VarUInteger 16) = Grams; a$_ g:Grams = GramsUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 1826ab8..fbd64ca 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -5,7 +5,7 @@ import { Address, BitString, Cell, ExternalAddress, Slice } from 'ton'; 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, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadAnyAddressUser, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBitUser, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadExtAddressUser, loadFalseAnonField, loadGramsUser, loadHashmapEUser, 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, storeAddressUser, storeAnonymousData, storeAnyAddressUser, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBitUser, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeExtAddressUser, storeFalseAnonField, storeGramsUser, storeHashmapEUser, 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 } from './generated_files/generated_test'; +import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, 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, loadHashmapEUser, 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, storeHashmapEUser, 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'; import { randomInt } from 'crypto'; const fixturesDir = path.resolve(__dirname, 'fixtures'); @@ -184,6 +184,12 @@ describe('Generating tlb code', () => { let anyAddressUserNull: AnyAddressUser = { kind: 'AnyAddressUser', src: null } checkSameOnStoreLoad(anyAddressUserNull, loadAnyAddressUser, storeAnyAddressUser) + + let varUIntegerUser: VarUIntegerUser = { kind: 'VarUIntegerUser', v: BigInt(5) } + checkSameOnStoreLoad(varUIntegerUser, loadVarUIntegerUser, storeVarUIntegerUser) + + let varIntegerUser: VarIntegerUser = { kind: 'VarIntegerUser', v: BigInt(-6) } + checkSameOnStoreLoad(varIntegerUser, loadVarIntegerUser, storeVarIntegerUser) }) test('Combinators', () => { From 25df10321d053dc92362e73ef9b1c2cbed9b5376 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Fri, 12 Jan 2024 03:12:42 -0500 Subject: [PATCH 06/28] add comments before structs --- src/generators/typescript/generator.ts | 1 + test/generated_files/generated_block.ts | 1320 ++++++++++++++++++++++- test/generated_files/generated_test.ts | 188 ++++ 3 files changed, 1498 insertions(+), 11 deletions(-) diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index a91841c..d8c63ea 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -334,6 +334,7 @@ export class TypescriptGenerator implements CodeGenerator { constructorsDeclarations.push(structX); this.jsCodeFunctionsDeclarations.push(tComment(constructor.declaration)); + this.jsCodeConstructorDeclarations.push(tComment(constructor.declaration)); }); this.addExceptionStmts(tlbType, loadStatements, storeStatements); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 703602a..9d68097 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -9,22 +9,34 @@ export function bitLen(n: number) { return n.toString(2).length;; } +// unit$_ = Unit; + export interface Unit { readonly kind: 'Unit'; } +// true$_ = True; + export interface True { readonly kind: 'True'; } +// bool_false$0 = BoolFalse; + export interface BoolFalse { readonly kind: 'BoolFalse'; } +// bool_true$1 = BoolTrue; + export interface BoolTrue { readonly kind: 'BoolTrue'; } +// nothing$0 {X:Type} = Maybe X; + +// just$1 {X:Type} value:X = Maybe X; + export type Maybe = Maybe_nothing | Maybe_just; export interface Maybe_nothing { @@ -36,6 +48,10 @@ export interface Maybe_just { readonly value: X; } +// left$0 {X:Type} {Y:Type} value:X = Either X Y; + +// right$1 {X:Type} {Y:Type} value:Y = Either X Y; + export type Either = Either_left | Either_right; export interface Either_left { @@ -48,12 +64,19 @@ export interface Either_right { readonly value: Y; } +// pair$_ {X:Type} {Y:Type} first:X second:Y = Both X Y; + export interface Both { readonly kind: 'Both'; readonly first: X; readonly second: Y; } +/* +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; +*/ + export interface Hashmap { readonly kind: 'Hashmap'; readonly n: number; @@ -63,6 +86,13 @@ export interface Hashmap { readonly node: HashmapNode; } +// hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; + +/* +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; +*/ + export type HashmapNode = HashmapNode_hmn_leaf | HashmapNode_hmn_fork; export interface HashmapNode_hmn_leaf { @@ -77,6 +107,12 @@ export interface HashmapNode_hmn_fork { readonly right: Hashmap; } +// hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + +// hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + +// hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + export type HmLabel = HmLabel_hml_short | HmLabel_hml_long | HmLabel_hml_same; export interface HmLabel_hml_short { @@ -101,6 +137,10 @@ export interface HmLabel_hml_same { readonly n: number; } +// unary_zero$0 = Unary ~0; + +// unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + export type Unary = Unary_unary_zero | Unary_unary_succ; export interface Unary_unary_zero { @@ -113,6 +153,10 @@ export interface Unary_unary_succ { readonly x: Unary; } +// hme_empty$0 {n:#} {X:Type} = HashmapE n X; + +// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; export interface HashmapE_hme_empty { @@ -126,12 +170,20 @@ export interface HashmapE_hme_root { readonly root: Hashmap; } +// _ {n:#} _:(Hashmap n True) = BitstringSet n; + export interface BitstringSet { readonly kind: 'BitstringSet'; readonly n: number; readonly _: Hashmap; } +/* +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +*/ + export interface HashmapAug { readonly kind: 'HashmapAug'; readonly n: number; @@ -141,6 +193,13 @@ export interface HashmapAug { readonly node: HashmapAugNode; } +// ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; + +/* +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; +*/ + export type HashmapAugNode = HashmapAugNode_ahmn_leaf | HashmapAugNode_ahmn_fork; export interface HashmapAugNode_ahmn_leaf { @@ -157,6 +216,16 @@ export interface HashmapAugNode_ahmn_fork { readonly extra: Y; } +/* +ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y + = HashmapAugE n X Y; +*/ + +/* +ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) + extra:Y = HashmapAugE n X Y; +*/ + export type HashmapAugE = HashmapAugE_ahme_empty | HashmapAugE_ahme_root; export interface HashmapAugE_ahme_empty { @@ -172,6 +241,12 @@ export interface HashmapAugE_ahme_root { readonly extra: Y; } +/* +vhm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(VarHashmapNode m X) + = VarHashmap n X; +*/ + export interface VarHashmap { readonly kind: 'VarHashmap'; readonly n: number; @@ -181,6 +256,19 @@ export interface VarHashmap { readonly node: VarHashmapNode; } +// vhmn_leaf$00 {n:#} {X:Type} value:X = VarHashmapNode n X; + +/* +vhmn_fork$01 {n:#} {X:Type} left:^(VarHashmap n X) + right:^(VarHashmap n X) value:(Maybe X) + = VarHashmapNode (n + 1) X; +*/ + +/* +vhmn_cont$1 {n:#} {X:Type} branch:Bit child:^(VarHashmap n X) + value:X = VarHashmapNode (n + 1) X; +*/ + export type VarHashmapNode = VarHashmapNode_vhmn_leaf | VarHashmapNode_vhmn_fork | VarHashmapNode_vhmn_cont; export interface VarHashmapNode_vhmn_leaf { @@ -205,6 +293,13 @@ export interface VarHashmapNode_vhmn_cont { readonly value: X; } +// vhme_empty$0 {n:#} {X:Type} = VarHashmapE n X; + +/* +vhme_root$1 {n:#} {X:Type} root:^(VarHashmap n X) + = VarHashmapE n X; +*/ + export type VarHashmapE = VarHashmapE_vhme_empty | VarHashmapE_vhme_root; export interface VarHashmapE_vhme_empty { @@ -218,6 +313,12 @@ export interface VarHashmapE_vhme_root { readonly root: VarHashmap; } +/* +phm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(PfxHashmapNode m X) + = PfxHashmap n X; +*/ + export interface PfxHashmap { readonly kind: 'PfxHashmap'; readonly n: number; @@ -227,6 +328,13 @@ export interface PfxHashmap { readonly node: PfxHashmapNode; } +// phmn_leaf$0 {n:#} {X:Type} value:X = PfxHashmapNode n X; + +/* +phmn_fork$1 {n:#} {X:Type} left:^(PfxHashmap n X) + right:^(PfxHashmap n X) = PfxHashmapNode (n + 1) X; +*/ + export type PfxHashmapNode = PfxHashmapNode_phmn_leaf | PfxHashmapNode_phmn_fork; export interface PfxHashmapNode_phmn_leaf { @@ -242,6 +350,13 @@ export interface PfxHashmapNode_phmn_fork { readonly right: PfxHashmap; } +// phme_empty$0 {n:#} {X:Type} = PfxHashmapE n X; + +/* +phme_root$1 {n:#} {X:Type} root:^(PfxHashmap n X) + = PfxHashmapE n X; +*/ + export type PfxHashmapE = PfxHashmapE_phme_empty | PfxHashmapE_phme_root; export interface PfxHashmapE_phme_empty { @@ -255,28 +370,62 @@ export interface PfxHashmapE_phme_root { readonly root: PfxHashmap; } +/* +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +*/ + export interface Anycast { readonly kind: 'Anycast'; readonly depth: number; readonly rewrite_pfx: BitString; } +// _ grams:Grams = Coins; + export interface Coins { readonly kind: 'Coins'; readonly grams: bigint; } +/* +extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) + = ExtraCurrencyCollection; +*/ + export interface ExtraCurrencyCollection { readonly kind: 'ExtraCurrencyCollection'; readonly dict: HashmapE; } +/* +currencies$_ grams:Grams other:ExtraCurrencyCollection + = CurrencyCollection; +*/ + export interface CurrencyCollection { readonly kind: 'CurrencyCollection'; readonly grams: bigint; readonly other: ExtraCurrencyCollection; } +/* +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddressInt dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfo; +*/ + +/* +ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt + import_fee:Grams = CommonMsgInfo; +*/ + +/* +ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfo; +*/ + export type CommonMsgInfo = CommonMsgInfo_int_msg_info | CommonMsgInfo_ext_in_msg_info | CommonMsgInfo_ext_out_msg_info; export interface CommonMsgInfo_int_msg_info { @@ -308,6 +457,18 @@ export interface CommonMsgInfo_ext_out_msg_info { readonly created_at: number; } +/* +int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddress dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; +*/ + +/* +ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; +*/ + export type CommonMsgInfoRelaxed = CommonMsgInfoRelaxed_int_msg_info | CommonMsgInfoRelaxed_ext_out_msg_info; export interface CommonMsgInfoRelaxed_int_msg_info { @@ -332,12 +493,20 @@ export interface CommonMsgInfoRelaxed_ext_out_msg_info { readonly created_at: number; } +// tick_tock$_ tick:Bool tock:Bool = TickTock; + export interface TickTock { readonly kind: 'TickTock'; readonly tick: boolean; readonly tock: boolean; } +/* +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(Maybe ^Cell) = StateInit; +*/ + export interface StateInit { readonly kind: 'StateInit'; readonly split_depth: Maybe; @@ -347,6 +516,12 @@ export interface StateInit { readonly library: Maybe; } +/* +_ split_depth:(Maybe (## 5)) special:(Maybe TickTock) + code:(Maybe ^Cell) data:(Maybe ^Cell) + library:(HashmapE 256 SimpleLib) = StateInitWithLibs; +*/ + export interface StateInitWithLibs { readonly kind: 'StateInitWithLibs'; readonly split_depth: Maybe; @@ -356,12 +531,20 @@ export interface StateInitWithLibs { readonly library: HashmapE; } +// simple_lib$_ public:Bool root:^Cell = SimpleLib; + export interface SimpleLib { readonly kind: 'SimpleLib'; readonly public0: boolean; readonly root: Slice; } +/* +message$_ {X:Type} info:CommonMsgInfo + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = Message X; +*/ + export interface Message { readonly kind: 'Message'; readonly info: CommonMsgInfo; @@ -369,6 +552,12 @@ export interface Message { readonly body: Either; } +/* +message$_ {X:Type} info:CommonMsgInfoRelaxed + init:(Maybe (Either StateInit ^StateInit)) + body:(Either X ^X) = MessageRelaxed X; +*/ + export interface MessageRelaxed { readonly kind: 'MessageRelaxed'; readonly info: CommonMsgInfoRelaxed; @@ -376,11 +565,28 @@ export interface MessageRelaxed { readonly body: Either; } +// _ (Message Any) = MessageAny; + export interface MessageAny { readonly kind: 'MessageAny'; readonly anon0: Message; } +/* +interm_addr_regular$0 use_dest_bits:(#<= 96) + = IntermediateAddress; +*/ + +/* +interm_addr_simple$10 workchain_id:int8 addr_pfx:uint64 + = IntermediateAddress; +*/ + +/* +interm_addr_ext$11 workchain_id:int32 addr_pfx:uint64 + = IntermediateAddress; +*/ + export type IntermediateAddress = IntermediateAddress_interm_addr_regular | IntermediateAddress_interm_addr_simple | IntermediateAddress_interm_addr_ext; export interface IntermediateAddress_interm_addr_regular { @@ -400,6 +606,12 @@ export interface IntermediateAddress_interm_addr_ext { readonly addr_pfx: number; } +/* +msg_envelope#4 cur_addr:IntermediateAddress + next_addr:IntermediateAddress fwd_fee_remaining:Grams + msg:^(Message Any) = MsgEnvelope; +*/ + export interface MsgEnvelope { readonly kind: 'MsgEnvelope'; readonly cur_addr: IntermediateAddress; @@ -408,6 +620,41 @@ export interface MsgEnvelope { readonly msg: Message; } +/* +msg_import_ext$000 msg:^(Message Any) transaction:^Transaction + = InMsg; +*/ + +/* +msg_import_ihr$010 msg:^(Message Any) transaction:^Transaction + ihr_fee:Grams proof_created:^Cell = InMsg; +*/ + +/* +msg_import_imm$011 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +*/ + +/* +msg_import_fin$100 in_msg:^MsgEnvelope + transaction:^Transaction fwd_fee:Grams = InMsg; +*/ + +/* +msg_import_tr$101 in_msg:^MsgEnvelope out_msg:^MsgEnvelope + transit_fee:Grams = InMsg; +*/ + +/* +msg_discard_fin$110 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams = InMsg; +*/ + +/* +msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64 + fwd_fee:Grams proof_delivered:^Cell = InMsg; +*/ + export type InMsg = InMsg_msg_import_ext | InMsg_msg_import_ihr | InMsg_msg_import_imm | InMsg_msg_import_fin | InMsg_msg_import_tr | InMsg_msg_discard_fin | InMsg_msg_discard_tr; export interface InMsg_msg_import_ext { @@ -460,19 +707,67 @@ export interface InMsg_msg_discard_tr { readonly proof_delivered: Slice; } +/* +import_fees$_ fees_collected:Grams + value_imported:CurrencyCollection = ImportFees; +*/ + export interface ImportFees { readonly kind: 'ImportFees'; readonly fees_collected: bigint; readonly value_imported: CurrencyCollection; } +// _ (HashmapAugE 256 InMsg ImportFees) = InMsgDescr; + export interface InMsgDescr { readonly kind: 'InMsgDescr'; readonly anon0: HashmapAugE; } -export type OutMsg = OutMsg_msg_export_ext | OutMsg_msg_export_imm | OutMsg_msg_export_new | OutMsg_msg_export_tr | OutMsg_msg_export_deq | OutMsg_msg_export_deq_short | OutMsg_msg_export_tr_req | OutMsg_msg_export_deq_imm; - +/* +msg_export_ext$000 msg:^(Message Any) + transaction:^Transaction = OutMsg; +*/ + +/* +msg_export_imm$010 out_msg:^MsgEnvelope + transaction:^Transaction reimport:^InMsg = OutMsg; +*/ + +/* +msg_export_new$001 out_msg:^MsgEnvelope + transaction:^Transaction = OutMsg; +*/ + +/* +msg_export_tr$011 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +*/ + +/* +msg_export_deq$1100 out_msg:^MsgEnvelope + import_block_lt:uint63 = OutMsg; +*/ + +/* +msg_export_deq_short$1101 msg_env_hash:bits256 + next_workchain:int32 next_addr_pfx:uint64 + import_block_lt:uint64 = OutMsg; +*/ + +/* +msg_export_tr_req$111 out_msg:^MsgEnvelope + imported:^InMsg = OutMsg; +*/ + +/* +msg_export_deq_imm$100 out_msg:^MsgEnvelope + reimport:^InMsg = OutMsg; +*/ + +export type OutMsg = OutMsg_msg_export_ext | OutMsg_msg_export_imm | OutMsg_msg_export_new | OutMsg_msg_export_tr | OutMsg_msg_export_deq | OutMsg_msg_export_deq_short | OutMsg_msg_export_tr_req | OutMsg_msg_export_deq_imm; + export interface OutMsg_msg_export_ext { readonly kind: 'OutMsg_msg_export_ext'; readonly msg: Message; @@ -524,43 +819,62 @@ export interface OutMsg_msg_export_deq_imm { readonly reimport: InMsg; } +// _ enqueued_lt:uint64 out_msg:^MsgEnvelope = EnqueuedMsg; + export interface EnqueuedMsg { readonly kind: 'EnqueuedMsg'; readonly enqueued_lt: number; readonly out_msg: MsgEnvelope; } +// _ (HashmapAugE 256 OutMsg CurrencyCollection) = OutMsgDescr; + export interface OutMsgDescr { readonly kind: 'OutMsgDescr'; readonly anon0: HashmapAugE; } +// _ (HashmapAugE 352 EnqueuedMsg uint64) = OutMsgQueue; + export interface OutMsgQueue { readonly kind: 'OutMsgQueue'; readonly anon0: HashmapAugE; } +// processed_upto$_ last_msg_lt:uint64 last_msg_hash:bits256 = ProcessedUpto; + export interface ProcessedUpto { readonly kind: 'ProcessedUpto'; readonly last_msg_lt: number; readonly last_msg_hash: BitString; } +// _ (HashmapE 96 ProcessedUpto) = ProcessedInfo; + export interface ProcessedInfo { readonly kind: 'ProcessedInfo'; readonly anon0: HashmapE; } +// ihr_pending$_ import_lt:uint64 = IhrPendingSince; + export interface IhrPendingSince { readonly kind: 'IhrPendingSince'; readonly import_lt: number; } +// _ (HashmapE 320 IhrPendingSince) = IhrPendingInfo; + export interface IhrPendingInfo { readonly kind: 'IhrPendingInfo'; readonly anon0: HashmapE; } +/* +_ out_queue:OutMsgQueue proc_info:ProcessedInfo + ihr_pending:IhrPendingInfo = OutMsgQueueInfo; +*/ + export interface OutMsgQueueInfo { readonly kind: 'OutMsgQueueInfo'; readonly out_queue: OutMsgQueue; @@ -568,6 +882,11 @@ export interface OutMsgQueueInfo { readonly ihr_pending: IhrPendingInfo; } +/* +storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7) + public_cells:(VarUInteger 7) = StorageUsed; +*/ + export interface StorageUsed { readonly kind: 'StorageUsed'; readonly _cells: bigint; @@ -575,12 +894,22 @@ export interface StorageUsed { readonly public_cells: bigint; } +/* +storage_used_short$_ cells:(VarUInteger 7) + bits:(VarUInteger 7) = StorageUsedShort; +*/ + export interface StorageUsedShort { readonly kind: 'StorageUsedShort'; readonly _cells: bigint; readonly bits: bigint; } +/* +storage_info$_ used:StorageUsed last_paid:uint32 + due_payment:(Maybe Grams) = StorageInfo; +*/ + export interface StorageInfo { readonly kind: 'StorageInfo'; readonly used: StorageUsed; @@ -588,6 +917,13 @@ export interface StorageInfo { readonly due_payment: Maybe; } +// account_none$0 = Account; + +/* +account$1 addr:MsgAddressInt storage_stat:StorageInfo + storage:AccountStorage = Account; +*/ + export type Account = Account_account_none | Account_account; export interface Account_account_none { @@ -601,6 +937,12 @@ export interface Account_account { readonly storage: AccountStorage; } +/* +account_storage$_ last_trans_lt:uint64 + balance:CurrencyCollection state:AccountState + = AccountStorage; +*/ + export interface AccountStorage { readonly kind: 'AccountStorage'; readonly last_trans_lt: number; @@ -608,6 +950,12 @@ export interface AccountStorage { readonly state: AccountState; } +// account_uninit$00 = AccountState; + +// account_active$1 _:StateInit = AccountState; + +// account_frozen$01 state_hash:bits256 = AccountState; + export type AccountState = AccountState_account_uninit | AccountState_account_active | AccountState_account_frozen; export interface AccountState_account_uninit { @@ -624,6 +972,14 @@ export interface AccountState_account_frozen { readonly state_hash: BitString; } +// acc_state_uninit$00 = AccountStatus; + +// acc_state_frozen$01 = AccountStatus; + +// acc_state_active$10 = AccountStatus; + +// acc_state_nonexist$11 = AccountStatus; + export type AccountStatus = AccountStatus_acc_state_uninit | AccountStatus_acc_state_frozen | AccountStatus_acc_state_active | AccountStatus_acc_state_nonexist; export interface AccountStatus_acc_state_uninit { @@ -642,6 +998,11 @@ export interface AccountStatus_acc_state_nonexist { readonly kind: 'AccountStatus_acc_state_nonexist'; } +/* +account_descr$_ account:^Account last_trans_hash:bits256 + last_trans_lt:uint64 = ShardAccount; +*/ + export interface ShardAccount { readonly kind: 'ShardAccount'; readonly account: Account; @@ -649,17 +1010,31 @@ export interface ShardAccount { readonly last_trans_lt: number; } +// depth_balance$_ split_depth:(#<= 30) balance:CurrencyCollection = DepthBalanceInfo; + export interface DepthBalanceInfo { readonly kind: 'DepthBalanceInfo'; readonly split_depth: number; readonly balance: CurrencyCollection; } +// _ (HashmapAugE 256 ShardAccount DepthBalanceInfo) = ShardAccounts; + export interface ShardAccounts { readonly kind: 'ShardAccounts'; readonly anon0: HashmapAugE; } +/* +transaction$0111 account_addr:bits256 lt:uint64 + prev_trans_hash:bits256 prev_trans_lt:uint64 now:uint32 + outmsg_cnt:uint15 + orig_status:AccountStatus end_status:AccountStatus + ^[ in_msg:(Maybe ^(Message Any)) out_msgs:(HashmapE 15 ^(Message Any)) ] + total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account) + description:^TransactionDescr = Transaction; +*/ + export interface Transaction { readonly kind: 'Transaction'; readonly account_addr: BitString; @@ -677,6 +1052,11 @@ export interface Transaction { readonly description: TransactionDescr; } +/* +merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 + old:^X new:^X = MERKLE_UPDATE X; +*/ + export interface MERKLE_UPDATE { readonly kind: 'MERKLE_UPDATE'; readonly old_hash: BitString; @@ -685,12 +1065,19 @@ export interface MERKLE_UPDATE { readonly new0: X; } +/* +update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256 + = HASH_UPDATE X; +*/ + export interface HASH_UPDATE { readonly kind: 'HASH_UPDATE'; readonly old_hash: BitString; readonly new_hash: BitString; } +// merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; + export interface MERKLE_PROOF { readonly kind: 'MERKLE_PROOF'; readonly virtual_hash: BitString; @@ -698,6 +1085,13 @@ export interface MERKLE_PROOF { readonly virtual_root: X; } +/* +acc_trans#5 account_addr:bits256 + transactions:(HashmapAug 64 ^Transaction CurrencyCollection) + state_update:^(HASH_UPDATE Account) + = AccountBlock; +*/ + export interface AccountBlock { readonly kind: 'AccountBlock'; readonly account_addr: BitString; @@ -705,11 +1099,20 @@ export interface AccountBlock { readonly state_update: HASH_UPDATE; } +// _ (HashmapAugE 256 AccountBlock CurrencyCollection) = ShardAccountBlocks; + export interface ShardAccountBlocks { readonly kind: 'ShardAccountBlocks'; readonly anon0: HashmapAugE; } +/* +tr_phase_storage$_ storage_fees_collected:Grams + storage_fees_due:(Maybe Grams) + status_change:AccStatusChange + = TrStoragePhase; +*/ + export interface TrStoragePhase { readonly kind: 'TrStoragePhase'; readonly storage_fees_collected: bigint; @@ -717,6 +1120,12 @@ export interface TrStoragePhase { readonly status_change: AccStatusChange; } +// acst_unchanged$0 = AccStatusChange; + +// acst_frozen$10 = AccStatusChange; + +// acst_deleted$11 = AccStatusChange; + export type AccStatusChange = AccStatusChange_acst_unchanged | AccStatusChange_acst_frozen | AccStatusChange_acst_deleted; export interface AccStatusChange_acst_unchanged { @@ -731,12 +1140,33 @@ export interface AccStatusChange_acst_deleted { readonly kind: 'AccStatusChange_acst_deleted'; } +/* +tr_phase_credit$_ due_fees_collected:(Maybe Grams) + credit:CurrencyCollection = TrCreditPhase; +*/ + export interface TrCreditPhase { readonly kind: 'TrCreditPhase'; readonly due_fees_collected: Maybe; readonly credit: CurrencyCollection; } +/* +tr_phase_compute_skipped$0 reason:ComputeSkipReason + = TrComputePhase; +*/ + +/* +tr_phase_compute_vm$1 success:Bool msg_state_used:Bool + account_activated:Bool gas_fees:Grams + ^[ gas_used:(VarUInteger 7) + gas_limit:(VarUInteger 7) gas_credit:(Maybe (VarUInteger 3)) + mode:int8 exit_code:int32 exit_arg:(Maybe int32) + vm_steps:uint32 + vm_init_state_hash:bits256 vm_final_state_hash:bits256 ] + = TrComputePhase; +*/ + export type TrComputePhase = TrComputePhase_tr_phase_compute_skipped | TrComputePhase_tr_phase_compute_vm; export interface TrComputePhase_tr_phase_compute_skipped { @@ -761,6 +1191,14 @@ export interface TrComputePhase_tr_phase_compute_vm { readonly vm_final_state_hash: BitString; } +// cskip_no_state$00 = ComputeSkipReason; + +// cskip_bad_state$01 = ComputeSkipReason; + +// cskip_no_gas$10 = ComputeSkipReason; + +// cskip_suspended$110 = ComputeSkipReason; + export type ComputeSkipReason = ComputeSkipReason_cskip_no_state | ComputeSkipReason_cskip_bad_state | ComputeSkipReason_cskip_no_gas | ComputeSkipReason_cskip_suspended; export interface ComputeSkipReason_cskip_no_state { @@ -779,6 +1217,16 @@ export interface ComputeSkipReason_cskip_suspended { readonly kind: 'ComputeSkipReason_cskip_suspended'; } +/* +tr_phase_action$_ success:Bool valid:Bool no_funds:Bool + status_change:AccStatusChange + total_fwd_fees:(Maybe Grams) total_action_fees:(Maybe Grams) + result_code:int32 result_arg:(Maybe int32) tot_actions:uint16 + spec_actions:uint16 skipped_actions:uint16 msgs_created:uint16 + action_list_hash:bits256 tot_msg_size:StorageUsedShort + = TrActionPhase; +*/ + export interface TrActionPhase { readonly kind: 'TrActionPhase'; readonly success: boolean; @@ -797,6 +1245,18 @@ export interface TrActionPhase { readonly tot_msg_size: StorageUsedShort; } +// tr_phase_bounce_negfunds$00 = TrBouncePhase; + +/* +tr_phase_bounce_nofunds$01 msg_size:StorageUsedShort + req_fwd_fees:Grams = TrBouncePhase; +*/ + +/* +tr_phase_bounce_ok$1 msg_size:StorageUsedShort + msg_fees:Grams fwd_fees:Grams = TrBouncePhase; +*/ + export type TrBouncePhase = TrBouncePhase_tr_phase_bounce_negfunds | TrBouncePhase_tr_phase_bounce_nofunds | TrBouncePhase_tr_phase_bounce_ok; export interface TrBouncePhase_tr_phase_bounce_negfunds { @@ -816,6 +1276,57 @@ export interface TrBouncePhase_tr_phase_bounce_ok { readonly fwd_fees: bigint; } +/* +trans_ord$0000 credit_first:Bool + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool bounce:(Maybe TrBouncePhase) + destroyed:Bool + = TransactionDescr; +*/ + +/* +trans_storage$0001 storage_ph:TrStoragePhase + = TransactionDescr; +*/ + +/* +trans_tick_tock$001 is_tock:Bool storage_ph:TrStoragePhase + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool = TransactionDescr; +*/ + +/* +trans_split_prepare$0100 split_info:SplitMergeInfo + storage_ph:(Maybe TrStoragePhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; +*/ + +/* +trans_split_install$0101 split_info:SplitMergeInfo + prepare_transaction:^Transaction + installed:Bool = TransactionDescr; +*/ + +/* +trans_merge_prepare$0110 split_info:SplitMergeInfo + storage_ph:TrStoragePhase aborted:Bool + = TransactionDescr; +*/ + +/* +trans_merge_install$0111 split_info:SplitMergeInfo + prepare_transaction:^Transaction + storage_ph:(Maybe TrStoragePhase) + credit_ph:(Maybe TrCreditPhase) + compute_ph:TrComputePhase action:(Maybe ^TrActionPhase) + aborted:Bool destroyed:Bool + = TransactionDescr; +*/ + export type TransactionDescr = TransactionDescr_trans_ord | TransactionDescr_trans_storage | TransactionDescr_trans_tick_tock | TransactionDescr_trans_split_prepare | TransactionDescr_trans_split_install | TransactionDescr_trans_merge_prepare | TransactionDescr_trans_merge_install; export interface TransactionDescr_trans_ord { @@ -881,6 +1392,12 @@ export interface TransactionDescr_trans_merge_install { readonly destroyed: boolean; } +/* +split_merge_info$_ cur_shard_pfx_len:(## 6) + acc_split_depth:(## 6) this_addr:bits256 sibling_addr:bits256 + = SplitMergeInfo; +*/ + export interface SplitMergeInfo { readonly kind: 'SplitMergeInfo'; readonly cur_shard_pfx_len: number; @@ -889,6 +1406,13 @@ export interface SplitMergeInfo { readonly sibling_addr: BitString; } +/* +smc_info#076ef1ea actions:uint16 msgs_sent:uint16 + unixtime:uint32 block_lt:uint64 trans_lt:uint64 + rand_seed:bits256 balance_remaining:CurrencyCollection + myself:MsgAddressInt global_config:(Maybe Cell) = SmartContractInfo; +*/ + export interface SmartContractInfo { readonly kind: 'SmartContractInfo'; readonly actions: number; @@ -902,6 +1426,13 @@ export interface SmartContractInfo { readonly global_config: Maybe; } +// out_list_empty$_ = OutList 0; + +/* +out_list$_ {n:#} prev:^(OutList n) action:OutAction + = OutList (n + 1); +*/ + export type OutList = OutList_out_list_empty | OutList_out_list; export interface OutList_out_list_empty { @@ -915,6 +1446,23 @@ export interface OutList_out_list { readonly action: OutAction; } +/* +action_send_msg#0ec3c86d mode:(## 8) + out_msg:^(MessageRelaxed Any) = OutAction; +*/ + +// action_set_code#ad4de08e new_code:^Cell = OutAction; + +/* +action_reserve_currency#36e6b809 mode:(## 8) + currency:CurrencyCollection = OutAction; +*/ + +/* +action_change_library#26fa1dd4 mode:(## 7) + libref:LibRef = OutAction; +*/ + export type OutAction = OutAction_action_send_msg | OutAction_action_set_code | OutAction_action_reserve_currency | OutAction_action_change_library; export interface OutAction_action_send_msg { @@ -940,6 +1488,10 @@ export interface OutAction_action_change_library { readonly libref: LibRef; } +// libref_hash$0 lib_hash:bits256 = LibRef; + +// libref_ref$1 library:^Cell = LibRef; + export type LibRef = LibRef_libref_hash | LibRef_libref_ref; export interface LibRef_libref_hash { @@ -952,12 +1504,19 @@ export interface LibRef_libref_ref { readonly library: Slice; } +// out_list_node$_ prev:^Cell action:OutAction = OutListNode; + export interface OutListNode { readonly kind: 'OutListNode'; readonly prev: Slice; readonly action: OutAction; } +/* +shard_ident$00 shard_pfx_bits:(#<= 60) + workchain_id:int32 shard_prefix:uint64 = ShardIdent; +*/ + export interface ShardIdent { readonly kind: 'ShardIdent'; readonly shard_pfx_bits: number; @@ -965,6 +1524,12 @@ export interface ShardIdent { readonly shard_prefix: number; } +/* +ext_blk_ref$_ end_lt:uint64 + seq_no:uint32 root_hash:bits256 file_hash:bits256 + = ExtBlkRef; +*/ + export interface ExtBlkRef { readonly kind: 'ExtBlkRef'; readonly end_lt: number; @@ -973,6 +1538,11 @@ export interface ExtBlkRef { readonly file_hash: BitString; } +/* +block_id_ext$_ shard_id:ShardIdent seq_no:uint32 + root_hash:bits256 file_hash:bits256 = BlockIdExt; +*/ + export interface BlockIdExt { readonly kind: 'BlockIdExt'; readonly shard_id: ShardIdent; @@ -981,11 +1551,31 @@ export interface BlockIdExt { readonly file_hash: BitString; } +// master_info$_ master:ExtBlkRef = BlkMasterInfo; + export interface BlkMasterInfo { readonly kind: 'BlkMasterInfo'; readonly master: ExtBlkRef; } +/* +shard_state#9023afe2 global_id:int32 + shard_id:ShardIdent + seq_no:uint32 vert_seq_no:# + gen_utime:uint32 gen_lt:uint64 + min_ref_mc_seqno:uint32 + out_msg_queue_info:^OutMsgQueueInfo + before_split:(## 1) + accounts:^ShardAccounts + ^[ overload_history:uint64 underload_history:uint64 + total_balance:CurrencyCollection + total_validator_fees:CurrencyCollection + libraries:(HashmapE 256 LibDescr) + master_ref:(Maybe BlkMasterInfo) ] + custom:(Maybe ^McStateExtra) + = ShardStateUnsplit; +*/ + export interface ShardStateUnsplit { readonly kind: 'ShardStateUnsplit'; readonly global_id: number; @@ -1007,6 +1597,10 @@ export interface ShardStateUnsplit { readonly custom: Maybe; } +// split_state#5f327da5 left:^ShardStateUnsplit right:^ShardStateUnsplit = ShardState; + +// _ ShardStateUnsplit = ShardState; + export type ShardState = ShardState_split_state | ShardState__; export interface ShardState_split_state { @@ -1020,12 +1614,40 @@ export interface ShardState__ { readonly anon0: ShardStateUnsplit; } +/* +shared_lib_descr$00 lib:^Cell publishers:(Hashmap 256 True) + = LibDescr; +*/ + export interface LibDescr { readonly kind: 'LibDescr'; readonly lib: Slice; readonly publishers: Hashmap; } +/* +block_info#9bc7a987 version:uint32 + not_master:(## 1) + after_merge:(## 1) before_split:(## 1) + after_split:(## 1) + want_split:Bool want_merge:Bool + key_block:Bool vert_seqno_incr:(## 1) + flags:(## 8) { flags <= 1 } + seq_no:# vert_seq_no:# { vert_seq_no >= vert_seqno_incr } + { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } + shard:ShardIdent gen_utime:uint32 + start_lt:uint64 end_lt:uint64 + gen_validator_list_hash_short:uint32 + gen_catchain_seqno:uint32 + min_ref_mc_seqno:uint32 + prev_key_block_seqno:uint32 + gen_software:flags . 0?GlobalVersion + master_ref:not_master?^BlkMasterInfo + prev_ref:^(BlkPrevInfo after_merge) + prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0) + = BlockInfo; +*/ + export interface BlockInfo { readonly kind: 'BlockInfo'; readonly prev_seq_no: number; @@ -1055,6 +1677,10 @@ export interface BlockInfo { readonly prev_vert_ref: BlkPrevInfo | undefined; } +// prev_blk_info$_ prev:ExtBlkRef = BlkPrevInfo 0; + +// prev_blks_info$_ prev1:^ExtBlkRef prev2:^ExtBlkRef = BlkPrevInfo 1; + export type BlkPrevInfo = BlkPrevInfo_prev_blk_info | BlkPrevInfo_prev_blks_info; export interface BlkPrevInfo_prev_blk_info { @@ -1068,6 +1694,13 @@ export interface BlkPrevInfo_prev_blks_info { readonly prev2: ExtBlkRef; } +/* +block#11ef55aa global_id:int32 + info:^BlockInfo value_flow:^ValueFlow + state_update:^(MERKLE_UPDATE ShardState) + extra:^BlockExtra = Block; +*/ + export interface Block { readonly kind: 'Block'; readonly global_id: number; @@ -1077,6 +1710,15 @@ export interface Block { readonly extra: BlockExtra; } +/* +block_extra in_msg_descr:^InMsgDescr + out_msg_descr:^OutMsgDescr + account_blocks:^ShardAccountBlocks + rand_seed:bits256 + created_by:bits256 + custom:(Maybe ^McBlockExtra) = BlockExtra; +*/ + export interface BlockExtra { readonly kind: 'BlockExtra'; readonly in_msg_descr: InMsgDescr; @@ -1087,6 +1729,35 @@ export interface BlockExtra { readonly custom: Maybe; } +/* +value_flow#b8e48dfb ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; +*/ + +/* +value_flow_v2#3ebf98b7 ^[ from_prev_blk:CurrencyCollection + to_next_blk:CurrencyCollection + imported:CurrencyCollection + exported:CurrencyCollection ] + fees_collected:CurrencyCollection + burned:CurrencyCollection + ^[ + fees_imported:CurrencyCollection + recovered:CurrencyCollection + created:CurrencyCollection + minted:CurrencyCollection + ] = ValueFlow; +*/ + export type ValueFlow = ValueFlow_value_flow | ValueFlow_value_flow_v2; export interface ValueFlow_value_flow { @@ -1116,6 +1787,13 @@ export interface ValueFlow_value_flow_v2 { readonly minted: CurrencyCollection; } +// bt_leaf$0 {X:Type} leaf:X = BinTree X; + +/* +bt_fork$1 {X:Type} left:^(BinTree X) right:^(BinTree X) + = BinTree X; +*/ + export type BinTree = BinTree_bt_leaf | BinTree_bt_fork; export interface BinTree_bt_leaf { @@ -1129,6 +1807,12 @@ export interface BinTree_bt_fork { readonly right: BinTree; } +// fsm_none$0 = FutureSplitMerge; + +// fsm_split$10 split_utime:uint32 interval:uint32 = FutureSplitMerge; + +// fsm_merge$11 merge_utime:uint32 interval:uint32 = FutureSplitMerge; + export type FutureSplitMerge = FutureSplitMerge_fsm_none | FutureSplitMerge_fsm_split | FutureSplitMerge_fsm_merge; export interface FutureSplitMerge_fsm_none { @@ -1147,6 +1831,34 @@ export interface FutureSplitMerge_fsm_merge { readonly interval: number; } +/* +shard_descr#b seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + fees_collected:CurrencyCollection + funds_created:CurrencyCollection = ShardDescr; +*/ + +/* +shard_descr_new#a seq_no:uint32 reg_mc_seqno:uint32 + start_lt:uint64 end_lt:uint64 + root_hash:bits256 file_hash:bits256 + before_split:Bool before_merge:Bool + want_split:Bool want_merge:Bool + nx_cc_updated:Bool flags:(## 3) { flags = 0 } + next_catchain_seqno:uint32 next_validator_shard:uint64 + min_ref_mc_seqno:uint32 gen_utime:uint32 + split_merge_at:FutureSplitMerge + ^[ fees_collected:CurrencyCollection + funds_created:CurrencyCollection ] = ShardDescr; +*/ + export type ShardDescr = ShardDescr_shard_descr | ShardDescr_shard_descr_new; export interface ShardDescr_shard_descr { @@ -1195,11 +1907,20 @@ export interface ShardDescr_shard_descr_new { readonly funds_created: CurrencyCollection; } +// _ (HashmapE 32 ^(BinTree ShardDescr)) = ShardHashes; + export interface ShardHashes { readonly kind: 'ShardHashes'; readonly anon0: HashmapE>; } +// bta_leaf$0 {X:Type} {Y:Type} extra:Y leaf:X = BinTreeAug X Y; + +/* +bta_fork$1 {X:Type} {Y:Type} left:^(BinTreeAug X Y) + right:^(BinTreeAug X Y) extra:Y = BinTreeAug X Y; +*/ + export type BinTreeAug = BinTreeAug_bta_leaf | BinTreeAug_bta_fork; export interface BinTreeAug_bta_leaf { @@ -1215,23 +1936,40 @@ export interface BinTreeAug_bta_fork { readonly extra: Y; } +// _ fees:CurrencyCollection create:CurrencyCollection = ShardFeeCreated; + export interface ShardFeeCreated { readonly kind: 'ShardFeeCreated'; readonly fees: CurrencyCollection; readonly create: CurrencyCollection; } +// _ (HashmapAugE 96 ShardFeeCreated ShardFeeCreated) = ShardFees; + export interface ShardFees { readonly kind: 'ShardFees'; readonly anon0: HashmapAugE; } +/* +_ config_addr:bits256 config:^(Hashmap 32 ^Cell) + = ConfigParams; +*/ + export interface ConfigParams { readonly kind: 'ConfigParams'; readonly config_addr: BitString; readonly config: Hashmap; } +/* +validator_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 + nx_cc_updated:Bool += ValidatorInfo; +*/ + export interface ValidatorInfo { readonly kind: 'ValidatorInfo'; readonly validator_list_hash_short: number; @@ -1239,29 +1977,44 @@ export interface ValidatorInfo { readonly nx_cc_updated: boolean; } +/* +validator_base_info$_ + validator_list_hash_short:uint32 + catchain_seqno:uint32 += ValidatorBaseInfo; +*/ + export interface ValidatorBaseInfo { readonly kind: 'ValidatorBaseInfo'; readonly validator_list_hash_short: number; readonly catchain_seqno: number; } +// _ key:Bool max_end_lt:uint64 = KeyMaxLt; + export interface KeyMaxLt { readonly kind: 'KeyMaxLt'; readonly key: boolean; readonly max_end_lt: number; } +// _ key:Bool blk_ref:ExtBlkRef = KeyExtBlkRef; + export interface KeyExtBlkRef { readonly kind: 'KeyExtBlkRef'; readonly key: boolean; readonly blk_ref: ExtBlkRef; } +// _ (HashmapAugE 32 KeyExtBlkRef KeyMaxLt) = OldMcBlocksInfo; + export interface OldMcBlocksInfo { readonly kind: 'OldMcBlocksInfo'; readonly anon0: HashmapAugE; } +// counters#_ last_updated:uint32 total:uint64 cnt2048:uint64 cnt65536:uint64 = Counters; + export interface Counters { readonly kind: 'Counters'; readonly last_updated: number; @@ -1270,12 +2023,18 @@ export interface Counters { readonly cnt65536: number; } +// creator_info#4 mc_blocks:Counters shard_blocks:Counters = CreatorStats; + export interface CreatorStats { readonly kind: 'CreatorStats'; readonly mc_blocks: Counters; readonly shard_blocks: Counters; } +// block_create_stats#17 counters:(HashmapE 256 CreatorStats) = BlockCreateStats; + +// block_create_stats_ext#34 counters:(HashmapAugE 256 CreatorStats uint32) = BlockCreateStats; + export type BlockCreateStats = BlockCreateStats_block_create_stats | BlockCreateStats_block_create_stats_ext; export interface BlockCreateStats_block_create_stats { @@ -1288,6 +2047,20 @@ export interface BlockCreateStats_block_create_stats_ext { readonly counters: HashmapAugE; } +/* +masterchain_state_extra#cc26 + shard_hashes:ShardHashes + config:ConfigParams + ^[ flags:(## 16) { flags <= 1 } + validator_info:ValidatorInfo + prev_blocks:OldMcBlocksInfo + after_key_block:Bool + last_key_block:(Maybe ExtBlkRef) + block_create_stats:(flags . 0)?BlockCreateStats ] + global_balance:CurrencyCollection += McStateExtra; +*/ + export interface McStateExtra { readonly kind: 'McStateExtra'; readonly shard_hashes: ShardHashes; @@ -1301,17 +2074,28 @@ export interface McStateExtra { readonly global_balance: CurrencyCollection; } +// ed25519_pubkey#8e81278a pubkey:bits256 = SigPubKey; + export interface SigPubKey { readonly kind: 'SigPubKey'; readonly pubkey: BitString; } +// ed25519_signature#5 R:bits256 s:bits256 = CryptoSignatureSimple; + export interface CryptoSignatureSimple { readonly kind: 'CryptoSignatureSimple'; readonly R: BitString; readonly s: BitString; } +/* +chained_signature#f signed_cert:^SignedCertificate temp_key_signature:CryptoSignatureSimple + = CryptoSignature; +*/ + +// _ CryptoSignatureSimple = CryptoSignature; + export type CryptoSignature = CryptoSignature_chained_signature | CryptoSignature__; export interface CryptoSignature_chained_signature { @@ -1325,12 +2109,16 @@ export interface CryptoSignature__ { readonly anon0: CryptoSignatureSimple; } +// sig_pair$_ node_id_short:bits256 sign:CryptoSignature = CryptoSignaturePair; + export interface CryptoSignaturePair { readonly kind: 'CryptoSignaturePair'; readonly node_id_short: BitString; readonly sign: CryptoSignature; } +// certificate#4 temp_key:SigPubKey valid_since:uint32 valid_until:uint32 = Certificate; + export interface Certificate { readonly kind: 'Certificate'; readonly temp_key: SigPubKey; @@ -1338,17 +2126,36 @@ export interface Certificate { readonly valid_until: number; } +// certificate_env#a419b7d certificate:Certificate = CertificateEnv; + export interface CertificateEnv { readonly kind: 'CertificateEnv'; readonly certificate: Certificate; } +/* +signed_certificate$_ certificate:Certificate certificate_signature:CryptoSignature + = SignedCertificate; +*/ + export interface SignedCertificate { readonly kind: 'SignedCertificate'; readonly certificate: Certificate; readonly certificate_signature: CryptoSignature; } +/* +masterchain_block_extra#cca5 + key_block:(## 1) + shard_hashes:ShardHashes + shard_fees:ShardFees + ^[ prev_blk_signatures:(HashmapE 16 CryptoSignaturePair) + recover_create_msg:(Maybe ^InMsg) + mint_msg:(Maybe ^InMsg) ] + config:key_block?ConfigParams += McBlockExtra; +*/ + export interface McBlockExtra { readonly kind: 'McBlockExtra'; readonly key_block: number; @@ -1360,6 +2167,10 @@ export interface McBlockExtra { readonly config: ConfigParams | undefined; } +// validator#53 public_key:SigPubKey weight:uint64 = ValidatorDescr; + +// validator_addr#73 public_key:SigPubKey weight:uint64 adnl_addr:bits256 = ValidatorDescr; + export type ValidatorDescr = ValidatorDescr_validator | ValidatorDescr_validator_addr; export interface ValidatorDescr_validator { @@ -1375,6 +2186,18 @@ export interface ValidatorDescr_validator_addr { readonly adnl_addr: BitString; } +/* +validators#11 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + list:(Hashmap 16 ValidatorDescr) = ValidatorSet; +*/ + +/* +validators_ext#12 utime_since:uint32 utime_until:uint32 + total:(## 16) main:(## 16) { main <= total } { main >= 1 } + total_weight:uint64 list:(HashmapE 16 ValidatorDescr) = ValidatorSet; +*/ + export type ValidatorSet = ValidatorSet_validators | ValidatorSet_validators_ext; export interface ValidatorSet_validators { @@ -1396,6 +2219,106 @@ export interface ValidatorSet_validators_ext { readonly list: HashmapE; } +// _ config_addr:bits256 = ConfigParam 0; + +// _ elector_addr:bits256 = ConfigParam 1; + +// _ minter_addr:bits256 = ConfigParam 2; + +// _ fee_collector_addr:bits256 = ConfigParam 3; + +// _ dns_root_addr:bits256 = ConfigParam 4; + +// _ BurningConfig = ConfigParam 5; + +// _ mint_new_price:Grams mint_add_price:Grams = ConfigParam 6; + +// _ to_mint:ExtraCurrencyCollection = ConfigParam 7; + +// _ GlobalVersion = ConfigParam 8; + +// _ mandatory_params:(Hashmap 32 True) = ConfigParam 9; + +// _ critical_params:(Hashmap 32 True) = ConfigParam 10; + +// _ ConfigVotingSetup = ConfigParam 11; + +// _ workchains:(HashmapE 32 WorkchainDescr) = ConfigParam 12; + +// _ ComplaintPricing = ConfigParam 13; + +// _ BlockCreateFees = ConfigParam 14; + +/* +_ validators_elected_for:uint32 elections_start_before:uint32 + elections_end_before:uint32 stake_held_for:uint32 + = ConfigParam 15; +*/ + +/* +_ max_validators:(## 16) max_main_validators:(## 16) min_validators:(## 16) + { max_validators >= max_main_validators } + { max_main_validators >= min_validators } + { min_validators >= 1 } + = ConfigParam 16; +*/ + +// _ min_stake:Grams max_stake:Grams min_total_stake:Grams max_stake_factor:uint32 = ConfigParam 17; + +// _ (Hashmap 32 StoragePrices) = ConfigParam 18; + +// _ global_id:int32 = ConfigParam 19; + +// config_mc_gas_prices#_ GasLimitsPrices = ConfigParam 20; + +// config_gas_prices#_ GasLimitsPrices = ConfigParam 21; + +// config_mc_block_limits#_ BlockLimits = ConfigParam 22; + +// config_block_limits#_ BlockLimits = ConfigParam 23; + +// config_mc_fwd_prices#_ MsgForwardPrices = ConfigParam 24; + +// config_fwd_prices#_ MsgForwardPrices = ConfigParam 25; + +// _ CatchainConfig = ConfigParam 28; + +// _ ConsensusConfig = ConfigParam 29; + +// _ fundamental_smc_addr:(HashmapE 256 True) = ConfigParam 31; + +// _ prev_validators:ValidatorSet = ConfigParam 32; + +// _ prev_temp_validators:ValidatorSet = ConfigParam 33; + +// _ cur_validators:ValidatorSet = ConfigParam 34; + +// _ cur_temp_validators:ValidatorSet = ConfigParam 35; + +// _ next_validators:ValidatorSet = ConfigParam 36; + +// _ next_temp_validators:ValidatorSet = ConfigParam 37; + +// _ (HashmapE 256 ValidatorSignedTempKey) = ConfigParam 39; + +// _ MisbehaviourPunishmentConfig = ConfigParam 40; + +// _ SizeLimitsConfig = ConfigParam 43; + +// _ SuspendedAddressList = ConfigParam 44; + +// _ OracleBridgeParams = ConfigParam 71; + +// _ OracleBridgeParams = ConfigParam 72; + +// _ OracleBridgeParams = ConfigParam 73; + +// _ JettonBridgeParams = ConfigParam 79; + +// _ JettonBridgeParams = ConfigParam 81; + +// _ JettonBridgeParams = ConfigParam 82; + export type ConfigParam = ConfigParam__ | ConfigParam__1 | ConfigParam__2 | ConfigParam__3 | ConfigParam__4 | ConfigParam__5 | ConfigParam__6 | ConfigParam__7 | ConfigParam__8 | ConfigParam__9 | ConfigParam__10 | ConfigParam__11 | ConfigParam__12 | ConfigParam__13 | ConfigParam__14 | ConfigParam__15 | ConfigParam__16 | ConfigParam__17 | ConfigParam__18 | ConfigParam__19 | ConfigParam_config_mc_gas_prices | ConfigParam_config_gas_prices | ConfigParam_config_mc_block_limits | ConfigParam_config_block_limits | ConfigParam_config_mc_fwd_prices | ConfigParam_config_fwd_prices | ConfigParam__26 | ConfigParam__27 | ConfigParam__28 | ConfigParam__29 | ConfigParam__30 | ConfigParam__31 | ConfigParam__32 | ConfigParam__33 | ConfigParam__34 | ConfigParam__35 | ConfigParam__36 | ConfigParam__37 | ConfigParam__38 | ConfigParam__39 | ConfigParam__40 | ConfigParam__41 | ConfigParam__42 | ConfigParam__43 | ConfigParam__44; export interface ConfigParam__ { @@ -1632,6 +2555,12 @@ export interface ConfigParam__44 { readonly anon0: JettonBridgeParams; } +/* +burning_config#01 + blackhole_addr:(Maybe bits256) + fee_burn_num:# fee_burn_denom:# { fee_burn_num <= fee_burn_denom } { fee_burn_denom >= 1 } = BurningConfig; +*/ + export interface BurningConfig { readonly kind: 'BurningConfig'; readonly blackhole_addr: Maybe; @@ -1639,12 +2568,16 @@ export interface BurningConfig { readonly fee_burn_denom: number; } +// capabilities#c4 version:uint32 capabilities:uint64 = GlobalVersion; + export interface GlobalVersion { readonly kind: 'GlobalVersion'; readonly version: number; readonly capabilities: number; } +// cfg_vote_cfg#36 min_tot_rounds:uint8 max_tot_rounds:uint8 min_wins:uint8 max_losses:uint8 min_store_sec:uint32 max_store_sec:uint32 bit_price:uint32 cell_price:uint32 = ConfigProposalSetup; + export interface ConfigProposalSetup { readonly kind: 'ConfigProposalSetup'; readonly min_tot_rounds: number; @@ -1657,12 +2590,19 @@ export interface ConfigProposalSetup { readonly _cell_price: number; } +// cfg_vote_setup#91 normal_params:^ConfigProposalSetup critical_params:^ConfigProposalSetup = ConfigVotingSetup; + export interface ConfigVotingSetup { readonly kind: 'ConfigVotingSetup'; readonly normal_params: ConfigProposalSetup; readonly critical_params: ConfigProposalSetup; } +/* +cfg_proposal#f3 param_id:int32 param_value:(Maybe ^Cell) if_hash_equal:(Maybe uint256) + = ConfigProposal; +*/ + export interface ConfigProposal { readonly kind: 'ConfigProposal'; readonly param_id: number; @@ -1670,6 +2610,12 @@ export interface ConfigProposal { readonly if_hash_equal: Maybe; } +/* +cfg_proposal_status#ce expires:uint32 proposal:^ConfigProposal is_critical:Bool + voters:(HashmapE 16 True) remaining_weight:int64 validator_set_id:uint256 + rounds_remaining:uint8 wins:uint8 losses:uint8 = ConfigProposalStatus; +*/ + export interface ConfigProposalStatus { readonly kind: 'ConfigProposalStatus'; readonly expires: number; @@ -1683,6 +2629,16 @@ export interface ConfigProposalStatus { readonly losses: number; } +// wfmt_basic#1 vm_version:int32 vm_mode:uint64 = WorkchainFormat 1; + +/* +wfmt_ext#0 min_addr_len:(## 12) max_addr_len:(## 12) addr_len_step:(## 12) + { min_addr_len >= 64 } { min_addr_len <= max_addr_len } + { max_addr_len <= 1023 } { addr_len_step <= 1023 } + workchain_type_id:(## 32) { workchain_type_id >= 1 } + = WorkchainFormat 0; +*/ + export type WorkchainFormat = WorkchainFormat_wfmt_basic | WorkchainFormat_wfmt_ext; export interface WorkchainFormat_wfmt_basic { @@ -1699,6 +2655,13 @@ export interface WorkchainFormat_wfmt_ext { readonly workchain_type_id: number; } +/* +wc_split_merge_timings#0 + split_merge_delay:uint32 split_merge_interval:uint32 + min_split_merge_interval:uint32 max_split_merge_delay:uint32 + = WcSplitMergeTimings; +*/ + export interface WcSplitMergeTimings { readonly kind: 'WcSplitMergeTimings'; readonly split_merge_delay: number; @@ -1707,6 +2670,25 @@ export interface WcSplitMergeTimings { readonly max_split_merge_delay: number; } +/* +workchain#a6 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + = WorkchainDescr; +*/ + +/* +workchain_v2#a7 enabled_since:uint32 actual_min_split:(## 8) + min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split } + basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 } + zerostate_root_hash:bits256 zerostate_file_hash:bits256 + version:uint32 format:(WorkchainFormat basic) + split_merge_timings:WcSplitMergeTimings + = WorkchainDescr; +*/ + export type WorkchainDescr = WorkchainDescr_workchain | WorkchainDescr_workchain_v2; export interface WorkchainDescr_workchain { @@ -1742,6 +2724,8 @@ export interface WorkchainDescr_workchain_v2 { readonly split_merge_timings: WcSplitMergeTimings; } +// complaint_prices#1a deposit:Grams bit_price:Grams cell_price:Grams = ComplaintPricing; + export interface ComplaintPricing { readonly kind: 'ComplaintPricing'; readonly deposit: bigint; @@ -1749,12 +2733,22 @@ export interface ComplaintPricing { readonly _cell_price: bigint; } +/* +block_grams_created#6b masterchain_block_fee:Grams basechain_block_fee:Grams + = BlockCreateFees; +*/ + export interface BlockCreateFees { readonly kind: 'BlockCreateFees'; readonly masterchain_block_fee: bigint; readonly basechain_block_fee: bigint; } +/* +_#cc utime_since:uint32 bit_price_ps:uint64 cell_price_ps:uint64 + mc_bit_price_ps:uint64 mc_cell_price_ps:uint64 = StoragePrices; +*/ + export interface StoragePrices { readonly kind: 'StoragePrices'; readonly utime_since: number; @@ -1764,6 +2758,23 @@ export interface StoragePrices { readonly mc_cell_price_ps: number; } +/* +gas_prices#dd gas_price:uint64 gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; +*/ + +/* +gas_prices_ext#de gas_price:uint64 gas_limit:uint64 special_gas_limit:uint64 gas_credit:uint64 + block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64 + = GasLimitsPrices; +*/ + +/* +gas_flat_pfx#d1 flat_gas_limit:uint64 flat_gas_price:uint64 other:GasLimitsPrices + = GasLimitsPrices; +*/ + export type GasLimitsPrices = GasLimitsPrices_gas_prices | GasLimitsPrices_gas_prices_ext | GasLimitsPrices_gas_flat_pfx; export interface GasLimitsPrices_gas_prices { @@ -1794,6 +2805,11 @@ export interface GasLimitsPrices_gas_flat_pfx { readonly other: GasLimitsPrices; } +/* +param_limits#c3 underload:# soft_limit:# { underload <= soft_limit } + hard_limit:# { soft_limit <= hard_limit } = ParamLimits; +*/ + export interface ParamLimits { readonly kind: 'ParamLimits'; readonly underload: number; @@ -1801,6 +2817,11 @@ export interface ParamLimits { readonly hard_limit: number; } +/* +block_limits#5d bytes:ParamLimits gas:ParamLimits lt_delta:ParamLimits + = BlockLimits; +*/ + export interface BlockLimits { readonly kind: 'BlockLimits'; readonly bytes: ParamLimits; @@ -1808,6 +2829,11 @@ export interface BlockLimits { readonly lt_delta: ParamLimits; } +/* +msg_forward_prices#ea lump_price:uint64 bit_price:uint64 cell_price:uint64 + ihr_price_factor:uint32 first_frac:uint16 next_frac:uint16 = MsgForwardPrices; +*/ + export interface MsgForwardPrices { readonly kind: 'MsgForwardPrices'; readonly lump_price: number; @@ -1818,6 +2844,17 @@ export interface MsgForwardPrices { readonly next_frac: number; } +/* +catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; +*/ + +/* +catchain_config_new#c2 flags:(## 7) { flags = 0 } shuffle_mc_validators:Bool + mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 + shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; +*/ + export type CatchainConfig = CatchainConfig_catchain_config | CatchainConfig_catchain_config_new; export interface CatchainConfig_catchain_config { @@ -1828,15 +2865,48 @@ export interface CatchainConfig_catchain_config { readonly shard_validators_num: number; } -export interface CatchainConfig_catchain_config_new { - readonly kind: 'CatchainConfig_catchain_config_new'; - readonly flags: number; - readonly shuffle_mc_validators: boolean; - readonly mc_catchain_lifetime: number; - readonly shard_catchain_lifetime: number; - readonly shard_validators_lifetime: number; - readonly shard_validators_num: number; -} +export interface CatchainConfig_catchain_config_new { + readonly kind: 'CatchainConfig_catchain_config_new'; + readonly flags: number; + readonly shuffle_mc_validators: boolean; + readonly mc_catchain_lifetime: number; + readonly shard_catchain_lifetime: number; + readonly shard_validators_lifetime: number; + readonly shard_validators_num: number; +} + +/* +consensus_config#d6 round_candidates:# { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; +*/ + +/* +consensus_config_new#d7 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; +*/ + +/* +consensus_config_v3#d8 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 = ConsensusConfig; +*/ + +/* +consensus_config_v4#d9 flags:(## 7) { flags = 0 } new_catchain_ids:Bool + round_candidates:(## 8) { round_candidates >= 1 } + next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 + fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 + max_block_bytes:uint32 max_collated_bytes:uint32 + proto_version:uint16 catchain_max_blocks_coeff:uint32 = ConsensusConfig; +*/ export type ConsensusConfig = ConsensusConfig_consensus_config | ConsensusConfig_consensus_config_new | ConsensusConfig_consensus_config_v3 | ConsensusConfig_consensus_config_v4; @@ -1897,6 +2967,8 @@ export interface ConsensusConfig_consensus_config_v4 { readonly catchain_max_blocks_coeff: number; } +// validator_temp_key#3 adnl_addr:bits256 temp_public_key:SigPubKey seqno:# valid_until:uint32 = ValidatorTempKey; + export interface ValidatorTempKey { readonly kind: 'ValidatorTempKey'; readonly adnl_addr: BitString; @@ -1905,12 +2977,24 @@ export interface ValidatorTempKey { readonly valid_until: number; } +// signed_temp_key#4 key:^ValidatorTempKey signature:CryptoSignature = ValidatorSignedTempKey; + export interface ValidatorSignedTempKey { readonly kind: 'ValidatorSignedTempKey'; readonly key: ValidatorTempKey; readonly signature: CryptoSignature; } +/* +misbehaviour_punishment_config_v1#01 + default_flat_fine:Grams default_proportional_fine:uint32 + severity_flat_mult:uint16 severity_proportional_mult:uint16 + unpunishable_interval:uint16 + long_interval:uint16 long_flat_mult:uint16 long_proportional_mult:uint16 + medium_interval:uint16 medium_flat_mult:uint16 medium_proportional_mult:uint16 + = MisbehaviourPunishmentConfig; +*/ + export interface MisbehaviourPunishmentConfig { readonly kind: 'MisbehaviourPunishmentConfig'; readonly default_flat_fine: bigint; @@ -1926,6 +3010,17 @@ export interface MisbehaviourPunishmentConfig { readonly medium_proportional_mult: number; } +/* +size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig; +*/ + +/* +size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 + max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32 + max_acc_public_libraries:uint32 = SizeLimitsConfig; +*/ + export type SizeLimitsConfig = SizeLimitsConfig_size_limits_config | SizeLimitsConfig_size_limits_config_v2; export interface SizeLimitsConfig_size_limits_config { @@ -1951,12 +3046,16 @@ export interface SizeLimitsConfig_size_limits_config_v2 { readonly max_acc_public_libraries: number; } +// suspended_address_list#00 addresses:(HashmapE 288 Unit) suspended_until:uint32 = SuspendedAddressList; + export interface SuspendedAddressList { readonly kind: 'SuspendedAddressList'; readonly addresses: HashmapE; readonly suspended_until: number; } +// oracle_bridge_params#_ bridge_address:bits256 oracle_mutlisig_address:bits256 oracles:(HashmapE 256 uint256) external_chain_address:bits256 = OracleBridgeParams; + export interface OracleBridgeParams { readonly kind: 'OracleBridgeParams'; readonly bridge_address: BitString; @@ -1965,6 +3064,14 @@ export interface OracleBridgeParams { readonly external_chain_address: BitString; } +/* +jetton_bridge_prices#_ bridge_burn_fee:Coins bridge_mint_fee:Coins + wallet_min_tons_for_storage:Coins + wallet_gas_consumption:Coins + minter_min_tons_for_storage:Coins + discover_gas_consumption:Coins = JettonBridgePrices; +*/ + export interface JettonBridgePrices { readonly kind: 'JettonBridgePrices'; readonly bridge_burn_fee: Coins; @@ -1975,6 +3082,10 @@ export interface JettonBridgePrices { readonly discover_gas_consumption: Coins; } +// jetton_bridge_params_v0#00 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 burn_bridge_fee:Coins = JettonBridgeParams; + +// jetton_bridge_params_v1#01 bridge_address:bits256 oracles_address:bits256 oracles:(HashmapE 256 uint256) state_flags:uint8 prices:^JettonBridgePrices external_chain_address:bits256 = JettonBridgeParams; + export type JettonBridgeParams = JettonBridgeParams_jetton_bridge_params_v0 | JettonBridgeParams_jetton_bridge_params_v1; export interface JettonBridgeParams_jetton_bridge_params_v0 { @@ -1996,6 +3107,11 @@ export interface JettonBridgeParams_jetton_bridge_params_v1 { readonly external_chain_address: BitString; } +/* +block_signatures_pure#_ sig_count:uint32 sig_weight:uint64 + signatures:(HashmapE 16 CryptoSignaturePair) = BlockSignaturesPure; +*/ + export interface BlockSignaturesPure { readonly kind: 'BlockSignaturesPure'; readonly sig_count: number; @@ -2003,12 +3119,16 @@ export interface BlockSignaturesPure { readonly signatures: HashmapE; } +// block_signatures#11 validator_info:ValidatorBaseInfo pure_signatures:BlockSignaturesPure = BlockSignatures; + export interface BlockSignatures { readonly kind: 'BlockSignatures'; readonly validator_info: ValidatorBaseInfo; readonly pure_signatures: BlockSignaturesPure; } +// block_proof#c3 proof_for:BlockIdExt root:^Cell signatures:(Maybe ^BlockSignatures) = BlockProof; + export interface BlockProof { readonly kind: 'BlockProof'; readonly proof_for: BlockIdExt; @@ -2016,6 +3136,10 @@ export interface BlockProof { readonly signatures: Maybe; } +// chain_empty$_ = ProofChain 0; + +// chain_link$_ {n:#} root:^Cell prev:n?^(ProofChain n) = ProofChain (n + 1); + export type ProofChain = ProofChain_chain_empty | ProofChain_chain_link; export interface ProofChain_chain_empty { @@ -2029,6 +3153,11 @@ export interface ProofChain_chain_link { readonly prev: ProofChain | undefined; } +/* +top_block_descr#d5 proof_for:BlockIdExt signatures:(Maybe ^BlockSignatures) + len:(## 8) { len >= 1 } { len <= 8 } chain:(ProofChain len) = TopBlockDescr; +*/ + export interface TopBlockDescr { readonly kind: 'TopBlockDescr'; readonly proof_for: BlockIdExt; @@ -2037,11 +3166,18 @@ export interface TopBlockDescr { readonly chain: ProofChain; } +// top_block_descr_set#4ac789f3 collection:(HashmapE 96 ^TopBlockDescr) = TopBlockDescrSet; + export interface TopBlockDescrSet { readonly kind: 'TopBlockDescrSet'; readonly collection: HashmapE; } +/* +prod_info#34 utime:uint32 mc_blk_ref:ExtBlkRef state_proof:^(MERKLE_PROOF Block) + prod_proof:^(MERKLE_PROOF ShardState) = ProducerInfo; +*/ + export interface ProducerInfo { readonly kind: 'ProducerInfo'; readonly utime: number; @@ -2050,6 +3186,10 @@ export interface ProducerInfo { readonly prod_proof: MERKLE_PROOF; } +// no_blk_gen from_utime:uint32 prod_info:^ProducerInfo = ComplaintDescr; + +// no_blk_gen_diff prod_info_old:^ProducerInfo prod_info_new:^ProducerInfo = ComplaintDescr; + export type ComplaintDescr = ComplaintDescr_no_blk_gen | ComplaintDescr_no_blk_gen_diff; export interface ComplaintDescr_no_blk_gen { @@ -2064,6 +3204,8 @@ export interface ComplaintDescr_no_blk_gen_diff { readonly prod_info_new: ProducerInfo; } +// validator_complaint#bc validator_pubkey:bits256 description:^ComplaintDescr created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint; + export interface ValidatorComplaint { readonly kind: 'ValidatorComplaint'; readonly validator_pubkey: BitString; @@ -2076,6 +3218,8 @@ export interface ValidatorComplaint { readonly suggested_fine_part: number; } +// complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus; + export interface ValidatorComplaintStatus { readonly kind: 'ValidatorComplaintStatus'; readonly complaint: ValidatorComplaint; @@ -2084,6 +3228,24 @@ export interface ValidatorComplaintStatus { readonly weight_remaining: number; } +// vm_stk_null#00 = VmStackValue; + +// vm_stk_tinyint#01 value:int64 = VmStackValue; + +// vm_stk_int#0201_ value:int257 = VmStackValue; + +// vm_stk_nan#02ff = VmStackValue; + +// vm_stk_cell#03 cell:^Cell = VmStackValue; + +// vm_stk_slice#04 _:VmCellSlice = VmStackValue; + +// vm_stk_builder#05 cell:^Cell = VmStackValue; + +// vm_stk_cont#06 cont:VmCont = VmStackValue; + +// vm_stk_tuple#07 len:(## 16) data:(VmTuple len) = VmStackValue; + export type VmStackValue = VmStackValue_vm_stk_null | VmStackValue_vm_stk_tinyint | VmStackValue_vm_stk_int | VmStackValue_vm_stk_nan | VmStackValue_vm_stk_cell | VmStackValue_vm_stk_slice | VmStackValue_vm_stk_builder | VmStackValue_vm_stk_cont | VmStackValue_vm_stk_tuple; export interface VmStackValue_vm_stk_null { @@ -2130,6 +3292,11 @@ export interface VmStackValue_vm_stk_tuple { readonly data: VmTuple; } +/* +_ cell:^Cell st_bits:(## 10) end_bits:(## 10) { st_bits <= end_bits } + st_ref:(#<= 4) end_ref:(#<= 4) { st_ref <= end_ref } = VmCellSlice; +*/ + export interface VmCellSlice { readonly kind: 'VmCellSlice'; readonly _cell: Slice; @@ -2139,6 +3306,12 @@ export interface VmCellSlice { readonly end_ref: number; } +// vm_tupref_nil$_ = VmTupleRef 0; + +// vm_tupref_single$_ entry:^VmStackValue = VmTupleRef 1; + +// vm_tupref_any$_ {n:#} ref:^(VmTuple (n + 2)) = VmTupleRef (n + 2); + export type VmTupleRef = VmTupleRef_vm_tupref_nil | VmTupleRef_vm_tupref_single | VmTupleRef_vm_tupref_any; export interface VmTupleRef_vm_tupref_nil { @@ -2156,6 +3329,10 @@ export interface VmTupleRef_vm_tupref_any { readonly ref: VmTuple; } +// vm_tuple_nil$_ = VmTuple 0; + +// vm_tuple_tcons$_ {n:#} head:(VmTupleRef n) tail:^VmStackValue = VmTuple (n + 1); + export type VmTuple = VmTuple_vm_tuple_nil | VmTuple_vm_tuple_tcons; export interface VmTuple_vm_tuple_nil { @@ -2169,12 +3346,18 @@ export interface VmTuple_vm_tuple_tcons { readonly tail: VmStackValue; } +// vm_stack#_ depth:(## 24) stack:(VmStackList depth) = VmStack; + export interface VmStack { readonly kind: 'VmStack'; readonly depth: number; readonly stack: VmStackList; } +// vm_stk_nil#_ = VmStackList 0; + +// vm_stk_cons#_ {n:#} rest:^(VmStackList n) tos:VmStackValue = VmStackList (n + 1); + export type VmStackList = VmStackList_vm_stk_nil | VmStackList_vm_stk_cons; export interface VmStackList_vm_stk_nil { @@ -2188,11 +3371,18 @@ export interface VmStackList_vm_stk_cons { readonly tos: VmStackValue; } +// _ cregs:(HashmapE 4 VmStackValue) = VmSaveList; + export interface VmSaveList { readonly kind: 'VmSaveList'; readonly cregs: HashmapE; } +/* +gas_limits#_ remaining:int64 _:^[ max_limit:int64 cur_limit:int64 credit:int64 ] + = VmGasLimits; +*/ + export interface VmGasLimits { readonly kind: 'VmGasLimits'; readonly remaining: number; @@ -2201,11 +3391,18 @@ export interface VmGasLimits { readonly credit: number; } +// _ libraries:(HashmapE 256 ^Cell) = VmLibraries; + export interface VmLibraries { readonly kind: 'VmLibraries'; readonly libraries: HashmapE; } +/* +vm_ctl_data$_ nargs:(Maybe uint13) stack:(Maybe VmStack) save:VmSaveList +cp:(Maybe int16) = VmControlData; +*/ + export interface VmControlData { readonly kind: 'VmControlData'; readonly nargs: Maybe; @@ -2214,6 +3411,32 @@ export interface VmControlData { readonly cp: Maybe; } +// vmc_std$00 cdata:VmControlData code:VmCellSlice = VmCont; + +// vmc_envelope$01 cdata:VmControlData next:^VmCont = VmCont; + +// vmc_quit$1000 exit_code:int32 = VmCont; + +// vmc_quit_exc$1001 = VmCont; + +// vmc_repeat$10100 count:uint63 body:^VmCont after:^VmCont = VmCont; + +// vmc_until$110000 body:^VmCont after:^VmCont = VmCont; + +// vmc_again$110001 body:^VmCont = VmCont; + +/* +vmc_while_cond$110010 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +*/ + +/* +vmc_while_body$110011 cond:^VmCont body:^VmCont +after:^VmCont = VmCont; +*/ + +// vmc_pushint$1111 value:int32 next:^VmCont = VmCont; + export type VmCont = VmCont_vmc_std | VmCont_vmc_envelope | VmCont_vmc_quit | VmCont_vmc_quit_exc | VmCont_vmc_repeat | VmCont_vmc_until | VmCont_vmc_again | VmCont_vmc_while_cond | VmCont_vmc_while_body | VmCont_vmc_pushint; export interface VmCont_vmc_std { @@ -2275,11 +3498,17 @@ export interface VmCont_vmc_pushint { readonly next: VmCont; } +// _ (HashmapE 256 ^DNSRecord) = DNS_RecordSet; + export interface DNS_RecordSet { readonly kind: 'DNS_RecordSet'; readonly anon0: HashmapE; } +// chunk_ref_empty$_ = TextChunkRef 0; + +// chunk_ref$_ {n:#} ref:^(TextChunks (n + 1)) = TextChunkRef (n + 1); + export type TextChunkRef = TextChunkRef_chunk_ref_empty | TextChunkRef_chunk_ref; export interface TextChunkRef_chunk_ref_empty { @@ -2292,6 +3521,10 @@ export interface TextChunkRef_chunk_ref { readonly ref: TextChunks; } +// text_chunk_empty$_ = TextChunks 0; + +// text_chunk$_ {n:#} len:(## 8) data:(bits (len * 8)) next:(TextChunkRef n) = TextChunks (n + 1); + export type TextChunks = TextChunks_text_chunk_empty | TextChunks_text_chunk; export interface TextChunks_text_chunk_empty { @@ -2306,12 +3539,30 @@ export interface TextChunks_text_chunk { readonly next: TextChunkRef; } +// text$_ chunks:(## 8) rest:(TextChunks chunks) = Text; + export interface Text { readonly kind: 'Text'; readonly chunks: number; readonly rest: TextChunks; } +// dns_text#1eda _:Text = DNSRecord; + +// dns_next_resolver#ba93 resolver:MsgAddressInt = DNSRecord; + +/* +dns_adnl_address#ad01 adnl_addr:bits256 flags:(## 8) { flags <= 1 } + proto_list:flags . 0?ProtoList = DNSRecord; +*/ + +/* +dns_smc_address#9fd3 smc_addr:MsgAddressInt flags:(## 8) { flags <= 1 } + cap_list:flags . 0?SmcCapList = DNSRecord; +*/ + +// dns_storage_address#7473 bag_id:bits256 = DNSRecord; + export type DNSRecord = DNSRecord_dns_text | DNSRecord_dns_next_resolver | DNSRecord_dns_adnl_address | DNSRecord_dns_smc_address | DNSRecord_dns_storage_address; export interface DNSRecord_dns_text { @@ -2343,6 +3594,10 @@ export interface DNSRecord_dns_storage_address { readonly bag_id: BitString; } +// proto_list_nil$0 = ProtoList; + +// proto_list_next$1 head:Protocol tail:ProtoList = ProtoList; + export type ProtoList = ProtoList_proto_list_nil | ProtoList_proto_list_next; export interface ProtoList_proto_list_nil { @@ -2355,10 +3610,16 @@ export interface ProtoList_proto_list_next { readonly tail: ProtoList; } +// proto_http#4854 = Protocol; + export interface Protocol { readonly kind: 'Protocol'; } +// cap_list_nil$0 = SmcCapList; + +// cap_list_next$1 head:SmcCapability tail:SmcCapList = SmcCapList; + export type SmcCapList = SmcCapList_cap_list_nil | SmcCapList_cap_list_next; export interface SmcCapList_cap_list_nil { @@ -2371,6 +3632,14 @@ export interface SmcCapList_cap_list_next { readonly tail: SmcCapList; } +// cap_method_seqno#5371 = SmcCapability; + +// cap_method_pubkey#71f4 = SmcCapability; + +// cap_is_wallet#2177 = SmcCapability; + +// cap_name#ff name:Text = SmcCapability; + export type SmcCapability = SmcCapability_cap_method_seqno | SmcCapability_cap_method_pubkey | SmcCapability_cap_is_wallet | SmcCapability_cap_name; export interface SmcCapability_cap_method_seqno { @@ -2390,6 +3659,11 @@ export interface SmcCapability_cap_name { readonly name: Text; } +/* +chan_config$_ init_timeout:uint32 close_timeout:uint32 a_key:bits256 b_key:bits256 + a_addr:^MsgAddressInt b_addr:^MsgAddressInt channel_id:uint64 min_A_extra:Grams = ChanConfig; +*/ + export interface ChanConfig { readonly kind: 'ChanConfig'; readonly init_timeout: number; @@ -2402,6 +3676,12 @@ export interface ChanConfig { readonly min_A_extra: bigint; } +// chan_state_init$000 signed_A:Bool signed_B:Bool min_A:Grams min_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; + +// chan_state_close$001 signed_A:Bool signed_B:Bool promise_A:Grams promise_B:Grams expire_at:uint32 A:Grams B:Grams = ChanState; + +// chan_state_payout$010 A:Grams B:Grams = ChanState; + export type ChanState = ChanState_chan_state_init | ChanState_chan_state_close | ChanState_chan_state_payout; export interface ChanState_chan_state_init { @@ -2432,6 +3712,8 @@ export interface ChanState_chan_state_payout { readonly B: bigint; } +// chan_promise$_ channel_id:uint64 promise_A:Grams promise_B:Grams = ChanPromise; + export interface ChanPromise { readonly kind: 'ChanPromise'; readonly channel_id: number; @@ -2439,12 +3721,22 @@ export interface ChanPromise { readonly promise_B: bigint; } +// chan_signed_promise#_ sig:(Maybe ^bits512) promise:ChanPromise = ChanSignedPromise; + export interface ChanSignedPromise { readonly kind: 'ChanSignedPromise'; readonly sig: Maybe; readonly promise: ChanPromise; } +// chan_msg_init#27317822 inc_A:Grams inc_B:Grams min_A:Grams min_B:Grams channel_id:uint64 = ChanMsg; + +// chan_msg_close#f28ae183 extra_A:Grams extra_B:Grams promise:ChanSignedPromise = ChanMsg; + +// chan_msg_timeout#43278a28 = ChanMsg; + +// chan_msg_payout#37fe7810 = ChanMsg; + export type ChanMsg = ChanMsg_chan_msg_init | ChanMsg_chan_msg_close | ChanMsg_chan_msg_timeout | ChanMsg_chan_msg_payout; export interface ChanMsg_chan_msg_init { @@ -2471,6 +3763,8 @@ export interface ChanMsg_chan_msg_payout { readonly kind: 'ChanMsg_chan_msg_payout'; } +// chan_signed_msg$_ sig_A:(Maybe ^bits512) sig_B:(Maybe ^bits512) msg:ChanMsg = ChanSignedMsg; + export interface ChanSignedMsg { readonly kind: 'ChanSignedMsg'; readonly sig_A: Maybe; @@ -2478,11 +3772,15 @@ export interface ChanSignedMsg { readonly msg: ChanMsg; } +// chan_op_cmd#912838d1 msg:ChanSignedMsg = ChanOp; + export interface ChanOp { readonly kind: 'ChanOp'; readonly msg: ChanSignedMsg; } +// chan_data$_ config:^ChanConfig state:^ChanState = ChanData; + export interface ChanData { readonly kind: 'ChanData'; readonly config: ChanConfig; diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index fcfc73c..5818003 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -9,12 +9,18 @@ export function bitLen(n: number) { return n.toString(2).length;; } +// tmpa$_ a:# b:# = Simple; + export interface Simple { readonly kind: 'Simple'; readonly a: number; readonly b: number; } +// bool_false$0 a:# b:(## 7) c:# = TwoConstructors; + +// bool_true$1 b:# = TwoConstructors; + export type TwoConstructors = TwoConstructors_bool_false | TwoConstructors_bool_true; export interface TwoConstructors_bool_false { @@ -29,23 +35,33 @@ export interface TwoConstructors_bool_true { readonly b: number; } +// tmpb$_ y:(## 5) = FixedIntParam; + export interface FixedIntParam { readonly kind: 'FixedIntParam'; readonly y: number; } +// tmpc$_ y:FixedIntParam c:# = TypedField; + export interface TypedField { readonly kind: 'TypedField'; readonly y: FixedIntParam; readonly c: number; } +// tmpd#_ y:FixedIntParam c:# = SharpConstructor; + export interface SharpConstructor { readonly kind: 'SharpConstructor'; readonly y: FixedIntParam; readonly c: number; } +// nothing$0 {TheType:Type} = Maybe TheType; + +// just$1 {TheType:Type} value:TheType = Maybe TheType; + export type Maybe = Maybe_nothing | Maybe_just; export interface Maybe_nothing { @@ -57,11 +73,17 @@ export interface Maybe_just { readonly value: TheType; } +// thejust$_ x:(Maybe SharpConstructor) = TypedParam; + export interface TypedParam { readonly kind: 'TypedParam'; readonly x: Maybe; } +// left$0 {X:Type} {Y:Type} value:X = Either X Y; + +// right$1 {X:Type} {Y:Type} value:Y = Either X Y; + export type Either = Either_left | Either_right; export interface Either_left { @@ -74,38 +96,52 @@ export interface Either_right { readonly value: Y; } +// a$_ {x:#} value:(## x) = BitLenArg x; + export interface BitLenArg { readonly kind: 'BitLenArg'; readonly x: number; readonly value: bigint; } +// a$_ t:(BitLenArg 4) = BitLenArgUser; + export interface BitLenArgUser { readonly kind: 'BitLenArgUser'; readonly t: BitLenArg; } +// a$_ {x:#} value:(## x) = ExprArg (2 + x); + export interface ExprArg { readonly kind: 'ExprArg'; readonly x: number; readonly value: bigint; } +// a$_ t:(ExprArg 6) = ExprArgUser; + export interface ExprArgUser { readonly kind: 'ExprArgUser'; readonly t: ExprArg; } +// a$_ a:ExprArgUser = ComplexTypedField; + export interface ComplexTypedField { readonly kind: 'ComplexTypedField'; readonly a: ExprArgUser; } +// a$_ a:^ExprArgUser = CellTypedField; + export interface CellTypedField { readonly kind: 'CellTypedField'; readonly a: ExprArgUser; } +// a$_ t:# ^[ q:# ] ^[ a:(## 32) ^[ e:# ] ^[ b:(## 32) d:# ^[ c:(## 32) ] ] ] = CellsSimple; + export interface CellsSimple { readonly kind: 'CellsSimple'; readonly t: number; @@ -117,6 +153,8 @@ export interface CellsSimple { readonly c: number; } +// b$_ d:int11 g:bits2 {Arg:Type} arg:Arg x:Any = IntBits Arg; + export interface IntBits { readonly kind: 'IntBits'; readonly d: number; @@ -125,17 +163,23 @@ export interface IntBits { readonly x: Slice; } +// a$_ {x:#} a:(IntBits (int (1 + x))) = IntBitsInside (x * 2); + export interface IntBitsInside { readonly kind: 'IntBitsInside'; readonly x: number; readonly a: IntBits; } +// a$_ x:(IntBitsInside 6) = IntBitsOutside; + export interface IntBitsOutside { readonly kind: 'IntBitsOutside'; readonly x: IntBitsInside; } +// a$_ {e:#} h:(int (e * 8)) f:(uint (7 * e)) i:(bits (5 + e)) j:(int 5) k:(uint e) tc:Cell = IntBitsParametrized e; + export interface IntBitsParametrized { readonly kind: 'IntBitsParametrized'; readonly e: number; @@ -147,34 +191,48 @@ export interface IntBitsParametrized { readonly tc: Slice; } +// a$_ {x:#} a:(IntBitsParametrized x) = IntBitsParametrizedInside x; + export interface IntBitsParametrizedInside { readonly kind: 'IntBitsParametrizedInside'; readonly x: number; readonly a: IntBitsParametrized; } +// a$_ x:(IntBitsParametrizedInside 5) = IntBitsParametrizedOutside; + export interface IntBitsParametrizedOutside { readonly kind: 'IntBitsParametrizedOutside'; readonly x: IntBitsParametrizedInside; } +// a$_ x:(#< 4) y:(#<= 4) = LessThan; + export interface LessThan { readonly kind: 'LessThan'; readonly x: number; readonly y: number; } +// a$_ {A:Type} t:# x:A = OneComb A; + export interface OneComb { readonly kind: 'OneComb'; readonly t: number; readonly x: A; } +// a$_ y:(OneComb(OneComb(OneComb int3))) = ManyComb; + export interface ManyComb { readonly kind: 'ManyComb'; readonly y: OneComb>>; } +// unary_zero$0 = Unary ~0; + +// unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1); + export type Unary = Unary_unary_zero | Unary_unary_succ; export interface Unary_unary_zero { @@ -187,6 +245,14 @@ export interface Unary_unary_succ { readonly x: Unary; } +// b$01 m:# k:# = ParamConst 2 1; + +// c$01 n:# m:# k:# = ParamConst 3 3; + +// a$_ n:# = ParamConst 1 1; + +// d$_ n:# m:# k:# l:# = ParamConst 4 2; + export type ParamConst = ParamConst_b | ParamConst_c | ParamConst_a | ParamConst_d; export interface ParamConst_b { @@ -215,6 +281,14 @@ export interface ParamConst_d { readonly l: number; } +// a$0 = ParamDifNames 2 ~1; + +// b$1 = ParamDifNames 3 ~1; + +// c$1 {n:#} x:(ParamDifNames 2 ~n) = ParamDifNames 2 ~(n + 1); + +// d$0 {m:#} x:(ParamDifNames 3 ~m) = ParamDifNames 3 ~(m * 2); + export type ParamDifNames = ParamDifNames_a | ParamDifNames_b | ParamDifNames_c | ParamDifNames_d; export interface ParamDifNames_a { @@ -237,12 +311,16 @@ export interface ParamDifNames_d { readonly x: ParamDifNames; } +// e$0 {k:#} x:(ParamDifNames 2 ~k) = ParamDifNamesUser; + export interface ParamDifNamesUser { readonly kind: 'ParamDifNamesUser'; readonly k: number; readonly x: ParamDifNames; } +// b$1 {y:#} t:# z:# { t = (~y) * 2} = NegationFromImplicit ~(y + 1); + export interface NegationFromImplicit { readonly kind: 'NegationFromImplicit'; readonly y: number; @@ -250,6 +328,8 @@ export interface NegationFromImplicit { readonly z: number; } +// hm_edge#_ {l:#} {m:#} label:(Unary ~l) {7 = (~m) + l} = UnaryUserCheckOrder; + export interface UnaryUserCheckOrder { readonly kind: 'UnaryUserCheckOrder'; readonly l: number; @@ -257,6 +337,13 @@ export interface UnaryUserCheckOrder { readonly label: Unary; } +/* +a$_ {X:Type} info:int32 + init:(Maybe (Either X ^int22)) + other:(Either X ^(OneComb X)) + body:(Either X ^X) = CombArgCellRef X; +*/ + export interface CombArgCellRef { readonly kind: 'CombArgCellRef'; readonly info: number; @@ -265,37 +352,54 @@ export interface CombArgCellRef { readonly body: Either; } +// a$_ x:(CombArgCellRef int12) = CombArgCellRefUser; + export interface CombArgCellRefUser { readonly kind: 'CombArgCellRefUser'; readonly x: CombArgCellRef; } +// a$_ {n:#} ref:^(BitLenArg (n + 2)) = MathExprAsCombArg (n + 2); + export interface MathExprAsCombArg { readonly kind: 'MathExprAsCombArg'; readonly n: number; readonly ref: BitLenArg; } +// _ a:# = EmptyTag; + export interface EmptyTag { readonly kind: 'EmptyTag'; readonly a: number; } +// a#f4 x:# = SharpTag; + export interface SharpTag { readonly kind: 'SharpTag'; readonly x: number; } +// a$1011 x:# = DollarTag; + export interface DollarTag { readonly kind: 'DollarTag'; readonly x: number; } +// a$_ s:(3 * int5) = TupleCheck; + export interface TupleCheck { readonly kind: 'TupleCheck'; readonly s: Array; } +/* +hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) + {n = (~m) + l} node:(HashmapNode m X) = Hashmap n X; +*/ + export interface Hashmap { readonly kind: 'Hashmap'; readonly n: number; @@ -305,6 +409,13 @@ export interface Hashmap { readonly node: HashmapNode; } +// hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X; + +/* +hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X) + right:^(Hashmap n X) = HashmapNode (n + 1) X; +*/ + export type HashmapNode = HashmapNode_hmn_leaf | HashmapNode_hmn_fork; export interface HashmapNode_hmn_leaf { @@ -319,6 +430,12 @@ export interface HashmapNode_hmn_fork { readonly right: Hashmap; } +// hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + +// hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + +// hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + export type HmLabel = HmLabel_hml_short | HmLabel_hml_long | HmLabel_hml_same; export interface HmLabel_hml_short { @@ -343,6 +460,10 @@ export interface HmLabel_hml_same { readonly n: number; } +// hme_empty$0 {n:#} {X:Type} = HashmapE n X; + +// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; + export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; export interface HashmapE_hme_empty { @@ -356,28 +477,42 @@ export interface HashmapE_hme_root { readonly root: Hashmap; } +// a$_ x:(HashmapE 8 uint16) = HashmapEUser; + export interface HashmapEUser { readonly kind: 'HashmapEUser'; readonly x: HashmapE; } +// _ a:(## 1) b:a?(## 32) = ConditionalField; + export interface ConditionalField { readonly kind: 'ConditionalField'; readonly a: number; readonly b: number | undefined; } +// _ a:(## 6) b:(a . 2)?(## 32) = BitSelection; + export interface BitSelection { readonly kind: 'BitSelection'; readonly a: number; readonly b: number | undefined; } +// _ flags:(## 10) { flags <= 100 } = ImplicitCondition; + export interface ImplicitCondition { readonly kind: 'ImplicitCondition'; readonly flags: number; } +// _ a:# = MultipleEmptyConstructor 0; + +// _ b:(## 5) = MultipleEmptyConstructor 1; + +// a$_ x:(## 6) = MultipleEmptyConstructor 2; + export type MultipleEmptyConstructor = MultipleEmptyConstructor__ | MultipleEmptyConstructor__1 | MultipleEmptyConstructor_a; export interface MultipleEmptyConstructor__ { @@ -395,10 +530,16 @@ export interface MultipleEmptyConstructor_a { readonly x: number; } +// true$_ = True; + export interface True { readonly kind: 'True'; } +// a$0 {n:#} = ParamNamedArgInSecondConstr n; + +// b$1 {n:#} = ParamNamedArgInSecondConstr (n + 1); + export type ParamNamedArgInSecondConstr = ParamNamedArgInSecondConstr_a | ParamNamedArgInSecondConstr_b; export interface ParamNamedArgInSecondConstr_a { @@ -411,39 +552,55 @@ export interface ParamNamedArgInSecondConstr_b { readonly n: number; } +// a$_ msg:^(Maybe Any) = RefCombinatorAny; + export interface RefCombinatorAny { readonly kind: 'RefCombinatorAny'; readonly msg: Maybe; } +// a$_ n:# { 5 + n = 7 } = EqualityExpression; + export interface EqualityExpression { readonly kind: 'EqualityExpression'; readonly n: number; } +// a$_ x:(## 1) y:x?^Simple = ConditionalRef; + export interface ConditionalRef { readonly kind: 'ConditionalRef'; readonly x: number; readonly y: Simple | undefined; } +// block_info#9bc7a987 seq_no:# { prev_seq_no:# } { ~prev_seq_no + 1 = seq_no } = LoadFromNegationOutsideExpr; + export interface LoadFromNegationOutsideExpr { readonly kind: 'LoadFromNegationOutsideExpr'; readonly prev_seq_no: number; readonly seq_no: number; } +// bit$_ (## 1) anon0:# = AnonymousData; + export interface AnonymousData { readonly kind: 'AnonymousData'; readonly anon0: number; readonly anon0_0: number; } +// vm_stk_int#0201_ value:int257 = FalseAnonField; + export interface FalseAnonField { readonly kind: 'FalseAnonField'; readonly value: bigint; } +// b$1 Simple = ConstructorOrder; + +// a$0 a:Simple = ConstructorOrder; + export type ConstructorOrder = ConstructorOrder_b | ConstructorOrder_a; export interface ConstructorOrder_b { @@ -456,6 +613,10 @@ export interface ConstructorOrder_a { readonly a: Simple; } +// a a:# = CheckCrc32; + +// b b:# c:# = CheckCrc32; + export type CheckCrc32 = CheckCrc32_a | CheckCrc32_b; export interface CheckCrc32_a { @@ -469,63 +630,90 @@ export interface CheckCrc32_b { readonly c: number; } +// a$_ const:# = CheckKeyword; + export interface CheckKeyword { readonly kind: 'CheckKeyword'; readonly const0: number; } +// a$_ {X:Type} t:# y:(Maybe ^X) = RefCombinatorInRefHelper X; + export interface RefCombinatorInRefHelper { readonly kind: 'RefCombinatorInRefHelper'; readonly t: number; readonly y: Maybe; } +// a$_ msg:^(RefCombinatorInRefHelper Any) = RefCombinatorInRef; + export interface RefCombinatorInRef { readonly kind: 'RefCombinatorInRef'; readonly msg: RefCombinatorInRefHelper; } +// _ a:Bool = BoolUser; + export interface BoolUser { readonly kind: 'BoolUser'; readonly a: boolean; } +/* +anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; +*/ + export interface Anycast { readonly kind: 'Anycast'; readonly depth: number; readonly rewrite_pfx: BitString; } +// _ src:MsgAddressInt = AddressUser; + export interface AddressUser { readonly kind: 'AddressUser'; readonly src: Address; } +// _ src:MsgAddressExt = ExtAddressUser; + export interface ExtAddressUser { readonly kind: 'ExtAddressUser'; readonly src: ExternalAddress | null; } +// _ src:MsgAddress = AnyAddressUser; + export interface AnyAddressUser { readonly kind: 'AnyAddressUser'; readonly src: Address | ExternalAddress | null; } +// a$_ b:Bit = BitUser; + export interface BitUser { readonly kind: 'BitUser'; readonly b: boolean; } +// a$_ v:(VarUInteger 5) = VarUIntegerUser; + export interface VarUIntegerUser { readonly kind: 'VarUIntegerUser'; readonly v: bigint; } +// a$_ v:(VarInteger 5) = VarIntegerUser; + export interface VarIntegerUser { readonly kind: 'VarIntegerUser'; readonly v: bigint; } +// a$_ g:Grams = GramsUser; + export interface GramsUser { readonly kind: 'GramsUser'; readonly g: bigint; From 6169930eb7f5871fa665ca935da546b09f7a9c7d Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Fri, 12 Jan 2024 16:33:59 -0500 Subject: [PATCH 07/28] Handle HashmapE as Dictionary --- src/ast.ts | 7 + src/astbuilder/fill_constructors.ts | 1 + src/astbuilder/handle_type.ts | 10 + src/generators/typescript/complex_expr.ts | 44 +- src/generators/typescript/generator.ts | 26 +- src/generators/typescript/utils.ts | 8 + src/main.ts | 2 + test/generated_files/generated_block.ts | 519 ++++++++++++++-------- test/generated_files/generated_test.ts | 379 +++++++++++++--- test/tlb/test.tlb | 11 +- test/tlbgen.spec.ts | 162 +++---- 11 files changed, 801 insertions(+), 368 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index e8aae94..f5aece5 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -91,6 +91,12 @@ export type TLBVarIntegerType = { n: TLBMathExpr; } +export type TLBHashmapType = { + kind: "TLBHashmapType"; + key: TLBMathExprType, + value: TLBFieldType +} + export type TLBCellType = { kind: "TLBCellType"; }; @@ -136,6 +142,7 @@ export type TLBFieldType = | TLBBoolType | TLBCoinsType | TLBAddressType + | TLBHashmapType | TLBVarIntegerType | TLBCellType | TLBMathExprType diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index b20dc80..6c8559a 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -432,6 +432,7 @@ function checkAndRemovePrimitives( typesToDelete.set("MsgAddress", ["606aa05e", "21d0382b"]) typesToDelete.set("VarUInteger", ["11d56c2e"]) typesToDelete.set("VarInteger", ["d466ed5"]) + typesToDelete.set("HashmapE", ["32bae5cb", "28fa3979"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 5c4fdc3..ea9af99 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -161,6 +161,16 @@ export function getType( constructor ), }; + } else if (expr.name == "HashmapE") { + if (expr.args.length != 2) { + throw new Error('') + } + let key = getType(expr.args[0], constructor, fieldTypeName) + let value = getType(expr.args[1], constructor, fieldTypeName) + if (key.kind != 'TLBExprMathType') { + throw new Error('Hashmap key should be number') + } + return { kind: "TLBHashmapType", key: key, value: value }; } else if ( expr.name == "VarUInteger" && (expr.args[0] instanceof MathExpr || diff --git a/src/generators/typescript/complex_expr.ts b/src/generators/typescript/complex_expr.ts index 7d6a08f..c6d02e0 100644 --- a/src/generators/typescript/complex_expr.ts +++ b/src/generators/typescript/complex_expr.ts @@ -1,8 +1,8 @@ -import { TLBCode, TLBConstructorTag, TLBField } from "../../ast"; +import { TLBCode, TLBConstructorTag, TLBField, TLBHashmapType, TLBMathExprType } from "../../ast"; import { findNotReservedName, firstLower, getCurrentSlice } from "../../utils"; import { ConstructorContext } from "./generator"; -import { BinaryExpression, Expression, GenDeclaration, Identifier, Statement, TypeExpression, TypeParametersExpression, TypedIdentifier, id, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tDeclareVariable, tExpressionStatement, tForCycle, tFunctionCall, tFunctionDeclaration, tIfStatement, tMemberExpression, tMultiStatement, tNumericLiteral, tReturnStatement, tStringLiteral, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, toCode } from "./tsgen"; -import { ExprForParam, getNegationDerivationFunctionBody } from "./utils"; +import { BinaryExpression, Expression, GenDeclaration, Identifier, ObjectExpression, Statement, TypeExpression, TypeParametersExpression, TypedIdentifier, id, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tDeclareVariable, tExpressionStatement, tForCycle, tFunctionCall, tFunctionDeclaration, tIfStatement, tMemberExpression, tMultiStatement, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, toCode } from "./tsgen"; +import { ExprForParam, convertToAST, getNegationDerivationFunctionBody, isBigIntExpr } from "./utils"; export function tEqualExpression(left: Expression, right: Expression) { return tBinaryExpression(left, '==', right) @@ -330,3 +330,41 @@ export function negationDerivationFuncDecl( ) ); } +export function dictStoreStmt(currentCell: string, storeParametersInside: Expression[], keyForStore: Expression, valueStore: ObjectExpression): Statement | undefined { + return tExpressionStatement(tFunctionCall(tMemberExpression(id(currentCell), id('storeDict')), storeParametersInside.concat([keyForStore, valueStore]))); +} +export function dictTypeParamExpr(fieldType: TLBHashmapType, typeParamExpr: TypeExpression): TypeExpression | undefined { + return tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([(isBigIntExpr(fieldType.key) ? id('bigint') : id('number')), typeParamExpr])); +} +export function dictValueStore(typeParamExpr: TypeExpression, storeFunctionExpr: Expression) { + return tObjectExpression([ + tObjectProperty(id('serialize'), + tArrowFunctionExpression([tTypedIdentifier(id('arg'), typeParamExpr), tTypedIdentifier(id('builder'), id('Builder'))], [tExpressionStatement(tFunctionCall(tFunctionCall(storeFunctionExpr, [id('arg')]), [id('builder')]))]) + ), + tObjectProperty(id('parse'), + id("() => { throw new Error('Not implemented') }") + ) + ]); +} +export function dictLoadExpr(keyForLoad: Expression, loadFunctionExpr: Expression, currentSlice: string): Expression | undefined { + return tFunctionCall(tMemberExpression(id('Dictionary'), id('load')), [keyForLoad, dictValueLoad(loadFunctionExpr), id(currentSlice)]); +} +function dictValueLoad(loadFunctionExpr: Expression) { + return tObjectExpression([ + tObjectProperty(id('serialize'), + id("() => { throw new Error('Not implemented') }") + ), + tObjectProperty(id('parse'), + loadFunctionExpr + ) + ]); +} +export function dictKeyExpr(keyType: TLBMathExprType, ctx: ConstructorContext, objectId?: string): Expression { + let param: Expression; + if (objectId) { + param = convertToAST(keyType.expr, ctx.constructor, id(objectId)); + } else { + param = convertToAST(keyType.expr, ctx.constructor); + } + return tFunctionCall(tMemberExpression(id('Dictionary.Keys'), (isBigIntExpr(keyType) ? id('BigUint') : id('Uint'))), [param]); +} diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index d8c63ea..84f9c74 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -1,3 +1,4 @@ +import { Identifier } from "typescript"; import { TLBCode, TLBConstructor, @@ -62,7 +63,6 @@ import { TypeParametersExpression, TypedIdentifier, id, - tArrowFunctionExpression, tComment, tExpressionStatement, tFunctionCall, @@ -94,6 +94,7 @@ import { getTypeParametersExpression, isBigInt, } from "./utils"; +import { dictKeyExpr, dictLoadExpr, dictValueStore, dictTypeParamExpr, dictStoreStmt } from "./complex_expr"; /* @@ -589,9 +590,6 @@ export class TypescriptGenerator implements CodeGenerator { ); }); } else if (field.subFields.length == 0) { - if (field == undefined) { - throw new Error(""); - } let fieldInfo = this.handleType( field, field.fieldType, @@ -902,6 +900,25 @@ export class TypescriptGenerator implements CodeGenerator { if (subExprInfo.storeStmtInside) { result.storeStmtInside = storeInNewCell(currentCell, subExprInfo.storeStmtInside); } + } else if (fieldType.kind == "TLBHashmapType") { + let keyForLoad: Expression = dictKeyExpr(fieldType.key, ctx); + let keyForStore: Expression = dictKeyExpr(fieldType.key, ctx, ctx.typeName); + let subExprInfo = this.handleType( + field, + fieldType.value, + false, + ctx, + slicePrefix, + argIndex + ); + + if (subExprInfo.typeParamExpr && subExprInfo.loadFunctionExpr && subExprInfo.storeFunctionExpr) { + result.loadExpr = dictLoadExpr(keyForLoad, subExprInfo.loadFunctionExpr, currentSlice) + let valueStore = dictValueStore(subExprInfo.typeParamExpr, subExprInfo.storeFunctionExpr) + result.typeParamExpr = dictTypeParamExpr(fieldType, subExprInfo.typeParamExpr) + result.storeStmtInside = dictStoreStmt(currentCell, storeParametersInside, keyForStore, valueStore) + result.storeStmtOutside = dictStoreStmt(currentCell, storeParametersOutside, keyForStore, valueStore) + } } else if (fieldType.kind == "TLBNamedType" && fieldType.arguments.length) { let typeName = fieldType.name; @@ -1021,3 +1038,4 @@ export class TypescriptGenerator implements CodeGenerator { return result; } } + diff --git a/src/generators/typescript/utils.ts b/src/generators/typescript/utils.ts index 16dfda8..ab9ef17 100644 --- a/src/generators/typescript/utils.ts +++ b/src/generators/typescript/utils.ts @@ -3,6 +3,7 @@ import { TLBCode, TLBConstructor, TLBMathExpr, + TLBMathExprType, TLBNumberExpr, TLBNumberType, TLBParameter, @@ -215,6 +216,13 @@ export function getCondition(conditions: Array): Expression { } } +export function isBigIntExpr(fieldType: TLBMathExprType) { + if (fieldType.expr instanceof TLBNumberExpr && fieldType.expr.n <= 64) { + return false; + } + return true; +} + export function isBigInt(fieldType: TLBNumberType) { if (fieldType.bits instanceof TLBNumberExpr) { if (fieldType.bits.n <= 64) { diff --git a/src/main.ts b/src/main.ts index 86112f4..2db2d8e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,6 +27,8 @@ export function generate(tree: Program, input: string) { codeGenerator.addTonCoreClassUsage("Cell"); codeGenerator.addTonCoreClassUsage("Address"); codeGenerator.addTonCoreClassUsage("ExternalAddress"); + codeGenerator.addTonCoreClassUsage("Dictionary") + codeGenerator.addTonCoreClassUsage("DictionaryValue") codeGenerator.addBitLenFunction(); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 9d68097..6061141 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -5,6 +5,8 @@ import { BitString } from 'ton' import { Cell } from 'ton' import { Address } from 'ton' import { ExternalAddress } from 'ton' +import { Dictionary } from 'ton' +import { DictionaryValue } from 'ton' export function bitLen(n: number) { return n.toString(2).length;; } @@ -153,23 +155,6 @@ export interface Unary_unary_succ { readonly x: Unary; } -// hme_empty$0 {n:#} {X:Type} = HashmapE n X; - -// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; - -export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; - -export interface HashmapE_hme_empty { - readonly kind: 'HashmapE_hme_empty'; - readonly n: number; -} - -export interface HashmapE_hme_root { - readonly kind: 'HashmapE_hme_root'; - readonly n: number; - readonly root: Hashmap; -} - // _ {n:#} _:(Hashmap n True) = BitstringSet n; export interface BitstringSet { @@ -395,7 +380,7 @@ extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) export interface ExtraCurrencyCollection { readonly kind: 'ExtraCurrencyCollection'; - readonly dict: HashmapE; + readonly dict: Dictionary; } /* @@ -528,7 +513,7 @@ export interface StateInitWithLibs { readonly special: Maybe; readonly code: Maybe; readonly data: Maybe; - readonly library: HashmapE; + readonly library: Dictionary; } // simple_lib$_ public:Bool root:^Cell = SimpleLib; @@ -853,7 +838,7 @@ export interface ProcessedUpto { export interface ProcessedInfo { readonly kind: 'ProcessedInfo'; - readonly anon0: HashmapE; + readonly anon0: Dictionary; } // ihr_pending$_ import_lt:uint64 = IhrPendingSince; @@ -867,7 +852,7 @@ export interface IhrPendingSince { export interface IhrPendingInfo { readonly kind: 'IhrPendingInfo'; - readonly anon0: HashmapE; + readonly anon0: Dictionary; } /* @@ -1046,7 +1031,7 @@ export interface Transaction { readonly orig_status: AccountStatus; readonly end_status: AccountStatus; readonly in_msg: Maybe>; - readonly out_msgs: HashmapE>; + readonly out_msgs: Dictionary>; readonly total_fees: CurrencyCollection; readonly state_update: HASH_UPDATE; readonly description: TransactionDescr; @@ -1592,7 +1577,7 @@ export interface ShardStateUnsplit { readonly underload_history: number; readonly total_balance: CurrencyCollection; readonly total_validator_fees: CurrencyCollection; - readonly libraries: HashmapE; + readonly libraries: Dictionary; readonly master_ref: Maybe; readonly custom: Maybe; } @@ -1911,7 +1896,7 @@ export interface ShardDescr_shard_descr_new { export interface ShardHashes { readonly kind: 'ShardHashes'; - readonly anon0: HashmapE>; + readonly anon0: Dictionary>; } // bta_leaf$0 {X:Type} {Y:Type} extra:Y leaf:X = BinTreeAug X Y; @@ -2039,7 +2024,7 @@ export type BlockCreateStats = BlockCreateStats_block_create_stats | BlockCreate export interface BlockCreateStats_block_create_stats { readonly kind: 'BlockCreateStats_block_create_stats'; - readonly counters: HashmapE; + readonly counters: Dictionary; } export interface BlockCreateStats_block_create_stats_ext { @@ -2161,7 +2146,7 @@ export interface McBlockExtra { readonly key_block: number; readonly shard_hashes: ShardHashes; readonly shard_fees: ShardFees; - readonly prev_blk_signatures: HashmapE; + readonly prev_blk_signatures: Dictionary; readonly recover_create_msg: Maybe; readonly mint_msg: Maybe; readonly config: ConfigParams | undefined; @@ -2216,7 +2201,7 @@ export interface ValidatorSet_validators_ext { readonly total: number; readonly main: number; readonly total_weight: number; - readonly list: HashmapE; + readonly list: Dictionary; } // _ config_addr:bits256 = ConfigParam 0; @@ -2384,7 +2369,7 @@ export interface ConfigParam__11 { export interface ConfigParam__12 { readonly kind: 'ConfigParam__12'; - readonly workchains: HashmapE; + readonly workchains: Dictionary; } export interface ConfigParam__13 { @@ -2472,7 +2457,7 @@ export interface ConfigParam__27 { export interface ConfigParam__28 { readonly kind: 'ConfigParam__28'; - readonly fundamental_smc_addr: HashmapE; + readonly fundamental_smc_addr: Dictionary; } export interface ConfigParam__29 { @@ -2507,7 +2492,7 @@ export interface ConfigParam__34 { export interface ConfigParam__35 { readonly kind: 'ConfigParam__35'; - readonly anon0: HashmapE; + readonly anon0: Dictionary; } export interface ConfigParam__36 { @@ -2621,7 +2606,7 @@ export interface ConfigProposalStatus { readonly expires: number; readonly proposal: ConfigProposal; readonly is_critical: boolean; - readonly voters: HashmapE; + readonly voters: Dictionary; readonly remaining_weight: number; readonly validator_set_id: bigint; readonly rounds_remaining: number; @@ -3050,7 +3035,7 @@ export interface SizeLimitsConfig_size_limits_config_v2 { export interface SuspendedAddressList { readonly kind: 'SuspendedAddressList'; - readonly addresses: HashmapE; + readonly addresses: Dictionary; readonly suspended_until: number; } @@ -3060,7 +3045,7 @@ export interface OracleBridgeParams { readonly kind: 'OracleBridgeParams'; readonly bridge_address: BitString; readonly oracle_mutlisig_address: BitString; - readonly oracles: HashmapE; + readonly oracles: Dictionary; readonly external_chain_address: BitString; } @@ -3092,7 +3077,7 @@ export interface JettonBridgeParams_jetton_bridge_params_v0 { readonly kind: 'JettonBridgeParams_jetton_bridge_params_v0'; readonly bridge_address: BitString; readonly oracles_address: BitString; - readonly oracles: HashmapE; + readonly oracles: Dictionary; readonly state_flags: number; readonly burn_bridge_fee: Coins; } @@ -3101,7 +3086,7 @@ export interface JettonBridgeParams_jetton_bridge_params_v1 { readonly kind: 'JettonBridgeParams_jetton_bridge_params_v1'; readonly bridge_address: BitString; readonly oracles_address: BitString; - readonly oracles: HashmapE; + readonly oracles: Dictionary; readonly state_flags: number; readonly prices: JettonBridgePrices; readonly external_chain_address: BitString; @@ -3116,7 +3101,7 @@ export interface BlockSignaturesPure { readonly kind: 'BlockSignaturesPure'; readonly sig_count: number; readonly sig_weight: number; - readonly signatures: HashmapE; + readonly signatures: Dictionary; } // block_signatures#11 validator_info:ValidatorBaseInfo pure_signatures:BlockSignaturesPure = BlockSignatures; @@ -3170,7 +3155,7 @@ export interface TopBlockDescr { export interface TopBlockDescrSet { readonly kind: 'TopBlockDescrSet'; - readonly collection: HashmapE; + readonly collection: Dictionary; } /* @@ -3223,7 +3208,7 @@ export interface ValidatorComplaint { export interface ValidatorComplaintStatus { readonly kind: 'ValidatorComplaintStatus'; readonly complaint: ValidatorComplaint; - readonly voters: HashmapE; + readonly voters: Dictionary; readonly vset_id: bigint; readonly weight_remaining: number; } @@ -3375,7 +3360,7 @@ export interface VmStackList_vm_stk_cons { export interface VmSaveList { readonly kind: 'VmSaveList'; - readonly cregs: HashmapE; + readonly cregs: Dictionary; } /* @@ -3395,7 +3380,7 @@ export interface VmGasLimits { export interface VmLibraries { readonly kind: 'VmLibraries'; - readonly libraries: HashmapE; + readonly libraries: Dictionary; } /* @@ -3502,7 +3487,7 @@ export interface VmCont_vmc_pushint { export interface DNS_RecordSet { readonly kind: 'DNS_RecordSet'; - readonly anon0: HashmapE; + readonly anon0: Dictionary; } // chunk_ref_empty$_ = TextChunkRef 0; @@ -4224,52 +4209,6 @@ export function storeUnary(unary: Unary): (builder: Builder) => void { throw new Error('Expected one of "Unary_unary_zero", "Unary_unary_succ" in loading "Unary", but data does not satisfy any constructor'); } -// hme_empty$0 {n:#} {X:Type} = HashmapE n X; - -// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; - -export function loadHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): HashmapE { - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { - slice.loadUint(1); - return { - kind: 'HashmapE_hme_empty', - n: n, - } - - } - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { - slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); - let root: Hashmap = loadHashmap(slice1, n, loadX); - return { - kind: 'HashmapE_hme_root', - n: n, - root: root, - } - - } - throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); -} - -export function storeHashmapE(hashmapE: HashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { - if ((hashmapE.kind == 'HashmapE_hme_empty')) { - return ((builder: Builder) => { - builder.storeUint(0b0, 1); - }) - - } - if ((hashmapE.kind == 'HashmapE_hme_root')) { - return ((builder: Builder) => { - builder.storeUint(0b1, 1); - let cell1 = beginCell(); - storeHashmap(hashmapE.root, storeX)(cell1); - builder.storeRef(cell1); - }) - - } - throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); -} - // _ {n:#} _:(Hashmap n True) = BitstringSet n; export function loadBitstringSet(slice: Slice, n: number): BitstringSet { @@ -4853,10 +4792,13 @@ extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) */ export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollection { - let dict: HashmapE = loadHashmapE(slice, 32, ((slice: Slice) => { + let dict: Dictionary = Dictionary.load(Dictionary.Keys.Uint(32), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { return slice.loadVarUintBig(bitLen((32 - 1))) - })); + }), + }, slice); return { kind: 'ExtraCurrencyCollection', dict: dict, @@ -4866,12 +4808,17 @@ export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollecti export function storeExtraCurrencyCollection(extraCurrencyCollection: ExtraCurrencyCollection): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(extraCurrencyCollection.dict, ((arg: bigint) => { - return ((builder: Builder) => { - builder.storeVarUint(arg, bitLen((32 - 1))); - }) + builder.storeDict(extraCurrencyCollection.dict, Dictionary.Keys.Uint(32), { + serialize: ((arg: bigint, builder: Builder) => { + ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeVarUint(arg, bitLen((32 - 1))); + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -5224,7 +5171,10 @@ export function loadStateInitWithLibs(slice: Slice): StateInitWithLibs { return slice1 })); - let library: HashmapE = loadHashmapE(slice, 256, loadSimpleLib); + let library: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadSimpleLib, + }, slice); return { kind: 'StateInitWithLibs', split_depth: split_depth, @@ -5263,7 +5213,12 @@ export function storeStateInitWithLibs(stateInitWithLibs: StateInitWithLibs): (b }) }))(builder); - storeHashmapE(stateInitWithLibs.library, storeSimpleLib)(builder); + builder.storeDict(stateInitWithLibs.library, Dictionary.Keys.BigUint(256), { + serialize: ((arg: SimpleLib, builder: Builder) => { + storeSimpleLib(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6214,7 +6169,10 @@ export function storeProcessedUpto(processedUpto: ProcessedUpto): (builder: Buil // _ (HashmapE 96 ProcessedUpto) = ProcessedInfo; export function loadProcessedInfo(slice: Slice): ProcessedInfo { - let anon0: HashmapE = loadHashmapE(slice, 96, loadProcessedUpto); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(96), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadProcessedUpto, + }, slice); return { kind: 'ProcessedInfo', anon0: anon0, @@ -6224,7 +6182,12 @@ export function loadProcessedInfo(slice: Slice): ProcessedInfo { export function storeProcessedInfo(processedInfo: ProcessedInfo): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(processedInfo.anon0, storeProcessedUpto)(builder); + builder.storeDict(processedInfo.anon0, Dictionary.Keys.BigUint(96), { + serialize: ((arg: ProcessedUpto, builder: Builder) => { + storeProcessedUpto(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6250,7 +6213,10 @@ export function storeIhrPendingSince(ihrPendingSince: IhrPendingSince): (builder // _ (HashmapE 320 IhrPendingSince) = IhrPendingInfo; export function loadIhrPendingInfo(slice: Slice): IhrPendingInfo { - let anon0: HashmapE = loadHashmapE(slice, 320, loadIhrPendingSince); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(320), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadIhrPendingSince, + }, slice); return { kind: 'IhrPendingInfo', anon0: anon0, @@ -6260,7 +6226,12 @@ export function loadIhrPendingInfo(slice: Slice): IhrPendingInfo { export function storeIhrPendingInfo(ihrPendingInfo: IhrPendingInfo): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(ihrPendingInfo.anon0, storeIhrPendingSince)(builder); + builder.storeDict(ihrPendingInfo.anon0, Dictionary.Keys.BigUint(320), { + serialize: ((arg: IhrPendingSince, builder: Builder) => { + storeIhrPendingSince(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6682,14 +6653,17 @@ export function loadTransaction(slice: Slice): Transaction { })) })); - let out_msgs: HashmapE> = loadHashmapE>(slice1, 15, ((slice: Slice) => { + let out_msgs: Dictionary> = Dictionary.load(Dictionary.Keys.Uint(15), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadMessage(slice1, ((slice: Slice) => { return slice })) - })); + }), + }, slice1); let total_fees: CurrencyCollection = loadCurrencyCollection(slice); let slice2 = slice.loadRef().beginParse(); let state_update: HASH_UPDATE = loadHASH_UPDATE(slice2, loadAccount); @@ -6742,20 +6716,25 @@ export function storeTransaction(transaction: Transaction): (builder: Builder) = }) }))(cell1); - storeHashmapE>(transaction.out_msgs, ((arg: Message) => { - return ((builder: Builder) => { - let cell1 = beginCell(); - storeMessage(arg, ((arg: Slice) => { - return ((builder: Builder) => { - builder.storeSlice(arg); - }) + cell1.storeDict(transaction.out_msgs, Dictionary.Keys.Uint(15), { + serialize: ((arg: Message, builder: Builder) => { + ((arg: Message) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeMessage(arg, ((arg: Slice) => { + return ((builder: Builder) => { + builder.storeSlice(arg); + }) - }))(cell1); - builder.storeRef(cell1); + }))(cell1); + builder.storeRef(cell1); - }) + }) - }))(cell1); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeRef(cell1); storeCurrencyCollection(transaction.total_fees)(builder); let cell2 = beginCell(); @@ -8180,7 +8159,10 @@ export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { let underload_history: number = slice3.loadUint(64); let total_balance: CurrencyCollection = loadCurrencyCollection(slice3); let total_validator_fees: CurrencyCollection = loadCurrencyCollection(slice3); - let libraries: HashmapE = loadHashmapE(slice3, 256, loadLibDescr); + let libraries: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadLibDescr, + }, slice3); let master_ref: Maybe = loadMaybe(slice3, loadBlkMasterInfo); let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); @@ -8234,7 +8216,12 @@ export function storeShardStateUnsplit(shardStateUnsplit: ShardStateUnsplit): (b cell3.storeUint(shardStateUnsplit.underload_history, 64); storeCurrencyCollection(shardStateUnsplit.total_balance)(cell3); storeCurrencyCollection(shardStateUnsplit.total_validator_fees)(cell3); - storeHashmapE(shardStateUnsplit.libraries, storeLibDescr)(cell3); + cell3.storeDict(shardStateUnsplit.libraries, Dictionary.Keys.BigUint(256), { + serialize: ((arg: LibDescr, builder: Builder) => { + storeLibDescr(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); storeMaybe(shardStateUnsplit.master_ref, storeBlkMasterInfo)(cell3); builder.storeRef(cell3); storeMaybe(shardStateUnsplit.custom, ((arg: McStateExtra) => { @@ -9094,11 +9081,14 @@ export function storeShardDescr(shardDescr: ShardDescr): (builder: Builder) => v // _ (HashmapE 32 ^(BinTree ShardDescr)) = ShardHashes; export function loadShardHashes(slice: Slice): ShardHashes { - let anon0: HashmapE> = loadHashmapE>(slice, 32, ((slice: Slice) => { + let anon0: Dictionary> = Dictionary.load(Dictionary.Keys.Uint(32), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadBinTree(slice1, loadShardDescr) - })); + }), + }, slice); return { kind: 'ShardHashes', anon0: anon0, @@ -9108,15 +9098,20 @@ export function loadShardHashes(slice: Slice): ShardHashes { export function storeShardHashes(shardHashes: ShardHashes): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE>(shardHashes.anon0, ((arg: BinTree) => { - return ((builder: Builder) => { - let cell1 = beginCell(); - storeBinTree(arg, storeShardDescr)(cell1); - builder.storeRef(cell1); + builder.storeDict(shardHashes.anon0, Dictionary.Keys.Uint(32), { + serialize: ((arg: BinTree, builder: Builder) => { + ((arg: BinTree) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeBinTree(arg, storeShardDescr)(cell1); + builder.storeRef(cell1); - }) + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -9437,7 +9432,10 @@ export function storeCreatorStats(creatorStats: CreatorStats): (builder: Builder export function loadBlockCreateStats(slice: Slice): BlockCreateStats { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x17))) { slice.loadUint(8); - let counters: HashmapE = loadHashmapE(slice, 256, loadCreatorStats); + let counters: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadCreatorStats, + }, slice); return { kind: 'BlockCreateStats_block_create_stats', counters: counters, @@ -9463,7 +9461,12 @@ export function storeBlockCreateStats(blockCreateStats: BlockCreateStats): (buil if ((blockCreateStats.kind == 'BlockCreateStats_block_create_stats')) { return ((builder: Builder) => { builder.storeUint(0x17, 8); - storeHashmapE(blockCreateStats.counters, storeCreatorStats)(builder); + builder.storeDict(blockCreateStats.counters, Dictionary.Keys.BigUint(256), { + serialize: ((arg: CreatorStats, builder: Builder) => { + storeCreatorStats(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -9762,7 +9765,10 @@ export function loadMcBlockExtra(slice: Slice): McBlockExtra { let shard_hashes: ShardHashes = loadShardHashes(slice); let shard_fees: ShardFees = loadShardFees(slice); let slice1 = slice.loadRef().beginParse(); - let prev_blk_signatures: HashmapE = loadHashmapE(slice1, 16, loadCryptoSignaturePair); + let prev_blk_signatures: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadCryptoSignaturePair, + }, slice1); let recover_create_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadInMsg(slice1) @@ -9796,7 +9802,12 @@ export function storeMcBlockExtra(mcBlockExtra: McBlockExtra): (builder: Builder storeShardHashes(mcBlockExtra.shard_hashes)(builder); storeShardFees(mcBlockExtra.shard_fees)(builder); let cell1 = beginCell(); - storeHashmapE(mcBlockExtra.prev_blk_signatures, storeCryptoSignaturePair)(cell1); + cell1.storeDict(mcBlockExtra.prev_blk_signatures, Dictionary.Keys.Uint(16), { + serialize: ((arg: CryptoSignaturePair, builder: Builder) => { + storeCryptoSignaturePair(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); storeMaybe(mcBlockExtra.recover_create_msg, ((arg: InMsg) => { return ((builder: Builder) => { let cell1 = beginCell(); @@ -9919,7 +9930,10 @@ export function loadValidatorSet(slice: Slice): ValidatorSet { let total: number = slice.loadUint(16); let main: number = slice.loadUint(16); let total_weight: number = slice.loadUint(64); - let list: HashmapE = loadHashmapE(slice, 16, loadValidatorDescr); + let list: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadValidatorDescr, + }, slice); if ((!(main <= total))) { throw new Error('Condition (main <= total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); } @@ -9966,7 +9980,12 @@ export function storeValidatorSet(validatorSet: ValidatorSet): (builder: Builder builder.storeUint(validatorSet.total, 16); builder.storeUint(validatorSet.main, 16); builder.storeUint(validatorSet.total_weight, 64); - storeHashmapE(validatorSet.list, storeValidatorDescr)(builder); + builder.storeDict(validatorSet.list, Dictionary.Keys.Uint(16), { + serialize: ((arg: ValidatorDescr, builder: Builder) => { + storeValidatorDescr(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); if ((!(validatorSet.main <= validatorSet.total))) { throw new Error('Condition (validatorSet.main <= validatorSet.total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); } @@ -10179,7 +10198,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 12)) { - let workchains: HashmapE = loadHashmapE(slice, 32, loadWorkchainDescr); + let workchains: Dictionary = Dictionary.load(Dictionary.Keys.Uint(32), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadWorkchainDescr, + }, slice); return { kind: 'ConfigParam__12', workchains: workchains, @@ -10332,7 +10354,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 31)) { - let fundamental_smc_addr: HashmapE = loadHashmapE(slice, 256, loadTrue); + let fundamental_smc_addr: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadTrue, + }, slice); return { kind: 'ConfigParam__28', fundamental_smc_addr: fundamental_smc_addr, @@ -10388,7 +10413,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 39)) { - let anon0: HashmapE = loadHashmapE(slice, 256, loadValidatorSignedTempKey); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadValidatorSignedTempKey, + }, slice); return { kind: 'ConfigParam__35', anon0: anon0, @@ -10546,7 +10574,12 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__12')) { return ((builder: Builder) => { - storeHashmapE(configParam.workchains, storeWorkchainDescr)(builder); + builder.storeDict(configParam.workchains, Dictionary.Keys.Uint(32), { + serialize: ((arg: WorkchainDescr, builder: Builder) => { + storeWorkchainDescr(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -10659,7 +10692,12 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__28')) { return ((builder: Builder) => { - storeHashmapE(configParam.fundamental_smc_addr, storeTrue)(builder); + builder.storeDict(configParam.fundamental_smc_addr, Dictionary.Keys.BigUint(256), { + serialize: ((arg: True, builder: Builder) => { + storeTrue(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -10701,7 +10739,12 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__35')) { return ((builder: Builder) => { - storeHashmapE(configParam.anon0, storeValidatorSignedTempKey)(builder); + builder.storeDict(configParam.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: ValidatorSignedTempKey, builder: Builder) => { + storeValidatorSignedTempKey(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -10982,7 +11025,10 @@ export function loadConfigProposalStatus(slice: Slice): ConfigProposalStatus { let slice1 = slice.loadRef().beginParse(); let proposal: ConfigProposal = loadConfigProposal(slice1); let is_critical: boolean = slice.loadBoolean(); - let voters: HashmapE = loadHashmapE(slice, 16, loadTrue); + let voters: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadTrue, + }, slice); let remaining_weight: number = slice.loadInt(64); let validator_set_id: bigint = slice.loadUintBig(256); let rounds_remaining: number = slice.loadUint(8); @@ -11013,7 +11059,12 @@ export function storeConfigProposalStatus(configProposalStatus: ConfigProposalSt storeConfigProposal(configProposalStatus.proposal)(cell1); builder.storeRef(cell1); builder.storeBit(configProposalStatus.is_critical); - storeHashmapE(configProposalStatus.voters, storeTrue)(builder); + builder.storeDict(configProposalStatus.voters, Dictionary.Keys.Uint(16), { + serialize: ((arg: True, builder: Builder) => { + storeTrue(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeInt(configProposalStatus.remaining_weight, 64); builder.storeUint(configProposalStatus.validator_set_id, 256); builder.storeUint(configProposalStatus.rounds_remaining, 8); @@ -12185,7 +12236,10 @@ export function storeSizeLimitsConfig(sizeLimitsConfig: SizeLimitsConfig): (buil export function loadSuspendedAddressList(slice: Slice): SuspendedAddressList { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x00))) { slice.loadUint(8); - let addresses: HashmapE = loadHashmapE(slice, 288, loadUnit); + let addresses: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(288), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadUnit, + }, slice); let suspended_until: number = slice.loadUint(32); return { kind: 'SuspendedAddressList', @@ -12200,7 +12254,12 @@ export function loadSuspendedAddressList(slice: Slice): SuspendedAddressList { export function storeSuspendedAddressList(suspendedAddressList: SuspendedAddressList): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x00, 8); - storeHashmapE(suspendedAddressList.addresses, storeUnit)(builder); + builder.storeDict(suspendedAddressList.addresses, Dictionary.Keys.BigUint(288), { + serialize: ((arg: Unit, builder: Builder) => { + storeUnit(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeUint(suspendedAddressList.suspended_until, 32); }) @@ -12211,10 +12270,13 @@ export function storeSuspendedAddressList(suspendedAddressList: SuspendedAddress export function loadOracleBridgeParams(slice: Slice): OracleBridgeParams { let bridge_address: BitString = slice.loadBits(256); let oracle_mutlisig_address: BitString = slice.loadBits(256); - let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let oracles: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { return slice.loadUintBig(256) - })); + }), + }, slice); let external_chain_address: BitString = slice.loadBits(256); return { kind: 'OracleBridgeParams', @@ -12230,12 +12292,17 @@ export function storeOracleBridgeParams(oracleBridgeParams: OracleBridgeParams): return ((builder: Builder) => { builder.storeBits(oracleBridgeParams.bridge_address); builder.storeBits(oracleBridgeParams.oracle_mutlisig_address); - storeHashmapE(oracleBridgeParams.oracles, ((arg: bigint) => { - return ((builder: Builder) => { - builder.storeUint(arg, 256); - }) + builder.storeDict(oracleBridgeParams.oracles, Dictionary.Keys.BigUint(256), { + serialize: ((arg: bigint, builder: Builder) => { + ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeBits(oracleBridgeParams.external_chain_address); }) @@ -12289,10 +12356,13 @@ export function loadJettonBridgeParams(slice: Slice): JettonBridgeParams { slice.loadUint(8); let bridge_address: BitString = slice.loadBits(256); let oracles_address: BitString = slice.loadBits(256); - let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let oracles: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { return slice.loadUintBig(256) - })); + }), + }, slice); let state_flags: number = slice.loadUint(8); let burn_bridge_fee: Coins = loadCoins(slice); return { @@ -12309,10 +12379,13 @@ export function loadJettonBridgeParams(slice: Slice): JettonBridgeParams { slice.loadUint(8); let bridge_address: BitString = slice.loadBits(256); let oracles_address: BitString = slice.loadBits(256); - let oracles: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let oracles: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { return slice.loadUintBig(256) - })); + }), + }, slice); let state_flags: number = slice.loadUint(8); let slice1 = slice.loadRef().beginParse(); let prices: JettonBridgePrices = loadJettonBridgePrices(slice1); @@ -12337,12 +12410,17 @@ export function storeJettonBridgeParams(jettonBridgeParams: JettonBridgeParams): builder.storeUint(0x00, 8); builder.storeBits(jettonBridgeParams.bridge_address); builder.storeBits(jettonBridgeParams.oracles_address); - storeHashmapE(jettonBridgeParams.oracles, ((arg: bigint) => { - return ((builder: Builder) => { - builder.storeUint(arg, 256); - }) + builder.storeDict(jettonBridgeParams.oracles, Dictionary.Keys.BigUint(256), { + serialize: ((arg: bigint, builder: Builder) => { + ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeUint(jettonBridgeParams.state_flags, 8); storeCoins(jettonBridgeParams.burn_bridge_fee)(builder); }) @@ -12353,12 +12431,17 @@ export function storeJettonBridgeParams(jettonBridgeParams: JettonBridgeParams): builder.storeUint(0x01, 8); builder.storeBits(jettonBridgeParams.bridge_address); builder.storeBits(jettonBridgeParams.oracles_address); - storeHashmapE(jettonBridgeParams.oracles, ((arg: bigint) => { - return ((builder: Builder) => { - builder.storeUint(arg, 256); - }) + builder.storeDict(jettonBridgeParams.oracles, Dictionary.Keys.BigUint(256), { + serialize: ((arg: bigint, builder: Builder) => { + ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeUint(arg, 256); + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeUint(jettonBridgeParams.state_flags, 8); let cell1 = beginCell(); storeJettonBridgePrices(jettonBridgeParams.prices)(cell1); @@ -12378,7 +12461,10 @@ block_signatures_pure#_ sig_count:uint32 sig_weight:uint64 export function loadBlockSignaturesPure(slice: Slice): BlockSignaturesPure { let sig_count: number = slice.loadUint(32); let sig_weight: number = slice.loadUint(64); - let signatures: HashmapE = loadHashmapE(slice, 16, loadCryptoSignaturePair); + let signatures: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadCryptoSignaturePair, + }, slice); return { kind: 'BlockSignaturesPure', sig_count: sig_count, @@ -12392,7 +12478,12 @@ export function storeBlockSignaturesPure(blockSignaturesPure: BlockSignaturesPur return ((builder: Builder) => { builder.storeUint(blockSignaturesPure.sig_count, 32); builder.storeUint(blockSignaturesPure.sig_weight, 64); - storeHashmapE(blockSignaturesPure.signatures, storeCryptoSignaturePair)(builder); + builder.storeDict(blockSignaturesPure.signatures, Dictionary.Keys.Uint(16), { + serialize: ((arg: CryptoSignaturePair, builder: Builder) => { + storeCryptoSignaturePair(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -12584,11 +12675,14 @@ export function storeTopBlockDescr(topBlockDescr: TopBlockDescr): (builder: Buil export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4ac789f3))) { slice.loadUint(32); - let collection: HashmapE = loadHashmapE(slice, 96, ((slice: Slice) => { + let collection: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(96), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadTopBlockDescr(slice1) - })); + }), + }, slice); return { kind: 'TopBlockDescrSet', collection: collection, @@ -12601,15 +12695,20 @@ export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { export function storeTopBlockDescrSet(topBlockDescrSet: TopBlockDescrSet): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x4ac789f3, 32); - storeHashmapE(topBlockDescrSet.collection, ((arg: TopBlockDescr) => { - return ((builder: Builder) => { - let cell1 = beginCell(); - storeTopBlockDescr(arg)(cell1); - builder.storeRef(cell1); + builder.storeDict(topBlockDescrSet.collection, Dictionary.Keys.BigUint(96), { + serialize: ((arg: TopBlockDescr, builder: Builder) => { + ((arg: TopBlockDescr) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTopBlockDescr(arg)(cell1); + builder.storeRef(cell1); - }) + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -12768,7 +12867,10 @@ export function loadValidatorComplaintStatus(slice: Slice): ValidatorComplaintSt slice.loadUint(8); let slice1 = slice.loadRef().beginParse(); let complaint: ValidatorComplaint = loadValidatorComplaint(slice1); - let voters: HashmapE = loadHashmapE(slice, 16, loadTrue); + let voters: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadTrue, + }, slice); let vset_id: bigint = slice.loadUintBig(256); let weight_remaining: number = slice.loadInt(64); return { @@ -12789,7 +12891,12 @@ export function storeValidatorComplaintStatus(validatorComplaintStatus: Validato let cell1 = beginCell(); storeValidatorComplaint(validatorComplaintStatus.complaint)(cell1); builder.storeRef(cell1); - storeHashmapE(validatorComplaintStatus.voters, storeTrue)(builder); + builder.storeDict(validatorComplaintStatus.voters, Dictionary.Keys.Uint(16), { + serialize: ((arg: True, builder: Builder) => { + storeTrue(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); builder.storeUint(validatorComplaintStatus.vset_id, 256); builder.storeInt(validatorComplaintStatus.weight_remaining, 64); }) @@ -13189,7 +13296,10 @@ export function storeVmStackList(vmStackList: VmStackList): (builder: Builder) = // _ cregs:(HashmapE 4 VmStackValue) = VmSaveList; export function loadVmSaveList(slice: Slice): VmSaveList { - let cregs: HashmapE = loadHashmapE(slice, 4, loadVmStackValue); + let cregs: Dictionary = Dictionary.load(Dictionary.Keys.Uint(4), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadVmStackValue, + }, slice); return { kind: 'VmSaveList', cregs: cregs, @@ -13199,7 +13309,12 @@ export function loadVmSaveList(slice: Slice): VmSaveList { export function storeVmSaveList(vmSaveList: VmSaveList): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(vmSaveList.cregs, storeVmStackValue)(builder); + builder.storeDict(vmSaveList.cregs, Dictionary.Keys.Uint(4), { + serialize: ((arg: VmStackValue, builder: Builder) => { + storeVmStackValue(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -13240,11 +13355,14 @@ export function storeVmGasLimits(vmGasLimits: VmGasLimits): (builder: Builder) = // _ libraries:(HashmapE 256 ^Cell) = VmLibraries; export function loadVmLibraries(slice: Slice): VmLibraries { - let libraries: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let libraries: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return slice1 - })); + }), + }, slice); return { kind: 'VmLibraries', libraries: libraries, @@ -13254,15 +13372,20 @@ export function loadVmLibraries(slice: Slice): VmLibraries { export function storeVmLibraries(vmLibraries: VmLibraries): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(vmLibraries.libraries, ((arg: Slice) => { - return ((builder: Builder) => { - let cell1 = beginCell(); - cell1.storeSlice(arg); - builder.storeRef(cell1); + builder.storeDict(vmLibraries.libraries, Dictionary.Keys.BigUint(256), { + serialize: ((arg: Slice, builder: Builder) => { + ((arg: Slice) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + cell1.storeSlice(arg); + builder.storeRef(cell1); - }) + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -13576,11 +13699,14 @@ export function storeVmCont(vmCont: VmCont): (builder: Builder) => void { // _ (HashmapE 256 ^DNSRecord) = DNS_RecordSet; export function loadDNS_RecordSet(slice: Slice): DNS_RecordSet { - let anon0: HashmapE = loadHashmapE(slice, 256, ((slice: Slice) => { + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadDNSRecord(slice1) - })); + }), + }, slice); return { kind: 'DNS_RecordSet', anon0: anon0, @@ -13590,15 +13716,20 @@ export function loadDNS_RecordSet(slice: Slice): DNS_RecordSet { export function storeDNS_RecordSet(dNS_RecordSet: DNS_RecordSet): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(dNS_RecordSet.anon0, ((arg: DNSRecord) => { - return ((builder: Builder) => { - let cell1 = beginCell(); - storeDNSRecord(arg)(cell1); - builder.storeRef(cell1); + builder.storeDict(dNS_RecordSet.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: DNSRecord, builder: Builder) => { + ((arg: DNSRecord) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeDNSRecord(arg)(cell1); + builder.storeRef(cell1); - }) + }) - }))(builder); + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index 5818003..fc13bb9 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -5,6 +5,8 @@ import { BitString } from 'ton' import { Cell } from 'ton' import { Address } from 'ton' import { ExternalAddress } from 'ton' +import { Dictionary } from 'ton' +import { DictionaryValue } from 'ton' export function bitLen(n: number) { return n.toString(2).length;; } @@ -460,28 +462,11 @@ export interface HmLabel_hml_same { readonly n: number; } -// hme_empty$0 {n:#} {X:Type} = HashmapE n X; - -// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; - -export type HashmapE = HashmapE_hme_empty | HashmapE_hme_root; - -export interface HashmapE_hme_empty { - readonly kind: 'HashmapE_hme_empty'; - readonly n: number; -} - -export interface HashmapE_hme_root { - readonly kind: 'HashmapE_hme_root'; - readonly n: number; - readonly root: Hashmap; -} - // a$_ x:(HashmapE 8 uint16) = HashmapEUser; export interface HashmapEUser { readonly kind: 'HashmapEUser'; - readonly x: HashmapE; + readonly x: Dictionary; } // _ a:(## 1) b:a?(## 32) = ConditionalField; @@ -719,6 +704,64 @@ export interface GramsUser { readonly g: bigint; } +// a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser; + +export interface HashmapVUIUser { + readonly kind: 'HashmapVUIUser'; + readonly x: Dictionary; +} + +// a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell; + +export interface HashmapTPCell { + readonly kind: 'HashmapTPCell'; + readonly x: Dictionary; +} + +// a$_ {n:#} x:(HashmapE n uint5) = HashmapVarKey n; + +export interface HashmapVarKey { + readonly kind: 'HashmapVarKey'; + readonly n: number; + readonly x: Dictionary; +} + +// a$_ x:(HashmapVarKey 5) = HashmapVarKeyUser; + +export interface HashmapVarKeyUser { + readonly kind: 'HashmapVarKeyUser'; + readonly x: HashmapVarKey; +} + +// a$_ {n:#} x:(HashmapE (n+2) uint5) = HashmapExprKey n; + +export interface HashmapExprKey { + readonly kind: 'HashmapExprKey'; + readonly n: number; + readonly x: Dictionary; +} + +// a$_ x:(HashmapExprKey 5) = HashmapExprKeyUser; + +export interface HashmapExprKeyUser { + readonly kind: 'HashmapExprKeyUser'; + readonly x: HashmapExprKey; +} + +// a$_ {A: Type} x:(HashmapE 200 (OneComb A)) = HashmapOneComb A; + +export interface HashmapOneComb { + readonly kind: 'HashmapOneComb'; + readonly x: Dictionary>; +} + +// a$_ x:(HashmapOneComb uint5) = HashmapOneCombUser; + +export interface HashmapOneCombUser { + readonly kind: 'HashmapOneCombUser'; + readonly x: HashmapOneComb; +} + // tmpa$_ a:# b:# = Simple; export function loadSimple(slice: Slice): Simple { @@ -2140,59 +2183,16 @@ export function storeHmLabel(hmLabel: HmLabel): (builder: Builder) => void { throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" in loading "HmLabel", but data does not satisfy any constructor'); } -// hme_empty$0 {n:#} {X:Type} = HashmapE n X; - -// hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X; - -export function loadHashmapE(slice: Slice, n: number, loadX: (slice: Slice) => X): HashmapE { - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { - slice.loadUint(1); - return { - kind: 'HashmapE_hme_empty', - n: n, - } - - } - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { - slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); - let root: Hashmap = loadHashmap(slice1, n, loadX); - return { - kind: 'HashmapE_hme_root', - n: n, - root: root, - } - - } - throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); -} - -export function storeHashmapE(hashmapE: HashmapE, storeX: (x: X) => (builder: Builder) => void): (builder: Builder) => void { - if ((hashmapE.kind == 'HashmapE_hme_empty')) { - return ((builder: Builder) => { - builder.storeUint(0b0, 1); - }) - - } - if ((hashmapE.kind == 'HashmapE_hme_root')) { - return ((builder: Builder) => { - builder.storeUint(0b1, 1); - let cell1 = beginCell(); - storeHashmap(hashmapE.root, storeX)(cell1); - builder.storeRef(cell1); - }) - - } - throw new Error('Expected one of "HashmapE_hme_empty", "HashmapE_hme_root" in loading "HashmapE", but data does not satisfy any constructor'); -} - // a$_ x:(HashmapE 8 uint16) = HashmapEUser; export function loadHashmapEUser(slice: Slice): HashmapEUser { - let x: HashmapE = loadHashmapE(slice, 8, ((slice: Slice) => { + let x: Dictionary = Dictionary.load(Dictionary.Keys.Uint(8), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { return slice.loadUint(16) - })); + }), + }, slice); return { kind: 'HashmapEUser', x: x, @@ -2202,12 +2202,17 @@ export function loadHashmapEUser(slice: Slice): HashmapEUser { export function storeHashmapEUser(hashmapEUser: HashmapEUser): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapE(hashmapEUser.x, ((arg: number) => { - return ((builder: Builder) => { - builder.storeUint(arg, 16); - }) - - }))(builder); + builder.storeDict(hashmapEUser.x, Dictionary.Keys.Uint(8), { + serialize: ((arg: number, builder: Builder) => { + ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 16); + }) + + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -2889,3 +2894,233 @@ export function storeGramsUser(gramsUser: GramsUser): (builder: Builder) => void } +// a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser; + +export function loadHashmapVUIUser(slice: Slice): HashmapVUIUser { + let x: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(100), { + serialize: () => { throw new Error('Not implemented') }, + parse: loadVarUIntegerUser, + }, slice); + return { + kind: 'HashmapVUIUser', + x: x, + } + +} + +export function storeHashmapVUIUser(hashmapVUIUser: HashmapVUIUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapVUIUser.x, Dictionary.Keys.BigUint(100), { + serialize: ((arg: VarUIntegerUser, builder: Builder) => { + storeVarUIntegerUser(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + +// a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell; + +export function loadHashmapTPCell(slice: Slice): HashmapTPCell { + let x: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(100), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + let slice1 = slice.loadRef().beginParse(); + return loadTypedParam(slice1) + + }), + }, slice); + return { + kind: 'HashmapTPCell', + x: x, + } + +} + +export function storeHashmapTPCell(hashmapTPCell: HashmapTPCell): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapTPCell.x, Dictionary.Keys.BigUint(100), { + serialize: ((arg: TypedParam, builder: Builder) => { + ((arg: TypedParam) => { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeTypedParam(arg)(cell1); + builder.storeRef(cell1); + + }) + + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + +// a$_ {n:#} x:(HashmapE n uint5) = HashmapVarKey n; + +export function loadHashmapVarKey(slice: Slice, n: number): HashmapVarKey { + let x: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(n), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return slice.loadUint(5) + + }), + }, slice); + return { + kind: 'HashmapVarKey', + n: n, + x: x, + } + +} + +export function storeHashmapVarKey(hashmapVarKey: HashmapVarKey): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapVarKey.x, Dictionary.Keys.BigUint(hashmapVarKey.n), { + serialize: ((arg: number, builder: Builder) => { + ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 5); + }) + + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + +// a$_ x:(HashmapVarKey 5) = HashmapVarKeyUser; + +export function loadHashmapVarKeyUser(slice: Slice): HashmapVarKeyUser { + let x: HashmapVarKey = loadHashmapVarKey(slice, 5); + return { + kind: 'HashmapVarKeyUser', + x: x, + } + +} + +export function storeHashmapVarKeyUser(hashmapVarKeyUser: HashmapVarKeyUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapVarKey(hashmapVarKeyUser.x)(builder); + }) + +} + +// a$_ {n:#} x:(HashmapE (n+2) uint5) = HashmapExprKey n; + +export function loadHashmapExprKey(slice: Slice, n: number): HashmapExprKey { + let x: Dictionary = Dictionary.load(Dictionary.Keys.BigUint((n + 2)), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return slice.loadUint(5) + + }), + }, slice); + return { + kind: 'HashmapExprKey', + n: n, + x: x, + } + +} + +export function storeHashmapExprKey(hashmapExprKey: HashmapExprKey): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapExprKey.x, Dictionary.Keys.BigUint((hashmapExprKey.n + 2)), { + serialize: ((arg: number, builder: Builder) => { + ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 5); + }) + + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + +// a$_ x:(HashmapExprKey 5) = HashmapExprKeyUser; + +export function loadHashmapExprKeyUser(slice: Slice): HashmapExprKeyUser { + let x: HashmapExprKey = loadHashmapExprKey(slice, 5); + return { + kind: 'HashmapExprKeyUser', + x: x, + } + +} + +export function storeHashmapExprKeyUser(hashmapExprKeyUser: HashmapExprKeyUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapExprKey(hashmapExprKeyUser.x)(builder); + }) + +} + +// a$_ {A: Type} x:(HashmapE 200 (OneComb A)) = HashmapOneComb A; + +export function loadHashmapOneComb(slice: Slice, loadA: (slice: Slice) => A): HashmapOneComb { + let x: Dictionary> = Dictionary.load(Dictionary.Keys.BigUint(200), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return loadOneComb(slice, loadA) + + }), + }, slice); + return { + kind: 'HashmapOneComb', + x: x, + } + +} + +export function storeHashmapOneComb(hashmapOneComb: HashmapOneComb, storeA: (a: A) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapOneComb.x, Dictionary.Keys.BigUint(200), { + serialize: ((arg: OneComb, builder: Builder) => { + ((arg: OneComb) => { + return ((builder: Builder) => { + storeOneComb(arg, storeA)(builder); + }) + + })(arg)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + +// a$_ x:(HashmapOneComb uint5) = HashmapOneCombUser; + +export function loadHashmapOneCombUser(slice: Slice): HashmapOneCombUser { + let x: HashmapOneComb = loadHashmapOneComb(slice, ((slice: Slice) => { + return slice.loadUint(5) + + })); + return { + kind: 'HashmapOneCombUser', + x: x, + } + +} + +export function storeHashmapOneCombUser(hashmapOneCombUser: HashmapOneCombUser): (builder: Builder) => void { + return ((builder: Builder) => { + storeHashmapOneComb(hashmapOneCombUser.x, ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 5); + }) + + }))(builder); + }) + +} + diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index f5707eb..e8aae12 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -158,4 +158,13 @@ a$_ v:(VarUInteger 5) = VarUIntegerUser; a$_ v:(VarInteger 5) = VarIntegerUser; nanograms$_ amount:(VarUInteger 16) = Grams; -a$_ g:Grams = GramsUser; \ No newline at end of file +a$_ g:Grams = GramsUser; + +a$_ x:(HashmapE 100 VarUIntegerUser) = HashmapVUIUser; +a$_ x:(HashmapE 100 ^TypedParam) = HashmapTPCell; +a$_ {n:#} x:(HashmapE n uint5) = HashmapVarKey n; +a$_ x:(HashmapVarKey 5) = HashmapVarKeyUser; +a$_ {n:#} x:(HashmapE (n+2) uint5) = HashmapExprKey n; +a$_ x:(HashmapExprKey 5) = HashmapExprKeyUser; +a$_ {A: Type} x:(HashmapE 200 (OneComb A)) = HashmapOneComb A; +a$_ x:(HashmapOneComb uint5) = HashmapOneCombUser; diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index fbd64ca..2fb20aa 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -1,16 +1,28 @@ import path from 'path'; -import { Address, BitString, Cell, ExternalAddress, Slice } from 'ton'; +import { Address, BitString, Cell, Dictionary, DictionaryKeyTypes, ExternalAddress, Slice } from 'ton'; 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, GramsUser, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, 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, loadHashmapEUser, 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, storeHashmapEUser, 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'; +import { AddressUser, AnonymousData, AnyAddressUser, BitLenArg, BitLenArgUser, BitSelection, BitUser, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, ExtAddressUser, FalseAnonField, GramsUser, 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, 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, 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'; import { randomInt } from 'crypto'; const fixturesDir = path.resolve(__dirname, 'fixtures'); -function deepEqual(object1: any, object2: any) { +function isPrimitive(input: any) { + if (input == null) { + // This is here to correctly handle document.all. + return input === null || input === undefined; + } + const type = typeof input; + return type !== "object" && type !== "function"; + } + +function deepEqual(object1: any, object2: any): boolean { + if (isPrimitive(object1) && isPrimitive(object2)) { + return object1 == object2; + } if (object1 instanceof BitString && object2 instanceof BitString) { return object1.equals(object2); } @@ -21,6 +33,25 @@ function deepEqual(object1: any, object2: any) { return object1.equals(object2); } + if (object1 instanceof Dictionary && object2 instanceof Dictionary) { + if (object1.size != object2.size) { + return false; + } + let ok = true; + object1.keys().forEach((key) => { + let value1 = object1.get(key); + if (!object2.has(key)) { + ok = false; + } + let value2 = object2.get(key); + let equal = deepEqual(value1, value2); + if (!equal) { + ok = false; + } + }) + return ok; + } + const keys1 = Object.keys(object1); const keys2 = Object.keys(object2); @@ -190,6 +221,40 @@ describe('Generating tlb code', () => { let varIntegerUser: VarIntegerUser = { kind: 'VarIntegerUser', v: BigInt(-6) } checkSameOnStoreLoad(varIntegerUser, loadVarIntegerUser, storeVarIntegerUser) + + let simpleDict: Dictionary = Dictionary.empty() + simpleDict.set(1, 6); + simpleDict.set(2, 7); + simpleDict.set(0, 5); + let hashmapEUser: HashmapEUser = { kind: 'HashmapEUser', x: simpleDict } + checkSameOnStoreLoad(hashmapEUser, loadHashmapEUser, storeHashmapEUser); + + let vuiDict: Dictionary = Dictionary.empty() + vuiDict.set(BigInt(6), {kind: 'VarUIntegerUser', v: BigInt(5)}) + vuiDict.set(BigInt(7), {kind: 'VarUIntegerUser', v: BigInt(3)}) + let hashmapVUIUser: HashmapVUIUser = { kind: 'HashmapVUIUser', 'x': vuiDict} + checkSameOnStoreLoad(hashmapVUIUser, loadHashmapVUIUser, storeHashmapVUIUser); + + let tpcDict: Dictionary = Dictionary.empty() + tpcDict.set(BigInt(5), {kind: 'TypedParam', x: {kind: 'Maybe_just', value: {kind: 'SharpConstructor', c: 3, y: {kind: 'FixedIntParam', y: 4}}}}) + tpcDict.set(BigInt(3), {kind: 'TypedParam', x: {kind: 'Maybe_just', value: {kind: 'SharpConstructor', c: 9, y: {kind: 'FixedIntParam', y: 8}}}}) + let hashmapTPCell: HashmapTPCell = { kind: 'HashmapTPCell', x: tpcDict} + checkSameOnStoreLoad(hashmapTPCell, loadHashmapTPCell, storeHashmapTPCell); + + let vkDict: Dictionary = Dictionary.empty() + vkDict.set(BigInt(3), 6) + vkDict.set(BigInt(7), 9) + let hashmapVarKeyUser: HashmapVarKeyUser = { kind: 'HashmapVarKeyUser', x: {kind: 'HashmapVarKey', n: 5, x: vkDict }} + checkSameOnStoreLoad(hashmapVarKeyUser, loadHashmapVarKeyUser, storeHashmapVarKeyUser); + + let hashmapExprKeyUser: HashmapExprKeyUser = { kind: 'HashmapExprKeyUser', x: {kind: 'HashmapExprKey', n: 5, x: vkDict }} + checkSameOnStoreLoad(hashmapExprKeyUser, loadHashmapExprKeyUser, storeHashmapExprKeyUser); + + let ocuDict: Dictionary> = Dictionary.empty() + ocuDict.set(BigInt(1), { kind: 'OneComb', t: 3, x: 6 }) + ocuDict.set(BigInt(19), { kind: 'OneComb', t: 5, x: 4 }) + let hashmapOneCombUser: HashmapOneCombUser = { kind: 'HashmapOneCombUser', x: {kind: 'HashmapOneComb', x: ocuDict }} + checkSameOnStoreLoad(hashmapOneCombUser, loadHashmapOneCombUser, storeHashmapOneCombUser); }) test('Combinators', () => { @@ -279,97 +344,6 @@ describe('Generating tlb code', () => { checkThrowOnStoreLoad(equalityExpressionIncorrect, loadEqualityExpression, storeEqualityExpression); }) - test('Builtins', () => { - expect.hasAssertions() - - let hashmapEUser: HashmapEUser = { - kind: 'HashmapEUser', - x: { - kind: 'HashmapE_hme_root', - n: 8, - root: { - kind: 'Hashmap', - l: 0, m: 8, n: 8, - label: { - kind: 'HmLabel_hml_short', - n: 0, m: 8, - len: { kind: 'Unary_unary_zero' }, - s: [] - }, - node: { - kind: 'HashmapNode_hmn_fork', - n: 7, - left: { - kind: 'Hashmap', - n: 7, - m: 5, - l: 2, - label: { - kind: 'HmLabel_hml_long', - m: 7, - n: 2, - s: getBooleanArray('00') - }, - node: { - kind: 'HashmapNode_hmn_fork', - n: 4, - left: { - kind: 'Hashmap', - n: 4, - m: 0, - l: 4, - label: { - kind: 'HmLabel_hml_long', - m: 4, - n: 4, - s: getBooleanArray('0001') - }, - node: { - kind: 'HashmapNode_hmn_leaf', - value: 777 - } - }, - right: { - kind: 'Hashmap', - n: 4, - m: 0, - l: 4, - label: { - kind: 'HmLabel_hml_long', - m: 4, - n: 4, - s: getBooleanArray('0001') - }, - node: { - kind: 'HashmapNode_hmn_leaf', - value: 111 - } - } - } - }, - right: { - kind: 'Hashmap', - n: 7, - m: 0, - l: 7, - label: { - kind: 'HmLabel_hml_long', - m: 7, - n: 7, - s: getBooleanArray('0000000') - }, - node: { - kind: 'HashmapNode_hmn_leaf', - value: 777 - } - } - } - } - } - } - checkSameOnStoreLoad(hashmapEUser, loadHashmapEUser, storeHashmapEUser); - }) - test('Constructor Tags', () => { expect.hasAssertions() From 4bf7e5061cd19a1cf4b0efdf60e052171402f3c4 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Mon, 15 Jan 2024 15:34:28 -0500 Subject: [PATCH 08/28] HashmapAugE --- src/ast.ts | 5 +- src/astbuilder/fill_constructors.ts | 1 + src/astbuilder/handle_type.ts | 11 + src/generators/typescript/complex_expr.ts | 21 +- src/generators/typescript/generator.ts | 39 ++- src/generators/typescript/tsgen.ts | 22 +- test/generated_files/generated_block.ts | 339 ++++++++++++++-------- test/generated_files/generated_test.ts | 195 +++++++++++++ test/tlb/test.tlb | 14 + test/tlbgen.spec.ts | 18 +- 10 files changed, 521 insertions(+), 144 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index f5aece5..36b3d49 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -93,8 +93,9 @@ export type TLBVarIntegerType = { export type TLBHashmapType = { kind: "TLBHashmapType"; - key: TLBMathExprType, - value: TLBFieldType + key: TLBMathExprType; + value: TLBFieldType; + extra?: TLBFieldType; } export type TLBCellType = { diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index 6c8559a..78440e2 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -433,6 +433,7 @@ function checkAndRemovePrimitives( typesToDelete.set("VarUInteger", ["11d56c2e"]) typesToDelete.set("VarInteger", ["d466ed5"]) typesToDelete.set("HashmapE", ["32bae5cb", "28fa3979"]) + typesToDelete.set("HashmapAugE", ["36820dce", "5f71ac75"]) typesToDelete.forEach((opCodesExpected: string[], typeName: string) => { let typeItems = typeDeclarations.get(typeName); diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index ea9af99..94fe4c3 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -171,6 +171,17 @@ export function getType( throw new Error('Hashmap key should be number') } return { kind: "TLBHashmapType", key: key, value: value }; + } else if (expr.name == "HashmapAugE") { + if (expr.args.length != 3) { + throw new Error('Not enough arguments for HashmapAugE') + } + let key = getType(expr.args[0], constructor, fieldTypeName) + let value = getType(expr.args[1], constructor, fieldTypeName) + let extra = getType(expr.args[2], constructor, fieldTypeName) + if (key.kind != 'TLBExprMathType') { + throw new Error('Hashmap key should be number') + } + return { kind: "TLBHashmapType", key: key, value: value, extra: extra }; } else if ( expr.name == "VarUInteger" && (expr.args[0] instanceof MathExpr || diff --git a/src/generators/typescript/complex_expr.ts b/src/generators/typescript/complex_expr.ts index c6d02e0..e4482ee 100644 --- a/src/generators/typescript/complex_expr.ts +++ b/src/generators/typescript/complex_expr.ts @@ -1,7 +1,7 @@ import { TLBCode, TLBConstructorTag, TLBField, TLBHashmapType, TLBMathExprType } from "../../ast"; import { findNotReservedName, firstLower, getCurrentSlice } from "../../utils"; import { ConstructorContext } from "./generator"; -import { BinaryExpression, Expression, GenDeclaration, Identifier, ObjectExpression, Statement, TypeExpression, TypeParametersExpression, TypedIdentifier, id, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tDeclareVariable, tExpressionStatement, tForCycle, tFunctionCall, tFunctionDeclaration, tIfStatement, tMemberExpression, tMultiStatement, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, toCode } from "./tsgen"; +import { BinaryExpression, Expression, GenDeclaration, Identifier, ObjectExpression, Statement, TypeExpression, TypeParametersExpression, TypedIdentifier, id, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tDeclareVariable, tExpressionStatement, tForCycle, tFunctionCall, tFunctionDeclaration, tIfStatement, tMemberExpression, tMultiStatement, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tStructExpression, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, toCode } from "./tsgen"; import { ExprForParam, convertToAST, getNegationDerivationFunctionBody, isBigIntExpr } from "./utils"; export function tEqualExpression(left: Expression, right: Expression) { @@ -336,10 +336,14 @@ export function dictStoreStmt(currentCell: string, storeParametersInside: Expres export function dictTypeParamExpr(fieldType: TLBHashmapType, typeParamExpr: TypeExpression): TypeExpression | undefined { return tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([(isBigIntExpr(fieldType.key) ? id('bigint') : id('number')), typeParamExpr])); } -export function dictValueStore(typeParamExpr: TypeExpression, storeFunctionExpr: Expression) { +export function dictValueStore(typeParamExpr: TypeExpression, storeFunctionExpr: Expression, extraStoreFunctionExpr?: Expression) { + let subStatements = [tExpressionStatement(tFunctionCall(tFunctionCall(storeFunctionExpr, [id(extraStoreFunctionExpr? 'arg.value' : 'arg')]), [id('builder')]))] + if (extraStoreFunctionExpr) { + subStatements = [tExpressionStatement(tFunctionCall(tFunctionCall(extraStoreFunctionExpr, [id('arg.extra')]), [id('builder')]))].concat(subStatements) + } return tObjectExpression([ tObjectProperty(id('serialize'), - tArrowFunctionExpression([tTypedIdentifier(id('arg'), typeParamExpr), tTypedIdentifier(id('builder'), id('Builder'))], [tExpressionStatement(tFunctionCall(tFunctionCall(storeFunctionExpr, [id('arg')]), [id('builder')]))]) + tArrowFunctionExpression([tTypedIdentifier(id('arg'), typeParamExpr), tTypedIdentifier(id('builder'), id('Builder'))], subStatements) ), tObjectProperty(id('parse'), id("() => { throw new Error('Not implemented') }") @@ -367,4 +371,15 @@ export function dictKeyExpr(keyType: TLBMathExprType, ctx: ConstructorContext, o param = convertToAST(keyType.expr, ctx.constructor); } return tFunctionCall(tMemberExpression(id('Dictionary.Keys'), (isBigIntExpr(keyType) ? id('BigUint') : id('Uint'))), [param]); +}export function dictAugParse(extraLoadExpr: Expression, loadExpr: Expression): Expression { + return tArrowFunctionExpression([tTypedIdentifier(id('slice'), id('Slice'))], [ + tReturnStatement(tObjectExpression([ + tObjectProperty(id('extra'), extraLoadExpr), + tObjectProperty(id('value'), loadExpr), + ])) + ]); } +export function dictAugTypeExpr(typeExpr: TypeExpression, extraTypeExpr: TypeExpression): TypeExpression { + return tStructExpression([tTypedIdentifier(id('value'), typeExpr), tTypedIdentifier(id('extra'), extraTypeExpr)]); +} + diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index 84f9c74..a38ed0a 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -1,4 +1,3 @@ -import { Identifier } from "typescript"; import { TLBCode, TLBConstructor, @@ -25,6 +24,12 @@ import { checkKindStmt, checkTagExpr, coverFuncCall, + dictAugParse, + dictAugTypeExpr, + dictKeyExpr, dictLoadExpr, + dictStoreStmt, + dictTypeParamExpr, + dictValueStore, inSeparateRef, loadExprForParam, loadFromNewSlice, @@ -70,7 +75,6 @@ import { tIfStatement, tImportDeclaration, tMemberExpression, - tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, @@ -82,7 +86,7 @@ import { tTypedIdentifier, tUnionTypeDeclaration, tUnionTypeExpression, - toCode, + toCode } from "./tsgen"; import { ExprForParam, @@ -94,7 +98,6 @@ import { getTypeParametersExpression, isBigInt, } from "./utils"; -import { dictKeyExpr, dictLoadExpr, dictValueStore, dictTypeParamExpr, dictStoreStmt } from "./complex_expr"; /* @@ -903,18 +906,25 @@ export class TypescriptGenerator implements CodeGenerator { } else if (fieldType.kind == "TLBHashmapType") { let keyForLoad: Expression = dictKeyExpr(fieldType.key, ctx); let keyForStore: Expression = dictKeyExpr(fieldType.key, ctx, ctx.typeName); - let subExprInfo = this.handleType( - field, - fieldType.value, - false, - ctx, - slicePrefix, - argIndex - ); + let subExprInfo = this.handleType(field, fieldType.value, fieldType.extra != undefined, ctx, slicePrefix, argIndex); + if (subExprInfo.typeParamExpr && subExprInfo.loadFunctionExpr && subExprInfo.storeFunctionExpr) { - result.loadExpr = dictLoadExpr(keyForLoad, subExprInfo.loadFunctionExpr, currentSlice) - let valueStore = dictValueStore(subExprInfo.typeParamExpr, subExprInfo.storeFunctionExpr) + let valueStore: Expression; + if (fieldType.extra && subExprInfo.loadExpr) { + let extraInfo = this.handleType(field, fieldType.extra, true, ctx, slicePrefix, argIndex); + if (extraInfo.typeParamExpr) { + subExprInfo.typeParamExpr = dictAugTypeExpr(subExprInfo.typeParamExpr, extraInfo.typeParamExpr) + } + valueStore = dictValueStore(subExprInfo.typeParamExpr, subExprInfo.storeFunctionExpr, extraInfo.storeFunctionExpr) + + if (extraInfo.loadExpr) { + result.loadExpr = dictLoadExpr(keyForLoad, dictAugParse(extraInfo.loadExpr, subExprInfo.loadExpr), currentSlice) + } + } else { + valueStore = dictValueStore(subExprInfo.typeParamExpr, subExprInfo.storeFunctionExpr) + result.loadExpr = dictLoadExpr(keyForLoad, subExprInfo.loadFunctionExpr, currentSlice) + } result.typeParamExpr = dictTypeParamExpr(fieldType, subExprInfo.typeParamExpr) result.storeStmtInside = dictStoreStmt(currentCell, storeParametersInside, keyForStore, valueStore) result.storeStmtOutside = dictStoreStmt(currentCell, storeParametersOutside, keyForStore, valueStore) @@ -1038,4 +1048,3 @@ export class TypescriptGenerator implements CodeGenerator { return result; } } - diff --git a/src/generators/typescript/tsgen.ts b/src/generators/typescript/tsgen.ts index dd45e5c..76062ba 100644 --- a/src/generators/typescript/tsgen.ts +++ b/src/generators/typescript/tsgen.ts @@ -85,6 +85,11 @@ export interface ObjectExpression extends ASTNode { objectValues: Array; } +export interface StructExpression extends ASTNode { + type: "StructExpression"; + fields: Array; +} + export interface FunctionCall extends ASTNode { type: "FunctionCall"; functionId: Expression; @@ -176,7 +181,8 @@ export type TypeExpression = | Identifier | TypeWithParameters | ArrowFunctionType - | UnionTypeExpression; + | UnionTypeExpression + | StructExpression; export type Statement = | ReturnStatement | ExpressionStatement @@ -189,6 +195,7 @@ export type Expression = | TypeExpression | Literal | ObjectExpression + | StructExpression | FunctionCall | MemberExpression | ArrowFunctionExpression @@ -298,6 +305,13 @@ export function tObjectExpression( return { type: "ObjectExpression", objectValues: objectValues }; } +export function tStructExpression( + fields: Array +): StructExpression { + return { type: "StructExpression", fields: fields }; +} + + export function tReturnStatement(returnValue: Expression): ReturnStatement { return { type: "ReturnStatement", returnValue: returnValue }; } @@ -574,6 +588,12 @@ export function toCode( code.add("}", false); } + if (node.type == "StructExpression") { + code.add("{", false); + toCodeArray(node.fields, code, ", "); + code.add("}", false); + } + if (node.type == "MultiStatement") { node.statements.forEach((statement) => { code.append(toCode(statement)); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 6061141..7d948e1 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -201,31 +201,6 @@ export interface HashmapAugNode_ahmn_fork { readonly extra: Y; } -/* -ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y - = HashmapAugE n X Y; -*/ - -/* -ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) - extra:Y = HashmapAugE n X Y; -*/ - -export type HashmapAugE = HashmapAugE_ahme_empty | HashmapAugE_ahme_root; - -export interface HashmapAugE_ahme_empty { - readonly kind: 'HashmapAugE_ahme_empty'; - readonly n: number; - readonly extra: Y; -} - -export interface HashmapAugE_ahme_root { - readonly kind: 'HashmapAugE_ahme_root'; - readonly n: number; - readonly root: HashmapAug; - readonly extra: Y; -} - /* vhm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n) {n = (~m) + l} node:(VarHashmapNode m X) @@ -707,7 +682,7 @@ export interface ImportFees { export interface InMsgDescr { readonly kind: 'InMsgDescr'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } /* @@ -816,14 +791,14 @@ export interface EnqueuedMsg { export interface OutMsgDescr { readonly kind: 'OutMsgDescr'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } // _ (HashmapAugE 352 EnqueuedMsg uint64) = OutMsgQueue; export interface OutMsgQueue { readonly kind: 'OutMsgQueue'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } // processed_upto$_ last_msg_lt:uint64 last_msg_hash:bits256 = ProcessedUpto; @@ -1007,7 +982,7 @@ export interface DepthBalanceInfo { export interface ShardAccounts { readonly kind: 'ShardAccounts'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } /* @@ -1088,7 +1063,7 @@ export interface AccountBlock { export interface ShardAccountBlocks { readonly kind: 'ShardAccountBlocks'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } /* @@ -1933,7 +1908,7 @@ export interface ShardFeeCreated { export interface ShardFees { readonly kind: 'ShardFees'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } /* @@ -1995,7 +1970,7 @@ export interface KeyExtBlkRef { export interface OldMcBlocksInfo { readonly kind: 'OldMcBlocksInfo'; - readonly anon0: HashmapAugE; + readonly anon0: Dictionary; } // counters#_ last_updated:uint32 total:uint64 cnt2048:uint64 cnt65536:uint64 = Counters; @@ -2029,7 +2004,7 @@ export interface BlockCreateStats_block_create_stats { export interface BlockCreateStats_block_create_stats_ext { readonly kind: 'BlockCreateStats_block_create_stats_ext'; - readonly counters: HashmapAugE; + readonly counters: Dictionary; } /* @@ -4335,64 +4310,6 @@ export function storeHashmapAugNode(hashmapAugNode: HashmapAugNode, throw new Error('Expected one of "HashmapAugNode_ahmn_leaf", "HashmapAugNode_ahmn_fork" in loading "HashmapAugNode", but data does not satisfy any constructor'); } -/* -ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y - = HashmapAugE n X Y; -*/ - -/* -ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) - extra:Y = HashmapAugE n X Y; -*/ - -export function loadHashmapAugE(slice: Slice, n: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAugE { - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b0))) { - slice.loadUint(1); - let extra: Y = loadY(slice); - return { - kind: 'HashmapAugE_ahme_empty', - n: n, - extra: extra, - } - - } - if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { - slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); - let root: HashmapAug = loadHashmapAug(slice1, n, loadX, loadY); - let extra: Y = loadY(slice); - return { - kind: 'HashmapAugE_ahme_root', - n: n, - root: root, - extra: extra, - } - - } - throw new Error('Expected one of "HashmapAugE_ahme_empty", "HashmapAugE_ahme_root" in loading "HashmapAugE", but data does not satisfy any constructor'); -} - -export function storeHashmapAugE(hashmapAugE: HashmapAugE, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { - if ((hashmapAugE.kind == 'HashmapAugE_ahme_empty')) { - return ((builder: Builder) => { - builder.storeUint(0b0, 1); - storeY(hashmapAugE.extra)(builder); - }) - - } - if ((hashmapAugE.kind == 'HashmapAugE_ahme_root')) { - return ((builder: Builder) => { - builder.storeUint(0b1, 1); - let cell1 = beginCell(); - storeHashmapAug(hashmapAugE.root, storeX, storeY)(cell1); - builder.storeRef(cell1); - storeY(hashmapAugE.extra)(builder); - }) - - } - throw new Error('Expected one of "HashmapAugE_ahme_empty", "HashmapAugE_ahme_root" in loading "HashmapAugE", but data does not satisfy any constructor'); -} - export function varHashmap_get_l(label: HmLabel): number { if ((label.kind == 'HmLabel_hml_short')) { let n = label.n; @@ -5802,7 +5719,16 @@ export function storeImportFees(importFees: ImportFees): (builder: Builder) => v // _ (HashmapAugE 256 InMsg ImportFees) = InMsgDescr; export function loadInMsgDescr(slice: Slice): InMsgDescr { - let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadInMsg, loadImportFees); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadImportFees(slice), + value: loadInMsg(slice), + } + + }), + }, slice); return { kind: 'InMsgDescr', anon0: anon0, @@ -5812,7 +5738,23 @@ export function loadInMsgDescr(slice: Slice): InMsgDescr { export function storeInMsgDescr(inMsgDescr: InMsgDescr): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(inMsgDescr.anon0, storeInMsg, storeImportFees)(builder); + builder.storeDict(inMsgDescr.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: {value: InMsg, extra: ImportFees}, builder: Builder) => { + ((arg: ImportFees) => { + return ((builder: Builder) => { + storeImportFees(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: InMsg) => { + return ((builder: Builder) => { + storeInMsg(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6104,7 +6046,16 @@ export function storeEnqueuedMsg(enqueuedMsg: EnqueuedMsg): (builder: Builder) = // _ (HashmapAugE 256 OutMsg CurrencyCollection) = OutMsgDescr; export function loadOutMsgDescr(slice: Slice): OutMsgDescr { - let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadOutMsg, loadCurrencyCollection); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadCurrencyCollection(slice), + value: loadOutMsg(slice), + } + + }), + }, slice); return { kind: 'OutMsgDescr', anon0: anon0, @@ -6114,7 +6065,23 @@ export function loadOutMsgDescr(slice: Slice): OutMsgDescr { export function storeOutMsgDescr(outMsgDescr: OutMsgDescr): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(outMsgDescr.anon0, storeOutMsg, storeCurrencyCollection)(builder); + builder.storeDict(outMsgDescr.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: {value: OutMsg, extra: CurrencyCollection}, builder: Builder) => { + ((arg: CurrencyCollection) => { + return ((builder: Builder) => { + storeCurrencyCollection(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: OutMsg) => { + return ((builder: Builder) => { + storeOutMsg(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6122,10 +6089,16 @@ export function storeOutMsgDescr(outMsgDescr: OutMsgDescr): (builder: Builder) = // _ (HashmapAugE 352 EnqueuedMsg uint64) = OutMsgQueue; export function loadOutMsgQueue(slice: Slice): OutMsgQueue { - let anon0: HashmapAugE = loadHashmapAugE(slice, 352, loadEnqueuedMsg, ((slice: Slice) => { - return slice.loadUint(64) + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(352), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: slice.loadUint(64), + value: loadEnqueuedMsg(slice), + } - })); + }), + }, slice); return { kind: 'OutMsgQueue', anon0: anon0, @@ -6135,12 +6108,23 @@ export function loadOutMsgQueue(slice: Slice): OutMsgQueue { export function storeOutMsgQueue(outMsgQueue: OutMsgQueue): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(outMsgQueue.anon0, storeEnqueuedMsg, ((arg: number) => { - return ((builder: Builder) => { - builder.storeUint(arg, 64); - }) + builder.storeDict(outMsgQueue.anon0, Dictionary.Keys.BigUint(352), { + serialize: ((arg: {value: EnqueuedMsg, extra: number}, builder: Builder) => { + ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 64); + }) - }))(builder); + })(arg.extra)(builder); + ((arg: EnqueuedMsg) => { + return ((builder: Builder) => { + storeEnqueuedMsg(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6608,7 +6592,16 @@ export function storeDepthBalanceInfo(depthBalanceInfo: DepthBalanceInfo): (buil // _ (HashmapAugE 256 ShardAccount DepthBalanceInfo) = ShardAccounts; export function loadShardAccounts(slice: Slice): ShardAccounts { - let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadShardAccount, loadDepthBalanceInfo); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadDepthBalanceInfo(slice), + value: loadShardAccount(slice), + } + + }), + }, slice); return { kind: 'ShardAccounts', anon0: anon0, @@ -6618,7 +6611,23 @@ export function loadShardAccounts(slice: Slice): ShardAccounts { export function storeShardAccounts(shardAccounts: ShardAccounts): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(shardAccounts.anon0, storeShardAccount, storeDepthBalanceInfo)(builder); + builder.storeDict(shardAccounts.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: {value: ShardAccount, extra: DepthBalanceInfo}, builder: Builder) => { + ((arg: DepthBalanceInfo) => { + return ((builder: Builder) => { + storeDepthBalanceInfo(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: ShardAccount) => { + return ((builder: Builder) => { + storeShardAccount(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -6901,7 +6910,16 @@ export function storeAccountBlock(accountBlock: AccountBlock): (builder: Builder // _ (HashmapAugE 256 AccountBlock CurrencyCollection) = ShardAccountBlocks; export function loadShardAccountBlocks(slice: Slice): ShardAccountBlocks { - let anon0: HashmapAugE = loadHashmapAugE(slice, 256, loadAccountBlock, loadCurrencyCollection); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadCurrencyCollection(slice), + value: loadAccountBlock(slice), + } + + }), + }, slice); return { kind: 'ShardAccountBlocks', anon0: anon0, @@ -6911,7 +6929,23 @@ export function loadShardAccountBlocks(slice: Slice): ShardAccountBlocks { export function storeShardAccountBlocks(shardAccountBlocks: ShardAccountBlocks): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(shardAccountBlocks.anon0, storeAccountBlock, storeCurrencyCollection)(builder); + builder.storeDict(shardAccountBlocks.anon0, Dictionary.Keys.BigUint(256), { + serialize: ((arg: {value: AccountBlock, extra: CurrencyCollection}, builder: Builder) => { + ((arg: CurrencyCollection) => { + return ((builder: Builder) => { + storeCurrencyCollection(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: AccountBlock) => { + return ((builder: Builder) => { + storeAccountBlock(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -9202,7 +9236,16 @@ export function storeShardFeeCreated(shardFeeCreated: ShardFeeCreated): (builder // _ (HashmapAugE 96 ShardFeeCreated ShardFeeCreated) = ShardFees; export function loadShardFees(slice: Slice): ShardFees { - let anon0: HashmapAugE = loadHashmapAugE(slice, 96, loadShardFeeCreated, loadShardFeeCreated); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(96), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadShardFeeCreated(slice), + value: loadShardFeeCreated(slice), + } + + }), + }, slice); return { kind: 'ShardFees', anon0: anon0, @@ -9212,7 +9255,23 @@ export function loadShardFees(slice: Slice): ShardFees { export function storeShardFees(shardFees: ShardFees): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(shardFees.anon0, storeShardFeeCreated, storeShardFeeCreated)(builder); + builder.storeDict(shardFees.anon0, Dictionary.Keys.BigUint(96), { + serialize: ((arg: {value: ShardFeeCreated, extra: ShardFeeCreated}, builder: Builder) => { + ((arg: ShardFeeCreated) => { + return ((builder: Builder) => { + storeShardFeeCreated(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: ShardFeeCreated) => { + return ((builder: Builder) => { + storeShardFeeCreated(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -9357,7 +9416,16 @@ export function storeKeyExtBlkRef(keyExtBlkRef: KeyExtBlkRef): (builder: Builder // _ (HashmapAugE 32 KeyExtBlkRef KeyMaxLt) = OldMcBlocksInfo; export function loadOldMcBlocksInfo(slice: Slice): OldMcBlocksInfo { - let anon0: HashmapAugE = loadHashmapAugE(slice, 32, loadKeyExtBlkRef, loadKeyMaxLt); + let anon0: Dictionary = Dictionary.load(Dictionary.Keys.Uint(32), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadKeyMaxLt(slice), + value: loadKeyExtBlkRef(slice), + } + + }), + }, slice); return { kind: 'OldMcBlocksInfo', anon0: anon0, @@ -9367,7 +9435,23 @@ export function loadOldMcBlocksInfo(slice: Slice): OldMcBlocksInfo { export function storeOldMcBlocksInfo(oldMcBlocksInfo: OldMcBlocksInfo): (builder: Builder) => void { return ((builder: Builder) => { - storeHashmapAugE(oldMcBlocksInfo.anon0, storeKeyExtBlkRef, storeKeyMaxLt)(builder); + builder.storeDict(oldMcBlocksInfo.anon0, Dictionary.Keys.Uint(32), { + serialize: ((arg: {value: KeyExtBlkRef, extra: KeyMaxLt}, builder: Builder) => { + ((arg: KeyMaxLt) => { + return ((builder: Builder) => { + storeKeyMaxLt(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: KeyExtBlkRef) => { + return ((builder: Builder) => { + storeKeyExtBlkRef(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } @@ -9444,10 +9528,16 @@ export function loadBlockCreateStats(slice: Slice): BlockCreateStats { } if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x34))) { slice.loadUint(8); - let counters: HashmapAugE = loadHashmapAugE(slice, 256, loadCreatorStats, ((slice: Slice) => { - return slice.loadUint(32) + let counters: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: slice.loadUint(32), + value: loadCreatorStats(slice), + } - })); + }), + }, slice); return { kind: 'BlockCreateStats_block_create_stats_ext', counters: counters, @@ -9473,12 +9563,23 @@ export function storeBlockCreateStats(blockCreateStats: BlockCreateStats): (buil if ((blockCreateStats.kind == 'BlockCreateStats_block_create_stats_ext')) { return ((builder: Builder) => { builder.storeUint(0x34, 8); - storeHashmapAugE(blockCreateStats.counters, storeCreatorStats, ((arg: number) => { - return ((builder: Builder) => { - builder.storeUint(arg, 32); - }) + builder.storeDict(blockCreateStats.counters, Dictionary.Keys.BigUint(256), { + serialize: ((arg: {value: CreatorStats, extra: number}, builder: Builder) => { + ((arg: number) => { + return ((builder: Builder) => { + builder.storeUint(arg, 32); + }) - }))(builder); + })(arg.extra)(builder); + ((arg: CreatorStats) => { + return ((builder: Builder) => { + storeCreatorStats(arg)(builder); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); }) } diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index fc13bb9..a3587e6 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -762,6 +762,51 @@ export interface HashmapOneCombUser { readonly x: HashmapOneComb; } +/* +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +*/ + +export interface HashmapAug { + readonly kind: 'HashmapAug'; + readonly n: number; + readonly l: number; + readonly m: number; + readonly label: HmLabel; + readonly node: HashmapAugNode; +} + +// ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; + +/* +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; +*/ + +export type HashmapAugNode = HashmapAugNode_ahmn_leaf | HashmapAugNode_ahmn_fork; + +export interface HashmapAugNode_ahmn_leaf { + readonly kind: 'HashmapAugNode_ahmn_leaf'; + readonly extra: Y; + readonly value: X; +} + +export interface HashmapAugNode_ahmn_fork { + readonly kind: 'HashmapAugNode_ahmn_fork'; + readonly n: number; + readonly left: HashmapAug; + readonly right: HashmapAug; + readonly extra: Y; +} + +// a$_ x:(HashmapAugE 16 Grams FixedIntParam) = HashmapAugEUser; + +export interface HashmapAugEUser { + readonly kind: 'HashmapAugEUser'; + readonly x: Dictionary; +} + // tmpa$_ a:# b:# = Simple; export function loadSimple(slice: Slice): Simple { @@ -3124,3 +3169,153 @@ export function storeHashmapOneCombUser(hashmapOneCombUser: HashmapOneCombUser): } +export function hashmapAug_get_l(label: HmLabel): number { + if ((label.kind == 'HmLabel_hml_short')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_long')) { + let n = label.n; + return n + + } + if ((label.kind == 'HmLabel_hml_same')) { + let n = label.n; + return n + + } + throw new Error('Expected one of "HmLabel_hml_short", "HmLabel_hml_long", "HmLabel_hml_same" for type "HmLabel" while getting "label", but data does not satisfy any constructor'); +} + +/* +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +*/ + +export function loadHashmapAug(slice: Slice, n: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAug { + let label: HmLabel = loadHmLabel(slice, n); + let l = hashmapAug_get_l(label); + let node: HashmapAugNode = loadHashmapAugNode(slice, (n - l), loadX, loadY); + return { + kind: 'HashmapAug', + n: n, + m: (n - l), + label: label, + l: l, + node: node, + } + +} + +export function storeHashmapAug(hashmapAug: HashmapAug, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + return ((builder: Builder) => { + storeHmLabel(hashmapAug.label)(builder); + storeHashmapAugNode(hashmapAug.node, storeX, storeY)(builder); + }) + +} + +// ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; + +/* +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; +*/ + +export function loadHashmapAugNode(slice: Slice, arg0: number, loadX: (slice: Slice) => X, loadY: (slice: Slice) => Y): HashmapAugNode { + if ((arg0 == 0)) { + let extra: Y = loadY(slice); + let value: X = loadX(slice); + return { + kind: 'HashmapAugNode_ahmn_leaf', + extra: extra, + value: value, + } + + } + if (true) { + let slice1 = slice.loadRef().beginParse(); + let left: HashmapAug = loadHashmapAug(slice1, (arg0 - 1), loadX, loadY); + let slice2 = slice.loadRef().beginParse(); + let right: HashmapAug = loadHashmapAug(slice2, (arg0 - 1), loadX, loadY); + let extra: Y = loadY(slice); + return { + kind: 'HashmapAugNode_ahmn_fork', + n: (arg0 - 1), + left: left, + right: right, + extra: extra, + } + + } + throw new Error('Expected one of "HashmapAugNode_ahmn_leaf", "HashmapAugNode_ahmn_fork" in loading "HashmapAugNode", but data does not satisfy any constructor'); +} + +export function storeHashmapAugNode(hashmapAugNode: HashmapAugNode, storeX: (x: X) => (builder: Builder) => void, storeY: (y: Y) => (builder: Builder) => void): (builder: Builder) => void { + if ((hashmapAugNode.kind == 'HashmapAugNode_ahmn_leaf')) { + return ((builder: Builder) => { + storeY(hashmapAugNode.extra)(builder); + storeX(hashmapAugNode.value)(builder); + }) + + } + if ((hashmapAugNode.kind == 'HashmapAugNode_ahmn_fork')) { + return ((builder: Builder) => { + let cell1 = beginCell(); + storeHashmapAug(hashmapAugNode.left, storeX, storeY)(cell1); + builder.storeRef(cell1); + let cell2 = beginCell(); + storeHashmapAug(hashmapAugNode.right, storeX, storeY)(cell2); + builder.storeRef(cell2); + storeY(hashmapAugNode.extra)(builder); + }) + + } + throw new Error('Expected one of "HashmapAugNode_ahmn_leaf", "HashmapAugNode_ahmn_fork" in loading "HashmapAugNode", but data does not satisfy any constructor'); +} + +// a$_ x:(HashmapAugE 16 Grams FixedIntParam) = HashmapAugEUser; + +export function loadHashmapAugEUser(slice: Slice): HashmapAugEUser { + let x: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { + serialize: () => { throw new Error('Not implemented') }, + parse: ((slice: Slice) => { + return { + extra: loadFixedIntParam(slice), + value: slice.loadCoins(), + } + + }), + }, slice); + return { + kind: 'HashmapAugEUser', + x: x, + } + +} + +export function storeHashmapAugEUser(hashmapAugEUser: HashmapAugEUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(hashmapAugEUser.x, Dictionary.Keys.Uint(16), { + serialize: ((arg: {value: bigint, extra: FixedIntParam}, builder: Builder) => { + ((arg: FixedIntParam) => { + return ((builder: Builder) => { + storeFixedIntParam(arg)(builder); + }) + + })(arg.extra)(builder); + ((arg: bigint) => { + return ((builder: Builder) => { + builder.storeCoins(arg); + }) + + })(arg.value)(builder); + }), + parse: () => { throw new Error('Not implemented') }, + }); + }) + +} + diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index e8aae12..bf6da31 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -168,3 +168,17 @@ a$_ {n:#} x:(HashmapE (n+2) uint5) = HashmapExprKey n; a$_ x:(HashmapExprKey 5) = HashmapExprKeyUser; a$_ {A: Type} x:(HashmapE 200 (OneComb A)) = HashmapOneComb A; a$_ x:(HashmapOneComb uint5) = HashmapOneCombUser; + +ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#} + label:(HmLabel ~l n) {n = (~m) + l} + node:(HashmapAugNode m X Y) = HashmapAug n X Y; +ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y; +ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y) + right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y; + +ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y + = HashmapAugE n X Y; +ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y) + extra:Y = HashmapAugE n X Y; + +a$_ x:(HashmapAugE 16 Grams FixedIntParam) = HashmapAugEUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 2fb20aa..b946bbb 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -5,7 +5,7 @@ import { Address, BitString, Cell, Dictionary, DictionaryKeyTypes, ExternalAddre 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, GramsUser, 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, 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, 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'; +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'; import { randomInt } from 'crypto'; const fixturesDir = path.resolve(__dirname, 'fixtures'); @@ -255,6 +255,13 @@ describe('Generating tlb code', () => { ocuDict.set(BigInt(19), { kind: 'OneComb', t: 5, x: 4 }) let hashmapOneCombUser: HashmapOneCombUser = { kind: 'HashmapOneCombUser', x: {kind: 'HashmapOneComb', x: ocuDict }} checkSameOnStoreLoad(hashmapOneCombUser, loadHashmapOneCombUser, storeHashmapOneCombUser); + + let dictAug: Dictionary = Dictionary.empty() + dictAug.set(5, { value: BigInt(4), extra: { kind: 'FixedIntParam', y: 7 } }) + dictAug.set(6, { value: BigInt(3), extra: { kind: 'FixedIntParam', y: 9 } }) + dictAug.set(5, { value: BigInt(8), extra: { kind: 'FixedIntParam', y: 11 } }) + let hashmapAugEUser: HashmapAugEUser = { kind: 'HashmapAugEUser', x: dictAug } + checkSameOnStoreLoad(hashmapAugEUser, loadHashmapAugEUser, storeHashmapAugEUser) }) test('Combinators', () => { @@ -508,9 +515,12 @@ describe('Generating tlb code', () => { const cs = Cell.fromBase64(state); let blk = loadBlock(cs.beginParse()); - let builder = beginCell(); - storeBlock(blk)(builder); - expect(deepEqual(cs.hash(), builder.endCell().hash())).toBeTruthy() + // let builder = beginCell(); + // storeBlock(blk)(builder); + + // expect(deepEqual(cs.hash(), builder.endCell().hash())).toBeTruthy() + + checkSameOnStoreLoad(blk, loadBlock, storeBlock) }) }) From d636070128d1be679dc7ffcab3d6117a7b6d1c3c Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Mon, 15 Jan 2024 21:21:50 -0500 Subject: [PATCH 09/28] start cli & npm package --- .gitignore | 1 + generate_all.ts | 24 --- generate_tests.ts | 11 ++ index.ts | 1 - jest.config.js | 3 + main.ts | 24 +++ package-lock.json | 402 +++++++++++++++++++++++++++++++++++++++++++- package.json | 12 +- src/main.ts | 15 ++ test/tlbgen.spec.ts | 5 +- tsconfig.json | 102 +---------- 11 files changed, 464 insertions(+), 136 deletions(-) delete mode 100644 generate_all.ts create mode 100644 generate_tests.ts delete mode 100644 index.ts create mode 100755 main.ts diff --git a/.gitignore b/.gitignore index 0182f89..c2c69bb 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ typings/ ## ====== dist/ +build/ \ No newline at end of file diff --git a/generate_all.ts b/generate_all.ts deleted file mode 100644 index 55bcc41..0000000 --- a/generate_all.ts +++ /dev/null @@ -1,24 +0,0 @@ -import fs from 'fs' -import path from 'path' -import util from 'util' - -import { parse, ast } from '@igorivaniuk/tlb-parser' -import { generate } from './src/main' - - -const fixturesDir = path.resolve(__dirname, 'test') - -function generateCode(filename: string) { - const input = fs.readFileSync( - path.resolve(fixturesDir, 'tlb', filename + '.tlb'), - 'utf-8', - ) - const parsed = parse(input) - - const tree = ast(input) - - fs.writeFile('test/generated_files/generated_' + filename + '.ts', generate(tree, input), () => { }); -} - -generateCode('block') -generateCode('test') diff --git a/generate_tests.ts b/generate_tests.ts new file mode 100644 index 0000000..5aa4c3c --- /dev/null +++ b/generate_tests.ts @@ -0,0 +1,11 @@ +import path from 'path' +import util from 'util' +import { generateCode } from './src/main' + +function genCodeForTest(name: string) { + const fixturesDir = path.resolve(__dirname, 'test') + generateCode(path.resolve(fixturesDir, 'tlb', name + '.tlb'), 'test/generated_files/generated_' + name + '.ts') +} + +genCodeForTest('block') +genCodeForTest('test') diff --git a/index.ts b/index.ts deleted file mode 100644 index 955ef64..0000000 --- a/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("Hi") diff --git a/jest.config.js b/jest.config.js index b413e10..8af0e05 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,7 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', + testMatch: [ + "**/?(*.)+(spec|test).[j]s?(x)" + ] }; \ No newline at end of file diff --git a/main.ts b/main.ts new file mode 100755 index 0000000..cab57b1 --- /dev/null +++ b/main.ts @@ -0,0 +1,24 @@ +#!/usr/bin/env node +import meow from 'meow'; +import { generateCode } from './src/main'; + +const cli = meow(` + Usage + $ foo + + Options + --output, -o Output file, defult = tlbpath + ".tst" +`, { + flags: { + output: { + type: 'string', + shortFlag: 'o' + } + } +}); + + +let input = cli.input.at(0) +if (input) { + generateCode(input, input + ".ts"); +} diff --git a/package-lock.json b/package-lock.json index cdd8c61..cd1f0c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,24 @@ { - "name": "amy", - "version": "1.0.0", + "name": "@polyprogrammist_test/tlbgen", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "amy", - "version": "1.0.0", + "name": "@polyprogrammist_test/tlbgen", + "version": "1.0.2", "license": "ISC", "dependencies": { "@igorivaniuk/tlb-parser": "^0.1.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": { + "tlbgen": "build/main.js" + }, "devDependencies": { "@jest/globals": "^29.7.0", "jest": "^29.7.0", @@ -1111,6 +1115,11 @@ "pretty-format": "^29.0.0" } }, + "node_modules/@types/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==" + }, "node_modules/@types/node": { "version": "20.10.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", @@ -1119,6 +1128,11 @@ "undici-types": "~5.26.4" } }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==" + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -1220,6 +1234,14 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/axios": { "version": "0.25.0", "resolved": "https://registry.npmjs.org/axios/-/axios-0.25.0.tgz", @@ -1425,6 +1447,22 @@ "node": ">=6" } }, + "node_modules/camelcase-keys": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", + "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "dependencies": { + "camelcase": "^5.3.1", + "map-obj": "^4.0.0", + "quick-lru": "^4.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001572", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001572.tgz", @@ -1610,6 +1648,37 @@ } } }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decamelize-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.1.tgz", + "integrity": "sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==", + "dependencies": { + "decamelize": "^1.1.0", + "map-obj": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decamelize-keys/node_modules/map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/dedent": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", @@ -1906,6 +1975,14 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, + "node_modules/hard-rejection": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", + "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", + "engines": { + "node": ">=6" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -1925,6 +2002,33 @@ "node": ">= 0.4" } }, + "node_modules/hosted-git-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/hosted-git-info/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/hosted-git-info/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -1964,6 +2068,14 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "engines": { + "node": ">=8" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2018,6 +2130,14 @@ "node": ">=0.12.0" } }, + "node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -2735,6 +2855,14 @@ "node": "*" } }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -2837,6 +2965,61 @@ "tmpl": "1.0.5" } }, + "node_modules/map-obj": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz", + "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/meow": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-9.0.0.tgz", + "integrity": "sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==", + "dependencies": { + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize": "^1.2.0", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.0", + "normalize-package-data": "^3.0.0", + "read-pkg-up": "^7.0.1", + "redent": "^3.0.0", + "trim-newlines": "^3.0.0", + "type-fest": "^0.18.0", + "yargs-parser": "^20.2.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/meow/node_modules/type-fest": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", + "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/meow/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "engines": { + "node": ">=10" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -2862,6 +3045,14 @@ "node": ">=6" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2873,6 +3064,19 @@ "node": "*" } }, + "node_modules/minimist-options": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", + "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", + "dependencies": { + "arrify": "^1.0.1", + "is-plain-obj": "^1.1.0", + "kind-of": "^6.0.3" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -2893,6 +3097,50 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==" }, + "node_modules/normalize-package-data": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", + "dependencies": { + "hosted-git-info": "^4.0.1", + "is-core-module": "^2.5.0", + "semver": "^7.3.4", + "validate-npm-package-license": "^3.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/normalize-package-data/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/normalize-package-data/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/normalize-package-data/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -3121,11 +3369,101 @@ } ] }, + "node_modules/quick-lru": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", + "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "engines": { + "node": ">=8" + } + }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" }, + "node_modules/read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dependencies": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dependencies": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg-up/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" + }, + "node_modules/read-pkg/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/read-pkg/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/read-pkg/node_modules/type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3239,6 +3577,34 @@ "source-map": "^0.6.0" } }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.16.tgz", + "integrity": "sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==" + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -3307,6 +3673,17 @@ "node": ">=6" } }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -3435,6 +3812,14 @@ "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", + "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", + "engines": { + "node": ">=8" + } + }, "node_modules/ts-jest": { "version": "29.1.1", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", @@ -3649,6 +4034,15 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index c9aebc9..06b8e70 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,15 @@ { - "name": "amy", - "version": "1.0.0", + "name": "@polyprogrammist_test/tlbgen", + "version": "1.0.2", "description": "", "main": "index.js", "scripts": { - "test": "jest" + "test": "jest", + "build": "npm run compile", + "compile": "tsc" + }, + "bin": { + "tlbgen": "build/main.js" }, "keywords": [], "author": "", @@ -19,6 +24,7 @@ "@igorivaniuk/tlb-parser": "^0.1.0", "@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/main.ts b/src/main.ts index 2db2d8e..28e2f8c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,6 +10,10 @@ import { CodeBuilder } from "./generators/CodeBuilder"; import { CodeGenerator, CommonGenDeclaration } from "./generators/generator"; import { TypescriptGenerator } from "./generators/typescript/generator"; +import { ast } from '@igorivaniuk/tlb-parser' +import fs from 'fs' + + export function generate(tree: Program, input: string) { let oldTlbCode: TLBCodeBuild = { types: new Map() }; @@ -58,3 +62,14 @@ export function generate(tree: Program, input: string) { return generatedCode; } + +export function generateCode(inputPath: string, outputPath: string) { + const input = fs.readFileSync( + inputPath, + 'utf-8', + ) + + const tree = ast(input) + + fs.writeFile(outputPath, generate(tree, input), () => { }); +} \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index b946bbb..0f51b51 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -6,11 +6,8 @@ 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'; -import { randomInt } from 'crypto'; -const fixturesDir = path.resolve(__dirname, 'fixtures'); - -function isPrimitive(input: any) { +function isPrimitive(input: object) { if (input == null) { // This is here to correctly handle document.all. return input === null || input === undefined; diff --git a/tsconfig.json b/tsconfig.json index e075f97..52c3fcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,109 +1,11 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "outDir": "build", } } From 1c761546478c7f82c63a45c2841f624bee56e0cf Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 13:00:16 -0500 Subject: [PATCH 10/28] finalize binary --- generate_tests.ts | 2 +- main.ts | 21 +++++++++++++++++---- src/main.ts | 14 ++++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/generate_tests.ts b/generate_tests.ts index 5aa4c3c..bc30286 100644 --- a/generate_tests.ts +++ b/generate_tests.ts @@ -4,7 +4,7 @@ import { generateCode } from './src/main' function genCodeForTest(name: string) { const fixturesDir = path.resolve(__dirname, 'test') - generateCode(path.resolve(fixturesDir, 'tlb', name + '.tlb'), 'test/generated_files/generated_' + name + '.ts') + generateCode(path.resolve(fixturesDir, 'tlb', name + '.tlb'), 'test/generated_files/generated_' + name + '.ts', 'typescript') } genCodeForTest('block') diff --git a/main.ts b/main.ts index cab57b1..68d54ce 100755 --- a/main.ts +++ b/main.ts @@ -4,15 +4,20 @@ import { generateCode } from './src/main'; const cli = meow(` Usage - $ foo + $ tlbgen Options - --output, -o Output file, defult = tlbpath + ".tst" + --output, -o Output file, defult = tlbpath + ".ts" + --language, -l Programming language result. Supported languages: ["typescript"]. Default: "typescript" `, { flags: { output: { type: 'string', - shortFlag: 'o' + alias: 'o' + }, + language: { + type: 'string', + alias: 'l' } } }); @@ -20,5 +25,13 @@ const cli = meow(` let input = cli.input.at(0) if (input) { - generateCode(input, input + ".ts"); + let output = input + '.ts' + if (cli.flags.output) { + output = cli.flags.output; + } + let language = 'typescript' + if (cli.flags.language) { + language = cli.flags.language + } + generateCode(input, output, language); } diff --git a/src/main.ts b/src/main.ts index 28e2f8c..6898cc9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,7 +14,7 @@ import { ast } from '@igorivaniuk/tlb-parser' import fs from 'fs' -export function generate(tree: Program, input: string) { +export function generate(tree: Program, input: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) { let oldTlbCode: TLBCodeBuild = { types: new Map() }; let splittedInput = input.split("\n"); @@ -22,7 +22,7 @@ export function generate(tree: Program, input: string) { fillConstructors(tree.declarations, oldTlbCode, splittedInput); let tlbCode: TLBCode = convertCodeToReadonly(oldTlbCode); - let codeGenerator: CodeGenerator = new TypescriptGenerator(tlbCode); + let codeGenerator: CodeGenerator = getGenerator(tlbCode); codeGenerator.addTonCoreClassUsage("Builder"); codeGenerator.addTonCoreClassUsage("Slice"); @@ -63,7 +63,7 @@ export function generate(tree: Program, input: string) { return generatedCode; } -export function generateCode(inputPath: string, outputPath: string) { +export function generateCode(inputPath: string, outputPath: string, resultLanguage: string) { const input = fs.readFileSync( inputPath, 'utf-8', @@ -71,5 +71,11 @@ export function generateCode(inputPath: string, outputPath: string) { const tree = ast(input) - fs.writeFile(outputPath, generate(tree, input), () => { }); + fs.writeFile(outputPath, generate(tree, input, (tlbCode: TLBCode) => { + if (resultLanguage == 'typescript') { + return new TypescriptGenerator(tlbCode) + } else { + throw new Error(`Result language ${resultLanguage} is not supported`) + } + }), () => { }); } \ No newline at end of file From aff9e4bf6c48b78f15c6368b1c0cc9449ceaf045 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 14:13:23 -0500 Subject: [PATCH 11/28] Add exports for NPM package --- index.ts | 4 ++++ package.json | 4 ++-- src/main.ts | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 index.ts diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..0d505a1 --- /dev/null +++ b/index.ts @@ -0,0 +1,4 @@ +import { generateCode } from "./src/main"; +export { generateCode, generateCodeByAST, generateCodeWithGenerator } from "./src/main"; +export { CodeGenerator } from "./src/generators/generator"; +export { TypescriptGenerator } from "./src/generators/typescript/generator"; \ No newline at end of file diff --git a/package.json b/package.json index 06b8e70..1da4a04 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "@polyprogrammist_test/tlbgen", - "version": "1.0.2", + "version": "1.0.13", "description": "", - "main": "index.js", + "main": "build/index.js", "scripts": { "test": "jest", "build": "npm run compile", diff --git a/src/main.ts b/src/main.ts index 6898cc9..3105570 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,7 +14,7 @@ import { ast } from '@igorivaniuk/tlb-parser' import fs from 'fs' -export function generate(tree: Program, input: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) { +export function generateCodeByAST(tree: Program, input: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) { let oldTlbCode: TLBCodeBuild = { types: new Map() }; let splittedInput = input.split("\n"); @@ -63,7 +63,7 @@ export function generate(tree: Program, input: string, getGenerator: (tlbCode: T return generatedCode; } -export function generateCode(inputPath: string, outputPath: string, resultLanguage: string) { +export function generateCodeWithGenerator(inputPath: string, outputPath: string, getGenerator: (tlbCode: TLBCode) => CodeGenerator) { const input = fs.readFileSync( inputPath, 'utf-8', @@ -71,11 +71,16 @@ export function generateCode(inputPath: string, outputPath: string, resultLangua const tree = ast(input) - fs.writeFile(outputPath, generate(tree, input, (tlbCode: TLBCode) => { + fs.writeFile(outputPath, generateCodeByAST(tree, input, getGenerator), () => { }); +} + +export function generateCode(inputPath: string, outputPath: string, resultLanguage: string) { + let getGenerator = (tlbCode: TLBCode) => { if (resultLanguage == 'typescript') { return new TypescriptGenerator(tlbCode) } else { throw new Error(`Result language ${resultLanguage} is not supported`) } - }), () => { }); + } + generateCodeWithGenerator(inputPath, outputPath, getGenerator); } \ No newline at end of file From 9e6eb1d935b8bc172e010d17b9248905ceec123a Mon Sep 17 00:00:00 2001 From: Vadim Volodin Date: Tue, 16 Jan 2024 18:14:14 -0500 Subject: [PATCH 12/28] Create README.md --- README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ef2912 --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +# TLB Generator +This package allows you to generate `Typescript` code for serializing and deserializing structures according to the `TLB` scheme provided. + +[Here](https://docs.ton.org/develop/data-formats/tl-b-language) you can find documentation for creating TLB schemes, and more advanced article is [here](https://docs.ton.org/develop/data-formats/tl-b-types). + +This package uses [TLB-Parser](https://github.com/ton-community/tlb-parser) to get AST of the scheme. + +## Installation + +```bash +npm install @polyprogrammist_test/tlbgen +``` + +## Usage + +### CLI + +Create a file with TLB scheme according to the [documentation](https://docs.ton.org/develop/data-formats/tl-b-language). This is an example of such a file (call it `example.tlb`): +``` +t$_ x:# y:(uint 5) = A; +``` + +Then do: +```bash +npx tlbgen example.tlb +``` + +It will create a file called `example.tlb.ts` with the following code: +```typescript +export interface A { + readonly kind: 'A'; + readonly x: number; + readonly y: number; +} +export function loadA(slice: Slice): A { + let x: number = slice.loadUint(32); + let y: number = slice.loadUint(5); + return { + kind: 'A', + x: x, + y: y, + } + +} +export function storeA(a: A): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(a.x, 32); + builder.storeUint(a.y, 5); + }) + +} +``` + +You also can set an output file with `-o` option: `npx tlbgen -o other_file.ts example.tlb`. + +One of the examples where you can see various abilities of the tool is [block.tlb](https://github.com/PolyProgrammist/tlbgenerator/blob/master/test/tlb/block.tlb). The generation result for it is [here](https://github.com/PolyProgrammist/tlbgenerator/blob/master/test/generated_files/generated_block.ts). + +### Node JS +Also you can use the tool from inside JS or TS code. + +```typescript +import { generateCode } from "@polyprogrammist_test/tlbgen" +generateCode('example.tlb', 'example.tlb.ts', "typescript") +``` + + +## 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. + +Built-in types supported are: + - `Bool` -> `boolean` (loaded with `loadBoolean`, stored with `storeBit`) + - `MsgAddressInt` -> `Address` (loaded with `loadAddress`, stored with `storeAddress`) + - `MsgAddressExt` -> `ExternalAddress | null` (loaded with `loadMaybeExternalAddress`, stored with `storeAddress`) + - `MsgAddress` -> `Address | ExternalAddress | null` (loaded with `loadAddressAny`, stored with `storeAddress`) + - `VarUInteger` -> `bigint` (loaded with `loadVarUintBig`, stored with `storeVarUint`) + - `VarInteger` -> `bigint` (loaded with `loadVarIntBig`, stored with `storeVarInt`) + - `Bit` -> `boolean` (loaded with `loadBit`, stored with `storeBit`) + - `Grams` -> `bigint` (loaded with `loadCoins`, stored with `storeCoins`) + - `HashmapE n Value` -> `Dictionary` (or `Dictionary` if n <= 64) (loaded with `Dictionary.load`, stored with `storeDict`) + - `HashmapAugE n Value Extra` -> `Dictionary` (or `number` instead of `bigint` if `n <= 64`) (loaded with `Dictionary.load`, stored with `storeDict`) + +Please note that the tricky thing here with `HashmapAugE` is that in `TLB` scheme extra is [stored](https://github.com/ton-blockchain/ton/blob/062b7b4a92dd67e32d963cf3f04b8bc97d8b7ed5/crypto/block/block.tlb#L49) not only with values, but in intermediate nodes as well. However `Dictionary` in ton-core doesn't store the intermediate nodes. That is why `HashmapAugE` can be correctly loaded by the generated code, but storing is incorrect. + +## License + +This package is released under the [MIT License](LICENSE). From 623301e5bc9ff2fc8b84135fc8eb1f68aacc7163 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 18:15:58 -0500 Subject: [PATCH 13/28] Add license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6312342 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Vadim Volodin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From 131673a56fccb14e2cec831e06eea15c35cc91a3 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 18:20:17 -0500 Subject: [PATCH 14/28] Fix CI --- .github/workflows/jest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index 5504883..31820bb 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -12,5 +12,5 @@ jobs: - run: npm install - run: npm install -g ts-node - run: sed -i 's/"+", "Type"/"#", "Type"/g' "node_modules/@igorivaniuk/tlb-parser/dist/ast/nodes.d.ts" - - run: ts-node generate_all.ts + - run: ts-node generate_tests.ts - run: npm run test From 93ce06980f5794421b7d43f0761a45f27292c93b Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 18:21:36 -0500 Subject: [PATCH 15/28] Add npm run build to CI --- .github/workflows/jest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index 31820bb..227bf5f 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -11,6 +11,7 @@ jobs: node-version: '20' - run: npm install - run: npm install -g ts-node + - run: npm run build - run: sed -i 's/"+", "Type"/"#", "Type"/g' "node_modules/@igorivaniuk/tlb-parser/dist/ast/nodes.d.ts" - run: ts-node generate_tests.ts - run: npm run test From 86d76d56d8888ce2f844c20828a160c6edb2c4fa Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Tue, 16 Jan 2024 18:22:47 -0500 Subject: [PATCH 16/28] Move npm run build after + to # --- .github/workflows/jest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index 227bf5f..76c9ab9 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -11,7 +11,7 @@ jobs: node-version: '20' - run: npm install - run: npm install -g ts-node - - run: npm run build - run: sed -i 's/"+", "Type"/"#", "Type"/g' "node_modules/@igorivaniuk/tlb-parser/dist/ast/nodes.d.ts" + - run: npm run build - run: ts-node generate_tests.ts - run: npm run test From b8261683f69c03cb2b65022142d45c4673af3c28 Mon Sep 17 00:00:00 2001 From: thekiba Date: Sun, 11 Feb 2024 21:24:00 +0400 Subject: [PATCH 17/28] chore: rename package and update package.json --- .gitignore | 3 ++- package-lock.json | 25 ++++++++++++++----------- package.json | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index c2c69bb..6d48f5c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,5 +64,6 @@ typings/ ## Custom ## ====== +.idea dist/ -build/ \ No newline at end of file +build/ diff --git a/package-lock.json b/package-lock.json index cd1f0c1..a102bac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@polyprogrammist_test/tlbgen", - "version": "1.0.2", + "version": "1.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@polyprogrammist_test/tlbgen", - "version": "1.0.2", + "version": "1.0.13", "license": "ISC", "dependencies": { - "@igorivaniuk/tlb-parser": "^0.1.0", + "@ton-community/tlb-parser": "^0.1.1", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", "meow": "^9.0.0", @@ -630,14 +630,6 @@ "node": ">=12" } }, - "node_modules/@igorivaniuk/tlb-parser": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@igorivaniuk/tlb-parser/-/tlb-parser-0.1.0.tgz", - "integrity": "sha512-U7tNvwK3SL5BXujg5t3HZ0/aHnUkfT/acLG7E8J1R3CL6O/q6mfPcQnDfbIHPrnb6He+UMKhSsFjTbd4kKSvnw==", - "dependencies": { - "ohm-js": "^16.6.0" - } - }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1016,6 +1008,17 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@ton-community/tlb-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@ton-community/tlb-parser/-/tlb-parser-0.1.1.tgz", + "integrity": "sha512-WbtJNhe4OA0FquhM5ADf163roczNnq9b0MAPD7PVmso9gIOiUHRdHtYtAA5dI56MJst0O9g7Sw4nkKQy568MGw==", + "dependencies": { + "ohm-js": "^16.6.0" + }, + "bin": { + "tlb-parser": "dist/cli.js" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", diff --git a/package.json b/package.json index 1da4a04..ecc9611 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@polyprogrammist_test/tlbgen", + "name": "@ton-community/tlb-codegen", "version": "1.0.13", "description": "", "main": "build/index.js", @@ -21,7 +21,7 @@ "typescript": "^5.3.3" }, "dependencies": { - "@igorivaniuk/tlb-parser": "^0.1.0", + "@ton-community/tlb-parser": "^0.1.1", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", "meow": "^9.0.0", From b9cdba8f4543d292e70393ffa044bd0ccb43c2bf Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Sun, 11 Feb 2024 12:49:23 -0500 Subject: [PATCH 18/28] Switch to @ton-community/tlb-parser and add one more Block cell to tests --- .github/workflows/jest.yml | 1 - package-lock.json | 4 ++-- src/astbuilder/fill_constructors.ts | 2 +- src/astbuilder/handle_field.ts | 2 +- src/astbuilder/handle_type.ts | 2 +- src/astbuilder/utils.ts | 2 +- src/main.ts | 4 ++-- test/tlbgen.spec.ts | 7 +++++++ 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index 76c9ab9..283c7fd 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -11,7 +11,6 @@ jobs: node-version: '20' - run: npm install - run: npm install -g ts-node - - run: sed -i 's/"+", "Type"/"#", "Type"/g' "node_modules/@igorivaniuk/tlb-parser/dist/ast/nodes.d.ts" - run: npm run build - run: ts-node generate_tests.ts - run: npm run test diff --git a/package-lock.json b/package-lock.json index a102bac..3593f42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@polyprogrammist_test/tlbgen", + "name": "@ton-community/tlb-codegen", "version": "1.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@polyprogrammist_test/tlbgen", + "name": "@ton-community/tlb-codegen", "version": "1.0.13", "license": "ISC", "dependencies": { diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index 78440e2..23a4047 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -8,7 +8,7 @@ import { NameExpr, NegateExpr, NumberExpr, -} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser/dist/ast/nodes"; import * as crc32 from "crc-32"; import { TLBBinaryOp, diff --git a/src/astbuilder/handle_field.ts b/src/astbuilder/handle_field.ts index 0ac9119..5e88e4f 100644 --- a/src/astbuilder/handle_field.ts +++ b/src/astbuilder/handle_field.ts @@ -11,7 +11,7 @@ import { FieldNamedDef, MathExpr, NameExpr, -} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser/dist/ast/nodes"; import { TLBField } from "../ast"; import { getType } from "./handle_type"; import { TLBConstructorBuild, TLBTypeBuild } from "./utils"; diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 94fe4c3..83d0b23 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -9,7 +9,7 @@ import { NegateExpr, NumberExpr, Expression as ParserExpression, -} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser/dist/ast/nodes"; import { TLBBinaryOp, TLBFieldType, diff --git a/src/astbuilder/utils.ts b/src/astbuilder/utils.ts index 097e22d..1d530d5 100644 --- a/src/astbuilder/utils.ts +++ b/src/astbuilder/utils.ts @@ -5,7 +5,7 @@ import { NegateExpr, NumberExpr, SimpleExpr, -} from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser/dist/ast/nodes"; import { TLBBinaryOp, TLBConstructorTag, diff --git a/src/main.ts b/src/main.ts index 3105570..60f2f83 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { Program } from "@igorivaniuk/tlb-parser/dist/ast/nodes"; +import { Program } from "@ton-community/tlb-parser/dist/ast/nodes"; import { TLBCode, TLBType } from "./ast"; import { TLBCodeBuild, @@ -10,7 +10,7 @@ import { CodeBuilder } from "./generators/CodeBuilder"; import { CodeGenerator, CommonGenDeclaration } from "./generators/generator"; import { TypescriptGenerator } from "./generators/typescript/generator"; -import { ast } from '@igorivaniuk/tlb-parser' +import { ast } from "@ton-community/tlb-parser"; import fs from 'fs' diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 0f51b51..c04afde 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -519,5 +519,12 @@ describe('Generating tlb code', () => { // expect(deepEqual(cs.hash(), builder.endCell().hash())).toBeTruthy() checkSameOnStoreLoad(blk, loadBlock, storeBlock) + + const state2 = 'te6cckECEQEAAt0AJBAR71Wq////EQECAwQCoJvHqYcAAAAAgAECfjyTAAAAAQAAAAAAAAAAAAAAAABlyLWCAAAogZ67zMAAACiBnrvM0GBwTmIACCBSAiVwRAIlWR/EAAAABQAAAAAAAAAuBQYCEbjkjftFjQskhAcIKooETrjlNgwuHXtEbLkDiuPrh7ZsS5HcxL7sNQNLOzzxOJ8XpFaKmfMqRiqpTnODMFdkpeK+t1j9zpUGcLCGnyCbQQIcAhwJCiOJSjP2/QsLOJrSCYuSECQN4EQ1pAkI/Vq884HrhAXxgd/DMXKL3mNyX4QAmdB48ZNajadP6O+MetbFj9DF2crDtBqc+RNACwwNAJgAACiBnqyKhAIlcESQSl3z7iZHMb+ZzHB8UIicVmATlmlWML4cDjyK41AJDYwykU65Oj8VFycT567wJMI2c1Fp8XEpQ0oBBl7EszbpAJgAACiBnqyKigJ+PJIwkmdyOJaxAUgUAn96h7ctdbYa5ZqyLAxMr2CCCwI53+D63OzKxdebePB4BjmKCG0WpYdB4mhfQTshVEFholJiAiWCyjMIQaAjO2wWUZhB/mYlt0AIDg4ADQAQ7msoAAhojAEDTrjlNgwuHXtEbLkDiuPrh7ZsS5HcxL7sNQNLOzzxOJ8eUBr0CDsnKj+rfShCIEjNWz4L02mNMNBkMZ/Gt7d08wIcAB9ojAEDF6RWipnzKkYqqU5zgzBXZKXivrdY/c6VBnCwhp8gm0F20Jc6TiScBHS6NjRcwVkdaQJ0Gui4rsOnO0bOcbXHBAIcAB8oSAEBDImrgKWVyalum/bej1OHSpOS2UkgmMuIkBF7MzHXi7MAGChIAQEVd40DOrZ4FN5JCQjeUCvgm+Lo7v7TK7JOTt/GFqoW0AAZKEgBARILJG1IfD7ez2RrP8gh/dsLILjLke5aI27M3MaDIy1bABgCASAPEAATvgAAA7yRYnrqkAATv////7yLlvycUBOzqtE='; + const cs2 = Cell.fromBase64(state2); + + let blk2 = loadBlock(cs2.beginParse()); + + checkSameOnStoreLoad(blk2, loadBlock, storeBlock) }) }) From 764b626a1ab0d433d60c62c403f94f8c9de8c439 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Sun, 11 Feb 2024 12:59:15 -0500 Subject: [PATCH 19/28] beginParse for exotic cells --- src/generators/typescript/complex_expr.ts | 2 +- test/generated_files/generated_block.ts | 320 +++++++++++----------- test/generated_files/generated_test.ts | 38 +-- test/tlbgen.spec.ts | 2 + 4 files changed, 182 insertions(+), 180 deletions(-) diff --git a/src/generators/typescript/complex_expr.ts b/src/generators/typescript/complex_expr.ts index e4482ee..fd2d5bb 100644 --- a/src/generators/typescript/complex_expr.ts +++ b/src/generators/typescript/complex_expr.ts @@ -52,7 +52,7 @@ export function sliceLoad(slicePrefix: number[], currentSlice: string) { tFunctionCall(tMemberExpression(id(currentSlice), id("loadRef")), []), id("beginParse") ), - [] + [id('true')] ) ) ); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 7d948e1..575b3d9 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -3987,9 +3987,9 @@ export function loadHashmapNode(slice: Slice, arg0: number, loadX: (slice: Sl } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: Hashmap = loadHashmap(slice1, (arg0 - 1), loadX); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: Hashmap = loadHashmap(slice2, (arg0 - 1), loadX); return { kind: 'HashmapNode_hmn_fork', @@ -4270,9 +4270,9 @@ export function loadHashmapAugNode(slice: Slice, arg0: number, loadX: (sli } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: HashmapAug = loadHashmapAug(slice1, (arg0 - 1), loadX, loadY); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: HashmapAug = loadHashmapAug(slice2, (arg0 - 1), loadX, loadY); let extra: Y = loadY(slice); return { @@ -4384,9 +4384,9 @@ export function loadVarHashmapNode(slice: Slice, arg0: number, loadX: (slice: } if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { slice.loadUint(2); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: VarHashmap = loadVarHashmap(slice1, (arg0 - 1), loadX); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: VarHashmap = loadVarHashmap(slice2, (arg0 - 1), loadX); let value: Maybe = loadMaybe(slice, loadX); return { @@ -4401,7 +4401,7 @@ export function loadVarHashmapNode(slice: Slice, arg0: number, loadX: (slice: if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); let branch: boolean = slice.loadBit(); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let child: VarHashmap = loadVarHashmap(slice1, (arg0 - 1), loadX); let value: X = loadX(slice); return { @@ -4469,7 +4469,7 @@ export function loadVarHashmapE(slice: Slice, n: number, loadX: (slice: Slice } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let root: VarHashmap = loadVarHashmap(slice1, n, loadX); return { kind: 'VarHashmapE_vhme_root', @@ -4568,9 +4568,9 @@ export function loadPfxHashmapNode(slice: Slice, arg0: number, loadX: (slice: } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: PfxHashmap = loadPfxHashmap(slice1, (arg0 - 1), loadX); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: PfxHashmap = loadPfxHashmap(slice2, (arg0 - 1), loadX); return { kind: 'PfxHashmapNode_phmn_fork', @@ -4624,7 +4624,7 @@ export function loadPfxHashmapE(slice: Slice, n: number, loadX: (slice: Slice } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let root: PfxHashmap = loadPfxHashmap(slice1, n, loadX); return { kind: 'PfxHashmapE_phme_root', @@ -5001,17 +5001,17 @@ export function loadStateInit(slice: Slice): StateInit { })); let special: Maybe = loadMaybe(slice, loadTickTock); let code: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); let data: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); let library: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); @@ -5079,12 +5079,12 @@ export function loadStateInitWithLibs(slice: Slice): StateInitWithLibs { })); let special: Maybe = loadMaybe(slice, loadTickTock); let code: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); let data: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); @@ -5144,7 +5144,7 @@ export function storeStateInitWithLibs(stateInitWithLibs: StateInitWithLibs): (b export function loadSimpleLib(slice: Slice): SimpleLib { let public0: boolean = slice.loadBoolean(); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let root: Slice = slice1; return { kind: 'SimpleLib', @@ -5174,14 +5174,14 @@ export function loadMessage(slice: Slice, loadX: (slice: Slice) => X): Messag let info: CommonMsgInfo = loadCommonMsgInfo(slice); let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { return loadEither(slice, loadStateInit, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadStateInit(slice1) })) })); let body: Either = loadEither(slice, loadX, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadX(slice1) })); @@ -5234,14 +5234,14 @@ export function loadMessageRelaxed(slice: Slice, loadX: (slice: Slice) => X): let info: CommonMsgInfoRelaxed = loadCommonMsgInfoRelaxed(slice); let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { return loadEither(slice, loadStateInit, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadStateInit(slice1) })) })); let body: Either = loadEither(slice, loadX, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadX(slice1) })); @@ -5399,7 +5399,7 @@ export function loadMsgEnvelope(slice: Slice): MsgEnvelope { let cur_addr: IntermediateAddress = loadIntermediateAddress(slice); let next_addr: IntermediateAddress = loadIntermediateAddress(slice); let fwd_fee_remaining: bigint = slice.loadCoins(); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: Message = loadMessage(slice1, ((slice: Slice) => { return slice @@ -5472,12 +5472,12 @@ msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64 export function loadInMsg(slice: Slice): InMsg { if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b000))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: Message = loadMessage(slice1, ((slice: Slice) => { return slice })); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); return { kind: 'InMsg_msg_import_ext', @@ -5488,15 +5488,15 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: Message = loadMessage(slice1, ((slice: Slice) => { return slice })); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); let ihr_fee: bigint = slice.loadCoins(); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let proof_created: Slice = slice3; return { kind: 'InMsg_msg_import_ihr', @@ -5509,9 +5509,9 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b011))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); let fwd_fee: bigint = slice.loadCoins(); return { @@ -5524,9 +5524,9 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b100))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); let fwd_fee: bigint = slice.loadCoins(); return { @@ -5539,9 +5539,9 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b101))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice2); let transit_fee: bigint = slice.loadCoins(); return { @@ -5554,7 +5554,7 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b110))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let transaction_id: number = slice.loadUint(64); let fwd_fee: bigint = slice.loadCoins(); @@ -5568,11 +5568,11 @@ export function loadInMsg(slice: Slice): InMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b111))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: MsgEnvelope = loadMsgEnvelope(slice1); let transaction_id: number = slice.loadUint(64); let fwd_fee: bigint = slice.loadCoins(); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let proof_delivered: Slice = slice2; return { kind: 'InMsg_msg_discard_tr', @@ -5803,12 +5803,12 @@ msg_export_deq_imm$100 out_msg:^MsgEnvelope export function loadOutMsg(slice: Slice): OutMsg { if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b000))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: Message = loadMessage(slice1, ((slice: Slice) => { return slice })); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); return { kind: 'OutMsg_msg_export_ext', @@ -5819,11 +5819,11 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b010))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let reimport: InMsg = loadInMsg(slice3); return { kind: 'OutMsg_msg_export_imm', @@ -5835,9 +5835,9 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b001))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let transaction: Transaction = loadTransaction(slice2); return { kind: 'OutMsg_msg_export_new', @@ -5848,9 +5848,9 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b011))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let imported: InMsg = loadInMsg(slice2); return { kind: 'OutMsg_msg_export_tr', @@ -5861,7 +5861,7 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1100))) { slice.loadUint(4); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); let import_block_lt: number = slice.loadUint(63); return { @@ -5888,9 +5888,9 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b111))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let imported: InMsg = loadInMsg(slice2); return { kind: 'OutMsg_msg_export_tr_req', @@ -5901,9 +5901,9 @@ export function loadOutMsg(slice: Slice): OutMsg { } if (((slice.remainingBits >= 3) && (slice.preloadUint(3) == 0b100))) { slice.loadUint(3); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let reimport: InMsg = loadInMsg(slice2); return { kind: 'OutMsg_msg_export_deq_imm', @@ -6023,7 +6023,7 @@ export function storeOutMsg(outMsg: OutMsg): (builder: Builder) => void { export function loadEnqueuedMsg(slice: Slice): EnqueuedMsg { let enqueued_lt: number = slice.loadUint(64); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MsgEnvelope = loadMsgEnvelope(slice1); return { kind: 'EnqueuedMsg', @@ -6544,7 +6544,7 @@ account_descr$_ account:^Account last_trans_hash:bits256 */ export function loadShardAccount(slice: Slice): ShardAccount { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let account: Account = loadAccount(slice1); let last_trans_hash: BitString = slice.loadBits(256); let last_trans_lt: number = slice.loadUint(64); @@ -6653,9 +6653,9 @@ export function loadTransaction(slice: Slice): Transaction { let outmsg_cnt: number = slice.loadUint(15); let orig_status: AccountStatus = loadAccountStatus(slice); let end_status: AccountStatus = loadAccountStatus(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg: Maybe> = loadMaybe>(slice1, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadMessage(slice1, ((slice: Slice) => { return slice @@ -6665,7 +6665,7 @@ export function loadTransaction(slice: Slice): Transaction { let out_msgs: Dictionary> = Dictionary.load(Dictionary.Keys.Uint(15), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadMessage(slice1, ((slice: Slice) => { return slice @@ -6674,9 +6674,9 @@ export function loadTransaction(slice: Slice): Transaction { }), }, slice1); let total_fees: CurrencyCollection = loadCurrencyCollection(slice); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let state_update: HASH_UPDATE = loadHASH_UPDATE(slice2, loadAccount); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let description: TransactionDescr = loadTransactionDescr(slice3); return { kind: 'Transaction', @@ -6766,9 +6766,9 @@ export function loadMERKLE_UPDATE(slice: Slice, loadX: (slice: Slice) => X): slice.loadUint(8); let old_hash: BitString = slice.loadBits(256); let new_hash: BitString = slice.loadBits(256); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let old: X = loadX(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let new0: X = loadX(slice2); return { kind: 'MERKLE_UPDATE', @@ -6833,7 +6833,7 @@ export function loadMERKLE_PROOF(slice: Slice, loadX: (slice: Slice) => X): M slice.loadUint(8); let virtual_hash: BitString = slice.loadBits(256); let depth: number = slice.loadUint(16); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let virtual_root: X = loadX(slice1); return { kind: 'MERKLE_PROOF', @@ -6870,11 +6870,11 @@ export function loadAccountBlock(slice: Slice): AccountBlock { slice.loadUint(4); let account_addr: BitString = slice.loadBits(256); let transactions: HashmapAug = loadHashmapAug(slice, 64, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTransaction(slice1) }), loadCurrencyCollection); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let state_update: HASH_UPDATE = loadHASH_UPDATE(slice1, loadAccount); return { kind: 'AccountBlock', @@ -7104,7 +7104,7 @@ export function loadTrComputePhase(slice: Slice): TrComputePhase { let msg_state_used: boolean = slice.loadBoolean(); let account_activated: boolean = slice.loadBoolean(); let gas_fees: bigint = slice.loadCoins(); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let gas_used: bigint = slice1.loadVarUintBig(bitLen((7 - 1))); let gas_limit: bigint = slice1.loadVarUintBig(bitLen((7 - 1))); let gas_credit: Maybe = loadMaybe(slice1, ((slice: Slice) => { @@ -7473,7 +7473,7 @@ export function loadTransactionDescr(slice: Slice): TransactionDescr { let credit_ph: Maybe = loadMaybe(slice, loadTrCreditPhase); let compute_ph: TrComputePhase = loadTrComputePhase(slice); let action: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTrActionPhase(slice1) })); @@ -7508,7 +7508,7 @@ export function loadTransactionDescr(slice: Slice): TransactionDescr { let storage_ph: TrStoragePhase = loadTrStoragePhase(slice); let compute_ph: TrComputePhase = loadTrComputePhase(slice); let action: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTrActionPhase(slice1) })); @@ -7531,7 +7531,7 @@ export function loadTransactionDescr(slice: Slice): TransactionDescr { let storage_ph: Maybe = loadMaybe(slice, loadTrStoragePhase); let compute_ph: TrComputePhase = loadTrComputePhase(slice); let action: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTrActionPhase(slice1) })); @@ -7551,7 +7551,7 @@ export function loadTransactionDescr(slice: Slice): TransactionDescr { if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0101))) { slice.loadUint(4); let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prepare_transaction: Transaction = loadTransaction(slice1); let installed: boolean = slice.loadBoolean(); return { @@ -7578,13 +7578,13 @@ export function loadTransactionDescr(slice: Slice): TransactionDescr { if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b0111))) { slice.loadUint(4); let split_info: SplitMergeInfo = loadSplitMergeInfo(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prepare_transaction: Transaction = loadTransaction(slice1); let storage_ph: Maybe = loadMaybe(slice, loadTrStoragePhase); let credit_ph: Maybe = loadMaybe(slice, loadTrCreditPhase); let compute_ph: TrComputePhase = loadTrComputePhase(slice); let action: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTrActionPhase(slice1) })); @@ -7829,7 +7829,7 @@ export function loadOutList(slice: Slice, arg0: number): OutList { } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prev: OutList = loadOutList(slice1, (arg0 - 1)); let action: OutAction = loadOutAction(slice); return { @@ -7882,7 +7882,7 @@ export function loadOutAction(slice: Slice): OutAction { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x0ec3c86d))) { slice.loadUint(32); let mode: number = slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg: MessageRelaxed = loadMessageRelaxed(slice1, ((slice: Slice) => { return slice @@ -7896,7 +7896,7 @@ export function loadOutAction(slice: Slice): OutAction { } if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xad4de08e))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let new_code: Slice = slice1; return { kind: 'OutAction_action_set_code', @@ -7989,7 +7989,7 @@ export function loadLibRef(slice: Slice): LibRef { } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let library: Slice = slice1; return { kind: 'LibRef_libref_ref', @@ -8023,7 +8023,7 @@ export function storeLibRef(libRef: LibRef): (builder: Builder) => void { // out_list_node$_ prev:^Cell action:OutAction = OutListNode; export function loadOutListNode(slice: Slice): OutListNode { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prev: Slice = slice1; let action: OutAction = loadOutAction(slice); return { @@ -8183,12 +8183,12 @@ export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { let gen_utime: number = slice.loadUint(32); let gen_lt: number = slice.loadUint(64); let min_ref_mc_seqno: number = slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let out_msg_queue_info: OutMsgQueueInfo = loadOutMsgQueueInfo(slice1); let before_split: number = slice.loadUint(1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let accounts: ShardAccounts = loadShardAccounts(slice2); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let overload_history: number = slice3.loadUint(64); let underload_history: number = slice3.loadUint(64); let total_balance: CurrencyCollection = loadCurrencyCollection(slice3); @@ -8199,7 +8199,7 @@ export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { }, slice3); let master_ref: Maybe = loadMaybe(slice3, loadBlkMasterInfo); let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadMcStateExtra(slice1) })); @@ -8278,9 +8278,9 @@ export function storeShardStateUnsplit(shardStateUnsplit: ShardStateUnsplit): (b export function loadShardState(slice: Slice): ShardState { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x5f327da5))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: ShardStateUnsplit = loadShardStateUnsplit(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: ShardStateUnsplit = loadShardStateUnsplit(slice2); return { kind: 'ShardState_split_state', @@ -8330,7 +8330,7 @@ shared_lib_descr$00 lib:^Cell publishers:(Hashmap 256 True) export function loadLibDescr(slice: Slice): LibDescr { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b00))) { slice.loadUint(2); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let lib: Slice = slice1; let publishers: Hashmap = loadHashmap(slice, 256, loadTrue); return { @@ -8402,14 +8402,14 @@ export function loadBlockInfo(slice: Slice): BlockInfo { let prev_key_block_seqno: number = slice.loadUint(32); let gen_software: GlobalVersion | undefined = ((flags & (1 << 0)) ? loadGlobalVersion(slice) : undefined); let master_ref: BlkMasterInfo | undefined = (not_master ? ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadBlkMasterInfo(slice1) })(slice) : undefined); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prev_ref: BlkPrevInfo = loadBlkPrevInfo(slice1, after_merge); let prev_vert_ref: BlkPrevInfo | undefined = (vert_seqno_incr ? ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadBlkPrevInfo(slice1, 0) })(slice) : undefined); @@ -8517,9 +8517,9 @@ export function loadBlkPrevInfo(slice: Slice, arg0: number): BlkPrevInfo { } if ((arg0 == 1)) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prev1: ExtBlkRef = loadExtBlkRef(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let prev2: ExtBlkRef = loadExtBlkRef(slice2); return { kind: 'BlkPrevInfo_prev_blks_info', @@ -8563,13 +8563,13 @@ export function loadBlock(slice: Slice): Block { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x11ef55aa))) { slice.loadUint(32); let global_id: number = slice.loadInt(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let info: BlockInfo = loadBlockInfo(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let value_flow: ValueFlow = loadValueFlow(slice2); let cell3 = slice.loadRef(); let state_update = cell3; - let slice4 = slice.loadRef().beginParse(); + let slice4 = slice.loadRef().beginParse(true); let extra: BlockExtra = loadBlockExtra(slice4); return { kind: 'Block', @@ -8614,16 +8614,16 @@ block_extra in_msg_descr:^InMsgDescr export function loadBlockExtra(slice: Slice): BlockExtra { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4a33f6fd))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let in_msg_descr: InMsgDescr = loadInMsgDescr(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let out_msg_descr: OutMsgDescr = loadOutMsgDescr(slice2); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let account_blocks: ShardAccountBlocks = loadShardAccountBlocks(slice3); let rand_seed: BitString = slice.loadBits(256); let created_by: BitString = slice.loadBits(256); let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadMcBlockExtra(slice1) })); @@ -8700,13 +8700,13 @@ value_flow_v2#3ebf98b7 ^[ from_prev_blk:CurrencyCollection export function loadValueFlow(slice: Slice): ValueFlow { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0xb8e48dfb))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let from_prev_blk: CurrencyCollection = loadCurrencyCollection(slice1); let to_next_blk: CurrencyCollection = loadCurrencyCollection(slice1); let imported: CurrencyCollection = loadCurrencyCollection(slice1); let exported: CurrencyCollection = loadCurrencyCollection(slice1); let fees_collected: CurrencyCollection = loadCurrencyCollection(slice); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let fees_imported: CurrencyCollection = loadCurrencyCollection(slice2); let recovered: CurrencyCollection = loadCurrencyCollection(slice2); let created: CurrencyCollection = loadCurrencyCollection(slice2); @@ -8727,14 +8727,14 @@ export function loadValueFlow(slice: Slice): ValueFlow { } if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x3ebf98b7))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let from_prev_blk: CurrencyCollection = loadCurrencyCollection(slice1); let to_next_blk: CurrencyCollection = loadCurrencyCollection(slice1); let imported: CurrencyCollection = loadCurrencyCollection(slice1); let exported: CurrencyCollection = loadCurrencyCollection(slice1); let fees_collected: CurrencyCollection = loadCurrencyCollection(slice); let burned: CurrencyCollection = loadCurrencyCollection(slice); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let fees_imported: CurrencyCollection = loadCurrencyCollection(slice2); let recovered: CurrencyCollection = loadCurrencyCollection(slice2); let created: CurrencyCollection = loadCurrencyCollection(slice2); @@ -8819,9 +8819,9 @@ export function loadBinTree(slice: Slice, loadX: (slice: Slice) => X): BinTre } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: BinTree = loadBinTree(slice1, loadX); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: BinTree = loadBinTree(slice2, loadX); return { kind: 'BinTree_bt_fork', @@ -9017,7 +9017,7 @@ export function loadShardDescr(slice: Slice): ShardDescr { let min_ref_mc_seqno: number = slice.loadUint(32); let gen_utime: number = slice.loadUint(32); let split_merge_at: FutureSplitMerge = loadFutureSplitMerge(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let fees_collected: CurrencyCollection = loadCurrencyCollection(slice1); let funds_created: CurrencyCollection = loadCurrencyCollection(slice1); if ((!(flags == 0))) { @@ -9118,7 +9118,7 @@ export function loadShardHashes(slice: Slice): ShardHashes { let anon0: Dictionary> = Dictionary.load(Dictionary.Keys.Uint(32), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadBinTree(slice1, loadShardDescr) }), @@ -9171,9 +9171,9 @@ export function loadBinTreeAug(slice: Slice, loadX: (slice: Slice) => X, l } if (((slice.remainingBits >= 1) && (slice.preloadUint(1) == 0b1))) { slice.loadUint(1); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: BinTreeAug = loadBinTreeAug(slice1, loadX, loadY); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: BinTreeAug = loadBinTreeAug(slice2, loadX, loadY); let extra: Y = loadY(slice); return { @@ -9283,9 +9283,9 @@ _ config_addr:bits256 config:^(Hashmap 32 ^Cell) export function loadConfigParams(slice: Slice): ConfigParams { let config_addr: BitString = slice.loadBits(256); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let config: Hashmap = loadHashmap(slice1, 32, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); @@ -9605,7 +9605,7 @@ export function loadMcStateExtra(slice: Slice): McStateExtra { slice.loadUint(16); let shard_hashes: ShardHashes = loadShardHashes(slice); let config: ConfigParams = loadConfigParams(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let flags: number = slice1.loadUint(16); let validator_info: ValidatorInfo = loadValidatorInfo(slice1); let prev_blocks: OldMcBlocksInfo = loadOldMcBlocksInfo(slice1); @@ -9709,7 +9709,7 @@ chained_signature#f signed_cert:^SignedCertificate temp_key_signature:CryptoSign export function loadCryptoSignature(slice: Slice): CryptoSignature { if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0xf))) { slice.loadUint(4); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let signed_cert: SignedCertificate = loadSignedCertificate(slice1); let temp_key_signature: CryptoSignatureSimple = loadCryptoSignatureSimple(slice); return { @@ -9865,18 +9865,18 @@ export function loadMcBlockExtra(slice: Slice): McBlockExtra { let key_block: number = slice.loadUint(1); let shard_hashes: ShardHashes = loadShardHashes(slice); let shard_fees: ShardFees = loadShardFees(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prev_blk_signatures: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { serialize: () => { throw new Error('Not implemented') }, parse: loadCryptoSignaturePair, }, slice1); let recover_create_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadInMsg(slice1) })); let mint_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadInMsg(slice1) })); @@ -11034,9 +11034,9 @@ export function storeConfigProposalSetup(configProposalSetup: ConfigProposalSetu export function loadConfigVotingSetup(slice: Slice): ConfigVotingSetup { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x91))) { slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let normal_params: ConfigProposalSetup = loadConfigProposalSetup(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let critical_params: ConfigProposalSetup = loadConfigProposalSetup(slice2); return { kind: 'ConfigVotingSetup', @@ -11071,7 +11071,7 @@ export function loadConfigProposal(slice: Slice): ConfigProposal { slice.loadUint(8); let param_id: number = slice.loadInt(32); let param_value: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 })); @@ -11123,7 +11123,7 @@ export function loadConfigProposalStatus(slice: Slice): ConfigProposalStatus { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xce))) { slice.loadUint(8); let expires: number = slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let proposal: ConfigProposal = loadConfigProposal(slice1); let is_critical: boolean = slice.loadBoolean(); let voters: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { @@ -12157,7 +12157,7 @@ export function storeValidatorTempKey(validatorTempKey: ValidatorTempKey): (buil export function loadValidatorSignedTempKey(slice: Slice): ValidatorSignedTempKey { if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0x4))) { slice.loadUint(4); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let key: ValidatorTempKey = loadValidatorTempKey(slice1); let signature: CryptoSignature = loadCryptoSignature(slice); return { @@ -12488,7 +12488,7 @@ export function loadJettonBridgeParams(slice: Slice): JettonBridgeParams { }), }, slice); let state_flags: number = slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prices: JettonBridgePrices = loadJettonBridgePrices(slice1); let external_chain_address: BitString = slice.loadBits(256); return { @@ -12621,10 +12621,10 @@ export function loadBlockProof(slice: Slice): BlockProof { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xc3))) { slice.loadUint(8); let proof_for: BlockIdExt = loadBlockIdExt(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let root: Slice = slice1; let signatures: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadBlockSignatures(slice1) })); @@ -12671,10 +12671,10 @@ export function loadProofChain(slice: Slice, arg0: number): ProofChain { } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let root: Slice = slice1; let prev: ProofChain | undefined = ((arg0 - 1) ? ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadProofChain(slice1, (arg0 - 1)) })(slice) : undefined); @@ -12722,7 +12722,7 @@ export function loadTopBlockDescr(slice: Slice): TopBlockDescr { slice.loadUint(8); let proof_for: BlockIdExt = loadBlockIdExt(slice); let signatures: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadBlockSignatures(slice1) })); @@ -12779,7 +12779,7 @@ export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { let collection: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(96), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTopBlockDescr(slice1) }), @@ -12824,9 +12824,9 @@ export function loadProducerInfo(slice: Slice): ProducerInfo { slice.loadUint(8); let utime: number = slice.loadUint(32); let mc_blk_ref: ExtBlkRef = loadExtBlkRef(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let state_proof: MERKLE_PROOF = loadMERKLE_PROOF(slice1, loadBlock); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let prod_proof: MERKLE_PROOF = loadMERKLE_PROOF(slice2, loadShardState); return { kind: 'ProducerInfo', @@ -12863,7 +12863,7 @@ export function loadComplaintDescr(slice: Slice): ComplaintDescr { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x450e8bd9))) { slice.loadUint(32); let from_utime: number = slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prod_info: ProducerInfo = loadProducerInfo(slice1); return { kind: 'ComplaintDescr_no_blk_gen', @@ -12874,9 +12874,9 @@ export function loadComplaintDescr(slice: Slice): ComplaintDescr { } if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4737b0ca))) { slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let prod_info_old: ProducerInfo = loadProducerInfo(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let prod_info_new: ProducerInfo = loadProducerInfo(slice2); return { kind: 'ComplaintDescr_no_blk_gen_diff', @@ -12920,7 +12920,7 @@ export function loadValidatorComplaint(slice: Slice): ValidatorComplaint { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0xbc))) { slice.loadUint(8); let validator_pubkey: BitString = slice.loadBits(256); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let description: ComplaintDescr = loadComplaintDescr(slice1); let created_at: number = slice.loadUint(32); let severity: number = slice.loadUint(8); @@ -12966,7 +12966,7 @@ export function storeValidatorComplaint(validatorComplaint: ValidatorComplaint): export function loadValidatorComplaintStatus(slice: Slice): ValidatorComplaintStatus { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x2d))) { slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let complaint: ValidatorComplaint = loadValidatorComplaint(slice1); let voters: Dictionary = Dictionary.load(Dictionary.Keys.Uint(16), { serialize: () => { throw new Error('Not implemented') }, @@ -13057,7 +13057,7 @@ export function loadVmStackValue(slice: Slice): VmStackValue { } if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x03))) { slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let _cell: Slice = slice1; return { kind: 'VmStackValue_vm_stk_cell', @@ -13076,7 +13076,7 @@ export function loadVmStackValue(slice: Slice): VmStackValue { } if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x05))) { slice.loadUint(8); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let _cell: Slice = slice1; return { kind: 'VmStackValue_vm_stk_builder', @@ -13183,7 +13183,7 @@ _ cell:^Cell st_bits:(## 10) end_bits:(## 10) { st_bits <= end_bits } */ export function loadVmCellSlice(slice: Slice): VmCellSlice { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let _cell: Slice = slice1; let st_bits: number = slice.loadUint(10); let end_bits: number = slice.loadUint(10); @@ -13239,7 +13239,7 @@ export function loadVmTupleRef(slice: Slice, arg0: number): VmTupleRef { } if ((arg0 == 1)) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let entry: VmStackValue = loadVmStackValue(slice1); return { kind: 'VmTupleRef_vm_tupref_single', @@ -13248,7 +13248,7 @@ export function loadVmTupleRef(slice: Slice, arg0: number): VmTupleRef { } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let ref: VmTuple = loadVmTuple(slice1, ((arg0 - 2) + 2)); return { kind: 'VmTupleRef_vm_tupref_any', @@ -13298,7 +13298,7 @@ export function loadVmTuple(slice: Slice, arg0: number): VmTuple { } if (true) { let head: VmTupleRef = loadVmTupleRef(slice, (arg0 - 1)); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let tail: VmStackValue = loadVmStackValue(slice1); return { kind: 'VmTuple_vm_tuple_tcons', @@ -13362,7 +13362,7 @@ export function loadVmStackList(slice: Slice, arg0: number): VmStackList { } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let rest: VmStackList = loadVmStackList(slice1, (arg0 - 1)); let tos: VmStackValue = loadVmStackValue(slice); return { @@ -13427,7 +13427,7 @@ gas_limits#_ remaining:int64 _:^[ max_limit:int64 cur_limit:int64 credit:int64 ] export function loadVmGasLimits(slice: Slice): VmGasLimits { let remaining: number = slice.loadInt(64); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let max_limit: number = slice1.loadInt(64); let cur_limit: number = slice1.loadInt(64); let credit: number = slice1.loadInt(64); @@ -13459,7 +13459,7 @@ export function loadVmLibraries(slice: Slice): VmLibraries { let libraries: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1 }), @@ -13578,7 +13578,7 @@ export function loadVmCont(slice: Slice): VmCont { if (((slice.remainingBits >= 2) && (slice.preloadUint(2) == 0b01))) { slice.loadUint(2); let cdata: VmControlData = loadVmControlData(slice); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let next: VmCont = loadVmCont(slice1); return { kind: 'VmCont_vmc_envelope', @@ -13606,9 +13606,9 @@ export function loadVmCont(slice: Slice): VmCont { if (((slice.remainingBits >= 5) && (slice.preloadUint(5) == 0b10100))) { slice.loadUint(5); let count: number = slice.loadUint(63); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let body: VmCont = loadVmCont(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let after: VmCont = loadVmCont(slice2); return { kind: 'VmCont_vmc_repeat', @@ -13620,9 +13620,9 @@ export function loadVmCont(slice: Slice): VmCont { } if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110000))) { slice.loadUint(6); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let body: VmCont = loadVmCont(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let after: VmCont = loadVmCont(slice2); return { kind: 'VmCont_vmc_until', @@ -13633,7 +13633,7 @@ export function loadVmCont(slice: Slice): VmCont { } if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110001))) { slice.loadUint(6); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let body: VmCont = loadVmCont(slice1); return { kind: 'VmCont_vmc_again', @@ -13643,11 +13643,11 @@ export function loadVmCont(slice: Slice): VmCont { } if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110010))) { slice.loadUint(6); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let cond: VmCont = loadVmCont(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let body: VmCont = loadVmCont(slice2); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let after: VmCont = loadVmCont(slice3); return { kind: 'VmCont_vmc_while_cond', @@ -13659,11 +13659,11 @@ export function loadVmCont(slice: Slice): VmCont { } if (((slice.remainingBits >= 6) && (slice.preloadUint(6) == 0b110011))) { slice.loadUint(6); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let cond: VmCont = loadVmCont(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let body: VmCont = loadVmCont(slice2); - let slice3 = slice.loadRef().beginParse(); + let slice3 = slice.loadRef().beginParse(true); let after: VmCont = loadVmCont(slice3); return { kind: 'VmCont_vmc_while_body', @@ -13676,7 +13676,7 @@ export function loadVmCont(slice: Slice): VmCont { if (((slice.remainingBits >= 4) && (slice.preloadUint(4) == 0b1111))) { slice.loadUint(4); let value: number = slice.loadInt(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let next: VmCont = loadVmCont(slice1); return { kind: 'VmCont_vmc_pushint', @@ -13803,7 +13803,7 @@ export function loadDNS_RecordSet(slice: Slice): DNS_RecordSet { let anon0: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(256), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadDNSRecord(slice1) }), @@ -13847,7 +13847,7 @@ export function loadTextChunkRef(slice: Slice, arg0: number): TextChunkRef { } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let ref: TextChunks = loadTextChunks(slice1, ((arg0 - 1) + 1)); return { kind: 'TextChunkRef_chunk_ref', @@ -14262,9 +14262,9 @@ export function loadChanConfig(slice: Slice): ChanConfig { let close_timeout: number = slice.loadUint(32); let a_key: BitString = slice.loadBits(256); let b_key: BitString = slice.loadBits(256); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let a_addr: Address = slice1.loadAddress(); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let b_addr: Address = slice2.loadAddress(); let channel_id: number = slice.loadUint(64); let min_A_extra: bigint = slice.loadCoins(); @@ -14429,7 +14429,7 @@ export function storeChanPromise(chanPromise: ChanPromise): (builder: Builder) = export function loadChanSignedPromise(slice: Slice): ChanSignedPromise { let sig: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1.loadBits(512) })); @@ -14554,12 +14554,12 @@ export function storeChanMsg(chanMsg: ChanMsg): (builder: Builder) => void { export function loadChanSignedMsg(slice: Slice): ChanSignedMsg { let sig_A: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1.loadBits(512) })); let sig_B: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1.loadBits(512) })); @@ -14624,9 +14624,9 @@ export function storeChanOp(chanOp: ChanOp): (builder: Builder) => void { // chan_data$_ config:^ChanConfig state:^ChanState = ChanData; export function loadChanData(slice: Slice): ChanData { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let config: ChanConfig = loadChanConfig(slice1); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let state: ChanState = loadChanState(slice2); return { kind: 'ChanData', diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index a3587e6..d850f82 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -1136,7 +1136,7 @@ export function storeComplexTypedField(complexTypedField: ComplexTypedField): (b // a$_ a:^ExprArgUser = CellTypedField; export function loadCellTypedField(slice: Slice): CellTypedField { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let a: ExprArgUser = loadExprArgUser(slice1); return { kind: 'CellTypedField', @@ -1158,16 +1158,16 @@ export function storeCellTypedField(_cellTypedField: CellTypedField): (builder: export function loadCellsSimple(slice: Slice): CellsSimple { let t: number = slice.loadUint(32); - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let q: number = slice1.loadUint(32); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let a: number = slice2.loadUint(32); - let slice21 = slice2.loadRef().beginParse(); + let slice21 = slice2.loadRef().beginParse(true); let e: number = slice21.loadUint(32); - let slice22 = slice2.loadRef().beginParse(); + let slice22 = slice2.loadRef().beginParse(true); let b: number = slice22.loadUint(32); let d: number = slice22.loadUint(32); - let slice221 = slice22.loadRef().beginParse(); + let slice221 = slice22.loadRef().beginParse(true); let c: number = slice221.loadUint(32); return { kind: 'CellsSimple', @@ -1823,19 +1823,19 @@ export function loadCombArgCellRef(slice: Slice, loadX: (slice: Slice) => X): let info: number = slice.loadInt(32); let init: Maybe> = loadMaybe>(slice, ((slice: Slice) => { return loadEither(slice, loadX, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return slice1.loadInt(22) })) })); let other: Either> = loadEither>(slice, loadX, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadOneComb(slice1, loadX) })); let body: Either = loadEither(slice, loadX, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadX(slice1) })); @@ -1917,7 +1917,7 @@ export function storeCombArgCellRefUser(combArgCellRefUser: CombArgCellRefUser): // a$_ {n:#} ref:^(BitLenArg (n + 2)) = MathExprAsCombArg (n + 2); export function loadMathExprAsCombArg(slice: Slice, arg0: number): MathExprAsCombArg { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let ref: BitLenArg = loadBitLenArg(slice1, ((arg0 - 2) + 2)); return { kind: 'MathExprAsCombArg', @@ -2087,9 +2087,9 @@ export function loadHashmapNode(slice: Slice, arg0: number, loadX: (slice: Sl } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: Hashmap = loadHashmap(slice1, (arg0 - 1), loadX); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: Hashmap = loadHashmap(slice2, (arg0 - 1), loadX); return { kind: 'HashmapNode_hmn_fork', @@ -2446,7 +2446,7 @@ export function storeParamNamedArgInSecondConstr(paramNamedArgInSecondConstr: Pa // a$_ msg:^(Maybe Any) = RefCombinatorAny; export function loadRefCombinatorAny(slice: Slice): RefCombinatorAny { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { return slice @@ -2501,7 +2501,7 @@ export function storeEqualityExpression(equalityExpression: EqualityExpression): export function loadConditionalRef(slice: Slice): ConditionalRef { let x: number = slice.loadUint(1); let y: Simple | undefined = (x ? ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadSimple(slice1) })(slice) : undefined); @@ -2708,7 +2708,7 @@ export function storeCheckKeyword(checkKeyword: CheckKeyword): (builder: Builder export function loadRefCombinatorInRefHelper(slice: Slice, loadX: (slice: Slice) => X): RefCombinatorInRefHelper { let t: number = slice.loadUint(32); let y: Maybe = loadMaybe(slice, ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadX(slice1) })); @@ -2739,7 +2739,7 @@ export function storeRefCombinatorInRefHelper(refCombinatorInRefHelper: RefCo // a$_ msg:^(RefCombinatorInRefHelper Any) = RefCombinatorInRef; export function loadRefCombinatorInRef(slice: Slice): RefCombinatorInRef { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let msg: RefCombinatorInRefHelper = loadRefCombinatorInRefHelper(slice1, ((slice: Slice) => { return slice @@ -2971,7 +2971,7 @@ export function loadHashmapTPCell(slice: Slice): HashmapTPCell { let x: Dictionary = Dictionary.load(Dictionary.Keys.BigUint(100), { serialize: () => { throw new Error('Not implemented') }, parse: ((slice: Slice) => { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); return loadTypedParam(slice1) }), @@ -3236,9 +3236,9 @@ export function loadHashmapAugNode(slice: Slice, arg0: number, loadX: (sli } if (true) { - let slice1 = slice.loadRef().beginParse(); + let slice1 = slice.loadRef().beginParse(true); let left: HashmapAug = loadHashmapAug(slice1, (arg0 - 1), loadX, loadY); - let slice2 = slice.loadRef().beginParse(); + let slice2 = slice.loadRef().beginParse(true); let right: HashmapAug = loadHashmapAug(slice2, (arg0 - 1), loadX, loadY); let extra: Y = loadY(slice); return { diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index c04afde..bc66014 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -508,6 +508,8 @@ describe('Generating tlb code', () => { }) test('block tlb tests', () => { + expect.hasAssertions() + const state = 'te6cckEC0QEAF4EABBAR71Wq////EQ4LARoKigRFBc22uwt5FAe5LkwV9/aUCMG3DMEFmhpBL/V+tBDI/gV3bfbEh9X1jahPoZpMXpC6TwToe2oBAiKcJCMWgMzjAhkCGSUCI1uQI6/i////EQAAAAAAAAAAAAAAAAACCJygAAAAAWQpXggAACE4Ni/9xAGyx8EgCgQDAdkAAAAAAAAAAP//////////glm7Tyr7ph7bvcoliLx6hZAAAhODYReUQBssfBAKstMwDM/+WPxY9XNFdU/4cu5AdlJJxlQd/rujBrVRmS8DPQgPzqUD9KMX8as2Dwctu9c04+8yNoUKVi2nVyoIECITgglm7Tyr7ph7cAUQIxMBBLN2nlX3TD24GAYQIxMBAZDm24nj3jYYBywVIxMBAQHXwZPFZ1f4SRIIAgEgoQkAE7////+8hct+TjABEQAAAAAAAAAAUKICEbjkjftDxPT2BA0MAA0AEO5rKAAIAiWCWbtPKwbudNwSzdp5V90w9sAIEBACoJvHqYcAAAAAhAECCJygAAAAAQAAAAAAAAAAAAAAAABkKV4IAAAhODYv/cAAACE4Ni/9xGSeizgABnF2AbLHwQGyxDjEAAAAAwAAAAAAAAAuRg8AmAAAITg2ILuBAgicn5OTTn6kV5z6E216F7w1p7ywI+Wsbfm4l7+fH+PH3tbaRLtCQmSNinuI8RM1X14LJBOd+k8nDROIBcr5XT35BMwCASARFgATvgAAA7yRYnrqkCMTAQCVZm3cySLJmM8TJCITAQBXbLG1sxxLaBSmIhEA7TNAkoCvNMhLqAIBIBcWABO/////vIuW/JxQABO+AAADvJFVjgoQIxMBAyKPwswTbge4RG8ZABGgAAAA7xs7OCQDiUoz9v0AAAAAMhjte0ADZ9Ue4JasekQN2qxAbkcpsPnm3xb+QdycBRLKp6O4P7y5zuVClQ61W4lQ2IB7RVnlRQ3Zf7ntQCAfGwEHnTCbchwCBw6YTbkeHQKkv9hmS6t5x389cc3WraAW8v9u/tHNgS00XoIS5/rCIFutGIBUYWwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WqAAABCcGxf+4ZiAVGF9jAqS/8DbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY4csEcRWBtqDZepDMCpWf6e4TGBEQr1oVdFBVra1hoWmBM4PscoAAAEJwbF/7gnLBHEZWkBAYJdAQmYc4+QICECCQw5x8gQIyICU7/tv+KF5I5D4kmpP2G9Ole4W7PrWAo836gCz/UsR488Shhzj5AZhzj5QHFfAkW/+10YVX8suGLI/VWnKzNQacHbz88tvbzdIeyzKUTUvL6ABGxlABGgAAAA7xhMWuQjW5Ajr+L///8RAAAAAAAAAAAAAAAAAAIInJ8AAAABZCleBQAAITg2ILuBAbLHvyBFJyYoSAEBpRWq+4O2768Q6YgNNGQjmj0oa8zM5VMgwFF0+iWqUqkAAiITgglm7TysG7nTcCgpIxMBBLN2nlYN3Om4LSopKEgBAbPpZJ0QzLN5No6Bo6fo5JyOtT9qzGmwui/6gAgvcO45AAEjEwEBkOba1PLVX/hHLCsoSAEBuwbzUGdFxfamI50TKnCzhDnLYP+V9i5FJhuhLoROiJsAAShIAQFdcwvHm2Gi3vzR5QK6MzZpJ2XoxG6s9cU5A+NecaY2ZQBnIxMBAyKPw4EbB4nYRC8uKEgBAW8xXyW0o5rBLIX+pOz+eoPl5Z0fBZeD+gw+8nlzCIBhAAAjEwEBQHDBzHvk29hwMEojEwEAUApu/uIBspgxd0ojEQD9ZwkwKFUL2DJ5MyMRAPxRfpdfYWL4NHwzKEgBAdesu2AjOMhtYQ81z7Ni/Xb8GLGBJHa2/KmaBnjmZfz1AAAiEQDjkp2cjH78iDXQIhEA4qsjFN6mokg2fyIRAOKYHdmYGycIN4EiEQDh3QxQfyu5CJ04Ig8AxgUbDbsGSJw5Ig8AxR33sLE3CDqFIg8AxHL6Yno2qJs7Ig8AxC6kdAuZaJo8Ig8AxCi4DqgjyD2JIg8AxCCrNzFaaJk+Ig8AxCBpdu+8CJg/Ig8AxB7y0orbaECNIg8AxB7qPeidiJdBIg8AxB7pSOPSiEKQIg9QMQaGMcp2EkOSIZu6g2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HAMQaGHhPJk8fJ/pSBwkG9iigbeI6u0UIcOptjngRxq8d+vVLS6LY0AACE4BYzRwaeKEgBAT3wohgPv4MQ4+vz7gM349tPPFYHsqlZSMuevDm3t4EBAhUoSAEBOxcU0HjSRdQVv8jz/2RdmNPXidHJrEXKTEh77ypybKAAAgCYAAAhODYReUQBssfBAKstMwDM/+WPxY9XNFdU/4cu5AdlJJxlQd/rujBrVRmS8DPQgPzqUD9KMX8as2Dwctu9c04+8yNoUKVi2nVyoCMTAQEB18De1F6B2EmjSChIAQHskKRO7gK+2EDBDog1EWPunjYT652+jadgeD2kSXFOKAABKEgBAeK+z0GLoJJXqHmcgiUmFab+cGE3G05kIzFL1fGvx+7yAGcoSAEB7X4mvTbvptXZtPaqq5gTrwdCqEJEl390/UB0ycmJCL4AACIRAOfckED3AmmoTKoiEQDgKvnhz8sqaE2sIg8AzWFSJqtV6M5OIg8AxY+VQnVA6M1PIg8Aw4VN2Uwz6FCwIg8AwmgbZ7zyCFGyIg8AwLPaWJdUqMxSIg8AwEW+c768iMtTIg8AwCGKXAQqSFS2Ig8AwCAp2uw86FW4Ig0Avii23INoylYiDQCg9iRqgQhXuyINAKD0o/xyaFi9Ig0AoNeOM7+oyVkiDQCg1z9eQuhawCINAKDWv15C6MhbIg0AoNIwddNIx1whmbpq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60BQaOLJc2OxZkrdV5VNejNdZYocwulM6KlsjAputOLtERFZ6SV/oAABCcGxf+4cdANFoBtv+KF5I5D4kmpP2G9Ole4W7PrWAo836gCz/UsR488SgFBxZV4CB2Yc4+VxXwO1ewzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WgAAITg2L/3DbOLcUyYI0cPzAxVFzkG6J7zghhDc9bLr92Oh7WOzkVkAACEogQULwWQpXggAAUYgFRiGRjYAIbDLrdCUFp5hRPWGHj4xFiYQBbwAAAAAAAAAAAAAAAAS1FLaRJ5QuM990nhh8UYSKv4bVGu4tw/IIW8MYUE5+OBACeQHvsPQkAAAAAAAAAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCcqwgKOzuSym5usTshSpMpCr16O7s5bepH1izbp7Xp2Czizf8kNDqAW3uBWuovIThZFt6VZVorL4SzhvSsRKnI0wBAaByA7V2BtqDZepDMCpWf6e4TGBEQr1oVdFBVra1hoWmBM4PscAAAhODYv/cHx8n+lIHCQb2KKBt4jq7RQhw6m2OeBHGrx369UtLotjQAAITgFjNHBZCleCAADRywRxIamlmAhEMgFcGG4cyxEBoZwBvyYrVcEwc47gAAAAAAAIAAAAAAAJGZSaqgI5ubq7EBkS9iYCyLImlfsoM+uTwXHcA6Ll23kCQIEwAnUOc4xOIAAAAAAAAAAAhgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAgnLsg1gBXx7Xxc8sPHDKhgW6z7UHcU5ZMO7TJUYI4hsdeNd1bVzcsM9RXJH+4PoemNCiNrt5WeZxeO791T0M+08OAgHgbGsBAd9yAd2IAMDbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY4BE2TDQHoAPruZj44qfgANmByqblxPjLe/6PijbrlfomSpMKoT4olv46Ec0Oyon/E9itWsVVbgoHiSurUO1mI0HAAAAALIUryEP2V8t5tAQTQA24AukIAWGZLq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60oLTzCiegAAAAAAAAAAAAAAAAAAAAAADk0YjFlMzVkLWYyMGUtNDJkYS04MGU2LWNiM2ZkYWY2YjcwNCMTAQFAcMEXdEtZuHB1dihIAQEzX6VT6kvKa9205IdZXLH1EnzQYt5IxkFRCl98L8aoHQBhAQxGBgMOcfJyAbNIAMDbUGy9SGYFSs/09wmMCIhXrQq6KCrW1rDQtMCZwfY5ACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WlBaeYUT0Bhzj5AAAQnBsX/uEyFK8EMBzAFAAAAAAOTRiMWUzNWQtZjIwZS00MmRhLTgwZTYtY2IzZmRhZjZiNzA0InHACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WiLIWQQyFK8EAAAITg2L/3EUGjiyXNk0DGxSMTAQBQCm5J2mgweHh3dgARoAAAAO8ZEcTMKEgBAStT6er4RaQYeNe/8rQVgaM+C5Ec6gMxWKLQBM/s3OP9ADojEQD9Zwh7ILuJuHp5eyhIAQHGJBxyRx2nxj5LaPE51bQZCvSffkDzMhCsMKvaDnBwrgBfIxEA/FF94lfH4Nh9fHsAEaAAAADvGKfJJChIAQHF0rr8QO139Iq41hqZKErCW8ACJrijYIM1RHpJjqtT8gA4IhEA45Kc54Tlemh+0CIRAOKrIl/XDSAogH8oSAEBT02ni3tLW5UgUljEDbLdnR8ffMmUf/QmI5hnM/54gr0AJSIRAOKYHSSQgaTogoEoSAEBM68Z6oNiYqIE/xCVIXNCO5DHgBCH0v6D8o0IlWLSbt8AJiIRAOHdC5t3kjbonYMiDwDGBGYGIYQonIQiDwDFHUKpF7TohoUoSAEBNB3OA0eOfDTx/kErEufcekh6AE8/s2emeGEsVZlHOG8AGCIPAMRyRVrgtIibhyIPAMQt72xyF0iaiCIPAMQoAwcOoaiKiShIAQGiHAzPwfwORsBp02k9WV3cjFaEUdSQ36sRel1jRCTNJAAUIg8AxB/2L5fYSJmLIg8AxB+0b1Y56JiMIg8AxB49yvFZSI6NKEgBAUZtH4yDm+D0wHPn5Yce9BEfDbMoaajlB1Ud1mN/OtlWAA0iDwDEHjU2Txtol48iDwDEHjRBSlBokZAoSAEBdZZPFv97JSIbVQ4JyJgoDuTkm83nC6jEYDVcwGxoNjIACyIPUDEGWO/kFYqTkihIAQEM+/iVpCeSGVQ7v7SwKOqMLsAP7eS6EZo6dUA/pfUPEAAIIZu6g2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HAMQZY3C1pCVzFHjnW5pCIDMke2Eo0dBFsj0nDOu0KHDzAnsVol79cAACE4Ni/9waUInPABgbag2XqQzAqVn+nuExgREK9aFXRQVa2tYaFpgTOD7HCGIIZwyFK8EAAAITg2L/3DYgyxuFrSFNAoJUBWQAAAAFkKVNZDx4g+gWglbhB38WtcZ5x5JAn5jqXB4f3jyt4GZK2irpzvcQAwJYAE6AyFK8hD9lfLcAoSAEBHgrDQCiPcdY0HrD7MU6zKEzVsG2o7h+uS9pWs8wbnJ8ADChIAQHKxBWQY1y/aOvinbyMXBGKE2NY8M7FwIMOajGn3/DSHAAQKEgBAecXqSOr4K1n8v+a4nkWws/qYIhRZOoeR+i9A/Iu/Zz+ABQoSAEBwLwm5Uey6iIGJ9PifbSXU8cHk7HL4jPeZbCRWeuPvHIAFShIAQGqWL/ZPmD9wOC1butJ0zbkCcW4NbO4mCXgMZLGpgeq5QAXKEgBAVtS27/eOLwtYVWxS0d8zkZ94CVGNHFHaFvO6Zn5UDJUABkoSAEBOCsW8AxTELrth9Wtfx0GfnCzwOhxw7/npgcWWP0PicAAHCJzwAYG2oNl6kMwKlZ/p7hMYERCvWhV0UFWtrWGhaYEzg+xwhiCGcMhSpj4AACE4BYzRw2INDDwnkyTQKCfKEgBATSTTv6zIMNhS6ljIyo9l6Dw2TQ6QRE+qW2FK+Hj3iFKAAEoSAEBlJTRzI7fEvBWcaGpugmSEJbrUIEeGSTsZcPGKfu4CBIABAATvgAAA7yE+MJA0ABrsEAAAAAAAAAAANlj4IAAEJwbF/7hbb/iheSOQ+JJqT9hvTpXuFuz61gKPN+oAs/1LEePPEpAIxMBAJVmbSfYGfN4z6WkKEgBAT6FZvX18rkB8AC7g6PivCJByqd21885qflpQfuAgXmcAAAiEwEAV2yxAMITdUinpihIAQGggxo341fgvkQKy3tnb2FOymbihPqgx8XXa1uwuk/xdgBeIhEA7TM/3Y+mXqipqChIAQHekhfgIk36qC9gwNk/4lpJwJJlrZ+6mgm0xNEwIMuhxAAqIhEA59yPjAX5k4irqihIAQHLtFsOh+u3y+guD+3i0xwpF5AAgcz8NYv3QPwJ8GZ+XAAsIhEA4Cr5LN7CVEitrChIAQHIF3gFICgSZ5FN5CQLsqXEHdeKjdl2VTk72mko9KkK5gAeIg8AzWCdNaJ/yM6uIg8AxY7gUWxqyM2vIg8Aw4SY6ENdyLGwKEgBAcNf5HCvff88cYOGfq4hMLsZQ4rpmN3p5TESjIZeHYfdABoiDwDCZ2Z2tBvos7IoSAEBzB2qFVwzmJ0RM8aZixilBpPTlGx0GtCUi57FA+izvrAAGyIPAMCzJWeOfojMtCIPAMBFCYK15mjLtSIPAMAg1Wr7VCi3tihIAQFwNwR3atIjdJf2/elobh7DuB75ni/SufuFCxxWOBzdhwAUIg0Av3Tp42bIubgoSAEBRX2kAc8o5m/8t/t3sEEMmGqq5/W7d7/F9FIduN6duNkADyINAL1zxdOtSMq6Ig0AoEEzYarovLsoSAEB6XW8yt4T58ElUyuuyJ54dMGtFU0CexVUycIVI3a8c2YADSINAKA/svOcSL69KEgBAUK7MUSjrXWVXuZBYUKlHUKrroQGX+yfWhtNhz7lN8n6AAsiDQCgIp0q6YjJvyINAKAiTlVsyMHAKEgBAXxNBe3bbHX79cjVPvcm8cvZKtPEGQqLP9IzrRkbIfjWAAkiDQCgIc5VbMjIwiILAJ0/bP0ox8Mhl7pq3nHfz1xzdatoBby/27+0c2BLTReghLn+sIgW60BOakUIU2cW4pkwRo4fmBiqLnIN0T3nBDCG562XX7sdD2sdnIrIAAEJRAgoXgzEIm/ACwzJdW847+euObrVtALeX+3f2jmwJaaL0EJc/1hEC3WiLIWOQyEuC4AAAISiBBQvDTmpFCFTQMbFAFEAAAAHKamjF34U6KK3xtVYfJKAXDfvq96k6gufJtm4qCqODWvc6mJQQChIAQH+tf9oIOL/DZSD5+DWLIF9hGeJ+0rlgMh4hm2VnavVwAAHKEgBAUgdtUNfI6DNuGnT4LxXs0enI/3ZDm/o4GHoKSGDln4+AAkoSAEBPGpn9ZfihdTNKNHBnuCU+UJCqd2zuEnF8cCnicSLziUACChIAQGMKLC8jkc1VDLelznZZQAbKi948QotANztzp+kaw4W7QAIKEgBAVMWIkIDHF47BX2a46BlCEEASbT5onV/U/84xeSJyavbABIoSAEBjEEiz61R0H6dN/31qP+jdNbMpw2LOYRARFnHgWqSWNQAFihIAQH7oZuYMFt25/R/rDYjGn6YHeVcFBL0C+pwhZCqt/bUbQAYKEgBAejgWpiIE/DT5RzO8P3ny8oYPEHblFq5UlxWkXAW5QQUAB0oSAEBHEzwo1WeCo4ej1Vob5/vEp/iY9isaWQiUjPKLXSa2F0AJyhIAQG6AR8M/S/UB23zXmBMm80bjwEVWFYt7N0B/gicRJjr1wBlKEgBAZAkBO+kH7fhtV/nPdXl/YhX9N1x4bZfgSrpmy1eIH/CACQY+N7F'; const cs = Cell.fromBase64(state); From f4485953207dd1c68dad4a25e018460a7f2df4a4 Mon Sep 17 00:00:00 2001 From: polyprogrammist Date: Sun, 11 Feb 2024 13:03:27 -0500 Subject: [PATCH 20/28] Change import 'ton' for 'ton-core' --- src/generators/typescript/generator.ts | 2 +- test/generated_files/generated_block.ts | 18 +++++++++--------- test/generated_files/generated_test.ts | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index a38ed0a..4c3d6dc 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")) + tImportDeclaration(id(name), tStringLiteral("ton-core")) ); } addBitLenFunction() { diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 575b3d9..afcad74 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -1,12 +1,12 @@ -import { Builder } from 'ton' -import { Slice } from 'ton' -import { beginCell } from 'ton' -import { BitString } from 'ton' -import { Cell } from 'ton' -import { Address } from 'ton' -import { ExternalAddress } from 'ton' -import { Dictionary } from 'ton' -import { DictionaryValue } from 'ton' +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;; } diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index d850f82..e188afd 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -1,12 +1,12 @@ -import { Builder } from 'ton' -import { Slice } from 'ton' -import { beginCell } from 'ton' -import { BitString } from 'ton' -import { Cell } from 'ton' -import { Address } from 'ton' -import { ExternalAddress } from 'ton' -import { Dictionary } from 'ton' -import { DictionaryValue } from 'ton' +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;; } From 12dd1dd7082a0a633d633aea54e90f48d8a2b089 Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 01:55:31 +0400 Subject: [PATCH 21/28] chore: update @ton-community/tlb-parser@^0.1.2 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3593f42..f6073dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.13", "license": "ISC", "dependencies": { - "@ton-community/tlb-parser": "^0.1.1", + "@ton-community/tlb-parser": "^0.1.2", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", "meow": "^9.0.0", @@ -1009,9 +1009,9 @@ } }, "node_modules/@ton-community/tlb-parser": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@ton-community/tlb-parser/-/tlb-parser-0.1.1.tgz", - "integrity": "sha512-WbtJNhe4OA0FquhM5ADf163roczNnq9b0MAPD7PVmso9gIOiUHRdHtYtAA5dI56MJst0O9g7Sw4nkKQy568MGw==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@ton-community/tlb-parser/-/tlb-parser-0.1.2.tgz", + "integrity": "sha512-Qz3py5un9KWS8jw0bprSGZ45r3czK8NeHoHl+mzYvzavK+4UmcJ5PZRmvgF5lY0MC7+qS+pWKn5LeTyLKPXe8Q==", "dependencies": { "ohm-js": "^16.6.0" }, diff --git a/package.json b/package.json index ecc9611..e9dcc01 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "typescript": "^5.3.3" }, "dependencies": { - "@ton-community/tlb-parser": "^0.1.1", + "@ton-community/tlb-parser": "^0.1.2", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", "meow": "^9.0.0", From 96d5848a9c44ad6b235b047f5e44cca0aa2eec6e Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 01:57:09 +0400 Subject: [PATCH 22/28] refactor: optimize imports --- src/astbuilder/fill_constructors.ts | 2 +- src/astbuilder/handle_field.ts | 2 +- src/astbuilder/handle_type.ts | 2 +- src/astbuilder/utils.ts | 2 +- src/main.ts | 6 ++---- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/astbuilder/fill_constructors.ts b/src/astbuilder/fill_constructors.ts index 23a4047..e058e8c 100644 --- a/src/astbuilder/fill_constructors.ts +++ b/src/astbuilder/fill_constructors.ts @@ -8,7 +8,7 @@ import { NameExpr, NegateExpr, NumberExpr, -} from "@ton-community/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser"; import * as crc32 from "crc-32"; import { TLBBinaryOp, diff --git a/src/astbuilder/handle_field.ts b/src/astbuilder/handle_field.ts index 5e88e4f..17c70b6 100644 --- a/src/astbuilder/handle_field.ts +++ b/src/astbuilder/handle_field.ts @@ -11,7 +11,7 @@ import { FieldNamedDef, MathExpr, NameExpr, -} from "@ton-community/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser"; import { TLBField } from "../ast"; import { getType } from "./handle_type"; import { TLBConstructorBuild, TLBTypeBuild } from "./utils"; diff --git a/src/astbuilder/handle_type.ts b/src/astbuilder/handle_type.ts index 83d0b23..d5e5a92 100644 --- a/src/astbuilder/handle_type.ts +++ b/src/astbuilder/handle_type.ts @@ -9,7 +9,7 @@ import { NegateExpr, NumberExpr, Expression as ParserExpression, -} from "@ton-community/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser"; import { TLBBinaryOp, TLBFieldType, diff --git a/src/astbuilder/utils.ts b/src/astbuilder/utils.ts index 1d530d5..03f891f 100644 --- a/src/astbuilder/utils.ts +++ b/src/astbuilder/utils.ts @@ -5,7 +5,7 @@ import { NegateExpr, NumberExpr, SimpleExpr, -} from "@ton-community/tlb-parser/dist/ast/nodes"; +} from "@ton-community/tlb-parser"; import { TLBBinaryOp, TLBConstructorTag, diff --git a/src/main.ts b/src/main.ts index 60f2f83..aae046b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { Program } from "@ton-community/tlb-parser/dist/ast/nodes"; +import { ast, Program } from "@ton-community/tlb-parser"; import { TLBCode, TLBType } from "./ast"; import { TLBCodeBuild, @@ -9,8 +9,6 @@ import { fillConstructors } from "./astbuilder/fill_constructors"; import { CodeBuilder } from "./generators/CodeBuilder"; import { CodeGenerator, CommonGenDeclaration } from "./generators/generator"; import { TypescriptGenerator } from "./generators/typescript/generator"; - -import { ast } from "@ton-community/tlb-parser"; import fs from 'fs' @@ -83,4 +81,4 @@ export function generateCode(inputPath: string, outputPath: string, resultLangua } } generateCodeWithGenerator(inputPath, outputPath, getGenerator); -} \ No newline at end of file +} From 7e9495a332bd3fb0912d702d64266b4cddf3b6c2 Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:03:55 +0400 Subject: [PATCH 23/28] 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'; From 4eb9e63b1b84bfcd1c5ff32d808ec25dd904d9da Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:35:25 +0400 Subject: [PATCH 24/28] chore: chore update @ton-community/tlb-parser@^0.1.3 --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8dbc013..d6529d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.13", "license": "ISC", "dependencies": { - "@ton-community/tlb-parser": "^0.1.2", + "@ton-community/tlb-parser": "^0.1.3", "@ton/core": "^0.54.0", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", @@ -17,7 +17,7 @@ "ts-jest": "^29.1.1" }, "bin": { - "tlbgen": "build/main.js" + "tlb": "build/main.js" }, "devDependencies": { "@jest/globals": "^29.7.0", @@ -1009,9 +1009,9 @@ } }, "node_modules/@ton-community/tlb-parser": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@ton-community/tlb-parser/-/tlb-parser-0.1.2.tgz", - "integrity": "sha512-Qz3py5un9KWS8jw0bprSGZ45r3czK8NeHoHl+mzYvzavK+4UmcJ5PZRmvgF5lY0MC7+qS+pWKn5LeTyLKPXe8Q==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@ton-community/tlb-parser/-/tlb-parser-0.1.3.tgz", + "integrity": "sha512-1GLlgQTMJzw0l4b0rSuz1PjHxROxfpuJB1/ONxOVvU+At/vZo304pWuYyJHxsXwCLJdaPEVOWSOry8paTsRRJQ==", "dependencies": { "ohm-js": "^16.6.0" }, diff --git a/package.json b/package.json index b48bd8e..869ff6f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@ton/core": "^0.54.0", - "@ton-community/tlb-parser": "^0.1.2", + "@ton-community/tlb-parser": "^0.1.3", "@types/jest": "^29.5.11", "crc-32": "^1.2.2", "meow": "^9.0.0", From c784072a5ea04bd93ccaf8d9c31945742ce6793b Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:42:36 +0400 Subject: [PATCH 25/28] docs: update --- README.md | 14 ++++++++------ package.json | 2 +- test/generated_files/generated_block.ts | 8 ++++---- test/tlb/block.tlb | 6 +++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 87665b2..1b2ae50 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This package uses [TLB-Parser](https://github.com/ton-community/tlb-parser) to g ## Installation ```bash -npm install @polyprogrammist_test/tlbgen +npm install @ton-community/tlb-codegen ``` ## Usage @@ -22,7 +22,7 @@ t$_ x:# y:(uint 5) = A; Then do: ```bash -npx tlbgen example.tlb +npx tlb example.tlb ``` It will create a file called `example.tlb.ts` with the following code: @@ -51,15 +51,15 @@ export function storeA(a: A): (builder: Builder) => void { } ``` -You also can set an output file with `-o` option: `npx tlbgen -o other_file.ts example.tlb`. +You also can set an output file with `-o` option: `npx tlb -o other_file.ts example.tlb`. -One of the examples where you can see various abilities of the tool is [block.tlb](https://github.com/PolyProgrammist/tlbgenerator/blob/master/test/tlb/block.tlb). The generation result for it is [here](https://github.com/PolyProgrammist/tlbgenerator/blob/master/test/generated_files/generated_block.ts). +One of the examples where you can see various abilities of the tool is [block.tlb](https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb). The generation result for it is [here](https://github.com/PolyProgrammist/tlbgenerator/blob/master/test/generated_files/generated_block.ts). ### Node JS Also you can use the tool from inside JS or TS code. ```typescript -import { generateCode } from "@polyprogrammist_test/tlbgen" +import { generateCode } from "@ton-community/tlb-codegen" generateCode('example.tlb', 'example.tlb.ts', "typescript") ``` @@ -80,7 +80,9 @@ Built-in types supported are: - `HashmapE n Value` -> `Dictionary` (or `Dictionary` if n <= 64) (loaded with `Dictionary.load`, stored with `storeDict`) - `HashmapAugE n Value Extra` -> `Dictionary` (or `number` instead of `bigint` if `n <= 64`) (loaded with `Dictionary.load`, stored with `storeDict`) -Please note that the tricky thing here with `HashmapAugE` is that in `TLB` scheme extra is [stored](https://github.com/ton-blockchain/ton/blob/062b7b4a92dd67e32d963cf3f04b8bc97d8b7ed5/crypto/block/block.tlb#L49) not only with values, but in intermediate nodes as well. However `Dictionary` in ton-core doesn't store the intermediate nodes. That is why `HashmapAugE` can be correctly loaded by the generated code, but storing is incorrect. +> Please note that the tricky thing here with `HashmapAugE` is that in `TLB` scheme extra is [stored](https://github.com/ton-blockchain/ton/blob/062b7b4a92dd67e32d963cf3f04b8bc97d8b7ed5/crypto/block/block.tlb#L49) not only with values, but in intermediate nodes as well. However `Dictionary` in [@ton/core](https://github.com/ton-org/ton-core) doesn't store the intermediate nodes. That is why `HashmapAugE` can be correctly loaded by the generated code, but storing is incorrect. + +> Please note that `BinTree` is not supported yet. In the future it will be supported as built-in type `BinTree` from [@ton/core](https://github.com/ton-org/ton-core). ## License diff --git a/package.json b/package.json index 869ff6f..f86b19e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "compile": "tsc" }, "bin": { - "tlbgen": "build/main.js" + "tlb": "build/main.js" }, "keywords": [], "author": "", diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 485ea58..ec701d4 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -1013,7 +1013,7 @@ export interface Transaction { } /* -merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 +!merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 old:^X new:^X = MERKLE_UPDATE X; */ @@ -1036,7 +1036,7 @@ export interface HASH_UPDATE { readonly new_hash: BitString; } -// merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; +// !merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; export interface MERKLE_PROOF { readonly kind: 'MERKLE_PROOF'; @@ -6757,7 +6757,7 @@ export function storeTransaction(transaction: Transaction): (builder: Builder) = } /* -merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 +!merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 old:^X new:^X = MERKLE_UPDATE X; */ @@ -6826,7 +6826,7 @@ export function storeHASH_UPDATE(hASH_UPDATE: HASH_UPDATE, storeX: (x: X) } -// merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; +// !merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; export function loadMERKLE_PROOF(slice: Slice, loadX: (slice: Slice) => X): MERKLE_PROOF { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x03))) { diff --git a/test/tlb/block.tlb b/test/tlb/block.tlb index 5e6c602..4b36f13 100644 --- a/test/tlb/block.tlb +++ b/test/tlb/block.tlb @@ -276,11 +276,11 @@ transaction$0111 account_addr:bits256 lt:uint64 total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account) description:^TransactionDescr = Transaction; -merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 +!merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256 old:^X new:^X = MERKLE_UPDATE X; update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256 = HASH_UPDATE X; -merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; +!merkle_proof#03 {X:Type} virtual_hash:bits256 depth:uint16 virtual_root:^X = MERKLE_PROOF X; acc_trans#5 account_addr:bits256 transactions:(HashmapAug 64 ^Transaction CurrencyCollection) @@ -935,4 +935,4 @@ chan_signed_msg$_ sig_A:(Maybe ^bits512) sig_B:(Maybe ^bits512) msg:ChanMsg = Ch chan_op_cmd#912838d1 msg:ChanSignedMsg = ChanOp; -chan_data$_ config:^ChanConfig state:^ChanState = ChanData; \ No newline at end of file +chan_data$_ config:^ChanConfig state:^ChanState = ChanData; From 90fc50a20b4cab98bbf1a712f2a83c2c9406a5a5 Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:54:17 +0400 Subject: [PATCH 26/28] docs: update --- README.md | 4 ++-- main.ts | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1b2ae50..297d8cc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Then do: npx tlb example.tlb ``` -It will create a file called `example.tlb.ts` with the following code: +It will create a file called `example.ts` with the following code: ```typescript export interface A { readonly kind: 'A'; @@ -60,7 +60,7 @@ Also you can use the tool from inside JS or TS code. ```typescript import { generateCode } from "@ton-community/tlb-codegen" -generateCode('example.tlb', 'example.tlb.ts', "typescript") +generateCode('example.tlb', 'example.ts', "typescript") ``` diff --git a/main.ts b/main.ts index 68d54ce..387a68e 100755 --- a/main.ts +++ b/main.ts @@ -4,11 +4,21 @@ import { generateCode } from './src/main'; const cli = meow(` Usage - $ tlbgen + $ tlb Options - --output, -o Output file, defult = tlbpath + ".ts" + --output, -o Output file, default = tlbpath with .ts extension e.g. ./path/to/file.tlb -> ./path/to/file.ts --language, -l Programming language result. Supported languages: ["typescript"]. Default: "typescript" + + Examples + $ tlb ./path/to/file.tlb + > Output: ./path/to/file.ts + + $ tlb -o ./path/to/output.ts ./path/to/file.tlb + > Output: ./path/to/output.ts + + $ tlb -l typescript ./path/to/file.tlb + > Output: ./path/to/file.ts `, { flags: { output: { @@ -25,7 +35,12 @@ const cli = meow(` let input = cli.input.at(0) if (input) { - let output = input + '.ts' + if (input.match(/\.tlb$/) == null) { + console.error('Input file must have .tlb extension') + process.exit(1) + } + + let output = input.replace('.tlb', '.ts') if (cli.flags.output) { output = cli.flags.output; } From 3df7c61408d98727ecb4241297afba90267773d0 Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:56:38 +0400 Subject: [PATCH 27/28] feat: log after execution --- main.ts | 6 +++--- src/main.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 387a68e..0f09e23 100755 --- a/main.ts +++ b/main.ts @@ -12,13 +12,13 @@ const cli = meow(` Examples $ tlb ./path/to/file.tlb - > Output: ./path/to/file.ts + > Generated code is saved to ./path/to/file.ts $ tlb -o ./path/to/output.ts ./path/to/file.tlb - > Output: ./path/to/output.ts + > Generated code is saved to ./path/to/output.ts $ tlb -l typescript ./path/to/file.tlb - > Output: ./path/to/file.ts + > Generated code is saved to ./path/to/file.ts `, { flags: { output: { diff --git a/src/main.ts b/src/main.ts index aae046b..c7cc107 100644 --- a/src/main.ts +++ b/src/main.ts @@ -70,6 +70,7 @@ export function generateCodeWithGenerator(inputPath: string, outputPath: string, const tree = ast(input) fs.writeFile(outputPath, generateCodeByAST(tree, input, getGenerator), () => { }); + console.log(`Generated code is saved to ${outputPath}`); } export function generateCode(inputPath: string, outputPath: string, resultLanguage: string) { From 731a7b51b50371660c85c8a3c71f3b4ea512b9d7 Mon Sep 17 00:00:00 2001 From: thekiba Date: Mon, 12 Feb 2024 02:57:51 +0400 Subject: [PATCH 28/28] chore: release v1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f86b19e..6cda0c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ton-community/tlb-codegen", - "version": "1.0.13", + "version": "1.0.0", "description": "", "main": "build/index.js", "scripts": {