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

typechain

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typechain - npm Package Compare versions

Comparing version 0.0.5 to 0.0.7

dist/errors.d.ts

1

dist/abiParser.d.ts

@@ -39,1 +39,2 @@ import { EvmType } from "./typeParser";

export declare function parse(abi: Array<RawAbiDefinition>): Contract;
export declare function extractAbi(rawJson: string): RawAbiDefinition[];

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

const chalk_1 = require("chalk");
const errors_1 = require("./errors");
function parse(abi) {

@@ -93,1 +94,21 @@ const constants = [];

}
function extractAbi(rawJson) {
let json;
try {
json = JSON.parse(rawJson);
}
catch (_a) {
throw new errors_1.MalformedAbiError("Not a json");
}
if (!json) {
throw new errors_1.MalformedAbiError("Not a json");
}
if (Array.isArray(json)) {
return json;
}
if (Array.isArray(json.abi)) {
return json.abi;
}
throw new errors_1.MalformedAbiError("Not a valid ABI");
}
exports.extractAbi = extractAbi;

@@ -12,2 +12,3 @@ #!/usr/bin/env node

const copyRuntime_1 = require("./copyRuntime");
const abiParser_1 = require("./abiParser");
const cwd = process.cwd();

@@ -44,3 +45,3 @@ function main() {

const abiString = fs_1.readFileSync(absPath).toString();
const rawAbi = JSON.parse(abiString);
const rawAbi = abiParser_1.extractAbi(abiString);
const typescriptSourceFile = generateSource_1.generateSource(rawAbi, { fileName: filenameWithoutAnyExtensions, relativeRuntimePath: runtimeRelativePath });

@@ -56,2 +57,8 @@ fs_1.writeFileSync(outputPath, typescriptSourceFile);

}
main();
try {
main();
}
catch (error) {
console.error(chalk_1.red("Error occured: ", error.message));
process.exit(1);
}

4

dist/generateSource.js

@@ -22,3 +22,3 @@ "use strict";

public constructor(web3: any, address: string) {
public constructor(web3: any, address: string | BigNumber) {
const abi = ${JSON.stringify(abi)};

@@ -28,3 +28,3 @@ super(web3, address, abi);

static async createAndValidate(web3: any, address: string): Promise<${typeName}> {
static async createAndValidate(web3: any, address: string | BigNumber): Promise<${typeName}> {
const contract = new ${typeName}(web3, address);

@@ -31,0 +31,0 @@ const code = await promisify(web3.eth.getCode, [address]);

@@ -65,3 +65,3 @@ "use strict";

generateCodeForOutput() {
return "BigNumber";
return "string";
}

@@ -68,0 +68,0 @@ generateCodeForInput() {

{
"name": "typechain",
"version": "0.0.5",
"version": "0.0.7",
"license": "MIT",

@@ -36,2 +36,5 @@ "repository": "https://github.com/Neufund/Typechain",

},
"peerDependencies": {
"web3": "0.20.x"
},
"scripts": {

@@ -38,0 +41,0 @@ "build": "rm -rf ./dist && tsc -p ./tsconfig.production.json",

@@ -15,2 +15,4 @@ # Typechain

Note: Typechain requires web3 in version: `0.20.x`.
## Usage

@@ -180,2 +182,10 @@

### Q: How do I customize generated classes?
A: You can create your own class that extends generated one and adds additional methods etc.
Currently we discuss various ideas around extendibility including APIs files (adding semantics to
ABIs for covering popular cases like working with dates) or using user-defined templates for
generated code.
## Roadmap 🛣️

@@ -182,0 +192,0 @@

@@ -18,4 +18,6 @@ import { BigNumber } from "bignumber.js";

public readonly rawWeb3Contract: any;
public readonly address: string;
constructor(web3: any, public readonly address: string, public readonly contractAbi: object) {
constructor(web3: any, address: string | BigNumber, public readonly contractAbi: object) {
this.address = address.toString();
this.rawWeb3Contract = web3.eth.contract(contractAbi).at(address);

@@ -22,0 +24,0 @@ }

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