Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/coinbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/coinbase",
"version": "2.1.0",
"version": "2.1.1-alpha.1",
"description": "Coinbase SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised 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 Expand Up @@ -59,6 +59,6 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.0.5",
"@web3-onboard/common": "^2.2.0"
"@web3-onboard/common": "^2.2.1-alpha.1"
}
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/common",
"version": "2.2.0",
"version": "2.2.1-alpha.1",
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised 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
4 changes: 2 additions & 2 deletions packages/common/src/eip-1193.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type {
ChainId,
EIP1193Provider,
ProviderAccounts
} from './types'
import { ProviderRpcError } from './errors'
} from './types.js'
import { ProviderRpcError } from './errors.js'

/**
* Takes a provider instance along with events
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ProviderRpcErrorCode } from './types'
import type { ProviderRpcErrorCode } from './types.js'

export class ProviderRpcError extends Error {
message: string
Expand Down
12 changes: 6 additions & 6 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { ProviderRpcError } from './errors'
export { createEIP1193Provider } from './eip-1193'
export { SofiaProLight, SofiaProRegular, SofiaProSemiBold } from './fonts'
export { weiToEth } from './utils'
export { ProviderRpcError } from './errors.js'
export { createEIP1193Provider } from './eip-1193.js'
export { SofiaProLight, SofiaProRegular, SofiaProSemiBold } from './fonts.js'
export { weiToEth } from './utils.js'

export * from './types'
export * from './validation'
export * from './types.js'
export * from './validation.js'
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.8.0",
"version": "2.8.1-alpha.1",
"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 Expand Up @@ -82,7 +82,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.2.0",
"@web3-onboard/common": "^2.2.1-alpha.1",
"bignumber.js": "^9.0.0",
"bnc-sdk": "^4.4.1",
"bowser": "^2.11.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/chain.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { firstValueFrom } from 'rxjs'
import { filter, map } from 'rxjs/operators'
import { ProviderRpcErrorCode } from '@web3-onboard/common'
import { addNewChain, switchChain } from './provider'
import { state } from './store'
import { switchChainModal$ } from './streams'
import { validateSetChainOptions } from './validation'
import type { WalletState } from './types'
import { toHexString } from './utils'
import { addNewChain, switchChain } from './provider.js'
import { state } from './store/index.js'
import { switchChainModal$ } from './streams.js'
import { validateSetChainOptions } from './validation.js'
import type { WalletState } from './types.js'
import { toHexString } from './utils.js'

async function setChain(options: {
chainId: string | number
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Configuration } from './types'
import { getDevice } from './utils'
import type { Configuration } from './types.js'
import { getDevice } from './utils.js'

export let configuration: Configuration = {
svelteInstance: null,
Expand Down
22 changes: 13 additions & 9 deletions packages/core/src/connect.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { firstValueFrom } from 'rxjs'
import { filter, withLatestFrom, pluck } from 'rxjs/operators'
import { configuration } from './configuration'
import { state } from './store'
import { setWalletModules } from './store/actions'
import { connectWallet$, wallets$ } from './streams'
import type { ConnectOptions, ConnectOptionsString, WalletState } from './types'
import { wait } from './utils'
import { validateConnectOptions } from './validation'
import { configuration } from './configuration.js'
import { state } from './store/index.js'
import { setWalletModules } from './store/actions.js'
import { connectWallet$, wallets$ } from './streams.js'
import type {
ConnectOptions,
ConnectOptionsString,
WalletState
} from './types.js'
import { wait } from './utils.js'
import { validateConnectOptions } from './validation.js'

async function connect(
options?: ConnectOptions | ConnectOptionsString
Expand All @@ -25,8 +29,8 @@ async function connect(
if (!chains.length)
throw new Error(
'At least one chain must be set before attempting to connect a wallet'
)
)

const { autoSelect } = options || {
autoSelect: { label: '', disableModals: false }
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configuration } from './configuration'
import type { AppState } from './types'
import { configuration } from './configuration.js'
import type { AppState } from './types.js'

export const APP_INITIAL_STATE: AppState = {
wallets: [],
Expand All @@ -25,7 +25,7 @@ export const APP_INITIAL_STATE: AppState = {
},
notifications: [],
locale: '',
connect : {
connect: {
showSidebar: true
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/disconnect.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getBlocknativeSdk } from './services'
import { state } from './store'
import { removeWallet } from './store/actions'
import { disconnectWallet$ } from './streams'
import type { DisconnectOptions, WalletState } from './types'
import { validateDisconnectOptions } from './validation'
import { getBlocknativeSdk } from './services.js'
import { state } from './store/index.js'
import { removeWallet } from './store/actions.js'
import { disconnectWallet$ } from './streams.js'
import type { DisconnectOptions, WalletState } from './types.js'
import { validateDisconnectOptions } from './validation.js'

async function disconnect(options: DisconnectOptions): Promise<WalletState[]> {
const error = validateDisconnectOptions(options)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { addMessages, init, getLocaleFromNavigator } from 'svelte-i18n'
import merge from 'lodash.merge'
import en from './en.json'
import type { i18nOptions } from '../types'
import type { i18nOptions } from '../types.js'

function initialize(options?: i18nOptions): void {
if (options) {
Expand Down
30 changes: 15 additions & 15 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { SofiaProRegular } from '@web3-onboard/common'
import connectWallet from './connect'
import disconnectWallet from './disconnect'
import setChain from './chain'
import { state } from './store'
import { reset$ } from './streams'
import initI18N from './i18n'
import connectWallet from './connect.js'
import disconnectWallet from './disconnect.js'
import setChain from './chain.js'
import { state } from './store/index.js'
import { reset$ } from './streams.js'
import initI18N from './i18n/index.js'
import App from './views/Index.svelte'
import type { InitOptions, Notify } from './types'
import { APP_INITIAL_STATE } from './constants'
import { configuration, updateConfiguration } from './configuration'
import updateBalances from './update-balances'
import { chainIdToHex } from './utils'
import { preflightNotifications } from './preflight-notifications'
import type { InitOptions, Notify } from './types.js'
import { APP_INITIAL_STATE } from './constants.js'
import { configuration, updateConfiguration } from './configuration.js'
import updateBalances from './update-balances.js'
import { chainIdToHex } from './utils.js'
import { preflightNotifications } from './preflight-notifications.js'

import {
validateInitOptions,
validateNotify,
validateNotifyOptions
} from './validation'
} from './validation.js'

import {
addChains,
Expand All @@ -28,7 +28,7 @@ import {
setPrimaryWallet,
setWalletModules,
updateConnectModal
} from './store/actions'
} from './store/actions.js'

const API = {
connectWallet,
Expand Down Expand Up @@ -65,7 +65,7 @@ export type {
Notify,
UpdateNotification,
PreflightNotificationsOptions
} from './types'
} from './types.js'

export type { EIP1193Provider } from '@web3-onboard/common'

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import type {
CustomNotification,
Notification,
NotificationType
} from './types'
} from './types.js'

import { validateTransactionHandlerReturn } from './validation'
import { state } from './store'
import { addNotification } from './store/actions'
import updateBalances from './update-balances'
import { updateTransaction } from './streams'
import { validateTransactionHandlerReturn } from './validation.js'
import { state } from './store/index.js'
import { addNotification } from './store/actions.js'
import updateBalances from './update-balances.js'
import { updateTransaction } from './streams.js'

export function handleTransactionUpdates(
transaction: EthereumTransactionData
Expand Down
14 changes: 6 additions & 8 deletions packages/core/src/preflight-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { nanoid } from 'nanoid'
import defaultCopy from './i18n/en.json'
import type { Network } from 'bnc-sdk'

import type { Notification, PreflightNotificationsOptions } from './types'
import { addNotification, removeNotification } from './store/actions'
import { state } from './store'
import { eventToType } from './notify'
import { networkToChainId } from './utils'
import { validatePreflightNotifications } from './validation'
import type { Notification, PreflightNotificationsOptions } from './types.js'
import { addNotification, removeNotification } from './store/actions.js'
import { state } from './store/index.js'
import { eventToType } from './notify.js'
import { networkToChainId } from './utils.js'
import { validatePreflightNotifications } from './validation.js'

let notificationsArr: Notification[]
state.select('notifications').subscribe(notifications => {
Expand All @@ -18,8 +18,6 @@ state.select('notifications').subscribe(notifications => {
export async function preflightNotifications(
options: PreflightNotificationsOptions
): Promise<string | void> {


const invalid = validatePreflightNotifications(options)

if (invalid) {
Expand Down
25 changes: 13 additions & 12 deletions packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import type {
} from '@web3-onboard/common'

import { weiToEth } from '@web3-onboard/common'
import { disconnectWallet$ } from './streams'
import type { Account, Address, Balances, Ens, WalletState } from './types'
import { updateAccount, updateWallet } from './store/actions'
import { validEnsChain } from './utils'
import disconnect from './disconnect'
import { state } from './store'
import { getBlocknativeSdk } from './services'
import { disconnectWallet$ } from './streams.js'
import type { Account, Address, Balances, Ens, WalletState } from './types.js'
import { updateAccount, updateWallet } from './store/actions.js'
import { validEnsChain } from './utils.js'
import disconnect from './disconnect.js'
import { state } from './store/index.js'
import { getBlocknativeSdk } from './services.js'

export const ethersProviders: {
[key: string]: providers.StaticJsonRpcProvider
Expand Down Expand Up @@ -340,16 +340,17 @@ export async function getBalance(
): Promise<Balances | null> {
// chain we don't recognize and don't have a rpcUrl for requests
if (!chain) return null

const { wallets } = state.get()

try {
const wallet = wallets.find(wallet => !!wallet.provider)
const provider = wallet.provider
const balanceHex = await provider.request({ method: 'eth_getBalance', params:[address,'latest'] })
return balanceHex
? { [chain.token || 'eth']: weiToEth(balanceHex) }
: null
const balanceHex = await provider.request({
method: 'eth_getBalance',
params: [address, 'latest']
})
return balanceHex ? { [chain.token || 'eth']: weiToEth(balanceHex) } : null
} catch (error) {
console.error(error)
return null
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/replacement.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { EthereumTransactionData, Network } from 'bnc-sdk'
import { BigNumber } from 'ethers'
import { configuration } from './configuration'
import { state } from './store'
import type { WalletState } from './types'
import { gweiToWeiHex, networkToChainId, toHexString } from './utils'
import { configuration } from './configuration.js'
import { state } from './store/index.js'
import type { WalletState } from './types.js'
import { gweiToWeiHex, networkToChainId, toHexString } from './utils.js'

const ACTIONABLE_EVENT_CODES: string[] = ['txPool']
const VALID_GAS_NETWORKS: Network[] = ['main', 'matic-main']
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/services.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MultiChain } from 'bnc-sdk'
import { configuration } from './configuration'
import { handleTransactionUpdates } from './notify'
import { configuration } from './configuration.js'
import { handleTransactionUpdates } from './notify.js'

let blocknativeSdk: MultiChain

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Chain, WalletInit, WalletModule } from '@web3-onboard/common'
import { nanoid } from 'nanoid'
import { dispatch } from './index'
import { configuration } from '../configuration'
import { dispatch } from './index.js'
import { configuration } from '../configuration.js'

import type {
Account,
Expand All @@ -27,7 +27,7 @@ import type {
Notify,
ConnectModalOptions,
UpdateConnectModalAction
} from '../types'
} from '../types.js'

import {
validateAccountCenterUpdate,
Expand All @@ -41,7 +41,7 @@ import {
validateUpdateBalances,
validateNotify,
validateConnectModalUpdate
} from '../validation'
} from '../validation.js'

import {
ADD_CHAINS,
Expand All @@ -58,7 +58,7 @@ import {
REMOVE_NOTIFICATION,
UPDATE_ALL_WALLETS,
UPDATE_CONNECT_MODAL
} from './constants'
} from './constants.js'

export function addChains(chains: Chain[]): void {
// chains are validated on init
Expand Down
Loading