Skip to content

Commit

Permalink
Add Kaikas browser wallet support (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayanami authored Jun 17, 2022
1 parent 8ed6c42 commit d127277
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions connectors/kaikas.ts
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;
}
}

0 comments on commit d127277

Please sign in to comment.