Skip to content

Commit 0d6fd78

Browse files
authored
Merge pull request expanse-org#1 from ldcc/master
require webu instead web3
2 parents d362a98 + 234c581 commit 0d6fd78

File tree

21 files changed

+16813
-187
lines changed

21 files changed

+16813
-187
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This command will:
6767
download more data in exchange for avoiding processing the entire history of the HappyUC network,
6868
which is very CPU intensive.
6969
* Start up Ghuc's built-in interactive [JavaScript console](https://github.com/happyuc-project/happyuc-go/wiki/JavaScript-Console),
70-
(via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/happyuc-project/wiki/wiki/JavaScript-API)
70+
(via the trailing `console` subcommand) through which you can invoke all official [`webu` methods](https://github.com/happyuc-project/wiki/wiki/JavaScript-API)
7171
as well as Ghuc's own [management APIs](https://github.com/happyuc-project/happyuc-go/wiki/Management-APIs).
7272
This too is optional and if you leave it out you can always attach to an already running Ghuc instance
7373
with `ghuc attach`.
@@ -156,15 +156,15 @@ HTTP based JSON-RPC API options:
156156
* `--rpc` Enable the HTTP-RPC server
157157
* `--rpcaddr` HTTP-RPC server listening interface (default: "localhost")
158158
* `--rpcport` HTTP-RPC server listening port (default: 8545)
159-
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3")
159+
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,webu")
160160
* `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
161161
* `--ws` Enable the WS-RPC server
162162
* `--wsaddr` WS-RPC server listening interface (default: "localhost")
163163
* `--wsport` WS-RPC server listening port (default: 8546)
164-
* `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3")
164+
* `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,webu")
165165
* `--wsorigins` Origins from which to accept websockets requests
166166
* `--ipcdisable` Disable the IPC-RPC server
167-
* `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
167+
* `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,webu")
168168
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
169169

170170
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect

README_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This command will:
6767
download more data in exchange for avoiding processing the entire history of the HappyUC network,
6868
which is very CPU intensive.
6969
* Start up Ghuc's built-in interactive [JavaScript console](https://github.com/happyuc-project/happyuc-go/wiki/JavaScript-Console),
70-
(via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/happyuc-project/wiki/wiki/JavaScript-API)
70+
(via the trailing `console` subcommand) through which you can invoke all official [`webu` methods](https://github.com/happyuc-project/wiki/wiki/JavaScript-API)
7171
as well as Ghuc's own [management APIs](https://github.com/happyuc-project/happyuc-go/wiki/Management-APIs).
7272
This too is optional and if you leave it out you can always attach to an already running Ghuc instance
7373
with `ghuc attach`.
@@ -156,15 +156,15 @@ HTTP based JSON-RPC API options:
156156
* `--rpc` Enable the HTTP-RPC server
157157
* `--rpcaddr` HTTP-RPC server listening interface (default: "localhost")
158158
* `--rpcport` HTTP-RPC server listening port (default: 8545)
159-
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3")
159+
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,webu")
160160
* `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
161161
* `--ws` Enable the WS-RPC server
162162
* `--wsaddr` WS-RPC server listening interface (default: "localhost")
163163
* `--wsport` WS-RPC server listening port (default: 8546)
164-
* `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3")
164+
* `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,webu")
165165
* `--wsorigins` Origins from which to accept websockets requests
166166
* `--ipcdisable` Disable the IPC-RPC server
167-
* `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
167+
* `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,webu")
168168
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
169169

170170
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect

accounts/keystore/keystore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
// Package keystore implements encrypted storage of secp256k1 private keys.
1818
//
19-
// Keys are stored as encrypted JSON files according to the Web3 Secret Storage specification.
20-
// See https://github.com/happyuc-project/wiki/wiki/Web3-Secret-Storage-Definition for more information.
19+
// Keys are stored as encrypted JSON files according to the webu Secret Storage specification.
20+
// See https://github.com/happyuc-project/wiki/wiki/webu-Secret-Storage-Definition for more information.
2121
package keystore
2222

2323
import (

accounts/keystore/keystore_passphrase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
This key store behaves as KeyStorePlain with the difference that
2020
the private key is encrypted and on disk uses another JSON encoding.
2121
22-
The crypto is documented at https://github.com/happyuc-project/wiki/wiki/Web3-Secret-Storage-Definition
22+
The crypto is documented at https://github.com/happyuc-project/wiki/wiki/webu-Secret-Storage-Definition
2323
2424
*/
2525

cmd/ghuc/consolecmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func localConsole(ctx *cli.Context) error {
9292
Client: client,
9393
Preload: utils.MakeConsolePreloads(ctx),
9494
}
95-
9695
console, err := console.New(config)
9796
if err != nil {
9897
utils.Fatalf("Failed to start the JavaScript console: %v", err)

cmd/ghuc/consolecmd_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ import (
2626
"strings"
2727
"testing"
2828
"time"
29-
3029
"github.com/happyuc-project/happyuc-go/params"
3130
)
3231

3332
const (
34-
ipcAPIs = "admin:1.0 debug:1.0 huc:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
35-
httpAPIs = "huc:1.0 net:1.0 rpc:1.0 web3:1.0"
33+
ipcAPIs = "admin:1.0 debug:1.0 huc:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 webu:1.0"
34+
httpAPIs = "huc:1.0 net:1.0 rpc:1.0 webu:1.0"
3635
)
3736

3837
// Tests that a node embedded within a console can be started up properly and

cmd/pupphuc/module_dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ var dashboardContent = `
222222
<div class="clearfix"></div>
223223
</div>
224224
<div class="x_content">
225-
<p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with HappyUC enabled third party web DApps. Beside all the functionality provided by the HappyUC Wallet, Mist is an extended web-browser where loaded pages have access to the HappyUC network via a web3.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
225+
<p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with HappyUC enabled third party web DApps. Beside all the functionality provided by the HappyUC Wallet, Mist is an extended web-browser where loaded pages have access to the HappyUC network via a webu.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
226226
<p>Under the hood the browser is backed by a happyuc-go full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
227227
<br/>
228228
<p>To connect with the Mist browser, you'll need to initialize your private network first via Ghuc as Mist does not currently support calling Ghuc directly. To initialize your local chain, download <a href="/{{.GhucGenesis}}"><code>{{.GhucGenesis}}</code></a> and run:

console/bridge.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (b *bridge) SleepBlocks(call otto.FunctionCall) (response otto.Value) {
244244
throwJSException("expected number as second argument")
245245
}
246246
}
247-
// go through the console, this will allow web3 to call the appropriate
247+
// go through the console, this will allow webu to call the appropriate
248248
// callbacks if a delayed response or notification is received.
249249
blockNumber := func() int64 {
250250
result, err := call.Otto.Run("eth.blockNumber")
@@ -276,7 +276,7 @@ type jsonrpcCall struct {
276276
Params []interface{}
277277
}
278278

279-
// Send implements the web3 provider "send" method.
279+
// Send implements the webu provider "send" method.
280280
func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
281281
// Remarshal the request into a Go value.
282282
JSON, _ := call.Otto.Object("JSON")

console/console.go

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"syscall"
3030

3131
"github.com/happyuc-project/happyuc-go/internal/jsre"
32-
"github.com/happyuc-project/happyuc-go/internal/web3ext"
32+
"github.com/happyuc-project/happyuc-go/internal/webuext"
3333
"github.com/happyuc-project/happyuc-go/rpc"
3434
"github.com/mattn/go-colorable"
3535
"github.com/peterh/liner"
@@ -99,6 +99,7 @@ func New(config Config) (*Console, error) {
9999
if err := console.init(config.Preload); err != nil {
100100
return nil, err
101101
}
102+
102103
return console, nil
103104
}
104105

@@ -121,34 +122,40 @@ func (c *Console) init(preload []string) error {
121122
if err := c.jsre.Compile("bignumber.js", jsre.BigNumber_JS); err != nil {
122123
return fmt.Errorf("bignumber.js: %v", err)
123124
}
124-
if err := c.jsre.Compile("web3.js", jsre.Web3_JS); err != nil {
125-
return fmt.Errorf("web3.js: %v", err)
125+
126+
if err := c.jsre.Compile("webu.js", jsre.Webu_JS); err != nil {
127+
return fmt.Errorf("webu.js: %v", err)
126128
}
127-
if _, err := c.jsre.Run("var Web3 = require('web3');"); err != nil {
128-
return fmt.Errorf("web3 require: %v", err)
129+
130+
// TODO do require webu
131+
if _, err := c.jsre.Run("var Webu = require('web3');"); err != nil {
132+
return fmt.Errorf("webu require: %v", err)
129133
}
130-
if _, err := c.jsre.Run("var web3 = new Web3(jeth);"); err != nil {
131-
return fmt.Errorf("web3 provider: %v", err)
134+
135+
if _, err := c.jsre.Run("var webu = new Webu(jeth);"); err != nil {
136+
return fmt.Errorf("webu provider: %v", err)
132137
}
138+
133139
// Load the supported APIs into the JavaScript runtime environment
134140
apis, err := c.client.SupportedModules()
135141
if err != nil {
136142
return fmt.Errorf("api modules: %v", err)
137143
}
138-
flatten := "var eth = web3.eth; var personal = web3.personal; "
144+
145+
flatten := "var huc = webu.huc; var personal = webu.personal; "
139146
for api := range apis {
140-
if api == "web3" {
147+
if api == "webu" {
141148
continue // manually mapped or ignore
142149
}
143-
if file, ok := web3ext.Modules[api]; ok {
150+
if file, ok := webuext.Modules[api]; ok {
144151
// Load our extension for the module.
145152
if err = c.jsre.Compile(fmt.Sprintf("%s.js", api), file); err != nil {
146153
return fmt.Errorf("%s.js: %v", api, err)
147154
}
148-
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
149-
} else if obj, err := c.jsre.Run("web3." + api); err == nil && obj.IsObject() {
150-
// Enable web3.js built-in extension if available.
151-
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
155+
flatten += fmt.Sprintf("var %s = webu.%s; ", api, api)
156+
} else if obj, err := c.jsre.Run("webu." + api); err == nil && obj.IsObject() {
157+
// Enable webu.js built-in extension if available.
158+
flatten += fmt.Sprintf("var %s = webu.%s; ", api, api)
152159
}
153160
}
154161
if _, err = c.jsre.Run(flatten); err != nil {
@@ -166,8 +173,8 @@ func (c *Console) init(preload []string) error {
166173
}
167174
// Override the openWallet, unlockAccount, newAccount and sign methods since
168175
// these require user interaction. Assign these method in the Console the
169-
// original web3 callbacks. These will be called by the jeth.* methods after
170-
// they got the password from the user and send the original web3 request to
176+
// original webu callbacks. These will be called by the jeth.* methods after
177+
// they got the password from the user and send the original webu request to
171178
// the backend.
172179
if obj := personal.Object(); obj != nil { // make sure the personal api is enabled over the interface
173180
if _, err = c.jsre.Run(`jeth.openWallet = personal.openWallet;`); err != nil {
@@ -257,8 +264,8 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
257264
if line[start] == '.' || (line[start] >= 'a' && line[start] <= 'z') || (line[start] >= 'A' && line[start] <= 'Z') {
258265
continue
259266
}
260-
// Handle web3 in a special way (i.e. other numbers aren't auto completed)
261-
if start >= 3 && line[start-3:start] == "web3" {
267+
// Handle webu in a special way (i.e. other numbers aren't auto completed)
268+
if start >= 3 && line[start-3:start] == "webu" {
262269
start -= 3
263270
continue
264271
}
@@ -275,7 +282,7 @@ func (c *Console) Welcome() {
275282
// Print some generic Ghuc metadata
276283
fmt.Fprint(c.printer, "Welcome to the Ghuc JavaScript console!\n\n")
277284
c.jsre.Run(`
278-
console.log("instance: " + web3.version.node);
285+
console.log("instance: " + webu.version.node);
279286
console.log("coinbase: " + eth.coinbase);
280287
console.log("at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")");
281288
console.log(" datadir: " + admin.datadir);

core/types/transaction.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error {
150150
return err
151151
}
152152

153-
// MarshalJSON encodes the web3 RPC transaction format.
153+
// MarshalJSON encodes the webu RPC transaction format.
154154
func (tx *Transaction) MarshalJSON() ([]byte, error) {
155155
hash := tx.Hash()
156156
data := tx.data
157157
data.Hash = &hash
158158
return data.MarshalJSON()
159159
}
160160

161-
// UnmarshalJSON decodes the web3 RPC transaction format.
161+
// UnmarshalJSON decodes the webu RPC transaction format.
162162
func (tx *Transaction) UnmarshalJSON(input []byte) error {
163163
var dec txdata
164164
if err := dec.UnmarshalJSON(input); err != nil {

0 commit comments

Comments
 (0)