mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
cleanup rebase 1.4.6
This commit is contained in:
parent
e959453cda
commit
77b280115b
7 changed files with 6 additions and 936 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
[submodule "cmd/mist/assets/ext/expanse.js"]
|
[submodule "cmd/mist/assets/ext/expanse.js"]
|
||||||
path = cmd/mist/assets/ext/expanse.js
|
path = cmd/mist/assets/ext/expanse.js
|
||||||
url = https://github.com/expanse-org/web3.js
|
url = https://github.com/expanse-project/web3.js
|
||||||
|
|
|
||||||
426
cmd/gexp/js.go
426
cmd/gexp/js.go
|
|
@ -1,426 +0,0 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
|
||||||
// Copyright 2015 go-expanse Authors
|
|
||||||
// This file is part of go-expanse.
|
|
||||||
//
|
|
||||||
// go-expanse is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// go-expanse is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with go-expanse. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"math/big"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
|
||||||
"github.com/expanse-project/go-expanse/accounts"
|
|
||||||
"github.com/expanse-project/go-expanse/cmd/utils"
|
|
||||||
"github.com/expanse-project/go-expanse/common"
|
|
||||||
"github.com/expanse-project/go-expanse/common/registrar"
|
|
||||||
"github.com/expanse-project/go-expanse/exp"
|
|
||||||
"github.com/expanse-project/go-expanse/internal/web3ext"
|
|
||||||
re "github.com/expanse-project/go-expanse/jsre"
|
|
||||||
"github.com/expanse-project/go-expanse/node"
|
|
||||||
"github.com/expanse-project/go-expanse/rpc"
|
|
||||||
"github.com/peterh/liner"
|
|
||||||
"github.com/robertkrimen/otto"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
passwordRegexp = regexp.MustCompile("personal.[nus]")
|
|
||||||
onlyws = regexp.MustCompile("^\\s*$")
|
|
||||||
exit = regexp.MustCompile("^\\s*exit\\s*;*\\s*$")
|
|
||||||
)
|
|
||||||
|
|
||||||
type jsre struct {
|
|
||||||
re *re.JSRE
|
|
||||||
stack *node.Node
|
|
||||||
wait chan *big.Int
|
|
||||||
ps1 string
|
|
||||||
atexit func()
|
|
||||||
corsDomain string
|
|
||||||
client rpc.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeCompleter(re *jsre) liner.WordCompleter {
|
|
||||||
return func(line string, pos int) (head string, completions []string, tail string) {
|
|
||||||
if len(line) == 0 || pos == 0 {
|
|
||||||
return "", nil, ""
|
|
||||||
}
|
|
||||||
// chuck data to relevant part for autocompletion, e.g. in case of nested lines exp.getBalance(exp.coinb<tab><tab>
|
|
||||||
i := 0
|
|
||||||
for i = pos - 1; i > 0; i-- {
|
|
||||||
if line[i] == '.' || (line[i] >= 'a' && line[i] <= 'z') || (line[i] >= 'A' && line[i] <= 'Z') {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if i >= 3 && line[i] == '3' && line[i-3] == 'w' && line[i-2] == 'e' && line[i-1] == 'b' {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return line[:i], re.re.CompleteKeywords(line[i:pos]), line[pos:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newLightweightJSRE(docRoot string, client rpc.Client, datadir string, interactive bool) *jsre {
|
|
||||||
js := &jsre{ps1: "> "}
|
|
||||||
js.wait = make(chan *big.Int)
|
|
||||||
js.client = client
|
|
||||||
js.re = re.New(docRoot)
|
|
||||||
if err := js.apiBindings(); err != nil {
|
|
||||||
utils.Fatalf("Unable to initialize console - %v", err)
|
|
||||||
}
|
|
||||||
js.setupInput(datadir)
|
|
||||||
return js
|
|
||||||
}
|
|
||||||
|
|
||||||
func newJSRE(stack *node.Node, docRoot, corsDomain string, client rpc.Client, interactive bool) *jsre {
|
|
||||||
js := &jsre{stack: stack, ps1: "> "}
|
|
||||||
// set default cors domain used by startRpc from CLI flag
|
|
||||||
js.corsDomain = corsDomain
|
|
||||||
js.wait = make(chan *big.Int)
|
|
||||||
js.client = client
|
|
||||||
js.re = re.New(docRoot)
|
|
||||||
if err := js.apiBindings(); err != nil {
|
|
||||||
utils.Fatalf("Unable to connect - %v", err)
|
|
||||||
}
|
|
||||||
js.setupInput(stack.DataDir())
|
|
||||||
return js
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) setupInput(datadir string) {
|
|
||||||
self.withHistory(datadir, func(hist *os.File) { utils.Stdin.ReadHistory(hist) })
|
|
||||||
utils.Stdin.SetCtrlCAborts(true)
|
|
||||||
utils.Stdin.SetWordCompleter(makeCompleter(self))
|
|
||||||
utils.Stdin.SetTabCompletionStyle(liner.TabPrints)
|
|
||||||
self.atexit = func() {
|
|
||||||
self.withHistory(datadir, func(hist *os.File) {
|
|
||||||
hist.Truncate(0)
|
|
||||||
utils.Stdin.WriteHistory(hist)
|
|
||||||
})
|
|
||||||
utils.Stdin.Close()
|
|
||||||
close(self.wait)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) batch(statement string) {
|
|
||||||
err := self.re.EvalAndPrettyPrint(statement)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%v", jsErrorString(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.atexit != nil {
|
|
||||||
self.atexit()
|
|
||||||
}
|
|
||||||
|
|
||||||
self.re.Stop(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// show summary of current gexp instance
|
|
||||||
func (self *jsre) welcome() {
|
|
||||||
self.re.Run(`
|
|
||||||
(function () {
|
|
||||||
console.log('instance: ' + web3.version.node);
|
|
||||||
console.log("coinbase: " + exp.coinbase);
|
|
||||||
var ts = 1000 * exp.getBlock(exp.blockNumber).timestamp;
|
|
||||||
console.log("at block: " + exp.blockNumber + " (" + new Date(ts) + ")");
|
|
||||||
console.log(' datadir: ' + admin.datadir);
|
|
||||||
})();
|
|
||||||
`)
|
|
||||||
if modules, err := self.supportedApis(); err == nil {
|
|
||||||
loadedModules := make([]string, 0)
|
|
||||||
for api, version := range modules {
|
|
||||||
loadedModules = append(loadedModules, fmt.Sprintf("%s:%s", api, version))
|
|
||||||
}
|
|
||||||
sort.Strings(loadedModules)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) supportedApis() (map[string]string, error) {
|
|
||||||
return self.client.SupportedModules()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (js *jsre) apiBindings() error {
|
|
||||||
apis, err := js.supportedApis()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
apiNames := make([]string, 0, len(apis))
|
|
||||||
for a, _ := range apis {
|
|
||||||
apiNames = append(apiNames, a)
|
|
||||||
}
|
|
||||||
|
|
||||||
jeth := utils.NewJeth(js.re, js.client)
|
|
||||||
js.re.Set("jeth", struct{}{})
|
|
||||||
t, _ := js.re.Get("jeth")
|
|
||||||
jethObj := t.Object()
|
|
||||||
|
|
||||||
jethObj.Set("send", jeth.Send)
|
|
||||||
jethObj.Set("sendAsync", jeth.Send)
|
|
||||||
|
|
||||||
err = js.re.Compile("bignumber.js", re.BigNumber_JS)
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Error loading bignumber.js: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = js.re.Compile("web3.js", re.Web3_JS)
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Error loading web3.js: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = js.re.Run("var Web3 = require('web3');")
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Error requiring web3: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = js.re.Run("var web3 = new Web3(jeth);")
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Error setting web3 provider: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// load only supported API's in javascript runtime
|
|
||||||
shortcuts := "var exp = web3.exp; var personal = web3.personal; "
|
|
||||||
for _, apiName := range apiNames {
|
|
||||||
if apiName == "web3" || apiName == "rpc" {
|
|
||||||
continue // manually mapped or ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
if jsFile, ok := web3ext.Modules[apiName]; ok {
|
|
||||||
if err = js.re.Compile(fmt.Sprintf("%s.js", apiName), jsFile); err == nil {
|
|
||||||
shortcuts += fmt.Sprintf("var %s = web3.%s; ", apiName, apiName)
|
|
||||||
} else {
|
|
||||||
utils.Fatalf("Error loading %s.js: %v", apiName, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = js.re.Run(shortcuts)
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Error setting namespaces: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
js.re.Run(`var GlobalRegistrar = exp.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`)
|
|
||||||
|
|
||||||
// overrule some of the methods that require password as input and ask for it interactively
|
|
||||||
p, err := js.re.Get("personal")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Unable to overrule sensitive methods in personal module")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override the unlockAccount and newAccount methods on the personal object since these require user interaction.
|
|
||||||
// Assign the jeth.unlockAccount and jeth.newAccount in the jsre the original web3 callbacks. These will be called
|
|
||||||
// by the jeth.* methods after they got the password from the user and send the original web3 request to the backend.
|
|
||||||
if persObj := p.Object(); persObj != nil { // make sure the personal api is enabled over the interface
|
|
||||||
js.re.Run(`jeth.unlockAccount = personal.unlockAccount;`)
|
|
||||||
persObj.Set("unlockAccount", jeth.UnlockAccount)
|
|
||||||
js.re.Run(`jeth.newAccount = personal.newAccount;`)
|
|
||||||
persObj.Set("newAccount", jeth.NewAccount)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer.
|
|
||||||
// Bind these if the admin module is available.
|
|
||||||
if a, err := js.re.Get("admin"); err == nil {
|
|
||||||
if adminObj := a.Object(); adminObj != nil {
|
|
||||||
adminObj.Set("sleepBlocks", jeth.SleepBlocks)
|
|
||||||
adminObj.Set("sleep", jeth.Sleep)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) AskPassword() (string, bool) {
|
|
||||||
pass, err := utils.Stdin.PasswordPrompt("Passphrase: ")
|
|
||||||
if err != nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
return pass, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) ConfirmTransaction(tx string) bool {
|
|
||||||
// Retrieve the Expanse instance from the node
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
if err := self.stack.Service(&expanse); err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// If natspec is enabled, ask for permission
|
|
||||||
if expanse.NatSpec && false /* disabled for now */ {
|
|
||||||
// notice := natspec.GetNotice(self.xeth, tx, expanse.HTTPClient())
|
|
||||||
// fmt.Println(notice)
|
|
||||||
// answer, _ := self.Prompt("Confirm Transaction [y/n]")
|
|
||||||
// return strings.HasPrefix(strings.Trim(answer, " "), "y")
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) UnlockAccount(addr []byte) bool {
|
|
||||||
fmt.Printf("Please unlock account %x.\n", addr)
|
|
||||||
pass, err := utils.Stdin.PasswordPrompt("Passphrase: ")
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// TODO: allow retry
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
if err := self.stack.Service(&expanse); err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
a := accounts.Account{Address: common.BytesToAddress(addr)}
|
|
||||||
if err := expanse.AccountManager().Unlock(a, pass); err != nil {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
fmt.Println("Account is now unlocked for this session.")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// preloadJSFiles loads JS files that the user has specified with ctx.PreLoadJSFlag into
|
|
||||||
// the JSRE. If not all files could be loaded it will return an error describing the error.
|
|
||||||
func (self *jsre) preloadJSFiles(ctx *cli.Context) error {
|
|
||||||
if ctx.GlobalString(utils.PreLoadJSFlag.Name) != "" {
|
|
||||||
assetPath := ctx.GlobalString(utils.JSpathFlag.Name)
|
|
||||||
jsFiles := strings.Split(ctx.GlobalString(utils.PreLoadJSFlag.Name), ",")
|
|
||||||
for _, file := range jsFiles {
|
|
||||||
filename := common.AbsolutePath(assetPath, strings.TrimSpace(file))
|
|
||||||
if err := self.re.Exec(filename); err != nil {
|
|
||||||
return fmt.Errorf("%s: %v", file, jsErrorString(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// jsErrorString adds a backtrace to errors generated by otto.
|
|
||||||
func jsErrorString(err error) string {
|
|
||||||
if ottoErr, ok := err.(*otto.Error); ok {
|
|
||||||
return ottoErr.String()
|
|
||||||
}
|
|
||||||
return err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) interactive() {
|
|
||||||
// Read input lines.
|
|
||||||
prompt := make(chan string)
|
|
||||||
inputln := make(chan string)
|
|
||||||
go func() {
|
|
||||||
defer close(inputln)
|
|
||||||
for {
|
|
||||||
line, err := utils.Stdin.Prompt(<-prompt)
|
|
||||||
if err != nil {
|
|
||||||
if err == liner.ErrPromptAborted { // ctrl-C
|
|
||||||
self.resetPrompt()
|
|
||||||
inputln <- ""
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
inputln <- line
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
// Wait for Ctrl-C, too.
|
|
||||||
sig := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(sig, os.Interrupt)
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if self.atexit != nil {
|
|
||||||
self.atexit()
|
|
||||||
}
|
|
||||||
self.re.Stop(false)
|
|
||||||
}()
|
|
||||||
for {
|
|
||||||
prompt <- self.ps1
|
|
||||||
select {
|
|
||||||
case <-sig:
|
|
||||||
fmt.Println("caught interrupt, exiting")
|
|
||||||
return
|
|
||||||
case input, ok := <-inputln:
|
|
||||||
if !ok || indentCount <= 0 && exit.MatchString(input) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if onlyws.MatchString(input) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
str += input + "\n"
|
|
||||||
self.setIndent()
|
|
||||||
if indentCount <= 0 {
|
|
||||||
if !excludeFromHistory(str) {
|
|
||||||
utils.Stdin.AppendHistory(str[:len(str)-1])
|
|
||||||
}
|
|
||||||
self.parseInput(str)
|
|
||||||
str = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func excludeFromHistory(input string) bool {
|
|
||||||
return len(input) == 0 || input[0] == ' ' || passwordRegexp.MatchString(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func (self *jsre) withHistory(datadir string, op func(*os.File)) {
|
|
||||||
hist, err := os.OpenFile(filepath.Join(datadir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("unable to open history file: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
op(hist)
|
|
||||||
hist.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) parseInput(code string) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
fmt.Println("[native] error", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err := self.re.EvalAndPrettyPrint(code); err != nil {
|
|
||||||
if ottoErr, ok := err.(*otto.Error); ok {
|
|
||||||
fmt.Println(ottoErr.String())
|
|
||||||
} else {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var indentCount = 0
|
|
||||||
var str = ""
|
|
||||||
|
|
||||||
func (self *jsre) resetPrompt() {
|
|
||||||
indentCount = 0
|
|
||||||
str = ""
|
|
||||||
self.ps1 = "> "
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *jsre) setIndent() {
|
|
||||||
open := strings.Count(str, "{")
|
|
||||||
open += strings.Count(str, "(")
|
|
||||||
closed := strings.Count(str, "}")
|
|
||||||
closed += strings.Count(str, ")")
|
|
||||||
indentCount = open - closed
|
|
||||||
if indentCount <= 0 {
|
|
||||||
self.ps1 = "> "
|
|
||||||
} else {
|
|
||||||
self.ps1 = strings.Join(make([]string, indentCount*2), "..")
|
|
||||||
self.ps1 += " "
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,504 +0,0 @@
|
||||||
// Copyright 2015 The go-expanse Authors
|
|
||||||
// This file is part of go-expanse.
|
|
||||||
//
|
|
||||||
// go-expanse is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// go-expanse is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with go-expanse. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
|
||||||
"runtime"
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/expanse-project/go-expanse/accounts"
|
|
||||||
"github.com/expanse-project/go-expanse/common"
|
|
||||||
"github.com/expanse-project/go-expanse/common/compiler"
|
|
||||||
"github.com/expanse-project/go-expanse/common/httpclient"
|
|
||||||
"github.com/expanse-project/go-expanse/core"
|
|
||||||
"github.com/expanse-project/go-expanse/crypto"
|
|
||||||
"github.com/expanse-project/go-expanse/eth"
|
|
||||||
"github.com/expanse-project/go-expanse/ethdb"
|
|
||||||
"github.com/expanse-project/go-expanse/node"
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
testSolcPath = ""
|
|
||||||
solcVersion = "0.9.23"
|
|
||||||
testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
|
|
||||||
testBalance = "10000000000000000000"
|
|
||||||
// of empty string
|
|
||||||
testHash = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
versionRE = regexp.MustCompile(strconv.Quote(`"compilerVersion":"` + solcVersion + `"`))
|
|
||||||
testNodeKey, _ = crypto.HexToECDSA("4b50fa71f5c3eeb8fdc452224b2395af2fcc3d125e06c32c82e048c0559db03f")
|
|
||||||
testAccount, _ = crypto.HexToECDSA("e6fab74a43941f82d89cb7faa408e227cdad3153c4720e540e855c19b15e6674")
|
|
||||||
testGenesis = `{"` + testAddress[2:] + `": {"balance": "` + testBalance + `"}}`
|
|
||||||
)
|
|
||||||
|
|
||||||
type testjethre struct {
|
|
||||||
*jsre
|
|
||||||
lastConfirm string
|
|
||||||
client *httpclient.HTTPClient
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temporary disabled while natspec hasn't been migrated
|
|
||||||
//func (self *testjethre) ConfirmTransaction(tx string) bool {
|
|
||||||
// var expanse *exp.Expanse
|
|
||||||
// self.stack.Service(&expanse)
|
|
||||||
//
|
|
||||||
// if expanse.NatSpec {
|
|
||||||
// self.lastConfirm = natspec.GetNotice(self.xeth, tx, self.client)
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
//}
|
|
||||||
|
|
||||||
func testJEthRE(t *testing.T) (string, *testjethre, *node.Node) {
|
|
||||||
return testREPL(t, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testREPL(t *testing.T, config func(*exp.Config)) (string, *testjethre, *node.Node) {
|
|
||||||
tmp, err := ioutil.TempDir("", "gexp-test")
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// Create a networkless protocol stack
|
|
||||||
stack, err := node.New(&node.Config{DataDir: tmp, PrivateKey: testNodeKey, Name: "test", NoDiscovery: true})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to create node: %v", err)
|
|
||||||
}
|
|
||||||
// Initialize and register the Expanse protocol
|
|
||||||
accman := accounts.NewPlaintextManager(filepath.Join(tmp, "keystore"))
|
|
||||||
db, _ := ethdb.NewMemDatabase()
|
|
||||||
core.WriteGenesisBlockForTesting(db, core.GenesisAccount{
|
|
||||||
Address: common.HexToAddress(testAddress),
|
|
||||||
Balance: common.String2Big(testBalance),
|
|
||||||
})
|
|
||||||
ethConf := &exp.Config{
|
|
||||||
ChainConfig: &core.ChainConfig{HomesteadBlock: new(big.Int)},
|
|
||||||
TestGenesisState: db,
|
|
||||||
AccountManager: accman,
|
|
||||||
DocRoot: "/",
|
|
||||||
SolcPath: testSolcPath,
|
|
||||||
PowTest: true,
|
|
||||||
|
|
||||||
}
|
|
||||||
if config != nil {
|
|
||||||
config(ethConf)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
|
||||||
return exp.New(ctx, ethConf)
|
|
||||||
}); err != nil {
|
|
||||||
t.Fatalf("failed to register expanse protocol: %v", err)
|
|
||||||
}
|
|
||||||
// Initialize all the keys for testing
|
|
||||||
a, err := accman.ImportECDSA(testAccount, "")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := accman.Unlock(a, ""); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// Start the node and assemble the REPL tester
|
|
||||||
if err := stack.Start(); err != nil {
|
|
||||||
t.Fatalf("failed to start test stack: %v", err)
|
|
||||||
}
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
stack.Service(&expanse)
|
|
||||||
|
|
||||||
assetPath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "expanse", "go-expanse", "cmd", "mist", "assets", "ext")
|
|
||||||
client, err := stack.Attach()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to attach to node: %v", err)
|
|
||||||
}
|
|
||||||
tf := &testjethre{client: expanse.HTTPClient()}
|
|
||||||
repl := newJSRE(stack, assetPath, "", client, false)
|
|
||||||
tf.jsre = repl
|
|
||||||
return tmp, tf, stack
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNodeInfo(t *testing.T) {
|
|
||||||
t.Skip("broken after p2p update")
|
|
||||||
tmp, repl, expanse := testJEthRE(t)
|
|
||||||
defer expanse.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
want := `{"DiscPort":0,"IP":"0.0.0.0","ListenAddr":"","Name":"test","NodeID":"4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5","NodeUrl":"enode://4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5@0.0.0.0:0","TCPPort":0,"Td":"131072"}`
|
|
||||||
checkEvalJSON(t, repl, `admin.nodeInfo`, want)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAccounts(t *testing.T) {
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
checkEvalJSON(t, repl, `exp.accounts`, `["`+testAddress+`"]`)
|
|
||||||
checkEvalJSON(t, repl, `exp.coinbase`, `"`+testAddress+`"`)
|
|
||||||
val, err := repl.re.Run(`jexp.newAccount("password")`)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("expected no error, got %v", err)
|
|
||||||
}
|
|
||||||
addr := val.String()
|
|
||||||
if !regexp.MustCompile(`0x[0-9a-f]{40}`).MatchString(addr) {
|
|
||||||
t.Errorf("address not hex: %q", addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEvalJSON(t, repl, `exp.accounts`, `["`+testAddress+`","`+addr+`"]`)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBlockChain(t *testing.T) {
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
// get current block dump before export/import.
|
|
||||||
val, err := repl.re.Run("JSON.stringify(debug.dumpBlock(exp.blockNumber))")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("expected no error, got %v", err)
|
|
||||||
}
|
|
||||||
beforeExport := val.String()
|
|
||||||
|
|
||||||
// do the export
|
|
||||||
extmp, err := ioutil.TempDir("", "gexp-test-export")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(extmp)
|
|
||||||
tmpfile := filepath.Join(extmp, "export.chain")
|
|
||||||
tmpfileq := strconv.Quote(tmpfile)
|
|
||||||
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
node.Service(&expanse)
|
|
||||||
expanse.BlockChain().Reset()
|
|
||||||
|
|
||||||
checkEvalJSON(t, repl, `admin.exportChain(`+tmpfileq+`)`, `true`)
|
|
||||||
if _, err := os.Stat(tmpfile); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check import, verify that dumpBlock gives the same result.
|
|
||||||
checkEvalJSON(t, repl, `admin.importChain(`+tmpfileq+`)`, `true`)
|
|
||||||
checkEvalJSON(t, repl, `debug.dumpBlock(exp.blockNumber)`, beforeExport)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMining(t *testing.T) {
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
checkEvalJSON(t, repl, `exp.mining`, `false`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
checkEvalJSON(t, repl, `admin.startRPC("127.0.0.1", 5004, "*", "web3,exp,net")`, `true`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCheckTestAccountBalance(t *testing.T) {
|
|
||||||
t.Skip() // i don't think it tests the correct behaviour here. it's actually testing
|
|
||||||
// internals which shouldn't be tested. This now fails because of a change in the core
|
|
||||||
// and i have no means to fix this, sorry - @obscuren
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
repl.re.Run(`primary = "` + testAddress + `"`)
|
|
||||||
checkEvalJSON(t, repl, `exp.getBalance(primary)`, `"`+testBalance+`"`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSignature(t *testing.T) {
|
|
||||||
tmp, repl, node := testJEthRE(t)
|
|
||||||
defer node.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
val, err := repl.re.Run(`exp.sign("` + testAddress + `", "` + testHash + `")`)
|
|
||||||
|
|
||||||
// This is a very preliminary test, lacking actual signature verification
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Error running js: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
output := val.String()
|
|
||||||
t.Logf("Output: %v", output)
|
|
||||||
|
|
||||||
regex := regexp.MustCompile(`^0x[0-9a-f]{130}$`)
|
|
||||||
if !regex.MatchString(output) {
|
|
||||||
t.Errorf("Signature is not 65 bytes represented in hexadecimal.")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContract(t *testing.T) {
|
|
||||||
t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand")
|
|
||||||
coinbase := common.HexToAddress(testAddress)
|
|
||||||
tmp, repl, expanse := testREPL(t, func(conf *exp.Config) {
|
|
||||||
conf.Etherbase = coinbase
|
|
||||||
conf.PowTest = true
|
|
||||||
})
|
|
||||||
if err := expanse.Start(); err != nil {
|
|
||||||
t.Errorf("error starting expanse: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer expanse.Stop()
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
// Temporary disabled while registrar isn't migrated
|
|
||||||
//reg := registrar.New(repl.xeth)
|
|
||||||
//_, err := reg.SetGlobalRegistrar("", coinbase)
|
|
||||||
//if err != nil {
|
|
||||||
// t.Errorf("error setting HashReg: %v", err)
|
|
||||||
//}
|
|
||||||
//_, err = reg.SetHashReg("", coinbase)
|
|
||||||
//if err != nil {
|
|
||||||
// t.Errorf("error setting HashReg: %v", err)
|
|
||||||
//}
|
|
||||||
//_, err = reg.SetUrlHint("", coinbase)
|
|
||||||
//if err != nil {
|
|
||||||
// t.Errorf("error setting HashReg: %v", err)
|
|
||||||
//}
|
|
||||||
/* TODO:
|
|
||||||
* lookup receipt and contract addresses by tx hash
|
|
||||||
* name registration for HashReg and UrlHint addresses
|
|
||||||
* mine those transactions
|
|
||||||
* then set once more SetHashReg SetUrlHint
|
|
||||||
*/
|
|
||||||
|
|
||||||
source := `contract test {\n` +
|
|
||||||
" /// @notice Will multiply `a` by 7." + `\n` +
|
|
||||||
` function multiply(uint a) returns(uint d) {\n` +
|
|
||||||
` return a * 7;\n` +
|
|
||||||
` }\n` +
|
|
||||||
`}\n`
|
|
||||||
|
|
||||||
if checkEvalJSON(t, repl, `admin.stopNatSpec()`, `true`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
contractInfo, err := ioutil.ReadFile("info_test.json")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("%v", err)
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `primary = exp.accounts[0]`, `"`+testAddress+`"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `source = "`+source+`"`, `"`+source+`"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// if solc is found with right version, test it, otherwise read from file
|
|
||||||
sol, err := compiler.New("")
|
|
||||||
if err != nil {
|
|
||||||
t.Logf("solc not found: mocking contract compilation step")
|
|
||||||
} else if sol.Version() != solcVersion {
|
|
||||||
t.Logf("WARNING: solc different version found (%v, test written for %v, may need to update)", sol.Version(), solcVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
info, err := ioutil.ReadFile("info_test.json")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("%v", err)
|
|
||||||
}
|
|
||||||
_, err = repl.re.Run(`contract = JSON.parse(` + strconv.Quote(string(info)) + `)`)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if checkEvalJSON(t, repl, `contract = exp.compile.solidity(source).test`, string(contractInfo)) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if checkEvalJSON(t, repl, `contract.code`, `"0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if checkEvalJSON(
|
|
||||||
t, repl,
|
|
||||||
`contractaddress = exp.sendTransaction({from: primary, data: contract.code})`,
|
|
||||||
`"0x46d69d55c3c4b86a924a92c9fc4720bb7bce1d74"`,
|
|
||||||
) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !processTxs(repl, t, 8) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
callSetup := `abiDef = JSON.parse('[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}]');
|
|
||||||
Multiply7 = exp.contract(abiDef);
|
|
||||||
multiply7 = Multiply7.at(contractaddress);
|
|
||||||
`
|
|
||||||
_, err = repl.re.Run(callSetup)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error setting up contract, got %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
expNotice := ""
|
|
||||||
if repl.lastConfirm != expNotice {
|
|
||||||
t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if checkEvalJSON(t, repl, `admin.startNatSpec()`, `true`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0x4ef9088431a8033e4580d00e4eb2487275e031ff4163c7529df0ef45af17857b"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !processTxs(repl, t, 1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x46d69d55c3c4b86a924a92c9fc4720bb7bce1d74","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}`
|
|
||||||
if repl.lastConfirm != expNotice {
|
|
||||||
t.Errorf("incorrect confirmation message: expected\n%v, got\n%v", expNotice, repl.lastConfirm)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var contentHash = `"0x86d2b7cf1e72e9a7a3f8d96601f0151742a2f780f1526414304fbe413dc7f9bd"`
|
|
||||||
if sol != nil && solcVersion != sol.Version() {
|
|
||||||
modContractInfo := versionRE.ReplaceAll(contractInfo, []byte(`"compilerVersion":"`+sol.Version()+`"`))
|
|
||||||
fmt.Printf("modified contractinfo:\n%s\n", modContractInfo)
|
|
||||||
contentHash = `"` + common.ToHex(crypto.Keccak256([]byte(modContractInfo))) + `"`
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `filename = "/tmp/info.json"`, `"/tmp/info.json"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `contentHash = admin.saveInfo(contract.info, filename)`, contentHash) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `admin.register(primary, contractaddress, contentHash)`, `true`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if checkEvalJSON(t, repl, `admin.registerUrl(primary, contentHash, "file://"+filename)`, `true`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if checkEvalJSON(t, repl, `admin.startNatSpec()`, `true`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !processTxs(repl, t, 3) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0x66d7635c12ad0b231e66da2f987ca3dfdca58ffe49c6442aa55960858103fd0c"`) != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !processTxs(repl, t, 1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
expNotice = "Will multiply 6 by 7."
|
|
||||||
if repl.lastConfirm != expNotice {
|
|
||||||
t.Errorf("incorrect confirmation message: expected\n%v, got\n%v", expNotice, repl.lastConfirm)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func pendingTransactions(repl *testjethre, t *testing.T) (txc int64, err error) {
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
repl.stack.Service(&expanse)
|
|
||||||
|
|
||||||
txs := expanse.TxPool().GetTransactions()
|
|
||||||
return int64(len(txs)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func processTxs(repl *testjethre, t *testing.T, expTxc int) bool {
|
|
||||||
var txc int64
|
|
||||||
var err error
|
|
||||||
for i := 0; i < 50; i++ {
|
|
||||||
txc, err = pendingTransactions(repl, t)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error checking pending transactions: %v", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if expTxc < int(txc) {
|
|
||||||
t.Errorf("too many pending transactions: expected %v, got %v", expTxc, txc)
|
|
||||||
return false
|
|
||||||
} else if expTxc == int(txc) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
|
||||||
if int(txc) != expTxc {
|
|
||||||
t.Errorf("incorrect number of pending transactions, expected %v, got %v", expTxc, txc)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
var expanse *exp.Expanse
|
|
||||||
repl.stack.Service(&expanse)
|
|
||||||
|
|
||||||
err = expanse.StartMining(runtime.NumCPU(), "")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error mining: %v", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
defer expanse.StopMining()
|
|
||||||
|
|
||||||
timer := time.NewTimer(100 * time.Second)
|
|
||||||
blockNr := expanse.BlockChain().CurrentBlock().Number()
|
|
||||||
height := new(big.Int).Add(blockNr, big.NewInt(1))
|
|
||||||
repl.wait <- height
|
|
||||||
select {
|
|
||||||
case <-timer.C:
|
|
||||||
// if times out make sure the xeth loop does not block
|
|
||||||
go func() {
|
|
||||||
select {
|
|
||||||
case repl.wait <- nil:
|
|
||||||
case <-repl.wait:
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
case <-repl.wait:
|
|
||||||
}
|
|
||||||
txc, err = pendingTransactions(repl, t)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error checking pending transactions: %v", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if txc != 0 {
|
|
||||||
t.Errorf("%d trasactions were not mined", txc)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkEvalJSON(t *testing.T, re *testjethre, expr, want string) error {
|
|
||||||
val, err := re.re.Run("JSON.stringify(" + expr + ")")
|
|
||||||
if err == nil && val.String() != want {
|
|
||||||
err = fmt.Errorf("Output mismatch for `%s`:\ngot: %s\nwant: %s", expr, val.String(), want)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
_, file, line, _ := runtime.Caller(1)
|
|
||||||
file = filepath.Base(file)
|
|
||||||
fmt.Printf("\t%s:%d: %v\n", file, line, err)
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
@ -221,7 +221,7 @@ participating.
|
||||||
// because it is not intended to run while testing.
|
// because it is not intended to run while testing.
|
||||||
// In addition to this check, bad block reports are sent only
|
// In addition to this check, bad block reports are sent only
|
||||||
// for chains with the main network genesis block and network id 1.
|
// for chains with the main network genesis block and network id 1.
|
||||||
eth.EnableBadBlockReporting = true
|
exp.EnableBadBlockReporting = true
|
||||||
|
|
||||||
utils.SetupNetwork(ctx)
|
utils.SetupNetwork(ctx)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/expanse-project/go-expanse/core/types"
|
"github.com/expanse-project/go-expanse/core/types"
|
||||||
"github.com/expanse-project/go-expanse/logger"
|
"github.com/expanse-project/go-expanse/logger"
|
||||||
"github.com/expanse-project/go-expanse/logger/glog"
|
"github.com/expanse-project/go-expanse/logger/glog"
|
||||||
"github.comexpanse-project/go-expanse/rlp"
|
"github.com/expanse-project/go-expanse/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -2642,7 +2642,7 @@ Web3.prototype.createBatch = function () {
|
||||||
module.exports = Web3;
|
module.exports = Web3;
|
||||||
|
|
||||||
|
|
||||||
},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/property":44,"./web3/requestmanager":45,"./web3/settings":46}],23:[function(require,module,exports){
|
},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/exp":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/property":44,"./web3/requestmanager":45,"./web3/settings":46}],23:[function(require,module,exports){
|
||||||
/*
|
/*
|
||||||
This file is part of web3.js.
|
This file is part of web3.js.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3088,7 +3088,7 @@ ContractFactory.prototype.getData = function () {
|
||||||
* @param {Address} contract address
|
* @param {Address} contract address
|
||||||
*/
|
*/
|
||||||
var Contract = function (exp, abi, address) {
|
var Contract = function (exp, abi, address) {
|
||||||
this._eth = exp;
|
this._exp = exp;
|
||||||
this.transactionHash = null;
|
this.transactionHash = null;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.abi = abi;
|
this.abi = abi;
|
||||||
|
|
@ -3965,7 +3965,7 @@ var sha3 = require('../utils/sha3');
|
||||||
* This prototype should be used to call/sendTransaction to solidity functions
|
* This prototype should be used to call/sendTransaction to solidity functions
|
||||||
*/
|
*/
|
||||||
var SolidityFunction = function (exp, json, address) {
|
var SolidityFunction = function (exp, json, address) {
|
||||||
this._eth = exp;
|
this._exp = exp;
|
||||||
this._inputTypes = json.inputs.map(function (i) {
|
this._inputTypes = json.inputs.map(function (i) {
|
||||||
return i.type;
|
return i.type;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue