@paywithglide/glide-react 0.0.7 → 0.0.8

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.
@@ -77,7 +77,8 @@ export type GlideDepositWalletProvider = {
77
77
  export type GlideDepositOptions = {
78
78
  app: string;
79
79
  recipient?: Hex;
80
- mode?: "deposit" | "withdraw";
80
+ mode?: "deposit" | "withdraw" | "pay";
81
+ amount?: string;
81
82
  preferGaslessPayment?: boolean;
82
83
  walletProvider?: GlideDepositWalletProvider;
83
84
  baseUrl?: string;
package/dist/glide.js CHANGED
@@ -6,7 +6,7 @@ class E {
6
6
  constructor(e) {
7
7
  p(this, "opts");
8
8
  p(this, "open", () => {
9
- var e, t, s, o;
9
+ var e, t, s, r;
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 || !!((o = this.opts.walletProvider) != null && o.signTypedDataAsync);
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);
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}` : ""}`
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}` : ""}`
20
20
  ), this.initialize();
21
21
  }
22
22
  });
23
23
  p(this, "iframeEventHandler", async (e) => {
24
- var s, o, a, n, d, l, c, h, m, w, y, u, f, g;
24
+ var s, r, a, n, d, l, c, h, m, w, y, 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
- }), (o = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || o.postMessage(
36
+ }), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.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 (r) {
44
+ } catch (o) {
45
45
  (n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
46
46
  {
47
47
  type: "didSwitchChain",
48
48
  success: !1,
49
- error: r
49
+ error: o
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 r = await this.opts.walletProvider.sendTransactionAsync(
60
+ const o = 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: r
67
+ txHash: o
68
68
  },
69
69
  this.baseUrl
70
70
  );
71
- } catch (r) {
71
+ } catch (o) {
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: r
76
+ error: o
77
77
  },
78
78
  this.baseUrl
79
79
  );
@@ -96,23 +96,23 @@ class E {
96
96
  return;
97
97
  }
98
98
  try {
99
- const r = await this.opts.walletProvider.signTypedDataAsync(
99
+ const o = await this.opts.walletProvider.signTypedDataAsync(
100
100
  t.data
101
101
  );
102
102
  (u = (y = this.iframe) == null ? void 0 : y.contentWindow) == null || u.postMessage(
103
103
  {
104
104
  type: "didSignTypedData",
105
105
  success: !0,
106
- signature: r
106
+ signature: o
107
107
  },
108
108
  this.baseUrl
109
109
  );
110
- } catch (r) {
110
+ } catch (o) {
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: r
115
+ error: o
116
116
  },
117
117
  this.baseUrl
118
118
  );
@@ -173,17 +173,27 @@ const D = ({
173
173
  recipient: e,
174
174
  preferGaslessPayment: t,
175
175
  mode: s,
176
- walletProvider: o,
177
- baseUrl: a
176
+ amount: r,
177
+ walletProvider: a,
178
+ baseUrl: n
178
179
  }) => ({
179
180
  openGlideDeposit: P(() => new E({
180
181
  app: i,
181
182
  recipient: e,
182
183
  preferGaslessPayment: t,
183
184
  mode: s,
184
- walletProvider: o,
185
- baseUrl: a
186
- }), [i, e, t, s, o, a]).open
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
187
197
  });
188
198
  export {
189
199
  E as GlideDeposit,
@@ -3,11 +3,12 @@ interface UseGlideDepositProps {
3
3
  app: string;
4
4
  recipient?: Hex;
5
5
  preferGaslessPayment?: boolean;
6
- mode?: "deposit" | "withdraw";
6
+ mode?: "deposit" | "withdraw" | "pay";
7
+ amount?: string;
7
8
  walletProvider?: GlideDepositWalletProvider;
8
9
  baseUrl?: string;
9
10
  }
10
- export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, walletProvider, baseUrl, }: UseGlideDepositProps) => {
11
+ export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, amount, walletProvider, baseUrl, }: UseGlideDepositProps) => {
11
12
  openGlideDeposit: () => void;
12
13
  };
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -23,7 +23,7 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@paywithglide/glide-js": "^0.9.35",
26
+ "@paywithglide/glide-js": "^0.10.0",
27
27
  "@tanstack/react-query": "^5.61.5",
28
28
  "react": "^18.3.1",
29
29
  "react-dom": "^18.3.1",
@@ -31,6 +31,7 @@
31
31
  "wagmi": "^2.13.0"
32
32
  },
33
33
  "devDependencies": {
34
+ "@antiwork/shortest": "^0.2.1",
34
35
  "@eslint/js": "^9.15.0",
35
36
  "@types/react": "^18.3.12",
36
37
  "@types/react-dom": "^18.3.1",