diff --git a/packages/api/src/api/mappers/sourceCodeMapper.ts b/packages/api/src/api/mappers/sourceCodeMapper.ts index c720898402..0f5070a89b 100644 --- a/packages/api/src/api/mappers/sourceCodeMapper.ts +++ b/packages/api/src/api/mappers/sourceCodeMapper.ts @@ -19,7 +19,7 @@ export const SOURCE_CODE_EMPTY_INFO: ContractSourceCodeDto = { export const mapContractSourceCode = (data: ContractVerificationInfo): ContractSourceCodeDto => { let sourceCode: string; - if (data.request.codeFormat.startsWith("vyper-multi-file")) { + if (data.request.codeFormat.startsWith("vyper-multi-file") && typeof data.request.sourceCode !== "string") { const vyperFileNames = Object.keys(data.request.sourceCode); if (vyperFileNames.length === 1) { sourceCode = data.request.sourceCode[vyperFileNames[0]]; diff --git a/packages/api/test/contract-api.e2e-spec.ts b/packages/api/test/contract-api.e2e-spec.ts index 1e1bc988eb..e68ffe3fdc 100644 --- a/packages/api/test/contract-api.e2e-spec.ts +++ b/packages/api/test/contract-api.e2e-spec.ts @@ -93,6 +93,7 @@ describe("Contract API (e2e)", () => { abi: [], }, request: { + codeFormat: "solidity-single-file", sourceCode: "sourceCode", constructorArguments: "0x0001", contractName: "contractName", @@ -141,6 +142,7 @@ describe("Contract API (e2e)", () => { abi: [], }, request: { + codeFormat: "solidity-standard-json-input", sourceCode: { language: "Solidity", settings: { @@ -205,7 +207,10 @@ describe("Contract API (e2e)", () => { abi: [], }, request: { - sourceCode: "sourceCode", + codeFormat: "vyper-multi-file", + sourceCode: { + "Base.vy": "Base.vy content", + }, constructorArguments: "0x0001", contractName: "contractName", optimizationUsed: true, @@ -234,7 +239,7 @@ describe("Contract API (e2e)", () => { OptimizationUsed: "1", Proxy: "0", Runs: "", - SourceCode: "sourceCode", + SourceCode: "Base.vy content", SwarmSource: "", }, ], @@ -253,21 +258,10 @@ describe("Contract API (e2e)", () => { abi: [], }, request: { + codeFormat: "vyper-multi-file", sourceCode: { - language: "Vyper", - settings: { - optimizer: { - enabled: true, - }, - }, - sources: { - "Base.vy": { - content: "Base.vy content", - }, - "faucet.vy": { - content: "faucet.vy content", - }, - }, + "Base.vy": "Base.vy content", + "faucet.vy": "faucet.vy content", }, constructorArguments: "0x0001", contractName: "contractName",