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
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,10 @@
5
5
-**Minimal Dependencies**: All wallet dependencies are included in separate packages, so you only include the ones you want to use in your app.
6
6
-**Multiple Wallets and Accounts Connection**: Allow your users to connect multiple wallets and multiple accounts within each wallet at the same time to your app.
7
7
-**Multiple Chain Support**: Allow users to switch between chains/networks with ease.
8
+
-**Account Center**: A persistent interface to manage wallet connections and networks, with a minimal version for mobile
9
+
-**Notify**: Real-time transaction notifications for the connected wallet addresses for all transaction states
8
10
-**Wallet Provider Standardization**: All wallet modules expose a provider that is patched to be compliant with the [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193), [EIP-1102](https://eips.ethereum.org/EIPS/eip-1102), [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085) and [EIP-3326](https://ethereum-magicians.org/t/eip-3326-wallet-switchethereumchain/5471) specifications.
9
-
-**Dynamic Imports**: Supporting multiple wallets in your app requires a lot of dependencies. Onboard dynamically imports a wallet and it's dependencies only when the user selects it, so that minimal bandwidth is used.
11
+
-**Dynamic Imports**: Supporting multiple wallets in your app requires a lot of dependencies. Onboard dynamically imports a wallet and its dependencies only when the user selects it, so that minimal bandwidth is used.
token:TokenSymbol// the native token symbol, eg ETH, BNB, MATIC
50
52
color?:string// the color used to represent the chain and will be used as a background for the icon
51
53
icon?:string// the icon to represent the chain
54
+
publicRpcUrl?:string// an optional public RPC used when adding a new chain config to the wallet
55
+
blockExplorerUrl?:string// also used when adding a new config to the wallet
52
56
}
53
57
```
54
58
@@ -114,6 +118,99 @@ type AccountCenterPosition =
114
118
|'topLeft'
115
119
```
116
120
121
+
**`notify`**
122
+
Notify provides by default transaction notifications for all connected wallets on the current blockchain. When switching chains the previous chain listeners remain active for 60 seconds to allow capture and report of an remaining transactions that may be in flight.
123
+
By default transaction notifications are captured if a DAppID is provided in the Onboard config along with the Account Center being enabled.
124
+
An object that defines whether transaction notifications will display (defaults to true if an API key is provided). This object contains an `enabled` flag prop and an optional `transactionHandler` which is a callback that can disable or allow customizations of notifications.
125
+
Currently notifications are positioned in the same location as the account center (either below, if the Account Center is positioned along the top, or above if positioned on the bottom of the view).
126
+
The `transactionHandler` can react off any property of the Ethereum TransactionData returned to the callback from the event (see console.log in example init). In turn, it can return a Custom `Notification` object to define the verbiage, styling, or add functionality:
127
+
- `Notification.message` - to completely customize the message shown
128
+
- `Notification.eventCode` - handle codes in your own way - see codes here under the notify prop [default en file here](src/i18n/en.json)
129
+
- `Notification.type` - icon type displayed (see `NotificationType` below for options)
130
+
- `Notification.autoDismiss` - time (in ms) after which the notification will be dismissed. If set to `0` the notification will remain on screen until the user dismisses the notification, refreshes the page or navigates away from the site with the notifications
131
+
- `Notification.link` - add link to the transaction hash. For instance, a link to the transaction on etherscan
132
+
- `Notification.onClick()` - onClick handler for when user clicks the notification element
133
+
134
+
Notify can also be styled by using the CSS variables found below. These are setup to allow maximum customization with base styling variables setting the global theme (i.e. `--onboard-grey-600`) along with more precise component level styling variables available (`--notify-onboard-grey-600`) with the latter taking precedent if defined
135
+
136
+
If notifications are enabled the notifications can be handled through onboard app state as seen below.
Notify can be used to deliver custom DApp notifications by passing a `CustomNotification` object to the `customNotification` action. This will return an `UpdateNotification` type.
191
+
This `UpdateNotification` will return an `update` function that can be passed a new `CustomNotification` to update the existing notification.
192
+
The `customNotification` method also returns a `dismiss` method that is called without any parameters to dismiss the notification.
193
+
194
+
```typescript
195
+
const { update, dismiss } =
196
+
onboard.state.actions.customNotification({
197
+
type: 'pending',
198
+
message:
199
+
'This is a custom DApp pending notification to use however you want',
200
+
autoDismiss: 0
201
+
})
202
+
setTimeout(
203
+
() =>
204
+
update({
205
+
eventCode: 'dbUpdateSuccess',
206
+
message: 'Updated status for custom notification',
207
+
type: 'success',
208
+
autoDismiss: 8000
209
+
}),
210
+
4000
211
+
)
212
+
```
213
+
117
214
### Initialization Example
118
215
119
216
Putting it all together, here is an example initialization with the injected wallet modules:
0 commit comments