@typechain/ethers-v4
Advanced tools
Comparing version 5.1.0 to 6.0.0
# @typechain/ethers-v4 | ||
## 6.0.0 | ||
### Patch Changes | ||
- Updated dependencies [0ac4921] | ||
- Updated dependencies [95517e9] | ||
- Updated dependencies [33ee803] | ||
- typechain@6.0.0 | ||
## 5.1.0 | ||
@@ -4,0 +13,0 @@ |
@@ -14,3 +14,3 @@ "use strict"; | ||
function codegenForOverloadedFunctions(options, fns) { | ||
return fns.map((fn) => generateFunction(options, fn, `"${typechain_1.getSignatureForFn(fn)}"`)).join('\n'); | ||
return fns.map((fn) => generateFunction(options, fn, `"${(0, typechain_1.getSignatureForFn)(fn)}"`)).join('\n'); | ||
} | ||
@@ -21,6 +21,6 @@ exports.codegenForOverloadedFunctions = codegenForOverloadedFunctions; | ||
${generateFunctionDocumentation(fn.documentation)} | ||
${overloadedName !== null && overloadedName !== void 0 ? overloadedName : fn.name}(${types_1.generateInputTypes(fn.inputs)} overrides?: UnsignedTransaction): ${options.overrideOutput | ||
${overloadedName !== null && overloadedName !== void 0 ? overloadedName : fn.name}(${(0, types_1.generateInputTypes)(fn.inputs)} overrides?: UnsignedTransaction): ${options.overrideOutput | ||
? options.overrideOutput | ||
: `Promise<${fn.stateMutability === 'pure' || fn.stateMutability === 'view' | ||
? types_1.generateOutputTypes(fn.outputs) | ||
? (0, types_1.generateOutputTypes)(fn.outputs) | ||
: 'ContractTransaction'}>`}; | ||
@@ -27,0 +27,0 @@ `; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const lodash_1 = require("lodash"); | ||
const typechain_1 = require("typechain"); | ||
const common_1 = require("../common"); | ||
@@ -20,3 +21,3 @@ const functions_1 = require("./functions"); | ||
functions: { | ||
${lodash_1.values(contract.functions) | ||
${(0, lodash_1.values)(contract.functions) | ||
.map((v) => v[0]) | ||
@@ -28,3 +29,3 @@ .map(generateInterfaceFunctionDescription) | ||
events: { | ||
${lodash_1.values(contract.events) | ||
${(0, lodash_1.values)(contract.events) | ||
.map((v) => v[0]) | ||
@@ -50,6 +51,6 @@ .map(generateInterfaceEventDescription) | ||
functions: { | ||
${lodash_1.values(contract.functions).map(functions_1.codegenFunctions.bind(null, {})).join('\n')} | ||
${(0, lodash_1.values)(contract.functions).map(functions_1.codegenFunctions.bind(null, {})).join('\n')} | ||
}; | ||
${lodash_1.values(contract.functions) | ||
${(0, lodash_1.values)(contract.functions) | ||
.filter((f) => !reserved_keywords_1.reservedKeywords.has(f[0].name)) | ||
@@ -60,3 +61,3 @@ .map(functions_1.codegenFunctions.bind(null, {})) | ||
filters: { | ||
${lodash_1.values(contract.events) | ||
${(0, lodash_1.values)(contract.events) | ||
.map((v) => v[0]) | ||
@@ -68,3 +69,3 @@ .map(generateEvents) | ||
estimate: { | ||
${lodash_1.values(contract.functions) | ||
${(0, lodash_1.values)(contract.functions) | ||
.map(functions_1.codegenFunctions.bind(null, { overrideOutput: 'Promise<BigNumber>' })) | ||
@@ -78,3 +79,3 @@ .join('\n')} | ||
function codegenContractFactory(contract, abi, bytecode) { | ||
const constructorArgs = (contract.constructor[0] ? types_1.generateInputTypes(contract.constructor[0].inputs) : '') + | ||
const constructorArgs = (contract.constructor[0] ? (0, types_1.generateInputTypes)(contract.constructor[0].inputs) : '') + | ||
'overrides?: UnsignedTransaction'; | ||
@@ -195,6 +196,6 @@ const constructorArgNamesWithoutOverrides = contract.constructor[0] | ||
function generateParamArrayTypes(params) { | ||
return `[${params.map((param) => types_1.generateInputType(param.type)).join(', ')}]`; | ||
return `[${params.map((param) => (0, types_1.generateInputType)(param.type)).join(', ')}]`; | ||
} | ||
function generateParamNames(params) { | ||
return params.map((param) => param.name).join(', '); | ||
return params.map((param) => param.name && (0, typechain_1.createPositionalIdentifier)(param.name)).join(', '); | ||
} | ||
@@ -206,3 +207,3 @@ function generateParamArrayNames(params) { | ||
return ` | ||
${event.name}(${generateEventTypes(event.inputs)}): EventFilter; | ||
${event.name}(${generateEventInputs(event.inputs)}): EventFilter; | ||
`; | ||
@@ -218,3 +219,3 @@ } | ||
} | ||
function generateEventTypes(eventArgs) { | ||
function generateEventInputs(eventArgs) { | ||
if (eventArgs.length === 0) { | ||
@@ -225,3 +226,3 @@ return ''; | ||
.map((arg) => { | ||
return `${arg.name}: ${generateEventArgType(arg)}`; | ||
return `${arg.name && (0, typechain_1.createPositionalIdentifier)(arg.name)}: ${generateEventArgType(arg)}`; | ||
}) | ||
@@ -231,4 +232,4 @@ .join(', ') + ', '); | ||
function generateEventArgType(eventArg) { | ||
return eventArg.isIndexed ? `${types_1.generateInputType(eventArg.type)} | null` : 'null'; | ||
return eventArg.isIndexed ? `${(0, types_1.generateInputType)(eventArg.type)} | null` : 'null'; | ||
} | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateOutputComplexType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputTypes = void 0; | ||
const typechain_1 = require("typechain"); | ||
function generateInputTypes(input) { | ||
@@ -8,3 +9,5 @@ if (input.length === 0) { | ||
} | ||
return (input.map((input, index) => `${input.name || `arg${index}`}: ${generateInputType(input.type)}`).join(', ') + ', '); | ||
return (input | ||
.map((input, index) => `${(0, typechain_1.createPositionalIdentifier)(input.name) || `arg${index}`}: ${generateInputType(input.type)}`) | ||
.join(', ') + ', '); | ||
} | ||
@@ -11,0 +14,0 @@ exports.generateInputTypes = generateInputTypes; |
@@ -16,6 +16,6 @@ "use strict"; | ||
const { cwd, outDir } = config; | ||
this.outDirAbs = path_1.resolve(cwd, outDir || DEFAULT_OUT_PATH); | ||
this.outDirAbs = (0, path_1.resolve)(cwd, outDir || DEFAULT_OUT_PATH); | ||
} | ||
transformFile(file) { | ||
const fileExt = typechain_1.getFileExtension(file.path); | ||
const fileExt = (0, typechain_1.getFileExtension)(file.path); | ||
// For json files with both ABI and bytecode, both the contract typing and factory can be | ||
@@ -33,4 +33,4 @@ // generated at once. For split files (.abi and .bin) we don't know in which order they will | ||
transformBinFile(file) { | ||
const name = typechain_1.getFilename(file.path); | ||
const bytecode = typechain_1.extractBytecode(file.contents); | ||
const name = (0, typechain_1.getFilename)(file.path); | ||
const bytecode = (0, typechain_1.extractBytecode)(file.contents); | ||
if (!bytecode) { | ||
@@ -49,10 +49,10 @@ return; | ||
transformAbiOrFullJsonFile(file) { | ||
const name = typechain_1.getFilename(file.path); | ||
const abi = typechain_1.extractAbi(file.contents); | ||
const name = (0, typechain_1.getFilename)(file.path); | ||
const abi = (0, typechain_1.extractAbi)(file.contents); | ||
if (abi.length === 0) { | ||
return; | ||
} | ||
const documentation = typechain_1.extractDocumentation(file.contents); | ||
const contract = typechain_1.parse(abi, name, documentation); | ||
const bytecode = typechain_1.extractBytecode(file.contents) || this.bytecodeCache[name]; | ||
const documentation = (0, typechain_1.extractDocumentation)(file.contents); | ||
const contract = (0, typechain_1.parse)(abi, name, documentation); | ||
const bytecode = (0, typechain_1.extractBytecode)(file.contents) || this.bytecodeCache[name]; | ||
if (bytecode) { | ||
@@ -68,4 +68,4 @@ return [this.genContractTypingsFile(contract), this.genContractFactoryFile(contract, abi, bytecode)]; | ||
return { | ||
path: path_1.join(this.outDirAbs, `${contract.name}.d.ts`), | ||
contents: codegen_1.codegenContractTypings(contract), | ||
path: (0, path_1.join)(this.outDirAbs, `${contract.name}.d.ts`), | ||
contents: (0, codegen_1.codegenContractTypings)(contract), | ||
}; | ||
@@ -75,4 +75,4 @@ } | ||
return { | ||
path: path_1.join(this.outDirAbs, 'factories', `${contract.name}${common_1.FACTORY_POSTFIX}.ts`), | ||
contents: codegen_1.codegenContractFactory(contract, abi, bytecode), | ||
path: (0, path_1.join)(this.outDirAbs, 'factories', `${contract.name}${common_1.FACTORY_POSTFIX}.ts`), | ||
contents: (0, codegen_1.codegenContractFactory)(contract, abi, bytecode), | ||
}; | ||
@@ -86,4 +86,4 @@ } | ||
return { | ||
path: path_1.join(this.outDirAbs, 'factories', `${contract.name}${common_1.FACTORY_POSTFIX}.ts`), | ||
contents: codegen_1.codegenAbstractContractFactory(contract, abi), | ||
path: (0, path_1.join)(this.outDirAbs, 'factories', `${contract.name}${common_1.FACTORY_POSTFIX}.ts`), | ||
contents: (0, codegen_1.codegenAbstractContractFactory)(contract, abi), | ||
}; | ||
@@ -94,4 +94,4 @@ }); | ||
{ | ||
path: path_1.join(this.outDirAbs, 'index.d.ts'), | ||
contents: fs_1.readFileSync(path_1.join(__dirname, '../static/index.d.ts'), 'utf-8'), | ||
path: (0, path_1.join)(this.outDirAbs, 'index.d.ts'), | ||
contents: (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../static/index.d.ts'), 'utf-8'), | ||
}, | ||
@@ -98,0 +98,0 @@ ]; |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "5.1.0", | ||
"version": "6.0.0", | ||
"license": "MIT", | ||
@@ -36,3 +36,3 @@ "repository": "https://github.com/ethereum-ts/Typechain", | ||
"peerDependencies": { | ||
"typechain": "^5.0.0", | ||
"typechain": "^6.0.0", | ||
"ethers": "^4.0.0" | ||
@@ -39,0 +39,0 @@ }, |
@@ -10,3 +10,2 @@ # Typechain target Ethers-v4 | ||
<a href="https://github.com/ethereum-ts/TypeChain/actions"><img alt="Build Status" src="https://github.com/ethereum-ts/TypeChain/workflows/CI/badge.svg"></a> | ||
<a href="https://coveralls.io/github/ethereum-ts/TypeChain?branch=master"><img alt="Coverage" src="https://coveralls.io/repos/github/ethereum-ts/TypeChain/badge.svg?branch=master"></a> | ||
<img alt="Downloads" src="https://img.shields.io/npm/dm/typechain.svg"> | ||
@@ -13,0 +12,0 @@ <a href="https://github.com/prettier/prettier"><img alt="Prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg"></a> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42514
490
75