Skip to content

Commit f22d2fc

Browse files
authored
Merge pull request #1087 from blocknative/release/2.1.0
Release: 2.1.0 (main)
2 parents 925ef0f + 2993732 commit f22d2fc

File tree

93 files changed

+2127
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2127
-427
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ jobs:
394394
- image: cimg/node:16.13.1
395395
working_directory: ~/web3-onboard-monorepo/packages/web3auth
396396
steps:
397-
- node-build-steps
397+
- node-staging-build-steps
398398
build-staging-dcent:
399399
docker:
400400
- image: cimg/node:16.13.1

.github/workflows/issue-to-notion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515
-H 'Authorization: Bearer '"$NOTION_TOKEN"'' \
1616
-H "Content-Type: application/json" \
1717
-H "Notion-Version: 2022-02-22" \
18-
--data '{"parent":{"type":"database_id","database_id":"'"$DATABASE_ID"'"},"icon":{"type":"emoji","emoji":"🐛"},"properties":{"Name":{"type":"title","title":[{"type":"text","text":{"content":"'"$TITLE"'"}}]},"Assigned":{"people":['${people:0:-1}']},"Status":{"select":{"name":"'"$STATUS"'"}},"Flag":{"multi_select":[{"name":"'"$FLAG"'"}]},"Type":{"multi_select":[{"name":"bug"}]},"Project":{"multi_select":[{"name":"'"$PROJECT_NAME"'"}]}},"children":[{"object":"block","type":"bookmark","bookmark":{"url":"'"$ISSUE_URL"'"}}]}'
18+
--data '{"parent":{"type":"database_id","database_id":"'"$DATABASE_ID"'"},"icon":{"type":"emoji","emoji":"🐛"},"properties":{"Name":{"type":"title","title":[{"type":"text","text":{"content":"'"$(echo $TITLE | tr '"' "'")"'"}}]},"Assigned":{"people":['${people:0:-1}']},"Status":{"select":{"name":"'"$STATUS"'"}},"Flag":{"multi_select":[{"name":"'"$FLAG"'"}]},"Type":{"multi_select":[{"name":"bug"}]},"Project":{"multi_select":[{"name":"'"$PROJECT_NAME"'"}]}},"children":[{"object":"block","type":"bookmark","bookmark":{"url":"'"$ISSUE_URL"'"}}]}'
1919
env:
2020
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
2121
STATE: ${{ github.event.issue.state }}
2222
ISSUE_URL: ${{ github.event.issue.html_url }}
2323
TITLE: ${{ github.event.issue.title }}
24-
FLAG: Next Sprint
24+
FLAG: Github
2525
STATUS: Backlog
2626
# Product Work Board
2727
DATABASE_ID: 29876f9a9b864ca39a984f42e17fd345

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
- **Minimal Dependencies**: All wallet dependencies are included in separate packages, so you only include the ones you want to use in your app.
66
- **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.
77
- **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
810
- **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.
1012

1113
## Quickstart
1214

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web3-onboard-monorepo",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"private": true,
55
"workspaces": [
66
"./packages/*"

packages/coinbase/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/coinbase",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "Coinbase Wallet module for web3-onboard",
55
"module": "dist/index.js",
66
"browser": "dist/index.js",
@@ -21,6 +21,6 @@
2121
},
2222
"dependencies": {
2323
"@coinbase/wallet-sdk": "^3.0.5",
24-
"@web3-onboard/common": "2.1.1"
24+
"@web3-onboard/common": "2.1.2"
2525
}
2626
}

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",

