@typechain/ethers-v5
Advanced tools
Comparing version 6.0.3 to 6.0.4
# @typechain/ethers-v5 | ||
## 6.0.4 | ||
### Patch Changes | ||
- 743a600: Fix code generation for events with tuples | ||
## 6.0.3 | ||
@@ -4,0 +10,0 @@ |
@@ -253,7 +253,7 @@ "use strict"; | ||
function generateEvents(event) { | ||
const outputTypes = event.inputs.length > 0 | ||
? types_1.generateOutputTypes(true, event.inputs.map((input, i) => { var _a; return ({ name: (_a = input.name) !== null && _a !== void 0 ? _a : `arg${i.toString()}`, type: input.type }); })).replace(' &', ',') | ||
: '[], {}'; | ||
const components = event.inputs.map((input, i) => { var _a; return ({ name: (_a = input.name) !== null && _a !== void 0 ? _a : `arg${i.toString()}`, type: input.type }); }); | ||
const arrayOutput = types_1.generateOutputComplexTypeAsArray(components); | ||
const objectOutput = types_1.generateOutputComplexTypesAsObject(components) || '{}'; | ||
return ` | ||
${event.name}(${generateEventTypes(event.inputs)}): TypedEventFilter<${outputTypes}>; | ||
${event.name}(${generateEventTypes(event.inputs)}): TypedEventFilter<${arrayOutput}, ${objectOutput}>; | ||
`; | ||
@@ -260,0 +260,0 @@ } |
@@ -8,5 +8,7 @@ import { EvmType, EvmOutputType, TupleType, AbiParameter, AbiOutputParameter } from 'typechain'; | ||
/** | ||
* always return an array type; if there are named outputs, merge them to that type | ||
* Always return an array type; if there are named outputs, merge them to that type | ||
* this generates slightly better typings fixing: https://github.com/ethereum-ts/TypeChain/issues/232 | ||
**/ | ||
export declare function generateOutputComplexType(components: AbiOutputParameter[]): string; | ||
export declare function generateOutputComplexTypeAsArray(components: AbiOutputParameter[]): string; | ||
export declare function generateOutputComplexTypesAsObject(components: AbiOutputParameter[]): string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateOutputComplexType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputTypes = void 0; | ||
exports.generateOutputComplexTypesAsObject = exports.generateOutputComplexTypeAsArray = exports.generateOutputComplexType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputTypes = void 0; | ||
const lodash_1 = require("lodash"); | ||
function generateInputTypes(input) { | ||
@@ -85,14 +86,26 @@ if (input.length === 0) { | ||
/** | ||
* always return an array type; if there are named outputs, merge them to that type | ||
* Always return an array type; if there are named outputs, merge them to that type | ||
* this generates slightly better typings fixing: https://github.com/ethereum-ts/TypeChain/issues/232 | ||
**/ | ||
function generateOutputComplexType(components) { | ||
let namedElementsCode = ''; | ||
const existingOutputComponents = lodash_1.compact([ | ||
generateOutputComplexTypeAsArray(components), | ||
generateOutputComplexTypesAsObject(components), | ||
]); | ||
return existingOutputComponents.join(' & '); | ||
} | ||
exports.generateOutputComplexType = generateOutputComplexType; | ||
function generateOutputComplexTypeAsArray(components) { | ||
return `[${components.map((t) => generateOutputType(t.type)).join(', ')}]`; | ||
} | ||
exports.generateOutputComplexTypeAsArray = generateOutputComplexTypeAsArray; | ||
function generateOutputComplexTypesAsObject(components) { | ||
let namedElementsCode; | ||
const namedElements = components.filter((e) => !!e.name); | ||
if (namedElements.length > 0) { | ||
namedElementsCode = ' & {' + namedElements.map((t) => `${t.name}: ${generateOutputType(t.type)}`).join(',') + ' }'; | ||
namedElementsCode = '{' + namedElements.map((t) => `${t.name}: ${generateOutputType(t.type)}`).join(',') + ' }'; | ||
} | ||
return `[${components.map((t) => generateOutputType(t.type)).join(', ')}] ${namedElementsCode}`; | ||
return namedElementsCode; | ||
} | ||
exports.generateOutputComplexType = generateOutputComplexType; | ||
exports.generateOutputComplexTypesAsObject = generateOutputComplexTypesAsObject; | ||
//# sourceMappingURL=types.js.map |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "repository": "https://github.com/ethereum-ts/Typechain", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53410
603