forked from ethereum/remix-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
257 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
plugin api | ||
|
||
# current APIs: | ||
|
||
## 1) notifications | ||
|
||
### app (key: app) | ||
|
||
- unfocus `[]` | ||
- focus `[]` | ||
|
||
### compiler (key: compiler) | ||
|
||
- compilationFinished `[success (bool), data (obj), source (obj)]` | ||
- compilationData `[compilationResult]` | ||
|
||
### transaction listener (key: txlistener) | ||
|
||
- newTransaction `tx (obj)` | ||
|
||
## 2) interactions | ||
|
||
### app | ||
|
||
- getExecutionContextProvider `@return {String} provider (injected | web3 | vm)` | ||
- updateTitle `@param {String} title` | ||
|
||
### config | ||
|
||
- setConfig `@param {String} path, @param {String} content` | ||
- getConfig `@param {String} path` | ||
- removeConfig `@param {String} path` | ||
|
||
### compiler | ||
- getCompilationResult `@return {Object} compilation result` | ||
|
||
### udapp (only VM) | ||
- runTx `@param {Object} tx` | ||
- getAccounts `@return {Array} acccounts` | ||
- createVMAccount `@param {String} privateKey, @param {String} balance (hex)` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,62 @@ | ||
'use strict' | ||
var executionContext = require('../../execution-context') | ||
|
||
/* | ||
Defines available API. `key` / `type` | ||
*/ | ||
module.exports = (registry) => { | ||
module.exports = (fileProviders, compiler, udapp, tabbedMenu) => { | ||
return { | ||
app: { | ||
getExecutionContextProvider: (mod, cb) => { | ||
cb(null, executionContext.getProvider()) | ||
}, | ||
updateTitle: (mod, title, cb) => { | ||
tabbedMenu.updateTabTitle(mod, title) | ||
} | ||
}, | ||
config: { | ||
setConfig: (mod, path, content, cb) => { | ||
registry.get('fileproviders/config').api.set(mod + '/' + path, content) | ||
fileProviders['config'].set(mod + '/' + path, content) | ||
cb() | ||
}, | ||
getConfig: (mod, path, cb) => { | ||
cb(null, registry.get('fileproviders/config').get(mod + '/' + path)) | ||
cb(null, fileProviders['config'].get(mod + '/' + path)) | ||
}, | ||
removeConfig: (mod, path, cb) => { | ||
cb(null, registry.get('fileproviders/config').api.remove(mod + '/' + path)) | ||
cb(null, fileProviders['config'].remove(mod + '/' + path)) | ||
if (cb) cb() | ||
} | ||
}, | ||
compiler: { | ||
getCompilationResult: () => { | ||
return registry.get('compiler').api.lastCompilationResult | ||
getCompilationResult: (mod, cb) => { | ||
cb(null, compiler.lastCompilationResult) | ||
} | ||
}, | ||
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) => { | ||
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) | ||
}, | ||
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') | ||
udapp.createVMAccount(privateKey, balance, (error, address) => { | ||
cb(error, address) | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.