@taqueria/plugin-contract-types 0.3.1 → 0.4.0-rc3

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,7 +268,7 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
283
268
  typescriptType: `string`
284
269
  };
285
270
  // chest
286
- if (node.prim === 'chest' || node.prim === 'chest_key') return {
271
+ if (node.prim === "chest" || node.prim === "chest_key") return {
287
272
  kind: `value`,
288
273
  raw: node,
289
274
  value: node.prim,
@@ -295,8 +280,8 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
295
280
  raw: node
296
281
  };
297
282
  // Unknown
298
- $901f5cf476ef87a5$export$16bf6fe03653420f(node, `Unknown type`);
299
- throw new $901f5cf476ef87a5$export$d214d56e7a53a664(`Unknown type`, {
283
+ (0, $901f5cf476ef87a5$export$16bf6fe03653420f)(node, `Unknown type`);
284
+ throw new (0, $901f5cf476ef87a5$export$d214d56e7a53a664)(`Unknown type`, {
300
285
  node: node
301
286
  });
302
287
  };
@@ -306,8 +291,7 @@ const $b95e97a0bb3bf047$var$visitType = (node, options)=>{
306
291
  const $4e7cd4eb63db9934$export$eb0413f5ee90780 = (methods, storage)=>{
307
292
  const getSchemaObjectType = (vars)=>{
308
293
  // console.log('getSchemaObjectType', { vars });
309
- if (vars.some((x)=>!x
310
- )) 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`, {
311
295
  vars: vars
312
296
  });
313
297
  return vars.reduce((out, x, i)=>{
@@ -344,12 +328,10 @@ const $4e7cd4eb63db9934$export$eb0413f5ee90780 = (methods, storage)=>{
344
328
  const $8fdd19ff0013f28e$export$d355209543d39bc0 = (storage, methods, contractName, parsedContract, protocol, typeAliasData, typeUtilsData)=>{
345
329
  const usedStrictTypes = [];
346
330
  const addTypeAlias = (strictType)=>{
347
- if (!usedStrictTypes.some((x)=>x.aliasType === strictType.aliasType
348
- )) usedStrictTypes.push(strictType);
331
+ if (!usedStrictTypes.some((x)=>x.aliasType === strictType.aliasType)) usedStrictTypes.push(strictType);
349
332
  };
350
333
  // Not really tabs :)
351
- const tabs = (indent)=>Array(indent).fill(` `).join(``)
352
- ;
334
+ const tabs = (indent)=>Array(indent).fill(` `).join(``);
353
335
  const toIndentedItems = (indent, delimeters, items)=>{
354
336
  return `
355
337
  ${tabs(indent + 1)}${items.join(`${delimeters.afterItem ?? ``}
@@ -362,23 +344,23 @@ ${tabs(indent)}`;
362
344
  const prim = `prim` in t.raw ? t.raw.prim : `unknown`;
363
345
  // Strict mode
364
346
  if (t.typescriptType === `boolean` || t.typescriptType === `string` && prim === `string`) return `${t.typescriptType}`;
365
- if (t.typescriptType === 'number') {
347
+ if (t.typescriptType === "number") {
366
348
  const simpleBaseType = `string | BigNumber | number`;
367
349
  const typeAlias = {
368
350
  aliasType: prim,
369
351
  simpleTypeDefinition: `type ${prim} = ${simpleBaseType};`,
370
352
  simpleTypeImports: [
371
353
  {
372
- name: 'BigNumber',
354
+ name: "BigNumber",
373
355
  isDefault: true,
374
- from: 'bignumber.js'
356
+ from: "bignumber.js"
375
357
  }
376
358
  ]
377
359
  };
378
360
  addTypeAlias(typeAlias);
379
361
  return typeAlias.aliasType;
380
362
  }
381
- const simpleBaseType = t.typescriptType === 'Date' ? 'Date | string' : t.typescriptType;
363
+ const simpleBaseType = t.typescriptType === "Date" ? "Date | string" : t.typescriptType;
382
364
  const typeAlias = {
383
365
  aliasType: prim,
384
366
  simpleTypeDefinition: `type ${prim} = ${simpleBaseType};`
@@ -390,28 +372,27 @@ ${tabs(indent)}`;
390
372
  if (t.kind === `map`) {
391
373
  const typeAlias = t.map.isBigMap ? {
392
374
  aliasType: `BigMap`,
393
- simpleTypeDefinition: 'type BigMap<K, T> = MichelsonMap<K, T>;',
375
+ simpleTypeDefinition: "type BigMap<K, T> = MichelsonMap<K, T>;",
394
376
  simpleTypeImports: [
395
377
  {
396
- name: 'MichelsonMap',
397
- from: '@taquito/taquito'
378
+ name: "MichelsonMap",
379
+ from: "@taquito/taquito"
398
380
  }
399
381
  ]
400
382
  } : {
401
383
  aliasType: `MMap`,
402
- simpleTypeDefinition: 'type MMap<K, T> = MichelsonMap<K, T>;',
384
+ simpleTypeDefinition: "type MMap<K, T> = MichelsonMap<K, T>;",
403
385
  simpleTypeImports: [
404
386
  {
405
- name: 'MichelsonMap',
406
- from: '@taquito/taquito'
387
+ name: "MichelsonMap",
388
+ from: "@taquito/taquito"
407
389
  }
408
390
  ]
409
391
  };
410
392
  addTypeAlias(typeAlias);
411
393
  return `${typeAlias.aliasType}<${typeToCode(t.map.key, indent)}, ${typeToCode(t.map.value, indent)}>`;
412
394
  }
413
- if (t.kind === `object`) return `{${toIndentedItems(indent, {}, t.fields.map((a, i)=>varToCode(a, i, indent + 1) + `;`
414
- ))}}`;
395
+ if (t.kind === `object`) return `{${toIndentedItems(indent, {}, t.fields.map((a, i)=>varToCode(a, i, indent + 1) + `;`))}}`;
415
396
  if (t.kind === `union`) {
416
397
  const getUnionItem = (a, i)=>{
417
398
  const itemCode = `${varToCode(a, i, indent + 1)}`;
@@ -436,12 +417,12 @@ ${tabs(indent)}`;
436
417
  }
437
418
  if (t.kind === `never`) return `never`;
438
419
  if (t.kind === `unknown`) return `unknown`;
439
- $901f5cf476ef87a5$export$16bf6fe03653420f(t, `Unknown type`);
440
- 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`, {
441
422
  t: t
442
423
  });
443
424
  };
444
- const varToCode = (t, i, indent, numberVarNamePrefix = '')=>{
425
+ const varToCode = (t, i, indent, numberVarNamePrefix = "")=>{
445
426
  return `${t.name ?? `${numberVarNamePrefix}${i}`}${t.type.optional ? `?` : ``}: ${typeToCode(t.type, indent)}`;
446
427
  };
447
428
  const argsToCode = (args, indent, asObject)=>{
@@ -449,9 +430,7 @@ ${tabs(indent)}`;
449
430
  if (args[0].type.kind === `unit`) return ``;
450
431
  return `${args[0].name ?? `param`}: ${typeToCode(args[0].type, indent + 1)}`;
451
432
  }
452
- const result = `${toIndentedItems(indent, {}, args.filter((x)=>x.name || x.type.kind !== `unit`
453
- ).map((a, i)=>varToCode(a, i, indent + 1, asObject ? '' : '_') + `,`
454
- ))}`;
433
+ const result = `${toIndentedItems(indent, {}, args.filter((x)=>x.name || x.type.kind !== `unit`).map((a, i)=>varToCode(a, i, indent + 1, asObject ? "" : "_") + `,`))}`;
455
434
  if (asObject) return `params: {${result}}`;
456
435
  return result;
457
436
  };
@@ -479,12 +458,10 @@ ${tabs(indent)}`;
479
458
  const methodsObjectCode = methodsObjectToCode(0);
480
459
  const storageCode = storageToCode(0);
481
460
  // Simple type aliases
482
- const simpleTypeMappingImportsAll = new Map(usedStrictTypes.map((x)=>x.simpleTypeImports ?? []
483
- ).reduce($901f5cf476ef87a5$export$37679993c4e6bc41, []).map((x)=>[
461
+ const simpleTypeMappingImportsAll = new Map(usedStrictTypes.map((x)=>x.simpleTypeImports ?? []).reduce((0, $901f5cf476ef87a5$export$37679993c4e6bc41), []).map((x)=>[
484
462
  `${x?.from}:${x?.name}:${x?.isDefault}`,
485
463
  x
486
- ]
487
- ));
464
+ ]));
488
465
  const simpleTypeMappingImportsFrom = [
489
466
  ...simpleTypeMappingImportsAll.values()
490
467
  ].reduce((out, x)=>{
@@ -493,25 +470,20 @@ ${tabs(indent)}`;
493
470
  });
494
471
  if (x.isDefault) entry.default = x.name;
495
472
  else entry.names.push(x.name);
496
- entry.names.sort((a, b)=>a.localeCompare(b)
497
- );
473
+ entry.names.sort((a, b)=>a.localeCompare(b));
498
474
  return out;
499
475
  }, {});
500
476
  const simpleTypeMappingImportsText = Object.keys(simpleTypeMappingImportsFrom).map((k)=>{
501
477
  const entry = simpleTypeMappingImportsFrom[k];
502
478
  const items = [
503
479
  entry.default,
504
- entry.names.length ? `{ ${entry.names.join(', ')} }` : ''
505
- ].filter((x)=>x
506
- );
507
- return `import ${items.join(', ')} from '${k}';\n`;
508
- }).join('');
509
- const simpleTypeMapping = usedStrictTypes.sort((a, b)=>a.aliasType.localeCompare(b.aliasType)
510
- ).map((x)=>x.simpleTypeDefinition
511
- ).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`);
512
485
  const typeUtilsDefinitions = `import { ContractAbstractionFromContractType, WalletContractAbstractionFromContractType } from '${typeUtilsData.importPath}';`;
513
- const typeAliasesDefinitions = typeAliasData.mode === 'simple' ? `${simpleTypeMappingImportsText}${simpleTypeMapping}` : typeAliasData.mode === 'local' ? typeAliasData.fileContent : `import { ${usedStrictTypes.map((x)=>x.aliasType
514
- ).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}';`;
515
487
  const contractTypeName = `${contractName}ContractType`;
516
488
  const walletTypeName = `${contractName}WalletType`;
517
489
  const codeName = `${contractName}Code`;
@@ -549,25 +521,25 @@ export const ${codeName}: { __type: '${codeName}', protocol: string, code: objec
549
521
  const $38088c948e5b4cf5$var$parseContractWithMinimalProtocolLevel = (contractScript, format, contractLevelIndex)=>{
550
522
  const contractLevels = [
551
523
  {
552
- name: 'PsDELPH1',
524
+ name: "PsDELPH1",
553
525
  key: $3ymtt$taquitomichelcodec.Protocol.PsDELPH1
554
526
  },
555
527
  {
556
- name: 'PtEdo2Zk',
528
+ name: "PtEdo2Zk",
557
529
  key: $3ymtt$taquitomichelcodec.Protocol.PtEdo2Zk
558
530
  },
559
531
  {
560
- name: 'PsFLorena',
532
+ name: "PsFLorena",
561
533
  key: $3ymtt$taquitomichelcodec.Protocol.PsFLorena
562
534
  },
563
535
  ];
564
536
  const protocol = contractLevels[contractLevelIndex];
565
- 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);
566
538
  const p = new $3ymtt$taquitomichelcodec.Parser({
567
539
  protocol: protocol.key
568
540
  });
569
541
  try {
570
- 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));
571
543
  if (contract) return {
572
544
  contract: contract,
573
545
  protocol: protocol
@@ -583,11 +555,9 @@ const $38088c948e5b4cf5$export$adc4e820bbd3332 = (contractScript, contractName,
583
555
  protocol: $3ymtt$taquitomichelcodec.Protocol.PsFLorena
584
556
  });
585
557
  const { contract: contract , protocol: protocol } = $38088c948e5b4cf5$var$parseContractWithMinimalProtocolLevel(contractScript, format, 0);
586
- const contractStorage = contract.find((x)=>x.prim === `storage`
587
- );
588
- const contractParameter = contract.find((x)=>x.prim === `parameter`
589
- );
590
- 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);
591
561
  const storage = storageResult ?? {
592
562
  storage: {
593
563
  kind: `object`,
@@ -597,12 +567,12 @@ const $38088c948e5b4cf5$export$adc4e820bbd3332 = (contractScript, contractName,
597
567
  fields: []
598
568
  }
599
569
  };
600
- const parameterResult = contractParameter && $b95e97a0bb3bf047$export$5c00959a6ba200c1(contractParameter);
570
+ const parameterResult = contractParameter && (0, $b95e97a0bb3bf047$export$5c00959a6ba200c1)(contractParameter);
601
571
  const methods = parameterResult?.methods ?? [];
602
572
  // If there's only one entrypoint, then we call it "default"
603
573
  if (methods.length === 1) methods[0].name = `default`;
604
- const schemaOutput = $4e7cd4eb63db9934$export$eb0413f5ee90780(methods, storage);
605
- const typescriptCode = $8fdd19ff0013f28e$export$d355209543d39bc0(storage, methods, contractName, contract, protocol, typeAliasData, typeUtilsData);
574
+ const schemaOutput = (0, $4e7cd4eb63db9934$export$eb0413f5ee90780)(methods, storage);
575
+ const typescriptCode = (0, $8fdd19ff0013f28e$export$d355209543d39bc0)(storage, methods, contractName, contract, protocol, typeAliasData, typeUtilsData);
606
576
  return {
607
577
  schemaOutput: schemaOutput,
608
578
  typescriptCodeOutput: typescriptCode,
@@ -741,13 +711,13 @@ export type WalletContractAbstractionFromContractType<TContract extends BaseCont
741
711
 
742
712
 
743
713
  const $ce33c3ba360b60b0$var$fs = {
744
- mkdir: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).mkdir),
745
- copyFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).copyFile),
746
- readdir: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).readdir),
747
- readFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).readFile),
748
- writeFile: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).writeFile),
749
- stat: $3ymtt$util.promisify(($parcel$interopDefault($3ymtt$fs)).stat),
750
- 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
751
721
  };
