Skip to content

Commit 346bdba

Browse files
leightktAdamj1232ByteZhang1024sanyu1225finessevanes
authored
Release 2.24.2 (docs) (#1792)
* update Google Analytics Script (#1770) * feat: add OneKey wallet (#1739) * feat: Support OneKey wallet * fix: OneKey docs * Update injected package.json version * Update demo package.json --------- Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * Fix: Connect view on safari mobile & Remove unnecessary validation check for autoSelect (#1773) * working as expected * Bump versions * Remove testing css * Remove testing code from demo * feat: add blocto wallet (#1699) * Release 2.24.1 (develop) (#1776) * Release 2.24.1 (#1777) * Update +page.md (#1775) * Feature- update appMetadata (#1779) * update versions * Upgrade wallet connect v2 packages (#1788) --------- Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> Co-authored-by: ByteZhang <ByteZhang@protonmail.com> Co-authored-by: jimmy.pan <pan831225@gmail.com> Co-authored-by: vanes <vanessa.mercado24@gmail.com>
1 parent 895e056 commit 346bdba

30 files changed

+247
-96
lines changed

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@web3-onboard/blocto": "^2.0.0-alpha.1",
5353
"@web3-onboard/cede-store": "^2.0.2",
5454
"@web3-onboard/coinbase": "^2.2.4",
55-
"@web3-onboard/core": "^2.20.2-alpha.1",
55+
"@web3-onboard/core": "^2.20.3-alpha.1",
5656
"@web3-onboard/dcent": "^2.2.7",
5757
"@web3-onboard/enkrypt": "^2.0.4",
5858
"@web3-onboard/fortmatic": "^2.0.19",
@@ -61,7 +61,7 @@
6161
"@web3-onboard/gas": "^2.1.8",
6262
"@web3-onboard/gnosis": "^2.1.10",
6363
"@web3-onboard/infinity-wallet": "^2.0.4",
64-
"@web3-onboard/injected-wallets": "^2.10.1-alpha.1",
64+
"@web3-onboard/injected-wallets": "^2.10.1",
6565
"@web3-onboard/keepkey": "^2.3.7",
6666
"@web3-onboard/keystone": "^2.3.7",
6767
"@web3-onboard/ledger": "^2.4.6",

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ type RecommendedInjectedWallets = {
223223
}
224224
```
225225
226+
**`updateAppMetadata`**
227+
228+
If you need to update your Application Metadata after initialization, you can call the `updateAppMetadata` function with the new configuration
229+
230+
```typescript
231+
onboard.state.actions.updateAppMetadata({
232+
logo: `<svg width="100%" height="100%" viewBox="0 0 12 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0L0.0100002 6L4 10L0.0100002 14.01L0 20H12V14L8 10L12 6.01V0H0ZM10 14.5V18H2V14.5L6 10.5L10 14.5Z" fill="#929BED"/>
233+
</svg>`,
234+
description: 'Updated Description!'
235+
})
236+
```
237+
226238
---
227239
228240
#### connect

docs/src/routes/docs/[...4]wallets/[...24]walletconnect/+page.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Walletconnect
2+
title: WalletConnect
33
---
44

55
# {$frontmatter.title}
@@ -116,7 +116,16 @@ const onboard = Onboard({
116116
wallets: [
117117
walletConnect
118118
//... other wallets
119-
]
119+
],
120+
chains: [ // chains that are passed as optional chains to WC wallet after cleaning and parsing as number[]
121+
{
122+
id: '0x89',
123+
token: 'MATIC',
124+
label: 'Polygon',
125+
rpcUrl: 'https://matic-mainnet.chainstacklabs.com'
126+
}
127+
// ...
128+
]
120129
})
121130

122131
const connectedWallets = await onboard.connectWallet()

docs/yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4437,10 +4437,10 @@
44374437
"@walletconnect/window-getters" "^1.0.1"
44384438
tslib "1.14.1"
44394439

4440-
"@web3-onboard/blocto@^2.0.0":
4441-
version "2.0.0-alpha.1"
4442-
resolved "https://registry.yarnpkg.com/@web3-onboard/blocto/-/blocto-2.0.0-alpha.1.tgz#8781646d98520b80be090c622e218b9dfea12221"
4443-
integrity sha512-YBhsjkVdL6Z/SXoQeFNt5Rjj1WxlXg1oKOBOZOqfioPuMwmi8RJOLcLi7evhVUdGs5T8sYCBWg+eDeA/K6XK7w==
4440+
"@web3-onboard/blocto@^2.0.0-alpha.1":
4441+
version "2.0.0"
4442+
resolved "https://registry.yarnpkg.com/@web3-onboard/blocto/-/blocto-2.0.0.tgz#eb631e911b7c13ad11089bb3574e97b673f14463"
4443+
integrity sha512-99/YzRuE9VBXWVLI6tAKxwFvCXq7WV24a3rM76yY5yVEEeNfewh8PWQ/2Yfz71Vfi6YWVPKzGo3LHspz4caTzA==
44444444
dependencies:
44454445
"@blocto/sdk" "^0.4.6"
44464446
"@web3-onboard/common" "^2.3.1"
@@ -4470,10 +4470,10 @@
44704470
ethers "5.5.4"
44714471
joi "17.9.1"
44724472

4473-
"@web3-onboard/core@^2.20.2-alpha.1":
4474-
version "2.20.2-alpha.1"
4475-
resolved "https://registry.yarnpkg.com/@web3-onboard/core/-/core-2.20.2-alpha.1.tgz#da3618634c430ef6468e27067fc21244dac026db"
4476-
integrity sha512-9zLzGG2F9KxOBe/KTE7hGPON/kbjn2e8rDVAzP79rzn+AwO5kvPcLapBgJRbh2FlbKx2werotGTUtZNKRaFMPA==
4473+
"@web3-onboard/core@^2.20.3-alpha.1":
4474+
version "2.20.3-alpha.1"
4475+
resolved "https://registry.yarnpkg.com/@web3-onboard/core/-/core-2.20.3-alpha.1.tgz#4ffd0eb7293c6fcd05860012be9b0af9b038f169"
4476+
integrity sha512-oqcNhEcgtmxeiwMF1BIxZQHEvZwHpUSUkCRwn3gheu28UWCB3bnSSiEuH2vzH8loQEqmj4LSi/bDzGHV3LdOWA==
44774477
dependencies:
44784478
"@web3-onboard/common" "^2.3.3"
44794479
bignumber.js "^9.0.0"
@@ -4566,10 +4566,10 @@
45664566
dependencies:
45674567
"@infinitywallet/infinity-connector" "^1.0.6"
45684568

4569-
"@web3-onboard/injected-wallets@^2.10.1-alpha.1":
4570-
version "2.10.1-alpha.1"
4571-
resolved "https://registry.yarnpkg.com/@web3-onboard/injected-wallets/-/injected-wallets-2.10.1-alpha.1.tgz#2f459f3dba4ecf3eca8131bd335cffcfcf9273fc"
4572-
integrity sha512-IeDWc5VvdkypktGa40Np1hvHCmDE+BCHc+r/TpUAhn2dg/XOQQfr1v6aI8PnST546ulEzE2PwFSXUZtsosLLGQ==
4569+
"@web3-onboard/injected-wallets@^2.10.1":
4570+
version "2.10.1"
4571+
resolved "https://registry.yarnpkg.com/@web3-onboard/injected-wallets/-/injected-wallets-2.10.1.tgz#d4a45ba897c578819544805399761c61b8173166"
4572+
integrity sha512-PhmMI+RNeGowL2cfmp7/v3atrJ8KsjKXgXs6CofwMzDxQXfu1DwXdIh+Hd2Py/ZeRgOEeAehf63gftaVvfn/9g==
45734573
dependencies:
45744574
"@web3-onboard/common" "^2.3.3"
45754575
joi "17.9.1"

packages/core/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ type RecommendedInjectedWallets = {
193193
}
194194
```
195195
196+
**`updateAppMetadata`**
197+
198+
If you need to update your Application Metadata after initialization, you can call the `updateAppMetadata` function with the new configuration
199+
200+
```typescript
201+
onboard.state.actions.updateAppMetadata({
202+
logo: `<svg width="100%" height="100%" viewBox="0 0 12 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0L0.0100002 6L4 10L0.0100002 14.01L0 20H12V14L8 10L12 6.01V0H0ZM10 14.5V18H2V14.5L6 10.5L10 14.5Z" fill="#929BED"/>
203+
</svg>`,
204+
description: 'Updated Description!'
205+
})
206+
```
207+
208+
---
209+
196210
**`connect`**
197211
An object that allows for customization of the Connect Modal and accepts the type ConnectModalOptions.
198212

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.20.2",
3+
"version": "2.20.3",
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/configuration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getDevice } from './utils.js'
33

44
export let configuration: Configuration = {
55
svelteInstance: null,
6-
appMetadata: null,
76
apiKey: null,
87
device: getDevice(),
98
initialWalletInit: [],

packages/core/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export const APP_INITIAL_STATE: AppState = {
2626
connect: {
2727
showSidebar: true,
2828
disableClose: false
29-
}
29+
},
30+
appMetadata: null,
3031
}
3132

3233
export const STORAGE_KEYS = {

packages/core/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
setPrimaryWallet,
3333
setWalletModules,
3434
updateConnectModal,
35-
updateTheme
35+
updateTheme,
36+
updateAppMetadata
3637
} from './store/actions.js'
3738
import type { PatchedEIP1193Provider } from '@web3-onboard/transaction-preview'
3839
import { getBlocknativeSdk } from './services.js'
@@ -53,7 +54,8 @@ const API = {
5354
updateBalances,
5455
updateAccountCenter,
5556
setPrimaryWallet,
56-
updateTheme
57+
updateTheme,
58+
updateAppMetadata
5759
}
5860
}
5961
}
@@ -92,7 +94,7 @@ function init(options: InitOptions): OnboardAPI {
9294
const {
9395
wallets,
9496
chains,
95-
appMetadata = null,
97+
appMetadata,
9698
i18n,
9799
accountCenter,
98100
apiKey,
@@ -208,7 +210,6 @@ function init(options: InitOptions): OnboardAPI {
208210
const app = svelteInstance || mountApp(theme, disableFontDownload)
209211

210212
updateConfiguration({
211-
appMetadata,
212213
svelteInstance: app,
213214
apiKey,
214215
initialWalletInit: wallets,
@@ -217,6 +218,8 @@ function init(options: InitOptions): OnboardAPI {
217218
unstoppableResolution
218219
})
219220

221+
appMetadata && updateAppMetadata(appMetadata)
222+
220223
if (apiKey && transactionPreview) {
221224
const getBnSDK = async () => {
222225
transactionPreview.init({

packages/core/src/store/actions.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Chain, WalletInit, WalletModule } from '@web3-onboard/common'
1+
import type { AppMetadata, Chain, WalletInit, WalletModule } from '@web3-onboard/common'
22
import { nanoid } from 'nanoid'
33
import { dispatch } from './index.js'
44
import { configuration } from '../configuration.js'
@@ -29,7 +29,8 @@ import type {
2929
ConnectModalOptions,
3030
UpdateConnectModalAction,
3131
Theme,
32-
UpdateChainsAction
32+
UpdateChainsAction,
33+
UpdateAppMetadataAction
3334
} from '../types.js'
3435

3536
import {
@@ -45,7 +46,8 @@ import {
4546
validateNotify,
4647
validateConnectModalUpdate,
4748
validateUpdateTheme,
48-
validateSetChainOptions
49+
validateSetChainOptions,
50+
validateAppMetadataUpdate
4951
} from '../validation.js'
5052

5153
import {
@@ -63,7 +65,8 @@ import {
6365
REMOVE_NOTIFICATION,
6466
UPDATE_ALL_WALLETS,
6567
UPDATE_CONNECT_MODAL,
66-
UPDATE_CHAINS
68+
UPDATE_CHAINS,
69+
UPDATE_APP_METADATA
6770
} from './constants.js'
6871

6972
export function addChains(chains: Chain[]): void {
@@ -438,3 +441,20 @@ export function updateTheme(theme: Theme): void {
438441
const themingObj = returnTheme(theme)
439442
themingObj && handleThemeChange(themingObj)
440443
}
444+
445+
export function updateAppMetadata(
446+
update: AppMetadata| Partial<AppMetadata>
447+
): void {
448+
const error = validateAppMetadataUpdate(update)
449+
450+
if (error) {
451+
throw error
452+
}
453+
454+
const action = {
455+
type: UPDATE_APP_METADATA,
456+
payload: update
457+
}
458+
459+
dispatch(action as UpdateAppMetadataAction)
460+
}

packages/core/src/store/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export const UPDATE_NOTIFY = 'update_notify'
1313
export const ADD_NOTIFICATION = 'add_notification'
1414
export const REMOVE_NOTIFICATION = 'remove_notification'
1515
export const UPDATE_ALL_WALLETS = 'update_balance'
16+
export const UPDATE_APP_METADATA = 'update_app_metadata'

packages/core/src/store/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import type {
1919
RemoveNotificationAction,
2020
UpdateAllWalletsAction,
2121
UpdateConnectModalAction,
22-
UpdateChainsAction
22+
UpdateChainsAction,
23+
UpdateAppMetadataAction
2324
} from '../types.js'
2425

2526
import {
@@ -37,7 +38,8 @@ import {
3738
ADD_NOTIFICATION,
3839
REMOVE_NOTIFICATION,
3940
UPDATE_ALL_WALLETS,
40-
UPDATE_CHAINS
41+
UPDATE_CHAINS,
42+
UPDATE_APP_METADATA
4143
} from './constants.js'
4244

4345
function reducer(state: AppState, action: Action): AppState {
@@ -218,6 +220,18 @@ function reducer(state: AppState, action: Action): AppState {
218220
}
219221
}
220222

223+
case UPDATE_APP_METADATA: {
224+
const update = payload as UpdateAppMetadataAction['payload']
225+
226+
return {
227+
...state,
228+
appMetadata: {
229+
...state.appMetadata,
230+
...update
231+
}
232+
}
233+
}
234+
221235
case RESET_STORE:
222236
return APP_INITIAL_STATE
223237

packages/core/src/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export interface AppState {
179179
locale: Locale
180180
notify: Notify
181181
notifications: Notification[]
182-
connect: ConnectModalOptions
182+
connect: ConnectModalOptions,
183+
appMetadata: AppMetadata
183184
}
184185

185186
export type Configuration = {
@@ -428,7 +429,8 @@ export type Action =
428429
| AddNotificationAction
429430
| RemoveNotificationAction
430431
| UpdateAllWalletsAction
431-
| UpdateConnectModalAction
432+
| UpdateConnectModalAction
433+
| UpdateAppMetadataAction
432434

433435
export type AddChainsAction = { type: 'add_chains'; payload: Chain[] }
434436
export type UpdateChainsAction = { type: 'update_chains'; payload: Chain }
@@ -494,6 +496,11 @@ export type UpdateAllWalletsAction = {
494496
payload: WalletState[]
495497
}
496498

499+
export type UpdateAppMetadataAction = {
500+
type: 'update_app_metadata'
501+
payload: AppMetadata | Partial<AppMetadata>
502+
}
503+
497504
// ==== MISC ==== //
498505
export type ChainStyle = {
499506
icon: string

packages/core/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ export const chainStyles: Record<string, ChainStyle> = {
212212
'0x14a33': {
213213
icon: baseIcon,
214214
color: '#0259F9'
215+
},
216+
'0x80001': {
217+
icon: polygonIcon,
218+
color: '#8247E5'
215219
}
216220
}
217221

packages/core/src/validation.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
chainNamespaceValidation,
1010
chainIdValidation,
1111
chainValidation,
12-
validate
12+
validate,
13+
AppMetadata
1314
} from '@web3-onboard/common'
1415

1516
import type {
@@ -128,6 +129,19 @@ const appMetadata = Joi.object({
128129
agreement
129130
})
130131

132+
const appMetadataUpdate = Joi.object({
133+
name: Joi.string(),
134+
description: Joi.string(),
135+
icon: Joi.string(),
136+
logo: Joi.string(),
137+
gettingStartedGuide: Joi.string(),
138+
email: Joi.string(),
139+
appUrl: Joi.string(),
140+
explore: Joi.string(),
141+
recommendedInjectedWallets: Joi.array().items(recommendedWallet),
142+
agreement
143+
})
144+
131145
const walletModule = Joi.object({
132146
label: Joi.string().required(),
133147
getInfo: Joi.function().arity(1).required(),
@@ -432,3 +446,9 @@ export function validateUpdateBalances(data: WalletState[]): ValidateReturn {
432446
export function validateUpdateTheme(data: Theme): ValidateReturn {
433447
return validate(theme, data)
434448
}
449+
450+
export function validateAppMetadataUpdate(
451+
data: AppMetadata | Partial<AppMetadata>
452+
): ValidateReturn {
453+
return validate(appMetadataUpdate, data)
454+
}

0 commit comments

Comments
 (0)