@taqueria/plugin-contract-types 0.42.3 → 0.42.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -118
- package/index.cjs.map +1 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/tasks.ts +12 -13
- package/tsconfig.json +1 -1
- package/_readme.eta +0 -133
package/README.md
CHANGED
|
@@ -10,121 +10,4 @@ Benefits of using generated types:
|
|
|
10
10
|
- Calling smart contract methods with types is done directly, removing the need for utility methods
|
|
11
11
|
- Simplifies your code and improves readability
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Taqueria v0.26.0 or later
|
|
16
|
-
- Node.js v16.16 or later. (v17.x.x or later is not supported)
|
|
17
|
-
- Taquito v11.2 or later (optional)
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
To install the Contract Types plugin on a Taqueria project, navigate to the project folder and run:
|
|
22
|
-
```shell
|
|
23
|
-
taq install @taqueria/plugin-contract-types
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Configuration
|
|
27
|
-
|
|
28
|
-
This plugin will look for Michelson files according to the `artifactsDir` configured in `.taq/config.json`. By default, this value is `artifacts` but can be changed as needed
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
The plugin provides a single command to Taqueria: `taq generate types`
|
|
33
|
-
|
|
34
|
-
This will look for `.tz` files in the `artifacts` directory and will generate a series of related `.ts` files in the `/types` directory (default folder created to store the generated files). These files export type definitions for each method which can then be used by Taquito and your IDE
|
|
35
|
-
|
|
36
|
-
### The `generate types` Command
|
|
37
|
-
|
|
38
|
-
#### Syntax
|
|
39
|
-
```shell
|
|
40
|
-
taq generate types [typeOutputDir]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
#### Parameters
|
|
44
|
-
|
|
45
|
-
| parameter | required | description |
|
|
46
|
-
|:-------------:|:-----------|----------------------------------------------------|
|
|
47
|
-
| typeOutputDir | no | The output directory for the `.ts` files generated |
|
|
48
|
-
|
|
49
|
-
#### CLI Aliases
|
|
50
|
-
|
|
51
|
-
The following aliases are interchangable with `generate types`
|
|
52
|
-
- `gen`
|
|
53
|
-
- `gentypes`
|
|
54
|
-
|
|
55
|
-
#### Options
|
|
56
|
-
|
|
57
|
-
The `generate types` command will accept the following optional parameters:
|
|
58
|
-
|
|
59
|
-
| flag | name | description |
|
|
60
|
-
|:-----:|:--------------|----------------------------------------------|
|
|
61
|
-
| -t | typeAliasMode | Use type aliases in the generated types |
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Taquito Workflow Improvements
|
|
65
|
-
|
|
66
|
-
The generated TS types can be used in a Taquito project which provides an improved developing experience, and simplifies the way types are provided to Taquito method calls. Some examples of how these changes are put into use are detailed below
|
|
67
|
-
|
|
68
|
-
> ### :page_with_curl: Note
|
|
69
|
-
> You can view the full example in the `example-usage.ts` file on Github: [example-usage.ts](https://github.com/pinnacle-labs/taqueria/blob/main/taqueria-plugin-contract-types/example/example-usage.ts)
|
|
70
|
-
|
|
71
|
-
### Calling the `.at` Method of a Contract
|
|
72
|
-
|
|
73
|
-
Traditionally, calling the `.at` method of a contract with Taquito required the developer to pass the parameter's type via a utility method:
|
|
74
|
-
```ts Utility Method
|
|
75
|
-
const contract = await Tezos.contract.at(`KT123...`, contractAbstractionComposer<TestContractType>());
|
|
76
|
-
```
|
|
77
|
-
or a cast:
|
|
78
|
-
```ts Cast
|
|
79
|
-
const contract = await Tezos.contract.at(`KT123...`) as ContractProviderFromContractType<TestContractType>;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
When using generated types, the developer can now directly use the type in the call to `.at`:
|
|
83
|
-
```ts
|
|
84
|
-
const contract = await Tezos.contract.at<TestContract>(`KT123...`);
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Using a Wallet
|
|
88
|
-
|
|
89
|
-
Using a wallet is simplified in a similar way:
|
|
90
|
-
```ts
|
|
91
|
-
const contract = await Tezos.wallet.at(`KT123...`, walletAbstractionComposer<TestContractType>());
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Becomes:
|
|
95
|
-
```ts
|
|
96
|
-
const contract = await Tezos.wallet.at<TestWalletContract>(`KT123...`);
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Contract Origination
|
|
100
|
-
|
|
101
|
-
The Taquito contract origination did not have any way to provide a type, so this used to require a cast:
|
|
102
|
-
```ts
|
|
103
|
-
const originationResult = await Tezos.contract.originate({...});
|
|
104
|
-
const contract = await originationResult.contract(5) as ContractProviderFromContractType<TestContractType2>;
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Now, it can directly accept a type:
|
|
108
|
-
```ts
|
|
109
|
-
const originationResult = await Tezos.contract.originate({...});
|
|
110
|
-
const contract = await originationResult.contract<TestContract2>(5);
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
### Storage
|
|
115
|
-
|
|
116
|
-
When accessing storage, there was no way to pass the type through the contract class. This required providing the type a second time:
|
|
117
|
-
```ts
|
|
118
|
-
const contract = await Tezos.contract.at(`KT123...`) as ContractProviderFromContractType<TestContractType>;
|
|
119
|
-
const storage = await contract.storage<StorageFromContractType<TestContractType>>();
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Now, the contract type provides the default storage type:
|
|
123
|
-
```ts
|
|
124
|
-
const contract = await Tezos.contract.at<TestContract>(`KT123...`);
|
|
125
|
-
const storage = await contract.storage();
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Plugin Architecture
|
|
129
|
-
|
|
130
|
-
This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM
|
|
13
|
+
For more information, please see our documentation for the [Taqueria Contract Types plugin](https://taqueria.io/docs/plugins/plugin-contract-types/)
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","tasks.ts","src/cli-process.ts","src/generator/contract-name.ts","src/generator/process.ts","src/generator/common.ts","src/generator/contract-parser.ts","src/generator/schema-output.ts","src/generator/typescript-output.ts","src/type-aliases-file-content.ts","src/type-utils-file-content.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport { tasks } from './tasks';\nexport { generateContractTypesProcessContractFiles } from './src/cli-process';\n\nPlugin.create(i18n => ({\n\talias: 'contract-types',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'generate types',\n\t\t\tcommand: 'generate types [typescriptDir]',\n\t\t\tdescription: 'Generate types for a contract to be used with taquito',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'typescriptDir',\n\t\t\t\t\tdescription: 'The output directory for the generated type files',\n\t\t\t\t\tdefaultValue: 'types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tflag: 'typeAliasMode',\n\t\t\t\t\tchoices: ['file', 'simple'],\n\t\t\t\t\tdescription: 'The type aliases used in the generated types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['gen types', 'gentypes'],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t],\n\tproxy: tasks.generateTypes,\n}), process.argv);\n","import { isContractFile, RequestArgs } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { generateContractTypesProcessContractFiles } from './src/cli-process';\ninterface Opts extends RequestArgs.t {\n\t// TODO: Document these\n\ttypescriptDir?: string;\n\ttypeAliasMode?: 'local' | 'file' | 'library' | 'simple';\n\tcontract?: string;\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(\n\t\tparsedArgs.config.artifactsDir ?? 'artifacts',\n\t\t/\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`,\n\t);\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tasync (contractFilename: string): Promise<string> => {\n\t\tconst contractAbspath = getContractAbspath(contractFilename, parsedArgs);\n\t\tawait generateContractTypesProcessContractFiles({\n\t\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\t\tinputFiles: [contractAbspath],\n\t\t\toutputTypescriptDirectory: parsedArgs.typescriptDir || 'types',\n\t\t\tformat: 'tz',\n\t\t\ttypeAliasMode: parsedArgs.typeAliasMode ?? 'file',\n\t\t});\n\n\t\treturn `${contractFilename}: Types generated`;\n\t};\n\nconst generateContractTypesAll = async (parsedArgs: Opts): Promise<string[]> => {\n\tconst files = await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir });\n\tconst contractFiles = files.filter(isContractFile);\n\treturn await Promise.all(contractFiles.map(generateContractTypes(parsedArgs)));\n};\n\nexport const generateTypes = (parsedArgs: Opts) => {\n\tparsedArgs.typescriptDir = parsedArgs.typescriptDir || 'types';\n\n\tconsole.log('generateTypes', {\n\t\ttypescriptDir: parsedArgs.typescriptDir,\n\t});\n\n\tconst p = parsedArgs.contract\n\t\t? generateContractTypes(parsedArgs)(parsedArgs.contract)\n\t\t: generateContractTypesAll(parsedArgs);\n\n\treturn p.then(data => {\n\t\tconsole.log(\n\t\t\t(Array.isArray(data))\n\t\t\t\t? data.join('\\n')\n\t\t\t\t: data,\n\t\t);\n\t});\n};\n\nexport const tasks = {\n\tgenerateTypes,\n};\n","import fsRaw from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\nimport { normalizeContractName } from './generator/contract-name';\nimport { generateContractTypesFromMichelsonCode } from './generator/process';\nimport { TypeAliasData, TypeUtilsData } from './generator/typescript-output';\nimport { typeAliasesFileContent } from './type-aliases-file-content';\nimport { typeUtilsFileContent } from './type-utils-file-content';\n\nconst fs = {\n\tmkdir: promisify(fsRaw.mkdir),\n\tcopyFile: promisify(fsRaw.copyFile),\n\treaddir: promisify(fsRaw.readdir),\n\treadFile: promisify(fsRaw.readFile),\n\twriteFile: promisify(fsRaw.writeFile),\n\tstat: promisify(fsRaw.stat),\n\texists: fsRaw.existsSync,\n};\n\nconst getAllFiles = async (rootPath: string, filter: (fullPath: string) => boolean): Promise<string[]> => {\n\tconst allFiles = [] as string[];\n\n\tconst getAllFilesRecursive = async (dirPath: string) => {\n\t\tlet files = await fs.readdir(dirPath, { withFileTypes: true });\n\n\t\tfor (const f of files) {\n\t\t\tconst subPath = path.resolve(dirPath, f.name);\n\n\t\t\tif (f.isDirectory()) {\n\t\t\t\tawait getAllFilesRecursive(subPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!filter(subPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tallFiles.push(subPath);\n\t\t}\n\t};\n\n\tawait getAllFilesRecursive(rootPath);\n\treturn allFiles;\n};\n\nexport const generateContractTypesProcessContractFiles = async ({\n\tinputTzContractDirectory,\n\tinputFiles,\n\toutputTypescriptDirectory,\n\tformat,\n\ttypeAliasMode,\n}: {\n\tinputTzContractDirectory: string;\n\tinputFiles?: string[];\n\toutputTypescriptDirectory: string;\n\tformat: 'tz' | 'json';\n\ttypeAliasMode: 'local' | 'file' | 'library' | 'simple';\n}): Promise<void> => {\n\tconsole.log(\n\t\t`Generating Types: ${path.resolve(inputTzContractDirectory)} => ${path.resolve(outputTypescriptDirectory)}`,\n\t);\n\n\tconst ext = '.' + format;\n\tconst filesAll = await getAllFiles(inputTzContractDirectory, x => x.endsWith(ext));\n\tconst files = inputFiles ? filesAll.filter(f => inputFiles.some(inputFile => f.endsWith(inputFile))) : filesAll;\n\n\tconsole.log(`Contracts Found: ${[``, ...files].join(`\\n\\t- `)}`);\n\n\tconst typeAliasImportPath = `@taquito/contract-type-generator`;\n\n\tconst typeAliasData: TypeAliasData = typeAliasMode === 'local'\n\t\t? { mode: typeAliasMode, fileContent: typeAliasesFileContent }\n\t\t: typeAliasMode === 'file'\n\t\t? { mode: typeAliasMode, importPath: `./type-aliases` }\n\t\t: typeAliasMode === 'library'\n\t\t? { mode: typeAliasMode, importPath: typeAliasImportPath }\n\t\t: { mode: 'simple' };\n\n\tif (typeAliasMode === 'file') {\n\t\t// Copy the type alias file\n\t\tawait fs.mkdir(outputTypescriptDirectory, { recursive: true });\n\t\tawait fs.writeFile(path.join(outputTypescriptDirectory, './type-aliases.ts'), typeAliasesFileContent);\n\t}\n\n\t// Copy the type utils file\n\tconst typeUtilsData: TypeUtilsData = { importPath: `./type-utils` };\n\tawait fs.mkdir(outputTypescriptDirectory, { recursive: true });\n\tawait fs.writeFile(path.join(outputTypescriptDirectory, './type-utils.ts'), typeUtilsFileContent);\n\n\tfor (const fullPath of files) {\n\t\tconst fileRelativePath = fullPath.replace(path.resolve(inputTzContractDirectory), '');\n\t\tconst fileName = fileRelativePath.replace(ext, '');\n\t\tconst inputFilePath = path.join(inputTzContractDirectory, fileRelativePath);\n\t\tconst typesOutputFilePath = path.join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.types.ts`));\n\t\tconst codeContentOutputFilePath = path.join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.code.ts`));\n\t\tconst schemaContentOutputFilePath = path.join(\n\t\t\toutputTypescriptDirectory,\n\t\t\tfileRelativePath.replace(ext, `.schema.json`),\n\t\t);\n\t\tconsole.log(`Processing ${fileRelativePath}...`);\n\n\t\ttry {\n\t\t\tconst contractTypeName = normalizeContractName(fileName);\n\n\t\t\tconst michelsonCode = await fs.readFile(inputFilePath, { encoding: `utf8` });\n\n\t\t\tconst {\n\t\t\t\tschemaOutput,\n\t\t\t\ttypescriptCodeOutput: { typesFileContent: typesFileContentRaw, contractCodeFileContent },\n\t\t\t} = generateContractTypesFromMichelsonCode(michelsonCode, contractTypeName, format, typeAliasData, typeUtilsData);\n\n\t\t\t// Correct relative paths for nested contracts\n\t\t\tconst nestedDirDepth = fileRelativePath.replace(/^.?\\/?/, '').split('/').length - 1;\n\t\t\tconst typesFileContent = nestedDirDepth <= 0\n\t\t\t\t? typesFileContentRaw\n\t\t\t\t: typesFileContentRaw.replace(\n\t\t\t\t\t/from '\\.\\//g,\n\t\t\t\t\t`from '${[...new Array(nestedDirDepth)].map(() => '../').join('')}`,\n\t\t\t\t);\n\n\t\t\t// Write output (ensure dir exists)\n\t\t\tawait fs.mkdir(path.dirname(typesOutputFilePath), { recursive: true });\n\t\t\tawait fs.writeFile(typesOutputFilePath, typesFileContent);\n\t\t\tawait fs.writeFile(codeContentOutputFilePath, contractCodeFileContent);\n\n\t\t\tconst debugSchema = false;\n\t\t\tif (debugSchema) {\n\t\t\t\tawait fs.writeFile(schemaContentOutputFilePath, JSON.stringify(schemaOutput, null, 2));\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tconsole.error(`❌ Could not process ${fileRelativePath}`, { err });\n\t\t}\n\t}\n};\n","export const normalizeContractName = (text: string) =>\n\ttext\n\t\t.replace(/[^A-Za-z0-9]/g, '_')\n\t\t.split('_')\n\t\t.filter(x => x)\n\t\t.map(x => x[0].toUpperCase() + x.substring(1))\n\t\t.join('');\n","import * as M from '@taquito/michel-codec';\nimport { GenerateApiError } from './common';\nimport { parseContractParameter, parseContractStorage } from './contract-parser';\nimport { SchemaOutput, toSchema } from './schema-output';\nimport { toTypescriptCode, TypeAliasData, TypescriptCodeOutput, TypeUtilsData } from './typescript-output';\n\nconst parseContractWithMinimalProtocolLevel = (\n\tcontractScript: string,\n\tformat: 'tz' | 'json',\n\tcontractLevelIndex: number,\n): { contract: M.MichelsonContract; protocol: { name: string; key: string } } => {\n\tconst contractLevels = [\n\t\t{ name: 'PsDELPH1', key: M.Protocol.PsDELPH1 },\n\t\t{ name: 'PtEdo2Zk', key: M.Protocol.PtEdo2Zk },\n\t\t{ name: 'PsFLorena', key: M.Protocol.PsFLorena },\n\t];\n\n\tconst protocol = contractLevels[contractLevelIndex];\n\tif (!protocol) {\n\t\tthrow new GenerateApiError(`Could not parse contract script`, contractScript);\n\t}\n\n\tconst p = new M.Parser({ protocol: protocol.key });\n\n\ttry {\n\t\tconst contract = (\n\t\t\tformat === 'tz'\n\t\t\t\t? p.parseScript(contractScript)\n\t\t\t\t: p.parseJSON(JSON.parse(contractScript))\n\t\t) as M.MichelsonContract;\n\t\tif (contract) {\n\t\t\treturn {\n\t\t\t\tcontract,\n\t\t\t\tprotocol,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Ignore parse errors\n\t}\n\n\t// Try again with next level\n\treturn parseContractWithMinimalProtocolLevel(contractScript, format, contractLevelIndex + 1);\n};\n\nexport const parseContractInterface = (\n\tcontractScript: string,\n\tformat: 'tz' | 'json',\n) => {\n\tconst p = new M.Parser({ protocol: M.Protocol.PsFLorena });\n\n\tconst { contract, protocol } = parseContractWithMinimalProtocolLevel(contractScript, format, 0);\n\n\tconst contractStorage = contract.find(x => x.prim === `storage`) as undefined | M.MichelsonContractStorage;\n\tconst contractParameter = contract.find(x => x.prim === `parameter`) as undefined | M.MichelsonContractParameter;\n\n\tconst storageResult = contractStorage && parseContractStorage(contractStorage);\n\tconst storage = storageResult\n\t\t?? { storage: { kind: `object`, raw: { prim: `never` } as M.MichelsonType, fields: [] } };\n\n\tconst parameterResult = contractParameter && parseContractParameter(contractParameter);\n\tconst methods = parameterResult?.methods ?? [];\n\n\treturn {\n\t\tstorage,\n\t\tmethods,\n\t\tcontract,\n\t\tprotocol,\n\t};\n};\n\nexport const generateContractTypesFromMichelsonCode = (\n\tcontractScript: string,\n\tcontractName: string,\n\tformat: 'tz' | 'json',\n\ttypeAliasData: TypeAliasData,\n\ttypeUtilsData: TypeUtilsData,\n): {\n\tschemaOutput: SchemaOutput;\n\ttypescriptCodeOutput: TypescriptCodeOutput;\n\tparsedContract: M.MichelsonContract;\n\tminimalProtocol: string;\n} => {\n\tconst {\n\t\tstorage,\n\t\tmethods,\n\t\tcontract,\n\t\tprotocol,\n\t} = parseContractInterface(\n\t\tcontractScript,\n\t\tformat,\n\t);\n\n\t// If there's only one entrypoint, then we call it \"default\"\n\tif (methods.length === 1) methods[0].name = `default`;\n\n\tconst schemaOutput = toSchema(methods, storage);\n\n\tconst typescriptCode = toTypescriptCode(\n\t\tstorage,\n\t\tmethods,\n\t\tcontractName,\n\t\tcontract,\n\t\tprotocol,\n\t\ttypeAliasData,\n\t\ttypeUtilsData,\n\t);\n\n\treturn {\n\t\tschemaOutput,\n\t\ttypescriptCodeOutput: typescriptCode,\n\t\tparsedContract: contract,\n\t\tminimalProtocol: protocol.key,\n\t};\n};\n","export class GenerateApiError implements Error {\n\tname = `GenerateApiError`;\n\tconstructor(public message: string, readonly data: unknown) {\n\t\tconsole.error(`❌ GenerateApiError: ${message}`, data);\n\t}\n}\n\nexport const assertExhaustive = (value: never, message: string): void => {\n\tconsole.error(message, { value });\n};\n\nexport const reduceFlatMap = <T>(out: T[], x: T[]): T[] => {\n\tout.push(...x);\n\treturn out;\n};\n\n// const reduceFlatMapTest = () => {\n// const items = [['a'], ['b']];\n// const itemsFlat = items.reduce(reduceFlatMap);\n// };\n","import * as M from '@taquito/michel-codec';\nimport { assertExhaustive, GenerateApiError, reduceFlatMap } from './common';\n\nexport type TypedStorage = {\n\tstorage: TypedType;\n};\nexport type TypedParameter = {\n\tmethods: TypedMethod[];\n};\nexport type TypedMethod = {\n\tname: string;\n\targs: TypedVar[];\n};\nexport type TypedVar = {\n\tname?: string;\n\ttype: TypedType;\n};\nexport type TypedType =\n\t& {\n\t\traw: M.MichelsonType;\n\t\toptional?: boolean;\n\t}\n\t& (\n\t\t{\n\t\t\tkind: 'unit';\n\t\t} | {\n\t\t\tkind: 'never';\n\t\t} | {\n\t\t\tkind: 'unknown';\n\t\t} | {\n\t\t\tkind: 'value';\n\t\t\tvalue: string;\n\t\t\ttypescriptType: 'string' | 'boolean' | 'number' | 'Date';\n\t\t} | {\n\t\t\tkind: 'union';\n\t\t\tunion: TypedVar[];\n\t\t} | {\n\t\t\tkind: 'object';\n\t\t\tfields: TypedVar[];\n\t\t} | {\n\t\t\tkind: 'array';\n\t\t\tarray: { item: TypedType };\n\t\t} | {\n\t\t\tkind: 'map';\n\t\t\tmap: { key: TypedType; value: TypedType; isBigMap: boolean };\n\t\t} | {\n\t\t\tkind: 'lambda';\n\t\t\tlambda: { arg: TypedType; ret: TypedType };\n\t\t}\n\t);\n\nconst toDebugSource = (node: M.MichelsonType) => {\n\treturn JSON.stringify(node);\n};\n\nexport const parseContractStorage = (storage: M.MichelsonContractStorage): TypedStorage => {\n\tconst fields = storage.args\n\t\t.map(x => visitVar(x))\n\t\t.reduce(reduceFlatMap, []);\n\n\tif (fields.length === 1 && !fields[0].name) {\n\t\treturn {\n\t\t\tstorage: fields[0].type,\n\t\t};\n\t}\n\n\treturn {\n\t\tstorage: {\n\t\t\tkind: `object` as const,\n\t\t\traw: storage as unknown as M.MichelsonType,\n\t\t\tfields,\n\t\t},\n\t};\n};\n\nexport const parseContractParameter = (parameter: M.MichelsonContractParameter): TypedParameter => {\n\treturn {\n\t\tmethods: parameter.args\n\t\t\t.map(x => visitContractParameterEndpoint(x as MMethod))\n\t\t\t.reduce(reduceFlatMap, []),\n\t};\n};\n\ntype MMethod = M.MichelsonTypeOr<[M.MichelsonType, M.MichelsonType]>;\nconst visitContractParameterEndpoint = (node: MMethod): TypedMethod[] => {\n\t// console.log('visitContractParameterEndpoint', { node });\n\n\t// Sub endpoints (i.e. admin endpoints that are imported)\n\tif (node.prim === `or`) {\n\t\treturn node.args.map(x => visitContractParameterEndpoint(x as MMethod)).reduce(reduceFlatMap, []);\n\t}\n\n\t// Sub endpoints as a list with a single or (i.e. admin endpoints that are imported)\n\tif (node.prim === `list` && node.args.length as number === 1 && (node.args[0] as MMethod)?.prim === `or`) {\n\t\treturn node.args.map(x => visitContractParameterEndpoint(x as MMethod)).reduce(reduceFlatMap, []);\n\t}\n\n\tconst nameRaw = node.annots?.[0];\n\n\t// If the name is missing, then we assume its the main / default entrypoint\n\tconst name = nameRaw?.startsWith('%') ? nameRaw.substr(1) : 'default';\n\n\tif (!name) {\n\t\tconsole.warn(`Unknown method: ${node.prim as string}`, { node, args: node.args });\n\t\treturn [];\n\t}\n\n\tconst nodeType = visitType(node, { ignorePairName: node.prim === 'pair' });\n\n\t// Method args are usually objects\n\tif (nodeType.kind === 'object') {\n\t\treturn [{ name, args: nodeType.fields }];\n\t}\n\n\t// Simple methods can have a single unnamed argument\n\treturn [{\n\t\tname,\n\t\targs: [{ type: nodeType }],\n\t}];\n};\n\n// type PrimOf<T extends M.MichelsonType> = T extends { prim: infer U } ? U : never;\n// type WithPrim<T extends M.MichelsonType, P extends PrimOf<T>> = T extends { prim: P } ? T : never;\n// const isPrimType = <TPrim extends PrimOf<M.MichelsonType>>(node: undefined | null | M.MichelsonType, prim: TPrim): node is WithPrim<M.MichelsonType, TPrim> => {\n// return (node && 'prim' in node && node.prim === prim) || false;\n// };\n\ntype MVarArgs = M.MichelsonType;\nconst visitVar = (node: MVarArgs): TypedVar[] => {\n\tconst name = `annots` in node && node.annots?.length === 1 ? node.annots[0].substr(1) : undefined;\n\tconst type = visitType(node);\n\n\treturn [{\n\t\tname,\n\t\ttype,\n\t}];\n};\n\ntype MType = M.MichelsonType;\nconst visitType = (node: MType, options?: { ignorePairName?: boolean }): TypedType => {\n\t// console.log('visitType', { node });\n\t// const debug_source = toDebugSource(node);\n\n\t// if (typeof node === `string`) {\n\t// return { kind: `value`, raw: node, value: node, typescriptType: `string` };\n\t// }\n\n\tif (!(`prim` in node)) {\n\t\t// Unknown\n\t\tconsole.error(`visitType no prim`, { node });\n\t\treturn { kind: `unknown`, raw: node };\n\t}\n\n\t// Union\n\tif (node.prim === `or`) {\n\t\tconst unionVars = node.args.map(x => visitVar(x)).reduce(reduceFlatMap, []).map(x => x);\n\n\t\t// Flatten with child unions\n\t\tconst union = unionVars.map(x => !x.name && x.type.kind === 'union' ? x.type.union : [x]).reduce(reduceFlatMap, []);\n\t\t// const union = unionVars.map(x=>x.type);\n\n\t\t// const union = unionVars.map(x => x.type);\n\n\t\t// Flatten with child unions\n\n\t\t// const rightSide = union[1];\n\t\t// if (rightSide.kind === `union`) {\n\t\t// union.pop();\n\t\t// union.push(...rightSide.union);\n\t\t// }\n\n\t\tif (union.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`or: Some fields are null`, { node });\n\t\t}\n\t\treturn {\n\t\t\tkind: `union`,\n\t\t\traw: node,\n\t\t\tunion,\n\t\t};\n\t}\n\n\t// Intersect\n\tif (node.prim === `pair`) {\n\t\tconst fields = node.args.map(x => visitVar(x)).reduce(reduceFlatMap, []);\n\t\tif (fields.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`pair: Some fields are null`, { node, args: node.args, fields });\n\t\t}\n\t\t// Disabled Check: Apparently pairs can have more than 2 items\n\t\t// if (fields.length !== 2) {\n\t\t// throw new GenerateApiError(`pair: Expected 2 items`, { node, length: fields.length, fields });\n\t\t// }\n\n\t\t// Flatten with unnamed child pairs\n\t\tconst fieldsFlat = fields.map(x =>\n\t\t\t(!x.name || options?.ignorePairName) && x.type.kind === 'object' ? x.type.fields : [x]\n\t\t).reduce(reduceFlatMap, []);\n\n\t\treturn {\n\t\t\tkind: `object`,\n\t\t\traw: node,\n\t\t\tfields: fieldsFlat,\n\t\t};\n\t}\n\n\t// list\n\tif (\n\t\tnode.prim === `list`\n\t\t|| node.prim === `set`\n\t) {\n\t\tif (node.args.length !== 1) {\n\t\t\tthrow new GenerateApiError(`list does not have 1 arg`, { node, args: node.args });\n\t\t}\n\n\t\tconst arrayItem = visitType(node.args[0]);\n\t\tif (!arrayItem) {\n\t\t\tthrow new GenerateApiError(`arrayItem are null`, { node, args: node.args, arrayItem });\n\t\t}\n\t\treturn {\n\t\t\tkind: `array`,\n\t\t\traw: node,\n\t\t\tarray: { item: arrayItem },\n\t\t};\n\t}\n\n\t// map\n\tif (\n\t\tnode.prim === `map`\n\t\t|| node.prim === `big_map`\n\t) {\n\t\tif (node.args.length !== 2) {\n\t\t\tthrow new GenerateApiError(`map does not have 2 args`, { node, args: node.args });\n\t\t}\n\n\t\tconst mapKey = visitType(node.args[0]);\n\t\tconst mapValue = visitType(node.args[1]);\n\t\tif (!mapKey || !mapValue) {\n\t\t\tthrow new GenerateApiError(`map is missing key or value`, { node, args: node.args, mapKey, mapValue });\n\t\t}\n\t\treturn {\n\t\t\tkind: `map`,\n\t\t\traw: node,\n\t\t\tmap: {\n\t\t\t\tkey: mapKey,\n\t\t\t\tvalue: mapValue,\n\t\t\t\tisBigMap: node.prim === `big_map`,\n\t\t\t},\n\t\t};\n\t}\n\n\t// option\n\tif (node.prim === `option`) {\n\t\treturn {\n\t\t\t...visitType(node.args[0]),\n\t\t\toptional: true,\n\t\t};\n\t}\n\n\t// boolean\n\tif (node.prim === `bool`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `boolean`,\n\t\t};\n\t}\n\n\t// numbers\n\tif (\n\t\tnode.prim === `nat`\n\t\t|| node.prim === `int`\n\t\t|| node.prim === `mutez`\n\t) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `number`,\n\t\t};\n\t}\n\n\t// Date\n\tif (node.prim === `timestamp`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `Date`,\n\t\t};\n\t}\n\n\t// strings\n\tif (\n\t\tnode.prim === `address`\n\t\t|| node.prim === `key`\n\t\t|| node.prim === `key_hash`\n\t\t|| node.prim === `chain_id`\n\t\t|| node.prim === `string`\n\t\t|| node.prim === `signature`\n\t\t|| node.prim === `ticket`\n\t\t|| node.prim === `bls12_381_fr`\n\t\t|| node.prim === `bls12_381_g1`\n\t\t|| node.prim === `bls12_381_g2`\n\t\t|| node.prim === `sapling_state`\n\t\t|| node.prim === `sapling_transaction`\n\t\t|| node.prim === `contract`\n\t) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// void\n\tif (node.prim === `unit`) {\n\t\treturn {\n\t\t\tkind: `unit`,\n\t\t\traw: node,\n\t\t};\n\t}\n\n\t// bytes?\n\tif (node.prim === `bytes`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\tif (node.prim === `lambda`) {\n\t\tif (node.args.length !== 2) {\n\t\t\tthrow new GenerateApiError(`lambda does not have 2 args`, { node, args: node.args });\n\t\t}\n\n\t\tconst argType = visitType(node.args[0]);\n\t\tconst retType = visitType(node.args[1]);\n\t\tif (!argType || !retType) {\n\t\t\tthrow new GenerateApiError(`lambda is missing arg or return`, { node, args: node.args, argType, retType });\n\t\t}\n\n\t\treturn {\n\t\t\tkind: `lambda`,\n\t\t\traw: node,\n\t\t\tlambda: {\n\t\t\t\targ: argType,\n\t\t\t\tret: retType,\n\t\t\t},\n\t\t};\n\t}\n\n\t// misc?\n\tif (node.prim === `operation`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// chest\n\tif (node.prim === 'chest' || node.prim === 'chest_key') {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// never\n\tif (node.prim === `never`) {\n\t\treturn {\n\t\t\tkind: `never`,\n\t\t\traw: node,\n\t\t};\n\t}\n\n\t// Unknown\n\tassertExhaustive(node, `Unknown type`);\n\tthrow new GenerateApiError(`Unknown type`, { node });\n};\n","import { GenerateApiError } from './common';\nimport { TypedMethod, TypedStorage, TypedType, TypedVar } from './contract-parser';\n\ntype SchemaObjectType = { [name: string]: SchemaType };\ntype SchemaOptionalType = { optional: true; type: SchemaType };\ntype SchemaType = string | SchemaType[] | SchemaObjectType | SchemaOptionalType | null;\ntype SchemaMethods = {\n\t[name: string]: {\n\t\tparams: SchemaType;\n\t};\n};\nexport type SchemaOutput = {\n\tmethods: SchemaMethods;\n\tstorage: SchemaType;\n};\n\nexport const toSchema = (methods: TypedMethod[], storage: TypedStorage): SchemaOutput => {\n\tconst getSchemaObjectType = (vars: TypedVar[]) => {\n\t\t// console.log('getSchemaObjectType', { vars });\n\n\t\tif (vars.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`getSchemaObjectType has null vars`, { vars });\n\t\t}\n\n\t\treturn vars.reduce((out, x, i) => {\n\t\t\tout[x.name ?? i] = getSchemaType(x.type);\n\t\t\treturn out;\n\t\t}, {} as SchemaObjectType);\n\t};\n\n\tconst getSchemaType = (t: TypedType): SchemaType => {\n\t\tswitch (t.kind) {\n\t\t\tcase 'value':\n\t\t\t\tif (t.value) {\n\t\t\t\t\treturn t.optional\n\t\t\t\t\t\t? { optional: true, type: t.value }\n\t\t\t\t\t\t: t.value;\n\t\t\t\t}\n\t\t\t\treturn null;\n\n\t\t\tcase 'array':\n\t\t\t\treturn t.array ? [getSchemaType(t.array.item)] : null;\n\n\t\t\tcase 'map':\n\t\t\t\treturn t.map ? ['map', getSchemaType(t.map.key), getSchemaType(t.map.value)] : null;\n\n\t\t\tcase 'object':\n\t\t\t\treturn t.fields ? getSchemaObjectType(t.fields) : null;\n\n\t\t\tcase 'unit':\n\t\t\t\treturn 'unit';\n\n\t\t\tcase 'never':\n\t\t\t\treturn 'never';\n\n\t\t\tcase 'lambda':\n\t\t\t\treturn ['lambda', getSchemaType(t.lambda.arg), getSchemaType(t.lambda.ret)];\n\n\t\t\tdefault:\n\t\t\t\treturn `${t.raw as unknown as string}`;\n\t\t}\n\t};\n\n\tconst schemaMethods = methods.reduce((out, x) => {\n\t\t// console.log('schemaMethods', { x });\n\n\t\tout[x.name] = {\n\t\t\tparams: x.args.length === 1 && !x.args[0].name\n\t\t\t\t? getSchemaType(x.args[0].type)\n\t\t\t\t: getSchemaObjectType(x.args ?? []),\n\t\t};\n\t\treturn out;\n\t}, {} as SchemaMethods);\n\n\tconst schemaStorage = getSchemaType(storage.storage);\n\n\treturn {\n\t\tmethods: schemaMethods,\n\t\tstorage: schemaStorage,\n\t};\n};\n","import { assertExhaustive, GenerateApiError, reduceFlatMap } from './common';\nimport { TypedMethod, TypedStorage, TypedType, TypedVar } from './contract-parser';\n\nexport type TypescriptCodeOutput = {\n\ttypesFileContent: string;\n\tcontractCodeFileContent: string;\n\tstorage: string;\n\tmethods: string;\n\tmethodsObject: string;\n};\n\nexport type TypeAliasData = {\n\tmode: 'local';\n\tfileContent?: string;\n} | {\n\tmode: 'file' | 'library';\n\timportPath?: string;\n} | {\n\tmode: 'simple';\n};\n\nexport type TypeUtilsData = {\n\timportPath: string;\n};\n\nexport const createTypescriptCodeGenerator = (options?: { mode?: 'types' | 'defaultValue' }) => {\n\ttype TypeAlias = {\n\t\taliasType: string;\n\t\tsimpleTypeDefinition: string;\n\t\tsimpleTypeImports?: { name: string; isDefault?: boolean; from: string }[];\n\t};\n\tconst usedStrictTypes = [] as TypeAlias[];\n\tconst addTypeAlias = (strictType: TypeAlias) => {\n\t\tif (!usedStrictTypes.some(x => x.aliasType === strictType.aliasType)) {\n\t\t\tusedStrictTypes.push(strictType);\n\t\t}\n\t};\n\n\t// Not really tabs :)\n\tconst tabs = (indent: number) => Array(indent).fill(` `).join(``);\n\tconst toIndentedItems = (\n\t\tindent: number,\n\t\tdelimiters: { afterItem?: string; beforeItem?: string },\n\t\titems: string[],\n\t) => {\n\t\treturn `\n${tabs(indent + 1)}${\n\t\t\titems.join(`${delimiters.afterItem ?? ``}\n${tabs(indent + 1)}${delimiters.beforeItem ?? ``}`)\n\t\t}\n${tabs(indent)}`;\n\t};\n\n\tconst typeToCode = (t: TypedType, indent: number): string => {\n\t\tif (t.optional) {\n\t\t\treturn `{Some: ${typeToCode({ ...t, optional: false }, indent)}} | null`;\n\t\t}\n\n\t\tif (options?.mode === 'defaultValue') {\n\t\t\treturn typeToCode_defaultValue(t, indent);\n\t\t}\n\n\t\tif (t.kind === `value`) {\n\t\t\t// return `${t.typescriptType}`;\n\n\t\t\tconst prim = `prim` in t.raw ? t.raw.prim : `unknown`;\n\n\t\t\t// Strict mode\n\t\t\tif (\n\t\t\t\tt.typescriptType === `boolean`\n\t\t\t\t|| t.typescriptType === `string` && prim === `string`\n\t\t\t) {\n\t\t\t\treturn `${t.typescriptType}`;\n\t\t\t}\n\n\t\t\tif (t.typescriptType === 'number') {\n\t\t\t\tconst simpleBaseType = `string | BigNumber | number`;\n\t\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\t\taliasType: prim,\n\t\t\t\t\tsimpleTypeDefinition: `type ${prim} = ${simpleBaseType};`,\n\t\t\t\t\tsimpleTypeImports: [{ name: 'BigNumber', isDefault: true, from: 'bignumber.js' }],\n\t\t\t\t};\n\t\t\t\taddTypeAlias(typeAlias);\n\n\t\t\t\treturn typeAlias.aliasType;\n\t\t\t}\n\n\t\t\tconst simpleBaseType = t.typescriptType === 'Date' ? 'Date | string' : t.typescriptType;\n\t\t\tconst typeAlias: TypeAlias = { aliasType: prim, simpleTypeDefinition: `type ${prim} = ${simpleBaseType};` };\n\t\t\taddTypeAlias(typeAlias);\n\n\t\t\treturn typeAlias.aliasType;\n\t\t}\n\t\tif (t.kind === `array`) {\n\t\t\treturn `Array<${typeToCode(t.array.item, indent)}>`;\n\t\t}\n\t\tif (t.kind === `map`) {\n\t\t\tconst typeAlias: TypeAlias = t.map.isBigMap\n\t\t\t\t? {\n\t\t\t\t\taliasType: `BigMap`,\n\t\t\t\t\tsimpleTypeDefinition: 'type BigMap<K, T> = MichelsonMap<K, T>;',\n\t\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonMap', from: '@taquito/taquito' }],\n\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\taliasType: `MMap`,\n\t\t\t\t\tsimpleTypeDefinition: 'type MMap<K, T> = MichelsonMap<K, T>;',\n\t\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonMap', from: '@taquito/taquito' }],\n\t\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\n\t\t\treturn `${typeAlias.aliasType}<${typeToCode(t.map.key, indent)}, ${typeToCode(t.map.value, indent)}>`;\n\t\t}\n\t\tif (t.kind === `lambda`) {\n\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\taliasType: 'Instruction',\n\t\t\t\tsimpleTypeDefinition: `type Instruction = MichelsonInstruction;`,\n\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonInstruction', isDefault: false, from: '@taquito/michel-codec' }],\n\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\t\t\treturn `Instruction[]`;\n\t\t}\n\t\tif (t.kind === `object`) {\n\t\t\treturn `{${toIndentedItems(indent, {}, t.fields.map((a, i) => varToCode(a, i, indent + 1) + `;`))}}`;\n\t\t}\n\t\tif (t.kind === `union`) {\n\t\t\tconst getUnionItem = (a: TypedVar, i: number) => {\n\t\t\t\tconst itemCode = `${varToCode(a, i, indent + 1)}`;\n\n\t\t\t\t// Keep on single line if already on single line\n\t\t\t\tif (!itemCode.includes(`\\n`)) {\n\t\t\t\t\treturn `{ ${itemCode} }`;\n\t\t\t\t}\n\n\t\t\t\t// Indent if multi-line (and remake with extra indent)\n\t\t\t\treturn `{${toIndentedItems(indent + 1, {}, [`${varToCode(a, i, indent + 2)}`])}}`;\n\t\t\t};\n\n\t\t\treturn `(${toIndentedItems(indent, { beforeItem: `| ` }, t.union.map(getUnionItem))})`;\n\t\t}\n\t\tif (t.kind === `unit`) {\n\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\taliasType: `unit`,\n\t\t\t\tsimpleTypeDefinition: `type unit = (true | undefined);`,\n\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\t\t\treturn typeAlias.aliasType;\n\t\t}\n\t\tif (t.kind === `never`) {\n\t\t\treturn `never`;\n\t\t}\n\t\tif (t.kind === `unknown`) {\n\t\t\treturn `unknown`;\n\t\t}\n\n\t\tassertExhaustive(t, `Unknown type`);\n\t\tthrow new GenerateApiError(`Unknown type node`, { t });\n\t};\n\n\tconst typeToCode_defaultValue = (t: TypedType, indent: number): string => {\n\t\tif (t.kind === `value`) {\n\t\t\t// return `${t.typescriptType}`;\n\n\t\t\tconst prim = `prim` in t.raw ? t.raw.prim : `unknown`;\n\n\t\t\t// Strict mode\n\t\t\tif (t.typescriptType === 'boolean') {\n\t\t\t\treturn `true`;\n\t\t\t}\n\t\t\tif (t.typescriptType === `string` && prim === `string`) {\n\t\t\t\treturn `'VALUE'`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'number') {\n\t\t\t\treturn `tas.${prim}('42')`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'Date') {\n\t\t\t\treturn `tas.timestamp(new Date())`;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tprim === 'address'\n\t\t\t\t|| prim === 'contract'\n\t\t\t) {\n\t\t\t\treturn `tas.${prim}('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456')`;\n\t\t\t}\n\t\t\tif (prim === 'bytes') {\n\t\t\t\treturn `tas.${prim}(char2Bytes('DATA'))`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'string') {\n\t\t\t\treturn `tas.${prim}('VALUE')`;\n\t\t\t}\n\t\t\tassertExhaustive(t.typescriptType, `Unknown value type`);\n\n\t\t\treturn prim;\n\t\t}\n\t\tif (t.kind === `array`) {\n\t\t\treturn `[${typeToCode(t.array.item, indent)}]`;\n\t\t}\n\t\tif (t.kind === `map`) {\n\t\t\tconst keyPrim = `prim` in t.map.key.raw ? t.map.key.raw.prim : `unknown`;\n\t\t\tconst isStringBasedKey = t.map.key.kind === 'value' && keyPrim === 'string';\n\t\t\tif (isStringBasedKey) {\n\t\t\t\treturn `tas.${t.map.isBigMap ? 'bigMap' : 'map'}({ \n${tabs(indent + 1)}${typeToCode(t.map.key, indent)}: ${typeToCode(t.map.value, indent)},\n${tabs(indent)}})`;\n\t\t\t}\n\n\t\t\treturn `tas.${t.map.isBigMap ? 'bigMap' : 'map'}([{ \n${tabs(indent + 1)}key: ${typeToCode(t.map.key, indent)}, \n${tabs(indent + 1)}value: ${typeToCode(t.map.value, indent)},\n${tabs(indent)}}])`;\n\t\t}\n\t\tif (t.kind === `object`) {\n\t\t\tconst delimiter = options?.mode === 'defaultValue' ? ',' : `;`;\n\t\t\treturn `{${toIndentedItems(indent, {}, t.fields.map((a, i) => varToCode(a, i, indent + 1) + delimiter))}}`;\n\t\t}\n\t\tif (t.kind === `union`) {\n\t\t\tconst getUnionItem = (a: TypedVar, i: number) => {\n\t\t\t\tconst itemCode = `${varToCode(a, i, indent + 1)}`;\n\n\t\t\t\t// Keep on single line if already on single line\n\t\t\t\tif (!itemCode.includes(`\\n`)) {\n\t\t\t\t\treturn `{ ${itemCode} }`;\n\t\t\t\t}\n\n\t\t\t\t// Indent if multi-line (and remake with extra indent)\n\t\t\t\treturn `{${toIndentedItems(indent + 1, {}, [`${varToCode(a, i, indent + 2)}`])}}`;\n\t\t\t};\n\n\t\t\treturn `(${toIndentedItems(indent, { beforeItem: `| ` }, t.union.map(getUnionItem))})`;\n\t\t}\n\t\tif (t.kind === `unit`) {\n\t\t\treturn `tas.unit()`;\n\t\t}\n\t\tif (t.kind === `never`) {\n\t\t\treturn `never`;\n\t\t}\n\t\tif (t.kind === `unknown`) {\n\t\t\treturn `unknown`;\n\t\t}\n\t\tif (t.kind === 'lambda') {\n\t\t\treturn `tas.lambda([])`;\n\t\t}\n\n\t\tassertExhaustive(t, `Unknown type`);\n\t\tthrow new GenerateApiError(`Unknown type node`, { t });\n\t};\n\n\tconst varToCode = (t: TypedVar, i: number, indent: number, numberVarNamePrefix = ''): string => {\n\t\tlet typeName = typeToCode(t.type, indent);\n\t\treturn `${t.name ?? `${numberVarNamePrefix}${i}`}: ${typeName}`;\n\t};\n\n\tconst argsToCode = (args: TypedVar[], indent: number, asObject: boolean): string => {\n\t\tif (args.length === 1) {\n\t\t\tif (args[0].type.kind === `unit`) return ``;\n\n\t\t\tif (options?.mode === 'defaultValue') {\n\t\t\t\treturn typeToCode(args[0].type, indent + 1);\n\t\t\t}\n\t\t\treturn `${args[0].name ?? `param`}: ${typeToCode(args[0].type, indent + 1)}`;\n\t\t}\n\n\t\tconst result = `${\n\t\t\ttoIndentedItems(\n\t\t\t\tindent,\n\t\t\t\t{},\n\t\t\t\targs.filter(x => x.name || x.type.kind !== `unit`).map((a, i) => {\n\t\t\t\t\tif (!asObject && options?.mode === 'defaultValue') {\n\t\t\t\t\t\treturn typeToCode(a.type, indent + 1) + `,`;\n\t\t\t\t\t}\n\t\t\t\t\treturn varToCode(a, i, indent + 1, asObject ? '' : '_') + `,`;\n\t\t\t\t}),\n\t\t\t)\n\t\t}`;\n\n\t\tif (asObject) {\n\t\t\tif (options?.mode === 'defaultValue') {\n\t\t\t\treturn `{${result}}`;\n\t\t\t}\n\t\t\treturn `params: {${result}}`;\n\t\t}\n\n\t\treturn result;\n\t};\n\n\treturn {\n\t\tusedStrictTypes,\n\t\ttabs,\n\t\ttoIndentedItems,\n\t\ttypeToCode,\n\t\targsToCode,\n\t};\n};\n\nexport const toTypescriptCode = (\n\tstorage: TypedStorage,\n\tmethods: TypedMethod[],\n\tcontractName: string,\n\tparsedContract: unknown,\n\tprotocol: { name: string; key: string },\n\ttypeAliasData: TypeAliasData,\n\ttypeUtilsData: TypeUtilsData,\n): TypescriptCodeOutput => {\n\tconst {\n\t\tusedStrictTypes,\n\t\ttoIndentedItems,\n\t\ttypeToCode,\n\t\targsToCode,\n\t} = createTypescriptCodeGenerator();\n\n\tconst methodsToCode = (indent: number) => {\n\t\tconst methodFields = methods.map(x => {\n\t\t\tconst methodCode = `${x.name}: (${argsToCode(x.args, indent + 1, false)}) => Promise<void>;`;\n\t\t\treturn methodCode;\n\t\t});\n\n\t\tconst methodsTypeCode = `type Methods = {${toIndentedItems(indent, {}, methodFields)}};`;\n\t\treturn methodsTypeCode;\n\t};\n\tconst methodsObjectToCode = (indent: number) => {\n\t\tconst methodFields = methods.map(x => {\n\t\t\tconst methodCode = `${x.name}: (${argsToCode(x.args, indent + 1, true)}) => Promise<void>;`;\n\t\t\treturn methodCode;\n\t\t});\n\n\t\tconst methodsTypeCode = `type MethodsObject = {${toIndentedItems(indent, {}, methodFields)}};`;\n\t\treturn methodsTypeCode;\n\t};\n\n\tconst storageToCode = (indent: number) => {\n\t\tconst storageTypeCode = `export type Storage = ${typeToCode(storage.storage, indent)};`;\n\t\treturn storageTypeCode;\n\t};\n\n\tconst methodsCode = methodsToCode(0);\n\tconst methodsObjectCode = methodsObjectToCode(0);\n\tconst storageCode = storageToCode(0);\n\n\t// Simple type aliases\n\tconst simpleTypeMappingImportsAll = new Map(\n\t\tusedStrictTypes.map(x => x.simpleTypeImports ?? []).reduce(reduceFlatMap, []).map(\n\t\t\tx => [`${x?.from}:${x?.name}:${x?.isDefault}`, x],\n\t\t),\n\t);\n\tconst simpleTypeMappingImportsFrom = [...simpleTypeMappingImportsAll.values()].reduce((out, x) => {\n\t\tconst entry = out[x.from] ?? (out[x.from] = { names: [] });\n\t\tif (x.isDefault) {\n\t\t\tentry.default = x.name;\n\t\t} else {\n\t\t\tentry.names.push(x.name);\n\t\t}\n\t\tentry.names.sort((a, b) => a.localeCompare(b));\n\t\treturn out;\n\t}, {} as { [from: string]: { names: string[]; default?: string } });\n\n\tconst simpleTypeMappingImportsText = Object.keys(simpleTypeMappingImportsFrom)\n\t\t.map(k => {\n\t\t\tconst entry = simpleTypeMappingImportsFrom[k];\n\t\t\tconst items = [entry.default, entry.names.length ? `{ ${entry.names.join(', ')} }` : ''].filter(x => x);\n\t\t\treturn `import ${items.join(', ')} from '${k}';\\n`;\n\t\t})\n\t\t.join('');\n\n\tconst simpleTypeMapping = usedStrictTypes\n\t\t.sort((a, b) => a.aliasType.localeCompare(b.aliasType))\n\t\t.map(x => x.simpleTypeDefinition).join(`\\n`);\n\n\tconst typeUtilsDefinitions =\n\t\t`import { ContractAbstractionFromContractType, WalletContractAbstractionFromContractType } from '${typeUtilsData.importPath}';`;\n\n\tconst typeAliasesDefinitions = typeAliasData.mode === 'simple'\n\t\t? `${simpleTypeMappingImportsText}${simpleTypeMapping}`\n\t\t: typeAliasData.mode === 'local'\n\t\t? typeAliasData.fileContent\n\t\t: `import { ${usedStrictTypes.map(x => x.aliasType).join(`, `)} } from '${typeAliasData.importPath}';`;\n\n\tconst contractTypeName = `${contractName}ContractType`;\n\tconst walletTypeName = `${contractName}WalletType`;\n\tconst codeName = `${contractName}Code`;\n\n\tconst typesFileContent = `\n${typeUtilsDefinitions}\n${typeAliasesDefinitions}\n\n${storageCode}\n\n${methodsCode}\n\n${methodsObjectCode}\n\ntype contractTypes = { methods: Methods, methodsObject: MethodsObject, storage: Storage, code: { __type: '${codeName}', protocol: string, code: object[] } };\nexport type ${contractTypeName} = ContractAbstractionFromContractType<contractTypes>;\nexport type ${walletTypeName} = WalletContractAbstractionFromContractType<contractTypes>;\n`;\n\n\tconst contractCodeFileContent = `\nexport const ${codeName}: { __type: '${codeName}', protocol: string, code: object[] } = {\n __type: '${codeName}',\n protocol: '${protocol.key}',\n code: JSON.parse(\\`${JSON.stringify(parsedContract)}\\`)\n};\n`;\n\treturn {\n\t\ttypesFileContent,\n\t\tcontractCodeFileContent,\n\t\tstorage: storageCode,\n\t\tmethods: methodsCode,\n\t\tmethodsObject: methodsObjectCode,\n\t};\n};\n","// This is required for copying the type aliases to a local file\nexport const typeAliasesFileContent = `\nimport { assertMichelsonInstruction, Expr, MichelsonCode } from '@taquito/michel-codec';\nimport { MichelsonMap } from '@taquito/taquito';\nimport { BigNumber } from 'bignumber.js';\n\nexport type Instruction = MichelsonCode;\n\nexport type unit = (true | undefined) & { __type: 'unit' };\n\nexport type address = string & { __type: 'address' };\nexport type bytes = string & { __type: 'bytes' };\nexport type contract = string & { __type: 'contract' };\nexport type operation = string & { __type: 'operation' };\nexport type key = string & { __type: 'key' };\nexport type key_hash = string & { __type: 'key_hash' };\nexport type signature = string & { __type: 'signature' };\nexport type ticket = string & { __type: 'ticket' };\n\nexport type timestamp = string & { __type: 'timestamp' };\n\nexport type int = BigNumber & { __type: 'int' };\nexport type nat = BigNumber & { __type: 'nat' };\n\nexport type mutez = BigNumber & { __type: 'mutez' };\nexport type tez = BigNumber & { __type: 'tez' };\n\ntype MapKey = Array<any> | object | string | boolean | number;\nexport type MMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => V };\nexport type BigMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => Promise<V> };\n\nexport type chest = string & { __type: 'chest' };\nexport type chest_key = string & { __type: 'chest_key' };\n\nconst createStringTypeTas = <T extends string>() => {\n\treturn (value: string): T => value as T;\n};\n\nconst createBigNumberTypeTas = <T extends BigNumber>() => {\n\treturn (value: number | BigNumber | string): T => new BigNumber(value) as T;\n};\n\ntype asMapParamOf<K, V> = K extends string ? { [key: string]: V } | Array<{ key: K; value: V }>\n\t: K extends number ? { [key: number]: V } | Array<{ key: K; value: V }>\n\t: Array<{ key: K; value: V }>;\n\nfunction asMap<K extends MapKey, V>(value: asMapParamOf<K, V>): MMap<K, V> {\n\tconst m = new MichelsonMap<K, V>();\n\tif (Array.isArray(value)) {\n\t\tconst vArray = value as Array<{ key: K; value: V }>;\n\t\tvArray.forEach(x => m.set(x.key, x.value));\n\t} else {\n\t\tconst vObject = value as { [key: string]: V };\n\t\tObject.keys(vObject).forEach(key => m.set(key as unknown as K, vObject[key]));\n\t}\n\treturn m as MMap<K, V>;\n}\nconst asBigMap = <K extends MapKey, V>(value: asMapParamOf<K, V>) => asMap(value) as unknown as BigMap<K, V>;\n\nfunction add<T extends BigNumber>(a: T, b: T): T {\n\treturn a.plus(b) as T;\n}\nfunction subtract<T extends BigNumber>(a: T, b: T): T {\n\treturn a.minus(b) as T;\n}\n\nfunction createLambdaTypeTas(expr: Expr): MichelsonCode {\n\tassertMichelsonInstruction(expr);\n return expr as MichelsonCode;\n}\n\n/** tas: Tezos 'as' casting for strict types */\nexport const tas = {\n\taddress: createStringTypeTas<address>(),\n\tbytes: createStringTypeTas<bytes>(),\n\tcontract: createStringTypeTas<contract>(),\n\tchest: createStringTypeTas<chest>(),\n\tchest_key: createStringTypeTas<chest_key>(),\n\ttimestamp: (value: string | Date): timestamp => new Date(value).toISOString() as timestamp,\n\n\tint: createBigNumberTypeTas<int>(),\n\tnat: createBigNumberTypeTas<nat>(),\n\tmutez: createBigNumberTypeTas<mutez>(),\n\ttez: createBigNumberTypeTas<tez>(),\n\n\tmap: asMap,\n\tbigMap: asBigMap,\n\n\t// Operations\n\tadd,\n\tsubtract,\n\n lambda: createLambdaTypeTas,\n\n\t// To number\n\tnumber: (value: string | BigNumber) => Number(value + ''),\n\tunit: () => true as unit,\n};\n`;\n","// This is required for copying the type utils to a local file\nexport const typeUtilsFileContent = `\nimport { ContractAbstraction, ContractMethod, ContractMethodObject, ContractProvider, Wallet } from '@taquito/taquito';\n\ntype BaseContractType = { methods: unknown, methodsObject: unknown, storage: unknown };\n\ntype ContractMethodsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {\n[M in keyof TContract['methods']]:\nTContract['methods'][M] extends (...args: infer A) => unknown\n? (...args: A) => ContractMethod<T>\n: never\n};\ntype ContractMethodsObjectsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {\n[M in keyof TContract['methodsObject']]:\nTContract['methodsObject'][M] extends (...args: infer A) => unknown\n? (...args: A) => ContractMethodObject<T>\n: never\n};\ntype ContractStorageOf<TContract extends BaseContractType> = TContract['storage'];\n\nexport type ContractAbstractionFromContractType<TContract extends BaseContractType> = \n ContractAbstraction<ContractProvider, \n ContractMethodsOf<ContractProvider, TContract>,\n ContractMethodsObjectsOf<ContractProvider, TContract>,\n {},\n {},\n ContractStorageOf<TContract>\n >;\n\nexport type WalletContractAbstractionFromContractType<TContract extends BaseContractType> = \n ContractAbstraction<Wallet, \n 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S;AAAA,EACT,OAAO;AAAA,IACN,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,QACf,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,WAAW;AAAA,UACX,MAAM;AAAA,UACN,SAAS,CAAC,QAAQ,QAAQ;AAAA,UAC1B,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,SAAS,CAAC,aAAa,UAAU;AAAA,MACjC,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA,OAAO,MAAM;AACd,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_path","simpleBaseType","typeAlias","fsRaw","path","glob"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","tasks.ts","src/cli-process.ts","src/generator/contract-name.ts","src/generator/process.ts","src/generator/common.ts","src/generator/contract-parser.ts","src/generator/schema-output.ts","src/generator/typescript-output.ts","src/type-aliases-file-content.ts","src/type-utils-file-content.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport { tasks } from './tasks';\nexport { generateContractTypesProcessContractFiles } from './src/cli-process';\n\nPlugin.create(i18n => ({\n\talias: 'contract-types',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'generate types',\n\t\t\tcommand: 'generate types [typescriptDir]',\n\t\t\tdescription: 'Generate types for a contract to be used with taquito',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'typescriptDir',\n\t\t\t\t\tdescription: 'The output directory for the generated type files',\n\t\t\t\t\tdefaultValue: 'types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tflag: 'typeAliasMode',\n\t\t\t\t\tchoices: ['file', 'simple'],\n\t\t\t\t\tdescription: 'The type aliases used in the generated types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['gen types', 'gentypes'],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t],\n\tproxy: tasks.generateTypes,\n}), process.argv);\n","import { isContractFile, RequestArgs } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { generateContractTypesProcessContractFiles } from './src/cli-process';\ninterface Opts extends RequestArgs.t {\n\t// TODO: Document these\n\ttypescriptDir?: string;\n\ttypeAliasMode?: 'local' | 'file' | 'library' | 'simple';\n\tcontract?: string;\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(\n\t\tparsedArgs.config.artifactsDir ?? 'artifacts',\n\t\t/\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`,\n\t);\n\nconst generateContractTypes = (parsedArgs: Opts) => async (contractFilename: string): Promise<string> => {\n\tconst contractAbspath = getContractAbspath(contractFilename, parsedArgs);\n\tawait generateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [contractAbspath],\n\t\toutputTypescriptDirectory: parsedArgs.typescriptDir || 'types',\n\t\tformat: 'tz',\n\t\ttypeAliasMode: parsedArgs.typeAliasMode ?? 'file',\n\t});\n\n\treturn `${contractFilename}: Types generated`;\n};\n\nconst generateContractTypesAll = async (parsedArgs: Opts): Promise<string[]> => {\n\tconst files = await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir });\n\tconst contractFiles = files.filter(isContractFile);\n\treturn await Promise.all(contractFiles.map(generateContractTypes(parsedArgs)));\n};\n\nexport const generateTypes = (parsedArgs: Opts) => {\n\tparsedArgs.typescriptDir = parsedArgs.typescriptDir || 'types';\n\n\tconsole.log('generateTypes', {\n\t\ttypescriptDir: parsedArgs.typescriptDir,\n\t});\n\n\tconst p = parsedArgs.contract\n\t\t? generateContractTypes(parsedArgs)(parsedArgs.contract)\n\t\t: generateContractTypesAll(parsedArgs);\n\n\treturn p.then(data => {\n\t\tconsole.log(\n\t\t\t(Array.isArray(data))\n\t\t\t\t? data.join('\\n')\n\t\t\t\t: data,\n\t\t);\n\t});\n};\n\nexport const tasks = {\n\tgenerateTypes,\n};\n","import fsRaw from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\nimport { normalizeContractName } from './generator/contract-name';\nimport { generateContractTypesFromMichelsonCode } from './generator/process';\nimport { TypeAliasData, TypeUtilsData } from './generator/typescript-output';\nimport { typeAliasesFileContent } from './type-aliases-file-content';\nimport { typeUtilsFileContent } from './type-utils-file-content';\n\nconst fs = {\n\tmkdir: promisify(fsRaw.mkdir),\n\tcopyFile: promisify(fsRaw.copyFile),\n\treaddir: promisify(fsRaw.readdir),\n\treadFile: promisify(fsRaw.readFile),\n\twriteFile: promisify(fsRaw.writeFile),\n\tstat: promisify(fsRaw.stat),\n\texists: fsRaw.existsSync,\n};\n\nconst getAllFiles = async (rootPath: string, filter: (fullPath: string) => boolean): Promise<string[]> => {\n\tconst allFiles = [] as string[];\n\n\tconst getAllFilesRecursive = async (dirPath: string) => {\n\t\tlet files = await fs.readdir(dirPath, { withFileTypes: true });\n\n\t\tfor (const f of files) {\n\t\t\tconst subPath = path.resolve(dirPath, f.name);\n\n\t\t\tif (f.isDirectory()) {\n\t\t\t\tawait getAllFilesRecursive(subPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!filter(subPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tallFiles.push(subPath);\n\t\t}\n\t};\n\n\tawait getAllFilesRecursive(rootPath);\n\treturn allFiles;\n};\n\nexport const generateContractTypesProcessContractFiles = async ({\n\tinputTzContractDirectory,\n\tinputFiles,\n\toutputTypescriptDirectory,\n\tformat,\n\ttypeAliasMode,\n}: {\n\tinputTzContractDirectory: string;\n\tinputFiles?: string[];\n\toutputTypescriptDirectory: string;\n\tformat: 'tz' | 'json';\n\ttypeAliasMode: 'local' | 'file' | 'library' | 'simple';\n}): Promise<void> => {\n\tconsole.log(\n\t\t`Generating Types: ${path.resolve(inputTzContractDirectory)} => ${path.resolve(outputTypescriptDirectory)}`,\n\t);\n\n\tconst ext = '.' + format;\n\tconst filesAll = await getAllFiles(inputTzContractDirectory, x => x.endsWith(ext));\n\tconst files = inputFiles ? filesAll.filter(f => inputFiles.some(inputFile => f.endsWith(inputFile))) : filesAll;\n\n\tconsole.log(`Contracts Found: ${[``, ...files].join(`\\n\\t- `)}`);\n\n\tconst typeAliasImportPath = `@taquito/contract-type-generator`;\n\n\tconst typeAliasData: TypeAliasData = typeAliasMode === 'local'\n\t\t? { mode: typeAliasMode, fileContent: typeAliasesFileContent }\n\t\t: typeAliasMode === 'file'\n\t\t? { mode: typeAliasMode, importPath: `./type-aliases` }\n\t\t: typeAliasMode === 'library'\n\t\t? { mode: typeAliasMode, importPath: typeAliasImportPath }\n\t\t: { mode: 'simple' };\n\n\tif (typeAliasMode === 'file') {\n\t\t// Copy the type alias file\n\t\tawait fs.mkdir(outputTypescriptDirectory, { recursive: true });\n\t\tawait fs.writeFile(path.join(outputTypescriptDirectory, './type-aliases.ts'), typeAliasesFileContent);\n\t}\n\n\t// Copy the type utils file\n\tconst typeUtilsData: TypeUtilsData = { importPath: `./type-utils` };\n\tawait fs.mkdir(outputTypescriptDirectory, { recursive: true });\n\tawait fs.writeFile(path.join(outputTypescriptDirectory, './type-utils.ts'), typeUtilsFileContent);\n\n\tfor (const fullPath of files) {\n\t\tconst fileRelativePath = fullPath.replace(path.resolve(inputTzContractDirectory), '');\n\t\tconst fileName = fileRelativePath.replace(ext, '');\n\t\tconst inputFilePath = path.join(inputTzContractDirectory, fileRelativePath);\n\t\tconst typesOutputFilePath = path.join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.types.ts`));\n\t\tconst codeContentOutputFilePath = path.join(outputTypescriptDirectory, fileRelativePath.replace(ext, `.code.ts`));\n\t\tconst schemaContentOutputFilePath = path.join(\n\t\t\toutputTypescriptDirectory,\n\t\t\tfileRelativePath.replace(ext, `.schema.json`),\n\t\t);\n\t\tconsole.log(`Processing ${fileRelativePath}...`);\n\n\t\ttry {\n\t\t\tconst contractTypeName = normalizeContractName(fileName);\n\n\t\t\tconst michelsonCode = await fs.readFile(inputFilePath, { encoding: `utf8` });\n\n\t\t\tconst {\n\t\t\t\tschemaOutput,\n\t\t\t\ttypescriptCodeOutput: { typesFileContent: typesFileContentRaw, contractCodeFileContent },\n\t\t\t} = generateContractTypesFromMichelsonCode(michelsonCode, contractTypeName, format, typeAliasData, typeUtilsData);\n\n\t\t\t// Correct relative paths for nested contracts\n\t\t\tconst nestedDirDepth = fileRelativePath.replace(/^.?\\/?/, '').split('/').length - 1;\n\t\t\tconst typesFileContent = nestedDirDepth <= 0\n\t\t\t\t? typesFileContentRaw\n\t\t\t\t: typesFileContentRaw.replace(\n\t\t\t\t\t/from '\\.\\//g,\n\t\t\t\t\t`from '${[...new Array(nestedDirDepth)].map(() => '../').join('')}`,\n\t\t\t\t);\n\n\t\t\t// Write output (ensure dir exists)\n\t\t\tawait fs.mkdir(path.dirname(typesOutputFilePath), { recursive: true });\n\t\t\tawait fs.writeFile(typesOutputFilePath, typesFileContent);\n\t\t\tawait fs.writeFile(codeContentOutputFilePath, contractCodeFileContent);\n\n\t\t\tconst debugSchema = false;\n\t\t\tif (debugSchema) {\n\t\t\t\tawait fs.writeFile(schemaContentOutputFilePath, JSON.stringify(schemaOutput, null, 2));\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tconsole.error(`❌ Could not process ${fileRelativePath}`, { err });\n\t\t}\n\t}\n};\n","export const normalizeContractName = (text: string) =>\n\ttext\n\t\t.replace(/[^A-Za-z0-9]/g, '_')\n\t\t.split('_')\n\t\t.filter(x => x)\n\t\t.map(x => x[0].toUpperCase() + x.substring(1))\n\t\t.join('');\n","import * as M from '@taquito/michel-codec';\nimport { GenerateApiError } from './common';\nimport { parseContractParameter, parseContractStorage } from './contract-parser';\nimport { SchemaOutput, toSchema } from './schema-output';\nimport { toTypescriptCode, TypeAliasData, TypescriptCodeOutput, TypeUtilsData } from './typescript-output';\n\nconst parseContractWithMinimalProtocolLevel = (\n\tcontractScript: string,\n\tformat: 'tz' | 'json',\n\tcontractLevelIndex: number,\n): { contract: M.MichelsonContract; protocol: { name: string; key: string } } => {\n\tconst contractLevels = [\n\t\t{ name: 'PsDELPH1', key: M.Protocol.PsDELPH1 },\n\t\t{ name: 'PtEdo2Zk', key: M.Protocol.PtEdo2Zk },\n\t\t{ name: 'PsFLorena', key: M.Protocol.PsFLorena },\n\t];\n\n\tconst protocol = contractLevels[contractLevelIndex];\n\tif (!protocol) {\n\t\tthrow new GenerateApiError(`Could not parse contract script`, contractScript);\n\t}\n\n\tconst p = new M.Parser({ protocol: protocol.key });\n\n\ttry {\n\t\tconst contract = (\n\t\t\tformat === 'tz'\n\t\t\t\t? p.parseScript(contractScript)\n\t\t\t\t: p.parseJSON(JSON.parse(contractScript))\n\t\t) as M.MichelsonContract;\n\t\tif (contract) {\n\t\t\treturn {\n\t\t\t\tcontract,\n\t\t\t\tprotocol,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Ignore parse errors\n\t}\n\n\t// Try again with next level\n\treturn parseContractWithMinimalProtocolLevel(contractScript, format, contractLevelIndex + 1);\n};\n\nexport const parseContractInterface = (\n\tcontractScript: string,\n\tformat: 'tz' | 'json',\n) => {\n\tconst p = new M.Parser({ protocol: M.Protocol.PsFLorena });\n\n\tconst { contract, protocol } = parseContractWithMinimalProtocolLevel(contractScript, format, 0);\n\n\tconst contractStorage = contract.find(x => x.prim === `storage`) as undefined | M.MichelsonContractStorage;\n\tconst contractParameter = contract.find(x => x.prim === `parameter`) as undefined | M.MichelsonContractParameter;\n\n\tconst storageResult = contractStorage && parseContractStorage(contractStorage);\n\tconst storage = storageResult\n\t\t?? { storage: { kind: `object`, raw: { prim: `never` } as M.MichelsonType, fields: [] } };\n\n\tconst parameterResult = contractParameter && parseContractParameter(contractParameter);\n\tconst methods = parameterResult?.methods ?? [];\n\n\treturn {\n\t\tstorage,\n\t\tmethods,\n\t\tcontract,\n\t\tprotocol,\n\t};\n};\n\nexport const generateContractTypesFromMichelsonCode = (\n\tcontractScript: string,\n\tcontractName: string,\n\tformat: 'tz' | 'json',\n\ttypeAliasData: TypeAliasData,\n\ttypeUtilsData: TypeUtilsData,\n): {\n\tschemaOutput: SchemaOutput;\n\ttypescriptCodeOutput: TypescriptCodeOutput;\n\tparsedContract: M.MichelsonContract;\n\tminimalProtocol: string;\n} => {\n\tconst {\n\t\tstorage,\n\t\tmethods,\n\t\tcontract,\n\t\tprotocol,\n\t} = parseContractInterface(\n\t\tcontractScript,\n\t\tformat,\n\t);\n\n\t// If there's only one entrypoint, then we call it \"default\"\n\tif (methods.length === 1) methods[0].name = `default`;\n\n\tconst schemaOutput = toSchema(methods, storage);\n\n\tconst typescriptCode = toTypescriptCode(\n\t\tstorage,\n\t\tmethods,\n\t\tcontractName,\n\t\tcontract,\n\t\tprotocol,\n\t\ttypeAliasData,\n\t\ttypeUtilsData,\n\t);\n\n\treturn {\n\t\tschemaOutput,\n\t\ttypescriptCodeOutput: typescriptCode,\n\t\tparsedContract: contract,\n\t\tminimalProtocol: protocol.key,\n\t};\n};\n","export class GenerateApiError implements Error {\n\tname = `GenerateApiError`;\n\tconstructor(public message: string, readonly data: unknown) {\n\t\tconsole.error(`❌ GenerateApiError: ${message}`, data);\n\t}\n}\n\nexport const assertExhaustive = (value: never, message: string): void => {\n\tconsole.error(message, { value });\n};\n\nexport const reduceFlatMap = <T>(out: T[], x: T[]): T[] => {\n\tout.push(...x);\n\treturn out;\n};\n\n// const reduceFlatMapTest = () => {\n// const items = [['a'], ['b']];\n// const itemsFlat = items.reduce(reduceFlatMap);\n// };\n","import * as M from '@taquito/michel-codec';\nimport { assertExhaustive, GenerateApiError, reduceFlatMap } from './common';\n\nexport type TypedStorage = {\n\tstorage: TypedType;\n};\nexport type TypedParameter = {\n\tmethods: TypedMethod[];\n};\nexport type TypedMethod = {\n\tname: string;\n\targs: TypedVar[];\n};\nexport type TypedVar = {\n\tname?: string;\n\ttype: TypedType;\n};\nexport type TypedType =\n\t& {\n\t\traw: M.MichelsonType;\n\t\toptional?: boolean;\n\t}\n\t& (\n\t\t{\n\t\t\tkind: 'unit';\n\t\t} | {\n\t\t\tkind: 'never';\n\t\t} | {\n\t\t\tkind: 'unknown';\n\t\t} | {\n\t\t\tkind: 'value';\n\t\t\tvalue: string;\n\t\t\ttypescriptType: 'string' | 'boolean' | 'number' | 'Date';\n\t\t} | {\n\t\t\tkind: 'union';\n\t\t\tunion: TypedVar[];\n\t\t} | {\n\t\t\tkind: 'object';\n\t\t\tfields: TypedVar[];\n\t\t} | {\n\t\t\tkind: 'array';\n\t\t\tarray: { item: TypedType };\n\t\t} | {\n\t\t\tkind: 'map';\n\t\t\tmap: { key: TypedType; value: TypedType; isBigMap: boolean };\n\t\t} | {\n\t\t\tkind: 'lambda';\n\t\t\tlambda: { arg: TypedType; ret: TypedType };\n\t\t}\n\t);\n\nconst toDebugSource = (node: M.MichelsonType) => {\n\treturn JSON.stringify(node);\n};\n\nexport const parseContractStorage = (storage: M.MichelsonContractStorage): TypedStorage => {\n\tconst fields = storage.args\n\t\t.map(x => visitVar(x))\n\t\t.reduce(reduceFlatMap, []);\n\n\tif (fields.length === 1 && !fields[0].name) {\n\t\treturn {\n\t\t\tstorage: fields[0].type,\n\t\t};\n\t}\n\n\treturn {\n\t\tstorage: {\n\t\t\tkind: `object` as const,\n\t\t\traw: storage as unknown as M.MichelsonType,\n\t\t\tfields,\n\t\t},\n\t};\n};\n\nexport const parseContractParameter = (parameter: M.MichelsonContractParameter): TypedParameter => {\n\treturn {\n\t\tmethods: parameter.args\n\t\t\t.map(x => visitContractParameterEndpoint(x as MMethod))\n\t\t\t.reduce(reduceFlatMap, []),\n\t};\n};\n\ntype MMethod = M.MichelsonTypeOr<[M.MichelsonType, M.MichelsonType]>;\nconst visitContractParameterEndpoint = (node: MMethod): TypedMethod[] => {\n\t// console.log('visitContractParameterEndpoint', { node });\n\n\t// Sub endpoints (i.e. admin endpoints that are imported)\n\tif (node.prim === `or`) {\n\t\treturn node.args.map(x => visitContractParameterEndpoint(x as MMethod)).reduce(reduceFlatMap, []);\n\t}\n\n\t// Sub endpoints as a list with a single or (i.e. admin endpoints that are imported)\n\tif (node.prim === `list` && node.args.length as number === 1 && (node.args[0] as MMethod)?.prim === `or`) {\n\t\treturn node.args.map(x => visitContractParameterEndpoint(x as MMethod)).reduce(reduceFlatMap, []);\n\t}\n\n\tconst nameRaw = node.annots?.[0];\n\n\t// If the name is missing, then we assume its the main / default entrypoint\n\tconst name = nameRaw?.startsWith('%') ? nameRaw.substr(1) : 'default';\n\n\tif (!name) {\n\t\tconsole.warn(`Unknown method: ${node.prim as string}`, { node, args: node.args });\n\t\treturn [];\n\t}\n\n\tconst nodeType = visitType(node, { ignorePairName: node.prim === 'pair' });\n\n\t// Method args are usually objects\n\tif (nodeType.kind === 'object') {\n\t\treturn [{ name, args: nodeType.fields }];\n\t}\n\n\t// Simple methods can have a single unnamed argument\n\treturn [{\n\t\tname,\n\t\targs: [{ type: nodeType }],\n\t}];\n};\n\n// type PrimOf<T extends M.MichelsonType> = T extends { prim: infer U } ? U : never;\n// type WithPrim<T extends M.MichelsonType, P extends PrimOf<T>> = T extends { prim: P } ? T : never;\n// const isPrimType = <TPrim extends PrimOf<M.MichelsonType>>(node: undefined | null | M.MichelsonType, prim: TPrim): node is WithPrim<M.MichelsonType, TPrim> => {\n// return (node && 'prim' in node && node.prim === prim) || false;\n// };\n\ntype MVarArgs = M.MichelsonType;\nconst visitVar = (node: MVarArgs): TypedVar[] => {\n\tconst name = `annots` in node && node.annots?.length === 1 ? node.annots[0].substr(1) : undefined;\n\tconst type = visitType(node);\n\n\treturn [{\n\t\tname,\n\t\ttype,\n\t}];\n};\n\ntype MType = M.MichelsonType;\nconst visitType = (node: MType, options?: { ignorePairName?: boolean }): TypedType => {\n\t// console.log('visitType', { node });\n\t// const debug_source = toDebugSource(node);\n\n\t// if (typeof node === `string`) {\n\t// return { kind: `value`, raw: node, value: node, typescriptType: `string` };\n\t// }\n\n\tif (!(`prim` in node)) {\n\t\t// Unknown\n\t\tconsole.error(`visitType no prim`, { node });\n\t\treturn { kind: `unknown`, raw: node };\n\t}\n\n\t// Union\n\tif (node.prim === `or`) {\n\t\tconst unionVars = node.args.map(x => visitVar(x)).reduce(reduceFlatMap, []).map(x => x);\n\n\t\t// Flatten with child unions\n\t\tconst union = unionVars.map(x => !x.name && x.type.kind === 'union' ? x.type.union : [x]).reduce(reduceFlatMap, []);\n\t\t// const union = unionVars.map(x=>x.type);\n\n\t\t// const union = unionVars.map(x => x.type);\n\n\t\t// Flatten with child unions\n\n\t\t// const rightSide = union[1];\n\t\t// if (rightSide.kind === `union`) {\n\t\t// union.pop();\n\t\t// union.push(...rightSide.union);\n\t\t// }\n\n\t\tif (union.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`or: Some fields are null`, { node });\n\t\t}\n\t\treturn {\n\t\t\tkind: `union`,\n\t\t\traw: node,\n\t\t\tunion,\n\t\t};\n\t}\n\n\t// Intersect\n\tif (node.prim === `pair`) {\n\t\tconst fields = node.args.map(x => visitVar(x)).reduce(reduceFlatMap, []);\n\t\tif (fields.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`pair: Some fields are null`, { node, args: node.args, fields });\n\t\t}\n\t\t// Disabled Check: Apparently pairs can have more than 2 items\n\t\t// if (fields.length !== 2) {\n\t\t// throw new GenerateApiError(`pair: Expected 2 items`, { node, length: fields.length, fields });\n\t\t// }\n\n\t\t// Flatten with unnamed child pairs\n\t\tconst fieldsFlat = fields.map(x =>\n\t\t\t(!x.name || options?.ignorePairName) && x.type.kind === 'object' ? x.type.fields : [x]\n\t\t).reduce(reduceFlatMap, []);\n\n\t\treturn {\n\t\t\tkind: `object`,\n\t\t\traw: node,\n\t\t\tfields: fieldsFlat,\n\t\t};\n\t}\n\n\t// list\n\tif (\n\t\tnode.prim === `list`\n\t\t|| node.prim === `set`\n\t) {\n\t\tif (node.args.length !== 1) {\n\t\t\tthrow new GenerateApiError(`list does not have 1 arg`, { node, args: node.args });\n\t\t}\n\n\t\tconst arrayItem = visitType(node.args[0]);\n\t\tif (!arrayItem) {\n\t\t\tthrow new GenerateApiError(`arrayItem are null`, { node, args: node.args, arrayItem });\n\t\t}\n\t\treturn {\n\t\t\tkind: `array`,\n\t\t\traw: node,\n\t\t\tarray: { item: arrayItem },\n\t\t};\n\t}\n\n\t// map\n\tif (\n\t\tnode.prim === `map`\n\t\t|| node.prim === `big_map`\n\t) {\n\t\tif (node.args.length !== 2) {\n\t\t\tthrow new GenerateApiError(`map does not have 2 args`, { node, args: node.args });\n\t\t}\n\n\t\tconst mapKey = visitType(node.args[0]);\n\t\tconst mapValue = visitType(node.args[1]);\n\t\tif (!mapKey || !mapValue) {\n\t\t\tthrow new GenerateApiError(`map is missing key or value`, { node, args: node.args, mapKey, mapValue });\n\t\t}\n\t\treturn {\n\t\t\tkind: `map`,\n\t\t\traw: node,\n\t\t\tmap: {\n\t\t\t\tkey: mapKey,\n\t\t\t\tvalue: mapValue,\n\t\t\t\tisBigMap: node.prim === `big_map`,\n\t\t\t},\n\t\t};\n\t}\n\n\t// option\n\tif (node.prim === `option`) {\n\t\treturn {\n\t\t\t...visitType(node.args[0]),\n\t\t\toptional: true,\n\t\t};\n\t}\n\n\t// boolean\n\tif (node.prim === `bool`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `boolean`,\n\t\t};\n\t}\n\n\t// numbers\n\tif (\n\t\tnode.prim === `nat`\n\t\t|| node.prim === `int`\n\t\t|| node.prim === `mutez`\n\t) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `number`,\n\t\t};\n\t}\n\n\t// Date\n\tif (node.prim === `timestamp`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `Date`,\n\t\t};\n\t}\n\n\t// strings\n\tif (\n\t\tnode.prim === `address`\n\t\t|| node.prim === `key`\n\t\t|| node.prim === `key_hash`\n\t\t|| node.prim === `chain_id`\n\t\t|| node.prim === `string`\n\t\t|| node.prim === `signature`\n\t\t|| node.prim === `ticket`\n\t\t|| node.prim === `bls12_381_fr`\n\t\t|| node.prim === `bls12_381_g1`\n\t\t|| node.prim === `bls12_381_g2`\n\t\t|| node.prim === `sapling_state`\n\t\t|| node.prim === `sapling_transaction`\n\t\t|| node.prim === `contract`\n\t) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// void\n\tif (node.prim === `unit`) {\n\t\treturn {\n\t\t\tkind: `unit`,\n\t\t\traw: node,\n\t\t};\n\t}\n\n\t// bytes?\n\tif (node.prim === `bytes`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\tif (node.prim === `lambda`) {\n\t\tif (node.args.length !== 2) {\n\t\t\tthrow new GenerateApiError(`lambda does not have 2 args`, { node, args: node.args });\n\t\t}\n\n\t\tconst argType = visitType(node.args[0]);\n\t\tconst retType = visitType(node.args[1]);\n\t\tif (!argType || !retType) {\n\t\t\tthrow new GenerateApiError(`lambda is missing arg or return`, { node, args: node.args, argType, retType });\n\t\t}\n\n\t\treturn {\n\t\t\tkind: `lambda`,\n\t\t\traw: node,\n\t\t\tlambda: {\n\t\t\t\targ: argType,\n\t\t\t\tret: retType,\n\t\t\t},\n\t\t};\n\t}\n\n\t// misc?\n\tif (node.prim === `operation`) {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// chest\n\tif (node.prim === 'chest' || node.prim === 'chest_key') {\n\t\treturn {\n\t\t\tkind: `value`,\n\t\t\traw: node,\n\t\t\tvalue: node.prim,\n\t\t\ttypescriptType: `string`,\n\t\t};\n\t}\n\n\t// never\n\tif (node.prim === `never`) {\n\t\treturn {\n\t\t\tkind: `never`,\n\t\t\traw: node,\n\t\t};\n\t}\n\n\t// Unknown\n\tassertExhaustive(node, `Unknown type`);\n\tthrow new GenerateApiError(`Unknown type`, { node });\n};\n","import { GenerateApiError } from './common';\nimport { TypedMethod, TypedStorage, TypedType, TypedVar } from './contract-parser';\n\ntype SchemaObjectType = { [name: string]: SchemaType };\ntype SchemaOptionalType = { optional: true; type: SchemaType };\ntype SchemaType = string | SchemaType[] | SchemaObjectType | SchemaOptionalType | null;\ntype SchemaMethods = {\n\t[name: string]: {\n\t\tparams: SchemaType;\n\t};\n};\nexport type SchemaOutput = {\n\tmethods: SchemaMethods;\n\tstorage: SchemaType;\n};\n\nexport const toSchema = (methods: TypedMethod[], storage: TypedStorage): SchemaOutput => {\n\tconst getSchemaObjectType = (vars: TypedVar[]) => {\n\t\t// console.log('getSchemaObjectType', { vars });\n\n\t\tif (vars.some(x => !x)) {\n\t\t\tthrow new GenerateApiError(`getSchemaObjectType has null vars`, { vars });\n\t\t}\n\n\t\treturn vars.reduce((out, x, i) => {\n\t\t\tout[x.name ?? i] = getSchemaType(x.type);\n\t\t\treturn out;\n\t\t}, {} as SchemaObjectType);\n\t};\n\n\tconst getSchemaType = (t: TypedType): SchemaType => {\n\t\tswitch (t.kind) {\n\t\t\tcase 'value':\n\t\t\t\tif (t.value) {\n\t\t\t\t\treturn t.optional\n\t\t\t\t\t\t? { optional: true, type: t.value }\n\t\t\t\t\t\t: t.value;\n\t\t\t\t}\n\t\t\t\treturn null;\n\n\t\t\tcase 'array':\n\t\t\t\treturn t.array ? [getSchemaType(t.array.item)] : null;\n\n\t\t\tcase 'map':\n\t\t\t\treturn t.map ? ['map', getSchemaType(t.map.key), getSchemaType(t.map.value)] : null;\n\n\t\t\tcase 'object':\n\t\t\t\treturn t.fields ? getSchemaObjectType(t.fields) : null;\n\n\t\t\tcase 'unit':\n\t\t\t\treturn 'unit';\n\n\t\t\tcase 'never':\n\t\t\t\treturn 'never';\n\n\t\t\tcase 'lambda':\n\t\t\t\treturn ['lambda', getSchemaType(t.lambda.arg), getSchemaType(t.lambda.ret)];\n\n\t\t\tdefault:\n\t\t\t\treturn `${t.raw as unknown as string}`;\n\t\t}\n\t};\n\n\tconst schemaMethods = methods.reduce((out, x) => {\n\t\t// console.log('schemaMethods', { x });\n\n\t\tout[x.name] = {\n\t\t\tparams: x.args.length === 1 && !x.args[0].name\n\t\t\t\t? getSchemaType(x.args[0].type)\n\t\t\t\t: getSchemaObjectType(x.args ?? []),\n\t\t};\n\t\treturn out;\n\t}, {} as SchemaMethods);\n\n\tconst schemaStorage = getSchemaType(storage.storage);\n\n\treturn {\n\t\tmethods: schemaMethods,\n\t\tstorage: schemaStorage,\n\t};\n};\n","import { assertExhaustive, GenerateApiError, reduceFlatMap } from './common';\nimport { TypedMethod, TypedStorage, TypedType, TypedVar } from './contract-parser';\n\nexport type TypescriptCodeOutput = {\n\ttypesFileContent: string;\n\tcontractCodeFileContent: string;\n\tstorage: string;\n\tmethods: string;\n\tmethodsObject: string;\n};\n\nexport type TypeAliasData = {\n\tmode: 'local';\n\tfileContent?: string;\n} | {\n\tmode: 'file' | 'library';\n\timportPath?: string;\n} | {\n\tmode: 'simple';\n};\n\nexport type TypeUtilsData = {\n\timportPath: string;\n};\n\nexport const createTypescriptCodeGenerator = (options?: { mode?: 'types' | 'defaultValue' }) => {\n\ttype TypeAlias = {\n\t\taliasType: string;\n\t\tsimpleTypeDefinition: string;\n\t\tsimpleTypeImports?: { name: string; isDefault?: boolean; from: string }[];\n\t};\n\tconst usedStrictTypes = [] as TypeAlias[];\n\tconst addTypeAlias = (strictType: TypeAlias) => {\n\t\tif (!usedStrictTypes.some(x => x.aliasType === strictType.aliasType)) {\n\t\t\tusedStrictTypes.push(strictType);\n\t\t}\n\t};\n\n\t// Not really tabs :)\n\tconst tabs = (indent: number) => Array(indent).fill(` `).join(``);\n\tconst toIndentedItems = (\n\t\tindent: number,\n\t\tdelimiters: { afterItem?: string; beforeItem?: string },\n\t\titems: string[],\n\t) => {\n\t\treturn `\n${tabs(indent + 1)}${\n\t\t\titems.join(`${delimiters.afterItem ?? ``}\n${tabs(indent + 1)}${delimiters.beforeItem ?? ``}`)\n\t\t}\n${tabs(indent)}`;\n\t};\n\n\tconst typeToCode = (t: TypedType, indent: number): string => {\n\t\tif (t.optional) {\n\t\t\treturn `{Some: ${typeToCode({ ...t, optional: false }, indent)}} | null`;\n\t\t}\n\n\t\tif (options?.mode === 'defaultValue') {\n\t\t\treturn typeToCode_defaultValue(t, indent);\n\t\t}\n\n\t\tif (t.kind === `value`) {\n\t\t\t// return `${t.typescriptType}`;\n\n\t\t\tconst prim = `prim` in t.raw ? t.raw.prim : `unknown`;\n\n\t\t\t// Strict mode\n\t\t\tif (\n\t\t\t\tt.typescriptType === `boolean`\n\t\t\t\t|| t.typescriptType === `string` && prim === `string`\n\t\t\t) {\n\t\t\t\treturn `${t.typescriptType}`;\n\t\t\t}\n\n\t\t\tif (t.typescriptType === 'number') {\n\t\t\t\tconst simpleBaseType = `string | BigNumber | number`;\n\t\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\t\taliasType: prim,\n\t\t\t\t\tsimpleTypeDefinition: `type ${prim} = ${simpleBaseType};`,\n\t\t\t\t\tsimpleTypeImports: [{ name: 'BigNumber', isDefault: true, from: 'bignumber.js' }],\n\t\t\t\t};\n\t\t\t\taddTypeAlias(typeAlias);\n\n\t\t\t\treturn typeAlias.aliasType;\n\t\t\t}\n\n\t\t\tconst simpleBaseType = t.typescriptType === 'Date' ? 'Date | string' : t.typescriptType;\n\t\t\tconst typeAlias: TypeAlias = { aliasType: prim, simpleTypeDefinition: `type ${prim} = ${simpleBaseType};` };\n\t\t\taddTypeAlias(typeAlias);\n\n\t\t\treturn typeAlias.aliasType;\n\t\t}\n\t\tif (t.kind === `array`) {\n\t\t\treturn `Array<${typeToCode(t.array.item, indent)}>`;\n\t\t}\n\t\tif (t.kind === `map`) {\n\t\t\tconst typeAlias: TypeAlias = t.map.isBigMap\n\t\t\t\t? {\n\t\t\t\t\taliasType: `BigMap`,\n\t\t\t\t\tsimpleTypeDefinition: 'type BigMap<K, T> = MichelsonMap<K, T>;',\n\t\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonMap', from: '@taquito/taquito' }],\n\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\taliasType: `MMap`,\n\t\t\t\t\tsimpleTypeDefinition: 'type MMap<K, T> = MichelsonMap<K, T>;',\n\t\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonMap', from: '@taquito/taquito' }],\n\t\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\n\t\t\treturn `${typeAlias.aliasType}<${typeToCode(t.map.key, indent)}, ${typeToCode(t.map.value, indent)}>`;\n\t\t}\n\t\tif (t.kind === `lambda`) {\n\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\taliasType: 'Instruction',\n\t\t\t\tsimpleTypeDefinition: `type Instruction = MichelsonInstruction;`,\n\t\t\t\tsimpleTypeImports: [{ name: 'MichelsonInstruction', isDefault: false, from: '@taquito/michel-codec' }],\n\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\t\t\treturn `Instruction[]`;\n\t\t}\n\t\tif (t.kind === `object`) {\n\t\t\treturn `{${toIndentedItems(indent, {}, t.fields.map((a, i) => varToCode(a, i, indent + 1) + `;`))}}`;\n\t\t}\n\t\tif (t.kind === `union`) {\n\t\t\tconst getUnionItem = (a: TypedVar, i: number) => {\n\t\t\t\tconst itemCode = `${varToCode(a, i, indent + 1)}`;\n\n\t\t\t\t// Keep on single line if already on single line\n\t\t\t\tif (!itemCode.includes(`\\n`)) {\n\t\t\t\t\treturn `{ ${itemCode} }`;\n\t\t\t\t}\n\n\t\t\t\t// Indent if multi-line (and remake with extra indent)\n\t\t\t\treturn `{${toIndentedItems(indent + 1, {}, [`${varToCode(a, i, indent + 2)}`])}}`;\n\t\t\t};\n\n\t\t\treturn `(${toIndentedItems(indent, { beforeItem: `| ` }, t.union.map(getUnionItem))})`;\n\t\t}\n\t\tif (t.kind === `unit`) {\n\t\t\tconst typeAlias: TypeAlias = {\n\t\t\t\taliasType: `unit`,\n\t\t\t\tsimpleTypeDefinition: `type unit = (true | undefined);`,\n\t\t\t};\n\t\t\taddTypeAlias(typeAlias);\n\t\t\treturn typeAlias.aliasType;\n\t\t}\n\t\tif (t.kind === `never`) {\n\t\t\treturn `never`;\n\t\t}\n\t\tif (t.kind === `unknown`) {\n\t\t\treturn `unknown`;\n\t\t}\n\n\t\tassertExhaustive(t, `Unknown type`);\n\t\tthrow new GenerateApiError(`Unknown type node`, { t });\n\t};\n\n\tconst typeToCode_defaultValue = (t: TypedType, indent: number): string => {\n\t\tif (t.kind === `value`) {\n\t\t\t// return `${t.typescriptType}`;\n\n\t\t\tconst prim = `prim` in t.raw ? t.raw.prim : `unknown`;\n\n\t\t\t// Strict mode\n\t\t\tif (t.typescriptType === 'boolean') {\n\t\t\t\treturn `true`;\n\t\t\t}\n\t\t\tif (t.typescriptType === `string` && prim === `string`) {\n\t\t\t\treturn `'VALUE'`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'number') {\n\t\t\t\treturn `tas.${prim}('42')`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'Date') {\n\t\t\t\treturn `tas.timestamp(new Date())`;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tprim === 'address'\n\t\t\t\t|| prim === 'contract'\n\t\t\t) {\n\t\t\t\treturn `tas.${prim}('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456')`;\n\t\t\t}\n\t\t\tif (prim === 'bytes') {\n\t\t\t\treturn `tas.${prim}(char2Bytes('DATA'))`;\n\t\t\t}\n\t\t\tif (t.typescriptType === 'string') {\n\t\t\t\treturn `tas.${prim}('VALUE')`;\n\t\t\t}\n\t\t\tassertExhaustive(t.typescriptType, `Unknown value type`);\n\n\t\t\treturn prim;\n\t\t}\n\t\tif (t.kind === `array`) {\n\t\t\treturn `[${typeToCode(t.array.item, indent)}]`;\n\t\t}\n\t\tif (t.kind === `map`) {\n\t\t\tconst keyPrim = `prim` in t.map.key.raw ? t.map.key.raw.prim : `unknown`;\n\t\t\tconst isStringBasedKey = t.map.key.kind === 'value' && keyPrim === 'string';\n\t\t\tif (isStringBasedKey) {\n\t\t\t\treturn `tas.${t.map.isBigMap ? 'bigMap' : 'map'}({ \n${tabs(indent + 1)}${typeToCode(t.map.key, indent)}: ${typeToCode(t.map.value, indent)},\n${tabs(indent)}})`;\n\t\t\t}\n\n\t\t\treturn `tas.${t.map.isBigMap ? 'bigMap' : 'map'}([{ \n${tabs(indent + 1)}key: ${typeToCode(t.map.key, indent)}, \n${tabs(indent + 1)}value: ${typeToCode(t.map.value, indent)},\n${tabs(indent)}}])`;\n\t\t}\n\t\tif (t.kind === `object`) {\n\t\t\tconst delimiter = options?.mode === 'defaultValue' ? ',' : `;`;\n\t\t\treturn `{${toIndentedItems(indent, {}, t.fields.map((a, i) => varToCode(a, i, indent + 1) + delimiter))}}`;\n\t\t}\n\t\tif (t.kind === `union`) {\n\t\t\tconst getUnionItem = (a: TypedVar, i: number) => {\n\t\t\t\tconst itemCode = `${varToCode(a, i, indent + 1)}`;\n\n\t\t\t\t// Keep on single line if already on single line\n\t\t\t\tif (!itemCode.includes(`\\n`)) {\n\t\t\t\t\treturn `{ ${itemCode} }`;\n\t\t\t\t}\n\n\t\t\t\t// Indent if multi-line (and remake with extra indent)\n\t\t\t\treturn `{${toIndentedItems(indent + 1, {}, [`${varToCode(a, i, indent + 2)}`])}}`;\n\t\t\t};\n\n\t\t\treturn `(${toIndentedItems(indent, { beforeItem: `| ` }, t.union.map(getUnionItem))})`;\n\t\t}\n\t\tif (t.kind === `unit`) {\n\t\t\treturn `tas.unit()`;\n\t\t}\n\t\tif (t.kind === `never`) {\n\t\t\treturn `never`;\n\t\t}\n\t\tif (t.kind === `unknown`) {\n\t\t\treturn `unknown`;\n\t\t}\n\t\tif (t.kind === 'lambda') {\n\t\t\treturn `tas.lambda([])`;\n\t\t}\n\n\t\tassertExhaustive(t, `Unknown type`);\n\t\tthrow new GenerateApiError(`Unknown type node`, { t });\n\t};\n\n\tconst varToCode = (t: TypedVar, i: number, indent: number, numberVarNamePrefix = ''): string => {\n\t\tlet typeName = typeToCode(t.type, indent);\n\t\treturn `${t.name ?? `${numberVarNamePrefix}${i}`}: ${typeName}`;\n\t};\n\n\tconst argsToCode = (args: TypedVar[], indent: number, asObject: boolean): string => {\n\t\tif (args.length === 1) {\n\t\t\tif (args[0].type.kind === `unit`) return ``;\n\n\t\t\tif (options?.mode === 'defaultValue') {\n\t\t\t\treturn typeToCode(args[0].type, indent + 1);\n\t\t\t}\n\t\t\treturn `${args[0].name ?? `param`}: ${typeToCode(args[0].type, indent + 1)}`;\n\t\t}\n\n\t\tconst result = `${\n\t\t\ttoIndentedItems(\n\t\t\t\tindent,\n\t\t\t\t{},\n\t\t\t\targs.filter(x => x.name || x.type.kind !== `unit`).map((a, i) => {\n\t\t\t\t\tif (!asObject && options?.mode === 'defaultValue') {\n\t\t\t\t\t\treturn typeToCode(a.type, indent + 1) + `,`;\n\t\t\t\t\t}\n\t\t\t\t\treturn varToCode(a, i, indent + 1, asObject ? '' : '_') + `,`;\n\t\t\t\t}),\n\t\t\t)\n\t\t}`;\n\n\t\tif (asObject) {\n\t\t\tif (options?.mode === 'defaultValue') {\n\t\t\t\treturn `{${result}}`;\n\t\t\t}\n\t\t\treturn `params: {${result}}`;\n\t\t}\n\n\t\treturn result;\n\t};\n\n\treturn {\n\t\tusedStrictTypes,\n\t\ttabs,\n\t\ttoIndentedItems,\n\t\ttypeToCode,\n\t\targsToCode,\n\t};\n};\n\nexport const toTypescriptCode = (\n\tstorage: TypedStorage,\n\tmethods: TypedMethod[],\n\tcontractName: string,\n\tparsedContract: unknown,\n\tprotocol: { name: string; key: string },\n\ttypeAliasData: TypeAliasData,\n\ttypeUtilsData: TypeUtilsData,\n): TypescriptCodeOutput => {\n\tconst {\n\t\tusedStrictTypes,\n\t\ttoIndentedItems,\n\t\ttypeToCode,\n\t\targsToCode,\n\t} = createTypescriptCodeGenerator();\n\n\tconst methodsToCode = (indent: number) => {\n\t\tconst methodFields = methods.map(x => {\n\t\t\tconst methodCode = `${x.name}: (${argsToCode(x.args, indent + 1, false)}) => Promise<void>;`;\n\t\t\treturn methodCode;\n\t\t});\n\n\t\tconst methodsTypeCode = `type Methods = {${toIndentedItems(indent, {}, methodFields)}};`;\n\t\treturn methodsTypeCode;\n\t};\n\tconst methodsObjectToCode = (indent: number) => {\n\t\tconst methodFields = methods.map(x => {\n\t\t\tconst methodCode = `${x.name}: (${argsToCode(x.args, indent + 1, true)}) => Promise<void>;`;\n\t\t\treturn methodCode;\n\t\t});\n\n\t\tconst methodsTypeCode = `type MethodsObject = {${toIndentedItems(indent, {}, methodFields)}};`;\n\t\treturn methodsTypeCode;\n\t};\n\n\tconst storageToCode = (indent: number) => {\n\t\tconst storageTypeCode = `export type Storage = ${typeToCode(storage.storage, indent)};`;\n\t\treturn storageTypeCode;\n\t};\n\n\tconst methodsCode = methodsToCode(0);\n\tconst methodsObjectCode = methodsObjectToCode(0);\n\tconst storageCode = storageToCode(0);\n\n\t// Simple type aliases\n\tconst simpleTypeMappingImportsAll = new Map(\n\t\tusedStrictTypes.map(x => x.simpleTypeImports ?? []).reduce(reduceFlatMap, []).map(\n\t\t\tx => [`${x?.from}:${x?.name}:${x?.isDefault}`, x],\n\t\t),\n\t);\n\tconst simpleTypeMappingImportsFrom = [...simpleTypeMappingImportsAll.values()].reduce((out, x) => {\n\t\tconst entry = out[x.from] ?? (out[x.from] = { names: [] });\n\t\tif (x.isDefault) {\n\t\t\tentry.default = x.name;\n\t\t} else {\n\t\t\tentry.names.push(x.name);\n\t\t}\n\t\tentry.names.sort((a, b) => a.localeCompare(b));\n\t\treturn out;\n\t}, {} as { [from: string]: { names: string[]; default?: string } });\n\n\tconst simpleTypeMappingImportsText = Object.keys(simpleTypeMappingImportsFrom)\n\t\t.map(k => {\n\t\t\tconst entry = simpleTypeMappingImportsFrom[k];\n\t\t\tconst items = [entry.default, entry.names.length ? `{ ${entry.names.join(', ')} }` : ''].filter(x => x);\n\t\t\treturn `import ${items.join(', ')} from '${k}';\\n`;\n\t\t})\n\t\t.join('');\n\n\tconst simpleTypeMapping = usedStrictTypes\n\t\t.sort((a, b) => a.aliasType.localeCompare(b.aliasType))\n\t\t.map(x => x.simpleTypeDefinition).join(`\\n`);\n\n\tconst typeUtilsDefinitions =\n\t\t`import { ContractAbstractionFromContractType, WalletContractAbstractionFromContractType } from '${typeUtilsData.importPath}';`;\n\n\tconst typeAliasesDefinitions = typeAliasData.mode === 'simple'\n\t\t? `${simpleTypeMappingImportsText}${simpleTypeMapping}`\n\t\t: typeAliasData.mode === 'local'\n\t\t? typeAliasData.fileContent\n\t\t: `import { ${usedStrictTypes.map(x => x.aliasType).join(`, `)} } from '${typeAliasData.importPath}';`;\n\n\tconst contractTypeName = `${contractName}ContractType`;\n\tconst walletTypeName = `${contractName}WalletType`;\n\tconst codeName = `${contractName}Code`;\n\n\tconst typesFileContent = `\n${typeUtilsDefinitions}\n${typeAliasesDefinitions}\n\n${storageCode}\n\n${methodsCode}\n\n${methodsObjectCode}\n\ntype contractTypes = { methods: Methods, methodsObject: MethodsObject, storage: Storage, code: { __type: '${codeName}', protocol: string, code: object[] } };\nexport type ${contractTypeName} = ContractAbstractionFromContractType<contractTypes>;\nexport type ${walletTypeName} = WalletContractAbstractionFromContractType<contractTypes>;\n`;\n\n\tconst contractCodeFileContent = `\nexport const ${codeName}: { __type: '${codeName}', protocol: string, code: object[] } = {\n __type: '${codeName}',\n protocol: '${protocol.key}',\n code: JSON.parse(\\`${JSON.stringify(parsedContract)}\\`)\n};\n`;\n\treturn {\n\t\ttypesFileContent,\n\t\tcontractCodeFileContent,\n\t\tstorage: storageCode,\n\t\tmethods: methodsCode,\n\t\tmethodsObject: methodsObjectCode,\n\t};\n};\n","// This is required for copying the type aliases to a local file\nexport const typeAliasesFileContent = `\nimport { assertMichelsonInstruction, Expr, MichelsonCode } from '@taquito/michel-codec';\nimport { MichelsonMap } from '@taquito/taquito';\nimport { BigNumber } from 'bignumber.js';\n\nexport type Instruction = MichelsonCode;\n\nexport type unit = (true | undefined) & { __type: 'unit' };\n\nexport type address = string & { __type: 'address' };\nexport type bytes = string & { __type: 'bytes' };\nexport type contract = string & { __type: 'contract' };\nexport type operation = string & { __type: 'operation' };\nexport type key = string & { __type: 'key' };\nexport type key_hash = string & { __type: 'key_hash' };\nexport type signature = string & { __type: 'signature' };\nexport type ticket = string & { __type: 'ticket' };\n\nexport type timestamp = string & { __type: 'timestamp' };\n\nexport type int = BigNumber & { __type: 'int' };\nexport type nat = BigNumber & { __type: 'nat' };\n\nexport type mutez = BigNumber & { __type: 'mutez' };\nexport type tez = BigNumber & { __type: 'tez' };\n\ntype MapKey = Array<any> | object | string | boolean | number;\nexport type MMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => V };\nexport type BigMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => Promise<V> };\n\nexport type chest = string & { __type: 'chest' };\nexport type chest_key = string & { __type: 'chest_key' };\n\nconst createStringTypeTas = <T extends string>() => {\n\treturn (value: string): T => value as T;\n};\n\nconst createBigNumberTypeTas = <T extends BigNumber>() => {\n\treturn (value: number | BigNumber | string): T => new BigNumber(value) as T;\n};\n\ntype asMapParamOf<K, V> = K extends string ? { [key: string]: V } | Array<{ key: K; value: V }>\n\t: K extends number ? { [key: number]: V } | Array<{ key: K; value: V }>\n\t: Array<{ key: K; value: V }>;\n\nfunction asMap<K extends MapKey, V>(value: asMapParamOf<K, V>): MMap<K, V> {\n\tconst m = new MichelsonMap<K, V>();\n\tif (Array.isArray(value)) {\n\t\tconst vArray = value as Array<{ key: K; value: V }>;\n\t\tvArray.forEach(x => m.set(x.key, x.value));\n\t} else {\n\t\tconst vObject = value as { [key: string]: V };\n\t\tObject.keys(vObject).forEach(key => m.set(key as unknown as K, vObject[key]));\n\t}\n\treturn m as MMap<K, V>;\n}\nconst asBigMap = <K extends MapKey, V>(value: asMapParamOf<K, V>) => asMap(value) as unknown as BigMap<K, V>;\n\nfunction add<T extends BigNumber>(a: T, b: T): T {\n\treturn a.plus(b) as T;\n}\nfunction subtract<T extends BigNumber>(a: T, b: T): T {\n\treturn a.minus(b) as T;\n}\n\nfunction createLambdaTypeTas(expr: Expr): MichelsonCode {\n\tassertMichelsonInstruction(expr);\n return expr as MichelsonCode;\n}\n\n/** tas: Tezos 'as' casting for strict types */\nexport const tas = {\n\taddress: createStringTypeTas<address>(),\n\tbytes: createStringTypeTas<bytes>(),\n\tcontract: createStringTypeTas<contract>(),\n\tchest: createStringTypeTas<chest>(),\n\tchest_key: createStringTypeTas<chest_key>(),\n\ttimestamp: (value: string | Date): timestamp => new Date(value).toISOString() as timestamp,\n\n\tint: createBigNumberTypeTas<int>(),\n\tnat: createBigNumberTypeTas<nat>(),\n\tmutez: createBigNumberTypeTas<mutez>(),\n\ttez: createBigNumberTypeTas<tez>(),\n\n\tmap: asMap,\n\tbigMap: asBigMap,\n\n\t// Operations\n\tadd,\n\tsubtract,\n\n lambda: createLambdaTypeTas,\n\n\t// To number\n\tnumber: (value: string | BigNumber) => Number(value + ''),\n\tunit: () => true as unit,\n};\n`;\n","// This is required for copying the type utils to a local file\nexport const typeUtilsFileContent = `\nimport { ContractAbstraction, ContractMethod, ContractMethodObject, ContractProvider, Wallet } from '@taquito/taquito';\n\ntype BaseContractType = { methods: unknown, methodsObject: unknown, storage: unknown };\n\ntype ContractMethodsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {\n[M in keyof TContract['methods']]:\nTContract['methods'][M] extends (...args: infer A) => unknown\n? (...args: A) => ContractMethod<T>\n: never\n};\ntype ContractMethodsObjectsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {\n[M in keyof TContract['methodsObject']]:\nTContract['methodsObject'][M] extends (...args: infer A) => unknown\n? (...args: A) => ContractMethodObject<T>\n: never\n};\ntype ContractStorageOf<TContract extends BaseContractType> = TContract['storage'];\n\nexport type ContractAbstractionFromContractType<TContract extends BaseContractType> = \n ContractAbstraction<ContractProvider, \n ContractMethodsOf<ContractProvider, TContract>,\n ContractMethodsObjectsOf<ContractProvider, TContract>,\n {},\n {},\n ContractStorageOf<TContract>\n >;\n\nexport type WalletContractAbstractionFromContractType<TContract extends BaseContractType> = \n ContractAbstraction<Wallet, \n ContractMethodsOf<Wallet, TContract>,\n ContractMethodsObjectsOf<Wallet, TContract>,\n {},\n {},\n ContractStorageOf<TContract>\n >;\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAoD;;;ACApD,sBAA4C;AAC5C,uBAAiB;AACjB,IAAAC,eAAqB;;;ACFrB,gBAAkB;AAClB,kBAAiB;AACjB,kBAA0B;;;ACFnB,IAAM,wBAAwB,CAAC,SACrC,KACE,QAAQ,iBAAiB,GAAG,EAC5B,MAAM,GAAG,EACT,OAAO,OAAK,CAAC,EACb,IAAI,OAAK,EAAE,CAAC,EAAE,YAAY,IAAI,EAAE,UAAU,CAAC,CAAC,EAC5C,KAAK,EAAE;;;ACNV,QAAmB;;;ACAZ,IAAM,mBAAN,MAAwC;AAAA,EAE9C,YAAmB,SAA0B,MAAe;AAAzC;AAA0B;AAD7C,gBAAO;AAEN,YAAQ,MAAM,4BAAuB,OAAO,IAAI,IAAI;AAAA,EACrD;AACD;AAE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AAM,OAAO,8BAAc;AACjD,SAAO,MAAM,QAAQ,IAAI,cAAc,IAAI,sBAAsB,UAAU,CAAC,CAAC;AAC9E;AAEO,IAAM,gBAAgB,CAAC,eAAqB;AAClD,aAAW,gBAAgB,WAAW,iBAAiB;AAEvD,UAAQ,IAAI,iBAAiB;AAAA,IAC5B,eAAe,WAAW;AAAA,EAC3B,CAAC;AAED,QAAM,IAAI,WAAW,WAClB,sBAAsB,UAAU,EAAE,WAAW,QAAQ,IACrD,yBAAyB,UAAU;AAEtC,SAAO,EAAE,KAAK,UAAQ;AACrB,YAAQ;AAAA,MACN,MAAM,QAAQ,IAAI,IAChB,KAAK,KAAK,IAAI,IACd;AAAA,IACJ;AAAA,EACD,CAAC;AACF;AAEO,IAAM,QAAQ;AAAA,EACpB;AACD;;;ADtDA,wBAAO,OAAO,WAAS;AAAA,EACtB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,IACN,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,QACf,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,WAAW;AAAA,UACX,MAAM;AAAA,UACN,SAAS,CAAC,QAAQ,QAAQ;AAAA,UAC1B,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,MACA,SAAS,CAAC,aAAa,UAAU;AAAA,MACjC,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA,OAAO,MAAM;AACd,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_path","simpleBaseType","typeAlias","fsRaw","path","glob"]}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","tasks.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport { tasks } from './tasks';\nexport { generateContractTypesProcessContractFiles } from './src/cli-process';\n\nPlugin.create(i18n => ({\n\talias: 'contract-types',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'generate types',\n\t\t\tcommand: 'generate types [typescriptDir]',\n\t\t\tdescription: 'Generate types for a contract to be used with taquito',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'typescriptDir',\n\t\t\t\t\tdescription: 'The output directory for the generated type files',\n\t\t\t\t\tdefaultValue: 'types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tflag: 'typeAliasMode',\n\t\t\t\t\tchoices: ['file', 'simple'],\n\t\t\t\t\tdescription: 'The type aliases used in the generated types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['gen types', 'gentypes'],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t],\n\tproxy: tasks.generateTypes,\n}), process.argv);\n","import { isContractFile, RequestArgs } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { generateContractTypesProcessContractFiles } from './src/cli-process';\ninterface Opts extends RequestArgs.t {\n\t// TODO: Document these\n\ttypescriptDir?: string;\n\ttypeAliasMode?: 'local' | 'file' | 'library' | 'simple';\n\tcontract?: string;\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(\n\t\tparsedArgs.config.artifactsDir ?? 'artifacts',\n\t\t/\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`,\n\t);\n\nconst generateContractTypes = (parsedArgs: Opts)
|
|
1
|
+
{"version":3,"sources":["index.ts","tasks.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport { tasks } from './tasks';\nexport { generateContractTypesProcessContractFiles } from './src/cli-process';\n\nPlugin.create(i18n => ({\n\talias: 'contract-types',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'generate types',\n\t\t\tcommand: 'generate types [typescriptDir]',\n\t\t\tdescription: 'Generate types for a contract to be used with taquito',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'typescriptDir',\n\t\t\t\t\tdescription: 'The output directory for the generated type files',\n\t\t\t\t\tdefaultValue: 'types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tflag: 'typeAliasMode',\n\t\t\t\t\tchoices: ['file', 'simple'],\n\t\t\t\t\tdescription: 'The type aliases used in the generated types',\n\t\t\t\t}),\n\t\t\t],\n\t\t\taliases: ['gen types', 'gentypes'],\n\t\t\thandler: 'proxy',\n\t\t}),\n\t],\n\tproxy: tasks.generateTypes,\n}), process.argv);\n","import { isContractFile, RequestArgs } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { generateContractTypesProcessContractFiles } from './src/cli-process';\ninterface Opts extends RequestArgs.t {\n\t// TODO: Document these\n\ttypescriptDir?: string;\n\ttypeAliasMode?: 'local' | 'file' | 'library' | 'simple';\n\tcontract?: string;\n}\n\nconst getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>\n\tjoin(\n\t\tparsedArgs.config.artifactsDir ?? 'artifacts',\n\t\t/\\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`,\n\t);\n\nconst generateContractTypes = (parsedArgs: Opts) => async (contractFilename: string): Promise<string> => {\n\tconst contractAbspath = getContractAbspath(contractFilename, parsedArgs);\n\tawait generateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [contractAbspath],\n\t\toutputTypescriptDirectory: parsedArgs.typescriptDir || 'types',\n\t\tformat: 'tz',\n\t\ttypeAliasMode: parsedArgs.typeAliasMode ?? 'file',\n\t});\n\n\treturn `${contractFilename}: Types generated`;\n};\n\nconst generateContractTypesAll = async (parsedArgs: Opts): Promise<string[]> => {\n\tconst files = await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir });\n\tconst contractFiles = files.filter(isContractFile);\n\treturn await Promise.all(contractFiles.map(generateContractTypes(parsedArgs)));\n};\n\nexport const generateTypes = (parsedArgs: Opts) => {\n\tparsedArgs.typescriptDir = parsedArgs.typescriptDir || 'types';\n\n\tconsole.log('generateTypes', {\n\t\ttypescriptDir: parsedArgs.typescriptDir,\n\t});\n\n\tconst p = parsedArgs.contract\n\t\t? generateContractTypes(parsedArgs)(parsedArgs.contract)\n\t\t: generateContractTypesAll(parsedArgs);\n\n\treturn p.then(data => {\n\t\tconsole.log(\n\t\t\t(Array.isArray(data))\n\t\t\t\t? data.join('\\n')\n\t\t\t\t: data,\n\t\t);\n\t});\n};\n\nexport const tasks = {\n\tgenerateTypes,\n};\n"],"mappings":";;;;;;AAAA,SAAS,QAAQ,QAAQ,eAAe,YAAY;;;ACApD,SAAS,sBAAmC;AAC5C,OAAO,UAAU;AACjB,SAAS,YAAY;AASrB,IAAM,qBAAqB,CAAC,kBAA0B,eACrD;AAAA,EACC,WAAW,OAAO,gBAAgB;AAAA,EAClC,QAAQ,KAAK,gBAAgB,IAAI,mBAAmB,GAAG,gBAAgB;AACxE;AAED,IAAM,wBAAwB,CAAC,eAAqB,OAAO,qBAA8C;AACxG,QAAM,kBAAkB,mBAAmB,kBAAkB,UAAU;AACvE,QAAM,0CAA0C;AAAA,IAC/C,0BAA0B,WAAW,OAAO,gBAAgB;AAAA,IAC5D,YAAY,CAAC,eAAe;AAAA,IAC5B,2BAA2B,WAAW,iBAAiB;AAAA,IACvD,QAAQ;AAAA,IACR,eAAe,WAAW,iBAAiB;AAAA,EAC5C,CAAC;AAED,SAAO,GAAG,gBAAgB;AAC3B;AAE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6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-contract-types",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.6",
|
|
4
4
|
"main": "index.cjs",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"source": "index.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript": "^5.2.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@taqueria/node-sdk": "^0.42.
|
|
37
|
+
"@taqueria/node-sdk": "^0.42.6",
|
|
38
38
|
"@taquito/michel-codec": "^18.0.0-RC.0",
|
|
39
39
|
"@taquito/signer": "^18.0.0-RC.0",
|
|
40
40
|
"@taquito/taquito": "^18.0.0-RC.0",
|
package/tasks.ts
CHANGED
|
@@ -15,19 +15,18 @@ const getContractAbspath = (contractFilename: string, parsedArgs: Opts) =>
|
|
|
15
15
|
/\.tz$/.test(contractFilename) ? contractFilename : `${contractFilename}.tz`,
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
const generateContractTypes = (parsedArgs: Opts) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
18
|
+
const generateContractTypes = (parsedArgs: Opts) => async (contractFilename: string): Promise<string> => {
|
|
19
|
+
const contractAbspath = getContractAbspath(contractFilename, parsedArgs);
|
|
20
|
+
await generateContractTypesProcessContractFiles({
|
|
21
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',
|
|
22
|
+
inputFiles: [contractAbspath],
|
|
23
|
+
outputTypescriptDirectory: parsedArgs.typescriptDir || 'types',
|
|
24
|
+
format: 'tz',
|
|
25
|
+
typeAliasMode: parsedArgs.typeAliasMode ?? 'file',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return `${contractFilename}: Types generated`;
|
|
29
|
+
};
|
|
31
30
|
|
|
32
31
|
const generateContractTypesAll = async (parsedArgs: Opts): Promise<string[]> => {
|
|
33
32
|
const files = await glob('**/*.tz', { cwd: parsedArgs.config.artifactsDir });
|
package/tsconfig.json
CHANGED
package/_readme.eta
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<% if (it.output == "github") { %>
|
|
2
|
-
# Taqueria Contract Types Plugin
|
|
3
|
-
<% } %>
|
|
4
|
-
|
|
5
|
-
This plugin provides a `taq generate types` command which will generate and export TypeScript types from compiled Michelson smart contracts. These generated types then work with your IDE and Taquito, providing type safety and an improved code authoring experience
|
|
6
|
-
|
|
7
|
-
Benefits of using generated types:
|
|
8
|
-
- Static types used to call smart contract methods are checked at compile time, improving code reliability
|
|
9
|
-
- Generated types enable auto-completion and syntax highlighting in your IDE
|
|
10
|
-
- Developing apps with Taquito is faster and more reliable
|
|
11
|
-
- The VS Code Extension provides tooltip hints for parameter types used to call a smart contract method
|
|
12
|
-
- Calling smart contract methods with types is done directly, removing the need for utility methods
|
|
13
|
-
- Simplifies your code and improves readability
|
|
14
|
-
|
|
15
|
-
## Requirements
|
|
16
|
-
|
|
17
|
-
- Taqueria v0.26.0 or later
|
|
18
|
-
- Node.js v16.16 or later. (v17.x.x or later is not supported)
|
|
19
|
-
- Taquito v11.2 or later (optional)
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
To install the Contract Types plugin on a Taqueria project, navigate to the project folder and run:
|
|
24
|
-
```shell
|
|
25
|
-
taq install @taqueria/plugin-contract-types
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Configuration
|
|
29
|
-
|
|
30
|
-
This plugin will look for Michelson files according to the `artifactsDir` configured in `.taq/config.json`. By default, this value is `artifacts` but can be changed as needed
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
The plugin provides a single command to Taqueria: `taq generate types`
|
|
35
|
-
|
|
36
|
-
This will look for `.tz` files in the `artifacts` directory and will generate a series of related `.ts` files in the `/types` directory (default folder created to store the generated files). These files export type definitions for each method which can then be used by Taquito and your IDE
|
|
37
|
-
|
|
38
|
-
### The `generate types` Command
|
|
39
|
-
|
|
40
|
-
#### Syntax
|
|
41
|
-
```shell
|
|
42
|
-
taq generate types [typeOutputDir]
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
#### Parameters
|
|
46
|
-
|
|
47
|
-
| parameter | required | description |
|
|
48
|
-
|:-------------:|:-----------|----------------------------------------------------|
|
|
49
|
-
| typeOutputDir | no | The output directory for the `.ts` files generated |
|
|
50
|
-
|
|
51
|
-
#### CLI Aliases
|
|
52
|
-
|
|
53
|
-
The following aliases are interchangable with `generate types`
|
|
54
|
-
- `gen`
|
|
55
|
-
- `gentypes`
|
|
56
|
-
|
|
57
|
-
#### Options
|
|
58
|
-
|
|
59
|
-
The `generate types` command will accept the following optional parameters:
|
|
60
|
-
|
|
61
|
-
| flag | name | description |
|
|
62
|
-
|:-----:|:--------------|----------------------------------------------|
|
|
63
|
-
| -t | typeAliasMode | Use type aliases in the generated types |
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## Taquito Workflow Improvements
|
|
67
|
-
|
|
68
|
-
The generated TS types can be used in a Taquito project which provides an improved developing experience, and simplifies the way types are provided to Taquito method calls. Some examples of how these changes are put into use are detailed below
|
|
69
|
-
|
|
70
|
-
<%~ it.noteOpenAdmonition %>
|
|
71
|
-
You can view the full example in the `example-usage.ts` file on Github: [example-usage.ts](https://github.com/pinnacle-labs/taqueria/blob/main/taqueria-plugin-contract-types/example/example-usage.ts)
|
|
72
|
-
<%= it.closeAdmonition %>
|
|
73
|
-
|
|
74
|
-
### Calling the `.at` Method of a Contract
|
|
75
|
-
|
|
76
|
-
Traditionally, calling the `.at` method of a contract with Taquito required the developer to pass the parameter's type via a utility method:
|
|
77
|
-
```ts Utility Method
|
|
78
|
-
const contract = await Tezos.contract.at(`KT123...`, contractAbstractionComposer<TestContractType>());
|
|
79
|
-
```
|
|
80
|
-
or a cast:
|
|
81
|
-
```ts Cast
|
|
82
|
-
const contract = await Tezos.contract.at(`KT123...`) as ContractProviderFromContractType<TestContractType>;
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
When using generated types, the developer can now directly use the type in the call to `.at`:
|
|
86
|
-
```ts
|
|
87
|
-
const contract = await Tezos.contract.at<TestContract>(`KT123...`);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Using a Wallet
|
|
91
|
-
|
|
92
|
-
Using a wallet is simplified in a similar way:
|
|
93
|
-
```ts
|
|
94
|
-
const contract = await Tezos.wallet.at(`KT123...`, walletAbstractionComposer<TestContractType>());
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Becomes:
|
|
98
|
-
```ts
|
|
99
|
-
const contract = await Tezos.wallet.at<TestWalletContract>(`KT123...`);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Contract Origination
|
|
103
|
-
|
|
104
|
-
The Taquito contract origination did not have any way to provide a type, so this used to require a cast:
|
|
105
|
-
```ts
|
|
106
|
-
const originationResult = await Tezos.contract.originate({...});
|
|
107
|
-
const contract = await originationResult.contract(5) as ContractProviderFromContractType<TestContractType2>;
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Now, it can directly accept a type:
|
|
111
|
-
```ts
|
|
112
|
-
const originationResult = await Tezos.contract.originate({...});
|
|
113
|
-
const contract = await originationResult.contract<TestContract2>(5);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
### Storage
|
|
118
|
-
|
|
119
|
-
When accessing storage, there was no way to pass the type through the contract class. This required providing the type a second time:
|
|
120
|
-
```ts
|
|
121
|
-
const contract = await Tezos.contract.at(`KT123...`) as ContractProviderFromContractType<TestContractType>;
|
|
122
|
-
const storage = await contract.storage<StorageFromContractType<TestContractType>>();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Now, the contract type provides the default storage type:
|
|
126
|
-
```ts
|
|
127
|
-
const contract = await Tezos.contract.at<TestContract>(`KT123...`);
|
|
128
|
-
const storage = await contract.storage();
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Plugin Architecture
|
|
132
|
-
|
|
133
|
-
This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM
|