Skip to content

Commit 12100c5

Browse files
authored
fix(relayer): match wallet-webapp FeeOptions request shape (#966)
* fix(relayer): wrap feeOptions calldata for simulation * fix(relayer): request FeeOptions as wallet (match wallet-webapp-v3) * fix(relayer): restore AbiFunction import
1 parent a4db649 commit 12100c5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • packages/services/relayer/src/relayer/rpc-relayer

packages/services/relayer/src/relayer/rpc-relayer/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TransactionPrecondition,
88
ETHTxnStatus,
99
} from './relayer.gen.js'
10-
import { Address, Hex, Bytes, AbiFunction } from 'ox'
10+
import { Address, Hex, AbiFunction } from 'ox'
1111
import { Constants, Payload, Network } from '@0xsequence/wallet-primitives'
1212
import { FeeOption, FeeQuote, OperationStatus, Relayer } from '../index.js'
1313
import { decodePrecondition } from '../../preconditions/index.js'
@@ -137,15 +137,21 @@ export class RpcRelayer implements Relayer {
137137
to: Address.Address,
138138
calls: Payload.Call[],
139139
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
140+
// IMPORTANT:
141+
// The relayer FeeOptions endpoint simulates `eth_call(to, data)`.
142+
// wallet-webapp-v3 requests FeeOptions with `to = wallet` and `data = Payload.encode(calls, self=wallet)`.
143+
// This works for undeployed wallets and avoids guest-module simulation pitfalls.
140144
const callsStruct: Payload.Calls = { type: 'call', space: 0n, nonce: 0n, calls: calls }
141-
const data = Payload.encode(callsStruct)
145+
146+
const feeOptionsTo = wallet
147+
const data = Payload.encode(callsStruct, wallet)
142148

143149
try {
144150
const result = await this.client.feeOptions(
145151
{
146152
wallet,
147-
to,
148-
data: Bytes.toHex(data),
153+
to: feeOptionsTo,
154+
data: Hex.fromBytes(data),
149155
},
150156
{ ...(this.projectAccessKey ? { 'X-Access-Key': this.projectAccessKey } : undefined) },
151157
)

0 commit comments

Comments
 (0)