1
- const querystring = require ( 'querystring' ) ;
2
1
module . exports = function ( getRequest , apiKey ) {
3
2
return {
4
3
/**
@@ -10,9 +9,10 @@ module.exports =function(getRequest, apiKey) {
10
9
eth_blockNumber ( ) {
11
10
const module = 'proxy' ;
12
11
const action = 'eth_blockNumber' ;
13
- var query = querystring . stringify ( {
12
+ const queryObject = {
14
13
module, action, apiKey
15
- } ) ;
14
+ } ;
15
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
16
16
return getRequest ( query ) ;
17
17
} ,
18
18
/**
@@ -26,9 +26,10 @@ module.exports =function(getRequest, apiKey) {
26
26
const module = 'proxy' ;
27
27
const action = 'eth_getBlockByNumber' ;
28
28
const boolean = true ;
29
- var query = querystring . stringify ( {
29
+ const queryObject = {
30
30
module, action, tag, apiKey, boolean
31
- } ) ;
31
+ } ;
32
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
32
33
return getRequest ( query ) ;
33
34
} ,
34
35
/**
@@ -42,9 +43,10 @@ module.exports =function(getRequest, apiKey) {
42
43
eth_getUncleByBlockNumberAndIndex ( tag , index ) {
43
44
const module = 'proxy' ;
44
45
const action = 'eth_getUncleByBlockNumberAndIndex' ;
45
- var query = querystring . stringify ( {
46
+ const queryObject = {
46
47
module, action, apiKey, tag, index
47
- } ) ;
48
+ } ;
49
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
48
50
return getRequest ( query ) ;
49
51
} ,
50
52
/**
@@ -57,9 +59,10 @@ module.exports =function(getRequest, apiKey) {
57
59
eth_getBlockTransactionCountByNumber ( tag ) {
58
60
const module = 'proxy' ;
59
61
const action = 'eth_getBlockTransactionCountByNumber' ;
60
- var query = querystring . stringify ( {
62
+ const queryObject = {
61
63
module, action, apiKey, tag
62
- } ) ;
64
+ } ;
65
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
63
66
return getRequest ( query ) ;
64
67
} ,
65
68
/**
@@ -72,9 +75,10 @@ module.exports =function(getRequest, apiKey) {
72
75
eth_getTransactionByHash ( txhash ) {
73
76
const module = 'proxy' ;
74
77
const action = 'eth_getTransactionByHash' ;
75
- var query = querystring . stringify ( {
78
+ const queryObject = {
76
79
module, action, apiKey, txhash
77
- } ) ;
80
+ } ;
81
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
78
82
return getRequest ( query ) ;
79
83
} ,
80
84
/**
@@ -88,9 +92,10 @@ module.exports =function(getRequest, apiKey) {
88
92
eth_getTransactionByBlockNumberAndIndex ( tag , index ) {
89
93
const module = 'proxy' ;
90
94
const action = 'eth_getTransactionByBlockNumberAndIndex' ;
91
- var query = querystring . stringify ( {
95
+ const queryObject = {
92
96
module, action, apiKey, tag, index
93
- } ) ;
97
+ } ;
98
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
94
99
return getRequest ( query ) ;
95
100
} ,
96
101
/**
@@ -103,9 +108,10 @@ module.exports =function(getRequest, apiKey) {
103
108
eth_getTransactionCount ( address ) {
104
109
const module = 'proxy' ;
105
110
const action = 'eth_getTransactionCount' ;
106
- var query = querystring . stringify ( {
111
+ const queryObject = {
107
112
module, action, apiKey, address
108
- } ) ;
113
+ } ;
114
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
109
115
return getRequest ( query ) ;
110
116
} ,
111
117
/**
@@ -118,9 +124,10 @@ module.exports =function(getRequest, apiKey) {
118
124
eth_sendRawTransaction ( hex ) {
119
125
const module = 'proxy' ;
120
126
const action = 'eth_sendRawTransaction' ;
121
- var query = querystring . stringify ( {
127
+ const queryObject = {
122
128
module, action, apiKey, hex
123
- } ) ;
129
+ } ;
130
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
124
131
return getRequest ( query ) ;
125
132
} ,
126
133
/**
@@ -133,9 +140,11 @@ module.exports =function(getRequest, apiKey) {
133
140
eth_getTransactionReceipt ( txhash ) {
134
141
const module = 'proxy' ;
135
142
const action = 'eth_getTransactionReceipt' ;
136
- var query = querystring . stringify ( {
143
+
144
+ const queryObject = {
137
145
module, action, apiKey, txhash
138
- } ) ;
146
+ } ;
147
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
139
148
return getRequest ( query ) ;
140
149
} ,
141
150
/**
@@ -150,9 +159,10 @@ module.exports =function(getRequest, apiKey) {
150
159
eth_call ( to , data , tag ) {
151
160
const module = 'proxy' ;
152
161
const action = 'eth_call' ;
153
- var query = querystring . stringify ( {
162
+ const queryObject = {
154
163
module, action, apiKey, to, data, tag
155
- } ) ;
164
+ } ;
165
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
156
166
return getRequest ( query ) ;
157
167
} ,
158
168
/**
@@ -166,9 +176,10 @@ module.exports =function(getRequest, apiKey) {
166
176
eth_getCode ( address , tag ) {
167
177
const module = 'proxy' ;
168
178
const action = 'eth_getCode' ;
169
- var query = querystring . stringify ( {
179
+ const queryObject = {
170
180
module, action, apiKey, address, tag
171
- } ) ;
181
+ } ;
182
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
172
183
return getRequest ( query ) ;
173
184
} ,
174
185
/**
@@ -183,9 +194,10 @@ module.exports =function(getRequest, apiKey) {
183
194
eth_getStorageAt ( address , position , tag ) {
184
195
const module = 'proxy' ;
185
196
const action = 'eth_getStorageAt' ;
186
- var query = querystring . stringify ( {
197
+ const queryObject = {
187
198
module, action, apiKey, address, position, tag
188
- } ) ;
199
+ }
200
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
189
201
return getRequest ( query ) ;
190
202
} ,
191
203
/**
@@ -196,9 +208,10 @@ module.exports =function(getRequest, apiKey) {
196
208
eth_gasPrice ( ) {
197
209
const module = 'proxy' ;
198
210
const action = 'eth_gasPrice' ;
199
- var query = querystring . stringify ( {
211
+ const queryObject = {
200
212
module, action, apiKey
201
- } ) ;
213
+ } ;
214
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
202
215
return getRequest ( query ) ;
203
216
} ,
204
217
/**
@@ -219,9 +232,10 @@ module.exports =function(getRequest, apiKey) {
219
232
eth_estimateGas ( to , value , gasPrice , gas ) {
220
233
const module = 'proxy' ;
221
234
const action = 'eth_estimateGas' ;
222
- var query = querystring . stringify ( {
235
+ const queryObject = {
223
236
module, action, apiKey, to, value, gasPrice, gas
224
- } ) ;
237
+ }
238
+ var query = new URLSearchParams ( queryObject ) . toString ( ) ;
225
239
return getRequest ( query ) ;
226
240
} ,
227
241
} ;
0 commit comments