Skip to content

Commit

Permalink
Add frame connector (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
goosewobbler authored May 10, 2023
1 parent 6053661 commit 2ba8d26
Show file tree
Hide file tree
Showing 14 changed files with 347 additions and 7 deletions.
19 changes: 18 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/injected
steps:
- node-build-steps
build-frame:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/frame
steps:
- node-build-steps
build-keepkey:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -421,6 +427,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/injected
steps:
- node-staging-build-steps
build-staging-frame:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/frame
steps:
- node-staging-build-steps
build-staging-keepkey:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -647,6 +659,12 @@ workflows:
<<: *deploy_production_filters
- build-staging-injected:
<<: *deploy_staging_filters
frame:
jobs:
- build-frame:
<<: *deploy_production_filters
- build-staging-frame:
<<: *deploy_staging_filters
keepkey:
jobs:
- build-keepkey:
Expand Down Expand Up @@ -839,4 +857,3 @@ workflows:
<<: *deploy_production_filters
- build-staging-cede-store:
<<: *deploy_staging_filters

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ For full documentation, check out the README.md for each package or the [docs pa
- [Frontier](packages/frontier/README.md)
- [XDEFI](packages/xdefi/README.md)
- [Infinity Wallet](packages/infinity-wallet/README.md)
- [Frame](packages/frame/README.md)

**Hardware Wallets**

Expand Down
3 changes: 3 additions & 0 deletions docs/src/lib/services/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const intiOnboard = async (theme) => {
const { default: uauthModule } = await import('@web3-onboard/uauth')
const { default: trustModule } = await import('@web3-onboard/trust')
const { default: xdefiModule } = await import('@web3-onboard/xdefi')
const { default: frameModule } = await import('@web3-onboard/frame')
const INFURA_ID = '8b60d52405694345a99bcb82e722e0af'

const injected = injectedModule()
Expand All @@ -76,6 +77,7 @@ const intiOnboard = async (theme) => {
const torus = torusModule()
const trust = trustModule()
const xdefi = xdefiModule()
const frame = frameModule()
const cede = cedeModule()

const portis = portisModule({
Expand Down Expand Up @@ -132,6 +134,7 @@ const intiOnboard = async (theme) => {
keystone,
keepkey,
portis,
frame,
infinityWallet
],
chains: [
Expand Down
3 changes: 2 additions & 1 deletion docs/src/routes/docs/[...1]overview/[...1]introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Web3-Onboard is the quickest and easiest way to add multi-wallet and multi-chain

web3-onboard supports all EVM networks. Supporting a new network is simply a matter of adding its details in the Chains section upon initialization. For more information see [initialization options](../../docs/modules/core.md#options).

- Ethereum
- Ethereum
- Polygon
- Base Goerli
- Goerli
Expand Down Expand Up @@ -156,6 +156,7 @@ We recommend you add the [Core Repo](../../docs/modules/core.md#install) and con
- [MEW](../../docs/wallets/mewwallet.md#install)
- [Portis](../../docs/wallets/portis.md#install)
- [Web3Auth](../../docs/wallets/web3auth.md#install)
- [Frame](../../docs/wallets/frame.md#install)

**Hardware Wallets**

Expand Down
81 changes: 81 additions & 0 deletions docs/src/routes/docs/[...4]wallets/frame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Frame

[Frame](https://frame.sh/) is a privacy focused EVM desktop wallet, enabling a secure system-wide interface to your chains and web3 accounts.

### Install

```sh copy
yarn add @web3-onboard/core @web3-onboard/frame
```

or

```sh copy
npm install @web3-onboard/core @web3-onboard/frame
```

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import frameModule from '@web3-onboard/frame'

// initialize the module
const frame = frameModule()

const onboard = Onboard({
// ... other Onboard options
wallets: [
frame
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

### Filtering Platforms

You may decide that on certain platforms you do not want to display this wallet as a selectable option. To do that you can use the `filter` init option which is an array of platforms that you would like this wallet to **not** be displayed to the end user:

```typescript
import Onboard from '@web3-onboard/core'
import frameModule from '@web3-onboard/frame'

const frame = frameModule({ filter: ['iOS', 'Android'] })

const onboard = Onboard({
// ... other Onboard options
wallets: [
frame
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

The following is a list of the platforms that can be filtered:

```typescript
type Platform =
| 'Windows Phone'
| 'Windows'
| 'macOS'
| 'iOS'
| 'Android'
| 'Linux'
| 'Chrome OS'
| 'Android Browser'
| 'Chrome'
| 'Chromium'
| 'Firefox'
| 'Microsoft Edge'
| 'Opera'
| 'Safari'
| 'desktop'
| 'mobile'
| 'tablet'
```
1 change: 1 addition & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@web3-onboard/coinbase": "^2.2.3-alpha.2",
"@web3-onboard/transaction-preview": "^2.0.7-alpha.2",
"@web3-onboard/dcent": "^2.2.6-alpha.2",
"@web3-onboard/frame": "2.21.2-alpha.1",
"@web3-onboard/frontier": "^2.0.3-alpha.2",
"@web3-onboard/fortmatic": "^2.0.18-alpha.2",
"@web3-onboard/gas": "^2.1.7-alpha.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import Onboard from '@web3-onboard/core'
import fortmaticModule from '@web3-onboard/fortmatic'
import frameModule from '@web3-onboard/frame'
import gnosisModule from '@web3-onboard/gnosis'
import infinityWalletModule from '@web3-onboard/infinity-wallet'
import injectedModule, { ProviderLabel } from '@web3-onboard/injected-wallets'
Expand Down Expand Up @@ -170,6 +171,7 @@
})
const dcent = dcentModule()
const frameWallet = frameModule()
const sequence = sequenceModule()
const enkrypt = enkryptModule()
const mewWallet = mewWalletModule()
Expand All @@ -180,6 +182,7 @@
const onboard = Onboard({
wallets: [
injected,
frameWallet,
ledger,
trezor,
walletConnect,
Expand Down
74 changes: 74 additions & 0 deletions packages/frame/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# @web3-onboard/frame

## Wallet module for connecting Frame to web3-onboard

[Frame](https://frame.sh/) is a privacy focused EVM desktop wallet, enabling a secure system-wide interface to your chains and web3 accounts.

### Install

`npm i @web3-onboard/core @web3-onboard/frame`

### Usage

```typescript
import Onboard from '@web3-onboard/core'
import frameModule from '@web3-onboard/frame'

const frame = frameModule()

const onboard = Onboard({
// ... other Onboard options
wallets: [
frame
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

### Filtering Platforms

You may decide that on certain platforms you do not want to display this wallet as a selectable option. To do that you can use the `filter` init option which is an array of platforms that you would like this wallet to **not** be displayed to the end user:

```typescript
import Onboard from '@web3-onboard/core'
import frameModule from '@web3-onboard/frame'

const frame = frameModule({ filter: ['iOS', 'Android'] })

const onboard = Onboard({
// ... other Onboard options
wallets: [
frame
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```

The following is a list of the platforms that can be filtered:

```typescript
type Platform =
| 'Windows Phone'
| 'Windows'
| 'macOS'
| 'iOS'
| 'Android'
| 'Linux'
| 'Chrome OS'
| 'Android Browser'
| 'Chrome'
| 'Chromium'
| 'Firefox'
| 'Microsoft Edge'
| 'Opera'
| 'Safari'
| 'desktop'
| 'mobile'
| 'tablet'
```
65 changes: 65 additions & 0 deletions packages/frame/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@web3-onboard/frame",
"version": "2.21.2-alpha.1",
"description": "Frame 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",
"Web3",
"EVM",
"Frame",
"dapp",
"Multichain",
"Wallet",
"Transaction",
"Provider",
"Hardware Wallet",
"Notifications",
"React",
"Svelte",
"Vue",
"Next",
"Nuxt",
"MetaMask",
"Coinbase",
"WalletConnect",
"Ledger",
"Trezor",
"Connect Wallet",
"Ethereum Hooks",
"Blocknative",
"Mempool",
"pending",
"confirmed",
"Injected Wallet",
"Crypto",
"Crypto Wallet"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/frame"
},
"homepage": "https://onboard.blocknative.com",
"bugs": "https://github.com/blocknative/web3-onboard/issues",
"module": "dist/index.js",
"browser": "dist/index.js",
"main": "dist/index.js",
"type": "module",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"type-check": "tsc --noEmit"
},
"license": "MIT",
"devDependencies": {
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.3.1",
"eth-provider": "^0.13.6"
}
}
4 changes: 4 additions & 0 deletions packages/frame/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 153.4 152.9" color="#00d2be">
<path fill="currentColor" d="M145.1,75.6v-58c0-5.1-4.2-9.3-9.3-9.3h0H77.7c-0.6,0-1.1-0.2-1.6-0.6l-7-7c-0.4-0.4-1-0.7-1.6-0.7H9.3 C4.2,0,0,4.1,0,9.3c0,0,0,0,0,0l0,0v58c0,0.6,0.2,1.1,0.6,1.6l7,7c0.4,0.4,0.7,1,0.7,1.6v58c0,5.1,4.2,9.3,9.3,9.3c0,0,0,0,0,0h58.2 c0.6,0,1.1,0.2,1.6,0.6l7,7c0.4,0.4,1,0.6,1.6,0.6h58.2c5.1,0,9.3-4.1,9.3-9.3c0,0,0,0,0,0l0,0v-58c0-0.6-0.2-1.1-0.6-1.6l-7-7 C145.4,76.7,145.1,76.2,145.1,75.6z M105.6,106.6H47.9c-0.7,0-1.3-0.6-1.3-1.3V47.7c0-0.7,0.6-1.3,1.3-1.3h57.7 c0.7,0,1.3,0.6,1.3,1.3v57.6C107,106,106.4,106.6,105.6,106.6z" />
</svg>`
46 changes: 46 additions & 0 deletions packages/frame/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { WalletInit } from '@web3-onboard/common'

async function getProvider() {
const injected = (window as any).ethereum

if (injected && injected.isFrame) {
return injected
}

const { default: ethProvider } = await import('eth-provider')
return ethProvider('frame')
}

function frame(): WalletInit {
return () => {
return {
label: 'Frame',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async () => {
const provider = await getProvider()

return {
provider,
interface: {
connect: () =>
provider
.request({
method: 'eth_requestAccounts'
})
.catch((err: { message: string }) => {
if (err.message.includes('Unexpected end of JSON input')) {
throw new Error('Frame is not running')
}

throw err
}),
disconnect: provider.close
}
}
},
platforms: ['desktop']
}
}
}

export default frame
Loading

0 comments on commit 2ba8d26

Please sign in to comment.