diff --git a/src/components/Accounts/AccountPermissionsSuccess.tsx b/src/components/Accounts/AccountPermissionsSuccess.tsx
index d88e4e3..9b1cd1f 100644
--- a/src/components/Accounts/AccountPermissionsSuccess.tsx
+++ b/src/components/Accounts/AccountPermissionsSuccess.tsx
@@ -31,7 +31,7 @@ export const AccountPermissionsSuccess: React.FC = () => {
driver's license and insurance card until you revoke access.
-
+
{!isEmbed() && (
diff --git a/src/hooks/useFinishShareAccounts.tsx b/src/hooks/useFinishShareAccounts.tsx
index fa06f2e..5bd0e18 100644
--- a/src/hooks/useFinishShareAccounts.tsx
+++ b/src/hooks/useFinishShareAccounts.tsx
@@ -1,23 +1,20 @@
-import { useDevCredentials } from '../context/DevCredentialsContext';
-import { AccountManagerMandatoryParams } from '../types';
import { useUIManager } from '../context/UIManagerContext';
import { useSendAuthPayloadToParent } from './useSendAuthPayloadToParent';
import { UiStates } from '../enums';
-import { backToThirdParty } from '../utils/messageHandler';
-// Account-sharing analogue of useFinishShareVehicles: surfaces accountGranted +
-// transactionHash to the parent, then advances to the success screen (popup) or
-// redirects back to the third party (redirect mode, no transactionHash).
+// Account-sharing analogue of useFinishShareVehicles: surfaces accountGranted to
+// the parent, then shows the success screen. AccountPermissionsSuccess owns the
+// "Back to " return action (and embedders navigate themselves), so we must
+// NOT call backToThirdParty here — doing so closed the popup before the success
+// screen was ever shown.
export const useFinishShareAccounts = () => {
- const { redirectUri, utm } = useDevCredentials();
const { setUiState, setComponentData } = useUIManager();
const sendAuthPayloadToParent = useSendAuthPayloadToParent();
- return (transactionHash?: string) => {
- sendAuthPayloadToParent({ accountGranted: true, transactionHash }, (authPayload) => {
+ return () => {
+ sendAuthPayloadToParent({ accountGranted: true }, () => {
setComponentData({ action: 'account-shared' });
setUiState(UiStates.ACCOUNT_PERMISSIONS_SUCCESS);
- if (!transactionHash) backToThirdParty(authPayload, redirectUri, utm);
});
};
};
diff --git a/src/services/turnkeyService.ts b/src/services/turnkeyService.ts
index 38306ba..a8e2714 100644
--- a/src/services/turnkeyService.ts
+++ b/src/services/turnkeyService.ts
@@ -196,14 +196,18 @@ export const generateIpfsSources = async (
};
// Account-level SACD source: grants document cloudevents on the user's account
-// DID (did:ethr:137:), not on a vehicle. Mirrors generateIpfsSources but
-// carries the driver-document agreements and the correct account asset DID.
+// DID (did:ethr::), not on a vehicle. Mirrors generateIpfsSources
+// but carries the driver-document agreements and the correct account asset DID.
export const generateAccountIpfsSource = async (
permissions: Permission[],
clientId: `0x${string}` | null,
expiration: BigInt,
): Promise => {
const grantor = kernelSigner.smartContractAddress!;
+ // Use the signer's actual chain (polygon=137 in prod, polygonAmoy=80002 in dev)
+ // so the asset DID matches the chain the grant is executed on — hardcoding 137
+ // orphaned the grant on non-prod environments.
+ const chainId = kernelSigner.chain.id;
const ipfsRes = await withTimeout(
kernelSigner.signAndUploadSACDAgreement({
expiration,
@@ -211,7 +215,7 @@ export const generateAccountIpfsSource = async (
grantee: clientId as `0x${string}`,
attachments: [],
grantor,
- asset: `did:ethr:137:${grantor}`,
+ asset: `did:ethr:${chainId}:${grantor}`,
cloudEventAgreements: buildDriverDocAgreements(grantor),
}),
KERNEL_OP_TIMEOUT_MS,