@taqueria/plugin-contract-types 0.73.12 → 0.78.10
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/{chunk-C3LWMIKT.js → chunk-UITQITSS.js} +162 -30
- package/chunk-UITQITSS.js.map +1 -0
- package/index.cjs +161 -29
- package/index.cjs.map +1 -1
- package/index.js +1 -1
- package/package.json +13 -13
- package/run.cjs +161 -29
- package/run.cjs.map +1 -1
- package/run.js +1 -1
- package/src/cli-process.cjs +161 -29
- package/src/cli-process.cjs.map +1 -1
- package/src/cli-process.js +1 -1
- package/src/type-utils-file-content.ts +162 -29
- package/src/type-utils.ts +210 -9
- package/chunk-C3LWMIKT.js.map +0 -1
package/src/type-utils.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ContractAbstraction,
|
|
1
|
+
import { ContractAbstraction, ContractMethodObject, ContractProvider, Wallet } from '@taquito/taquito';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// Support both old (methods) and new (methodsObject) contract type definitions
|
|
4
|
+
type BaseContractType = { methodsObject: unknown; storage: unknown; methods?: unknown };
|
|
4
5
|
|
|
5
|
-
type ContractMethodsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {
|
|
6
|
-
[M in keyof TContract['methods']]: TContract['methods'][M] extends (...args: infer A) => unknown
|
|
7
|
-
? (...args: A) => ContractMethod<T>
|
|
8
|
-
: never;
|
|
9
|
-
};
|
|
10
6
|
type ContractMethodsObjectsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> = {
|
|
11
7
|
[M in keyof TContract['methodsObject']]: TContract['methodsObject'][M] extends (...args: infer A) => unknown
|
|
12
8
|
? (...args: A) => ContractMethodObject<T>
|
|
@@ -14,9 +10,17 @@ type ContractMethodsObjectsOf<T extends ContractProvider | Wallet, TContract ext
|
|
|
14
10
|
};
|
|
15
11
|
type ContractStorageOf<TContract extends BaseContractType> = TContract['storage'];
|
|
16
12
|
|
|
13
|
+
// Type for the methods proxy - converts positional args to methodsObject call
|
|
14
|
+
type ContractMethodsOf<T extends ContractProvider | Wallet, TContract extends BaseContractType> =
|
|
15
|
+
TContract['methods'] extends object ? {
|
|
16
|
+
[M in keyof TContract['methods']]: TContract['methods'][M] extends (...args: infer A) => unknown
|
|
17
|
+
? (...args: A) => ContractMethodObject<T>
|
|
18
|
+
: never;
|
|
19
|
+
}
|
|
20
|
+
: ContractMethodsObjectsOf<T, TContract>;
|
|
21
|
+
|
|
17
22
|
export type ContractAbstractionFromContractType<TContract extends BaseContractType> = ContractAbstraction<
|
|
18
23
|
ContractProvider,
|
|
19
|
-
ContractMethodsOf<ContractProvider, TContract>,
|
|
20
24
|
ContractMethodsObjectsOf<ContractProvider, TContract>,
|
|
21
25
|
{},
|
|
22
26
|
{},
|
|
@@ -25,9 +29,206 @@ export type ContractAbstractionFromContractType<TContract extends BaseContractTy
|
|
|
25
29
|
|
|
26
30
|
export type WalletContractAbstractionFromContractType<TContract extends BaseContractType> = ContractAbstraction<
|
|
27
31
|
Wallet,
|
|
28
|
-
ContractMethodsOf<Wallet, TContract>,
|
|
29
32
|
ContractMethodsObjectsOf<Wallet, TContract>,
|
|
30
33
|
{},
|
|
31
34
|
{},
|
|
32
35
|
ContractStorageOf<TContract>
|
|
33
36
|
>;
|
|
37
|
+
|
|
38
|
+
// Extended contract type that includes the backwards-compatible methods property
|
|
39
|
+
export type ContractAbstractionWithMethods<TContract extends BaseContractType> =
|
|
40
|
+
& ContractAbstractionFromContractType<
|
|
41
|
+
TContract
|
|
42
|
+
>
|
|
43
|
+
& {
|
|
44
|
+
methods: ContractMethodsOf<ContractProvider, TContract>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type WalletContractAbstractionWithMethods<TContract extends BaseContractType> =
|
|
48
|
+
& WalletContractAbstractionFromContractType<TContract>
|
|
49
|
+
& {
|
|
50
|
+
methods: ContractMethodsOf<Wallet, TContract>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Extract parameter names from a Taquito TokenSchema
|
|
55
|
+
* Returns an array of parameter names in order, or numbered names (_0, _1, etc) if unnamed
|
|
56
|
+
*/
|
|
57
|
+
function extractParamNames(schema: unknown): string[] {
|
|
58
|
+
if (!schema || typeof schema !== 'object') return [];
|
|
59
|
+
|
|
60
|
+
const s = schema as Record<string, unknown>;
|
|
61
|
+
const schemaObj = s.schema;
|
|
62
|
+
|
|
63
|
+
// Single parameter (not an object with multiple fields)
|
|
64
|
+
if (!schemaObj || typeof schemaObj !== 'object') {
|
|
65
|
+
return ['param'];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Object with named fields
|
|
69
|
+
const fieldSchema = schemaObj as Record<string, unknown>;
|
|
70
|
+
const keys = Object.keys(fieldSchema);
|
|
71
|
+
|
|
72
|
+
// If keys look like numbered params, they're positional
|
|
73
|
+
// Otherwise return the named keys
|
|
74
|
+
return keys.length > 0 ? keys : ['param'];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a methods proxy that converts positional arguments to object arguments
|
|
79
|
+
* for backwards compatibility with Taquito < 24.0.0
|
|
80
|
+
*
|
|
81
|
+
* @param methodsObject - The contract's methodsObject from Taquito v24
|
|
82
|
+
* @param parameterSchema - The contract's parameterSchema for introspection
|
|
83
|
+
* @returns A proxy object that mimics the old methods API
|
|
84
|
+
*/
|
|
85
|
+
function createMethodsProxy<T extends ContractProvider | Wallet>(
|
|
86
|
+
methodsObject: Record<string, (args?: unknown) => ContractMethodObject<T>>,
|
|
87
|
+
parameterSchema: { generateSchema: () => unknown; isMultipleEntryPoint: boolean },
|
|
88
|
+
): Record<string, (...args: unknown[]) => ContractMethodObject<T>> {
|
|
89
|
+
const schema = parameterSchema.generateSchema() as Record<string, unknown>;
|
|
90
|
+
|
|
91
|
+
return new Proxy({} as Record<string, (...args: unknown[]) => ContractMethodObject<T>>, {
|
|
92
|
+
get(_target, prop: string) {
|
|
93
|
+
if (typeof prop !== 'string' || !(prop in methodsObject)) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Get the schema for this entrypoint
|
|
98
|
+
let entrypointSchema: unknown;
|
|
99
|
+
if (parameterSchema.isMultipleEntryPoint && schema.schema) {
|
|
100
|
+
entrypointSchema = (schema.schema as Record<string, unknown>)[prop];
|
|
101
|
+
} else {
|
|
102
|
+
entrypointSchema = schema;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const paramNames = extractParamNames(entrypointSchema);
|
|
106
|
+
|
|
107
|
+
// Return a function that converts positional args to object args
|
|
108
|
+
return (...positionalArgs: unknown[]): ContractMethodObject<T> => {
|
|
109
|
+
// If no args or single arg that's already an object with matching keys, pass through
|
|
110
|
+
if (positionalArgs.length === 0) {
|
|
111
|
+
return methodsObject[prop]();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Single arg case - check if it's already an object format
|
|
115
|
+
if (positionalArgs.length === 1) {
|
|
116
|
+
const arg = positionalArgs[0];
|
|
117
|
+
if (arg && typeof arg === 'object' && !Array.isArray(arg)) {
|
|
118
|
+
// Might already be in object format, pass through
|
|
119
|
+
return methodsObject[prop](arg);
|
|
120
|
+
}
|
|
121
|
+
// Single primitive value - wrap with param name
|
|
122
|
+
if (paramNames.length === 1) {
|
|
123
|
+
return methodsObject[prop]({ [paramNames[0]]: arg });
|
|
124
|
+
}
|
|
125
|
+
// Pass through as-is
|
|
126
|
+
return methodsObject[prop](arg);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Multiple args - convert to object using param names
|
|
130
|
+
const argsObject: Record<string, unknown> = {};
|
|
131
|
+
positionalArgs.forEach((arg, index) => {
|
|
132
|
+
const paramName = paramNames[index] ?? `_${index}`;
|
|
133
|
+
argsObject[paramName] = arg;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return methodsObject[prop](argsObject);
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
has(_target, prop: string) {
|
|
140
|
+
return prop in methodsObject;
|
|
141
|
+
},
|
|
142
|
+
ownKeys() {
|
|
143
|
+
return Object.keys(methodsObject);
|
|
144
|
+
},
|
|
145
|
+
getOwnPropertyDescriptor(_target, prop: string) {
|
|
146
|
+
if (prop in methodsObject) {
|
|
147
|
+
return { enumerable: true, configurable: true };
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Wraps a Taquito v24+ ContractAbstraction to add backwards-compatible methods property.
|
|
156
|
+
*
|
|
157
|
+
* Taquito v24 removed the `methods` property (which used positional arguments) in favor
|
|
158
|
+
* of `methodsObject` (which uses named object arguments). This wrapper adds back a
|
|
159
|
+
* `methods` property that converts positional arguments to the object format expected
|
|
160
|
+
* by `methodsObject`.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Before (Taquito < 24):
|
|
165
|
+
* const contract = await Tezos.contract.at(address);
|
|
166
|
+
* await contract.methods.transfer("tz1...", 100).send();
|
|
167
|
+
*
|
|
168
|
+
* // After (Taquito >= 24) with wrapper:
|
|
169
|
+
* const contract = await Tezos.contract.at(address);
|
|
170
|
+
* const wrapped = tas.wrapContractWithMethods(contract);
|
|
171
|
+
* await wrapped.methods.transfer("tz1...", 100).send(); // Still works!
|
|
172
|
+
*
|
|
173
|
+
* // Or use methodsObject directly:
|
|
174
|
+
* await contract.methodsObject.transfer({ to: "tz1...", amount: 100 }).send();
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @param contract - A Taquito v24+ ContractAbstraction
|
|
178
|
+
* @returns The same contract with an added methods property for backwards compatibility
|
|
179
|
+
*/
|
|
180
|
+
export function wrapContractWithMethods<TContract extends BaseContractType>(
|
|
181
|
+
contract: ContractAbstractionFromContractType<TContract>,
|
|
182
|
+
): ContractAbstractionWithMethods<TContract> {
|
|
183
|
+
// If methods already exists (shouldn't in v24, but safety check), return as-is
|
|
184
|
+
if ('methods' in contract && contract.methods) {
|
|
185
|
+
return contract as ContractAbstractionWithMethods<TContract>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const methodsProxy = createMethodsProxy(
|
|
189
|
+
contract.methodsObject as Record<string, (args?: unknown) => ContractMethodObject<ContractProvider>>,
|
|
190
|
+
contract.parameterSchema as { generateSchema: () => unknown; isMultipleEntryPoint: boolean },
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
return new Proxy(contract, {
|
|
194
|
+
get(target, prop) {
|
|
195
|
+
if (prop === 'methods') {
|
|
196
|
+
return methodsProxy;
|
|
197
|
+
}
|
|
198
|
+
return (target as unknown as Record<string | symbol, unknown>)[prop];
|
|
199
|
+
},
|
|
200
|
+
has(target, prop) {
|
|
201
|
+
if (prop === 'methods') return true;
|
|
202
|
+
return prop in target;
|
|
203
|
+
},
|
|
204
|
+
}) as ContractAbstractionWithMethods<TContract>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Wallet version of wrapContractWithMethods
|
|
209
|
+
*/
|
|
210
|
+
export function wrapWalletContractWithMethods<TContract extends BaseContractType>(
|
|
211
|
+
contract: WalletContractAbstractionFromContractType<TContract>,
|
|
212
|
+
): WalletContractAbstractionWithMethods<TContract> {
|
|
213
|
+
if ('methods' in contract && contract.methods) {
|
|
214
|
+
return contract as WalletContractAbstractionWithMethods<TContract>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const methodsProxy = createMethodsProxy(
|
|
218
|
+
contract.methodsObject as Record<string, (args?: unknown) => ContractMethodObject<Wallet>>,
|
|
219
|
+
contract.parameterSchema as { generateSchema: () => unknown; isMultipleEntryPoint: boolean },
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return new Proxy(contract, {
|
|
223
|
+
get(target, prop) {
|
|
224
|
+
if (prop === 'methods') {
|
|
225
|
+
return methodsProxy;
|
|
226
|
+
}
|
|
227
|
+
return (target as unknown as Record<string | symbol, unknown>)[prop];
|
|
228
|
+
},
|
|
229
|
+
has(target, prop) {
|
|
230
|
+
if (prop === 'methods') return true;
|
|
231
|
+
return prop in target;
|
|
232
|
+
},
|
|
233
|
+
}) as WalletContractAbstractionWithMethods<TContract>;
|
|
234
|
+
}
|
package/chunk-C3LWMIKT.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["src/cli-process.ts","src/type-aliases-file-content.ts","src/type-utils-file-content.ts"],"sourcesContent":["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","// 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,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,iBAAiB;;;ACDnB,IAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACA/B,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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