From a35736949bf2e4dc817afb8825f7556a3d126d97 Mon Sep 17 00:00:00 2001 From: Vynnyk Dmytro Date: Mon, 9 Dec 2024 23:57:50 +0100 Subject: [PATCH] Wallet 453 (#1106) * Return not prefixed signature from sdk event response * Increase min payment amount --- src/constants.ts | 6 +++--- src/libs/services/deployer-service/index.ts | 2 +- src/libs/services/ledger/ledger.ts | 14 ++++++++------ src/libs/services/ledger/types.ts | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 2582d689d..50c635ae2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -14,9 +14,9 @@ export const ERROR_DISPLAYED_BEFORE_ATTEMPT_IS_DECREMENTED = 1; export const MOTES_PER_CSPR_RATE = '1000000000'; // 1 000 000 000 MOTES === 1 CSPR export const TRANSFER_COST_MOTES = '100000000'; // 0.1 CSPR export const TRANSFER_MIN_AMOUNT_MOTES = '2500000000'; // 2.5 CSPR -export const ERC20_PAYMENT_AMOUNT_AVERAGE_MOTES = '1500000000'; // 1.5 CSPR -export const NFT_CEP47_PAYMENT_AMOUNT_AVERAGE_MOTES = '1000000000'; // 1 CSPR -export const NFT_CEP78_PAYMENT_AMOUNT_AVERAGE_MOTES = '3000000000'; // 3 CSPR +export const ERC20_PAYMENT_AMOUNT_AVERAGE_MOTES = '3000000000'; // 3 CSPR +export const NFT_CEP47_PAYMENT_AMOUNT_AVERAGE_MOTES = '2000000000'; // 2 CSPR +export const NFT_CEP78_PAYMENT_AMOUNT_AVERAGE_MOTES = '9000000000'; // 9 CSPR export const STAKE_COST_MOTES = '2500000000'; // 2.5 CSPR export const DELEGATION_MIN_AMOUNT_MOTES = '500000000000'; // 500 CSPR export const MAX_DELEGATORS = 1200; 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';