gen-typescript-from-tolk-dev 0.2.4 → 0.3.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.
@@ -168,20 +168,21 @@ class StackReader {
168
168
  exports.StackReader = StackReader;
169
169
  // When constructing a TVM tuple (when calling a get method), we often need to make cells.
170
170
  // For example, given an address, we should result in { type: 'slice', cell: (serialized address) }
171
- function makeCell(ctx, fieldPath, ty, v) {
171
+ function makeCell(ctx, fieldPath, tyIdx, v, uLabelTyIdx) {
172
172
  let b = c.beginCell();
173
- (0, dynamic_serialization_1.dynamicPack)(ctx, fieldPath, ty, v, b); // does validation, throws if invalid, e.g. number instead of address
173
+ (0, dynamic_serialization_1.dynamicPack)(ctx, fieldPath, tyIdx, v, b, uLabelTyIdx); // does validation, throws if invalid, e.g. number instead of address
174
174
  return b.endCell();
175
175
  }
176
176
  // Pack value `v` of type `ty` to a TVM tuple, as an argument of a get method.
177
177
  // Parameter `fieldPath` is used for error messages only, e.g. when provided invalid input.
178
- function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
178
+ function dynamicConstruct(ctx, fieldPath, tyIdx, v, tupleIfW = false, uLabelTyIdx) {
179
179
  if (tupleIfW) { // inside `array<T>` or `[T, ...]`, if T is non-primitive, it's a sub-tuple
180
- if ((0, types_kernel_1.calcWidthOnStack)(ctx.symbols, ty) === 1) {
181
- return dynamicConstruct(ctx, fieldPath, ty, v, false);
180
+ if ((0, types_kernel_1.calcWidthOnStack)(ctx.symbols, tyIdx) === 1) {
181
+ return dynamicConstruct(ctx, fieldPath, tyIdx, v, false, uLabelTyIdx);
182
182
  }
183
- return [{ type: 'tuple', items: dynamicConstruct(ctx, fieldPath, ty, v, false) }];
183
+ return [{ type: 'tuple', items: dynamicConstruct(ctx, fieldPath, tyIdx, v, false, uLabelTyIdx) }];
184
184
  }
185
+ const ty = ctx.symbols.tyByIdx(tyIdx);
185
186
  switch (ty.kind) {
186
187
  case 'int':
187
188
  case 'intN':
@@ -189,20 +190,20 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
189
190
  case 'varintN':
190
191
  case 'varuintN':
191
192
  case 'coins': {
192
- (0, dynamic_validation_1.checkIsNumber)(fieldPath, ty, v);
193
+ (0, dynamic_validation_1.checkIsNumber)(ctx, fieldPath, tyIdx, v);
193
194
  return [{ type: 'int', value: v }];
194
195
  }
195
196
  case 'bool': {
196
- (0, dynamic_validation_1.checkIsBoolean)(fieldPath, ty, v);
197
+ (0, dynamic_validation_1.checkIsBoolean)(ctx, fieldPath, tyIdx, v);
197
198
  return [{ type: 'int', value: (v ? -1n : 0n) }];
198
199
  }
199
200
  case 'cell': {
200
- (0, dynamic_validation_1.checkIsObject)(fieldPath, ty, v);
201
+ (0, dynamic_validation_1.checkIsObject)(ctx, fieldPath, tyIdx, v);
201
202
  return [{ type: 'cell', cell: v }];
202
203
  }
203
204
  case 'builder': {
204
205
  // the call to `makeCell()`, automatically does validation of input (of v)
205
- return [{ type: 'builder', cell: makeCell(ctx, fieldPath, ty, v) }];
206
+ return [{ type: 'builder', cell: makeCell(ctx, fieldPath, tyIdx, v, uLabelTyIdx) }];
206
207
  }
207
208
  case 'slice':
208
209
  case 'remaining':
@@ -210,28 +211,28 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
210
211
  case 'addressExt':
211
212
  case 'addressAny':
212
213
  case 'bitsN': {
213
- return [{ type: 'slice', cell: makeCell(ctx, fieldPath, ty, v) }];
214
+ return [{ type: 'slice', cell: makeCell(ctx, fieldPath, tyIdx, v, uLabelTyIdx) }];
214
215
  }
215
216
  case 'string': {
216
- return [{ type: 'cell', cell: makeCell(ctx, fieldPath, ty, v) }];
217
+ return [{ type: 'cell', cell: makeCell(ctx, fieldPath, tyIdx, v, uLabelTyIdx) }];
217
218
  }
218
219
  case 'addressOpt': {
219
220
  if (v === null) {
220
221
  return [{ type: 'null' }];
221
222
  }
222
- return [{ type: 'slice', cell: makeCell(ctx, fieldPath, ty, v) }];
223
+ return [{ type: 'slice', cell: makeCell(ctx, fieldPath, tyIdx, v, uLabelTyIdx) }];
223
224
  }
224
225
  case 'nullLiteral': {
225
226
  return [{ type: 'null' }];
226
227
  }
227
228
  case 'callable': {
228
- throw new unsupported_errors_1.NotSupportedTypeOnStack(ty, fieldPath);
229
+ throw new unsupported_errors_1.NotSupportedTypeOnStack((0, types_kernel_1.renderTy)(ctx.symbols, tyIdx), fieldPath);
229
230
  }
230
231
  case 'void': {
231
232
  return [];
232
233
  }
233
234
  case 'unknown': {
234
- (0, dynamic_validation_1.checkIsObjectWithProperty)(fieldPath, ty, v, 'type'); // c.TupleItem has 'type'
235
+ (0, dynamic_validation_1.checkIsObjectWithProperty)(ctx, fieldPath, tyIdx, v, 'type'); // c.TupleItem has 'type'
235
236
  return [v];
236
237
  }
237
238
  case 'nullable': {
@@ -244,7 +245,7 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
244
245
  result.push({ type: 'int', value: 0n });
245
246
  }
246
247
  else {
247
- result = dynamicConstruct(ctx, fieldPath, ty.inner, v);
248
+ result = dynamicConstruct(ctx, fieldPath, ty.inner_ty_idx, v);
248
249
  result.push({ type: 'int', value: BigInt(ty.stack_type_id) });
249
250
  }
250
251
  return result;
@@ -252,57 +253,55 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
252
253
  if (v === null) {
253
254
  return [{ type: 'null' }];
254
255
  }
255
- return dynamicConstruct(ctx, fieldPath, ty.inner, v);
256
+ return dynamicConstruct(ctx, fieldPath, ty.inner_ty_idx, v);
256
257
  }
257
258
  case 'cellOf': {
258
- (0, dynamic_validation_1.checkIsObjectWithProperty)(fieldPath, ty, v, 'ref');
259
- return [{ type: 'cell', cell: makeCell(ctx, fieldPath, ty.inner, v.ref) }];
259
+ (0, dynamic_validation_1.checkIsObjectWithProperty)(ctx, fieldPath, tyIdx, v, 'ref');
260
+ return [{ type: 'cell', cell: makeCell(ctx, fieldPath, ty.inner_ty_idx, v.ref) }];
260
261
  }
261
262
  case 'arrayOf': {
262
- (0, dynamic_validation_1.checkIsArray)(fieldPath, ty, v);
263
- return [{ type: 'tuple', items: v.map((ith) => dynamicConstruct(ctx, 'ith', ty.inner, ith, true)[0]) }];
263
+ (0, dynamic_validation_1.checkIsArray)(ctx, fieldPath, tyIdx, v);
264
+ return [{ type: 'tuple', items: v.map((ith) => dynamicConstruct(ctx, 'ith', ty.inner_ty_idx, ith, true)[0]) }];
264
265
  }
265
266
  case 'lispListOf': {
266
- (0, dynamic_validation_1.checkIsArray)(fieldPath, ty, v);
267
- return [v.reduceRight((tail, head) => ({ type: 'tuple', items: [dynamicConstruct(ctx, 'head', ty.inner, head, true)[0], tail] }), { type: 'null' })];
267
+ (0, dynamic_validation_1.checkIsArray)(ctx, fieldPath, tyIdx, v);
268
+ return [v.reduceRight((tail, head) => ({ type: 'tuple', items: [dynamicConstruct(ctx, 'head', ty.inner_ty_idx, head, true)[0], tail] }), { type: 'null' })];
268
269
  }
269
270
  case 'tensor': {
270
- (0, dynamic_validation_1.checkIsArray)(fieldPath, ty, v, ty.items.length);
271
- return v.flatMap((item, idx) => dynamicConstruct(ctx, `${fieldPath}[${idx}]`, ty.items[idx], item));
271
+ (0, dynamic_validation_1.checkIsArray)(ctx, fieldPath, tyIdx, v, ty.items_ty_idx.length);
272
+ return v.flatMap((item, idx) => dynamicConstruct(ctx, `${fieldPath}[${idx}]`, ty.items_ty_idx[idx], item));
272
273
  }
273
274
  case 'shapedTuple': {
274
- (0, dynamic_validation_1.checkIsArray)(fieldPath, ty, v, ty.items.length);
275
- return [{ type: 'tuple', items: v.map((ith, idx) => dynamicConstruct(ctx, `${fieldPath}[${idx}]`, ty.items[idx], ith, true)[0]) }];
275
+ (0, dynamic_validation_1.checkIsArray)(ctx, fieldPath, tyIdx, v, ty.items_ty_idx.length);
276
+ return [{ type: 'tuple', items: v.map((ith, idx) => dynamicConstruct(ctx, `${fieldPath}[${idx}]`, ty.items_ty_idx[idx], ith, true)[0]) }];
276
277
  }
277
278
  case 'mapKV': {
278
- (0, dynamic_validation_1.checkIsObject)(fieldPath, ty, v);
279
+ (0, dynamic_validation_1.checkIsObject)(ctx, fieldPath, tyIdx, v);
279
280
  if (v.size === 0) {
280
281
  return [{ type: 'null' }];
281
282
  }
282
- let dictKey = (0, dynamic_serialization_1.createTonCoreDictionaryKey)(fieldPath, ty.k);
283
- let dictValue = (0, dynamic_serialization_1.createTonCoreDictionaryValue)(ctx, fieldPath, ty.v);
283
+ let dictKey = (0, dynamic_serialization_1.createTonCoreDictionaryKey)(ctx, fieldPath, ty.key_ty_idx);
284
+ let dictValue = (0, dynamic_serialization_1.createTonCoreDictionaryValue)(ctx, fieldPath, ty.value_ty_idx);
284
285
  return [{ type: 'cell', cell: c.beginCell().storeDictDirect(v, dictKey, dictValue).endCell() }];
285
286
  }
286
287
  case 'EnumRef': {
287
- (0, dynamic_validation_1.checkIsNumber)(fieldPath, ty, v);
288
+ (0, dynamic_validation_1.checkIsNumber)(ctx, fieldPath, tyIdx, v);
288
289
  return [{ type: 'int', value: v }];
289
290
  }
290
291
  case 'StructRef': {
291
- (0, dynamic_validation_1.checkIsObject)(fieldPath, ty, v);
292
- let structRef = ctx.symbols.getStruct(ty.struct_name);
293
- return structRef.fields.flatMap(f => {
294
- const fTy = ty.type_args ? (0, types_kernel_1.instantiateGenerics)(f.ty, structRef.type_params, ty.type_args) : f.ty;
295
- return dynamicConstruct(ctx, `${fieldPath}.${f.name}`, fTy, v[f.name]);
296
- });
292
+ (0, dynamic_validation_1.checkIsObject)(ctx, fieldPath, tyIdx, v);
293
+ return ctx.symbols.structFieldsOf(tyIdx).flatMap(f => dynamicConstruct(ctx, `${fieldPath}.${f.name}`, f.ty_idx, v[f.name], false, f.uLabelTyIdx));
297
294
  }
298
295
  case 'AliasRef': {
299
- let aliasRef = ctx.symbols.getAlias(ty.alias_name);
300
- const targetTy = ty.type_args ? (0, types_kernel_1.instantiateGenerics)(aliasRef.target_ty, aliasRef.type_params, ty.type_args) : aliasRef.target_ty;
301
- return dynamicConstruct(ctx, fieldPath, targetTy, v);
296
+ const target = ctx.symbols.aliasTargetOf(tyIdx);
297
+ return dynamicConstruct(ctx, fieldPath, target.ty_idx, v, false, target.uLabelTyIdx);
302
298
  }
303
299
  case 'union': {
304
- const variants = (0, types_kernel_1.createLabelsForUnion)(ctx.symbols, ty.variants);
305
- const hasNull = variants.find(v => v.variant_ty.kind === 'nullLiteral');
300
+ if (ty.stack_width === undefined) {
301
+ throw new Error(`unexpected stack_width=undefined at ${fieldPath}`);
302
+ }
303
+ const variants = (0, types_kernel_1.createLabelsForUnion)(ctx.symbols, ty.variants, uLabelTyIdx);
304
+ const hasNull = variants.find(v => ctx.symbols.tyByIdx(v.variant_ty_idx).kind === 'nullLiteral');
306
305
  let result = [];
307
306
  if (hasNull && v === null) {
308
307
  for (let i = 0; i < ty.stack_width - 1; ++i) {
@@ -311,19 +310,19 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
311
310
  result.push({ type: 'int', value: 0n });
312
311
  }
313
312
  else {
314
- (0, dynamic_validation_1.checkIsObjectWithProperty)(fieldPath, ty, v, '$');
313
+ (0, dynamic_validation_1.checkIsObjectWithProperty)(ctx, fieldPath, tyIdx, v, '$');
315
314
  const activeVariant = variants.find(variant => v.$ === variant.labelStr);
316
315
  if (!activeVariant) {
317
- (0, dynamic_validation_1.throwInvalidInput)(fieldPath, ty, `non-existing union variant for $ = '${v.$}'`);
316
+ (0, dynamic_validation_1.throwInvalidInput)(ctx, fieldPath, tyIdx, `non-existing union variant for $ = '${v.$}'`);
318
317
  }
319
318
  if (activeVariant.hasValueField && !v.hasOwnProperty('value')) {
320
- (0, dynamic_validation_1.throwInvalidInput)(fieldPath, ty, `expected {$,value} but field 'value' not provided`);
319
+ (0, dynamic_validation_1.throwInvalidInput)(ctx, fieldPath, tyIdx, `expected {$,value} but field 'value' not provided`);
321
320
  }
322
321
  for (let i = 0; i < ty.stack_width - 1 - activeVariant.stack_width; ++i) {
323
322
  result.push({ type: 'null' });
324
323
  }
325
324
  let actualValue = activeVariant.hasValueField ? v.value : v;
326
- result.push(...dynamicConstruct(ctx, `${fieldPath}#${activeVariant.labelStr}`, activeVariant.variant_ty, actualValue));
325
+ result.push(...dynamicConstruct(ctx, `${fieldPath}#${activeVariant.labelStr}`, activeVariant.variant_ty_idx, actualValue, false));
327
326
  result.push({ type: 'int', value: BigInt(activeVariant.stack_type_id) });
328
327
  }
329
328
  return result;
@@ -333,13 +332,14 @@ function dynamicConstruct(ctx, fieldPath, ty, v, tupleIfW = false) {
333
332
  }
334
333
  // Parse `ty` from a TVM tuple on a stack, returned as a result of a get method invocation.
335
334
  // Parameter `fieldPath` is used for error messages only, e.g. when can't deserialize CellRef<T>.
336
- function dynamicParse(ctx, r, fieldPath, ty, unTupleIfW = false) {
335
+ function dynamicParse(ctx, r, fieldPath, tyIdx, unTupleIfW = false, uLabelTyIdx) {
337
336
  if (unTupleIfW) { // inside `array<T>` or `[T, ...]`, if T is non-primitive, it's a sub-tuple
338
- let wOnStack = (0, types_kernel_1.calcWidthOnStack)(ctx.symbols, ty);
337
+ let wOnStack = (0, types_kernel_1.calcWidthOnStack)(ctx.symbols, tyIdx);
339
338
  if (wOnStack !== 1) {
340
- return r.readTuple(wOnStack, (r) => dynamicParse(ctx, r, fieldPath, ty, false));
339
+ return r.readTuple(wOnStack, (r) => dynamicParse(ctx, r, fieldPath, tyIdx, false, uLabelTyIdx));
341
340
  }
342
341
  }
342
+ const ty = ctx.symbols.tyByIdx(tyIdx);
343
343
  switch (ty.kind) {
344
344
  case 'int':
345
345
  case 'intN':
@@ -354,66 +354,66 @@ function dynamicParse(ctx, r, fieldPath, ty, unTupleIfW = false) {
354
354
  case 'string': return r.readSnakeString();
355
355
  case 'remaining': return r.readSlice();
356
356
  case 'address': return r.readSlice().loadAddress();
357
- case 'addressOpt': return dynamicParse(ctx, r, fieldPath, { kind: 'nullable', inner: { kind: 'address' } });
357
+ case 'addressOpt': return r.readNullable((r) => r.readSlice().loadAddress());
358
358
  case 'addressExt': return r.readSlice().loadExternalAddress();
359
- case 'addressAny': return (0, dynamic_serialization_1.dynamicUnpack)(ctx, fieldPath, ty, r.readSlice());
359
+ case 'addressAny': return (0, dynamic_serialization_1.dynamicUnpack)(ctx, fieldPath, tyIdx, r.readSlice());
360
360
  case 'bitsN': return r.readSlice();
361
361
  case 'nullLiteral': return r.readNullLiteral();
362
- case 'callable': throw new unsupported_errors_1.NotSupportedTypeOnStack(ty, fieldPath);
362
+ case 'callable': throw new unsupported_errors_1.NotSupportedTypeOnStack((0, types_kernel_1.renderTy)(ctx.symbols, tyIdx), fieldPath);
363
363
  case 'void': return void 0;
364
364
  case 'unknown': return r.readUnknown();
365
365
  case 'nullable': {
366
366
  if (ty.stack_type_id) {
367
- return r.readWideNullable(ty.stack_width, (r) => dynamicParse(ctx, r, fieldPath, ty.inner));
367
+ return r.readWideNullable(ty.stack_width, (r) => dynamicParse(ctx, r, fieldPath, ty.inner_ty_idx));
368
368
  }
369
- return r.readNullable((r) => dynamicParse(ctx, r, fieldPath, ty.inner));
369
+ return r.readNullable((r) => dynamicParse(ctx, r, fieldPath, ty.inner_ty_idx));
370
370
  }
371
- case 'cellOf': return r.readCellRef((s) => (0, dynamic_serialization_1.dynamicUnpack)(ctx, fieldPath, ty.inner, s));
372
- case 'arrayOf': return r.readArrayOf((r) => dynamicParse(ctx, r, fieldPath, ty.inner, true));
373
- case 'lispListOf': return r.readLispListOf((r) => dynamicParse(ctx, r, fieldPath, ty.inner, true));
371
+ case 'cellOf': return r.readCellRef((s) => (0, dynamic_serialization_1.dynamicUnpack)(ctx, fieldPath, ty.inner_ty_idx, s));
372
+ case 'arrayOf': return r.readArrayOf((r) => dynamicParse(ctx, r, fieldPath, ty.inner_ty_idx, true));
373
+ case 'lispListOf': return r.readLispListOf((r) => dynamicParse(ctx, r, fieldPath, ty.inner_ty_idx, true));
374
374
  case 'tensor': {
375
375
  let result = [];
376
- for (let i = 0; i < ty.items.length; ++i) {
377
- result.push(dynamicParse(ctx, r, `${fieldPath}[${i}]`, ty.items[i]));
376
+ for (let i = 0; i < ty.items_ty_idx.length; ++i) {
377
+ result.push(dynamicParse(ctx, r, `${fieldPath}[${i}]`, ty.items_ty_idx[i]));
378
378
  }
379
379
  return result;
380
380
  }
381
381
  case 'shapedTuple': {
382
- return r.readTuple(ty.items.length, (r) => {
382
+ return r.readTuple(ty.items_ty_idx.length, (r) => {
383
383
  let result = [];
384
- for (let i = 0; i < ty.items.length; ++i) {
385
- result.push(dynamicParse(ctx, r, `${fieldPath}[${i}]`, ty.items[i], true));
384
+ for (let i = 0; i < ty.items_ty_idx.length; ++i) {
385
+ result.push(dynamicParse(ctx, r, `${fieldPath}[${i}]`, ty.items_ty_idx[i], true));
386
386
  }
387
387
  return result;
388
388
  });
389
389
  }
390
390
  case 'mapKV': {
391
- let dictKey = (0, dynamic_serialization_1.createTonCoreDictionaryKey)(fieldPath, ty.k);
392
- let dictValue = (0, dynamic_serialization_1.createTonCoreDictionaryValue)(ctx, fieldPath, ty.v);
391
+ let dictKey = (0, dynamic_serialization_1.createTonCoreDictionaryKey)(ctx, fieldPath, ty.key_ty_idx);
392
+ let dictValue = (0, dynamic_serialization_1.createTonCoreDictionaryValue)(ctx, fieldPath, ty.value_ty_idx);
393
393
  return r.readDictionary(dictKey, dictValue);
394
394
  }
395
395
  case 'EnumRef': return r.readBigInt();
396
396
  case 'StructRef': {
397
- const structRef = ctx.symbols.getStruct(ty.struct_name);
398
397
  let result = { $: ty.struct_name };
399
- for (let f of structRef.fields) {
400
- const fTy = ty.type_args ? (0, types_kernel_1.instantiateGenerics)(f.ty, structRef.type_params, ty.type_args) : f.ty;
401
- result[f.name] = dynamicParse(ctx, r, `${fieldPath}.${f.name}`, fTy);
398
+ for (let f of ctx.symbols.structFieldsOf(tyIdx)) {
399
+ result[f.name] = dynamicParse(ctx, r, `${fieldPath}.${f.name}`, f.ty_idx, false, f.uLabelTyIdx);
402
400
  }
403
401
  return result;
404
402
  }
405
403
  case 'AliasRef': {
406
- const aliasRef = ctx.symbols.getAlias(ty.alias_name);
407
- const targetTy = ty.type_args ? (0, types_kernel_1.instantiateGenerics)(aliasRef.target_ty, aliasRef.type_params, ty.type_args) : aliasRef.target_ty;
408
- return dynamicParse(ctx, r, fieldPath, targetTy);
404
+ const target = ctx.symbols.aliasTargetOf(tyIdx);
405
+ return dynamicParse(ctx, r, fieldPath, target.ty_idx, false, target.uLabelTyIdx);
409
406
  }
410
407
  case 'genericT': throw new Error(`unexpected genericT=${ty.name_t} at ${fieldPath}`);
411
408
  case 'union': {
412
- const variants = (0, types_kernel_1.createLabelsForUnion)(ctx.symbols, ty.variants);
409
+ if (ty.stack_width === undefined) {
410
+ throw new Error(`unexpected stack_width=undefined at ${fieldPath}`);
411
+ }
412
+ const variants = (0, types_kernel_1.createLabelsForUnion)(ctx.symbols, ty.variants, uLabelTyIdx);
413
413
  const infoForTypeId = {};
414
414
  for (let v of variants) {
415
415
  infoForTypeId[v.stack_type_id] = [v.stack_width, v.hasValueField ? v.labelStr : null,
416
- (r) => dynamicParse(ctx, r, `${fieldPath}#${v.labelStr}`, v.variant_ty)
416
+ (r) => dynamicParse(ctx, r, `${fieldPath}#${v.labelStr}`, v.variant_ty_idx, false)
417
417
  ];
418
418
  }
419
419
  return r.readUnionType(ty.stack_width, infoForTypeId);
@@ -424,8 +424,8 @@ function dynamicParse(ctx, r, fieldPath, ty, unTupleIfW = false) {
424
424
  * Pack any `value` of type `ty` to a TVM tuple.
425
425
  * This tuple can be used as a get method argument or debug-printed as human-readable.
426
426
  */
427
- function makeTvmTupleDynamic(ctx, ty, value) {
428
- return dynamicConstruct(ctx, 'value', ty, value);
427
+ function makeTvmTupleDynamic(ctx, tyIdx, value) {
428
+ return dynamicConstruct(ctx, 'value', tyIdx, value);
429
429
  }
430
430
  /**
431
431
  * Invoke any get method taking plain JS variables as arguments and interpreting the resulting TVM tuple according to ABI.
@@ -443,9 +443,9 @@ async function callGetMethodDynamic(provider, ctx, getMethodName, args) {
443
443
  }
444
444
  const stackIn = [];
445
445
  for (let i = 0; i < args.length; ++i) {
446
- stackIn.push(...dynamicConstruct(ctx, getM.parameters[i].name, getM.parameters[i].ty, args[i]));
446
+ stackIn.push(...dynamicConstruct(ctx, getM.parameters[i].name, getM.parameters[i].ty_idx, args[i]));
447
447
  }
448
- const expectedSlotsOut = (0, types_kernel_1.calcWidthOnStack)(ctx.symbols, getM.return_ty);
448
+ const expectedSlotsOut = (0, types_kernel_1.calcWidthOnStack)(ctx.symbols, getM.return_ty_idx);
449
449
  const r = StackReader.fromGetMethod(expectedSlotsOut, await provider.get(getMethodName, stackIn));
450
- return dynamicParse(ctx, r, 'result', getM.return_ty);
450
+ return dynamicParse(ctx, r, 'result', getM.return_ty_idx);
451
451
  }
@@ -1,22 +1,21 @@
1
1
  import * as c from '@ton/core';
2
- import type { Ty } from './abi-types';
3
2
  import { DynamicCtx } from './dynamic-ctx';
4
- export declare function createTonCoreDictionaryKey(fieldPath: string, tyK: Ty): c.DictionaryKey<any>;
5
- export declare function createTonCoreDictionaryValue(ctx: DynamicCtx, fieldPath: string, tyV: Ty): c.DictionaryValue<any>;
6
- export declare function dynamicPack(ctx: DynamicCtx, fieldPath: string, ty: Ty, v: any, b: c.Builder): void;
7
- export declare function dynamicUnpack(ctx: DynamicCtx, fieldPath: string, ty: Ty, s: c.Slice): any;
3
+ export declare function createTonCoreDictionaryKey(ctx: DynamicCtx, fieldPath: string, tyKIdx: number): c.DictionaryKey<any>;
4
+ export declare function createTonCoreDictionaryValue(ctx: DynamicCtx, fieldPath: string, tyVIdx: number): c.DictionaryValue<any>;
5
+ export declare function dynamicPack(ctx: DynamicCtx, fieldPath: string, tyIdx: number, v: any, b: c.Builder, uLabelTyIdx?: number): void;
6
+ export declare function dynamicUnpack(ctx: DynamicCtx, fieldPath: string, tyIdx: number, s: c.Slice, uLabelTyIdx?: number): any;
8
7
  /**
9
8
  * Pack any input to a builder according to an ABI schema.
10
9
  * Example: `struct Point { x: int8, y: int8 }`.
11
10
  * After being converted, it's stored as ABI.
12
- * Call: `packToBuilderDynamic(ctx, structTy, { x: 10, y: 20 }, b)` appends 0x0A14.
11
+ * Call: `packToBuilderDynamic(ctx, pointTyIdx, { x: 10, y: 20 }, b)` appends 0x0A14.
13
12
  * When input is incorrect (e.g. missing property in a JS object), throws InvalidDynamicInput.
14
13
  */
15
- export declare function packToBuilderDynamic(ctx: DynamicCtx, ty: Ty, value: any, b: c.Builder): void;
14
+ export declare function packToBuilderDynamic(ctx: DynamicCtx, tyIdx: number, value: any, b: c.Builder): void;
16
15
  /**
17
16
  * Unpack any slice to a JS variable according to an ABI schema.
18
17
  * Example: `struct Point { x: int8, y: int8 }`.
19
- * Call: `unpackFromSliceDynamic(ctx, structTy, hex"0A14")` returns `{ x: 10, y: 20 }`.
18
+ * Call: `unpackFromSliceDynamic(ctx, pointTyIdx, hex"0A14")` returns `{ x: 10, y: 20 }`.
20
19
  * When ty can't be deserialized, throws CantUnpackDynamic.
21
20
  */
22
- export declare function unpackFromSliceDynamic(ctx: DynamicCtx, ty: Ty, s: c.Slice): any;
21
+ export declare function unpackFromSliceDynamic(ctx: DynamicCtx, tyIdx: number, s: c.Slice): any;