Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Accounts/AccountPermissionsSuccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const AccountPermissionsSuccess: React.FC = () => {
driver's license and insurance card until you revoke access.
</p>
</div>
<div className="flex fex-col">
<div className="flex flex-col">
{!isEmbed() && (
<div className="flex justify-center w-full">
<PrimaryButton onClick={handleBackToThirdParty} width="sm:w-64 w-full">
Expand Down
17 changes: 7 additions & 10 deletions src/hooks/useFinishShareAccounts.tsx
Original file line number Diff line number Diff line change
@@ -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 <app>" 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<AccountManagerMandatoryParams>();
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);
});
};
};
10 changes: 7 additions & 3 deletions src/services/turnkeyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,26 @@ export const generateIpfsSources = async (
};

// Account-level SACD source: grants document cloudevents on the user's account
// DID (did:ethr:137:<grantor>), not on a vehicle. Mirrors generateIpfsSources but
// carries the driver-document agreements and the correct account asset DID.
// DID (did:ethr:<chainId>:<grantor>), 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<string> => {
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,
permissions,
grantee: clientId as `0x${string}`,
attachments: [],
grantor,
asset: `did:ethr:137:${grantor}`,
asset: `did:ethr:${chainId}:${grantor}`,
cloudEventAgreements: buildDriverDocAgreements(grantor),
}),
KERNEL_OP_TIMEOUT_MS,
Expand Down