diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-01-25 23:29:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-25 23:29:40 +0800 |
commit | 1886d03faa9b7d8cdf335da84c297d30c213bb69 (patch) | |
tree | 23fafe325e5832046d2fd698adb7b69b16bc8f5d | |
parent | f1069a30b9ca13769ace154ff25dfabc83f25485 (diff) | |
download | dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar.gz dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar.bz2 dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar.lz dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar.xz dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.tar.zst dexon-1886d03faa9b7d8cdf335da84c297d30c213bb69.zip |
console, internal/web3ext: remove bzz and ens extensions (#3602)
web3.js includes bzz methods and throws an error when the extension
module is reregistered. The ENS RPC API is deprecated and not exposed by
anything.
-rw-r--r-- | console/console.go | 4 | ||||
-rw-r--r-- | internal/web3ext/web3ext.go | 97 |
2 files changed, 4 insertions, 97 deletions
diff --git a/console/console.go b/console/console.go index 9bb3df926..389d52858 100644 --- a/console/console.go +++ b/console/console.go @@ -137,10 +137,14 @@ func (c *Console) init(preload []string) error { continue // manually mapped or ignore } if file, ok := web3ext.Modules[api]; ok { + // Load our extension for the module. 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) + } 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) } } if _, err = c.jsre.Run(flatten); err != nil { diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index e10e66045..edbe45fa3 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -19,10 +19,8 @@ package web3ext var Modules = map[string]string{ "admin": Admin_JS, - "bzz": Bzz_JS, "chequebook": Chequebook_JS, "debug": Debug_JS, - "ens": ENS_JS, "eth": Eth_JS, "miner": Miner_JS, "net": Net_JS, @@ -32,101 +30,6 @@ var Modules = map[string]string{ "txpool": TxPool_JS, } -const Bzz_JS = ` -web3._extend({ - property: 'bzz', - methods: - [ - new web3._extend.Method({ - name: 'syncEnabled', - call: 'bzz_syncEnabled', - params: 1, - inputFormatter: [null] - }), - new web3._extend.Method({ - name: 'swapEnabled', - call: 'bzz_swapEnabled', - params: 1, - inputFormatter: [null] - }), - new web3._extend.Method({ - name: 'download', - call: 'bzz_download', - params: 2, - inputFormatter: [null, null] - }), - new web3._extend.Method({ - name: 'upload', - call: 'bzz_upload', - params: 2, - inputFormatter: [null, null] - }), - new web3._extend.Method({ - name: 'resolve', - call: 'bzz_resolve', - params: 1, - inputFormatter: [null] - }), - new web3._extend.Method({ - name: 'get', - call: 'bzz_get', - params: 1, - inputFormatter: [null] - }), - new web3._extend.Method({ - name: 'put', - call: 'bzz_put', - params: 2, - inputFormatter: [null, null] - }), - new web3._extend.Method({ - name: 'modify', - call: 'bzz_modify', - params: 4, - inputFormatter: [null, null, null, null] - }) - ], - properties: - [ - new web3._extend.Property({ - name: 'hive', - getter: 'bzz_hive' - }), - new web3._extend.Property({ - name: 'info', - getter: 'bzz_info', - }), - ] -}); -` - -const ENS_JS = ` -web3._extend({ - property: 'ens', - methods: - [ - new web3._extend.Method({ - name: 'register', - call: 'ens_register', - params: 1, - inputFormatter: [null] - }), - new web3._extend.Method({ - name: 'setContentHash', - call: 'ens_setContentHash', - params: 2, - inputFormatter: [null, null] - }), - new web3._extend.Method({ - name: 'resolve', - call: 'ens_resolve', - params: 1, - inputFormatter: [null] - }), - ] -}) -` - const Chequebook_JS = ` web3._extend({ property: 'chequebook', |