remove getContract && getContracts

pull/1/head
yann300 7 years ago
parent 980bab63de
commit 207700fad4
  1. 6
      src/app.js
  2. 18
      src/app/tabs/run-tab.js
  3. 4
      src/recorder.js

@ -713,12 +713,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
currentFile: () => { currentFile: () => {
return config.get('currentFile') return config.get('currentFile')
}, },
getContracts: () => {
return compiler.getContracts()
},
getContract: (name) => {
return compiler.getContract(name)
},
visitContracts: (cb) => { visitContracts: (cb) => {
compiler.visitContracts(cb) compiler.visitContracts(cb)
}, },

@ -30,7 +30,7 @@ function runTab (appAPI = {}, appEvents = {}, opts = {}) {
clearInstanceElement.addEventListener('click', () => { clearInstanceElement.addEventListener('click', () => {
event.trigger('clearInstance', []) event.trigger('clearInstance', [])
}) })
var recorderInterface = makeRecorder(event, appAPI, appEvents) var recorderInterface = makeRecorder(event, appAPI, appEvents, opts)
var pendingTxsContainer = yo` var pendingTxsContainer = yo`
<div class="${css.pendingTxsContainer}"> <div class="${css.pendingTxsContainer}">
<div class="${css.pendingTxsText}"> <div class="${css.pendingTxsText}">
@ -46,7 +46,7 @@ function runTab (appAPI = {}, appEvents = {}, opts = {}) {
var el = yo` var el = yo`
<div> <div>
${settings(container, appAPI, appEvents, opts)} ${settings(container, appAPI, appEvents, opts)}
${contractDropdown(event, appAPI, appEvents, instanceContainer)} ${contractDropdown(event, appAPI, appEvents, opts, instanceContainer)}
${pendingTxsContainer} ${pendingTxsContainer}
${instanceContainer} ${instanceContainer}
</div> </div>
@ -134,8 +134,8 @@ function updateAccountBalances (container, appAPI) {
/* ------------------------------------------------ /* ------------------------------------------------
RECORDER RECORDER
------------------------------------------------ */ ------------------------------------------------ */
function makeRecorder (events, appAPI, appEvents) { function makeRecorder (events, appAPI, appEvents, opts) {
var recorder = new Recorder({ var recorder = new Recorder(opts.compiler, {
events: { events: {
udapp: appEvents.udapp, udapp: appEvents.udapp,
executioncontext: executionContext.event, executioncontext: executionContext.event,
@ -206,7 +206,7 @@ function makeRecorder (events, appAPI, appEvents) {
section CONTRACT DROPDOWN and BUTTONS section CONTRACT DROPDOWN and BUTTONS
------------------------------------------------ */ ------------------------------------------------ */
function contractDropdown (events, appAPI, appEvents, instanceContainer) { function contractDropdown (events, appAPI, appEvents, opts, instanceContainer) {
instanceContainer.appendChild(noInstancesText) instanceContainer.appendChild(noInstancesText)
var compFails = yo`<i title="Contract compilation failed. Please check the compile tab for more information." class="fa fa-times-circle ${css.errorIcon}" ></i>` var compFails = yo`<i title="Contract compilation failed. Please check the compile tab for more information." class="fa fa-times-circle ${css.errorIcon}" ></i>`
appEvents.compiler.register('compilationFinished', function (success, data, source) { appEvents.compiler.register('compilationFinished', function (success, data, source) {
@ -229,7 +229,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
if (contractName) { if (contractName) {
return { return {
name: contractName, name: contractName,
contract: appAPI.getContract(contractName) contract: opts.compiler.getContract(contractName)
} }
} }
return null return null
@ -256,7 +256,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
function setInputParamsPlaceHolder () { function setInputParamsPlaceHolder () {
createButtonInput.value = '' createButtonInput.value = ''
if (appAPI.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) { if (opts.compiler.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) {
var ctrabi = txHelper.getConstructorInterface(getSelectedContract().contract.object.abi) var ctrabi = txHelper.getConstructorInterface(getSelectedContract().contract.object.abi)
if (ctrabi.inputs.length) { if (ctrabi.inputs.length) {
createButtonInput.setAttribute('placeholder', txHelper.inputParametersDeclarationToString(ctrabi.inputs)) createButtonInput.setAttribute('placeholder', txHelper.inputParametersDeclarationToString(ctrabi.inputs))
@ -281,7 +281,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi) var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
var args = createButtonInput.value var args = createButtonInput.value
txFormat.buildData(selectedContract.name, selectedContract.contract.object, appAPI.getContracts(), true, constructor, args, (error, data) => { txFormat.buildData(selectedContract.name, selectedContract.contract.object, opts.compiler.getContracts(), true, constructor, args, (error, data) => {
if (!error) { if (!error) {
appAPI.logMessage(`creation of ${selectedContract.name} pending...`) appAPI.logMessage(`creation of ${selectedContract.name} pending...`)
appAPI.udapp().createContract(data, (error, txResult) => { appAPI.udapp().createContract(data, (error, txResult) => {
@ -333,7 +333,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
instanceContainer.appendChild(appAPI.udappUI().renderInstanceFromABI(abi, address, address)) instanceContainer.appendChild(appAPI.udappUI().renderInstanceFromABI(abi, address, address))
}) })
} else { } else {
var contract = appAPI.getContract(contractNames.children[contractNames.selectedIndex].innerHTML) var contract = opts.compiler.getContract(contractNames.children[contractNames.selectedIndex].innerHTML)
instanceContainer.appendChild(appAPI.udappUI().renderInstance(contract.object, address, selectContractNames.value)) instanceContainer.appendChild(appAPI.udappUI().renderInstance(contract.object, address, selectContractNames.value))
} }
} }

@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom')
* *
*/ */
class Recorder { class Recorder {
constructor (opts = {}) { constructor (compiler, opts = {}) {
var self = this var self = this
self._api = opts.api self._api = opts.api
self.event = new EventManager() self.event = new EventManager()
@ -33,7 +33,7 @@ class Recorder {
if (this.data._listen) { if (this.data._listen) {
var record = { value, parameters: payLoad.funArgs } var record = { value, parameters: payLoad.funArgs }
if (!to) { if (!to) {
var selectedContract = self._api.getContract(payLoad.contractName) var selectedContract = compiler.getContract(payLoad.contractName)
if (selectedContract) { if (selectedContract) {
var abi = selectedContract.object.abi var abi = selectedContract.object.abi
var sha3 = ethutil.bufferToHex(ethutil.sha3(abi)) var sha3 = ethutil.bufferToHex(ethutil.sha3(abi))

Loading…
Cancel
Save