Skip to content

Commit

Permalink
feat: bitgetWallet support (#1919)
Browse files Browse the repository at this point in the history
* feat:add @web3-onboard/bitget packages

* dosc:bitget Wallet

* feat:Upgrade npm package

* feat:Change package name

* feat:Change package name

* Update packages/bitkeep/package.json

* Update packages/bitget-wallet/package.json

* Format code

* Add CI

* Rename bitget

* delete wrong type

* Test and remove type file for bitkeep

* Import deps dynamically

* Add bitkeep and bitget to docs site

---------

Co-authored-by: kean <[email protected]@bitget.com>
Co-authored-by: Adam Carpenter <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2023
1 parent ffb01e3 commit 24c825d
Show file tree
Hide file tree
Showing 44 changed files with 534 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,18 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/venly
steps:
- node-build-steps
build-bitget:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/bitget
steps:
- node-build-steps
build-bitkeep:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/bitkeep
steps:
- node-build-steps

# Build staging/Alpha releases
build-staging-core:
Expand Down Expand Up @@ -661,6 +673,18 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/venly
steps:
- node-staging-build-steps
build-staging-bitget:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/bitget
steps:
- node-staging-build-steps
build-staging-bitkeep:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/bitkeep
steps:
- node-staging-build-steps

workflows:
version: 2
Expand Down Expand Up @@ -911,3 +935,15 @@ workflows:
<<: *deploy_production_filters
- build-staging-venly:
<<: *deploy_staging_filters
bitget:
jobs:
- build-bitget:
<<: *deploy_production_filters
- build-staging-bitget:
<<: *deploy_staging_filters
bitkeep:
jobs:
- build-bitkeep:
<<: *deploy_production_filters
- build-staging-bitkeep:
<<: *deploy_staging_filters
48 changes: 48 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...2]bitget/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Bitget
---

# {$frontmatter.title}

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

Bitget 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

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

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

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

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

</TabPanel>
</Tabs>

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bitgetWalletModule from '@web3-onboard/bitget'

const bitgetWallet = bitgetWalletModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
48 changes: 48 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...3]bitkeep/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: BitKeep
---

# {$frontmatter.title}

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

BitKeep 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

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

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

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

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

</TabPanel>
</Tabs>

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bitKeepWalletModule from '@web3-onboard/bitkeep'

const bitKeepWallet = bitKeepWalletModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
33 changes: 33 additions & 0 deletions packages/bitget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# @web3-onboard/bitget

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

Bitget 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/bitget`

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

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bitgetWalletModule from '@web3-onboard/bitget'

const bitgetWallet = bitgetWalletModule()

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

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
67 changes: 67 additions & 0 deletions packages/bitget/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "@web3-onboard/bitget",
"version": "2.0.0-alpha.1",
"description": "bitget-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",
"bitgetWallet"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/bitget-wallet"
},
"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": "^4.5.5"
},
"dependencies": {
"@bitget-wallet/web3-sdk": "^0.0.6",
"@web3-onboard/common": "^2.3.3"
}
}
51 changes: 51 additions & 0 deletions packages/bitget/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { WalletInit, EIP1193Provider } from '@web3-onboard/common'

let bitgetDependencies: any = null
let bitgetAdapter: any = null

const loadBitgetDependencies = async (getAdapter?: boolean) => {
if (!bitgetDependencies) {
bitgetDependencies = await import('@bitget-wallet/web3-sdk')
}
if (getAdapter && !bitgetAdapter) {
bitgetAdapter = new bitgetDependencies.LegacyEip1193Adapter()
return bitgetAdapter
}
if (getAdapter) {
return bitgetAdapter
}
return bitgetDependencies
}

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

return () => {
return {
label: 'Bitget',
getIcon: async () => {
const sdkAdapter = await loadBitgetDependencies(true)
return sdkAdapter.getLogo()
},
getInterface: async () => {
const {
currentProvider,
getIsInstall,
getDownload,
installWalletMessage
} = await loadBitgetDependencies()

let provider: EIP1193Provider
if (getIsInstall()) {
provider = currentProvider()
} else {
window.open(getDownload(), '_blank')
throw new Error(installWalletMessage)
}
return { provider }
}
}
}
}

export default bitget
15 changes: 15 additions & 0 deletions packages/bitget/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"]
}
}
33 changes: 33 additions & 0 deletions packages/bitkeep/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# @web3-onboard/bitkeep

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

Bitkeep 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/bitkeep`

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

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import bitkeepModule from '@web3-onboard/bitkeep'

const bitKeep = bitkeepModule()

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

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

0 comments on commit 24c825d

Please sign in to comment.