Skip to content
Draft
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
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 64 additions & 1 deletion src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
scaleBigIntByPercent
} from "@alto/utils"
import * as sentry from "@sentry/node"
import { encryptSeismicTx } from "seismic-encrypt"
import {
type Account,
BaseError,
Expand Down Expand Up @@ -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<Hex> {
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,
Expand Down Expand Up @@ -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(
{
Expand Down
3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Loading