Skip to content

Commit

Permalink
fix(alchemy-signer): fix the sign tx method to return the full tx
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed May 21, 2024
1 parent 7673fc5 commit 7c30cd3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/alchemy/src/signer/signer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SmartAccountAuthenticator } from "@alchemy/aa-core";
import { takeBytes, type SmartAccountAuthenticator } from "@alchemy/aa-core";
import {
hashMessage,
hashTypedData,
Expand Down Expand Up @@ -215,11 +215,20 @@ export class AlchemySigner
return this.inner.signRawMessage(messageHash);
};

signTransaction: CustomSource["signTransaction"] = (tx, args) => {
signTransaction: CustomSource["signTransaction"] = async (tx, args) => {
const serializeFn = args?.serializer ?? serializeTransaction;
const serializedTx = serializeFn(tx);
const signatureHex = await this.inner.signRawMessage(
keccak256(serializedTx)
);

const signature = {
r: takeBytes(signatureHex, { count: 32 }),
s: takeBytes(signatureHex, { count: 32, offset: 32 }),
v: BigInt(takeBytes(signatureHex, { count: 1, offset: 64 })),
};

return this.inner.signRawMessage(keccak256(serializedTx));
return serializeFn(tx, signature);
};

/**
Expand Down

0 comments on commit 7c30cd3

Please sign in to comment.