Skip to content

Commit 507438a

Browse files
committed
window.lute
1 parent 493ecf9 commit 507438a

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lute-connect",
3-
"version": "1.6.2",
3+
"version": "1.6.3",
44
"description": "Enables dApps to communicate with Lute, an Algorand wallet",
55
"main": "./dist/main.cjs.js",
66
"module": "./dist/main.esm.js",

src/main.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export class SignDataError extends Error {
109109
}
110110
}
111111

112+
interface IWindow extends Window {
113+
lute?: Boolean;
114+
}
115+
112116
const left = 100 + window.screenX;
113117
const top = 100 + window.screenY;
114118
const PARAMS = `width=500,height=750,left=${left},top=${top}`;
@@ -123,19 +127,9 @@ export default class LuteConnect {
123127
this.siteName = siteName || document.title || "Unknown site";
124128
}
125129

126-
async isExtensionInstalled() {
127-
return await fetch(`chrome-extension://${EXT_ID}/assets/icon-16.png`)
128-
.then(() => {
129-
return true;
130-
})
131-
.catch(() => {
132-
return false;
133-
});
134-
}
135-
136130
connect(genesisID: string): Promise<Address[]> {
137131
return new Promise(async (resolve, reject) => {
138-
const useExt = this.forceWeb ? false : await this.isExtensionInstalled();
132+
const useExt = this.forceWeb ? false : (window as IWindow).lute;
139133
let win: any;
140134
if (useExt) {
141135
window.dispatchEvent(
@@ -175,7 +169,7 @@ export default class LuteConnect {
175169

176170
signTxns(txns: WalletTransaction[]): Promise<(Uint8Array | null)[]> {
177171
return new Promise(async (resolve, reject) => {
178-
const useExt = this.forceWeb ? false : await this.isExtensionInstalled();
172+
const useExt = this.forceWeb ? false : (window as IWindow).lute;
179173
let win: any;
180174
if (useExt) {
181175
window.dispatchEvent(
@@ -215,7 +209,7 @@ export default class LuteConnect {
215209

216210
signData(data: string, metadata: SignMetadata): Promise<SignDataResponse> {
217211
return new Promise(async (resolve, reject) => {
218-
const useExt = this.forceWeb ? false : await this.isExtensionInstalled();
212+
const useExt = this.forceWeb ? false : (window as IWindow).lute;
219213
let win: any;
220214
if (useExt) {
221215
window.dispatchEvent(

0 commit comments

Comments
 (0)