Skip to content

Commit 1886d03

Browse files
authored
console, internal/web3ext: remove bzz and ens extensions (bnb-chain#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.
1 parent f1069a3 commit 1886d03

2 files changed

Lines changed: 4 additions & 97 deletions

File tree

‎console/console.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,14 @@ func (c *Console) init(preload []string) error {
137137
continue // manually mapped or ignore
138138
}
139139
if file, ok := web3ext.Modules[api]; ok {
140+
// Load our extension for the module.
140141
if err = c.jsre.Compile(fmt.Sprintf("%s.js", api), file); err != nil {
141142
return fmt.Errorf("%s.js: %v", api, err)
142143
}
143144
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
145+
} else if obj, err := c.jsre.Run("web3." + api); err == nil && obj.IsObject() {
146+
// Enable web3.js built-in extension if available.
147+
flatten += fmt.Sprintf("var %s = web3.%s; ", api, api)
144148
}
145149
}
146150
if _, err = c.jsre.Run(flatten); err != nil {

‎internal/web3ext/web3ext.go‎

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ package web3ext
1919

2020
var Modules = map[string]string{
2121
"admin": Admin_JS,
22-
"bzz": Bzz_JS,
2322
"chequebook": Chequebook_JS,
2423
"debug": Debug_JS,
25-
"ens": ENS_JS,
2624
"eth": Eth_JS,
2725
"miner": Miner_JS,
2826
"net": Net_JS,
@@ -32,101 +30,6 @@ var Modules = map[string]string{
3230
"txpool": TxPool_JS,
3331
}
3432

35-
const Bzz_JS = `
36-
web3._extend({
37-
property: 'bzz',
38-
methods:
39-
[
40-
new web3._extend.Method({
41-
name: 'syncEnabled',
42-
call: 'bzz_syncEnabled',
43-
params: 1,
44-
inputFormatter: [null]
45-
}),
46-
new web3._extend.Method({
47-
name: 'swapEnabled',
48-
call: 'bzz_swapEnabled',
49-
params: 1,
50-
inputFormatter: [null]
51-
}),
52-
new web3._extend.Method({
53-
name: 'download',
54-
call: 'bzz_download',
55-
params: 2,
56-
inputFormatter: [null, null]
57-
}),
58-
new web3._extend.Method({
59-
name: 'upload',
60-
call: 'bzz_upload',
61-
params: 2,
62-
inputFormatter: [null, null]
63-
}),
64-
new web3._extend.Method({
65-
name: 'resolve',
66-
call: 'bzz_resolve',
67-
params: 1,
68-
inputFormatter: [null]
69-
}),
70-
new web3._extend.Method({
71-
name: 'get',
72-
call: 'bzz_get',
73-
params: 1,
74-
inputFormatter: [null]
75-
}),
76-
new web3._extend.Method({
77-
name: 'put',
78-
call: 'bzz_put',
79-
params: 2,
80-
inputFormatter: [null, null]
81-
}),
82-
new web3._extend.Method({
83-
name: 'modify',
84-
call: 'bzz_modify',
85-
params: 4,
86-
inputFormatter: [null, null, null, null]
87-
})
88-
],
89-
properties:
90-
[
91-
new web3._extend.Property({
92-
name: 'hive',
93-
getter: 'bzz_hive'
94-
}),
95-
new web3._extend.Property({
96-
name: 'info',
97-
getter: 'bzz_info',
98-
}),
99-
]
100-
});
101-
`
102-
103-
const ENS_JS = `
104-
web3._extend({
105-
property: 'ens',
106-
methods:
107-
[
108-
new web3._extend.Method({
109-
name: 'register',
110-
call: 'ens_register',
111-
params: 1,
112-
inputFormatter: [null]
113-
}),
114-
new web3._extend.Method({
115-
name: 'setContentHash',
116-
call: 'ens_setContentHash',
117-
params: 2,
118-
inputFormatter: [null, null]
119-
}),
120-
new web3._extend.Method({
121-
name: 'resolve',
122-
call: 'ens_resolve',
123-
params: 1,
124-
inputFormatter: [null]
125-
}),
126-
]
127-
})
128-
`
129-
13033
const Chequebook_JS = `
13134
web3._extend({
13235
property: 'chequebook',

0 commit comments

Comments
 (0)