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

@reflexer-finance/geb-typechain

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reflexer-finance/geb-typechain - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

33

lib/codegen.js

@@ -43,3 +43,4 @@ "use strict";

`
import { ERC20 } from '@reflexer-finance/geb-provider'` + template;
import { ERC20 } from '@reflexer-finance/geb-contract-base'` +
template;
}

@@ -49,8 +50,14 @@ if (template.includes('TransactionRequest')) {

`
import { TransactionRequest } from '@reflexer-finance/geb-provider'` +
import { TransactionRequest } from '@reflexer-finance/geb-contract-base'` +
template;
}
if (template.includes('MulticallRequest')) {
template =
`
import { MulticallRequest } from '@reflexer-finance/geb-contract-base'` +
template;
}
template =
`
import { BaseContractAPI } from '@reflexer-finance/geb-provider'` +
import { BaseContractAPI } from '@reflexer-finance/geb-contract-base'` +
template;

@@ -78,7 +85,21 @@ return template;

function codegenForSingleFunction(fn, abiFragment) {
const isView = fn.stateMutability === 'view';
const inputTypes = types_1.generateInputTypes(fn.inputs, fn.stateMutability);
const outputType = types_1.generateOutputTypes(fn.outputs);
const processedInputName = types_1.generateInputNames(fn.inputs);
// Example of what the template below generate for a view function:
// balanceOf(address: string): Promise<BigNumber>
// balanceOf(address: string, multicall: true): MulticallRequest<BigNumber>
// balanceOf(address: string, multicall?: true): Promise<BigNumber> | MulticallRequest<BigNumber>{
// // prettier-ignore
// // @ts-ignore
// const abi = {"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}
// return this.ethCallOrMulticall(abi, [address], multicall)
// }
// prettier-ignore
return `
${generateFunctionDocumentation(fn.documentation)}
${fn.name}(${types_1.generateInputTypes(fn.inputs, fn.stateMutability)}): Promise<${fn.stateMutability === 'view' ? `${types_1.generateOutputTypes(fn.outputs)}` : 'TransactionRequest'}> {
${isView ? `${fn.name}(${inputTypes}): Promise<${outputType}>` : ''}
${isView ? `${fn.name}(${inputTypes} multicall: true): MulticallRequest<${outputType}>` : ''}
${fn.name}(${inputTypes}${isView ? 'multicall?: true' : ''}): ${isView ? `Promise<${outputType}> | MulticallRequest<${outputType}>` : 'TransactionRequest'} {

@@ -89,5 +110,5 @@ // prettier-ignore

return this.${fn.stateMutability === 'view' ? 'ethCall' : 'ethSend'}(abi, [
return this.${isView ? 'ethCallOrMulticall' : 'getTransactionRequest'}(abi, [
${processedInputName.join(", ")}
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : ''})
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : isView ? ', multicall' : ''})
}

@@ -94,0 +115,0 @@ `;

4

package.json
{
"name": "@reflexer-finance/geb-typechain",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -19,3 +19,3 @@ "main": "./lib/index.js",

},
"gitHead": "539871a04c8ff9b83093fc51364006ceef0d8fe3"
"gitHead": "f7907a0f773fbf43c2616dacca56656b8a49d4ea"
}

@@ -61,3 +61,4 @@ import {

`
import { ERC20 } from '@reflexer-finance/geb-provider'` + template
import { ERC20 } from '@reflexer-finance/geb-contract-base'` +
template
}

@@ -68,9 +69,16 @@

`
import { TransactionRequest } from '@reflexer-finance/geb-provider'` +
import { TransactionRequest } from '@reflexer-finance/geb-contract-base'` +
template
}
if (template.includes('MulticallRequest')) {
template =
`
import { MulticallRequest } from '@reflexer-finance/geb-contract-base'` +
template
}
template =
`
import { BaseContractAPI } from '@reflexer-finance/geb-provider'` +
import { BaseContractAPI } from '@reflexer-finance/geb-contract-base'` +
template

@@ -114,8 +122,24 @@ return template

): string {
const isView = fn.stateMutability === 'view'
const inputTypes = generateInputTypes(fn.inputs, fn.stateMutability)
const outputType = generateOutputTypes(fn.outputs)
const processedInputName = generateInputNames(fn.inputs)
// Example of what the template below generate for a view function:
// balanceOf(address: string): Promise<BigNumber>
// balanceOf(address: string, multicall: true): MulticallRequest<BigNumber>
// balanceOf(address: string, multicall?: true): Promise<BigNumber> | MulticallRequest<BigNumber>{
// // prettier-ignore
// // @ts-ignore
// const abi = {"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}
// return this.ethCallOrMulticall(abi, [address], multicall)
// }
// prettier-ignore
return `
${generateFunctionDocumentation(fn.documentation)}
${fn.name}(${generateInputTypes(fn.inputs, fn.stateMutability)}): Promise<${fn.stateMutability === 'view'? `${generateOutputTypes(fn.outputs)}`: 'TransactionRequest'}> {
${isView ? `${fn.name}(${inputTypes}): Promise<${outputType}>`: ''}
${isView ? `${fn.name}(${inputTypes} multicall: true): MulticallRequest<${outputType}>`: ''}
${fn.name}(${inputTypes}${isView? 'multicall?: true' : ''}): ${isView ? `Promise<${outputType}> | MulticallRequest<${outputType}>`: 'TransactionRequest'} {

@@ -126,5 +150,5 @@ // prettier-ignore

return this.${fn.stateMutability === 'view' ? 'ethCall' : 'ethSend'}(abi, [
return this.${isView ? 'ethCallOrMulticall' : 'getTransactionRequest'}(abi, [
${processedInputName.join(", ")}
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : ''})
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : isView? ', multicall' : ''})
}

@@ -131,0 +155,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