@reflexer-finance/geb-typechain
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -24,2 +24,3 @@ "use strict"; | ||
template.includes('BigNumber\n') || | ||
template.includes('BigNumber.') || | ||
template.includes('BigNumber>')) { | ||
@@ -80,3 +81,3 @@ template = | ||
${generateFunctionDocumentation(fn.documentation)} | ||
${fn.name}(${types_1.generateInputTypes(fn.inputs)}): Promise<${fn.stateMutability === 'view' ? `${types_1.generateOutputTypes(fn.outputs)}` : 'TransactionRequest'}> { | ||
${fn.name}(${types_1.generateInputTypes(fn.inputs, fn.stateMutability)}): Promise<${fn.stateMutability === 'view' ? `${types_1.generateOutputTypes(fn.outputs)}` : 'TransactionRequest'}> { | ||
@@ -89,3 +90,3 @@ // prettier-ignore | ||
${processedInputName.join(", ")} | ||
]) | ||
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : ''}) | ||
} | ||
@@ -92,0 +93,0 @@ `; |
@@ -1,3 +0,3 @@ | ||
import { EvmType, EvmOutputType, TupleType, AbiParameter, AbiOutputParameter } from 'typechain'; | ||
export declare function generateInputTypes(input: Array<AbiParameter>): string; | ||
import { EvmType, EvmOutputType, TupleType, AbiParameter, AbiOutputParameter, StateMutability } from 'typechain'; | ||
export declare function generateInputTypes(input: Array<AbiParameter>, stateMutability: StateMutability): string; | ||
export declare function generateInputNames(input: Array<AbiParameter>): string[]; | ||
@@ -4,0 +4,0 @@ export declare function generateOutputTypes(outputs: Array<AbiOutputParameter>): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateOutputTupleType = exports.generateTupleType = exports.generateOutputType = exports.generateInputType = exports.generateOutputTypes = exports.generateInputNames = exports.generateInputTypes = void 0; | ||
function generateInputTypes(input) { | ||
function generateInputTypes(input, stateMutability) { | ||
let ret = ''; | ||
if (stateMutability === 'payable') { | ||
if (input.map((x) => x.name).some((x) => x === 'ethValue')) { | ||
throw new Error('Payable contracts with variable named ethValue'); | ||
} | ||
ret = 'ethValue: BigNumberish, '; | ||
} | ||
if (input.length === 0) { | ||
return ''; | ||
return ret; | ||
} | ||
const processedInputName = generateInputNames(input); | ||
return (input | ||
.map((input, index) => `${processedInputName[index]}: ${generateInputType(input.type)}`) | ||
.join(', ') + ', '); | ||
ret += | ||
input | ||
.map((input, index) => `${processedInputName[index]}: ${generateInputType(input.type)}`) | ||
.join(', ') + ', '; | ||
return ret; | ||
} | ||
@@ -13,0 +22,0 @@ exports.generateInputTypes = generateInputTypes; |
{ | ||
"name": "@reflexer-finance/geb-typechain", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "7ef562d2cd86a17cf8f301734bf4f792f01db492" | ||
"gitHead": "539871a04c8ff9b83093fc51364006ceef0d8fe3" | ||
} |
@@ -38,2 +38,3 @@ import { | ||
template.includes('BigNumber\n') || | ||
template.includes('BigNumber.') || | ||
template.includes('BigNumber>') | ||
@@ -117,3 +118,3 @@ ) { | ||
${generateFunctionDocumentation(fn.documentation)} | ||
${fn.name}(${generateInputTypes(fn.inputs)}): Promise<${fn.stateMutability === 'view'? `${generateOutputTypes(fn.outputs)}`: 'TransactionRequest'}> { | ||
${fn.name}(${generateInputTypes(fn.inputs, fn.stateMutability)}): Promise<${fn.stateMutability === 'view'? `${generateOutputTypes(fn.outputs)}`: 'TransactionRequest'}> { | ||
@@ -126,3 +127,3 @@ // prettier-ignore | ||
${processedInputName.join(", ")} | ||
]) | ||
]${fn.stateMutability === 'payable' ? ', BigNumber.from(ethValue)' : ''}) | ||
} | ||
@@ -129,0 +130,0 @@ ` |
@@ -7,7 +7,21 @@ import { | ||
AbiOutputParameter, | ||
StateMutability, | ||
} from 'typechain' | ||
export function generateInputTypes(input: Array<AbiParameter>): string { | ||
export function generateInputTypes( | ||
input: Array<AbiParameter>, | ||
stateMutability: StateMutability | ||
): string { | ||
let ret = '' | ||
if (stateMutability === 'payable') { | ||
if (input.map((x) => x.name).some((x) => x === 'ethValue')) { | ||
throw new Error('Payable contracts with variable named ethValue') | ||
} | ||
ret = 'ethValue: BigNumberish, ' | ||
} | ||
if (input.length === 0) { | ||
return '' | ||
return ret | ||
} | ||
@@ -17,3 +31,3 @@ | ||
return ( | ||
ret += | ||
input | ||
@@ -27,3 +41,4 @@ .map( | ||
.join(', ') + ', ' | ||
) | ||
return ret | ||
} | ||
@@ -30,0 +45,0 @@ |
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
203612
634