@paywithglide/glide-react 0.0.28 → 0.0.30

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.
@@ -1,5 +1,5 @@
1
1
  import { GlideWidgetTheme } from './theme.ts';
2
- import { CAIP2 } from '@paywithglide/glide-js';
2
+ import { CAIP2, Chain, Currency } from '@paywithglide/glide-js';
3
3
  export type Hex = `0x${string}`;
4
4
  export type EVMTransaction = {
5
5
  chainId: number;
@@ -89,6 +89,8 @@ export type GlideDepositOptions = {
89
89
  mode?: "deposit" | "withdraw" | "pay" | "call" | "buy";
90
90
  amount?: string;
91
91
  sessionId?: string;
92
+ chain?: Chain;
93
+ currency?: Currency;
92
94
  evm?: {
93
95
  chainId: number;
94
96
  to: Hex;
@@ -99,7 +101,7 @@ export type GlideDepositOptions = {
99
101
  token: Hex;
100
102
  amount: bigint;
101
103
  };
102
- gasRefuelUSD?: string;
104
+ gasRefuelAmountPerChain?: Record<CAIP2, string>;
103
105
  sessionMetadata?: string;
104
106
  preferGaslessPayment?: boolean;
105
107
  excludeChainIds?: CAIP2[];
package/dist/glide.js CHANGED
@@ -1,31 +1,31 @@
1
- var Z = Object.defineProperty;
2
- var _ = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var S = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { useMemo as I } from "react";
5
- function ee(s, { strict: t = !0 } = {}) {
1
+ var ee = Object.defineProperty;
2
+ var te = (s, t, e) => t in s ? ee(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var S = (s, t, e) => te(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as E } from "react";
5
+ function se(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
- function R(s) {
9
- return ee(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
8
+ function K(s) {
9
+ return se(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
- const K = "2.21.51";
12
- let x = {
11
+ const F = "2.21.51";
12
+ let P = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
- version: `viem@${K}`
14
+ version: `viem@${F}`
15
15
  };
16
- class $ extends Error {
16
+ class x extends Error {
17
17
  constructor(t, e = {}) {
18
18
  var a;
19
19
  const i = (() => {
20
20
  var n;
21
- return e.cause instanceof $ ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
- })(), r = e.cause instanceof $ && e.cause.docsPath || e.docsPath, o = (a = x.getDocsUrl) == null ? void 0 : a.call(x, { ...e, docsPath: r }), c = [
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 = P.getDocsUrl) == null ? void 0 : a.call(P, { ...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
- ...x.version ? [`Version: ${x.version}`] : []
28
+ ...P.version ? [`Version: ${P.version}`] : []
29
29
  ].join(`
30
30
  `);
31
31
  super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
@@ -58,40 +58,40 @@ 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 = K;
61
+ }), this.details = i, this.docsPath = r, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = F;
62
62
  }
63
63
  walk(t) {
64
- return N(this, t);
64
+ return V(this, t);
65
65
  }
66
66
  }
67
- function N(s, t) {
68
- return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? N(s.cause, t) : t ? null : s;
67
+ function V(s, t) {
68
+ return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? V(s.cause, t) : t ? null : s;
69
69
  }
70
- class F extends $ {
70
+ class q extends x {
71
71
  constructor({ size: t, targetSize: e, type: i }) {
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 E(s, { dir: t, size: e = 32 } = {}) {
76
- return typeof s == "string" ? te(s, { dir: t, size: e }) : se(s, { dir: t, size: e });
75
+ function U(s, { dir: t, size: e = 32 } = {}) {
76
+ return typeof s == "string" ? ie(s, { dir: t, size: e }) : re(s, { dir: t, size: e });
77
77
  }
78
- function te(s, { dir: t, size: e = 32 } = {}) {
78
+ function ie(s, { dir: t, size: e = 32 } = {}) {
79
79
  if (e === null)
80
80
  return s;
81
81
  const i = s.replace("0x", "");
82
82
  if (i.length > e * 2)
83
- throw new F({
83
+ throw new q({
84
84
  size: Math.ceil(i.length / 2),
85
85
  targetSize: e,
86
86
  type: "hex"
87
87
  });
88
88
  return `0x${i[t === "right" ? "padEnd" : "padStart"](e * 2, "0")}`;
89
89
  }
90
- function se(s, { dir: t, size: e = 32 } = {}) {
90
+ function re(s, { dir: t, size: e = 32 } = {}) {
91
91
  if (e === null)
92
92
  return s;
93
93
  if (s.length > e)
94
- throw new F({
94
+ throw new q({
95
95
  size: s.length,
96
96
  targetSize: e,
97
97
  type: "bytes"
@@ -103,46 +103,46 @@ function se(s, { dir: t, size: e = 32 } = {}) {
103
103
  }
104
104
  return i;
105
105
  }
106
- class ie extends $ {
106
+ class oe extends x {
107
107
  constructor({ max: t, min: e, signed: i, size: r, value: o }) {
108
108
  super(`Number "${o}" is not in safe ${r ? `${r * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${e} to ${t})` : `(above ${e})`}`, { name: "IntegerOutOfRangeError" });
109
109
  }
110
110
  }
111
- class re extends $ {
111
+ class ne extends x {
112
112
  constructor({ givenSize: t, maxSize: e }) {
113
113
  super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
114
114
  }
115
115
  }
116
- function V(s, { size: t }) {
117
- if (R(s) > t)
118
- throw new re({
119
- givenSize: R(s),
116
+ function J(s, { size: t }) {
117
+ if (K(s) > t)
118
+ throw new ne({
119
+ givenSize: K(s),
120
120
  maxSize: t
121
121
  });
122
122
  }
123
- const oe = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
124
- function ne(s, t = {}) {
125
- return typeof s == "number" || typeof s == "bigint" ? ce(s, t) : typeof s == "string" ? de(s, t) : typeof s == "boolean" ? ae(s, t) : q(s, t);
123
+ const ae = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
124
+ function ce(s, t = {}) {
125
+ return typeof s == "number" || typeof s == "bigint" ? le(s, t) : typeof s == "string" ? he(s, t) : typeof s == "boolean" ? de(s, t) : X(s, t);
126
126
  }
127
- function ae(s, t = {}) {
127
+ function de(s, t = {}) {
128
128
  const e = `0x${Number(s)}`;
129
- return typeof t.size == "number" ? (V(e, { size: t.size }), E(e, { size: t.size })) : e;
129
+ return typeof t.size == "number" ? (J(e, { size: t.size }), U(e, { size: t.size })) : e;
130
130
  }
131
- function q(s, t = {}) {
131
+ function X(s, t = {}) {
132
132
  let e = "";
133
133
  for (let r = 0; r < s.length; r++)
134
- e += oe[s[r]];
134
+ e += ae[s[r]];
135
135
  const i = `0x${e}`;
136
- return typeof t.size == "number" ? (V(i, { size: t.size }), E(i, { dir: "right", size: t.size })) : i;
136
+ return typeof t.size == "number" ? (J(i, { size: t.size }), U(i, { dir: "right", size: t.size })) : i;
137
137
  }
138
- function ce(s, t = {}) {
138
+ function le(s, t = {}) {
139
139
  const { signed: e, size: i } = t, r = BigInt(s);
140
140
  let o;
141
141
  i ? e ? o = (1n << BigInt(i) * 8n - 1n) - 1n : o = 2n ** (BigInt(i) * 8n) - 1n : typeof s == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
142
142
  const c = typeof o == "bigint" && e ? -o - 1n : 0;
143
143
  if (o && r > o || r < c) {
144
144
  const n = typeof s == "bigint" ? "n" : "";
145
- throw new ie({
145
+ throw new oe({
146
146
  max: o ? `${o}${n}` : void 0,
147
147
  min: `${c}${n}`,
148
148
  signed: e,
@@ -151,14 +151,14 @@ 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 ? E(a, { size: i }) : a;
154
+ return i ? U(a, { size: i }) : a;
155
155
  }
156
- const le = /* @__PURE__ */ new TextEncoder();
157
- function de(s, t = {}) {
158
- const e = le.encode(s);
159
- return q(e, t);
156
+ const pe = /* @__PURE__ */ new TextEncoder();
157
+ function he(s, t = {}) {
158
+ const e = pe.encode(s);
159
+ return X(e, t);
160
160
  }
161
- class P {
161
+ class k {
162
162
  constructor(t) {
163
163
  S(this, "opts");
164
164
  S(this, "open", () => {
@@ -173,25 +173,27 @@ class P {
173
173
  }
174
174
  });
175
175
  S(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, D, M, T, A, G, j, B, C, W, H, L, O;
176
+ var i, r, o, c, a, n, p, h, u, m, f, g, y, w, d, b, $, I, v, z, A, M, T, D, C, G, j, B, W, H, L, O, R, N;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
180
- const d = this.opts.recipient, X = (i = this.opts.walletProvider) == null ? void 0 : i.address, J = (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
- (n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
180
+ const l = this.opts.recipient, Q = (i = this.opts.walletProvider) == null ? void 0 : i.address, Y = (r = this.opts.walletProvider) == null ? void 0 : r.availableChainIds, Z = (o = this.opts.walletProvider) == null ? void 0 : o.currentChainId, _ = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
181
+ (h = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || h.postMessage(
182
182
  {
183
183
  type: "initialize",
184
184
  sessionId: this.opts.sessionId,
185
- recipient: d,
186
- connectedWalletAddress: X,
187
- availableChainIds: J,
188
- currentChainId: Q,
189
- preferGaslessPayment: Y,
185
+ recipient: l,
186
+ connectedWalletAddress: Q,
187
+ availableChainIds: Y,
188
+ currentChainId: Z,
189
+ preferGaslessPayment: _,
190
190
  excludeChainIds: this.opts.excludeChainIds,
191
191
  excludeCurrencyTiers: this.opts.excludeCurrencyTiers,
192
192
  excludeFundingSources: this.opts.excludeFundingSources,
193
193
  mode: this.opts.mode,
194
194
  amount: this.opts.amount,
195
+ chainId: (n = this.opts.chain) == null ? void 0 : n.id,
196
+ currencyId: (p = this.opts.currency) == null ? void 0 : p.id,
195
197
  evmTx: this.opts.evm,
196
198
  tokenApproval: this.opts.approval,
197
199
  sessionMetadata: this.opts.sessionMetadata,
@@ -200,20 +202,20 @@ class P {
200
202
  didProvideLocalStorage: !!this.opts.localStorageProvider,
201
203
  debug: this.opts.debug,
202
204
  popupsBlocked: this.opts.popupsBlocked,
203
- gasRefuelUSD: this.opts.gasRefuelUSD
205
+ gasRefuelAmountPerChain: this.opts.gasRefuelAmountPerChain
204
206
  },
205
207
  new URL(this.baseUrl).origin
206
- ), this.iframe.style.opacity = "1", (h = (p = this.opts).onOpen) == null || h.call(p);
208
+ ), this.iframe.style.opacity = "1", (m = (u = this.opts).onOpen) == null || m.call(u);
207
209
  break;
208
210
  }
209
211
  case "localStorage.getKeys": {
210
212
  if (!this.opts.localStorageProvider)
211
213
  throw new Error("localStorageProvider is not set");
212
- const d = await this.opts.localStorageProvider.getKeys();
213
- (m = (u = this.iframe) == null ? void 0 : u.contentWindow) == null || m.postMessage(
214
+ const l = await this.opts.localStorageProvider.getKeys();
215
+ (g = (f = this.iframe) == null ? void 0 : f.contentWindow) == null || g.postMessage(
214
216
  {
215
217
  type: "localStorage.didGetKeys",
216
- keys: d
218
+ keys: l
217
219
  },
218
220
  this.baseUrl
219
221
  );
@@ -235,25 +237,25 @@ class P {
235
237
  case "localStorage.getItem": {
236
238
  if (!this.opts.localStorageProvider)
237
239
  throw new Error("localStorageProvider is not set");
238
- const d = await this.opts.localStorageProvider.getItem(e.key);
239
- (g = (f = this.iframe) == null ? void 0 : f.contentWindow) == null || g.postMessage(
240
+ const l = await this.opts.localStorageProvider.getItem(e.key);
241
+ (w = (y = this.iframe) == null ? void 0 : y.contentWindow) == null || w.postMessage(
240
242
  {
241
243
  type: "localStorage.didGetItem",
242
244
  key: e.key,
243
- value: d
245
+ value: l
244
246
  },
245
247
  this.baseUrl
246
248
  );
247
249
  break;
248
250
  }
249
251
  case "success":
250
- (b = (l = this.opts) == null ? void 0 : l.onSuccess) == null || b.call(l, e.hash);
252
+ (b = (d = this.opts) == null ? void 0 : d.onSuccess) == null || b.call(d, e.hash);
251
253
  break;
252
254
  case "close":
253
- this.removeIframe(), this.destroy(), (w = (y = this.opts) == null ? void 0 : y.onClose) == null || w.call(y);
255
+ this.removeIframe(), this.destroy(), (I = ($ = this.opts) == null ? void 0 : $.onClose) == null || I.call($);
254
256
  break;
255
257
  case "setMode":
256
- (k = (v = this.opts) == null ? void 0 : v.onSetMode) == null || k.call(v, e.mode);
258
+ (z = (v = this.opts) == null ? void 0 : v.onSetMode) == null || z.call(v, e.mode);
257
259
  break;
258
260
  case "switchChain":
259
261
  if (!this.opts.walletProvider)
@@ -261,7 +263,7 @@ class P {
261
263
  try {
262
264
  await this.opts.walletProvider.switchChainAsync({
263
265
  chainId: e.chainId
264
- }), (z = (U = this.iframe) == null ? void 0 : U.contentWindow) == null || z.postMessage(
266
+ }), (M = (A = this.iframe) == null ? void 0 : A.contentWindow) == null || M.postMessage(
265
267
  {
266
268
  type: "didSwitchChain",
267
269
  success: !0,
@@ -269,12 +271,12 @@ class P {
269
271
  },
270
272
  this.baseUrl
271
273
  );
272
- } catch (d) {
273
- (M = (D = this.iframe) == null ? void 0 : D.contentWindow) == null || M.postMessage(
274
+ } catch (l) {
275
+ (D = (T = this.iframe) == null ? void 0 : T.contentWindow) == null || D.postMessage(
274
276
  {
275
277
  type: "didSwitchChain",
276
278
  success: !1,
277
- error: d
279
+ error: l
278
280
  },
279
281
  this.baseUrl
280
282
  );
@@ -285,23 +287,23 @@ class P {
285
287
  if (!this.opts.walletProvider)
286
288
  throw new Error("walletProvider is not set");
287
289
  try {
288
- const d = await this.opts.walletProvider.sendTransactionAsync(
290
+ const l = await this.opts.walletProvider.sendTransactionAsync(
289
291
  e.tx
290
292
  );
291
- (A = (T = this.iframe) == null ? void 0 : T.contentWindow) == null || A.postMessage(
293
+ (G = (C = this.iframe) == null ? void 0 : C.contentWindow) == null || G.postMessage(
292
294
  {
293
295
  type: "didSendTransaction",
294
296
  success: !0,
295
- txHash: d
297
+ txHash: l
296
298
  },
297
299
  this.baseUrl
298
300
  );
299
- } catch (d) {
300
- (j = (G = this.iframe) == null ? void 0 : G.contentWindow) == null || j.postMessage(
301
+ } catch (l) {
302
+ (B = (j = this.iframe) == null ? void 0 : j.contentWindow) == null || B.postMessage(
301
303
  {
302
304
  type: "didSendTransaction",
303
305
  success: !1,
304
- error: d
306
+ error: l
305
307
  },
306
308
  this.baseUrl
307
309
  );
@@ -313,7 +315,7 @@ class P {
313
315
  if (!this.opts.walletProvider)
314
316
  throw new Error("walletProvider is not set");
315
317
  if (!this.opts.walletProvider.signTypedDataAsync) {
316
- (C = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || C.postMessage(
318
+ (H = (W = this.iframe) == null ? void 0 : W.contentWindow) == null || H.postMessage(
317
319
  {
318
320
  type: "didSignTypedData",
319
321
  success: !1,
@@ -324,23 +326,23 @@ class P {
324
326
  return;
325
327
  }
326
328
  try {
327
- const d = await this.opts.walletProvider.signTypedDataAsync(
329
+ const l = await this.opts.walletProvider.signTypedDataAsync(
328
330
  e.data
329
331
  );
330
- (H = (W = this.iframe) == null ? void 0 : W.contentWindow) == null || H.postMessage(
332
+ (O = (L = this.iframe) == null ? void 0 : L.contentWindow) == null || O.postMessage(
331
333
  {
332
334
  type: "didSignTypedData",
333
335
  success: !0,
334
- signature: d
336
+ signature: l
335
337
  },
336
338
  this.baseUrl
337
339
  );
338
- } catch (d) {
339
- (O = (L = this.iframe) == null ? void 0 : L.contentWindow) == null || O.postMessage(
340
+ } catch (l) {
341
+ (N = (R = this.iframe) == null ? void 0 : R.contentWindow) == null || N.postMessage(
340
342
  {
341
343
  type: "didSignTypedData",
342
344
  success: !1,
343
- error: d
345
+ error: l
344
346
  },
345
347
  this.baseUrl
346
348
  );
@@ -353,9 +355,9 @@ class P {
353
355
  }
354
356
  get externalUrl() {
355
357
  var t, e, i;
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(
358
+ 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.chain ? `&chainId=${this.opts.chain.id}` : ""}${this.opts.currency ? `&currencyId=${this.opts.currency.id}` : ""}${this.opts.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${ce(
357
359
  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.gasRefuelUSD ? `&gasRefuelUSD=${this.opts.gasRefuelUSD}` : ""}`;
360
+ )}` : ""}${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
361
  }
360
362
  initialize() {
361
363
  window.addEventListener("message", this.iframeEventHandler);
@@ -390,47 +392,51 @@ class P {
390
392
  t && (t.remove(), document.body.classList.remove("glide-deposit-open"));
391
393
  }
392
394
  }
393
- const ue = ({
395
+ const fe = ({
394
396
  app: s,
395
397
  recipient: t,
396
- gasRefuelUSD: e,
397
- preferGaslessPayment: i,
398
- excludeChainIds: r,
399
- excludeCurrencyTiers: o,
400
- excludeFundingSources: c,
401
- mode: a,
402
- sessionMetadata: n,
403
- theme: p,
404
- walletProvider: h,
405
- localStorageProvider: u,
406
- onOpen: m,
407
- onSuccess: f,
408
- onClose: g,
409
- autoCloseOnSuccess: l,
398
+ chain: e,
399
+ currency: i,
400
+ gasRefuelAmountPerChain: r,
401
+ preferGaslessPayment: o,
402
+ excludeChainIds: c,
403
+ excludeCurrencyTiers: a,
404
+ excludeFundingSources: n,
405
+ mode: p,
406
+ sessionMetadata: h,
407
+ theme: u,
408
+ walletProvider: m,
409
+ localStorageProvider: f,
410
+ onOpen: g,
411
+ onSuccess: y,
412
+ onClose: w,
413
+ autoCloseOnSuccess: d,
410
414
  popupsBlocked: b,
411
- baseUrl: y,
412
- debug: w
415
+ baseUrl: $,
416
+ debug: I
413
417
  }) => {
414
- const v = I(() => new P({
418
+ const v = E(() => new k({
415
419
  app: s,
416
420
  recipient: t,
417
- gasRefuelUSD: e,
418
- preferGaslessPayment: i,
419
- excludeChainIds: r,
420
- excludeCurrencyTiers: o,
421
- excludeFundingSources: c,
422
- mode: a,
423
- sessionMetadata: n,
424
- theme: p,
425
- walletProvider: h,
426
- localStorageProvider: u,
427
- onOpen: m,
428
- onSuccess: f,
429
- onClose: g,
430
- autoCloseOnSuccess: l,
421
+ chain: e,
422
+ currency: i,
423
+ gasRefuelAmountPerChain: r,
424
+ preferGaslessPayment: o,
425
+ excludeChainIds: c,
426
+ excludeCurrencyTiers: a,
427
+ excludeFundingSources: n,
428
+ mode: p,
429
+ sessionMetadata: h,
430
+ theme: u,
431
+ walletProvider: m,
432
+ localStorageProvider: f,
433
+ onOpen: g,
434
+ onSuccess: y,
435
+ onClose: w,
436
+ autoCloseOnSuccess: d,
431
437
  popupsBlocked: b,
432
- baseUrl: y,
433
- debug: w
438
+ baseUrl: $,
439
+ debug: I
434
440
  }), [
435
441
  s,
436
442
  t,
@@ -447,17 +453,19 @@ const ue = ({
447
453
  m,
448
454
  f,
449
455
  g,
450
- l,
451
- b,
452
456
  y,
453
- w
457
+ w,
458
+ d,
459
+ b,
460
+ $,
461
+ I
454
462
  ]);
455
463
  return {
456
464
  openGlideDeposit: v.open,
457
465
  externalUrl: v.externalUrl,
458
466
  opts: v.opts
459
467
  };
460
- }, me = ({
468
+ }, ge = ({
461
469
  app: s,
462
470
  preferGaslessPayment: t,
463
471
  excludeChainIds: e,
@@ -473,11 +481,11 @@ const ue = ({
473
481
  onSuccess: m,
474
482
  onClose: f,
475
483
  autoCloseOnSuccess: g,
476
- popupsBlocked: l,
477
- baseUrl: b,
478
- debug: y
484
+ popupsBlocked: y,
485
+ baseUrl: w,
486
+ debug: d
479
487
  }) => {
480
- const w = I(() => new P({
488
+ const b = E(() => new k({
481
489
  app: s,
482
490
  preferGaslessPayment: t,
483
491
  excludeChainIds: e,
@@ -494,9 +502,9 @@ const ue = ({
494
502
  onSuccess: m,
495
503
  onClose: f,
496
504
  autoCloseOnSuccess: g,
497
- popupsBlocked: l,
498
- baseUrl: b,
499
- debug: y
505
+ popupsBlocked: y,
506
+ baseUrl: w,
507
+ debug: d
500
508
  }), [
501
509
  s,
502
510
  t,
@@ -513,16 +521,16 @@ const ue = ({
513
521
  m,
514
522
  f,
515
523
  g,
516
- l,
517
- b,
518
- y
524
+ y,
525
+ w,
526
+ d
519
527
  ]);
520
528
  return {
521
- openGlidePay: w.open,
522
- externalUrl: w.externalUrl,
523
- opts: w.opts
529
+ openGlidePay: b.open,
530
+ externalUrl: b.externalUrl,
531
+ opts: b.opts
524
532
  };
525
- }, fe = ({
533
+ }, ye = ({
526
534
  app: s,
527
535
  evm: t,
528
536
  approval: e,
@@ -538,11 +546,11 @@ const ue = ({
538
546
  onSuccess: m,
539
547
  onClose: f,
540
548
  autoCloseOnSuccess: g,
541
- popupsBlocked: l,
542
- baseUrl: b,
543
- debug: y
549
+ popupsBlocked: y,
550
+ baseUrl: w,
551
+ debug: d
544
552
  }) => {
545
- const w = I(() => new P({
553
+ const b = E(() => new k({
546
554
  app: s,
547
555
  evm: t,
548
556
  approval: e,
@@ -559,9 +567,9 @@ const ue = ({
559
567
  onSuccess: m,
560
568
  onClose: f,
561
569
  autoCloseOnSuccess: g,
562
- popupsBlocked: l,
563
- baseUrl: b,
564
- debug: y
570
+ popupsBlocked: y,
571
+ baseUrl: w,
572
+ debug: d
565
573
  }), [
566
574
  s,
567
575
  t,
@@ -578,49 +586,53 @@ const ue = ({
578
586
  m,
579
587
  f,
580
588
  g,
581
- l,
582
- b,
583
- y
589
+ y,
590
+ w,
591
+ d
584
592
  ]);
585
593
  return {
586
- openGlideCall: w.open,
587
- externalUrl: w.externalUrl,
588
- opts: w.opts
594
+ openGlideCall: b.open,
595
+ externalUrl: b.externalUrl,
596
+ opts: b.opts
589
597
  };
590
- }, ge = ({
598
+ }, we = ({
591
599
  app: s,
592
600
  recipient: t,
593
- preferGaslessPayment: e,
594
- excludeChainIds: i,
595
- excludeCurrencyTiers: r,
596
- excludeFundingSources: o,
597
- sessionMetadata: c,
598
- theme: a,
599
- walletProvider: n,
600
- localStorageProvider: p,
601
- onOpen: h,
602
- onSuccess: u,
603
- onClose: m,
604
- autoCloseOnSuccess: f,
605
- baseUrl: g
601
+ chain: e,
602
+ currency: i,
603
+ preferGaslessPayment: r,
604
+ excludeChainIds: o,
605
+ excludeCurrencyTiers: c,
606
+ excludeFundingSources: a,
607
+ sessionMetadata: n,
608
+ theme: p,
609
+ walletProvider: h,
610
+ localStorageProvider: u,
611
+ onOpen: m,
612
+ onSuccess: f,
613
+ onClose: g,
614
+ autoCloseOnSuccess: y,
615
+ baseUrl: w
606
616
  }) => {
607
- const l = I(() => new P({
617
+ const d = E(() => new k({
608
618
  app: s,
609
619
  recipient: t,
610
- preferGaslessPayment: e,
611
- excludeChainIds: i,
612
- excludeCurrencyTiers: r,
613
- excludeFundingSources: o,
614
- sessionMetadata: c,
620
+ chain: e,
621
+ currency: i,
622
+ preferGaslessPayment: r,
623
+ excludeChainIds: o,
624
+ excludeCurrencyTiers: c,
625
+ excludeFundingSources: a,
626
+ sessionMetadata: n,
615
627
  mode: "buy",
616
- theme: a,
617
- walletProvider: n,
618
- localStorageProvider: p,
619
- onOpen: h,
620
- onSuccess: u,
621
- onClose: m,
622
- autoCloseOnSuccess: f,
623
- baseUrl: g
628
+ theme: p,
629
+ walletProvider: h,
630
+ localStorageProvider: u,
631
+ onOpen: m,
632
+ onSuccess: f,
633
+ onClose: g,
634
+ autoCloseOnSuccess: y,
635
+ baseUrl: w
624
636
  }), [
625
637
  s,
626
638
  t,
@@ -636,14 +648,16 @@ const ue = ({
636
648
  u,
637
649
  m,
638
650
  f,
639
- g
651
+ g,
652
+ y,
653
+ w
640
654
  ]);
641
655
  return {
642
- openGlideBuy: l.open,
643
- externalUrl: l.externalUrl,
644
- opts: l.opts
656
+ openGlideBuy: d.open,
657
+ externalUrl: d.externalUrl,
658
+ opts: d.opts
645
659
  };
646
- }, ye = Object.freeze({
660
+ }, be = Object.freeze({
647
661
  getItem: (s) => new Promise((t, e) => {
648
662
  try {
649
663
  const i = localStorage.getItem(s);
@@ -676,10 +690,10 @@ const ue = ({
676
690
  })
677
691
  });
678
692
  export {
679
- P as GlideDeposit,
680
- ye as browserLocalStorageProvider,
681
- ge as useGlideBuy,
682
- fe as useGlideCall,
683
- ue as useGlideDeposit,
684
- me as useGlidePay
693
+ k as GlideDeposit,
694
+ be as browserLocalStorageProvider,
695
+ we as useGlideBuy,
696
+ ye as useGlideCall,
697
+ fe as useGlideDeposit,
698
+ ge as useGlidePay
685
699
  };
@@ -1,9 +1,11 @@
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, Chain, Currency } from '@paywithglide/glide-js';
4
4
  interface UseGlideBuyProps {
5
5
  app: string;
6
6
  recipient?: string;
7
+ chain?: Chain;
8
+ currency?: Currency;
7
9
  preferGaslessPayment?: boolean;
8
10
  excludeChainIds?: CAIP2[];
9
11
  excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
@@ -18,7 +20,7 @@ interface UseGlideBuyProps {
18
20
  autoCloseOnSuccess?: boolean;
19
21
  baseUrl?: string;
20
22
  }
21
- export declare const useGlideBuy: ({ app, recipient, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideBuyProps) => {
23
+ export declare const useGlideBuy: ({ app, recipient, chain, currency, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideBuyProps) => {
22
24
  openGlideBuy: () => void;
23
25
  externalUrl: string;
24
26
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -1,10 +1,12 @@
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, Chain, Currency } from '@paywithglide/glide-js';
4
4
  interface UseGlideDepositProps {
5
5
  app: string;
6
6
  recipient?: string;
7
- gasRefuelUSD?: string;
7
+ chain?: Chain;
8
+ currency?: Currency;
9
+ gasRefuelAmountPerChain?: Record<CAIP2, string>;
8
10
  preferGaslessPayment?: boolean;
9
11
  excludeChainIds?: CAIP2[];
10
12
  excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
@@ -22,7 +24,7 @@ interface UseGlideDepositProps {
22
24
  baseUrl?: string;
23
25
  debug?: boolean;
24
26
  }
25
- export declare const useGlideDeposit: ({ app, recipient, gasRefuelUSD, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
27
+ export declare const useGlideDeposit: ({ app, recipient, chain, currency, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
26
28
  openGlideDeposit: () => void;
27
29
  externalUrl: string;
28
30
  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.28",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"