@paywithglide/glide-react 0.0.27 → 0.0.29
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 +1 -1
- package/dist/glide.js +25 -25
- package/dist/useGlideDeposit.d.ts +2 -2
- package/package.json +1 -1
package/dist/GlideDeposit.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export type GlideDepositOptions = {
|
|
|
99
99
|
token: Hex;
|
|
100
100
|
amount: bigint;
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
gasRefuelAmountPerChain?: Record<CAIP2, string>;
|
|
103
103
|
sessionMetadata?: string;
|
|
104
104
|
preferGaslessPayment?: boolean;
|
|
105
105
|
excludeChainIds?: CAIP2[];
|
package/dist/glide.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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 P = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { useMemo as I } 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
|
}
|
|
8
8
|
function R(s) {
|
|
9
9
|
return ee(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const N = "2.21.51";
|
|
12
12
|
let x = {
|
|
13
13
|
getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
|
|
14
|
-
version: `viem@${
|
|
14
|
+
version: `viem@${N}`
|
|
15
15
|
};
|
|
16
16
|
class $ extends Error {
|
|
17
17
|
constructor(t, e = {}) {
|
|
@@ -58,14 +58,14 @@ class $ extends Error {
|
|
|
58
58
|
configurable: !0,
|
|
59
59
|
writable: !0,
|
|
60
60
|
value: "BaseError"
|
|
61
|
-
}), this.details = i, this.docsPath = r, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version =
|
|
61
|
+
}), this.details = i, this.docsPath = r, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = N;
|
|
62
62
|
}
|
|
63
63
|
walk(t) {
|
|
64
|
-
return
|
|
64
|
+
return K(this, t);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ?
|
|
67
|
+
function K(s, t) {
|
|
68
|
+
return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? K(s.cause, t) : t ? null : s;
|
|
69
69
|
}
|
|
70
70
|
class F extends $ {
|
|
71
71
|
constructor({ size: t, targetSize: e, type: i }) {
|
|
@@ -160,8 +160,8 @@ function de(s, t = {}) {
|
|
|
160
160
|
}
|
|
161
161
|
class S {
|
|
162
162
|
constructor(t) {
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
P(this, "opts");
|
|
164
|
+
P(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,19 +172,19 @@ class S {
|
|
|
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, p, h, u, m, f, g, l, b, y, w, v, k, U, z, A, M, T, D, G, j, B,
|
|
175
|
+
P(this, "iframeEventHandler", async (t) => {
|
|
176
|
+
var i, r, o, c, a, n, p, h, u, m, f, g, l, b, y, w, v, k, U, z, A, 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": {
|
|
180
|
-
const d = this.opts.recipient,
|
|
180
|
+
const d = this.opts.recipient, J = (i = this.opts.walletProvider) == null ? void 0 : i.address, X = (r = this.opts.walletProvider) == null ? void 0 : r.availableChainIds, Q = (o = this.opts.walletProvider) == null ? void 0 : o.currentChainId, Y = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
|
|
181
181
|
(n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
|
|
182
182
|
{
|
|
183
183
|
type: "initialize",
|
|
184
184
|
sessionId: this.opts.sessionId,
|
|
185
185
|
recipient: d,
|
|
186
|
-
connectedWalletAddress:
|
|
187
|
-
availableChainIds:
|
|
186
|
+
connectedWalletAddress: J,
|
|
187
|
+
availableChainIds: X,
|
|
188
188
|
currentChainId: Q,
|
|
189
189
|
preferGaslessPayment: Y,
|
|
190
190
|
excludeChainIds: this.opts.excludeChainIds,
|
|
@@ -200,7 +200,7 @@ class S {
|
|
|
200
200
|
didProvideLocalStorage: !!this.opts.localStorageProvider,
|
|
201
201
|
debug: this.opts.debug,
|
|
202
202
|
popupsBlocked: this.opts.popupsBlocked,
|
|
203
|
-
|
|
203
|
+
gasRefuelAmountPerChain: this.opts.gasRefuelAmountPerChain
|
|
204
204
|
},
|
|
205
205
|
new URL(this.baseUrl).origin
|
|
206
206
|
), this.iframe.style.opacity = "1", (h = (p = this.opts).onOpen) == null || h.call(p);
|
|
@@ -297,7 +297,7 @@ class S {
|
|
|
297
297
|
this.baseUrl
|
|
298
298
|
);
|
|
299
299
|
} catch (d) {
|
|
300
|
-
(
|
|
300
|
+
(G = (C = this.iframe) == null ? void 0 : C.contentWindow) == null || G.postMessage(
|
|
301
301
|
{
|
|
302
302
|
type: "didSendTransaction",
|
|
303
303
|
success: !1,
|
|
@@ -313,7 +313,7 @@ class S {
|
|
|
313
313
|
if (!this.opts.walletProvider)
|
|
314
314
|
throw new Error("walletProvider is not set");
|
|
315
315
|
if (!this.opts.walletProvider.signTypedDataAsync) {
|
|
316
|
-
(
|
|
316
|
+
(B = (j = this.iframe) == null ? void 0 : j.contentWindow) == null || B.postMessage(
|
|
317
317
|
{
|
|
318
318
|
type: "didSignTypedData",
|
|
319
319
|
success: !1,
|
|
@@ -355,7 +355,7 @@ class S {
|
|
|
355
355
|
var t, e, i;
|
|
356
356
|
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.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${ne(
|
|
357
357
|
this.opts.evm.value || 0n
|
|
358
|
-
)}` : ""}${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.
|
|
358
|
+
)}` : ""}${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))}` : ""}`;
|
|
359
359
|
}
|
|
360
360
|
initialize() {
|
|
361
361
|
window.addEventListener("message", this.iframeEventHandler);
|
|
@@ -393,7 +393,7 @@ class S {
|
|
|
393
393
|
const ue = ({
|
|
394
394
|
app: s,
|
|
395
395
|
recipient: t,
|
|
396
|
-
|
|
396
|
+
gasRefuelAmountPerChain: e,
|
|
397
397
|
preferGaslessPayment: i,
|
|
398
398
|
excludeChainIds: r,
|
|
399
399
|
excludeCurrencyTiers: o,
|
|
@@ -411,10 +411,10 @@ const ue = ({
|
|
|
411
411
|
baseUrl: y,
|
|
412
412
|
debug: w
|
|
413
413
|
}) => {
|
|
414
|
-
const v =
|
|
414
|
+
const v = I(() => new S({
|
|
415
415
|
app: s,
|
|
416
416
|
recipient: t,
|
|
417
|
-
|
|
417
|
+
gasRefuelAmountPerChain: e,
|
|
418
418
|
preferGaslessPayment: i,
|
|
419
419
|
excludeChainIds: r,
|
|
420
420
|
excludeCurrencyTiers: o,
|
|
@@ -477,7 +477,7 @@ const ue = ({
|
|
|
477
477
|
baseUrl: b,
|
|
478
478
|
debug: y
|
|
479
479
|
}) => {
|
|
480
|
-
const w =
|
|
480
|
+
const w = I(() => new S({
|
|
481
481
|
app: s,
|
|
482
482
|
preferGaslessPayment: t,
|
|
483
483
|
excludeChainIds: e,
|
|
@@ -542,7 +542,7 @@ const ue = ({
|
|
|
542
542
|
baseUrl: b,
|
|
543
543
|
debug: y
|
|
544
544
|
}) => {
|
|
545
|
-
const w =
|
|
545
|
+
const w = I(() => new S({
|
|
546
546
|
app: s,
|
|
547
547
|
evm: t,
|
|
548
548
|
approval: e,
|
|
@@ -604,7 +604,7 @@ const ue = ({
|
|
|
604
604
|
autoCloseOnSuccess: f,
|
|
605
605
|
baseUrl: g
|
|
606
606
|
}) => {
|
|
607
|
-
const l =
|
|
607
|
+
const l = I(() => new S({
|
|
608
608
|
app: s,
|
|
609
609
|
recipient: t,
|
|
610
610
|
preferGaslessPayment: e,
|
|
@@ -4,7 +4,7 @@ import { CAIP2 } from '@paywithglide/glide-js';
|
|
|
4
4
|
interface UseGlideDepositProps {
|
|
5
5
|
app: string;
|
|
6
6
|
recipient?: string;
|
|
7
|
-
|
|
7
|
+
gasRefuelAmountPerChain?: Record<CAIP2, string>;
|
|
8
8
|
preferGaslessPayment?: boolean;
|
|
9
9
|
excludeChainIds?: CAIP2[];
|
|
10
10
|
excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
|
|
@@ -22,7 +22,7 @@ interface UseGlideDepositProps {
|
|
|
22
22
|
baseUrl?: string;
|
|
23
23
|
debug?: boolean;
|
|
24
24
|
}
|
|
25
|
-
export declare const useGlideDeposit: ({ app, recipient,
|
|
25
|
+
export declare const useGlideDeposit: ({ app, recipient, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
|
|
26
26
|
openGlideDeposit: () => void;
|
|
27
27
|
externalUrl: string;
|
|
28
28
|
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|