dappuniversity / eth-todo-list

Blockchain Todo App Tutorial Powered by Ethereum Smart Contracts
549 stars 549 forks source link

On task completion, getting error "send transactions from field must be defined!" #24

Open shivi28 opened 2 years ago

shivi28 commented 2 years ago

After completing the task, when I toggle the task checkbox I am getting below error.

app.js:126 Uncaught (in promise) Error: The send transactions "from" field must be defined!
    at HTMLInputElement.toggleCompleted (app.js:124:28)
    at HTMLInputElement.dispatch (jquery.min.js:3:12444)
    at HTMLInputElement.r.handle (jquery.min.js:3:9173)
shivi28 commented 2 years ago

To resolve this issue update the toggleCompleted()in app.js

Older code

toggleCompleted: async (e) => {
        App.setLoading(true)
        const taskId = e.target.name
        await App.todoList.toggleCompleted(taskId)
        window.location.reload()
    }

Updated code:

toggleCompleted: async (e) => {
        App.setLoading(true)
        const taskId = e.target.name
        await App.todoList.toggleCompleted(taskId,{ from: App.account })
        window.location.reload()
    }

In the updated code, added {from: App.account} argument in App.todoList.toggleCompleted()