@paywithglide/glide-react 0.0.8 → 0.0.9
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/glide.js +48 -42
- package/dist/index.d.ts +1 -0
- package/dist/useGlideDeposit.d.ts +2 -3
- package/dist/useGlidePay.d.ts +12 -0
- package/package.json +1 -1
package/dist/glide.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (i, e, t) =>
|
|
4
|
-
import { useMemo as
|
|
5
|
-
class
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var D = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var p = (i, e, t) => D(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { useMemo as v } from "react";
|
|
5
|
+
class b {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
p(this, "opts");
|
|
8
8
|
p(this, "open", () => {
|
|
9
|
-
var e, t, s,
|
|
9
|
+
var e, t, s, o;
|
|
10
10
|
if (!document.body.classList.contains("glide-deposit-open")) {
|
|
11
11
|
if (document.body.classList.add("glide-deposit-open"), this.opts.mode === "deposit" && !this.opts.recipient)
|
|
12
12
|
throw new Error("recipient is required for deposit mode");
|
|
@@ -14,14 +14,14 @@ class E {
|
|
|
14
14
|
throw new Error(
|
|
15
15
|
"walletProvider.signTypedDataAsync is required when preferGaslessPayment=true"
|
|
16
16
|
);
|
|
17
|
-
const
|
|
17
|
+
const r = 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);
|
|
18
18
|
this.openUrl(
|
|
19
|
-
`${this.baseUrl}${this.opts.app}?embed=true${
|
|
19
|
+
`${this.baseUrl}${this.opts.app}?embed=true${r ? `&recipient=${r}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `¤tChainId=${l}` : ""}${d ? `&availableChainIds=${d.join(",")}` : ""}${c ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}`
|
|
20
20
|
), this.initialize();
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
p(this, "iframeEventHandler", async (e) => {
|
|
24
|
-
var s,
|
|
24
|
+
var s, o, r, n, d, l, c, h, m, y, w, u, f, g;
|
|
25
25
|
const t = e.data;
|
|
26
26
|
switch (t.type) {
|
|
27
27
|
case "close":
|
|
@@ -33,7 +33,7 @@ class E {
|
|
|
33
33
|
try {
|
|
34
34
|
await this.opts.walletProvider.switchChainAsync({
|
|
35
35
|
chainId: t.chainId
|
|
36
|
-
}), (
|
|
36
|
+
}), (o = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || o.postMessage(
|
|
37
37
|
{
|
|
38
38
|
type: "didSwitchChain",
|
|
39
39
|
success: !0,
|
|
@@ -41,12 +41,12 @@ class E {
|
|
|
41
41
|
},
|
|
42
42
|
this.baseUrl
|
|
43
43
|
);
|
|
44
|
-
} catch (
|
|
45
|
-
(n = (
|
|
44
|
+
} catch (a) {
|
|
45
|
+
(n = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || n.postMessage(
|
|
46
46
|
{
|
|
47
47
|
type: "didSwitchChain",
|
|
48
48
|
success: !1,
|
|
49
|
-
error:
|
|
49
|
+
error: a
|
|
50
50
|
},
|
|
51
51
|
this.baseUrl
|
|
52
52
|
);
|
|
@@ -57,23 +57,23 @@ class E {
|
|
|
57
57
|
if (!this.opts.walletProvider)
|
|
58
58
|
throw new Error("walletProvider is not set");
|
|
59
59
|
try {
|
|
60
|
-
const
|
|
60
|
+
const a = await this.opts.walletProvider.sendTransactionAsync(
|
|
61
61
|
t.tx
|
|
62
62
|
);
|
|
63
63
|
(l = (d = this.iframe) == null ? void 0 : d.contentWindow) == null || l.postMessage(
|
|
64
64
|
{
|
|
65
65
|
type: "didSendTransaction",
|
|
66
66
|
success: !0,
|
|
67
|
-
txHash:
|
|
67
|
+
txHash: a
|
|
68
68
|
},
|
|
69
69
|
this.baseUrl
|
|
70
70
|
);
|
|
71
|
-
} catch (
|
|
71
|
+
} catch (a) {
|
|
72
72
|
(h = (c = this.iframe) == null ? void 0 : c.contentWindow) == null || h.postMessage(
|
|
73
73
|
{
|
|
74
74
|
type: "didSendTransaction",
|
|
75
75
|
success: !1,
|
|
76
|
-
error:
|
|
76
|
+
error: a
|
|
77
77
|
},
|
|
78
78
|
this.baseUrl
|
|
79
79
|
);
|
|
@@ -85,7 +85,7 @@ class E {
|
|
|
85
85
|
if (!this.opts.walletProvider)
|
|
86
86
|
throw new Error("walletProvider is not set");
|
|
87
87
|
if (!this.opts.walletProvider.signTypedDataAsync) {
|
|
88
|
-
(
|
|
88
|
+
(y = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || y.postMessage(
|
|
89
89
|
{
|
|
90
90
|
type: "didSignTypedData",
|
|
91
91
|
success: !1,
|
|
@@ -96,23 +96,23 @@ class E {
|
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
try {
|
|
99
|
-
const
|
|
99
|
+
const a = await this.opts.walletProvider.signTypedDataAsync(
|
|
100
100
|
t.data
|
|
101
101
|
);
|
|
102
|
-
(u = (
|
|
102
|
+
(u = (w = this.iframe) == null ? void 0 : w.contentWindow) == null || u.postMessage(
|
|
103
103
|
{
|
|
104
104
|
type: "didSignTypedData",
|
|
105
105
|
success: !0,
|
|
106
|
-
signature:
|
|
106
|
+
signature: a
|
|
107
107
|
},
|
|
108
108
|
this.baseUrl
|
|
109
109
|
);
|
|
110
|
-
} catch (
|
|
110
|
+
} catch (a) {
|
|
111
111
|
(g = (f = this.iframe) == null ? void 0 : f.contentWindow) == null || g.postMessage(
|
|
112
112
|
{
|
|
113
113
|
type: "didSignTypedData",
|
|
114
114
|
success: !1,
|
|
115
|
-
error:
|
|
115
|
+
error: a
|
|
116
116
|
},
|
|
117
117
|
this.baseUrl
|
|
118
118
|
);
|
|
@@ -168,34 +168,40 @@ class E {
|
|
|
168
168
|
document.querySelectorAll(".glide-deposit-loader").forEach((e) => e.remove());
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const T = ({
|
|
172
172
|
app: i,
|
|
173
173
|
recipient: e,
|
|
174
174
|
preferGaslessPayment: t,
|
|
175
175
|
mode: s,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
baseUrl: n
|
|
176
|
+
walletProvider: o,
|
|
177
|
+
baseUrl: r
|
|
179
178
|
}) => ({
|
|
180
|
-
openGlideDeposit:
|
|
179
|
+
openGlideDeposit: v(() => new b({
|
|
181
180
|
app: i,
|
|
182
181
|
recipient: e,
|
|
183
182
|
preferGaslessPayment: t,
|
|
184
183
|
mode: s,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
184
|
+
walletProvider: o,
|
|
185
|
+
baseUrl: r
|
|
186
|
+
}), [i, e, t, s, o, r]).open
|
|
187
|
+
}), $ = ({
|
|
188
|
+
app: i,
|
|
189
|
+
preferGaslessPayment: e,
|
|
190
|
+
amount: t,
|
|
191
|
+
walletProvider: s,
|
|
192
|
+
baseUrl: o
|
|
193
|
+
}) => ({
|
|
194
|
+
openGlidePay: v(() => new b({
|
|
195
|
+
app: i,
|
|
196
|
+
preferGaslessPayment: e,
|
|
197
|
+
mode: "pay",
|
|
198
|
+
amount: t,
|
|
199
|
+
walletProvider: s,
|
|
200
|
+
baseUrl: o
|
|
201
|
+
}), [i, e, s, o, t]).open
|
|
197
202
|
});
|
|
198
203
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
b as GlideDeposit,
|
|
205
|
+
T as useGlideDeposit,
|
|
206
|
+
$ as useGlidePay
|
|
201
207
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,11 @@ interface UseGlideDepositProps {
|
|
|
3
3
|
app: string;
|
|
4
4
|
recipient?: Hex;
|
|
5
5
|
preferGaslessPayment?: boolean;
|
|
6
|
-
mode?: "deposit" | "withdraw"
|
|
7
|
-
amount?: string;
|
|
6
|
+
mode?: "deposit" | "withdraw";
|
|
8
7
|
walletProvider?: GlideDepositWalletProvider;
|
|
9
8
|
baseUrl?: string;
|
|
10
9
|
}
|
|
11
|
-
export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode,
|
|
10
|
+
export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, walletProvider, baseUrl, }: UseGlideDepositProps) => {
|
|
12
11
|
openGlideDeposit: () => void;
|
|
13
12
|
};
|
|
14
13
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GlideDepositWalletProvider } from './GlideDeposit.ts';
|
|
2
|
+
interface UseGlidePayProps {
|
|
3
|
+
app: string;
|
|
4
|
+
preferGaslessPayment?: boolean;
|
|
5
|
+
amount: string;
|
|
6
|
+
walletProvider?: GlideDepositWalletProvider;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const useGlidePay: ({ app, preferGaslessPayment, amount, walletProvider, baseUrl, }: UseGlidePayProps) => {
|
|
10
|
+
openGlidePay: () => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|