diff --git a/src/cli/utils.ts b/src/cli/utils.ts index 7d1fedc..f8c99a2 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -3,7 +3,11 @@ import * as Mocha from 'mocha'; import * as mkdirpCallback from 'mkdirp'; import * as rimrafCallback from 'rimraf'; import * as qrcode from 'qrcode-terminal'; -import { writeFile as writeFileCallback, exists as existsCallback } from 'fs'; +import { + writeFile as writeFileCallback, + exists as existsCallback, + readFile as readFileCallback, +} from 'fs'; import * as globCallback from 'glob'; import * as path from 'path'; import { promisify } from 'util'; @@ -13,6 +17,7 @@ const glob = promisify(globCallback); const mkdirp = promisify(mkdirpCallback); const rimraf = promisify(rimrafCallback); const writeFile = promisify(writeFileCallback); +const readFile = promisify(readFileCallback); // It's nice to give people proper stack traces when they have a problem with their code. // Trace shows async traces, and Clarify removes internal Node entries. @@ -389,7 +394,7 @@ export const pathToIdentifier = (filePath: string) => filePath.substr(0, filePat */ export const build = async (contractPath: string) => { // Get the base filename from path and log status - const basename = path.basename(contractPath, '.cpp'); + // const basename = path.basename(contractPath, '.cpp'); // Never Used // Compile contract at path await compileContract(contractPath); // Generate Typescript definitions for contract @@ -433,6 +438,17 @@ export const compileContract = async (contractPath: string) => { } const outputPath = outputPathForContract(contractPath); + const buildFlagsPathComponents = path.parse(contractPath); + const buildFlagsPath = + buildFlagsPathComponents.dir + '/' + buildFlagsPathComponents.name + '.lamflags'; + let buildFlags = ''; + + if (await exists(buildFlagsPath)) { + const data = await readFile(buildFlagsPath); + + console.log('\n Adding build flags to compile command: ' + data.toString()); + buildFlags = data.toString(); + } // Run the compile contract script inside our docker container. await docker @@ -444,7 +460,7 @@ export const compileContract = async (contractPath: string) => { 'bin', 'project', contractPath - )}" "${outputPath}" "${basename}"` + )}" "${outputPath}" "${basename}" ${buildFlags}` ) .catch(err => { spinner.fail('Failed to compile'); diff --git a/src/eosManager.ts b/src/eosManager.ts index 2e60625..2e0af3e 100644 --- a/src/eosManager.ts +++ b/src/eosManager.ts @@ -131,9 +131,12 @@ export class EOSManager { return value; }) .catch(error => { - logOutput(chalk.red('Threw error: ') + error); - console.log( - chalk.cyan('Payload causing the above error: ') + JSON.stringify(transaction, null, 4) + logOutput( + chalk.red('Threw error: ') + + error + + '\n' + + chalk.cyan('Payload causing the above error: ') + + JSON.stringify(transaction, null, 4) ); throw error; }); diff --git a/src/scripts/compile_contract.sh b/src/scripts/compile_contract.sh index e26f430..0e7baa4 100755 --- a/src/scripts/compile_contract.sh +++ b/src/scripts/compile_contract.sh @@ -7,10 +7,13 @@ PATH="$PATH:/opt/eosio/bin" filename="$1" outputPath="$2" contractName="$3" +addedBuildFlags="$4" # Ensure the output directory exists mkdir -p "project/$outputPath" # compile smart contract to wasm and abi files using EOSIO.CDT (Contract Development Toolkit) # https://github.com/EOSIO/eosio.cdt -eosio-cpp -abigen "$filename" -o "project/$outputPath/$contractName.wasm" --contract "$contractName" +eosio-cpp -abigen "$filename" -o "project/$outputPath/$contractName.wasm" --contract "$contractName" $4 + + diff --git a/src/utils.ts b/src/utils.ts index 9c97415..57aded7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -154,9 +154,6 @@ const assertExpectedEOSError = async ( try { await operation; } catch (error) { - if (verbose_logging) { - console.log('Verbose error output: ' + JSON.stringify(error, null, 4)); - } if (error.json && error.json.error && error.json.error.name) { // Compare error and fail if the error doesn't match the expected assert(