Skip to content

Commit 5983e5b

Browse files
committed
fix block statements. - fixes #2
fix .config unset not working
1 parent faf2029 commit 5983e5b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

bin/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ cheers 🙌
117117
case '.config':
118118
switch(commandParts[1]){
119119
case 'set': shell.setSetting(commandParts[2], convert(commandParts[3])); break;
120-
case 'del': delete shell.settings[commandParts[2]]; break;
120+
case 'unset': delete shell.settings[commandParts[2]]; break;
121121
default: return cb(shell.settings);
122122
} break;
123123
case '.session':
@@ -159,7 +159,6 @@ cheers 🙌
159159
return cb();
160160
}
161161
return cb(`${c.bold(c.yellow(shell.blockchain.proc.pid))} - ${shell.blockchain.proc.spawnargs.join(', ')}`)
162-
163162
default:
164163
console.error(`Unknown Command: '${command}'. Type '${c.bold('.help')}' for a list of commands.`);
165164
}
@@ -171,7 +170,7 @@ cheers 🙌
171170

172171
/* REPL cmd */
173172
shell.run(statement).then(res => {
174-
if(typeof res === 'object'){
173+
if(!Array.isArray(res) && typeof res === 'object'){
175174
return cb();
176175
}
177176
LAST_KNOWN_RESULT = res;

src/handler.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SolidityStatement {
6060
this.scope = SCOPE.VERSION_PRAGMA;
6161
this.hasNoReturnValue = true;
6262
this.rawCommand = this.fixStatement(this.rawCommand);
63-
} else if (this.rawCommand.startsWith('pragma ')) {
63+
} else if (this.rawCommand.startsWith('pragma ') || this.rawCommand.startsWith('import ')) {
6464
this.scope = SCOPE.SOURCE_UNIT;
6565
this.hasNoReturnValue = true;
6666
this.rawCommand = this.fixStatement(this.rawCommand);
@@ -91,7 +91,7 @@ class SolidityStatement {
9191
}
9292

9393
fixStatement(stm) {
94-
return stm.endsWith(';') ? stm : `${stm};`
94+
return (stm.endsWith(';') || stm.endsWith('}')) ? stm : `${stm};`
9595
}
9696

9797
toString() {
@@ -287,13 +287,11 @@ contract ${this.settings.templateContractName} {
287287
let contractData = res.contracts[''];
288288
contractData[this.settings.templateContractName]['main'] = this.settings.templateFuncMain;
289289

290-
291290
this.blockchain.deploy(contractData, (err, retval) => {
292291
if (err) {
293292
this.revert();
294293
return reject(err)
295294
}
296-
297295
return resolve(retval) // return value
298296
})
299297
}).catch(errors => {
@@ -426,5 +424,6 @@ class Blockchain {
426424

427425
module.exports = {
428426
InteractiveSolidityShell,
429-
SolidityStatement
427+
SolidityStatement,
428+
SCOPE
430429
}

0 commit comments

Comments
 (0)