Skip to content

Commit

Permalink
check veraible
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine de Chevigné committed Nov 21, 2024
1 parent 42d5679 commit 354bdbe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions run/jobs/processContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const fetchEtherscanData = async (address, workspace) => {
apiKey = getScannerKey('SNOWTRACE');
break;
case 'buildbear':
scannerHost = `api.buildbear.io/v1/explorer/${workspace.name}`;
scannerHost = `api.buildbear.io/v1/explorer/slimy-jugsgernaut-ea0852a40`;
apiKey = getScannerKey('BUILDBEAR');
headers['Authorization'] = `Bearer ${apiKey}`;
break;
Expand All @@ -85,7 +85,7 @@ const fetchEtherscanData = async (address, workspace) => {
const response = await withTimeout(axios.get(endpoint, { headers }));
return response ? response.data : null;
} catch (error) {
if (error.response.status >= 400)
if (error.response && error.response.status >= 400)
return error.response;

throw error;
Expand All @@ -104,13 +104,17 @@ const findScannerMetadata = async (workspace, contract) => {
const sources = scannerData.result[0].SourceCode;
let parsedSources;
if (sources.startsWith('{{'))
parsedSources = JSON.parse(sources.substring(1, sources.length - 1)).sources;
try {
parsedSources = JSON.parse(sources.substring(1, sources.length - 1)).sources;
} catch (error) {
parsedSources = null;
}
else
parsedSources = {
[`${scannerData.result[0].ContractName.split('.sol')[0]}.sol`]: { content: sources }
};

const verificationData = scannerData.result[0].ABI == 'Contract source code not verified' ?
const verificationData = !parsedSources || scannerData.result[0].ABI == 'Contract source code not verified' ?
null :
{
compilerVersion: scannerData.result[0].CompilerVersion,
Expand Down
12 changes: 12 additions & 0 deletions run/migrations/20241121121032-optional-hashed-bytecode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface) {
await queryInterface.sequelize.query('ALTER TABLE transaction_trace_steps ALTER COLUMN "contractHashedBytecode" DROP NOT NULL;');
},

async down (queryInterface) {
await queryInterface.sequelize.query('ALTER TABLE transaction_trace_steps ALTER COLUMN "contractHashedBytecode" SET NOT NULL;');
}
};

0 comments on commit 354bdbe

Please sign in to comment.