gen-typescript-from-tolk-dev 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -27
- package/bin/generator.js +1 -13
- package/dist/abi-types.d.ts +169 -0
- package/dist/abi-types.js +8 -0
- package/dist/abi.d.ts +53 -0
- package/dist/abi.js +13 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +122 -0
- package/dist/codegen-ctx.d.ts +66 -0
- package/dist/codegen-ctx.js +108 -0
- package/dist/dynamic-ctx.d.ts +17 -0
- package/dist/dynamic-ctx.js +39 -0
- package/dist/dynamic-debug-print.d.ts +9 -0
- package/{src/dynamic-debug-print.ts → dist/dynamic-debug-print.js} +57 -65
- package/dist/dynamic-get-methods.d.ts +43 -0
- package/dist/dynamic-get-methods.js +451 -0
- package/dist/dynamic-serialization.d.ts +22 -0
- package/dist/dynamic-serialization.js +453 -0
- package/dist/dynamic-validation.d.ts +8 -0
- package/{src/dynamic-validation.ts → dist/dynamic-validation.js} +19 -18
- package/dist/emit-field-defs.d.ts +5 -0
- package/dist/emit-field-defs.js +61 -0
- package/dist/emit-pack-unpack.d.ts +9 -0
- package/dist/emit-pack-unpack.js +296 -0
- package/dist/emit-stack-rw.d.ts +4 -0
- package/dist/emit-stack-rw.js +232 -0
- package/dist/emit-ts-types.d.ts +6 -0
- package/dist/emit-ts-types.js +74 -0
- package/dist/formatting.d.ts +15 -0
- package/{src/formatting.ts → dist/formatting.js} +26 -28
- package/dist/generate-ts-wrappers.d.ts +7 -0
- package/dist/generate-ts-wrappers.js +444 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/out-template.generated.d.ts +1 -0
- package/dist/out-template.generated.js +6 -0
- package/dist/tolk-to-abi.d.ts +2 -0
- package/dist/tolk-to-abi.js +22 -0
- package/dist/types-kernel.d.ts +10 -0
- package/dist/types-kernel.js +212 -0
- package/dist/unsupported-errors.d.ts +28 -0
- package/{src/unsupported-errors.ts → dist/unsupported-errors.js} +33 -39
- package/package.json +73 -27
- package/src/abi-types.ts +0 -157
- package/src/abi.ts +0 -132
- package/src/cli-generate-from-abi-json.ts +0 -21
- package/src/codegen-ctx.ts +0 -115
- package/src/dynamic-ctx.ts +0 -55
- package/src/dynamic-get-methods.ts +0 -454
- package/src/dynamic-serialization.ts +0 -430
- package/src/emit-field-defs.ts +0 -60
- package/src/emit-pack-unpack.ts +0 -280
- package/src/emit-stack-rw.ts +0 -239
- package/src/emit-ts-types.ts +0 -66
- package/src/generate-from-abi-json.ts +0 -22
- package/src/generate-ts-wrappers.ts +0 -477
- package/src/out-template.ts +0 -514
- package/src/tolk-to-abi.ts +0 -5
- package/src/types-kernel.ts +0 -215
- package/tsconfig.json +0 -13
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
3
|
+
// Source of truth: src/out-template.ts
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.OUT_TEMPLATE = void 0;
|
|
6
|
+
exports.OUT_TEMPLATE = "// AUTO-GENERATED, do not edit\n// it's a TypeScript wrapper for a CONTRACT_CLASS_NAME contract in Tolk\n/* eslint-disable */\n\nimport * as c from '@ton/core';\nimport { beginCell, ContractProvider, Sender, SendMode } from '@ton/core';\n\n// ————————————————————————————————————————————\n// predefined types and functions\n//\n\n// {{if:has_remaining}}\ntype RemainingBitsAndRefs = c.Slice\n// {{/if:has_remaining}}\n\n// {{if:has_addressAny}}\nexport type any_address = c.Address | c.ExternalAddress | 'none'\n// {{/if:has_addressAny}}\n\n// {{if:has_arrayOf}}\ntype array<T> = T[]\n// {{/if:has_arrayOf}}\n\n// {{if:has_lispListOf}}\n// TypeScript wrappers flatten a TVM linked list `[1 [2 [3 null]]]` to `[1 2 3]`\ntype lisp_list<T> = T[]\n// {{/if:has_lispListOf}}\n\ntype StoreCallback<T> = (obj: T, b: c.Builder) => void\ntype LoadCallback<T> = (s: c.Slice) => T\n\nexport type CellRef<T> = {\n ref: T\n}\n\nfunction makeCellFrom<T>(self: T, storeFn_T: StoreCallback<T>): c.Cell {\n let b = beginCell();\n storeFn_T(self, b);\n return b.endCell();\n}\n\nfunction loadAndCheckPrefix32(s: c.Slice, expected: number, structName: string): void {\n let prefix = s.loadUint(32);\n if (prefix !== expected) {\n throw new Error(`Incorrect prefix for '${structName}': expected 0x${expected.toString(16).padStart(8, '0')}, got 0x${prefix.toString(16).padStart(8, '0')}`);\n }\n}\n\n// {{if:has_non32Prefixes}}\nfunction formatPrefix(prefixNum: number, prefixLen: number): string {\n return prefixLen % 4 ? `0b${prefixNum.toString(2).padStart(prefixLen, '0')}` : `0x${prefixNum.toString(16).padStart(prefixLen / 4, '0')}`;\n}\n\nfunction loadAndCheckPrefix(s: c.Slice, expected: number, prefixLen: number, structName: string): void {\n let prefix = s.loadUint(prefixLen);\n if (prefix !== expected) {\n throw new Error(`Incorrect prefix for '${structName}': expected ${formatPrefix(expected, prefixLen)}, got ${formatPrefix(prefix, prefixLen)}`);\n }\n}\n// {{/if:has_non32Prefixes}}\n\nfunction lookupPrefix(s: c.Slice, expected: number, prefixLen: number): boolean {\n return s.remainingBits >= prefixLen && s.preloadUint(prefixLen) === expected;\n}\n\n// {{if:has_implicitUnionPrefix}}\nfunction lookupPrefixAndEat(s: c.Slice, expected: number, prefixLen: number): boolean {\n if (lookupPrefix(s, expected, prefixLen)) {\n s.skip(prefixLen);\n return true;\n }\n return false;\n}\n// {{/if:has_implicitUnionPrefix}}\n\nfunction throwNonePrefixMatch(fieldPath: string): never {\n throw new Error(`Incorrect prefix for '${fieldPath}': none of variants matched`);\n}\n\nfunction storeCellRef<T>(cell: CellRef<T>, b: c.Builder, storeFn_T: StoreCallback<T>): void {\n let b_ref = c.beginCell();\n storeFn_T(cell.ref, b_ref);\n b.storeRef(b_ref.endCell());\n}\n\nfunction loadCellRef<T>(s: c.Slice, loadFn_T: LoadCallback<T>): CellRef<T> {\n let s_ref = s.loadRef().beginParse();\n return { ref: loadFn_T(s_ref) };\n}\n\n// {{if:has_addressAny}}\nfunction storeTolkAddressAny(a: any_address, b: c.Builder): void {\n let maybe_addr = a === 'none' ? null : a;\n b.storeAddress(maybe_addr);\n}\n\nfunction loadTolkAddressAny(s: c.Slice): any_address {\n let maybe_addr = s.loadAddressAny();\n return maybe_addr === null ? 'none' : maybe_addr;\n}\n// {{/if:has_addressAny}}\n\n// {{if:has_bitsN}}\nfunction storeTolkBitsN(v: c.Slice, nBits: number, b: c.Builder): void {\n if (v.remainingBits !== nBits) { throw new Error(`expected ${nBits} bits, got ${v.remainingBits}`); }\n if (v.remainingRefs !== 0) { throw new Error(`expected 0 refs, got ${v.remainingRefs}`); }\n b.storeSlice(v);\n}\n\nfunction loadTolkBitsN(s: c.Slice, nBits: number): c.Slice {\n return new c.Slice(new c.BitReader(s.loadBits(nBits)), []);\n}\n// {{/if:has_bitsN}}\n\n// {{if:has_remaining}}\nfunction storeTolkRemaining(v: RemainingBitsAndRefs, b: c.Builder): void {\n b.storeSlice(v);\n}\n\nfunction loadTolkRemaining(s: c.Slice): RemainingBitsAndRefs {\n let rest = s.clone();\n s.loadBits(s.remainingBits);\n while (s.remainingRefs) {\n s.loadRef();\n }\n return rest;\n}\n// {{/if:has_remaining}}\n\nfunction storeTolkNullable<T>(v: T | null, b: c.Builder, storeFn_T: StoreCallback<T>): void {\n if (v === null) {\n b.storeUint(0, 1);\n } else {\n b.storeUint(1, 1);\n storeFn_T(v, b);\n }\n}\n\n// {{if:has_arrayOf}}\nfunction storeArrayOf<T>(v: array<T>, b: c.Builder, storeFn_T: StoreCallback<T>): void {\n // the compiler stores array<T> in chunks; in TypeScript, for simplicity, store \"1 elem = 1 ref\"\n let tail = null as c.Cell | null;\n for (let i = 0; i < v.length; ++i) {\n let chunkB = beginCell().storeMaybeRef(tail);\n storeFn_T(v[v.length - 1 - i], chunkB);\n tail = chunkB.endCell();\n }\n b.storeUint(v.length, 8);\n b.storeMaybeRef(tail);\n}\n\nfunction loadArrayOf<T>(s: c.Slice, loadFn_T: LoadCallback<T>): array<T> {\n let len = s.loadUint(8);\n let head = s.loadMaybeRef();\n let outArr = [] as array<T>;\n while (head != null) {\n let s = head.beginParse();\n head = s.loadMaybeRef();\n while (s.remainingBits || s.remainingRefs) {\n outArr.push(loadFn_T(s));\n }\n }\n if (len !== outArr.length) {\n throw new Error(`mismatch array binary data: expected ${len} elements, got ${outArr.length}`);\n }\n return outArr;\n}\n// {{/if:has_arrayOf}}\n\n// {{if:has_lispListOf}}\nfunction storeLispListOf<T>(v: lisp_list<T>, b: c.Builder, storeFn_T: StoreCallback<T>): void {\n let tail = c.Cell.EMPTY;\n for (let i = 0; i < v.length; ++i) {\n let itemB = beginCell();\n storeFn_T(v[i], itemB);\n tail = itemB.storeRef(tail).endCell();\n }\n b.storeRef(tail);\n}\n\nfunction loadLispListOf<T>(s: c.Slice, loadFn_T: LoadCallback<T>): lisp_list<T> {\n let outArr = [] as lisp_list<T>;\n let head = s.loadRef().beginParse();\n while (head.remainingRefs) {\n let tailSnaked = head.loadRef();\n let headValue = loadFn_T(head);\n head.endParse(); // ensure no data is present besides T\n outArr.unshift(headValue);\n head = tailSnaked.beginParse();\n }\n return outArr;\n}\n// {{/if:has_lispListOf}}\n\n// {{if:has_customDictV}}\nfunction createDictionaryValue<V>(loadFn_V: LoadCallback<V>, storeFn_V: StoreCallback<V>): c.DictionaryValue<V> {\n return {\n serialize(self: V, b: c.Builder) {\n storeFn_V(self, b);\n },\n parse(s: c.Slice): V {\n const value = loadFn_V(s);\n s.endParse();\n return value;\n }\n }\n}\n// {{/if:has_customDictV}}\n\n// ————————————————————————————————————————————\n// parse get methods result from a TVM stack\n//\n\nclass StackReader {\n constructor(private tuple: c.TupleItem[]) {\n }\n\n static fromGetMethod(expectedN: number, getMethodResult: { stack: c.TupleReader }): StackReader {\n let tuple = [] as c.TupleItem[];\n while (getMethodResult.stack.remaining) {\n tuple.push(getMethodResult.stack.pop());\n }\n if (tuple.length !== expectedN) {\n throw new Error(`expected ${expectedN} stack width, got ${tuple.length}`);\n }\n return new StackReader(tuple);\n }\n\n private popExpecting<ItemT>(itemType: string): ItemT {\n const item = this.tuple.shift();\n if (item?.type !== itemType) {\n throw new Error(`not '${itemType}' on a stack`);\n }\n return item as ItemT;\n }\n\n readBigInt(): bigint {\n return this.popExpecting<c.TupleItemInt>('int').value;\n }\n\n readBoolean(): boolean {\n return this.popExpecting<c.TupleItemInt>('int').value !== 0n;\n }\n\n readCell(): c.Cell {\n return this.popExpecting<c.TupleItemCell>('cell').cell;\n }\n\n readSlice(): c.Slice {\n return this.popExpecting<c.TupleItemSlice>('slice').cell.beginParse();\n }\n\n // {{if:stackReadsBuilder}}\n readBuilder(): c.Builder {\n return beginCell().storeSlice(this.popExpecting<c.TupleItemBuilder>('builder').cell.beginParse());\n }\n // {{/if:stackReadsBuilder}}\n\n // {{if:stackReadsUnknown}}\n readUnknown(): c.TupleItem {\n // `unknown` from Tolk is left as a raw tuple item\n return this.tuple.shift()!;\n }\n // {{/if:stackReadsUnknown}}\n\n // {{if:stackReadsArrayOf}}\n readArrayOf<T>(readFn_T: (nestedReader: StackReader) => T): T[] {\n const subItems = this.popExpecting<c.Tuple>('tuple').items;\n const subReader = new StackReader(subItems);\n // array len N => N subItems => N calls to readFn_T\n return [...subItems].map(_ => readFn_T(subReader));\n }\n // {{/if:stackReadsArrayOf}}\n\n // {{if:stackReadsLispListOf}}\n readLispListOf<T>(readFn_T: (nestedReader: StackReader) => T): T[] {\n // read `[1 [2 [3 null]]]` to `[1 2 3]`\n let pairReader: StackReader = this;\n let outArr = [] as T[];\n while (true) {\n if (pairReader.tuple[0].type === 'null') {\n pairReader.tuple.shift();\n break;\n }\n let headAndTail = pairReader.popExpecting<c.Tuple>('tuple').items;\n if (headAndTail.length !== 2) {\n throw new Error(`malformed lisp_list, expected 2 stack width, got ${headAndTail.length}`);\n }\n pairReader = new StackReader(headAndTail);\n outArr.push(readFn_T(pairReader));\n }\n return outArr;\n }\n // {{/if:stackReadsLispListOf}}\n\n // {{if:stackReadsSnakeString}}\n readSnakeString(): string {\n return this.readCell().beginParse().loadStringTail();\n }\n // {{/if:stackReadsSnakeString}}\n\n // {{if:stackReadsTuple}}\n readTuple<T>(expectedN: number, readFn_T: (nestedReader: StackReader) => T): T {\n const subItems = this.popExpecting<c.Tuple>('tuple').items;\n if (subItems.length !== expectedN) {\n throw new Error(`expected ${expectedN} items in a tuple, got ${subItems.length}`);\n }\n return readFn_T(new StackReader(subItems));\n }\n // {{/if:stackReadsTuple}}\n\n // {{if:stackReadsNullLiteral}}\n readNullLiteral(): null {\n this.popExpecting<c.TupleItemNull>('null');\n return null;\n }\n // {{/if:stackReadsNullLiteral}}\n\n // {{if:stackReadsNullable}}\n readNullable<T>(readFn_T: (r: StackReader) => T): T | null {\n if (this.tuple[0].type === 'null') {\n this.tuple.shift();\n return null;\n }\n return readFn_T(this);\n }\n // {{/if:stackReadsNullable}}\n\n // {{if:stackReadsWideNullable}}\n readWideNullable<T>(stackW: number, readFn_T: (r: StackReader) => T): T | null {\n const slotTypeId = this.tuple[stackW - 1];\n if (slotTypeId?.type !== 'int') {\n throw new Error(`not 'int' on a stack`);\n }\n if (slotTypeId.value === 0n) {\n this.tuple = this.tuple.slice(stackW);\n return null;\n }\n const valueT = readFn_T(this);\n this.tuple.shift();\n return valueT;\n }\n // {{/if:stackReadsWideNullable}}\n\n // {{if:stackReadsUnionType}}\n readUnionType<T>(stackW: number, infoForTypeId: Record<number, [number, string | null, (r: StackReader) => any]>): T {\n const slotTypeId = this.tuple[stackW - 1];\n if (slotTypeId?.type !== 'int') {\n throw new Error(`not 'int' on a stack`);\n }\n const info = infoForTypeId[Number(slotTypeId.value)]; // [stackWidth, label, readFn_T{i}]\n if (info == null) {\n throw new Error(`unexpected UTag=${slotTypeId.value}`);\n }\n const label = info[1];\n this.tuple = this.tuple.slice(stackW - 1 - info[0]);\n const valueT = info[2](this);\n this.tuple.shift();\n return label == null ? valueT : { $: label, value: valueT } as T;\n }\n // {{/if:stackReadsUnionType}}\n\n // {{if:stackReadsCellRef}}\n readCellRef<T>(loadFn_T: LoadCallback<T>): CellRef<T> {\n return { ref: loadFn_T(this.readCell().beginParse()) };\n }\n // {{/if:stackReadsCellRef}}\n\n // {{if:stackReadsMapKV}}\n readDictionary<K extends c.DictionaryKeyTypes, V>(keySerializer: c.DictionaryKey<K>, valueSerializer: c.DictionaryValue<V>): c.Dictionary<K, V> {\n if (this.tuple[0].type === 'null') {\n this.tuple.shift();\n return c.Dictionary.empty<K, V>(keySerializer, valueSerializer);\n }\n return c.Dictionary.loadDirect<K, V>(keySerializer, valueSerializer, this.readCell());\n }\n // {{/if:stackReadsMapKV}}\n}\n\n// {{if:has_customPackUnpack}}\n// ————————————————————————————————————————————\n// custom packToBuilder and unpackFromSlice\n//\n\ntype CustomPackToBuilderFn<T> = (self: T, b: c.Builder) => void\ntype CustomUnpackFromSliceFn<T> = (s: c.Slice) => T\n\nlet customSerializersRegistry: Map<string, [CustomPackToBuilderFn<any> | null, CustomUnpackFromSliceFn<any> | null]> = new Map;\n\nfunction ensureCustomSerializerRegistered(typeName: string) {\n if (!customSerializersRegistry.has(typeName)) {\n throw new Error(`Custom packToBuilder/unpackFromSlice was not registered for type 'CONTRACT_CLASS_NAME.${typeName}'.\\n(in Tolk code, they have custom logic \\`fun ${typeName}__packToBuilder\\`)\\nSteps to fix:\\n1) in your code, create and implement\\n > function ${typeName}__packToBuilder(self: ${typeName}, b: Builder): void { ... }\\n > function ${typeName}__unpackFromSlice(s: Slice): ${typeName} { ... }\\n2) register them in advance by calling\\n > CONTRACT_CLASS_NAME.registerCustomPackUnpack('${typeName}', ${typeName}__packToBuilder, ${typeName}__unpackFromSlice);`);\n }\n}\n\nfunction invokeCustomPackToBuilder<T>(typeName: string, self: T, b: c.Builder) {\n ensureCustomSerializerRegistered(typeName);\n customSerializersRegistry.get(typeName)![0]!(self, b);\n}\n\nfunction invokeCustomUnpackFromSlice<T>(typeName: string, s: c.Slice): T {\n ensureCustomSerializerRegistered(typeName);\n return customSerializersRegistry.get(typeName)![1]!(s);\n}\n// {{/if:has_customPackUnpack}}\n\n// ————————————————————————————————————————————\n// auto-generated serializers to/from cells\n//\n\ntype coins = bigint\n\n// {{intNAliases}}\n\n// {{uintNAliases}}\n\n// {{if:has_varIntN}}\n// {{varIntNAliases}}\n// {{/if:has_varIntN}}\n\n// {{if:has_bitsN}}\n// {{sliceAliases}}\n// {{/if:has_bitsN}}\n\n// {{packUnpackSerializers}}\n\n// ————————————————————————————————————————————\n// class CONTRACT_CLASS_NAME\n//\n\ninterface ExtraSendOptions {\n bounce?: boolean // default: false\n sendMode?: SendMode // default: SendMode.PAY_GAS_SEPARATELY\n extraCurrencies?: c.ExtraCurrency // default: empty dict\n}\n\ninterface DeployedAddrOptions {\n workchain?: number // default: 0 (basechain)\n toShard?: { fixedPrefixLength: number; closeTo: c.Address }\n overrideContractCode?: c.Cell\n}\n\nfunction calculateDeployedAddress(code: c.Cell, data: c.Cell, options: DeployedAddrOptions): c.Address {\n const stateInitCell = beginCell().store(c.storeStateInit({\n code,\n data,\n splitDepth: options.toShard?.fixedPrefixLength,\n special: null, // todo will somebody need special?\n libraries: null, // todo will somebody need libraries?\n })).endCell();\n\n let addrHash = stateInitCell.hash();\n if (options.toShard) {\n const shardDepth = options.toShard.fixedPrefixLength;\n addrHash = beginCell() // todo any way to do it better? N bits from closeTo + 256-N from stateInitCell\n .storeBits(new c.BitString(options.toShard.closeTo.hash, 0, shardDepth))\n .storeBits(new c.BitString(stateInitCell.hash(), shardDepth, 256 - shardDepth))\n .endCell()\n .beginParse().loadBuffer(32);\n }\n\n return new c.Address(options.workchain ?? 0, addrHash);\n}\n\nexport class CONTRACT_CLASS_NAME implements c.Contract {\n static CodeCell = c.Cell.fromBase64('{{codeBoc64}}');\n\n static Errors = {\n // {{errorCodes}}\n }\n\n readonly address: c.Address\n readonly init?: { code: c.Cell, data: c.Cell }\n\n private constructor(address: c.Address, init?: { code: c.Cell, data: c.Cell }) {\n this.address = address;\n this.init = init;\n }\n\n // {{if:has_customPackUnpack}}\n static registerCustomPackUnpack<T>(\n typeName: string,\n packToBuilderFn: CustomPackToBuilderFn<T> | null,\n unpackFromSliceFn: CustomUnpackFromSliceFn<T> | null,\n ) {\n if (customSerializersRegistry.has(typeName)) {\n throw new Error(`Custom pack/unpack for 'CONTRACT_CLASS_NAME.${typeName}' already registered`);\n }\n customSerializersRegistry.set(typeName, [packToBuilderFn, unpackFromSliceFn]);\n }\n // {{/if:has_customPackUnpack}}\n\n static fromAddress(address: c.Address) {\n return new CONTRACT_CLASS_NAME(address);\n }\n\n // {{fromStorageMethod}}\n\n // {{createCellsMethods}}\n\n // {{if:has_sendDeploy}}\n async sendDeploy(provider: ContractProvider, via: Sender, msgValue: coins, extraOptions?: ExtraSendOptions) {\n return provider.internal(via, {\n value: msgValue,\n body: c.Cell.EMPTY,\n ...extraOptions\n });\n }\n // {{/if:has_sendDeploy}}\n\n // {{sendMethods}}\n\n // {{getMethods}}\n}\n";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertTolkFileToABI = convertTolkFileToABI;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const tolk_js_1 = require("@ton/tolk-js");
|
|
9
|
+
// This function is used ONLY for development (when tolk-js is installed),
|
|
10
|
+
// it is not exposed as public API.
|
|
11
|
+
async function convertTolkFileToABI(absFileName) {
|
|
12
|
+
let compileResult = await (0, tolk_js_1.runTolkCompiler)({
|
|
13
|
+
entrypointFileName: absFileName,
|
|
14
|
+
fsReadCallback: path => fs_1.default.readFileSync(path, 'utf-8'),
|
|
15
|
+
});
|
|
16
|
+
if (compileResult.status === 'error') {
|
|
17
|
+
throw new Error(`Can not compile with tolk-js: ${compileResult.message}`);
|
|
18
|
+
}
|
|
19
|
+
let json = compileResult.abiJson;
|
|
20
|
+
json.codeBoc64 = compileResult.codeBoc64;
|
|
21
|
+
return json;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Ty, UnionVariant } from './abi-types';
|
|
2
|
+
import { SymTable } from './codegen-ctx';
|
|
3
|
+
export declare function renderTy(ty: Ty): string;
|
|
4
|
+
export interface UnionVariantLabeled extends UnionVariant {
|
|
5
|
+
labelStr: string;
|
|
6
|
+
hasValueField: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createLabelsForUnion(symbols: SymTable, variants: UnionVariant[]): UnionVariantLabeled[];
|
|
9
|
+
export declare function instantiateGenerics(ty: Ty, typeParams: string[] | undefined, typeArgs: Ty[]): Ty;
|
|
10
|
+
export declare function calcWidthOnStack(symbols: SymTable, ty: Ty): number;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderTy = renderTy;
|
|
4
|
+
exports.createLabelsForUnion = createLabelsForUnion;
|
|
5
|
+
exports.instantiateGenerics = instantiateGenerics;
|
|
6
|
+
exports.calcWidthOnStack = calcWidthOnStack;
|
|
7
|
+
/*
|
|
8
|
+
Contains basic functions working with ABI types,
|
|
9
|
+
which are used both for generating wrappers and dynamic serialization.
|
|
10
|
+
They do not emit TypeScript expressions and do not depend on CodegenCtx and DynamicCtx.
|
|
11
|
+
*/
|
|
12
|
+
// Render intermediate representation back to a valid Tolk type, exactly as it was in original sources.
|
|
13
|
+
function renderTy(ty) {
|
|
14
|
+
switch (ty.kind) {
|
|
15
|
+
case 'int': return `int`;
|
|
16
|
+
case 'intN': return `int${ty.n}`;
|
|
17
|
+
case 'uintN': return `uint${ty.n}`;
|
|
18
|
+
case 'varintN': return `varint${ty.n}`;
|
|
19
|
+
case 'varuintN': return `varuint${ty.n}`;
|
|
20
|
+
case 'coins': return `coins`;
|
|
21
|
+
case 'bool': return `bool`;
|
|
22
|
+
case 'cell': return `cell`;
|
|
23
|
+
case 'builder': return `builder`;
|
|
24
|
+
case 'slice': return `slice`;
|
|
25
|
+
case 'string': return `string`;
|
|
26
|
+
case 'remaining': return `RemainingBitsAndRefs`;
|
|
27
|
+
case 'address': return `address`;
|
|
28
|
+
case 'addressOpt': return `address?`;
|
|
29
|
+
case 'addressExt': return `ext_address`;
|
|
30
|
+
case 'addressAny': return `any_address`;
|
|
31
|
+
case 'bitsN': return `bits${ty.n}`;
|
|
32
|
+
case 'nullLiteral': return `null`;
|
|
33
|
+
case 'callable': return `continuation`;
|
|
34
|
+
case 'void': return `void`;
|
|
35
|
+
case 'unknown': return `unknown`;
|
|
36
|
+
case 'nullable': return `${renderTy(ty.inner)}?`;
|
|
37
|
+
case 'cellOf': return `Cell<${renderTy(ty.inner)}>`;
|
|
38
|
+
case 'arrayOf': return `array<${renderTy(ty.inner)}>`;
|
|
39
|
+
case 'lispListOf': return `lisp_list<${renderTy(ty.inner)}>`;
|
|
40
|
+
case 'tensor': return `(${ty.items.map(renderTy).join(', ')})`;
|
|
41
|
+
case 'shapedTuple': return `[${ty.items.map(renderTy).join(', ')}]`;
|
|
42
|
+
case 'mapKV': return `map<${renderTy(ty.k)}, ${renderTy(ty.v)}>`;
|
|
43
|
+
case 'EnumRef': return ty.enum_name;
|
|
44
|
+
case 'StructRef': return ty.struct_name + (ty.type_args ? `<${ty.type_args.map(renderTy).join(', ')}>` : '');
|
|
45
|
+
case 'AliasRef': return ty.alias_name + (ty.type_args ? `<${ty.type_args.map(renderTy).join(', ')}>` : '');
|
|
46
|
+
case 'genericT': return ty.name_t;
|
|
47
|
+
case 'union': return ty.variants.map(v => renderTy(v.variant_ty)).join(' | ');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// A "label" is the `$` field in TypeScript output, used to differentiate structs and union variants.
|
|
51
|
+
// Tolk `int32 | int64` -> TS `{ $: 'int32', value: bigint } | { $: 'int64', value: bigint }`.
|
|
52
|
+
// This function creates a string for `$`.
|
|
53
|
+
function createLabel(symbols, ty) {
|
|
54
|
+
switch (ty.kind) {
|
|
55
|
+
case 'int': return `int`;
|
|
56
|
+
case 'intN': return `int${ty.n}`;
|
|
57
|
+
case 'uintN': return `uint${ty.n}`;
|
|
58
|
+
case 'varintN': return `varint${ty.n}`;
|
|
59
|
+
case 'varuintN': return `varuint${ty.n}`;
|
|
60
|
+
case 'coins': return `coins`;
|
|
61
|
+
case 'bool': return `bool`;
|
|
62
|
+
case 'cell': return `cell`;
|
|
63
|
+
case 'builder': return `builder`;
|
|
64
|
+
case 'slice': return `slice`;
|
|
65
|
+
case 'string': return `string`;
|
|
66
|
+
case 'remaining': return `RemainingBitsAndRefs`;
|
|
67
|
+
case 'address': return `address`;
|
|
68
|
+
case 'addressOpt': return `address?`;
|
|
69
|
+
case 'addressExt': return `ext_address`;
|
|
70
|
+
case 'addressAny': return `any_address`;
|
|
71
|
+
case 'bitsN': return `bits${ty.n}`;
|
|
72
|
+
case 'nullLiteral': return `null`;
|
|
73
|
+
case 'callable': return `callable`;
|
|
74
|
+
case 'void': return `void`;
|
|
75
|
+
case 'unknown': return `unknown`;
|
|
76
|
+
case 'nullable': return `${createLabel(symbols, ty.inner)}?`;
|
|
77
|
+
case 'cellOf': return `Cell`;
|
|
78
|
+
case 'arrayOf': return `array`;
|
|
79
|
+
case 'lispListOf': return `lisp_list`;
|
|
80
|
+
case 'tensor': return `tensor`;
|
|
81
|
+
case 'shapedTuple': return `shaped`;
|
|
82
|
+
case 'mapKV': return `map`;
|
|
83
|
+
case 'EnumRef': return ty.enum_name;
|
|
84
|
+
case 'StructRef': return ty.struct_name;
|
|
85
|
+
case 'AliasRef': return createLabel(symbols, symbols.getAliasTarget(ty.alias_name));
|
|
86
|
+
case 'genericT': return ty.name_t;
|
|
87
|
+
case 'union': return ty.variants.map(v => createLabel(symbols, v.variant_ty)).join('|');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Every Tolk struct is generated as TS `interface` with `$` field.
|
|
91
|
+
// Tolk `struct A { ... }` -> TS `interface A { $: 'A', ... }`.
|
|
92
|
+
// So, Tolk `A | B` is represented as TS `A | B` (unlike primitives),
|
|
93
|
+
// because every struct has its own label.
|
|
94
|
+
function isStructWithItsOwnLabel(symbols, ty) {
|
|
95
|
+
if (ty.kind === 'StructRef')
|
|
96
|
+
return true;
|
|
97
|
+
if (ty.kind === 'AliasRef')
|
|
98
|
+
return isStructWithItsOwnLabel(symbols, symbols.getAliasTarget(ty.alias_name));
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
// Given a union `T1 | T2 | ...`, calculate a TypeScript representation:
|
|
102
|
+
// whether each variant should be `$ + value` or not, and what string does `$` hold.
|
|
103
|
+
function createLabelsForUnion(symbols, variants) {
|
|
104
|
+
// in all practical cases, `T_i` is a structure or a primitive;
|
|
105
|
+
// we try to shorten a label (`createLabel()` is a "simple string of a type"):
|
|
106
|
+
// - for a generic struct, use `Wrapper`, not `Wrapper<xxx>`
|
|
107
|
+
// - for `Cell<...>`, use a shorthand `Cell`
|
|
108
|
+
// - etc.
|
|
109
|
+
// but if it results in a duplicate (e.g. `Wrapper<int32> | Wrapper<int64>` => ['Wrapper','Wrapper']),
|
|
110
|
+
// then full-string Tolk types are used, and `value` is always required:
|
|
111
|
+
// `type U = { $: 'Wrapper<int32>', value: Wrapper<int32> } | ...`
|
|
112
|
+
let unique = new Set();
|
|
113
|
+
let hasDuplicates = false;
|
|
114
|
+
variants.forEach(variant => {
|
|
115
|
+
let labelStr = createLabel(symbols, variant.variant_ty);
|
|
116
|
+
hasDuplicates || (hasDuplicates = unique.has(labelStr));
|
|
117
|
+
unique.add(labelStr);
|
|
118
|
+
});
|
|
119
|
+
return variants.map(variant => {
|
|
120
|
+
let variantTy = variant.variant_ty;
|
|
121
|
+
if (variantTy.kind === 'nullLiteral') {
|
|
122
|
+
return { ...variant, labelStr: '', hasValueField: false };
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...variant,
|
|
126
|
+
labelStr: hasDuplicates ? renderTy(variantTy) : createLabel(symbols, variantTy),
|
|
127
|
+
hasValueField: hasDuplicates ? true : !isStructWithItsOwnLabel(symbols, variantTy)
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Replace all generic Ts (typeParams) with instantiation (typeArgs) recursively.
|
|
132
|
+
// Example: `(int, T, Wrapper<T?>)` and T=coins => `(int, coins, Wrapper<coins?>)`
|
|
133
|
+
function instantiateGenerics(ty, typeParams, typeArgs) {
|
|
134
|
+
if (ty.kind === 'nullable')
|
|
135
|
+
return { ...ty, inner: instantiateGenerics(ty.inner, typeParams, typeArgs) };
|
|
136
|
+
if (ty.kind === 'cellOf')
|
|
137
|
+
return { ...ty, inner: instantiateGenerics(ty.inner, typeParams, typeArgs) };
|
|
138
|
+
if (ty.kind === 'arrayOf')
|
|
139
|
+
return { ...ty, inner: instantiateGenerics(ty.inner, typeParams, typeArgs) };
|
|
140
|
+
if (ty.kind === 'lispListOf')
|
|
141
|
+
return { ...ty, inner: instantiateGenerics(ty.inner, typeParams, typeArgs) };
|
|
142
|
+
if (ty.kind === 'tensor')
|
|
143
|
+
return { ...ty, items: ty.items.map(item => instantiateGenerics(item, typeParams, typeArgs)) };
|
|
144
|
+
if (ty.kind === 'shapedTuple')
|
|
145
|
+
return { ...ty, items: ty.items.map(item => instantiateGenerics(item, typeParams, typeArgs)) };
|
|
146
|
+
if (ty.kind === 'mapKV')
|
|
147
|
+
return { ...ty, k: instantiateGenerics(ty.k, typeParams, typeArgs), v: instantiateGenerics(ty.v, typeParams, typeArgs) };
|
|
148
|
+
if (ty.kind === 'StructRef')
|
|
149
|
+
return { ...ty, type_args: ty.type_args?.map(ta => instantiateGenerics(ta, typeParams, typeArgs)) };
|
|
150
|
+
if (ty.kind === 'AliasRef')
|
|
151
|
+
return { ...ty, type_args: ty.type_args?.map(ta => instantiateGenerics(ta, typeParams, typeArgs)) };
|
|
152
|
+
if (ty.kind === 'union')
|
|
153
|
+
return { ...ty, variants: ty.variants.map(v => ({ ...v, variant_ty: instantiateGenerics(v.variant_ty, typeParams, typeArgs) })) };
|
|
154
|
+
if (ty.kind === 'genericT') {
|
|
155
|
+
const idx = typeParams?.indexOf(ty.name_t);
|
|
156
|
+
if (idx === undefined || idx === -1 || idx >= typeArgs.length)
|
|
157
|
+
throw new Error(`inconsistent generics: could not find type argument for ${ty.name_t}`);
|
|
158
|
+
return typeArgs[idx];
|
|
159
|
+
}
|
|
160
|
+
return ty;
|
|
161
|
+
}
|
|
162
|
+
// Calculate, how many stack slots a type occupies.
|
|
163
|
+
function calcWidthOnStack(symbols, ty) {
|
|
164
|
+
switch (ty.kind) {
|
|
165
|
+
case 'void': {
|
|
166
|
+
// void is like "unit", equal to an empty tensor
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
case 'tensor': {
|
|
170
|
+
// a tensor is a sum of its elements
|
|
171
|
+
return ty.items.map(item => calcWidthOnStack(symbols, item)).reduce((p, c) => p + c, 0);
|
|
172
|
+
}
|
|
173
|
+
case 'StructRef': {
|
|
174
|
+
// a struct is a named tensor: fields one by one;
|
|
175
|
+
// if a struct is generic `Wrapper<T>`, we have typeArgs T=xxx, and replace T in each field
|
|
176
|
+
// (it works unless `T` is used in unions)
|
|
177
|
+
const structRef = symbols.getStruct(ty.struct_name);
|
|
178
|
+
return structRef.fields.map(f => {
|
|
179
|
+
const fTy = ty.type_args ? instantiateGenerics(f.ty, structRef.type_params, ty.type_args) : f.ty;
|
|
180
|
+
return calcWidthOnStack(symbols, fTy);
|
|
181
|
+
}).reduce((p, c) => p + c, 0);
|
|
182
|
+
}
|
|
183
|
+
case 'AliasRef': {
|
|
184
|
+
// an alias is the same as its underlying (target) type;
|
|
185
|
+
// if an alias is generic `Maybe<T>`, we have typeArgs T=xxx, and replace T in its target
|
|
186
|
+
const aliasRef = symbols.getAlias(ty.alias_name);
|
|
187
|
+
const targetTy = ty.type_args ? instantiateGenerics(aliasRef.target_ty, aliasRef.type_params, ty.type_args) : aliasRef.target_ty;
|
|
188
|
+
return calcWidthOnStack(symbols, targetTy);
|
|
189
|
+
}
|
|
190
|
+
case 'nullable': {
|
|
191
|
+
// for primitive nullables (common case), like `int?` and `address?`, it's 1 (TVM value or NULL);
|
|
192
|
+
// for non-primitive nullables, the compiler inserts stackWidth and stackTypeId
|
|
193
|
+
return ty.stack_width ?? 1;
|
|
194
|
+
}
|
|
195
|
+
case 'union': {
|
|
196
|
+
// for union types, the compiler always inserts stackWidth for simplicity (and stackTypeId for each variant)
|
|
197
|
+
return ty.stack_width;
|
|
198
|
+
}
|
|
199
|
+
case 'genericT': {
|
|
200
|
+
// all generics must have been instantiated up to this point
|
|
201
|
+
throw new Error(`unexpected genericT=${ty.name_t} in calcWidthOnStack`);
|
|
202
|
+
}
|
|
203
|
+
default: {
|
|
204
|
+
// almost all types are TVM primitives that occupy 1 stack slot:
|
|
205
|
+
// - intN is TVM INT
|
|
206
|
+
// - array<T> is TVM TUPLE
|
|
207
|
+
// - map<K, V> is TVM DICT or NULL
|
|
208
|
+
// etc.
|
|
209
|
+
return 1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Ty } from './abi-types';
|
|
2
|
+
export declare class SymbolNotFound extends Error {
|
|
3
|
+
constructor(symbolKind: string, notFoundName: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class CantGeneratePackUnpack extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class NonStandardDictKey extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class NotSupportedTypeOnStack extends Error {
|
|
12
|
+
constructor(ty: Ty, fieldPath: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class CantGenerateWrappersAtAll extends Error {
|
|
15
|
+
constructor(where: string, prevEx: any);
|
|
16
|
+
}
|
|
17
|
+
export declare class InvalidDynamicInput extends Error {
|
|
18
|
+
constructor(msg: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class CantPackDynamic extends Error {
|
|
21
|
+
constructor(fieldPath: string, msg: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class CantUnpackDynamic extends Error {
|
|
24
|
+
constructor(fieldPath: string, msg: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class CantCallGetMethodDynamic extends Error {
|
|
27
|
+
constructor(getMethodName: string, msg: string);
|
|
28
|
+
}
|
|
@@ -1,82 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// can not be initialized, or has unresolved types, or other errors while parsing Tolk sources.
|
|
6
|
-
export class CantParseInputTolkFile extends Error {
|
|
7
|
-
constructor(message: string) {
|
|
8
|
-
super(message);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CantCallGetMethodDynamic = exports.CantUnpackDynamic = exports.CantPackDynamic = exports.InvalidDynamicInput = exports.CantGenerateWrappersAtAll = exports.NotSupportedTypeOnStack = exports.NonStandardDictKey = exports.CantGeneratePackUnpack = exports.SymbolNotFound = void 0;
|
|
4
|
+
const types_kernel_1 = require("./types-kernel");
|
|
12
5
|
// Fired when TyRef contains unresolved symbols,
|
|
13
|
-
// e.g. { kind: 'StructRef',
|
|
14
|
-
|
|
15
|
-
constructor(symbolKind
|
|
6
|
+
// e.g. { kind: 'StructRef', struct_name: 'non-existing' }
|
|
7
|
+
class SymbolNotFound extends Error {
|
|
8
|
+
constructor(symbolKind, notFoundName) {
|
|
16
9
|
super(`${symbolKind} ${notFoundName} not found`);
|
|
17
10
|
}
|
|
18
11
|
}
|
|
19
|
-
|
|
12
|
+
exports.SymbolNotFound = SymbolNotFound;
|
|
20
13
|
// Fired if serialization to/from cells can not be applied to a specific type/struct.
|
|
21
14
|
// E.g., a struct contains `int` (not int32/uint64): it's used only in contract getters.
|
|
22
15
|
// For such structs, `fromSlice`/`store` is just `throw` with description
|
|
23
16
|
// (the overall process of generating wrappers continues, only a specific struct can't be serialized).
|
|
24
|
-
|
|
25
|
-
constructor(message
|
|
17
|
+
class CantGeneratePackUnpack extends Error {
|
|
18
|
+
constructor(message) {
|
|
26
19
|
super(message);
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
|
-
|
|
22
|
+
exports.CantGeneratePackUnpack = CantGeneratePackUnpack;
|
|
30
23
|
// `Dictionary<K, V>` from @ton/core allows only predefined KeyT.
|
|
31
24
|
// For others, we can not generate wrappers at all (not only to/from cell, but even declarations).
|
|
32
|
-
|
|
33
|
-
constructor(message
|
|
25
|
+
class NonStandardDictKey extends Error {
|
|
26
|
+
constructor(message) {
|
|
34
27
|
super(message);
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
exports.NonStandardDictKey = NonStandardDictKey;
|
|
38
31
|
// Some types, like callables/lambdas, can not be used in get methods, we can't generate wrappers then.
|
|
39
|
-
|
|
40
|
-
constructor(ty
|
|
41
|
-
super(`'${fieldPath}' can not be used in get methods, because it contains '${renderTy(ty)}'`);
|
|
32
|
+
class NotSupportedTypeOnStack extends Error {
|
|
33
|
+
constructor(ty, fieldPath) {
|
|
34
|
+
super(`'${fieldPath}' can not be used in get methods, because it contains '${(0, types_kernel_1.renderTy)(ty)}'`);
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
|
-
|
|
37
|
+
exports.NotSupportedTypeOnStack = NotSupportedTypeOnStack;
|
|
45
38
|
// This error is fired "to the outer world".
|
|
46
|
-
|
|
47
|
-
constructor(where
|
|
39
|
+
class CantGenerateWrappersAtAll extends Error {
|
|
40
|
+
constructor(where, prevEx) {
|
|
48
41
|
super(`${where}: [${prevEx.constructor.name}] ${prevEx.message ?? prevEx.toString()}`);
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
|
-
|
|
44
|
+
exports.CantGenerateWrappersAtAll = CantGenerateWrappersAtAll;
|
|
52
45
|
// This error is fired when invalid input is passed into dynamic serialization.
|
|
53
46
|
// For example, passed an object instead of a number, a field is missing, etc.
|
|
54
|
-
|
|
55
|
-
constructor(msg
|
|
47
|
+
class InvalidDynamicInput extends Error {
|
|
48
|
+
constructor(msg) {
|
|
56
49
|
super(msg);
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
|
-
|
|
52
|
+
exports.InvalidDynamicInput = InvalidDynamicInput;
|
|
60
53
|
// This error is fired when dynamic serialization (from a JS object to a cell) failed.
|
|
61
54
|
// For example, passed an object instead of a number, a field is missing, etc.
|
|
62
|
-
|
|
63
|
-
constructor(fieldPath
|
|
55
|
+
class CantPackDynamic extends Error {
|
|
56
|
+
constructor(fieldPath, msg) {
|
|
64
57
|
super(`cannot serialize '${fieldPath}' dynamically: ${msg}`);
|
|
65
58
|
}
|
|
66
59
|
}
|
|
67
|
-
|
|
60
|
+
exports.CantPackDynamic = CantPackDynamic;
|
|
68
61
|
// This error is fired when dynamic deserialization (from a cell into a JS object) failed.
|
|
69
62
|
// For example, none of union prefixes match.
|
|
70
|
-
|
|
71
|
-
constructor(fieldPath
|
|
63
|
+
class CantUnpackDynamic extends Error {
|
|
64
|
+
constructor(fieldPath, msg) {
|
|
72
65
|
super(`cannot deserialize '${fieldPath}' dynamically: ${msg}`);
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
|
-
|
|
68
|
+
exports.CantUnpackDynamic = CantUnpackDynamic;
|
|
76
69
|
// This error is fired when dynamic calling get method (from a JS object to a TVM tuple) failed.
|
|
77
70
|
// For example, passed an object instead of a number, a field is missing, etc.
|
|
78
|
-
|
|
79
|
-
constructor(getMethodName
|
|
71
|
+
class CantCallGetMethodDynamic extends Error {
|
|
72
|
+
constructor(getMethodName, msg) {
|
|
80
73
|
super(`cannot call get method '${getMethodName}' dynamically: ${msg}`);
|
|
81
74
|
}
|
|
82
75
|
}
|
|
76
|
+
exports.CantCallGetMethodDynamic = CantCallGetMethodDynamic;
|
package/package.json
CHANGED
|
@@ -1,32 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
2
|
+
"name": "gen-typescript-from-tolk-dev",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Generate TypeScript wrappers from Tolk ABI",
|
|
5
|
+
"author": "TON Core",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
13
16
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
"./src/*": {
|
|
18
|
+
"types": "./dist/*.d.ts",
|
|
19
|
+
"import": "./dist/*.js",
|
|
20
|
+
"require": "./dist/*.js",
|
|
21
|
+
"default": "./dist/*.js"
|
|
17
22
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"@ton/sandbox": ">=0.37.0",
|
|
26
|
-
"@ton/ton": ">=15.3.1 <16.0.0",
|
|
27
|
-
"@types/jest": "^30.0.0",
|
|
28
|
-
"@types/node": "^22.17.2",
|
|
29
|
-
"jest": "^30.0.5",
|
|
30
|
-
"ts-jest": "^29.4.1"
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
"*": {
|
|
27
|
+
"src/*": [
|
|
28
|
+
"dist/*"
|
|
29
|
+
]
|
|
31
30
|
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin",
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"bin": "./bin/generator.js",
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/tolk-vm/gen-typescript-from-tolk.git"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"ton",
|
|
48
|
+
"tolk",
|
|
49
|
+
"typescript",
|
|
50
|
+
"abi",
|
|
51
|
+
"wrappers"
|
|
52
|
+
],
|
|
53
|
+
"scripts": {
|
|
54
|
+
"sync:template": "node scripts/sync-out-template.js",
|
|
55
|
+
"clean": "node --eval \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
56
|
+
"build": "npm run clean && npm run sync:template && tsc -p tsconfig.build.json",
|
|
57
|
+
"typecheck": "npm run sync:template && tsc -p tsconfig.json",
|
|
58
|
+
"test": "npm run sync:template && jest --config jest.config.js --verbose",
|
|
59
|
+
"check": "npm run build && npm test",
|
|
60
|
+
"pack:dry-run": "npm pack --dry-run",
|
|
61
|
+
"prepack": "npm run build",
|
|
62
|
+
"dev:codegen": "npm run sync:template && ts-node dev-codegen.ts"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@ton/core": "0.62.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@ton/crypto": "3.3.0",
|
|
69
|
+
"@ton/sandbox": "0.37.2",
|
|
70
|
+
"@ton/ton": "15.4.0",
|
|
71
|
+
"@types/jest": "30.0.0",
|
|
72
|
+
"@types/node": "22.18.8",
|
|
73
|
+
"jest": "30.2.0",
|
|
74
|
+
"ts-jest": "29.4.4",
|
|
75
|
+
"ts-node": "10.9.2",
|
|
76
|
+
"typescript": "5.9.3"
|
|
77
|
+
}
|
|
32
78
|
}
|