@paywithglide/glide-react 0.0.31 → 0.0.32
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 +2 -2
- package/dist/glide.js +48 -45
- package/dist/useGlideBuy.d.ts +2 -2
- package/dist/useGlideCall.d.ts +2 -2
- package/dist/useGlideDeposit.d.ts +4 -3
- package/dist/useGlidePay.d.ts +2 -2
- package/package.json +1 -1
package/dist/GlideDeposit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlideWidgetTheme } from './theme.ts';
|
|
2
|
-
import { CAIP2 } from '@paywithglide/glide-js';
|
|
2
|
+
import { CAIP2, Session } from '@paywithglide/glide-js';
|
|
3
3
|
export type Hex = `0x${string}`;
|
|
4
4
|
export type EVMTransaction = {
|
|
5
5
|
chainId: number;
|
|
@@ -110,7 +110,7 @@ export type GlideDepositOptions = {
|
|
|
110
110
|
walletProvider?: GlideDepositWalletProvider;
|
|
111
111
|
localStorageProvider?: GlideLocalStorageProvider;
|
|
112
112
|
onOpen?: () => void;
|
|
113
|
-
onSuccess?: (
|
|
113
|
+
onSuccess?: (fulfillmentTxHash: Hex, session: Session) => void;
|
|
114
114
|
onClose?: () => void;
|
|
115
115
|
onSetMode?: (mode: "deposit" | "withdraw") => void;
|
|
116
116
|
autoCloseOnSuccess?: boolean;
|
package/dist/glide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Z = Object.defineProperty;
|
|
2
2
|
var _ = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import { useMemo as
|
|
3
|
+
var k = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { useMemo as U } from "react";
|
|
5
5
|
function ee(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 R(s) {
|
|
|
9
9
|
return ee(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
|
|
10
10
|
}
|
|
11
11
|
const N = "2.21.51";
|
|
12
|
-
let
|
|
12
|
+
let E = {
|
|
13
13
|
getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
|
|
14
14
|
version: `viem@${N}`
|
|
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 =
|
|
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 = [
|
|
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
|
-
...
|
|
28
|
+
...E.version ? [`Version: ${E.version}`] : []
|
|
29
29
|
].join(`
|
|
30
30
|
`);
|
|
31
31
|
super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
|
|
@@ -72,7 +72,7 @@ class F extends x {
|
|
|
72
72
|
super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${t}) exceeds padding size (${e}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function A(s, { dir: t, size: e = 32 } = {}) {
|
|
76
76
|
return typeof s == "string" ? te(s, { dir: t, size: e }) : se(s, { dir: t, size: e });
|
|
77
77
|
}
|
|
78
78
|
function te(s, { dir: t, size: e = 32 } = {}) {
|
|
@@ -126,14 +126,14 @@ function ne(s, t = {}) {
|
|
|
126
126
|
}
|
|
127
127
|
function ae(s, t = {}) {
|
|
128
128
|
const e = `0x${Number(s)}`;
|
|
129
|
-
return typeof t.size == "number" ? (V(e, { size: t.size }),
|
|
129
|
+
return typeof t.size == "number" ? (V(e, { size: t.size }), A(e, { size: t.size })) : e;
|
|
130
130
|
}
|
|
131
131
|
function q(s, t = {}) {
|
|
132
132
|
let e = "";
|
|
133
133
|
for (let r = 0; r < s.length; r++)
|
|
134
134
|
e += oe[s[r]];
|
|
135
135
|
const i = `0x${e}`;
|
|
136
|
-
return typeof t.size == "number" ? (V(i, { size: t.size }),
|
|
136
|
+
return typeof t.size == "number" ? (V(i, { size: t.size }), A(i, { dir: "right", size: t.size })) : i;
|
|
137
137
|
}
|
|
138
138
|
function ce(s, t = {}) {
|
|
139
139
|
const { signed: e, size: i } = t, r = BigInt(s);
|
|
@@ -151,17 +151,17 @@ function ce(s, t = {}) {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
const a = `0x${(e && r < 0 ? (1n << BigInt(i * 8)) + BigInt(r) : r).toString(16)}`;
|
|
154
|
-
return i ?
|
|
154
|
+
return i ? A(a, { size: i }) : a;
|
|
155
155
|
}
|
|
156
156
|
const de = /* @__PURE__ */ new TextEncoder();
|
|
157
157
|
function le(s, t = {}) {
|
|
158
158
|
const e = de.encode(s);
|
|
159
159
|
return q(e, t);
|
|
160
160
|
}
|
|
161
|
-
class
|
|
161
|
+
class z {
|
|
162
162
|
constructor(t) {
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
k(this, "opts");
|
|
164
|
+
k(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 U {
|
|
|
172
172
|
this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
|
|
176
|
-
var i, r, o, c, a, n, h, u, m, f, g, y, l, w, d, b, v, I, P, $,
|
|
175
|
+
k(this, "iframeEventHandler", async (t) => {
|
|
176
|
+
var i, r, o, c, a, n, h, u, m, f, g, y, l, w, d, b, v, I, P, S, $, M, T, D, C, G, j, B, W, H, L, O;
|
|
177
177
|
const e = t.data;
|
|
178
178
|
switch (e.type) {
|
|
179
179
|
case "sendInit": {
|
|
@@ -249,7 +249,7 @@ class U {
|
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
251
|
case "success":
|
|
252
|
-
(w = (l = this.opts) == null ? void 0 : l.onSuccess) == null || w.call(l, e.hash);
|
|
252
|
+
(w = (l = this.opts) == null ? void 0 : l.onSuccess) == null || w.call(l, e.hash, e.session);
|
|
253
253
|
break;
|
|
254
254
|
case "close":
|
|
255
255
|
this.removeIframe(), this.destroy(), (b = (d = this.opts) == null ? void 0 : d.onClose) == null || b.call(d);
|
|
@@ -263,7 +263,7 @@ class U {
|
|
|
263
263
|
try {
|
|
264
264
|
await this.opts.walletProvider.switchChainAsync({
|
|
265
265
|
chainId: e.chainId
|
|
266
|
-
}), (
|
|
266
|
+
}), (S = (P = this.iframe) == null ? void 0 : P.contentWindow) == null || S.postMessage(
|
|
267
267
|
{
|
|
268
268
|
type: "didSwitchChain",
|
|
269
269
|
success: !0,
|
|
@@ -272,7 +272,7 @@ class U {
|
|
|
272
272
|
this.baseUrl
|
|
273
273
|
);
|
|
274
274
|
} catch (p) {
|
|
275
|
-
(M = (
|
|
275
|
+
(M = ($ = this.iframe) == null ? void 0 : $.contentWindow) == null || M.postMessage(
|
|
276
276
|
{
|
|
277
277
|
type: "didSwitchChain",
|
|
278
278
|
success: !1,
|
|
@@ -404,19 +404,20 @@ const ue = ({
|
|
|
404
404
|
excludeCurrencyTiers: n,
|
|
405
405
|
excludeFundingSources: h,
|
|
406
406
|
mode: u,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
407
|
+
sessionId: m,
|
|
408
|
+
sessionMetadata: f,
|
|
409
|
+
theme: g,
|
|
410
|
+
walletProvider: y,
|
|
411
|
+
localStorageProvider: l,
|
|
412
|
+
onOpen: w,
|
|
413
|
+
onSuccess: d,
|
|
414
|
+
onClose: b,
|
|
415
|
+
autoCloseOnSuccess: v,
|
|
416
|
+
popupsBlocked: I,
|
|
417
|
+
baseUrl: P,
|
|
418
|
+
debug: S
|
|
418
419
|
}) => {
|
|
419
|
-
const $ =
|
|
420
|
+
const $ = U(() => new z({
|
|
420
421
|
app: s,
|
|
421
422
|
recipient: t,
|
|
422
423
|
chainId: e,
|
|
@@ -428,17 +429,18 @@ const ue = ({
|
|
|
428
429
|
excludeCurrencyTiers: n,
|
|
429
430
|
excludeFundingSources: h,
|
|
430
431
|
mode: u,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
432
|
+
sessionId: m,
|
|
433
|
+
sessionMetadata: f,
|
|
434
|
+
theme: g,
|
|
435
|
+
walletProvider: y,
|
|
436
|
+
localStorageProvider: l,
|
|
437
|
+
onOpen: w,
|
|
438
|
+
onSuccess: d,
|
|
439
|
+
onClose: b,
|
|
440
|
+
autoCloseOnSuccess: v,
|
|
441
|
+
popupsBlocked: I,
|
|
442
|
+
baseUrl: P,
|
|
443
|
+
debug: S
|
|
442
444
|
}), [
|
|
443
445
|
s,
|
|
444
446
|
t,
|
|
@@ -461,7 +463,8 @@ const ue = ({
|
|
|
461
463
|
b,
|
|
462
464
|
v,
|
|
463
465
|
I,
|
|
464
|
-
P
|
|
466
|
+
P,
|
|
467
|
+
S
|
|
465
468
|
]);
|
|
466
469
|
return {
|
|
467
470
|
openGlideDeposit: $.open,
|
|
@@ -488,7 +491,7 @@ const ue = ({
|
|
|
488
491
|
baseUrl: w,
|
|
489
492
|
debug: d
|
|
490
493
|
}) => {
|
|
491
|
-
const b =
|
|
494
|
+
const b = U(() => new z({
|
|
492
495
|
app: s,
|
|
493
496
|
preferGaslessPayment: t,
|
|
494
497
|
excludeChainIds: e,
|
|
@@ -553,7 +556,7 @@ const ue = ({
|
|
|
553
556
|
baseUrl: w,
|
|
554
557
|
debug: d
|
|
555
558
|
}) => {
|
|
556
|
-
const b =
|
|
559
|
+
const b = U(() => new z({
|
|
557
560
|
app: s,
|
|
558
561
|
evm: t,
|
|
559
562
|
approval: e,
|
|
@@ -617,7 +620,7 @@ const ue = ({
|
|
|
617
620
|
autoCloseOnSuccess: l,
|
|
618
621
|
baseUrl: w
|
|
619
622
|
}) => {
|
|
620
|
-
const d =
|
|
623
|
+
const d = U(() => new z({
|
|
621
624
|
app: s,
|
|
622
625
|
recipient: t,
|
|
623
626
|
chainId: e,
|
|
@@ -693,7 +696,7 @@ const ue = ({
|
|
|
693
696
|
})
|
|
694
697
|
});
|
|
695
698
|
export {
|
|
696
|
-
|
|
699
|
+
z as GlideDeposit,
|
|
697
700
|
ye as browserLocalStorageProvider,
|
|
698
701
|
ge as useGlideBuy,
|
|
699
702
|
fe as useGlideCall,
|
package/dist/useGlideBuy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex } from './GlideDeposit.ts';
|
|
2
2
|
import { GlideWidgetTheme } from './theme.ts';
|
|
3
|
-
import { CAIP2 } from '@paywithglide/glide-js';
|
|
3
|
+
import { CAIP2, Session } from '@paywithglide/glide-js';
|
|
4
4
|
interface UseGlideBuyProps {
|
|
5
5
|
app: string;
|
|
6
6
|
recipient?: string;
|
|
@@ -15,7 +15,7 @@ interface UseGlideBuyProps {
|
|
|
15
15
|
walletProvider?: GlideDepositWalletProvider;
|
|
16
16
|
localStorageProvider?: GlideLocalStorageProvider;
|
|
17
17
|
onOpen?: () => void;
|
|
18
|
-
onSuccess?: (hash: Hex) => void;
|
|
18
|
+
onSuccess?: (hash: Hex, session: Session) => void;
|
|
19
19
|
onClose?: () => void;
|
|
20
20
|
autoCloseOnSuccess?: boolean;
|
|
21
21
|
baseUrl?: string;
|
package/dist/useGlideCall.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex } from './GlideDeposit.ts';
|
|
2
2
|
import { GlideWidgetTheme } from './theme.ts';
|
|
3
|
-
import { CAIP2 } from '@paywithglide/glide-js';
|
|
3
|
+
import { CAIP2, Session } from '@paywithglide/glide-js';
|
|
4
4
|
interface UseGlideCallProps {
|
|
5
5
|
app: string;
|
|
6
6
|
evm: {
|
|
@@ -22,7 +22,7 @@ interface UseGlideCallProps {
|
|
|
22
22
|
walletProvider?: GlideDepositWalletProvider;
|
|
23
23
|
localStorageProvider?: GlideLocalStorageProvider;
|
|
24
24
|
onOpen?: () => void;
|
|
25
|
-
onSuccess?: (hash: Hex) => void;
|
|
25
|
+
onSuccess?: (hash: Hex, session: Session) => void;
|
|
26
26
|
onClose?: () => void;
|
|
27
27
|
autoCloseOnSuccess?: boolean;
|
|
28
28
|
popupsBlocked?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider } from './GlideDeposit.ts';
|
|
2
2
|
import { GlideWidgetTheme } from './theme.ts';
|
|
3
|
-
import { CAIP2 } from '@paywithglide/glide-js';
|
|
3
|
+
import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
|
|
4
4
|
interface UseGlideDepositProps {
|
|
5
5
|
app: string;
|
|
6
6
|
recipient?: string;
|
|
@@ -13,19 +13,20 @@ interface UseGlideDepositProps {
|
|
|
13
13
|
excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
|
|
14
14
|
excludeFundingSources?: FundingSource[];
|
|
15
15
|
mode?: "deposit" | "withdraw";
|
|
16
|
+
sessionId?: string;
|
|
16
17
|
sessionMetadata?: string;
|
|
17
18
|
theme?: GlideWidgetTheme;
|
|
18
19
|
walletProvider?: GlideDepositWalletProvider;
|
|
19
20
|
localStorageProvider?: GlideLocalStorageProvider;
|
|
20
21
|
onOpen?: () => void;
|
|
21
|
-
onSuccess?: (hash:
|
|
22
|
+
onSuccess?: (hash: Hex, session: Session) => void;
|
|
22
23
|
onClose?: () => void;
|
|
23
24
|
autoCloseOnSuccess?: boolean;
|
|
24
25
|
popupsBlocked?: boolean;
|
|
25
26
|
baseUrl?: string;
|
|
26
27
|
debug?: boolean;
|
|
27
28
|
}
|
|
28
|
-
export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
|
|
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) => {
|
|
29
30
|
openGlideDeposit: () => void;
|
|
30
31
|
externalUrl: string;
|
|
31
32
|
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|
package/dist/useGlidePay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider } from './GlideDeposit.ts';
|
|
2
2
|
import { GlideWidgetTheme } from './theme.ts';
|
|
3
|
-
import { CAIP2 } from '@paywithglide/glide-js';
|
|
3
|
+
import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
|
|
4
4
|
type UseGlidePayProps = {
|
|
5
5
|
app: string;
|
|
6
6
|
amount?: string;
|
|
@@ -14,7 +14,7 @@ type UseGlidePayProps = {
|
|
|
14
14
|
walletProvider?: GlideDepositWalletProvider;
|
|
15
15
|
localStorageProvider?: GlideLocalStorageProvider;
|
|
16
16
|
onOpen?: () => void;
|
|
17
|
-
onSuccess?: (hash:
|
|
17
|
+
onSuccess?: (hash: Hex, session: Session) => void;
|
|
18
18
|
onClose?: () => void;
|
|
19
19
|
autoCloseOnSuccess?: boolean;
|
|
20
20
|
popupsBlocked?: boolean;
|