@ -48,22 +48,32 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
} ,
udapp : {
runTx : ( mod , tx , cb ) => {
if ( executionContext . getProvider ( ) !== 'vm' ) return cb ( 'plugin API does not allow sending a transaction through a web3 connection. Only vm mode is allowed' )
udapp . silentRunTx ( tx , ( error , result ) => {
executionContext . detectNetwork ( ( error , network ) => {
if ( error ) return cb ( error )
cb ( null , {
transactionHash : result . transactionHash ,
status : result . result . status ,
gasUsed : '0x' + result . result . gasUsed . toString ( 'hex' ) ,
error : result . result . vm . exceptionError ,
return : result . result . vm . return ? '0x' + result . result . vm . return . toString ( 'hex' ) : '0x' ,
createdAddress : result . result . createdAddress ? '0x' + result . result . createdAddress . toString ( 'hex' ) : undefined
if ( network . name === 'Main' && network . id === '1' ) {
return cb ( 'It is not allowed to make this action against mainnet' )
}
udapp . silentRunTx ( tx , ( error , result ) => {
if ( error ) return cb ( error )
cb ( null , {
transactionHash : result . transactionHash ,
status : result . result . status ,
gasUsed : '0x' + result . result . gasUsed . toString ( 'hex' ) ,
error : result . result . vm . exceptionError ,
return : result . result . vm . return ? '0x' + result . result . vm . return . toString ( 'hex' ) : '0x' ,
createdAddress : result . result . createdAddress ? '0x' + result . result . createdAddress . toString ( 'hex' ) : undefined
} )
} )
} )
} ,
getAccounts : ( mod , cb ) => {
if ( executionContext . getProvider ( ) !== 'vm' ) return cb ( 'plugin API does not allow retrieving accounts through a web3 connection. Only vm mode is allowed' )
udapp . getAccounts ( cb )
executionContext . detectNetwork ( ( error , network ) => {
if ( error ) return cb ( error )
if ( network . name === 'Main' && network . id === '1' ) {
return cb ( 'It is not allowed to make this action against mainnet' )
}
udapp . getAccounts ( cb )
} )
} ,
createVMAccount : ( mod , privateKey , balance , cb ) => {
if ( executionContext . getProvider ( ) !== 'vm' ) return cb ( 'plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed' )
@ -73,6 +83,9 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
}
} ,
editor : {
getFilesFromPath : ( mod , path , cb ) => {
fileManager . filesFromPath ( path , cb )
} ,
getCurrentFile : ( mod , cb ) => {
var path = fileManager . currentFile ( )
if ( ! path ) {
@ -97,7 +110,8 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
if ( provider ) {
// TODO add approval to user for external plugin to set the content of the given `path`
provider . set ( path , content , ( error ) => {
cb ( error )
if ( error ) return cb ( error )
fileManager . syncEditor ( path )
} )
} else {
cb ( path + ' not available' )