Skip to content

Commit

Permalink
feat: add @web3-onboard/okx (#2229)
Browse files Browse the repository at this point in the history
* feat: add @web3-onboard/okx

* feat(okx sdk): use createDownloadMessage

* Update packages/okx/src/types.ts

* Prettier

---------

Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
  • Loading branch information
vanishcode and Adamj1232 authored Jun 13, 2024
1 parent 9958cfe commit 5626431
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/trust
steps:
- node-build-steps
build-okx:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/okx
steps:
- node-build-steps
build-frontier:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -552,6 +558,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/trust
steps:
- node-staging-build-steps
build-staging-okx:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/okx
steps:
- node-staging-build-steps
build-staging-frontier:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -851,6 +863,12 @@ workflows:
<<: *deploy_production_filters
- build-staging-trust:
<<: *deploy_staging_filters
okx:
jobs:
- build-okx:
<<: *deploy_production_filters
- build-staging-okx:
<<: *deploy_staging_filters
frontier:
jobs:
- build-frontier:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ For full documentation, check out the README.md for each package or the [docs pa
- [Arcana](packages/arcana-auth/README.md)
- [Coinbase](packages/coinbase/README.md)
- [Trust](packages/trust/README.md)
- [OKX](packages/okx/README.md)
- [WalletConnect](packages/walletconnect/README.md)
- [Safe](packages/gnosis/README.md)
- [Magic](packages/magic/README.md)
Expand Down
5 changes: 3 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' '@web3-onboard/blocto' '@web3-onboard/capsule' '@web3-onboard/particle-network' '@web3-onboard/metamask' '@web3-onboard/bitget' '@web3-onboard/arcana-auth' '@web3-onboard/venly'",
"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' '@web3-onboard/capsule@next' '@web3-onboard/metamask@next' '@web3-onboard/bitget@next' '@web3-onboard/arcana-auth@next' '@web3-onboard/venly@next' '@web3-onboard/particle-network@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/okx' '@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' '@web3-onboard/capsule' '@web3-onboard/particle-network' '@web3-onboard/metamask' '@web3-onboard/bitget' '@web3-onboard/arcana-auth' '@web3-onboard/venly'",
"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/okx@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' '@web3-onboard/capsule@next' '@web3-onboard/metamask@next' '@web3-onboard/bitget@next' '@web3-onboard/arcana-auth@next' '@web3-onboard/venly@next' '@web3-onboard/particle-network@next'"
},
"devDependencies": {
"@algolia/client-search": "^4.17.0",
Expand Down Expand Up @@ -72,6 +72,7 @@
"@web3-onboard/magic": "^2.2.1",
"@web3-onboard/metamask": "^2.1.1",
"@web3-onboard/mew-wallet": "^2.1.1",
"@web3-onboard/okx": "2.0.0-alpha.1",
"@web3-onboard/particle-network": "^2.1.1",
"@web3-onboard/phantom": "^2.1.1",
"@web3-onboard/portis": "^2.2.1",
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: torusModule } = await import('@web3-onboard/torus')
const { default: uauthModule } = await import('@web3-onboard/uauth')
const { default: trustModule } = await import('@web3-onboard/trust')
const { default: okxModule } = await import('@web3-onboard/okx')
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')
Expand Down Expand Up @@ -93,6 +94,7 @@ const intiOnboard = async (theme) => {
const taho = tahoModule()
const torus = torusModule()
const trust = trustModule()
const okx = okxModule()
const xdefi = xdefiModule()
const cede = cedeModule()
const bitget = bitgetModule()
Expand Down Expand Up @@ -152,6 +154,7 @@ const intiOnboard = async (theme) => {
ledger,
trezor,
trust,
okx,
gnosis,
taho,
bitget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ We recommend you add the [Core Repo](../../modules/core.md#install) and consider
- [Magic](../../wallets/magic.md#login-options)
- [MetaMask](../../wallets/metamask.md#install)
- [MEW](../../wallets/mewwallet.md#install)
- [OKX](../../wallets/okx.md#install)
- [Portis](../../wallets/portis.md#install)
- [Web3Auth](../../wallets/web3auth.md#install)
- [WalletConnect](../../wallets/walletconnect.md#install)
Expand Down
50 changes: 50 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...37]okx/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: OKX Wallet
---

# {$frontmatter.title}

Wallet module for connecting OKX wallet through Web3 Onboard

### Install

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

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

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

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

</TabPanel>
</Tabs>

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import okxWallet from '@web3-onboard/okx'

const okx = okxWallet()

const onboard = Onboard({
// ... other Onboard options
wallets: [
okx
//... 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)
10 changes: 8 additions & 2 deletions docs/src/routes/examples/[...1]connect-wallet/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Remember- if you used create-react-app, please follow the [additional setup inst
<TabPanel value="yarn">

```sh copy
yarn add @web3-onboard/react @web3-onboard/injected-wallets @web3-onboard/infinity-wallet @web3-onboard/fortmatic @web3-onboard/gnosis @web3-onboard/keepkey @web3-onboard/keystone @web3-onboard/ledger @web3-onboard/portis @web3-onboard/trezor @web3-onboard/walletconnect @web3-onboard/coinbase @web3-onboard/magic @web3-onboard/dcent @web3-onboard/sequence @web3-onboard/taho @web3-onboard/trust @web3-onboard/frontier
yarn add @web3-onboard/react @web3-onboard/injected-wallets @web3-onboard/infinity-wallet @web3-onboard/fortmatic @web3-onboard/gnosis @web3-onboard/keepkey @web3-onboard/keystone @web3-onboard/ledger @web3-onboard/portis @web3-onboard/trezor @web3-onboard/walletconnect @web3-onboard/coinbase @web3-onboard/magic @web3-onboard/dcent @web3-onboard/sequence @web3-onboard/taho @web3-onboard/trust @web3-onboard/frontier @web3-onboard/okx
```

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

```sh copy
npm install @web3-onboard/react @web3-onboard/injected-wallets @web3-onboard/infinity-wallet @web3-onboard/fortmatic @web3-onboard/gnosis @web3-onboard/keepkey @web3-onboard/keystone @web3-onboard/ledger @web3-onboard/portis @web3-onboard/trezor @web3-onboard/walletconnect @web3-onboard/coinbase @web3-onboard/magic @web3-onboard/dcent @web3-onboard/sequence @web3-onboard/taho @web3-onboard/trust @web3-onboard/frontier
npm install @web3-onboard/react @web3-onboard/injected-wallets @web3-onboard/infinity-wallet @web3-onboard/fortmatic @web3-onboard/gnosis @web3-onboard/keepkey @web3-onboard/keystone @web3-onboard/ledger @web3-onboard/portis @web3-onboard/trezor @web3-onboard/walletconnect @web3-onboard/coinbase @web3-onboard/magic @web3-onboard/dcent @web3-onboard/sequence @web3-onboard/taho @web3-onboard/trust @web3-onboard/frontier @web3-onboard/okx
```

</TabPanel>
Expand Down Expand Up @@ -60,6 +60,7 @@ import dcentModule from '@web3-onboard/dcent'
import sequenceModule from '@web3-onboard/sequence'
import tahoModule from '@web3-onboard/taho'
import trustModule from '@web3-onboard/trust'
import okxModule from '@web3-onboard/okx'
import frontierModule from '@web3-onboard/frontier'
import ConnectWallet from './ConnectWallet'

Expand All @@ -86,6 +87,7 @@ const safe = safeModule()
const sequence = sequenceModule()
const taho = tahoModule() // Previously named Tally Ho wallet
const trust = trustModule()
const okx = okxModule()
const frontier = frontierModule()

const trezorOptions = {
Expand All @@ -105,6 +107,7 @@ const wallets = [
sequence,
injected,
trust,
okx,
frontier,
taho,
ledger,
Expand Down Expand Up @@ -324,6 +327,7 @@ import dcentModule from '@web3-onboard/dcent'
import sequenceModule from '@web3-onboard/sequence'
import tahoModule from '@web3-onboard/taho'
import trustModule from '@web3-onboard/trust'
import okxModule from '@web3-onboard/okx'
import frontierModule from '@web3-onboard/frontier'

const INFURA_KEY = ''
Expand All @@ -349,6 +353,7 @@ const safe = safeModule()
const sequence = sequenceModule()
const taho = tahoModule() // Previously named Tally Ho wallet
const trust = trustModule()
const okx = okxModule()
const frontier = frontierModule()

const trezorOptions = {
Expand All @@ -375,6 +380,7 @@ const wallets = [
coinbase,
dcent,
trust,
okx,
frontier,
trezor,
walletConnect,
Expand Down
1 change: 1 addition & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@web3-onboard/magic": "^2.2.1",
"@web3-onboard/metamask": "^2.1.1",
"@web3-onboard/mew-wallet": "^2.1.1",
"@web3-onboard/okx": "2.0.0-alpha.1",
"@web3-onboard/particle-network": "^2.1.1",
"@web3-onboard/phantom": "^2.1.1",
"@web3-onboard/portis": "^2.2.1",
Expand Down
6 changes: 5 additions & 1 deletion packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import uauthModule from '@web3-onboard/uauth'
import phantomModule from '@web3-onboard/phantom'
import trustModule from '@web3-onboard/trust'
import okxModule from '@web3-onboard/okx'
import frontierModule from '@web3-onboard/frontier'
import bloctoModule from '@web3-onboard/blocto'
import cedeStoreModule from '@web3-onboard/cede-store'
Expand Down Expand Up @@ -100,7 +101,8 @@
displayUnavailable: [
ProviderLabel.MetaMask,
ProviderLabel.Trust,
ProviderLabel.Phantom
ProviderLabel.Phantom,
ProviderLabel.OKXWallet
]
// but only show Binance and Bitski wallet if they are available
// filter: {
Expand Down Expand Up @@ -182,6 +184,7 @@
const zeal = zealModule()
const phantom = phantomModule()
const trust = trustModule()
const okx = okxModule()
const frontier = frontierModule()
const cedeStore = cedeStoreModule()
const blocto = bloctoModule()
Expand Down Expand Up @@ -267,6 +270,7 @@
phantom,
safe,
trust,
okx,
tallyho,
bitget,
enkrypt,
Expand Down
33 changes: 33 additions & 0 deletions packages/okx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# @web3-onboard/okx

## Wallet module for connecting OKX Wallet through web3-onboard

OKX Wallet SDK wallet module for connecting to Web3-Onboard. 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.

### Install

**NPM**
`npm i @web3-onboard/core @web3-onboard/okx`

**Yarn**
`yarn add @web3-onboard/core @web3-onboard/okx`

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import okxModule from '@web3-onboard/okx'

const okx = okxModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
66 changes: 66 additions & 0 deletions packages/okx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@web3-onboard/okx",
"version": "2.0.0-alpha.1",
"description": "OKX Wallet SDK wallet module for connecting to Web3-Onboard. 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",
"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",
"Enkrypt",
"OKX"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/okx"
},
"homepage": "https://www.blocknative.com/onboard",
"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": {
"@types/node": "^17.0.21",
"typescript": "^5.4.5"
},
"dependencies": {
"@web3-onboard/common": "^2.4.1"
}
}
5 changes: 5 additions & 0 deletions packages/okx/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default `<svg width="100%" height="100%" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="1000" height="1000" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M393.949 218.518H231.049C224.129 218.518 218.519 224.128 218.519 231.048V393.948C218.519 400.869 224.129 406.479 231.049 406.479H393.949C400.87 406.479 406.48 400.869 406.48 393.948V231.048C406.48 224.128 400.87 218.518 393.949 218.518ZM581.992 406.479H419.092C412.172 406.479 406.561 412.09 406.561 419.01V581.91C406.561 588.831 412.172 594.441 419.092 594.441H581.992C588.913 594.441 594.523 588.831 594.523 581.91V419.01C594.523 412.09 588.913 406.479 581.992 406.479ZM606.974 218.518H769.874C776.794 218.518 782.405 224.128 782.405 231.048V393.948C782.405 400.869 776.794 406.479 769.874 406.479H606.974C600.053 406.479 594.443 400.869 594.443 393.948V231.048C594.443 224.128 600.053 218.518 606.974 218.518ZM393.95 594.442H231.049C224.129 594.442 218.519 600.052 218.519 606.973V769.873C218.519 776.793 224.129 782.404 231.049 782.404H393.95C400.87 782.404 406.48 776.793 406.48 769.873V606.973C406.48 600.052 400.87 594.442 393.95 594.442ZM606.974 594.442H769.874C776.794 594.442 782.405 600.052 782.405 606.973V769.873C782.405 776.793 776.794 782.404 769.874 782.404H606.974C600.053 782.404 594.443 776.793 594.443 769.873V606.973C594.443 600.052 600.053 594.442 606.974 594.442Z" fill="white"/>
</svg>
`
Loading

0 comments on commit 5626431

Please sign in to comment.