diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index d889815..b9face3 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -30,7 +30,7 @@ jobs: - name: Update version run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version - + - name: Publish run: npm publish --access public --tag canary env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e9b336..4afcc59 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,12 +26,12 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'yarn' + cache: "yarn" - name: Install dependencies run: yarn --frozen-lockfile - - name: 'Create env file' + - name: "Create env file" run: | touch .env echo MAINNET_RPC="${{ secrets.MAINNET_RPC }}" >> .env diff --git a/.mocharc.json b/.mocharc.json index 5302990..4423b68 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,7 +1,7 @@ { - "require": ["ts-node/register"], - "extension": [".ts"], - "spec": "test/unit/**/*.spec.ts", - "timeout": "10000", - "exit": true -} \ No newline at end of file + "require": ["ts-node/register"], + "extension": [".ts"], + "spec": "test/unit/**/*.spec.ts", + "timeout": "10000", + "exit": true +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..d7bcc1e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,22 @@ +{ + "overrides": [ + { + "files": ["**.ts", "**.js"], + "options": { + "printWidth": 145, + "tabWidth": 2, + "semi": true, + "singleQuote": true, + "useTabs": false, + "endOfLine": "auto" + } + }, + { + "files": "**.json", + "options": { + "tabWidth": 2, + "printWidth": 200 + } + } + ] +} diff --git a/README.md b/README.md index b511a39..f6c5782 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ vm.allowCheatcodes(address(mock_myContract)); ``` 3. Enjoy of easy mock calls + ```JavaScript /// Mock myFuncName function, when called with `arg1`, `arg2` to return `return1` mock_myContract.mock_call_myFuncName(arg1, arg2, return1); diff --git a/copy-templates.js b/copy-templates.js index bc4a778..d23cb3a 100644 --- a/copy-templates.js +++ b/copy-templates.js @@ -1,8 +1,6 @@ const fs = require('fs'); const path = require('path'); -// prettier-ignore - /** * Copies the mockContractTemplate.hbs file from the src/templates folder to the dist/templates folder */ diff --git a/nodemon.json b/nodemon.json index c4fd72c..a9762fe 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,15 +1,6 @@ { - "ignore": [ - "node_modules", - ".git", - "lib", - "**/*.test.ts", - "**/*.spec.ts", - "**/*.sol" - ], - "watch": [ - "src/**/*" - ], + "ignore": ["node_modules", ".git", "lib", "**/*.test.ts", "**/*.spec.ts", "**/*.sol"], + "watch": ["src/**/*"], "ext": "ts", "exec": "yarn mock-gen --contractsDir ./solidity/contracts --outDir ./out" -} \ No newline at end of file +} diff --git a/package.json b/package.json index 562c45b..e643697 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "dependencies": { "@defi-wonderland/solidity-utils": "0.0.0-4298c6c6", "handlebars": "4.7.7", + "prettier": "^3.0.3", "yargs": "17.7.2" }, "devDependencies": { @@ -51,7 +52,7 @@ "chai-as-promised": "7.1.1", "cross-env": "7.0.3", "eslint": "8.40.0", - "husky": "8.0.3", + "husky": "^8.0.3", "lint-staged": "10", "mocha": "10.2.0", "nodemon": "2.0.22", diff --git a/src/get-constructor.ts b/src/get-constructor.ts index b01b2da..80a4637 100644 --- a/src/get-constructor.ts +++ b/src/get-constructor.ts @@ -1,8 +1,4 @@ -import { - ContractDefinitionNode, - FunctionDefinitionNode, - VariableDeclarationNode, -} from './types'; +import { ContractDefinitionNode, FunctionDefinitionNode, VariableDeclarationNode } from './types'; /** * Return the constructor of the contract @@ -12,23 +8,18 @@ import { export const getConstructor = (contractNode: ContractDefinitionNode): string => { // Get the contract's name const contractName: string = contractNode.name; - + // Filter the nodes and keep only the FunctionDefinition related ones - const functionNodes = contractNode.nodes.filter( - (node) => node.nodeType === 'FunctionDefinition' - ) as FunctionDefinitionNode[]; - if(!functionNodes) return; + const functionNodes = contractNode.nodes.filter((node) => node.nodeType === 'FunctionDefinition') as FunctionDefinitionNode[]; + if (!functionNodes) return; // Find the node from the functionNodes that is the constructor - const constructorNode = functionNodes.find( - node => node.kind === 'constructor' - ) as FunctionDefinitionNode; + const constructorNode = functionNodes.find((node) => node.kind === 'constructor') as FunctionDefinitionNode; if (!constructorNode || constructorNode.kind !== 'constructor') return; - + // Get the parameters of the constructor, if there are no parameters then we use an empty array - const parameters: VariableDeclarationNode[] = - constructorNode.parameters.parameters ? constructorNode.parameters.parameters : []; - + const parameters: VariableDeclarationNode[] = constructorNode.parameters.parameters ? constructorNode.parameters.parameters : []; + // We save the parameters in an array with their types and storage location const mockConstructorParameters: string[] = []; // We save the parameters names in an other array @@ -37,11 +28,8 @@ export const getConstructor = (contractNode: ContractDefinitionNode): string => parameters.forEach((parameter) => { // If the storage location is memory or calldata then we keep it const storageLocation = - parameter.storageLocation === 'memory' || - parameter.storageLocation === 'calldata' - ? `${parameter.storageLocation} ` - : ''; - + parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' ? `${parameter.storageLocation} ` : ''; + // We remove the 'contract ' string from the type name if it exists const typeName: string = parameter.typeDescriptions.typeString.replace(/contract |struct |enum /g, ''); diff --git a/src/get-external-functions.ts b/src/get-external-functions.ts index b25d4db..bc155d1 100644 --- a/src/get-external-functions.ts +++ b/src/get-external-functions.ts @@ -1,9 +1,4 @@ -import { - ContractDefinitionNode, - FunctionDefinitionNode, - VariableDeclarationNode, - ExternalFunctionOptions, -} from './types'; +import { ContractDefinitionNode, FunctionDefinitionNode, VariableDeclarationNode, ExternalFunctionOptions } from './types'; /** * Returns the infomration of the external function for the mock contract @@ -12,9 +7,7 @@ import { */ export const getExternalMockFunctions = (contractNode: ContractDefinitionNode): ExternalFunctionOptions[] => { // Filter the nodes and keep only the FunctionDefinition related ones - const functionNodes = contractNode.nodes.filter( - (node) => node.nodeType === 'FunctionDefinition' - ) as FunctionDefinitionNode[]; + const functionNodes = contractNode.nodes.filter((node) => node.nodeType === 'FunctionDefinition') as FunctionDefinitionNode[]; const externalFunctions: ExternalFunctionOptions[] = []; // Loop through the function nodes @@ -37,9 +30,7 @@ export const getExternalMockFunctions = (contractNode: ContractDefinitionNode): parameters.forEach((parameter: VariableDeclarationNode) => { // If the storage location is memory or calldata then we keep it const storageLocation = - parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' - ? `${parameter.storageLocation} ` - : ''; + parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' ? `${parameter.storageLocation} ` : ''; // We remove the 'contract ' string from the type name if it exists const typeName: string = parameter.typeDescriptions.typeString.replace(/contract |struct |enum /g, ''); @@ -56,9 +47,7 @@ export const getExternalMockFunctions = (contractNode: ContractDefinitionNode): const signature = parameterTypes ? `${funcNode.name}(${parameterTypes.join(',')})` : `${funcNode.name}()`; - const returnParameters: VariableDeclarationNode[] = funcNode.returnParameters.parameters - ? funcNode.returnParameters.parameters - : []; + const returnParameters: VariableDeclarationNode[] = funcNode.returnParameters.parameters ? funcNode.returnParameters.parameters : []; // We save the return parameters in an array with their types and storage location const functionReturnParameters: string[] = []; @@ -68,9 +57,7 @@ export const getExternalMockFunctions = (contractNode: ContractDefinitionNode): returnParameters.forEach((parameter: VariableDeclarationNode) => { // If the storage location is memory or calldata then we keep it const storageLocation = - parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' - ? `${parameter.storageLocation} ` - : ''; + parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' ? `${parameter.storageLocation} ` : ''; // We remove the 'contract ' string from the type name if it exists const typeName: string = parameter.typeDescriptions.typeString.replace(/contract |struct |enum /g, ''); diff --git a/src/get-imports.ts b/src/get-imports.ts index 7711b8d..3e352e1 100644 --- a/src/get-imports.ts +++ b/src/get-imports.ts @@ -7,9 +7,7 @@ import { Ast, ImportDirectiveNode } from './types'; */ export const getImports = (ast: Ast): string[] => { // Filter the nodes and keep only the ImportDirective related ones - const importNodes = ast.nodes.filter( - node => node.nodeType === 'ImportDirective' - ) as ImportDirectiveNode[]; + const importNodes = ast.nodes.filter((node) => node.nodeType === 'ImportDirective') as ImportDirectiveNode[]; // Create the import code for every node and save it in the importStatements array const importStatements: string[] = importNodes.map((importDirective) => { @@ -20,9 +18,7 @@ export const getImports = (ast: Ast): string[] => { return `import '${absolutePath}';`; } // Get the names of the named imports - const imports = symbolAliases.map( - (symbolAlias) => symbolAlias.foreign.name - ); + const imports = symbolAliases.map((symbolAlias) => symbolAlias.foreign.name); return `import {${imports.join(', ')}} from '${absolutePath}';`; }); diff --git a/src/get-internal-functions.ts b/src/get-internal-functions.ts index 30f5e1b..1f458ab 100644 --- a/src/get-internal-functions.ts +++ b/src/get-internal-functions.ts @@ -1,9 +1,4 @@ -import { - ContractDefinitionNode, - FunctionDefinitionNode, - VariableDeclarationNode, - InternalFunctionOptions, -} from './types'; +import { ContractDefinitionNode, FunctionDefinitionNode, VariableDeclarationNode, InternalFunctionOptions } from './types'; /** * Returns the infomration of the internal function for the mock contract @@ -12,9 +7,7 @@ import { */ export const getInternalMockFunctions = (contractNode: ContractDefinitionNode): InternalFunctionOptions[] => { // Filter the nodes and keep only the FunctionDefinition related ones - const functionNodes = contractNode.nodes.filter( - (node) => node.nodeType === 'FunctionDefinition' - ) as FunctionDefinitionNode[]; + const functionNodes = contractNode.nodes.filter((node) => node.nodeType === 'FunctionDefinition') as FunctionDefinitionNode[]; const internalFunctions: InternalFunctionOptions[] = []; // Loop through the function nodes @@ -37,9 +30,7 @@ export const getInternalMockFunctions = (contractNode: ContractDefinitionNode): parameters.forEach((parameter: VariableDeclarationNode) => { // If the storage location is memory or calldata then we keep it const storageLocation = - parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' - ? `${parameter.storageLocation} ` - : ''; + parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' ? `${parameter.storageLocation} ` : ''; // We remove the 'contract ' string from the type name if it exists // We remove '[]' at the end of array types @@ -57,9 +48,7 @@ export const getInternalMockFunctions = (contractNode: ContractDefinitionNode): const signature = parameterTypes ? `${funcNode.name}(${parameterTypes.join(',')})` : `${funcNode.name}()`; - const returnParameters: VariableDeclarationNode[] = funcNode.returnParameters.parameters - ? funcNode.returnParameters.parameters - : []; + const returnParameters: VariableDeclarationNode[] = funcNode.returnParameters.parameters ? funcNode.returnParameters.parameters : []; // We save the return parameters in an array with their types and storage location const functionReturnParameters: string[] = []; @@ -72,9 +61,7 @@ export const getInternalMockFunctions = (contractNode: ContractDefinitionNode): returnParameters.forEach((parameter: VariableDeclarationNode) => { // If the storage location is memory or calldata then we keep it const storageLocation = - parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' - ? `${parameter.storageLocation} ` - : ''; + parameter.storageLocation === 'memory' || parameter.storageLocation === 'calldata' ? `${parameter.storageLocation} ` : ''; // We remove the 'contract ' string from the type name if it exists const typeName: string = parameter.typeDescriptions.typeString.replace(/contract |struct |enum /g, ''); diff --git a/src/get-variables-functions.ts b/src/get-variables-functions.ts index 7b96885..8ecd7b2 100644 --- a/src/get-variables-functions.ts +++ b/src/get-variables-functions.ts @@ -15,9 +15,7 @@ import { typeFix } from './utils'; */ export const getStateVariables = (contractNode: ContractDefinitionNode): StateVariablesOptions => { // Filter the nodes and keep only the VariableDeclaration related ones - const stateVariableNodes = contractNode.nodes.filter( - (node) => node.nodeType === 'VariableDeclaration' - ) as VariableDeclarationNode[]; + const stateVariableNodes = contractNode.nodes.filter((node) => node.nodeType === 'VariableDeclaration') as VariableDeclarationNode[]; // Define arrays to save our data const mappingFunctions: MappingStateVariableOptions[] = []; @@ -45,8 +43,7 @@ export const getStateVariables = (contractNode: ContractDefinitionNode): StateVa const arrayMockFunction: ArrayStateVariableOptions = getArrayFunction(stateVariableNode); arrayFunctions.push(arrayMockFunction); } else { - const basicStateVariableMockFunction: BasicStateVariableOptions = - getBasicStateVariableFunction(stateVariableNode); + const basicStateVariableMockFunction: BasicStateVariableOptions = getBasicStateVariableFunction(stateVariableNode); basicStateVariableFunctions.push(basicStateVariableMockFunction); } }); @@ -78,10 +75,7 @@ function getArrayFunction(arrayNode: VariableDeclarationNode): ArrayStateVariabl const isStruct: boolean = arrayNode.typeName.baseType.typeDescriptions.typeString.includes('struct '); // compile base type - const baseType: string = typeFix(arrayNode.typeName.baseType.typeDescriptions.typeString).replace( - /contract |struct |enum /g, - '' - ); + const baseType: string = typeFix(arrayNode.typeName.baseType.typeDescriptions.typeString).replace(/contract |struct |enum /g, ''); // If the array is internal we don't create mockCall for it const isInternal: boolean = arrayNode.visibility == 'internal'; @@ -115,16 +109,10 @@ function getMappingFunction(mappingNode: VariableDeclarationNode): MappingStateV // Name of the mapping const mappingName: string = mappingNode.name; // Type name - const keyType: string = typeFix(mappingNode.typeName.keyType.typeDescriptions.typeString).replace( - /contract |struct |enum /g, - '' - ); + const keyType: string = typeFix(mappingNode.typeName.keyType.typeDescriptions.typeString).replace(/contract |struct |enum /g, ''); // Value type - const valueType: string = typeFix(mappingNode.typeName.valueType.typeDescriptions.typeString).replace( - /contract |struct |enum /g, - '' - ); + const valueType: string = typeFix(mappingNode.typeName.valueType.typeDescriptions.typeString).replace(/contract |struct |enum /g, ''); // If the mapping is internal we don't create mockCall for it const isInternal: boolean = mappingNode.visibility == 'internal'; @@ -157,10 +145,7 @@ function getBasicStateVariableFunction(variableNode: VariableDeclarationNode): B const variableName: string = variableNode.name; // remove spec type leading string - const variableType: string = typeFix(variableNode.typeDescriptions.typeString).replace( - /contract |struct |enum /g, - '' - ); + const variableType: string = typeFix(variableNode.typeDescriptions.typeString).replace(/contract |struct |enum /g, ''); // If the variable is internal we don't create mockCall for it const isInternal: boolean = variableNode.visibility == 'internal'; diff --git a/src/mock-contract-generator.ts b/src/mock-contract-generator.ts index 5ec9bcd..8283af1 100644 --- a/src/mock-contract-generator.ts +++ b/src/mock-contract-generator.ts @@ -1,17 +1,5 @@ -import { - getExternalMockFunctions, - getInternalMockFunctions, - getConstructor, - getImports, - getStateVariables, - Ast, -} from './index'; -import { - getSubDirNameFromPath, - registerHandlebarsTemplates, - getContractNames, - compileSolidityFilesFoundry, -} from './utils'; +import { getExternalMockFunctions, getInternalMockFunctions, getConstructor, getImports, getStateVariables, Ast } from './index'; +import { getSubDirNameFromPath, registerHandlebarsTemplates, getContractNames, compileSolidityFilesFoundry } from './utils'; import Handlebars from 'handlebars'; import { writeFileSync, existsSync, readdirSync } from 'fs'; import { ensureDir, emptyDir } from 'fs-extra'; @@ -24,11 +12,7 @@ import { StateVariablesOptions, ContractDefinitionNode } from './types'; * @param compiledArtifactsDir The directory where the compiled artifacts are located * @param generatedContractsDir The directory where the mock contracts will be generated */ -export const generateMockContracts = async ( - contractsDir: string, - compiledArtifactsDir: string, - generatedContractsDir: string -) => { +export const generateMockContracts = async (contractsDir: string, compiledArtifactsDir: string, generatedContractsDir: string) => { const templateContent: string = registerHandlebarsTemplates(); const template = Handlebars.compile(templateContent); try { @@ -90,7 +74,7 @@ export const generateMockContracts = async ( // Get the contract node and check if it's a library // Also check if is another contract inside the file and avoid it const contractNode = ast.nodes.find( - (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === contractName + (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === contractName, ) as ContractDefinitionNode; if (!contractNode || contractNode.abstract || contractNode.contractKind === 'library') return; diff --git a/src/run.ts b/src/run.ts index c8c531f..3969c4b 100644 --- a/src/run.ts +++ b/src/run.ts @@ -2,7 +2,7 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; -import {generateMockContracts} from './index'; +import { generateMockContracts } from './index'; (async () => { const { contracts, out, genDir } = getProcessArguments(); @@ -29,4 +29,4 @@ function getProcessArguments() { }, }) .parseSync(); -} \ No newline at end of file +} diff --git a/src/templates/mockContractTemplate.hbs b/src/templates/mockContractTemplate.hbs index 72c05ae..abf81e5 100644 --- a/src/templates/mockContractTemplate.hbs +++ b/src/templates/mockContractTemplate.hbs @@ -1,7 +1,7 @@ /// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; -import 'forge-std/Test.sol'; +import {Test} from 'forge-std/Test.sol'; import { {{~contractName~}} } from '{{contractImport}}'; {{#each import}} {{this}}; diff --git a/test/e2e/get-internal-functions.spec.ts b/test/e2e/get-internal-functions.spec.ts index f5436f0..9f64ddc 100644 --- a/test/e2e/get-internal-functions.spec.ts +++ b/test/e2e/get-internal-functions.spec.ts @@ -23,10 +23,9 @@ describe('getInternalMockFunctions', () => { const ast = require(compiledArtifactsPath).ast; if (!ast) throw new Error(`AST for ${mockName} not found`); const contractNode = ast.nodes.find( - (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === mockName + (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === mockName, ) as ContractDefinitionNode; - if (!contractNode || contractNode.abstract || contractNode.contractKind === 'library') - throw new Error(`Contract ${mockName} not found`); + if (!contractNode || contractNode.abstract || contractNode.contractKind === 'library') throw new Error(`Contract ${mockName} not found`); contractNodes = { ...contractNodes, [mockName]: contractNode }; }); @@ -36,7 +35,7 @@ describe('getInternalMockFunctions', () => { it('contract D must include constructor', async () => { const contractNode = contractNodes['MockContractD']; const constructor = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.kind === 'constructor' + (node) => node.nodeType === 'FunctionDefinition' && node.kind === 'constructor', ) as FunctionDefinitionNode; expect(constructor).to.not.be.undefined; @@ -48,7 +47,7 @@ describe('getInternalMockFunctions', () => { it('MockContractD must include setting variable', async () => { const contractNode = contractNodes['MockContractD']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set__internalUintVar' + (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set__internalUintVar', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('public'); @@ -61,7 +60,7 @@ describe('getInternalMockFunctions', () => { it('MockContractD must include mock call', async () => { const contractNode = contractNodes['MockContractD']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === 'mock_call__setInternalUintVar' + (node) => node.nodeType === 'FunctionDefinition' && node.name === 'mock_call__setInternalUintVar', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('public'); @@ -87,7 +86,7 @@ describe('getInternalMockFunctions', () => { it('MockContractD must include overriden internal func', async () => { const contractNode = contractNodes['MockContractD']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === '_setInternalUintVar' + (node) => node.nodeType === 'FunctionDefinition' && node.name === '_setInternalUintVar', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('internal'); diff --git a/test/e2e/set-variables.spec.ts b/test/e2e/set-variables.spec.ts index 0276a85..6a8b797 100644 --- a/test/e2e/set-variables.spec.ts +++ b/test/e2e/set-variables.spec.ts @@ -20,10 +20,9 @@ describe('getInternalMockFunctions', () => { const ast = require(compiledArtifactsPath).ast; if (!ast) throw new Error(`AST for ${mockName} not found`); const contractNode = ast.nodes.find( - (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === mockName + (node) => node.nodeType === 'ContractDefinition' && node.canonicalName === mockName, ) as ContractDefinitionNode; - if (!contractNode || contractNode.abstract || contractNode.contractKind === 'library') - throw new Error(`Contract ${mockName} not found`); + if (!contractNode || contractNode.abstract || contractNode.contractKind === 'library') throw new Error(`Contract ${mockName} not found`); contractNodes = { ...contractNodes, [mockName]: contractNode }; }); @@ -32,7 +31,7 @@ describe('getInternalMockFunctions', () => { it('must include setters for struct variables', async () => { const contractNode = contractNodes['MockContractTest']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_myStructVariable' + (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_myStructVariable', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('public'); @@ -41,7 +40,7 @@ describe('getInternalMockFunctions', () => { it('must include setters for struct arrays', async () => { const contractNode = contractNodes['MockContractTest']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_myStructArray' + (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_myStructArray', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('public'); @@ -50,7 +49,7 @@ describe('getInternalMockFunctions', () => { it('must include setters for struct mappings', async () => { const contractNode = contractNodes['MockContractTest']; const func = contractNode.nodes.find( - (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_uint256ToMyStruct' + (node) => node.nodeType === 'FunctionDefinition' && node.name === 'set_uint256ToMyStruct', ) as FunctionDefinitionNode; expect(func).to.not.be.undefined; expect(func.visibility).to.equal('public'); diff --git a/test/unit/get-internal-functions.spec.ts b/test/unit/get-internal-functions.spec.ts index 606926c..24f0d6d 100644 --- a/test/unit/get-internal-functions.spec.ts +++ b/test/unit/get-internal-functions.spec.ts @@ -169,11 +169,7 @@ describe('getInternalMockFunctions', () => { nodeType: 'FunctionDefinition', kind: 'function', parameters: { - parameters: [ - FakeParameter(1, 'contract IERC20', ''), - FakeParameter(2, 'struct MyStruct', ''), - FakeParameter(3, 'enum MyEnum', ''), - ], + parameters: [FakeParameter(1, 'contract IERC20', ''), FakeParameter(2, 'struct MyStruct', ''), FakeParameter(3, 'enum MyEnum', '')], }, returnParameters: { parameters: [], @@ -242,11 +238,7 @@ describe('getInternalMockFunctions', () => { parameters: [], }, returnParameters: { - parameters: [ - FakeParameter(1, 'contract IERC20', ''), - FakeParameter(2, 'struct MyStruct', ''), - FakeParameter(3, 'enum MyEnum', ''), - ], + parameters: [FakeParameter(1, 'contract IERC20', ''), FakeParameter(2, 'struct MyStruct', ''), FakeParameter(3, 'enum MyEnum', '')], }, virtual: true, visibility: 'internal', diff --git a/tsconfig.json b/tsconfig.json index b44f99f..c8afc51 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "esModuleInterop": true, "removeComments": true, "outDir": "dist", - "resolveJsonModule": true, + "resolveJsonModule": true }, "include": ["src/*.ts", "src/**/*.hbs"], "exclude": ["node_modules", "dist"] diff --git a/yarn.lock b/yarn.lock index bd4b27a..a42e9de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2079,7 +2079,7 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -husky@8.0.3: +husky@^8.0.3: version "8.0.3" resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== @@ -3055,6 +3055,11 @@ prettier@^2.7.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643" + integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg== + pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"