-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Kaikas browser wallet support (#54)
- Loading branch information
Ayanami
authored
Jun 17, 2022
1 parent
8ed6c42
commit d127277
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import LockConnector from '../src/connector'; | ||
|
||
export default class Connector extends LockConnector { | ||
async connect() { | ||
let provider; | ||
if (window['klaytn']) { | ||
provider = window['klaytn']; | ||
try { | ||
await window['klaytn'].enable(); | ||
} catch (e) { | ||
console.error(e); | ||
// Return when the error is Error: User denied account authorization | ||
if (e.code === -32603) return; | ||
} | ||
} else if (window['caver']) { | ||
provider = window['caver'].currentProvider; | ||
} | ||
return provider; | ||
} | ||
|
||
async isLoggedIn() { | ||
if (!window['klaytn']) return false; | ||
if (window['klaytn'].selectedAddress) return true; | ||
await new Promise((r) => setTimeout(r, 400)); | ||
return !!window['klaytn'].selectedAddress; | ||
} | ||
} |