Skip to content

Commit 3eabc06

Browse files
committed
fix(relayer): request FeeOptions as wallet (match wallet-webapp-v3)
1 parent 2e0d110 commit 3eabc06

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

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

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

Lines changed: 9 additions & 11 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 } 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,23 +137,21 @@ export class RpcRelayer implements Relayer {
137137
to: Address.Address,
138138
calls: Payload.Call[],
139139
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
140-
// NOTE: The relayer backend simulates a call to `to` with calldata `data`.
141-
// For undeployed wallets, `to` may be the guest module, so `data` must be valid
142-
// calldata for the guest module (i.e. execute(payload, stubSig)), not the raw
143-
// v3 payload bytes.
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.
144144
const callsStruct: Payload.Calls = { type: 'call', space: 0n, nonce: 0n, calls: calls }
145145

146-
const execute = AbiFunction.from('function execute(bytes calldata _payload, bytes calldata _signature)')
147-
const payload = Payload.encode(callsStruct, to)
148-
const stubSignature = '0x0001'
149-
const data = AbiFunction.encodeData(execute, [Bytes.toHex(payload), stubSignature])
146+
const feeOptionsTo = wallet
147+
const data = Payload.encode(callsStruct, wallet)
150148

151149
try {
152150
const result = await this.client.feeOptions(
153151
{
154152
wallet,
155-
to,
156-
data,
153+
to: feeOptionsTo,
154+
data: Hex.fromBytes(data),
157155
},
158156
{ ...(this.projectAccessKey ? { 'X-Access-Key': this.projectAccessKey } : undefined) },
159157
)

0 commit comments

Comments
 (0)