@swype-org/react-sdk 0.1.229 → 0.1.230

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/index.js CHANGED
@@ -155,304 +155,6 @@ function useBlinkDepositAmount() {
155
155
  };
156
156
  }
157
157
 
158
- // node_modules/@wagmi/core/dist/esm/utils/getAction.js
159
- function getAction(client, actionFn, name) {
160
- const action_implicit = client[actionFn.name];
161
- if (typeof action_implicit === "function")
162
- return action_implicit;
163
- const action_explicit = client[name];
164
- if (typeof action_explicit === "function")
165
- return action_explicit;
166
- return (params) => actionFn(client, params);
167
- }
168
-
169
- // node_modules/@wagmi/core/dist/esm/version.js
170
- var version = "2.22.1";
171
-
172
- // node_modules/@wagmi/core/dist/esm/utils/getVersion.js
173
- var getVersion = () => `@wagmi/core@${version}`;
174
-
175
- // node_modules/@wagmi/core/dist/esm/errors/base.js
176
- var __classPrivateFieldGet = function(receiver, state, kind, f) {
177
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
178
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
179
- };
180
- var _BaseError_instances;
181
- var _BaseError_walk;
182
- var BaseError = class _BaseError extends Error {
183
- get docsBaseUrl() {
184
- return "https://wagmi.sh/core";
185
- }
186
- get version() {
187
- return getVersion();
188
- }
189
- constructor(shortMessage, options = {}) {
190
- super();
191
- _BaseError_instances.add(this);
192
- Object.defineProperty(this, "details", {
193
- enumerable: true,
194
- configurable: true,
195
- writable: true,
196
- value: void 0
197
- });
198
- Object.defineProperty(this, "docsPath", {
199
- enumerable: true,
200
- configurable: true,
201
- writable: true,
202
- value: void 0
203
- });
204
- Object.defineProperty(this, "metaMessages", {
205
- enumerable: true,
206
- configurable: true,
207
- writable: true,
208
- value: void 0
209
- });
210
- Object.defineProperty(this, "shortMessage", {
211
- enumerable: true,
212
- configurable: true,
213
- writable: true,
214
- value: void 0
215
- });
216
- Object.defineProperty(this, "name", {
217
- enumerable: true,
218
- configurable: true,
219
- writable: true,
220
- value: "WagmiCoreError"
221
- });
222
- const details = options.cause instanceof _BaseError ? options.cause.details : options.cause?.message ? options.cause.message : options.details;
223
- const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
224
- this.message = [
225
- shortMessage || "An error occurred.",
226
- "",
227
- ...options.metaMessages ? [...options.metaMessages, ""] : [],
228
- ...docsPath ? [
229
- `Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
230
- ] : [],
231
- ...details ? [`Details: ${details}`] : [],
232
- `Version: ${this.version}`
233
- ].join("\n");
234
- if (options.cause)
235
- this.cause = options.cause;
236
- this.details = details;
237
- this.docsPath = docsPath;
238
- this.metaMessages = options.metaMessages;
239
- this.shortMessage = shortMessage;
240
- }
241
- walk(fn) {
242
- return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
243
- }
244
- };
245
- _BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
246
- if (fn?.(err))
247
- return err;
248
- if (err.cause)
249
- return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
250
- return err;
251
- };
252
-
253
- // node_modules/@wagmi/core/dist/esm/errors/config.js
254
- var ConnectorNotConnectedError = class extends BaseError {
255
- constructor() {
256
- super("Connector not connected.");
257
- Object.defineProperty(this, "name", {
258
- enumerable: true,
259
- configurable: true,
260
- writable: true,
261
- value: "ConnectorNotConnectedError"
262
- });
263
- }
264
- };
265
- var ConnectorAccountNotFoundError = class extends BaseError {
266
- constructor({ address, connector }) {
267
- super(`Account "${address}" not found for connector "${connector.name}".`);
268
- Object.defineProperty(this, "name", {
269
- enumerable: true,
270
- configurable: true,
271
- writable: true,
272
- value: "ConnectorAccountNotFoundError"
273
- });
274
- }
275
- };
276
- var ConnectorChainMismatchError = class extends BaseError {
277
- constructor({ connectionChainId, connectorChainId }) {
278
- super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
279
- metaMessages: [
280
- `Current Chain ID: ${connectorChainId}`,
281
- `Expected Chain ID: ${connectionChainId}`
282
- ]
283
- });
284
- Object.defineProperty(this, "name", {
285
- enumerable: true,
286
- configurable: true,
287
- writable: true,
288
- value: "ConnectorChainMismatchError"
289
- });
290
- }
291
- };
292
- var ConnectorUnavailableReconnectingError = class extends BaseError {
293
- constructor({ connector }) {
294
- super(`Connector "${connector.name}" unavailable while reconnecting.`, {
295
- details: [
296
- "During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
297
- "All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
298
- "This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
299
- ].join(" ")
300
- });
301
- Object.defineProperty(this, "name", {
302
- enumerable: true,
303
- configurable: true,
304
- writable: true,
305
- value: "ConnectorUnavailableReconnectingError"
306
- });
307
- }
308
- };
309
- async function getConnectorClient(config, parameters = {}) {
310
- const { assertChainId = true } = parameters;
311
- let connection;
312
- if (parameters.connector) {
313
- const { connector: connector2 } = parameters;
314
- if (config.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
315
- throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
316
- const [accounts, chainId2] = await Promise.all([
317
- connector2.getAccounts().catch((e) => {
318
- if (parameters.account === null)
319
- return [];
320
- throw e;
321
- }),
322
- connector2.getChainId()
323
- ]);
324
- connection = {
325
- accounts,
326
- chainId: chainId2,
327
- connector: connector2
328
- };
329
- } else
330
- connection = config.state.connections.get(config.state.current);
331
- if (!connection)
332
- throw new ConnectorNotConnectedError();
333
- const chainId = parameters.chainId ?? connection.chainId;
334
- const connectorChainId = await connection.connector.getChainId();
335
- if (assertChainId && connectorChainId !== chainId)
336
- throw new ConnectorChainMismatchError({
337
- connectionChainId: chainId,
338
- connectorChainId
339
- });
340
- const connector = connection.connector;
341
- if (connector.getClient)
342
- return connector.getClient({ chainId });
343
- const account = parseAccount(parameters.account ?? connection.accounts[0]);
344
- if (account)
345
- account.address = getAddress(account.address);
346
- if (parameters.account && !connection.accounts.some((x) => x.toLowerCase() === account.address.toLowerCase()))
347
- throw new ConnectorAccountNotFoundError({
348
- address: account.address,
349
- connector
350
- });
351
- const chain = config.chains.find((chain2) => chain2.id === chainId);
352
- const provider = await connection.connector.getProvider({ chainId });
353
- return createClient({
354
- account,
355
- chain,
356
- name: "Connector Client",
357
- transport: (opts) => custom(provider)({ ...opts, retryCount: 0 })
358
- });
359
- }
360
-
361
- // node_modules/@wagmi/core/dist/esm/actions/getAccount.js
362
- function getAccount(config) {
363
- const uid = config.state.current;
364
- const connection = config.state.connections.get(uid);
365
- const addresses = connection?.accounts;
366
- const address = addresses?.[0];
367
- const chain = config.chains.find((chain2) => chain2.id === connection?.chainId);
368
- const status = config.state.status;
369
- switch (status) {
370
- case "connected":
371
- return {
372
- address,
373
- addresses,
374
- chain,
375
- chainId: connection?.chainId,
376
- connector: connection?.connector,
377
- isConnected: true,
378
- isConnecting: false,
379
- isDisconnected: false,
380
- isReconnecting: false,
381
- status
382
- };
383
- case "reconnecting":
384
- return {
385
- address,
386
- addresses,
387
- chain,
388
- chainId: connection?.chainId,
389
- connector: connection?.connector,
390
- isConnected: !!address,
391
- isConnecting: false,
392
- isDisconnected: false,
393
- isReconnecting: true,
394
- status
395
- };
396
- case "connecting":
397
- return {
398
- address,
399
- addresses,
400
- chain,
401
- chainId: connection?.chainId,
402
- connector: connection?.connector,
403
- isConnected: false,
404
- isConnecting: true,
405
- isDisconnected: false,
406
- isReconnecting: false,
407
- status
408
- };
409
- case "disconnected":
410
- return {
411
- address: void 0,
412
- addresses: void 0,
413
- chain: void 0,
414
- chainId: void 0,
415
- connector: void 0,
416
- isConnected: false,
417
- isConnecting: false,
418
- isDisconnected: true,
419
- isReconnecting: false,
420
- status
421
- };
422
- }
423
- }
424
- async function getWalletClient(config, parameters = {}) {
425
- const client = await getConnectorClient(config, parameters);
426
- return client.extend(walletActions);
427
- }
428
- async function waitForTransactionReceipt(config, parameters) {
429
- const { chainId, timeout = 0, ...rest } = parameters;
430
- const client = config.getClient({ chainId });
431
- const action = getAction(client, waitForTransactionReceipt$1, "waitForTransactionReceipt");
432
- const receipt = await action({ ...rest, timeout });
433
- if (receipt.status === "reverted") {
434
- const action_getTransaction = getAction(client, getTransaction, "getTransaction");
435
- const { from: account, ...txn } = await action_getTransaction({
436
- hash: receipt.transactionHash
437
- });
438
- const action_call = getAction(client, call, "call");
439
- const code = await action_call({
440
- ...txn,
441
- account,
442
- data: txn.input,
443
- gasPrice: txn.type !== "eip1559" ? txn.gasPrice : void 0,
444
- maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
445
- maxPriorityFeePerGas: txn.type === "eip1559" ? txn.maxPriorityFeePerGas : void 0
446
- });
447
- const reason = code?.data ? hexToString(`0x${code.data.substring(138)}`) : "unknown reason";
448
- throw new Error(reason);
449
- }
450
- return {
451
- ...receipt,
452
- chainId: client.chain.id
453
- };
454
- }
455
-
456
158
  // src/api.ts
457
159
  var api_exports = {};
458
160
  __export(api_exports, {
@@ -636,180 +338,478 @@ async function signTransfer(apiBaseUrl, token, transferId, signedUserOp, authori
636
338
  if (!res.ok) await throwApiError(res);
637
339
  return await res.json();
638
340
  }
639
- async function fetchAuthorizationSession(apiBaseUrl, sessionId) {
341
+ async function fetchAuthorizationSession(apiBaseUrl, sessionId) {
342
+ const res = await fetch(
343
+ `${apiBaseUrl}/v1/authorization-sessions/${sessionId}`
344
+ );
345
+ if (!res.ok) await throwApiError(res);
346
+ return await res.json();
347
+ }
348
+ async function registerPasskey(apiBaseUrl, token, credentialId, publicKey) {
349
+ const res = await fetch(`${apiBaseUrl}/v1/users/config/passkey`, {
350
+ method: "POST",
351
+ headers: {
352
+ "Content-Type": "application/json",
353
+ Authorization: `Bearer ${token}`
354
+ },
355
+ body: JSON.stringify({ credentialId, publicKey })
356
+ });
357
+ if (!res.ok) await throwApiError(res);
358
+ }
359
+ async function reportPasskeyActivity(apiBaseUrl, token, credentialId) {
360
+ const res = await fetch(`${apiBaseUrl}/v1/users/config/passkey`, {
361
+ method: "PATCH",
362
+ headers: {
363
+ "Content-Type": "application/json",
364
+ Authorization: `Bearer ${token}`
365
+ },
366
+ body: JSON.stringify({ credentialId })
367
+ });
368
+ if (!res.ok) await throwApiError(res);
369
+ }
370
+ async function fetchUserConfig(apiBaseUrl, token) {
371
+ const res = await fetch(`${apiBaseUrl}/v1/users/config`, {
372
+ headers: { Authorization: `Bearer ${token}` }
373
+ });
374
+ if (!res.ok) await throwApiError(res);
375
+ return await res.json();
376
+ }
377
+ async function updateUserConfig(apiBaseUrl, token, config) {
378
+ const res = await fetch(`${apiBaseUrl}/v1/users`, {
379
+ method: "PATCH",
380
+ headers: {
381
+ "Content-Type": "application/json",
382
+ Authorization: `Bearer ${token}`
383
+ },
384
+ body: JSON.stringify({ config })
385
+ });
386
+ if (!res.ok) await throwApiError(res);
387
+ }
388
+ async function updateUserConfigBySession(apiBaseUrl, sessionId, config) {
389
+ const res = await fetch(
390
+ `${apiBaseUrl}/v1/authorization-sessions/${sessionId}/user-config`,
391
+ {
392
+ method: "PATCH",
393
+ headers: { "Content-Type": "application/json" },
394
+ body: JSON.stringify({ config })
395
+ }
396
+ );
397
+ if (!res.ok) await throwApiError(res);
398
+ }
399
+ async function createGuestTransfer(apiBaseUrl, params) {
400
+ const body = {
401
+ id: params.id ?? crypto.randomUUID(),
402
+ type: "guest",
403
+ merchantAuthorization: params.merchantAuthorization,
404
+ destinations: params.destinations,
405
+ amount: {
406
+ amount: params.amount,
407
+ currency: params.currency ?? "USD"
408
+ },
409
+ providerId: params.providerId
410
+ };
411
+ const res = await fetch(`${apiBaseUrl}/v1/transfers`, {
412
+ method: "POST",
413
+ headers: { "Content-Type": "application/json" },
414
+ body: JSON.stringify(body)
415
+ });
416
+ if (!res.ok) await throwApiError(res);
417
+ return await res.json();
418
+ }
419
+ async function getTransferByGuestToken(apiBaseUrl, guestToken) {
420
+ const params = new URLSearchParams({ guestToken });
421
+ const res = await fetch(`${apiBaseUrl}/v1/transfers?${params.toString()}`);
422
+ if (!res.ok) await throwApiError(res);
423
+ return await res.json();
424
+ }
425
+ async function setTransferSender(apiBaseUrl, transferId, guestSessionToken, senderAddress, sourceChainId, sourceToken) {
426
+ const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}/sender`, {
427
+ method: "PUT",
428
+ headers: {
429
+ "Content-Type": "application/json",
430
+ "x-guest-session-token": guestSessionToken
431
+ },
432
+ body: JSON.stringify({ senderAddress, sourceChainId, sourceToken })
433
+ });
434
+ if (!res.ok) await throwApiError(res);
435
+ return await res.json();
436
+ }
437
+ async function signGuestTransfer(apiBaseUrl, transferId, guestSessionToken, originTxHash) {
438
+ const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
439
+ method: "PATCH",
440
+ headers: {
441
+ "Content-Type": "application/json",
442
+ "x-guest-session-token": guestSessionToken
443
+ },
444
+ body: JSON.stringify({ originTxHash })
445
+ });
446
+ if (!res.ok) await throwApiError(res);
447
+ return await res.json();
448
+ }
449
+ async function getGuestTransfer(apiBaseUrl, transferId, guestSessionToken) {
450
+ const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
451
+ headers: {
452
+ "x-guest-session-token": guestSessionToken
453
+ }
454
+ });
455
+ if (!res.ok) await throwApiError(res);
456
+ return await res.json();
457
+ }
458
+ async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionToken, walletAddress) {
459
+ const params = new URLSearchParams({ walletAddress });
640
460
  const res = await fetch(
641
- `${apiBaseUrl}/v1/authorization-sessions/${sessionId}`
461
+ `${apiBaseUrl}/v1/transfers/${transferId}/balances?${params.toString()}`,
462
+ {
463
+ headers: {
464
+ "x-guest-session-token": guestSessionToken
465
+ }
466
+ }
642
467
  );
643
468
  if (!res.ok) await throwApiError(res);
469
+ const data = await res.json();
470
+ return data.items;
471
+ }
472
+ async function fetchGuestAccount(apiBaseUrl, guestToken) {
473
+ const params = new URLSearchParams({ guestToken });
474
+ const res = await fetch(`${apiBaseUrl}/v1/accounts?${params.toString()}`);
475
+ if (res.status === 404) return null;
476
+ if (!res.ok) await throwApiError(res);
644
477
  return await res.json();
645
478
  }
