Skip to content

Commit a570c3a

Browse files
authored
Merge pull request #1904 from blocknative/release/2.24.10
Release 2.24.10
2 parents df7480f + d14ddef commit a570c3a

File tree

26 files changed

+201
-63
lines changed

26 files changed

+201
-63
lines changed

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@web3-onboard/blocto": "^2.0.0",
5656
"@web3-onboard/cede-store": "^2.1.0",
5757
"@web3-onboard/coinbase": "^2.2.5",
58-
"@web3-onboard/core": "^2.21.0",
58+
"@web3-onboard/core": "^2.21.1",
5959
"@web3-onboard/dcent": "^2.2.7",
6060
"@web3-onboard/enkrypt": "^2.0.4",
6161
"@web3-onboard/fortmatic": "^2.0.19",
@@ -64,7 +64,7 @@
6464
"@web3-onboard/gas": "^2.1.8",
6565
"@web3-onboard/gnosis": "^2.1.10",
6666
"@web3-onboard/infinity-wallet": "^2.0.4",
67-
"@web3-onboard/injected-wallets": "^2.10.2",
67+
"@web3-onboard/injected-wallets": "^2.10.6",
6868
"@web3-onboard/keepkey": "^2.3.7",
6969
"@web3-onboard/keystone": "^2.3.7",
7070
"@web3-onboard/ledger": "^2.5.1",

docs/src/routes/docs/[...3]modules/[...1]core/+page.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,15 @@ type Chain = {
156156
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
157157
// PLEASE NOTE: Some wallets require an rpcUrl, label, and token for actions such as adding a new chain.
158158
// It is recommended to include rpcUrl, label, and token for full functionality.
159-
rpcUrl?: string // Recommended to include. Used for network requests.
159+
rpcUrl?: string // Recommended to include. Used for network requests (eg Alchemy or Infura end point).
160160
label?: string // Recommended to include. Used for display, eg Ethereum Mainnet.
161161
token?: TokenSymbol // Recommended to include. The native token symbol, eg ETH, BNB, MATIC.
162162
color?: string // the color used to represent the chain and will be used as a background for the icon
163163
icon?: string // the icon to represent the chain
164164
publicRpcUrl?: string // an optional public RPC used when adding a new chain config to the wallet
165165
blockExplorerUrl?: string // also used when adding a new config to the wallet
166166
secondaryTokens?: SecondaryTokens[] // An optional array of tokens (max of 5) to be available to the dapp in the app state object per wallet within the wallet account and displayed in Account Center (if enabled)
167+
protectedRpcUrl?: string //An optional protected RPC URL - Defaults to Blocknative's private RPC aggregator to allow users to update the chain RPC within their wallet, specifically for private RPCs that protect user transactions. More information can be found at `https://docs.blocknative.com/blocknative-mev-protection/transaction-boost`
167168
}
168169

