Skip to content

Commit

Permalink
Added _triggerConfigChange (#6025)
Browse files Browse the repository at this point in the history
* Added _triggerConfigChange

Updated CHANGELOG.md

Updated CHANGELOG.md

Signed-off-by: Parthib <parthibdutta02@gmail.com>

* Updated CHANGELOG.md

Signed-off-by: Parthib <parthibdutta02@gmail.com>

---------

Signed-off-by: Parthib <parthibdutta02@gmail.com>
Co-authored-by: Oleksii Kosynskyi <oleksii.kosynskyi@gmail.com>
Co-authored-by: Wyatt Barnes <me@wyatt.email>
Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 25, 2023
1 parent 5153961 commit 7c13a90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1471,3 +1471,4 @@ should use 4.0.1-alpha.0 for testing.
#### web3-types

- Added `filters` param to the `Filter` type (#6010)

58 changes: 9 additions & 49 deletions packages/web3-core/src/web3_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ export abstract class Web3Config
* Will set the handleRevert
*/
public set handleRevert(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'handleRevert',
oldValue: this.config.handleRevert,
newValue: val,
});
this._triggerConfigChange('handleRevert', val);
this.config.handleRevert = val;
}

Expand All @@ -144,11 +140,7 @@ export abstract class Web3Config
* Will set the default account.
*/
public set defaultAccount(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultAccount',
oldValue: this.config.defaultAccount,
newValue: val,
});
this._triggerConfigChange('defaultAccount', val);
this.config.defaultAccount = val;
}

Expand Down Expand Up @@ -176,11 +168,7 @@ export abstract class Web3Config
* - `"safe"` - String: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work network`s latest blocks.
*/
public set defaultBlock(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultBlock',
oldValue: this.config.defaultBlock,
newValue: val,
});
this._triggerConfigChange('defaultBlock', val);
this.config.defaultBlock = val;
}

Expand All @@ -197,11 +185,7 @@ export abstract class Web3Config
* Will set the transactionSendTimeout.
*/
public set transactionSendTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionSendTimeout',
oldValue: this.config.transactionSendTimeout,
newValue: val,
});
this._triggerConfigChange('transactionSendTimeout', val);
this.config.transactionSendTimeout = val;
}

Expand All @@ -217,11 +201,7 @@ export abstract class Web3Config
* Will set the transactionBlockTimeout.
*/
public set transactionBlockTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionBlockTimeout',
oldValue: this.config.transactionBlockTimeout,
newValue: val,
});
this._triggerConfigChange('transactionBlockTimeout', val);
this.config.transactionBlockTimeout = val;
}

Expand All @@ -237,12 +217,7 @@ export abstract class Web3Config
* Will set the transactionConfirmationBlocks.
*/
public set transactionConfirmationBlocks(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationBlocks',
oldValue: this.config.transactionConfirmationBlocks,
newValue: val,
});

this._triggerConfigChange('transactionConfirmationBlocks', val);
this.config.transactionConfirmationBlocks = val;
}

Expand All @@ -258,12 +233,7 @@ export abstract class Web3Config
* Will set the transactionPollingInterval.
*/
public set transactionPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionPollingInterval',
oldValue: this.config.transactionPollingInterval,
newValue: val,
});

this._triggerConfigChange('transactionPollingInterval', val);
this.config.transactionPollingInterval = val;

this.transactionReceiptPollingInterval = val;
Expand Down Expand Up @@ -298,12 +268,7 @@ export abstract class Web3Config
* Will set the transactionReceiptPollingInterval
*/
public set transactionReceiptPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionReceiptPollingInterval',
oldValue: this.config.transactionReceiptPollingInterval,
newValue: val,
});

this._triggerConfigChange('transactionReceiptPollingInterval', val);
this.config.transactionReceiptPollingInterval = val;
}

Expand All @@ -312,12 +277,7 @@ export abstract class Web3Config
}

public set transactionConfirmationPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationPollingInterval',
oldValue: this.config.transactionConfirmationPollingInterval,
newValue: val,
});

this._triggerConfigChange('transactionConfirmationPollingInterval', val);
this.config.transactionConfirmationPollingInterval = val;
}

Expand Down

0 comments on commit 7c13a90

Please sign in to comment.