Skip to content

Commit

Permalink
Wallet 453 (#1106)
Browse files Browse the repository at this point in the history
* Return not prefixed signature from sdk event response

* Increase min payment amount
  • Loading branch information
Comp0te authored Dec 9, 2024
1 parent cdc5091 commit a357369
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/services/deployer-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions src/libs/services/ledger/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -342,7 +344,7 @@ export class Ledger {
async signMessage(
message: string,
account: Partial<LedgerAccount>
): Promise<SignResult> {
): Promise<Pick<SignResult, 'signature' | 'signatureHex'>> {
try {
if (account.index === undefined) {
this.#processError({ status: LedgerEventStatus.InvalidIndex });
Expand Down
2 changes: 2 additions & 0 deletions src/libs/services/ledger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export interface LedgerAccountsOptions {
export interface SignResult {
signatureHex: string;
signature: Uint8Array;
prefixedSignatureHex: string;
prefixedSignature: Uint8Array;
}

export type LedgerTransport = 'USB' | 'Bluetooth';
Expand Down

0 comments on commit a357369

Please sign in to comment.