From 9f9ad7ab674ace1889a8e539aa5f815aa85a7595 Mon Sep 17 00:00:00 2001
From: zer0stars <74260741+zer0stars@users.noreply.github.com>
Date: Mon, 15 Jun 2026 15:54:32 -0400
Subject: [PATCH] fix(account): derive asset DID chain from signer; show
success screen instead of auto-closing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- generateAccountIpfsSource: use kernelSigner.chain.id (polygon 137 / amoy 80002)
for the account asset DID instead of hardcoding 137 — the hardcode orphaned the
grant on non-prod environments.
- useFinishShareAccounts: stop calling backToThirdParty on finish. transactionHash
was always undefined so it always fired, closing the popup before the
AccountPermissionsSuccess screen (which owns the 'Back to ' button) was ever
shown. Now mirrors the vehicle flow: show the success screen, let it own return.
- Fix 'fex-col' -> 'flex-col' typo in the now-visible success screen.
---
.../Accounts/AccountPermissionsSuccess.tsx | 2 +-
src/hooks/useFinishShareAccounts.tsx | 17 +++++++----------
src/services/turnkeyService.ts | 10 +++++++---
3 files changed, 15 insertions(+), 14 deletions(-)
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,