packages/common/src/elements/AddressTable.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
}
5656
5757
tbody tr:hover {
58-
background-color: var(
58+
background: var(
5959
--account-select-primary-100,
6060
var(--onboard-primary-100, var(--primary-100))
6161
);
@@ -70,7 +70,7 @@
7070
7171
.selected-row,
7272
.selected-row:hover {
73-
background-color: var(
73+
background: var(
7474
--account-select-primary-500,
7575
var(--onboard-primary-500, var(--primary-500))
7676
);

packages/common/src/elements/TableHeader.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
}
7272
7373
input:disabled {
74-
background-color: var(
74+
background: var(
7575
--account-select-gray-100,
7676
var(--onboard-gray-100, var(--gray-100))
7777
);
@@ -80,7 +80,7 @@
8080
input[type='checkbox'] {
8181
-webkit-appearance: none;
8282
width: auto;
83-
background-color: var(
83+
background: var(
8484
--account-select-white,
8585
var(--onboard-white, var(--white))
8686
);
@@ -105,7 +105,7 @@
105105
}
106106
107107
input[type='checkbox']:checked {
108-
background-color: var(
108+
background: var(
109109
--account-select-primary-500,
110110
var(--onboard-primary-500, var(--primary-500))
111111
);

packages/common/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ export interface Chain {
430430
color?: string
431431
icon?: string // svg string
432432
providerConnectionInfo?: ConnectionInfo
433+
publicRpcUrl?: string
434+
blockExplorerUrl?: string
433435
}
434436

435437
export type TokenSymbol = string // eg ETH

packages/common/src/views/AccountSelect.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
}
244244
245245
select:disabled {
246-
background-color: var(
246+
background: var(
247247
--account-select-gray-100,
248248
var(--onboard-gray-100, var(--gray-100))
249249
);
@@ -397,7 +397,7 @@
397397
right: 0.2rem;
398398
width: 2.5rem;
399399
height: 2.5rem;
400-
background-color: var(
400+
background: var(
401401
--account-select-white,
402402
var(--onboard-white, var(--white))
403403
);

packages/core/README.md

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Install the core module:
1010

1111
If you would like to support all wallets, then you can install all of the wallet modules:
1212

13-
`npm i @web3-onboard/injected-wallets @web3-onboard/coinbase @web3-onboard/ledger @web3-onboard/trezor @web3-onboard/keepkey @web3-onboard/walletconnect @web3-onboard/torus @web3-onboard/portis @web3-onboard/mew @web3-onboard/gnosis @web3-onboard/magic @web3-onboard/fortmatic`
13+
`npm i @web3-onboard/injected-wallets @web3-onboard/coinbase @web3-onboard/ledger @web3-onboard/trezor @web3-onboard/keepkey @web3-onboard/walletconnect @web3-onboard/web3auth @web3-onboard/torus @web3-onboard/portis @web3-onboard/mew @web3-onboard/gnosis @web3-onboard/magic @web3-onboard/fortmatic @web3-onboard/dcent`
1414

1515
Note:
1616

@@ -29,6 +29,8 @@ type InitOptions {
2929
appMetadata?: AppMetadata
3030
i18n?: i18nOptions
3131
accountCenter?: AccountCenterOptions
32+
apiKey?: string
33+
notify?: Partial<NotifyOptions>
3234
}
3335
```
3436

@@ -49,6 +51,8 @@ type Chain = {
4951
token: TokenSymbol // the native token symbol, eg ETH, BNB, MATIC
5052
color?: string // the color used to represent the chain and will be used as a background for the icon
5153
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
5256
}
5357
```
5458
@@ -114,6 +118,99 @@ type AccountCenterPosition =
114118
| 'topLeft'
115119
```
116120
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.
137+
```javascript
138+
const wallets = onboard.state.select('notifications')
139+
const { unsubscribe } = wallets.subscribe(update =>
140+
console.log('transaction notifications: ', update)
141+
)
142+
143+
// unsubscribe when updates are no longer needed
144+
unsubscribe()
145+
```
146+
147+
```typescript
148+
export type NotifyOptions = {
149+
enabled: boolean // default: true
150+
/**
151+
* Callback that receives all transaction events
152+
* Return a custom notification based on the event
153+
* Or return false to disable notification for this event
154+
* Or return undefined for a default notification
155+
*/
156+
transactionHandler?: (
157+
event: EthereumTransactionData
158+
) => TransactionHandlerReturn
159+
}
160+
161+
export type TransactionHandlerReturn = CustomNotification | boolean | void
162+
163+
export type CustomNotification = Partial<Omit<Notification, 'id' | 'startTime'>>
164+
165+
export type Notification = {
166+
id: string
167+
key: string
168+
type: NotificationType
169+
network: Network
170+
startTime?: number
171+
eventCode: string
172+
message: string
173+
autoDismiss: number
174+
link?: string
175+
onClick?: (event: Event) => void
176+
}
177+
178+
export type NotificationType = 'pending' | 'success' | 'error' | 'hint'
179+
180+
export declare type Network = 'main' | 'testnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'xdai' | 'bsc-main' | 'matic-main' | 'fantom-main' | 'matic-mumbai' | 'local';
181+
182+
export interface UpdateNotification {
183+
(notificationObject: CustomNotification): {
184+
dismiss: () => void
185+
update: UpdateNotification
186+
}
187+
}
188+
```
189+
190+
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+
117214
### Initialization Example
118215

119216
Putting it all together, here is an example initialization with the injected wallet modules:
@@ -174,6 +271,19 @@ const onboard = Onboard({
174271
{ name: 'Coinbase', url: 'https://wallet.coinbase.com/' }
175272
]
176273
},
274+
apiKey: 'xxx387fb-bxx1-4xxc-a0x3-9d37e426xxxx'
275+
notify: {
276+
enabled: true,
277+
transactionHandler: transaction => {
278+
console.log({ transaction })
279+
if (transaction.eventCode === 'txPool') {
280+
return {
281+
type: 'success',
282+
message: 'Your transaction from #1 DApp is in the mempool',
283+
}
284+
}
285+
}
286+
},
177287
accountCenter: {
178288
desktop: {
179289
position: 'topRight',
@@ -192,6 +302,20 @@ const onboard = Onboard({
192302
selectingWallet: {
193303
header: 'custom text header'
194304
}
305+
},
306+
notify: {
307+
transaction: {
308+
txStuck: 'custom text for this notification event'
309+
},
310+
watched: {
311+
// Any words in brackets can be re-ordered or removed to fit your dapps desired verbiage
312+
"txPool": "Your account is {verb} {formattedValue} {asset} {preposition} {counterpartyShortened}"
313+
}
314+
}
315+
},
316+
es: {
317+
transaction: {
318+
txRequest: 'Su transacción está esperando que confirme'
195319
}
196320
}
197321
}
@@ -283,6 +407,9 @@ type AppState = {
283407
chains: Chain[]
284408
accountCenter: AccountCenter
285409
walletModules: WalletModule[]
410+
locale: Locale
411+
notify: NotifyOptions
412+
notifications: Notification[]
286413
}
287414

288415
type Chain {
@@ -603,6 +730,19 @@ The Onboard styles can customized via [CSS variables](https://developer.mozilla.
603730
/* SPACING */
604731
--account-select-modal-margin-4: 1rem;
605732
--account-select-modal-margin-5: 0.5rem;
733+
734+
/* notify STYLES */
735+
--notify-onboard-font-family-normal
736+
--notify-onboard-font-size-5
737+
--notify-onboard-gray-300
738+
--notify-onboard-gray-600
739+
--notify-onboard-border-radius
740+
--notify-onboard-font-size-7
741+
--notify-onboard-font-size-6
742+
--notify-onboard-line-height-4
743+
--notify-onboard-primary-100
744+
--notify-onboard-primary-400
745+
--notify-onboard-main-padding
606746
}
607747
```
608748

packages/core/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.2.12",
3+
"version": "2.3.0",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",
@@ -41,13 +41,16 @@
4141
"typescript": "^4.5.5"
4242
},
4343
"dependencies": {
44-
"@web3-onboard/common": "^2.1.1",
44+
"@web3-onboard/common": "^2.1.2",
45+
"bignumber.js": "^9.0.0",
46+
"bnc-sdk": "^4.4.1",
4547
"bowser": "^2.11.0",
4648
"ethers": "5.5.3",
4749
"eventemitter3": "^4.0.7",
4850
"joi": "17.6.0",
4951
"lodash.merge": "^4.6.2",
5052
"lodash.partition": "^4.6.0",
53+
"nanoid": "^4.0.0",
5154
"rxjs": "^7.5.2",
5255
"svelte": "^3.46.4",
5356
"svelte-i18n": "^3.3.13"

packages/core/rollup.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import replace from '@rollup/plugin-replace'
44
import json from '@rollup/plugin-json'
55
import sveltePreprocess from 'svelte-preprocess'
66
import typescript from '@rollup/plugin-typescript'
7-
import copy from '@rollup-extras/plugin-copy';
7+
import copy from '@rollup-extras/plugin-copy'
88

99
const production = !process.env.ROLLUP_WATCH
1010

@@ -51,6 +51,9 @@ export default {
5151
'svelte/store',
5252
'lodash.merge',
5353
'lodash.partition',
54-
'eventemitter3'
54+
'eventemitter3',
55+
'bignumber.js',
56+
'bnc-sdk',
57+
'nanoid'
5558
]
5659
}

packages/core/src/configuration.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Configuration } from './types'
2+
import { getDevice } from './utils'
3+
4+
export let configuration: Configuration = {
5+
svelteInstance: null,
6+
appMetadata: null,
7+
apiKey: null,
8+
device: getDevice()
9+
}
10+
11+
export function updateConfiguration(update: Partial<Configuration>): void {
12+
configuration = { ...configuration, ...update }
13+
}

0 commit comments

Comments
 (0)