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