add approveToken; pass correct default account param
This commit is contained in:
parent
a8fa5f2666
commit
a27c17f067
|
@ -46,6 +46,9 @@ class Actions {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
web3() {
|
||||||
|
return web3;
|
||||||
|
}
|
||||||
|
|
||||||
addProject(params) {
|
addProject(params) {
|
||||||
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({from: \"${web3.eth.defaultAccount}\", gas: 2000000})`
|
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({from: \"${web3.eth.defaultAccount}\", gas: 2000000})`
|
||||||
|
@ -76,6 +79,14 @@ class Actions {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
approveToken(params) {
|
||||||
|
let text = `await StandardToken.methods.approve(\"${LiquidPledging.options.address}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
|
||||||
|
doAction(text, async () => {
|
||||||
|
let mintReceipt = await StandardToken.methods.approve(LiquidPledging.options.address, web3.utils.toWei(params.amount, "ether")).send({gas: 2000000})
|
||||||
|
console.dir("txHash: " + mintReceipt.transactionHash)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Actions;
|
module.exports = Actions;
|
||||||
|
|
|
@ -12,7 +12,7 @@ async function app(actions) {
|
||||||
|
|
||||||
if (subAction === 'List Projects') {
|
if (subAction === 'List Projects') {
|
||||||
} if (subAction === 'Create Project') {
|
} if (subAction === 'Create Project') {
|
||||||
let params = (await menus.createProject("0x0000000000000000000000000000000000000001"))
|
let params = (await menus.createProject(actions.web3().eth.defaultAccount))
|
||||||
actions.addProject(params);
|
actions.addProject(params);
|
||||||
} if (subAction === 'view Project') {
|
} if (subAction === 'view Project') {
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ async function app(actions) {
|
||||||
let params = (await menus.mintToken())
|
let params = (await menus.mintToken())
|
||||||
action.mintToken(params);
|
action.mintToken(params);
|
||||||
} if (subAction === 'Aprove') {
|
} if (subAction === 'Aprove') {
|
||||||
|
let params = (await menus.approveToken())
|
||||||
|
action.approveToken(params);
|
||||||
}
|
}
|
||||||
} else if (action === 'Exit') {
|
} else if (action === 'Exit') {
|
||||||
process.exit()
|
process.exit()
|
||||||
|
|
21
src/menus.js
21
src/menus.js
|
@ -212,6 +212,27 @@ const menus = {
|
||||||
filter: Number
|
filter: Number
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
},
|
||||||
|
|
||||||
|
approveToken: async function(lpAddress) {
|
||||||
|
return inquirer.prompt([
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
name: 'tokenAddress',
|
||||||
|
message: 'What is the token address?',
|
||||||
|
filter: String,
|
||||||
|
validate: function(value) {
|
||||||
|
return value.indexOf("0x") === 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
name: 'amount',
|
||||||
|
message: 'amount (in ether units)',
|
||||||
|
default: 2,
|
||||||
|
filter: Number
|
||||||
|
}
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue