@swype-org/react-sdk 0.1.228 → 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.cjs +502 -461
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +502 -461
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -155,316 +155,19 @@ 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, {
|
|
459
161
|
createAccount: () => createAccount,
|
|
460
162
|
createAccountAuthorizationSession: () => createAccountAuthorizationSession,
|
|
163
|
+
createGuestAccount: () => createGuestAccount,
|
|
461
164
|
createGuestTransfer: () => createGuestTransfer,
|
|
462
165
|
createTransfer: () => createTransfer,
|
|
463
166
|
fetchAccount: () => fetchAccount,
|
|
464
167
|
fetchAccounts: () => fetchAccounts,
|
|
465
168
|
fetchAuthorizationSession: () => fetchAuthorizationSession,
|
|
466
169
|
fetchChains: () => fetchChains,
|
|
467
|
-
|
|
170
|
+
fetchGuestAccount: () => fetchGuestAccount,
|
|
468
171
|
fetchGuestTransferBalances: () => fetchGuestTransferBalances,
|
|
469
172
|
fetchMerchantPublicKey: () => fetchMerchantPublicKey,
|
|
470
173
|
fetchProviders: () => fetchProviders,
|
|
@@ -606,197 +309,507 @@ async function fetchMerchantPublicKey(apiBaseUrl, merchantId) {
|
|
|
606
309
|
if (!res.ok) await throwApiError(res);
|
|
607
310
|
return await res.json();
|
|
608
311
|
}
|
|
609
|
-
async function fetchTransfer(apiBaseUrl, token, transferId, authorizationSessionToken) {
|
|
610
|
-
if (!token && !authorizationSessionToken) {
|
|
611
|
-
throw new Error("Missing auth credentials for transfer fetch.");
|
|
612
|
-
}
|
|
312
|
+
async function fetchTransfer(apiBaseUrl, token, transferId, authorizationSessionToken) {
|
|
313
|
+
if (!token && !authorizationSessionToken) {
|
|
314
|
+
throw new Error("Missing auth credentials for transfer fetch.");
|
|
315
|
+
}
|
|
316
|
+
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
317
|
+
headers: {
|
|
318
|
+
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
319
|
+
...authorizationSessionToken ? { "x-authorization-session-token": authorizationSessionToken } : {}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
if (!res.ok) await throwApiError(res);
|
|
323
|
+
return await res.json();
|
|
324
|
+
}
|
|
325
|
+
async function signTransfer(apiBaseUrl, token, transferId, signedUserOp, authorizationSessionToken) {
|
|
326
|
+
if (!token && !authorizationSessionToken) {
|
|
327
|
+
throw new Error("Missing auth credentials for transfer signing.");
|
|
328
|
+
}
|
|
329
|
+
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
330
|
+
method: "PATCH",
|
|
331
|
+
headers: {
|
|
332
|
+
"Content-Type": "application/json",
|
|
333
|
+
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
334
|
+
...authorizationSessionToken ? { "x-authorization-session-token": authorizationSessionToken } : {}
|
|
335
|
+
},
|
|
336
|
+
body: JSON.stringify({ signedUserOp })
|
|
337
|
+
});
|
|
338
|
+
if (!res.ok) await throwApiError(res);
|
|
339
|
+
return await res.json();
|
|
340
|
+
}
|
|
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) {
|
|
613
438
|
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
439
|
+
method: "PATCH",
|
|
614
440
|
headers: {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
441
|
+
"Content-Type": "application/json",
|
|
442
|
+
"x-guest-session-token": guestSessionToken
|
|
443
|
+
},
|
|
444
|
+
body: JSON.stringify({ originTxHash })
|
|
618
445
|
});
|
|
619
446
|
if (!res.ok) await throwApiError(res);
|
|
620
447
|
return await res.json();
|
|
621
448
|
}
|
|
622
|
-
async function
|
|
623
|
-
if (!token && !authorizationSessionToken) {
|
|
624
|
-
throw new Error("Missing auth credentials for transfer signing.");
|
|
625
|
-
}
|
|
449
|
+
async function getGuestTransfer(apiBaseUrl, transferId, guestSessionToken) {
|
|
626
450
|
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
627
|
-
method: "PATCH",
|
|
628
451
|
headers: {
|
|
629
|
-
"
|
|
630
|
-
|
|
631
|
-
...authorizationSessionToken ? { "x-authorization-session-token": authorizationSessionToken } : {}
|
|
632
|
-
},
|
|
633
|
-
body: JSON.stringify({ signedUserOp })
|
|
452
|
+
"x-guest-session-token": guestSessionToken
|
|
453
|
+
}
|
|
634
454
|
});
|
|
635
455
|
if (!res.ok) await throwApiError(res);
|
|
636
456
|
return await res.json();
|
|
637
457
|
}
|
|
638
|
-
async function
|
|
458
|
+
async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionToken, walletAddress) {
|
|
459
|
+
const params = new URLSearchParams({ walletAddress });
|
|
639
460
|
const res = await fetch(
|
|
640
|
-
`${apiBaseUrl}/v1/
|
|
461
|
+
`${apiBaseUrl}/v1/transfers/${transferId}/balances?${params.toString()}`,
|
|
462
|
+
{
|
|
463
|
+
headers: {
|
|
464
|
+
"x-guest-session-token": guestSessionToken
|
|
465
|
+
}
|
|
466
|
+
}
|
|
641
467
|
);
|
|
642
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);
|
|
643
477
|
return await res.json();
|
|
644
478
|
}
|
|
645
|
-
async function
|
|
646
|
-
const res = await fetch(`${apiBaseUrl}/v1/
|
|
479
|
+
async function createGuestAccount(apiBaseUrl, guestSessionToken, providerId, name) {
|
|
480
|
+
const res = await fetch(`${apiBaseUrl}/v1/accounts`, {
|
|
647
481
|
method: "POST",
|
|
648
482
|
headers: {
|
|
649
483
|
"Content-Type": "application/json",
|
|
650
|
-
|
|
484
|
+
"x-guest-session-token": guestSessionToken
|
|
651
485
|
},
|
|
652
|
-
body: JSON.stringify({
|
|
486
|
+
body: JSON.stringify({ providerId, name })
|
|
653
487
|
});
|
|
654
488
|
if (!res.ok) await throwApiError(res);
|
|
489
|
+
return await res.json();
|
|
655
490
|
}
|
|
656
|
-
async function
|
|
657
|
-
const res = await fetch(`${apiBaseUrl}/v1/
|
|
658
|
-
method: "
|
|
491
|
+
async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
|
|
492
|
+
const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
|
|
493
|
+
method: "PUT",
|
|
659
494
|
headers: {
|
|
660
495
|
"Content-Type": "application/json",
|
|
661
|
-
Authorization: `Bearer ${
|
|
496
|
+
"Authorization": `Bearer ${accessToken}`,
|
|
497
|
+
"x-guest-session-token": guestSessionToken
|
|
662
498
|
},
|
|
663
|
-
body: JSON.stringify(
|
|
499
|
+
body: JSON.stringify(body)
|
|
664
500
|
});
|
|
665
501
|
if (!res.ok) await throwApiError(res);
|
|
502
|
+
return await res.json();
|
|
666
503
|
}
|
|
667
|
-
async function
|
|
668
|
-
const res = await fetch(
|
|
669
|
-
|
|
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 })
|
|
670
717
|
});
|
|
671
|
-
if (!res.ok) await throwApiError(res);
|
|
672
|
-
return await res.json();
|
|
673
718
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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
|
+
}
|
|
684
782
|
}
|
|
685
|
-
async function
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
{
|
|
689
|
-
method: "PATCH",
|
|
690
|
-
headers: { "Content-Type": "application/json" },
|
|
691
|
-
body: JSON.stringify({ config })
|
|
692
|
-
}
|
|
693
|
-
);
|
|
694
|
-
if (!res.ok) await throwApiError(res);
|
|
783
|
+
async function getWalletClient(config, parameters = {}) {
|
|
784
|
+
const client = await getConnectorClient(config, parameters);
|
|
785
|
+
return client.extend(walletActions);
|
|
695
786
|
}
|
|
696
|
-
async function
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
|
|
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
|
|
707
812
|
};
|
|
708
|
-
const res = await fetch(`${apiBaseUrl}/v1/transfers`, {
|
|
709
|
-
method: "POST",
|
|
710
|
-
headers: { "Content-Type": "application/json" },
|
|
711
|
-
body: JSON.stringify(body)
|
|
712
|
-
});
|
|
713
|
-
if (!res.ok) await throwApiError(res);
|
|
714
|
-
return await res.json();
|
|
715
|
-
}
|
|
716
|
-
async function getTransferByGuestToken(apiBaseUrl, guestToken) {
|
|
717
|
-
const params = new URLSearchParams({ guestToken });
|
|
718
|
-
const res = await fetch(`${apiBaseUrl}/v1/transfers?${params.toString()}`);
|
|
719
|
-
if (!res.ok) await throwApiError(res);
|
|
720
|
-
return await res.json();
|
|
721
|
-
}
|
|
722
|
-
async function setTransferSender(apiBaseUrl, transferId, guestSessionToken, senderAddress, sourceChainId, sourceToken) {
|
|
723
|
-
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}/sender`, {
|
|
724
|
-
method: "PUT",
|
|
725
|
-
headers: {
|
|
726
|
-
"Content-Type": "application/json",
|
|
727
|
-
"x-guest-session-token": guestSessionToken
|
|
728
|
-
},
|
|
729
|
-
body: JSON.stringify({ senderAddress, sourceChainId, sourceToken })
|
|
730
|
-
});
|
|
731
|
-
if (!res.ok) await throwApiError(res);
|
|
732
|
-
return await res.json();
|
|
733
|
-
}
|
|
734
|
-
async function signGuestTransfer(apiBaseUrl, transferId, guestSessionToken, originTxHash) {
|
|
735
|
-
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
736
|
-
method: "PATCH",
|
|
737
|
-
headers: {
|
|
738
|
-
"Content-Type": "application/json",
|
|
739
|
-
"x-guest-session-token": guestSessionToken
|
|
740
|
-
},
|
|
741
|
-
body: JSON.stringify({ originTxHash })
|
|
742
|
-
});
|
|
743
|
-
if (!res.ok) await throwApiError(res);
|
|
744
|
-
return await res.json();
|
|
745
|
-
}
|
|
746
|
-
async function getGuestTransfer(apiBaseUrl, transferId, guestSessionToken) {
|
|
747
|
-
const res = await fetch(`${apiBaseUrl}/v1/transfers/${transferId}`, {
|
|
748
|
-
headers: {
|
|
749
|
-
"x-guest-session-token": guestSessionToken
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
if (!res.ok) await throwApiError(res);
|
|
753
|
-
return await res.json();
|
|
754
|
-
}
|
|
755
|
-
async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionToken, walletAddress) {
|
|
756
|
-
const params = new URLSearchParams({ walletAddress });
|
|
757
|
-
const res = await fetch(
|
|
758
|
-
`${apiBaseUrl}/v1/transfers/${transferId}/balances?${params.toString()}`,
|
|
759
|
-
{
|
|
760
|
-
headers: {
|
|
761
|
-
"x-guest-session-token": guestSessionToken
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
);
|
|
765
|
-
if (!res.ok) await throwApiError(res);
|
|
766
|
-
const data = await res.json();
|
|
767
|
-
return data.items;
|
|
768
|
-
}
|
|
769
|
-
async function fetchGuestPreauthAccount(apiBaseUrl, guestToken) {
|
|
770
|
-
const params = new URLSearchParams({ guestToken });
|
|
771
|
-
const res = await fetch(`${apiBaseUrl}/v1/guest-preauth?${params.toString()}`);
|
|
772
|
-
if (res.status === 404) return null;
|
|
773
|
-
if (!res.ok) await throwApiError(res);
|
|
774
|
-
return await res.json();
|
|
775
|
-
}
|
|
776
|
-
async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
|
|
777
|
-
const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
|
|
778
|
-
method: "PUT",
|
|
779
|
-
headers: {
|
|
780
|
-
"Content-Type": "application/json",
|
|
781
|
-
"Authorization": `Bearer ${accessToken}`,
|
|
782
|
-
"x-guest-session-token": guestSessionToken
|
|
783
|
-
},
|
|
784
|
-
body: JSON.stringify(body)
|
|
785
|
-
});
|
|
786
|
-
if (!res.ok) await throwApiError(res);
|
|
787
|
-
return await res.json();
|
|
788
|
-
}
|
|
789
|
-
async function reportActionCompletion(apiBaseUrl, actionId, result) {
|
|
790
|
-
const res = await fetch(
|
|
791
|
-
`${apiBaseUrl}/v1/authorization-actions/${actionId}`,
|
|
792
|
-
{
|
|
793
|
-
method: "PATCH",
|
|
794
|
-
headers: { "Content-Type": "application/json" },
|
|
795
|
-
body: JSON.stringify({ status: "COMPLETED", result })
|
|
796
|
-
}
|
|
797
|
-
);
|
|
798
|
-
if (!res.ok) await throwApiError(res);
|
|
799
|
-
return await res.json();
|
|
800
813
|
}
|
|
801
814
|
|
|
802
815
|
// src/passkeyRpId.ts
|
|
@@ -2210,7 +2223,8 @@ function paymentReducer(state, action) {
|
|
|
2210
2223
|
...state,
|
|
2211
2224
|
guestPreauthAccountId: null,
|
|
2212
2225
|
activePublicKey: null,
|
|
2213
|
-
error: null
|
|
2226
|
+
error: null,
|
|
2227
|
+
userIntent: "configure-one-tap"
|
|
2214
2228
|
};
|
|
2215
2229
|
// ── User intent & error ──────────────────────────────────────
|
|
2216
2230
|
case "SET_USER_INTENT":
|
|
@@ -8242,9 +8256,9 @@ function usePaymentEffects(deps) {
|
|
|
8242
8256
|
if (state.guestPreauthAccountId) return;
|
|
8243
8257
|
if (!state.transfer || state.transfer.status !== "COMPLETED") return;
|
|
8244
8258
|
let cancelled = false;
|
|
8245
|
-
const
|
|
8259
|
+
const checkGuestAccount = async () => {
|
|
8246
8260
|
try {
|
|
8247
|
-
const result = await
|
|
8261
|
+
const result = await fetchGuestAccount(apiBaseUrl, state.guestSessionToken);
|
|
8248
8262
|
if (cancelled) return;
|
|
8249
8263
|
if (result && !result.hasPasskey) {
|
|
8250
8264
|
dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: result.accountId });
|
|
@@ -8252,7 +8266,7 @@ function usePaymentEffects(deps) {
|
|
|
8252
8266
|
} catch {
|
|
8253
8267
|
}
|
|
8254
8268
|
};
|
|
8255
|
-
|
|
8269
|
+
checkGuestAccount();
|
|
8256
8270
|
return () => {
|
|
8257
8271
|
cancelled = true;
|
|
8258
8272
|
};
|
|
@@ -8548,7 +8562,29 @@ function BlinkPaymentInner({
|
|
|
8548
8562
|
onAuthorizeToken: provider.handleAuthorizeToken,
|
|
8549
8563
|
onSelectGuestToken: guestTransfer.handleSelectGuestToken,
|
|
8550
8564
|
onLogin: () => dispatch({ type: "REQUEST_LOGIN" }),
|
|
8551
|
-
onPreauthorize: () =>
|
|
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
|
+
}
|
|
8552
8588
|
}), [
|
|
8553
8589
|
auth,
|
|
8554
8590
|
passkey,
|
|
@@ -8559,7 +8595,12 @@ function BlinkPaymentInner({
|
|
|
8559
8595
|
oneTapSetup,
|
|
8560
8596
|
guestTransfer,
|
|
8561
8597
|
handleLogout,
|
|
8562
|
-
handleNewPayment
|
|
8598
|
+
handleNewPayment,
|
|
8599
|
+
state.guestPreauthAccountId,
|
|
8600
|
+
state.guestSessionToken,
|
|
8601
|
+
state.selectedProviderId,
|
|
8602
|
+
state.providers,
|
|
8603
|
+
apiBaseUrl
|
|
8563
8604
|
]);
|
|
8564
8605
|
return /* @__PURE__ */ jsx(
|
|
8565
8606
|
StepRenderer,
|