@paywithglide/glide-react 0.0.33 → 0.0.34

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.
@@ -115,6 +115,7 @@ export type GlideDepositOptions = {
115
115
  onSetMode?: (mode: "deposit" | "withdraw") => void;
116
116
  autoCloseOnSuccess?: boolean;
117
117
  container?: HTMLElement;
118
+ disableWithdrawToSelfSuggestion?: boolean;
118
119
  theme?: GlideWidgetTheme;
119
120
  popupsBlocked?: boolean;
120
121
  baseUrl?: string;
package/dist/glide.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var _ = Object.defineProperty;
2
2
  var ee = (s, t, e) => t in s ? _(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var k = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { useMemo as U } from "react";
3
+ var U = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as z } from "react";
5
5
  function te(s, { strict: t = !0 } = {}) {
6
6
  return !s || typeof s != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
7
7
  }
@@ -9,7 +9,7 @@ function N(s) {
9
9
  return te(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
11
  const K = "2.21.51";
12
- let E = {
12
+ let k = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
14
  version: `viem@${K}`
15
15
  };
@@ -19,13 +19,13 @@ class x extends Error {
19
19
  const i = (() => {
20
20
  var n;
21
21
  return e.cause instanceof x ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
- })(), r = e.cause instanceof x && e.cause.docsPath || e.docsPath, o = (a = E.getDocsUrl) == null ? void 0 : a.call(E, { ...e, docsPath: r }), c = [
22
+ })(), r = e.cause instanceof x && e.cause.docsPath || e.docsPath, o = (a = k.getDocsUrl) == null ? void 0 : a.call(k, { ...e, docsPath: r }), c = [
23
23
  t || "An error occurred.",
24
24
  "",
25
25
  ...e.metaMessages ? [...e.metaMessages, ""] : [],
26
26
  ...o ? [`Docs: ${o}`] : [],
27
27
  ...i ? [`Details: ${i}`] : [],
28
- ...E.version ? [`Version: ${E.version}`] : []
28
+ ...k.version ? [`Version: ${k.version}`] : []
29
29
  ].join(`
30
30
  `);
31
31
  super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
@@ -158,10 +158,10 @@ function pe(s, t = {}) {
158
158
  const e = le.encode(s);
159
159
  return J(e, t);
160
160
  }
161
- class z {
161
+ class T {
162
162
  constructor(t) {
163
- k(this, "opts");
164
- k(this, "open", () => {
163
+ U(this, "opts");
164
+ U(this, "open", () => {
165
165
  if (!(!this.opts.container && document.body.classList.contains("glide-deposit-open"))) {
166
166
  if (this.opts.container || document.body.classList.add("glide-deposit-open"), (this.opts.mode === "deposit" || this.opts.mode === "buy") && !this.opts.recipient)
167
167
  throw new Error("recipient is required for deposit/buy mode");
@@ -172,8 +172,8 @@ class z {
172
172
  this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
173
173
  }
174
174
  });
175
- k(this, "iframeEventHandler", async (t) => {
176
- var i, r, o, c, a, n, u, m, f, g, y, w, b, d, l, p, I, v, P, S, $, M, T, D, C, G, j, B, W, H, O, L, R;
175
+ U(this, "iframeEventHandler", async (t) => {
176
+ var i, r, o, c, a, n, u, m, g, f, y, w, b, d, l, p, S, v, I, P, E, $, M, D, C, G, W, j, B, H, O, L, R;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
@@ -198,6 +198,7 @@ class z {
198
198
  tokenApproval: this.opts.approval,
199
199
  sessionMetadata: this.opts.sessionMetadata,
200
200
  autoCloseOnSuccess: this.opts.autoCloseOnSuccess,
201
+ disableWithdrawToSelfSuggestion: this.opts.disableWithdrawToSelfSuggestion,
201
202
  theme: {
202
203
  ...this.opts.theme || {},
203
204
  colorScheme: ((n = this.opts.theme) == null ? void 0 : n.colorScheme) || getComputedStyle(document.documentElement).colorScheme || ""
@@ -212,14 +213,14 @@ class z {
212
213
  break;
213
214
  }
214
215
  case "didOpen": {
215
- this.iframe.style.opacity = "1", (f = (m = this.opts).onOpen) == null || f.call(m);
216
+ this.iframe.style.opacity = "1", (g = (m = this.opts).onOpen) == null || g.call(m);
216
217
  break;
217
218
  }
218
219
  case "localStorage.getKeys": {
219
220
  if (!this.opts.localStorageProvider)
220
221
  throw new Error("localStorageProvider is not set");
221
222
  const h = await this.opts.localStorageProvider.getKeys();
222
- (y = (g = this.iframe) == null ? void 0 : g.contentWindow) == null || y.postMessage(
223
+ (y = (f = this.iframe) == null ? void 0 : f.contentWindow) == null || y.postMessage(
223
224
  {
224
225
  type: "localStorage.didGetKeys",
225
226
  keys: h
@@ -259,10 +260,10 @@ class z {
259
260
  (l = (d = this.opts) == null ? void 0 : d.onSuccess) == null || l.call(d, e.hash, e.session);
260
261
  break;
261
262
  case "close":
262
- this.removeIframe(), this.destroy(), (I = (p = this.opts) == null ? void 0 : p.onClose) == null || I.call(p);
263
+ this.removeIframe(), this.destroy(), (S = (p = this.opts) == null ? void 0 : p.onClose) == null || S.call(p);
263
264
  break;
264
265
  case "setMode":
265
- (P = (v = this.opts) == null ? void 0 : v.onSetMode) == null || P.call(v, e.mode);
266
+ (I = (v = this.opts) == null ? void 0 : v.onSetMode) == null || I.call(v, e.mode);
266
267
  break;
267
268
  case "switchChain":
268
269
  if (!this.opts.walletProvider)
@@ -270,7 +271,7 @@ class z {
270
271
  try {
271
272
  await this.opts.walletProvider.switchChainAsync({
272
273
  chainId: e.chainId
273
- }), ($ = (S = this.iframe) == null ? void 0 : S.contentWindow) == null || $.postMessage(
274
+ }), (E = (P = this.iframe) == null ? void 0 : P.contentWindow) == null || E.postMessage(
274
275
  {
275
276
  type: "didSwitchChain",
276
277
  success: !0,
@@ -279,7 +280,7 @@ class z {
279
280
  this.baseUrl
280
281
  );
281
282
  } catch (h) {
282
- (T = (M = this.iframe) == null ? void 0 : M.contentWindow) == null || T.postMessage(
283
+ (M = ($ = this.iframe) == null ? void 0 : $.contentWindow) == null || M.postMessage(
283
284
  {
284
285
  type: "didSwitchChain",
285
286
  success: !1,
@@ -306,7 +307,7 @@ class z {
306
307
  this.baseUrl
307
308
  );
308
309
  } catch (h) {
309
- (j = (G = this.iframe) == null ? void 0 : G.contentWindow) == null || j.postMessage(
310
+ (W = (G = this.iframe) == null ? void 0 : G.contentWindow) == null || W.postMessage(
310
311
  {
311
312
  type: "didSendTransaction",
312
313
  success: !1,
@@ -322,7 +323,7 @@ class z {
322
323
  if (!this.opts.walletProvider)
323
324
  throw new Error("walletProvider is not set");
324
325
  if (!this.opts.walletProvider.signTypedDataAsync) {
325
- (W = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || W.postMessage(
326
+ (B = (j = this.iframe) == null ? void 0 : j.contentWindow) == null || B.postMessage(
326
327
  {
327
328
  type: "didSignTypedData",
328
329
  success: !1,
@@ -364,7 +365,7 @@ class z {
364
365
  var t, e, i;
365
366
  return `${this.baseUrl}${this.opts.app}?${this.opts.recipient ? `&recipient=${this.opts.recipient}` : ""}${this.opts.preferGaslessPayment ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}${this.opts.chainId ? `&chainId=${this.opts.chainId}` : ""}${this.opts.currencyId ? `&currencyId=${this.opts.currencyId}` : ""}${this.opts.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${ae(
366
367
  this.opts.evm.value || 0n
367
- )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
368
+ )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${this.opts.debug ? "&debug=true" : ""}${this.opts.popupsBlocked ? "&popupsBlocked=true" : ""}${this.opts.disableWithdrawToSelfSuggestion ? "&disableWithdrawToSelfSuggestion=true" : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
368
369
  }
369
370
  initialize() {
370
371
  window.addEventListener("message", this.iframeEventHandler);
@@ -411,20 +412,21 @@ const me = ({
411
412
  excludeCurrencyTiers: n,
412
413
  excludeFundingSources: u,
413
414
  mode: m,
414
- sessionId: f,
415
- sessionMetadata: g,
416
- theme: y,
417
- walletProvider: w,
418
- localStorageProvider: b,
419
- onOpen: d,
420
- onSuccess: l,
421
- onClose: p,
422
- autoCloseOnSuccess: I,
423
- popupsBlocked: v,
415
+ sessionId: g,
416
+ sessionMetadata: f,
417
+ disableWithdrawToSelfSuggestion: y,
418
+ theme: w,
419
+ walletProvider: b,
420
+ localStorageProvider: d,
421
+ onOpen: l,
422
+ onSuccess: p,
423
+ onClose: S,
424
+ autoCloseOnSuccess: v,
425
+ popupsBlocked: I,
424
426
  baseUrl: P,
425
- debug: S
427
+ debug: E
426
428
  }) => {
427
- const $ = U(() => new z({
429
+ const $ = z(() => new T({
428
430
  app: s,
429
431
  recipient: t,
430
432
  chainId: e,
@@ -436,18 +438,19 @@ const me = ({
436
438
  excludeCurrencyTiers: n,
437
439
  excludeFundingSources: u,
438
440
  mode: m,
439
- sessionId: f,
440
- sessionMetadata: g,
441
- theme: y,
442
- walletProvider: w,
443
- localStorageProvider: b,
444
- onOpen: d,
445
- onSuccess: l,
446
- onClose: p,
447
- autoCloseOnSuccess: I,
448
- popupsBlocked: v,
441
+ sessionId: g,
442
+ sessionMetadata: f,
443
+ disableWithdrawToSelfSuggestion: y,
444
+ theme: w,
445
+ walletProvider: b,
446
+ localStorageProvider: d,
447
+ onOpen: l,
448
+ onSuccess: p,
449
+ onClose: S,
450
+ autoCloseOnSuccess: v,
451
+ popupsBlocked: I,
449
452
  baseUrl: P,
450
- debug: S
453
+ debug: E
451
454
  }), [
452
455
  s,
453
456
  t,
@@ -460,25 +463,26 @@ const me = ({
460
463
  n,
461
464
  u,
462
465
  m,
463
- f,
464
466
  g,
467
+ f,
465
468
  y,
466
469
  w,
467
470
  b,
468
471
  d,
469
472
  l,
470
473
  p,
471
- I,
474
+ S,
472
475
  v,
476
+ I,
473
477
  P,
474
- S
478
+ E
475
479
  ]);
476
480
  return {
477
481
  openGlideDeposit: $.open,
478
482
  externalUrl: $.externalUrl,
479
483
  opts: $.opts
480
484
  };
481
- }, fe = ({
485
+ }, ge = ({
482
486
  app: s,
483
487
  preferGaslessPayment: t,
484
488
  excludeChainIds: e,
@@ -490,15 +494,15 @@ const me = ({
490
494
  theme: n,
491
495
  walletProvider: u,
492
496
  localStorageProvider: m,
493
- onOpen: f,
494
- onSuccess: g,
497
+ onOpen: g,
498
+ onSuccess: f,
495
499
  onClose: y,
496
500
  autoCloseOnSuccess: w,
497
501
  popupsBlocked: b,
498
502
  baseUrl: d,
499
503
  debug: l
500
504
  }) => {
501
- const p = U(() => new z({
505
+ const p = z(() => new T({
502
506
  app: s,
503
507
  preferGaslessPayment: t,
504
508
  excludeChainIds: e,
@@ -511,8 +515,8 @@ const me = ({
511
515
  theme: n,
512
516
  walletProvider: u,
513
517
  localStorageProvider: m,
514
- onOpen: f,
515
- onSuccess: g,
518
+ onOpen: g,
519
+ onSuccess: f,
516
520
  onClose: y,
517
521
  autoCloseOnSuccess: w,
518
522
  popupsBlocked: b,
@@ -530,8 +534,8 @@ const me = ({
530
534
  n,
531
535
  u,
532
536
  m,
533
- f,
534
537
  g,
538
+ f,
535
539
  y,
536
540
  w,
537
541
  b,
@@ -543,7 +547,7 @@ const me = ({
543
547
  externalUrl: p.externalUrl,
544
548
  opts: p.opts
545
549
  };
546
- }, ge = ({
550
+ }, fe = ({
547
551
  app: s,
548
552
  evm: t,
549
553
  approval: e,
@@ -555,15 +559,15 @@ const me = ({
555
559
  theme: n,
556
560
  walletProvider: u,
557
561
  localStorageProvider: m,
558
- onOpen: f,
559
- onSuccess: g,
562
+ onOpen: g,
563
+ onSuccess: f,
560
564
  onClose: y,
561
565
  autoCloseOnSuccess: w,
562
566
  popupsBlocked: b,
563
567
  baseUrl: d,
564
568
  debug: l
565
569
  }) => {
566
- const p = U(() => new z({
570
+ const p = z(() => new T({
567
571
  app: s,
568
572
  evm: t,
569
573
  approval: e,
@@ -576,8 +580,8 @@ const me = ({
576
580
  theme: n,
577
581
  walletProvider: u,
578
582
  localStorageProvider: m,
579
- onOpen: f,
580
- onSuccess: g,
583
+ onOpen: g,
584
+ onSuccess: f,
581
585
  onClose: y,
582
586
  autoCloseOnSuccess: w,
583
587
  popupsBlocked: b,
@@ -595,8 +599,8 @@ const me = ({
595
599
  n,
596
600
  u,
597
601
  m,
598
- f,
599
602
  g,
603
+ f,
600
604
  y,
601
605
  w,
602
606
  b,
@@ -620,14 +624,14 @@ const me = ({
620
624
  sessionMetadata: n,
621
625
  theme: u,
622
626
  walletProvider: m,
623
- localStorageProvider: f,
624
- onOpen: g,
627
+ localStorageProvider: g,
628
+ onOpen: f,
625
629
  onSuccess: y,
626
630
  onClose: w,
627
631
  autoCloseOnSuccess: b,
628
632
  baseUrl: d
629
633
  }) => {
630
- const l = U(() => new z({
634
+ const l = z(() => new T({
631
635
  app: s,
632
636
  recipient: t,
633
637
  chainId: e,
@@ -640,8 +644,8 @@ const me = ({
640
644
  mode: "buy",
641
645
  theme: u,
642
646
  walletProvider: m,
643
- localStorageProvider: f,
644
- onOpen: g,
647
+ localStorageProvider: g,
648
+ onOpen: f,
645
649
  onSuccess: y,
646
650
  onClose: w,
647
651
  autoCloseOnSuccess: b,
@@ -658,8 +662,8 @@ const me = ({
658
662
  n,
659
663
  u,
660
664
  m,
661
- f,
662
665
  g,
666
+ f,
663
667
  y,
664
668
  w,
665
669
  b,
@@ -703,10 +707,10 @@ const me = ({
703
707
  })
704
708
  });
705
709
  export {
706
- z as GlideDeposit,
710
+ T as GlideDeposit,
707
711
  we as browserLocalStorageProvider,
708
712
  ye as useGlideBuy,
709
- ge as useGlideCall,
713
+ fe as useGlideCall,
710
714
  me as useGlideDeposit,
711
- fe as useGlidePay
715
+ ge as useGlidePay
712
716
  };
@@ -13,8 +13,10 @@ interface UseGlideDepositProps {
13
13
  excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
14
14
  excludeFundingSources?: FundingSource[];
15
15
  mode?: "deposit" | "withdraw";
16
+ hideWithdrawAddress?: boolean;
16
17
  sessionId?: string;
17
18
  sessionMetadata?: string;
19
+ disableWithdrawToSelfSuggestion?: boolean;
18
20
  theme?: GlideWidgetTheme;
19
21
  walletProvider?: GlideDepositWalletProvider;
20
22
  localStorageProvider?: GlideLocalStorageProvider;
@@ -26,7 +28,7 @@ interface UseGlideDepositProps {
26
28
  baseUrl?: string;
27
29
  debug?: boolean;
28
30
  }
29
- export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
31
+ export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionId, sessionMetadata, disableWithdrawToSelfSuggestion, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
30
32
  openGlideDeposit: () => void;
31
33
  externalUrl: string;
32
34
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"