Skip to content

Commit bf2600f

Browse files
feat: add OneKey wallet (#1739)
* feat: Support OneKey wallet * fix: OneKey docs * Update injected package.json version * Update demo package.json --------- Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent 478ad48 commit bf2600f

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

docs/src/routes/docs/[...4]wallets/[...9]injected/+page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ const injected = injectedModule({
334334
- BifrostWallet - _Desktop & Mobile_
335335
- Safeheron - _Desktop_
336336
- Talisman - _Desktop_
337+
- OneKey - _Desktop & Mobile_
337338

338339
## Build Environments
339340

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@web3-onboard/gas": "^2.1.7",
3636
"@web3-onboard/gnosis": "^2.1.9",
3737
"@web3-onboard/infinity-wallet": "^2.0.3",
38-
"@web3-onboard/injected-wallets": "^2.10.0",
38+
"@web3-onboard/injected-wallets": "^2.10.1-alpha.1",
3939
"@web3-onboard/keepkey": "^2.3.7",
4040
"@web3-onboard/keystone": "^2.3.7",
4141
"@web3-onboard/ledger": "^2.4.5",

packages/injected/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/injected-wallets",
3-
"version": "2.10.0",
3+
"version": "2.10.1-alpha.1",
44
"description": "Injected wallet module for connecting browser extension and mobile wallets 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.",
55
"keywords": [
66
"Ethereum",

packages/injected/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ export const WALLET_NAMES: { [key: string]: string } = {
2626
rainbow: 'Rainbow',
2727
defiwallet: 'DeFi Wallet',
2828
safeheron: 'Safeheron',
29-
talismanEth: 'Talisman'
29+
talismanEth: 'Talisman',
30+
onekey: 'OneKey'
3031
}

packages/injected/src/icons/onekey.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<svg width="450" height="450" viewBox="0 0 450 450" fill="none" xmlns="http://www.w3.org/2000/svg">
3+
<path d="M448.628 224.314C448.628 379.171 379.171 448.628 224.314 448.628C69.4575 448.628 0 379.171 0 224.314C0 69.4575 69.4575 0 224.314 0C379.171 0 448.628 69.4575 448.628 224.314Z" fill="#3BD23D"/>
4+
<path d="M244.583 95.1172L182.18 95.1172L171.232 128.221H205.892V197.951H244.583V95.1172Z" fill="black"/>
5+
<path fill-rule="evenodd" clip-rule="evenodd" d="M295.485 282.343C295.485 321.648 263.622 353.511 224.317 353.511C185.012 353.511 153.149 321.648 153.149 282.343C153.149 243.039 185.012 211.176 224.317 211.176C263.622 211.176 295.485 243.039 295.485 282.343ZM263.175 282.343C263.175 303.804 245.778 321.202 224.317 321.202C202.856 321.202 185.459 303.804 185.459 282.343C185.459 260.882 202.856 243.485 224.317 243.485C245.778 243.485 263.175 260.882 263.175 282.343Z" fill="black"/>
6+
</svg>`

packages/injected/src/types.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export enum ProviderIdentityFlag {
6262
SafePal = 'isSafePal',
6363
DeFiWallet = 'isDeficonnectProvider',
6464
Safeheron = 'isSafeheron',
65-
Talisman = 'isTalisman'
65+
Talisman = 'isTalisman',
66+
OneKey = 'isOneKey'
6667
}
6768

6869

@@ -82,6 +83,7 @@ export enum ProviderExternalUrl {
8283
Phantom = 'https://phantom.app/download',
8384
Talisman = 'https://www.talisman.xyz/',
8485
Trust = 'https://trustwallet.com/download/',
86+
OneKey = 'https://onekey.so/download/',
8587
}
8688

8789
export enum ProviderLabel {
@@ -134,7 +136,8 @@ export enum ProviderLabel {
134136
SafePal = 'SafePal',
135137
DeFiWallet = 'DeFi Wallet',
136138
Safeheron = 'Safeheron',
137-
Talisman = 'Talisman'
139+
Talisman = 'Talisman',
140+
OneKey = 'OneKey'
138141
}
139142

140143
export interface MeetOneProvider extends ExternalProvider {
@@ -166,7 +169,8 @@ export enum InjectedNameSpace {
166169
Frontier = 'frontier',
167170
DeFiConnectProvider = 'deficonnectProvider',
168171
Safeheron = 'safeheron',
169-
Talisman = 'talismanEth'
172+
Talisman = 'talismanEth',
173+
OneKey = '$onekey'
170174
}
171175

172176
export interface CustomWindow extends Window {
@@ -203,6 +207,9 @@ export interface CustomWindow extends Window {
203207
deficonnectProvider: InjectedProvider
204208
safeheron: InjectedProvider
205209
talismanEth: InjectedProvider
210+
$onekey: {
211+
ethereum: InjectedProvider
212+
}
206213
}
207214

208215
export type InjectedProvider = ExternalProvider &

packages/injected/src/wallets.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,21 @@ const talisman: InjectedWalletModule = {
785785
externalUrl: ProviderExternalUrl.Talisman
786786
}
787787

788+
const onekey: InjectedWalletModule = {
789+
label: ProviderLabel.OneKey,
790+
injectedNamespace: InjectedNameSpace.OneKey,
791+
checkProviderIdentity: ({ provider }) =>
792+
!!provider &&
793+
!!provider.ethereum &&
794+
!!provider.ethereum[ProviderIdentityFlag.OneKey],
795+
getIcon: async () => (await import('./icons/onekey.js')).default,
796+
getInterface: async () => ({
797+
provider: createEIP1193Provider(window.$onekey.ethereum)
798+
}),
799+
platforms: ['all'],
800+
externalUrl: ProviderExternalUrl.OneKey
801+
}
802+
788803
const wallets = [
789804
zeal,
790805
exodus,
@@ -833,7 +848,8 @@ const wallets = [
833848
defiwallet,
834849
infinitywallet,
835850
safeheron,
836-
talisman
851+
talisman,
852+
onekey
837853
]
838854

839855
export default wallets

0 commit comments

Comments
 (0)