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
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/coinbase
steps:
- node-build-steps
build-web3auth:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/web3auth
steps:
- node-build-steps
build-dcent:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -383,6 +389,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/coinbase
steps:
- node-staging-build-steps
build-staging-web3auth:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/web3auth
steps:
- node-build-steps
build-staging-dcent:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -501,6 +513,12 @@ workflows:
<<: *deploy_production_filters
- build-staging-coinbase:
<<: *deploy_staging_filters
web3auth:
jobs:
- build-web3auth:
<<: *deploy_production_filters
- build-staging-web3auth:
<<: *deploy_staging_filters
dcent:
jobs:
- build-dcent:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
dist/
package-lock.json
.rpt2_cache
.vscode
.vscode
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.0.3",
"version": "2.0.4",
"description": "Coinbase Wallet module for web3-onboard",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand All @@ -21,6 +21,6 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.0.5",
"@web3-onboard/common": "2.1.0"
"@web3-onboard/common": "2.1.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.1.0",
"version": "2.1.1",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ethers, BigNumber } from 'ethers'
import type { ConnectionInfo } from 'ethers/lib/utils'
import type EventEmitter from 'eventemitter3'
import type { TypedData as EIP712TypedData } from 'eip-712'
export type { TypedData as EIP712TypedData } from 'eip-712'
Expand Down Expand Up @@ -428,6 +429,7 @@ export interface Chain {
token: TokenSymbol // eg ETH, BNB, MATIC
color?: string
icon?: string // svg string
providerConnectionInfo?: ConnectionInfo
}

export type TokenSymbol = string // eg ETH
Expand Down
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.2.11",
"version": "2.2.12",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down Expand Up @@ -41,7 +41,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.1.0",
"@web3-onboard/common": "^2.1.1",
"bowser": "^2.11.0",
"ethers": "5.5.3",
"eventemitter3": "^4.0.7",
Expand Down
30 changes: 16 additions & 14 deletions packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ export const ethersProviders: {
[key: string]: providers.StaticJsonRpcProvider
} = {}

export function getProvider(chain: Chain): providers.StaticJsonRpcProvider {
if (!chain) return null

if (!ethersProviders[chain.rpcUrl]) {
ethersProviders[chain.rpcUrl] = new providers.StaticJsonRpcProvider(
chain.providerConnectionInfo?.url
? chain.providerConnectionInfo
: chain.rpcUrl
)
}

return ethersProviders[chain.rpcUrl]
}

