Skip to content

Commit

Permalink
Mark apiKey init prop as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamj1232 committed Oct 17, 2024
1 parent 4aacf5a commit 413f1c4
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 41 deletions.
26 changes: 16 additions & 10 deletions docs/src/routes/docs/[...3]modules/[...1]core/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ type InitOptions {
* the Theme initialization object or set as css variable
*/
disableFontDownload?: boolean
/**
* @deprecated apiKey parameter has been deprecated and is no
* longer used within Web3-Onboard to provide notifications
*/
apiKey?: string
}

```
Expand Down Expand Up @@ -533,18 +538,18 @@ type ContainerElements = {
#### notify
Notify is a feature that provides DApps with the ability to send custom messages to the client. This document will provide you with an overview of Notify and guide you through the process of integrating it into your decentralized application (dapp). Check out the [customNotifications API docs for examples and code snippets](#customnotification).
Notify is a feature that provides DApps with the ability to send custom messages to the client. This document will provide you with an overview of Notify and guide you through the process of integrating it into your decentralized application (dapp). Check out the [customNotifications API docs for examples and code snippets](#customnotification).
<img src="{notifyImg}" alt="Transaction notifications image"/>
Notifications are by default positioned in the same location as the Account Center (if enabled) or can be positioned separately using the `position` property.
##### **Notify Configuration**
| Property | Type | Description |
| -------------------- | --------------- | ------------------------------------------------------------- |
| `enabled` | boolean | Indicates whether transaction notifications will be displayed |
| `position` | CommonPositions | Position of the notification on the screen |
| Property | Type | Description |
| ---------- | --------------- | ------------------------------------------------------------- |
| `enabled` | boolean | Indicates whether transaction notifications will be displayed |
| `position` | CommonPositions | Position of the notification on the screen |
##### **Position Options**
Expand Down Expand Up @@ -727,25 +732,25 @@ const onboard = Onboard({
notify: {
desktop: {
enabled: true,
transactionHandler: transaction => {
transactionHandler: (transaction) => {
console.log({ transaction })
if (transaction.eventCode === 'txPool') {
return {
type: 'success',
message: 'Your transaction from #1 DApp is in the mempool',
message: 'Your transaction from #1 DApp is in the mempool'
}
}
},
position: 'bottomLeft'
},
mobile: {
enabled: true,
transactionHandler: transaction => {
transactionHandler: (transaction) => {
console.log({ transaction })
if (transaction.eventCode === 'txPool') {
return {
type: 'success',
message: 'Your transaction from #1 DApp is in the mempool',
message: 'Your transaction from #1 DApp is in the mempool'
}
}
},
Expand Down Expand Up @@ -777,7 +782,8 @@ const onboard = Onboard({
},
watched: {
// Any words in brackets can be re-ordered or removed to fit your dapps desired verbiage
"txPool": "Your account is {verb} {formattedValue} {asset} {preposition} {counterpartyShortened}"
txPool:
'Your account is {verb} {formattedValue} {asset} {preposition} {counterpartyShortened}'
}
}
},
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getDevice } from './utils.js'

export let configuration: Configuration = {
svelteInstance: null,
apiKey: undefined,
device: getDevice(),
initialWalletInit: [],
gas: undefined,
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function init(options: InitOptions): OnboardAPI {
appMetadata,
i18n,
accountCenter,
apiKey,
notify,
gas,
connect,
Expand Down Expand Up @@ -235,7 +234,6 @@ function init(options: InitOptions): OnboardAPI {

updateConfiguration({
svelteInstance: app,
apiKey,
initialWalletInit: wallets,
gas,
unstoppableResolution,
Expand All @@ -244,7 +242,7 @@ function init(options: InitOptions): OnboardAPI {

appMetadata && updateAppMetadata(appMetadata)

if (apiKey && transactionPreview) {
if (transactionPreview) {
console.error(
'Transaction Preview support has been removed and is no longer supported within Web3-Onboard'
)
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ export async function replaceTransaction({
| undefined
}

const { gas, apiKey } = configuration
const { gas } = configuration
if (!gas) return
// get gas price
const [gasResult] = await gas.get({
chains: [networkToChainId[network]],
endpoint: 'blockPrices',
apiKey
endpoint: 'blockPrices'
})

const { maxFeePerGas, maxPriorityFeePerGas } =
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type gas from '@web3-onboard/gas'
import type unstoppableResolution from '@web3-onboard/unstoppable-resolution'

import type en from './i18n/en.json'
import type { EthereumTransactionData, Network } from 'bnc-sdk'
import type { Network } from 'bnc-sdk'
import type { GetEnsTextReturnType } from 'viem'
import type { Config, Connector, WagmiModuleAPI } from '@web3-onboard/wagmi'
import type wagmi from '@web3-onboard/wagmi'
Expand Down Expand Up @@ -49,8 +49,8 @@ export interface InitOptions {
*/
accountCenter?: AccountCenterOptions
/**
* Opt in to Blocknative value add services (transaction updates) by providing
* your Blocknative API key, head to https://explorer.blocknative.com/account
* @deprecated apiKey parameter has been deprecated and is no
* longer used within Web3-Onboard to provide notifications
*/
apiKey?: string
/**
Expand All @@ -72,7 +72,7 @@ export interface InitOptions {
/**
* @deprecated Transaction Preview support has ended and Transaction Preview
* is no longer supported as part of Web3-Onboard.
* Please remove from your onboard config to avoid
* Please remove from your onboard config to avoid
* console errors and un-expected behavior
*/
transactionPreview?: unknown
Expand Down Expand Up @@ -202,6 +202,10 @@ export type Configuration = {
device: Device | DeviceNotBrowser
initialWalletInit: WalletInit[]
appMetadata?: AppMetadata | null
/**
* @deprecated APIKey parameter has been deprecated and is no
* longer used within Web3-Onboard
*/
apiKey?: string
gas?: typeof gas
wagmi?: WagmiModuleAPI
Expand Down
4 changes: 0 additions & 4 deletions packages/gas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import gas from '@web3-onboard/gas'
// API key is optional and if provided allows for faster poll rates
const ethMainnetGasBlockPrices = gas.stream({
chains: ['0x1'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices'
})

Expand All @@ -35,7 +34,6 @@ setTimeout(ethGasUnsub, 10000)
// OR you can subscribe to multiple chains at once:
const gasBlockPrices = gas.stream({
chains: ['0x1', '0x89'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices',
// can override default poll rate as well
poll: 1000
Expand All @@ -54,7 +52,6 @@ setTimeout(unsubscribe, 10000)
// Can also just do a one time get rather than a stream
const gasBlockPrices = await gas.get({
chains: ['0x1', '0x89'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices'
})
```
Expand All @@ -74,7 +71,6 @@ let bnGasPrices

