@volr/react 0.1.79 → 0.1.81
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 +49 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +49 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -737,6 +737,7 @@ declare function defaultIdempotencyKey(): string;
|
|
|
737
737
|
type NetworkInfo = {
|
|
738
738
|
name: string;
|
|
739
739
|
rpcUrl?: string;
|
|
740
|
+
invokerAddress?: string;
|
|
740
741
|
};
|
|
741
742
|
type CreateGetNetworkInfoDeps = {
|
|
742
743
|
client: APIClient;
|
|
@@ -744,7 +745,7 @@ type CreateGetNetworkInfoDeps = {
|
|
|
744
745
|
};
|
|
745
746
|
/**
|
|
746
747
|
* Factory to create a getNetworkInfo resolver bound to provided deps.
|
|
747
|
-
* Returns chain name and optionally RPC URL.
|
|
748
|
+
* Returns chain name and optionally RPC URL and invokerAddress.
|
|
748
749
|
* Priority: 1) rpcOverrides (for RPC URL) 2) Backend API (cached)
|
|
749
750
|
*/
|
|
750
751
|
declare function createGetNetworkInfo(deps: CreateGetNetworkInfoDeps): (chainId: number, includeRpcUrl?: boolean) => Promise<NetworkInfo>;
|
package/dist/index.d.ts
CHANGED
|
@@ -737,6 +737,7 @@ declare function defaultIdempotencyKey(): string;
|
|
|
737
737
|
type NetworkInfo = {
|
|
738
738
|
name: string;
|
|
739
739
|
rpcUrl?: string;
|
|
740
|
+
invokerAddress?: string;
|
|
740
741
|
};
|
|
741
742
|
type CreateGetNetworkInfoDeps = {
|
|
742
743
|
client: APIClient;
|
|
@@ -744,7 +745,7 @@ type CreateGetNetworkInfoDeps = {
|
|
|
744
745
|
};
|
|
745
746
|
/**
|
|
746
747
|
* Factory to create a getNetworkInfo resolver bound to provided deps.
|
|
747
|
-
* Returns chain name and optionally RPC URL.
|
|
748
|
+
* Returns chain name and optionally RPC URL and invokerAddress.
|
|
748
749
|
* Priority: 1) rpcOverrides (for RPC URL) 2) Backend API (cached)
|
|
749
750
|
*/
|
|
750
751
|
declare function createGetNetworkInfo(deps: CreateGetNetworkInfoDeps): (chainId: number, includeRpcUrl?: boolean) => Promise<NetworkInfo>;
|
package/dist/index.js
CHANGED
|
@@ -9783,7 +9783,6 @@ function useAutoRecover({
|
|
|
9783
9783
|
return;
|
|
9784
9784
|
}
|
|
9785
9785
|
const refreshedUser = await client.refreshSession();
|
|
9786
|
-
console.log("[Provider] Session refreshed, user:", refreshedUser);
|
|
9787
9786
|
setAccessTokenState(client.getAccessToken());
|
|
9788
9787
|
setRefreshTokenState(client.getRefreshToken());
|
|
9789
9788
|
if (refreshedUser) {
|
|
@@ -9836,7 +9835,6 @@ function useWalletEvents({
|
|
|
9836
9835
|
}
|
|
9837
9836
|
const ethereum = window.ethereum;
|
|
9838
9837
|
const handleAccountsChanged = (accounts) => {
|
|
9839
|
-
console.log("[Provider] accountsChanged event:", accounts);
|
|
9840
9838
|
if (accounts.length === 0) {
|
|
9841
9839
|
console.warn("[Provider] Wallet disconnected, logging out...");
|
|
9842
9840
|
setTimeout(() => logout(), 3e3);
|
|
@@ -10009,17 +10007,25 @@ function VolrProvider({ config, children }) {
|
|
|
10009
10007
|
setError(null);
|
|
10010
10008
|
const keyStorageType = newProvider.keyStorageType;
|
|
10011
10009
|
setProviderState(newProvider);
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
setUser(
|
|
10017
|
-
}
|
|
10010
|
+
const userHasCompleteData = user?.keyStorageType === "passkey" && user?.blobUrl && user?.prfInput && user?.id;
|
|
10011
|
+
if (userHasCompleteData) {
|
|
10012
|
+
console.log("[Provider] setProvider: User data already complete, skipping refresh");
|
|
10013
|
+
if (user.keyStorageType !== keyStorageType) {
|
|
10014
|
+
setUser((prev) => ({ ...prev, keyStorageType }));
|
|
10015
|
+
}
|
|
10016
|
+
} else {
|
|
10017
|
+
try {
|
|
10018
|
+
const refreshedUser = await client.refreshSession();
|
|
10019
|
+
if (refreshedUser) {
|
|
10020
|
+
console.log("[Provider] setProvider: User data refreshed:", refreshedUser);
|
|
10021
|
+
setUser(refreshedUser);
|
|
10022
|
+
} else {
|
|
10023
|
+
setUser((prev) => ({ ...prev, keyStorageType }));
|
|
10024
|
+
}
|
|
10025
|
+
} catch (error2) {
|
|
10026
|
+
console.warn("[Provider] setProvider: Failed to refresh user data:", error2);
|
|
10018
10027
|
setUser((prev) => ({ ...prev, keyStorageType }));
|
|
10019
10028
|
}
|
|
10020
|
-
} catch (error2) {
|
|
10021
|
-
console.warn("[Provider] setProvider: Failed to refresh user data:", error2);
|
|
10022
|
-
setUser((prev) => ({ ...prev, keyStorageType }));
|
|
10023
10029
|
}
|
|
10024
10030
|
safeStorage.setItem(STORAGE_KEYS.provider, keyStorageType);
|
|
10025
10031
|
syncRef.current?.broadcast({
|
|
@@ -10270,30 +10276,34 @@ function useRelay() {
|
|
|
10270
10276
|
if (input.chainId === 0) {
|
|
10271
10277
|
throw new Error("chainId cannot be 0");
|
|
10272
10278
|
}
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10279
|
+
let invokerAddress = opts.invokerAddress;
|
|
10280
|
+
if (!invokerAddress) {
|
|
10281
|
+
const networkData = await client.get(
|
|
10282
|
+
`/networks/${input.chainId}`
|
|
10283
|
+
);
|
|
10284
|
+
invokerAddress = networkData.invokerAddress;
|
|
10285
|
+
}
|
|
10277
10286
|
if (!invokerAddress) {
|
|
10278
10287
|
throw new Error(
|
|
10279
10288
|
`Invoker address not configured for chainId ${input.chainId}`
|
|
10280
10289
|
);
|
|
10281
10290
|
}
|
|
10282
|
-
const { sessionSig } = await signSession({
|
|
10283
|
-
signer: opts.signer,
|
|
10284
|
-
from: input.from,
|
|
10285
|
-
auth: input.auth,
|
|
10286
|
-
calls: input.calls,
|
|
10287
|
-
invokerAddress: input.from
|
|
10288
|
-
});
|
|
10289
10291
|
if (!opts.rpcClient) {
|
|
10290
10292
|
throw new Error("rpcClient is required for relay");
|
|
10291
10293
|
}
|
|
10292
|
-
const authNonce = await
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10294
|
+
const [sessionResult, authNonce] = await Promise.all([
|
|
10295
|
+
// Sign session (EIP-7702: User EOA becomes the verifyingContract)
|
|
10296
|
+
signSession({
|
|
10297
|
+
signer: opts.signer,
|
|
10298
|
+
from: input.from,
|
|
10299
|
+
auth: input.auth,
|
|
10300
|
+
calls: input.calls,
|
|
10301
|
+
invokerAddress: input.from
|
|
10302
|
+
}),
|
|
10303
|
+
// Get auth nonce (sponsored mode)
|
|
10304
|
+
getAuthNonce(opts.rpcClient, input.from, "sponsored")
|
|
10305
|
+
]);
|
|
10306
|
+
const { sessionSig } = sessionResult;
|
|
10297
10307
|
const authorizationTuple = await signAuthorization({
|
|
10298
10308
|
signer: opts.signer,
|
|
10299
10309
|
chainId: input.chainId,
|
|
@@ -18044,6 +18054,7 @@ function createGetRpcUrl(deps) {
|
|
|
18044
18054
|
networkCache.set(chainId, {
|
|
18045
18055
|
rpcUrl: response.rpcUrl,
|
|
18046
18056
|
name: response.name,
|
|
18057
|
+
invokerAddress: response.invokerAddress,
|
|
18047
18058
|
timestamp: Date.now()
|
|
18048
18059
|
});
|
|
18049
18060
|
console.log("[getRpcUrl] RPC URL fetched and cached");
|
|
@@ -18057,18 +18068,21 @@ function createGetNetworkInfo(deps) {
|
|
|
18057
18068
|
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
18058
18069
|
return {
|
|
18059
18070
|
name: cached.name || `Chain ${chainId}`,
|
|
18060
|
-
rpcUrl: includeRpcUrl ? cached.rpcUrl : void 0
|
|
18071
|
+
rpcUrl: includeRpcUrl ? cached.rpcUrl : void 0,
|
|
18072
|
+
invokerAddress: cached.invokerAddress
|
|
18061
18073
|
};
|
|
18062
18074
|
}
|
|
18063
18075
|
const response = await client.get(`/networks/${chainId}${includeRpcUrl ? "?includeRpcUrl=true" : ""}`);
|
|
18064
18076
|
networkCache.set(chainId, {
|
|
18065
18077
|
name: response.name,
|
|
18066
18078
|
rpcUrl: response.rpcUrl,
|
|
18079
|
+
invokerAddress: response.invokerAddress,
|
|
18067
18080
|
timestamp: Date.now()
|
|
18068
18081
|
});
|
|
18069
18082
|
return {
|
|
18070
18083
|
name: response.name,
|
|
18071
|
-
rpcUrl: includeRpcUrl ? response.rpcUrl : void 0
|
|
18084
|
+
rpcUrl: includeRpcUrl ? response.rpcUrl : void 0,
|
|
18085
|
+
invokerAddress: response.invokerAddress
|
|
18072
18086
|
};
|
|
18073
18087
|
};
|
|
18074
18088
|
}
|
|
@@ -18413,7 +18427,12 @@ async function sendCalls(args) {
|
|
|
18413
18427
|
activeProvider = resolved.activeProvider;
|
|
18414
18428
|
const result = await deps.relay(
|
|
18415
18429
|
{ chainId, from: normalizedFrom, auth, calls: normalizedCalls },
|
|
18416
|
-
{
|
|
18430
|
+
{
|
|
18431
|
+
signer,
|
|
18432
|
+
rpcClient: deps.rpcClient,
|
|
18433
|
+
idempotencyKey,
|
|
18434
|
+
invokerAddress: precheckQuote.invokerAddress
|
|
18435
|
+
}
|
|
18417
18436
|
);
|
|
18418
18437
|
if (result.status === "QUEUED" || result.status === "PENDING") {
|
|
18419
18438
|
return pollTransactionStatus(result.txId, deps.client);
|