@typechain/ethers-v5
Advanced tools
Comparing version 7.0.1 to 7.1.0
# @typechain/ethers-v5 | ||
## 7.1.0 | ||
### Minor Changes | ||
- e4edd2c: Export typed events | ||
## 7.0.1 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { FunctionDeclaration, CodegenConfig } from 'typechain'; | ||
import { CodegenConfig, FunctionDeclaration } from 'typechain'; | ||
interface GenerateFunctionOptions { | ||
@@ -3,0 +3,0 @@ returnResultObject?: boolean; |
@@ -55,2 +55,4 @@ "use strict"; | ||
${lodash_1.values(contract.events).map(generateEventTypeExports).join('\n')} | ||
export class ${contract.name} extends BaseContract { | ||
@@ -101,6 +103,3 @@ connect(signerOrProvider: Signer | Provider | string): this; | ||
filters: { | ||
${lodash_1.values(contract.events) | ||
.map((v) => v[0]) | ||
.map(generateEvents) | ||
.join('\n')} | ||
${lodash_1.values(contract.events).map(generateEventFilters).join('\n')} | ||
}; | ||
@@ -125,7 +124,9 @@ | ||
var _a; | ||
const constructorArgs = (contract.constructor && contract.constructor[0] ? types_1.generateInputTypes(contract.constructor[0].inputs) : '') + | ||
const constructorArgs = (contract.constructor[0] ? types_1.generateInputTypes(contract.constructor[0].inputs) : '') + | ||
`overrides?: ${((_a = contract.constructor[0]) === null || _a === void 0 ? void 0 : _a.stateMutability) === 'payable' | ||
? 'PayableOverrides & { from?: string | Promise<string> }' | ||
: 'Overrides & { from?: string | Promise<string> }'}`; | ||
const constructorArgNamesWithoutOverrides = contract.constructor && contract.constructor[0] ? generateParamNames(contract.constructor[0].inputs) : ''; | ||
const constructorArgNamesWithoutOverrides = contract.constructor[0] | ||
? generateParamNames(contract.constructor[0].inputs) | ||
: ''; | ||
const constructorArgNames = constructorArgNamesWithoutOverrides | ||
@@ -266,8 +267,38 @@ ? `${constructorArgNamesWithoutOverrides}, overrides || {}` | ||
} | ||
function generateEvents(event) { | ||
function generateEventFilters(events) { | ||
if (events.length === 1) { | ||
return generateEventFilter(events[0], true); | ||
} | ||
else { | ||
return events.map((e) => generateEventFilter(e, false)).join('\n'); | ||
} | ||
} | ||
function generateEventFilter(event, includeNameFilter) { | ||
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) || '{}'; | ||
let filter = ` | ||
'${generateEventSignature(event)}'(${generateEventTypes(event.inputs)}): TypedEventFilter<${arrayOutput}, ${objectOutput}>; | ||
`; | ||
if (includeNameFilter) { | ||
filter += ` | ||
${event.name}(${generateEventTypes(event.inputs)}): TypedEventFilter<${arrayOutput}, ${objectOutput}>; | ||
`; | ||
} | ||
return filter; | ||
} | ||
function generateEventTypeExports(events) { | ||
if (events.length === 1) { | ||
return generateEventTypeExport(events[0], false); | ||
} | ||
else { | ||
return events.map((e) => generateEventTypeExport(e, true)).join('\n'); | ||
} | ||
} | ||
function generateEventTypeExport(event, includeArgTypes) { | ||
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<${arrayOutput}, ${objectOutput}>; | ||
export type ${event.name}${includeArgTypes ? event.inputs.map((input) => '_' + input.type.originalType).join('') + '_Event' : 'Event'} = TypedEvent<${arrayOutput} & ${objectOutput}>; | ||
`; | ||
@@ -274,0 +305,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { EvmType, EvmOutputType, TupleType, AbiParameter, AbiOutputParameter } from 'typechain'; | ||
import { AbiOutputParameter, AbiParameter, EvmOutputType, EvmType, TupleType } from 'typechain'; | ||
export declare function generateInputTypes(input: Array<AbiParameter>): string; | ||
@@ -3,0 +3,0 @@ export declare function generateOutputTypes(returnResultObject: boolean, outputs: Array<AbiOutputParameter>): string; |
@@ -1,2 +0,2 @@ | ||
import { BytecodeWithLinkReferences, Config, Contract, FileDescription, TypeChainTarget, CodegenConfig } from 'typechain'; | ||
import { BytecodeWithLinkReferences, CodegenConfig, Config, Contract, FileDescription, TypeChainTarget } from 'typechain'; | ||
export interface IEthersCfg { | ||
@@ -3,0 +3,0 @@ outDir?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lodash_1 = require("lodash"); | ||
const path_1 = require("path"); | ||
const lodash_1 = require("lodash"); | ||
const typechain_1 = require("typechain"); | ||
const codegen_1 = require("./codegen"); | ||
const hardhat_1 = require("./codegen/hardhat"); | ||
const common_1 = require("./common"); | ||
const hardhat_1 = require("./codegen/hardhat"); | ||
const DEFAULT_OUT_PATH = './types/ethers-contracts/'; | ||
@@ -10,0 +10,0 @@ class Ethers extends typechain_1.TypeChainTarget { |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "7.0.1", | ||
"version": "7.1.0", | ||
"license": "MIT", | ||
@@ -44,6 +44,11 @@ "repository": "https://github.com/ethereum-ts/Typechain", | ||
"devDependencies": { | ||
"ganache-cli": "^6.9.1", | ||
"ganache-cli": "^6.12.2", | ||
"test-utils": "1.0.0", | ||
"typechain": "*" | ||
"typechain": "*", | ||
"@types/lodash": "^4.14.139" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.15", | ||
"ts-essentials": "^7.0.1" | ||
} | ||
} |
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
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
61080
696
8
4
+ Addedlodash@^4.17.15
+ Addedts-essentials@^7.0.1