const ethMainnetGasBlockPrices = gas.stream({
chains: ['0x1'], // '0x89' can also be added/replaced here for Polygon gas data
apiKey: '<OPTIONAL_API_KEY>', // for faster refresh rates
endpoint: 'blockPrices'
})

Expand Down
4 changes: 2 additions & 2 deletions packages/gas/src/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function get(options: RequestOptions): Promise<GasPlatformResponse[]> {
throw invalid
}

const { chains, endpoint, apiKey } = options
const { chains, endpoint } = options

const requestUrls = chains.map(chainId =>
getRequestUrl({ chainId, apiKey, endpoint })
getRequestUrl({ chainId, endpoint })
)

return firstValueFrom(
Expand Down
1 change: 0 additions & 1 deletion packages/gas/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export type RequestEndpoint = 'blockPrices'
export type RequestOptions = {
chains: ChainId[]
endpoint: RequestEndpoint
apiKey?: string
}

export type StreamOptions = RequestOptions & { poll?: number }
Expand Down
10 changes: 2 additions & 8 deletions packages/gas/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { ChainId, RequestEndpoint } from './types.js'

export function getRequestUrl({
chainId,
endpoint,
apiKey
endpoint
}: {
chainId: ChainId
endpoint: RequestEndpoint
apiKey?: string
}): { url: string; headers: { authorization?: string } } {
switch (endpoint) {
case 'blockPrices':
Expand All @@ -16,11 +14,7 @@ export function getRequestUrl({
chainId,
16
)}`,
headers: apiKey
? {
authorization: apiKey
}
: {}
headers: {}
}
default:
throw new Error(`Unrecognized request endpoint: ${endpoint}`)
Expand Down
5 changes: 0 additions & 5 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import { init, useConnectWallet } from '@web3-onboard/react'
import injectedModule from '@web3-onboard/injected-wallets'
import { ethers } from 'ethers'

// Sign up to get your free API key at https://explorer.blocknative.com/?signup=true
// Required for Transaction Notifications and Transaction Preview
const apiKey = '1730eff0-9d50-4382-a3fe-89f0d34a2070'

const injected = injectedModule()

const infuraKey = '<INFURA_KEY>'
Expand All @@ -36,7 +32,6 @@ const rpcUrl = `https://mainnet.infura.io/v3/${infuraKey}`
// initialize Onboard
init({
// This javascript object is unordered meaning props do not require a certain order
apiKey,
wallets: [injected],
chains: [
{
Expand Down

0 comments on commit 413f1c4

Please sign in to comment.