export function requestAccounts(
provider: EIP1193Provider
): Promise<ProviderAccounts> {
Expand Down Expand Up @@ -231,13 +245,7 @@ export async function getEns(
// chain we don't recognize and don't have a rpcUrl for requests
if (!chain) return null

if (!ethersProviders[chain.rpcUrl]) {
ethersProviders[chain.rpcUrl] = new providers.StaticJsonRpcProvider(
chain.rpcUrl
)
}

const provider = ethersProviders[chain.rpcUrl]
const provider = getProvider(chain);

try {
const name = await provider.lookupAddress(address)
Expand Down Expand Up @@ -277,13 +285,7 @@ export async function getBalance(
// chain we don't recognize and don't have a rpcUrl for requests
if (!chain) return null

if (!ethersProviders[chain.rpcUrl]) {
ethersProviders[chain.rpcUrl] = new providers.StaticJsonRpcProvider(
chain.rpcUrl
)
}

const provider = ethersProviders[chain.rpcUrl]
const provider = getProvider(chain);

try {
const balanceWei = await provider.getBalance(address)
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export function addChains(chains: Chain[]): void {
// chains are validated on init
const action = {
type: ADD_CHAINS,
payload: chains.map(({ namespace = 'evm', ...rest }) => ({
payload: chains.map(({ namespace = 'evm', id, ...rest }) => ({
...rest,
namespace
namespace,
id : id.toLowerCase()
}))
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const chainIdToLabel: Record<string, string> = {
'0x89': 'Polygon',
'0xfa': 'Fantom',
'0xa': 'Optimism',
'0x45': 'Optimism Kovan',
'0xa86a': 'Avalanche',
'0xa4ec': 'Celo',
'0x64': 'Gnosis',
Expand Down Expand Up @@ -125,6 +126,10 @@ export const chainStyles: Record<string, ChainStyle> = {
icon: optimismIcon,
color: '#FF0420'
},
'0x45': {
icon: optimismIcon,
color: '#FF0420'
},
'0xa86a': {
icon: avalancheIcon,
color: '#E84142'
Expand Down
19 changes: 17 additions & 2 deletions packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@ const chainId = Joi.string().pattern(/^0x[0-9a-fA-F]+$/)
const chainNamespace = Joi.string().valid('evm')
const unknownObject = Joi.object().unknown()

/** Related to ConnectionInfo from 'ethers/lib/utils' */
const providerConnectionInfo = Joi.object({
url: Joi.string().required(),
headers: Joi.object(),
user: Joi.string(),
password: Joi.string(),
allowInsecureAuthentication: Joi.boolean(),
allowGzip: Joi.boolean(),
throttleLimit: Joi.number(),
throttleSlotInterval: Joi.number(),
throttleCallback: Joi.function(),
timeout: Joi.number()
})

const chain = Joi.object({
namespace: chainNamespace,
id: chainId.required(),
rpcUrl: Joi.string().required(),
label: Joi.string().required(),
token: Joi.string().required(),
icon: Joi.string(),
color: Joi.string()
color: Joi.string(),
providerConnectionInfo: providerConnectionInfo
})

const connectedChain = Joi.object({
Expand Down Expand Up @@ -214,4 +229,4 @@ export function validateLocale(data: string): ValidateReturn {
export function validateUpdateBalances(data:
WalletState[]): ValidateReturn {
return validate(wallets, data)
}
}
4 changes: 2 additions & 2 deletions packages/dcent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/dcent",
"version": "2.0.0",
"version": "2.0.1",
"description": "D'CENT module for web3-onboard",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
Expand All @@ -18,7 +18,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.1.0",
"@web3-onboard/common": "^2.1.1",
"@ethereumjs/common": "^2.6.1",
"@ethereumjs/tx": "^3.4.0",
"@ethersproject/providers": "^5.5.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "2.0.2",
"version": "2.0.3",
"devDependencies": {
"assert": "^2.0.0",
"buffer": "^6.0.3",
Expand All @@ -23,11 +23,11 @@
},
"dependencies": {
"@web3-onboard/coinbase": "^2.0.3",
"@web3-onboard/core": "^2.2.11",
"@web3-onboard/core": "^2.2.12",
"@web3-onboard/dcent": "^2.0.0",
"@web3-onboard/fortmatic": "^2.0.2",
"@web3-onboard/gnosis": "^2.0.1",
"@web3-onboard/injected-wallets": "^2.0.8",
"@web3-onboard/injected-wallets": "^2.0.9",
"@web3-onboard/keepkey": "^2.1.0",
"@web3-onboard/keystone": "^2.1.1",
"@web3-onboard/ledger": "^2.1.0",
Expand All @@ -36,6 +36,7 @@
"@web3-onboard/torus": "^2.0.1",
"@web3-onboard/trezor": "^2.1.0",
"@web3-onboard/walletconnect": "^2.0.1",
"@web3-onboard/web3auth": "^2.0.0",
"vconsole": "^3.9.5"
},
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import walletConnectModule from '@web3-onboard/walletconnect'
import coinbaseModule from '@web3-onboard/coinbase'
import magicModule from '@web3-onboard/magic'
import web3authModule from '@web3-onboard/web3auth'

import dcentModule from '@web3-onboard/dcent'
import {
recoverAddress,
Expand Down Expand Up @@ -69,6 +71,10 @@
apiKey: 'pk_test_886ADCAB855632AA'
})

const web3auth = web3authModule({
clientId: 'DJuUOKvmNnlzy6ruVgeWYWIMKLRyYtjYa9Y10VCeJzWZcygDlrYLyXsBQjpJ2hxlBO9dnl8t9GmAC2qOP5vnIGo'
})

const torus = torusModule()
const ledger = ledgerModule()
const keepkey = keepkeyModule()
Expand All @@ -92,6 +98,7 @@

const onboard = Onboard({
wallets: [
web3auth,
ledger,
trezor,
walletConnect,
Expand Down
4 changes: 2 additions & 2 deletions packages/fortmatic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/fortmatic",
"version": "2.0.2",
"version": "2.0.3",
"description": "Fortmatic module for web3-onboard",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand All @@ -20,7 +20,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.0.7",
"@web3-onboard/common": "^2.1.1",
"fortmatic": "^2.2.1"
}
}
4 changes: 2 additions & 2 deletions packages/gnosis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/gnosis",
"version": "2.0.1",
"version": "2.0.2",
"description": "Gnosis module for web3-onboard",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand All @@ -23,6 +23,6 @@
"dependencies": {
"@gnosis.pm/safe-apps-provider": "^0.9.2",
"@gnosis.pm/safe-apps-sdk": "^6.1.1",
"@web3-onboard/common": "^2.0.7"
"@web3-onboard/common": "^2.1.1"
}
}
4 changes: 2 additions & 2 deletions packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/injected-wallets",
"version": "2.0.8",
"version": "2.0.9",
"description": "Injected wallets module for web3-onboard",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand All @@ -25,7 +25,7 @@
"window": "^4.2.7"
},
"dependencies": {
"@web3-onboard/common": "^2.1.0",
"@web3-onboard/common": "^2.1.1",
"joi": "^17.4.2",
"lodash.uniqby": "^4.7.0"
}
Expand Down
1 change: 1 addition & 0 deletions packages/injected/src/icons/exodus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIyIiBoZWlnaHQ9IjEyNCIgdmlld0JveD0iMCAwIDEyMiAxMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxtYXNrIGlkPSJtYXNrMF8zMF8xMTAiIHN0eWxlPSJtYXNrLXR5cGU6YWxwaGEiIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjAiIHk9IjAiIHdpZHRoPSIxMjIiIGhlaWdodD0iMTI0Ij4KPHBhdGggZD0iTTEyMS43ODcgMzQuODMzMUw2OS4zODc2IDAuNDc2NTYyVjE5LjY4NTVMMTAzLjAwMiA0MS41Mjg4TDk5LjA0NzQgNTQuMDQySDY5LjM4NzZWNjkuOTU4SDk5LjA0NzRMMTAzLjAwMiA4Mi40NzEyTDY5LjM4NzYgMTA0LjMxNFYxMjMuNTIzTDEyMS43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line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum ProviderIdentityFlag {
CoinbaseExtension = 'isCoinbaseWallet',
Detected = 'request',
Dcent = 'isDcentWallet',
Exodus = 'isExodus',
Frame = 'isFrame',
HuobiWallet = 'isHbWallet',
HyperPay = 'isHyperPay',
Expand Down Expand Up @@ -52,6 +53,7 @@ export enum ProviderLabel {
Coinbase = 'Coinbase Wallet',
Dcent = `D'CENT`,
Detected = 'Detected Wallet',
Exodus = 'Exodus',
Frame = 'Frame',
HuobiWallet = 'Huobi Wallet',
HyperPay = 'HyperPay',
Expand Down
11 changes: 11 additions & 0 deletions packages/injected/src/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ const metamask: InjectedWalletModule = {
platforms: ['all']
}

const exodus: InjectedWalletModule = {
label: ProviderLabel.Exodus,
injectedNamespace: InjectedNameSpace.Ethereum,
checkProviderIdentity: ({ provider }) =>
!!provider && !!provider[ProviderIdentityFlag.Exodus],
getIcon: async () => (await import('./icons/exodus.js')).default,
getInterface: getInjectedInterface(ProviderIdentityFlag.Exodus),
platforms: ['all']
}

const brave: InjectedWalletModule = {
label: ProviderLabel.Brave,
injectedNamespace: InjectedNameSpace.Ethereum,
Expand Down Expand Up @@ -464,6 +474,7 @@ const tally: InjectedWalletModule = {
}

const wallets = [
exodus,
metamask,
binance,
coinbase,
Expand Down
Loading