From c3a947913b1be79f1b0507fb22e3ed7e4c56c863 Mon Sep 17 00:00:00 2001 From: Dmytro Vynnyk Date: Mon, 9 Dec 2024 23:18:33 +0100 Subject: [PATCH] Return not prefixed signature from sdk event response --- src/libs/services/deployer-service/index.ts | 2 +- src/libs/services/ledger/ledger.ts | 14 ++++++++------ src/libs/services/ledger/types.ts | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libs/services/deployer-service/index.ts b/src/libs/services/deployer-service/index.ts index c97b42706..e2619c493 100644 --- a/src/libs/services/deployer-service/index.ts +++ b/src/libs/services/deployer-service/index.ts @@ -239,7 +239,7 @@ export const signLedgerDeploy = async ( const approval = new DeployUtil.Approval(); approval.signer = activeAccount.publicKey; - approval.signature = resp.signatureHex; + approval.signature = resp.prefixedSignatureHex; deploy.approvals.push(approval); return deploy; diff --git a/src/libs/services/ledger/ledger.ts b/src/libs/services/ledger/ledger.ts index da3c9e5c5..0b6646e5a 100644 --- a/src/libs/services/ledger/ledger.ts +++ b/src/libs/services/ledger/ledger.ts @@ -302,18 +302,18 @@ export class Ledger { ? result.signatureRSV.subarray(0, 64) : result.signatureRSV; - const signatureHex = `02${patchedSignature.toString('hex')}`; + const prefixedSignatureHex = `02${patchedSignature.toString('hex')}`; this.#LedgerEventStatussSubject.next({ status: LedgerEventStatus.SignatureCompleted, publicKey: account.publicKey, deployHash, - signatureHex + signatureHex: prefixedSignatureHex }); const prefix = new Uint8Array([0x02]); - if (!signatureHex) { + if (!prefixedSignatureHex) { this.#processError({ status: LedgerEventStatus.SignatureFailed, publicKey: account.publicKey, @@ -323,8 +323,10 @@ export class Ledger { } return { - signatureHex, - signature: new Uint8Array([...prefix, ...patchedSignature]) + signatureHex: patchedSignature.toString('hex'), + signature: patchedSignature, + prefixedSignatureHex, + prefixedSignature: new Uint8Array([...prefix, ...patchedSignature]) }; } catch (e) { if (e instanceof LedgerError) { @@ -342,7 +344,7 @@ export class Ledger { async signMessage( message: string, account: Partial - ): Promise { + ): Promise> { try { if (account.index === undefined) { this.#processError({ status: LedgerEventStatus.InvalidIndex }); diff --git a/src/libs/services/ledger/types.ts b/src/libs/services/ledger/types.ts index 83ea3a913..ae484bf8e 100644 --- a/src/libs/services/ledger/types.ts +++ b/src/libs/services/ledger/types.ts @@ -49,6 +49,8 @@ export interface LedgerAccountsOptions { export interface SignResult { signatureHex: string; signature: Uint8Array; + prefixedSignatureHex: string; + prefixedSignature: Uint8Array; } export type LedgerTransport = 'USB' | 'Bluetooth';