752
722
  const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
753
723
  const allFiles = [];
@@ -756,7 +726,7 @@ const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
756
726
  withFileTypes: true
757
727
  });
758
728
  for (const f of files){
759
- const subPath = ($parcel$interopDefault($3ymtt$path)).resolve(dirPath, f.name);
729
+ const subPath = (0, ($parcel$interopDefault($3ymtt$path))).resolve(dirPath, f.name);
760
730
  if (f.isDirectory()) {
761
731
  await getAllFilesRecursive(subPath);
762
732
  continue;
@@ -768,37 +738,34 @@ const $ce33c3ba360b60b0$var$getAllFiles = async (rootPath, filter)=>{
768
738
  await getAllFilesRecursive(rootPath);
769
739
  return allFiles;
770
740
  };
771
- const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirectory: inputTzContractDirectory , inputFiles: inputFiles , outputTypescriptDirectory: outputTypescriptDirectory , format: format , typeAliasMode: typeAliasMode , })=>{
772
- console.log(`Generating Types: ${($parcel$interopDefault($3ymtt$path)).resolve(inputTzContractDirectory)} => ${($parcel$interopDefault($3ymtt$path)).resolve(outputTypescriptDirectory)}`);
773
- const ext = '.' + format;
774
- const filesAll = await $ce33c3ba360b60b0$var$getAllFiles(inputTzContractDirectory, (x)=>x.endsWith(ext)
775
- );
776
- const files = inputFiles ? filesAll.filter((f)=>inputFiles.some((inputFile)=>f.endsWith(inputFile)
777
- )
778
- ) : 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;
779
746
  console.log(`Contracts Found: ${[
780
747
  ``,
781
748
  ...files
782
749
  ].join(`\n\t- `)}`);
783
750
  const typeAliasImportPath = `@taquito/contract-type-generator`;
784
- const typeAliasData = typeAliasMode === 'local' ? {
751
+ const typeAliasData = typeAliasMode === "local" ? {
785
752
  mode: typeAliasMode,
786
- fileContent: $7d27ec5ea3b0470e$export$4bf5db15180664ad
787
- } : typeAliasMode === 'file' ? {
753
+ fileContent: (0, $7d27ec5ea3b0470e$export$4bf5db15180664ad)
754
+ } : typeAliasMode === "file" ? {
788
755
  mode: typeAliasMode,
789
756
  importPath: `./type-aliases`
790
- } : typeAliasMode === 'library' ? {
757
+ } : typeAliasMode === "library" ? {
791
758
  mode: typeAliasMode,
792
759
  importPath: typeAliasImportPath
793
760
  } : {
794
- mode: 'simple'
761
+ mode: "simple"
795
762
  };
796
- if (typeAliasMode === 'file') {
763
+ if (typeAliasMode === "file") {
797
764
  // Copy the type alias file
798
765
  await $ce33c3ba360b60b0$var$fs.mkdir(outputTypescriptDirectory, {
799
766
  recursive: true
800
767
  });
801
- 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));
802
769
  }
803
770
  // Copy the type utils file
804
771
  const typeUtilsData = {
@@ -807,23 +774,23 @@ const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirect
807
774
  await $ce33c3ba360b60b0$var$fs.mkdir(outputTypescriptDirectory, {
808
775
  recursive: true
809
776
  });
810
- 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));
811
778
  for (const fullPath of files){
812
- const fileRelativePath = fullPath.replace(($parcel$interopDefault($3ymtt$path)).resolve(inputTzContractDirectory), '');
813
- const fileName = fileRelativePath.replace(ext, '');
814
- const inputFilePath = ($parcel$interopDefault($3ymtt$path)).join(inputTzContractDirectory, fileRelativePath);
815
- const typesOutputFilePath = ($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.types.ts`));
816
- const codeContentOutputFilePath = ($parcel$interopDefault($3ymtt$path)).join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.code.ts`));
817
- 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`));
818
785
  console.log(`Processing ${fileRelativePath}...`);
819
786
  try {
820
- const contractTypeName = $3f5c875567479895$export$bd8d1d28710832a7(fileName);
787
+ const contractTypeName = (0, $3f5c875567479895$export$bd8d1d28710832a7)(fileName);
821
788
  const michelsonCode = await $ce33c3ba360b60b0$var$fs.readFile(inputFilePath, {
822
789
  encoding: `utf8`
823
790
  });
824
- 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);
825
792
  // Write output (ensure dir exists)
826
- await $ce33c3ba360b60b0$var$fs.mkdir(($parcel$interopDefault($3ymtt$path)).dirname(typesOutputFilePath), {
793
+ await $ce33c3ba360b60b0$var$fs.mkdir((0, ($parcel$interopDefault($3ymtt$path))).dirname(typesOutputFilePath), {
827
794
  recursive: true
828
795
  });
829
796
  await $ce33c3ba360b60b0$var$fs.writeFile(typesOutputFilePath, typesFileContent);
@@ -839,35 +806,32 @@ const $ce33c3ba360b60b0$export$2ab4539ae1119673 = async ({ inputTzContractDirect
839
806
  };
840
807
 
841
808
 
842
- const $3beaa6d78a95a243$var$getContractAbspath = (contractFilename, parsedArgs)=>$3ymtt$path.join(parsedArgs.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`)
843
- ;
809
+ const $3beaa6d78a95a243$var$getContractAbspath = (contractFilename, parsedArgs)=>(0, $3ymtt$path.join)(parsedArgs.config.artifactsDir, /\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`);
844
810
  const $3beaa6d78a95a243$var$generateContractTypes = (parsedArgs)=>async (contractFilename)=>{
845
811
  const contractAbspath = $3beaa6d78a95a243$var$getContractAbspath(contractFilename, parsedArgs);
846
- await $ce33c3ba360b60b0$export$2ab4539ae1119673({
847
- inputTzContractDirectory: parsedArgs.artifactsDir,
812
+ await (0, $ce33c3ba360b60b0$export$2ab4539ae1119673)({
813
+ inputTzContractDirectory: parsedArgs.config.artifactsDir,
848
814
  inputFiles: [
849
815
  contractAbspath
850
816
  ],
851
- outputTypescriptDirectory: parsedArgs.typescriptDir,
852
- format: 'tz',
853
- typeAliasMode: parsedArgs.typeAliasMode ?? 'file'
817
+ outputTypescriptDirectory: parsedArgs.typescriptDir || "types",
818
+ format: "tz",
819
+ typeAliasMode: parsedArgs.typeAliasMode ?? "file"
854
820
  });
855
821
  return `${contractFilename}: Types generated`;
856
- }
857
- ;
822
+ };
858
823
  const $3beaa6d78a95a243$var$generateContractTypesAll = async (parsedArgs)=>{
859
- const files = await ($parcel$interopDefault($3ymtt$fastglob))("**/*.tz", {
860
- cwd: parsedArgs.artifactsDir
824
+ const files = await (0, ($parcel$interopDefault($3ymtt$fastglob)))("**/*.tz", {
825
+ cwd: parsedArgs.config.artifactsDir
861
826
  });
862
827
  return await Promise.all(files.map($3beaa6d78a95a243$var$generateContractTypes(parsedArgs)));
863
828
  };
864
829
  const $3beaa6d78a95a243$export$3350b7b754d5c00c = (parsedArgs)=>{
865
- parsedArgs.typescriptDir = parsedArgs.typescriptDir || 'types';
866
- console.log('generateTypes', {
830
+ parsedArgs.typescriptDir = parsedArgs.typescriptDir || "types";
831
+ console.log("generateTypes", {
867
832
  typescriptDir: parsedArgs.typescriptDir
868
833
  });
869
- const argsTyped = parsedArgs;
870
- 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);
871
835
  return p.then((data)=>{
872
836
  console.log(Array.isArray(data) ? data.join("\n") : data);
873
837
  });
@@ -877,29 +841,29 @@ const $3beaa6d78a95a243$export$7191f9b9098a3ea4 = {
877
841
  };
878
842
 
879
843
 
880
- $3ymtt$taquerianodesdk.Plugin.create((i18n)=>({
844
+ (0, $3ymtt$taquerianodesdk.Plugin).create((i18n)=>({
881
845
  alias: "contract-types",
882
846
  schema: "1.0",
883
847
  version: "0.1",
884
848
  tasks: [
885
- $3ymtt$taquerianodesdk.Task.create({
849
+ (0, $3ymtt$taquerianodesdk.Task).create({
886
850
  task: "generate types",
887
851
  command: "generate types [typescriptDir]",
888
852
  description: "Generate types for a contract to be used with taquito",
889
853
  positionals: [
890
- $3ymtt$taquerianodesdk.PositionalArg.create({
854
+ (0, $3ymtt$taquerianodesdk.PositionalArg).create({
891
855
  placeholder: "typescriptDir",
892
856
  description: "The output directory for the generated type files",
893
857
  defaultValue: "types"
894
- })
858
+ }),
895
859
  ],
896
860
  options: [
897
- $3ymtt$taquerianodesdk.Option.create({
861
+ (0, $3ymtt$taquerianodesdk.Option).create({
898
862
  shortFlag: "t",
899
863
  flag: "typeAliasMode",
900
864
  choices: [
901
- 'file',
902
- 'simple'
865
+ "file",
866
+ "simple"
903
867
  ],
904
868
  description: "The type aliases used in the generated types"
905
869
  }),
@@ -911,9 +875,8 @@ $3ymtt$taquerianodesdk.Plugin.create((i18n)=>({
911
875
  handler: "proxy"
912
876
  }),
913
877
  ],
914
- proxy: $3beaa6d78a95a243$export$7191f9b9098a3ea4.generateTypes
915
- })
916
- , process.argv);
878
+ proxy: (0, $3beaa6d78a95a243$export$7191f9b9098a3ea4).generateTypes
879
+ }), process.argv);
917
880
 
918
881
 
919
882
  //# sourceMappingURL=index.js.map