lifinance / widget

LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
https://li.fi/widget
Apache License 2.0
127 stars 86 forks source link

feat: emit events for settings changes #312

Closed DNR500 closed 1 month ago

DNR500 commented 1 month ago

Jira: LF-10342

This PR as the settingUpdate event - this event will fire whenever the settings in the Widget are changed

Testing

Note: for testing I have been cherry-picking the addition of the WidgetEventsControl from the https://github.com/lifinance/widget/pull/309. its in this one commit. Once that PR is merged those changes will be available here as well

To test using the WidgetEventsControl

Using the event

To add a listener

widgetEvents.on(WidgetEvent.SettingUpdated, (payload) => console.log(payload))

The payload for the event will look like this...

{
  "setting": "slippage",
  "newValue": "0.4",
  "oldValue": "0.3",
  "newSettings": { ... } // all the settings values after the change
  "oldSettings": { ... } // all the settings values before the change
}

The above is for the slippage setting but each of the settings will emit an event when changed. This should cover - appearance, gasPrice, language, routePriority, enabledAutoRefuel, slippage, disabledBridges, enabledBridges, _enabledBridges, disabledExchanges, enabledExchanges and _enabledExchanges

github-actions[bot] commented 1 month ago

Hey! This is your new endopint: https://b7cae349.widget-settingsev.pages.dev

github-actions[bot] commented 1 month ago

Hey! This is your new endopint: https://d3f5bd09.widget-settingsev.pages.dev

github-actions[bot] commented 1 month ago

Hey! This is your new endopint: https://e0759c6b.widget-settingsev.pages.dev

github-actions[bot] commented 1 month ago

Hey! This is your new endopint: https://c05b5e54.widget-settingsev.pages.dev