Skip to content

Commit 959d5c4

Browse files
authored
Merge pull request #1104 from blocknative/release/2.2.0
Release 2.2.0 - Main
2 parents f22d2fc + 26fadd9 commit 959d5c4

Some content is hidden

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

46 files changed

+881
-543
lines changed

.github/ISSUE_TEMPLATE/BUG.yml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ labels: [bug]
55
assignees:
66
- taylorjdawson
77
- aaronbarnardsound
8+
- Adamj1232
9+
- mahmud-bn
810
body:
911
- type: markdown
1012
attributes:
1113
value: |
12-
Thanks for taking the time to fill out this bug report!
14+
Thanks for taking the time to fill out this bug report! Note that the more detailed the report the faster we can get the issue fixed.
15+
When possible, please provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) this will
16+
reduce the time it takes us to fix the issue.
1317
- type: textarea
1418
attributes:
1519
label: Current Behavior
@@ -25,26 +29,61 @@ body:
2529
- type: textarea
2630
attributes:
2731
label: Steps To Reproduce
28-
description: Steps to reproduce the behavior.
32+
description: Steps to reproduce the behavior. Link or paste your [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) here.
2933
placeholder: |
3034
1. In this environment...
3135
2. With this config...
3236
3. Run '...'
3337
4. See error...
3438
validations:
3539
required: false
40+
- type: dropdown
41+
attributes:
42+
label: What package is effected by this issue?
43+
options:
44+
- @web3-onboard/core
45+
- @web3-onboard/common
46+
- @web3-onboard/coinbase
47+
- @web3-onboard/decent
48+
- @web3-onboard/formatic
49+
- @web3-onboard/gnosis
50+
- @web3-onboard/injected
51+
- @web3-onboard/keepkey
52+
- @web3-onboard/keystone
53+
- @web3-onboard/ledger
54+
- @web3-onboard/magic
55+
- @web3-onboard/mew
56+
- @web3-onboard/portis
57+
- @web3-onboard/react
58+
- @web3-onboard/torus
59+
- @web3-onboard/trezor
60+
- @web3-onboard/vue
61+
- @web3-onboard/walletconnect
62+
- @web3-onboard/walletlink
63+
- @web3-onboard/web3auth
64+
- bnc-onboard (v1)
65+
validations:
66+
required: true
67+
- type: dropdown
68+
attributes:
69+
label: Is this a build or a runtime issue?
70+
multiple: true
71+
options:
72+
- Build
73+
- Runtime
74+
- N/A
75+
validations:
76+
required: true
3677
- type: input
3778
attributes:
38-
label: Onboard Version
79+
label: Package Version
3980
description: What version of Onboard are you using?
4081
validations:
4182
required: true
4283
- type: input
4384
attributes:
4485
label: Node Version
4586
description: What version of NodeJS are you running?
46-
validations:
47-
required: true
4887
- type: dropdown
4988
id: browsers
5089
attributes:
@@ -70,3 +109,11 @@ body:
70109
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
71110
validations:
72111
required: false
112+
- type: checkboxes
113+
id: terms
114+
attributes:
115+
label: Sanity Check
116+
description: Sanity check to ensure that issue has been properly filled out to reduce friction for all involved parties.
117+
options:
118+
- label: If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example).
119+
required: true

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/**/dist

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212

1313
## Quickstart
1414

15-
Install the core Onboard library and the injected wallets module to support browser extension and mobile wallets:
15+
Install the core Onboard library, the injected wallets module and optionally ethers js to support browser extension and mobile wallets:
1616

17-
`npm i @web3-onboard/core @web3-onboard/injected-wallets`
17+
**NPM**
18+
`npm i @web3-onboard/core @web3-onboard/injected-wallets ethers`
1819

