You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: packages/web3-core/src/web3_config.ts
+123-2Lines changed: 123 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -94,10 +94,21 @@ export abstract class Web3Config
94
94
Object.assign(this._config,options);
95
95
}
96
96
97
+
/**
98
+
* The `handleRevert` options property returns the revert reason string if enabled for the following methods:
99
+
* - web3.eth.sendTransaction()
100
+
* - web3.eth.call()
101
+
* - myContract.methods.myMethod().call()
102
+
* - myContract.methods.myMethod().send()
103
+
* Default is `false`.
104
+
*/
97
105
publicgethandleRevert(){
98
106
returnthis._config.handleRevert;
99
107
}
100
108
109
+
/**
110
+
* Will set the handleRevert
111
+
*/
101
112
publicsethandleRevert(val){
102
113
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
103
114
name: 'handleRevert',
@@ -107,10 +118,19 @@ export abstract class Web3Config
107
118
this._config.handleRevert=val;
108
119
}
109
120
121
+
/**
122
+
* This default address is used as the default `from` property, if no `from` property is specified in for the following methods:
123
+
* - web3.eth.sendTransaction()
124
+
* - web3.eth.call()
125
+
* - myContract.methods.myMethod().call()
126
+
* - myContract.methods.myMethod().send()
127
+
*/
110
128
publicgetdefaultAccount(){
111
129
returnthis._config.defaultAccount;
112
130
}
113
-
131
+
/**
132
+
* Will set the default account.
133
+
*/
114
134
publicsetdefaultAccount(val){
115
135
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
116
136
name: 'defaultAccount',
@@ -120,10 +140,30 @@ export abstract class Web3Config
120
140
this._config.defaultAccount=val;
121
141
}
122
142
143
+
/**
144
+
* The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. The default value is `"latest"`.
145
+
* - web3.eth.getBalance()
146
+
* - web3.eth.getCode()
147
+
* - web3.eth.getTransactionCount()
148
+
* - web3.eth.getStorageAt()
149
+
* - web3.eth.call()
150
+
* - myContract.methods.myMethod().call()
151
+
*
152
+
* @returns {BlockNumberOrTag}
153
+
*/
123
154
publicgetdefaultBlock(){
124
155
returnthis._config.defaultBlock;
125
156
}
126
157
158
+
/**
159
+
* Will set the default block.
160
+
*
161
+
* @param {BlockNumberOrTag} val
162
+
* - A block number
163
+
* - `"earliest"` - String: The genesis block
164
+
* - `"latest"` - String: The latest block (current head of the blockchain)
165
+
* - `"pending"` - String: The currently mined block (including pending transactions)
166
+
*/
127
167
publicsetdefaultBlock(val){
128
168
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
129
169
name: 'defaultBlock',
@@ -133,10 +173,17 @@ export abstract class Web3Config
133
173
this._config.defaultBlock=val;
134
174
}
135
175
176
+
/**
177
+
* The `transactionBlockTimeout` is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error.
178
+
* Default is `50`.
179
+
*/
136
180
publicgettransactionBlockTimeout(){
137
181
returnthis._config.transactionBlockTimeout;
138
182
}
139
183
184
+
/**
185
+
* Will set the transactionBlockTimeout.
186
+
*/
140
187
publicsettransactionBlockTimeout(val){
141
188
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
142
189
name: 'transactionBlockTimeout',
@@ -146,10 +193,17 @@ export abstract class Web3Config
146
193
this._config.transactionBlockTimeout=val;
147
194
}
148
195
196
+
/**
197
+
* This defines the number of blocks it requires until a transaction is considered confirmed.
198
+
* Default is `24`.
199
+
*/
149
200
publicgettransactionConfirmationBlocks(){
150
201
returnthis._config.transactionConfirmationBlocks;
151
202
}
152
203
204
+
/**
205
+
* Will set the transactionConfirmationBlocks.
206
+
*/
153
207
publicsettransactionConfirmationBlocks(val){
154
208
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
155
209
name: 'transactionConfirmationBlocks',
@@ -160,10 +214,17 @@ export abstract class Web3Config
160
214
this._config.transactionConfirmationBlocks=val;
161
215
}
162
216
217
+
/**
218
+
* Used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network.
219
+
* Default is `1000` ms.
220
+
*/
163
221
publicgettransactionPollingInterval(){
164
222
returnthis._config.transactionPollingInterval;
165
223
}
166
224
225
+
/**
226
+
* Will set the transactionPollingInterval.
227
+
*/
167
228
publicsettransactionPollingInterval(val){
168
229
this.emit(Web3ConfigEvent.CONFIG_CHANGE,{
169
230
name: 'transactionPollingInterval',
@@ -176,21 +237,34 @@ export abstract class Web3Config
176
237
this.transactionReceiptPollingInterval=val;
177
238
this.transactionConfirmationPollingInterval=val;
178
239
}
179
-
240
+
/**
241
+
* Used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending.
* The `transactionPollingInterval` is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network.
* The blockHeaderTimeout is used over socket-based connections. This option defines the amount seconds it should wait for “newBlockHeaders” event before falling back to polling to fetch transaction receipt.
0 commit comments