Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typechain/ethers-v5

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typechain/ethers-v5 - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

CHANGELOG.md

6

dist/codegen/index.js

@@ -8,2 +8,3 @@ "use strict";

const common_1 = require("../common");
const reserved_keywords_1 = require("./reserved-keywords");
function codegenContractTypings(contract) {

@@ -73,3 +74,6 @@ const contractImports = ['Contract', 'ContractTransaction'];

${lodash_1.values(contract.functions).map(functions_1.codegenFunctions.bind(null, {})).join('\n')}
${lodash_1.values(contract.functions)
.filter((f) => !reserved_keywords_1.reservedKeywords.has(f[0].name))
.map(functions_1.codegenFunctions.bind(null, {}))
.join('\n')}

@@ -76,0 +80,0 @@ callStatic: {

@@ -7,2 +7,6 @@ import { EvmType, EvmOutputType, TupleType, AbiParameter, AbiOutputParameter } from 'typechain';

export declare function generateTupleType(tuple: TupleType, generator: (evmType: EvmType) => string): string;
export declare function generateOutputTupleType(tuple: TupleType): string;
/**
* 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;

27

dist/codegen/types.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateOutputTupleType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputTypes = void 0;
exports.generateOutputComplexType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputTypes = void 0;
function generateInputTypes(input) {

@@ -16,6 +16,3 @@ if (input.length === 0) {

else {
return `{
${outputs.map((t) => t.name && `${t.name}: ${generateOutputType(t.type)}, `).join('')}
${outputs.map((t, i) => `${i}: ${generateOutputType(t.type)}`).join(', ')}
}`;
return generateOutputComplexType(outputs);
}

@@ -78,3 +75,3 @@ }

case 'tuple':
return generateOutputTupleType(evmType);
return generateOutputComplexType(evmType.components);
case 'unknown':

@@ -89,9 +86,15 @@ return 'any';

exports.generateTupleType = generateTupleType;
function generateOutputTupleType(tuple) {
return ('{' +
tuple.components.map((component) => `${component.name}: ${generateOutputType(component.type)} ,`).join('\n') +
tuple.components.map((component, index) => `${index}: ${generateOutputType(component.type)}`).join(', ') +
'}');
/**
* 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 namedElements = components.filter((e) => !!e.name);
if (namedElements.length > 0) {
namedElementsCode = ' & {' + namedElements.map((t) => `${t.name}: ${generateOutputType(t.type)}`).join(',') + ' }';
}
return `[${components.map((t) => generateOutputType(t.type)).join(', ')}] ${namedElementsCode}`;
}
exports.generateOutputTupleType = generateOutputTupleType;
exports.generateOutputComplexType = generateOutputComplexType;
//# sourceMappingURL=types.js.map

@@ -11,3 +11,3 @@ {

],
"version": "4.0.0",
"version": "5.0.0",
"license": "MIT",

@@ -25,3 +25,2 @@ "repository": "https://github.com/ethereum-ts/Typechain",

"scripts": {
"prepublishOnly": "yarn lint && yarn format && yarn test && yarn typecheck && (cd ../.. && yarn build)",
"start": "ts-node -T ./src/index.ts",

@@ -43,14 +42,5 @@ "format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"",

"devDependencies": {
"@types/chai": "^4.2.7",
"@types/chai-as-promised": "^7.1.2",
"@types/chai-subset": "^1.3.3",
"@types/mocha": "^5.2.7",
"@types/sinon": "^7.5.1",
"@types/sinon-chai": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.12.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-http": "^4.3.0",
"chai-subset": "^1.6.0",
"eslint": "^6.8.0",

@@ -61,10 +51,8 @@ "eslint-config-typestrict": "^1.0.0",

"ganache-cli": "^6.9.1",
"mocha": "^6.2.2",
"sinon": "^8.0.1",
"sinon-chai": "^3.3.0",
"mocha": "^8.2.0",
"test-utils": "1.0.0",
"ts-node": "^8.5.4",
"typechain": "^4.0.0",
"typechain": "*",
"typescript": "3.9.0-beta"
}
}

@@ -9,3 +9,3 @@ # Typechain target Ethers-v5

<p align="center">
<a href="https://circleci.com/gh/ethereum-ts/TypeChain"><img alt="Build Status" src="https://circleci.com/gh/ethereum-ts/TypeChain/tree/master.svg?style=svg"></a>
<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>

@@ -22,3 +22,4 @@ <img alt="Downloads" src="https://img.shields.io/npm/dm/typechain.svg">

This package requires TypeScript >= 3.8. If you need support for earlier TS versions check out: 1.0 version of this package.
This package requires TypeScript >= 3.8. If you need support for earlier TS versions check out: 1.0 version of this
package.

@@ -29,18 +30,26 @@ ## [TypeChain readme](https://github.com/ethereum-ts/TypeChain)

The main files generated by this target are `<contract-name>.d.ts`. They declare typesafe interfaces for your contracts on top of ethers `Contract` instances:
* typed contract's methods, available both at `contract.someMethod(...)` and `contract.functions.someMethod(...)`
* typed events in `contract.interface.events.AnEvent` and filters in `contract.filters.AnEvent`
* typed method gas estimates in `contract.estimateGas.someMethod`
* overrides for the event listener methods (`on`, `once`, etc) that return the same contract type.
The main files generated by this target are `<contract-name>.d.ts`. They declare typesafe interfaces for your contracts
on top of ethers `Contract` instances:
Note: these are just _type declarations_ to help you call the blockchain properly, so they're not available at runtime, and all of the contracts are still instances of the same `Contract` class.
- typed contract's methods, available both at `contract.someMethod(...)` and `contract.functions.someMethod(...)`
- typed events in `contract.interface.events.AnEvent` and filters in `contract.filters.AnEvent`
- typed method gas estimates in `contract.estimateGas.someMethod`
- overrides for the event listener methods (`on`, `once`, etc) that return the same contract type.
Note: these are just _type declarations_ to help you call the blockchain properly, so they're not available at runtime,
and all of the contracts are still instances of the same `Contract` class.
## Contract factories
This target also generates a concrete factory class for each contract, to help you deploy or connect to contract instances. The factory classes are an extension of ethers' `ContractFactory`. They serve two main purposes:
* wrap passing contract ABI and bytecode to the `ContractFactory` class, so you don't have to load and parse the JSON manually
* provide a correctly typed interface to `ContractFactory` (since it returns plain `Contract` instances).
This target also generates a concrete factory class for each contract, to help you deploy or connect to contract
instances. The factory classes are an extension of ethers' `ContractFactory`. They serve two main purposes:
Abstract contracts or solidity interfaces are handled a bit different, because they have no bytecode. For those, a simplified factory is generated that doesn't extends `ContractFactory`, and only includes the static `connect` method, so you can easily connect to a deployed instance without having to pass the ABI manually.
- wrap passing contract ABI and bytecode to the `ContractFactory` class, so you don't have to load and parse the JSON
manually
- provide a correctly typed interface to `ContractFactory` (since it returns plain `Contract` instances).
Abstract contracts or solidity interfaces are handled a bit different, because they have no bytecode. For those, a
simplified factory is generated that doesn't extends `ContractFactory`, and only includes the static `connect` method,
so you can easily connect to a deployed instance without having to pass the ABI manually.
## Basic example

@@ -47,0 +56,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc