Skip to content

Commit

Permalink
fix: sign txn result param
Browse files Browse the repository at this point in the history
  • Loading branch information
vrockz747 committed Nov 29, 2024
1 parent 78db231 commit 67b0867
Show file tree
Hide file tree
Showing 5 changed files with 4,695 additions and 6,490 deletions.
15 changes: 4 additions & 11 deletions packages/app-starknet/src/operations/signTxn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ISDK } from '@cypherock/sdk-core';
import {
createStatusListener,
assert,
hexToUint8Array,
uint8ArrayToHex,
createLoggerWithPrefix,
} from '@cypherock/sdk-utils';
Expand All @@ -13,7 +12,6 @@ import {
} from '../../proto/generated/types';
import {
assertOrThrowInvalidResult,
getStarknetApiJs,
OperationHelper,
logger as rootLogger,
} from '../../utils';
Expand Down Expand Up @@ -64,11 +62,8 @@ export const signTxn = async (
assertOrThrowInvalidResult(confirmResponse.confirmation);
forceStatusUpdate(SignTxnEvent.CONFIRM);

const txnBytes = hexToUint8Array(params.txn);
await helper.sendQuery({
txn: {
txn: txnBytes,
},
txn: params.txn,
});

const accepted = await helper.waitForResult();
Expand All @@ -83,12 +78,10 @@ export const signTxn = async (

forceStatusUpdate(SignTxnEvent.PIN_CARD);

const key = uint8ArrayToHex(result.signature.signature);
const starknet = getStarknetApiJs();
const signature = starknet.ec.starkCurve.sign(params.txn, key.slice(0, 64));
const signature = uint8ArrayToHex(result.signature.signature);

return {
signature: signature.toCompactHex(),
serializedTxn: signature.toCompactHex(),
signature,
serializedTxn: signature,
};
};
4 changes: 3 additions & 1 deletion packages/app-starknet/src/operations/signTxn/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ISignTxnUnsignedTxn } from '../../proto/generated/types';

export enum SignTxnEvent {
INIT = 0,
CONFIRM = 1,
Expand All @@ -13,7 +15,7 @@ export interface ISignTxnParams {

walletId: Uint8Array;
derivationPath: number[];
txn: string;
txn: ISignTxnUnsignedTxn;
}

export interface ISignTxnResult {
Expand Down
Loading

0 comments on commit 67b0867

Please sign in to comment.