mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
Changed eth to food in command line interface. Added new commands to console for sending transaction with additional data in Json format: sendTransactionWithData and getTransactionFormatted
This commit is contained in:
parent
f353505c69
commit
accd5b4735
2 changed files with 46 additions and 4 deletions
|
|
@ -131,7 +131,7 @@ func (c *Console) init(preload []string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("api modules: %v", err)
|
||||
}
|
||||
flatten := "var eth = web3.eth; var personal = web3.personal; "
|
||||
flatten := "var food = web3.eth; var personal = web3.personal; "
|
||||
for api := range apis {
|
||||
if api == "web3" {
|
||||
continue // manually mapped or ignore
|
||||
|
|
@ -141,7 +141,11 @@ func (c *Console) init(preload []string) error {
|
|||
if err = c.jsre.Compile(fmt.Sprintf("%s.js", api), file); err != nil {
|
||||
return fmt.Errorf("%s.js: %v", api, err)
|
||||
}
|
||||
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
|
||||
if api == "eth" {
|
||||
flatten += fmt.Sprintf("var food = web3.%s; ", api)
|
||||
} else {
|
||||
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
|
||||
}
|
||||
} else if obj, err := c.jsre.Run("web3." + api); err == nil && obj.IsObject() {
|
||||
// Enable web3.js built-in extension if available.
|
||||
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ var Modules = map[string]string{
|
|||
"chequebook": Chequebook_JS,
|
||||
"clique": Clique_JS,
|
||||
"debug": Debug_JS,
|
||||
"eth": Eth_JS,
|
||||
"eth": Eth_JS,
|
||||
"miner": Miner_JS,
|
||||
"net": Net_JS,
|
||||
"personal": Personal_JS,
|
||||
|
|
@ -412,7 +412,45 @@ web3._extend({
|
|||
params: 2,
|
||||
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
|
||||
}),
|
||||
],
|
||||
new web3._extend.Method({
|
||||
name: 'sendTransactionWithData',
|
||||
call: function(args) {
|
||||
if (args[1]) {
|
||||
if (!web3._extend.utils.isObject(args[1])) {
|
||||
args[1] = "{\"description\":\"" + args[1] + "\"}"
|
||||
} else {
|
||||
args[1] = JSON.stringify(args[1])
|
||||
}
|
||||
args[0].data = web3.toHex(args[1])
|
||||
}
|
||||
return 'eth_sendTransaction'
|
||||
},
|
||||
params: 1,
|
||||
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'getTransactionFormatted',
|
||||
call: 'eth_getTransactionByHash',
|
||||
params: 1,
|
||||
outputFormatter: function (tx) {
|
||||
if(tx.blockNumber !== null)
|
||||
tx.blockNumber = web3.toDecimal(tx.blockNumber);
|
||||
if(tx.transactionIndex !== null)
|
||||
tx.transactionIndex = web3.toDecimal(tx.transactionIndex);
|
||||
tx.nonce = web3.toDecimal(tx.nonce);
|
||||
tx.gas = web3.toDecimal(tx.gas);
|
||||
tx.gasPrice = web3.toBigNumber(tx.gasPrice);
|
||||
tx.value = web3.toBigNumber(tx.value);
|
||||
inputStr = web3.toUtf8(tx.input);
|
||||
if (web3._extend.utils.isJson(inputStr)) {
|
||||
tx.input = JSON.parse(inputStr);
|
||||
} else {
|
||||
tx.input = inputStr;
|
||||
}
|
||||
return tx;
|
||||
}
|
||||
}),
|
||||
],
|
||||
properties: [
|
||||
new web3._extend.Property({
|
||||
name: 'pendingTransactions',
|
||||
|
|
|
|||
Loading…
Reference in a new issue