@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 CHANGED
@@ -1,12 +1,12 @@
1
- var v = Object.defineProperty;
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 {
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, r;
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 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 || !!((r = this.opts.walletProvider) != null && r.signTypedDataAsync);
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${a ? `&recipient=${a}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `&currentChainId=${l}` : ""}${d ? `&availableChainIds=${d.join(",")}` : ""}${c ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}`
19
+ `${this.baseUrl}${this.opts.app}?embed=true${r ? `&recipient=${r}` : ""}${n ? `&connectedWalletAddress=${n}` : ""}${l ? `&currentChainId=${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, r, a, n, d, l, c, h, m, w, y, u, f, g;
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
- }), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.postMessage(
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 (o) {
45
- (n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
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: o
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 o = await this.opts.walletProvider.sendTransactionAsync(
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: o
67
+ txHash: a
68
68
  },
69
69
  this.baseUrl
70
70
  );
71
- } catch (o) {
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: o
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
- (w = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || w.postMessage(
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 o = await this.opts.walletProvider.signTypedDataAsync(
99
+ const a = await this.opts.walletProvider.signTypedDataAsync(
100
100
  t.data
101
101
  );
102
- (u = (y = this.iframe) == null ? void 0 : y.contentWindow) == null || u.postMessage(
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: o
106
+ signature: a
107
107
  },
108
108
  this.baseUrl
109
109
  );
110
- } catch (o) {
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: o
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 D = ({
171
+ const T = ({
172
172
  app: i,
173
173
  recipient: e,
174
174
  preferGaslessPayment: t,
175
175
  mode: s,
176
- amount: r,
177
- walletProvider: a,
178
- baseUrl: n
176
+ walletProvider: o,
177
+ baseUrl: r
179
178
  }) => ({
180
- openGlideDeposit: P(() => new E({
179
+ openGlideDeposit: v(() => new b({
181
180
  app: i,
182
181
  recipient: e,
183
182
  preferGaslessPayment: t,
184
183
  mode: s,
185
- amount: r,
186
- walletProvider: a,
187
- baseUrl: n
188
- }), [
189
- i,
190
- e,
191
- t,
192
- s,
193
- a,
194
- n,
195
- r
196
- ]).open
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
- E as GlideDeposit,
200
- D as useGlideDeposit
204
+ b as GlideDeposit,
205
+ T as useGlideDeposit,
206
+ $ as useGlidePay
201
207
  };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './GlideDeposit.ts';
2
2
  export * from './useGlideDeposit.ts';
3
+ export * from './useGlidePay.ts';
@@ -3,12 +3,11 @@ interface UseGlideDepositProps {
3
3
  app: string;
4
4
  recipient?: Hex;
5
5
  preferGaslessPayment?: boolean;
6
- mode?: "deposit" | "withdraw" | "pay";
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, amount, walletProvider, baseUrl, }: UseGlideDepositProps) => {
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"