@paywithglide/glide-react 0.0.4 → 0.0.6
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/GlideDeposit.d.ts +4 -4
- package/dist/glide.js +40 -40
- package/dist/useGlideDeposit.d.ts +3 -2
- package/package.json +1 -1
package/dist/GlideDeposit.d.ts
CHANGED
|
@@ -77,17 +77,17 @@ export type GlideDepositWalletProvider = {
|
|
|
77
77
|
export type GlideDepositOptions = {
|
|
78
78
|
app: string;
|
|
79
79
|
recipient?: Hex;
|
|
80
|
-
mode
|
|
80
|
+
mode?: "deposit" | "withdraw";
|
|
81
|
+
preferGaslessPayment?: boolean;
|
|
81
82
|
walletProvider?: GlideDepositWalletProvider;
|
|
82
83
|
baseUrl?: string;
|
|
83
84
|
};
|
|
84
85
|
export declare class GlideDeposit {
|
|
85
86
|
opts: GlideDepositOptions;
|
|
86
87
|
constructor(opts: GlideDepositOptions);
|
|
87
|
-
private didInit;
|
|
88
|
-
initialize(): void;
|
|
89
|
-
destroy(): void;
|
|
90
88
|
open: () => void;
|
|
89
|
+
private initialize;
|
|
90
|
+
private destroy;
|
|
91
91
|
private get baseUrl();
|
|
92
92
|
private get iframe();
|
|
93
93
|
private iframeEventHandler;
|
package/dist/glide.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
var v = Object.defineProperty;
|
|
2
|
-
var b = (
|
|
3
|
-
var
|
|
4
|
-
import { useMemo as
|
|
5
|
-
class
|
|
2
|
+
var b = (i, e, t) => e in i ? v(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var p = (i, e, t) => b(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { useMemo as P } from "react";
|
|
5
|
+
class E {
|
|
6
6
|
constructor(e) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var e, t, s, a;
|
|
7
|
+
p(this, "opts");
|
|
8
|
+
p(this, "open", () => {
|
|
9
|
+
var e, t, s, o;
|
|
11
10
|
if (!document.body.classList.contains("glide-deposit-open")) {
|
|
12
11
|
if (document.body.classList.add("glide-deposit-open"), this.opts.mode === "deposit" && !this.opts.recipient)
|
|
13
12
|
throw new Error("recipient is required for deposit mode");
|
|
14
|
-
|
|
13
|
+
if (this.opts.preferGaslessPayment && this.opts.walletProvider && !this.opts.walletProvider.signTypedDataAsync)
|
|
14
|
+
throw new Error(
|
|
15
|
+
"walletProvider.signTypedDataAsync is required when preferGaslessPayment=true"
|
|
16
|
+
);
|
|
17
|
+
const a = this.opts.recipient, n = (e = this.opts.walletProvider) == null ? void 0 : e.address, d = (t = this.opts.walletProvider) == null ? void 0 : t.availableChainIds, l = (s = this.opts.walletProvider) == null ? void 0 : s.currentChainId, c = this.opts.preferGaslessPayment || !!((o = this.opts.walletProvider) != null && o.signTypedDataAsync);
|
|
15
18
|
this.openUrl(
|
|
16
|
-
`${this.baseUrl}${this.opts.app}?embed=true${
|
|
17
|
-
);
|
|
19
|
+
`${this.baseUrl}${this.opts.app}?embed=true${a ? `&recipient=${a}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `¤tChainId=${l}` : ""}${d ? `&availableChainIds=${d.join(",")}` : ""}${c ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}`
|
|
20
|
+
), this.initialize();
|
|
18
21
|
}
|
|
19
22
|
});
|
|
20
|
-
|
|
21
|
-
var s,
|
|
23
|
+
p(this, "iframeEventHandler", async (e) => {
|
|
24
|
+
var s, o, a, n, d, l, c, h, m, w, y, u, f, g;
|
|
22
25
|
const t = e.data;
|
|
23
26
|
switch (t.type) {
|
|
24
27
|
case "close":
|
|
25
|
-
this.removeIframe(), this.hideLoader();
|
|
28
|
+
this.removeIframe(), this.hideLoader(), this.destroy();
|
|
26
29
|
break;
|
|
27
30
|
case "switchChain":
|
|
28
31
|
if (!this.opts.walletProvider)
|
|
@@ -30,7 +33,7 @@ class P {
|
|
|
30
33
|
try {
|
|
31
34
|
await this.opts.walletProvider.switchChainAsync({
|
|
32
35
|
chainId: t.chainId
|
|
33
|
-
}), (
|
|
36
|
+
}), (o = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || o.postMessage(
|
|
34
37
|
{
|
|
35
38
|
type: "didSwitchChain",
|
|
36
39
|
success: !0,
|
|
@@ -39,7 +42,7 @@ class P {
|
|
|
39
42
|
this.baseUrl
|
|
40
43
|
);
|
|
41
44
|
} catch (r) {
|
|
42
|
-
(n = (
|
|
45
|
+
(n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
|
|
43
46
|
{
|
|
44
47
|
type: "didSwitchChain",
|
|
45
48
|
success: !1,
|
|
@@ -57,7 +60,7 @@ class P {
|
|
|
57
60
|
const r = await this.opts.walletProvider.sendTransactionAsync(
|
|
58
61
|
t.tx
|
|
59
62
|
);
|
|
60
|
-
(
|
|
63
|
+
(l = (d = this.iframe) == null ? void 0 : d.contentWindow) == null || l.postMessage(
|
|
61
64
|
{
|
|
62
65
|
type: "didSendTransaction",
|
|
63
66
|
success: !0,
|
|
@@ -66,7 +69,7 @@ class P {
|
|
|
66
69
|
this.baseUrl
|
|
67
70
|
);
|
|
68
71
|
} catch (r) {
|
|
69
|
-
(h = (
|
|
72
|
+
(h = (c = this.iframe) == null ? void 0 : c.contentWindow) == null || h.postMessage(
|
|
70
73
|
{
|
|
71
74
|
type: "didSendTransaction",
|
|
72
75
|
success: !1,
|
|
@@ -82,7 +85,7 @@ class P {
|
|
|
82
85
|
if (!this.opts.walletProvider)
|
|
83
86
|
throw new Error("walletProvider is not set");
|
|
84
87
|
if (!this.opts.walletProvider.signTypedDataAsync) {
|
|
85
|
-
(
|
|
88
|
+
(w = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || w.postMessage(
|
|
86
89
|
{
|
|
87
90
|
type: "didSignTypedData",
|
|
88
91
|
success: !1,
|
|
@@ -96,7 +99,7 @@ class P {
|
|
|
96
99
|
const r = await this.opts.walletProvider.signTypedDataAsync(
|
|
97
100
|
t.data
|
|
98
101
|
);
|
|
99
|
-
(
|
|
102
|
+
(u = (y = this.iframe) == null ? void 0 : y.contentWindow) == null || u.postMessage(
|
|
100
103
|
{
|
|
101
104
|
type: "didSignTypedData",
|
|
102
105
|
success: !0,
|
|
@@ -121,7 +124,7 @@ class P {
|
|
|
121
124
|
this.opts = e;
|
|
122
125
|
}
|
|
123
126
|
initialize() {
|
|
124
|
-
|
|
127
|
+
window.addEventListener("message", this.iframeEventHandler);
|
|
125
128
|
}
|
|
126
129
|
destroy() {
|
|
127
130
|
window.removeEventListener("message", this.iframeEventHandler);
|
|
@@ -141,7 +144,7 @@ class P {
|
|
|
141
144
|
t.id = "glide-deposit-iframe", t.setAttribute(
|
|
142
145
|
"style",
|
|
143
146
|
"z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"
|
|
144
|
-
), t.src = e, t.allow = "payment", document.body.appendChild(t), window.setTimeout(() => {
|
|
147
|
+
), t.src = e, t.allow = "payment *; clipboard-write *", document.body.appendChild(t), window.setTimeout(() => {
|
|
145
148
|
var s;
|
|
146
149
|
(s = t == null ? void 0 : t.contentWindow) == null || s.focus();
|
|
147
150
|
}, 100);
|
|
@@ -165,27 +168,24 @@ class P {
|
|
|
165
168
|
document.querySelectorAll(".glide-deposit-loader").forEach((e) => e.remove());
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
|
-
const
|
|
169
|
-
app:
|
|
171
|
+
const D = ({
|
|
172
|
+
app: i,
|
|
170
173
|
recipient: e,
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
preferGaslessPayment: t,
|
|
175
|
+
mode: s,
|
|
176
|
+
walletProvider: o,
|
|
173
177
|
baseUrl: a
|
|
174
|
-
}) => {
|
|
175
|
-
|
|
176
|
-
app:
|
|
178
|
+
}) => ({
|
|
179
|
+
openGlideDeposit: P(() => new E({
|
|
180
|
+
app: i,
|
|
177
181
|
recipient: e,
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
preferGaslessPayment: t,
|
|
183
|
+
mode: s,
|
|
184
|
+
walletProvider: o,
|
|
180
185
|
baseUrl: a
|
|
181
|
-
}), [
|
|
182
|
-
|
|
183
|
-
i.destroy();
|
|
184
|
-
}), [i]), {
|
|
185
|
-
openGlideDeposit: i.open
|
|
186
|
-
};
|
|
187
|
-
};
|
|
186
|
+
}), [i, e, t, s, o, a]).open
|
|
187
|
+
});
|
|
188
188
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
E as GlideDeposit,
|
|
190
|
+
D as useGlideDeposit
|
|
191
191
|
};
|
|
@@ -2,11 +2,12 @@ import { GlideDepositWalletProvider, Hex } from './GlideDeposit.ts';
|
|
|
2
2
|
interface UseGlideDepositProps {
|
|
3
3
|
app: string;
|
|
4
4
|
recipient?: Hex;
|
|
5
|
+
preferGaslessPayment?: boolean;
|
|
5
6
|
mode?: "deposit" | "withdraw";
|
|
6
|
-
walletProvider
|
|
7
|
+
walletProvider?: GlideDepositWalletProvider;
|
|
7
8
|
baseUrl?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const useGlideDeposit: ({ app, recipient, mode, walletProvider, baseUrl, }: UseGlideDepositProps) => {
|
|
10
|
+
export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, walletProvider, baseUrl, }: UseGlideDepositProps) => {
|
|
10
11
|
openGlideDeposit: () => void;
|
|
11
12
|
};
|
|
12
13
|
export {};
|