@taqueria/plugin-contract-types 0.3.0 → 0.4.0-rc2

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/index.js CHANGED
@@ -14,10 +14,7 @@ function $parcel$interopDefault(a) {
14
14
 
15
15
 
16
16
 
17
- const $3f5c875567479895$export$bd8d1d28710832a7 = (text)=>text.replace(/[^A-Za-z0-9]/g, '_').split("_").filter((x)=>x
18
- ).map((x)=>x[0].toUpperCase() + x.substring(1)
19
- ).join('')
20
- ;
17
+ const $3f5c875567479895$export$bd8d1d28710832a7 = (text)=>text.replace(/[^A-Za-z0-9]/g, "_").split("_").filter((x)=>x).map((x)=>x[0].toUpperCase() + x.substring(1)).join("");
21
18
 
22
19
 
23
20
 
@@ -37,11 +34,10 @@ const $901f5cf476ef87a5$export$16bf6fe03653420f = (value, message)=>{
37
34
  const $901f5cf476ef87a5$export$37679993c4e6bc41 = (out, x)=>{
38
35
  out.push(...x);
39
36
  return out;
40
- } // const reduceFlatMapTest = () => {
37
+ }; // const reduceFlatMapTest = () => {
41
38
  // const items = [['a'], ['b']];
42
39
  // const itemsFlat = items.reduce(reduceFlatMap);
43
40
  // };
44
- ;
45
41
 
46
42
 
47
43
 
@@ -49,8 +45,7 @@ const $b95e97a0bb3bf047$var$toDebugSource = (node)=>{
49
45
  return JSON.stringify(node);
50
46
  };
51
47
  const $b95e97a0bb3bf047$export$cc65da7b09dcddd7 = (storage)=>{
52
- const fields = storage.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)
53
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
48
+ const fields = storage.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
54
49
  if (fields.length === 1 && !fields[0].name) return {
55
50
  storage: fields[0].type
56
51
  };
@@ -64,20 +59,17 @@ const $b95e97a0bb3bf047$export$cc65da7b09dcddd7 = (storage)=>{
64
59
  };
65
60
  const $b95e97a0bb3bf047$export$5c00959a6ba200c1 = (parameter)=>{
66
61
  return {
67
- methods: parameter.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)
68
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, [])
62
+ methods: parameter.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), [])
69
63
  };
70
64
  };
71
65
  const $b95e97a0bb3bf047$var$visitContractParameterEndpoint = (node)=>{
72
66
  // console.log('visitContractParameterEndpoint', { node });
73
67
  // Sub endpoints (i.e. admin endpoints that are imported)
74
- if (node.prim === `or`) return node.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)
75
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
68
+ if (node.prim === `or`) return node.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
76
69
  // Sub endpoints as a list with a single or (i.e. admin endpoints that are imported)
