|
7 | 7 | TransactionPrecondition, |
8 | 8 | ETHTxnStatus, |
9 | 9 | } from './relayer.gen.js' |
10 | | -import { Address, Hex, Bytes, AbiFunction } from 'ox' |
| 10 | +import { Address, Hex } from 'ox' |
11 | 11 | import { Constants, Payload, Network } from '@0xsequence/wallet-primitives' |
12 | 12 | import { FeeOption, FeeQuote, OperationStatus, Relayer } from '../index.js' |
13 | 13 | import { decodePrecondition } from '../../preconditions/index.js' |
@@ -137,23 +137,21 @@ export class RpcRelayer implements Relayer { |
137 | 137 | to: Address.Address, |
138 | 138 | calls: Payload.Call[], |
139 | 139 | ): 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. |
144 | 144 | const callsStruct: Payload.Calls = { type: 'call', space: 0n, nonce: 0n, calls: calls } |
145 | 145 |
|
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) |
150 | 148 |
|
151 | 149 | try { |
152 | 150 | const result = await this.client.feeOptions( |
153 | 151 | { |
154 | 152 | wallet, |
155 | | - to, |
156 | | - data, |
| 153 | + to: feeOptionsTo, |
| 154 | + data: Hex.fromBytes(data), |
157 | 155 | }, |
158 | 156 | { ...(this.projectAccessKey ? { 'X-Access-Key': this.projectAccessKey } : undefined) }, |
159 | 157 | ) |
|
0 commit comments