646
- async function registerPasskey(apiBaseUrl, token, credentialId, publicKey) {
647
- const res = await fetch(`${apiBaseUrl}/v1/users/config/passkey`, {
479
+ async function createGuestAccount(apiBaseUrl, guestSessionToken, providerId, name) {
480
+ const res = await fetch(`${apiBaseUrl}/v1/accounts`, {
648
481
  method: "POST",
649
482
  headers: {
650
483
  "Content-Type": "application/json",
651
- Authorization: `Bearer ${token}`
484
+ "x-guest-session-token": guestSessionToken
652
485
  },
653
- body: JSON.stringify({ credentialId, publicKey })
486
+ body: JSON.stringify({ providerId, name })
654
487
  });
655
488
  if (!res.ok) await throwApiError(res);
489
+ return await res.json();
656
490
  }
657
- async function reportPasskeyActivity(apiBaseUrl, token, credentialId) {
658
- const res = await fetch(`${apiBaseUrl}/v1/users/config/passkey`, {
659
- method: "PATCH",
491
+ async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
492
+ const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
493
+ method: "PUT",
660
494
  headers: {
661
495
  "Content-Type": "application/json",
662
- Authorization: `Bearer ${token}`
496
+ "Authorization": `Bearer ${accessToken}`,
497
+ "x-guest-session-token": guestSessionToken
663
498
  },
664
- body: JSON.stringify({ credentialId })
499
+ body: JSON.stringify(body)
665
500
  });
666
501
  if (!res.ok) await throwApiError(res);
502
+ return await res.json();
667
503
  }
668
- async function fetchUserConfig(apiBaseUrl, token) {
669
- const res = await fetch(`${apiBaseUrl}/v1/users/config`, {
670
- headers: { Authorization: `Bearer ${token}` }
504
+ async function reportActionCompletion(apiBaseUrl, actionId, result) {
505
+ const res = await fetch(
506
+ `${apiBaseUrl}/v1/authorization-actions/${actionId}`,
507
+ {
508
+ method: "PATCH",
509
+ headers: { "Content-Type": "application/json" },
510
+ body: JSON.stringify({ status: "COMPLETED", result })
511
+ }
512
+ );
513
+ if (!res.ok) await throwApiError(res);
514
+ return await res.json();
515
+ }
516
+
517
+ // node_modules/@wagmi/core/dist/esm/utils/getAction.js
518
+ function getAction(client, actionFn, name) {
519
+ const action_implicit = client[actionFn.name];
520
+ if (typeof action_implicit === "function")
521
+ return action_implicit;
522
+ const action_explicit = client[name];
523
+ if (typeof action_explicit === "function")
524
+ return action_explicit;
525
+ return (params) => actionFn(client, params);
526
+ }
527
+
528
+ // node_modules/@wagmi/core/dist/esm/version.js
529
+ var version = "2.22.1";
530
+
531
+ // node_modules/@wagmi/core/dist/esm/utils/getVersion.js
532
+ var getVersion = () => `@wagmi/core@${version}`;
533
+
534
+ // node_modules/@wagmi/core/dist/esm/errors/base.js
535
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
536
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
537
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
538
+ };
539
+ var _BaseError_instances;
540
+ var _BaseError_walk;
541
+ var BaseError = class _BaseError extends Error {
542
+ get docsBaseUrl() {
543
+ return "https://wagmi.sh/core";
544
+ }
545
+ get version() {
546
+ return getVersion();
547
+ }
548
+ constructor(shortMessage, options = {}) {
549
+ super();
550
+ _BaseError_instances.add(this);
551
+ Object.defineProperty(this, "details", {
552
+ enumerable: true,
553
+ configurable: true,
554
+ writable: true,
555
+ value: void 0
556
+ });
557
+ Object.defineProperty(this, "docsPath", {
558
+ enumerable: true,
559
+ configurable: true,
560
+ writable: true,
561
+ value: void 0
562
+ });
563
+ Object.defineProperty(this, "metaMessages", {
564
+ enumerable: true,
565
+ configurable: true,
566
+ writable: true,
567
+ value: void 0
568
+ });
569
+ Object.defineProperty(this, "shortMessage", {
570
+ enumerable: true,
571
+ configurable: true,
572
+ writable: true,
573
+ value: void 0
574
+ });
575
+ Object.defineProperty(this, "name", {
576
+ enumerable: true,
577
+ configurable: true,
578
+ writable: true,
579
+ value: "WagmiCoreError"
580
+ });
581
+ const details = options.cause instanceof _BaseError ? options.cause.details : options.cause?.message ? options.cause.message : options.details;
582
+ const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
583
+ this.message = [
584
+ shortMessage || "An error occurred.",
585
+ "",
586
+ ...options.metaMessages ? [...options.metaMessages, ""] : [],
587
+ ...docsPath ? [
588
+ `Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
589
+ ] : [],
590
+ ...details ? [`Details: ${details}`] : [],
591
+ `Version: ${this.version}`
592
+ ].join("\n");
593
+ if (options.cause)
594
+ this.cause = options.cause;
595
+ this.details = details;
596
+ this.docsPath = docsPath;
597
+ this.metaMessages = options.metaMessages;
598
+ this.shortMessage = shortMessage;
599
+ }
600
+ walk(fn) {
601
+ return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
602
+ }
603
+ };
604
+ _BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
605
+ if (fn?.(err))
606
+ return err;
607
+ if (err.cause)
608
+ return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
609
+ return err;
610
+ };
611
+
612
+ // node_modules/@wagmi/core/dist/esm/errors/config.js
613
+ var ConnectorNotConnectedError = class extends BaseError {
614
+ constructor() {
615
+ super("Connector not connected.");
616
+ Object.defineProperty(this, "name", {
617
+ enumerable: true,
618
+ configurable: true,
619
+ writable: true,
620
+ value: "ConnectorNotConnectedError"
621
+ });
622
+ }
623
+ };
624
+ var ConnectorAccountNotFoundError = class extends BaseError {
625
+ constructor({ address, connector }) {
626
+ super(`Account "${address}" not found for connector "${connector.name}".`);
627
+ Object.defineProperty(this, "name", {
628
+ enumerable: true,
629
+ configurable: true,
630
+ writable: true,
631
+ value: "ConnectorAccountNotFoundError"
632
+ });
633
+ }
634
+ };
635
+ var ConnectorChainMismatchError = class extends BaseError {
636
+ constructor({ connectionChainId, connectorChainId }) {
637
+ super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
638
+ metaMessages: [
639
+ `Current Chain ID: ${connectorChainId}`,
640
+ `Expected Chain ID: ${connectionChainId}`
641
+ ]
642
+ });
643
+ Object.defineProperty(this, "name", {
644
+ enumerable: true,
645
+ configurable: true,
646
+ writable: true,
647
+ value: "ConnectorChainMismatchError"
648
+ });
649
+ }
650
+ };
651
+ var ConnectorUnavailableReconnectingError = class extends BaseError {
652
+ constructor({ connector }) {
653
+ super(`Connector "${connector.name}" unavailable while reconnecting.`, {
654
+ details: [
655
+ "During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
656
+ "All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
657
+ "This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
658
+ ].join(" ")
659
+ });
660
+ Object.defineProperty(this, "name", {
661
+ enumerable: true,
662
+ configurable: true,
663
+ writable: true,
664
+ value: "ConnectorUnavailableReconnectingError"
665
+ });
666
+ }
667
+ };
668
+ async function getConnectorClient(config, parameters = {}) {
669
+ const { assertChainId = true } = parameters;
670
+ let connection;
671
+ if (parameters.connector) {
672
+ const { connector: connector2 } = parameters;
673
+ if (config.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
674
+ throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
675
+ const [accounts, chainId2] = await Promise.all([
676
+ connector2.getAccounts().catch((e) => {
677
+ if (parameters.account === null)
678
+ return [];
679
+ throw e;
680
+ }),
681
+ connector2.getChainId()
682
+ ]);
683
+ connection = {
684
+ accounts,
685
+ chainId: chainId2,
686
+ connector: connector2
687
+ };
688
+ } else
689
+ connection = config.state.connections.get(config.state.current);
690
+ if (!connection)
691
+ throw new ConnectorNotConnectedError();
692
+ const chainId = parameters.chainId ?? connection.chainId;
693
+ const connectorChainId = await connection.connector.getChainId();
694
+ if (assertChainId && connectorChainId !== chainId)
695
+ throw new ConnectorChainMismatchError({
696
+ connectionChainId: chainId,
697
+ connectorChainId
698
+ });
699
+ const connector = connection.connector;
700
+ if (connector.getClient)
701
+ return connector.getClient({ chainId });
702
+ const account = parseAccount(parameters.account ?? connection.accounts[0]);
703
+ if (account)
704
+ account.address = getAddress(account.address);
705
+ if (parameters.account && !connection.accounts.some((x) => x.toLowerCase() === account.address.toLowerCase()))
706
+ throw new ConnectorAccountNotFoundError({
707
+ address: account.address,
708
+ connector
709
+ });
710
+ const chain = config.chains.find((chain2) => chain2.id === chainId);
711
+ const provider = await connection.connector.getProvider({ chainId });
712
+ return createClient({
713
+ account,
714
+ chain,
715
+ name: "Connector Client",
716
+ transport: (opts) => custom(provider)({ ...opts, retryCount: 0 })
671
717
  });
672
- if (!res.ok) await throwApiError(res);
673
- return await res.json();
674
718
  }
675
- async function updateUserConfig(apiBaseUrl, token, config) {
676
- const res = await fetch(`${apiBaseUrl}/v1/users`, {
677
- method: "PATCH",
678
- headers: {
679
- "Content-Type": "application/json",
680
- Authorization: `Bearer ${token}`
681
- },
682
- body: JSON.stringify({ config })
683
- });
684
- if (!res.ok) await throwApiError(res);
719
+
720
+ // node_modules/@wagmi/core/dist/esm/actions/getAccount.js
721
+ function getAccount(config) {
722
+ const uid = config.state.current;
723
+ const connection = config.state.connections.get(uid);
724
+ const addresses = connection?.accounts;
725
+ const address = addresses?.[0];
726
+ const chain = config.chains.find((chain2) => chain2.id === connection?.chainId);
727
+ const status = config.state.status;
728
+ switch (status) {
729
+ case "connected":
730
+ return {
731
+ address,
732
+ addresses,
733
+ chain,
734
+ chainId: connection?.chainId,
735
+ connector: connection?.connector,
736
+ isConnected: true,
737
+ isConnecting: false,
738
+ isDisconnected: false,
739
+ isReconnecting: false,
740
+ status
741
+ };
742
+ case "reconnecting":
743
+ return {
744
+ address,
745
+ addresses,
746
+ chain,
747
+ chainId: connection?.chainId,
748
+ connector: connection?.connector,
749
+ isConnected: !!address,
750
+ isConnecting: false,
751
+ isDisconnected: false,
752
+ isReconnecting: true,
753
+ status
754
+ };
755
+ case "connecting":
756
+ return {
757
+ address,
758
+ addresses,
759
+ chain,
760
+ chainId: connection?.chainId,
761
+ connector: connection?.connector,
762
+ isConnected: false,
763
+ isConnecting: true,
764
+ isDisconnected: false,
765
+ isReconnecting: false,
766
+ status
767
+ };
768
+ case "disconnected":
769
+ return {
770
+ address: void 0,
771
+ addresses: void 0,
772
+ chain: void 0,
773
+ chainId: void 0,
774
+ connector: void 0,
775
+ isConnected: false,
776
+ isConnecting: false,
777
+ isDisconnected: true,
778
+ isReconnecting: false,
779
+ status
780
+ };
781
+ }
685
782
  }
686
- async function updateUserConfigBySession(apiBaseUrl, sessionId, config) {
687
- const res = await fetch(
688
- `${apiBaseUrl}/v1/authorization-sessions/${sessionId}/user-config`,
689
- {
690
- method: "PATCH",
691
- headers: { "Content-Type": "application/json" },
692
- body: JSON.stringify({ config })
693
- }
694
- );
695
- if (!res.ok) await throwApiError(res);
783
+ async function getWalletClient(config, parameters = {}) {
784
+ const client = await getConnectorClient(config, parameters);
785
+ return client.extend(walletActions);
696
786
  }
697
- async function createGuestTransfer(apiBaseUrl, params) {
698
- const body = {
699
- id: params.id ?? crypto.randomUUID(),
700
- type: "guest",
701
- merchantAuthorization: params.merchantAuthorization,
702
- destinations: params.destinations,
703
- amount: {
704
- amount: params.amount,
705
- currency: params.currency ?? "USD"
706
- },
707
- providerId: params.providerId
787
+ async function waitForTransactionReceipt(config, parameters) {
788
+ const { chainId, timeout = 0, ...rest } = parameters;
789
+ const client = config.getClient({ chainId });
790
+ const action = getAction(client, waitForTransactionReceipt$1, "waitForTransactionReceipt");
791
+ const receipt = await action({ ...rest, timeout });
792
+ if (receipt.status === "reverted") {
793
+ const action_getTransaction = getAction(client, getTransaction, "getTransaction");
794
+ const { from: account, ...txn } = await action_getTransaction({
795
+ hash: receipt.transactionHash
796
+ });
797
+ const action_call = getAction(client, call, "call");
798
+ const code = await action_call({
799
+ ...txn,
800
+ account,
801
+ data: txn.input,
802
+ gasPrice: txn.type !== "eip1559" ? txn.gasPrice : void 0,
803
+ maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
804
+ maxPriorityFeePerGas: txn.type === "eip1559" ? txn.maxPriorityFeePerGas : void 0
805
+ });
806
+ const reason = code?.data ? hexToString(`0x${code.data.substring(138)}`) : "unknown reason";
807
+ throw new Error(reason);
808
+ }
809
+ return {
810
+ ...receipt,
811
+ chainId: client.chain.id
708
812
  };
709
- const res = await fetch(`${apiBaseUrl}/v1/transfers`, {
710
- method: "POST",
711
- headers: { "Content-Type": "application/json" },
712
- body: JSON.stringify(body)
713
- });
714
- if (!res.ok) await throwApiError(res);
715
- return await res.json();
716
- }
717
- async function getTransferByGuestToken(apiBaseUrl, guestToken) {
718
- const params = new URLSearchParams({ guestToken });
719
- const res = await fetch(`${apiBaseUrl}/v1/transfers?${params.toString()}`);
720
- if (!res.ok) await throwApiError(res);
721
- return await res.json();
722
- }
723
- async function setTransferSender(apiBaseUrl, transferId, guestSessionToken, senderAddress, sourceChainId, sourceToken) {
724
- const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}/sender`, {
725
- method: "PUT",
726
- headers: {
727
- "Content-Type": "application/json",
728
- "x-guest-session-token": guestSessionToken
729
- },
730
- body: JSON.stringify({ senderAddress, sourceChainId, sourceToken })
731
- });
732
- if (!res.ok) await throwApiError(res);
733
- return await res.json();
734
- }
735
- async function signGuestTransfer(apiBaseUrl, transferId, guestSessionToken, originTxHash) {
736
- const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
737
- method: "PATCH",
738
- headers: {
739
- "Content-Type": "application/json",
740
- "x-guest-session-token": guestSessionToken
741
- },
742
- body: JSON.stringify({ originTxHash })
743
- });
744
- if (!res.ok) await throwApiError(res);
745
- return await res.json();
746
- }
747
- async function getGuestTransfer(apiBaseUrl, transferId, guestSessionToken) {
748
- const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
749
- headers: {
750
- "x-guest-session-token": guestSessionToken
751
- }
752
- });
753
- if (!res.ok) await throwApiError(res);
754
- return await res.json();
755
- }
756
- async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionToken, walletAddress) {
757
- const params = new URLSearchParams({ walletAddress });
758
- const res = await fetch(
759
- `${apiBaseUrl}/v1/transfers/${transferId}/balances?${params.toString()}`,
760
- {
761
- headers: {
762
- "x-guest-session-token": guestSessionToken
763
- }
764
- }
765
- );
766
- if (!res.ok) await throwApiError(res);
767
- const data = await res.json();
768
- return data.items;
769
- }
770
- async function fetchGuestAccount(apiBaseUrl, guestToken) {
771
- const params = new URLSearchParams({ guestToken });
772
- const res = await fetch(`${apiBaseUrl}/v1/accounts?${params.toString()}`);
773
- if (res.status === 404) return null;
774
- if (!res.ok) await throwApiError(res);
775
- return await res.json();
776
- }
777
- async function createGuestAccount(apiBaseUrl, guestSessionToken, providerId, name) {
778
- const res = await fetch(`${apiBaseUrl}/v1/accounts`, {
779
- method: "POST",
780
- headers: {
781
- "Content-Type": "application/json",
782
- "x-guest-session-token": guestSessionToken
783
- },
784
- body: JSON.stringify({ providerId, name })
785
- });
786
- if (!res.ok) await throwApiError(res);
787
- return await res.json();
788
- }
789
- async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
790
- const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
791
- method: "PUT",
792
- headers: {
793
- "Content-Type": "application/json",
794
- "Authorization": `Bearer ${accessToken}`,
795
- "x-guest-session-token": guestSessionToken
796
- },
797
- body: JSON.stringify(body)
798
- });
799
- if (!res.ok) await throwApiError(res);
800
- return await res.json();
801
- }
802
- async function reportActionCompletion(apiBaseUrl, actionId, result) {
803
- const res = await fetch(
804
- `${apiBaseUrl}/v1/authorization-actions/${actionId}`,
805
- {
806
- method: "PATCH",
807
- headers: { "Content-Type": "application/json" },
808
- body: JSON.stringify({ status: "COMPLETED", result })
809
- }
810
- );
811
- if (!res.ok) await throwApiError(res);
812
- return await res.json();
813
813
  }
