Skip to content

Commit

Permalink
fix: buildSignaturesFromSingerSignaturePairs doesn't work with compin…
Browse files Browse the repository at this point in the history
…ation of webauthn and ecdsa signature
  • Loading branch information
sherifahmed990 committed Dec 9, 2024
1 parent 1f93753 commit 8807648
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions src/account/Safe/SafeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1705,20 +1705,10 @@ export class SafeAccount extends SmartAccount {
({ segments, offset }, { signer, signature, isContractSignature }) => {
isContractSignature = isContractSignature || typeof signer != "string";
if (isContractSignature) {
if (typeof signer == "string") {
//ECDSAPublicAddress
return {
segments: [
...segments,
ethers.solidityPacked(
["uint256", "uint256", "uint8"],
[signer, start + offset, 0],
),
],
offset: offset + 32 + ethers.dataLength(signature),
};
} else {
//WebauthnPublicKey
if (typeof signer != "string") { //webauthn signature
//check if this is a webAuthn signature to replace
//the signer address with the shared signer address
//if init
if (webAuthnSignatureOverrides.isInit == null) {
throw RangeError(
"Must define isInit parameter when using WebAuthn",
Expand Down Expand Up @@ -1754,36 +1744,43 @@ export class SafeAccount extends SmartAccount {
},
);
}
return {
segments: [
...segments,
ethers.solidityPacked(
["uint256", "uint256", "uint8"],
[signer, start + offset, 0],
),
],
offset: offset + 32 + ethers.dataLength(signature),
};
}
}
return {
segments: [
...segments,
ethers.solidityPacked(
["uint256", "uint256", "uint8"],
[signer, start + offset, 0],
),
],
offset: offset + 32 + ethers.dataLength(signature),
};
} else {
return {
segments: [
...segments,
ethers.solidityPacked(["bytes"], [signature]),
],
offset: 0,
offset: offset,
};
}
},
{ segments: [] as string[], offset: 0 },
);
return ethers.concat([
...segments,
...signerSignaturePairs.map(({ signature }) =>
ethers.solidityPacked(
["uint256", "bytes"],
[ethers.dataLength(signature), signature],
),
...signerSignaturePairs.map(({ signer, signature, isContractSignature }) => {
isContractSignature = isContractSignature || typeof signer != "string";
if (isContractSignature) {
return ethers.solidityPacked(
["uint256", "bytes"],
[ethers.dataLength(signature), signature],
)
}else{
//only append signatures if a contract signature
return "0x";
}
},
),
]);
}
Expand Down

0 comments on commit 8807648

Please sign in to comment.