77
- if (node.prim === `list` && node.args.length === 1 && node.args[0]?.prim === `or`) return node.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)
78
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
70
+ if (node.prim === `list` && node.args.length === 1 && node.args[0]?.prim === `or`) return node.args.map((x)=>$b95e97a0bb3bf047$var$visitContractParameterEndpoint(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
79
71
  const nameRaw = node.annots?.[0];
80
- const name = nameRaw?.startsWith('%') ? nameRaw.substr(1) : null;
72
+ const name = nameRaw?.startsWith("%") ? nameRaw.substr(1) : null;
81
73
  if (!name) {
82
74
  console.warn(`Unknown method: ${node.prim}`, {
83
75
  node: node,
@@ -86,10 +78,10 @@ const $b95e97a0bb3bf047$var$visitContractParameterEndpoint = (node)=>{
86
78
  return [];
87
79
  }
88
80
  const nodeType = $b95e97a0bb3bf047$var$visitType(node, {
89
- ignorePairName: node.prim === 'pair'
81
+ ignorePairName: node.prim === "pair"
90
82
  });
91
83
  // Method args are usually objects
92
- if (nodeType.kind === 'object') return [
84
+ if (nodeType.kind === "object") return [
93
85
  {
94
86
  name: name,
95
87
  args: nodeType.fields
@@ -135,14 +127,11 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
135
127
  }
136
128
  // Union
137
129
  if (node.prim === `or`) {
138
- const unionVars = node.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)
139
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []).map((x)=>x
140
- );
130
+ const unionVars = node.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []).map((x)=>x);
141
131
  // Flatten with child unions
142
- const union = unionVars.map((x)=>!x.name && x.type.kind === 'union' ? x.type.union : [
132
+ const union = unionVars.map((x)=>!x.name && x.type.kind === "union" ? x.type.union : [
143
133
  x
144
- ]
145
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
134
+ ]).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
146
135
  // const union = unionVars.map(x=>x.type);
147
136
  // const union = unionVars.map(x => x.type);
148
137
  // Flatten with child unions
@@ -151,8 +140,7 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
151
140
  // union.pop();
152
141
  // union.push(...rightSide.union);
153
142
  // }
154
- if (union.some((x)=>!x
155
- )) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`or: Some fields are null`, {
143
+ if (union.some((x)=>!x)) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`or: Some fields are null`, {
156
144
  node: node
157
145
  });
158
146
  return {
@@ -163,10 +151,8 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
163
151
  }
164
152
  // Intersect
165
153
  if (node.prim === `pair`) {
166
- const fields = node.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)
167
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
168
- if (fields.some((x)=>!x
169
- )) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`pair: Some fields are null`, {
154
+ const fields = node.args.map((x)=>$b95e97a0bb3bf047$var$visitVar(x)).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
155
+ if (fields.some((x)=>!x)) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`pair: Some fields are null`, {
170
156
  node: node,
171
157
  args: node.args,
172
158
  fields: fields
@@ -176,10 +162,9 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
176
162
  // throw new GenerateApiError(`pair: Expected 2 items`, { node, length: fields.length, fields });
177
163
  // }
178
164
  // Flatten with unnamed child pairs
179
- const fieldsFlat = fields.map((x)=>(!x.name || options?.ignorePairName) && x.type.kind === 'object' ? x.type.fields : [
165
+ const fieldsFlat = fields.map((x)=>(!x.name || options?.ignorePairName) && x.type.kind === "object" ? x.type.fields : [
180
166
  x
181
- ]
182
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []);
167
+ ]).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []);
183
168
  return {
184
169
  kind: `object`,
185
170
  raw: node,
@@ -188,12 +173,12 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
188
173
  }
189
174
  // list
190
175
  if (node.prim === `list` || node.prim === `set`) {
191
- if (node.args.length !== 1) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`list does not have 1 arg`, {
176
+ if (node.args.length !== 1) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`list does not have 1 arg`, {
192
177
  node: node,
193
178
  args: node.args
194
179
  });
195
180
  const arrayItem = $b95e97a0bb3bf047$var$visitType(node.args[0]);
196
- if (!arrayItem) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`arrayItem are null`, {
181
+ if (!arrayItem) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`arrayItem are null`, {
197
182
  node: node,
198
183
  args: node.args,
199
184
  arrayItem: arrayItem
@@ -208,13 +193,13 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
208
193
  }
209
194
  // map
210
195
  if (node.prim === `map` || node.prim === `big_map`) {
211
- if (node.args.length !== 2) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`map does not have 2 args`, {
196
+ if (node.args.length !== 2) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`map does not have 2 args`, {
212
197
  node: node,
213
198
  args: node.args
214
199
  });
215
200
  const mapKey = $b95e97a0bb3bf047$var$visitType(node.args[0]);
216
201
  const mapValue = $b95e97a0bb3bf047$var$visitType(node.args[1]);
217
- if (!mapKey || !mapValue) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`map is missing key or value`, {
202
+ if (!mapKey || !mapValue) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`map is missing key or value`, {
218
203
  node: node,
219
204
  args: node.args,
220
205
  mapKey: mapKey,
@@ -283,16 +268,20 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
283
268
  typescriptType: `string`
284
269
  };
285
270
  // chest
286
- if (node.prim === 'chest') throw new Error('Not Implemented: chest');
287
- if (node.prim === 'chest_key') throw new Error('Not Implemented: chest_key');
271
+ if (node.prim === "chest" || node.prim === "chest_key") return {
272
+ kind: `value`,
273
+ raw: node,
274
+ value: node.prim,
275
+ typescriptType: `string`
276
+ };
288
277
  // never
289
278
  if (node.prim === `never`) return {
290
279
  kind: `never`,
291
280
  raw: node
292
281
  };
293
282
  // Unknown
294
- $901f5cf476ef87a5$export$16bf6fe03653420f(node, `Unknown type`);
295
- throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`Unknown type`, {
283
+ (0, $901f5cf476ef87a5$export$16bf6fe03653420f)(node, `Unknown type`);
284
+ throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`Unknown type`, {
296
285
  node: node
297
286
  });
298
287
  };
@@ -302,8 +291,7 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
302
291
  const $4e7cd4eb63db9934$export$eb0413f5ee90780 = (methods, storage)=>{
303
292
  const getSchemaObjectType = (vars)=>{
304
293
  // console.log('getSchemaObjectType', { vars });
305
- if (vars.some((x)=>!x
306
- )) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`getSchemaObjectType has null vars`, {
294
+ if (vars.some((x)=>!x)) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`getSchemaObjectType has null vars`, {
307
295
  vars: vars
308
296
  });
309
297
  return vars.reduce((out, x, i)=>{
@@ -340,12 +328,10 @@ const $4e7cd4eb63db9934$export$eb0413f5ee90780 = (methods, storage)=>{
340
328
  const $8fdd19ff0013f28e$export$d355209543d39bc0 = (storage, methods, contractName, parsedContract, protocol, typeAliasData, typeUtilsData)=>{
341
329
  const usedStrictTypes = [];
342
330
  const addTypeAlias = (strictType)=>{
343
- if (!usedStrictTypes.some((x)=>x.aliasType === strictType.aliasType
344
- )) usedStrictTypes.push(strictType);
331
+ if (!usedStrictTypes.some((x)=>x.aliasType === strictType.aliasType)) usedStrictTypes.push(strictType);
345
332
  };
346
333
  // Not really tabs :)
347
- const tabs = (indent)=>Array(indent).fill(` `).join(``)
348
- ;
334
+ const tabs = (indent)=>Array(indent).fill(` `).join(``);
349
335
  const toIndentedItems = (indent, delimeters, items)=>{
350
336
  return `
351
337
  ${tabs(indent + 1)}${items.join(`${delimeters.afterItem ?? ``}
@@ -358,23 +344,23 @@ ${tabs(indent)}`;
358
344
  const prim = `prim` in t.raw ? t.raw.prim : `unknown`;
359
345
  // Strict mode
360
346
  if (t.typescriptType === `boolean` || t.typescriptType === `string` && prim === `string`) return `${t.typescriptType}`;
361
- if (t.typescriptType === 'number') {
347
+ if (t.typescriptType === "number") {
362
348
  const simpleBaseType = `string | BigNumber | number`;
363
349
  const typeAlias = {
364
350
  aliasType: prim,
365
351
  simpleTypeDefinition: `type ${prim} = ${simpleBaseType};`,
366
352
  simpleTypeImports: [
367
353
  {
368
- name: 'BigNumber',
354
+ name: "BigNumber",
369
355
  isDefault: true,
370
- from: 'bignumber.js'
356
+ from: "bignumber.js"
371
357
  }
372
358
  ]
373
359
  };
374
360
  addTypeAlias(typeAlias);
375
361
  return typeAlias.aliasType;
376
362
  }
377
- const simpleBaseType = t.typescriptType === 'Date' ? 'Date | string' : t.typescriptType;
363
+ const simpleBaseType = t.typescriptType === "Date" ? "Date | string" : t.typescriptType;
378
364
  const typeAlias = {
379
365
  aliasType: prim,
380
366
  simpleTypeDefinition: `type ${prim} = ${simpleBaseType};`
@@ -386,28 +372,27 @@ ${tabs(indent)}`;
386
372
  if (t.kind === `map`) {
387
373
  const typeAlias = t.map.isBigMap ? {
388
374
  aliasType: `BigMap`,
389
- simpleTypeDefinition: 'type BigMap<K, T> = MichelsonMap<K, T>;',
375
+ simpleTypeDefinition: "type BigMap<K, T> = MichelsonMap<K, T>;",
390
376
  simpleTypeImports: [
391
377
  {
392
- name: 'MichelsonMap',
393
- from: '@taquito/taquito'
378
+ name: "MichelsonMap",
379
+ from: "@taquito/taquito"
394
380
  }
395
381
  ]
396
382
  } : {
397
383
  aliasType: `MMap`,
398
- simpleTypeDefinition: 'type MMap<K, T> = MichelsonMap<K, T>;',
384
+ simpleTypeDefinition: "type MMap<K, T> = MichelsonMap<K, T>;",
399
385
  simpleTypeImports: [
400
386
  {
401
- name: 'MichelsonMap',
402
- from: '@taquito/taquito'
387
+ name: "MichelsonMap",
388
+ from: "@taquito/taquito"
403
389
  }
404
390
  ]
405
391
  };
406
392
  addTypeAlias(typeAlias);
407
393
  return `${typeAlias.aliasType}<${typeToCode(t.map.key, indent)}, ${typeToCode(t.map.value, indent)}>`;
408
394
  }
409
- if (t.kind === `object`) return `{${toIndentedItems(indent, {}, t.fields.map((a, i)=>varToCode(a, i, indent + 1) + `;`
410
- ))}}`;
395
+ if (t.kind === `object`) return `{${toIndentedItems(indent, {}, t.fields.map((a, i)=>varToCode(a, i, indent + 1) + `;`))}}`;
411
396
  if (t.kind === `union`) {
412
397
  const getUnionItem = (a, i)=>{
413
398
  const itemCode = `${varToCode(a, i, indent + 1)}`;
@@ -432,12 +417,12 @@ ${tabs(indent)}`;
432
417
  }
433
418
  if (t.kind === `never`) return `never`;
434
419
  if (t.kind === `unknown`) return `unknown`;
435
- $901f5cf476ef87a5$export$16bf6fe03653420f(t, `Unknown type`);
436
- throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`Unknown type node`, {
420
+ (0, $901f5cf476ef87a5$export$16bf6fe03653420f)(t, `Unknown type`);
421
+ throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`Unknown type node`, {
437
422
  t: t
438
423
  });
439
424
  };
440
- const varToCode = (t, i, indent, numberVarNamePrefix = '')=>{
425
+ const varToCode = (t, i, indent, numberVarNamePrefix = "")=>{
441
426
  return `${t.name ?? `${numberVarNamePrefix}${i}`}${t.type.optional ? `?` : ``}: ${typeToCode(t.type, indent)}`;
442
427
  };
443
428
  const argsToCode = (args, indent, asObject)=>{
@@ -445,9 +430,7 @@ ${tabs(indent)}`;
445
430
  if (args[0].type.kind === `unit`) return ``;
446
431
  return `${args[0].name ?? `param`}: ${typeToCode(args[0].type, indent + 1)}`;
447
432
  }
448
- const result = `${toIndentedItems(indent, {}, args.filter((x)=>x.name || x.type.kind !== `unit`
449
- ).map((a, i)=>varToCode(a, i, indent + 1, asObject ? '' : '_') + `,`
450
- ))}`;
433
+ const result = `${toIndentedItems(indent, {}, args.filter((x)=>x.name || x.type.kind !== `unit`).map((a, i)=>varToCode(a, i, indent + 1, asObject ? "" : "_") + `,`))}`;
451
434
  if (asObject) return `params: {${result}}`;
452
435
  return result;
453
436
  };
@@ -475,12 +458,10 @@ ${tabs(indent)}`;
475
458
  const methodsObjectCode = methodsObjectToCode(0);
476
459
  const storageCode = storageToCode(0);
477
460
  // Simple type aliases
478
- const simpleTypeMappingImportsAll = new Map(usedStrictTypes.map((x)=>x.simpleTypeImports ?? []
479
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []).map((x)=>[
461
+ const simpleTypeMappingImportsAll = new Map(usedStrictTypes.map((x)=>x.simpleTypeImports ?? []).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []).map((x)=>[
480
462
  `${x?.from}:${x?.name}:${x?.isDefault}`,
481
463
  x
482
- ]
483
- ));
464
+ ]));
484
465
  const simpleTypeMappingImportsFrom = [
485
466
  ...simpleTypeMappingImportsAll.values()
486
467
  ].reduce((out, x)=>{
@@ -489,25 +470,20 @@ ${tabs(indent)}`;
489
470
  });
490
471
  if (x.isDefault) entry.default = x.name;
491
472
  else entry.names.push(x.name);
492
- entry.names.sort((a, b)=>a.localeCompare(b)
493
- );
473
+ entry.names.sort((a, b)=>a.localeCompare(b));
494
474
  return out;
495
475
  }, {});
496
476
  const simpleTypeMappingImportsText = Object.keys(simpleTypeMappingImportsFrom).map((k)=>{
497
477
  const entry = simpleTypeMappingImportsFrom[k];
498
478
  const items = [
499
479
  entry.default,
500
- entry.names.length ? `{ ${entry.names.join(', ')} }` : ''
501
- ].filter((x)=>x
502
- );
503
- return `import ${items.join(', ')} from '${k}';\n`;
504
- }).join('');
505
- const simpleTypeMapping = usedStrictTypes.sort((a, b)=>a.aliasType.localeCompare(b.aliasType)
506
- ).map((x)=>x.simpleTypeDefinition
507
- ).join(`\n`);
480
+ entry.names.length ? `{ ${entry.names.join(", ")} }` : ""
481
+ ].filter((x)=>x);
482
+ return `import ${items.join(", ")} from '${k}';\n`;
483
+ }).join("");
484
+ const simpleTypeMapping = usedStrictTypes.sort((a, b)=>a.aliasType.localeCompare(b.aliasType)).map((x)=>x.simpleTypeDefinition).join(`\n`);
508
485
  const typeUtilsDefinitions = `import { ContractAbstractionFromContractType, WalletContractAbstractionFromContractType } from '${typeUtilsData.importPath}';`;
509
- const typeAliasesDefinitions = typeAliasData.mode === 'simple' ? `${simpleTypeMappingImportsText}${simpleTypeMapping}` : typeAliasData.mode === 'local' ? typeAliasData.fileContent : `import { ${usedStrictTypes.map((x)=>x.aliasType
510
- ).join(`, `)} } from '${typeAliasData.importPath}';`;
486
+ const typeAliasesDefinitions = typeAliasData.mode === "simple" ? `${simpleTypeMappingImportsText}${simpleTypeMapping}` : typeAliasData.mode === "local" ? typeAliasData.fileContent : `import { ${usedStrictTypes.map((x)=>x.aliasType).join(`, `)} } from '${typeAliasData.importPath}';`;
511
487
  const contractTypeName = `${contractName}ContractType`;
512
488
  const walletTypeName = `${contractName}WalletType`;
513
489
  const codeName = `${contractName}Code`;
@@ -545,25 +521,25 @@ export const ${codeName}: { __type: '${codeName}', protocol: string, code: objec
545
521
  const $38088c948e5b4cf5$var$parseContractWithMinimalProtocolLevel = (contractScript, format, contractLevelIndex)=>{
546
522
  const contractLevels = [
547
523
  {
548
- name: 'PsDELPH1',
524
+ name: "PsDELPH1",
549
525
  key: $3ymtt$taquitomichelcodec.Protocol.PsDELPH1
550
526
  },
551
527
  {
552
- name: 'PtEdo2Zk',
528
+ name: "PtEdo2Zk",
553
529
  key: $3ymtt$taquitomichelcodec.Protocol.PtEdo2Zk
554
530
  },
555
531
  {
556
- name: 'PsFLorena',
532
+ name: "PsFLorena",
557
533
  key: $3ymtt$taquitomichelcodec.Protocol.PsFLorena
558
534
  },
559
535
  ];
560
536
  const protocol = contractLevels[contractLevelIndex];
561
- if (!protocol) throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`Could not parse contract script`, contractScript);
537
+ if (!protocol) throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`Could not parse contract script`, contractScript);
562
538
  const p = new $3ymtt$taquitomichelcodec.Parser({
563
539
  protocol: protocol.key
564
540
  });
565
541
  try {
566
- const contract = format === 'tz' ? p.parseScript(contractScript) : p.parseJSON(JSON.parse(contractScript));
542
+ const contract = format === "tz" ? p.parseScript(contractScript) : p.parseJSON(JSON.parse(contractScript));
567
543
  if (contract) return {
568
544
  contract: contract,
569
545
  protocol: protocol
@@ -579,11 +555,9 @@ const $38088c948e5b4cf5$export$adc4e820bbd3332 = (contractScript, contractName,
579
555
  protocol: $3ymtt$taquitomichelcodec.Protocol.PsFLorena
580
556
  });
581
557
  const { contract: contract , protocol: protocol } = $38088c948e5b4cf5$var$parseContractWithMinimalProtocolLevel(contractScript, format, 0);
582
- const contractStorage = contract.find((x)=>x.prim === `storage`
583
- );
584
- const contractParameter = contract.find((x)=>x.prim === `parameter`
585
- );
586
- const storageResult = contractStorage && $b95e97a0bb3bf047$export$cc65da7b09dcddd7(contractStorage);
558
+ const contractStorage = contract.find((x)=>x.prim === `storage`);
559
+ const contractParameter = contract.find((x)=>x.prim === `parameter`);
560
+ const storageResult = contractStorage && (0, $b95e97a0bb3bf047$export$cc65da7b09dcddd7)(contractStorage);
587
561
  const storage = storageResult ?? {
588
562
  storage: {
589
563
  kind: `object`,
@@ -593,10 +567,12 @@ const $38088c948e5b4cf5$export$adc4e820bbd3332 = (contractScript, contractName,
593
567
  fields: []
594
568
  }
595
569
  };
596
- const parameterResult = contractParameter && $b95e97a0bb3bf047$export$5c00959a6ba200c1(contractParameter);
570
+ const parameterResult = contractParameter && (0, $b95e97a0bb3bf047$export$5c00959a6ba200c1)(contractParameter);
597
571
  const methods = parameterResult?.methods ?? [];
598
- const schemaOutput = $4e7cd4eb63db9934$export$eb0413f5ee90780(methods, storage);
599
- const typescriptCode = $8fdd19ff0013f28e$export$d355209543d39bc0(storage, methods, contractName, contract, protocol, typeAliasData, typeUtilsData);
572
+ // If there's only one entrypoint, then we call it "default"
573
+ if (methods.length === 1) methods[0].name = `default`;
574
+ const schemaOutput = (0, $4e7cd4eb63db9934$export$eb0413f5ee90780)(methods, storage);
575
+ const typescriptCode = (0, $8fdd19ff0013f28e$export$d355209543d39bc0)(storage, methods, contractName, contract, protocol, typeAliasData, typeUtilsData);
600
576
  return {
601
577
  schemaOutput: schemaOutput,
602
578
  typescriptCodeOutput: typescriptCode,
@@ -633,6 +609,8 @@ type MapKey = Array<any> | object | string | boolean | number;
633
609
  export type MMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => V };
634
610
  export type BigMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => Promise<V> };
635
611
 
612
+ export type chest = string & { __type: 'chest' };
613
+ export type chest_key = string & { __type: 'chest_key' };
636
614
 
637
615
  const createStringTypeTas = <T extends string>() => {
638
616
  return (value: string): T => value as T;
@@ -671,6 +649,8 @@ export const tas = {
671
649
  address: createStringTypeTas<address>(),
672
650
  bytes: createStringTypeTas<bytes>(),
673
651
  contract: createStringTypeTas<contract>(),
652
+ chest: createStringTypeTas<chest>(),
653
+ chest_key: createStringTypeTas<chest_key>(),
674
654
  timestamp: (value: string | Date): timestamp => new Date(value).toISOString() as timestamp,
675
655
 
676
656
  int: createBigNumberTypeTas<int>(),
@@ -731,13 +711,13 @@ export type WalletContractAbstractionFromContractType<TContract extends BaseCont
731
711
 
732
712
 
733
713
  const $ce33c3ba360b60b0$var$fs = {
734
- mkdir: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).mkdir),
735
- copyFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).copyFile),
736
- readdir: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).readdir),
737
- readFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).readFile),
738
- writeFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).writeFile),
739
- stat: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).stat),
740
- exists: ($parcel$interopDefault($3ymtt$fs)).existsSync
714
+ mkdir: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).mkdir),
715
+ copyFile: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).copyFile),
716
+ readdir: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).readdir),
717
+ readFile: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).readFile),
718
+ writeFile: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).writeFile),
719
+ stat: (0, $3ymtt$util.promisify)((0, ($parcel$interopDefault($3ymtt$fs))).stat),
720
+ exists: (0, ($parcel$interopDefault($3ymtt$fs))).existsSync
741
721
  };
