Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add blocto wallet #1699

Merged
merged 27 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7667936
feat: support bloctoWallet
sanyu1225 May 9, 2023
87f725d
feat: add blocto and update doc
sanyu1225 May 10, 2023
bea6b9e
feat: update blocto description
sanyu1225 May 10, 2023
a6d8bb6
feat: update blocto version
sanyu1225 May 10, 2023
6951e10
docs: update blocto readme
sanyu1225 May 10, 2023
f9ca47f
docs: update introduction
sanyu1225 May 10, 2023
f44204e
feat: add blocto circleci config
sanyu1225 May 11, 2023
a709b66
feat: demo default use Polygon
sanyu1225 May 12, 2023
0c98bf6
fix: move docs to new folder
sanyu1225 May 15, 2023
86a0601
feat: available in the docs connection module
sanyu1225 May 15, 2023
af6400c
fix: resolve review change
sanyu1225 May 17, 2023
23d0b7d
move docs page, update bloct package version
leightkt May 17, 2023
c8f5735
add blocto to docs script
leightkt May 17, 2023
f62f4c6
re-add Tailsman to list of injected wallets
leightkt May 18, 2023
e8c3b2d
Update packages/blocto/package.json
sanyu1225 May 19, 2023
a494400
Update docs/package.json
sanyu1225 May 19, 2023
bc4cf2d
fix: use Optional Chaining enhanced debugging
sanyu1225 May 19, 2023
5345e1e
Merge branch 'develop' into develop
sanyu1225 May 22, 2023
2e07808
fix: bump version
sanyu1225 May 22, 2023
4906025
remove conditional prop chaining
leightkt May 23, 2023
35c5e73
fix: backward compatible
sanyu1225 May 27, 2023
4a0cf46
merge changes from develop
leightkt Jun 2, 2023
80c53cd
Merge branch 'develop' of github.com:blocknative/web3-onboard into de…
leightkt Jun 12, 2023
ad4c0a7
prettier bloct/index.ts
leightkt Jun 12, 2023
d12c6ca
Merge branch 'develop' of github.com:blocknative/web3-onboard into de…
leightkt Jun 12, 2023
819c3a9
docs: blocto Build Environments
sanyu1225 Jun 14, 2023
978d61b
Merge branch 'develop' into develop
leightkt Jun 14, 2023
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 @@ -395,6 +395,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-build-steps
build-blocto:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/blocto
steps:
- node-build-steps
build-venly:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -631,6 +637,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-staging-build-steps
build-staging-blocto:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/blocto
steps:
- node-staging-build-steps
build-staging-venly:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -869,6 +881,12 @@ workflows:
<<: *deploy_production_filters
- build-staging-cede-store:
<<: *deploy_staging_filters
blocto:
jobs:
- build-blocto:
<<: *deploy_production_filters
- build-staging-blocto:
<<: *deploy_staging_filters
venly:
jobs:
- build-venly:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ For full documentation, check out the README.md for each package or the [docs pa
- [XDEFI](packages/xdefi/README.md)
- [Infinity Wallet](packages/infinity-wallet/README.md)
- [Frame](packages/frame/README.md)
- [Blocto](packages/blocto/README.md)

**Hardware Wallets**

Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"format": "prettier --plugin-search-dir . --write .",
"prepare": "svelte-kit sync",
"test": "playwright test",
"w3o-latest-prod": "yarn add '@web3-onboard/core' '@web3-onboard/coinbase' '@web3-onboard/transaction-preview' '@web3-onboard/dcent' '@web3-onboard/frontier' '@web3-onboard/fortmatic' '@web3-onboard/frame' '@web3-onboard/gas' '@web3-onboard/gnosis' '@web3-onboard/keepkey' '@web3-onboard/keystone' '@web3-onboard/ledger' '@web3-onboard/infinity-wallet' '@web3-onboard/injected-wallets' '@web3-onboard/magic' '@web3-onboard/phantom' '@web3-onboard/portis' '@web3-onboard/sequence' '@web3-onboard/trezor' '@web3-onboard/trust' '@web3-onboard/torus' '@web3-onboard/taho' '@web3-onboard/web3auth' '@web3-onboard/walletconnect' '@web3-onboard/enkrypt' '@web3-onboard/mew-wallet' '@web3-onboard/xdefi' '@web3-onboard/uauth' '@web3-onboard/zeal' '@web3-onboard/cede-store'",
"w3o-latest-alpha": "yarn add '@web3-onboard/core@next' '@web3-onboard/coinbase@next' '@web3-onboard/transaction-preview@next' '@web3-onboard/dcent@next' '@web3-onboard/frontier@next' '@web3-onboard/fortmatic@next' '@web3-onboard/frame@next' '@web3-onboard/gas@next' '@web3-onboard/gnosis@next' '@web3-onboard/keepkey@next' '@web3-onboard/keystone@next' '@web3-onboard/ledger@next' '@web3-onboard/infinity-wallet@next' '@web3-onboard/injected-wallets@next' '@web3-onboard/magic@next' '@web3-onboard/phantom@next' '@web3-onboard/portis@next' '@web3-onboard/sequence@next' '@web3-onboard/trezor@next' '@web3-onboard/trust@next' '@web3-onboard/torus@next' '@web3-onboard/taho@next' '@web3-onboard/web3auth@next' '@web3-onboard/walletconnect@next' '@web3-onboard/enkrypt@next' '@web3-onboard/mew-wallet@next' '@web3-onboard/xdefi@next' '@web3-onboard/uauth@next' '@web3-onboard/zeal@next' '@web3-onboard/cede-store@next'"
"w3o-latest-prod": "yarn add '@web3-onboard/core' '@web3-onboard/coinbase' '@web3-onboard/transaction-preview' '@web3-onboard/dcent' '@web3-onboard/frontier' '@web3-onboard/fortmatic' '@web3-onboard/frame' '@web3-onboard/gas' '@web3-onboard/gnosis' '@web3-onboard/keepkey' '@web3-onboard/keystone' '@web3-onboard/ledger' '@web3-onboard/infinity-wallet' '@web3-onboard/injected-wallets' '@web3-onboard/magic' '@web3-onboard/phantom' '@web3-onboard/portis' '@web3-onboard/sequence' '@web3-onboard/trezor' '@web3-onboard/trust' '@web3-onboard/torus' '@web3-onboard/taho' '@web3-onboard/web3auth' '@web3-onboard/walletconnect' '@web3-onboard/enkrypt' '@web3-onboard/mew-wallet' '@web3-onboard/xdefi' '@web3-onboard/uauth' '@web3-onboard/zeal' '@web3-onboard/cede-store' '@web3-onboard/blocto'",
"w3o-latest-alpha": "yarn add '@web3-onboard/core@next' '@web3-onboard/coinbase@next' '@web3-onboard/transaction-preview@next' '@web3-onboard/dcent@next' '@web3-onboard/frontier@next' '@web3-onboard/fortmatic@next' '@web3-onboard/frame@next' '@web3-onboard/gas@next' '@web3-onboard/gnosis@next' '@web3-onboard/keepkey@next' '@web3-onboard/keystone@next' '@web3-onboard/ledger@next' '@web3-onboard/infinity-wallet@next' '@web3-onboard/injected-wallets@next' '@web3-onboard/magic@next' '@web3-onboard/phantom@next' '@web3-onboard/portis@next' '@web3-onboard/sequence@next' '@web3-onboard/trezor@next' '@web3-onboard/trust@next' '@web3-onboard/torus@next' '@web3-onboard/taho@next' '@web3-onboard/web3auth@next' '@web3-onboard/walletconnect@next' '@web3-onboard/enkrypt@next' '@web3-onboard/mew-wallet@next' '@web3-onboard/xdefi@next' '@web3-onboard/uauth@next' '@web3-onboard/zeal@next' '@web3-onboard/cede-store@next' '@web3-onboard/blocto@next'"
},
"devDependencies": {
"@algolia/client-search": "^4.17.0",
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 @@ -53,6 +53,7 @@ const intiOnboard = async (theme) => {
const { default: xdefiModule } = await import('@web3-onboard/xdefi')
const { default: cedeModule } = await import('@web3-onboard/cede-store')
const { default: frameModule } = await import('@web3-onboard/frame')
const { default: bloctoModule } = await import('@web3-onboard/blocto')
const { default: venlyModule } = await import('@web3-onboard/venly')
const INFURA_ID = '8b60d52405694345a99bcb82e722e0af'

Expand Down Expand Up @@ -108,6 +109,7 @@ const intiOnboard = async (theme) => {

const frame = frameModule()

const blocto = bloctoModule()
const venly = venlyModule({
clientId: 'blocknative',
environment: 'staging'
Expand Down Expand Up @@ -138,6 +140,7 @@ const intiOnboard = async (theme) => {
portis,
frame,
infinityWallet,
blocto
// venly
],
chains: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ We recommend you add the [Core Repo](../../modules/core.md#install) and consider
- [Portis](../../wallets/portis.md#install)
- [Web3Auth](../../wallets/web3auth.md#install)
- [Frame](../../wallets/frame.md#install)
- [Blocto](../../docs/wallets/blocto.md#install)

**Hardware Wallets**

Expand Down
88 changes: 88 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...1]blocto/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Blocto
---

# {$frontmatter.title}

Wallet module for connecting Blocto SDK to web3-onboard. Check out the [Blocto Developer Docs](https://docs.blocto.app/blocto-sdk/javascript-sdk/evm-sdk) for more information.

## Install

<Tabs values={['yarn', 'npm']}>
<TabPanel value="yarn">

```sh copy
yarn add @web3-onboard/blocto
```

</TabPanel>
<TabPanel value="npm">

```sh copy
npm install @web3-onboard/blocto
```

</TabPanel>
</Tabs>

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bloctoModule from '@web3-onboard/blocto'

// initialize the module with options
const blocto = bloctoModule()

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

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

## Build Environments

For build env configurations and setups please see the Build Env section [here](/docs/modules/core#build-environments)

### Webpack 4

Node built-ins are automatically bundled in v4 so that portion is handled automatically.

**Blocto** support will require a Babel to compile from es6 if not already supported. See config for Babel and Webpack4 as follows

`npm i --save-dev @babel/cli @babel/core @babel/node @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining @babel/plugin-syntax-bigint @babel/register`
**AND**
`npm i babel-loader`

**babel.config.js**

```javascript
module.exports = (api) => {
api.cache(true)
const plugins = [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-syntax-bigint'
]
return { plugins }
}
```

**webpack.config.js**

```javascript
config.module.rules = [
...otherModuleRules,
{
test: /\.js$/,
exclude: (_) => !/node_modules\/(@web3auth|@ethereumjs)/.test(_),
loader: 'babel-loader'
}
]
```
30 changes: 30 additions & 0 deletions packages/blocto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# @web3-onboard/blocto

## Wallet module for connecting Blocto SDK to web3-onboard

See [Blocto Developer Docs](https://docs.blocto.app/blocto-sdk/javascript-sdk/evm-sdk)

### Install

`npm i @web3-onboard/blocto`

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bloctoModule from '@web3-onboard/blocto'

// initialize the module with options
const blocto = bloctoModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
71 changes: 71 additions & 0 deletions packages/blocto/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "@web3-onboard/blocto",
"version": "2.0.0-alpha.1",
"description": "Blocto 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",
"Web3",
"EVM",
"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",
"Tally Ho",
"Blocto"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/core"
},
"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": {
"@ethersproject/providers": "^5.5.0",
"@types/lodash.uniqby": "^4.7.6",
"@types/node": "^17.0.21",
"ts-node": "^10.2.1",
"typescript": "^4.5.5",
"window": "^4.2.7"
},
"dependencies": {
"@web3-onboard/common": "^2.3.1",
"@blocto/sdk": "^0.4.6"
}
}
14 changes: 14 additions & 0 deletions packages/blocto/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default `
<svg width="32" height="32" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2233_2387)">
<rect width="60" height="60" rx="12" fill="white"/>
<path d="M32.9028 18.3063C28.3911 18.3063 23.9873 20.0459 20.6952 23.1319C17.0843 26.5176 14.7992 31.5177 13.4893 36.2212C12.6314 39.2992 12.2016 42.4915 12.2016 45.6853C12.2016 46.6511 12.2412 47.6089 12.3174 48.5556C12.4109 49.7069 13.5321 50.5046 14.6485 50.2033C15.6222 49.9416 16.6466 49.8005 17.7028 49.8005C19.8722 49.8005 21.9052 50.3904 23.648 51.4212C23.6908 51.4466 23.732 51.4719 23.7748 51.4957C26.6071 53.1846 29.9484 54.1123 33.5117 53.9934C42.8062 53.6857 50.399 46.123 50.7416 36.8301C51.1158 26.6635 42.9869 18.3047 32.9044 18.3047L32.9028 18.3063ZM32.9028 44.312C28.3975 44.312 24.7454 40.6599 24.7454 36.1562C24.7454 31.6525 28.3975 27.9987 32.9028 27.9987C37.4081 27.9987 41.0602 31.6509 41.0602 36.1562C41.0602 40.6614 37.4081 44.312 32.9028 44.312Z" fill="#14AAFF"/>
<path d="M25.5636 12.6826C25.5636 15.0344 24.3315 17.2164 22.308 18.4153C21.0377 19.1686 19.8468 20.0582 18.7684 21.0715C16.3755 23.3139 14.5898 26.0653 13.2673 28.7929C13.0072 29.3304 12.2 29.1402 12.2 28.5423V12.6826C12.2 8.99242 15.1924 6 18.8826 6C22.5728 6 25.5652 8.99242 25.5652 12.6826H25.5636Z" fill="#0075FF"/>
</g>
<defs>
<clipPath id="clip0_2233_2387">
<rect width="60" height="60" fill="white"/>
</clipPath>
</defs>
</svg>
`
86 changes: 86 additions & 0 deletions packages/blocto/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import type { WalletInit } from '@web3-onboard/common'

function BloctoWallet(): WalletInit {
if (typeof window === 'undefined') return () => null
return () => {
return {
label: 'Blocto',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async ({ chains }) => {
const { default: BloctoSDK } = await import('@blocto/sdk')

const { createEIP1193Provider } = await import('@web3-onboard/common')

const [defaultChain] = chains

const instance = new BloctoSDK({
ethereum: {
chainId: defaultChain.id,
rpc: defaultChain.rpcUrl
}
})
const bloctoProvider: any = instance.ethereum

const provider = createEIP1193Provider(bloctoProvider, {
eth_selectAccounts: null,
wallet_switchEthereumChain: async ({ params, baseRequest }) => {
const chain = chains.find(function (item) {
return item.id === (params && params[0] && params[0].chainId)
})
if (!chain) throw new Error('chain must be set before switching')
const providerRpcurl =
bloctoProvider.switchableNetwork[chain.id] &&
bloctoProvider.switchableNetwork[chain.id].rpc_url
const chainUrl = chain.rpcUrl
if (providerRpcurl !== chainUrl) {
await baseRequest({
method: 'wallet_addEthereumChain',
params: [
{
chainId: chain.id,
rpcUrls: [chainUrl]
}
]
})
}
await baseRequest({
method: 'wallet_switchEthereumChain',
params: [{ chainId: chain.id }]
})
return null
},
eth_chainId: async ({ baseRequest }) => {
const chainId = await baseRequest({ method: 'eth_chainId' })
return `0x${parseInt(chainId).toString(16)}`
}
})

provider.disconnect = () =>
instance.ethereum
? instance.ethereum.request({ method: 'wallet_disconnect' })
: null
// patch the chainChanged event
const on = bloctoProvider.on.bind(bloctoProvider)
bloctoProvider.on = (
event: string,
listener: (arg0: string) => void
) => {
on(event, (val: any) => {
if (event === 'chainChanged') {
listener(`0x${(val as number).toString(16)}`)
return
}
listener(val)
})
return bloctoProvider
}
return {
provider,
instance
}
}
}
}
}

export default BloctoWallet
Loading