Skip to content

Commit d0a3b51

Browse files
authored
🐛 (signer-eth) [DSDK-913]: Don't fail clear signing if a sub context cannot be provided (#1074)
2 parents b42aed1 + 024ec7e commit d0a3b51

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

.changeset/famous-donkeys-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ledgerhq/device-signer-kit-ethereum": patch
3+
---
4+
5+
Don't fail clear signing if a sub context cannot be provided

packages/signer/signer-eth/src/internal/app-binder/task/ProvideContextsTask.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,49 @@ describe("ProvideContextsTask", () => {
589589
expect.any(ProvideTokenInformationCommand),
590590
);
591591
});
592+
593+
it("should provide the transaction context even after a subcontext failure", async () => {
594+
// GIVEN
595+
const args: ProvideContextsTaskArgs = {
596+
contexts: [
597+
{
598+
context: {
599+
type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,
600+
payload: "payload",
601+
},
602+
subcontextCallbacks: [
603+
() =>
604+
Promise.resolve({
605+
type: ClearSignContextType.TOKEN,
606+
payload: "payload",
607+
}),
608+
],
609+
},
610+
],
611+
serializedTransaction: new Uint8Array(),
612+
derivationPath: "44'/60'/0'/0/0",
613+
};
614+
sendPayloadInChunksRunMock.mockResolvedValue(successResult);
615+
api.sendCommand.mockResolvedValue(errorResult);
616+
617+
// WHEN
618+
const task = new ProvideContextsTask(
619+
api,
620+
args,
621+
sendPayloadInChunksTaskMockFactory,
622+
sendCommandInChunksTaskMockFactory,
623+
);
624+
const result = await task.run();
625+
626+
// THEN
627+
expect(result).toEqual(Right(void 0));
628+
expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);
629+
expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {
630+
payload: "payload",
631+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
632+
commandFactory: expect.any(Function),
633+
});
634+
});
592635
});
593636

594637
describe("with subcontexts and certificate", () => {

packages/signer/signer-eth/src/internal/app-binder/task/ProvideContextsTask.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ export class ProvideContextsTask {
9494
continue;
9595
}
9696

97-
const res = await this.provideContext(subcontext);
98-
if (!isSuccessCommandResult(res)) {
99-
return Left(res);
100-
}
97+
// Don't fail immediately on subcontext errors because the main context may still be successful
98+
await this.provideContext(subcontext);
10199
}
102100

103101
if (context.type === ClearSignContextType.PROXY_INFO) {

0 commit comments

Comments
 (0)