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

Feature/okxwallet #1742

Closed
wants to merge 4 commits into from
Closed
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 @@ -395,6 +395,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-build-steps
build-okxwallet:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/okxwallet
steps:
- node-build-steps

# Build staging/Alpha releases
build-staging-core:
Expand Down Expand Up @@ -625,6 +631,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-staging-build-steps
build-staging-okxwallet:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/okxwallet
steps:
- node-staging-build-steps

workflows:
version: 2
Expand Down Expand Up @@ -857,3 +869,9 @@ workflows:
<<: *deploy_production_filters
- build-staging-cede-store:
<<: *deploy_staging_filters
okxwallet:
jobs:
- build-okxwallet:
<<: *deploy_production_filters
- build-staging-okxwallet:
<<: *deploy_staging_filters
45 changes: 45 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...28]okxwallet/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# OKX Wallet

Wallet module for connecting Okx wallet through web3-onboard

### Install

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

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

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

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

</TabPanel>
</Tabs>

## Usage

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

const okxWalletModule = okxWallet()

const onboard = Onboard({
// ... other Onboard options
wallets: [
okxWalletModule
//... 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)
29 changes: 29 additions & 0 deletions packages/okxwallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# @web3-onboard/okxwallet

### Install

`npm i @web3-onboard/okxwallet`

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import okxWalletModule from '@web3-onboard/okxwallet'

// initialize the module with options
const okxWalletSdk = okxWalletModule()

// can also initialize with no options...
// const okxWalletSdk = okxWalletModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
65 changes: 65 additions & 0 deletions packages/okxwallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@web3-onboard/okxwallet",
"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 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",
"OKX",
"OKX Wallet"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/okxwallet"
},
"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.2.3"
}
}
5 changes: 5 additions & 0 deletions packages/okxwallet/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>
`
35 changes: 35 additions & 0 deletions packages/okxwallet/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { WalletInit, EIP1193Provider } from '@web3-onboard/common'

import { CustomWindow } from './types.js'
declare const window: CustomWindow

function okxwallet(): WalletInit {
if (typeof window === 'undefined') return () => null

return () => {
return {
label: 'OKX Wallet',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async () => {
let provider: EIP1193Provider

if (window.okxwallet) {
// directly use the window.okxwallet injection
provider = window.okxwallet
} else {
// OKX wallet extension is not installed
// send user to install page
window.open('https://okx.com/download', '_blank')
throw new Error('Please Install OKX wallet to use this wallet')
}

return {
provider
}
},
platforms: ['all']
}
}
}

export default okxwallet
4 changes: 4 additions & 0 deletions packages/okxwallet/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { EIP1193Provider } from '@web3-onboard/common'
export interface CustomWindow extends Window {
okxwallet: EIP1193Provider
}
14 changes: 14 additions & 0 deletions packages/okxwallet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],

"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declarationDir": "dist",
"paths": {
"*": ["./src/*", "./node_modules/*"]
},
"typeRoots": ["node_modules/@types"],
}
}