Skip to content

Sponsored EOA Transactions (native AA on zksync chains) #827

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

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

d4mr
Copy link
Member

@d4mr d4mr commented Jan 9, 2025

closes TOOL-3001


PR-Codex overview

This PR focuses on updating the thirdweb dependency and enhancing transaction handling by introducing a new x-transaction-mode header to manage transaction modes more effectively, particularly for sponsored transactions.

Detailed summary

  • Updated thirdweb version from 5.80.1-nightly to 5.83.0.
  • Added transactionMode property in types.ts for transaction handling.
  • Introduced x-transaction-mode header across multiple routes to specify transaction mode.
  • Updated relevant functions to include transactionMode in their parameters.
  • Added validation and handling for sponsored transaction mode in various services.
  • Improved documentation for transaction mode in service methods and parameters.

The following files were skipped due to too many changes: sdk/src/services/MarketplaceDirectListingsService.ts, sdk/src/services/DeployService.ts, sdk/src/services/Erc20Service.ts, sdk/src/services/Erc721Service.ts, sdk/src/services/Erc1155Service.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

linear bot commented Jan 9, 2025

Copy link

zeet-co bot commented Jan 9, 2025

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://thirdweb-engine-ad8x-pb-sponsored-51ddfe.engine-aws-usw2.zeet.app before merging 😉

@@ -167,6 +167,7 @@ export class AccountFactoryService {
* @param requestBody
* @param simulateTx Simulates the transaction before adding it to the queue, returning an error if it fails simulation. Note: This step is less performant and recommended only for debugging purposes.
* @param xIdempotencyKey Transactions submitted with the same idempotency key will be de-duplicated. Only the last 100000 transactions are compared.
* @param xTransactionMode Transaction mode to use for EOA transactions. Will be ignored if using a smart wallet. If omitted, defaults to regular EOA transactions.
Copy link
Member

Choose a reason for hiding this comment

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

Was thinking it could also be used to turn sponsoring on/off for smart wallets. Fine for now though

@@ -1652,6 +1687,7 @@ export class Erc20Service {
headers: {
'x-backend-wallet-address': xBackendWalletAddress,
'x-idempotency-key': xIdempotencyKey,
'x-transaction-mode': xTransactionMode,
'x-account-address': xAccountAddress,
Copy link
Member

Choose a reason for hiding this comment

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

Mam so much repetition to add a header. Feels like it should be centralized

Copy link
Member Author

Choose a reason for hiding this comment

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

Fully agreed. My hono + zod refactor fixes a bunch of these issues

Type.Union(
[
Type.Literal("sponsored", {
description: "Attmpt to use native AA on ZKSync chains",
Copy link
Member

Choose a reason for hiding this comment

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

Typo in Attempt

import { hashTypedData } from "viem";
import { getChain } from "../../../shared/utils/chain"; // Adjust import path as needed

type SendTransactionResult = {
transactionHash: Hex;
};

type SendTransactionOption = TransactionSerializable & {
type SerializableTransaction = Awaited<
Copy link
Member

Choose a reason for hiding this comment

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

Don't we already have this type exported in the SDK?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exported, hance the struggle 😅

Copy link
Member

Choose a reason for hiding this comment

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

Just export it! Put up a PR we can get it out today

chainId,
from,
});

if (transaction.transactionMode === "sponsored") {
if (!isZkSyncChain(chain)) {
Copy link
Member

Choose a reason for hiding this comment

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

Here we could let it through if using a smart backend wallet for example

Signed-off-by: Prithvish Baidya <deformercoding@gmail.com>
@d4mr d4mr merged commit 9e2270d into main Jan 9, 2025
5 checks passed
@d4mr d4mr deleted the pb/sponsored-eoa-transactions branch January 9, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants