@swype-org/deposit 0.3.6 → 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/react.cjs CHANGED
@@ -44,24 +44,16 @@ function parseTransferComplete(data) {
44
44
  if (typeof t.id !== "string" || typeof t.status !== "string") {
45
45
  return null;
46
46
  }
47
- const transferType = parseTransferKind(t.type);
48
47
  return {
49
48
  type: "blink:transfer-complete",
50
49
  transfer: {
51
50
  id: t.id,
52
51
  status: t.status,
53
- ...transferType != null ? { type: transferType } : {},
54
52
  amount: parseAmount(t.amount),
55
53
  destinations: parseDestinations(t.destinations)
56
54
  }
57
55
  };
58
56
  }
59
- function parseTransferKind(value) {
60
- if (value === "guest" || value === "standard") {
61
- return value;
62
- }
63
- return void 0;
64
- }
65
57
  function parseAmount(value) {
66
58
  if (!value || typeof value !== "object") {
67
59
  return void 0;
@@ -102,9 +94,401 @@ function parseCloseRequest(data) {
102
94
  return { type: "blink:close-request" };
103
95
  }
104
96
 
97
+ // src/walletBridge/discover.ts
98
+ function createWalletDiscoverer() {
99
+ if (typeof window === "undefined") {
100
+ return makeNoopHandle();
101
+ }
102
+ const registry = /* @__PURE__ */ new Map();
103
+ const listeners = /* @__PURE__ */ new Set();
104
+ let destroyed = false;
105
+ const onAnnounce = (event) => {
106
+ if (destroyed) return;
107
+ const detail = event.detail;
108
+ if (!isValidProviderDetail(detail)) {
109
+ console.info("[blink-bridge:parent] dropping malformed EIP-6963 announcement", {
110
+ rawInfo: event.detail && event.detail.info
111
+ });
112
+ return;
113
+ }
114
+ const existing = registry.get(detail.info.uuid);
115
+ if (existing && existing.provider === detail.provider) {
116
+ return;
117
+ }
118
+ console.info("[blink-bridge:parent] EIP-6963 announceProvider", {
119
+ rdns: detail.info.rdns,
120
+ name: detail.info.name,
121
+ uuid: detail.info.uuid
122
+ });
123
+ registry.set(detail.info.uuid, {
124
+ info: { ...detail.info },
125
+ provider: detail.provider
126
+ });
127
+ notify();
128
+ };
129
+ window.addEventListener("eip6963:announceProvider", onAnnounce);
130
+ requestProviders();
131
+ const RESWEEP_INTERVALS_MS = [500, 1500, 3e3, 6e3];
132
+ const reSweepTimers = [];
133
+ for (const ms of RESWEEP_INTERVALS_MS) {
134
+ reSweepTimers.push(
135
+ setTimeout(() => {
136
+ if (!destroyed) requestProviders();
137
+ }, ms)
138
+ );
139
+ }
140
+ function requestProviders() {
141
+ try {
142
+ window.dispatchEvent(new Event("eip6963:requestProvider"));
143
+ } catch {
144
+ }
145
+ }
146
+ function notify() {
147
+ const snapshot = list();
148
+ for (const listener of listeners) {
149
+ try {
150
+ listener(snapshot);
151
+ } catch {
152
+ }
153
+ }
154
+ }
155
+ function list() {
156
+ return [...registry.values()];
157
+ }
158
+ return {
159
+ list,
160
+ get(uuid) {
161
+ return registry.get(uuid)?.provider;
162
+ },
163
+ subscribe(listener) {
164
+ listeners.add(listener);
165
+ return () => {
166
+ listeners.delete(listener);
167
+ };
168
+ },
169
+ requestProviders,
170
+ destroy() {
171
+ if (destroyed) return;
172
+ destroyed = true;
173
+ window.removeEventListener("eip6963:announceProvider", onAnnounce);
174
+ for (const t of reSweepTimers) clearTimeout(t);
175
+ registry.clear();
176
+ listeners.clear();
177
+ }
178
+ };
179
+ }
180
+ function makeNoopHandle() {
181
+ return {
182
+ list: () => [],
183
+ get: () => void 0,
184
+ subscribe: () => () => {
185
+ },
186
+ requestProviders: () => {
187
+ },
188
+ destroy: () => {
189
+ }
190
+ };
191
+ }
192
+ function isValidProviderDetail(value) {
193
+ if (!value || typeof value !== "object") return false;
194
+ const detail = value;
195
+ const info = detail.info;
196
+ const provider = detail.provider;
197
+ if (!info || !provider) return false;
198
+ if (typeof info.uuid !== "string" || info.uuid.length === 0) return false;
199
+ if (typeof info.name !== "string") return false;
200
+ if (typeof info.rdns !== "string") return false;
201
+ if (typeof provider.request !== "function") return false;
202
+ return true;
203
+ }
204
+
205
+ // src/walletBridge/protocol.ts
206
+ var BRIDGE_PROTOCOL_VERSION = 1;
207
+ var ALLOWED_RPC_METHODS = /* @__PURE__ */ new Set([
208
+ // Read
209
+ "eth_accounts",
210
+ "eth_blockNumber",
211
+ "eth_call",
212
+ "eth_chainId",
213
+ "eth_estimateGas",
214
+ "eth_gasPrice",
215
+ "eth_getBalance",
216
+ "eth_getCode",
217
+ "eth_getStorageAt",
218
+ "eth_getTransactionByHash",
219
+ "eth_getTransactionCount",
220
+ "eth_getTransactionReceipt",
221
+ "net_version",
222
+ "wallet_getCapabilities",
223
+ "wallet_getCallsStatus",
224
+ // Write / sign
225
+ "eth_requestAccounts",
226
+ "eth_sendTransaction",
227
+ "eth_sendRawTransaction",
228
+ "eth_sign",
229
+ "personal_sign",
230
+ "eth_signTypedData",
231
+ "eth_signTypedData_v3",
232
+ "eth_signTypedData_v4",
233
+ "wallet_addEthereumChain",
234
+ "wallet_switchEthereumChain",
235
+ "wallet_sendCalls",
236
+ "wallet_watchAsset"
237
+ ]);
238
+ var FORWARDED_PROVIDER_EVENTS = [
239
+ "accountsChanged",
240
+ "chainChanged",
241
+ "connect",
242
+ "disconnect",
243
+ "message"
244
+ ];
245
+ function parseBridgeMessage(data) {
246
+ if (!data || typeof data !== "object") return null;
247
+ const msg = data;
248
+ if (msg.protocolVersion !== BRIDGE_PROTOCOL_VERSION) return null;
249
+ switch (msg.type) {
250
+ case "blink:bridge-hello":
251
+ return msg;
252
+ case "blink:wallets-advertised":
253
+ return Array.isArray(msg.wallets) ? msg : null;
254
+ case "blink:rpc-request":
255
+ if (typeof msg.uuid !== "string" || typeof msg.id !== "string" || typeof msg.method !== "string") {
256
+ return null;
257
+ }
258
+ return msg;
259
+ case "blink:rpc-response":
260
+ if (typeof msg.id !== "string") return null;
261
+ return msg;
262
+ case "blink:rpc-event":
263
+ if (typeof msg.uuid !== "string" || typeof msg.event !== "string" || !Array.isArray(msg.args)) {
264
+ return null;
265
+ }
266
+ return msg;
267
+ case "blink:resolve-by-flag":
268
+ if (typeof msg.id !== "string" || !Array.isArray(msg.flags)) return null;
269
+ if (!msg.flags.every((f) => typeof f === "string" && f.length > 0)) return null;
270
+ return msg;
271
+ case "blink:resolve-by-flag-response":
272
+ if (typeof msg.id !== "string") return null;
273
+ if (msg.match !== null && (typeof msg.match !== "object" || !msg.match)) return null;
274
+ return msg;
275
+ default:
276
+ return null;
277
+ }
278
+ }
279
+
280
+ // src/walletBridge/rpcHost.ts
281
+ function attachRpcHost(options) {
282
+ const { iframeWindow, iframeOrigin, discoverer } = options;
283
+ const log = options.log ?? noopLog;
284
+ if (typeof window === "undefined") {
285
+ return { detach: () => {
286
+ } };
287
+ }
288
+ let detached = false;
289
+ const subscriptions = /* @__PURE__ */ new Map();
290
+ const unsubscribeFromDiscoverer = discoverer.subscribe((snapshot) => {
291
+ if (detached) return;
292
+ advertiseWallets(snapshot);
293
+ });
294
+ function postToIframe(message) {
295
+ if (detached) return;
296
+ try {
297
+ iframeWindow.postMessage(message, iframeOrigin);
298
+ } catch (err) {
299
+ log("postMessage to iframe failed", {
300
+ error: err instanceof Error ? err.message : String(err)
301
+ });
302
+ }
303
+ }
304
+ function advertiseWallets(snapshot) {
305
+ const wallets = snapshot.map((entry) => ({
306
+ uuid: entry.info.uuid,
307
+ rdns: entry.info.rdns,
308
+ name: entry.info.name,
309
+ icon: entry.info.icon
310
+ }));
311
+ console.info("[blink-bridge:parent] advertising wallets", wallets.map((w) => ({
312
+ rdns: w.rdns,
313
+ name: w.name
314
+ })));
315
+ const message = {
316
+ type: "blink:wallets-advertised",
317
+ protocolVersion: BRIDGE_PROTOCOL_VERSION,
318
+ wallets
319
+ };
320
+ postToIframe(message);
321
+ }
322
+ function ensureSubscription(uuid, provider) {
323
+ if (subscriptions.has(uuid)) return;
324
+ if (typeof provider.on !== "function") {
325
+ subscriptions.set(uuid, { provider, listeners: /* @__PURE__ */ new Map() });
326
+ return;
327
+ }
328
+ const record = { provider, listeners: /* @__PURE__ */ new Map() };
329
+ for (const event of FORWARDED_PROVIDER_EVENTS) {
330
+ const listener = (...args) => {
331
+ const eventMessage = {
332
+ type: "blink:rpc-event",
333
+ protocolVersion: BRIDGE_PROTOCOL_VERSION,
334
+ uuid,
335
+ event,
336
+ args
337
+ };
338
+ postToIframe(eventMessage);
339
+ };
340
+ try {
341
+ provider.on(event, listener);
342
+ record.listeners.set(event, listener);
343
+ } catch (err) {
344
+ log(`provider.on('${event}') threw \u2014 skipping that event`, {
345
+ uuid,
346
+ error: err instanceof Error ? err.message : String(err)
347
+ });
348
+ }
349
+ }
350
+ subscriptions.set(uuid, record);
351
+ }
352
+ function unsubscribeAll() {
353
+ for (const [, record] of subscriptions) {
354
+ const provider = record.provider;
355
+ if (typeof provider.removeListener !== "function") continue;
356
+ for (const [event, listener] of record.listeners) {
357
+ try {
358
+ provider.removeListener(event, listener);
359
+ } catch {
360
+ }
361
+ }
362
+ }
363
+ subscriptions.clear();
364
+ }
365
+ function sendError(id, code, message, data) {
366
+ const response = {
367
+ type: "blink:rpc-response",
368
+ protocolVersion: BRIDGE_PROTOCOL_VERSION,
369
+ id,
370
+ error: data === void 0 ? { code, message } : { code, message, data }
371
+ };
372
+ postToIframe(response);
373
+ }
374
+ function sendResult(id, result) {
375
+ const response = {
376
+ type: "blink:rpc-response",
377
+ protocolVersion: BRIDGE_PROTOCOL_VERSION,
378
+ id,
379
+ result
380
+ };
381
+ postToIframe(response);
382
+ }
383
+ const onMessage = (event) => {
384
+ if (detached) return;
385
+ if (event.source !== iframeWindow) return;
386
+ if (event.origin !== iframeOrigin) return;
387
+ const message = parseBridgeMessage(event.data);
388
+ if (!message) return;
389
+ switch (message.type) {
390
+ case "blink:bridge-hello": {
391
+ advertiseWallets(discoverer.list());
392
+ discoverer.requestProviders();
393
+ return;
394
+ }
395
+ case "blink:rpc-request": {
396
+ const { id, uuid, method, params } = message;
397
+ console.info("[blink-bridge:parent] rpc-request", { uuid, method });
398
+ if (!ALLOWED_RPC_METHODS.has(method)) {
399
+ log("rejecting non-allowlisted method", { uuid, method });
400
+ sendError(id, -32601, `Method not allowed: ${method}`);
401
+ return;
402
+ }
403
+ const provider = discoverer.get(uuid);
404
+ if (!provider) {
405
+ log("no provider for uuid", { uuid, method });
406
+ sendError(id, -32602, `Unknown wallet: ${uuid}`);
407
+ return;
408
+ }
409
+ ensureSubscription(uuid, provider);
410
+ provider.request({ method, params }).then((result) => {
411
+ console.info("[blink-bridge:parent] rpc-result", { uuid, method, ok: true });
412
+ sendResult(id, result);
413
+ }).catch((err) => {
414
+ const { code, message: errMessage, data } = normalizeProviderError(err);
415
+ console.info("[blink-bridge:parent] rpc-error", { uuid, method, code, message: errMessage });
416
+ sendError(id, code, errMessage, data);
417
+ });
418
+ return;
419
+ }
420
+ case "blink:resolve-by-flag": {
421
+ const match = resolveByFlag(discoverer.list(), message.flags, log);
422
+ console.info("[blink-bridge:parent] resolveByFlag", {
423
+ flags: message.flags,
424
+ match: match ? { rdns: match.rdns, flag: match.flag } : null
425
+ });
426
+ const response = {
427
+ type: "blink:resolve-by-flag-response",
428
+ protocolVersion: BRIDGE_PROTOCOL_VERSION,
429
+ id: message.id,
430
+ match
431
+ };
432
+ postToIframe(response);
433
+ return;
434
+ }
435
+ case "blink:wallets-advertised":
436
+ case "blink:rpc-response":
437
+ case "blink:rpc-event":
438
+ case "blink:resolve-by-flag-response":
439
+ return;
440
+ }
441
+ };
442
+ window.addEventListener("message", onMessage);
443
+ return {
444
+ detach() {
445
+ if (detached) return;
446
+ detached = true;
447
+ window.removeEventListener("message", onMessage);
448
+ unsubscribeFromDiscoverer();
449
+ unsubscribeAll();
450
+ }
451
+ };
452
+ }
453
+ function noopLog() {
454
+ }
455
+ function resolveByFlag(snapshot, flags, log) {
456
+ for (const flag of flags) {
457
+ for (const entry of snapshot) {
458
+ let value;
459
+ try {
460
+ value = entry.provider[flag];
461
+ } catch (err) {
462
+ log("provider threw on flag read \u2014 skipping", {
463
+ rdns: entry.info.rdns,
464
+ flag,
465
+ error: err instanceof Error ? err.message : String(err)
466
+ });
467
+ continue;
468
+ }
469
+ if (value) {
470
+ return { rdns: entry.info.rdns, uuid: entry.info.uuid, flag };
471
+ }
472
+ }
473
+ }
474
+ return null;
475
+ }
476
+ function normalizeProviderError(err) {
477
+ if (err && typeof err === "object") {
478
+ const e = err;
479
+ const code = typeof e.code === "number" ? e.code : -32603;
480
+ const message = typeof e.message === "string" ? e.message : err instanceof Error ? err.message : "Provider error";
481
+ const data = "data" in e ? e.data : void 0;
482
+ return data === void 0 ? { code, message } : { code, message, data };
483
+ }
484
+ return { code: -32603, message: typeof err === "string" ? err : "Provider error" };
485
+ }
486
+
105
487
  // src/iframe.ts
106
488
  var STYLE_ID = "blink-deposit-styles";
107
489
  var CLOSE_DURATION_MS = 280;
490
+ var MOBILE_SHEET_MAX_VIEWPORT_PX = 640;
491
+ var MOBILE_SHEET_MAX_SCREEN_PX = 900;
108
492
  var STYLES = `
109
493
  @keyframes blink-fade-in{from{opacity:0}to{opacity:1}}
110
494
  @keyframes blink-fade-out{from{opacity:1}to{opacity:0}}
@@ -113,12 +497,13 @@ var STYLES = `
113
497
  @keyframes blink-slide-down-full{from{transform:translateY(0)}to{transform:translateY(100%)}}
114
498
  [data-blink-overlay]{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:2147483647;animation:blink-fade-in .2s ease-out;backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
115
499
  [data-blink-overlay][data-blink-closing]{animation:blink-fade-out ${CLOSE_DURATION_MS}ms ease-in forwards;pointer-events:none}
116
- [data-blink-container]{width:min(440px,90vw);height:min(600px,85vh);border-radius:20px;overflow:hidden;box-shadow:0 24px 80px rgba(0,0,0,.4);animation:blink-slide-up .25s ease-out;display:flex;flex-direction:column;background:#f9fdff}
500
+ [data-blink-overlay][data-blink-mobile-sheet]{align-items:flex-end;touch-action:none;overscroll-behavior:contain}
501
+ [data-blink-container]{width:min(420px,92vw);height:min(600px,85vh);border-radius:24px;overflow:hidden;box-shadow:0 24px 80px rgba(0,0,0,.4);animation:blink-slide-up .25s ease-out;display:flex;flex-direction:column;background:transparent}
117
502
  [data-blink-overlay][data-blink-closing] [data-blink-container]{opacity:0;transition:opacity ${CLOSE_DURATION_MS}ms ease-in}
118
- [data-blink-handle]{display:none;justify-content:center;padding:10px 0 2px;background:#f9fdff;flex-shrink:0}
119
- [data-blink-handle]::after{content:'';width:36px;height:4px;border-radius:2px;background:#d1d5db}
120
- [data-blink-container] iframe{width:100%;flex:1;border:none;display:block;background:#f9fdff}
121
- @media(max-width:480px){[data-blink-overlay]{align-items:flex-end;touch-action:none;overscroll-behavior:contain}[data-blink-container]{width:100%;max-width:100%;height:66vh;border-radius:20px 20px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);animation:blink-slide-up-full .35s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom,0px)}[data-blink-overlay][data-blink-closing] [data-blink-container]{opacity:1;animation:blink-slide-down-full ${CLOSE_DURATION_MS}ms ease-in forwards}[data-blink-handle]{display:flex}}
503
+ [data-blink-container] iframe{width:100%;flex:1;border:none;display:block;background:transparent;color-scheme:normal;border-radius:inherit}
504
+ [data-blink-overlay][data-blink-mobile-sheet] [data-blink-container]{width:100%;max-width:100%;height:79vh;border-radius:24px 24px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);animation:blink-slide-up-full .35s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom,0px)}
505
+ [data-blink-overlay][data-blink-mobile-sheet][data-blink-closing] [data-blink-container]{opacity:1;animation:blink-slide-down-full ${CLOSE_DURATION_MS}ms ease-in forwards}
506
+ @media(max-width:${MOBILE_SHEET_MAX_VIEWPORT_PX}px){[data-blink-overlay]{align-items:flex-end;touch-action:none;overscroll-behavior:contain}[data-blink-container]{width:100%;max-width:100%;height:79vh;border-radius:24px 24px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25);animation:blink-slide-up-full .35s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom,0px)}[data-blink-overlay][data-blink-closing] [data-blink-container]{opacity:1;animation:blink-slide-down-full ${CLOSE_DURATION_MS}ms ease-in forwards}}
122
507
  `;
123
508
  function createIframe(url, containerElement) {
124
509
  ensureStyles();
@@ -126,19 +511,34 @@ function createIframe(url, containerElement) {
126
511
  let closeCallback = null;
127
512
  const overlay = document.createElement("div");
128
513
  overlay.setAttribute("data-blink-overlay", "");
514
+ if (shouldUseMobileSheetLayout()) {
515
+ overlay.setAttribute("data-blink-mobile-sheet", "");
516
+ }
129
517
  const container = document.createElement("div");
130
518
  container.setAttribute("data-blink-container", "");
131
519
  const iframe = document.createElement("iframe");
132
520
  iframe.src = url;
133
521
  const iframeOrigin = new URL(url).origin;
134
- iframe.allow = `publickey-credentials-get ${iframeOrigin}; publickey-credentials-create ${iframeOrigin}`;
522
+ iframe.allow = `publickey-credentials-get ${iframeOrigin}; publickey-credentials-create ${iframeOrigin}; clipboard-write ${iframeOrigin}`;
135
523
  const handle = document.createElement("div");
136
- handle.setAttribute("data-blink-handle", "");
137
524
  container.appendChild(handle);
138
525
  container.appendChild(iframe);
139
526
  overlay.appendChild(container);
140
527
  const mountTarget = containerElement ?? document.body;
141
528
  mountTarget.appendChild(overlay);
529
+ const discoverer = createWalletDiscoverer();
530
+ let rpcHostHandle = null;
531
+ const attachBridge = () => {
532
+ if (rpcHostHandle) return;
533
+ if (!iframe.contentWindow) return;
534
+ rpcHostHandle = attachRpcHost({
535
+ iframeWindow: iframe.contentWindow,
536
+ iframeOrigin,
537
+ discoverer
538
+ });
539
+ };
540
+ attachBridge();
541
+ iframe.addEventListener("load", attachBridge);
142
542
  const savedOverflow = document.body.style.overflow;
143
543
  document.body.style.overflow = "hidden";
144
544
  const onBackdropClick = (event) => {
@@ -165,6 +565,7 @@ function createIframe(url, containerElement) {
165
565
  if (closed) return;
166
566
  closed = true;
167
567
  removeListeners();
568
+ detachBridge();
168
569
  overlay.setAttribute("data-blink-closing", "");
169
570
  let removed = false;
170
571
  const removeOverlay = () => {
@@ -177,6 +578,14 @@ function createIframe(url, containerElement) {
177
578
  container.addEventListener("animationend", removeOverlay, { once: true });
178
579
  setTimeout(removeOverlay, CLOSE_DURATION_MS + 50);
179
580
  }
581
+ function detachBridge() {
582
+ iframe.removeEventListener("load", attachBridge);
583
+ if (rpcHostHandle) {
584
+ rpcHostHandle.detach();
585
+ rpcHostHandle = null;
586
+ }
587
+ discoverer.destroy();
588
+ }
180
589
  return {
181
590
  get contentWindow() {
182
591
  return iframe.contentWindow;
@@ -195,6 +604,7 @@ function createIframe(url, containerElement) {
195
604
  if (!closed) {
196
605
  closed = true;
197
606
  removeListeners();
607
+ detachBridge();
198
608
  overlay.remove();
199
609
  unlockScroll();
200
610
  }
@@ -202,12 +612,34 @@ function createIframe(url, containerElement) {
202
612
  };
203
613
  }
204
614
  function ensureStyles() {
205
- if (document.getElementById(STYLE_ID)) return;
615
+ const existingStyle = document.getElementById(STYLE_ID);
616
+ if (existingStyle) {
617
+ if (existingStyle.textContent !== STYLES) {
618
+ existingStyle.textContent = STYLES;
619
+ }
620
+ return;
621
+ }
206
622
  const style = document.createElement("style");
207
623
  style.id = STYLE_ID;
208
624
  style.textContent = STYLES;
209
625
  document.head.appendChild(style);
210
626
  }
627
+ function shouldUseMobileSheetLayout() {
628
+ if (typeof window === "undefined") return false;
629
+ if (window.matchMedia?.(`(max-width: ${MOBILE_SHEET_MAX_VIEWPORT_PX}px)`).matches) {
630
+ return true;
631
+ }
632
+ const viewportWidth = window.visualViewport?.width ?? window.innerWidth;
633
+ if (viewportWidth > 0 && viewportWidth <= MOBILE_SHEET_MAX_VIEWPORT_PX) {
634
+ return true;
635
+ }
636
+ const hasCoarsePointer = window.matchMedia?.("(pointer: coarse)").matches ?? false;
637
+ if (!hasCoarsePointer) {
638
+ return false;
639
+ }
640
+ const shortestScreenSide = Math.min(window.screen.width, window.screen.height);
641
+ return shortestScreenSide > 0 && shortestScreenSide <= MOBILE_SHEET_MAX_SCREEN_PX;
642
+ }
211
643
 
212
644
  // src/signer.ts
213
645
  var DEFAULT_SIGNER_TIMEOUT_MS = 15e3;
@@ -295,8 +727,10 @@ function isValidTokenAddress(value) {
295
727
  return TOKEN_ADDRESS_RE.test(value) || SOLANA_ADDRESS_RE.test(value);
296
728
  }
297
729
  function validateDepositRequest(request) {
298
- if (!Number.isFinite(request.amount) || request.amount <= 0) {
299
- throw new DepositError("INVALID_REQUEST", "amount must be a positive number.");
730
+ if (request.amount !== null) {
731
+ if (typeof request.amount !== "number" || !Number.isFinite(request.amount) || request.amount <= 0) {
732
+ throw new DepositError("INVALID_REQUEST", "amount must be a positive number or null.");
733
+ }
300
734
  }
301
735
  if (!Number.isInteger(request.chainId) || request.chainId <= 0) {
302
736
  throw new DepositError("INVALID_REQUEST", "chainId must be a positive integer.");
@@ -414,9 +848,7 @@ var Deposit = class {
414
848
  this.setStatus("completed");
415
849
  this.emit("complete", result);
416
850
  resolve(result);
417
- if (result.transfer.type !== "guest") {
418
- this.cleanup();
419
- }
851
+ this.cleanup();
420
852
  });
421
853
  };
422
854
  const onError = (error) => {