814
814
 
815
815
  // src/passkeyRpId.ts
@@ -8256,40 +8256,21 @@ function usePaymentEffects(deps) {
8256
8256
  if (state.guestPreauthAccountId) return;
8257
8257
  if (!state.transfer || state.transfer.status !== "COMPLETED") return;
8258
8258
  let cancelled = false;
8259
- const ensureGuestAccount = async () => {
8259
+ const checkGuestAccount = async () => {
8260
8260
  try {
8261
- let result = await fetchGuestAccount(apiBaseUrl, state.guestSessionToken);
8261
+ const result = await fetchGuestAccount(apiBaseUrl, state.guestSessionToken);
8262
8262
  if (cancelled) return;
8263
- if (!result && state.selectedProviderId) {
8264
- const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? "Wallet";
8265
- const created = await createGuestAccount(
8266
- apiBaseUrl,
8267
- state.guestSessionToken,
8268
- state.selectedProviderId,
8269
- providerName
8270
- );
8271
- if (cancelled) return;
8272
- result = { accountId: created.accountId, hasPasskey: false, walletAddress: null };
8273
- }
8274
8263
  if (result && !result.hasPasskey) {
8275
8264
  dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: result.accountId });
8276
8265
  }
8277
8266
  } catch {
8278
8267
  }
8279
8268
  };
