@onekeyfe/onekey-webln-provider 1.1.32 → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProviderWebln.d.ts +1 -3
- package/dist/ProviderWebln.js +14 -14
- package/dist/cjs/ProviderWebln.js +14 -14
- package/package.json +6 -6
package/dist/ProviderWebln.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { IInpageProviderConfig } from "@onekeyfe/cross-inpage-provider-core";
|
|
|
2
2
|
import { ProviderWeblnBase } from "./ProviderWeblnBase";
|
|
3
3
|
import { WeblnProviderEventsMap, GetInfoResponse, IProviderWebln, RequestInvoiceArgs, RequestInvoiceResponse } from "./types";
|
|
4
4
|
declare class ProviderWebln extends ProviderWeblnBase implements IProviderWebln {
|
|
5
|
-
|
|
6
|
-
isEnabled: boolean;
|
|
7
|
-
executing: boolean;
|
|
5
|
+
private states;
|
|
8
6
|
constructor(props: IInpageProviderConfig);
|
|
9
7
|
on<E extends keyof WeblnProviderEventsMap>(event: E, listener: WeblnProviderEventsMap[E]): this;
|
|
10
8
|
emit<E extends keyof WeblnProviderEventsMap>(event: E, ...args: Parameters<WeblnProviderEventsMap[E]>): boolean;
|
package/dist/ProviderWebln.js
CHANGED
|
@@ -11,9 +11,10 @@ import { ProviderWeblnBase } from "./ProviderWeblnBase";
|
|
|
11
11
|
class ProviderWebln extends ProviderWeblnBase {
|
|
12
12
|
constructor(props) {
|
|
13
13
|
super(props);
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
this.states = {
|
|
15
|
+
enabled: false,
|
|
16
|
+
executing: false
|
|
17
|
+
};
|
|
17
18
|
this.handlerLnurl();
|
|
18
19
|
}
|
|
19
20
|
on(event, listener) {
|
|
@@ -27,20 +28,19 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
27
28
|
}
|
|
28
29
|
enable() {
|
|
29
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (this.enabled) {
|
|
31
|
+
if (this.states.enabled) {
|
|
31
32
|
return { enabled: true };
|
|
32
33
|
}
|
|
33
34
|
const result = yield this._callBridge({ method: "enable" });
|
|
34
35
|
if (typeof result.enabled === "boolean") {
|
|
35
|
-
this.enabled =
|
|
36
|
-
this.isEnabled = result.enabled;
|
|
36
|
+
this.states.enabled = true;
|
|
37
37
|
}
|
|
38
38
|
return result;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
getInfo() {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
if (!this.enabled) {
|
|
43
|
+
if (!this.states.enabled) {
|
|
44
44
|
throw new Error("Please allow the connection request of webln before calling the getInfo method");
|
|
45
45
|
}
|
|
46
46
|
return this._callBridge({ method: "getInfo" });
|
|
@@ -48,7 +48,7 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
48
48
|
}
|
|
49
49
|
makeInvoice(args) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
if (!this.enabled) {
|
|
51
|
+
if (!this.states.enabled) {
|
|
52
52
|
throw new Error("Please allow the connection request of webln before calling the makeInvoice method");
|
|
53
53
|
}
|
|
54
54
|
return this._callBridge({ method: "makeInvoice", params: args });
|
|
@@ -56,7 +56,7 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
56
56
|
}
|
|
57
57
|
sendPayment(paymentRequest) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
if (!this.enabled) {
|
|
59
|
+
if (!this.states.enabled) {
|
|
60
60
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
61
61
|
}
|
|
62
62
|
return this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
@@ -64,14 +64,14 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
64
64
|
}
|
|
65
65
|
signMessage(message) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
if (!this.enabled) {
|
|
67
|
+
if (!this.states.enabled) {
|
|
68
68
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
69
69
|
}
|
|
70
70
|
return this._callBridge({ method: "signMessage", params: message });
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
verifyMessage(signature, message) {
|
|
74
|
-
if (!this.enabled) {
|
|
74
|
+
if (!this.states.enabled) {
|
|
75
75
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
76
76
|
}
|
|
77
77
|
return this._callBridge({
|
|
@@ -80,14 +80,14 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
getBalance() {
|
|
83
|
-
if (!this.enabled) {
|
|
83
|
+
if (!this.states.enabled) {
|
|
84
84
|
throw new Error("Please allow the connection request of webln before calling the getBalance method");
|
|
85
85
|
}
|
|
86
86
|
return this._callBridge({ method: "getBalance", params: undefined });
|
|
87
87
|
}
|
|
88
88
|
lnurl(lnurlString) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
if (!this.enabled) {
|
|
90
|
+
if (!this.states.enabled) {
|
|
91
91
|
throw new Error("Please allow the connection request of webln before calling the lnurl method");
|
|
92
92
|
}
|
|
93
93
|
return this._callBridge({ method: "lnurl", params: lnurlString });
|
|
@@ -145,7 +145,7 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
145
145
|
return window.webln.sendPayment(paymentRequest);
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
|
-
});
|
|
148
|
+
}, { capture: true });
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -14,9 +14,10 @@ const ProviderWeblnBase_1 = require("./ProviderWeblnBase");
|
|
|
14
14
|
class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
15
15
|
constructor(props) {
|
|
16
16
|
super(props);
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
this.states = {
|
|
18
|
+
enabled: false,
|
|
19
|
+
executing: false
|
|
20
|
+
};
|
|
20
21
|
this.handlerLnurl();
|
|
21
22
|
}
|
|
22
23
|
on(event, listener) {
|
|
@@ -30,20 +31,19 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
30
31
|
}
|
|
31
32
|
enable() {
|
|
32
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
if (this.enabled) {
|
|
34
|
+
if (this.states.enabled) {
|
|
34
35
|
return { enabled: true };
|
|
35
36
|
}
|
|
36
37
|
const result = yield this._callBridge({ method: "enable" });
|
|
37
38
|
if (typeof result.enabled === "boolean") {
|
|
38
|
-
this.enabled =
|
|
39
|
-
this.isEnabled = result.enabled;
|
|
39
|
+
this.states.enabled = true;
|
|
40
40
|
}
|
|
41
41
|
return result;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
getInfo() {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (!this.enabled) {
|
|
46
|
+
if (!this.states.enabled) {
|
|
47
47
|
throw new Error("Please allow the connection request of webln before calling the getInfo method");
|
|
48
48
|
}
|
|
49
49
|
return this._callBridge({ method: "getInfo" });
|
|
@@ -51,7 +51,7 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
51
51
|
}
|
|
52
52
|
makeInvoice(args) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
if (!this.enabled) {
|
|
54
|
+
if (!this.states.enabled) {
|
|
55
55
|
throw new Error("Please allow the connection request of webln before calling the makeInvoice method");
|
|
56
56
|
}
|
|
57
57
|
return this._callBridge({ method: "makeInvoice", params: args });
|
|
@@ -59,7 +59,7 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
59
59
|
}
|
|
60
60
|
sendPayment(paymentRequest) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (!this.enabled) {
|
|
62
|
+
if (!this.states.enabled) {
|
|
63
63
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
64
64
|
}
|
|
65
65
|
return this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
@@ -67,14 +67,14 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
67
67
|
}
|
|
68
68
|
signMessage(message) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
if (!this.enabled) {
|
|
70
|
+
if (!this.states.enabled) {
|
|
71
71
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
72
72
|
}
|
|
73
73
|
return this._callBridge({ method: "signMessage", params: message });
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
verifyMessage(signature, message) {
|
|
77
|
-
if (!this.enabled) {
|
|
77
|
+
if (!this.states.enabled) {
|
|
78
78
|
throw new Error("Please allow the connection request of webln before calling the sendPayment method");
|
|
79
79
|
}
|
|
80
80
|
return this._callBridge({
|
|
@@ -83,14 +83,14 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
getBalance() {
|
|
86
|
-
if (!this.enabled) {
|
|
86
|
+
if (!this.states.enabled) {
|
|
87
87
|
throw new Error("Please allow the connection request of webln before calling the getBalance method");
|
|
88
88
|
}
|
|
89
89
|
return this._callBridge({ method: "getBalance", params: undefined });
|
|
90
90
|
}
|
|
91
91
|
lnurl(lnurlString) {
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
if (!this.enabled) {
|
|
93
|
+
if (!this.states.enabled) {
|
|
94
94
|
throw new Error("Please allow the connection request of webln before calling the lnurl method");
|
|
95
95
|
}
|
|
96
96
|
return this._callBridge({ method: "lnurl", params: lnurlString });
|
|
@@ -148,7 +148,7 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
148
148
|
return window.webln.sendPayment(paymentRequest);
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
-
});
|
|
151
|
+
}, { capture: true });
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-webln-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.33",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
34
|
-
"@onekeyfe/extension-bridge-injected": "1.1.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.33",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.33",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.33",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "1.1.33"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "6d3e1d6ac8542a05a1f434dcdfa8a875aedb465b"
|
|
37
37
|
}
|