@paywithglide/glide-react 0.0.11 → 0.0.13
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 +9 -3
- package/dist/glide.js +212 -135
- package/dist/index.d.ts +2 -0
- package/dist/theme.d.ts +30 -0
- package/dist/useGlideBuy.d.ts +19 -0
- package/dist/useGlideCall.d.ts +10 -1
- package/dist/useGlideDeposit.d.ts +7 -2
- package/dist/useGlidePay.d.ts +7 -3
- package/package.json +10 -7
package/dist/GlideDeposit.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GlideWidgetTheme } from './theme.ts';
|
|
1
2
|
export type Hex = `0x${string}`;
|
|
2
3
|
export type EVMTransaction = {
|
|
3
4
|
chainId: number;
|
|
@@ -77,7 +78,7 @@ export type GlideDepositWalletProvider = {
|
|
|
77
78
|
export type GlideDepositOptions = {
|
|
78
79
|
app: string;
|
|
79
80
|
recipient?: Hex;
|
|
80
|
-
mode?: "deposit" | "withdraw" | "pay" | "call";
|
|
81
|
+
mode?: "deposit" | "withdraw" | "pay" | "call" | "buy";
|
|
81
82
|
amount?: string;
|
|
82
83
|
evm?: {
|
|
83
84
|
chainId: number;
|
|
@@ -85,9 +86,16 @@ export type GlideDepositOptions = {
|
|
|
85
86
|
data?: Hex;
|
|
86
87
|
value?: bigint;
|
|
87
88
|
};
|
|
89
|
+
approval?: {
|
|
90
|
+
token: Hex;
|
|
91
|
+
amount: bigint;
|
|
92
|
+
};
|
|
93
|
+
sessionMetadata?: string;
|
|
88
94
|
preferGaslessPayment?: boolean;
|
|
89
95
|
walletProvider?: GlideDepositWalletProvider;
|
|
90
96
|
onSuccess?: (hash: Hex) => void;
|
|
97
|
+
autoCloseOnSuccess?: boolean;
|
|
98
|
+
theme?: GlideWidgetTheme;
|
|
91
99
|
baseUrl?: string;
|
|
92
100
|
};
|
|
93
101
|
export declare class GlideDeposit {
|
|
@@ -103,6 +111,4 @@ export declare class GlideDeposit {
|
|
|
103
111
|
private openUrl;
|
|
104
112
|
private createIframe;
|
|
105
113
|
private removeIframe;
|
|
106
|
-
private showLoader;
|
|
107
|
-
private hideLoader;
|
|
108
114
|
}
|
package/dist/glide.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useMemo as
|
|
5
|
-
function
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var C = (s, t, e) => t in s ? k(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var m = (s, t, e) => C(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { useMemo as f } from "react";
|
|
5
|
+
function G(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
|
|
9
|
-
return
|
|
8
|
+
function U(s) {
|
|
9
|
+
return G(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
let
|
|
11
|
+
const D = "2.21.51";
|
|
12
|
+
let h = {
|
|
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@${D}`
|
|
15
15
|
};
|
|
16
|
-
class
|
|
16
|
+
class u extends Error {
|
|
17
17
|
constructor(t, e = {}) {
|
|
18
18
|
var a;
|
|
19
19
|
const i = (() => {
|
|
20
|
-
var
|
|
21
|
-
return e.cause instanceof
|
|
22
|
-
})(), n = e.cause instanceof
|
|
20
|
+
var o;
|
|
21
|
+
return e.cause instanceof u ? e.cause.details : (o = e.cause) != null && o.message ? e.cause.message : e.details;
|
|
22
|
+
})(), n = e.cause instanceof u && e.cause.docsPath || e.docsPath, r = (a = h.getDocsUrl) == null ? void 0 : a.call(h, { ...e, docsPath: n }), d = [
|
|
23
23
|
t || "An error occurred.",
|
|
24
24
|
"",
|
|
25
25
|
...e.metaMessages ? [...e.metaMessages, ""] : [],
|
|
26
26
|
...r ? [`Docs: ${r}`] : [],
|
|
27
27
|
...i ? [`Details: ${i}`] : [],
|
|
28
|
-
...
|
|
28
|
+
...h.version ? [`Version: ${h.version}`] : []
|
|
29
29
|
].join(`
|
|
30
30
|
`);
|
|
31
|
-
super(
|
|
31
|
+
super(d, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
|
|
32
32
|
enumerable: !0,
|
|
33
33
|
configurable: !0,
|
|
34
34
|
writable: !0,
|
|
@@ -58,40 +58,40 @@ class l extends Error {
|
|
|
58
58
|
configurable: !0,
|
|
59
59
|
writable: !0,
|
|
60
60
|
value: "BaseError"
|
|
61
|
-
}), this.details = i, this.docsPath = n, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version =
|
|
61
|
+
}), this.details = i, this.docsPath = n, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = D;
|
|
62
62
|
}
|
|
63
63
|
walk(t) {
|
|
64
|
-
return
|
|
64
|
+
return T(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 T(s, t) {
|
|
68
|
+
return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? T(s.cause, t) : t ? null : s;
|
|
69
69
|
}
|
|
70
|
-
class
|
|
70
|
+
class S extends u {
|
|
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
|
|
76
|
-
return typeof s == "string" ?
|
|
75
|
+
function y(s, { dir: t, size: e = 32 } = {}) {
|
|
76
|
+
return typeof s == "string" ? W(s, { dir: t, size: e }) : H(s, { dir: t, size: e });
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function W(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
|
|
83
|
+
throw new S({
|
|
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
|
|
90
|
+
function H(s, { dir: t, size: e = 32 } = {}) {
|
|
91
91
|
if (e === null)
|
|
92
92
|
return s;
|
|
93
93
|
if (s.length > e)
|
|
94
|
-
throw new
|
|
94
|
+
throw new S({
|
|
95
95
|
size: s.length,
|
|
96
96
|
targetSize: e,
|
|
97
97
|
type: "bytes"
|
|
@@ -103,88 +103,87 @@ function L(s, { dir: t, size: e = 32 } = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
return i;
|
|
105
105
|
}
|
|
106
|
-
class
|
|
106
|
+
class B extends u {
|
|
107
107
|
constructor({ max: t, min: e, signed: i, size: n, value: r }) {
|
|
108
108
|
super(`Number "${r}" is not in safe ${n ? `${n * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${e} to ${t})` : `(above ${e})`}`, { name: "IntegerOutOfRangeError" });
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
class j extends
|
|
111
|
+
class j extends u {
|
|
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
|
|
117
|
-
if (
|
|
116
|
+
function A(s, { size: t }) {
|
|
117
|
+
if (U(s) > t)
|
|
118
118
|
throw new j({
|
|
119
|
-
givenSize:
|
|
119
|
+
givenSize: U(s),
|
|
120
120
|
maxSize: t
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
const O = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
|
|
124
|
-
function
|
|
125
|
-
return typeof s == "number" || typeof s == "bigint" ? N(s, t) : typeof s == "string" ?
|
|
124
|
+
function z(s, t = {}) {
|
|
125
|
+
return typeof s == "number" || typeof s == "bigint" ? N(s, t) : typeof s == "string" ? V(s, t) : typeof s == "boolean" ? L(s, t) : M(s, t);
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function L(s, t = {}) {
|
|
128
128
|
const e = `0x${Number(s)}`;
|
|
129
|
-
return typeof t.size == "number" ? (
|
|
129
|
+
return typeof t.size == "number" ? (A(e, { size: t.size }), y(e, { size: t.size })) : e;
|
|
130
130
|
}
|
|
131
131
|
function M(s, t = {}) {
|
|
132
132
|
let e = "";
|
|
133
133
|
for (let n = 0; n < s.length; n++)
|
|
134
134
|
e += O[s[n]];
|
|
135
135
|
const i = `0x${e}`;
|
|
136
|
-
return typeof t.size == "number" ? (
|
|
136
|
+
return typeof t.size == "number" ? (A(i, { size: t.size }), y(i, { dir: "right", size: t.size })) : i;
|
|
137
137
|
}
|
|
138
138
|
function N(s, t = {}) {
|
|
139
139
|
const { signed: e, size: i } = t, n = BigInt(s);
|
|
140
140
|
let r;
|
|
141
141
|
i ? e ? r = (1n << BigInt(i) * 8n - 1n) - 1n : r = 2n ** (BigInt(i) * 8n) - 1n : typeof s == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
|
|
142
|
-
const
|
|
143
|
-
if (r && n > r || n <
|
|
144
|
-
const
|
|
145
|
-
throw new
|
|
146
|
-
max: r ? `${r}${
|
|
147
|
-
min: `${
|
|
142
|
+
const d = typeof r == "bigint" && e ? -r - 1n : 0;
|
|
143
|
+
if (r && n > r || n < d) {
|
|
144
|
+
const o = typeof s == "bigint" ? "n" : "";
|
|
145
|
+
throw new B({
|
|
146
|
+
max: r ? `${r}${o}` : void 0,
|
|
147
|
+
min: `${d}${o}`,
|
|
148
148
|
signed: e,
|
|
149
149
|
size: i,
|
|
150
|
-
value: `${s}${
|
|
150
|
+
value: `${s}${o}`
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
const a = `0x${(e && n < 0 ? (1n << BigInt(i * 8)) + BigInt(n) : n).toString(16)}`;
|
|
154
|
-
return i ?
|
|
154
|
+
return i ? y(a, { size: i }) : a;
|
|
155
155
|
}
|
|
156
|
-
const
|
|
157
|
-
function
|
|
158
|
-
const e =
|
|
156
|
+
const R = /* @__PURE__ */ new TextEncoder();
|
|
157
|
+
function V(s, t = {}) {
|
|
158
|
+
const e = R.encode(s);
|
|
159
159
|
return M(e, t);
|
|
160
160
|
}
|
|
161
161
|
class g {
|
|
162
162
|
constructor(t) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
163
|
+
m(this, "opts");
|
|
164
|
+
m(this, "open", () => {
|
|
165
|
+
var d, a, o, c;
|
|
166
|
+
if (document.body.classList.contains("glide-deposit-open")) return;
|
|
167
|
+
if (document.body.classList.add("glide-deposit-open"), (this.opts.mode === "deposit" || this.opts.mode === "buy") && !this.opts.recipient)
|
|
168
|
+
throw new Error("recipient is required for deposit/buy mode");
|
|
169
|
+
if (this.opts.preferGaslessPayment && this.opts.walletProvider && !this.opts.walletProvider.signTypedDataAsync)
|
|
170
|
+
throw new Error(
|
|
171
|
+
"walletProvider.signTypedDataAsync is required when preferGaslessPayment=true"
|
|
172
|
+
);
|
|
173
|
+
const t = this.opts.recipient, e = (d = this.opts.walletProvider) == null ? void 0 : d.address, i = (a = this.opts.walletProvider) == null ? void 0 : a.availableChainIds, n = (o = this.opts.walletProvider) == null ? void 0 : o.currentChainId, r = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
|
|
174
|
+
this.openUrl(
|
|
175
|
+
`${this.baseUrl}${this.opts.app}?embed=true${t ? `&recipient=${t}` : ""}${e ? `&connectedWalletAddress=${e}` : ""}${n ? `¤tChainId=${n}` : ""}${i ? `&availableChainIds=${i.join(",")}` : ""}${r ? "&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=${z(this.opts.evm.value || 0n)}` : ""}${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" : ""}`
|
|
176
|
+
), this.initialize();
|
|
178
177
|
});
|
|
179
|
-
|
|
180
|
-
var i, n, r,
|
|
178
|
+
m(this, "iframeEventHandler", async (t) => {
|
|
179
|
+
var i, n, r, d, a, o, c, l, $, w, v, b, x, P, I, E;
|
|
181
180
|
const e = t.data;
|
|
182
181
|
switch (e.type) {
|
|
183
182
|
case "success":
|
|
184
183
|
(n = (i = this.opts) == null ? void 0 : i.onSuccess) == null || n.call(i, e.hash);
|
|
185
184
|
break;
|
|
186
185
|
case "close":
|
|
187
|
-
this.removeIframe(), this.
|
|
186
|
+
this.removeIframe(), this.destroy();
|
|
188
187
|
break;
|
|
189
188
|
case "switchChain":
|
|
190
189
|
if (!this.opts.walletProvider)
|
|
@@ -192,7 +191,7 @@ class g {
|
|
|
192
191
|
try {
|
|
193
192
|
await this.opts.walletProvider.switchChainAsync({
|
|
194
193
|
chainId: e.chainId
|
|
195
|
-
}), (
|
|
194
|
+
}), (d = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || d.postMessage(
|
|
196
195
|
{
|
|
197
196
|
type: "didSwitchChain",
|
|
198
197
|
success: !0,
|
|
@@ -200,12 +199,12 @@ class g {
|
|
|
200
199
|
},
|
|
201
200
|
this.baseUrl
|
|
202
201
|
);
|
|
203
|
-
} catch (
|
|
204
|
-
(
|
|
202
|
+
} catch (p) {
|
|
203
|
+
(o = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || o.postMessage(
|
|
205
204
|
{
|
|
206
205
|
type: "didSwitchChain",
|
|
207
206
|
success: !1,
|
|
208
|
-
error:
|
|
207
|
+
error: p
|
|
209
208
|
},
|
|
210
209
|
this.baseUrl
|
|
211
210
|
);
|
|
@@ -216,23 +215,23 @@ class g {
|
|
|
216
215
|
if (!this.opts.walletProvider)
|
|
217
216
|
throw new Error("walletProvider is not set");
|
|
218
217
|
try {
|
|
219
|
-
const
|
|
218
|
+
const p = await this.opts.walletProvider.sendTransactionAsync(
|
|
220
219
|
e.tx
|
|
221
220
|
);
|
|
222
|
-
(
|
|
221
|
+
(l = (c = this.iframe) == null ? void 0 : c.contentWindow) == null || l.postMessage(
|
|
223
222
|
{
|
|
224
223
|
type: "didSendTransaction",
|
|
225
224
|
success: !0,
|
|
226
|
-
txHash:
|
|
225
|
+
txHash: p
|
|
227
226
|
},
|
|
228
227
|
this.baseUrl
|
|
229
228
|
);
|
|
230
|
-
} catch (
|
|
231
|
-
(
|
|
229
|
+
} catch (p) {
|
|
230
|
+
(w = ($ = this.iframe) == null ? void 0 : $.contentWindow) == null || w.postMessage(
|
|
232
231
|
{
|
|
233
232
|
type: "didSendTransaction",
|
|
234
233
|
success: !1,
|
|
235
|
-
error:
|
|
234
|
+
error: p
|
|
236
235
|
},
|
|
237
236
|
this.baseUrl
|
|
238
237
|
);
|
|
@@ -244,7 +243,7 @@ class g {
|
|
|
244
243
|
if (!this.opts.walletProvider)
|
|
245
244
|
throw new Error("walletProvider is not set");
|
|
246
245
|
if (!this.opts.walletProvider.signTypedDataAsync) {
|
|
247
|
-
(
|
|
246
|
+
(b = (v = this.iframe) == null ? void 0 : v.contentWindow) == null || b.postMessage(
|
|
248
247
|
{
|
|
249
248
|
type: "didSignTypedData",
|
|
250
249
|
success: !1,
|
|
@@ -255,23 +254,23 @@ class g {
|
|
|
255
254
|
return;
|
|
256
255
|
}
|
|
257
256
|
try {
|
|
258
|
-
const
|
|
257
|
+
const p = await this.opts.walletProvider.signTypedDataAsync(
|
|
259
258
|
e.data
|
|
260
259
|
);
|
|
261
260
|
(P = (x = this.iframe) == null ? void 0 : x.contentWindow) == null || P.postMessage(
|
|
262
261
|
{
|
|
263
262
|
type: "didSignTypedData",
|
|
264
263
|
success: !0,
|
|
265
|
-
signature:
|
|
264
|
+
signature: p
|
|
266
265
|
},
|
|
267
266
|
this.baseUrl
|
|
268
267
|
);
|
|
269
|
-
} catch (
|
|
270
|
-
(
|
|
268
|
+
} catch (p) {
|
|
269
|
+
(E = (I = this.iframe) == null ? void 0 : I.contentWindow) == null || E.postMessage(
|
|
271
270
|
{
|
|
272
271
|
type: "didSignTypedData",
|
|
273
272
|
success: !1,
|
|
274
|
-
error:
|
|
273
|
+
error: p
|
|
275
274
|
},
|
|
276
275
|
this.baseUrl
|
|
277
276
|
);
|
|
@@ -283,7 +282,7 @@ class g {
|
|
|
283
282
|
this.opts = t;
|
|
284
283
|
}
|
|
285
284
|
get externalUrl() {
|
|
286
|
-
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=${
|
|
285
|
+
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=${z(this.opts.evm.value || 0n)}` : ""}${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" : ""}`;
|
|
287
286
|
}
|
|
288
287
|
initialize() {
|
|
289
288
|
window.addEventListener("message", this.iframeEventHandler);
|
|
@@ -298,55 +297,53 @@ class g {
|
|
|
298
297
|
return document.getElementById("glide-deposit-iframe");
|
|
299
298
|
}
|
|
300
299
|
openUrl(t) {
|
|
301
|
-
this.
|
|
300
|
+
this.createIframe(t);
|
|
302
301
|
}
|
|
303
302
|
createIframe(t) {
|
|
304
303
|
this.removeIframe();
|
|
305
304
|
const e = document.createElement("iframe");
|
|
306
305
|
e.id = "glide-deposit-iframe", e.setAttribute(
|
|
307
306
|
"style",
|
|
308
|
-
"z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"
|
|
309
|
-
), e.
|
|
310
|
-
var i;
|
|
311
|
-
(i = e == null ? void 0 : e.contentWindow) == null || i.focus()
|
|
312
|
-
|
|
307
|
+
"z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0;"
|
|
308
|
+
), e.onload = () => {
|
|
309
|
+
var i, n;
|
|
310
|
+
e.style.opacity = "1", (i = e == null ? void 0 : e.contentWindow) == null || i.focus(), (n = e == null ? void 0 : e.contentWindow) == null || n.postMessage(
|
|
311
|
+
{
|
|
312
|
+
type: "updateTheme",
|
|
313
|
+
theme: this.opts.theme
|
|
314
|
+
},
|
|
315
|
+
this.baseUrl
|
|
316
|
+
);
|
|
317
|
+
}, e.src = t, e.allow = "payment *; clipboard-write *", document.body.appendChild(e);
|
|
313
318
|
}
|
|
314
319
|
removeIframe() {
|
|
315
320
|
const t = document.getElementById("glide-deposit-iframe");
|
|
316
321
|
t && (t.remove(), document.body.classList.remove("glide-deposit-open"));
|
|
317
322
|
}
|
|
318
|
-
showLoader() {
|
|
319
|
-
const t = document.createElement("style");
|
|
320
|
-
t.innerHTML = "@keyframes pulse { 0% { opacity: 1; transform: scale(0.1); } 100% { opacity: 0; transform: scale(1); } }", document.head.appendChild(t);
|
|
321
|
-
const e = document.createElement("div");
|
|
322
|
-
e.setAttribute("class", "glide-deposit-loader");
|
|
323
|
-
const i = document.createElement("main");
|
|
324
|
-
i.setAttribute(
|
|
325
|
-
"style",
|
|
326
|
-
"display: flex; align-items: center; justify-content: center; flex-direction: column; width: 100%; height: 100%;"
|
|
327
|
-
), e.appendChild(i), document.body.appendChild(e);
|
|
328
|
-
}
|
|
329
|
-
hideLoader() {
|
|
330
|
-
document.querySelectorAll(".glide-deposit-loader").forEach((t) => t.remove());
|
|
331
|
-
}
|
|
332
323
|
}
|
|
333
324
|
const X = ({
|
|
334
325
|
app: s,
|
|
335
326
|
recipient: t,
|
|
336
327
|
preferGaslessPayment: e,
|
|
337
328
|
mode: i,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
329
|
+
sessionMetadata: n,
|
|
330
|
+
theme: r,
|
|
331
|
+
walletProvider: d,
|
|
332
|
+
onSuccess: a,
|
|
333
|
+
autoCloseOnSuccess: o,
|
|
334
|
+
baseUrl: c
|
|
341
335
|
}) => {
|
|
342
|
-
const
|
|
336
|
+
const l = f(() => new g({
|
|
343
337
|
app: s,
|
|
344
338
|
recipient: t,
|
|
345
339
|
preferGaslessPayment: e,
|
|
346
340
|
mode: i,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
341
|
+
sessionMetadata: n,
|
|
342
|
+
theme: r,
|
|
343
|
+
walletProvider: d,
|
|
344
|
+
onSuccess: a,
|
|
345
|
+
autoCloseOnSuccess: o,
|
|
346
|
+
baseUrl: c
|
|
350
347
|
}), [
|
|
351
348
|
s,
|
|
352
349
|
t,
|
|
@@ -354,57 +351,137 @@ const X = ({
|
|
|
354
351
|
i,
|
|
355
352
|
n,
|
|
356
353
|
r,
|
|
357
|
-
|
|
354
|
+
d,
|
|
355
|
+
a,
|
|
356
|
+
o,
|
|
357
|
+
c
|
|
358
358
|
]);
|
|
359
359
|
return {
|
|
360
|
-
openGlideDeposit:
|
|
361
|
-
externalUrl:
|
|
360
|
+
openGlideDeposit: l.open,
|
|
361
|
+
externalUrl: l.externalUrl,
|
|
362
|
+
opts: l.opts
|
|
362
363
|
};
|
|
363
364
|
}, J = ({
|
|
364
365
|
app: s,
|
|
365
366
|
preferGaslessPayment: t,
|
|
366
367
|
amount: e,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
sessionMetadata: i,
|
|
369
|
+
theme: n,
|
|
370
|
+
walletProvider: r,
|
|
371
|
+
onSuccess: d,
|
|
372
|
+
autoCloseOnSuccess: a,
|
|
373
|
+
baseUrl: o
|
|
370
374
|
}) => {
|
|
371
|
-
const
|
|
375
|
+
const c = f(() => new g({
|
|
372
376
|
app: s,
|
|
373
377
|
preferGaslessPayment: t,
|
|
374
378
|
mode: "pay",
|
|
375
379
|
amount: e,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
sessionMetadata: i,
|
|
381
|
+
theme: n,
|
|
382
|
+
walletProvider: r,
|
|
383
|
+
onSuccess: d,
|
|
384
|
+
autoCloseOnSuccess: a,
|
|
385
|
+
baseUrl: o
|
|
386
|
+
}), [
|
|
387
|
+
s,
|
|
388
|
+
t,
|
|
389
|
+
e,
|
|
390
|
+
i,
|
|
391
|
+
n,
|
|
392
|
+
r,
|
|
393
|
+
d,
|
|
394
|
+
a,
|
|
395
|
+
o
|
|
396
|
+
]);
|
|
380
397
|
return {
|
|
381
|
-
openGlidePay:
|
|
382
|
-
externalUrl:
|
|
398
|
+
openGlidePay: c.open,
|
|
399
|
+
externalUrl: c.externalUrl,
|
|
400
|
+
opts: c.opts
|
|
383
401
|
};
|
|
384
402
|
}, K = ({
|
|
385
403
|
app: s,
|
|
386
404
|
evm: t,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
405
|
+
approval: e,
|
|
406
|
+
preferGaslessPayment: i,
|
|
407
|
+
sessionMetadata: n,
|
|
408
|
+
theme: r,
|
|
409
|
+
walletProvider: d,
|
|
410
|
+
onSuccess: a,
|
|
411
|
+
autoCloseOnSuccess: o,
|
|
412
|
+
baseUrl: c
|
|
391
413
|
}) => {
|
|
392
|
-
const
|
|
414
|
+
const l = f(() => new g({
|
|
393
415
|
app: s,
|
|
394
416
|
evm: t,
|
|
395
|
-
|
|
417
|
+
approval: e,
|
|
418
|
+
preferGaslessPayment: i,
|
|
419
|
+
sessionMetadata: n,
|
|
396
420
|
mode: "call",
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
421
|
+
theme: r,
|
|
422
|
+
walletProvider: d,
|
|
423
|
+
onSuccess: a,
|
|
424
|
+
autoCloseOnSuccess: o,
|
|
425
|
+
baseUrl: c
|
|
426
|
+
}), [
|
|
427
|
+
s,
|
|
428
|
+
t,
|
|
429
|
+
e,
|
|
430
|
+
i,
|
|
431
|
+
n,
|
|
432
|
+
r,
|
|
433
|
+
d,
|
|
434
|
+
a,
|
|
435
|
+
o,
|
|
436
|
+
c
|
|
437
|
+
]);
|
|
438
|
+
return {
|
|
439
|
+
openGlideCall: l.open,
|
|
440
|
+
externalUrl: l.externalUrl,
|
|
441
|
+
opts: l.opts
|
|
442
|
+
};
|
|
443
|
+
}, Q = ({
|
|
444
|
+
app: s,
|
|
445
|
+
recipient: t,
|
|
446
|
+
preferGaslessPayment: e,
|
|
447
|
+
sessionMetadata: i,
|
|
448
|
+
theme: n,
|
|
449
|
+
walletProvider: r,
|
|
450
|
+
onSuccess: d,
|
|
451
|
+
autoCloseOnSuccess: a,
|
|
452
|
+
baseUrl: o
|
|
453
|
+
}) => {
|
|
454
|
+
const c = f(() => new g({
|
|
455
|
+
app: s,
|
|
456
|
+
recipient: t,
|
|
457
|
+
preferGaslessPayment: e,
|
|
458
|
+
sessionMetadata: i,
|
|
459
|
+
mode: "buy",
|
|
460
|
+
theme: n,
|
|
461
|
+
walletProvider: r,
|
|
462
|
+
onSuccess: d,
|
|
463
|
+
autoCloseOnSuccess: a,
|
|
464
|
+
baseUrl: o
|
|
465
|
+
}), [
|
|
466
|
+
s,
|
|
467
|
+
t,
|
|
468
|
+
e,
|
|
469
|
+
i,
|
|
470
|
+
n,
|
|
471
|
+
r,
|
|
472
|
+
d,
|
|
473
|
+
a,
|
|
474
|
+
o
|
|
475
|
+
]);
|
|
401
476
|
return {
|
|
402
|
-
|
|
403
|
-
externalUrl:
|
|
477
|
+
openGlideBuy: c.open,
|
|
478
|
+
externalUrl: c.externalUrl,
|
|
479
|
+
opts: c.opts
|
|
404
480
|
};
|
|
405
481
|
};
|
|
406
482
|
export {
|
|
407
483
|
g as GlideDeposit,
|
|
484
|
+
Q as useGlideBuy,
|
|
408
485
|
K as useGlideCall,
|
|
409
486
|
X as useGlideDeposit,
|
|
410
487
|
J as useGlidePay
|
package/dist/index.d.ts
CHANGED
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type GlideWidgetTheme = {
|
|
2
|
+
modalBorderWidth?: string;
|
|
3
|
+
modalBorderRadius?: string;
|
|
4
|
+
buttonPrimaryForeground?: string;
|
|
5
|
+
buttonPrimaryBackground?: string;
|
|
6
|
+
buttonPrimaryBorderColor?: string;
|
|
7
|
+
buttonPrimaryBorderWidth?: string;
|
|
8
|
+
buttonPrimaryBorderRadius?: string;
|
|
9
|
+
buttonPrimaryPadding?: string;
|
|
10
|
+
buttonSecondaryBackground?: string;
|
|
11
|
+
buttonSecondaryBorderColor?: string;
|
|
12
|
+
buttonSecondaryBorderWidth?: string;
|
|
13
|
+
buttonSecondaryBorderRadius?: string;
|
|
14
|
+
buttonSecondaryPadding?: string;
|
|
15
|
+
alertBackground?: string;
|
|
16
|
+
alertBorderWidth?: string;
|
|
17
|
+
colorModalBackdrop?: string;
|
|
18
|
+
colorModalBackground?: string;
|
|
19
|
+
colorModalBorder?: string;
|
|
20
|
+
colorTextPrimary?: string;
|
|
21
|
+
colorTextSeconday?: string;
|
|
22
|
+
colorPrimaryButtonBackground?: string;
|
|
23
|
+
colorBackgroundSecondary?: string;
|
|
24
|
+
colorAlertBackground?: string;
|
|
25
|
+
colorAlertAccent?: string;
|
|
26
|
+
colorAlertWarningBackground?: string;
|
|
27
|
+
colorAlertWarningAccent?: string;
|
|
28
|
+
colorAlertBorder?: string;
|
|
29
|
+
appLogoHeight?: string;
|
|
30
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GlideDepositWalletProvider, Hex } from './GlideDeposit.ts';
|
|
2
|
+
import { GlideWidgetTheme } from './theme.ts';
|
|
3
|
+
interface UseGlideBuyProps {
|
|
4
|
+
app: string;
|
|
5
|
+
recipient?: Hex;
|
|
6
|
+
preferGaslessPayment?: boolean;
|
|
7
|
+
sessionMetadata?: string;
|
|
8
|
+
theme?: GlideWidgetTheme;
|
|
9
|
+
walletProvider?: GlideDepositWalletProvider;
|
|
10
|
+
onSuccess?: (hash: Hex) => void;
|
|
11
|
+
autoCloseOnSuccess?: boolean;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const useGlideBuy: ({ app, recipient, preferGaslessPayment, sessionMetadata, theme, walletProvider, onSuccess, autoCloseOnSuccess, baseUrl, }: UseGlideBuyProps) => {
|
|
15
|
+
openGlideBuy: () => void;
|
|
16
|
+
externalUrl: string;
|
|
17
|
+
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
package/dist/useGlideCall.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GlideDepositWalletProvider, Hex } from './GlideDeposit.ts';
|
|
2
|
+
import { GlideWidgetTheme } from './theme.ts';
|
|
2
3
|
interface UseGlideCallProps {
|
|
3
4
|
app: string;
|
|
4
5
|
evm: {
|
|
@@ -7,13 +8,21 @@ interface UseGlideCallProps {
|
|
|
7
8
|
data?: Hex;
|
|
8
9
|
value?: bigint;
|
|
9
10
|
};
|
|
11
|
+
approval?: {
|
|
12
|
+
token: Hex;
|
|
13
|
+
amount: bigint;
|
|
14
|
+
};
|
|
10
15
|
preferGaslessPayment?: boolean;
|
|
16
|
+
sessionMetadata?: string;
|
|
17
|
+
theme?: GlideWidgetTheme;
|
|
11
18
|
walletProvider?: GlideDepositWalletProvider;
|
|
12
19
|
onSuccess?: (hash: Hex) => void;
|
|
20
|
+
autoCloseOnSuccess?: boolean;
|
|
13
21
|
baseUrl?: string;
|
|
14
22
|
}
|
|
15
|
-
export declare const useGlideCall: ({ app, evm, preferGaslessPayment, walletProvider, onSuccess, baseUrl, }: UseGlideCallProps) => {
|
|
23
|
+
export declare const useGlideCall: ({ app, evm, approval, preferGaslessPayment, sessionMetadata, theme, walletProvider, onSuccess, autoCloseOnSuccess, baseUrl, }: UseGlideCallProps) => {
|
|
16
24
|
openGlideCall: () => void;
|
|
17
25
|
externalUrl: string;
|
|
26
|
+
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|
|
18
27
|
};
|
|
19
28
|
export {};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { GlideDepositWalletProvider, Hex } from './GlideDeposit.ts';
|
|
2
|
+
import { GlideWidgetTheme } from './theme.ts';
|
|
2
3
|
interface UseGlideDepositProps {
|
|
3
4
|
app: string;
|
|
4
5
|
recipient?: Hex;
|
|
5
6
|
preferGaslessPayment?: boolean;
|
|
6
7
|
mode?: "deposit" | "withdraw";
|
|
8
|
+
sessionMetadata?: string;
|
|
9
|
+
theme?: GlideWidgetTheme;
|
|
7
10
|
walletProvider?: GlideDepositWalletProvider;
|
|
8
|
-
onSuccess?: (hash:
|
|
11
|
+
onSuccess?: (hash: string) => void;
|
|
12
|
+
autoCloseOnSuccess?: boolean;
|
|
9
13
|
baseUrl?: string;
|
|
10
14
|
}
|
|
11
|
-
export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, walletProvider, onSuccess, baseUrl, }: UseGlideDepositProps) => {
|
|
15
|
+
export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, mode, sessionMetadata, theme, walletProvider, onSuccess, autoCloseOnSuccess, baseUrl, }: UseGlideDepositProps) => {
|
|
12
16
|
openGlideDeposit: () => void;
|
|
13
17
|
externalUrl: string;
|
|
18
|
+
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|
|
14
19
|
};
|
|
15
20
|
export {};
|
package/dist/useGlidePay.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { GlideDepositWalletProvider } from './GlideDeposit.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { GlideWidgetTheme } from './theme.ts';
|
|
3
3
|
interface UseGlidePayProps {
|
|
4
4
|
app: string;
|
|
5
5
|
preferGaslessPayment?: boolean;
|
|
6
6
|
amount: string;
|
|
7
|
+
sessionMetadata?: string;
|
|
8
|
+
theme?: GlideWidgetTheme;
|
|
7
9
|
walletProvider?: GlideDepositWalletProvider;
|
|
8
|
-
onSuccess?: (hash:
|
|
10
|
+
onSuccess?: (hash: string) => void;
|
|
11
|
+
autoCloseOnSuccess?: boolean;
|
|
9
12
|
baseUrl?: string;
|
|
10
13
|
}
|
|
11
|
-
export declare const useGlidePay: ({ app, preferGaslessPayment, amount, walletProvider, onSuccess, baseUrl, }: UseGlidePayProps) => {
|
|
14
|
+
export declare const useGlidePay: ({ app, preferGaslessPayment, amount, sessionMetadata, theme, walletProvider, onSuccess, autoCloseOnSuccess, baseUrl, }: UseGlidePayProps) => {
|
|
12
15
|
openGlidePay: () => void;
|
|
13
16
|
externalUrl: string;
|
|
17
|
+
opts: import('./GlideDeposit.ts').GlideDepositOptions;
|
|
14
18
|
};
|
|
15
19
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paywithglide/glide-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dev": "vite",
|
|
20
20
|
"build": "tsc --p ./tsconfig.build.json && vite build",
|
|
21
21
|
"build-web": "tsc --p ./tsconfig.build.json && vite build --mode web",
|
|
22
|
+
"build-chromeext": "tsc --p ./tsconfig.build.json && vite build --mode chromeext:popup && vite build --mode chromeext:content && vite build --mode chromeext:background",
|
|
22
23
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
23
24
|
"preview": "vite preview",
|
|
24
25
|
"prepublishOnly": "npm run build"
|
|
@@ -27,13 +28,10 @@
|
|
|
27
28
|
"@paywithglide/glide-js": "^0.10.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@tanstack/react-query": "^5.61.5",
|
|
31
|
-
"react": "^18.3.1",
|
|
32
|
-
"react-dom": "^18.3.1",
|
|
33
|
-
"viem": "^2.21.51",
|
|
34
|
-
"wagmi": "^2.13.0",
|
|
35
31
|
"@antiwork/shortest": "^0.2.1",
|
|
36
32
|
"@eslint/js": "^9.15.0",
|
|
33
|
+
"@tanstack/react-query": "^5.61.5",
|
|
34
|
+
"@types/chrome": "^0.0.299",
|
|
37
35
|
"@types/react": "^18.3.12",
|
|
38
36
|
"@types/react-dom": "^18.3.1",
|
|
39
37
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -41,9 +39,14 @@
|
|
|
41
39
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
42
40
|
"eslint-plugin-react-refresh": "^0.4.14",
|
|
43
41
|
"globals": "^15.12.0",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"react-dom": "^18.3.1",
|
|
44
44
|
"typescript": "~5.6.2",
|
|
45
45
|
"typescript-eslint": "^8.15.0",
|
|
46
|
+
"viem": "^2.21.51",
|
|
46
47
|
"vite": "^6.0.1",
|
|
47
|
-
"vite-plugin-dts": "^4.3.0"
|
|
48
|
+
"vite-plugin-dts": "^4.3.0",
|
|
49
|
+
"vite-plugin-static-copy": "^2.2.0",
|
|
50
|
+
"wagmi": "^2.13.0"
|
|
48
51
|
}
|
|
49
52
|
}
|