169170
interface SecondaryTokens {
@@ -415,6 +416,13 @@ type AccountCenter = {
415416
* Can be set as a global for Account Center or per interface (desktop/mobile)
416417
*/
417418
hideTransactionProtectionBtn?: boolean
419+
/**
420+
* defaults to
421+
* `docs.blocknative.com/blocknative-mev-protection/transaction-boost-alpha`
422+
* Use this property to override the default link to give users
423+
* more information about transaction protection and the RPC be set
424+
*/
425+
transactionProtectionInfoLink?: string
418426
/**
419427
* @deprecated Use top level containerElements property
420428
* with the accountCenter prop set to the desired container El. See documentation below

docs/src/routes/docs/[...4]wallets/[...11]injected/+page.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ const injected = injectedModule({
299299
- Trust - _Desktop & Mobile_
300300
- SafePal - _Desktop & Mobile_
301301
- Zerion - _Desktop & Mobile_
302-
- OKX Wallet - _Desktop_
302+
- OKX Wallet - _Desktop & Mobile_
303303
- Taho (Previously named Tally Ho wallet) - _Desktop_
304304
- Opera - _Desktop & Mobile_
305305
- Status - _Mobile_
@@ -345,6 +345,7 @@ const injected = injectedModule({
345345
- Ronin Wallet - _Desktop & Mobile_
346346
- Coin98 Wallet - _Desktop & Mobile_
347347
- SubWallet - _Desktop & Mobile_
348+
- Kayros - _Desktop_
348349

349350
## Build Environments
350351

docs/src/routes/examples/[...1]connect-wallet/+page.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const appMetadata = {
171171

172172
const web3Onboard = init({
173173
wallets,
174-
chains
174+
chains,
175175
appMetadata
176176
})
177177

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.24.9",
3+
"version": "2.24.10",
44
"private": true,
55
"workspaces": {
66
"packages": [

packages/core/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ type Chain = {
148148
publicRpcUrl?: string // an optional public RPC used when adding a new chain config to the wallet
149149
blockExplorerUrl?: string // also used when adding a new config to the wallet
150150
secondaryTokens?: SecondaryTokens[] // An optional array of tokens (max of 5) to be available to the dapp in the app state object per wallet within the wallet account and displayed in Account Center (if enabled)
151+
protectedRpcUrl?: string //An optional protected RPC URL - Defaults to Blocknative's private RPC aggregator to allow users to update the chain RPC within their wallet, specifically for private RPCs that protect user transactions. More information can be found at `https://docs.blocknative.com/blocknative-mev-protection/transaction-boost`
151152
}
152153
interface SecondaryTokens {
153154
/**
@@ -363,6 +364,16 @@ type AccountCenter = {
363364
position?: AccountCenterPosition // default: 'bottomRight'
364365
expanded?: boolean // default: true
365366
minimal?: boolean // enabled by default for mobile
367+
/**
368+
* Controls the visibility of the 'Enable Transaction Protection' button within the expanded Account Center.
369+
* - When set to false (default), the button is visible.
370+
* - When set to true, the button is hidden.
371+
* This setting can be configured globally for the Account Center, or separately for different interfaces like desktop/mobile.
372+
* defaults to `docs.blocknative.com/blocknative-mev-protection/transaction-boost-alpha`
373+
* Use this property to override the default link to give users
374+
* more information about transaction protection and the RPC be set
375+
*/
376+
transactionProtectionInfoLink?: string
366377

367378
/**
368379
* @deprecated Use top level containerElements property
@@ -381,6 +392,16 @@ type AccountCenterOptions = {
381392
* Can be set as a global for Account Center or per interface (desktop/mobile)
382393
*/
383394
hideTransactionProtectionBtn?: boolean
395+
/**
396+
* Controls the visibility of the 'Enable Transaction Protection' button within the expanded Account Center.
397+
* - When set to false (default), the button is visible.
398+
* - When set to true, the button is hidden.
399+
* This setting can be configured globally for the Account Center, or separately for different interfaces like desktop/mobile.
400+
* defaults to `docs.blocknative.com/blocknative-mev-protection/transaction-boost-alpha`
401+
* Use this property to override the default link to give users
402+
* more information about transaction protection and the RPC be set
403+
*/
404+
transactionProtectionInfoLink?: string
384405
}
385406

386407
type AccountCenterPosition =

packages/core/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/core",
3-
"version": "2.21.0",
3+
"version": "2.21.1",
44
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",

packages/core/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ export const STORAGE_KEYS = {
3737

3838
export const MOBILE_WINDOW_WIDTH = 768
3939

40-
export const BN_PROTECT_RPC_URL = 'https://rpc.blocknative.com/protect'
40+
export const BN_BOOST_RPC_URL = 'https://rpc.blocknative.com/boost'
41+
export const BN_BOOST_INFO_URL = 'https://docs.blocknative.com/blocknative-mev-protection/transaction-boost'

packages/core/src/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
},
6363
"confirmTransactionProtection": {
6464
"heading": "Enable Transaction Protection",
65-
"description": "Protect RPC Endpoints hide your transactions from front-running and sandwich bots to reduce unfavorable transaction settlement from slippage.",
65+
"description": "Protect RPC endpoints hide your transaction from front-running and sandwich bots.",
66+
"link": "Learn more",
6667
"enable": "Enable",
6768
"dismiss": "Dismiss"
6869
}

packages/core/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,21 @@ function init(options: InitOptions): OnboardAPI {
127127
// update accountCenter
128128
if (typeof accountCenter !== 'undefined') {
129129
let accountCenterUpdate
130-
const { hideTransactionProtectionBtn } = accountCenter
130+
const { hideTransactionProtectionBtn, transactionProtectionInfoLink } =
131+
accountCenter
131132

132133
if (device.type === 'mobile') {
133134
accountCenterUpdate = {
134135
...APP_INITIAL_STATE.accountCenter,
135136
hideTransactionProtectionBtn,
137+
transactionProtectionInfoLink,
136138
...(accountCenter.mobile ? accountCenter.mobile : {})
137139
}
138140
} else if (accountCenter.desktop) {
139141
accountCenterUpdate = {
140142
...APP_INITIAL_STATE.accountCenter,
141143
hideTransactionProtectionBtn,
144+
transactionProtectionInfoLink,
142145
...accountCenter.desktop
143146
}
144147
}

packages/core/src/provider.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,15 @@ export function trackWallet(
211211
)
212212
const account = accounts.find(account => account.address === address)
213213

214+
const ensChain = chains.find(
215+
({ id }) => id === validEnsChain(connectedWalletChain.id)
216+
)
217+
214218
const ensProm =
215219
account && account.ens
216220
? Promise.resolve(account.ens)
217-
: validEnsChain(connectedWalletChain.id)
218-
? getEns(address, chain)
221+
: ensChain
222+
? getEns(address, ensChain)
219223
: Promise.resolve(null)
220224

221225
const unsProm =
@@ -320,13 +324,16 @@ export function trackWallet(
320324
address,
321325
chain
322326
)
327+
const ensChain = chains.find(
328+
({ id }) => id === validEnsChain(chainId)
329+
)
323330

324-
const ensProm = validEnsChain(chainId)
325-
? getEns(address, chain)
331+
const ensProm = ensChain
332+
? getEns(address, ensChain)
326333
: Promise.resolve(null)
327334

328335
const unsProm = validEnsChain(chainId)
329-
? getUns(address, chain)
336+
? getUns(address, ensChain)
330337
: Promise.resolve(null)
331338

332339
const [balance, ens, uns, secondaryTokens] = await Promise.all([

packages/core/src/types.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export type ConnectModalOptions = {
249249
*/
250250
removeWhereIsMyWalletWarning?: boolean
251251
/**
252-
* Hide the "I don't have a wallet" link displayed
252+
* Hide the "I don't have a wallet" link displayed
253253
* on the left panel of the connect modal
254254
*/
255255
removeIDontHaveAWalletInfoLink?: boolean
@@ -281,6 +281,19 @@ export type AccountCenter = {
281281
* Can be set as a global for Account Center or per interface (desktop/mobile)
282282
*/
283283
hideTransactionProtectionBtn?: boolean
284+
/**
285+
* Controls the visibility of the 'Enable Transaction Protection' button
286+
* within the expanded Account Center.
287+
* - When set to false (default), the button is visible.
288+
* - When set to true, the button is hidden.
289+
* This setting can be configured globally for the Account Center, or
290+
* separately for different interfaces like desktop/mobile.
291+
* defaults to
292+
* `docs.blocknative.com/blocknative-mev-protection/transaction-boost-alpha`
293+
* Use this property to override the default link to give users
294+
* more information about transaction protection and the RPC be set
295+
*/
296+
transactionProtectionInfoLink?: string
284297
position?: AccountCenterPosition
285298
expanded?: boolean
286299
minimal?: boolean
@@ -294,6 +307,19 @@ export type AccountCenter = {
294307
export type AccountCenterOptions = {
295308
desktop: Omit<AccountCenter, 'expanded'>
296309
mobile: Omit<AccountCenter, 'expanded'>
310+
/**
311+
* Controls the visibility of the 'Enable Transaction Protection' button
312+
* within the expanded Account Center.
313+
* - When set to false (default), the button is visible.
314+
* - When set to true, the button is hidden.
315+
* This setting can be configured globally for the Account Center, or
316+
* separately for different interfaces like desktop/mobile.
317+
* defaults to
318+
* `docs.blocknative.com/blocknative-mev-protection/transaction-boost-alpha`
319+
* Use this property to override the default link to give users
320+
* more information about transaction protection and the RPC be set
321+
*/
322+
transactionProtectionInfoLink?: string
297323
/**
298324
* false by default - This allows removal of the
299325
* Enable Transaction Protection' button within the Account Center

packages/core/src/utils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,21 @@ export function getDevice(): Device | DeviceNotBrowser {
6262
export const notNullish = <T>(value: T | null | undefined): value is T =>
6363
value != null
6464

65-
export function validEnsChain(chainId: ChainId): boolean {
65+
export function validEnsChain(chainId: ChainId): ChainId | null {
66+
// return L2s as Eth for ens resolution
6667
switch (chainId) {
6768
case '0x1':
68-
case '0x3':
69-
case '0x4':
70-
case '0x5':
71-
return true
69+
case '0x89': // Polygon
70+
case '0xa': //Optimism
71+
case '0xa4b1': // Arb
72+
case '0x144': // zksync
73+
return '0x1'
74+
case '0x5': // Goerli
75+
return chainId
76+
case '0xaa36a7': // Sepolia
77+
return chainId
7278
default:
73-
return false
79+
return null
7480
}
7581
}
7682

packages/core/src/validation.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ const accountCenterInitOptions = Joi.object({
183183
position: commonPositions,
184184
minimal: Joi.boolean(),
185185
containerElement: Joi.string(),
186-
hideTransactionProtectionBtn: Joi.boolean()
186+
hideTransactionProtectionBtn: Joi.boolean(),
187+
transactionProtectionInfoLink: Joi.string()
187188
})
188189

189190
const accountCenter = Joi.object({
@@ -192,6 +193,7 @@ const accountCenter = Joi.object({
192193
expanded: Joi.boolean(),
193194
minimal: Joi.boolean(),
194195
hideTransactionProtectionBtn: Joi.boolean(),
196+
transactionProtectionInfoLink: Joi.string(),
195197
containerElement: Joi.string()
196198
})
197199

@@ -235,7 +237,8 @@ const initOptions = Joi.object({
235237
accountCenter: Joi.object({
236238
desktop: accountCenterInitOptions,
237239
mobile: accountCenterInitOptions,
238-
hideTransactionProtectionBtn: Joi.boolean()
240+
hideTransactionProtectionBtn: Joi.boolean(),
241+
transactionProtectionInfoLink: Joi.string()
239242
}),
240243
notify: [notifyOptions, notify],
241244
gas: Joi.object({
@@ -255,14 +258,13 @@ const initOptions = Joi.object({
255258
})
256259

257260
const connectOptions = Joi.object({
258-
autoSelect: Joi.alternatives()
259-
.try(
260-
Joi.object({
261-
label: Joi.string().required(),
262-
disableModals: Joi.boolean()
263-
}),
264-
Joi.string()
265-
)
261+
autoSelect: Joi.alternatives().try(
262+
Joi.object({
263+
label: Joi.string().required(),
264+
disableModals: Joi.boolean()
265+
}),
266+
Joi.string()
267+
)
266268
})
267269

268270
const disconnectOptions = Joi.object({

packages/core/src/views/account-center/AccountCenterPanel.svelte

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { _ } from 'svelte-i18n'
33
import { fly } from 'svelte/transition'
44
import { quartOut } from 'svelte/easing'
5+
import { shareReplay, startWith } from 'rxjs'
6+
57
import { wallets$ } from '../../streams.js'
68
import en from '../../i18n/en.json'
79
import WalletRow from './WalletRow.svelte'
@@ -22,12 +24,11 @@
2224
import shieldIcon from '../../icons/shield-icon.js'
2325
import { poweredByBlocknative } from '../../icons/index.js'
2426
import DisconnectAllConfirm from './DisconnectAllConfirm.svelte'
25-
import EnableTransactionProtection from './EnableTransactionProtection.svelte'
27+
import EnableTransactionProtectionModal from './EnableTransactionProtectionModal.svelte'
2628
import { configuration } from '../../configuration.js'
2729
import SecondaryTokenTable from './SecondaryTokenTable.svelte'
28-
import { shareReplay, startWith } from 'rxjs'
2930
import { updateChainRPC } from '../../provider.js'
30-
import { BN_PROTECT_RPC_URL } from '../../constants.js'
31+
import { BN_BOOST_RPC_URL, BN_BOOST_INFO_URL } from '../../constants.js'
3132
3233
export let expanded: boolean
3334
@@ -75,7 +76,7 @@
7576
await updateChainRPC(
7677
primaryWallet.provider,
7778
validAppChain,
78-
BN_PROTECT_RPC_URL
79+
validAppChain?.protectedRpcUrl || BN_BOOST_RPC_URL
7980
)
8081
enableTransactionProtection = false
8182
} catch (error) {
@@ -328,9 +329,11 @@
328329
/>
329330
{/if}
330331
{#if enableTransactionProtection}
331-
<EnableTransactionProtection
332+
<EnableTransactionProtectionModal
332333
onDismiss={() => (enableTransactionProtection = false)}
333334
onEnable={() => enableProtectionRPC()}
335+
infoLink={$accountCenter$.transactionProtectionInfoLink ||
336+
BN_BOOST_INFO_URL}
334337
/>
335338
{/if}
336339

@@ -457,8 +460,8 @@
457460
</div>
458461
</div>
459462
</div>
460-
<!-- Only display on Eth Mainnet -->
461-
{#if !$accountCenter$.hideTransactionProtectionBtn && primaryWalletOnMainnet}
463+
<!-- Only display on Eth Mainnet if protectedRpcUrl is not set per chain -->
464+
{#if !$accountCenter$.hideTransactionProtectionBtn && (primaryWalletOnMainnet || validAppChain?.protectedRpcUrl)}
462465
<div
463466
on:click={() => (enableTransactionProtection = true)}
464467
class="protect action-container flex items-center pointer"

0 commit comments

Comments
 (0)