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 gate wallet #2253

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/bitget
steps:
- node-build-steps
build-gate:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/gate
steps:
- node-build-steps
build-bitkeep:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -744,6 +750,13 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/bitget
steps:
- node-staging-build-steps

build-staging-gate:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/gate
steps:
- node-staging-build-steps
build-staging-bitkeep:
docker:
- image: cimg/node:16.13.1
Expand Down Expand Up @@ -1067,6 +1080,12 @@ workflows:
<<: *deploy_production_filters
- build-staging-bitget:
<<: *deploy_staging_filters
gate:
jobs:
- build-gate:
<<: *deploy_production_filters
- build-staging-gate:
<<: *deploy_staging_filters
bitkeep:
jobs:
- build-bitkeep:
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/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'"
"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/gate' '@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/gate@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 @@ -90,6 +90,7 @@
"@web3-onboard/web3auth": "^2.3.1",
"@web3-onboard/xdefi": "^2.1.1",
"@web3-onboard/zeal": "^2.1.1",
"@web3-onboard/gate": "2.0.0-alpha.1",
"animejs": "^3.2.1",
"bnc-sdk": "^4.6.6",
"ethers": "^5.7.0",
Expand Down
4 changes: 4 additions & 0 deletions docs/src/lib/services/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const intiOnboard = async theme => {
const { default: bloctoModule } = await import('@web3-onboard/blocto')
const { default: venlyModule } = await import('@web3-onboard/venly')
const { default: bitgetModule } = await import('@web3-onboard/bitget')
const { default: gateModule } = await import('@web3-onboard/gate')
// // const { default: capsuleModule, Environment } = await import('@web3-onboard/capsule')
const { default: finoaConnectModule } = await import('@web3-onboard/finoaconnect')
const { default: capsuleModule, Environment } = await import('@web3-onboard/capsule')
const { default: particleAuthModule } = await import('@web3-onboard/particle-network')
Expand Down Expand Up @@ -99,6 +101,7 @@ const intiOnboard = async theme => {
const xdefi = xdefiModule()
const cede = cedeModule()
const bitget = bitgetModule()
const gate = gateModule()

const portis = portisModule({
apiKey: 'b2b7586f-2b1e-4c30-a7fb-c2d1533b153b'
Expand Down Expand Up @@ -162,6 +165,7 @@ const intiOnboard = async theme => {
gnosis,
taho,
bitget,
gate,
xdefi,
uauth,
cede,
Expand Down
50 changes: 50 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...38]gate/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Gate Wallet
---

# {$frontmatter.title}

Wallet module for connecting Gate wallet through Web3 Onboard

### Install

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

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

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

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

</TabPanel>
</Tabs>

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import gateWallet from '@web3-onboard/gate'

const gate = gateWallet()

const onboard = Onboard({
// ... other Onboard options
wallets: [
gate
//... 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)
3 changes: 3 additions & 0 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import arcanaAuthModule from '@web3-onboard/arcana-auth'
import venlyModule from '@web3-onboard/venly'
import bitgetModule from '@web3-onboard/bitget'
import gateModule from '@web3-onboard/gate'
import bloomModule from '@web3-onboard/bloom'
import particleAuthModule from '@web3-onboard/particle-network'
import finoaConnectModule from '@web3-onboard/finoaconnect'
Expand Down Expand Up @@ -264,6 +265,7 @@

const dcent = dcentModule()
const bitget = bitgetModule()
const gate = gateModule()
const frameWallet = frameModule()
const sequence = sequenceModule()
const enkrypt = enkryptModule()
Expand Down Expand Up @@ -302,6 +304,7 @@
okx,
tallyho,
bitget,
gate,
bloom,
enkrypt,
infinityWallet,
Expand Down
33 changes: 33 additions & 0 deletions packages/gate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# @web3-onboard/gate

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

Gate 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/gate`

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

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import gatewalletModule from '@web3-onboard/gate'

const gatewallet = gatewalletModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
66 changes: 66 additions & 0 deletions packages/gate/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@web3-onboard/gate",
"version": "2.0.0-alpha.1",
"description": "Gate 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",
"Gate Wallet"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/gate"
},
"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"
}
}
32 changes: 32 additions & 0 deletions packages/gate/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default `<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" viewBox="0 0 192 192" fill="none">
<g clip-path="url(#clip0_1397_3764)">
<rect width="192" height="192" rx="8" fill="white"/>
<g clip-path="url(#clip1_1397_3764)">
<rect y="154.367" width="192" height="37.632" fill="#0255EB"/>
<path d="M96.0002 105.88C88.2941 105.88 80.9037 102.82 75.4547 97.3722C70.0057 91.9248 66.9445 84.5365 66.9445 76.8327C66.9445 69.1289 70.0057 61.7406 75.4547 56.2931C80.9037 50.8457 88.2941 47.7854 96.0002 47.7854V24.0054C85.5514 24.0054 75.3372 27.1029 66.6493 32.9063C57.9614 38.7097 51.19 46.9582 47.1914 56.6089C43.1928 66.2596 42.1466 76.8789 44.1851 87.124C46.2235 97.3691 51.2551 106.78 58.6436 114.166C66.032 121.552 75.4454 126.583 85.6935 128.62C95.9416 130.658 106.564 129.612 116.217 125.615C125.871 121.618 134.122 114.848 139.927 106.163C145.732 97.4774 148.83 87.2662 148.83 76.8203H125.031C125.036 80.6348 124.289 84.4127 122.832 87.9382C121.375 91.4636 119.238 94.6675 116.541 97.3664C113.845 100.065 110.643 102.206 107.118 103.667C103.594 105.128 99.8157 105.88 96.0002 105.88Z" fill="#0255EB"/>
<path d="M125.056 47.771H96V76.8183H125.056V47.771Z" fill="#00E697"/>
<path d="M191.975 149.995C163.17 143.085 130.573 139.182 95.9877 139.182C61.402 139.182 28.8049 143.085 0 149.995V154.317C0 164.307 3.96916 173.888 11.0344 180.952C18.0995 188.016 27.682 191.985 37.6737 191.985H154.326C164.318 191.985 173.9 188.016 180.966 180.952C188.031 173.888 192 164.307 192 154.317L191.975 149.995Z" fill="url(#paint0_linear_1397_3764)"/>
<path d="M191.975 154.338C163.387 147.125 130.709 143.031 95.9877 143.031C61.2661 143.031 28.5888 147.125 0 154.338C0 164.328 3.96916 173.909 11.0344 180.973C18.0995 188.037 27.682 192.005 37.6737 192.005H154.326C164.318 192.005 173.9 188.037 180.966 180.973C188.031 173.909 192 164.328 192 154.338H191.975Z" fill="#0255EB"/>
<path d="M75.2706 176.816H70.1994L66.2463 159.242L62.2128 176.816H57.1416L52.6758 156.648H56.1595L59.7359 173.593L63.7385 156.648H68.7849L72.6763 173.531L76.2341 156.648H79.7796L75.2706 176.816Z" fill="white"/>
<path d="M96.0743 161.521V176.792H92.7635V174.742C92.1447 175.455 91.3829 176.029 90.5275 176.428C89.6489 176.842 88.6883 177.053 87.717 177.045C86.3835 177.052 85.0752 176.682 83.943 175.977C82.1911 174.877 80.9277 173.147 80.413 171.144C79.8982 169.14 80.1712 167.016 81.1758 165.208C81.826 164.029 82.7737 163.041 83.9245 162.343C85.059 161.645 86.3665 161.279 87.6985 161.287C88.6698 161.279 89.6303 161.49 90.5089 161.904C91.3589 162.298 92.1197 162.862 92.7449 163.559V161.515L96.0743 161.521ZM90.5151 173.378C91.243 172.953 91.8477 172.347 92.2694 171.618C92.687 170.887 92.9003 170.057 92.887 169.216C92.8944 168.576 92.7744 167.942 92.534 167.35C92.2937 166.757 91.9378 166.218 91.487 165.765C91.0363 165.311 90.4997 164.952 89.9087 164.708C89.3176 164.464 88.6839 164.34 88.0444 164.343C87.1995 164.338 86.3689 164.562 85.6416 164.992C84.9083 165.415 84.2975 166.022 83.8689 166.752C83.4268 167.486 83.198 168.328 83.2079 169.185C83.206 170.033 83.427 170.866 83.8487 171.602C84.2703 172.338 84.878 172.95 85.6107 173.378C86.3526 173.802 87.1926 174.026 88.0475 174.026C88.9023 174.026 89.7424 173.802 90.4842 173.378H90.5151Z" fill="white"/>
<path d="M99.2749 176.816V156.648H102.592V176.816H99.2749Z" fill="white"/>
<path d="M105.76 176.816V156.648H109.077V176.816H105.76Z" fill="white"/>
<path d="M123.567 162.341C124.762 163.028 125.754 164.017 126.442 165.21C127.131 166.403 127.492 167.757 127.49 169.134C127.486 169.547 127.457 169.959 127.403 170.369H115.013C115.137 171.062 115.411 171.719 115.816 172.295C116.266 172.879 116.851 173.345 117.52 173.654C118.184 173.938 118.898 174.085 119.62 174.086C120.477 174.082 121.322 173.884 122.091 173.506C122.781 173.198 123.398 172.748 123.901 172.184L126.816 172.987C126.17 174.229 125.15 175.237 123.901 175.871C122.584 176.624 121.094 177.022 119.577 177.025C118.189 177.033 116.825 176.664 115.63 175.957C114.437 175.262 113.445 174.268 112.752 173.073C112.052 171.876 111.684 170.514 111.684 169.128C111.684 167.741 112.052 166.379 112.752 165.182C113.442 163.99 114.435 163.001 115.63 162.317C116.83 161.625 118.192 161.26 119.577 161.26C120.963 161.26 122.324 161.625 123.524 162.317L123.567 162.341ZM117.619 164.774C116.99 165.064 116.43 165.485 115.976 166.009C115.532 166.533 115.221 167.155 115.068 167.825H124.265C124.094 167.156 123.773 166.536 123.326 166.009C122.877 165.489 122.324 165.068 121.702 164.774C121.065 164.47 120.367 164.311 119.661 164.311C118.954 164.311 118.256 164.47 117.619 164.774Z" fill="white"/>
<path d="M131.696 157.891H134.951V161.546H139.652V164.461H134.951V171.605C134.946 172.011 135.058 172.41 135.272 172.754C135.482 173.099 135.772 173.387 136.119 173.594C136.472 173.802 136.876 173.911 137.286 173.909H139.794V176.817H136.594C135.725 176.83 134.87 176.601 134.124 176.156C133.379 175.722 132.762 175.1 132.332 174.353C131.894 173.604 131.666 172.751 131.671 171.883V164.473H128.793V161.559H131.671L131.696 157.891Z" fill="white"/>
</g>
</g>
<defs>
<linearGradient id="paint0_linear_1397_3764" x1="-130.24" y1="165.587" x2="330.633" y2="165.587" gradientUnits="userSpaceOnUse">
<stop offset="0.25" stop-color="white"/>
<stop offset="0.5" stop-color="#00E79D"/>
<stop offset="0.75" stop-color="white"/>
</linearGradient>
<clipPath id="clip0_1397_3764">
<rect width="192" height="192" rx="8" fill="white"/>
</clipPath>
<clipPath id="clip1_1397_3764">
<rect width="192" height="192" fill="white"/>
</clipPath>
</defs>
</svg>
`
42 changes: 42 additions & 0 deletions packages/gate/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
type WalletInit,
type EIP1193Provider,
createDownloadMessage
} from '@web3-onboard/common'
import { createEIP1193Provider } from '@web3-onboard/common'

import { CustomWindow } from './types.js'

declare const window: CustomWindow

const gate = (): WalletInit => {
if (typeof window === 'undefined') return () => null

return ({ device }) => {
return {
label: 'Gate Wallet',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async () => {
const gatewalletInjectionExists = window.hasOwnProperty('gatewallet')

let provider: EIP1193Provider

if (gatewalletInjectionExists) {
provider = createEIP1193Provider(window['gatewallet'])
} else {
const downloadUrl =
device.type === 'mobile'
? `https://gateio.onelink.me/DmA6/web3?dapp_url=${encodeURIComponent(window.location.href)}`
: 'https://www.gate.io/mobileapp'
throw new Error(createDownloadMessage('Gate Wallet', downloadUrl))
}
return {
provider
}
},
platforms: ['all']
}
}
}

export default gate
5 changes: 5 additions & 0 deletions packages/gate/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { EIP1193Provider } from '@web3-onboard/common'

export interface CustomWindow extends Window {
gatewallet?: EIP1193Provider
}
15 changes: 15 additions & 0 deletions packages/gate/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],

"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"declarationDir": "dist",
"paths": {
"*": ["./src/*", "./node_modules/*"]
},
"typeRoots": ["node_modules/@types"]
}
}
1 change: 1 addition & 0 deletions packages/injected/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const WALLET_NAMES: { [key: string]: string } = {
meetone: 'MeetOne',
frame: 'Frame',
bitget: 'Bitget Wallet',
gate: 'Gate Wallet',
sequence: 'Sequence',
core: 'Core',
enkrypt: 'Enkrypt',
Expand Down
Loading