@swype-org/deposit 0.3.13 → 0.3.14
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/{chunk-7Y4RWJI3.js → chunk-XYI3ZPQD.js} +421 -6
- package/dist/chunk-XYI3ZPQD.js.map +1 -0
- package/dist/index.cjs +423 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -3
- package/dist/index.d.ts +159 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +418 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/{types-CCi4cpnQ.d.cts → types-DYsZwNXq.d.cts} +10 -3
- package/dist/{types-CCi4cpnQ.d.ts → types-DYsZwNXq.d.ts} +10 -3
- package/package.json +2 -2
- package/dist/chunk-7Y4RWJI3.js.map +0 -1
|
@@ -22,6 +22,396 @@ function getDisplayMessage(error) {
|
|
|
22
22
|
return DISPLAY_MESSAGES[error.code] ?? error.message;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// src/walletBridge/discover.ts
|
|
26
|
+
function createWalletDiscoverer() {
|
|
27
|
+
if (typeof window === "undefined") {
|
|
28
|
+
return makeNoopHandle();
|
|
29
|
+
}
|
|
30
|
+
const registry = /* @__PURE__ */ new Map();
|
|
31
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
32
|
+
let destroyed = false;
|
|
33
|
+
const onAnnounce = (event) => {
|
|
34
|
+
if (destroyed) return;
|
|
35
|
+
const detail = event.detail;
|
|
36
|
+
if (!isValidProviderDetail(detail)) {
|
|
37
|
+
console.info("[blink-bridge:parent] dropping malformed EIP-6963 announcement", {
|
|
38
|
+
rawInfo: event.detail && event.detail.info
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const existing = registry.get(detail.info.uuid);
|
|
43
|
+
if (existing && existing.provider === detail.provider) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.info("[blink-bridge:parent] EIP-6963 announceProvider", {
|
|
47
|
+
rdns: detail.info.rdns,
|
|
48
|
+
name: detail.info.name,
|
|
49
|
+
uuid: detail.info.uuid
|
|
50
|
+
});
|
|
51
|
+
registry.set(detail.info.uuid, {
|
|
52
|
+
info: { ...detail.info },
|
|
53
|
+
provider: detail.provider
|
|
54
|
+
});
|
|
55
|
+
notify();
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("eip6963:announceProvider", onAnnounce);
|
|
58
|
+
requestProviders();
|
|
59
|
+
const RESWEEP_INTERVALS_MS = [500, 1500, 3e3, 6e3];
|
|
60
|
+
const reSweepTimers = [];
|
|
61
|
+
for (const ms of RESWEEP_INTERVALS_MS) {
|
|
62
|
+
reSweepTimers.push(
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
if (!destroyed) requestProviders();
|
|
65
|
+
}, ms)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function requestProviders() {
|
|
69
|
+
try {
|
|
70
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function notify() {
|
|
75
|
+
const snapshot = list();
|
|
76
|
+
for (const listener of listeners) {
|
|
77
|
+
try {
|
|
78
|
+
listener(snapshot);
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function list() {
|
|
84
|
+
return [...registry.values()];
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
list,
|
|
88
|
+
get(uuid) {
|
|
89
|
+
return registry.get(uuid)?.provider;
|
|
90
|
+
},
|
|
91
|
+
subscribe(listener) {
|
|
92
|
+
listeners.add(listener);
|
|
93
|
+
return () => {
|
|
94
|
+
listeners.delete(listener);
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
requestProviders,
|
|
98
|
+
destroy() {
|
|
99
|
+
if (destroyed) return;
|
|
100
|
+
destroyed = true;
|
|
101
|
+
window.removeEventListener("eip6963:announceProvider", onAnnounce);
|
|
102
|
+
for (const t of reSweepTimers) clearTimeout(t);
|
|
103
|
+
registry.clear();
|
|
104
|
+
listeners.clear();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function makeNoopHandle() {
|
|
109
|
+
return {
|
|
110
|
+
list: () => [],
|
|
111
|
+
get: () => void 0,
|
|
112
|
+
subscribe: () => () => {
|
|
113
|
+
},
|
|
114
|
+
requestProviders: () => {
|
|
115
|
+
},
|
|
116
|
+
destroy: () => {
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function isValidProviderDetail(value) {
|
|
121
|
+
if (!value || typeof value !== "object") return false;
|
|
122
|
+
const detail = value;
|
|
123
|
+
const info = detail.info;
|
|
124
|
+
const provider = detail.provider;
|
|
125
|
+
if (!info || !provider) return false;
|
|
126
|
+
if (typeof info.uuid !== "string" || info.uuid.length === 0) return false;
|
|
127
|
+
if (typeof info.name !== "string") return false;
|
|
128
|
+
if (typeof info.rdns !== "string") return false;
|
|
129
|
+
if (typeof provider.request !== "function") return false;
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/walletBridge/protocol.ts
|
|
134
|
+
var BRIDGE_PROTOCOL_VERSION = 1;
|
|
135
|
+
var ALLOWED_RPC_METHODS = /* @__PURE__ */ new Set([
|
|
136
|
+
// Read
|
|
137
|
+
"eth_accounts",
|
|
138
|
+
"eth_blockNumber",
|
|
139
|
+
"eth_call",
|
|
140
|
+
"eth_chainId",
|
|
141
|
+
"eth_estimateGas",
|
|
142
|
+
"eth_gasPrice",
|
|
143
|
+
"eth_getBalance",
|
|
144
|
+
"eth_getCode",
|
|
145
|
+
"eth_getStorageAt",
|
|
146
|
+
"eth_getTransactionByHash",
|
|
147
|
+
"eth_getTransactionCount",
|
|
148
|
+
"eth_getTransactionReceipt",
|
|
149
|
+
"net_version",
|
|
150
|
+
"wallet_getCapabilities",
|
|
151
|
+
"wallet_getCallsStatus",
|
|
152
|
+
// Write / sign
|
|
153
|
+
"eth_requestAccounts",
|
|
154
|
+
"eth_sendTransaction",
|
|
155
|
+
"eth_sendRawTransaction",
|
|
156
|
+
"eth_sign",
|
|
157
|
+
"personal_sign",
|
|
158
|
+
"eth_signTypedData",
|
|
159
|
+
"eth_signTypedData_v3",
|
|
160
|
+
"eth_signTypedData_v4",
|
|
161
|
+
"wallet_addEthereumChain",
|
|
162
|
+
"wallet_switchEthereumChain",
|
|
163
|
+
"wallet_sendCalls",
|
|
164
|
+
"wallet_watchAsset"
|
|
165
|
+
]);
|
|
166
|
+
var FORWARDED_PROVIDER_EVENTS = [
|
|
167
|
+
"accountsChanged",
|
|
168
|
+
"chainChanged",
|
|
169
|
+
"connect",
|
|
170
|
+
"disconnect",
|
|
171
|
+
"message"
|
|
172
|
+
];
|
|
173
|
+
function parseBridgeMessage(data) {
|
|
174
|
+
if (!data || typeof data !== "object") return null;
|
|
175
|
+
const msg = data;
|
|
176
|
+
if (msg.protocolVersion !== BRIDGE_PROTOCOL_VERSION) return null;
|
|
177
|
+
switch (msg.type) {
|
|
178
|
+
case "blink:bridge-hello":
|
|
179
|
+
return msg;
|
|
180
|
+
case "blink:wallets-advertised":
|
|
181
|
+
return Array.isArray(msg.wallets) ? msg : null;
|
|
182
|
+
case "blink:rpc-request":
|
|
183
|
+
if (typeof msg.uuid !== "string" || typeof msg.id !== "string" || typeof msg.method !== "string") {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
return msg;
|
|
187
|
+
case "blink:rpc-response":
|
|
188
|
+
if (typeof msg.id !== "string") return null;
|
|
189
|
+
return msg;
|
|
190
|
+
case "blink:rpc-event":
|
|
191
|
+
if (typeof msg.uuid !== "string" || typeof msg.event !== "string" || !Array.isArray(msg.args)) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
return msg;
|
|
195
|
+
case "blink:resolve-by-flag":
|
|
196
|
+
if (typeof msg.id !== "string" || !Array.isArray(msg.flags)) return null;
|
|
197
|
+
if (!msg.flags.every((f) => typeof f === "string" && f.length > 0)) return null;
|
|
198
|
+
return msg;
|
|
199
|
+
case "blink:resolve-by-flag-response":
|
|
200
|
+
if (typeof msg.id !== "string") return null;
|
|
201
|
+
if (msg.match !== null && (typeof msg.match !== "object" || !msg.match)) return null;
|
|
202
|
+
return msg;
|
|
203
|
+
default:
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/walletBridge/rpcHost.ts
|
|
209
|
+
function attachRpcHost(options) {
|
|
210
|
+
const { iframeWindow, iframeOrigin, discoverer } = options;
|
|
211
|
+
const log = options.log ?? noopLog;
|
|
212
|
+
if (typeof window === "undefined") {
|
|
213
|
+
return { detach: () => {
|
|
214
|
+
} };
|
|
215
|
+
}
|
|
216
|
+
let detached = false;
|
|
217
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
218
|
+
const unsubscribeFromDiscoverer = discoverer.subscribe((snapshot) => {
|
|
219
|
+
if (detached) return;
|
|
220
|
+
advertiseWallets(snapshot);
|
|
221
|
+
});
|
|
222
|
+
function postToIframe(message) {
|
|
223
|
+
if (detached) return;
|
|
224
|
+
try {
|
|
225
|
+
iframeWindow.postMessage(message, iframeOrigin);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
log("postMessage to iframe failed", {
|
|
228
|
+
error: err instanceof Error ? err.message : String(err)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function advertiseWallets(snapshot) {
|
|
233
|
+
const wallets = snapshot.map((entry) => ({
|
|
234
|
+
uuid: entry.info.uuid,
|
|
235
|
+
rdns: entry.info.rdns,
|
|
236
|
+
name: entry.info.name,
|
|
237
|
+
icon: entry.info.icon
|
|
238
|
+
}));
|
|
239
|
+
console.info("[blink-bridge:parent] advertising wallets", wallets.map((w) => ({
|
|
240
|
+
rdns: w.rdns,
|
|
241
|
+
name: w.name
|
|
242
|
+
})));
|
|
243
|
+
const message = {
|
|
244
|
+
type: "blink:wallets-advertised",
|
|
245
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
246
|
+
wallets
|
|
247
|
+
};
|
|
248
|
+
postToIframe(message);
|
|
249
|
+
}
|
|
250
|
+
function ensureSubscription(uuid, provider) {
|
|
251
|
+
if (subscriptions.has(uuid)) return;
|
|
252
|
+
if (typeof provider.on !== "function") {
|
|
253
|
+
subscriptions.set(uuid, { provider, listeners: /* @__PURE__ */ new Map() });
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const record = { provider, listeners: /* @__PURE__ */ new Map() };
|
|
257
|
+
for (const event of FORWARDED_PROVIDER_EVENTS) {
|
|
258
|
+
const listener = (...args) => {
|
|
259
|
+
const eventMessage = {
|
|
260
|
+
type: "blink:rpc-event",
|
|
261
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
262
|
+
uuid,
|
|
263
|
+
event,
|
|
264
|
+
args
|
|
265
|
+
};
|
|
266
|
+
postToIframe(eventMessage);
|
|
267
|
+
};
|
|
268
|
+
try {
|
|
269
|
+
provider.on(event, listener);
|
|
270
|
+
record.listeners.set(event, listener);
|
|
271
|
+
} catch (err) {
|
|
272
|
+
log(`provider.on('${event}') threw \u2014 skipping that event`, {
|
|
273
|
+
uuid,
|
|
274
|
+
error: err instanceof Error ? err.message : String(err)
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
subscriptions.set(uuid, record);
|
|
279
|
+
}
|
|
280
|
+
function unsubscribeAll() {
|
|
281
|
+
for (const [, record] of subscriptions) {
|
|
282
|
+
const provider = record.provider;
|
|
283
|
+
if (typeof provider.removeListener !== "function") continue;
|
|
284
|
+
for (const [event, listener] of record.listeners) {
|
|
285
|
+
try {
|
|
286
|
+
provider.removeListener(event, listener);
|
|
287
|
+
} catch {
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
subscriptions.clear();
|
|
292
|
+
}
|
|
293
|
+
function sendError(id, code, message, data) {
|
|
294
|
+
const response = {
|
|
295
|
+
type: "blink:rpc-response",
|
|
296
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
297
|
+
id,
|
|
298
|
+
error: data === void 0 ? { code, message } : { code, message, data }
|
|
299
|
+
};
|
|
300
|
+
postToIframe(response);
|
|
301
|
+
}
|
|
302
|
+
function sendResult(id, result) {
|
|
303
|
+
const response = {
|
|
304
|
+
type: "blink:rpc-response",
|
|
305
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
306
|
+
id,
|
|
307
|
+
result
|
|
308
|
+
};
|
|
309
|
+
postToIframe(response);
|
|
310
|
+
}
|
|
311
|
+
const onMessage = (event) => {
|
|
312
|
+
if (detached) return;
|
|
313
|
+
if (event.source !== iframeWindow) return;
|
|
314
|
+
if (event.origin !== iframeOrigin) return;
|
|
315
|
+
const message = parseBridgeMessage(event.data);
|
|
316
|
+
if (!message) return;
|
|
317
|
+
switch (message.type) {
|
|
318
|
+
case "blink:bridge-hello": {
|
|
319
|
+
advertiseWallets(discoverer.list());
|
|
320
|
+
discoverer.requestProviders();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
case "blink:rpc-request": {
|
|
324
|
+
const { id, uuid, method, params } = message;
|
|
325
|
+
console.info("[blink-bridge:parent] rpc-request", { uuid, method });
|
|
326
|
+
if (!ALLOWED_RPC_METHODS.has(method)) {
|
|
327
|
+
log("rejecting non-allowlisted method", { uuid, method });
|
|
328
|
+
sendError(id, -32601, `Method not allowed: ${method}`);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const provider = discoverer.get(uuid);
|
|
332
|
+
if (!provider) {
|
|
333
|
+
log("no provider for uuid", { uuid, method });
|
|
334
|
+
sendError(id, -32602, `Unknown wallet: ${uuid}`);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
ensureSubscription(uuid, provider);
|
|
338
|
+
provider.request({ method, params }).then((result) => {
|
|
339
|
+
console.info("[blink-bridge:parent] rpc-result", { uuid, method, ok: true });
|
|
340
|
+
sendResult(id, result);
|
|
341
|
+
}).catch((err) => {
|
|
342
|
+
const { code, message: errMessage, data } = normalizeProviderError(err);
|
|
343
|
+
console.info("[blink-bridge:parent] rpc-error", { uuid, method, code, message: errMessage });
|
|
344
|
+
sendError(id, code, errMessage, data);
|
|
345
|
+
});
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
case "blink:resolve-by-flag": {
|
|
349
|
+
const match = resolveByFlag(discoverer.list(), message.flags, log);
|
|
350
|
+
console.info("[blink-bridge:parent] resolveByFlag", {
|
|
351
|
+
flags: message.flags,
|
|
352
|
+
match: match ? { rdns: match.rdns, flag: match.flag } : null
|
|
353
|
+
});
|
|
354
|
+
const response = {
|
|
355
|
+
type: "blink:resolve-by-flag-response",
|
|
356
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
357
|
+
id: message.id,
|
|
358
|
+
match
|
|
359
|
+
};
|
|
360
|
+
postToIframe(response);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
case "blink:wallets-advertised":
|
|
364
|
+
case "blink:rpc-response":
|
|
365
|
+
case "blink:rpc-event":
|
|
366
|
+
case "blink:resolve-by-flag-response":
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
window.addEventListener("message", onMessage);
|
|
371
|
+
return {
|
|
372
|
+
detach() {
|
|
373
|
+
if (detached) return;
|
|
374
|
+
detached = true;
|
|
375
|
+
window.removeEventListener("message", onMessage);
|
|
376
|
+
unsubscribeFromDiscoverer();
|
|
377
|
+
unsubscribeAll();
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function noopLog() {
|
|
382
|
+
}
|
|
383
|
+
function resolveByFlag(snapshot, flags, log) {
|
|
384
|
+
for (const flag of flags) {
|
|
385
|
+
for (const entry of snapshot) {
|
|
386
|
+
let value;
|
|
387
|
+
try {
|
|
388
|
+
value = entry.provider[flag];
|
|
389
|
+
} catch (err) {
|
|
390
|
+
log("provider threw on flag read \u2014 skipping", {
|
|
391
|
+
rdns: entry.info.rdns,
|
|
392
|
+
flag,
|
|
393
|
+
error: err instanceof Error ? err.message : String(err)
|
|
394
|
+
});
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (value) {
|
|
398
|
+
return { rdns: entry.info.rdns, uuid: entry.info.uuid, flag };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
function normalizeProviderError(err) {
|
|
405
|
+
if (err && typeof err === "object") {
|
|
406
|
+
const e = err;
|
|
407
|
+
const code = typeof e.code === "number" ? e.code : -32603;
|
|
408
|
+
const message = typeof e.message === "string" ? e.message : err instanceof Error ? err.message : "Provider error";
|
|
409
|
+
const data = "data" in e ? e.data : void 0;
|
|
410
|
+
return data === void 0 ? { code, message } : { code, message, data };
|
|
411
|
+
}
|
|
412
|
+
return { code: -32603, message: typeof err === "string" ? err : "Provider error" };
|
|
413
|
+
}
|
|
414
|
+
|
|
25
415
|
// src/messages.ts
|
|
26
416
|
function parseTransferComplete(data) {
|
|
27
417
|
if (!data || typeof data !== "object") {
|
|
@@ -124,13 +514,26 @@ function createIframe(url, containerElement) {
|
|
|
124
514
|
const iframe = document.createElement("iframe");
|
|
125
515
|
iframe.src = url;
|
|
126
516
|
const iframeOrigin = new URL(url).origin;
|
|
127
|
-
iframe.allow = `publickey-credentials-get ${iframeOrigin}; publickey-credentials-create ${iframeOrigin}`;
|
|
517
|
+
iframe.allow = `publickey-credentials-get ${iframeOrigin}; publickey-credentials-create ${iframeOrigin}; clipboard-write ${iframeOrigin}`;
|
|
128
518
|
const handle = document.createElement("div");
|
|
129
519
|
container.appendChild(handle);
|
|
130
520
|
container.appendChild(iframe);
|
|
131
521
|
overlay.appendChild(container);
|
|
132
522
|
const mountTarget = containerElement ?? document.body;
|
|
133
523
|
mountTarget.appendChild(overlay);
|
|
524
|
+
const discoverer = createWalletDiscoverer();
|
|
525
|
+
let rpcHostHandle = null;
|
|
526
|
+
const attachBridge = () => {
|
|
527
|
+
if (rpcHostHandle) return;
|
|
528
|
+
if (!iframe.contentWindow) return;
|
|
529
|
+
rpcHostHandle = attachRpcHost({
|
|
530
|
+
iframeWindow: iframe.contentWindow,
|
|
531
|
+
iframeOrigin,
|
|
532
|
+
discoverer
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
attachBridge();
|
|
536
|
+
iframe.addEventListener("load", attachBridge);
|
|
134
537
|
const savedOverflow = document.body.style.overflow;
|
|
135
538
|
document.body.style.overflow = "hidden";
|
|
136
539
|
const onBackdropClick = (event) => {
|
|
@@ -157,6 +560,7 @@ function createIframe(url, containerElement) {
|
|
|
157
560
|
if (closed) return;
|
|
158
561
|
closed = true;
|
|
159
562
|
removeListeners();
|
|
563
|
+
detachBridge();
|
|
160
564
|
overlay.setAttribute("data-blink-closing", "");
|
|
161
565
|
let removed = false;
|
|
162
566
|
const removeOverlay = () => {
|
|
@@ -169,6 +573,14 @@ function createIframe(url, containerElement) {
|
|
|
169
573
|
container.addEventListener("animationend", removeOverlay, { once: true });
|
|
170
574
|
setTimeout(removeOverlay, CLOSE_DURATION_MS + 50);
|
|
171
575
|
}
|
|
576
|
+
function detachBridge() {
|
|
577
|
+
iframe.removeEventListener("load", attachBridge);
|
|
578
|
+
if (rpcHostHandle) {
|
|
579
|
+
rpcHostHandle.detach();
|
|
580
|
+
rpcHostHandle = null;
|
|
581
|
+
}
|
|
582
|
+
discoverer.destroy();
|
|
583
|
+
}
|
|
172
584
|
return {
|
|
173
585
|
get contentWindow() {
|
|
174
586
|
return iframe.contentWindow;
|
|
@@ -187,6 +599,7 @@ function createIframe(url, containerElement) {
|
|
|
187
599
|
if (!closed) {
|
|
188
600
|
closed = true;
|
|
189
601
|
removeListeners();
|
|
602
|
+
detachBridge();
|
|
190
603
|
overlay.remove();
|
|
191
604
|
unlockScroll();
|
|
192
605
|
}
|
|
@@ -309,8 +722,10 @@ function isValidTokenAddress(value) {
|
|
|
309
722
|
return TOKEN_ADDRESS_RE.test(value) || SOLANA_ADDRESS_RE.test(value);
|
|
310
723
|
}
|
|
311
724
|
function validateDepositRequest(request) {
|
|
312
|
-
if (
|
|
313
|
-
|
|
725
|
+
if (request.amount !== null) {
|
|
726
|
+
if (typeof request.amount !== "number" || !Number.isFinite(request.amount) || request.amount <= 0) {
|
|
727
|
+
throw new DepositError("INVALID_REQUEST", "amount must be a positive number or null.");
|
|
728
|
+
}
|
|
314
729
|
}
|
|
315
730
|
if (!Number.isInteger(request.chainId) || request.chainId <= 0) {
|
|
316
731
|
throw new DepositError("INVALID_REQUEST", "chainId must be a positive integer.");
|
|
@@ -622,6 +1037,6 @@ var Deposit = class {
|
|
|
622
1037
|
};
|
|
623
1038
|
var Checkout = Deposit;
|
|
624
1039
|
|
|
625
|
-
export { Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, getDisplayMessage };
|
|
626
|
-
//# sourceMappingURL=chunk-
|
|
627
|
-
//# sourceMappingURL=chunk-
|
|
1040
|
+
export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage };
|
|
1041
|
+
//# sourceMappingURL=chunk-XYI3ZPQD.js.map
|
|
1042
|
+
//# sourceMappingURL=chunk-XYI3ZPQD.js.map
|