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
* Update react package version
* New react hoooks for all actions exposed through api + updateAccountCenter, Update OnboardAPI type
* Update core version where needed
* Rename for better alignment with core docs
* Update export from core/import in react package, update docs
* Update signup link
* Update packages/react/README.md
* Position AC docs
type WalletInit= (helpers:WalletHelpers) => WalletModule | WalletModule[] |null;
287
+
223
288
const [
224
289
{
225
290
wallet, // the wallet that has been connected or null if not yet connected
226
291
connecting // boolean indicating if connection is in progress
227
292
},
228
293
connect, // function to call to initiate user to connect wallet
229
-
disconnect // function to call to with wallet<DisconnectOptions> to disconnect wallet
294
+
disconnect, // function to call with wallet<DisconnectOptions> to disconnect wallet
295
+
updateBalances, // function to be called with an optional array of wallet addresses connected through Onboard to update balance or empty/no params to update all connected wallets
296
+
setWalletModules // function to be called with an array of wallet modules to conditionally allow connection of wallet types i.e. setWalletModules([ledger, trezor, injected])
230
297
] =useConnectWallet()
231
298
```
232
299
@@ -264,6 +331,108 @@ const [
264
331
] =useSetChain()
265
332
```
266
333
334
+
## `useNotifications`
335
+
336
+
This hook allows the dev to access all notifications if enabled, send custom notifications and update notify <enable/disable & update transactionHandler function>
337
+
**note** requires an API key be added to the initialization, enabled by default if API key exists
type NotificationType ='pending'|'success'|'error'|'hint'
374
+
interface UpdateNotification {
375
+
(notificationObject: CustomNotification): {
376
+
dismiss: () =>void
377
+
update: UpdateNotification
378
+
}
379
+
}
380
+
type NotifyOptions = {
381
+
/**
382
+
* Defines whether to subscribe to transaction events or not
383
+
* default: true
384
+
*/
385
+
enabled?: boolean
386
+
/**
387
+
* Callback that receives all transaction events
388
+
* Return a custom notification based on the event
389
+
* Or return false to disable notification for this event
390
+
* Or return undefined for a default notification
391
+
*/
392
+
transactionHandler: (
393
+
event: EthereumTransactionData
394
+
) => TransactionHandlerReturn
395
+
396
+
const [
397
+
notifications, // the list of all notifications that update when notifications are added, updated or removed
398
+
customNotification, // a function that takes a customNotification object and allows custom notifications to be shown to the user, returns an update and dismiss callback
399
+
updateNotify // a function that takes a NotifyOptions object to allow updating of the properties
400
+
] =useNotifications()
401
+
402
+
// View notifications as they come in if you would like to handle them independent of the notification display
403
+
useEffect(() => {
404
+
console.log(notifications)
405
+
}, [notifications])
406
+
407
+
// Custom notification example
408
+
<button
409
+
className="bn-demo-button"
410
+
onClick={() => {
411
+
const { update } =
412
+
customNotification({
413
+
eventCode:'dbUpdate',
414
+
type:'hint',
415
+
message:'Custom hint notification created by the dapp',
416
+
onClick: () =>
417
+
window.open(`https://www.blocknative.com`)
418
+
})
419
+
// Update your notification example below
420
+
setTimeout(
421
+
() =>
422
+
update({
423
+
eventCode:'dbUpdateSuccess',
424
+
message:'Hint notification reason resolved!',
425
+
type:'success',
426
+
autoDismiss:5000
427
+
}),
428
+
4000
429
+
)
430
+
}}
431
+
>
432
+
Custom Hint Notification
433
+
</button>
434
+
```
435
+
267
436
## `useWallets`
268
437
269
438
This hook allows you to track the state of all the currently connected wallets.
@@ -275,3 +444,44 @@ type UseWallets = (): WalletState[]
275
444
276
445
constconnectedWallets=useWallets()
277
446
```
447
+
448
+
## `useAccountCenter`
449
+
450
+
This hook allows you to track and update the state of the AccountCenter
0 commit comments