Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet 453 #1106

Merged
merged 2 commits into from
Dec 9, 2024
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
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
Loading