Skip to content
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
1 change: 1 addition & 0 deletions src/modules/quotes/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum MeeSignatureType {
ERC20_PERMIT = "0x177eee02",
MM_DTK = "0x177eee03",
SAFE_SA = "0x177eee04",
OFF_CHAIN_P256 = "0x177eee10",
}

export const MEE_SIGNATURE_TYPE_OFFSET = 4;
Expand Down
65 changes: 32 additions & 33 deletions src/modules/quotes/quotes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,10 @@ export class QuotesService {
let quoteType: QuoteType;
// Detect quote type
if (!options.quoteType) {
if (signatureType === MeeSignatureType.OFF_CHAIN) {
if (
signatureType === MeeSignatureType.OFF_CHAIN ||
signatureType === MeeSignatureType.OFF_CHAIN_P256
) {
quoteType = "simple";
} else if (signatureType === MeeSignatureType.ON_CHAIN) {
quoteType = "onchain";
Expand Down Expand Up @@ -758,15 +761,13 @@ export class QuotesService {
TRUSTED_GAS_TANK_ADDRESS.toLowerCase()) ||
false;

const merkleTree = await withTrace(
"exec.createMerkleTree",
async () =>
await this.merkleTreeService.createMerkleTree(
packedMeeUserOps,
quoteType === "simple",
isEIP712SupportedMeeVersion,
isTrustedSponsorship,
),
const merkleTree = await withTrace("exec.createMerkleTree", async () =>
this.merkleTreeService.createMerkleTree(
packedMeeUserOps,
quoteType === "simple",
isEIP712SupportedMeeVersion,
isTrustedSponsorship,
),
)();

if (merkleTree.root !== hash) {
Expand Down Expand Up @@ -794,14 +795,14 @@ export class QuotesService {

let transaction: GetTransactionReturnType;

switch (signatureType) {
case MeeSignatureType.OFF_CHAIN:
case MeeSignatureType.ERC20_PERMIT:
case MeeSignatureType.MM_DTK:
case MeeSignatureType.SAFE_SA:
switch (quoteType) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote type is not provided by all the SDKs. Some old SDKs still don't send this and it might be a breaking change.

Let's revert back to the same approach

Copy link
Copy Markdown
Author

@filmakarov filmakarov Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's this code block
Screenshot 2026-02-23 at 19 20 08

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sure quote type is always defined.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the screenshot

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's no need to revert to the same approach
This code is much cleaner. Previous approach was confusing => quote type and sig type were mixed together , while they mean pretty miuch same

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reshare the pic, I see quoteType is optional in schema definition.

Sig type is good for backwards compatibility.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, all good. Yup I added this code block earlier for backwards compatibility.

I will merge this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoteType is optional in schema definition.

it is optional. but in the code it is always defined!

if (!options.quoteType) {
      if (signatureType === MeeSignatureType.OFF_CHAIN) {
      if (
        signatureType === MeeSignatureType.OFF_CHAIN ||
        signatureType === MeeSignatureType.OFF_CHAIN_P256
      ) {
        quoteType = "simple";
      } else if (signatureType === MeeSignatureType.ON_CHAIN) {
        quoteType = "onchain";
      } else if (signatureType === MeeSignatureType.ERC20_PERMIT) {
        quoteType = "permit";
      } else if (signatureType === MeeSignatureType.MM_DTK) {
        quoteType = "mm-dtk";
      } else if (signatureType === MeeSignatureType.SAFE_SA) {
        quoteType = "safe-sa";
      } else {
        throw new BadRequestException(
          `Unsupported signature type for quote type detection ${signatureType}`,
        );
      }
    } else {
      quoteType = options.quoteType;
    }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, initially its optional and its optional in quote phase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quote type is also better because two sig types (and more in future) can be still same quote type

case "simple":
case "permit":
case "mm-dtk":
case "safe-sa":
break;

case MeeSignatureType.ON_CHAIN: {
case "onchain": {
const [hash, chainId] = decodeAbiParameters(
[
{ type: "bytes32" }, //
Expand Down Expand Up @@ -848,9 +849,7 @@ export class QuotesService {
}

default: {
throw new BadRequestException(
`Unsupported signature type (${signatureType})`,
);
throw new BadRequestException(`Unsupported quote type (${quoteType})`);
}
}

Expand Down Expand Up @@ -890,8 +889,8 @@ export class QuotesService {

let signature: Hex;

switch (signatureType) {
case MeeSignatureType.OFF_CHAIN: {
switch (quoteType) {
case "simple": {
if (isSessionExists) {
if (isEIP712SupportedMeeVersion) {
signature = concatHex([
Expand Down Expand Up @@ -993,7 +992,7 @@ export class QuotesService {
break;
}

case MeeSignatureType.ON_CHAIN: {
case "onchain": {
const { r, s, v, ...tx } = transaction;
const serializableTx = { ...tx, data: tx.input, input: undefined };

Expand All @@ -1009,7 +1008,7 @@ export class QuotesService {
break;
}

case MeeSignatureType.ERC20_PERMIT: {
case "permit": {
if (isStxValidatorSupportedMeeVersion) {
// Stx validator permit signature decoding and re-packing
// owner is added as an extra parameter to the signature data
Expand Down Expand Up @@ -1163,7 +1162,7 @@ export class QuotesService {
break;
}

case MeeSignatureType.MM_DTK: {
case "mm-dtk": {
const delegateManagerAbi = {
name: "delegationManager",
type: "address",
Expand Down Expand Up @@ -1241,7 +1240,7 @@ export class QuotesService {
break;
}

case MeeSignatureType.SAFE_SA: {
case "safe-sa": {
// SafeTxnData struct definition from stx-contracts
const safeTxnDataAbi = {
name: "safeTxnData",
Expand Down Expand Up @@ -1313,7 +1312,7 @@ export class QuotesService {

default: {
throw new BadRequestException(
`Unsupported signature type (${signatureType})`,
`Unsupported quote type (${quoteType})`,
);
}
}
Expand Down Expand Up @@ -1425,7 +1424,7 @@ export class QuotesService {
return await this.entryPointService.simulateHandleOps(
paymentMeeUserOp,
{
retries: signatureType === MeeSignatureType.ON_CHAIN ? 20 : 0,
retries: quoteType === "onchain" ? 20 : 0,
useStorage: false,
},
);
Expand All @@ -1443,24 +1442,24 @@ export class QuotesService {
);

if (sigFailed) {
switch (signatureType) {
case MeeSignatureType.OFF_CHAIN:
switch (quoteType) {
case "simple":
throw new BadRequestException(
"Failed to verify your supertransaction signature. Please check your signature.",
);
case MeeSignatureType.ERC20_PERMIT:
case "permit":
throw new BadRequestException(
"Failed to verify your supertransaction signature. Please check your permit signature and permit token compatibility.",
);
case MeeSignatureType.ON_CHAIN:
case "onchain":
throw new BadRequestException(
"Failed to verify your supertransaction signature. Please check your onchain transaction signature.",
);
case MeeSignatureType.MM_DTK:
case "mm-dtk":
throw new BadRequestException(
"Failed to verify your supertransaction signature. Please check your metamask delegator signature.",
);
case MeeSignatureType.SAFE_SA:
case "safe-sa":
throw new BadRequestException(
"Failed to verify your supertransaction signature. Please check your Safe smart account signature.",
);
Expand Down
Loading