19-
- [@web3-onboard/core Official NPM Documentation](https://www.npmjs.com/package/@web3-onboard/core)
20+
**Yarn**
21+
`yarn add @web3-onboard/core @web3-onboard/injected-wallets ethers`
2022

2123
Then initialize in your app:
2224

2325
```javascript
2426
import Onboard from '@web3-onboard/core'
2527
import injectedModule from '@web3-onboard/injected-wallets'
28+
import { ethers } from 'ethers'
2629

2730
const MAINNET_RPC_URL = 'https://mainnet.infura.io/v3/<INFURA_KEY>'
2831

@@ -37,17 +40,31 @@ const onboard = Onboard({
3740
label: 'Ethereum Mainnet',
3841
rpcUrl: MAINNET_RPC_URL
3942
}
40-
],
41-
appMetadata: {
42-
name: 'My App',
43-
icon: '<SVG_ICON_STRING>',
44-
description: 'My app using Onboard'
45-
}
43+
]
4644
})
4745

4846
const wallets = await onboard.connectWallet()
4947

5048
console.log(wallets)
49+
50+
if (wallets[0]) {
51+
// create an ethers provider with the last connected wallet provider
52+
const ethersProvider = new ethers.providers.Web3Provider(
53+
wallets[0].provider,
54+
'any'
55+
)
56+
57+
const signer = ethersProvider.getSigner()
58+
59+
// send a transaction with the ethers provider
60+
const txn = await signer.sendTransaction({
61+
to: '0x',
62+
value: 100000000000000
63+
})
64+
65+
const receipt = await txn.wait()
66+
console.log(receipt)
67+
}
5168
```
5269

5370
## Documentation
@@ -64,22 +81,23 @@ For full documentation, check out the README.md for each package:
6481

6582
**SDK Wallets**
6683

67-
- [Fortmatic](packages/fortmatic/README.md)
84+
- [Coinbase](packages/coinbase/README.md)
85+
- [WalletConnect](packages/walletconnect/README.md)
6886
- [Gnosis](packages/gnosis/README.md)
69-
- [MEW](packages/mew/README.md)
87+
- [Magic](packages/magic/README.md)
88+
- [Fortmatic](packages/fortmatic/README.md)
7089
- [Portis](packages/portis/README.md)
71-
- [Torus](packages/torus/README.md)
72-
- [WalletConnect](packages/walletconnect/README.md)
73-
- [WalletLink](packages/walletlink/README.md)
74-
- Magic (in active development)
90+
- [MEW](packages/mew/README.md)
91+
- [Web3Auth](packages/web3auth/README.md)
7592

7693
**Hardware Wallets**
7794

78-
- [KeepKey](packages/keepkey/README.md)
7995
- [Ledger](packages/ledger/README.md)
8096
- [Trezor](packages/trezor/README.md)
8197
- [Keystone](packages/keystone/README.md)
98+
- [KeepKey](packages/keepkey/README.md)
8299
- [D'CENT](packages/dcent/README.md)
100+
83101
**Frameworks**
84102

85103
- [React](packages/react/README.md)

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.1.0",
3+
"version": "2.2.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.5",
3+
"version": "2.0.6",
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.2"
24+
"@web3-onboard/common": "^2.1.3"
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.2",
3+
"version": "2.1.3",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",

packages/common/src/hdwallets.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type Common from '@ethereumjs/common'
22
import type { BigNumber } from 'ethers'
3-
import type { CustomNetwork } from './types'
3+
import type { CustomNetwork, EIP1193Provider, RPCResponse } from './types'
44
import type { TransactionRequest } from '@ethersproject/providers'
55

66
/**
@@ -19,18 +19,22 @@ export const getCommon = async ({
1919
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2020
// @ts-ignore
2121
const CommonConstructor: typeof Common = Common.default || Common
22+
23+
const commonOptions = {
24+
// Berlin is the minimum hardfork that will allow for EIP1559
25+
hardfork: Hardfork.Berlin,
26+
// List of supported EIPS
27+
eips: [1559]
28+
}
2229
let common: Common
2330
try {
2431
common = new CommonConstructor({
2532
chain: customNetwork || chainId,
26-
// Berlin is the minimum hardfork that will allow for EIP1559
27-
hardfork: Hardfork.Berlin,
28-
// List of supported EIPS
29-
eips: [1559]
33+
...commonOptions
3034
})
3135
} catch (e: any) {
3236
if (e.message && /Chain.*not supported/.test(e.message)) {
33-
common = CommonConstructor.custom({ chainId })
37+
common = CommonConstructor.custom({ chainId }, commonOptions)
3438
} else {
3539
throw e
3640
}
@@ -77,3 +81,34 @@ export const bigNumberFieldsToStrings = (
7781
}),
7882
transaction
7983
) as StringifiedTransactionRequest
84+
85+
/**
86+
* Helper method for hardware wallets to build an object
87+
* with a request method used for making rpc requests.
88+
* @param getRpcUrl - callback used to get the current chain's rpc url
89+
* @returns An object with a request method
90+
* to be called when making rpc requests
91+
*/
92+
export const getHardwareWalletProvider = (
93+
getRpcUrl: () => string
94+
): { request: EIP1193Provider['request'] } => ({
95+
request: ({ method, params }) =>
96+
fetch(getRpcUrl(), {
97+
method: 'POST',
98+
headers: {
99+
'Content-Type': 'application/json'
100+
},
101+
body: JSON.stringify({
102+
jsonrpc: '2.0',
103+
id: '42',
104+
method,
105+
params
106+
})
107+
}).then(async res => {
108+
const response = (await res.json()) as RPCResponse
109+
if ('error' in response) {
110+
throw response.error
111+
}
112+
return response.result
113+
})
114+
})

packages/common/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ import type {
5353
Chain,
5454
TokenSymbol,
5555
CustomNetwork,
56-
TransactionObject
56+
TransactionObject,
57+
RPCResponse
5758
} from './types'
5859

5960
export { ProviderRpcErrorCode } from './types'
@@ -62,7 +63,11 @@ export { createEIP1193Provider } from './eip-1193'
6263
export { default as accountSelect } from './account-select'
6364
export { entryModal } from './entry-modal'
6465
export { SofiaProLight, SofiaProRegular, SofiaProSemiBold } from './fonts'
65-
export { getCommon, bigNumberFieldsToStrings } from './hdwallets'
66+
export {
67+
getCommon,
68+
bigNumberFieldsToStrings,
69+
getHardwareWalletProvider
70+
} from './hdwallets'
6671

6772
export type {
6873
RequestPatch,
@@ -119,5 +124,6 @@ export type {
119124
Chain,
120125
TokenSymbol,
121126
CustomNetwork,
122-
TransactionObject
127+
TransactionObject,
128+
RPCResponse
123129
}

packages/common/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,10 @@ export interface BootstrapNode {
466466
location: string
467467
comment: string
468468
}
469+
470+
export interface RPCResponse {
471+
id: number
472+
jsonrpc: string
473+
error?: { code: number; message: string }
474+
result?: any
475+
}

0 commit comments

Comments
 (0)