From e82d256427dd2886a128b0b38057d984f25c95ed Mon Sep 17 00:00:00 2001 From: Sahil Vasava Date: Fri, 3 Apr 2026 15:29:54 -0300 Subject: [PATCH] feat: encrypt bundle transactions for seismic chain using seismic-encrypt Uses encryptSeismicTx to encrypt handleOps calldata before submission when running against seismic testnet (chainId 5124). The encrypted tx is signed with a custom serializer and sent via sendRawTransaction. --- pnpm-lock.yaml | 15 ++++++++++ src/executor/executor.ts | 65 +++++++++++++++++++++++++++++++++++++++- src/package.json | 3 +- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 59e01b4b..cf9c0268 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,6 +152,9 @@ importers: prom-client: specifier: ^14.2.0 version: 14.2.0 + seismic-encrypt: + specifier: ^0.1.1 + version: 0.1.1(viem@2.27.0(typescript@5.3.3)(zod@3.22.4)) type-fest: specifier: ^4.35.0 version: 4.39.1 @@ -3529,6 +3532,11 @@ packages: secure-json-parse@2.7.0: resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} + seismic-encrypt@0.1.1: + resolution: {integrity: sha512-/Fj9TiPjQu/t844PKlYLvbEbYloW2IXREB7idUSVtmHDRPYQhPes5mpLfYa9pn4DG42cGl1xfvI/rLMsMy/Bfw==} + peerDependencies: + viem: 2.x + semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -7809,6 +7817,13 @@ snapshots: secure-json-parse@2.7.0: {} + seismic-encrypt@0.1.1(viem@2.27.0(typescript@5.3.3)(zod@3.22.4)): + dependencies: + '@noble/ciphers': 1.3.0 + '@noble/curves': 1.9.1 + '@noble/hashes': 1.8.0 + viem: 2.27.0(typescript@5.3.3)(zod@3.22.4) + semver@5.7.2: {} semver@6.3.1: {} diff --git a/src/executor/executor.ts b/src/executor/executor.ts index 0ae2d495..3ef2fe40 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -16,6 +16,7 @@ import { scaleBigIntByPercent } from "@alto/utils" import * as sentry from "@sentry/node" +import { encryptSeismicTx } from "seismic-encrypt" import { type Account, BaseError, @@ -90,6 +91,57 @@ export class Executor { this.eventManager = eventManager } + async sendSeismicTransaction({ + request, + account, + childLogger + }: { + request: { + to: Address + data: Hex + nonce: number + gas: bigint + gasPrice?: bigint + maxFeePerGas?: bigint + } + account: Account + childLogger: Logger + }): Promise { + const { publicClient, rpcUrl, chainId } = this.config + + const gasPrice = + request.gasPrice ?? request.maxFeePerGas ?? 0n + + childLogger.debug("encrypting transaction for seismic chain") + + const { seismicTx, serialize } = await encryptSeismicTx({ + tx: { + to: request.to, + data: request.data, + nonce: request.nonce, + gasPrice, + gas: request.gas, + chainId + }, + sender: account.address, + rpcUrl + }) + + const signed = await account.signTransaction!( + { ...seismicTx } as any, + { + serializer: (_tx: any, sig: any) => + serialize(sig!) + } + ) + + childLogger.debug("sending encrypted seismic transaction") + + return publicClient.sendRawTransaction({ + serializedTransaction: signed + }) + } + getBundleGasPrice({ bundle, networkGasPrice, @@ -247,7 +299,18 @@ export class Executor { multiple: this.config.gasLimitRoundingMultiple }) - transactionHash = await walletClient.sendTransaction(request) + // Seismic testnet chain id is 5124 + if (this.config.chainId === 5124) { + transactionHash = + await this.sendSeismicTransaction({ + request, + account, + childLogger + }) + } else { + transactionHash = + await walletClient.sendTransaction(request) + } childLogger.info( { diff --git a/src/package.json b/src/package.json index b929136f..3deedcd5 100644 --- a/src/package.json +++ b/src/package.json @@ -48,6 +48,7 @@ "@opentelemetry/sdk-node": "^0.52.1", "@opentelemetry/sdk-trace-base": "^1.25.1", "@opentelemetry/semantic-conventions": "^1.25.1", + "@pimlico/opentelemetry-instrumentation-viem": "^0.0.4", "@sentry/node": "^8.51.0", "@types/node": "^18.16.3", "@types/ws": "^8.5.10", @@ -62,8 +63,8 @@ "pino": "^9.6.0", "pino-http": "^10.4.0", "pino-pretty": "^13.0.0", - "@pimlico/opentelemetry-instrumentation-viem": "^0.0.4", "prom-client": "^14.2.0", + "seismic-encrypt": "^0.1.1", "type-fest": "^4.35.0", "viem": "^2.24.3", "yargs": "^17.7.1",