8280
- ensureGuestAccount();
8269
+ checkGuestAccount();
8281
8270
  return () => {
8282
8271
  cancelled = true;
8283
8272
  };
8284
- }, [
8285
- state.transfer,
8286
- state.guestSessionToken,
8287
- state.guestPreauthAccountId,
8288
- state.selectedProviderId,
8289
- state.providers,
8290
- apiBaseUrl,
8291
- dispatch
8292
- ]);
8273
+ }, [state.transfer, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8293
8274
  const settingOwnerRef = useRef(false);
8294
8275
  useEffect(() => {
8295
8276
  if (!state.guestPreauthAccountId) return;
@@ -8581,7 +8562,29 @@ function BlinkPaymentInner({
8581
8562
  onAuthorizeToken: provider.handleAuthorizeToken,
8582
8563
  onSelectGuestToken: guestTransfer.handleSelectGuestToken,
8583
8564
  onLogin: () => dispatch({ type: "REQUEST_LOGIN" }),
8584
- onPreauthorize: () => dispatch({ type: "REQUEST_LOGIN" })
8565
+ onPreauthorize: async () => {
8566
+ if (state.guestPreauthAccountId) {
8567
+ dispatch({ type: "REQUEST_LOGIN" });
8568
+ return;
8569
+ }
8570
+ if (!state.guestSessionToken || !state.selectedProviderId) {
8571
+ dispatch({ type: "REQUEST_LOGIN" });
8572
+ return;
8573
+ }
8574
+ try {
8575
+ const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? "Wallet";
8576
+ const created = await createGuestAccount(
8577
+ apiBaseUrl,
8578
+ state.guestSessionToken,
8579
+ state.selectedProviderId,
8580
+ providerName
8581
+ );
8582
+ dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: created.accountId });
8583
+ dispatch({ type: "REQUEST_LOGIN" });
8584
+ } catch {
8585
+ dispatch({ type: "REQUEST_LOGIN" });
8586
+ }
8587
+ }
8585
8588
  }), [
8586
8589
  auth,
8587
8590
  passkey,
@@ -8592,7 +8595,12 @@ function BlinkPaymentInner({
8592
8595
  oneTapSetup,
8593
8596
  guestTransfer,
8594
8597
  handleLogout,
8595
- handleNewPayment
8598
+ handleNewPayment,
8599
+ state.guestPreauthAccountId,
8600
+ state.guestSessionToken,
8601
+ state.selectedProviderId,
8602
+ state.providers,
8603
+ apiBaseUrl
8596
8604
  ]);
8597
8605
  return /* @__PURE__ */ jsx(
8598
8606
  StepRenderer,