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
4 changes: 4 additions & 0 deletions packages/claims-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added `updatedAt` field to the claims draft. ([#7523](https://github.com/MetaMask/core/pull/7523))

## [0.3.0]

### Added
Expand Down
8 changes: 7 additions & 1 deletion packages/claims-controller/src/ClaimsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ describe('ClaimsController', () => {
impactedTxHash: '0x123',
reimbursementWalletAddress: '0x456',
description: 'test description',
updatedAt: '2025-12-17T06:10:32.213Z',
};
const MOCK_CLAIM_DRAFTS: ClaimDraft[] = [
{
Expand All @@ -275,6 +276,7 @@ describe('ClaimsController', () => {
impactedTxHash: '0x123',
reimbursementWalletAddress: '0x456',
description: 'test description',
updatedAt: '2025-12-17T06:10:32.213Z',
},
{
draftId: 'mock-draft-2',
Expand All @@ -284,6 +286,7 @@ describe('ClaimsController', () => {
impactedTxHash: '0x789',
reimbursementWalletAddress: '0x012',
description: 'test description 2',
updatedAt: '2025-12-17T06:10:32.213Z',
},
];

Expand All @@ -295,7 +298,10 @@ describe('ClaimsController', () => {
expect(updatedState).not.toBe(initialState);
expect(updatedState.drafts).toHaveLength(1);
expect(updatedState.drafts[0].draftId).toBeDefined();
expect(updatedState.drafts[0]).toMatchObject(MOCK_DRAFT);
expect(updatedState.drafts[0]).toMatchObject({
...MOCK_DRAFT,
updatedAt: expect.any(String),
});
expect(updatedState.drafts[0].draftId).toBeDefined();
});
});
Expand Down
10 changes: 8 additions & 2 deletions packages/claims-controller/src/ClaimsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,19 @@ export class ClaimsController extends BaseController<
);

if (isExistingDraft) {
const updatedAt = new Date().toISOString();
this.update((state) => {
state.drafts = state.drafts.map((existingDraft) =>
existingDraft.draftId === draft.draftId
? { ...existingDraft, ...draft }
? {
...existingDraft,
...draft,
updatedAt,
}
: existingDraft,
);
});
return draft as ClaimDraft;
return { ...draft, updatedAt } as ClaimDraft;
}

// generate a new draft id, name and add it to the state
Expand All @@ -248,6 +253,7 @@ export class ClaimsController extends BaseController<
const newDraft: ClaimDraft = {
...draft,
draftId,
updatedAt: new Date().toISOString(),
};

this.update((state) => {
Expand Down
8 changes: 1 addition & 7 deletions packages/claims-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ export type Claim = {
export type ClaimDraft = Partial<
Omit<
Claim,
| 'id'
| 'shortId'
| 'createdAt'
| 'updatedAt'
| 'intercomId'
| 'status'
| 'attachments'
'id' | 'shortId' | 'createdAt' | 'intercomId' | 'status' | 'attachments'
>
> & {
/**
Expand Down
Loading