Skip to content

Commit

Permalink
Release 2.24.2 (#1793)
Browse files Browse the repository at this point in the history
* 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 (docs) (#1778)

* 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>
  • Loading branch information
5 people authored Jun 27, 2023
1 parent c8ab47f commit 1b6df15
Show file tree
Hide file tree
Showing 29 changed files with 235 additions and 84 deletions.
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@web3-onboard/blocto": "^2.0.0-alpha.1",
"@web3-onboard/cede-store": "^2.0.2",
"@web3-onboard/coinbase": "^2.2.4",
"@web3-onboard/core": "^2.20.2-alpha.1",
"@web3-onboard/core": "^2.20.3-alpha.1",
"@web3-onboard/dcent": "^2.2.7",
"@web3-onboard/enkrypt": "^2.0.4",
"@web3-onboard/fortmatic": "^2.0.19",
Expand All @@ -61,7 +61,7 @@
"@web3-onboard/gas": "^2.1.8",
"@web3-onboard/gnosis": "^2.1.10",
"@web3-onboard/infinity-wallet": "^2.0.4",
"@web3-onboard/injected-wallets": "^2.10.1-alpha.1",
"@web3-onboard/injected-wallets": "^2.10.1",
"@web3-onboard/keepkey": "^2.3.7",
"@web3-onboard/keystone": "^2.3.7",
"@web3-onboard/ledger": "^2.4.6",
Expand Down
12 changes: 12 additions & 0 deletions docs/src/routes/docs/[...3]modules/[...1]core/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ type RecommendedInjectedWallets = {
}
```
**`updateAppMetadata`**
If you need to update your Application Metadata after initialization, you can call the `updateAppMetadata` function with the new configuration
```typescript
onboard.state.actions.updateAppMetadata({
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"/>
</svg>`,
description: 'Updated Description!'
})
```
---
#### connect
Expand Down
13 changes: 11 additions & 2 deletions docs/src/routes/docs/[...4]wallets/[...24]walletconnect/+page.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Walletconnect
title: WalletConnect
---

# {$frontmatter.title}
Expand Down Expand Up @@ -116,7 +116,16 @@ const onboard = Onboard({
wallets: [
walletConnect
//... other wallets
]
],
chains: [ // chains that are passed as optional chains to WC wallet after cleaning and parsing as number[]
{
id: '0x89',
token: 'MATIC',
label: 'Polygon',
rpcUrl: 'https://matic-mainnet.chainstacklabs.com'
}
// ...
]
})

const connectedWallets = await onboard.connectWallet()
Expand Down
14 changes: 14 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,20 @@ type RecommendedInjectedWallets = {
}
```
**`updateAppMetadata`**
If you need to update your Application Metadata after initialization, you can call the `updateAppMetadata` function with the new configuration
```typescript
onboard.state.actions.updateAppMetadata({
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"/>
</svg>`,
description: 'Updated Description!'
})
```
---
**`connect`**
An object that allows for customization of the Connect Modal and accepts the type ConnectModalOptions.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.20.2",
"version": "2.20.3",
"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.",
"keywords": [
"Ethereum",
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,
appMetadata: null,
apiKey: null,
device: getDevice(),
initialWalletInit: [],
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const APP_INITIAL_STATE: AppState = {
connect: {
showSidebar: true,
disableClose: false
}
},
appMetadata: null,
}

export const STORAGE_KEYS = {
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import {
setPrimaryWallet,
setWalletModules,
updateConnectModal,
updateTheme
updateTheme,
updateAppMetadata
} from './store/actions.js'
import type { PatchedEIP1193Provider } from '@web3-onboard/transaction-preview'
import { getBlocknativeSdk } from './services.js'
Expand All @@ -53,7 +54,8 @@ const API = {
updateBalances,
updateAccountCenter,
setPrimaryWallet,
updateTheme
updateTheme,
updateAppMetadata
}
}
}
Expand Down Expand Up @@ -92,7 +94,7 @@ function init(options: InitOptions): OnboardAPI {
const {
wallets,
chains,
appMetadata = null,
appMetadata,
i18n,
accountCenter,
apiKey,
Expand Down Expand Up @@ -208,7 +210,6 @@ function init(options: InitOptions): OnboardAPI {
const app = svelteInstance || mountApp(theme, disableFontDownload)

updateConfiguration({
appMetadata,
svelteInstance: app,
apiKey,
initialWalletInit: wallets,
Expand All @@ -217,6 +218,8 @@ function init(options: InitOptions): OnboardAPI {
unstoppableResolution
})

appMetadata && updateAppMetadata(appMetadata)

if (apiKey && transactionPreview) {
const getBnSDK = async () => {
transactionPreview.init({
Expand Down
28 changes: 24 additions & 4 deletions packages/core/src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Chain, WalletInit, WalletModule } from '@web3-onboard/common'
import type { AppMetadata, Chain, WalletInit, WalletModule } from '@web3-onboard/common'
import { nanoid } from 'nanoid'
import { dispatch } from './index.js'
import { configuration } from '../configuration.js'
Expand Down Expand Up @@ -29,7 +29,8 @@ import type {
ConnectModalOptions,
UpdateConnectModalAction,
Theme,
UpdateChainsAction
UpdateChainsAction,
UpdateAppMetadataAction
} from '../types.js'

import {
Expand All @@ -45,7 +46,8 @@ import {
validateNotify,
validateConnectModalUpdate,
validateUpdateTheme,
validateSetChainOptions
validateSetChainOptions,
validateAppMetadataUpdate
} from '../validation.js'

import {
Expand All @@ -63,7 +65,8 @@ import {
REMOVE_NOTIFICATION,
UPDATE_ALL_WALLETS,
UPDATE_CONNECT_MODAL,
UPDATE_CHAINS
UPDATE_CHAINS,
UPDATE_APP_METADATA
} from './constants.js'

export function addChains(chains: Chain[]): void {
Expand Down Expand Up @@ -438,3 +441,20 @@ export function updateTheme(theme: Theme): void {
const themingObj = returnTheme(theme)
themingObj && handleThemeChange(themingObj)
}

export function updateAppMetadata(
update: AppMetadata| Partial<AppMetadata>
): void {
const error = validateAppMetadataUpdate(update)

if (error) {
throw error
}

const action = {
type: UPDATE_APP_METADATA,
payload: update
}

dispatch(action as UpdateAppMetadataAction)
}
1 change: 1 addition & 0 deletions packages/core/src/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export const UPDATE_NOTIFY = 'update_notify'
export const ADD_NOTIFICATION = 'add_notification'
export const REMOVE_NOTIFICATION = 'remove_notification'
export const UPDATE_ALL_WALLETS = 'update_balance'
export const UPDATE_APP_METADATA = 'update_app_metadata'
18 changes: 16 additions & 2 deletions packages/core/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import type {
RemoveNotificationAction,
UpdateAllWalletsAction,
UpdateConnectModalAction,
UpdateChainsAction
UpdateChainsAction,
UpdateAppMetadataAction
} from '../types.js'

import {
Expand All @@ -37,7 +38,8 @@ import {
ADD_NOTIFICATION,
REMOVE_NOTIFICATION,
UPDATE_ALL_WALLETS,
UPDATE_CHAINS
UPDATE_CHAINS,
UPDATE_APP_METADATA
} from './constants.js'

function reducer(state: AppState, action: Action): AppState {
Expand Down Expand Up @@ -218,6 +220,18 @@ function reducer(state: AppState, action: Action): AppState {
}
}

case UPDATE_APP_METADATA: {
const update = payload as UpdateAppMetadataAction['payload']

return {
...state,
appMetadata: {
...state.appMetadata,
...update
}
}
}

case RESET_STORE:
return APP_INITIAL_STATE

Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export interface AppState {
locale: Locale
notify: Notify
notifications: Notification[]
connect: ConnectModalOptions
connect: ConnectModalOptions,
appMetadata: AppMetadata
}

export type Configuration = {
Expand Down Expand Up @@ -428,7 +429,8 @@ export type Action =
| AddNotificationAction
| RemoveNotificationAction
| UpdateAllWalletsAction
| UpdateConnectModalAction
| UpdateConnectModalAction
| UpdateAppMetadataAction

export type AddChainsAction = { type: 'add_chains'; payload: Chain[] }
export type UpdateChainsAction = { type: 'update_chains'; payload: Chain }
Expand Down Expand Up @@ -494,6 +496,11 @@ export type UpdateAllWalletsAction = {
payload: WalletState[]
}

export type UpdateAppMetadataAction = {
type: 'update_app_metadata'
payload: AppMetadata | Partial<AppMetadata>
}

// ==== MISC ==== //
export type ChainStyle = {
icon: string
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ export const chainStyles: Record<string, ChainStyle> = {
'0x14a33': {
icon: baseIcon,
color: '#0259F9'
},
'0x80001': {
icon: polygonIcon,
color: '#8247E5'
}
}

Expand Down
22 changes: 21 additions & 1 deletion packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
chainNamespaceValidation,
chainIdValidation,
chainValidation,
validate
validate,
AppMetadata
} from '@web3-onboard/common'

import type {
Expand Down Expand Up @@ -128,6 +129,19 @@ const appMetadata = Joi.object({
agreement
})

const appMetadataUpdate = Joi.object({
name: Joi.string(),
description: Joi.string(),
icon: Joi.string(),
logo: Joi.string(),
gettingStartedGuide: Joi.string(),
email: Joi.string(),
appUrl: Joi.string(),
explore: Joi.string(),
recommendedInjectedWallets: Joi.array().items(recommendedWallet),
agreement
})

const walletModule = Joi.object({
label: Joi.string().required(),
getInfo: Joi.function().arity(1).required(),
Expand Down Expand Up @@ -432,3 +446,9 @@ export function validateUpdateBalances(data: WalletState[]): ValidateReturn {
export function validateUpdateTheme(data: Theme): ValidateReturn {
return validate(theme, data)
}

export function validateAppMetadataUpdate(
data: AppMetadata | Partial<AppMetadata>
): ValidateReturn {
return validate(appMetadataUpdate, data)
}
Loading

0 comments on commit 1b6df15

Please sign in to comment.