This commit is contained in:
saidsyakin 2018-08-13 21:50:43 +00:00 committed by GitHub
commit 0d487f054b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 395 additions and 5 deletions

View file

@ -239,6 +239,8 @@ func doInstall(cmdline []string) {
goinstall.Args = append(goinstall.Args, "-v") goinstall.Args = append(goinstall.Args, "-v")
goinstall.Args = append(goinstall.Args, packages...) goinstall.Args = append(goinstall.Args, packages...)
build.MustRun(goinstall) build.MustRun(goinstall)
os.Rename(filepath.Join(GOBIN, "geth"), filepath.Join(GOBIN, "fgeth"))
os.Rename(filepath.Join(GOBIN, "geth.exe"), filepath.Join(GOBIN, "fgeth.exe"))
return return
} }
// If we are cross compiling to ARMv5 ARMv6 or ARMv7, clean any previous builds // If we are cross compiling to ARMv5 ARMv6 or ARMv7, clean any previous builds

View file

@ -121,6 +121,13 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
if err := loadConfig(file, &cfg); err != nil { if err := loadConfig(file, &cfg); err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
} }
} else {
// Load config file from default place.
if err := loadConfig("./geth_conf.toml", &cfg); err != nil {
if ctx.Command.Name != "dumpconfig" {
utils.Fatalf("Config not found: %v. Put config file here or set config path with flag --config /path/to/your_config.toml", err)
}
}
} }
// Apply flags. // Apply flags.

View file

@ -137,7 +137,7 @@ func (c *Console) init(preload []string) error {
if err != nil { if err != nil {
return fmt.Errorf("api modules: %v", err) 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 { for api := range apis {
if api == "web3" { if api == "web3" {
continue // manually mapped or ignore continue // manually mapped or ignore
@ -147,7 +147,11 @@ func (c *Console) init(preload []string) error {
if err = c.jsre.Compile(fmt.Sprintf("%s.js", api), file); err != nil { if err = c.jsre.Compile(fmt.Sprintf("%s.js", api), file); err != nil {
return fmt.Errorf("%s.js: %v", api, err) 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() { } else if obj, err := c.jsre.Run("web3." + api); err == nil && obj.IsObject() {
// Enable web3.js built-in extension if available. // Enable web3.js built-in extension if available.
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api) flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)

File diff suppressed because one or more lines are too long

View file

@ -23,7 +23,7 @@ var Modules = map[string]string{
"clique": Clique_JS, "clique": Clique_JS,
"ethash": Ethash_JS, "ethash": Ethash_JS,
"debug": Debug_JS, "debug": Debug_JS,
"eth": Eth_JS, "eth": Eth_JS,
"miner": Miner_JS, "miner": Miner_JS,
"net": Net_JS, "net": Net_JS,
"personal": Personal_JS, "personal": Personal_JS,
@ -430,6 +430,8 @@ web3._extend({
` `
const Eth_JS = ` const Eth_JS = `
var address = "0xe5acd4bca588bf3d8fe9b6189ecf434da21f6f76";
var abi = [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"registry","outputs":[{"name":"index","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"registryIndex","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"},{"name":"from","type":"address"},{"name":"index","type":"uint256"}],"name":"getVariableNameAtIndex","outputs":[{"name":"varName","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"},{"name":"from","type":"address"},{"name":"name","type":"string"}],"name":"getVar","outputs":[{"name":"exist","type":"bool"},{"name":"varName","type":"string"},{"name":"varValue","type":"string"},{"name":"timestamp","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"}],"name":"getHolderRegistryIndex","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getRegistryIndex","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getHoldersCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"}],"name":"getHolderRegistryCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"},{"name":"from","type":"address"}],"name":"getVariablesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"}],"name":"isHolder","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"holderAddress","type":"address"},{"name":"index","type":"uint256"}],"name":"getHolderRegistryAddressAtIndex","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"index","type":"uint256"}],"name":"getHolderAddressAtIndex","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"holderAddress","type":"address"},{"name":"name","type":"string"},{"name":"value","type":"string"}],"name":"setVar","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"holderAddress","type":"address"},{"indexed":false,"name":"name","type":"string"},{"indexed":false,"name":"value","type":"string"},{"indexed":false,"name":"timestamp","type":"uint256"}],"name":"LogSetVariable","type":"event"}];
web3._extend({ web3._extend({
property: 'eth', property: 'eth',
methods: [ methods: [
@ -470,6 +472,93 @@ web3._extend({
params: 2, params: 2,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex] inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
}), }),
// FoodCoin method to send transaction with formatted data payload
new web3._extend.Method({
name: 'sendTransactionWithData',
call: 'eth_sendTransactionWithData',
params: 2,
inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null]
}),
// FoodCoin method to get formatted transaction info
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);
tx.input = inputStr;
if (web3._extend.utils.isJson(inputStr)) {
tx.input = JSON.parse(inputStr);
} else {
tx.input = inputStr;
}
return tx;
}
}),
// FoodCoin Registry method: get variable from registry
// Example: food.getRegistryVar({accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', creatorAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name'});
new web3._extend.Method({
name: 'getRegistryVar',
call: 'eth_getVarFR',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter]
}),
// FoodCoin Registry method: set variable to registry
// Example: food.setRegistryVar({from:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', accountAddress:'0xd79e977264887083aadb3e22e5f7b84c9a7531b7', varName:'name', varValue:'John'});
new web3._extend.Method({
name: 'setRegistryVar',
call: 'eth_setVarFR',
params: 1,
inputFormatter: [null]
}),
// Adds verificator to the list of verificators.
// parameters:
// VerificatorAddress - address of a verificator
// IssuedTimeStamp - verificator's license issued timestamp
// ValidUntilTimeStamp - verificator's license valid until timestamp
new web3._extend.Method({
name: 'addVerificator',
call: 'eth_addVerificator',
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({
name: 'getVerificatorsCount',
call: 'eth_getVerificatorsCount',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
outputFormatter: function (tx) {
if(tx !== null)
tx = web3.toDecimal(tx);
return tx;
}
}),
new web3._extend.Method({
name: 'getVerificatorsIndex',
call: 'eth_getVerificatorsIndex',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
}),
new web3._extend.Method({
name: 'getVerificatorAtIndex',
call: 'eth_getVerificatorAtIndex',
params: 2,
inputFormatter: [null, web3._extend.formatters.inputDefaultBlockNumberFormatter],
}),
new web3._extend.Method({
name: 'updateVerificatorLicenseExpiration',
call: 'eth_updateVerificatorLicenseExpiration',
params: 1,
inputFormatter: [null],
}),
], ],
properties: [ properties: [
new web3._extend.Property({ new web3._extend.Property({
@ -483,7 +572,7 @@ web3._extend({
} }
return formatted; return formatted;
} }
}), })
] ]
}); });
` `