diff --git a/.circleci/config.yml b/.circleci/config.yml index a14a74ca5..3539740e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 @@ -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: diff --git a/docs/package.json b/docs/package.json index 2c6cb1247..4f1d08d93 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", @@ -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", diff --git a/docs/src/lib/services/onboard.js b/docs/src/lib/services/onboard.js index 189b8908b..277adba50 100644 --- a/docs/src/lib/services/onboard.js +++ b/docs/src/lib/services/onboard.js @@ -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') @@ -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' @@ -162,6 +165,7 @@ const intiOnboard = async theme => { gnosis, taho, bitget, + gate, xdefi, uauth, cede, diff --git a/docs/src/routes/docs/[...4]wallets/[...38]gate/+page.md b/docs/src/routes/docs/[...4]wallets/[...38]gate/+page.md new file mode 100644 index 000000000..57acb65fb --- /dev/null +++ b/docs/src/routes/docs/[...4]wallets/[...38]gate/+page.md @@ -0,0 +1,50 @@ +--- +title: Gate Wallet +--- + +# {$frontmatter.title} + +Wallet module for connecting Gate wallet through Web3 Onboard + +### Install + + + + +```sh copy +yarn add @web3-onboard/gate +``` + + + + +```sh copy +npm install @web3-onboard/gate +``` + + + + +## 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) diff --git a/packages/demo/src/App.svelte b/packages/demo/src/App.svelte index cfbc5de47..afa8c701d 100644 --- a/packages/demo/src/App.svelte +++ b/packages/demo/src/App.svelte @@ -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' @@ -264,6 +265,7 @@ const dcent = dcentModule() const bitget = bitgetModule() + const gate = gateModule() const frameWallet = frameModule() const sequence = sequenceModule() const enkrypt = enkryptModule() @@ -302,6 +304,7 @@ okx, tallyho, bitget, + gate, bloom, enkrypt, infinityWallet, diff --git a/packages/gate/README.md b/packages/gate/README.md new file mode 100644 index 000000000..49ecc00ce --- /dev/null +++ b/packages/gate/README.md @@ -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) +``` diff --git a/packages/gate/package.json b/packages/gate/package.json new file mode 100644 index 000000000..d97d2bcd5 --- /dev/null +++ b/packages/gate/package.json @@ -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" + } +} diff --git a/packages/gate/src/icon.ts b/packages/gate/src/icon.ts new file mode 100644 index 000000000..efc514780 --- /dev/null +++ b/packages/gate/src/icon.ts @@ -0,0 +1,32 @@ +export default ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +` diff --git a/packages/gate/src/index.ts b/packages/gate/src/index.ts new file mode 100644 index 000000000..ddd09d731 --- /dev/null +++ b/packages/gate/src/index.ts @@ -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 diff --git a/packages/gate/src/types.ts b/packages/gate/src/types.ts new file mode 100644 index 000000000..8e961cd7c --- /dev/null +++ b/packages/gate/src/types.ts @@ -0,0 +1,5 @@ +import type { EIP1193Provider } from '@web3-onboard/common' + +export interface CustomWindow extends Window { + gatewallet?: EIP1193Provider +} diff --git a/packages/gate/tsconfig.json b/packages/gate/tsconfig.json new file mode 100644 index 000000000..09ae989f9 --- /dev/null +++ b/packages/gate/tsconfig.json @@ -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"] + } +} \ No newline at end of file diff --git a/packages/injected/src/constants.ts b/packages/injected/src/constants.ts index e036e1e02..54ca77495 100644 --- a/packages/injected/src/constants.ts +++ b/packages/injected/src/constants.ts @@ -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', diff --git a/packages/injected/src/icons/gate.ts b/packages/injected/src/icons/gate.ts new file mode 100644 index 000000000..efc514780 --- /dev/null +++ b/packages/injected/src/icons/gate.ts @@ -0,0 +1,32 @@ +export default ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +` diff --git a/packages/injected/src/types.ts b/packages/injected/src/types.ts index 150e61e3a..99d925550 100644 --- a/packages/injected/src/types.ts +++ b/packages/injected/src/types.ts @@ -72,6 +72,7 @@ export enum ProviderIdentityFlag { ZodiacPilot = 'isZodiacPilot', StableWallet = 'isStableWallet', Echooo = 'isEchooo', + Gate = 'isGateWallet' Keplr = 'keplr' } @@ -103,6 +104,7 @@ export enum ProviderExternalUrl { Rabby = 'https://rabby.io', ZodiacPilot = 'https://pilot.gnosisguild.org/', Echooo = 'https://www.echooo.xyz', + Gate = "https://www.gate.io/mobileapp" Keplr = 'https://www.keplr.app/download' } @@ -167,6 +169,7 @@ export enum ProviderLabel { ZodiacPilot = 'Zodiac Pilot', StableWallet = 'StableWallet', Echooo = 'Echooo', + Gate = "Gate Wallet" Keplr = 'Keplr' } @@ -194,6 +197,7 @@ export enum InjectedNameSpace { Zeal = 'zeal', Phantom = 'phantom', OKXWallet = 'okxwallet', + Gate = 'gatewallet', Trust = 'trustwallet', Frontier = 'frontier', DeFiConnectProvider = 'deficonnectProvider', @@ -257,7 +261,8 @@ export interface CustomWindow extends Window { foxwallet: InjectedProvider echooo: { ethereum: InjectedProvider - } + }, + gatewallet: InjectedProvider } export type InjectedProvider = ExternalProvider & diff --git a/packages/injected/src/wallets.ts b/packages/injected/src/wallets.ts index 77e7544dc..692746c03 100644 --- a/packages/injected/src/wallets.ts +++ b/packages/injected/src/wallets.ts @@ -590,6 +590,19 @@ const bitget: InjectedWalletModule = { externalUrl: ProviderExternalUrl.Bitget } +const gate: InjectedWalletModule = { + label: ProviderLabel.Gate, + injectedNamespace: InjectedNameSpace.Gate, + checkProviderIdentity: ({ provider }) => + !!provider && !!provider[ProviderIdentityFlag.Gate], + getIcon: async () => (await import('./icons/gate.js')).default, + getInterface: async () => ({ + provider: createEIP1193Provider(window.gatewallet) + }), + platforms: ['all'], + externalUrl: ProviderExternalUrl.Gate +} + const sequence: InjectedWalletModule = { label: ProviderLabel.Sequence, injectedNamespace: InjectedNameSpace.Ethereum, @@ -947,6 +960,7 @@ const wallets = [ apexwallet, atoken, bitget, + gate, bitpie, blockwallet, brave,