742
722
  const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
743
723
  const allFiles = [];
@@ -746,7 +726,7 @@ const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
746
726
  withFileTypes: true
747
727
  });
748
728
  for (const f of files){
749
- const subPath = ($parcel$interopDefault($3ymtt$path)).resolve(dirPath, f.name);
729
+ const subPath = (0, ($parcel$interopDefault($3ymtt$path))).resolve(dirPath, f.name);
750
730
  if (f.isDirectory()) {
751
731
  await getAllFilesRecursive(subPath);
752
732
  continue;
@@ -758,37 +738,34 @@ const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
758
738
  await getAllFilesRecursive(rootPath);
759
739
  return allFiles;
760
740
  };
761
- const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirectory: inputTzContractDirectory , inputFiles: inputFiles , outputTypescriptDirectory: outputTypescriptDirectory , format: format , typeAliasMode: typeAliasMode , })=>{
762
- console.log(`Generating Types: ${($parcel$interopDefault($3ymtt$path)).resolve(inputTzContractDirectory)} => ${($parcel$interopDefault($3ymtt$path)).resolve(outputTypescriptDirectory)}`);
763
- const ext = '.' + format;
764
- const filesAll = await $ce33c3ba360b60b0$var$getAllFiles(inputTzContractDirectory, (x)=>x.endsWith(ext)
765
- );
766
- const files = inputFiles ? filesAll.filter((f)=>inputFiles.some((inputFile)=>f.endsWith(inputFile)
767
- )
768
- ) : filesAll;
741
+ const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirectory: inputTzContractDirectory , inputFiles: inputFiles , outputTypescriptDirectory: outputTypescriptDirectory , format: format , typeAliasMode: typeAliasMode })=>{
742
+ console.log(`Generating Types: ${(0, ($parcel$interopDefault($3ymtt$path))).resolve(inputTzContractDirectory)} => ${(0, ($parcel$interopDefault($3ymtt$path))).resolve(outputTypescriptDirectory)}`);
743
+ const ext = "." + format;
744
+ const filesAll = await $ce33c3ba360b60b0$var$getAllFiles(inputTzContractDirectory, (x)=>x.endsWith(ext));
745
+ const files = inputFiles ? filesAll.filter((f)=>inputFiles.some((inputFile)=>f.endsWith(inputFile))) : filesAll;
769
746
  console.log(`Contracts Found: ${[
770
747
  ``,
771
748
  ...files
772
749
  ].join(`\n\t- `)}`);
773
750
  const typeAliasImportPath = `@taquito/contract-type-generator`;
774
- const typeAliasData = typeAliasMode === 'local' ? {
751
+ const typeAliasData = typeAliasMode === "local" ? {
775
752
  mode: typeAliasMode,
776
- fileContent: $7d27ec5ea3b0470e$export$4bf5db15180664ad
777
- } : typeAliasMode === 'file' ? {
753
+ fileContent: (0, $7d27ec5ea3b0470e$export$4bf5db15180664ad)
754
+ } : typeAliasMode === "file" ? {
778
755
  mode: typeAliasMode,
779
756
  importPath: `./type-aliases`
780
- } : typeAliasMode === 'library' ? {
757
+ } : typeAliasMode === "library" ? {
781
758
  mode: typeAliasMode,
782
759
  importPath: typeAliasImportPath
783
760
  } : {
784
- mode: 'simple'
761
+ mode: "simple"
785
762
  };
786
- if (typeAliasMode === 'file') {
763
+ if (typeAliasMode === "file") {
787
764
  // Copy the type alias file
788
765
  await $ce33c3ba360b60b0$var$fs.mkdir(outputTypescriptDirectory, {
789
766
  recursive: true
790
767
  });
791
- await $ce33c3ba360b60b0$var$fs.writeFile(($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, './type-aliases.ts'), $7d27ec5ea3b0470e$export$4bf5db15180664ad);
768
+ await $ce33c3ba360b60b0$var$fs.writeFile((0, ($parcel$interopDefault($3ymtt$path))).join(outputTypescriptDirectory, "./type-aliases.ts"), (0, $7d27ec5ea3b0470e$export$4bf5db15180664ad));
792
769
  }
793
770
  // Copy the type utils file
794
771
  const typeUtilsData = {
@@ -797,23 +774,23 @@ const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirect
797
774
  await $ce33c3ba360b60b0$var$fs.mkdir(outputTypescriptDirectory, {
798
775
  recursive: true
799
776
  });
800
- await $ce33c3ba360b60b0$var$fs.writeFile(($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, './type-utils.ts'), $d6317276dd27d471$export$e9cf70f604100ab7);
777
+ await $ce33c3ba360b60b0$var$fs.writeFile((0, ($parcel$interopDefault($3ymtt$path))).join(outputTypescriptDirectory, "./type-utils.ts"), (0, $d6317276dd27d471$export$e9cf70f604100ab7));
801
778
  for (const fullPath of files){
802
- const fileRelativePath = fullPath.replace(($parcel$interopDefault($3ymtt$path)).resolve(inputTzContractDirectory), '');
803
- const fileName = fileRelativePath.replace(ext, '');
804
- const inputFilePath = ($parcel$interopDefault($3ymtt$path)).join(inputTzContractDirectory, fileRelativePath);
805
- const typesOutputFilePath = ($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.types.ts`));
806
- const codeContentOutputFilePath = ($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.code.ts`));
807
- const schemaContentOutputFilePath = ($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.schema.json`));
779
+ const fileRelativePath = fullPath.replace((0, ($parcel$interopDefault($3ymtt$path))).resolve(inputTzContractDirectory), "");
780
+ const fileName = fileRelativePath.replace(ext, "");
781
+ const inputFilePath = (0, ($parcel$interopDefault($3ymtt$path))).join(inputTzContractDirectory, fileRelativePath);
782
+ const typesOutputFilePath = (0, ($parcel$interopDefault($3ymtt$path))).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.types.ts`));
783
+ const codeContentOutputFilePath = (0, ($parcel$interopDefault($3ymtt$path))).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.code.ts`));
784
+ const schemaContentOutputFilePath = (0, ($parcel$interopDefault($3ymtt$path))).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.schema.json`));
808
785
  console.log(`Processing ${fileRelativePath}...`);
809
786
  try {
810
- const contractTypeName = $3f5c875567479895$export$bd8d1d28710832a7(fileName);
787
+ const contractTypeName = (0, $3f5c875567479895$export$bd8d1d28710832a7)(fileName);
811
788
  const michelsonCode = await $ce33c3ba360b60b0$var$fs.readFile(inputFilePath, {
812
789
  encoding: `utf8`
813
790
  });
814
- const { schemaOutput: schemaOutput , typescriptCodeOutput: { typesFileContent: typesFileContent , contractCodeFileContent: contractCodeFileContent } } = $38088c948e5b4cf5$export$adc4e820bbd3332(michelsonCode, contractTypeName, format, typeAliasData, typeUtilsData);
791
+ const { schemaOutput: schemaOutput , typescriptCodeOutput: { typesFileContent: typesFileContent , contractCodeFileContent: contractCodeFileContent } , } = (0, $38088c948e5b4cf5$export$adc4e820bbd3332)(michelsonCode, contractTypeName, format, typeAliasData, typeUtilsData);
815
792
  // Write output (ensure dir exists)
816
- await $ce33c3ba360b60b0$var$fs.mkdir(($parcel$interopDefault($3ymtt$path)).dirname(typesOutputFilePath), {
793
+ await $ce33c3ba360b60b0$var$fs.mkdir((0, ($parcel$interopDefault($3ymtt$path))).dirname(typesOutputFilePath), {
817
794
  recursive: true
818
795
  });
819
796
  await $ce33c3ba360b60b0$var$fs.writeFile(typesOutputFilePath, typesFileContent);
@@ -829,36 +806,32 @@ const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirect
829
806
  };
830
807
 
831
808
 
832
- const $3beaa6d78a95a243$var$getContractAbspath = (contractFilename, parsedArgs)=>$3ymtt$path.join(parsedArgs.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)
833
- ;
809
+ const $3beaa6d78a95a243$var$getContractAbspath = (contractFilename, parsedArgs)=>(0, $3ymtt$path.join)(parsedArgs.config.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);
834
810
  const $3beaa6d78a95a243$var$generateContractTypes = (parsedArgs)=>async (contractFilename)=>{
835
811
  const contractAbspath = $3beaa6d78a95a243$var$getContractAbspath(contractFilename, parsedArgs);
836
- await $ce33c3ba360b60b0$export$2ab4539ae1119673({
837
- inputTzContractDirectory: parsedArgs.artifactsDir,
812
+ await (0, $ce33c3ba360b60b0$export$2ab4539ae1119673)({
813
+ inputTzContractDirectory: parsedArgs.config.artifactsDir,
838
814
  inputFiles: [
839
815
  contractAbspath
840
816
  ],
841
- outputTypescriptDirectory: parsedArgs.typescriptDir,
842
- format: 'tz',
843
- typeAliasMode: parsedArgs.typeAliasMode ?? 'file'
817
+ outputTypescriptDirectory: parsedArgs.typescriptDir || "types",
818
+ format: "tz",
819
+ typeAliasMode: parsedArgs.typeAliasMode ?? "file"
844
820
  });
845
821
  return `${contractFilename}: Types generated`;
846
- }
847
- ;
822
+ };
848
823
  const $3beaa6d78a95a243$var$generateContractTypesAll = async (parsedArgs)=>{
849
- const files = await ($parcel$interopDefault($3ymtt$fastglob))("**/*.tz", {
850
- cwd: parsedArgs.artifactsDir
824
+ const files = await (0, ($parcel$interopDefault($3ymtt$fastglob)))("**/*.tz", {
825
+ cwd: parsedArgs.config.artifactsDir
851
826
  });
852
827
  return await Promise.all(files.map($3beaa6d78a95a243$var$generateContractTypes(parsedArgs)));
853
828
  };
854
829
  const $3beaa6d78a95a243$export$3350b7b754d5c00c = (parsedArgs)=>{
855
- debugger;
856
- parsedArgs.typescriptDir = parsedArgs.typescriptDir || 'types';
857
- console.log('generateTypes', {
830
+ parsedArgs.typescriptDir = parsedArgs.typescriptDir || "types";
831
+ console.log("generateTypes", {
858
832
  typescriptDir: parsedArgs.typescriptDir
859
833
  });
860
- const argsTyped = parsedArgs;
861
- const p = argsTyped.contract ? $3beaa6d78a95a243$var$generateContractTypes(argsTyped)(argsTyped.contract) : $3beaa6d78a95a243$var$generateContractTypesAll(argsTyped);
834
+ const p = parsedArgs.contract ? $3beaa6d78a95a243$var$generateContractTypes(parsedArgs)(parsedArgs.contract) : $3beaa6d78a95a243$var$generateContractTypesAll(parsedArgs);
862
835
  return p.then((data)=>{
863
836
  console.log(Array.isArray(data) ? data.join("\n") : data);
864
837
  });
@@ -868,29 +841,29 @@ const $3beaa6d78a95a243$export$7191f9b9098a3ea4 = {
868
841
  };
869
842
 
870
843
 
871
- $3ymtt$taquerianodesdk.Plugin.create((i18n)=>({
844
+ (0, $3ymtt$taquerianodesdk.Plugin).create((i18n)=>({
872
845
  alias: "contract-types",
873
846
  schema: "1.0",
874
847
  version: "0.1",
875
848
  tasks: [
876
- $3ymtt$taquerianodesdk.Task.create({
849
+ (0, $3ymtt$taquerianodesdk.Task).create({
877
850
  task: "generate types",
878
851
  command: "generate types [typescriptDir]",
879
852
  description: "Generate types for a contract to be used with taquito",
880
853
  positionals: [
881
- $3ymtt$taquerianodesdk.PositionalArg.create({
854
+ (0, $3ymtt$taquerianodesdk.PositionalArg).create({
882
855
  placeholder: "typescriptDir",
883
856
  description: "The output directory for the generated type files",
884
857
  defaultValue: "types"
885
- })
858
+ }),
886
859
  ],
887
860
  options: [
888
- $3ymtt$taquerianodesdk.Option.create({
861
+ (0, $3ymtt$taquerianodesdk.Option).create({
889
862
  shortFlag: "t",
890
863
  flag: "typeAliasMode",
891
864
  choices: [
892
- 'file',
893
- 'simple'
865
+ "file",
866
+ "simple"
894
867
  ],
895
868
  description: "The type aliases used in the generated types"
896
869
  }),
@@ -902,9 +875,8 @@ $3ymtt$taquerianodesdk.Plugin.create((i18n)=>({
902
875
  handler: "proxy"
903
876
  }),
904
877
  ],
905
- proxy: $3beaa6d78a95a243$export$7191f9b9098a3ea4.generateTypes
906
- })
907
- , process.argv);
878
+ proxy: (0, $3beaa6d78a95a243$export$7191f9b9098a3ea4).generateTypes
879
+ }), process.argv);
908
880
 
909
881
 
910
882
  //# sourceMappingURL=index.js.map